|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.jscience.ml.cml.util.PMRDOMUtils
public class PMRDOMUtils
re-usable routines to support PMR* interfaces
| Field Summary | |
|---|---|
static int |
PRETTY
Description of the Field |
| Constructor Summary | |
|---|---|
PMRDOMUtils()
|
|
| Method Summary | |
|---|---|
static org.w3c.dom.Node |
cloneNode(org.w3c.dom.Node node,
org.w3c.dom.Document document)
clones node in context of new document. |
static org.w3c.dom.Attr[] |
copyAttributes(org.w3c.dom.Element e,
Picker p)
copies attributes chosen via a Picker callback. |
static java.util.Vector |
createVector(org.w3c.dom.NamedNodeMap nodeMap)
converts a NamedNodeMap to a vector the vector (but not its elements) is safely mutable. |
static java.util.Vector |
createVector(org.w3c.dom.NodeList nodes)
converts a NodeList to a vector the vector (but not its elements) is safely mutable. |
static org.w3c.dom.Attr[] |
cutAttributes(org.w3c.dom.Element e,
Picker p)
copies and removes attributes chosen via a Picker callback. |
static java.lang.String |
debug(org.w3c.dom.Node node)
convenience routine to output a Node as a String |
static void |
deleteWhitespaceDescendants(org.w3c.dom.Document document)
recursively removes all whitespace nodes |
static void |
deleteWhitespaceDescendants(org.w3c.dom.Element element)
recursively deletes all whitespace descendants |
static java.util.Enumeration |
depthFirstEnumeration(org.w3c.dom.Element element)
return all descendants in document order |
static org.w3c.dom.Element |
getAncestor(org.w3c.dom.Element element,
java.lang.String tagName)
gets first ancestor of 'element' with tagName; [element is not its own ancestor] |
static java.util.Vector |
getAncestors(org.w3c.dom.Element element)
gets all ancestors of 'element' including the document Element but not Document. |
static java.lang.String |
getAttribute(org.w3c.dom.Element element,
java.lang.String attName)
Kludge to overcome cases where getAttribute(attName) has been subverted |
static java.lang.String |
getAttributeString(org.w3c.dom.Attr att)
returns a string representing a single attribute in a start tag, for example foo=bar plugh"; String starts with space and delimiters are QUOT, not APOS |
static java.lang.String |
getAttributeString(org.w3c.dom.Element element)
returns the attributes in concatenated text form (suitable for insertion to start tags). |
static org.w3c.dom.Element |
getChildElement(org.w3c.dom.Element element,
int index)
get the index'th Element child If none returns null Count ignores non-Element nodes |
static java.util.Vector |
getChildElements(org.w3c.dom.Element element)
get all Element children If none, returns empty Vector |
static java.util.Vector |
getChildrenWithElementName(org.w3c.dom.Element element,
java.lang.String name)
gets vector of Element children with given element name (ignored if name is null or bad value of sensitivity). |
static org.w3c.dom.Element |
getFirstChildWithElementName(org.w3c.dom.Element element,
java.lang.String name)
gets first child with given element name (ignored if name is null). |
static org.w3c.dom.Text |
getPCDATAChildNode(org.w3c.dom.Element element)
if this has a single PCDATA child, returns it, else null |
static java.lang.String |
getPCDATAContent(org.w3c.dom.Element element)
if this has a single PCDATA child, returns its string value, else null |
static boolean |
isEmptyAttribute(java.lang.String attributeValue)
Gets the emptyAttribute attribute of the PMRDOMUtils class |
static boolean |
isEmptyElement(org.w3c.dom.Element element)
Gets the emptyElement attribute of the PMRDOMUtils class |
static java.lang.String |
normalizeString(java.lang.String s)
normalizes all whitespace in a string to single spaces |
static java.lang.String |
output(org.w3c.dom.Document document,
java.io.Writer w)
convenience routine |
static java.lang.String |
output(org.w3c.dom.Node node)
convenience routine to output a Node as a String |
static java.lang.String |
output(org.w3c.dom.Node node,
java.io.Writer w)
convenience routine |
static void |
outputChildContent(org.w3c.dom.Element element,
java.io.Writer w,
int type,
int level)
subclassed by specialist classes |
static void |
outputEmptyTag(org.w3c.dom.Element element,
java.io.Writer w,
int type,
int level)
subclassed by specialist classes |
static void |
outputEndElement(org.w3c.dom.Element element,
java.io.Writer w,
int level)
for building the tree If writer is null, noop; else outputs an end tag |
static void |
outputEndTag(org.w3c.dom.Element element,
java.io.Writer w,
int type,
int level)
subclassed by specialist classes |
static java.lang.String |
outputEventStream(org.w3c.dom.Node node,
java.io.Writer w,
int type,
int level)
Description of the Method |
static java.lang.String |
outputEventStream(org.w3c.dom.Node node,
java.io.Writer w,
int type,
int level,
java.lang.String encoding,
boolean xmlDecl,
java.lang.String dtd)
same as above but also outputs XMLDeclaration and DOCTYPE |
static void |
outputStartElement(org.w3c.dom.Element element,
java.io.Writer w,
org.w3c.dom.Element parentNode,
int level)
for building the tree If writer is null, builds a tree by adding this to parentNode, else outputs a start tag. |
static void |
outputStartTag(org.w3c.dom.Element element,
java.io.Writer w,
int type,
int level)
subclassed by specialist classes |
static void |
pasteAttributes(org.w3c.dom.Element e,
org.w3c.dom.Attr[] attrs)
adds Attributes to a given Element. |
static java.util.List |
pickElements(org.w3c.dom.Element rootElement,
Picker p)
match decendent elements. |
static void |
removeChildNodes(org.w3c.dom.Element element)
remove all child nodes |
static void |
removeNode(org.w3c.dom.Node node)
remove a node from its parent |
static void |
setPCDATAContent(org.w3c.dom.Element element,
java.lang.String s)
Sets a string to be the content of an existing single PCDATANode If there are no children, create a new PCDATANode. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int PRETTY
| Constructor Detail |
|---|
public PMRDOMUtils()
| Method Detail |
|---|
public static void deleteWhitespaceDescendants(org.w3c.dom.Element element)
element - Description of the Parameterpublic static void removeNode(org.w3c.dom.Node node)
node - to be removedpublic static void removeChildNodes(org.w3c.dom.Element element)
element - to remove child nodes frompublic static java.util.Enumeration depthFirstEnumeration(org.w3c.dom.Element element)
element - Description of the Parameter
public static java.util.Vector getChildElements(org.w3c.dom.Element element)
element - Description of the Parameter
public static org.w3c.dom.Element getChildElement(org.w3c.dom.Element element,
int index)
element - Description of the Parameterindex - Description of the Parameter
public static java.util.Vector getAncestors(org.w3c.dom.Element element)
element - Description of the Parameter
public static org.w3c.dom.Element getAncestor(org.w3c.dom.Element element,
java.lang.String tagName)
element - Description of the ParametertagName - Description of the Parameter
public static java.util.Vector createVector(org.w3c.dom.NodeList nodes)
nodes - NodeList to copy
public static java.util.Vector createVector(org.w3c.dom.NamedNodeMap nodeMap)
nodeMap - NodeMap to copy
public static java.lang.String getAttribute(org.w3c.dom.Element element,
java.lang.String attName)
element - Description of the ParameterattName - Description of the Parameter
public static java.lang.String getAttributeString(org.w3c.dom.Element element)
element - Description of the Parameter
public static java.lang.String getAttributeString(org.w3c.dom.Attr att)
att - Description of the Parameter
public static java.lang.String normalizeString(java.lang.String s)
s - the string
public static java.util.Vector getChildrenWithElementName(org.w3c.dom.Element element,
java.lang.String name)
element - Description of the Parametername - Description of the Parameter
public static org.w3c.dom.Element getFirstChildWithElementName(org.w3c.dom.Element element,
java.lang.String name)
element - Description of the Parametername - Description of the Parameter
public static java.lang.String getPCDATAContent(org.w3c.dom.Element element)
element - Description of the Parameter
public static org.w3c.dom.Text getPCDATAChildNode(org.w3c.dom.Element element)
element - Description of the Parameter
public static void setPCDATAContent(org.w3c.dom.Element element,
java.lang.String s)
element - The new pCDATAContent values - The new pCDATAContent value
public static java.lang.String outputEventStream(org.w3c.dom.Node node,
java.io.Writer w,
int type,
int level)
throws java.io.IOException
node - Description of the Parameterw - Description of the Parametertype - Description of the Parameterlevel - Description of the Parameter
java.io.IOException - Description of the Exceptionpublic static java.lang.String debug(org.w3c.dom.Node node)
node - Description of the Parameter
public static java.lang.String output(org.w3c.dom.Node node)
node - Description of the Parameter
public static java.lang.String output(org.w3c.dom.Document document,
java.io.Writer w)
throws java.io.IOException
document - Description of the Parameterw - Description of the Parameter
java.io.IOException - Description of the Exception
public static java.lang.String output(org.w3c.dom.Node node,
java.io.Writer w)
throws java.io.IOException
node - Description of the Parameterw - Description of the Parameter
java.io.IOException - Description of the Exception
public static java.lang.String outputEventStream(org.w3c.dom.Node node,
java.io.Writer w,
int type,
int level,
java.lang.String encoding,
boolean xmlDecl,
java.lang.String dtd)
throws java.io.IOException
node - Description of the Parameterw - Description of the Parametertype - Description of the Parameterlevel - Description of the Parameterencoding - Description of the ParameterxmlDecl - Description of the Parameterdtd - Description of the Parameter
java.io.IOException - Description of the Exceptionpublic static boolean isEmptyElement(org.w3c.dom.Element element)
element - Description of the Parameter
public static void outputStartTag(org.w3c.dom.Element element,
java.io.Writer w,
int type,
int level)
throws java.io.IOException
element - Description of the Parameterw - Description of the Parametertype - Description of the Parameterlevel - Description of the Parameter
java.io.IOException - Description of the Exception
public static void outputEmptyTag(org.w3c.dom.Element element,
java.io.Writer w,
int type,
int level)
throws java.io.IOException
element - Description of the Parameterw - Description of the Parametertype - Description of the Parameterlevel - Description of the Parameter
java.io.IOException - Description of the Exception
public static void outputStartElement(org.w3c.dom.Element element,
java.io.Writer w,
org.w3c.dom.Element parentNode,
int level)
throws java.io.IOException
element - Description of the Parameterw - Description of the ParameterparentNode - Description of the Parameterlevel - Description of the Parameter
java.io.IOException - Description of the Exception
public static void outputChildContent(org.w3c.dom.Element element,
java.io.Writer w,
int type,
int level)
throws java.io.IOException
element - Description of the Parameterw - Description of the Parametertype - Description of the Parameterlevel - Description of the Parameter
java.io.IOException - Description of the Exception
public static void outputEndTag(org.w3c.dom.Element element,
java.io.Writer w,
int type,
int level)
throws java.io.IOException
element - Description of the Parameterw - Description of the Parametertype - Description of the Parameterlevel - Description of the Parameter
java.io.IOException - Description of the Exception
public static void outputEndElement(org.w3c.dom.Element element,
java.io.Writer w,
int level)
throws java.io.IOException
element - Description of the Parameterw - Description of the Parameterlevel - Description of the Parameter
java.io.IOException - Description of the Exceptionpublic static void deleteWhitespaceDescendants(org.w3c.dom.Document document)
document - Description of the Parameterpublic static boolean isEmptyAttribute(java.lang.String attributeValue)
attributeValue - Description of the Parameter
public static org.w3c.dom.Node cloneNode(org.w3c.dom.Node node,
org.w3c.dom.Document document)
node - to clonedocument - context document
public static java.util.List pickElements(org.w3c.dom.Element rootElement,
Picker p)
rootElement - the element who along with its children will be processed.p - the Picker used to match the elements
public static org.w3c.dom.Attr[] copyAttributes(org.w3c.dom.Element e,
Picker p)
Picker callback.
Using the Picker, choose a set of Attributes to be copied from the Element.
e - the element whose Attributes are to be processedp - the picker that determines whether to choose the attribute
public static org.w3c.dom.Attr[] cutAttributes(org.w3c.dom.Element e,
Picker p)
throws org.w3c.dom.DOMException
Picker callback.
Using the Picker, choose a set of Attributes to be removed from the Element.
These Attributes are then returned
e - the element whose attributes are to be processedp - the Picker that determines whether to choose the attribute
org.w3c.dom.DOMException - propagated from the call to remove the Attribute node from the Element.
public static void pasteAttributes(org.w3c.dom.Element e,
org.w3c.dom.Attr[] attrs)
throws org.w3c.dom.DOMException
e - the element whose attributes are to be processedattrs - an array of the Attributes to be added
org.w3c.dom.DOMException - propagated from the call to add the Attribute node to the Element.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||