Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.jdaemon.util.data
Interface DataRepresentation  view DataRepresentation download DataRepresentation.java

All Known Implementing Classes:
JavaDataRepresentation

public interface DataRepresentation

Uberinterface for properties files, directory data, XML config, etc.

A DataRepresentation object represents two things: a named collection of simple attributes, and a named collection of child DataRepresentations (aka Elements). In addition, each DataRepresentation has a 'Type' value which can be retrieved through the getElementType method.

This paradigm works well for both data held in XML files and data held in JNDI directories. (Indeed, the API of DataRepresentation can be thought of as the lowest common denominator between the JNDI and DOM interfaces).

In the case of XML, a DataRepresentation maps to a Tag. The ElementType is the tag name. Attributes of the DataRepresentation are derived from attributes of the tag, and the Elements are derived from any enclosed tags. Every enclosed tag must have an additional 'key' attribute, which contains the key string used by the parent DataRepresentation to identify the child tags.

In the case of JNDI, a DataRepresentation maps to a Directory. The ElementType represented by the special objectClass attribute. Attributes of the DataRepresentation are derived from attributes of the directory, and Elements are derived from sub-directories.

Version:

Method Summary
 java.lang.String getAttribute(java.lang.Object key)
          Get the value of a simple attribute of the DataRepresentation.
 java.util.Iterator getAttributeKeys()
          Get all the valid attribute keys within this representation.
 DataRepresentation getElement(java.lang.Object key)
          Get a named child DataRepresentation.
 java.util.Iterator getElementKeys()
          Return all the valid Element keys within this representation.
 java.lang.String getElementType()
          Get the type of data in this representation.
 DataRepresentation newElement(java.lang.String type)
          Create a new DataRepresentation to which we can freely add data.
 void setAttribute(java.lang.Object key, java.lang.String value)
          Set an attribute of this representation.
 void setElement(java.lang.Object key, DataRepresentation other)
          Add an element to this representation with the given key.
 

Method Detail

getAttribute

public java.lang.String getAttribute(java.lang.Object key)
                              throws ReadError
Get the value of a simple attribute of the DataRepresentation.


getElement

public DataRepresentation getElement(java.lang.Object key)
                              throws ReadError
Get a named child DataRepresentation.


getElementType

public java.lang.String getElementType()
                                throws ReadError
Get the type of data in this representation.


getAttributeKeys

public java.util.Iterator getAttributeKeys()
                                    throws ReadError
Get all the valid attribute keys within this representation.


getElementKeys

public java.util.Iterator getElementKeys()
                                  throws ReadError
Return all the valid Element keys within this representation.


setAttribute

public void setAttribute(java.lang.Object key,
                         java.lang.String value)
                  throws WriteError
Set an attribute of this representation. Sets an existing attribute or creates a new attribute if an attribute with the given key does not already exist.


setElement

public void setElement(java.lang.Object key,
                       DataRepresentation other)
                throws WriteError,
                       ReadError
Add an element to this representation with the given key.

Creates a new child DataRepresentation with the given key and copies data from the given 'other' representation into it. If an element already exists, with the given key the entire old element is first deleted.

Note that we exlicity allow the given 'other' DataRepresentation to be a different class to this DataRepresentation. For example, it should be possible to use this method to copy data from an XML file to a JNDI directory.


newElement

public DataRepresentation newElement(java.lang.String type)
Create a new DataRepresentation to which we can freely add data. The created element is not a member of this or any parent representation.