|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.charlesames.utility.xml.Xml
public class Xml
Singleton class wrapping functionality for XML input and output.
| Nested Class Summary | |
|---|---|
static class |
Xml.XmlTags
|
| Field Summary | |
|---|---|
static java.text.SimpleDateFormat |
dateFormat
Standard XML date format. |
static java.lang.String |
FILE_EXTENSION
The standard extension for files containing text in XML format. |
static java.text.SimpleDateFormat |
timeFormat
Standard XML time format. |
static java.lang.String |
XSI_NAMESPACE
Namespace for XML node names prefixed with xsi, which stands for XML Schema Instance. |
| Method Summary | |
|---|---|
static org.w3c.dom.Element |
appendAttributeElement(org.w3c.dom.Element parentElement,
java.lang.String tagName,
java.lang.String attributeName,
java.lang.String value)
Creates a child element with the indicated tag name and adds an attribute to the child. |
static org.w3c.dom.Element |
appendContentElement(org.w3c.dom.Element parentElement,
java.lang.String tagName,
java.lang.String value)
Adds CDATA content to a node within a org.w3c.dom document. |
static org.w3c.dom.Element |
appendValueElement(org.w3c.dom.Element parentElement,
java.lang.String tagName,
java.lang.String value)
Creates a child element with the indicated tag name and adds text content to the child. |
static java.lang.String |
cdataDecode(java.lang.String text)
Decode a CDATA text stream from an XML data element. |
static java.lang.String |
cdataEncode(java.lang.String text)
Encode a text string so it can be written as CDATA into an XML data element. |
org.w3c.dom.Document |
createDocument()
Creates an org.w3c.dom document element. |
org.w3c.dom.DocumentType |
createDocumentType(java.lang.String qualifiedName,
java.lang.String publicID,
java.lang.String systemID)
Creates an org.w3c.dom document type element. |
org.w3c.dom.Document |
createXmlDoc()
|
java.lang.String |
documentToPrettyText(org.w3c.dom.Document document,
int tabsize,
org.w3c.dom.DocumentType documentType,
java.lang.String encoding)
Convert XML document into pretty-formatted text. |
static org.w3c.dom.Element |
findChildByAttribute(org.w3c.dom.Element parentElement,
java.lang.String elementName,
java.lang.String attributeName,
java.lang.String attributeValue)
Given a parent element, finds the first child element whose node name matches the elementName parameter AND whose value for a specified attribute matches the attributeValue parameter. |
static java.lang.String |
getAttributeElement(org.w3c.dom.Element parent,
java.lang.String tagName,
java.lang.String attributeName)
Deprecated. |
static org.w3c.dom.Element |
getChildElement(org.w3c.dom.Element parent,
java.lang.String tagName)
Locates the child element with the indicated tag name. |
static java.lang.String |
getContentElement(org.w3c.dom.Element parentElement,
java.lang.String tagName)
Finds a child element with the given tagName and returns the text content. |
static org.w3c.dom.Document |
getDocument(org.w3c.dom.Node node)
Get the document containing the indicated node. |
static java.lang.Long |
getLongContent(org.w3c.dom.Element element)
|
static java.lang.String |
getNodePath(org.w3c.dom.Node node)
Get the node-name path down to the indicated node. |
static java.lang.String |
getNodeTypeName(int nodeType)
Convert numerical org.w3c.dom node types into words. |
static Xml |
getSingleton()
Creates XML singleton on first invocation. |
static java.lang.String |
getValueElement(org.w3c.dom.Element parent,
java.lang.String tagName)
Extracts the text content of a child element with the indicated tag name. |
org.w3c.dom.Document |
readXmlDoc(java.io.File file)
Parses an input text file into an org.w3c.dom Document object. |
static void |
setCDataText(org.w3c.dom.Node parent,
java.lang.String text)
Adds CDATA content to a node within a org.w3c.dom document. |
void |
writeXmlDoc(java.io.File file,
org.w3c.dom.Document document,
int tabsize,
org.w3c.dom.DocumentType documentType,
java.lang.String encoding)
|
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String FILE_EXTENSION
public static final java.lang.String XSI_NAMESPACE
public static final java.text.SimpleDateFormat dateFormat
public static final java.text.SimpleDateFormat timeFormat
| Method Detail |
|---|
public static Xml getSingleton()
public static org.w3c.dom.Document getDocument(org.w3c.dom.Node node)
node - The indicated node.
Document; otherwise, the node's owner document.public org.w3c.dom.Document createDocument()
public org.w3c.dom.DocumentType createDocumentType(java.lang.String qualifiedName,
java.lang.String publicID,
java.lang.String systemID)
qualifiedName - The qualified name of the document type to be created.publicID - The external subset public identifier.systemID - The external subset system identifier.
public org.w3c.dom.Document readXmlDoc(java.io.File file)
file - A File object specifying the input file.
public org.w3c.dom.Document createXmlDoc()
public java.lang.String documentToPrettyText(org.w3c.dom.Document document,
int tabsize,
org.w3c.dom.DocumentType documentType,
java.lang.String encoding)
document - The source document.tabsize - Tab sizedocumentType - org.w3c.dom.DocumentType instance (null if no document type).encoding -
public void writeXmlDoc(java.io.File file,
org.w3c.dom.Document document,
int tabsize,
org.w3c.dom.DocumentType documentType,
java.lang.String encoding)
file - A File object specifying the output file.document - An org.w3c.dom Document object holding the data which is to be written out to the file.tabsize - Number of characters to intent for each element-embedding level.documentType - Document type (DTS declaration). Null if no document type.encoding - Character encoding. Must be UTF-8, UTF-16, or null (defaults to UTF-8).
public static void setCDataText(org.w3c.dom.Node parent,
java.lang.String text)
parent - The org.w3c.dom element which is to receive the text data.text - The text content which is to be added to the parent node.
public static org.w3c.dom.Element findChildByAttribute(org.w3c.dom.Element parentElement,
java.lang.String elementName,
java.lang.String attributeName,
java.lang.String attributeValue)
parentElement - The org.w3c.dom element whose child elements are to be scanned.elementName - The desired element name.attributeName - The name of the attribute to be checked.attributeValue - The desired element value.
public static org.w3c.dom.Element appendContentElement(org.w3c.dom.Element parentElement,
java.lang.String tagName,
java.lang.String value)
parentElement - The org.w3c.dom element which is to receive the text data.tagName - The name of the new child element which will contain the text datavalue - The text content which will become the content of the new child node.
public static java.lang.String getContentElement(org.w3c.dom.Element parentElement,
java.lang.String tagName)
parentElement - The org.w3c.dom element whose children are to be scanned.tagName - The desired child node name.
public static java.lang.Long getLongContent(org.w3c.dom.Element element)
element - The org.w3c.dom element whose text content is to be parsed.
public static org.w3c.dom.Element appendAttributeElement(org.w3c.dom.Element parentElement,
java.lang.String tagName,
java.lang.String attributeName,
java.lang.String value)
parentElement - An existing org.w3c.dom element to which the new node is to be appended.tagName - The node name to be applied when creating the child node.attributeName - The attribute name.value - The attribute value.
public static java.lang.String getAttributeElement(org.w3c.dom.Element parent,
java.lang.String tagName,
java.lang.String attributeName)
parent - The org.w3c.dom element whose children are to be scanned.tagName - The desired child node name.attributeName - The name of the attribute whose value is desired.
public static org.w3c.dom.Element appendValueElement(org.w3c.dom.Element parentElement,
java.lang.String tagName,
java.lang.String value)
parentElement - An existing org.w3c.dom element to which the new node is to be appended.tagName - The node name to be applied when creating the child node.value - The text which is to become the new node's content.
public static java.lang.String getValueElement(org.w3c.dom.Element parent,
java.lang.String tagName)
parent - An org.w3c.dom element whose children are to be scanned.tagName - The desired child element's node name.
public static org.w3c.dom.Element getChildElement(org.w3c.dom.Element parent,
java.lang.String tagName)
parent - An org.w3c.dom element whose children are to be scanned.tagName - The desired child element's node name.
public static java.lang.String cdataEncode(java.lang.String text)
text - The unencoded text.
public static java.lang.String cdataDecode(java.lang.String text)
text - The encoded text.
public static java.lang.String getNodePath(org.w3c.dom.Node node)
node - The indicated node.
public static java.lang.String getNodeTypeName(int nodeType)
nodeType - The org.w3c.dom node type, which is an integer.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||