org.opennms.netmgt.dao.castor
Class CastorUtils

java.lang.Object
  extended by org.opennms.netmgt.dao.castor.CastorUtils

public class CastorUtils
extends java.lang.Object

Utility class for Castor configuration files.

Author:
DJ Gregor

Method Summary
static
<T> T
unmarshal(java.lang.Class<T> clazz, java.io.Reader reader)
          Unmarshal a Castor XML configuration file.
static
<T> T
unmarshalWithTranslatedExceptions(java.lang.Class<T> clazz, java.io.Reader reader)
          Unmarshal a Castor XML configuration file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

unmarshal

public static <T> T unmarshal(java.lang.Class<T> clazz,
                              java.io.Reader reader)
                   throws org.exolab.castor.xml.MarshalException,
                          org.exolab.castor.xml.ValidationException
Unmarshal a Castor XML configuration file. Uses Java 5 generics for return type.

Type Parameters:
T - the class representing the marshalled XML configuration file. This will be the return time form the method.
Parameters:
clazz - the class representing the marshalled XML configuration file
reader - the marshalled XML configuration file to unmarshal
Returns:
Unmarshalled object representing XML file
Throws:
org.exolab.castor.xml.MarshalException - if the underlying Castor Unmarshaller.unmarshal() call throws a MarshalException
org.exolab.castor.xml.ValidationException - if the underlying Castor Unmarshaller.unmarshal() call throws a ValidationException

unmarshalWithTranslatedExceptions

public static <T> T unmarshalWithTranslatedExceptions(java.lang.Class<T> clazz,
                                                      java.io.Reader reader)
                                           throws org.springframework.dao.DataAccessException
Unmarshal a Castor XML configuration file. Uses Java 5 generics for return type and throws DataAccessExceptions.

Type Parameters:
T - the class representing the marshalled XML configuration file. This will be the return time form the method.
Parameters:
clazz - the class representing the marshalled XML configuration file
reader - the marshalled XML configuration file to unmarshal
Returns:
Unmarshalled object representing XML file
Throws:
org.springframework.dao.DataAccessException - if the underlying Castor Unmarshaller.unmarshal() call throws a MarshalException or ValidationException. The underlying exception will be translated using CastorExceptionTranslator.


Copyright © 2007. All Rights Reserved.