public class DomElement extends Object
Modifier and Type | Class and Description |
---|---|
static class |
DomElement.DomElementException |
static class |
DomElement.NotUniqueChildException |
static class |
DomElement.RequiredChildMissingException |
static class |
DomElement.UnexpectedChildException |
Constructor and Description |
---|
DomElement(Document owner) |
Modifier and Type | Method and Description |
---|---|
static void |
addDavStatus(Element prop,
String status)
Adds a DAV:status
child element with the given content.
|
static void |
attachPropertyFlag(Element e,
String flag,
boolean value)
Attaches property flag to a property.
|
static void |
attachSoapArrayType(Element e,
QualifiedName dt,
int size)
Attaches SOAP array type information to an element.
|
static void |
attachXmlDataDataType(Element e,
String dt)
Attaches XML DATA datatype information to an element to support
the special requirements of the Microsoft Webfolder client.
|
static void |
attachXsdDataType(Element e,
QualifiedName dt)
Attaches XML Schema datatype information to an element.
|
static void |
checkChildElementConstraints(Node parent,
IName allowed) |
static void |
checkChildElementConstraints(Node parent,
Set allowed) |
static List |
getChildren(Node parent,
IName name)
Gets all child element nodes with matching
IName . |
static List |
getChildren(Node parent,
String namespaceUri,
String name)
Get all children with matching namespace and name.
|
static NodeList |
getElements(Element parent,
IName name)
Get NodeList containing all descendants
with a certain element name.
|
static Node |
getFirstChild(Node parent,
IName name)
Get first child element with given name.
|
static Node |
getFirstChildOrDie(Node parent,
IName name,
boolean required)
Get first child with specified name, throwing an exception when there are multiple.
|
static List |
getHrefList(Node e) |
static Set |
getHrefs(Node e) |
static IInternationalString |
getInternationalText(Node e)
Gets an
IInternationalString from a node. |
static String |
getProcessingInstruction(Document doc,
String target)
Get the value of the first instance of a top-level processing instruction by name.
|
static String |
getSingleHref(Node e) |
static String |
getSingleHref(Node e,
boolean required) |
static String |
getText(Node e)
Get the (concatenated) text content of an element (only visits direct
children of type
Node.TEXT_NODE and Node.CDATA_SECTION_NODE ). |
static Object |
getTypedValue(Element e,
DateFormat df)
Gets the typed value from text content of an element based on it's
xsi:type attribute.
|
static boolean |
hasChild(Node parent,
IName name)
Determines if node has child with matching
IName . |
static boolean |
hasElementChildrenInDavNs(Element elem)
Checks whether there are Element children in the DAV: namespace.
|
static boolean |
hasOnlyTextContent(Node e)
Checks whether an element node contains only text content (being
nodes of type
Node.TEXT_NODE or Node.CDATA_SECTION_NODE }. |
static Node |
importNode(Document owner,
Node imp,
boolean deep)
Wrapper method for
Document.importNode(Node, boolean) , providing logging of
fatal errors (seen in early Xerces versions). |
static void |
inheritXmlAttributes(Element elem)
Inherit all attributes in the XML namespace, according to
Canonical XML
|
static Element |
makeNew(Document doc,
IName name)
Create a new element node with the given name.
|
static Element |
makeNew(Document doc,
IName name,
Object content)
Create a new element node with the given name and
optional content
|
static Element |
makeNew(Document doc,
QualifiedName name)
Create a new element node with the given qualified name (respecting the namespace prefix).
|
static Element |
makeNew(Document doc,
QualifiedName name,
Object content)
Create a new element node with the given name
(respecting the prefix) and optional content
|
static Element |
makeNew(Document doc,
String namespace,
String name)
Create a new element node
|
static Element |
makeNew(Document doc,
String namespace,
String name,
Object content)
Create a new element node with optional content
|
static Element |
makeNew(Document doc,
String namespace,
String prefix,
String name,
Object content)
Create a new element node (with specific prefix) and optional content
|
Element |
makeNew(IName name)
Create a new element node
|
Element |
makeNew(IName name,
Object content)
Create a new element node with optional content
|
static Comment |
makeSafeComment(Document doc,
String text) |
static String |
makeSafeXml(String val)
Check the string's content for XML compliance
(whether it can be used as value for a text node).
|
static boolean |
match(Node n,
IName name)
Compare a node's namespace and name
|
static boolean |
match(Node n,
Set names) |
static boolean |
match(Node n,
String namespace,
String name)
Compare a node's namespace and name
|
static void |
setText(Element e,
long val)
Set the text element content of an element to a stringified long value,
removing all previous content.
|
static void |
setText(Element e,
String val)
Set the text element content of an element, allowing
null
and removing all previous content. |
static void |
setUnsafeText(Element e,
String val)
Set the text element content of an element, allowing
null
and removing all previous content. |
public DomElement(Document owner)
public Element makeNew(IName name, Object content)
name
- name for the elementcontent
- optional content (content of type Element
is added as a child node, IInternationalString
s are added as Text
node
while setting the attribute xml:lang, otherwise the string value is added as a
Text
node)public Element makeNew(IName name)
name
- name for the elementpublic static Element makeNew(Document doc, String namespace, String prefix, String name, Object content)
doc
- the owner documentnamespace
- namespace namename
- element's local namecontent
- optional content (content of type Element
is added as a child node, IInternationalString
s are added as Text
node
while setting the attribute xml:lang, otherwise the string value is added as a
Text
node)prefix
- no descriptionpublic static Element makeNew(Document doc, String namespace, String name)
doc
- the owner documentnamespace
- namespace namename
- element's local namepublic static Element makeNew(Document doc, String namespace, String name, Object content)
doc
- the owner documentnamespace
- namespace namename
- element's local namecontent
- optional content (content of type Element
is added as a child node, IInternationalString
s are added as Text
node
while setting the attribute xml:lang, otherwise the string value is added as a
Text
node)public static Element makeNew(Document doc, IName name)
doc
- the owner documentname
- element's namepublic static Element makeNew(Document doc, QualifiedName name)
doc
- the owner documentname
- element's namepublic static Element makeNew(Document doc, IName name, Object content)
doc
- the owner documentname
- element's namecontent
- optional content (content of type Element
is added as a child node, IInternationalString
s are added as Text
node
while setting the attribute xml:lang, otherwise the string value is added as a
Text
node)public static Element makeNew(Document doc, QualifiedName name, Object content)
doc
- the owner documentname
- element's namecontent
- optional content (content of type Element
is added as a child node, IInternationalString
s are added as Text
node
while setting the attribute xml:lang, otherwise the string value is added as a
Text
node)public static boolean match(Node n, String namespace, String name)
n
- nodenamespace
- namespace namename
- namepublic static boolean match(Node n, IName name)
n
- nodename
- nameDAV:
and the name matchespublic static void attachXmlDataDataType(Element e, String dt)
e
- the element to which the datatype should be attacheddt
- the datatypepublic static void attachPropertyFlag(Element e, String flag, boolean value)
e
- the element to which the datatype should be attachedflag
- name of flagvalue
- boolean value of flagpublic static void attachXsdDataType(Element e, QualifiedName dt)
e
- the element to which the datatype should be attacheddt
- the datatypepublic static void attachSoapArrayType(Element e, QualifiedName dt, int size)
e
- the element to wich the datatype should be attacheddt
- the datatypesize
- size of arraypublic static boolean hasElementChildrenInDavNs(Element elem)
elem
- the element to checkpublic static void addDavStatus(Element prop, String status)
prop
- Element to which the DAV:status shall be addedstatus
- the HTTP status to setpublic static Object getTypedValue(Element e, DateFormat df)
Boolean
),
xs:dateTime
(mapped to Date
),
xs:long
(mapped to Long
) and
xs:int
(mapped to Integer
).
Other types are treated as string values. If the text content can not
be parsed according to the data type information, it's treated as string
as well.e
- containing elementdf
- date format parser (for ISO8601 dates)public static String getText(Node e)
Node.TEXT_NODE
and Node.CDATA_SECTION_NODE
).e
- parent elementpublic static String getSingleHref(Node e, boolean required) throws DomElement.DomElementException
DomElement.DomElementException
public static String getSingleHref(Node e) throws DomElement.DomElementException
DomElement.DomElementException
public static IInternationalString getInternationalText(Node e)
IInternationalString
from a node. For non-elements,
this is just the text content without language identification. For
elements, an attempts is made to find an xml:lang attribute in scope
to determine the language.e
- containing nodeIInternationalString
public static boolean hasOnlyTextContent(Node e)
Node.TEXT_NODE
or Node.CDATA_SECTION_NODE
}.e
- containing elementtrue
if only text contentpublic static NodeList getElements(Element parent, IName name)
parent
- the parent of the elements to findname
- the name of the elements to findpublic static List getChildren(Node parent, String namespaceUri, String name)
parent
- no descriptionnamespaceUri
- no descriptionname
- no descriptionpublic static Node getFirstChildOrDie(Node parent, IName name, boolean required) throws DomElement.DomElementException
parent
- container elementname
- name of requested child elementrequired
- when true
, an exception is thrown when the child element doesn't existnull
when not presentDomElement.NotUniqueChildException
- when multiple childs presentDomElement.RequiredChildMissingException
- when child not present and required was set to true
DomElement.DomElementException
public static void checkChildElementConstraints(Node parent, IName allowed) throws DomElement.UnexpectedChildException
public static void checkChildElementConstraints(Node parent, Set allowed) throws DomElement.UnexpectedChildException
public static Node getFirstChild(Node parent, IName name)
parent
- container elementname
- specified namenull
when not presentpublic static List getChildren(Node parent, IName name)
IName
.parent
- parent node from hwere to matchname
- element name to match fornull
).public static boolean hasChild(Node parent, IName name)
IName
.parent
- parent node from hwere to matchname
- element name to match forpublic static String getProcessingInstruction(Document doc, String target)
doc
- to be checkedtarget
- PI targetnull
public static void setUnsafeText(Element e, String val) throws DOMException
null
and removing all previous content. Checks for valid character content.e
- the elementval
- the text contentDOMException
- with code DOMException.INVALID_CHARACTER_ERR
when invalid content presentpublic static String makeSafeXml(String val)
val
- string valueDOMException
- with code DOMException.INVALID_CHARACTER_ERR
when invalid content presentpublic static void setText(Element e, String val)
null
and removing all previous content.e
- the elementval
- the text contentpublic static void setText(Element e, long val)
e
- the elementval
- the long valuepublic static void inheritXmlAttributes(Element elem)
elem
- anchor element (attributes are added)public static Node importNode(Document owner, Node imp, boolean deep)
Document.importNode(Node, boolean)
, providing logging of
fatal errors (seen in early Xerces versions).owner
- owner documentimp
- node to importdeep
- true
when importing recursivelyAccess Rights |
---|
SC | DC | Public Part | ACH |
---|---|---|---|
[sap.com] KMC-CM
|
[sap.com] tc/km/frwk
|
api
|
EP-KM-CM
|
[sap.com] KMC-WPC
|
[sap.com] tc/kmc/wpc/wpcfacade
|
api
|
EP-PIN-WPC-WCM
|
Copyright 2018 SAP AG Complete Copyright Notice