Package com.adobe.xfa

Class Model

All Implemented Interfaces:
Element.DualDomNode, Peer
Direct Known Subclasses:
AppModel, ConfigurationModel, ConnectionSetModel, DataModel, FormModel, LocaleSetModel, TemplateModel

public abstract class Model extends Element implements Element.DualDomNode
An abstract class from which to derive all other models.
  • Method Details

    • checkforCompatibleNS

      public static boolean checkforCompatibleNS(String aNS, String aModelNS)
      Helper function for isCompatibleNS
      Parameters:
      aNS - - namespace of node being checked
      aModelNS - - namespace of model being checked against.
    • getScriptTable

      public ScriptTable getScriptTable()
      Overrides:
      getScriptTable in class Element
    • addErrorList

      public final void addErrorList(ExFull error, int eSeverity, Element context)
    • removeLastError

      public final void removeLastError()
    • addUseHRefNode

      public void addUseHRefNode(Element poUseHRefNode)
      add a new new node to the useNodeHrefList
    • addUseNode

      public void addUseNode(Element poUse)
      add a new new node to the useNodeList
    • addXMLLoadErrorContext

      public void addXMLLoadErrorContext(Node oSrc, ExFull oEx)
      This method is called by derived classes to output the filename and line number when an error occurs during the load of an XML File.
    • allowUpdates

      public void allowUpdates(boolean bAllowUpdates)
      Sets whether this model can be updated at runtime. This should only be true for Designer.
      Parameters:
      bAllowUpdates - - true if this model can be modified at runtime, otherwise false.
    • clearErrorList

      public void clearErrorList()
      Clears the model's current list of errors.
    • clone

      public Element clone(Element parent, boolean bDeep)
      Overrides:
      clone in class Element
      See Also:
    • createElement

      public Element createElement(Element parent, Node prevSibling, String uri, String qName)
      Creates an element with the given parent, previous sibling, namespace uri and qualified name.
      Parameters:
      parent - the element's parent, if any.
      prevSibling - the element's previous sibling, if any.
      uri - the element's namespace URI. This string must be interned.
      qName - the element's qualified name. This string must be interned.
      Returns:
      a new element conformant to our schema.
    • createElement

      public Element createElement(Element parent, Node prevSibling, String uri, String localName, String qName, Attributes attributes, int lineNumber, String fileName)
      Creates an element with the given parent, sibling, namespace uri, local name and SAX attributes.
      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.
    • createElement

      public final Element createElement(int eTag, String name)
      Create an element with the given element tag and name.
      Parameters:
      eTag - the element's tag.
      name - the element's name, if known. This string must be interned.
      Returns:
      a new element conformant to the XFA schema.
    • createElement

      public final Element createElement(String className, String name, Element parent)
      Creates an element with the given class, name and parent.
      Parameters:
      className - the element's class name. This string must be interned.
      name - the element's name, if known. This string must be interned.
      parent - the element's parent.
      Returns:
      a new element conformant to the XFA schema.
    • createElement

      public Element createElement(String name)
      Creates an element with the given name.
      Parameters:
      name - the element's name. This string must be interned.
      Returns:
      a new element conformant to our schema.
    • createNode

      public abstract Node createNode(int eTag, Element parent, String aName, String aNS, boolean bDoVersionCheck)
      Create an element with the given tag, parent, name and uri.
      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.
    • createTextNode

      public final TextNode createTextNode(Element parent, Node prevSibling, char[] ch, int start, int length)
    • createTextNode

      public final TextNode createTextNode(Element parent, Node prevSibling, String text)
      Creates a text node with the given text.
      Parameters:
      parent - the node's parent, if any.
      prevSibling - the node's previous sibling, if any.
      text - the node's text.
      Returns:
      a new node conformant to our schema.
    • getAliasNode

      public final Element getAliasNode()
      Returns the node that is represented by the alias for this model. The returned model is normally the model itself, but not always. For example, while $template refers to the template model, by default, $data refers to the first child of the data model.
      Returns:
      an Node that corresponds to the alias for this model.
    • getAppModel

      public AppModel getAppModel()
      Overrides:
      getAppModel in class Element
    • getAppModelIsTransient

      public boolean getAppModelIsTransient()
    • getBaseNS

      public abstract String getBaseNS()
    • getCachedLocale

      public String getCachedLocale()
    • getContext

      public final Node getContext()
      Retrieves the current node, which is the starting node for calls to resolveNode() and resolveNodes()
      Returns:
      The current node.
    • getCurrentVersion

      public int getCurrentVersion()
      Gets the current version of this model.
      Returns:
      the version number (times 10).
    • getDeltas

      public Obj getDeltas(Node oNode)
    • getDocument

      public final Document getDocument()
      Returns this model's document.
      Returns:
      the document node.
    • getDelta

      public Obj getDelta(Element node, String sSOM)
    • getErrorContextList

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

      public List<ExFull> getErrorList()
      Gets all the errors that have been generated by this model since the last method call to clear the error list. Note that these are not fatal errors. They are typically syntax problems discovered when loading the collateral. Some applications may choose to sift through the list and stop processing if they recognize specific problems. However most applications should simply dump the messages into the log file and continue processing. i.e. treat this as a list of warnings.
      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)
    • getGenerator

      public Generator getGenerator()
    • getHeadNS

      public abstract String getHeadNS()
    • getHeadVersion

      public int getHeadVersion()
    • getIDValueMap

      public IDValueMap getIDValueMap()
    • getLegacySetting

      public boolean getLegacySetting(AppModel.LegacyMask nLegacyFlag)
      Gets the boolean value of a particular legacy setting.
      Parameters:
      nLegacyFlag - the specific legacy setting to check
      Returns:
      true if the legacy setting is set, or is the default the original version.
    • getLogMessenger

      public LogMessenger getLogMessenger()
      Retrieves the log messenger associated with this model.
      Returns:
      The log messenger.
    • getName

      public final String getName()
      Description copied from class: Element
      Gets this element's name.

      The name of an element is the value of its name attribute, or the element name if there is no name attribute.

      Overrides:
      getName in class Element
      Returns:
      the name of the element.
      See Also:
    • getNeedsNSNormalize

      public boolean getNeedsNSNormalize()
    • getNode

      public Element getNode(String aID)
      Look up an XFA ID. Since XFA IDs are only guaranteed to be unique within the scope of their model (to prevent conflicts with customer-controlled data), the lookup is done by namespace.

      Note: jfDomDocument::getElementByXFAId handles the conversion of versioned model namespace strings to unversioned ones.

      Parameters:
      aID - The node id
      Returns:
      The node if found, null if not found.
    • getNS

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

      public String getOriginalVersion(boolean bDefault)
    • getOriginalVersionNode

      public ProcessingInstruction getOriginalVersionNode(boolean bCreate, String sValue)
      Get the processing instruction that holds our version number.
      Parameters:
      bCreate - - if true, create the PI if it doesn't exist
      sValue - - the value to use for the PI if we create it
      Returns:
      the version node PI
    • getProtoList

      public List<ProtoableNode> getProtoList()
      Keep track of proto Nodes and 'use' tags for quick lookup later our
      Returns:
      our list of protos
    • getSchema

      public final Schema getSchema()
      Return the schema definition for this model.
      Returns:
      a class derived from Schema
    • getSourceBelow

      public int getSourceBelow()
    • getVersion

      public int getVersion(String sNS)
    • setXmlPeer

      public void setXmlPeer(Node peer)
      Specified by:
      setXmlPeer in interface Element.DualDomNode
    • getXmlPeer

      public Node getXmlPeer()
      Specified by:
      getXmlPeer in interface Element.DualDomNode
    • isCompatibleNS

      public boolean isCompatibleNS(String aNS)
      Determine if a specified namespace string is compatible with the namespace of this model. Essentially this determines if the two namespaces are equivalent (though the strings that represent them may not be identical).
      Parameters:
      aNS - The namespace to compare.
    • isContainer

      public final boolean isContainer()
      Description copied from class: Node
      Check to see if this is a container object. A container is defined as something that is not a leaf node not properties ( [0..1] occurrences ). It does NOT indicate whether this node derives from XFAContainer
      Overrides:
      isContainer in class Element
      Returns:
      true if this node is a container, false otherwise
    • isLoading

      public final boolean isLoading()
    • isVersionCompatible

      public boolean isVersionCompatible(int nVersion, int nTargetVersion)
    • loadNode

      public void loadNode(Element parent, Node node, Generator genTag)
    • loadSpecialAttribute

      public boolean loadSpecialAttribute(Attribute attr, String aLocalName, Element element, boolean bCheckOnly)
      loadSpecialAttribute should be called by the loadNode method. It scans for special attributes. Currently it only looks for event-related attributes (for automatic execution of script). The bCheckOnly flag can be set to TRUE to cause this routine to do nothing except return whether or not the attribute would be handled.
      Returns:
      true if the attribute is handled
    • loadSpecialNode

      public boolean loadSpecialNode(Element parent, Node node, boolean bCheckOnly)
      loadSpecialNode should be called by the loadNode method. It checks for special nodes. Currently it only looks for event-related nodes (for automatic execution of script).
      Returns:
      true if the node is handled
    • loadRootAttributes

      public boolean loadRootAttributes()
    • modelCleanup

      public void modelCleanup(Node node)
    • nodeCleanup

      public void nodeCleanup(Node pNode, boolean bHasAttrs, boolean bHasChildren)
    • doAttributeCleanup

      public boolean doAttributeCleanup(Node node, int eAttributeTag, String sAttrValue)
      Return TRUE if the given attribute can be removed, aka cleaned up from a given node. Return FALSE otherwise.
    • normalizeNameSpaces

      public void normalizeNameSpaces()
    • normalizeNameSpaces

      public void normalizeNameSpaces(Element poNode, String aURI)
      Helper function for normalizeNameSpaces().
      Parameters:
      poNode - the node to normalize.
      aURI - the new namespace.
    • normalizeNameSpaces

      public boolean normalizeNameSpaces(int nTargetVersion, List<NodeValidationInfo> oResult)
      Walks through the XFA DOM and normalizes the namespaces of all the nodes.
      Parameters:
      nTargetVersion - the version of the schema desired. One of XFAVERSION_10, ... XFAVERSION_HEAD.
      oResult - a list of NodeValidationInfo objects: invalid children, attributes and attribute values based upon the target version. If this model is not a valid child of its parent, this model will be the first entry of oResult. If oResult is not null, this method will ensure all child nodes attributes and attribute values are valid for given the target version.
      Returns:
      true if successful, else false.
    • preLoadNode

      public Node preLoadNode(Element parent, Node node, Generator genTag)
      Preprocess the node. The node may be removed.
      Returns:
      the next XML sibling to be processed, or null if all siblings have been processed.
    • preSave

      public void preSave(boolean bSaveXMLScript)
      Prepares this Model to be saved. Any model maintenance that may have been deferred is performed to ensure that the serialized form of the Model is correct. This method is called automatically before a Model is serialized to a stream, so it does not normally need to be called directly. The exception is when a Document is saved using Document.saveAs(java.io.OutputStream, Node, DOMSaveOptions) or Document.saveXML(java.io.OutputStream, DOMSaveOptions).
      Overrides:
      preSave in class Element
      See Also:
    • publish

      public boolean publish(Model.Publisher publisher)
      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.
      Parameters:
      publisher - an instance of a class derived from TemplateModel.Publisher.
    • ready

      public boolean ready(boolean bForced)
      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.
      Returns:
      true if ready scripts fire
    • remove

      public void remove()
      Description copied from class: Node
      Removes this node from its parent child list.
      Overrides:
      remove in class Node
      See Also:
    • removeReferences

      public void removeReferences(Node node)
      remove references to a given node.
    • remapTag

      public int remapTag(int eTag)
      Remap a given tag to a new value. This gives a model a chance to remap a tag to a new value after it's determined that the original wasn't valid in the current context. The default implementation returns the input tag, which is a no-op.
      Parameters:
      eTag - the original input tag.
      Returns:
      the new remapped tag.
    • resolveNodes

      public NodeList resolveNodes(String somNodes, boolean bPeek, boolean bLastInstance, boolean bNoProperties, DependencyTracker oDependencyTracker, BooleanHolder isAssociation)
      Description copied from class: Node
      Evaluates the Scripting Object Model expression, using this node as the current context.
      Overrides:
      resolveNodes in class Node
      See Also:
    • resolveProtos

      public void resolveProtos(boolean bForceExternalProtoResolve)
    • serialize

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

      public final void setAliasNode(Element aliasNode)
      Specify the node that is represented by the alias for this model.
      Parameters:
      aliasNode - The node that will represent this model.
    • setAppModel

      public void setAppModel(AppModel pNewModel)
      Parameters:
      pNewModel -
    • setAppModelIsTransient

      public void setAppModelIsTransient(boolean bAppModelIsTransient)
    • setContext

      public void setContext(Node node)
      Specifies the current node, which is the starting node for calls to resolveNode and resolveNodes.
      Parameters:
      node - the new current node.

      resolveNode and resolveNodes differ from Node.resolveNode() and Node.resolveNodes() in that the current node is the node set via setContext(), instead of "this" node.

    • setCurrentVersion

      public void setCurrentVersion(int nVersion)
    • setDOMProperties

      public final void setDOMProperties(String uri, String localName, String qName, Attributes attributes)
      Description copied from class: Element
      All name properties (including those in attributes) must be interned strings.
      Overrides:
      setDOMProperties in class Element
      See Also:
    • setIDValueMap

      public void setIDValueMap(IDValueMap idValueMap)
    • setName

      public final void setName(String name)
      Set the name for this model
      Overrides:
      setName in class Element
      Parameters:
      name - the model name
    • setNeedsNSNormalize

      public void setNeedsNSNormalize(boolean bNormalize)
    • shortCutName

      public String shortCutName()
    • validateUsage

      public boolean validateUsage(int nXFAVersion, int nAvailability, boolean bUpdateVersion)
      Description copied from class: Obj
      Validate if the given Version and Availability flags are valid for the current document
      Overrides:
      validateUsage in class Node
      Parameters:
      nXFAVersion - The target XFA Version
      nAvailability - The target Availability flags, this indicates for what clients the script is available
      bUpdateVersion - indicates if the model version can be updated by the calling code
      Returns:
      if true, Version and Availability flags are valid
      See Also:
    • validateUsageFailedIsFatal

      public boolean validateUsageFailedIsFatal(int nXFAVersion, int nAvailability)
      Description copied from class: Obj
      Determines if disallowing a version should be considered a fatal error.

      This method is called after calling Obj.validateUsage(int, int, boolean) when that method returns false.

      Overrides:
      validateUsageFailedIsFatal in class Node
      Parameters:
      nXFAVersion - The target XFA Version
      nAvailability - The target Availability flags, this indicates for what clients the script is available
      Returns:
      true if disallowing nVersion should be considered a fatal error
      See Also:
    • willDirtyDoc

      public void willDirtyDoc(boolean bWillDirty)
    • willDirtyDoc

      public boolean willDirtyDoc()
    • getOriginalXFAVersion

      public int getOriginalXFAVersion()
    • setOriginalXFAVersion

      public void setOriginalXFAVersion(int nXFAVersion)