Constructor and Description |
---|
CastorUtils() |
Modifier and Type | Method and Description |
---|---|
static <T> T |
duplicateObject(T object,
Class<T> clazz) |
static <T> org.exolab.castor.xml.Unmarshaller |
getUnmarshaller(Class<T> clazz) |
static String |
marshal(Object obj) |
static void |
marshalViaString(Object config,
File cfgFile)
Marshall to a string first, then write the string to the file.
|
static void |
marshalWithTranslatedExceptions(Object obj,
Writer writer)
Marshal a Castor XML configuration file.
|
static void |
marshalWithTranslatedExceptionsViaString(Object obj,
org.springframework.core.io.Resource resource)
Marshal a Castor XML configuration file.
|
static <T> T |
unmarshal(Class<T> clazz,
InputStream in)
Unmarshal a Castor XML configuration file.
|
static <T> T |
unmarshal(Class<T> clazz,
InputStream in,
boolean preserveWhitespace)
Unmarshal a Castor XML configuration file.
|
static <T> T |
unmarshal(Class<T> clazz,
Reader reader)
Deprecated.
Use a Resource or InputStream-based method instead to avoid character set issues.
|
static <T> T |
unmarshal(Class<T> clazz,
Reader reader,
boolean preserveWhitespace)
Deprecated.
Use a Resource or InputStream-based method instead to avoid character set issues.
|
static <T> T |
unmarshal(Class<T> clazz,
org.springframework.core.io.Resource resource)
Unmarshal a Castor XML configuration file.
|
static <T> T |
unmarshal(Class<T> clazz,
org.springframework.core.io.Resource resource,
boolean preserveWhitespace)
Unmarshal a Castor XML configuration file.
|
static <T> T |
unmarshalWithTranslatedExceptions(Class<T> clazz,
InputStream in)
Unmarshal a Castor XML configuration file.
|
static <T> T |
unmarshalWithTranslatedExceptions(Class<T> clazz,
InputStream in,
boolean preserveWhitespace)
Unmarshal a Castor XML configuration file.
|
static <T> T |
unmarshalWithTranslatedExceptions(Class<T> clazz,
Reader reader)
Deprecated.
Use a Resource or InputStream-based method instead to avoid character set issues.
|
static <T> T |
unmarshalWithTranslatedExceptions(Class<T> clazz,
Reader reader,
boolean preserveWhitespace)
Deprecated.
Use a Resource or InputStream-based method instead to avoid character set issues.
|
static <T> T |
unmarshalWithTranslatedExceptions(Class<T> clazz,
org.springframework.core.io.Resource resource)
Unmarshal a Castor XML configuration file.
|
static <T> T |
unmarshalWithTranslatedExceptions(Class<T> clazz,
org.springframework.core.io.Resource resource,
boolean preserveWhitespace)
Unmarshal a Castor XML configuration file.
|
public static void marshalWithTranslatedExceptions(Object obj, Writer writer) throws org.springframework.dao.DataAccessException
obj
- the object representing the objected to be marshalled to XMLwriter
- where the marshalled XML will be writtenorg.springframework.dao.DataAccessException
- if the underlying Castor
Marshaller.marshal() call throws a MarshalException or
ValidationException. The underlying exception will be translated
using MarshallingExceptionTranslator.public static String marshal(Object obj) throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException, IOException
org.exolab.castor.xml.MarshalException
org.exolab.castor.xml.ValidationException
IOException
public static void marshalWithTranslatedExceptionsViaString(Object obj, org.springframework.core.io.Resource resource) throws org.springframework.dao.DataAccessException
obj
- the object representing the objected to be marshalled to XMLresource
- a Resource
object.org.springframework.dao.DataAccessException
- if the underlying Castor
Marshaller.marshal() call throws a MarshalException or
ValidationException. The underlying exception will be translated
using MarshallingExceptionTranslator.public static <T> org.exolab.castor.xml.Unmarshaller getUnmarshaller(Class<T> clazz)
public static <T> T unmarshal(Class<T> clazz, Reader reader) throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
clazz
- the class representing the marshalled XML configuration
filereader
- the marshalled XML configuration file to unmarshalorg.exolab.castor.xml.MarshalException
- if the underlying Castor
Unmarshaller.unmarshal() call throws a org.exolab.castor.xml.MarshalExceptionorg.exolab.castor.xml.ValidationException
- if the underlying Castor
Unmarshaller.unmarshal() call throws a org.exolab.castor.xml.ValidationExceptionpublic static <T> T unmarshal(Class<T> clazz, Reader reader, boolean preserveWhitespace) throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
clazz
- the class representing the marshalled XML configuration
filereader
- the marshalled XML configuration file to unmarshalpreserveWhitespace
- whether or not to preserve whitespaceorg.exolab.castor.xml.MarshalException
- if the underlying Castor
Unmarshaller.unmarshal() call throws a org.exolab.castor.xml.MarshalExceptionorg.exolab.castor.xml.ValidationException
- if the underlying Castor
Unmarshaller.unmarshal() call throws a org.exolab.castor.xml.ValidationExceptionpublic static <T> T unmarshal(Class<T> clazz, InputStream in) throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
clazz
- the class representing the marshalled XML configuration filein
- the marshalled XML configuration file to unmarshalorg.exolab.castor.xml.MarshalException
- if the underlying Castor
Unmarshaller.unmarshal() call throws a org.exolab.castor.xml.MarshalExceptionorg.exolab.castor.xml.ValidationException
- if the underlying Castor
Unmarshaller.unmarshal() call throws a org.exolab.castor.xml.ValidationExceptionpublic static <T> T unmarshal(Class<T> clazz, InputStream in, boolean preserveWhitespace) throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
clazz
- the class representing the marshalled XML configuration filein
- the marshalled XML configuration file to unmarshalpreserveWhitespace
- whether or not to preserve whitespaceorg.exolab.castor.xml.MarshalException
- if the underlying Castor
Unmarshaller.unmarshal() call throws a org.exolab.castor.xml.MarshalExceptionorg.exolab.castor.xml.ValidationException
- if the underlying Castor
Unmarshaller.unmarshal() call throws a org.exolab.castor.xml.ValidationExceptionpublic static <T> T unmarshal(Class<T> clazz, org.springframework.core.io.Resource resource) throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException, IOException
clazz
- the class representing the marshalled XML configuration fileresource
- the marshalled XML configuration file to unmarshalorg.exolab.castor.xml.MarshalException
- if the underlying Castor
Unmarshaller.unmarshal() call throws a org.exolab.castor.xml.MarshalExceptionorg.exolab.castor.xml.ValidationException
- if the underlying Castor
Unmarshaller.unmarshal() call throws a org.exolab.castor.xml.ValidationExceptionIOException
- if the resource could not be openedpublic static <T> T unmarshal(Class<T> clazz, org.springframework.core.io.Resource resource, boolean preserveWhitespace) throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException, IOException
clazz
- the class representing the marshalled XML configuration fileresource
- the marshalled XML configuration file to unmarshalpreserveWhitespace
- whether or not to preserve whitespaceorg.exolab.castor.xml.MarshalException
- if the underlying Castor
Unmarshaller.unmarshal() call throws a org.exolab.castor.xml.MarshalExceptionorg.exolab.castor.xml.ValidationException
- if the underlying Castor
Unmarshaller.unmarshal() call throws a org.exolab.castor.xml.ValidationExceptionIOException
- if the resource could not be openedpublic static <T> T unmarshalWithTranslatedExceptions(Class<T> clazz, Reader reader) throws org.springframework.dao.DataAccessException
clazz
- the class representing the marshalled XML configuration
filereader
- the marshalled XML configuration file to unmarshalorg.springframework.dao.DataAccessException
- if the underlying Castor
Unmarshaller.unmarshal() call throws a MarshalException or
ValidationException. The underlying exception will be translated
using MarshallingExceptionTranslator.public static <T> T unmarshalWithTranslatedExceptions(Class<T> clazz, Reader reader, boolean preserveWhitespace) throws org.springframework.dao.DataAccessException
clazz
- the class representing the marshalled XML configuration filereader
- the marshalled XML configuration file to unmarshalpreserveWhitespace
- Whether to preserve whitespace when unmarshalling.org.springframework.dao.DataAccessException
- if the underlying Castor
Unmarshaller.unmarshal() call throws a MarshalException or
ValidationException. The underlying exception will be translated
using MarshallingExceptionTranslator.public static <T> T unmarshalWithTranslatedExceptions(Class<T> clazz, InputStream in) throws org.springframework.dao.DataAccessException
clazz
- the class representing the marshalled XML configuration filein
- the marshalled XML configuration file to unmarshalorg.springframework.dao.DataAccessException
- if the underlying Castor
Unmarshaller.unmarshal() call throws a MarshalException or
ValidationException. The underlying exception will be translated
using MarshallingExceptionTranslator.public static <T> T unmarshalWithTranslatedExceptions(Class<T> clazz, InputStream in, boolean preserveWhitespace) throws org.springframework.dao.DataAccessException
clazz
- the class representing the marshalled XML configuration filein
- the marshalled XML configuration file to unmarshalpreserveWhitespace
- whether to preserve whitespace when unmarshalling.org.springframework.dao.DataAccessException
- if the underlying Castor
Unmarshaller.unmarshal() call throws a MarshalException or
ValidationException. The underlying exception will be translated
using MarshallingExceptionTranslator.public static <T> T unmarshalWithTranslatedExceptions(Class<T> clazz, org.springframework.core.io.Resource resource)
clazz
- the class representing the marshalled XML configuration fileresource
- the marshalled XML configuration file to unmarshalorg.springframework.dao.DataAccessException
- if the resource could not be opened or the
underlying Castor
Unmarshaller.unmarshal() call throws a MarshalException or
ValidationException. The underlying exception will be translated
using MarshallingExceptionTranslator and will include information about
the resource from its toString() method.public static <T> T unmarshalWithTranslatedExceptions(Class<T> clazz, org.springframework.core.io.Resource resource, boolean preserveWhitespace)
clazz
- the class representing the marshalled XML configuration fileresource
- the marshalled XML configuration file to unmarshalorg.springframework.dao.DataAccessException
- if the resource could not be opened or the
underlying Castor
Unmarshaller.unmarshal() call throws a MarshalException or
ValidationException. The underlying exception will be translated
using MarshallingExceptionTranslator and will include information about
the resource from its toString() method.public static void marshalViaString(Object config, File cfgFile) throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException, IOException
config
- a Object
object.cfgFile
- a File
object.org.exolab.castor.xml.MarshalException
- if any.org.exolab.castor.xml.ValidationException
- if any.IOException
- if any.public static <T> T duplicateObject(T object, Class<T> clazz) throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
org.exolab.castor.xml.MarshalException
org.exolab.castor.xml.ValidationException
Copyright © 2016. All rights reserved.