Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.batik.dom.util
Class DOMUtilities

    java.lang.Object
      org.apache.batik.xml.XMLCharacters
          org.apache.batik.xml.XMLUtilities
              org.apache.batik.dom.util.DOMUtilities

    public class DOMUtilities

extends XMLUtilities

A collection of utility functions for the DOM.

Field Summary
`protected static String[]` | `LOCK_STRINGS` String constants representing DOM modifier strings for various all key lock combinations.
`protected static 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(Node node, Node parentNode)` Checks if the node can be appended on the given parent node
`static boolean` | `canAppendAny(ArrayList children, Node parentNode)` Checks whether any of the nodes from the list can be appended to a given parentNode.
`static boolean` | `canHaveChildren(Node parentNode)` Returns whether the given Node can have children.
`static String` | `contentToString(String s)` Returns the given content value transformed to replace invalid characters with entities.
`static Document` | `deepCloneDocument(Document doc, DOMImplementation impl)` Deep clones a document using the given DOM implementation.
`static int` | `getChildIndex(Node child)` Finds and returns the index of child node in its parent's children array
`static int` | `getChildIndex(Node child, Node parent)` Finds and returns the index of child node in the given parent's children array
`static String` | `getLocalName(String s)` Gets the local name from the given qualified name.
`static String` | `getModifiersList(int lockState, int modifiers)` Gets a DOM 3 modifiers string from the given lock and shift bitmasks.
`static String` | `getPrefix(String s)` Gets the prefix from the given qualified name.
`static String` | `getXML(Node n)` Serializes the given DOM node using `writeNode(Node,Writer)` and returns the XML as a String.
`static boolean` | `isAncestorOf(Node node, Node descendant)` Checks whether a node is ancestor of another node.
`static boolean` | `isAnyNodeAncestorOf(ArrayList ancestorNodes, Node node)` Checks if any of from the given list of nodes is an ancestor to another node
`static boolean` | `isParentOf(Node node, Node parentNode)` Tests whether the given node is a child of the given parent node.
`static boolean` | `isValidName(String s)` Tests whether the given string is a valid name.
`static boolean` | `isValidName11(String s)` Tests whether the given string is a valid XML 1.1 name.
`static boolean` | `isValidPrefix(String s)` Tests whether the given string is a valid prefix.
`static void` | `parseStyleSheetPIData(String data, HashTable table)` Parses a 'xml-stylesheet' processing instruction data section and puts the pseudo attributes in the given table.
`static Node` | `parseXML(String text, Document doc, String uri, Map prefixes, 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(Document doc, Writer w)` Writes the given document using the given writer.
`static void` | `writeNode(Node n, 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

### LOCK_STRINGS

    protected static final String[] LOCK_STRINGS

  String constants representing DOM modifier strings for various all key lock combinations.

### MODIFIER_STRINGS

    protected static final String[] MODIFIER_STRINGS

  String constants representing DOM modifier strings for various all shift modifier combinations.

Constructor Detail

### DOMUtilities

    protected DOMUtilities()

  Do not need to be instantiated.

Method Detail

### writeDocument

    public static void writeDocument(Document doc,
                                     Writer w)
                              throws IOException

  Writes the given document using the given writer.

  Throws:
    `IOException`

### writeNode

    public static void writeNode(Node n,
                                 Writer w)
                          throws IOException

  Writes a node using the given writer.

  Throws:
    `IOException`

### getXML

    public static String getXML(Node n)

  Serializes the given DOM node using `writeNode(Node,Writer)` and returns the XML as a String.

  Parameters:
    `n` - The Node to serialize.
  Returns:
    A String containing the XML serialization of the Node, or an empty String if there was a problem during serialization.

### contentToString

    public static String contentToString(String s)

  Returns the given content value transformed to replace invalid characters with entities.

### getChildIndex

    public static int getChildIndex(Node child,
                                    Node parent)

  Finds and returns the index of child node in the given parent's children array

  Parameters:
    `child` - The child node
    `parent` - The parent node
  Returns:
    the index

### getChildIndex

    public static int getChildIndex(Node child)

  Finds and returns the index of child node in its parent's children array

  Parameters:
    `child` - The child node
  Returns:
    the index in children array

### isAnyNodeAncestorOf

    public static boolean isAnyNodeAncestorOf(ArrayList ancestorNodes,
                                              Node node)

  Checks if any of from the given list of nodes is an ancestor to another node

  Parameters:
    `ancestorNodes` - The potential ancestor nodes
    `node` - The potential descendant node
  Returns:
    True if at least one node is ancestor of the given node

### isAncestorOf

    public static boolean isAncestorOf(Node node,
                                       Node descendant)

  Checks whether a node is ancestor of another node.

  Parameters:
    `node` - The potential ancestor node
    `descendant` - The potential descendant node
  Returns:
    True if node is ancestor of the descendant node

### isParentOf

    public static boolean isParentOf(Node node,
                                     Node parentNode)

  Tests whether the given node is a child of the given parent node.

  Parameters:
    `node` - The potential child node
    `parentNode` - Parent node
  Returns:
    True if a node is a child of the given parent node

### canAppend

    public static boolean canAppend(Node node,
                                    Node parentNode)

  Checks if the node can be appended on the given parent node

  Parameters:
    `node` - The given node
    `parentNode` - The given parent node
  Returns:
    True if the given node can be appended on the parent node

### canAppendAny

    public static boolean canAppendAny(ArrayList children,
                                       Node parentNode)

  Checks whether any of the nodes from the list can be appended to a given parentNode.

  Parameters:
    `children` - The given node list
    `parentNode` - The potential parent node
  Returns:
    true if at least one node from a list can be appended

### canHaveChildren

    public static boolean canHaveChildren(Node parentNode)

  Returns whether the given Node can have children.

  Parameters:
    `parentNode` - The Node to test
  Returns:
    `true` if the node can have children, `false` otherwise

### parseXML

    public static Node parseXML(String text,
                                Document doc,
                                String uri,
                                Map prefixes,
                                String wrapperElementName,
                                SAXDocumentFactory documentFactory)

  Parses the given XML string into a DocumentFragment of the given document or a new document if 'doc' is null.

  Parameters:
    `text` - The given XML string
    `doc` - The given document
    `uri` - The document URI
    `prefixes` - The prefixes map with (prefix, namespaceURI) pairs
    `wrapperElementName` - 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 map
    `documentFactory` - What document factory to use when parsing the text
  Returns:
    The document fragment or null on error.

### deepCloneDocument

    public static Document deepCloneDocument(Document doc,
                                             DOMImplementation impl)

  Deep clones a document using the given DOM implementation.

### isValidName

    public static boolean isValidName(String s)

  Tests whether the given string is a valid name.

### isValidName11

    public static boolean isValidName11(String s)

  Tests whether the given string is a valid XML 1.1 name.

### isValidPrefix

    public static boolean isValidPrefix(String s)

  Tests whether the given string is a valid prefix. This method assume that isValidName(s) is true.

### getPrefix

    public static String getPrefix(String s)

  Gets the prefix from the given qualified name. This method assume that isValidName(s) is true.

### getLocalName

    public static String getLocalName(String s)

  Gets the local name from the given qualified name. This method assume that isValidName(s) is true.

### parseStyleSheetPIData

    public static void parseStyleSheetPIData(String data,
                                             HashTable table)

  Parses a 'xml-stylesheet' processing instruction data section and puts the pseudo attributes in the given table.

### getModifiersList

    public static String getModifiersList(int lockState,
                                          int modifiers)

  Gets a DOM 3 modifiers string from the given lock and shift bitmasks.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2008 Apache Software Foundation. All Rights Reserved.