Package com.adobe.xfa

Class Document

  • All Implemented Interfaces:
    Peer

    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.

    • Field Detail

      • Encoding

        public static final java.lang.String Encoding
        XFA always encodes Documents as UTF-8 when serializing.
        See Also:
        Constant Field Values
      • MarkupAttrMiddle

        public static final byte[] MarkupAttrMiddle
      • MarkupAttrMiddleQuote

        public static final byte[] MarkupAttrMiddleQuote
      • MarkupDQuoteString

        public static final byte[] MarkupDQuoteString
      • MarkupQuoteString

        public static final byte[] MarkupQuoteString
      • MarkupCDATAStart

        public static final byte[] MarkupCDATAStart
      • MarkupCDATAEnd

        public static final byte[] MarkupCDATAEnd
      • MarkupCloseTag

        public static final byte[] MarkupCloseTag
      • MarkupDocType

        public static final byte[] MarkupDocType
      • MarkupEndEntity

        public static final byte[] MarkupEndEntity
      • MarkupEndParen2

        public static final byte[] MarkupEndParen2
      • MarkupEndTag

        public static final byte[] MarkupEndTag
      • MarkupEntity

        public static final byte[] MarkupEntity
      • MarkupPIStart

        public static final byte[] MarkupPIStart
      • MarkupPIEnd

        public static final byte[] MarkupPIEnd
      • MarkupReturn

        public static final byte[] MarkupReturn
      • MarkupSpace

        public static final byte[] MarkupSpace
      • MarkupStartParen

        public static final byte[] MarkupStartParen
      • MarkupStartTag

        public static final byte[] MarkupStartTag
      • MarkupSystem

        public static final byte[] MarkupSystem
    • Constructor Detail

      • Document

        public Document​(AppModel appModel)
        Instantiates a document node with the given app model.
        Parameters:
        appModel - an AppModel
    • Method Detail

      • createDocument

        public static Document createDocument​(AppModel appModel)
        Creates a new Document that is separate from any default Document associated with the app model.
        Parameters:
        appModel - an AppModel
        Returns:
        a new Document
      • autoUniquifyIDs

        public final boolean autoUniquifyIDs()
      • autoUniquifyIDs

        public final void autoUniquifyIDs​(boolean bAutoUniquifyIDs)
      • uniquifyIDsOnParse

        public final boolean uniquifyIDsOnParse()
      • uniquifyIDsOnParse

        public final void uniquifyIDsOnParse​(boolean bUniquifyIDsOnParse)
      • clearIdMap

        public final void clearIdMap()
        Clears all elements from the ID look up table.
      • getElementByXMLId

        public final Element getElementByXMLId​(java.lang.String idValue)
      • getElementByXFAId

        public final Element getElementByXFAId​(java.lang.String aNameSpaceURI,
                                               java.lang.String aIdValue)
      • getElementByPKey

        public final Element getElementByPKey​(Key key)
        Returns an element specified by its primary key.
        Parameters:
        key - The primary key value to search on. Often constructed with the use of Element.constructKey.
      • declareXMLId

        public final void declareXMLId​(java.lang.String aElementNameSpaceURI,
                                       java.lang.String aElementName,
                                       java.lang.String aIdAttributeName)
      • declareGlobalXMLId

        public final void declareGlobalXMLId​(java.lang.String aIdAttrNameSpaceURI,
                                             java.lang.String aIdAttrName)
      • declareXFAId

        public final void declareXFAId​(java.lang.String aNameSpaceURI,
                                       java.lang.String aIdAttributeName)
      • declarePKey

        public final void declarePKey​(java.lang.String aElementNameSpaceURI,
                                      java.lang.String aElementName,
                                      java.lang.String aPKeyNodeAddressList,
                                      Element namespaceContextNode)
        Defines a primary key on an element.
        Parameters:
        aElementNameSpaceURI - The element's namespace URI
        aElementName - The element's local name
        aPKeyNodeAddressList - A comma separated list of XPaths which identify the nodes to be used as primary key for this element
      • isId

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

        public final Node cloneNode​(boolean bDeep)
      • createElementNS

        public final Element createElementNS​(java.lang.String sNameSpaceURI,
                                             java.lang.String sQualifiedName,
                                             Element parent)
      • getFirstXMLChild

        public Node getFirstXMLChild()
        Description copied from class: Element
        Gets this element's first XML child.
        Overrides:
        getFirstXMLChild in class Element
        Returns:
        the first XML child.
      • getAppModel

        public AppModel getAppModel()
        Gets this document's app model.
        Overrides:
        getAppModel in class Element
        Returns:
        the app model.
      • getDocumentElement

        public final Element getDocumentElement()
        Gets this document's first element.
        Returns:
        the first element.
      • getGenerator

        public Generator getGenerator()
      • 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".
      • getParseFile

        public java.net.URL getParseFile()
        Gets an absolute URL that represents the source of the document, or null if the source is unknown.
      • getParseFileName

        public java.lang.String getParseFileName()
        Gets the parse file name for reporting purposes. For backwards compatibility, URL prefix is removed
      • getWillDirty

        public boolean getWillDirty()
        Indicates whether changes should cause the namespace dirty flag to be set on changes within this document.
        Overrides:
        getWillDirty in class Node
        Returns:
        true if changes should cause the namespace dirty flag to be set.
      • getSaveChecker

        public final com.adobe.xfa.SaveNameSpaceChecker getSaveChecker()
      • isDefaultDocument

        public final boolean isDefaultDocument()
      • isDefaultDocument

        public final void isDefaultDocument​(boolean bIsDefault)
      • 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.
      • indexSubtree

        public final void indexSubtree​(Element source,
                                       boolean bInDocumentCheckCompleted)
      • deindexSubtree

        public final void deindexSubtree​(Element source,
                                         boolean bInDocumentCheckCompleted)
      • idValueInUse

        public final boolean idValueInUse​(java.lang.String idValue)
        Indicates whether or not an ID value is currently in use in the document. It is not ID-type-specific; it will check all XFA IDs, XML IDs, etc.
        Parameters:
        idValue - the ID in question
        Returns:
        true if the ID value is currently used in the document
      • isIncrementalLoad

        public final boolean isIncrementalLoad()
      • 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.
      • loadIntoDocument

        public final Element loadIntoDocument​(java.io.InputStream is)
        This method loads an XML file into a unattached branch of the current document it is up to the class user to attach this branch to the current document
      • loadToNextElement

        public final Element loadToNextElement​(IntegerHolder depth)
        Retrieves an element from the DOM, using lazy loading. When using lazy loading, no XSL processing is available.
        Parameters:
        depth - optional parameter which returns the depth of the returned element in the DOM tree being constructed.
      • savePreamble

        public final void savePreamble​(java.io.OutputStream os,
                                       DOMSaveOptions options)
      • preSave

        public void preSave()
      • saveXML

        @Deprecated
        public final void saveXML​(java.io.OutputStream os,
                                  DOMSaveOptions options)
        Deprecated.
        Serializes this document (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.

        Overrides:
        saveXML in class Element
        Parameters:
        os - an output stream.
        options - the XML save options
      • 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
      • serialize

        public void serialize​(java.io.OutputStream outFile,
                              DOMSaveOptions options,
                              int level,
                              Node prevSibling)
                       throws java.io.IOException
        Deprecated.
        Description copied from class: Node
        The helper function used by saveXML()
        Overrides:
        serialize in class Element
        Parameters:
        outFile - Streamfile to write to
        options - save options
        level - the indent level
        prevSibling - our previous sibling -- needed for some markup options.
        Throws:
        java.io.IOException
        See Also:
        Node.serialize(OutputStream, DOMSaveOptions, int, Node)
      • setContext

        public final void setContext​(Model model,
                                     Element parent,
                                     boolean bIgnoreAggregating)
        Sets this document's context for loading so that we can import XML into an existing DOM.
        Parameters:
        model - the model we're loading this data into.
        parent - the parent element to load the XML under.
        bIgnoreAggregating - indicates whether we're to load the aggregating element or only its children.
      • setParseFileName

        public final void setParseFileName​(java.lang.String source)
      • setWillDirty

        public void setWillDirty​(boolean bWillDirty)
        Sets the flag that indicates whether changes within this document should cause the namespace dirty check flag to be set.
        Overrides:
        setWillDirty in class Node
        Parameters:
        bWillDirty - true if changes within this document should cause the namespace dirty check flag to be set.