net.beandocument
Class BeanDocument

java.lang.Object
  extended bynet.beandocument.BeanBaseNode
      extended bynet.beandocument.BeanDocument
All Implemented Interfaces:
org.w3c.dom.Document, org.w3c.dom.Node

public class BeanDocument
extends BeanBaseNode
implements org.w3c.dom.Document

Wraps a Java bean into a pseudo XML document instance.
This document implementation can be used by the BeanDocumentBuilder class which is able to construct new instances of the document by using a simple bean.

Author:
Jens Scheffler
See Also:
BeanDocumentBuilder.getDocument(Object)

Field Summary
protected  BeanElementFactory elementFactory
          Element factory to use for creating new child nodes
 
Fields inherited from class net.beandocument.BeanBaseNode
owner, parent
 
Fields inherited from interface org.w3c.dom.Node
ATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_TYPE_NODE, ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, NOTATION_NODE, PROCESSING_INSTRUCTION_NODE, TEXT_NODE
 
Constructor Summary
protected BeanDocument(BeanElementFactory elementFactory, java.lang.Object bean)
          Creates a new document based on the given bean
 
Method Summary
 org.w3c.dom.Attr createAttribute(java.lang.String name)
          NOTE: This function is not implemented and therefore will just throw an exception!
 org.w3c.dom.Attr createAttributeNS(java.lang.String namespace, java.lang.String name)
          NOTE: This function is not implemented and therefore will just throw an exception!
 org.w3c.dom.CDATASection createCDATASection(java.lang.String content)
          NOTE: This function is not implemented and therefore will just throw an exception!
 org.w3c.dom.Comment createComment(java.lang.String content)
          NOTE: This function is not implemented and therefore will just throw an exception!
 org.w3c.dom.DocumentFragment createDocumentFragment()
          Creates a new document fragment
 org.w3c.dom.Element createElement(java.lang.String name)
          NOTE: This function is not implemented and therefore will just throw an exception!
 org.w3c.dom.Element createElementNS(java.lang.String namespace, java.lang.String name)
          NOTE: This function is not implemented and therefore will just throw an exception!
 org.w3c.dom.EntityReference createEntityReference(java.lang.String name)
          NOTE: This function is not implemented and therefore will just throw an exception!
 org.w3c.dom.ProcessingInstruction createProcessingInstruction(java.lang.String target, java.lang.String data)
          NOTE: This function is not implemented and therefore will just throw an exception!
 org.w3c.dom.Text createTextNode(java.lang.String text)
          NOTE: This function is not implemented and therefore will just throw an exception!
 org.w3c.dom.NamedNodeMap getAttributes()
          Retrieves all attributes of the current document This will always return null since the document itself has not attributes
 org.w3c.dom.NodeList getChildNodes()
          Retrieves all child nodes of the current element
 org.w3c.dom.DocumentType getDoctype()
          Returns null as document type - beans to not define a specific document type
 org.w3c.dom.Element getDocumentElement()
          Returns the bean documents root element
 org.w3c.dom.Element getElementById(java.lang.String id)
          Tries to retrieve the element with the given ID - this feature is not implemented!
 org.w3c.dom.NodeList getElementsByTagName(java.lang.String name)
          NOTE: This functionality is not implemented since it could lead to infinite crawls.
 org.w3c.dom.NodeList getElementsByTagNameNS(java.lang.String namespace, java.lang.String name)
          NOTE: This functionality is not implemented since it could lead to infinite crawls.
 org.w3c.dom.Node getFirstChild()
          Returns the first child of the document - which matches the root element
 org.w3c.dom.DOMImplementation getImplementation()
          NOTE: This function is not implemented and therefore will just throw an exception!
 org.w3c.dom.Node getLastChild()
          Returns the last child of the document - which matches the root element
 java.lang.String getLocalName()
          Retrieves the local name - since Document has no name, will always return null
 org.w3c.dom.Node getNextSibling()
          Retrieves the next sibling - since Document itself has no siblings, will always return null
 java.lang.String getNodeName()
          Returns the name of the Document node, always the fixed "#document" value
 short getNodeType()
          Returns node type of this instance
 java.lang.String getNodeValue()
          Retrieves the node value - since Document itself has no value, will always return null
 org.w3c.dom.Document getOwnerDocument()
          Retrieves the owner document - since Document itself is a document, will always return null
 org.w3c.dom.Node getParentNode()
          Retrieves the parent node - since Document has no parent, will always return null
 org.w3c.dom.Node getPreviousSibling()
          Retrieves the previous sibling - since Document itself has no siblings, will always return null
 boolean hasAttributes()
          Boolean value if the document has attributes
 boolean hasChildNodes()
          Boolean value if the document has child nodes
 org.w3c.dom.Node importNode(org.w3c.dom.Node node, boolean recursive)
          NOTE: This function is not implemented and therefore will just throw an exception!
 
Methods inherited from class net.beandocument.BeanBaseNode
appendChild, cloneNode, getElementFactory, getNamespaceURI, getPrefix, insertBefore, isSupported, normalize, removeChild, replaceChild, setNextSibling, setNodeValue, setPrefix, setPreviousSibling
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.w3c.dom.Node
appendChild, cloneNode, getNamespaceURI, getPrefix, insertBefore, isSupported, normalize, removeChild, replaceChild, setNodeValue, setPrefix
 

Field Detail

elementFactory

protected final BeanElementFactory elementFactory
Element factory to use for creating new child nodes

Constructor Detail

BeanDocument

protected BeanDocument(BeanElementFactory elementFactory,
                       java.lang.Object bean)
Creates a new document based on the given bean

Parameters:
elementFactory - Element factory to use for all child elements
bean - Java bean to create the document instance from
Method Detail

createAttribute

public org.w3c.dom.Attr createAttribute(java.lang.String name)
                                 throws org.w3c.dom.DOMException
NOTE: This function is not implemented and therefore will just throw an exception!

Specified by:
createAttribute in interface org.w3c.dom.Document
Parameters:
name - Name of the attribute to create - ignored by this implementation
Returns:
(This function will never return normally)
Throws:
org.w3c.dom.DOMException - If method is called
See Also:
Document.createAttribute(java.lang.String)

createAttributeNS

public org.w3c.dom.Attr createAttributeNS(java.lang.String namespace,
                                          java.lang.String name)
                                   throws org.w3c.dom.DOMException
NOTE: This function is not implemented and therefore will just throw an exception!

Specified by:
createAttributeNS in interface org.w3c.dom.Document
Parameters:
namespace - Namespace for the attribute to create - ignored by this implementation
name - Name of the attribute to create - ignored by this implementation
Returns:
(This function will never return normally)
Throws:
org.w3c.dom.DOMException - If method is called
See Also:
Document.createAttributeNS(java.lang.String, java.lang.String)

createCDATASection

public org.w3c.dom.CDATASection createCDATASection(java.lang.String content)
                                            throws org.w3c.dom.DOMException
NOTE: This function is not implemented and therefore will just throw an exception!

Specified by:
createCDATASection in interface org.w3c.dom.Document
Parameters:
content - New content of the CDATA section which should be created - ignored by this implementation
Returns:
(This function will never return normally)
Throws:
org.w3c.dom.DOMException - If method is called
See Also:
Document.createCDATASection(java.lang.String)

createComment

public org.w3c.dom.Comment createComment(java.lang.String content)
NOTE: This function is not implemented and therefore will just throw an exception!

Specified by:
createComment in interface org.w3c.dom.Document
Parameters:
content - New content of the comment section which should be created - ignored by this implementation
Returns:
(This function will never return normally)
Throws:
java.lang.IllegalArgumentException - If the method is called
See Also:
Document.createComment(java.lang.String)

createDocumentFragment

public org.w3c.dom.DocumentFragment createDocumentFragment()
Creates a new document fragment

Specified by:
createDocumentFragment in interface org.w3c.dom.Document
Returns:
new document fragment instance
See Also:
Document.createDocumentFragment()

createElement

public org.w3c.dom.Element createElement(java.lang.String name)
                                  throws org.w3c.dom.DOMException
NOTE: This function is not implemented and therefore will just throw an exception!

Specified by:
createElement in interface org.w3c.dom.Document
Parameters:
name - New element name which should be created - ignored by this implementation
Returns:
(This function will never return normally)
Throws:
org.w3c.dom.DOMException - If method is called
See Also:
Document.createElement(java.lang.String)

createElementNS

public org.w3c.dom.Element createElementNS(java.lang.String namespace,
                                           java.lang.String name)
                                    throws org.w3c.dom.DOMException
NOTE: This function is not implemented and therefore will just throw an exception!

Specified by:
createElementNS in interface org.w3c.dom.Document
Parameters:
namespace - Namespace for the element to create - ignored by this implementation
name - New element name which should be created - ignored by this implementation
Returns:
(This function will never return normally)
Throws:
org.w3c.dom.DOMException - If method is called
See Also:
Document.createElementNS(java.lang.String, java.lang.String)

createEntityReference

public org.w3c.dom.EntityReference createEntityReference(java.lang.String name)
                                                  throws org.w3c.dom.DOMException
NOTE: This function is not implemented and therefore will just throw an exception!

Specified by:
createEntityReference in interface org.w3c.dom.Document
Parameters:
name - New entity reference name which should be created - ignored by this implementation
Returns:
(This function will never return normally)
Throws:
org.w3c.dom.DOMException - If method is called
See Also:
Document.createEntityReference(java.lang.String)

createProcessingInstruction

public org.w3c.dom.ProcessingInstruction createProcessingInstruction(java.lang.String target,
                                                                     java.lang.String data)
                                                              throws org.w3c.dom.DOMException
NOTE: This function is not implemented and therefore will just throw an exception!

Specified by:
createProcessingInstruction in interface org.w3c.dom.Document
Parameters:
target - New processing instruction target - ignored by this implementation
data - Data for processing instruction - ignored by this implementation
Returns:
(This function will never return normally)
Throws:
org.w3c.dom.DOMException - If method is called
See Also:
Document.createProcessingInstruction(java.lang.String, java.lang.String)

createTextNode

public org.w3c.dom.Text createTextNode(java.lang.String text)
NOTE: This function is not implemented and therefore will just throw an exception!

Specified by:
createTextNode in interface org.w3c.dom.Document
Parameters:
text - New text to use for node - ignored by this implementation
Returns:
(This function will never return normally)
Throws:
java.lang.IllegalArgumentException - If the method is called
See Also:
Document.createTextNode(java.lang.String)

getAttributes

public org.w3c.dom.NamedNodeMap getAttributes()
Retrieves all attributes of the current document This will always return null since the document itself has not attributes

Specified by:
getAttributes in interface org.w3c.dom.Node
Returns:
null value
See Also:
Node.getAttributes()

getChildNodes

public org.w3c.dom.NodeList getChildNodes()
Retrieves all child nodes of the current element

Specified by:
getChildNodes in interface org.w3c.dom.Node
Returns:
List of all child nodes
See Also:
Node.getChildNodes()

getDoctype

public org.w3c.dom.DocumentType getDoctype()
Returns null as document type - beans to not define a specific document type

Specified by:
getDoctype in interface org.w3c.dom.Document
Returns:
null value
See Also:
Document.getDoctype()

getDocumentElement

public org.w3c.dom.Element getDocumentElement()
Returns the bean documents root element

Specified by:
getDocumentElement in interface org.w3c.dom.Document
Returns:
root element of this document
See Also:
Document.getDocumentElement()

getElementById

public org.w3c.dom.Element getElementById(java.lang.String id)
Tries to retrieve the element with the given ID - this feature is not implemented!

Specified by:
getElementById in interface org.w3c.dom.Document
Parameters:
id - ID to search for in the given document
Returns:
Always null, since this method is not implemented
See Also:
Document.getElementById(java.lang.String)

getElementsByTagName

public org.w3c.dom.NodeList getElementsByTagName(java.lang.String name)
NOTE: This functionality is not implemented since it could lead to infinite crawls. Calls to this method will always return a empty list!

Specified by:
getElementsByTagName in interface org.w3c.dom.Document
Parameters:
name - Tag name to search for in the document
Returns:
Empty NodeList implementation
See Also:
Document.getElementsByTagName(java.lang.String)

getElementsByTagNameNS

public org.w3c.dom.NodeList getElementsByTagNameNS(java.lang.String namespace,
                                                   java.lang.String name)
NOTE: This functionality is not implemented since it could lead to infinite crawls. Calls to this method will always return a empty list!

Specified by:
getElementsByTagNameNS in interface org.w3c.dom.Document
Parameters:
namespace - Namespace to search for in the document
name - Tag name to search for in the document
Returns:
Empty NodeList implementation
See Also:
Document.getElementsByTagNameNS(java.lang.String, java.lang.String)

getFirstChild

public org.w3c.dom.Node getFirstChild()
Returns the first child of the document - which matches the root element

Specified by:
getFirstChild in interface org.w3c.dom.Node
Returns:
First child of the document
See Also:
Node.getFirstChild()

getImplementation

public org.w3c.dom.DOMImplementation getImplementation()
NOTE: This function is not implemented and therefore will just throw an exception!

Specified by:
getImplementation in interface org.w3c.dom.Document
Returns:
(This function will never return normally)
Throws:
java.lang.IllegalArgumentException - If the method is called
See Also:
Document.getImplementation()

getLastChild

public org.w3c.dom.Node getLastChild()
Returns the last child of the document - which matches the root element

Specified by:
getLastChild in interface org.w3c.dom.Node
Returns:
Last child of the document
See Also:
Node.getLastChild()

getLocalName

public java.lang.String getLocalName()
Retrieves the local name - since Document has no name, will always return null

Specified by:
getLocalName in interface org.w3c.dom.Node
Returns:
null value
See Also:
Node.getLocalName()

getNextSibling

public org.w3c.dom.Node getNextSibling()
Retrieves the next sibling - since Document itself has no siblings, will always return null

Specified by:
getNextSibling in interface org.w3c.dom.Node
Overrides:
getNextSibling in class BeanBaseNode
Returns:
null value
See Also:
Node.getNextSibling()

getNodeName

public java.lang.String getNodeName()
Returns the name of the Document node, always the fixed "#document" value

Specified by:
getNodeName in interface org.w3c.dom.Node
Returns:
String "#document"
See Also:
Node.getNodeName()

getNodeType

public short getNodeType()
Returns node type of this instance

Specified by:
getNodeType in interface org.w3c.dom.Node
Returns:
Node type constant from Node.DOCUMENT_NODE
See Also:
Node.getNodeType()

getNodeValue

public java.lang.String getNodeValue()
                              throws org.w3c.dom.DOMException
Retrieves the node value - since Document itself has no value, will always return null

Specified by:
getNodeValue in interface org.w3c.dom.Node
Returns:
null value
Throws:
org.w3c.dom.DOMException - (Not really, just returns null)
See Also:
Node.getNodeValue()

getOwnerDocument

public org.w3c.dom.Document getOwnerDocument()
Retrieves the owner document - since Document itself is a document, will always return null

Specified by:
getOwnerDocument in interface org.w3c.dom.Node
Overrides:
getOwnerDocument in class BeanBaseNode
Returns:
null value
See Also:
Node.getOwnerDocument()

getParentNode

public org.w3c.dom.Node getParentNode()
Retrieves the parent node - since Document has no parent, will always return null

Specified by:
getParentNode in interface org.w3c.dom.Node
Overrides:
getParentNode in class BeanBaseNode
Returns:
null value
See Also:
Node.getParentNode()

getPreviousSibling

public org.w3c.dom.Node getPreviousSibling()
Retrieves the previous sibling - since Document itself has no siblings, will always return null

Specified by:
getPreviousSibling in interface org.w3c.dom.Node
Overrides:
getPreviousSibling in class BeanBaseNode
Returns:
null value
See Also:
Node.getPreviousSibling()

hasAttributes

public boolean hasAttributes()
Boolean value if the document has attributes

Specified by:
hasAttributes in interface org.w3c.dom.Node
Returns:
Always false - since a document has no attributes
See Also:
Node.hasAttributes()

hasChildNodes

public boolean hasChildNodes()
Boolean value if the document has child nodes

Specified by:
hasChildNodes in interface org.w3c.dom.Node
Returns:
Flag depending on bean context
See Also:
Node.hasChildNodes()

importNode

public org.w3c.dom.Node importNode(org.w3c.dom.Node node,
                                   boolean recursive)
                            throws org.w3c.dom.DOMException
NOTE: This function is not implemented and therefore will just throw an exception!

Specified by:
importNode in interface org.w3c.dom.Document
Parameters:
node - Node to import - ignored by this implementation
recursive - flag if the node should be imported recursively - ignored by this implementation
Returns:
(This function will never return normally)
Throws:
org.w3c.dom.DOMException - If method is called
See Also:
Document.importNode(org.w3c.dom.Node, boolean)