|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.xmlmind.util.XMLUtil
public final class XMLUtil
A collection of utility functions (static methods) related to XML.
| Method Summary | |
|---|---|
static java.io.Reader |
createReader(java.io.InputStream in,
java.lang.String fallbackEncoding,
java.lang.String[] encoding)
Creates a reader allowing to read the contents of specified text source. |
static java.lang.String |
detectEncoding(byte[] bytes,
int byteCount,
int[] bomLength)
Detect XML encoding by examining specified bytes which have been read at the very start of an XML file. |
static java.lang.String |
loadChars(java.io.Reader in)
Load the characters contained in specified source. |
static java.lang.String |
loadText(java.io.File file,
java.lang.String[] encoding)
Equivalent to loadText(FileUtil.fileToURL(file), encoding). |
static java.lang.String |
loadText(java.io.InputStream in,
java.lang.String fallbackEncoding,
java.lang.String[] encoding)
Loads the contents of specified text source. |
static java.lang.String |
loadText(java.net.URL url,
java.lang.String[] encoding)
Loads the contents of specified text file. |
static javax.xml.parsers.SAXParser |
newSAXParser()
Equivalent to newSAXParser(true, false, false). |
static javax.xml.parsers.SAXParser |
newSAXParser(boolean namespaceAware,
boolean validating,
boolean xIncludeAware)
Convenience method: creates and returns a SAXParser. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static javax.xml.parsers.SAXParser newSAXParser()
throws javax.xml.parsers.ParserConfigurationException,
org.xml.sax.SAXException
newSAXParser(true, false, false).
javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException
public static javax.xml.parsers.SAXParser newSAXParser(boolean namespaceAware,
boolean validating,
boolean xIncludeAware)
throws javax.xml.parsers.ParserConfigurationException,
org.xml.sax.SAXException
namespaceAware - specifies whether the parser produced
by this code will provide support for XML namespacesvalidating - specifies whether the parser produced by
this code will validate documents against their DTDxIncludeAware - specifies whether the parser produced by
this code will process XIncludes
javax.xml.parsers.ParserConfigurationException - if a parser cannot be created
which satisfies the requested configuration
org.xml.sax.SAXException - for SAX errors
public static java.lang.String loadText(java.io.File file,
java.lang.String[] encoding)
throws java.io.IOException
loadText(FileUtil.fileToURL(file), encoding).
java.io.IOException
public static java.lang.String loadText(java.net.URL url,
java.lang.String[] encoding)
throws java.io.IOException
Unlike URLUtil.loadString(java.net.URL), this method implements
the detection of the encoding.
Note that the detection of the encoding always works because it uses a fallback value.
url - the location of the text fileencoding - the detected encoding is copied there.
May be null.
java.io.IOException - if there is an I/O problem
public static java.lang.String loadText(java.io.InputStream in,
java.lang.String fallbackEncoding,
java.lang.String[] encoding)
throws java.io.IOException
This method implements the detection of the encoding.
Note that the detection of the encoding always works because it uses a fallback value.
in - the text sourcefallbackEncoding - the fallback encoding
May be null.encoding - the detected encoding is copied there.
May be null.
java.io.IOException - if there is an I/O problemloadText(URL, String[])
public static java.lang.String loadChars(java.io.Reader in)
throws java.io.IOException
in - the character source
java.io.IOException - if there is an I/O problem
public static java.io.Reader createReader(java.io.InputStream in,
java.lang.String fallbackEncoding,
java.lang.String[] encoding)
throws java.io.IOException
This method implements the detection of the encoding.
Note that the detection of the encoding always works because it uses a fallback value.
in - the text sourceencoding - the detected encoding is copied there.
May be null.
java.io.IOException - if there is an I/O problem
public static java.lang.String detectEncoding(byte[] bytes,
int byteCount,
int[] bomLength)
bytes - bytes read at the very start of an XML filebyteCount - number of bytes read at the very start of an XML filebomLength - the length of the BOM is stored as the first element
of this array. This allows to skip the BOM. May be null.
null otherwise
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||