PropertyTree¶
-
public class
PropertyTree
extends PersistentComponent implements PropertySheet¶ PropertyTree is an implementation of a PropertySheet. It represents a property sheet with a tree structure and is actually backed by a Document object.
Author: Hugo Y. K. Lam See also:
org.dom4j.Document
Constructors¶
PropertyTree¶
PropertyTree¶
PropertyTree¶
-
public
PropertyTree
(InputStream ins)¶ Creates a new instance of PropertyTree.
Parameters: - ins – the input stream of the properties source.
Throws: - ComponentException – if the properties could not be loaded from the specified input stream.
Methods¶
addProperty¶
append¶
-
public boolean
append
(PropertySheet p)¶ Appends a property sheet to this property tree. The specified property sheet can only be appended if it is of the PropertyTree type.
Parameters: - p – the property sheet to be appended.
Returns: true if the operation is successful. false otherwise.
See also:
hk.hku.cecid.piazza.commons.util.PropertySheet.append(hk.hku.cecid.piazza.commons.util.PropertySheet)
containsKey¶
countProperties¶
createProperties¶
-
public Properties
createProperties
(String xpath)¶ Creates a Properties object which stores the properties retrieved by the specified xpath.
Parameters: - xpath – the properties xpath.
Returns: a Properties object which stores the retrieved properties.
See also:
hk.hku.cecid.piazza.commons.util.PropertySheet.createProperties(java.lang.String)
getProperties¶
getProperties¶
-
public String[][]
getProperties
(String xpath, String xpath2)¶ Gets a two-dimensional list of properties with the specified xpaths. The first xpath will define the first dimension of the list while the second xpath will define the second dimension. E.g.
<!- Properties content --> <application> <listener> <id>MyListener</id> <name>My Listener</name> </listener> <listener> <id>MyListener2</id> <name>My Listener 2</name> </listener> </application> First xpath: /application/listener Second xpath: ./id|./name Returned array: {{"MyListener","My Listener"},{"MyListener2","My Listener 2"}}
Parameters: - xpath – the first xpath.
- xpath2 – the second xpath.
Returns: a two-dimensional list of properties with the specified xpaths.
See also:
hk.hku.cecid.piazza.commons.util.PropertySheet.getProperties(java.lang.String, java.lang.String)
getProperty¶
-
public String
getProperty
(String xpath)¶ Gets a property with the specified xpath. If the xpath refers to more than one properpty, the first one will be returned.
Parameters: - xpath – the property xpath.
Returns: the property with the specified xpath.
See also:
hk.hku.cecid.piazza.commons.util.PropertySheet.getProperty(java.lang.String)
getProperty¶
-
public String
getProperty
(String xpath, String def)¶ Gets a property with the specified xpath. If the xpath refers to more than one properpty, the first one will be returned.
Parameters: - xpath – the property xpath.
- def – the default value.
Returns: the property with the specified xpath.
See also:
hk.hku.cecid.piazza.commons.util.PropertySheet.getProperty(java.lang.String, java.lang.String)
getPropertyNode¶
getPropertyNodes¶
loading¶
propertyNames¶
-
public Enumeration
propertyNames
()¶ Gets all the existing property xpaths.
Returns: all the existing property xpaths. See also:
hk.hku.cecid.piazza.commons.util.PropertySheet.propertyNames()
removeProperty¶
-
public boolean
removeProperty
(String xpath)¶ Removes a property with the specified xpath. If the xpath refers to more than one properpty, the first one will be removed.
Parameters: - xpath – the property xpath.
Returns: true if the operation is successful. false otherwise.
See also:
hk.hku.cecid.piazza.commons.util.PropertySheet.removeProperty(java.lang.String)
setProperty¶
-
public boolean
setProperty
(String xpath, String value)¶ Sets a property value with the specified key.
Parameters: - xpath – the property xpath.
- value – the property value.
Returns: true if the operation is successful. false otherwise.
See also:
hk.hku.cecid.piazza.commons.util.PropertySheet.setProperty(java.lang.String, java.lang.String)
storing¶
subtree¶
-
public PropertyTree
subtree
(String xpath)¶ Creates a sub-tree from this property tree.
Parameters: - xpath – the xpath for locating the subtree.
Returns: a new property tree.
toDocument¶
toString¶
-
public String
toString
()¶ Returns a string representation of this property tree, which is the XML text.
Returns: a string representation of this property tree. See also:
java.lang.Object.toString()