Package adams.flow.setup
Class FlowSetupManager
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractList<E>
-
- java.util.Vector<FlowSetup>
-
- adams.flow.setup.FlowSetupManager
-
- All Implemented Interfaces:
CloneHandler<FlowSetupManager>,FlowSetupStateListener,Serializable,Cloneable,Iterable<FlowSetup>,Collection<FlowSetup>,List<FlowSetup>,RandomAccess
public class FlowSetupManager extends Vector<FlowSetup> implements FlowSetupStateListener, CloneHandler<FlowSetupManager>
Manages several setups.- Version:
- $Revision$
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static StringCOUNTthe key for the number of stored setups.protected HashSet<ChangeListener>m_ChangeListenersthe change listeners.protected booleanm_Modifiedwhether manager got modified.protected StatusMessageHandlerm_StatusMessageHandlerthe handler to use for displaying messages.static StringPLACEHOLDER_PREFIXthe key prefix for a placeholder.static StringSETUP_PREFIXthe key prefix for a setup.-
Fields inherited from class java.util.Vector
capacityIncrement, elementCount, elementData
-
Fields inherited from class java.util.AbstractList
modCount
-
-
Constructor Summary
Constructors Constructor Description FlowSetupManager()Initializes the setup manager.FlowSetupManager(Collection<FlowSetup> collection)Initializes the setup manager.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(int index, FlowSetup element)Adds the setup at the specified location.booleanadd(FlowSetup e)Adds a setup.booleanaddAll(int index, Collection<? extends FlowSetup> c)Adds all elements of the collection at the specified location.booleanaddAll(Collection<? extends FlowSetup> c)Adds all the setups from the collection.voidaddChangeListener(ChangeListener l)Adds the listener to the internal list.voidaddElement(FlowSetup obj)Adds the specified setup.voidclear()Removes all setups.voidflowSetupStateChanged(FlowSetupStateEvent e)Gets called when the state of the flow setup changed.FlowSetupManagergetClone()Returns a clone of itself, with the setups being shallow copies.StatusMessageHandlergetStatusMessageHandler()Returns the current handler for status messages.intindexOf(String name)Returns the index of the flowsetup with the given name.voidinsertElementAt(FlowSetup obj, int index)Inserts the setup at the specified location.booleanisModified()Returns whether the manager was modified.protected voidmodified()Sets the modified state to TRUE and notifies all change listeners.protected voidmodified(boolean modified)Sets the modified state and notifies all change listeners.protected voidnotifyChangeListeners(ChangeEvent e)Sends the event to all change listeners.booleanread(String filename)Reads and returns the setups from the given file.FlowSetupremove(int index)Removes the specified setup.booleanremove(Object o)Removes the specified object.booleanremoveAll(Collection<?> c)Removes all setups of the specified collection.voidremoveAllElements()Removes all setups.voidremoveChangeListener(ChangeListener l)Removes the listener from the internal list.booleanremoveElement(Object obj)Removes the specified setup.voidremoveElementAt(int index)Removes the setup at the specified location.protected voidremoveRange(int fromIndex, int toIndex)Removes a range of setups.booleanretainAll(Collection<?> c)Retains only setups that are in the specified collection.FlowSetupset(int index, FlowSetup element)Sets the setup at the specified location.voidsetElementAt(FlowSetup obj, int index)Sets the setup at the specified location.voidsetModified(boolean value)Sets the modified state of the manager.voidsetSize(int newSize)Resizes the collection: if new size is larger, then null objects are added, otherwise the setups at the end discarded.voidsetStatusMessageHandler(StatusMessageHandler value)Sets the handler for status messages.booleanwrite(String filename)Writes the setups to the given file.-
Methods inherited from class java.util.Vector
capacity, clone, contains, containsAll, copyInto, elementAt, elements, ensureCapacity, equals, firstElement, forEach, get, hashCode, indexOf, indexOf, isEmpty, iterator, lastElement, lastIndexOf, lastIndexOf, listIterator, listIterator, removeIf, replaceAll, size, sort, spliterator, subList, toArray, toArray, toString, trimToSize
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Collection
parallelStream, stream, toArray
-
-
-
-
Field Detail
-
COUNT
public static final String COUNT
the key for the number of stored setups.- See Also:
- Constant Field Values
-
SETUP_PREFIX
public static final String SETUP_PREFIX
the key prefix for a setup.- See Also:
- Constant Field Values
-
PLACEHOLDER_PREFIX
public static final String PLACEHOLDER_PREFIX
the key prefix for a placeholder.- See Also:
- Constant Field Values
-
m_Modified
protected boolean m_Modified
whether manager got modified.
-
m_ChangeListeners
protected HashSet<ChangeListener> m_ChangeListeners
the change listeners.
-
m_StatusMessageHandler
protected StatusMessageHandler m_StatusMessageHandler
the handler to use for displaying messages.
-
-
Constructor Detail
-
FlowSetupManager
public FlowSetupManager()
Initializes the setup manager.
-
FlowSetupManager
public FlowSetupManager(Collection<FlowSetup> collection)
Initializes the setup manager.- Parameters:
collection- the collection to initialize with
-
-
Method Detail
-
setStatusMessageHandler
public void setStatusMessageHandler(StatusMessageHandler value)
Sets the handler for status messages.- Parameters:
value- the handler
-
getStatusMessageHandler
public StatusMessageHandler getStatusMessageHandler()
Returns the current handler for status messages.- Returns:
- the handler, null if none set
-
isModified
public boolean isModified()
Returns whether the manager was modified.- Returns:
- true if modified
-
setModified
public void setModified(boolean value)
Sets the modified state of the manager.- Parameters:
value- the modified state
-
modified
protected void modified()
Sets the modified state to TRUE and notifies all change listeners.
-
modified
protected void modified(boolean modified)
Sets the modified state and notifies all change listeners.- Parameters:
modified- the modified state
-
add
public boolean add(FlowSetup e)
Adds a setup.
-
addAll
public boolean addAll(Collection<? extends FlowSetup> c)
Adds all the setups from the collection.
-
addElement
public void addElement(FlowSetup obj)
Adds the specified setup.- Overrides:
addElementin classVector<FlowSetup>- Parameters:
obj- the setup to add
-
add
public void add(int index, FlowSetup element)Adds the setup at the specified location.
-
addAll
public boolean addAll(int index, Collection<? extends FlowSetup> c)Adds all elements of the collection at the specified location.
-
clear
public void clear()
Removes all setups.
-
getClone
public FlowSetupManager getClone()
Returns a clone of itself, with the setups being shallow copies.- Specified by:
getClonein interfaceCloneHandler<FlowSetupManager>- Returns:
- the clone
-
insertElementAt
public void insertElementAt(FlowSetup obj, int index)
Inserts the setup at the specified location.- Overrides:
insertElementAtin classVector<FlowSetup>- Parameters:
obj- the setup to insertindex- the position
-
remove
public FlowSetup remove(int index)
Removes the specified setup.
-
removeAll
public boolean removeAll(Collection<?> c)
Removes all setups of the specified collection.
-
remove
public boolean remove(Object o)
Removes the specified object.
-
removeAllElements
public void removeAllElements()
Removes all setups.- Overrides:
removeAllElementsin classVector<FlowSetup>
-
removeElement
public boolean removeElement(Object obj)
Removes the specified setup.- Overrides:
removeElementin classVector<FlowSetup>- Parameters:
obj- the setup to remove- Returns:
- true if removed successfully
-
removeElementAt
public void removeElementAt(int index)
Removes the setup at the specified location.- Overrides:
removeElementAtin classVector<FlowSetup>- Parameters:
index- the position of the setup to remove
-
removeRange
protected void removeRange(int fromIndex, int toIndex)Removes a range of setups.- Overrides:
removeRangein classVector<FlowSetup>- Parameters:
fromIndex- starting index (incl)toIndex- ending index (excl)
-
retainAll
public boolean retainAll(Collection<?> c)
Retains only setups that are in the specified collection.
-
setElementAt
public void setElementAt(FlowSetup obj, int index)
Sets the setup at the specified location.- Overrides:
setElementAtin classVector<FlowSetup>- Parameters:
obj- the setup to setindex- the position to place the setup
-
setSize
public void setSize(int newSize)
Resizes the collection: if new size is larger, then null objects are added, otherwise the setups at the end discarded.
-
write
public boolean write(String filename)
Writes the setups to the given file.- Parameters:
filename- the file to write to- Returns:
- true if successfully written
-
read
public boolean read(String filename)
Reads and returns the setups from the given file.- Parameters:
filename- the file to read from- Returns:
- true if successfully read
-
indexOf
public int indexOf(String name)
Returns the index of the flowsetup with the given name.- Parameters:
name- the name to look for- Returns:
- the index, -1 if not found
-
flowSetupStateChanged
public void flowSetupStateChanged(FlowSetupStateEvent e)
Gets called when the state of the flow setup changed.- Specified by:
flowSetupStateChangedin interfaceFlowSetupStateListener- Parameters:
e- the event
-
addChangeListener
public void addChangeListener(ChangeListener l)
Adds the listener to the internal list.- Parameters:
l- the listener to add
-
removeChangeListener
public void removeChangeListener(ChangeListener l)
Removes the listener from the internal list.- Parameters:
l- the listener to remove
-
notifyChangeListeners
protected void notifyChangeListeners(ChangeEvent e)
Sends the event to all change listeners.- Parameters:
e- the event to send
-
-