com.cometway.props
Class PropsList

java.lang.Object
  extended by com.cometway.props.PropsList

public class PropsList
extends java.lang.Object

This class represents a list of Props stored in memory. It can be extended to provide alternate storage layers, or used externally with associated Import and Export agents.


Field Summary
protected  boolean dirty
           
protected  FlushInterface flushHandler
           
protected  IPropsChangeListener propsChangeListener
           
protected  java.util.List propsList
           
protected  java.lang.Object[] synchObject
           
 
Constructor Summary
PropsList()
           
 
Method Summary
 void addProps(Props p)
          Adds the specified Props to this list.
 Props createProps()
          Creates a new Props and adds it to this list.
 void flush()
          Calls the FlushInterface implementation assigned to this object.
 Props getProps(java.lang.String key, java.lang.Object value)
          Returns the first matching Props in the list based on specified key and value.
 java.util.List listProps()
          Returns a List containing all of the Props contained by this List.
 java.util.List listProps(java.lang.String key, java.lang.Object value)
          Returns a List containing a subset of the Props contained by this list specified by a matching key and value.
 java.util.List listProps(java.lang.String key, java.lang.Object value, java.lang.String sortBy)
          Returns a List containing a subset of the Props contained by this list specified by a matching key and value.
 java.util.List listPropsMatchingRegEx(java.lang.String key, java.lang.String regex)
          Returns a List containing a subset of the Props contained by this list specified by a matching property containing a regular expression.
 java.util.List listPropsRegExMatching(java.lang.String key, java.lang.String str)
          Returns a List containing a subset of the Props contained by this list specified by a matching property containing a regular expression.
 boolean needsToSave()
          Returns true if any of the data managed by this list has been changed.
 boolean removeProps(Props p)
          If the list contains the specified Props it is removed and true is return; otherwise it returns false.
 boolean removeProps(java.lang.String key, java.lang.Object value)
          Removes all Props from the list with matching key and value.
 void resetNeedsToSave()
          Resets the changed (dirty) state of this PropsList.
 void setFlushHandler(FlushInterface flushHandler)
          Sets the FlushInterface implementation called by this class when its flush() method is called.
protected  void setPropsChangeListener(IPropsChangeListener propsChangeListener)
          Sets the PropsChangeListener implementation called by Props added or created in this PropsList.
static java.util.List sortPropsList(java.util.List propsList, java.lang.String key)
          Static method for sorting a List containing Props alphabetically by the specified key.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

synchObject

protected final java.lang.Object[] synchObject

propsList

protected java.util.List propsList

dirty

protected boolean dirty

propsChangeListener

protected IPropsChangeListener propsChangeListener

flushHandler

protected FlushInterface flushHandler
Constructor Detail

PropsList

public PropsList()
Method Detail

addProps

public void addProps(Props p)
Adds the specified Props to this list. The current IPropsChangeListener is added to the Props.


createProps

public Props createProps()
Creates a new Props and adds it to this list. The current IPropsChangeListener is added to the Props.


flush

public void flush()
Calls the FlushInterface implementation assigned to this object. Use setFlushHandler() method to set the FlushInterface implementation. This method is usually called in response to a change in the contents of the PropsList so that the changes can be saved.


getProps

public Props getProps(java.lang.String key,
                      java.lang.Object value)
Returns the first matching Props in the list based on specified key and value.


listProps

public java.util.List listProps()
Returns a List containing all of the Props contained by this List. If the list is empty, a List with zero (0) elements is returned.


listProps

public java.util.List listProps(java.lang.String key,
                                java.lang.Object value)
Returns a List containing a subset of the Props contained by this list specified by a matching key and value. If no matching Props are found, a List with zero (0) elements is returned.


listProps

public java.util.List listProps(java.lang.String key,
                                java.lang.Object value,
                                java.lang.String sortBy)
Returns a List containing a subset of the Props contained by this list specified by a matching key and value. The result set is alphabetically sorted using the specified key (sortBy). If no matching Props are found, a List with zero (0) elements is returned.


listPropsRegExMatching

public java.util.List listPropsRegExMatching(java.lang.String key,
                                             java.lang.String str)
Returns a List containing a subset of the Props contained by this list specified by a matching property containing a regular expression. If no matching Props are found, a List with zero (0) elements is returned.


listPropsMatchingRegEx

public java.util.List listPropsMatchingRegEx(java.lang.String key,
                                             java.lang.String regex)
Returns a List containing a subset of the Props contained by this list specified by a matching property containing a regular expression. If no matching Props are found, a List with zero (0) elements is returned.


needsToSave

public boolean needsToSave()
Returns true if any of the data managed by this list has been changed.


resetNeedsToSave

public void resetNeedsToSave()
Resets the changed (dirty) state of this PropsList.


removeProps

public boolean removeProps(Props p)
If the list contains the specified Props it is removed and true is return; otherwise it returns false.


removeProps

public boolean removeProps(java.lang.String key,
                           java.lang.Object value)
Removes all Props from the list with matching key and value. Returns true if Props were found and deleted; false otherwise.


setFlushHandler

public void setFlushHandler(FlushInterface flushHandler)
Sets the FlushInterface implementation called by this class when its flush() method is called.


setPropsChangeListener

protected void setPropsChangeListener(IPropsChangeListener propsChangeListener)
Sets the PropsChangeListener implementation called by Props added or created in this PropsList.


sortPropsList

public static java.util.List sortPropsList(java.util.List propsList,
                                           java.lang.String key)
Static method for sorting a List containing Props alphabetically by the specified key.