Class DataModel

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

public final class DataModel extends Model implements Model.DualDomModel
A class to model the collection of all XFA nodes that make up form data.
  • Field Details

    • FMT_XML_DATA

      public static final int FMT_XML_DATA
      Enumeration XFAXMLFormat:
      1. FMT_XML_DATA = 3rd party XML,
      2. FMT_XPF_DATA = XPF format.
      Note! The numbers assigned to these constants can't be changed! The scripting interface uses the numerical value to specify formats.
      See Also:
    • FMT_XPF_DATA

      public static final int FMT_XPF_DATA
      See Also:
  • Constructor Details

    • DataModel

      public DataModel(Element parent, Node prevSibling)
      Default Constructor.
  • Method Details

    • dataDescriptionNS

      public static String dataDescriptionNS()
    • getDataModel

      public static DataModel getDataModel(AppModel app, boolean bCreateIfNotFound, boolean bAppend)
      Gets the data model held within an XFA DOM hierarchy.
      Parameters:
      app - the application model.
      bCreateIfNotFound - when true, create a data model if needed.
      bAppend - when true, append any underling xml to the xfa root element when loading, and when false, create orphan xfa:datasets and xfa:data nodes. This behaviour occurs only works when bCreateIfNotFound is set to true.
      Returns:
      the data model, or null if none found.
    • getScriptTable

      public ScriptTable getScriptTable()
      Overrides:
      getScriptTable in class Model
    • 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.
    • createChild

      public Node createChild(boolean bIsLeaf, String aName)
    • createNode

      public Node createNode(int eClassTag, Element parent, String aNodeName, String ns, 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:
      eClassTag - the element's tag.
      parent - the element's parent.
      aNodeName - the element's name.
      ns - the element's namespace.
      bDoVersionCheck - check the element's version.
      Returns:
      a new element.
    • createElement

      public Element createElement(Element parent, Node prevSibling, String uri, String localName, String qName, Attributes attributes, int lineNumber, 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:
    • findAttrInNS

      public Attribute findAttrInNS(Element e, String aNodeName)
      Find an attribute via loose namespace checking. Our check simply verifies that the namespace is compatible with any variation of namespaces for this model. Using the variations are simply changes in version number.
      Parameters:
      e - the element to search
      aNodeName - the local name of the attribute
      Returns:
      attribute index. -1 if not found.
    • findAttrInNS

      public Attribute findAttrInNS(Attribute[] attrs, String aNodeName)
      Given an array of attributes, find the specified node name which exists in a namespace that is compatible with this data model's namespace. (This is a direct port of the C++ method by the same name, unlike the other variant of findAttrInNS above).
      Parameters:
      attrs - the array of attributes to search
      aNodeName - the local name of the attribute
      Returns:
      the attribute. null if not found.
    • getBaseNS

      public String getBaseNS()
      Specified by:
      getBaseNS in class Model
      See Also:
    • getDataDescriptionRoot

      public DataNode getDataDescriptionRoot(String sDataRootName)
    • createDataRootElement

      public DataNode createDataRootElement(DataNode dataDescription)
    • connectPeerToDocument

      public void connectPeerToDocument()
      Description copied from class: Element
      connectPeerToDocument() is used to rearrange the DOM tree when inserting or appending a node. It is provided here as a utility function for derived classes that could be adding child nodes, when peered against an orphan node. In particular, this happens with xfa:datasets and xfa:data, both of which may be created during the load process. On the C++ side, this method is only used by the data model. Due to the differences between the relationship of Documents and AppModels in Java, on the Java side it is also called when creating a DOM from scratch, from any ModelFactory's createDOM method. In the DataModel context at least, it should only be called if the DOM peer is an orphan. It takes that orphan and connects it to the document, and then moves the original peer of this node to be a child of the node that previously was orphaned.
      Overrides:
      connectPeerToDocument in class Element
    • getDataRoot

      public DataNode getDataRoot()
    • getDataWindow

      public DataWindow getDataWindow()
    • getSourceSetLink

      public DataModel.SourceSetLink getSourceSetLink()
    • initFromDataDescription

      public void initFromDataDescription(Element dataNode)
      used to ensure an export data tree has a basic population since an export data tree doesn't necessarily have any actual data bindings.
    • 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
    • isCompatibleNS

      public boolean isCompatibleNS(String aNS)
      Description copied from class: Model
      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).
      Overrides:
      isCompatibleNS in class Model
      Parameters:
      aNS - The namespace to compare.
    • loadNode

      public void loadNode(Element parent, Node node, Generator generator)
      Overrides:
      loadNode in class Model
    • loadRootAttributes

      public boolean loadRootAttributes()
      Overrides:
      loadRootAttributes in class Model
    • preSave

      public void preSave(boolean bSaveXMLScript)
      Description copied from class: Model
      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 Model
      See Also:
    • remove

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

      public static void removeDDPlaceholderFlags(Node dataNode, boolean bDeep)
    • resetPostLoadXML

      public void resetPostLoadXML()
      Overrides:
      resetPostLoadXML in class Element
    • resolveRef

      public Node resolveRef(String sSOM, Element contextNode, boolean bDataValue, boolean bDefault)
    • serialize

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

      public void setSourceSetLink(DataModel.SourceSetLink sourceSetLink)
    • setSaveFormat

      public void setSaveFormat(int format)
    • 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 Model
      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 Model
      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:
    • disableSchemaValidation

      public void disableSchemaValidation(boolean bMode)
    • getHeadNS

      public String getHeadNS()
      Specified by:
      getHeadNS in class Model
    • getHeadVersion

      public int getHeadVersion()
      Overrides:
      getHeadVersion in class Model
    • resolveAssociation

      public static Obj resolveAssociation(Element dataNode, String aAssociationName, BooleanHolder foundNullAssociation)
    • getRootOfDataDescription

      public static DataNode getRootOfDataDescription(Node dataDesc)
      Find a data description node's invalid input: '<'dd:dataDescription> ancestor.
    • findAssociation

      public static Node findAssociation(Node dataDesc, String aAssociationName)
      Recursive search of a data description for a invalid input: '<'dd:association> with a particular name. The first hit is returned.
    • getReflectedNodes

      public static void getReflectedNodes(Node dataNode, String aTargetNamespaceURI, String aTargetName, Key targetKey, List<String> oFKeyValueAddressList, Node namespaceContextNode, NodeList results)
      Recursive search of a data model for nodes of a particular target QName whose foreign key matches the supplied primary key. All hits are returned.