Package com.adobe.xfa.template
Class TemplateModel
- java.lang.Object
-
- com.adobe.xfa.Obj
-
- com.adobe.xfa.Node
-
- com.adobe.xfa.Element
-
- com.adobe.xfa.Model
-
- com.adobe.xfa.template.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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
TemplateModel.Insertion
A class to define a mapping between a key and template fragment reference.-
Nested classes/interfaces inherited from class com.adobe.xfa.Model
Model.DualDomModel, Model.Publisher
-
Nested classes/interfaces inherited from class com.adobe.xfa.Element
Element.DualDomNode, Element.ReplaceContent
-
Nested classes/interfaces inherited from class com.adobe.xfa.Node
Node.ChangeLogger
-
-
Field Summary
-
Fields inherited from class com.adobe.xfa.Element
AttrIsDefault, AttrIsFragment, AttrIsTransient, CREATEACTION
-
Fields inherited from class com.adobe.xfa.Node
CREATE_ALWAYS_NEW, CREATE_IF_NOT_EXIST, CREATE_MUST_NOT_EXIST, CREATE_REPLACE, gsXFANamespacePrefix
-
Fields inherited from interface com.adobe.xfa.ut.Peer
ATTR_CHANGED, CHILD_ADDED, CHILD_REMOVED, DESCENDENT_ADDED, DESCENDENT_ATTR_CHANGED, DESCENDENT_REMOVED, DESCENDENT_VALUE_CHANGED, PARENT_CHANGED, PERMS_LOCK_CLEARED, PERMS_LOCK_SET, PROTO_ATTR_CHANGED, PROTO_CHILD_ADDED, PROTO_CHILD_REMOVED, PROTO_DESCENDENT_ADDED, PROTO_DESCENDENT_ATTR_CHANGED, PROTO_DESCENDENT_REMOVED, PROTO_DESCENDENT_VALUE_CHANGED, PROTO_VALUE_CHANGED, UPDATED, VALUE_CHANGED
-
-
Constructor Summary
Constructors Constructor Description TemplateModel(Element parent, Node prevSibling)
TemplateModel(Element parent, Node prevSibling, java.lang.String uri, java.lang.String QName, java.lang.String name)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
adjustForVersion(int nVersion)
Make any adjustments necessary for the specified version.void
applyFixups()
Applies fixups on the template model just after it has been loaded.boolean
cleanupLegacySetting(AppModel.LegacyMask nIgnoreLegacyFlags)
Removes the originalXFAVersion PI if the default legacy flags are equal to the current legacy flags.void
convertToGeographicalOrder()
Arrange XFA-Template DOM nodes in geographical order.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)
Creates an element with the given parent, sibling, namespace uri, local name and SAX attributes.ProtoableNode
createLeaderTrailer(java.lang.String sReference, Node oParentContainer, boolean bPeek)
Node
createNode(int eTag, Element parent, java.lang.String aName, java.lang.String aNS, boolean bDoVersionCheck)
Create an element with the given tag, parent, name and uri.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.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.void
fixupRenderCache()
Removes render cache from the template model just after it has been loaded.java.lang.String
getBaseNS()
java.lang.String
getHeadNS()
boolean
getLegacySetting(AppModel.LegacyMask nLegacyFlag)
Gets the boolean value of a particular legacy setting.static Schema
getModelSchema()
java.lang.String
getOriginalVersion(boolean bDefault)
Override of Model.getOriginalVersion().int
getOriginalXFAVersion()
Gets the original version the template was authored with.ScriptTable
getScriptTable()
static TemplateModel
getTemplateModel(AppModel app, boolean bCreateIfNotFound)
Gets the template model held within an XFA DOM hierarchy.static java.lang.String
getValidationMessage(Element poValidateNode, java.lang.String aType)
int
getVersion(java.lang.String sNS)
Override of Model.getVersion().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.void
loadNode(Element parent, Node node, Generator generator)
boolean
loadSpecialAttribute(Attribute attribute, java.lang.String aLocalName, Element element, boolean bCheckOnly)
loadSpecialAttribute should be called by the loadNode method.void
nodeCleanup(Node node, boolean bHasAttrs, boolean bHasChildren)
void
normalizeNameSpaces(java.lang.String aNewNS)
Normalize the namespaces of the nodes under this model given a namespace.void
postLoad()
Node
preLoadNode(Element parent, Node node, Generator genTag)
Preprocess the node.boolean
publish(Model.Publisher publisher)
Publish the model to an Application Storage facility.void
setLegacySetting(AppModel.LegacyMask nLegacyFlags, boolean bValue)
Sets the boolean value of a particular legacy settingsvoid
setOriginalXFAVersion(int nXFAVersion)
static void
setValidationMessage(Element validateNode, java.lang.String sMessage, java.lang.String aType)
java.util.List<TemplateModel.Insertion>
splice(java.util.List<TemplateModel.Insertion> insertions, boolean removeInsertionPoints)
Splices external template fragments into this template.void
synchronizeXMPMetaData(java.lang.String sCreatorTool, java.lang.String sProducer)
Synchronize this template model with the peer x:xmpmeta packet.static java.lang.String
templateNS()
Namespaceboolean
validateGlobalField(Element poNodeImpl)
check if a node is a global field-
Methods inherited from class com.adobe.xfa.Model
addErrorList, addUseHRefNode, addUseNode, addXMLLoadErrorContext, allowUpdates, checkforCompatibleNS, clearErrorList, clone, createElement, createElement, createElement, createElement, createTextNode, createTextNode, getAliasNode, getAppModel, getAppModelIsTransient, getCachedLocale, getContext, getCurrentVersion, getDelta, getDeltas, getDocument, getErrorContextList, getErrorList, getEventManager, getGenerator, getHeadVersion, getIDValueMap, getLogMessenger, getName, getNeedsNSNormalize, getNode, getNS, getOriginalVersionNode, getProtoList, getSchema, getSourceBelow, getXmlPeer, isCompatibleNS, isContainer, isLoading, isVersionCompatible, loadRootAttributes, loadSpecialNode, modelCleanup, normalizeNameSpaces, normalizeNameSpaces, normalizeNameSpaces, preSave, ready, remapTag, remove, removeLastError, removeReferences, resolveNodes, resolveProtos, serialize, setAliasNode, setAppModel, setAppModelIsTransient, setContext, setCurrentVersion, setDOMProperties, setIDValueMap, setName, setNeedsNSNormalize, setXmlPeer, shortCutName, validateUsage, validateUsageFailedIsFatal, willDirtyDoc, willDirtyDoc
-
Methods inherited from class com.adobe.xfa.Element
appendChild, appendChild, appendPI, appendPI, assignNode, clone, connectPeerToDocument, constructKey, constructKeys, copyContent, defaultAttribute, defaultElement, defaultElement, establishID, evaluate, explodeQName, findAttr, findSchemaAttr, foundBadAttribute, foundBadAttribute, getAll, getAtom, getAttr, getAttribute, getAttribute, getAttributeByName, getAttrIndex, getAttrName, getAttrNS, getAttrProp, getAttrQName, getAttrVal, getChildReln, getClassAll, getClassIndex, getClassName, getDeltas, getElement, getElement, getElementClass, getElementLocal, getEnum, getEnum, getEventTable, getFirstXFAChild, getFirstXMLChild, getID, getIndex, getInheritedNS, getInstalledLocale, getIsNull, getLastXMLChild, getLineNumber, getLocalName, getModel, getNode, getNodes, getNodeSchema, getNumAttrs, getOneOfChild, getOneOfChild, getPI, getPI, getPrefix, getProperty, getProperty, getSaveXMLSaveTransient, getSchemaType, getScriptMethodInfo, getSibling, getText, getXFAChild, getXMLChild, getXMLName, getXPath, getXsiNilAttribute, inhibitPrettyPrint, inhibitPrettyPrint, insertChild, isFragment, isHidden, isHidden, isIndexed, isInstalledLocaleAmbient, isLeaf, isNameSpaceAttr, isPropertySpecified, isPropertySpecified, isPropertyValid, isSpecified, isSpecified, isSpecified, isTransient, isTransparent, isValidAttr, isValidChild, isValidElement, loadXML, loadXML, makeDefault, makeNonDefault, newAttribute, optimizeNameSpace, peekAttribute, peekElement, peekOneOfChild, peekProperty, peekProperty, postSave, privateSetName, processTextChildrenDuringParse, removeAttr, removeAttr, removeChild, removePI, removePI, removeWhiteSpace, removeXsiNilAttribute, replaceChild, resetPostLoadXML, resolveAndEnumerateChildren, resolveNodeCreate, resolvePrefix, saveFilteredXML, saveXML, saveXML, setAttribute, setAttribute, setAttribute, setAttribute, setAttrProp, setDefaultFlag, setElement, setIsDataWindowRoot, setIsIndexed, setLineNumber, setLocalName, setModel, setNS, setOneOfChild, setProperty, setProperty, setQName, setSaveXMLSaveTransient, setTransparent, setXMLName, setXsiNilAttribute, updateFromPeer
-
Methods inherited from class com.adobe.xfa.Node
checkAncestorPerms, checkDescendentPerms, checkPerms, cleanDirtyFlags, compareVersions, getData, getFirstXMLChildElement, getLocked, getNextXFASibling, getNextXMLSibling, getNextXMLSiblingElement, getNodeAsXML, getOwnerDocument, getPIAsXML, getPIName, getPreviousXMLSibling, getPrivateName, getPropName, getSOMExpression, getSOMExpression, getSomName, getUniqueSOMName, getWillDirty, getXFAChildCount, getXFAParent, getXfaPeer, getXMLChildCount, getXMLParent, hasChanged, isDefault, isDirty, isMapped, isPermsLockSet, isTransient, locateChildByClass, locateChildByName, logValueChangeHelper, notifyPeers, performSOMAssignment, resolveNode, resolveNode, resolveNode, resolveNodes, sendMessenge, setDirty, setDocument, setLocked, setMapped, setPermsLock, setPrivateName, setWillDirty, setXfaPeer, unLock, validateSchema
-
Methods inherited from class com.adobe.xfa.Obj
addPeer, addPeeredNode, clearPeers, deafen, getClassAtom, getClassTag, getPeer, getScriptProperty, getScriptThis, invokeFunction, isDeaf, isMute, isSameClass, isSameClass, isSameClass, mute, peerRemoved, removePeer, removePeeredNode, setClass, setClassTag, setScriptProperty, unDeafen, unMute
-
-
-
-
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 classModel
-
getVersion
public int getVersion(java.lang.String sNS)
Override of Model.getVersion().- Overrides:
getVersion
in classModel
-
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.
-
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 classModel
- 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(com.adobe.xfa.Element, com.adobe.xfa.Node, java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes, int, java.lang.String)
-
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 classModel
- 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)
-
getBaseNS
public java.lang.String getBaseNS()
- Specified by:
getBaseNS
in classModel
- See Also:
Model.getBaseNS()
-
getHeadNS
public java.lang.String getHeadNS()
- Specified by:
getHeadNS
in classModel
- See Also:
Model.getHeadNS()
-
getLegacySetting
public boolean getLegacySetting(AppModel.LegacyMask nLegacyFlag)
Description copied from class:Model
Gets the boolean value of a particular legacy setting.- Overrides:
getLegacySetting
in classModel
- Parameters:
nLegacyFlag
- the specific legacy setting to check- Returns:
true
if the legacy setting is set, or is the default the original version.- See Also:
Model.getLegacySetting(AppModel.LegacyMask)
-
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 classModel
- Returns:
- the original XFA version
-
getScriptTable
public ScriptTable getScriptTable()
- Overrides:
getScriptTable
in classModel
-
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 classModel
- Returns:
true
if the attribute is handled
-
nodeCleanup
public void nodeCleanup(Node node, boolean bHasAttrs, boolean bHasChildren)
- Overrides:
nodeCleanup
in classModel
-
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 classModel
-
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 updatebValue
- 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 classModel
-
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 anextras
element that in turn contain atext
element with the name "insertionPoint". Elements containing anextras
element that in turn contains atext
element with the name "insertionPointPlaceholder" are removed. The value contained within thetext
node is an insertion key, and it is matched against each key ininsertions
. 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 ininsertions
reference template fragments using the same syntax that theusehref
attribute uses to reference external prototype fragments:- URI#ID
- URI#som(expression)
- URI
TemplateModel
. The caller is responsible for registering anHrefHandler
with theAppModel
to allow any external references to be resolved.- Parameters:
insertions
- the insertions to be spliced into the template.removeInsertionPoints
- iftrue
, then any insertion points in the template are removed.- Returns:
- a
List
containing the entries frominsertions
for which no corresponding insertion point was found, ornull
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 classModel
- Parameters:
publisher
- an instance of a class derived from TemplateModel.Publisher.- See Also:
Model.publish(Publisher oPublisher)
-
-