OBEROn SDK

com.oberon.util
Class XMLUtils

java.lang.Object
  extended by com.oberon.util.XMLUtils

public class XMLUtils
extends java.lang.Object

Utilities for XML data manipulation

Version:
5.0

Constructor Summary
XMLUtils()
           
 
Method Summary
static int elementToJSONStream(org.jdom.Element xmlElement, java.io.OutputStreamWriter writer, boolean prettyFormat, boolean rootElement)
          Convert an XML structure to a JSON string and send the text to an Output stream
static java.lang.String elementToJSONString(org.jdom.Element xmlElement)
          Convert an XML structure to a JSON string, in pretty format
static java.lang.String elementToJSONString(org.jdom.Element xmlElement, boolean prettyFormat, boolean rootElement)
          Convert an XML structure to a JSON string
static int elementToStream(org.jdom.Element xmlElement, java.io.OutputStreamWriter writer, boolean prettyFormat)
          Convert an XML structure to a UTF-8 text string (in pretty format) and send the text to an Output stream
static int elementToStream(org.jdom.Element xmlElement, java.io.OutputStreamWriter writer, boolean prettyFormat, java.lang.String encoding)
          Convert an XML structure to a text string with the given character encoding and send the text to an Output stream
static java.lang.String elementToString(org.jdom.Element xmlElement)
          Convert an XML structure to a UTF-8 text string, in pretty format
static java.lang.String elementToString(org.jdom.Element xmlElement, boolean prettyFormat, boolean omitDeclaration, java.lang.String encoding)
          Convert an XML structure to a text string with the given character encoding
static java.lang.String elementToString(org.jdom.Element xmlElement, boolean prettyFormat, java.lang.String encoding)
          Convert an XML structure to a text string with the given character encoding
static org.jdom.Element parseJSONInputStream(java.io.InputStream inStream)
          Parse a JSON input stream
static org.jdom.Element parseXML(java.lang.String xmlText)
          Parse an UTF-8 XML text
static org.jdom.Element parseXML(java.lang.String xmlText, java.lang.String encoding)
          Parse an XML text for the given character encoding
static org.jdom.Element parseXMLInputStream(java.io.InputStream inStream)
          Parse an XML input stream
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLUtils

public XMLUtils()
Method Detail

parseXML

public static org.jdom.Element parseXML(java.lang.String xmlText)
                                 throws java.io.UnsupportedEncodingException,
                                        org.jdom.JDOMException,
                                        java.io.IOException
Parse an UTF-8 XML text

Returns:
the XML element structure
Throws:
java.io.UnsupportedEncodingException
org.jdom.JDOMException
java.io.IOException

parseXML

public static org.jdom.Element parseXML(java.lang.String xmlText,
                                        java.lang.String encoding)
                                 throws java.io.UnsupportedEncodingException,
                                        org.jdom.JDOMException,
                                        java.io.IOException
Parse an XML text for the given character encoding

Returns:
the XML element structure
Throws:
java.io.UnsupportedEncodingException
org.jdom.JDOMException
java.io.IOException

parseXMLInputStream

public static org.jdom.Element parseXMLInputStream(java.io.InputStream inStream)
                                            throws org.jdom.JDOMException,
                                                   java.io.IOException
Parse an XML input stream

Returns:
the XML element structure
Throws:
org.jdom.JDOMException
java.io.IOException
Since:
4.2.3

elementToString

public static java.lang.String elementToString(org.jdom.Element xmlElement)
                                        throws OberonException
Convert an XML structure to a UTF-8 text string, in pretty format

Throws:
OberonException

elementToString

public static java.lang.String elementToString(org.jdom.Element xmlElement,
                                               boolean prettyFormat,
                                               java.lang.String encoding)
                                        throws OberonException
Convert an XML structure to a text string with the given character encoding

Parameters:
prettyFormat - if true, generates indented text
Throws:
OberonException

elementToString

public static java.lang.String elementToString(org.jdom.Element xmlElement,
                                               boolean prettyFormat,
                                               boolean omitDeclaration,
                                               java.lang.String encoding)
                                        throws OberonException
Convert an XML structure to a text string with the given character encoding

Parameters:
prettyFormat - if true, generates indented text
omitDeclaration - if true, omit the xml header
Throws:
OberonException

elementToStream

public static int elementToStream(org.jdom.Element xmlElement,
                                  java.io.OutputStreamWriter writer,
                                  boolean prettyFormat)
                           throws java.io.IOException,
                                  OberonException
Convert an XML structure to a UTF-8 text string (in pretty format) and send the text to an Output stream

Throws:
java.io.IOException
OberonException

elementToStream

public static int elementToStream(org.jdom.Element xmlElement,
                                  java.io.OutputStreamWriter writer,
                                  boolean prettyFormat,
                                  java.lang.String encoding)
                           throws java.io.IOException,
                                  OberonException
Convert an XML structure to a text string with the given character encoding and send the text to an Output stream

Parameters:
prettyFormat - if true, generates indented text
Throws:
java.io.IOException
OberonException

elementToJSONString

public static java.lang.String elementToJSONString(org.jdom.Element xmlElement)
                                            throws OberonException
Convert an XML structure to a JSON string, in pretty format

Throws:
OberonException
Since:
4.2.3

elementToJSONString

public static java.lang.String elementToJSONString(org.jdom.Element xmlElement,
                                                   boolean prettyFormat,
                                                   boolean rootElement)
                                            throws OberonException
Convert an XML structure to a JSON string

Parameters:
prettyFormat - if true, generates indented text
rootElement - if true, add the rootElement
Throws:
OberonException
Since:
4.2.3

elementToJSONStream

public static int elementToJSONStream(org.jdom.Element xmlElement,
                                      java.io.OutputStreamWriter writer,
                                      boolean prettyFormat,
                                      boolean rootElement)
                               throws java.io.IOException,
                                      OberonException
Convert an XML structure to a JSON string and send the text to an Output stream

Parameters:
prettyFormat - if true, generates indented text
rootElement - if true, add the rootElement
Throws:
java.io.IOException
OberonException

parseJSONInputStream

public static org.jdom.Element parseJSONInputStream(java.io.InputStream inStream)
                                             throws java.io.IOException,
                                                    org.json.simple.parser.ParseException
Parse a JSON input stream

Returns:
the XML element structure
Throws:
org.json.simple.parser.ParseException
java.io.IOException
Since:
4.2.3

OBEROn SDK

Copyright © 2008-2014 Mirko Solazzi. All Rights Reserved.