JXTA

net.jxta.impl.document
Class DOMXMLDocument

java.lang.Object
  extended by net.jxta.impl.document.DOMXMLElement
      extended by net.jxta.impl.document.DOMXMLDocument
All Implemented Interfaces:
Attributable, Document, DocumentStreamIO, Element<DOMXMLElement>, StructuredDocument<DOMXMLElement>, StructuredTextDocument<DOMXMLElement>, TextDocument, TextDocumentReaderIO, TextElement<DOMXMLElement>, XMLDocument<DOMXMLElement>, XMLElement<DOMXMLElement>

public class DOMXMLDocument
extends DOMXMLElement
implements XMLDocument<DOMXMLElement>

This class is an implementation of the StructuredDocument interface using DOM

See Also:
W3C Document Object Model (DOM), DOM Java Language Binding, Document Object Model (DOM) Level 3 Load and Save Specification, Java API for XML Processing (JAXP), org.w3c.dom

Field Summary
static StructuredDocumentFactory.TextInstantiator INSTANTIATOR
           
 
Fields inherited from class net.jxta.impl.document.DOMXMLElement
domNode, root
 
Method Summary
 DOMXMLElement createElement(Object key)
          Create a new element without value.
 DOMXMLElement createElement(Object key, Object val)
          Create a new element with value.
 DOMXMLElement createElement(String name)
          Create a new element without value.
 DOMXMLElement createElement(String name, String value)
          Create a new element with value.
protected  Node getAssocNode()
          Returns the DOM Node associated with this StructuredDocument element.
 String getFileExtension()
          Returns the file extension type used by this Document.
 MimeMediaType getMimeType()
          Returns the MIME Media type of this Document per IETF RFC 2046 MIME : Media Types.
 Reader getReader()
          Returns the sequence of characters which represents the content of the TextDocument.
 InputStream getStream()
          Returns the stream of bytes which represents the content of this Document.
 void sendToStream(OutputStream stream)
          Send the contents of this Document to the specified stream.
 void sendToWriter(Writer writer)
          Send the contents of this TextDocument to the specified Writer.
 String toString()
          
 
Methods inherited from class net.jxta.impl.document.DOMXMLElement
addAttribute, addAttribute, appendChild, equals, getAttribute, getAttributes, getChildren, getChildren, getChildren, getKey, getName, getParent, getRoot, getTextValue, getValue
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface net.jxta.document.XMLElement
getRoot
 
Methods inherited from interface net.jxta.document.Attributable
addAttribute, addAttribute, getAttribute, getAttributes
 
Methods inherited from interface net.jxta.document.TextElement
getChildren, getKey, getName, getTextValue, getValue
 
Methods inherited from interface net.jxta.document.Element
appendChild, getChildren, getChildren, getParent
 

Field Detail

INSTANTIATOR

public static final StructuredDocumentFactory.TextInstantiator INSTANTIATOR
Method Detail

toString

public String toString()

Overrides:
toString in class Object

getMimeType

public MimeMediaType getMimeType()
Returns the MIME Media type of this Document per IETF RFC 2046 MIME : Media Types.

JXTA does not currently support the 'Multipart' or 'Message' media types.

Specified by:
getMimeType in interface Document
Returns:
The MIME Media Type for this Document.

getFileExtension

public String getFileExtension()
Returns the file extension type used by this Document. This value is usually chosen based upon the MIME Media Type.

Specified by:
getFileExtension in interface Document
Returns:
An appropriate file extension for this Document.

getStream

public InputStream getStream()
                      throws IOException
Returns the stream of bytes which represents the content of this Document.

Specified by:
getStream in interface DocumentStreamIO
Returns:
An InputStream containing the bytes of this Document.
Throws:
IOException - For errors while writing the Document.

sendToStream

public void sendToStream(OutputStream stream)
                  throws IOException
Send the contents of this Document to the specified stream.

Specified by:
sendToStream in interface DocumentStreamIO
Parameters:
stream - The OutputStream to which the Document will be written.
Throws:
IOException - For errors while writing the Document.

getReader

public Reader getReader()
Returns the sequence of characters which represents the content of the TextDocument.

Specified by:
getReader in interface TextDocumentReaderIO
Returns:
An Reader containing the characters of the TextDocument.

sendToWriter

public void sendToWriter(Writer writer)
                  throws IOException
Send the contents of this TextDocument to the specified Writer.

Specified by:
sendToWriter in interface TextDocumentReaderIO
Parameters:
writer - The Writer to which the characters of the TextDocument will be written.
Throws:
IOException - If an I/O error occurs.

createElement

public DOMXMLElement createElement(Object key)
Create a new element without value.

Specified by:
createElement in interface StructuredDocument<DOMXMLElement>
Parameters:
key - The key of the element to be created.
Returns:
The new element.

createElement

public DOMXMLElement createElement(Object key,
                                   Object val)
Create a new element with value.

Specified by:
createElement in interface StructuredDocument<DOMXMLElement>
Parameters:
key - The name of the element to be created.
val - The value of the element to be created or null if no value is desired.
Returns:
The new element.

createElement

public DOMXMLElement createElement(String name)
Create a new element without value.

Specified by:
createElement in interface StructuredTextDocument<DOMXMLElement>
Specified by:
createElement in interface XMLDocument<DOMXMLElement>
Parameters:
name - The name of the element to be created.
Returns:
The new element.

createElement

public DOMXMLElement createElement(String name,
                                   String value)
Create a new element with value.

Specified by:
createElement in interface StructuredTextDocument<DOMXMLElement>
Specified by:
createElement in interface XMLDocument<DOMXMLElement>
Parameters:
name - The name of the element to be created.
value - The value of the element to be created.
Returns:
The new element.

getAssocNode

protected Node getAssocNode()
Description copied from class: DOMXMLElement
Returns the DOM Node associated with this StructuredDocument element.

Overrides:
getAssocNode in class DOMXMLElement
Returns:
Node The DOM Node associated with this StructuredDocument element.

JXSE