Class TemplateModel

  • All Implemented Interfaces:
    Element.DualDomNode, Peer

    public final class TemplateModel
    extends Model
    A class to model the collection of all the XFA nodes that make up form template.
    • Constructor Detail

      • TemplateModel

        public TemplateModel​(Element parent,
                             Node prevSibling)
      • TemplateModel

        public TemplateModel​(Element parent,
                             Node prevSibling,
                             java.lang.String uri,
                             java.lang.String QName,
                             java.lang.String name)
    • Method Detail

      • enumerateScripts

        public static void enumerateScripts​(Model model,
                                            Node node,
                                            java.util.List<ScriptInfo> scripts,
                                            java.lang.String sSingleLanguage)
        Static method to be shared by Form Model's version of enumerateScripts. Recursive.
      • getModelSchema

        public static Schema getModelSchema()
      • getTemplateModel

        public static TemplateModel getTemplateModel​(AppModel app,
                                                     boolean bCreateIfNotFound)
        Gets the template model held within an XFA DOM hierarchy.
        Parameters:
        app - the application model.
        bCreateIfNotFound - when true, create a template model if needed.
        Returns:
        the template model or null if none found.
      • getValidationMessage

        public static java.lang.String getValidationMessage​(Element poValidateNode,
                                                            java.lang.String aType)
      • getOriginalVersion

        public java.lang.String getOriginalVersion​(boolean bDefault)
        Override of Model.getOriginalVersion(). This override is removed in the C++ version, but is required here because of the special handling for the model's namespace.
        Overrides:
        getOriginalVersion in class Model
      • getVersion

        public int getVersion​(java.lang.String sNS)
        Override of Model.getVersion().
        Overrides:
        getVersion in class Model
      • setValidationMessage

        public static void setValidationMessage​(Element validateNode,
                                                java.lang.String sMessage,
                                                java.lang.String aType)
      • templateNS

        public static java.lang.String templateNS()
        Namespace
        Returns:
        The template namespace URI string
      • applyFixups

        public void applyFixups()
        Applies fixups on the template model just after it has been loaded.

        Note that this Java implementation does not handle the full set of fixups that are currently handled in the C++ implementation.

      • fixupRenderCache

        public void fixupRenderCache()
        Removes render cache from the template model just after it has been loaded.
      • convertToGeographicalOrder

        public void convertToGeographicalOrder()
        Arrange XFA-Template DOM nodes in geographical order.
      • 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)
      • createLeaderTrailer

        public ProtoableNode createLeaderTrailer​(java.lang.String sReference,
                                                 Node oParentContainer,
                                                 boolean bPeek)
      • normalizeNameSpaces

        public void normalizeNameSpaces​(java.lang.String aNewNS)
        Normalize the namespaces of the nodes under this model given a namespace.
        Parameters:
        aNewNS - - the namespace to change to.
      • getOriginalXFAVersion

        public int getOriginalXFAVersion()
        Gets the original version the template was authored with.
        Overrides:
        getOriginalXFAVersion in class Model
        Returns:
        the original XFA version
      • loadSpecialAttribute

        public boolean loadSpecialAttribute​(Attribute attribute,
                                            java.lang.String aLocalName,
                                            Element element,
                                            boolean bCheckOnly)
        Description copied from class: Model
        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.
        Overrides:
        loadSpecialAttribute in class Model
        Returns:
        true if the attribute is handled
      • nodeCleanup

        public void nodeCleanup​(Node node,
                                boolean bHasAttrs,
                                boolean bHasChildren)
        Overrides:
        nodeCleanup in class Model
      • doAttributeCleanup

        public boolean doAttributeCleanup​(Node pNode,
                                          int eAttributeTag,
                                          java.lang.String sAttrValue)
        Return TRUE if the given attribute can be removed, aka cleaned up from a given node. Return FALSE otherwise. This was private in C++.
        Overrides:
        doAttributeCleanup in class Model
      • postLoad

        public void postLoad()
      • setLegacySetting

        public void setLegacySetting​(AppModel.LegacyMask nLegacyFlags,
                                     boolean bValue)
        Sets the boolean value of a particular legacy settings
        Parameters:
        nLegacyFlags - the specific legacy settings to update
        bValue - the new boolean value for the legacy setting
      • cleanupLegacySetting

        public boolean cleanupLegacySetting​(AppModel.LegacyMask nIgnoreLegacyFlags)
        Removes the originalXFAVersion PI if the default legacy flags are equal to the current legacy flags.
        Parameters:
        nIgnoreLegacyFlags - - the legacy flags that should be ignored in the comparison.
        Returns:
        TRUE if the default legacy flags are equal to the current legacy flags, otherwise FALSE.
      • setOriginalXFAVersion

        public void setOriginalXFAVersion​(int nXFAVersion)
        Overrides:
        setOriginalXFAVersion in class Model
      • splice

        public java.util.List<TemplateModel.Insertion> splice​(java.util.List<TemplateModel.Insertion> insertions,
                                                              boolean removeInsertionPoints)
        Splices external template fragments into this template. The points at which insertions are to be inserted are indicated by those elements containing an extras element that in turn contain a text element with the name "insertionPoint".

        Elements containing an extras element that in turn contains a text element with the name "insertionPointPlaceholder" are removed.

        The value contained within the text node is an insertion key, and it is matched against each key in insertions. The corresponding replacement reference identifies a template fragment that is loaded and inserted into the template. Each insertion is done by making a copy of the insertion point and inserting that copy before the insertion point. The template fragment reference is then resolved, and the resolved fragment is merged into the insertion point copy.

        The values in insertions reference template fragments using the same syntax that the usehref attribute uses to reference external prototype fragments:

        • URI#ID
        • URI#som(expression)
        • URI

        Any errors generated while loading the referenced fragment are copied to this TemplateModel.

        The caller is responsible for registering an HrefHandler with the AppModel to allow any external references to be resolved.

        Parameters:
        insertions - the insertions to be spliced into the template.
        removeInsertionPoints - if true, then any insertion points in the template are removed.
        Returns:
        a List containing the entries from insertions for which no corresponding insertion point was found, or null if all insertions were used.
        See Also:
        AppModel.getErrorList(), AppModel.setHrefHandler(HrefHandler handler)
      • synchronizeXMPMetaData

        public void synchronizeXMPMetaData​(java.lang.String sCreatorTool,
                                           java.lang.String sProducer)
        Synchronize this template model with the peer x:xmpmeta packet. MetaData information is copied from the older to the newer (by checking the timestamps in each).
        Parameters:
        sCreatorTool - - The name of the tool that created the form (may be empty).
        sProducer - - The producer that created the form (may be empty).
        Throws:
        ExFull - if synchronizing the metadata fails.
      • validateGlobalField

        public boolean validateGlobalField​(Element poNodeImpl)
        check if a node is a global field
      • invalidMethod

        public void invalidMethod​(java.lang.String sName)
        we needed to add the form methods into the template (see below in the scripting section) because Designer (for example) uses intellisence and since it doesn't have a form DOM it can show the $form properties. By adding the methods here they can actually populate the list of properties for $form.
      • adjustForVersion

        public void adjustForVersion​(int nVersion)
        Make any adjustments necessary for the specified version. If nVersion is 0, then the current version (i.e. getCurrentVersion()) is used.
      • 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 return the updated 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(Publisher oPublisher)
      • preLoadNode

        public Node preLoadNode​(Element parent,
                                Node node,
                                Generator genTag)
        Description copied from class: Model
        Preprocess the node. The node may be removed.
        Overrides:
        preLoadNode in class Model
        Returns:
        the next XML sibling to be processed, or null if all siblings have been processed.