Data Request Broker
2-3-release

fr.gael.drb.impl.xml
Class XmlDocument

java.lang.Object
  extended by fr.gael.drb.DrbDefaultNodesChangeProducer
      extended by fr.gael.drb.DrbAbstractNode
          extended by fr.gael.drb.impl.DrbNodeImpl
              extended by fr.gael.drb.impl.xml.XmlDocument
All Implemented Interfaces:
DrbMutableNode, DrbNode, DrbNodesChangeListener, DrbNodesChangeProducer, EventListener

public class XmlDocument
extends DrbNodeImpl

DOM Document


Field Summary
protected  DrbNode baseNode
          baseNode
protected  Document document
          The Document node.
 
Fields inherited from interface fr.gael.drb.DrbItem
ATTRIBUTE_ITEM, NODE_ITEM, UNDEFINED_ITEM, VALUE_ITEM
 
Constructor Summary
protected XmlDocument(Document document)
          Builds a new XmlDocument from a Document node
protected XmlDocument(DrbNode base_node)
          Builds a new XmlDocument from a file node.
protected XmlDocument(InputSource input_source)
          Builds a new XmlDocument from a InputSource
  XmlDocument(InputStream input_stream)
          Builds a new XmlDocument from an input stream.
  XmlDocument(Reader reader)
          Builds a new XmlDocument from a standard reader .
  XmlDocument(String xml_string)
          Builds a new XmlDocument from a string.
 
Method Summary
 boolean equals(Object obj)
          Indicates whether this node is "equal to" to another node.
 DrbAttributeList getAttributes()
          The attributes of the nodes.
 DrbNodeList getChildren()
          The list of children of the XML document.
 DrbSequence getContent()
          The root content of the XML document.
 Object getImpl(Class api)
          Returns a specific implementation.
 int getIndex()
          Returns the index of the node.
 String getName()
          Name of the node.
 String getNamespaceURI()
          Get namespace URI.
 DrbNode getParent()
          The parent of this node.
 String getPath()
          The full path of the node.
 DrbNode getRoot()
          Root node.
 Value getValue()
          The value of the node.
 int getValueType()
          The value type of the node.
 boolean hasImpl(Class api)
          Tests if a specific interface can be provided.
 
Methods inherited from class fr.gael.drb.impl.DrbNodeImpl
close, createAttribute, createNode, flush, getProvider
 
Methods inherited from class fr.gael.drb.DrbAbstractNode
allowsMultiOccurrence, appendChild, appendReference, getAttribute, getChildAt, getChildrenCount, getFirstChild, getItemType, getLastChild, getNamedChild, getNamespaceBindings, getNextSibling, getOccurrence, getPreviousSibling, getXPathName, getXPathName, hasChild, insertChild, removeChild, rename, replaceChild, setAttributes, setNamespaceBindings, setNamespaceURI, setValue, toString
 
Methods inherited from class fr.gael.drb.DrbDefaultNodesChangeProducer
addNodesChangeListener, getListenerList, nodesChanged, nodesInserted, nodesRemoved, removeNodesChangeListener, setListenerList, structureChanged
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

document

protected Document document
The Document node.


baseNode

protected DrbNode baseNode
baseNode

Constructor Detail

XmlDocument

public XmlDocument(String xml_string)
Builds a new XmlDocument from a string. This constructor initialises a node based on the XML document encoded in the passed string.

Parameters:
xml_string - The XML string. This parameter shall never be null.

XmlDocument

public XmlDocument(Reader reader)
Builds a new XmlDocument from a standard reader . This constructor initialises a node based on the XML document encoded in the passed Reader.

Parameters:
reader - The reader to build the document.

XmlDocument

public XmlDocument(InputStream input_stream)
Builds a new XmlDocument from an input stream. This constructor initialises a node based on the XML document encoded in the passed InputStream.

Parameters:
input_stream - The input stream to build the document.

XmlDocument

protected XmlDocument(DrbNode base_node)
Builds a new XmlDocument from a file node. This constructor initialises a node based on the XML document encoded in the underlying InputStream.

Parameters:
base_node - A reference to a the base node of an external implementation.

XmlDocument

protected XmlDocument(InputSource input_source)
Builds a new XmlDocument from a InputSource

Parameters:
input_source - The input source to build the DOM node.

XmlDocument

protected XmlDocument(Document document)
Builds a new XmlDocument from a Document node

Parameters:
document - The DOM document.
Method Detail

equals

public boolean equals(Object obj)
Indicates whether this node is "equal to" to another node. See Object.equals() for the general contract of this method.

Overrides:
equals in class DrbAbstractNode
Parameters:
obj - another value.
Returns:
true if this object is the same as the obj argument

getName

public String getName()
Name of the node. Read accessor to the previously set node name. The name is never null but may be an empty string.

Overrides:
getName in class DrbAbstractNode
Returns:
The name of the node.

getNamespaceURI

public String getNamespaceURI()
Get namespace URI.

Overrides:
getNamespaceURI in class DrbAbstractNode
Returns:
The namespace URI previsouly set or null if unspecified.

getPath

public String getPath()
The full path of the node. The full path is the path of the parent node to which is appended the name of the current node. If no parent have already been set no absolute path is considered. A path considering the current node has a root node is not valid for the factory and is therefore not significant in the current implementation.

Overrides:
getPath in class DrbAbstractNode
Returns:
The absolute path of the current node.

getIndex

public int getIndex()
Returns the index of the node. The index is the sequential position of the current node in its parent children list.

Overrides:
getIndex in class DrbAbstractNode
Returns:
The index of the current node in its parent children list.

getValueType

public int getValueType()
The value type of the node. The value type is determined from the value previously assigned to the node. If no speficic value has been previsouly set, fr.gael.drb.value.Value.NULL_ID type is returned.

Overrides:
getValueType in class DrbAbstractNode
Returns:
NULL_ID if the node does not provide value or any other valid type identifier otherwise.

getValue

public Value getValue()
The value of the node. The value is the one previously set.

Overrides:
getValue in class DrbAbstractNode
Returns:
A reference to the value of the node or null if no value has already been set.

getAttributes

public DrbAttributeList getAttributes()
The attributes of the nodes. This operation returns a list of attribute previously set (if any).

Overrides:
getAttributes in class DrbAbstractNode
Returns:
The list attributes of the current node or null if none.

getRoot

public DrbNode getRoot()
Root node. The root node retrieval is delegated to the parent node if any. If no parent has been declared for this node, the operation returns a reference to itself.

Overrides:
getRoot in class DrbAbstractNode
Returns:
A reference to the root node or null.
See Also:
DrbSimpleNode.getRoot()

getParent

public DrbNode getParent()
The parent of this node. Returns a reference to the parent node of the current node according to the current implementation. Most of the nodes have a parent except root nodes or if they have just been removed, etc. If the node has no parent the operation returns null.

Specified by:
getParent in class DrbAbstractNode
Returns:
The parent of this node or null.

getChildren

public DrbNodeList getChildren()
The list of children of the XML document. Returns the root XML Element of the document as defined by the W3C. The document may have an empty content and the operation returns therefore a null reference.

Specified by:
getChildren in class DrbAbstractNode
Returns:
The list of children if any null otherwise.

getContent

public DrbSequence getContent()
The root content of the XML document. Returns the content of the document at root level. According to the XML 1.0 specification, the Document node contains the root element (if any), comments and processing instructions.

Overrides:
getContent in class DrbAbstractNode
Returns:
The content of the document at root level.

hasImpl

public boolean hasImpl(Class api)
Tests if a specific interface can be provided. This operations tests with a minimum of time and memory consumption if the current implementation can provide a specific interface. It important to consider that hasImpl() provides information about the ability to provide such interface in general cases but not focused on the current instance. It may therefore be impossible to get a specific implementation from a node whereas hasImpl() operation returns true.

Overrides:
hasImpl in class DrbNodeImpl
Parameters:
api - The class type to test.
Returns:
true if an implementation of the interface can be provided and false otherwise.

getImpl

public Object getImpl(Class api)
Returns a specific implementation. This operation returns a reference to an object implementing a specific interface. This mean is useful to benefit by a specific and direct API instead of using the DrbNode interface. The provided object shall represent the current node such as it is possible after a call to this operation, to dismiss the reference to the node. For instance, a file is usually wrapped as a drb.impl.file.File class and thanks to this operation can be seen as a InputStream enabling direct access to the handled file.

Overrides:
getImpl in class DrbNodeImpl
Parameters:
api - The interface (or class) to be provided.
Returns:
A reference to the object implementing the interface or a null reference otherwise.

Data Request Broker - DRB API®
2-3-release

Copyright© 2001-2009 GAEL Consultant. All rights reserved. Use is subject to license terms .