|
SMILA (incubation) API documentation | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.smila.utils.xml.XMLUtils
public abstract class XMLUtils
All parse()
methods must be given a wellformatted XML rescource, in which the encoding is set
forth, since none of them recieves such an parameter. If no encoding is specified in the XML recource, UTF-8 is
assumed as set forth by the W3C recommendation.
For all stream()
methods without the encoding-paramter the default encoding UTF-8 is assumed (W3C
Recommendation?).
Method Summary | |
---|---|
static void |
clearGrammarCache()
clearGrammarCache. |
static boolean |
decodeBoolean(java.lang.String xmlBoolean)
|
static java.util.Date |
decodeDate(java.lang.String xmlDate)
|
static java.util.Date |
decodeDateTime(java.lang.String xmlDate)
|
static int |
decodeInteger(java.lang.String xmlInteger)
|
static java.lang.String |
encodeBoolean(boolean javaBoolean)
|
static java.lang.String |
encodeDate(java.util.Date javaDate)
|
static java.lang.String |
encodeDateTime(java.util.Date javaDate)
|
static java.lang.String |
encodeInteger(int value)
|
static java.lang.String |
encodeInteger(java.lang.Integer value)
|
static java.lang.String |
generateGUID(java.lang.Object o)
A 32 byte GUID generator (Globally Unique ID). |
static org.w3c.dom.Document |
getDocument()
Returns an empty document whose document element is not set! The type of the document is by default an XML-Document - I think. |
static org.w3c.dom.Document |
getDocument(java.lang.String docElement)
Creates a document with a new document element with it's name set to the given text. |
static java.lang.String |
getLocalPart(java.lang.String xml)
This method converts a given XML attribute or element name to a local representation by stripping it of its namespace prefix. |
static boolean |
isXML(byte[] message)
|
static boolean |
isXML(java.io.File file)
|
static boolean |
isXML(java.io.InputStream is)
|
static void |
loadSchema(java.lang.String schemaName,
BundleContext context)
|
static void |
loadSchemas(java.io.File folder,
java.lang.String filter,
java.lang.String schemaUrlPrefix)
|
static org.w3c.dom.Document |
parse(byte[] bytes,
boolean validate)
Shorthand for parse(bytes, new XMLUtilsConfig(validate,
true)). |
static org.w3c.dom.Document |
parse(byte[] bytes,
XMLUtilsConfig cfg)
Parses a document from the given byte-array.The applied enconding must be declared within the XML-document-instance or othersise UTF-8 is assumened according to the W3C recommendation. |
static org.w3c.dom.Document |
parse(java.io.File file,
boolean validate)
Shorthand for parse(file, new XMLUtilsConfig(validate,
true)). |
static org.w3c.dom.Document |
parse(java.io.File file,
XMLUtilsConfig cfg)
Parses a document from the given File. |
static org.w3c.dom.Document |
parse(java.io.InputStream is,
boolean validate)
Shorthand for parse(is , new XMLUtilsConfig(validate,
true)). |
static org.w3c.dom.Document |
parse(java.io.InputStream is,
XMLUtilsConfig cfg)
Parses a document from the given InputStream.The applied enconding must be declared within the XML-document-instance or othersise UTF-8 is assumened according to the W3C recommendation. |
static void |
removeWhitespaceTextNodes(org.w3c.dom.Element parent)
Traverserses through a DOM tree starting at the given element and removes all those text-nodes from it that only contain whitespaces. |
static void |
setGrammarCacheLock(boolean lockState)
|
static byte[] |
stream(org.w3c.dom.Element el,
boolean validate)
Shorthand for stream(el , validate,
"UTF-8")). |
static byte[] |
stream(org.w3c.dom.Element el,
boolean validate,
boolean preserveSpace)
Shorthand for stream(el , validate,
"UTF-8")). |
static byte[] |
stream(org.w3c.dom.Element el,
boolean validate,
java.lang.String enc,
boolean preserveSpace)
Streams the given DOM-(Sub)tree starting at the given Element into the returned byte-array. |
static void |
stream(org.w3c.dom.Element el,
boolean validate,
java.lang.String enc,
java.io.File file)
Streams the given DOM-(Sub)tree starting at the given Element into the given File. |
static void |
stream(org.w3c.dom.Element el,
boolean validate,
java.lang.String enc,
java.io.OutputStream os)
Streams the given DOM-(Sub)tree starting at the given Element into the returned byte-array. |
static boolean |
validate(org.w3c.dom.Element el)
Validates the given element and it's decendants against the XML-Schema as specified in the given element. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static void clearGrammarCache()
public static boolean decodeBoolean(java.lang.String xmlBoolean)
xmlBoolean
- -
public static java.util.Date decodeDate(java.lang.String xmlDate) throws java.text.ParseException
java.text.ParseException
public static java.util.Date decodeDateTime(java.lang.String xmlDate) throws java.text.ParseException
java.text.ParseException
public static int decodeInteger(java.lang.String xmlInteger)
public static java.lang.String encodeBoolean(boolean javaBoolean)
public static java.lang.String encodeDate(java.util.Date javaDate)
public static java.lang.String encodeDateTime(java.util.Date javaDate)
public static java.lang.String encodeInteger(int value)
public static java.lang.String encodeInteger(java.lang.Integer value)
public static final java.lang.String generateGUID(java.lang.Object o)
o
- -
public static org.w3c.dom.Document getDocument()
public static org.w3c.dom.Document getDocument(java.lang.String docElement)
docElement
- -
public static java.lang.String getLocalPart(java.lang.String xml)
xml
- -
public static boolean isXML(byte[] message)
public static boolean isXML(java.io.File file)
public static boolean isXML(java.io.InputStream is)
public static void loadSchema(java.lang.String schemaName, BundleContext context) throws XMLUtilsException
schemaName
- Schema name.
XMLUtilsException
- Unable to resolve schema.public static void loadSchemas(java.io.File folder, java.lang.String filter, java.lang.String schemaUrlPrefix) throws XMLUtilsException
XMLUtilsException
public static org.w3c.dom.Document parse(byte[] bytes, boolean validate) throws XMLUtilsException
parse(bytes, new XMLUtilsConfig(validate,
true)).
bytes
- -validate
- -
XMLUtilsException
- -public static org.w3c.dom.Document parse(byte[] bytes, XMLUtilsConfig cfg) throws XMLUtilsException
bytes
- -cfg
- -
XMLUtilsException
- if cgf contains invalid values or parsing results in an error.
XMLUtilsException
- -public static org.w3c.dom.Document parse(java.io.File file, boolean validate) throws XMLUtilsException
parse(file, new XMLUtilsConfig(validate,
true)).
file
- -validate
- -
XMLUtilsException
- -public static org.w3c.dom.Document parse(java.io.File file, XMLUtilsConfig cfg) throws XMLUtilsException
file
- -cfg
- -
XMLUtilsException
- if the File dosn't point to a valid location, cgf contains invalid values, or parsing results in an
error.
XMLUtilsException
- -public static org.w3c.dom.Document parse(java.io.InputStream is, boolean validate) throws XMLUtilsException
parse(is , new XMLUtilsConfig(validate,
true)).
is
- -validate
- -
XMLUtilsException
- -public static org.w3c.dom.Document parse(java.io.InputStream is, XMLUtilsConfig cfg) throws XMLUtilsException
cfg
- ---is
- -
XMLUtilsException
- if cgf contains invalid values or parsing results in an error.
XMLUtilsException
- -public static void removeWhitespaceTextNodes(org.w3c.dom.Element parent)
parent
- -public static void setGrammarCacheLock(boolean lockState)
public static byte[] stream(org.w3c.dom.Element el, boolean validate) throws XMLUtilsException
stream(el , validate,
"UTF-8")).
el
- -validate
- -
XMLUtilsException
- -public static byte[] stream(org.w3c.dom.Element el, boolean validate, boolean preserveSpace) throws XMLUtilsException
stream(el , validate,
"UTF-8")).
el
- -validate
- -preserveSpace
- -
XMLUtilsException
- -public static byte[] stream(org.w3c.dom.Element el, boolean validate, java.lang.String enc, boolean preserveSpace) throws XMLUtilsException
enc
- the encoding that shall be applied. The given String must conform to the encodings as set forth by the W3C
and are somewhat different to that of Java.validate
- whether the given DOM-(sub)tree shall be validated against an XML-Schema that is referenced in the given
element.preserveSpace
- -el
- -
XMLUtilsException
- -public static void stream(org.w3c.dom.Element el, boolean validate, java.lang.String enc, java.io.File file) throws XMLUtilsException
enc
- the encoding that shall be applied. The given String must conform to the encodings as set forth by the W3C
and are somewhat different to that of Java.validate
- whether the given DOM-(sub)tree shall be validated against an XML-Schema that is referenced in the given
element.file
- if it exist it will be overwritten otherwise created. If acces rights are violated an XMLUtilsExcpetion is
thrown.el
- -
XMLUtilsException
- -public static void stream(org.w3c.dom.Element el, boolean validate, java.lang.String enc, java.io.OutputStream os) throws XMLUtilsException
enc
- the encoding that shall be applied. The given String must conform to the encodings as set forth by the W3C
and are somewhat different to that of Java.validate
- whether the given DOM-(sub)tree shall be validated against an XML-Schema that is referenced in the given
element.el
- -os
- -
XMLUtilsException
- -public static boolean validate(org.w3c.dom.Element el) throws XMLUtilsException
Unless someone finds a way to validate a life DOM-Tree against a given schema, the quickest way to do this is to, write the damn thing into an ByteArrayOutputStream and to read from that again, and while reading it perform a validation.
el
- -
XMLUtilsException
- -
|
SMILA (incubation) API documentation | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |