Why not use java.util.Properties
?
Utilizing java.util.Properties
has the following disadvantages:
java.util.Hashtable
subclass: All the methods
defined in java.util.Hashtable
are accessible which means
arbitrary data can be placed where name/value pairs are the only
appropriate content.Why use this package?
java.util.Map
. Retrieval is extremely fast.
Useage
To get a property manager, do the following:
PropertyMgrIfc propertyMgr = PropertyMgr.getSingleton ();To retrieve a property
bar
for class Foo
, do the
following (assume the above):
final String barValue = propertyMgr.getProperty ( Foo.class, "bar" );To retrieve all properties for a class, Foo, do the following:
final Map fooProps = propertyMgr.getProperties ( Foo.class );One can get the default property for a class. To get the default property for a class Foo, do the following:
final String defaultProperty = propertyMgr.getDefaultProperty ( Foo.class );To see all classes who have properties assigned, do the following:
final Class definedClasses[] = propertyMgr.getClassesAssignedProperties ();
XML file format
Currently the XML file contains the DTD (please see note below). The XML structure follows:
<?xml version="1.0"?> <!DOCTYPE property-mgr SYSTEM "org.jplate.util.propertymgr.PropertyMgr.dtd"> <property-mgr> <properties class="fully qualified class name"> <property name="property name">property value</property> ... <default>default value<default> <properties> ... </property-mgr>
You may define as many classes/properties as needed in the XML file...
@see org.jplate.util.resourcemgr