|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.jinx.db.Hierarchy
public abstract class Hierarchy
Hierarchy implementations store data in a hierarchical form, based on nodes
and attributes. Each node is also a Hierachy object. Any Hierarchy can
store attributes; String keys attached to values. These values can be of
many different types ranging from primitives to Strings. Sub-nodes and
attributes with the same name can coexist inside the same node.
There are methods in this class for storing attributes as primitive types
and arrays of them, as well as a few handy odds and ends like
java.math.BigDecimal Objects.
API Stability: Stable.
Constructor Summary | |
---|---|
protected |
Hierarchy()
Constructs a new Hierarchy. |
Method Summary | |
---|---|
void |
addListener(HierarchyListener listener)
Allows a HierarchyListener to receive events from this specific Hierarchy, but not any of it's children. |
abstract java.util.Iterator |
attributes()
Provides an Iterator for the attributes that are stored in this Hierarchy, but not any of it's sub-nodes. |
void |
clear()
Clears all attributes and sub-nodes from this Hierarchy. |
abstract void |
clearAttributes()
Clears all attributes from this Hierarchy. |
abstract void |
clearNodes()
Clears all sub-nodes from this hierarchy. |
void |
close()
Closes the Hierarchy. |
void |
commit()
Completes the current transaction. |
void |
copyTo(Hierarchy h)
Recursively copies this Hierarchy object's contents into another. |
abstract Hierarchy |
createNode(java.lang.String name)
Creates a new node with the given name. |
abstract void |
deleteNode(java.lang.String name)
Removes the node with the given name. |
java.lang.String |
getAttribute(java.lang.String name)
Gets the value for the given attribute name, returning null if the attribute does not exist. |
java.math.BigDecimal |
getAttribute(java.lang.String name,
java.math.BigDecimal defaultValue)
|
java.math.BigDecimal[] |
getAttribute(java.lang.String name,
java.math.BigDecimal[] defaultValue)
|
java.math.BigInteger |
getAttribute(java.lang.String name,
java.math.BigInteger defaultValue)
|
java.math.BigInteger[] |
getAttribute(java.lang.String name,
java.math.BigInteger[] defaultValue)
|
boolean |
getAttribute(java.lang.String attribute,
boolean defaultValue)
Gets the value of an attribute as a boolean. |
boolean[] |
getAttribute(java.lang.String attribute,
boolean[] defaultValue)
Gets the value of an attribute as a boolean array. |
byte |
getAttribute(java.lang.String attribute,
byte defaultValue)
Provides the means to get an attribute as a byte value. |
byte[] |
getAttribute(java.lang.String attribute,
byte[] defaultValue)
|
char |
getAttribute(java.lang.String name,
char defaultValue)
|
char[] |
getAttribute(java.lang.String name,
char[] defaultValue)
|
double |
getAttribute(java.lang.String attribute,
double defaultValue)
Provides the means to get an attribute as a double value. |
double[] |
getAttribute(java.lang.String attribute,
double[] defaultValue)
|
float |
getAttribute(java.lang.String attribute,
float defaultValue)
Provides the means to get an attribute as a float value. |
float[] |
getAttribute(java.lang.String attribute,
float[] defaultValue)
|
int |
getAttribute(java.lang.String attribute,
int defaultValue)
Provides the means to get an attribute as an int value. |
int[] |
getAttribute(java.lang.String attribute,
int[] defaultValue)
|
double[] |
getAttribute(java.lang.String attribute,
int len,
double[] defaultValue)
|
float[] |
getAttribute(java.lang.String attribute,
int len,
float[] defaultValue)
|
long |
getAttribute(java.lang.String attribute,
long defaultValue)
Provides the means to get an attribute as a long value. |
long[] |
getAttribute(java.lang.String attribute,
long[] defaultValue)
|
short |
getAttribute(java.lang.String attribute,
short defaultValue)
Provides the means to get an attribute as a short value. |
short[] |
getAttribute(java.lang.String attribute,
short[] defaultValue)
|
java.lang.String |
getAttribute(java.lang.String name,
java.lang.String defaultValue)
Gets the value for the given attribute name, returning defaultValue if the attribute does not exist. |
java.net.URL |
getAttribute(java.lang.String name,
java.net.URL defaultValue)
Parses a URL from an attribute. |
protected abstract java.lang.Object |
getAttributeObject(java.lang.String name)
Gets the attribute's value Object. |
abstract Hierarchy |
getNode(java.lang.String name)
Provides the Hierarchy for the given node name. |
abstract boolean |
hasAttribute(java.lang.String name)
|
abstract java.util.Iterator |
nodes()
Provides an Iterator for the sub-nodes that are direct sub-nodes of this Hierarchy. |
void |
parseFromProperties(java.util.Properties prop)
Sets attributes in this Hierarchy according to a Properties Object. |
void |
parseFromXML(java.io.InputStream in)
Reads attributes and nodes for the Hierarchy from the given InputStream. |
protected void |
propertyChanged(java.lang.String name,
int ec)
Should be called when an attribute or node directly in this Hierarchy has changed in some manner. |
abstract java.lang.Object |
removeAttribute(java.lang.String name)
Remove the value for the given attribute name, returning the previous value. |
void |
removeListener(HierarchyListener listener)
Removes a HierarchyListener from this Hiereachy. |
void |
rollback()
Discards all changes since the most recent call to commit(). |
void |
setAttribute(java.lang.String name,
java.math.BigDecimal val)
|
void |
setAttribute(java.lang.String name,
java.math.BigDecimal[] values)
|
void |
setAttribute(java.lang.String name,
java.math.BigInteger val)
|
void |
setAttribute(java.lang.String name,
java.math.BigInteger[] values)
|
void |
setAttribute(java.lang.String attribute,
boolean value)
Sets an attribute. |
void |
setAttribute(java.lang.String attribute,
boolean[] values)
Sets an attribute. |
void |
setAttribute(java.lang.String attribute,
byte value)
|
void |
setAttribute(java.lang.String attribute,
byte[] values)
|
void |
setAttribute(java.lang.String name,
char value)
|
void |
setAttribute(java.lang.String name,
char[] value)
|
void |
setAttribute(java.lang.String attribute,
double value)
|
void |
setAttribute(java.lang.String attribute,
double[] values)
|
void |
setAttribute(java.lang.String attribute,
float value)
|
void |
setAttribute(java.lang.String attribute,
float[] values)
|
void |
setAttribute(java.lang.String attribute,
int value)
|
void |
setAttribute(java.lang.String attribute,
int[] values)
|
void |
setAttribute(java.lang.String attribute,
long value)
|
void |
setAttribute(java.lang.String attribute,
long[] values)
|
void |
setAttribute(java.lang.String attribute,
short value)
|
void |
setAttribute(java.lang.String attribute,
short[] values)
|
java.lang.String |
setAttribute(java.lang.String name,
java.lang.String obj)
Sets the value for the given attribute name, returning the previous value. |
void |
setAttribute(java.lang.String name,
java.net.URL val)
Sets the value of an attribute based on the String version of a URL object. |
protected abstract java.lang.Object |
setAttributeObject(java.lang.String name,
java.lang.Object obj)
Sets an attribute's value Object. |
void |
storeToProperties(java.util.Properties prop)
Stores this Hierarchy tree in a Properties Object. |
void |
storeToXML(java.io.OutputStream o)
Stores the Hierarchy tree to the given java.io.OutputStream as XML. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
protected Hierarchy()
Method Detail |
---|
public void close()
public void commit()
public void rollback()
public void storeToProperties(java.util.Properties prop)
prop
- the Properties object.public void parseFromProperties(java.util.Properties prop)
prop
- the Properties object.public void copyTo(Hierarchy h)
h
- the Hierarchy to copy to.public void parseFromXML(java.io.InputStream in) throws java.io.IOException, org.xml.sax.SAXException, javax.xml.parsers.ParserConfigurationException
in
- the InputStream to read from.
java.io.IOException
org.xml.sax.SAXException
javax.xml.parsers.ParserConfigurationException
public void storeToXML(java.io.OutputStream o) throws java.io.IOException
o
- the OutputStream to write to.
java.io.IOException
- if an I/O error occurs.public void clear()
public abstract void clearAttributes()
public abstract void clearNodes()
public abstract java.util.Iterator attributes()
public abstract java.util.Iterator nodes()
public char getAttribute(java.lang.String name, char defaultValue)
public void setAttribute(java.lang.String name, char value)
public char[] getAttribute(java.lang.String name, char[] defaultValue)
public void setAttribute(java.lang.String name, char[] value)
public java.net.URL getAttribute(java.lang.String name, java.net.URL defaultValue)
name
- the name of the attribute to parse the URL from.defaultValue
- the default to use in case of error.
public void setAttribute(java.lang.String name, java.net.URL val)
name
- the name of the attribute to set.val
- the URL to store as a String.public java.lang.String getAttribute(java.lang.String name, java.lang.String defaultValue)
name
- the name of the attribute to access.defaultValue
- the default value to return if the attribute doesn't
exist.
public java.lang.String getAttribute(java.lang.String name)
name
- the name of the attribute to access.
public java.lang.String setAttribute(java.lang.String name, java.lang.String obj)
name
- the name of the attribute to access.
protected abstract java.lang.Object getAttributeObject(java.lang.String name)
name
- the name of the attribute to access.
protected abstract java.lang.Object setAttributeObject(java.lang.String name, java.lang.Object obj)
name
- the name of the attribute to access.
public abstract java.lang.Object removeAttribute(java.lang.String name)
name
- the name of the attribute to access.
public abstract boolean hasAttribute(java.lang.String name)
public abstract void deleteNode(java.lang.String name)
name
- the name of the node.public abstract Hierarchy createNode(java.lang.String name)
name
- the name of the node.
public abstract Hierarchy getNode(java.lang.String name)
name
- the name of the node to access.
protected void propertyChanged(java.lang.String name, int ec)
name
- the name of the attribute that changed.ec
- the event constant from HierarchyEvent for what occured.public void addListener(HierarchyListener listener)
listener
- the HierarchyListener to add.public void removeListener(HierarchyListener listener)
listener
- the HierarchyListener to add.public void setAttribute(java.lang.String attribute, boolean[] values)
attribute
- the name of the attribute.values
- the value as a boolean array.public boolean[] getAttribute(java.lang.String attribute, boolean[] defaultValue)
attribute
- the name of the attribute.defaultValue
- the default value to return on a failure.
public void setAttribute(java.lang.String attribute, boolean value)
attribute
- the name of the attribute.value
- the value as a boolean.public boolean getAttribute(java.lang.String attribute, boolean defaultValue)
attribute
- the name of the attribute.defaultValue
- the default value to return on a failure.
public void setAttribute(java.lang.String attribute, float[] values)
public float[] getAttribute(java.lang.String attribute, int len, float[] defaultValue)
public float[] getAttribute(java.lang.String attribute, float[] defaultValue)
public void setAttribute(java.lang.String attribute, float value)
public float getAttribute(java.lang.String attribute, float defaultValue)
attribute
- the name of the attribute to retrieve.defaultValue
- the value to return if the attribute doesn't exist.public void setAttribute(java.lang.String attribute, double[] values)
public double[] getAttribute(java.lang.String attribute, int len, double[] defaultValue)
public double[] getAttribute(java.lang.String attribute, double[] defaultValue)
public void setAttribute(java.lang.String attribute, double value)
public double getAttribute(java.lang.String attribute, double defaultValue)
attribute
- the name of the attribute to retrieve.defaultValue
- the value to return if the attribute doesn't exist.public void setAttribute(java.lang.String attribute, long[] values)
public long[] getAttribute(java.lang.String attribute, long[] defaultValue)
public void setAttribute(java.lang.String attribute, long value)
public long getAttribute(java.lang.String attribute, long defaultValue)
attribute
- the name of the attribute to retrieve.defaultValue
- the value to return if the attribute doesn't exist.public void setAttribute(java.lang.String attribute, int[] values)
public int[] getAttribute(java.lang.String attribute, int[] defaultValue)
public void setAttribute(java.lang.String attribute, int value)
public int getAttribute(java.lang.String attribute, int defaultValue)
attribute
- the name of the attribute to retrieve.defaultValue
- the value to return if the attribute doesn't exist.public void setAttribute(java.lang.String attribute, short[] values)
public short[] getAttribute(java.lang.String attribute, short[] defaultValue)
public void setAttribute(java.lang.String attribute, short value)
public short getAttribute(java.lang.String attribute, short defaultValue)
attribute
- the name of the attribute to retrieve.defaultValue
- the value to return if the attribute doesn't exist.public void setAttribute(java.lang.String attribute, byte[] values)
public byte[] getAttribute(java.lang.String attribute, byte[] defaultValue)
public void setAttribute(java.lang.String attribute, byte value)
public byte getAttribute(java.lang.String attribute, byte defaultValue)
attribute
- the name of the attribute to retrieve.defaultValue
- the value to return if the attribute doesn't exist.public java.math.BigDecimal getAttribute(java.lang.String name, java.math.BigDecimal defaultValue)
public java.math.BigDecimal[] getAttribute(java.lang.String name, java.math.BigDecimal[] defaultValue)
public void setAttribute(java.lang.String name, java.math.BigDecimal val)
public void setAttribute(java.lang.String name, java.math.BigDecimal[] values)
public java.math.BigInteger getAttribute(java.lang.String name, java.math.BigInteger defaultValue)
public java.math.BigInteger[] getAttribute(java.lang.String name, java.math.BigInteger[] defaultValue)
public void setAttribute(java.lang.String name, java.math.BigInteger val)
public void setAttribute(java.lang.String name, java.math.BigInteger[] values)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |