Package com.adobe.xfa

Class AppModel

  • All Implemented Interfaces:
    Element.DualDomNode, Model.DualDomModel, Peer

    public final class AppModel
    extends Model
    implements Model.DualDomModel
    A class to represent the top level element in the XFA object model. All application-specific models are represented as sub-models of this one.
    Example:
     xfa <- this is the AppModel
       datasets <- this is the XFADataModel
         data <- this is $data in SOM expressions (a datagroup)
    • Constructor Detail

      • AppModel

        public AppModel​(LogMessenger messenger)
        Instantiates an app model with the given messenger.
        Parameters:
        messenger - a log messenger, if any.
    • Method Detail

      • includePacket

        public static boolean includePacket​(java.lang.String aPacketName,
                                            java.lang.String sInList)
        Determines if a packet should be included based on a packet list.
        Parameters:
        aPacketName - the packet to test for
        sInList - the list of packets
        Returns:
        boolean -- in or out.
      • addFactory

        public void addFactory​(ModelFactory factory)
        Adds a model factory to the list of registered factories.

        Factories are added for models that are to be loaded with a full implementation. If no model is explicitly added, a default model with minimal functionality will be used.

        Parameters:
        factory - the factory to add.
      • addPseudoModel

        public void addPseudoModel​(java.lang.String sShortCutName,
                                   Obj obj)
        Makes an object visible to the global scripting namespace. The obj parameter will typically be derived from PseudoModel. The shortcut name must start with a dollar sign ($).

        For example, an application might use this method to add an object derived from HostPseudoModel and register it with the name $host.

        Parameters:
        sShortCutName - the name of the scripting object.
        obj - the scriptable object
        See Also:
        removePseudoModel(String)
      • addScriptHandler

        public void addScriptHandler​(ScriptHandler handler)
        Adds (registers) a script handler for this app model. Script handlers are added to provide scripting support for various languages.
        Parameters:
        handler - the script handler to add.
      • clearScriptingContexts

        public void clearScriptingContexts()
        Clears any scripting contexts associated with all script handlers previously registered with this app model.
        See Also:
        addScriptHandler(ScriptHandler)
      • bumpVersionOnRichTextLoad

        public boolean bumpVersionOnRichTextLoad()
        Gets a boolean which indicates whether the XFA version should be bumped when loading rich text containing features not supported by the form's current version. This is false by default. Only Designer is expected to make use of this flag.
        Returns:
        true if version bumping is enabled for rich text loading.
      • bumpVersionOnRichTextLoad

        public void bumpVersionOnRichTextLoad​(boolean bBumpVersion)
        Sets a boolean which indicates whether the XFA version should be bumped when loading rich text containing features not supported by the form's current version. This is false by default. Only Designer is expected to make use of this flag
        Parameters:
        bBumpVersion - true to enable version bumping when loading rich text.
      • appendChild

        public void appendChild​(Node newChild,
                                boolean bValidate)
        Description copied from class: Element
        Appends the given child to this element.
        Overrides:
        appendChild in class Element
        Parameters:
        newChild - the child node being appended.
        bValidate - when true, ensures the given child is valid per the model's schema and throws an ExFull if not.
        See Also:
        Element.appendChild(Node, boolean)
      • createNode

        public Node createNode​(int eTag,
                               Element parent,
                               java.lang.String aName,
                               java.lang.String aNS,
                               boolean bDoVersionCheck)
        Description copied from class: Model
        Create an element with the given tag, parent, name and uri.
        Specified by:
        createNode in class Model
        Parameters:
        eTag - the element's tag.
        parent - the element's parent.
        aName - the element's name.
        aNS - the element's namespace.
        bDoVersionCheck - check the element's version.
        Returns:
        a new element.
        See Also:
        Model.createNode(int, Element, String, String, boolean)
      • createElement

        public Element createElement​(Element parent,
                                     Node prevSibling,
                                     java.lang.String uri,
                                     java.lang.String localName,
                                     java.lang.String qName,
                                     org.xml.sax.Attributes attributes,
                                     int lineNumber,
                                     java.lang.String fileName)
        Description copied from class: Model
        Creates an element with the given parent, sibling, namespace uri, local name and SAX attributes.
        Overrides:
        createElement in class Model
        Parameters:
        parent - the element's parent, if any.
        prevSibling - the element's previous sibling, if any.
        uri - the element's namespace. This string must be interned.
        localName - the element's name. This string must be interned.
        qName - the element's qualified name. This string must be interned.
        attributes - the element's (SAX) attribute definitions.
        Returns:
        a new element conformant to our schema.
        See Also:
        Model.createElement(Element, Node, String, String, String, Attributes, int, String)
      • dependencyTracker

        public void dependencyTracker​(DependencyTracker oDependencyTracker)
      • getAllowThirdPartyXml

        public boolean getAllowThirdPartyXml()
      • factories

        public java.util.List<ModelFactory> factories()
        Returns the list of registered factories.
        Returns:
        a list of Model factories.
      • getAttribute

        public Attribute getAttribute​(int eAttributeTag)
        get an attribute value, will return the default attribute value if none exist NON validating
        Overrides:
        getAttribute in class Element
      • getBaseNS

        public java.lang.String getBaseNS()
        Specified by:
        getBaseNS in class Model
      • getDynamicScriptProp

        public ScriptDynamicPropObj getDynamicScriptProp​(java.lang.String sPropertyName,
                                                         boolean bPropertyOverride,
                                                         boolean bPeek)
      • getErrorContextList

        public java.util.List<Element> getErrorContextList()
        Gets all the context nodes that correspond to entries in the error list.
        Overrides:
        getErrorContextList in class Model
        Returns:
        A list of Element objects where the load discovered a problem.
      • getErrorList

        public java.util.List<ExFull> getErrorList()
        Gets all the errors that have been generated by this app model since the last method call to clear the error list. This involves getting the error lists for all the descendant models and concatenating them together.
        Overrides:
        getErrorList in class Model
        Returns:
        the current list of ExFull error objects.
      • getEventManager

        public EventManager getEventManager()
        the EventManager manages xfe:script scripts and their associated events (ie. events that cause the scripts to execute)
        Overrides:
        getEventManager in class Model
      • getExternalProtosAreTransient

        public boolean getExternalProtosAreTransient()
        Determines whether external proto fragments are marked as transient when they are resolved. When proto fragments are marked as transient, the DOMSaveOptions.setSaveFragment(boolean) setting controls whether resolved fragments are included when the model is serialized. The default is false which means that resolved fragments are always serialized.

        This flag is only relevant if setHrefHandler(HrefHandler) has been called.

        Returns:
        true if external fragments should be transient (i.e. left as references when serialized), or false if they should be non-transient (i.e. expanded when serialized).
        See Also:
        setExternalProtosAreTransient(boolean)
      • getFragmentSearchPath

        public java.util.List<java.lang.String> getFragmentSearchPath()
        return the fragment search path.
        Returns:
        an array of File objects
      • getHeadNS

        public java.lang.String getHeadNS()
        Specified by:
        getHeadNS in class Model
      • getHrefHandler

        public HrefHandler getHrefHandler()
        Gets the current HrefService handler.
        Returns:
        the HrefService handler associated with the AppModel.
      • getIsFragmentDoc

        public boolean getIsFragmentDoc()
        indicate whether this AppModel is used as a source for template fragments
        Returns:
        true if a fragment source
      • getLogMessenger

        public LogMessenger getLogMessenger()
        Get the XFALogMessenger object.The XFALogMessenger object can be used to add or delete to the XFALogMessageHandlers active with the AppModel.
        Overrides:
        getLogMessenger in class Model
        Returns:
        The log messenger.
      • getNS

        public java.lang.String getNS()
        Description copied from class: Element
        Gets this element's namespace.
        Overrides:
        getNS in class Model
        Returns:
        the namespace URI.
        See Also:
        Element.getNS()
      • getOutputBelow

        public int getOutputBelow()
      • getPacketList

        public java.lang.String getPacketList()
        Gets the list of XFA packets to filter.
        Returns:
        the packet list.
      • getPreviousXMLSibling

        public Node getPreviousXMLSibling()
        Description copied from class: Node
        Gets this node's previous XML sibling. Note that this may be a fairly expensive operation, as it involves iterating through the parent's children looking for this node.
        Overrides:
        getPreviousXMLSibling in class Node
        Returns:
        the previous sibling, or null, if none.
        See Also:
        Node.getPreviousXMLSibling()
      • getSchemaType

        public int getSchemaType​(int eTag)
        Overrides:
        getSchemaType in class Element
      • getScriptHandlers

        public java.util.List<ScriptHandler> getScriptHandlers()
        Gets the list of script handlers registered with this app model.
        Returns:
        the list of script handlers.
      • getVersionRestriction

        public int getVersionRestriction()
      • getWillDirty

        public boolean getWillDirty()
        Overrides:
        getWillDirty in class Node
      • insertChild

        public void insertChild​(Node newChild,
                                Node refChild,
                                boolean bValidate)
        Description copied from class: Element
        Inserts a child before a specific child in the child list.
        Overrides:
        insertChild in class Element
        Parameters:
        newChild - the child to be inserted
        refChild - the child to insert before
        bValidate - if true, validate the insertion
        See Also:
        Element.insertChild(Node, Node, boolean)
      • isValidAttr

        public boolean isValidAttr​(int eTag,
                                   boolean bReport,
                                   java.lang.String value)
        Description copied from class: Element
        Determine if a specified attribute tag is valid for this node.
        Overrides:
        isValidAttr in class Element
        Parameters:
        eTag - the XFA tag to check
        Returns:
        true if valid.
        See Also:
        Element.isValidAttr(int, boolean, String)
      • isValidChild

        public boolean isValidChild​(int eTag,
                                    int nError,
                                    boolean bBeforeInsert,
                                    boolean bOccurrenceErrorOnly)
        Overrides:
        isValidChild in class Element
        Parameters:
        eTag - the class tag of the node that will be or has been appended
        bBeforeInsert - if true, then the child has not yet been inserted into the child list of this element.
        Returns:
        true if eTag is a valid child.
        See Also:
        Element.isValidChild(int, int, boolean, boolean)
      • isXFANode

        public boolean isXFANode​(java.lang.String uri,
                                 java.lang.String localName,
                                 java.lang.String qName)
        Is this element the root node of an XDP document.
        Parameters:
        uri - the namespace of this element
        localName - the local name of this element
        qName - the qualified name of this element
        Returns:
        boolean true if this is the root node of XDP
      • isXFANode

        public static boolean isXFANode​(Element node)
        Is the given element the root node of an XDP document.
      • lookupPseudoModel

        public Obj lookupPseudoModel​(java.lang.String sShortCutName)
        Looks up a scripting object registered with the global scripting namespace.
        Parameters:
        sShortCutName - the scripting shortcut name.
        Returns:
        a scripting object (typically derived from PseudoModel), or null if not found.
      • newDOM

        public Element newDOM()
        Creates a new node hierarchy of a new XFA DOM. The returned node will always be the AppModel. The children that this node has depends on which factories have been added via addFactory(). Each installed factory will create some default node or tree of nodes under the AppModel node.
        Returns:
        The root node of the new hierarchy.
      • ready

        public boolean ready​(boolean bForced)
        Description copied from class: Model
        Indicates that the model is ready. This causes the "ready" event to be issued so that script waiting on that event will execute. When applied to an AppModel, this call recursively calls ready() on each child model (as a convenience). Some applications may choose to call the ready() on each model individually. Calling ready() a second time on a given model has no effect.
        Overrides:
        ready in class Model
        Returns:
        true if ready scripts fire
      • publish

        public boolean publish​(Model.Publisher publisher)
        Description copied from class: Model
        Publish the model to an Application Storage facility. This involves updating all external references (such as image hrefs) such that they point to local collateral. The actual details of this are left up to the implementer of the class derived from Model.Publisher specified in the oPublisher parameter. What publish() itself does is recursively traverse the tree structure of the model. When an external reference is encountered (for example, the href attribute of an image node), the updateExternalRef() method is called. The node, attribute identifier and original value of the external reference are passed to updateExternalRef(). The derived class should copy the collateral to the application storage area (if desired), and should update the value of sExternalRefValue to indicate the new value for the external reference (probably some sort of relative path). If an external reference stored as an element value (for example, a uri node) is encountered, updateExternalRef is called with node and the eAttribute arg is set to XFA.TEXTNODETAG. Two or more instances of an identical external reference result in only one call to updateExternalRef(), because returned values are cached and reused. If called on the AppModel, this method recursively calls publish on all contained models.
        Overrides:
        publish in class Model
        Parameters:
        publisher - an instance of a class derived from TemplateModel.Publisher.
        See Also:
        Model.publish(com.adobe.xfa.Model.Publisher)
      • removePseudoModel

        public void removePseudoModel​(java.lang.String sShortCutName)
        Removes a scripting object shortcut from the global scripting namespace.
        Parameters:
        sShortCutName - the shortcut name of a scripting object
        See Also:
        addPseudoModel(String, Obj)
      • setAttribute

        public void setAttribute​(Attribute oValue,
                                 int eAttributeTag)
        Sets the value of an attribute
        Overrides:
        setAttribute in class Element
        Parameters:
        oValue - the attribute.
        eAttributeTag - The XFA tag name of the attribute being set.
      • setExternalProtosAreTransient

        public void setExternalProtosAreTransient​(boolean bExternalProtosAreTransient)
        Determines whether external proto fragments are marked as transient when they are resolved. When proto fragments are marked as transient, the DOMSaveOptions.setSaveFragment(boolean) setting controls whether resolved fragments are included when the model is serialized. The default is false which means that resolved fragments are always serialized.

        This flag is only relevant if setHrefHandler(HrefHandler) has been called.

        Parameters:
        bExternalProtosAreTransient - true if external fragments should be transient (i.e. left as references when serialized), or false if they should be non-transient (i.e. expanded when serialized).
        See Also:
        getExternalProtosAreTransient(), setHrefHandler(HrefHandler)
      • setFragmentSearchPath

        public void setFragmentSearchPath​(java.util.List<java.lang.String> oSearchPath)
        Set the fragment search path.
        Parameters:
        oSearchPath - fragment search path
      • setHrefHandler

        public void setHrefHandler​(HrefHandler handler)
        Sets the HrefService handler associated with this AppModel.
        Parameters:
        handler - the HrefService handler.

        The href service handles the URL resolution and fragment loading for all usehref attribute values on ProtoableNodes.

      • setIsFragmentDoc

        public void setIsFragmentDoc​(boolean bIsFragmentDoc)
        flag this AppModel as being a source for template fragments (or not)
        Parameters:
        bIsFragmentDoc - true if this is a source for template fragments.
      • setPacketHandler

        public void setPacketHandler​(PacketHandler oPacketHandler,
                                     java.lang.Object oHandlerData)
        Sets this app model's packet handler.
        Parameters:
        oPacketHandler - a packet handler.
        oHandlerData - some handler data.
      • setPacketList

        public void setPacketList​(java.lang.String sPackets)
        Sets the list of XFA packets to filter.
        Parameters:
        sPackets - the packet list.
      • setResolveAllExternalProtos

        public void setResolveAllExternalProtos​(boolean bResolveAllExternalProtos)
      • setSourceAbove

        public void setSourceAbove​(int eSouceAbove)
      • setSourceBelow

        public void setSourceBelow​(int eSouceBelow)
      • setVersionRestriction

        public void setVersionRestriction​(int nVersion,
                                          int eOutputBelow)
      • setWillDirty

        public void setWillDirty​(boolean bWillDirty)
        Overrides:
        setWillDirty in class Node
      • updateOriginalVersion

        public boolean updateOriginalVersion()
        Get a boolean that indicates if the originalXFAVersion processing instruction should be updated when each XFA Model child is saved.
        Returns:
        TRUE if the processing instruction should be updated, otherwise FALSE. This function is only for Designer so when they create a new document they can avoid creating the originalXFAVersion.
      • updateOriginalVersion

        public void updateOriginalVersion​(boolean bUpdate)
        Set a boolean that indicates if the originalXFAVersion processing instruction should be updated when each XFA Model child is saved.
        Parameters:
        bUpdate - - TRUE if the processing instruction should be updated, otherwise FALSE. This function is only for Designer so when they create a new document they can avoid creating the originalXFAVersion.