XFA4J

com.adobe.xfa
Class Document

java.lang.Object
  extended by com.adobe.xfa.Obj
      extended by com.adobe.xfa.Node
          extended by com.adobe.xfa.Element
              extended by com.adobe.xfa.Document

public class Document
extends Element

A container class to hold the XML document node of the DOM.

Conceptually, a DOM document node is the root of the document tree, and provides the primary access to the document's data.

Since elements, text nodes, comments, processing instructions, etc. cannot exist outside the context of a document, the Document interface also contains the factory methods needed to create these objects. Each Node objects created have an ownerDocument attribute which associates them with the Document in which they were created.


Nested Class Summary
 
Nested classes/interfaces inherited from class com.adobe.xfa.Node
Node.ChangeLogger
 
Field Summary
 
Fields inherited from class com.adobe.xfa.Node
CREATE_ALWAYS_NEW, CREATE_IF_NOT_EXIST, CREATE_MUST_NOT_EXIST, CREATE_REPLACE
 
Constructor Summary
Document(AppModel appModel)
          Instantiates a document node with the given app model.
 
Method Summary
 AppModel getAppModel()
          Gets this document's app model.
 java.lang.String getName()
          Gets this document's name.
 boolean hasChanged()
          Determines if this document has changed since being last loaded.
 Node importNode(Node source, boolean bDeep)
          Imports a copy of a Node from another document into this document.
 boolean isId(java.lang.String aElementNameSpaceURI, java.lang.String aElementName, java.lang.String aAttrNameSpaceURI, java.lang.String aAttrLocalName)
           
 void load(java.io.File file)
          Loads a document from a file.
 void load(java.io.InputStream is, java.lang.String encoding, boolean parseExternalDTD)
          Loads a document from an input stream.
 void load(java.io.InputStream is, java.lang.String source, java.lang.String encoding, boolean parseExternalDTD)
          Loads a document from an input stream.
 void saveAs(java.io.OutputStream os, Node startNode, DOMSaveOptions options)
          Serializes the given starting node (and all its children) to an output stream.
 
Methods inherited from class com.adobe.xfa.Element
appendChild, assignNode, getAttr, getAttribute, getElement, getFirstXFAChild, getFirstXMLChild, getInstalledLocale, getLastXMLChild, getModel, getNodes, getNS, getNumAttrs, getPrefix, getText, getXFAChild, getXMLChild, isInstalledLocaleAmbient, loadXML, saveXML, setAttribute, setAttribute, setAttribute, setLocalName, setName, setNS, setQName
 
Methods inherited from class com.adobe.xfa.Node
checkAncestorPerms, checkDescendentPerms, checkPerms, cleanDirtyFlags, compareVersions, getData, getDynamicScriptProp, getNextXFASibling, getNextXMLSibling, getOwnerDocument, getPreviousXMLSibling, getSOMExpression, getXFAChildCount, getXFAParent, getXMLChildCount, getXMLParent, hasChanged, remove, resolveNode, resolveNode, resolveNodes, setNextXMLSibling, setPermsLock, setXMLParent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Document

public Document(AppModel appModel)
Instantiates a document node with the given app model.

Parameters:
appModel - an AppModel
Method Detail

isId

public final boolean isId(java.lang.String aElementNameSpaceURI,
                          java.lang.String aElementName,
                          java.lang.String aAttrNameSpaceURI,
                          java.lang.String aAttrLocalName)

getAppModel

public AppModel getAppModel()
Gets this document's app model.

Overrides:
getAppModel in class Element
Returns:
the app model.

getName

public java.lang.String getName()
Gets this document's name.

Overrides:
getName in class Element
Returns:
the document name which is the constant value "#document".

importNode

public final Node importNode(Node source,
                             boolean bDeep)
Imports a copy of a Node from another document into this document. The source node, which may belong to a different document, is copied, with the copy belonging to this document. The copy is not placed into the document (the parent node is null).

Parameters:
source - the node (subtree) to be copied
bDeep - if true, recursively import the subtree under the specified node; if false, import only the node itself (and its attributes, if if is an Element
Returns:
the newly created copy of the source node, belonging to this document

hasChanged

public final boolean hasChanged()
Determines if this document has changed since being last loaded.

Returns:
the document state.

load

public final void load(java.io.InputStream is,
                       java.lang.String encoding,
                       boolean parseExternalDTD)
Loads a document from an input stream.

This overload should only be used in the case where the source is not known, or is not relevant (e.g., loading from an in-memory stream).

Parameters:
is - an input stream.
encoding - the input stream's encoding if known. If null, the encoding is detected automatically.
parseExternalDTD - parse any external DTD when true.
Throws:
ExFull - exceptions upon parse errors.

load

public final void load(java.io.File file)
Loads a document from a file. The lead bytes of the file are read to determine its encoding.

Parameters:
file - an input file.
Throws:
ExFull - exceptions upon parse errors.

load

public final void load(java.io.InputStream is,
                       java.lang.String source,
                       java.lang.String encoding,
                       boolean parseExternalDTD)
Loads a document from an input stream.

Parameters:
is - an input stream.
source - the source location, formatted as a file or URL.
encoding - the input stream's encoding if known. If null, the encoding is detected automatically.
parseExternalDTD - parse any external DTD when true.
Throws:
ExFull - exceptions upon parse errors.

saveAs

public final void saveAs(java.io.OutputStream os,
                         Node startNode,
                         DOMSaveOptions options)
Serializes the given starting node (and all its children) to an output stream.

This method does not perform any maintenance (e.g., namespace normalization) on any models contained within the document before saving.

Parameters:
os - an output stream.
startNode - the starting node.
options - the XML save options

XFA4J

© 2005 Adobe Systems Incorporated. All Rights Reserved.