public class XmlHandler
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
CODER |
static java.lang.String |
END_LT_TAG |
static java.lang.String |
GT |
static java.lang.String |
GT_TAG
The XML tags and the characters that replace them during conversion
|
static java.lang.String |
LT |
static java.lang.String |
LT_TAG |
static java.lang.String |
SEPARATOR |
protected static java.lang.String |
XMLELEMENT |
protected static java.lang.String |
XMLELEMENTINTERFACE
Defines an element
|
static java.lang.String |
XMLHEADEND |
static java.lang.String |
XMLHEADSTART |
Constructor and Description |
---|
XmlHandler()
Create a new instance of XmlHandler
|
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
addElementSpec(java.lang.String xmlStr)
Add the special characters indicating an XML element.
|
static java.lang.String |
addPrefix(java.lang.String prefix,
java.lang.String tag)
Add the prefix to the element tag name.
|
static java.lang.String |
addStringSpec(java.lang.String xmlStr)
Add the special characters indicating a string of any format that should
not be converted into anything else.
|
static Element |
elementFromStream(java.io.FileInputStream inputStream)
Create an element representing the data in the input stream.
|
static boolean |
elementsMatch(java.lang.String className1,
java.lang.String className2)
Return true if the two class names represent elements supported by the
current XML parser.
|
static Element |
firstWithName(Element rootElem,
java.lang.String elemName)
Get the first element with the specified name.
|
static java.lang.String |
getPrefix(java.lang.String valueStr)
Get the prefix to the value passed in if one exists.
|
static boolean |
isElement(java.lang.String className)
Return true if the class name indicates an XML element.
|
static boolean |
isElementSpec(java.lang.String xmlStr)
Return true if the String is an element specification.
|
static boolean |
isStringCoder(java.lang.String xmlStr)
Return true if the input is actually the string coder.
|
static java.util.Vector<java.lang.String> |
listToVector(Element xmlList)
Convert the list in XML format into a Vector.
|
static java.lang.String |
removeCoding(java.lang.String xmlStr)
Remove the special text sequences added as coding.
|
static java.lang.String |
removeElementSpecs(java.lang.String xmlStr)
Remove the text sequences indicating an XML element.
|
static java.lang.String |
removePrefix(java.lang.String valueStr)
Get the tag value with the prefix removed if one exists.
|
static java.lang.String |
removeStringSpec(java.lang.String xmlStr)
Remove the special text characters indicating the string that should not be
converted into XML.
|
static java.lang.String |
removeStringSpecs(java.lang.String xmlStr)
Remove the special text coding sequences anywhere in the string.
|
static Element |
stringToElement(java.lang.String elemStr)
Convert the string representation back to an element.
|
static Element |
wrapWithElement(java.lang.String tag,
java.lang.String meta)
Wrap the input string with an element.
|
static void |
xmlToFile(java.io.FileOutputStream outputStream,
Document document)
Convert an XML document into its String equivalent and write to the file.
|
static java.lang.String |
xmlToFormattedString(Element rootElem)
Convert an XML document into a formatted String equivalent.
|
static java.lang.String |
xmlToString(Document document)
Convert an XML document into its String equivalent.
|
static java.lang.String |
xmlToString(Element element)
Convert an XML element into its String equivalent.
|
public static final java.lang.String GT_TAG
public static final java.lang.String GT
public static final java.lang.String LT_TAG
public static final java.lang.String END_LT_TAG
public static final java.lang.String LT
public static final java.lang.String XMLHEADSTART
public static final java.lang.String XMLHEADEND
protected static final java.lang.String XMLELEMENTINTERFACE
protected static final java.lang.String XMLELEMENT
public static final java.lang.String SEPARATOR
public static final java.lang.String CODER
public static java.lang.String xmlToString(Document document) throws java.lang.Exception
document
- the document.java.lang.Exception
- any error.public static java.lang.String xmlToString(Element element) throws java.lang.Exception
element
- the element.java.lang.Exception
- any error.public static java.lang.String xmlToFormattedString(Element rootElem) throws java.lang.Exception
rootElem
- the root element.java.lang.Exception
- any error.public static void xmlToFile(java.io.FileOutputStream outputStream, Document document) throws java.lang.Exception
outputStream
- the file to write to.document
- the document.java.lang.Exception
- any error.public static Element stringToElement(java.lang.String elemStr) throws java.lang.Exception
elemStr
- the element as a string.java.lang.Exception
- any error.public static Element elementFromStream(java.io.FileInputStream inputStream) throws java.lang.Exception
inputStream
- the input stream in XML format.java.lang.Exception
- any error.public static java.util.Vector<java.lang.String> listToVector(Element xmlList)
xmlList
- the list in XML format.public static Element wrapWithElement(java.lang.String tag, java.lang.String meta)
tag
- the element tag.meta
- the string value.public static Element firstWithName(Element rootElem, java.lang.String elemName) throws java.lang.Exception
rootElem
- the root element to parse from.elemName
- the name of the element to find.null
if none exist.java.lang.Exception
- any error.public static java.lang.String addPrefix(java.lang.String prefix, java.lang.String tag)
prefix
- the prefix name.tag
- the tag name.public static java.lang.String getPrefix(java.lang.String valueStr)
valueStr
- the value to parse to retrieve the prefix.public static java.lang.String removePrefix(java.lang.String valueStr)
valueStr
- the value to parse to remove the prefix.public static boolean elementsMatch(java.lang.String className1, java.lang.String className2)
className1
- the class name of the first object.className2
- the class name of the second object.public static boolean isElement(java.lang.String className)
className
- the class name of the object.public static boolean isElementSpec(java.lang.String xmlStr)
xmlStr
- the xml String. This should start with the element class
and the special additional characters.public static boolean isStringCoder(java.lang.String xmlStr)
xmlStr
- the original String.public static java.lang.String addStringSpec(java.lang.String xmlStr)
xmlStr
- the original String.public static java.lang.String removeStringSpec(java.lang.String xmlStr)
xmlStr
- the original String with the special characters included.public static java.lang.String removeStringSpecs(java.lang.String xmlStr)
xmlStr
- the original String with the special characters included.public static java.lang.String addElementSpec(java.lang.String xmlStr)
xmlStr
- the original String.public static java.lang.String removeElementSpecs(java.lang.String xmlStr)
xmlStr
- the original String with the special characters included.public static java.lang.String removeCoding(java.lang.String xmlStr)
removeElementSpecs
and removeStringSpecs
for a complete clean.xmlStr
- the original String with the special characters included.