|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object lumis.util.XmlUtil
@StableMinor(version="4.1", sinceVersion="4.0") public class XmlUtil
Utility file for xml
Field Summary | |
---|---|
static String |
XML_HEADER
|
Constructor Summary | |
---|---|
XmlUtil()
|
Method Summary | |
---|---|
static Node |
addNode(Node xmlParentNode,
String newNodeName)
|
static Node |
addNode(Node xmlParentNode,
String xpathExpressionParentNode,
String newNodeName)
|
static Attr |
addNodeAttr(Node xmlParentNode,
String attributeName)
|
static Attr |
addNodeAttr(Node xmlParentNode,
String attributeName,
String value)
|
static Node |
addNodeFromXmlString(Node node,
String xmlString)
|
static Element |
addTextNode(Node xmlParentNode,
String newNodeName,
String newNodeText)
|
static Element |
addTextNode(Node xmlParentNode,
String xpathExpressionParentNode,
String newNodeName,
String newNodeText)
|
static Node[] |
addTextNodes(Node xmlParentNode,
String newNodesName,
String[] newNodesValue)
|
static Node[] |
addTextNodes(Node xmlParentNode,
String xpathExpressionParentNode,
String newNodesName,
String[] newNodesValue)
|
static boolean |
checkCondition(Node conditionNode,
String condition)
|
protected static boolean |
checkCondition(String leftValue,
String rightValue,
String conditionOperator)
|
static boolean |
checkSingleCondition(Node conditionNode,
String condition)
|
static byte[] |
convertToUTFBytes(byte[] content)
|
static Node |
copyNode(Node xmlNodeFrom,
Node xmlNodeTo)
|
static Node |
copyNode(Node xmlNodeFrom,
Node xmlNodeTo,
String xpathExpressionTo)
|
static Node |
copyNode(Node xmlNodeFrom,
String xpathExpressionFrom,
Node xmlNodeTo)
|
static Node |
copyNode(Node xmlNodeFrom,
String xpathExpressionFrom,
Node xmlNodeTo,
String xpathExpressionTo)
|
static PortalException |
createPortalException(SAXException e)
Creates a PortalException based on the given SAXException. |
static String |
encodeXml(String pStr)
Encodes a string to be used inside a XML document. |
static Document |
getDocument(File xmlFile)
|
static Document |
getDocument(HttpServletRequest request)
|
static Document |
getDocument(String xmlString)
|
static Document |
getDocumentFromFile(String filePath)
|
static Node |
getOrCreateNode(String path,
Node parentNode)
|
static String |
getTextContent(Node node)
|
static DocumentBuilder |
getXmlDocumentBuilder()
|
static Document |
getXMLDocumentFromString(String xml)
|
static String |
getXmlEncoding(String xmlString)
Returns the XML encoding for the xml with the given String. |
static String |
getXmlString(Document document)
|
static String |
getXmlString(Element element)
|
static Node |
importIntoNewDocument(Node originalNode)
Clones a node, and adopts it into a new document. |
static boolean |
isValidXmlString(String xml)
|
static void |
mergeAttributes(Node destinationNode,
Node sourceNode,
boolean replace)
|
static void |
mergeElements(Node destinationNode,
Node sourceNode,
boolean replace)
Merges the children elements from a node to another. |
static boolean |
nodeExists(String xpathExpression,
Node sourceNode)
|
static boolean |
readAttributeBoolean(String attributeName,
Node node)
|
static boolean |
readAttributeBoolean(String attributeName,
Node node,
boolean valueForNull)
|
static int |
readAttributeInt(String attributeName,
Node node,
int valueForNull)
Returns the attribute integer value in the given node. |
static String |
readAttributeOrNodeString(Node node,
String fieldName)
|
static String |
readAttributeOrNodeString(Node node,
String fieldName,
String valueForNull)
|
static String |
readAttributeString(String attributeName,
Node node)
|
static String |
readAttributeString(String attributeName,
Node node,
String valueForNull)
|
static boolean |
readNodeBoolean(String xpathExpression,
Node sourceNode,
boolean valueForNull)
|
static int |
readNodeInt(String xpathExpression,
Node sourceNode,
int valueForNull)
|
static Integer |
readNodeInteger(String xpathExpression,
Node sourceNode,
Integer valueForNull)
|
static String[] |
readNodesString(String xpathExpression,
Node sourceNode)
|
static String |
readNodeString(String xpathExpression,
Node sourceNode)
|
static String |
readNodeString(String xpathExpression,
Node sourceNode,
String valueForNull)
|
static void |
replaceChildNode(Node parentNode,
Node newChildNode)
|
static void |
replaceChildNode(String childNodeName,
Node node,
String xmlString)
|
static Node[] |
selectAncestorNodes(String ancestorNameQuery,
Node childNode)
|
static Node[] |
selectNodes(String childNameQuery,
Node parentNode)
|
static Node |
selectSingleAncestorNode(String ancestorNameQuery,
Node childNode)
|
static Node |
selectSingleNode(String childNameQuery,
Node parentNode)
|
protected static Node |
selectSingleNodeRecursiveByName(String nodeName,
Node parentNode)
|
static void |
setTextContent(Node parentNode,
String textValue)
|
static Node |
writeNodeString(String xpathExpression,
Node sourceNode,
String nodeValue)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String XML_HEADER
Constructor Detail |
---|
public XmlUtil()
Method Detail |
---|
public static DocumentBuilder getXmlDocumentBuilder() throws PortalException
PortalException
public static Document getDocument(File xmlFile) throws PortalException
PortalException
public static Document getDocument(HttpServletRequest request) throws Exception
Exception
public static Document getDocument(String xmlString) throws PortalException
PortalException
public static PortalException createPortalException(SAXException e)
e
- the SAXException
public static String getXmlString(Element element) throws PortalException
PortalException
public static String getXmlString(Document document) throws Exception
Exception
public static boolean readNodeBoolean(String xpathExpression, Node sourceNode, boolean valueForNull) throws PortalException
PortalException
public static boolean readAttributeBoolean(String attributeName, Node node) throws PortalException
PortalException
public static boolean readAttributeBoolean(String attributeName, Node node, boolean valueForNull) throws PortalException
PortalException
public static int readNodeInt(String xpathExpression, Node sourceNode, int valueForNull) throws PortalException
PortalException
public static Integer readNodeInteger(String xpathExpression, Node sourceNode, Integer valueForNull) throws PortalException
PortalException
public static String readAttributeString(String attributeName, Node node) throws PortalException
PortalException
public static int readAttributeInt(String attributeName, Node node, int valueForNull) throws PortalException
attributeName
- node
- valueForNull
-
PortalException
public static String readAttributeString(String attributeName, Node node, String valueForNull) throws PortalException
PortalException
public static String getTextContent(Node node)
public static void setTextContent(Node parentNode, String textValue)
public static String readNodeString(String xpathExpression, Node sourceNode) throws PortalException
PortalException
public static String readNodeString(String xpathExpression, Node sourceNode, String valueForNull) throws PortalException
PortalException
public static String[] readNodesString(String xpathExpression, Node sourceNode) throws PortalException
PortalException
public static boolean nodeExists(String xpathExpression, Node sourceNode) throws PortalException
PortalException
public static Element addTextNode(Node xmlParentNode, String newNodeName, String newNodeText) throws PortalException
PortalException
public static Element addTextNode(Node xmlParentNode, String xpathExpressionParentNode, String newNodeName, String newNodeText) throws PortalException
PortalException
public static Node[] addTextNodes(Node xmlParentNode, String newNodesName, String[] newNodesValue) throws PortalException
PortalException
public static Node[] addTextNodes(Node xmlParentNode, String xpathExpressionParentNode, String newNodesName, String[] newNodesValue) throws Exception
Exception
public static Node addNode(Node xmlParentNode, String newNodeName)
public static Node addNode(Node xmlParentNode, String xpathExpressionParentNode, String newNodeName) throws PortalException
PortalException
public static Attr addNodeAttr(Node xmlParentNode, String attributeName)
public static Attr addNodeAttr(Node xmlParentNode, String attributeName, String value)
public static Node copyNode(Node xmlNodeFrom, Node xmlNodeTo)
public static Node copyNode(Node xmlNodeFrom, String xpathExpressionFrom, Node xmlNodeTo) throws Exception
Exception
public static Node copyNode(Node xmlNodeFrom, Node xmlNodeTo, String xpathExpressionTo) throws Exception
Exception
public static Node copyNode(Node xmlNodeFrom, String xpathExpressionFrom, Node xmlNodeTo, String xpathExpressionTo) throws Exception
Exception
public static Document getDocumentFromFile(String filePath) throws Exception
Exception
public static Node selectSingleAncestorNode(String ancestorNameQuery, Node childNode) throws Exception
Exception
public static Node[] selectAncestorNodes(String ancestorNameQuery, Node childNode) throws Exception
Exception
public static Node importIntoNewDocument(Node originalNode) throws PortalException
originalNode
-
PortalException
public static Node selectSingleNode(String childNameQuery, Node parentNode) throws PortalException
PortalException
public static Node[] selectNodes(String childNameQuery, Node parentNode) throws PortalException
PortalException
public static boolean checkCondition(Node conditionNode, String condition) throws Exception
Exception
public static boolean checkSingleCondition(Node conditionNode, String condition) throws Exception
Exception
protected static boolean checkCondition(String leftValue, String rightValue, String conditionOperator)
protected static Node selectSingleNodeRecursiveByName(String nodeName, Node parentNode) throws Exception
Exception
public static Document getXMLDocumentFromString(String xml) throws PortalException
PortalException
public static byte[] convertToUTFBytes(byte[] content)
public static Node getOrCreateNode(String path, Node parentNode) throws PortalException
PortalException
public static Node writeNodeString(String xpathExpression, Node sourceNode, String nodeValue) throws PortalException
PortalException
public static String readAttributeOrNodeString(Node node, String fieldName) throws PortalException
PortalException
public static String readAttributeOrNodeString(Node node, String fieldName, String valueForNull) throws PortalException
PortalException
public static void replaceChildNode(Node parentNode, Node newChildNode) throws Exception
Exception
public static void replaceChildNode(String childNodeName, Node node, String xmlString) throws PortalException
PortalException
public static Node addNodeFromXmlString(Node node, String xmlString) throws PortalException
PortalException
public static void mergeAttributes(Node destinationNode, Node sourceNode, boolean replace) throws PortalException
PortalException
public static void mergeElements(Node destinationNode, Node sourceNode, boolean replace) throws PortalException
destinationNode
- the destination node, where the elements will be
appended or replaced.sourceNode
- the source node, where the elements will be copied from.replace
- if true, elements with the same name will be replaced;
if false they will not be copied if an element in the destinationNode
with the same name already exists.
PortalException
public static String encodeXml(String pStr)
public static String getXmlEncoding(String xmlString)
The encoding is read from the XML declaration.
xmlString
- the xml.
public static boolean isValidXmlString(String xml)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |