|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.ibm.designer.domino.xsp.api.util.XPagesDOMUtil
public class XPagesDOMUtil
A utility class that allows users to perform certain operations on the DOM Model of an XPage. It is recommended to use this class when performing certain operations on an XPage like getting the value of an attribute, setting an attribute value etc.
Field Summary | |
---|---|
static int |
MODE_ATTRIBUTE
|
static int |
MODE_COMPLEXCDATA
|
static int |
MODE_COMPLEXTEXT
|
static int |
MODE_INVALID_CDATA
|
static java.lang.String |
XML_NAMESPACE
|
static java.lang.String |
XML_NAMESPACE_PREFIX_SEP
|
protected static java.lang.String |
XML_PI_DATA
|
protected static java.lang.String |
XML_PI_TAG
|
Constructor Summary | |
---|---|
XPagesDOMUtil()
|
Method Summary | |
---|---|
static org.w3c.dom.Element |
addComplexProperty(org.w3c.dom.Element elt,
java.lang.String propertyName,
java.lang.String value)
Adds a complex property to the given element. |
protected static boolean |
checkParent(FacesDefinition definition,
java.lang.String namespaceUri,
java.lang.String id)
|
static void |
clearElement(org.w3c.dom.Element element)
Remove all of the given element's children. |
static void |
clearIds(org.w3c.dom.Element element)
Set all the IDs in the given element and all it's children to null. |
static org.w3c.dom.Element |
createChildElement(org.w3c.dom.Element parent,
FacesRegistry registry,
java.lang.String tag)
Create a child control inside another element. |
static org.w3c.dom.Element |
createElement(org.w3c.dom.Document ownerDocument,
FacesRegistry registry,
java.lang.String uri,
java.lang.String tagName)
Helper method to create an element. |
static java.lang.String |
createNamespacePrefix(java.lang.String prefix)
Creates a namespace prefix, given the control prefix. |
static java.lang.String |
createQualifiedTagName(java.lang.String prefix,
java.lang.String localName)
Combine a prefix and local name into a qualified name. |
static org.w3c.dom.Element |
createXPagesElement(org.w3c.dom.Document doc,
java.lang.String localName)
Creates an XPages core control element. |
protected static boolean |
elementNeedsId(FacesRegistry registry,
org.w3c.dom.Element element,
org.w3c.dom.Document doc)
Determines if the given element requires an ID in accordance with the tag's definition in the FacesRegistry. |
protected static boolean |
elementNeedsVar(FacesRegistry registry,
org.w3c.dom.Element element,
org.w3c.dom.Document doc)
Determines if the given element requires a var attribute in accordance with the tag's definition in the FacesRegistry. |
static java.lang.String |
ensureNamespaceDeclaration(org.w3c.dom.Document doc,
java.lang.String namespaceUri,
java.lang.String prefix)
Ensure a namspaceUri exists in a document. |
static boolean |
ensureRequiredNodesExist(org.w3c.dom.Document root)
Ensure the required document nodes exist to make this model a legal XPages form. |
static void |
ensureUniqueIds(org.w3c.dom.Document doc,
org.w3c.dom.Node root,
FacesRegistry registry)
Ensures the ids applied to the supplied node are unique in the context of the document they are being inserted into. |
static void |
ensureUniqueIds(org.w3c.dom.Document doc,
org.w3c.dom.Node root,
FacesRegistry registry,
boolean generateIdIfNotSet)
Ensures the ids applied to the supplied node are unique in the context of the document they are being inserted into. |
static void |
ensureUniqueIdsGenerateIfRequested(org.w3c.dom.Document doc,
org.w3c.dom.Node root,
FacesRegistry registry,
boolean generateId)
Using the given document as a reference for existing ids, ensures every element in the root has a unique id. |
static void |
ensureUniqueVars(org.w3c.dom.Document doc,
org.w3c.dom.Node root,
FacesRegistry registry)
Using the given document as a reference for existing vars, ensures every element in the given node has a unique var. |
static boolean |
findGlobalDefAndAddDependency(java.lang.String uri,
java.lang.String tagName,
DesignerProject project)
Finds a FacesDefinition for the given tag. |
static void |
formatNode(org.w3c.dom.Node node,
org.w3c.dom.ranges.Range range)
Formats a single node |
static void |
formatNodes(org.w3c.dom.Node[] nodes,
org.w3c.dom.ranges.Range range)
Format an array of nodes. |
static java.lang.String |
generateUniqueId(java.util.List<java.lang.String> idList,
org.w3c.dom.Element element)
Returns a unique id candidate for the given element. |
static java.lang.String |
generateUniqueId(java.util.List<java.lang.String> idList,
org.w3c.dom.Element element,
java.lang.String hint)
Returns a unique id candidate for the given element. |
static java.lang.String |
generateUniqueVar(java.util.List<java.lang.String> varList,
org.w3c.dom.Element element)
Returns a unique var candidate for the given element. |
static java.lang.String |
generateUniqueVar(java.util.List<java.lang.String> varList,
org.w3c.dom.Element element,
java.lang.String hint)
Returns a unique var candidate for the given element. |
static java.lang.String |
getAttribute(org.w3c.dom.Element element,
java.lang.String attribute)
Helper method to get an attribute value. |
static java.util.Map<java.lang.String,java.lang.String> |
getAttributeChildren(org.w3c.dom.Element element)
Get all the "this." attribute children of a node. |
static org.w3c.dom.Element |
getAttributeElement(org.w3c.dom.Element element,
java.lang.String attribute)
Return the element for the given attribute if it exists. |
static java.util.Map<java.lang.String,java.lang.String> |
getAttributes(org.w3c.dom.Element element)
Get all the attributes for an element. |
static java.lang.String |
getDefaultPrefix()
Returns the default namespace prefix for an XPage Core tag. |
static FacesDefinition |
getFacesDefinition(org.w3c.dom.Element element,
FacesRegistry registry)
Return a FacesDefintion for the given element. |
static java.lang.String[] |
getIds(org.w3c.dom.Node root,
org.w3c.dom.Node nodeToExclude)
Returns the IDs of all of the node that are a child of the given node. |
static java.lang.String[] |
getIds(org.w3c.dom.Node startNode,
org.w3c.dom.Node nodeToExclude,
FacesRegistry registry,
java.lang.String namespaceUri,
java.lang.String id,
boolean checkParent)
Returns an array of ids that are already defined on the XPage. |
static java.lang.String[] |
getIdsExcludeList(org.w3c.dom.Node root,
java.util.List<org.w3c.dom.Node> nodesToExclude)
|
static java.lang.String[] |
getIdsExcludeList(org.w3c.dom.Node startNode,
java.util.List<org.w3c.dom.Node> nodesToExclude,
FacesRegistry registry,
java.lang.String namespaceUri,
java.lang.String id,
boolean checkParent)
|
static int |
getModeForValue(java.lang.String attributeValue)
Returns the 'mode' for a given attribute value. |
static java.lang.String |
getNamespacePrefix(org.w3c.dom.Document doc,
java.lang.String namespaceUri)
Get the namespace prefix in use in a document of a namespaceUri. |
static java.lang.String |
getNamespaceUri()
Get the default namespace URI for core XPage controls |
static java.lang.String |
getNamespaceUri(org.w3c.dom.Document doc,
org.w3c.dom.Node node)
Return the namespace uri for the given element, searching the document if necessary. |
static java.lang.String |
getNamespaceUriForPrefix(org.w3c.dom.Document doc,
java.lang.String prefix)
Return the namespace uri associated with the given prefix, or null if there is none. |
static java.lang.String |
getPrefix(org.w3c.dom.Document doc,
java.lang.String namespaceUri,
FacesRegistry registry,
java.lang.String tagName)
Return the prefix for the given namespace URI and tag name. |
static java.lang.String |
getRootTagName()
Get the tagname that is the root of the xsp file (view). |
static java.lang.String[] |
getValuesOfAttr(org.w3c.dom.Node root,
org.w3c.dom.Node nodeToExclude,
FacesRegistry registry,
java.lang.String namespaceUri,
java.lang.String id,
boolean checkParent,
java.lang.String attrName)
Returns the values for all occurrances of a given attribute on a given document |
static java.lang.String[] |
getValuesOfAttrExcludeList(org.w3c.dom.Node root,
java.util.List<org.w3c.dom.Node> nodesToExclude,
FacesRegistry registry,
java.lang.String namespaceUri,
java.lang.String id,
boolean checkParent,
java.lang.String attrName)
Returns the values for all occurrances of a given attribute on a given document |
static java.lang.String[] |
getVars(org.w3c.dom.Node startNode,
org.w3c.dom.Node nodeToExclude)
Returns all of the values of the 'var' attributes on the document |
static java.lang.String[] |
getVars(org.w3c.dom.Node startNode,
org.w3c.dom.Node nodeToExclude,
FacesRegistry registry,
java.lang.String namespaceUri,
java.lang.String id,
boolean checkParent)
Returns the values of all of the var attributes on the given document. |
static org.w3c.dom.Element |
getViewNode(org.w3c.dom.Document doc)
Get the view node of a given document. |
static void |
initializeDefaultValues(org.w3c.dom.Element element,
FacesRegistry registry)
Helper method to call after an element has been created. |
static boolean |
isComponent(FacesDefinition def,
java.lang.String namespaceUri,
java.lang.String id)
Return true if the given def matches the given uri and id. |
static boolean |
setAttribute(org.w3c.dom.Element elt,
java.lang.String attributeName,
java.lang.String value)
Helper method to set an attribute. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int MODE_ATTRIBUTE
public static final int MODE_COMPLEXTEXT
public static final int MODE_COMPLEXCDATA
public static final int MODE_INVALID_CDATA
protected static final java.lang.String XML_PI_TAG
protected static final java.lang.String XML_PI_DATA
public static final java.lang.String XML_NAMESPACE
public static final java.lang.String XML_NAMESPACE_PREFIX_SEP
Constructor Detail |
---|
public XPagesDOMUtil()
Method Detail |
---|
public static org.w3c.dom.Element addComplexProperty(org.w3c.dom.Element elt, java.lang.String propertyName, java.lang.String value)
<xp:inputText id="inputText1"> <xp:this.converter> <xp:convertDateTime type="date"></xp:convertDateTime> </xp:this.converter> </xp:inputText>
elt
- the element to which the complex property is being definedpropertyName
- the name of the complex propertyvalue
- the value of the complex property
protected static boolean checkParent(FacesDefinition definition, java.lang.String namespaceUri, java.lang.String id)
public static void clearElement(org.w3c.dom.Element element)
element
- the element whose children are to be removedpublic static void clearIds(org.w3c.dom.Element element)
element
- the element to clearpublic static org.w3c.dom.Element createChildElement(org.w3c.dom.Element parent, FacesRegistry registry, java.lang.String tag)
parent
- the parent of the element to be createdregistry
- The FacesRegistry for the current applicationtag
- the tag name of the new element
public static org.w3c.dom.Element createElement(org.w3c.dom.Document ownerDocument, FacesRegistry registry, java.lang.String uri, java.lang.String tagName)
owenerDocument
- the document where the element is to be createdregistry
- the FacesRegistry for the current applicationuri
- the URI for the new elementtagName
- the XML tag local name of the new element
public static java.lang.String createNamespacePrefix(java.lang.String prefix)
prefix
- the proposed prefix, may not be null
public static java.lang.String createQualifiedTagName(java.lang.String prefix, java.lang.String localName)
prefix
- the namespace prefixlocalName
- the XML localname of the tag.
public static org.w3c.dom.Element createXPagesElement(org.w3c.dom.Document doc, java.lang.String localName)
doc
- document that is to contain the element, cannot be null;localName
- the XML local tag name of the element to be created, must belong to the XPages namespace
protected static boolean elementNeedsId(FacesRegistry registry, org.w3c.dom.Element element, org.w3c.dom.Document doc)
tagName
-
protected static boolean elementNeedsVar(FacesRegistry registry, org.w3c.dom.Element element, org.w3c.dom.Document doc)
tagName
-
public static java.lang.String ensureNamespaceDeclaration(org.w3c.dom.Document doc, java.lang.String namespaceUri, java.lang.String prefix)
doc
- the documentnamespaceUri
- URI being soughtprefix
- the prefix to use if one is not already defined
public static boolean ensureRequiredNodesExist(org.w3c.dom.Document root)
ensureProcessingInstructionExists(Document)
and
ensureViewExists(Document)
.
root
- the root of the dom document
public static void ensureUniqueIds(org.w3c.dom.Document doc, org.w3c.dom.Node root, FacesRegistry registry)
doc
- the Document
that the root
Node will be inserted intoroot
- the Node to be inserted into the Document.registry
- the FacesRegistry for the current applicationpublic static void ensureUniqueIds(org.w3c.dom.Document doc, org.w3c.dom.Node root, FacesRegistry registry, boolean generateIdIfNotSet)
doc
- the Document
that the root
Node will be inserted intoroot
- the Node to be inserted into the Document.registry
- the FacesRegistry for the current applicationgenerateIdIfNotSet
- if true, and a Node is found to not have an id an ID will be generated for the nodepublic static void ensureUniqueIdsGenerateIfRequested(org.w3c.dom.Document doc, org.w3c.dom.Node root, FacesRegistry registry, boolean generateId)
generateId
is true then it will always generate an ID for the given node (and its children).
doc
- the document that the node is being inserted intoFacesRegistry
- the registry for the current applicationgenerateId
- if true and an element doesn't have an id, then a new one will be set. If false an id is not generatedpublic static void ensureUniqueVars(org.w3c.dom.Document doc, org.w3c.dom.Node root, FacesRegistry registry)
doc
- the document that the node is being inserted intoroot
- the node being inserted - will be examined for the var attributeregistry
- the FacesRegistry for the current applicationpublic static boolean findGlobalDefAndAddDependency(java.lang.String uri, java.lang.String tagName, DesignerProject project)
uri
- the namespace URI of the tag being added to the pagetagName
- the tag name of the tag being added to the pageproject
- the current application
public static void formatNode(org.w3c.dom.Node node, org.w3c.dom.ranges.Range range)
node
- range
- public static void formatNodes(org.w3c.dom.Node[] nodes, org.w3c.dom.ranges.Range range)
nodes
- range
- public static java.lang.String generateUniqueId(java.util.List<java.lang.String> idList, org.w3c.dom.Element element)
idList
- a list of existing idselement
- the new element being added to the page
public static java.lang.String generateUniqueId(java.util.List<java.lang.String> idList, org.w3c.dom.Element element, java.lang.String hint)
idList
- a list of existing idselement
- the new element being added to the pagehint
- a hint that will be used in place of the tag name if provided
public static java.lang.String generateUniqueVar(java.util.List<java.lang.String> varList, org.w3c.dom.Element element)
varList
- a list of existing varselement
- the new element being added to the page
public static java.lang.String generateUniqueVar(java.util.List<java.lang.String> varList, org.w3c.dom.Element element, java.lang.String hint)
varList
- a list of existing varselement
- the new element being added to the pagehint
- a hint that will be used in place of the tag name if provided
public static java.lang.String getAttribute(org.w3c.dom.Element element, java.lang.String attribute)
<inputText id="inputText1"> <xp:this.value><![CDATA[#{javascript:return "test"}]]></xp:this.value> </inputText>
elt
- the element that whose attribute value is being queriedattributeName
- the name of the attribute that is sought
public static java.util.Map<java.lang.String,java.lang.String> getAttributeChildren(org.w3c.dom.Element element)
element
- the element to be examined
public static org.w3c.dom.Element getAttributeElement(org.w3c.dom.Element element, java.lang.String attribute)
<xp:inputText> <xp:this.style>width:300px;</xp:this.style> </xp:inputText>getAttributeElement(
element
- the Element whose attribute is being queriedattribute
- the name of the attribute we are looking up
public static java.util.Map<java.lang.String,java.lang.String> getAttributes(org.w3c.dom.Element element)
element
- node to get attributes for. May not be null.
public static java.lang.String getDefaultPrefix()
public static FacesDefinition getFacesDefinition(org.w3c.dom.Element element, FacesRegistry registry)
element
- the element whose definition is soughtregistry
- the FacesRegistry for the current applicatio
public static java.lang.String[] getIds(org.w3c.dom.Node root, org.w3c.dom.Node nodeToExclude)
root
- the node to search through.
public static java.lang.String[] getIds(org.w3c.dom.Node startNode, org.w3c.dom.Node nodeToExclude, FacesRegistry registry, java.lang.String namespaceUri, java.lang.String id, boolean checkParent)
startNode
- the node to start searching fromnodeToExclude
- a particular node whose id should not be included in the returned arrayregistry
- the FacesRegistry for the current applicationnamespaceUri
- an optional namespace that can be used to filter the elements whose ids are checkedid
- an optional control type id of controls to be filtered. e.g. controls of type "javax.faces.Output"checkParent
- a flag indicating whether or not the FacesDefinition hierarchy should be searched
public static java.lang.String[] getIdsExcludeList(org.w3c.dom.Node root, java.util.List<org.w3c.dom.Node> nodesToExclude)
root
- nodesToExclude
-
public static java.lang.String[] getIdsExcludeList(org.w3c.dom.Node startNode, java.util.List<org.w3c.dom.Node> nodesToExclude, FacesRegistry registry, java.lang.String namespaceUri, java.lang.String id, boolean checkParent)
id
- return only ids of elements with the given ID and URI - pass null in to disregard
this check.checkParent
- if looking for only the given namespace, tagname, if this element does
not match, should we check to see if it inherits from this type of element?public static int getModeForValue(java.lang.String attributeValue)
attributeValue
- the value of an attribute
public static java.lang.String getNamespacePrefix(org.w3c.dom.Document doc, java.lang.String namespaceUri)
doc
- the document to search for the prefixnamespaceUri
- the namespace URI being searched for
public static java.lang.String getNamespaceUri()
public static java.lang.String getNamespaceUri(org.w3c.dom.Document doc, org.w3c.dom.Node node)
doc
- the document to searchnode
- the node whose URI is soughtpublic static java.lang.String getNamespaceUriForPrefix(org.w3c.dom.Document doc, java.lang.String prefix)
doc
- the document to searchprefix
- the prefix whose URI is soughtpublic static java.lang.String getPrefix(org.w3c.dom.Document doc, java.lang.String namespaceUri, FacesRegistry registry, java.lang.String tagName)
doc
- the document to searchnamespaceUri
- the namespace URI whose prefix is soughtregistry
- the FacesRegistry which contains the tag definitiontagName
- the tag that requires a prefix
public static java.lang.String getRootTagName()
public static java.lang.String[] getValuesOfAttr(org.w3c.dom.Node root, org.w3c.dom.Node nodeToExclude, FacesRegistry registry, java.lang.String namespaceUri, java.lang.String id, boolean checkParent, java.lang.String attrName)
root
- the root node to start searching fromnodeToExclude
- a node to exclude from the searchregistry
- the FacesRegistry for the current applicationnamespaceUri
- the URI for nodes to checkid
- an optional control type id of controls to be filtered. e.g. controls of type "javax.faces.Output"checkParent
- a flag which determines if only children of the root should be searchedattrName
- the name of the attribute whose values are to be returned
public static java.lang.String[] getValuesOfAttrExcludeList(org.w3c.dom.Node root, java.util.List<org.w3c.dom.Node> nodesToExclude, FacesRegistry registry, java.lang.String namespaceUri, java.lang.String id, boolean checkParent, java.lang.String attrName)
root
- the root node to start searching fromnodesToExclude
- a list of nodes to exclude from the searchregistry
- the FacesRegistry for the current applicationnamespaceUri
- the URI for nodes to checkid
- an optional control type id of controls to be filtered. e.g. controls of type "javax.faces.Output"checkParent
- a flag which determines if only children of the root should be searchedattrName
- the name of the attribute whose values are to be returned
public static java.lang.String[] getVars(org.w3c.dom.Node startNode, org.w3c.dom.Node nodeToExclude)
startNode
- the starting point for the searchnodeToExclue
- a node to exclude from the search
public static java.lang.String[] getVars(org.w3c.dom.Node startNode, org.w3c.dom.Node nodeToExclude, FacesRegistry registry, java.lang.String namespaceUri, java.lang.String id, boolean checkParent)
startNode
- the node to start searching fromnodeToExclude
- a node that should not be included in the searchregistry
- the FacesRegistry for the current applicationnamespaceUri
- the URI of the tags that are to be searchedid
- an optional control type id of controls to be filtered. e.g. controls of type "javax.faces.Output"checkParent
- a flag which determines if only children of the root should be searched
public static org.w3c.dom.Element getViewNode(org.w3c.dom.Document doc)
doc
- the document to search
public static void initializeDefaultValues(org.w3c.dom.Element element, FacesRegistry registry)
element
- the element whose attributes are to be initializedregistry
- the FacesRegistry that contains a definition for the given elementpublic static boolean isComponent(FacesDefinition def, java.lang.String namespaceUri, java.lang.String id)
public static boolean setAttribute(org.w3c.dom.Element elt, java.lang.String attributeName, java.lang.String value)
<inputText id="inputText1"> <xp:this.value><![CDATA[#{javascript:return "test"}]]></xp:this.value> </inputText>
elt
- the element that the attribute is to be set onattributeName
- the name of the attribute that is to be setvalue
- the new value of the attribute
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |