ewe.data
Class PropertyList

java.lang.Object
  extended byewe.data.DataObject
      extended byewe.util.Vector
          extended byewe.data.PropertyList
All Implemented Interfaces:
Comparable, Copyable, DataUnit, HasProperties, Textable
Direct Known Subclasses:
FileChooserParameters, ImageCache, MultiListSelect, MultiListSelect.AvailableLists, PropertyList.NullPropertyList

public class PropertyList
extends Vector
implements HasProperties, Textable


Nested Class Summary
static class PropertyList.NullPropertyList
           
 
Field Summary
static PropertyList nullPropertyList
           
 
Constructor Summary
PropertyList()
           
PropertyList(Object[] nameAndValues)
           
 
Method Summary
 boolean _getSetField(String fieldName, Wrapper wrapper, boolean isGet)
          This is used for data transfer using a ewe.reflect.FieldTransfer object.
 boolean add(Object[] nameAndValues)
           
 boolean add(Property prop)
          Adds a non-exclusive property.
 boolean add(PropertyList prop)
           
 boolean add(String props, Object value)
          Adds a non-exclusive property.
 void defaultTo(String nameAndValues)
           
 boolean defaultTo(String name, Object value)
           
 void fromHashtable(Hashtable source)
          Put the values in the Hashtable into the PropertyList.
static PropertyList fromStrings(String s)
           
 Property get(String name)
          Get the property with the specified name.
 Property get(String name, Property previous)
          Get the property with the specified name, starting with the previous one.
static boolean getBoolean(Object propertyListOrStrings, String name, boolean defaultValue)
          This first converts the propertyListOrStrings parameters into a valid or empty PropertyList and then calls getBoolean(name,defaultValue) on that list.
 boolean getBoolean(String name, boolean def)
           
static double getDouble(Object propertyListOrStrings, String name, double defaultValue)
          This first converts the propertyListOrStrings parameters into a valid or empty PropertyList and then calls getDouble(name,defaultValue) on that list.
 double getDouble(String name, double def)
           
 void getField(String name, Wrapper wrapper)
           
static int getInt(Object propertyListOrStrings, String name, int defaultValue)
          This first converts the propertyListOrStrings parameters into a valid or empty PropertyList and then calls getInt(name,defaultValue) on that list.
 int getInt(String name, int def)
           
 String[] getNames()
           
 PropertyList getProperties()
          This returns itself.
static PropertyList getProperties(Object obj)
           
 Iterator getProperties(String prop)
          Return an Enumeration of all the properties with a given name.
 Vector getPropertyValues(String propertyName)
          Gather all the property values with a certain name into a Vector.
static boolean getSetProperties(Object obj, String fieldName, Wrapper wrapper, boolean isGet)
           
static String getString(Object propertyListOrStrings, String name, String defaultValue)
          This first converts the propertyListOrStrings parameters into a valid or empty PropertyList and then calls getString(name,defaultValue) on that list.
 String getString(String name, String deflt)
           
 String[] getStrings(String props, String defaultValue)
          Gets a set of properties, each associated with a string.
 String getText()
           
static Object getValue(Object propertyListOrStrings, String name, Object defaultValue)
          This first converts the propertyListOrStrings parameters into a valid or empty PropertyList and then calls getValue(name,defaultValue) on that list.
 Object getValue(String[] v, Object deflt)
          Gets the value of a property which may be named differently (e.g.
 Object getValue(String name, Object deflt)
          Gets the value of a property, with a default if it does not exist.
 Object getValue(Vector v, Object deflt)
          Gets the value of a property which may be named differently (e.g.
static PropertyList make(String from)
          This will create a new PropertyList and call setStrings() on it.
 void readConfigFile(StreamReader br)
           
 boolean remove(String props)
          Removes all properties with the name.
 boolean set(Property prop)
          Sets an exclusive property.
 boolean set(PropertyList pl)
           
 boolean set(String props, Object value)
          Sets an exclusive property.
 boolean setBoolean(String name, boolean value)
           
 void setField(String name, Wrapper wrapper)
           
 boolean setInt(String name, int value)
           
 boolean setStrings(String propsAndValues)
          Sets a set of properties, each associated with a string.
 void setText(String text)
           
 Hashtable toHashtable(Hashtable destination)
          Put the PropertyList values into a Hashtable.
static PropertyList toPropertyList(Object propertyListOrStrings)
          This will convert a set of properties encoded as Strings separated by '|' characters into a PropertyList OR it will return the PropertyList if the parameter implements HasProperties, OR it will return a nullPropertyList object
 
Methods inherited from class ewe.util.Vector
add, add, add, addAll, addAll, addAll, addCopiesFrom, addElement, clear, compare, contains, copyCopiesFrom, copyFrom, copyInto, copyInto, del, elementAt, elements, find, find, get, getCount, getFullCopy, insert, insertElementAt, isEmpty, iterator, iterator, pop, push, remove, removeAllElements, removeElementAt, set, setElementAt, setSize, size, sort, sort, toArray, toArray, toObjectArray, toString, zero
 
Methods inherited from class ewe.data.DataObject
appendAllFields, compareTo, copied, equals, getCopy, getDeclaredField, getDeclaredFieldValue, getDeclaredFieldValue, getFieldList, getFieldList, getMyFieldList, getNew
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode
 

Field Detail

nullPropertyList

public static final PropertyList nullPropertyList
Constructor Detail

PropertyList

public PropertyList(Object[] nameAndValues)

PropertyList

public PropertyList()
Method Detail

getProperties

public PropertyList getProperties()
This returns itself.

Specified by:
getProperties in interface HasProperties

add

public boolean add(Object[] nameAndValues)

defaultTo

public boolean defaultTo(String name,
                         Object value)

defaultTo

public void defaultTo(String nameAndValues)

setBoolean

public boolean setBoolean(String name,
                          boolean value)

setInt

public boolean setInt(String name,
                      int value)

getBoolean

public boolean getBoolean(String name,
                          boolean def)

getDouble

public double getDouble(String name,
                        double def)

getInt

public int getInt(String name,
                  int def)

get

public Property get(String name)
Get the property with the specified name.


get

public Property get(String name,
                    Property previous)
Get the property with the specified name, starting with the previous one.


getValue

public Object getValue(String name,
                       Object deflt)
Gets the value of a property, with a default if it does not exist.


getString

public String getString(String name,
                        String deflt)

getValue

public Object getValue(Vector v,
                       Object deflt)
Gets the value of a property which may be named differently (e.g. "color" and "colour").


getValue

public Object getValue(String[] v,
                       Object deflt)
Gets the value of a property which may be named differently (e.g. "color" and "colour").


set

public boolean set(Property prop)
Sets an exclusive property. i.e. only one property with that name can exist.


set

public boolean set(String props,
                   Object value)
Sets an exclusive property. i.e. only one property with that name can exist.


set

public boolean set(PropertyList pl)

setStrings

public boolean setStrings(String propsAndValues)
Sets a set of properties, each associated with a string. For example to set: "first"="hello" and "second"="there", call the method with the value: "first|hello|second|there".


getStrings

public String[] getStrings(String props,
                           String defaultValue)
Gets a set of properties, each associated with a string. For example to get: properties "first" and "second" call the method with the value: "first|second".


add

public boolean add(Property prop)
Adds a non-exclusive property. i.e. more than one property with that name can exist.


add

public boolean add(PropertyList prop)

add

public boolean add(String props,
                   Object value)
Adds a non-exclusive property. i.e. more than one property with that name can exist.


remove

public boolean remove(String props)
Removes all properties with the name.


getPropertyValues

public Vector getPropertyValues(String propertyName)
Gather all the property values with a certain name into a Vector.


getProperties

public Iterator getProperties(String prop)
Return an Enumeration of all the properties with a given name.


make

public static PropertyList make(String from)
This will create a new PropertyList and call setStrings() on it.

Parameters:
from - The encoded PropertyValues.
Returns:
a new PropertyList.
See Also:
setStrings()

getNames

public String[] getNames()

fromStrings

public static PropertyList fromStrings(String s)

getText

public String getText()
Specified by:
getText in interface Textable

setText

public void setText(String text)
Specified by:
setText in interface Textable

setField

public void setField(String name,
                     Wrapper wrapper)

getField

public void getField(String name,
                     Wrapper wrapper)

getProperties

public static PropertyList getProperties(Object obj)

getSetProperties

public static boolean getSetProperties(Object obj,
                                       String fieldName,
                                       Wrapper wrapper,
                                       boolean isGet)

_getSetField

public boolean _getSetField(String fieldName,
                            Wrapper wrapper,
                            boolean isGet)
Description copied from class: DataObject
This is used for data transfer using a ewe.reflect.FieldTransfer object. It is used if the programmer requests a field transfer but there is no such field in the object. In that case the _getSetField() method will be called and the programmer can programatically get/set the field data.

By default this method calls getProperties() and then calls the _getSetField() method in PropertyList.

Overrides:
_getSetField in class DataObject
Parameters:
fieldName - The name of the field.
wrapper - A wrapper containing the data to be assigned to the field or the wrapper into which you should place the field data.
isGet - if this is true then it is a get operation (in which case you should set the wrapper value to be the field value) if it is false it is a set operation and the wrapper contains the field value to assign to the field.
Returns:
the Object should return true if the field data was successfully transfered, false if not.

toPropertyList

public static PropertyList toPropertyList(Object propertyListOrStrings)
This will convert a set of properties encoded as Strings separated by '|' characters into a PropertyList OR it will return the PropertyList if the parameter implements HasProperties, OR it will return a nullPropertyList object

Parameters:
propertyListOrStrings - If this is a String it will be decoded using
Returns:
A new PropertyList or the nullPropertyList object if the specified cannot be converted to a PropertyList.

getValue

public static Object getValue(Object propertyListOrStrings,
                              String name,
                              Object defaultValue)
This first converts the propertyListOrStrings parameters into a valid or empty PropertyList and then calls getValue(name,defaultValue) on that list.

Parameters:
propertyListOrStrings -
name -
defaultValue -
Returns:

getInt

public static int getInt(Object propertyListOrStrings,
                         String name,
                         int defaultValue)
This first converts the propertyListOrStrings parameters into a valid or empty PropertyList and then calls getInt(name,defaultValue) on that list.


getDouble

public static double getDouble(Object propertyListOrStrings,
                               String name,
                               double defaultValue)
This first converts the propertyListOrStrings parameters into a valid or empty PropertyList and then calls getDouble(name,defaultValue) on that list.


getBoolean

public static boolean getBoolean(Object propertyListOrStrings,
                                 String name,
                                 boolean defaultValue)
This first converts the propertyListOrStrings parameters into a valid or empty PropertyList and then calls getBoolean(name,defaultValue) on that list.


getString

public static String getString(Object propertyListOrStrings,
                               String name,
                               String defaultValue)
This first converts the propertyListOrStrings parameters into a valid or empty PropertyList and then calls getString(name,defaultValue) on that list.


readConfigFile

public void readConfigFile(StreamReader br)

toHashtable

public Hashtable toHashtable(Hashtable destination)
Put the PropertyList values into a Hashtable.

Parameters:
destination - the destination Hashtable or null to return a new one.
Returns:
the destination Hashtable or a new one if destination was null.

fromHashtable

public void fromHashtable(Hashtable source)
Put the values in the Hashtable into the PropertyList.

Parameters:
source - the source Hashtable.