|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.ceryle.xml.PropertyManager
public class PropertyManager
Uses an XMLProcessor to provide access to a simple XML properties file that can be queried for name/value pairs. Each <property> element contains a name and value attribute. For example:
<property name="widget.color" value="#80ffff"/>
<property name="widget.height" value="60"/>
<property name="widget.width" value="200"/>
...
Note that the Ceryle properties file also contains a "type" and a "title" attribute for each property, designating (resp.) its datatype and a short description. Datatypes include: "int", "string", "color", "URL", "path", "boolean", "rect" and "struct". There is currently support for storage and retrieval of String, boolean, int, float, long and double values. Default values are required in the get methods, similar to the Java Preferences API.
Calling readProperty(String,String) on "struct" type properties will
return an int value indicating the number of embedded <value>
elements. A call to readProperties(String) will return a
Hashtable of name-value (key-value) pairs corresponding to the stored
attribute contents. The writeProperties(String,Set,String) method
is the corresponding write-to-file method. An example is shown below:
<property name="http://purl.org/ceryle/prop/#helperMap"
type="struct"
title="the map of MIME type to helper applications">
<value mime="application/fu-manchu"
ext="fuu"
desc="Fu Manchu documents"
action="1"
path="/usr/bin/fumanchu" />
</property>
XMLProcessor| Field Summary | |
|---|---|
static boolean |
valueAsColumn
A boolean variable controlling whether current property values are included in the generated XHTML PSI/Property Set document as a separate column or simply appended to the description. |
| Constructor Summary | |
|---|---|
PropertyManager(MessageHandler messagehandler,
XMLProcessor xp,
String filename)
Constructor provided a String filename containing the pathname of the preferences file. |
|
| Method Summary | |
|---|---|
MessageHandler |
getMessageHandler()
A convenience method returning the MessageHandler used with this PropertyManager. |
Properties |
getProperties()
Returns the current properties as a Properties object. |
Vector |
getProperties(boolean fullNames)
Returns a Vector of Vectors containing the entire list of properties. |
boolean |
isDirty()
Returns true if any properties have been modified since import of the properties file. |
Set |
readProperties(String name)
Returns a Set of Hashtables as the set of name-value pairs corresponding to the property name, null if unavailable or empty. |
boolean |
readProperty(String name,
boolean def)
Returns a boolean as the value corresponding to the property name, null if unavailable or empty. |
double |
readProperty(String name,
double def)
Returns a double as the value corresponding to the property name, null if unavailable or empty. |
float |
readProperty(String name,
float def)
Returns a float as the value corresponding to the property name, null if unavailable or empty. |
int |
readProperty(String name,
int def)
Returns an int as the value corresponding to the property name, null if unavailable or empty. |
long |
readProperty(String name,
long def)
Returns a long as the value corresponding to the property name, null if unavailable or empty. |
String |
readProperty(String name,
String def)
Returns a String as the value corresponding to the property name, null if unavailable or empty. |
void |
writeAsSystemProperty(String name,
String systemName,
boolean def)
Obtains the value of the named property and writes it as a Java System property of the name systemName (or using the same name if the second parameter is null). |
void |
writeAsSystemProperty(String name,
String systemName,
int def)
Obtains the value of the named property and writes it as a Java System property of the name systemName (or using the same name if the second parameter is null). |
boolean |
writeAsSystemProperty(String name,
String systemName,
String def)
Obtains the value of the named property from the property file and writes it as a Java System property of the name systemName (or using the same name if the second parameter is null), returning true. |
boolean |
writePreferences()
Writes the current properties document to the default preferences filename. |
boolean |
writePreferences(String filename)
Writes the current properties document to a File named filename. |
boolean |
writeProperties(String name,
Set set,
String title)
Writes to the properties Document the properties of String name with a Set of Hashtables each containing name-value pairs, returning true if the property replaced an existing value, false if the property did not exist prior. |
void |
writePropertiesAsXHTML(String filename)
Writes the current properties document to a generated XHTML file named filename. |
boolean |
writeProperty(String name,
String value,
String title)
Writes the property of String name with String value to the properties document, returning true if the property replaced an existing value, false if the property did not exist prior. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static boolean valueAsColumn
| Constructor Detail |
|---|
public PropertyManager(MessageHandler messagehandler,
XMLProcessor xp,
String filename)
throws FileNotFoundException,
ProcessException
The preferences file is built from a canonical properties file that is
not modified. If the preference file fails to load for any reason, an
attempt is made to load the properties file. If the properties file
cannot be read, a ProcessException is thrown and subsequent calls to
readProperty(String,String) will return null.
FileNotFoundException
ProcessException| Method Detail |
|---|
public int readProperty(String name,
int def)
name - the name or key of the propertydef - the default value of the property should it not be set
public long readProperty(String name,
long def)
name - the name or key of the propertydef - the default value of the property should it not be set
public float readProperty(String name,
float def)
name - the name or key of the propertydef - the default value of the property should it not be set
public double readProperty(String name,
double def)
name - the name or key of the propertydef - the default value of the property should it not be set
public boolean readProperty(String name,
boolean def)
name - the name or key of the propertydef - the default value of the property should it not be set
public String readProperty(String name,
String def)
name - the name or key of the propertydef - the default value of the property should it not be setpublic Set readProperties(String name)
public boolean writeProperty(String name,
String value,
String title)
throws ProcessException
Note that this does not write to a file, just the internal property Document.
ProcessException
public boolean writeProperties(String name,
Set set,
String title)
throws ProcessException
Note that this does not write to a file, just the internal property Document.
ProcessExceptionpublic boolean writePreferences()
public boolean writePreferences(String filename)
public void writePropertiesAsXHTML(String filename)
public Vector getProperties(boolean fullNames)
If the boolean fullNames is true, the full Ceryle property name is returned; if false, only the fragment identifier portion.
This returns null if no properties file has been read.
public Properties getProperties()
Properties object.
public boolean writeAsSystemProperty(String name,
String systemName,
String def)
readProperty(String,String)
returns null), no System property is set and the method returns false.
name - the name or key of the propertysystemName - the name to be used for the system propertydef - the default value of the property should it not be set
public void writeAsSystemProperty(String name,
String systemName,
boolean def)
name - the name or key of the propertysystemName - the name to be used for the system propertydef - the default value of the property should it not be set
public void writeAsSystemProperty(String name,
String systemName,
int def)
name - the name or key of the propertysystemName - the name to be used for the system propertydef - the default value of the property should it not be setpublic boolean isDirty()
public MessageHandler getMessageHandler()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||