|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.cometway.props.Props
public class Props
The Props object keeps track of a set of properties. Similar to a hashtable but includes many useful utilities. Props allows listeners to be added so that other objects can be notified when properties in this Props object get changed. There are also methods that return specific types of objects instead of the Object type and set properties with specific types.
| Constructor Summary | |
|---|---|
Props()
Creates a new Props based on a PropsContainer. |
|
Props(IPropsContainer container)
Creates a new Props based on a given IPropsContainer. |
|
| Method Summary | |
|---|---|
boolean |
addListener(IPropsChangeListener l)
Adds an IPropsChangeListener to the list of listeners for this object. |
void |
append(java.lang.String key,
java.lang.String s)
If the specified object is a String, it is the specified String is appended to it. |
boolean |
copy(Props srcProps,
java.lang.String key)
Copies the value of the property with the same name as key from srcProps into the IPropsContainer for this object. |
void |
copyFrom(Props srcProps)
Copies the contents of the specified Props into this one. |
void |
copyTo(Props destProps)
Copies the contents of this Props into the one specified. |
void |
decrementInteger(java.lang.String key)
Decrements the integer value of the specified key by 1. |
void |
dump()
Dumps a list of properties and their values to System.out. |
void |
enableListeners()
|
java.util.Enumeration |
enumerateKeys()
Returns an Enumeration of keys representing properties contained by this object's IPropsContainer. |
java.lang.String |
format(java.lang.String pattern)
Uses the specified MessageFormat pattern this method generates a string containing the inserted values from the cooresponding properties. |
boolean |
getBoolean(java.lang.String key)
Returns the boolean value of the requested property |
byte[] |
getByteArray(java.lang.String key)
Returns specified object as a byte array. |
char |
getCharacter(java.lang.String key)
Returns the char value of the requested property |
java.util.Date |
getDate(java.lang.String key)
Returns the Date value of the requested property. |
java.util.Date |
getDate(java.lang.String key,
java.text.DateFormat df)
Returns the Date value of the requested property. |
java.lang.String |
getDateString(java.lang.String key,
java.text.DateFormat df)
Returns a formatted date using the Date stored in the specified property. |
double |
getDouble(java.lang.String key)
Returns the double value of the requested property |
float |
getFloat(java.lang.String key)
Returns the float value of the requested property |
java.lang.String |
getHexString(java.lang.String key)
Returns the specified object as a String of hexidecimal bytes. |
int |
getInteger(java.lang.String key)
Returns the int value of the requested property |
java.util.Vector |
getKeys()
Returns a Vector containing the names of property keys currently accessible by getProperty. |
long |
getLong(java.lang.String key)
Returns the long value of the requested property |
protected java.lang.String |
getNextKey(java.lang.String source,
int start)
Used by parse() method to find the next key to replace. |
java.lang.Object |
getProperty(java.lang.String key)
Returns the property with the same name as the key parameter if available. |
java.lang.Object |
getProperty(java.lang.String key,
PropsSchema schema)
Returns the property with the same name as the key parameter if available. |
IPropsContainer |
getPropsContainer()
Returns a reference to the IPropfsContainer referenced by this object. |
int |
getSize(java.lang.String key)
Returns the size of the specified object. |
java.lang.String |
getString()
Returns the entire Props as a formatted String. |
java.lang.String |
getString(java.lang.String key)
Returns the String value of the requested property |
java.util.Vector |
getTokens(java.lang.String key)
Returns a Vector of Strings representing the tokens stored stored in the specified property separated by a comma, semi-colon, carriage return, or line-feed. |
java.util.Vector |
getTokens(java.lang.String key,
java.lang.String tokenSeparators)
Returns a Vector of Strings representing the tokens stored stored in the specified property separated by any of the characters specified by tokenSeparators. |
java.lang.String |
getTrimmedString(java.lang.String key)
Returns the specified object as a trimmed String. |
java.util.Vector |
getVector(java.lang.String key)
Returns the specified object as a Vector. |
boolean |
hasProperty(java.lang.String key)
Tests the existence of the specified property. |
void |
incrementInteger(java.lang.String key)
Increments the integer value of the specified key by 1. |
java.lang.String |
insertProps(java.lang.String str)
Inserts property String values into the passed string where property names are surrounded by angle brackets. |
static Props |
loadProps(java.lang.String file)
Loads a Props from the specified plain text file. |
void |
notifyPropsChanged(java.lang.String key)
Can be called externally to manually send props changes messages to all registered IPropsChangeListeners. |
void |
notifyPropsChangedIgnore(java.lang.String[] changedKeys,
IPropsChangeListener ignore)
Can be called externally to manually send props changes messages to all registered IPropsChangeListeners, except the one passed. |
void |
notifyPropsChangedIgnore(java.lang.String key,
IPropsChangeListener ignore)
Can be called externally to manually send props changes messages to all registered IPropsChangeListeners, except the one passed. |
void |
parse(java.lang.String source,
java.lang.String pattern)
Parses the source using the specified pattern, setting the specified properties with their coresponding values. |
boolean |
propertyMatchesRegEx(java.lang.String key,
java.lang.String regex)
Matches the string against the regular expression stored in the specified property. |
static Props |
readFromFile(java.lang.String file)
Reads a serialized Props from a file. |
boolean |
regExPropertyMatches(java.lang.String key,
java.lang.String str)
Matches the string against the regular expression stored in the specified property. |
void |
removeAll()
Removes all properties referenced by this class. |
boolean |
removeListener(IPropsChangeListener l)
Removes an IPropsChangeListener from the list of listeners for this object. |
boolean |
removeProperty(java.lang.String key)
Removes the property with the same name as the key parameter if available. |
void |
resumeNotify()
Resumes the automatic notification of IPropsChangeListeners. |
static boolean |
saveProps(java.lang.String file,
Props p)
Saves the specified Props to a plain text file. |
void |
set(java.lang.String key,
java.lang.Object value)
Sets the property key to the passed value. |
void |
setBoolean(java.lang.String key,
boolean value)
Sets the property key to a Boolean of the passed value. |
void |
setCharacter(java.lang.String key,
char value)
Sets the property key to a Character of the passed value. |
void |
setDefault(java.lang.String key,
java.lang.Object defaultValue)
If there is no value for the specified object, it is set to the value specified as default. |
void |
setDouble(java.lang.String key,
double value)
Sets the property key to a Double of the passed value. |
void |
setFloat(java.lang.String key,
float value)
Sets the property key to a Float of the passed value. |
void |
setInteger(java.lang.String key,
int value)
Sets the property key to a Integer of the passed value. |
void |
setLong(java.lang.String key,
long value)
Sets the property key to a Long of the passed value. |
void |
setProperty(java.lang.String key,
java.lang.Object value)
Sets the property key to the passed value. |
void |
setProperty(java.lang.String key,
Props srcProps)
Sets the property value for key to the value retrieved using the same key from srcProps. |
void |
setProperty(java.lang.String key,
Props srcProps,
java.lang.String srcKey)
Sets the property value for key to the value retrieved using srcKey from srcProps. |
void |
setPropsContainer(IPropsContainer container)
Sets the IPropsContainer used to access and store properties for this object. |
void |
suspendNotify()
Suspends the automatic notification of IPropsChangeListeners. |
java.lang.String |
toString()
Returns the entire Props as a formatted String. |
static void |
writeToFile(java.lang.String file,
Props p)
Writes the serialized Props to a plain text file. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public Props()
IPropsContainer,
PropsContainerpublic Props(IPropsContainer container)
c - a reference to an IPropsContainer.IPropsContainer| Method Detail |
|---|
public boolean addListener(IPropsChangeListener l)
l - a reference to an IPropsChangeListener.
public void append(java.lang.String key,
java.lang.String s)
public boolean copy(Props srcProps,
java.lang.String key)
srcProps - a reference to the source Props.key - the name of the property to copy.public void copyFrom(Props srcProps)
public void copyTo(Props destProps)
public void decrementInteger(java.lang.String key)
public void dump()
public java.util.Enumeration enumerateKeys()
public void enableListeners()
public java.lang.String format(java.lang.String pattern)
throws PropsException
PropsExceptionpublic boolean getBoolean(java.lang.String key)
key - the name of the property to process and retrieve.
public byte[] getByteArray(java.lang.String key)
public char getCharacter(java.lang.String key)
key - the name of the property to process and retrieve.
public java.util.Date getDate(java.lang.String key)
key - the name of the property to process and retrieve.
public java.util.Date getDate(java.lang.String key,
java.text.DateFormat df)
key - the name of the property to process and retrieve.df - the DateFormat used to parse this property if it is a String.
public java.lang.String getDateString(java.lang.String key,
java.text.DateFormat df)
key - the name of the property to format and return.df - the DateFormat used to format this property if it is a Date.
public double getDouble(java.lang.String key)
key - the name of the property to process and retrieve.
public float getFloat(java.lang.String key)
key - the name of the property to process and retrieve.
public java.lang.String getHexString(java.lang.String key)
public int getInteger(java.lang.String key)
key - the name of the property to process and retrieve.
public long getLong(java.lang.String key)
key - the name of the property to process and retrieve.
public java.util.Vector getKeys()
protected java.lang.String getNextKey(java.lang.String source,
int start)
public java.lang.Object getProperty(java.lang.String key)
key - the name of the property to retrieve.
public java.lang.Object getProperty(java.lang.String key,
PropsSchema schema)
throws PropsException
key - the name of the property to retrieve.schema - the PropsSchema used to determine the returned object type and style.
PropsExceptionpublic IPropsContainer getPropsContainer()
public int getSize(java.lang.String key)
public java.lang.String getString()
public java.lang.String getString(java.lang.String key)
key - the name of the property to process and retrieve.
public java.util.Vector getTokens(java.lang.String key)
public java.util.Vector getTokens(java.lang.String key,
java.lang.String tokenSeparators)
public java.lang.String getTrimmedString(java.lang.String key)
public java.util.Vector getVector(java.lang.String key)
public boolean hasProperty(java.lang.String key)
key - the name of the property to test.
public void incrementInteger(java.lang.String key)
public java.lang.String insertProps(java.lang.String str)
str - a String containing text with with property names surrounded by angle brackets.public void notifyPropsChanged(java.lang.String key)
key - the property that has changed.
public void notifyPropsChangedIgnore(java.lang.String key,
IPropsChangeListener ignore)
key - the property that has changed.l - a reference to an IPropsChangeListener.
public void notifyPropsChangedIgnore(java.lang.String[] changedKeys,
IPropsChangeListener ignore)
key - the property that has changed.l - a reference to an IPropsChangeListener.
public void parse(java.lang.String source,
java.lang.String pattern)
throws java.text.ParseException
java.text.ParseException
public boolean propertyMatchesRegEx(java.lang.String key,
java.lang.String regex)
key - the property containing the String to match against.regex - the regular expression used for matching.
public boolean regExPropertyMatches(java.lang.String key,
java.lang.String str)
key - the property that contains a regular expressionstr - the String that the regular expression is matched against.
public void removeAll()
public boolean removeListener(IPropsChangeListener l)
l - a reference to an IPropsChangeListener.
public boolean removeProperty(java.lang.String key)
key - the name of the property to retrieve.
public void resumeNotify()
public void set(java.lang.String key,
java.lang.Object value)
This method id deprecated. Use IPropsChangeListeners instead.
key - the name of the property to set.value - a reference to an Object.
public void setBoolean(java.lang.String key,
boolean value)
key - the name of the property to set.value - a boolean.
public void setCharacter(java.lang.String key,
char value)
key - the name of the property to set.value - a char.
public void setDefault(java.lang.String key,
java.lang.Object defaultValue)
public void setDouble(java.lang.String key,
double value)
key - the name of the property to set.value - a double.
public void setFloat(java.lang.String key,
float value)
key - the name of the property to set.value - a float.
public void setInteger(java.lang.String key,
int value)
key - the name of the property to set.value - an int.
public void setLong(java.lang.String key,
long value)
key - the name of the property to set.value - a long.
public void setProperty(java.lang.String key,
java.lang.Object value)
key - the name of the property to set.value - a reference to an Object.
public void setProperty(java.lang.String key,
Props srcProps)
key - the name of the property to set.value - a reference to an Object.
public void setProperty(java.lang.String key,
Props srcProps,
java.lang.String srcKey)
key - the name of the property to set.value - a reference to an Object.public void setPropsContainer(IPropsContainer container)
container - a reference to an IPropsContainer.public void suspendNotify()
public java.lang.String toString()
toString in class java.lang.Objectpublic static Props loadProps(java.lang.String file)
public static Props readFromFile(java.lang.String file)
public static boolean saveProps(java.lang.String file,
Props p)
public static void writeToFile(java.lang.String file,
Props p)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||