|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.novell.xml.util.XMLUtil
utility class for various XML support routines
| Field Summary | |
static String |
DIGITS
|
static String |
HEX_DIGITS
|
static String |
XML_STYLE_SHEET
Name of the xml-stylesheet processing instruction. |
| Method Summary | |
static void |
encodeAsCData(Writer stream,
String value)
Output a text value as a CDATA section |
static void |
encodeAttribute(Writer stream,
String value)
Encode an attribute value as XML to a stream. |
static void |
encodeText(Writer stream,
String text)
Encode character data as XML text: '&' and '<' will be replaced by '&' and '<' ']]>' will be encoded ']]>' |
static String |
escape(String string)
Returns the specified string with tabs, carriage returns, line feeds, and ampersands translated to XML-style nn; sequences. |
static String |
escape(String string,
int maxLength)
Returns the specified string with tabs, carriage returns, line feeds, and ampersands translated to XML-style nn; sequences. |
static URL |
filenameToURL(String filename)
Converts the specified filename into a URL that uses the file protocol. |
static String |
getLocalName(String qname)
Returns the local name from a qname. |
static String |
getPrefix(String qname)
Returns the prefix from a qname. |
static String |
getPseudoAttribute(String data,
String attrName)
Return the value of a pseudo XML attribute from a string. |
static boolean |
isNamespaceDecl(String name)
Checks an attribute qname to see if it is a namespace declaration |
static boolean |
isNCName(char c)
returns whether the passed character matches the XML Namespace "NCName" production |
static boolean |
isNCName(String str)
returns whether the passed string matches the XML Namespace "NCName" production |
static boolean |
isNCNameChar(char ch)
Returns whether the specified character conforms to the NCNameChar production in the XML Namespace grammar. |
static boolean |
isPITarget(String name)
Returns whether the passed string conforms to the PITarget production in the XML 1.0 Recommendation. |
static boolean |
isQName(String name)
Returns whether the passed string conforms to the QName production found in XML Names: http://www.w3.org/TR/REC-xml-names |
static boolean |
isXMLEncName(String str)
Return true if the passed string conforms to the XML EncName production |
static boolean |
isXMLName(char c)
Returns whether the specified char conforms to the Name production in the XML 1.0 grammar. |
static boolean |
isXMLName(String str)
Returns whether the specified string conforms to the Name production in the XML 1.0 grammar. |
static boolean |
isXMLNameChar(char ch)
Returns whether the specified character conforms to the NameChar production in the XML 1.0 grammar. |
static boolean |
isXMLVersionNum(String str)
Return true if the passed string conforms to the XML VersionNum production |
static boolean |
isXMLWhitespace(char c)
Returns whether the specified string conforms to the S production in the XML 1.0 grammar. |
static boolean |
isXMLWhitespace(String str)
Returns whether the specified string conforms to the S production in the XML 1.0 grammar. |
static String |
normalizeWhitespace(String source)
Normalize whitespace in a string by stripping leading and trailing whitespace, and converting all internal sequences of whitespace into a single space each. |
static String |
quote(String string)
Returns the specified string enclosed in double-quotes, with double-quotes, tabs, carriage returns, line feeds, and ampersands translated to XML-style nn;
sequences. |
static String |
quote(String string,
int maxLength)
Returns the specified string enclosed in double-quotes, with double-quotes, tabs, carriage returns, line feeds, and ampersands translated to XML-style nn;
sequences. |
static String |
replaceBuiltInEntities(String rawString)
|
static String |
toXML(String rawString)
encodes the passed string in XML-format: '<', '>', '&', '"', '\'' are replaced by "<", ">", "&", """, and "'" In addition, any two-char UTF-16 surrogate chars are replaced by character references |
static String |
toXML(String rawString,
String specials)
encodes the passed string in XML-format: '<', '>', '&', '"', '\'' are replaced by "<", ">", "&", """, and "'" Any chars in rawString found in specials String will be replaced by character references In addition, any two-char UTF-16 surrogate chars are replaced by character references |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final String XML_STYLE_SHEET
xml-stylesheet processing instruction.
public static final String DIGITS
public static final String HEX_DIGITS
| Method Detail |
public static URL filenameToURL(String filename)
throws MalformedURLException
file protocol.
filename - the filename to be converted
MalformedURLExceptionpublic static String escape(String string)
nn; sequences. If the string is
null, the six-character string "(null)" is
returned.
string - the string to escape
public static String escape(String string,
int maxLength)
nn; sequences. If the string is
null, the six-character string "(null)" is
returned.
If necessary, the returned string is truncated to force it to be no
longer than the specified maximum length. A truncated string ends with
the three characters "...".
string - the string to escapemaxLength - the escaped string's maximum length
public static String quote(String string)
nn;
sequences. If the string is null, the unquoted
six-character string "(null)" is returned.
string - the string to quote
public static String quote(String string,
int maxLength)
nn;
sequences. If the string is null, the unquoted
six-character string "(null)" is returned.
If necessary, the returned string is truncated to force it to be no
longer than the specified maximum length. A truncated string has its
last three characters replaced with "...".
string - the string to quotemaxLength - the quoted string's maximum length
public static String normalizeWhitespace(String source)
source - The string to be normalized
public static boolean isXMLName(String str)
str - the string to be checked
true if the string is an XML 1.0
Name, false if it is notpublic static boolean isXMLName(char c)
c - the char to be checked
true if the string is an XML 1.0
Name, false if it is notpublic static boolean isXMLNameChar(char ch)
ch - the character to be checked
true if the character is an XML 1.0
NameChar, false if it is notpublic static boolean isNCName(char c)
c - character to check
public static boolean isNCName(String str)
str - string to check
public static boolean isNCNameChar(char ch)
ch - the character to be checked
true if the character is an XML 1.0
NameChar, false if it is notpublic static boolean isQName(String name)
name - The string to check for conformance to QName.
public static boolean isPITarget(String name)
name - String to check
public static boolean isXMLWhitespace(String str)
str - the string to be checked
true if the string consists only of XML
whitespace, false if it does notpublic static boolean isXMLWhitespace(char c)
c - the char to be checked
true if the char is an XML 'S' production characterpublic static boolean isXMLVersionNum(String str)
str - The string to check.
public static boolean isXMLEncName(String str)
str - The string to check.
true if the passed string conforms to the XML EncName
production.public static boolean isNamespaceDecl(String name)
name - the attribute qname
public static String toXML(String rawString)
rawString - string to convert to XML format
public static String toXML(String rawString,
String specials)
rawString - string to convert to XML formatspecials - collection of chars to use char references for
public static void encodeText(Writer stream,
String text)
throws IOException
stream - The output stream to which to send the datatext - The text to encode
IOException
public static void encodeAttribute(Writer stream,
String value)
throws IOException
stream - The stream to which to write the attribute value.value - The attribute value.
IOException
public static void encodeAsCData(Writer stream,
String value)
throws IOException
stream - The writer to which to serialize the CDATA sectionvalue - The text value to output
IOExceptionpublic static String replaceBuiltInEntities(String rawString)
public static String getPseudoAttribute(String data,
String attrName)
data - The data to parse for the attribute valueattrName - The name of the pseudo attributepublic static String getLocalName(String qname)
qname - the qname whose local name is to be returned
public static String getPrefix(String qname)
qname - the qname whose local name is to be returned
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||