|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eigenbase.xom.XMLUtil
public class XMLUtil
Utilities for dealing with XML data. These methods must NOT depend upon any XML parser or object model (MSXML, DOM, SAX, etc.)
Constructor Summary | |
---|---|
XMLUtil()
|
Method Summary | |
---|---|
static String |
getFirstTagName(Reader xml)
Retrieve the name of the first tag in the XML document specified by the given Reader, without parsing the full file/string. |
static void |
printAtt(PrintWriter pw,
String val)
Quote a string so that it can be included as an XML attribute value. |
static void |
printAtt(PrintWriter pw,
String name,
boolean val)
Print an XML attribute name and value for boolean val |
static void |
printAtt(PrintWriter pw,
String name,
int val)
Print an XML attribute name and value for int val |
static void |
printAtt(PrintWriter pw,
String name,
String val)
Print an XML attribute name and value for string val |
static void |
printPCDATA(PrintWriter pw,
String data)
Quote a string, and write to a PrintWriter . |
static void |
printPCDATA(PrintWriter pw,
String tag,
String data)
|
static void |
printPCDATA(PrintWriter pw,
String tag,
String data,
boolean newline)
Quote a string in an element and a CDATA, and write to a PrintWriter . |
static String |
quoteAtt(String val)
Quote a string so that it can be included as an XML attribute value. |
static String |
quoteAtt(String name,
boolean val)
Return an XML attribute/value pair for boolean val |
static String |
quoteAtt(String name,
int val)
Return an XML attribute/value pair for int val |
static String |
quoteAtt(String name,
String val)
Return an XML attribute/value pair for String val |
static String |
quotePCDATA(String data)
Quote a string. |
static void |
stringEncodeXML(String input,
PrintWriter out)
Encode a String for XML output, displaying it to a PrintWriter. |
static boolean |
stringHasXMLSpecials(String input)
Determine if a String contains any XML special characters, return true if it does. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public XMLUtil()
Method Detail |
---|
public static boolean stringHasXMLSpecials(String input)
input
- the String to scan for XML special characters.
public static void stringEncodeXML(String input, PrintWriter out)
input
- a String to convert.out
- a PrintWriter to which to write the results.public static void printPCDATA(PrintWriter pw, String data)
PrintWriter
.
For example, "a string"
becomes <![CDATA[a
string]]>
. If the string contains ']]>' (which commonly
occurs when wrapping other XML documents), we give up on using
<![CDATA[
... ]]>
, and just encode the
string. For example, "A string with ]]> in it"
becomes
"A string with ]]> in it"
.
public static String quotePCDATA(String data)
printPCDATA(PrintWriter,String)
public static void printPCDATA(PrintWriter pw, String tag, String data, boolean newline)
PrintWriter
. For example, it tag
is "Value", then
"a string"
becomes <Value><![CDATA[a
string]]></Value>.
- Parameters:
newline
- whether to print a newline after the element- See Also:
printPCDATA(PrintWriter,String)
public static void printPCDATA(PrintWriter pw, String tag, String data)
public static String quoteAtt(String val)
public static String quoteAtt(String name, String val)
public static String quoteAtt(String name, int val)
public static String quoteAtt(String name, boolean val)
public static void printAtt(PrintWriter pw, String val)
public static void printAtt(PrintWriter pw, String name, String val)
public static void printAtt(PrintWriter pw, String name, int val)
public static void printAtt(PrintWriter pw, String name, boolean val)
public static String getFirstTagName(Reader xml)
xml
- a Reader containing an XML document.
|
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |