XFA4J

com.adobe.xfa
Class Element

java.lang.Object
  extended by com.adobe.xfa.Obj
      extended by com.adobe.xfa.Node
          extended by com.adobe.xfa.Element
Direct Known Subclasses:
Document, Model, Packet, ProtoableNode

public class Element
extends Node

A class to represent the XFA elements in a DOM. Elements differ from nodes in that they all conform to an XFA schema. All the XML comments Comment and processing instructions ProcessingInstruction of a DOM, lie outside the XFA schemas.


Nested Class Summary
 
Nested classes/interfaces inherited from class com.adobe.xfa.Node
Node.ChangeLogger
 
Field Summary
 
Fields inherited from class com.adobe.xfa.Node
CREATE_ALWAYS_NEW, CREATE_IF_NOT_EXIST, CREATE_MUST_NOT_EXIST, CREATE_REPLACE
 
Constructor Summary
protected Element()
          Instantiates an element node.
protected Element(Element parent, Node prevSibling)
          Instantiates an element node.
protected Element(Element parent, Node prevSibling, java.lang.String uri, java.lang.String name)
          Instantiates an element node with the given properties.
 
Method Summary
 void appendChild(Node child, boolean bValidate)
          Appends the given child to this element.
 Node assignNode(java.lang.String sSOMExpression, java.lang.String sValue, int eMode)
          Assigns the value given to the node located by the given SOM (Scripting Object Model) expression and interpreted relative to this element's context.
 Attribute getAttr(int n)
          Gets this element's n'th attribute.
 Attribute getAttribute(int eTag, boolean bPeek, boolean bValidate)
          Gets this element's attribute whose attribute tag is given.
 Element getElement(int eTag, boolean bPeek, int nOccurrence, boolean bReturnDefault, boolean bValidate)
          Gets this element's sub element whose element tag is given.
 Node getFirstXFAChild()
          Gets this element's first XFA child.
 Node getFirstXMLChild()
          Gets this element's first XML child.
 java.lang.String getInstalledLocale()
          Gets this element's installed locale.
 Node getLastXMLChild()
          Gets this element's last XML child.
 Model getModel()
          Gets this element's model.
 java.lang.String getName()
          Gets this element's name.
 NodeList getNodes()
          Gets this element's list of children.
 java.lang.String getNS()
          Gets this element's namespace.
 int getNumAttrs()
          Gets this element's number of attributes.
 java.lang.String getPrefix()
          Gets this element's namespace prefix.
 TextNode getText(boolean bPeek, boolean bReturnDefault, boolean bValidate)
          Gets this element's text node child.
 Node getXFAChild(int n)
          Gets this element's n'th XFA child.
 Node getXMLChild(int n)
          Gets this element's n'th XML child.
 boolean isInstalledLocaleAmbient()
          Determines if this element's installed locale is ambient.
 void loadXML(java.io.InputStream is, boolean bIgnoreAggregatingTag, boolean bReplaceContent)
          Loads and appends the specified XML fragment (or document) to this element.
 void saveXML(java.io.OutputStream outFile, DOMSaveOptions options)
          Serializes this element (and all its children) to an output stream.
 void setAttribute(Attribute attr, int eTag)
          Sets (adds) an attribute to this element.
 void setAttribute(int eVal, int eTag)
          Sets (adds) an enumerated attribute value to this element.
 Attribute setAttribute(java.lang.String nameSpace, java.lang.String qName, java.lang.String localName, java.lang.String value)
          Sets (adds) an attribute to this element.
 void setLocalName(java.lang.String name)
          Sets this element's local name.
 void setName(java.lang.String name)
          Sets this element's name attribute.
 void setNS(java.lang.String sNS)
          Sets this element's children null namespace to the given uri.
 void setQName(java.lang.String name)
          Sets this element's qualified name.
 
Methods inherited from class com.adobe.xfa.Node
checkAncestorPerms, checkDescendentPerms, checkPerms, cleanDirtyFlags, compareVersions, getData, getDynamicScriptProp, getNextXFASibling, getNextXMLSibling, getOwnerDocument, getPreviousXMLSibling, getSOMExpression, getXFAChildCount, getXFAParent, getXMLChildCount, getXMLParent, hasChanged, remove, resolveNode, resolveNode, resolveNodes, setNextXMLSibling, setPermsLock, setXMLParent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Element

protected Element()
Instantiates an element node.


Element

protected Element(Element parent,
                  Node prevSibling)
Instantiates an element node.

Parameters:
parent - the element's parent, if any.
prevSibling - the element's previous sibling, if any.

Element

protected Element(Element parent,
                  Node prevSibling,
                  java.lang.String uri,
                  java.lang.String name)
Instantiates an element node with the given properties.

Parameters:
parent - the element's parent, if any.
prevSibling - the element's previous sibling, if any.
uri - the element's namespace URI.
name - the element's name.
Method Detail

appendChild

public void appendChild(Node child,
                        boolean bValidate)
Appends the given child to this element.

Parameters:
child - 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.

assignNode

public final Node assignNode(java.lang.String sSOMExpression,
                             java.lang.String sValue,
                             int eMode)
Assigns the value given to the node located by the given SOM (Scripting Object Model) expression and interpreted relative to this element's context.

If the node doesn't exist, it can be created depending of the value of the given eMode. The eMode values are those identified in Node.assignNode().

Overrides:
assignNode in class Node
Parameters:
sSOMExpression - a SOM expression evaluating to a node.
sValue - the value to be assigned.
eMode - specifies whether the node should be created or not.
Returns:
the node identified by the SOM expression.

getAttr

public final Attribute getAttr(int n)
Gets this element's n'th attribute.

Parameters:
n - the zero-based index of the attribute.
Returns:
the n'th attribute.

getAttribute

public Attribute getAttribute(int eTag,
                              boolean bPeek,
                              boolean bValidate)
Gets this element's attribute whose attribute tag is given.

To peek at an attribute, set the peek argument to true. If the attribute is present, it is returned; otherwise null is returned.

To create an attribute, set the peek argument to false. If the attribute is absent, a default attribute is created and returned; for attributes with no default, null is returned.

If validation argument is true, and the validation fails, this method throws.

Parameters:
eTag - the tag of the attribute.
bPeek - whether to peek at the attribute or not.
bValidate - whether to validate the attribute or not.
Returns:
the attribute.

getXMLChild

public final Node getXMLChild(int n)
Gets this element's n'th XML child.

Parameters:
n - the zero-based index of the XML child.
Returns:
the n'th child.

getXFAChild

public final Node getXFAChild(int n)
Gets this element's n'th XFA child.

Parameters:
n - the zero-based index of the XFA child.
Returns:
the n'th child.

getElement

public Element getElement(int eTag,
                          boolean bPeek,
                          int nOccurrence,
                          boolean bReturnDefault,
                          boolean bValidate)
Gets this element's sub element whose element tag is given.

To return the element, set the returnDefault argument to true. If the element is present, it is returned; otherwise the default element is created and returned.

To peek at the element, set the peek argument to true. If the element is present, it is returned; otherwise null is returned. When set to true, default properties aren't created, and proto references are not expanded.

To create the element, set the peek argument to false. If the element is absent, a default element is created and returned.

If validation argument is true, and the validation fails, this method throws.

If the occurrence argument is out of range, this method throws.

Parameters:
eTag - the tag of the element to retrieve.
bPeek - whether to peek at the element, or not.
nOccurrence - the n'th occurrence of the element to retrieve.
bReturnDefault - whether to create a default element, or not.
bValidate - whether to validate the element, or not.
Returns:
the element, or null.

getFirstXMLChild

public Node getFirstXMLChild()
Gets this element's first XML child.

Overrides:
getFirstXMLChild in class Node
Returns:
the first XML child.

getFirstXFAChild

public Node getFirstXFAChild()
Gets this element's first XFA child.

Overrides:
getFirstXFAChild in class Node
Returns:
the first XFA child.

getInstalledLocale

public final java.lang.String getInstalledLocale()
Gets this element's installed locale. This method checks all enclosing field, draw, or subform ancestors, looking for their locale attribute.

Returns:
the installed locale name.

isInstalledLocaleAmbient

public final boolean isInstalledLocaleAmbient()
Determines if this element's installed locale is ambient.

Returns:
true if the installed locale name is "ambient", and false otherwise.
See Also:
Element.getInstalledLocale()

getLastXMLChild

public final Node getLastXMLChild()
Gets this element's last XML child.

Overrides:
getLastXMLChild in class Node
Returns:
the last XML child.

getModel

public final Model getModel()
Gets this element's model.

Overrides:
getModel in class Node
Returns:
the model.

getName

public java.lang.String getName()
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.

Specified by:
getName in class Node
Returns:
the name of the element.

getNodes

public NodeList getNodes()
Gets this element's list of children.

Overrides:
getNodes in class Node
Returns:
a node list of all child nodes.

getNS

public java.lang.String getNS()
Gets this element's namespace.

Returns:
the namespace URI.

getNumAttrs

public final int getNumAttrs()
Gets this element's number of attributes.

Returns:
the number of attributes.

getPrefix

public final java.lang.String getPrefix()
Gets this element's namespace prefix.

Returns:
the namespace prefix.

getText

public TextNode getText(boolean bPeek,
                        boolean bReturnDefault,
                        boolean bValidate)
Gets this element's text node child.

To return the text node, set the returnDefault argument to true. If the text node is present, it is returned; otherwise the default text node is created and returned.

To peek at the text node, set the peek argument to true. If the text node is present, it is returned; otherwise null is returned. When set to true, default properties aren't created, and proto references are not expanded.

To create the text node, set the peek argument to false. If the text node is absent, a default text node is created and returned.

If validation argument is true, and the validation fails, this method throws.

Parameters:
bPeek - whether to peek at the text node, or not.
bReturnDefault - whether to create a default text node, or not.
bValidate - whether to validate the text node, or not.
Returns:
the text node or null.

loadXML

public void loadXML(java.io.InputStream is,
                    boolean bIgnoreAggregatingTag,
                    boolean bReplaceContent)
Loads and appends the specified XML fragment (or document) to this element.

Parameters:
is - the input stream of XML fragment.
bIgnoreAggregatingTag - ignore the root node of the XML fragment, when true, in which case, the children of the root node will be appended to this element. Append the root node of the XML fragment to this element, when false.
bReplaceContent - replace the content of this element with the content of the root node of the XML fragment, when true.

saveXML

public void saveXML(java.io.OutputStream outFile,
                    DOMSaveOptions options)
Serializes this element (and all its children) to an output stream.

Parameters:
outFile - an output stream.
options - the XML save options

setAttribute

public void setAttribute(Attribute attr,
                         int eTag)
Sets (adds) an attribute to this element.

Parameters:
attr - the attribute.
eTag - The XFA tag name of the attribute being set.

setAttribute

public final void setAttribute(int eVal,
                               int eTag)
Sets (adds) an enumerated attribute value to this element.

Parameters:
eVal - the enumerated attribute value. See EnumAttr for valid values.
eTag - the XFA tag name of the attribute being set. See XFA for valid tag names.

setAttribute

public final Attribute setAttribute(java.lang.String nameSpace,
                                    java.lang.String qName,
                                    java.lang.String localName,
                                    java.lang.String value)
Sets (adds) an attribute to this element.

Parameters:
nameSpace - namespace of the attribute.
qName - the qualified name of the attribute.
localName - the local name of the attribute.
value - the value of the attribute.
Returns:
the attribute we just updated or created

setLocalName

public void setLocalName(java.lang.String name)
Sets this element's local name.

Parameters:
name - the new local name.

setName

public void setName(java.lang.String name)
Sets this element's name attribute.

Overrides:
setName in class Node
Parameters:
name - the name attribute value.

setNS

public final void setNS(java.lang.String sNS)
Sets this element's children null namespace to the given uri.

Parameters:
sNS - the namespace uri. This string must be interned. Javaport: added.

setQName

public final void setQName(java.lang.String name)
Sets this element's qualified name.

Parameters:
name - the new qualified name.

XFA4J

© 2005 Adobe Systems Incorporated. All Rights Reserved.