public class OwXMLDOMUtil extends Object
Implements DOM Node utility methods for XML access.
Please note: DOM is not thread safe.
To read the configuration for plugins and boot options use OwXMLUtil getters only.
Alfresco Workdesk
Copyright (c) Alfresco Software, Inc.
All rights reserved.
For licensing information read the license.txt file or
go to: http://wiki.alfresco.com
Constructor and Description |
---|
OwXMLDOMUtil(String strRootNodeName_p)
construct an empty XML Dom node
|
Modifier and Type | Method and Description |
---|---|
Node |
addNode(String strSubNodeName_p)
add a subnode to the node wrapped by this object
|
void |
addTextNode(String strNodeName_p,
String strText_p)
add a text node in the wrapped node
|
static String |
encodeSpecialCharactersForXML(String xmlString_p)
encodes special XML characters from the given string
|
static Element |
getChildElement(Element parent_p,
String childElementName_p)
get the child element
|
static String |
getChildElementText(Element parent_p,
String childElementName_p)
get text element of a given child
|
static Node |
getChildNode(Node node_p,
String childToFind_p)
get a given child node
|
static Document |
getDocumentFromInputStream(InputStream inputStream_p)
get a XML document from a given InputStream
|
static Document |
getDocumentFromString(String xml_p)
get a XML document from a given String
|
static String |
getElementText(Element element_p)
get the text of a node
|
InputStream |
getInputStream()
get an input stream for the XML content of the wrapped node
|
static InputStream |
getInputStream(Node node_p)
get an input stream for the XML content of a given node
|
static Document |
getNewDocument()
get a new XML document
|
static boolean |
getSafeBooleanAttributeValue(Node node_p,
String strAttributeName_p,
boolean fDefault_p)
get the value of a boolean attribute [true | false], catch exception
|
static boolean |
getSafeBooleanValue(Node node_p,
boolean fDefault_p)
get the value of a boolean node [true | false], catch exception
|
static List |
getSafeCDATAList(Node node_p)
retrieve a CDATA defined strings list from a node definition
|
static int |
getSafeIntegerAttributeValue(Node node_p,
String strAttributeName_p,
int iDefault_p)
get the value of a string attribute, catch exception
|
static List |
getSafeNodeList(Node node_p)
retrieve a node list in a subnode
|
static String |
getSafeStringAttributeValue(Node node_p,
String strAttributeName_p,
String strDefault_p)
get the value of a string attribute, catch exception
|
static List |
getSafeStringList(Node node_p)
retrieve a string list in a node
|
static Set |
getSafeStringSet(Node node_p)
retrieve a string list in a node
|
static void |
initialize(Document document)
Prepares the given DOM Document for concurrent access.
|
static void |
initialize(Node node)
Prepares the given DOM Node for concurrent access.
|
static String |
makeXMLString(String sText_p)
create a XML conform text representation
|
static void |
setNodeAttribute(Document document_p,
Node node_p,
String attrName_p,
String attrValue_p)
set a node attribute to the node of a given document
|
static boolean |
toFile(File file_p,
Node node_p)
write XML Node to file
|
String |
toString() |
static String |
toString(Node node_p)
write XML Node to a String
|
static void |
writeHtmlDump(Writer w_p,
Node node_p)
write XML Node as HTML to a writer object
|
static void |
writeHtmlDumpFiltered(Writer htmlWriter_p,
Node m_Node,
Map<String,String> values) |
public Node addNode(String strSubNodeName_p)
strSubNodeName_p
- String name of the new nodepublic void addTextNode(String strNodeName_p, String strText_p)
strNodeName_p
- String tag name of new nodestrText_p
- String text to set as new textnodepublic InputStream getInputStream() throws Exception
Exception
public static void writeHtmlDump(Writer w_p, Node node_p) throws Exception
public static Element getChildElement(Element parent_p, String childElementName_p)
parent_p
- childElementName_p
- Element
public static String getElementText(Element element_p)
element_p
- String
public static String getChildElementText(Element parent_p, String childElementName_p)
parent_p
- childElementName_p
- String
public static Node getChildNode(Node node_p, String childToFind_p)
node_p
- childToFind_p
- Node
public static String encodeSpecialCharactersForXML(String xmlString_p)
xmlString_p
- String
public static String makeXMLString(String sText_p)
public static boolean toFile(File file_p, Node node_p)
file_p
- File to write XML to.node_p
- Nodepublic static String toString(Node node_p) throws TransformerException
node_p
- NodeTransformerException
public static List getSafeNodeList(Node node_p)
node_p
- Nodepublic static InputStream getInputStream(Node node_p) throws Exception
Exception
public static boolean getSafeBooleanAttributeValue(Node node_p, String strAttributeName_p, boolean fDefault_p)
node_p
- Node
to get the attribute fromstrAttributeName_p
- name of the String attributefDefault_p
- Default string in case the attribute could not be foundpublic static boolean getSafeBooleanValue(Node node_p, boolean fDefault_p)
node_p
- Node
to get the attribute fromfDefault_p
- Default value in case the node could not be foundpublic static String getSafeStringAttributeValue(Node node_p, String strAttributeName_p, String strDefault_p)
node_p
- a Node
to get the attribute fromstrAttributeName_p
- name of the String attributestrDefault_p
- Default string in case the attribute could not be foundpublic static int getSafeIntegerAttributeValue(Node node_p, String strAttributeName_p, int iDefault_p)
node_p
- a Node
to get the attribute fromstrAttributeName_p
- name of the String attributeiDefault_p
- Default int in case the attribute could not be foundpublic static Set getSafeStringSet(Node node_p)
node_p
- Nodepublic static List getSafeStringList(Node node_p)
node_p
- Nodepublic static List getSafeCDATAList(Node node_p)
node_p
- Nodepublic static Document getDocumentFromInputStream(InputStream inputStream_p) throws IOException, SAXException, ParserConfigurationException
inputStream_p
- Document
IOException
SAXException
ParserConfigurationException
public static Document getNewDocument() throws ParserConfigurationException
Document
ParserConfigurationException
public static Document getDocumentFromString(String xml_p) throws IOException, SAXException, ParserConfigurationException
xml_p
- Document
IOException
SAXException
ParserConfigurationException
public static void setNodeAttribute(Document document_p, Node node_p, String attrName_p, String attrValue_p)
document_p
- node_p
- attrName_p
- attrValue_p
- public static void initialize(Node node)
node
- Node
the initialized DOM nodepublic static void initialize(Document document)
document
- Document
the initialized documentCopyright © 2014 Alfresco Business Solutions. All Rights Reserved.