|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.batik.xml.XMLCharacters
org.apache.batik.xml.XMLUtilities
org.apache.batik.dom.util.DOMUtilities
public class DOMUtilities
A collection of utility functions for the DOM.
Field Summary | |
---|---|
protected static java.lang.String[] |
LOCK_STRINGS
String constants representing DOM modifier strings for various all key lock combinations. |
protected static java.lang.String[] |
MODIFIER_STRINGS
String constants representing DOM modifier strings for various all shift modifier combinations. |
Fields inherited from class org.apache.batik.xml.XMLCharacters |
---|
ALPHABETIC_CHARACTER, NAME_CHARACTER, NAME_FIRST_CHARACTER, NAME11_CHARACTER, NAME11_FIRST_CHARACTER, PUBLIC_ID_CHARACTER, VERSION_CHARACTER, XML_CHARACTER |
Constructor Summary | |
---|---|
protected |
DOMUtilities()
Do not need to be instantiated. |
Method Summary | |
---|---|
static boolean |
canAppend(org.w3c.dom.Node node,
org.w3c.dom.Node parentNode)
Checks if the node can be appended on the given parent node |
static boolean |
canAppendAny(java.util.ArrayList children,
org.w3c.dom.Node parentNode)
Checks whether any of the nodes from the list can be appended to a given parentNode. |
static boolean |
canHaveChildren(org.w3c.dom.Node parentNode)
Returns whether the given Node can have children. |
static java.lang.String |
contentToString(java.lang.String s)
Returns the given content value transformed to replace invalid characters with entities. |
static org.w3c.dom.Document |
deepCloneDocument(org.w3c.dom.Document doc,
org.w3c.dom.DOMImplementation impl)
Deep clones a document using the given DOM implementation. |
static int |
getChildIndex(org.w3c.dom.Node child)
Finds and returns the index of child node in its parent's children array |
static int |
getChildIndex(org.w3c.dom.Node child,
org.w3c.dom.Node parent)
Finds and returns the index of child node in the given parent's children array |
static java.lang.String |
getLocalName(java.lang.String s)
Gets the local name from the given qualified name. |
static java.lang.String |
getModifiersList(int lockState,
int modifiers)
Gets a DOM 3 modifiers string from the given lock and shift bitmasks. |
static java.lang.String |
getPrefix(java.lang.String s)
Gets the prefix from the given qualified name. |
static java.lang.String |
getXML(org.w3c.dom.Node n)
Serializes the given DOM node using writeNode(Node,Writer)
and returns the XML as a String. |
static boolean |
isAncestorOf(org.w3c.dom.Node node,
org.w3c.dom.Node descendant)
Checks whether a node is ancestor of another node. |
static boolean |
isAnyNodeAncestorOf(java.util.ArrayList ancestorNodes,
org.w3c.dom.Node node)
Checks if any of from the given list of nodes is an ancestor to another node |
static boolean |
isParentOf(org.w3c.dom.Node node,
org.w3c.dom.Node parentNode)
Tests whether the given node is a child of the given parent node. |
static boolean |
isValidName(java.lang.String s)
Tests whether the given string is a valid name. |
static boolean |
isValidName11(java.lang.String s)
Tests whether the given string is a valid XML 1.1 name. |
static boolean |
isValidPrefix(java.lang.String s)
Tests whether the given string is a valid prefix. |
static void |
parseStyleSheetPIData(java.lang.String data,
HashTable table)
Parses a 'xml-stylesheet' processing instruction data section and puts the pseudo attributes in the given table. |
static org.w3c.dom.Node |
parseXML(java.lang.String text,
org.w3c.dom.Document doc,
java.lang.String uri,
java.util.Map prefixes,
java.lang.String wrapperElementName,
SAXDocumentFactory documentFactory)
Parses the given XML string into a DocumentFragment of the given document or a new document if 'doc' is null. |
static void |
writeDocument(org.w3c.dom.Document doc,
java.io.Writer w)
Writes the given document using the given writer. |
static void |
writeNode(org.w3c.dom.Node n,
java.io.Writer w)
Writes a node using the given writer. |
Methods inherited from class org.apache.batik.xml.XMLUtilities |
---|
createXMLDeclarationReader, createXMLDocumentReader, encodingToJavaEncoding, getXMLDeclarationEncoding, isXML11Character, isXML11NameCharacter, isXML11NameFirstCharacter, isXMLAlphabeticCharacter, isXMLCharacter, isXMLNameCharacter, isXMLNameFirstCharacter, isXMLPublicIdCharacter, isXMLSpace, isXMLVersionCharacter |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final java.lang.String[] LOCK_STRINGS
protected static final java.lang.String[] MODIFIER_STRINGS
Constructor Detail |
---|
protected DOMUtilities()
Method Detail |
---|
public static void writeDocument(org.w3c.dom.Document doc, java.io.Writer w) throws java.io.IOException
java.io.IOException
public static void writeNode(org.w3c.dom.Node n, java.io.Writer w) throws java.io.IOException
java.io.IOException
public static java.lang.String getXML(org.w3c.dom.Node n)
writeNode(Node,Writer)
and returns the XML as a String.
n
- The Node to serialize.
public static java.lang.String contentToString(java.lang.String s)
public static int getChildIndex(org.w3c.dom.Node child, org.w3c.dom.Node parent)
child
- The child nodeparent
- The parent node
public static int getChildIndex(org.w3c.dom.Node child)
child
- The child node
public static boolean isAnyNodeAncestorOf(java.util.ArrayList ancestorNodes, org.w3c.dom.Node node)
ancestorNodes
- The potential ancestor nodesnode
- The potential descendant node
public static boolean isAncestorOf(org.w3c.dom.Node node, org.w3c.dom.Node descendant)
node
- The potential ancestor nodedescendant
- The potential descendant node
public static boolean isParentOf(org.w3c.dom.Node node, org.w3c.dom.Node parentNode)
node
- The potential child nodeparentNode
- Parent node
public static boolean canAppend(org.w3c.dom.Node node, org.w3c.dom.Node parentNode)
node
- The given nodeparentNode
- The given parent node
public static boolean canAppendAny(java.util.ArrayList children, org.w3c.dom.Node parentNode)
children
- The given node listparentNode
- The potential parent node
public static boolean canHaveChildren(org.w3c.dom.Node parentNode)
parentNode
- The Node to test
true
if the node can have children,
false
otherwisepublic static org.w3c.dom.Node parseXML(java.lang.String text, org.w3c.dom.Document doc, java.lang.String uri, java.util.Map prefixes, java.lang.String wrapperElementName, SAXDocumentFactory documentFactory)
text
- The given XML stringdoc
- The given documenturi
- The document URIprefixes
- The prefixes map with (prefix, namespaceURI) pairswrapperElementName
- null: Ignore the wrapper element and prefixes map and try to
parse the text as a whole document otherwise: Wrap the given
text with the wrapper element with prefixes specified from the
prefixes mapdocumentFactory
- What document factory to use when parsing the text
public static org.w3c.dom.Document deepCloneDocument(org.w3c.dom.Document doc, org.w3c.dom.DOMImplementation impl)
public static boolean isValidName(java.lang.String s)
public static boolean isValidName11(java.lang.String s)
public static boolean isValidPrefix(java.lang.String s)
public static java.lang.String getPrefix(java.lang.String s)
public static java.lang.String getLocalName(java.lang.String s)
public static void parseStyleSheetPIData(java.lang.String data, HashTable table)
public static java.lang.String getModifiersList(int lockState, int modifiers)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |