org.placidus.jaxb
Class JaxbHelper

java.lang.Object
  extended by org.placidus.jaxb.JaxbHelper

public class JaxbHelper
extends java.lang.Object


Field Summary
static javax.xml.bind.JAXBContext cvJAXBContext
           
static java.lang.String PACKAGE_PATH
          package path for jaxb
 
Constructor Summary
JaxbHelper()
           
 
Method Summary
static java.lang.Object cloneObject(java.lang.Object obj)
          clones a given jaxb object by marshalling and unmarshalling
static java.util.List cloneObjectList(java.util.List objList)
          clones a given jaxb object list
static javax.xml.bind.JAXBContext getJAXBContext()
          To getJAXBContext, it will be initialized if it isnt already
static java.lang.String marshall(java.lang.Object obj)
          Converts obj to a string using JAXB.
static java.lang.Object unmarshallFromFile(java.lang.String fileName)
          calls unmarshallFromFile(String, boolean) with validate = false
static java.lang.Object unmarshallFromFile(java.lang.String fileName, boolean validate)
          Unmarshalls inputfilename to a jaxb object.
static java.lang.Object unmarshallFromInputSource(org.xml.sax.InputSource inputSource)
          calls unmarshallFromInputSource(InputSource, boolean) with validate = false
static java.lang.Object unmarshallFromInputSource(org.xml.sax.InputSource inputSource, boolean validate)
          Unmarshalls inputSource to a jaxb object.
static java.lang.Object unmarshallFromInputStream(java.io.InputStream inputStream)
          calls unmarshallFromInputStream(InputStream, boolean) with validate = false
static java.lang.Object unmarshallFromInputStream(java.io.InputStream inputStream, boolean validate)
          Unmarshalls inputStream to a jaxb object.
static java.lang.Object unmarshallFromSource(javax.xml.transform.Source source)
          calls unmarshallFromSource(Source, boolean) with validate = false
static java.lang.Object unmarshallFromSource(javax.xml.transform.Source source, boolean validate)
          Unmarshalls source to a jaxb object.
static java.lang.Object unmarshallFromString(java.lang.String xmlString)
          calls unmarshallFromString(String, boolean) with validate = false
static java.lang.Object unmarshallFromString(java.lang.String xmlString, boolean validate)
          Unmarshalls XML input to a jaxb object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cvJAXBContext

public static javax.xml.bind.JAXBContext cvJAXBContext

PACKAGE_PATH

public static java.lang.String PACKAGE_PATH
package path for jaxb

Constructor Detail

JaxbHelper

public JaxbHelper()
Method Detail

marshall

public static java.lang.String marshall(java.lang.Object obj)
                                 throws javax.xml.bind.JAXBException
Converts obj to a string using JAXB.

Parameters:
obj - the object to convert.
Returns:
the xml string representation of the object, or an empty string, if the conversion failed.
Throws:
javax.xml.bind.JAXBException

unmarshallFromString

public static java.lang.Object unmarshallFromString(java.lang.String xmlString)
                                             throws javax.xml.bind.JAXBException
calls unmarshallFromString(String, boolean) with validate = false

Throws:
javax.xml.bind.JAXBException

unmarshallFromString

public static java.lang.Object unmarshallFromString(java.lang.String xmlString,
                                                    boolean validate)
                                             throws javax.xml.bind.JAXBException
Unmarshalls XML input to a jaxb object.

Parameters:
xmlString - An XML input
Returns:
a jaxb object.
Throws:
javax.xml.bind.JAXBException

unmarshallFromFile

public static java.lang.Object unmarshallFromFile(java.lang.String fileName)
                                           throws javax.xml.bind.JAXBException,
                                                  java.io.FileNotFoundException
calls unmarshallFromFile(String, boolean) with validate = false

Throws:
javax.xml.bind.JAXBException
java.io.FileNotFoundException

unmarshallFromFile

public static java.lang.Object unmarshallFromFile(java.lang.String fileName,
                                                  boolean validate)
                                           throws javax.xml.bind.JAXBException,
                                                  java.io.FileNotFoundException
Unmarshalls inputfilename to a jaxb object.

Parameters:
fileName - for input XML
Returns:
a jaxb object.
Throws:
javax.xml.bind.JAXBException
java.io.FileNotFoundException

unmarshallFromSource

public static java.lang.Object unmarshallFromSource(javax.xml.transform.Source source)
                                             throws javax.xml.bind.JAXBException,
                                                    java.io.FileNotFoundException
calls unmarshallFromSource(Source, boolean) with validate = false

Throws:
javax.xml.bind.JAXBException
java.io.FileNotFoundException

unmarshallFromSource

public static java.lang.Object unmarshallFromSource(javax.xml.transform.Source source,
                                                    boolean validate)
                                             throws javax.xml.bind.JAXBException
Unmarshalls source to a jaxb object.

Parameters:
source - for input XML
Returns:
a jaxb object.
Throws:
javax.xml.bind.JAXBException

unmarshallFromInputStream

public static java.lang.Object unmarshallFromInputStream(java.io.InputStream inputStream)
                                                  throws javax.xml.bind.JAXBException,
                                                         java.io.FileNotFoundException
calls unmarshallFromInputStream(InputStream, boolean) with validate = false

Throws:
javax.xml.bind.JAXBException
java.io.FileNotFoundException

unmarshallFromInputStream

public static java.lang.Object unmarshallFromInputStream(java.io.InputStream inputStream,
                                                         boolean validate)
                                                  throws javax.xml.bind.JAXBException,
                                                         java.io.FileNotFoundException
Unmarshalls inputStream to a jaxb object.

Parameters:
inputStream - for input XML
Returns:
a jaxb object.
Throws:
javax.xml.bind.JAXBException
java.io.FileNotFoundException

unmarshallFromInputSource

public static java.lang.Object unmarshallFromInputSource(org.xml.sax.InputSource inputSource)
                                                  throws javax.xml.bind.JAXBException,
                                                         java.io.FileNotFoundException
calls unmarshallFromInputSource(InputSource, boolean) with validate = false

Throws:
javax.xml.bind.JAXBException
java.io.FileNotFoundException

unmarshallFromInputSource

public static java.lang.Object unmarshallFromInputSource(org.xml.sax.InputSource inputSource,
                                                         boolean validate)
                                                  throws javax.xml.bind.JAXBException,
                                                         java.io.FileNotFoundException
Unmarshalls inputSource to a jaxb object.

Parameters:
inputSource - for input XML
Returns:
a jaxb object.
Throws:
javax.xml.bind.JAXBException
java.io.FileNotFoundException

getJAXBContext

public static javax.xml.bind.JAXBContext getJAXBContext()
To getJAXBContext, it will be initialized if it isnt already

Returns:
JAXBContext

cloneObjectList

public static java.util.List cloneObjectList(java.util.List objList)
                                      throws javax.xml.bind.JAXBException
clones a given jaxb object list

Parameters:
objList - to clone
Returns:
new list with cloned objects
Throws:
javax.xml.bind.JAXBException - if marshall/unmarshall fails

cloneObject

public static java.lang.Object cloneObject(java.lang.Object obj)
                                    throws javax.xml.bind.JAXBException
clones a given jaxb object by marshalling and unmarshalling

Parameters:
obj - to clone
Returns:
cloned object
Throws:
javax.xml.bind.JAXBException - if marshall/unmarshall fails


Copyright © 2006 DS. All Rights Reserved.