raccoon.core.badhnati.castor
Class CastorParser

java.lang.Object
  extended by raccoon.core.badhnati.castor.CastorParser
Direct Known Subclasses:
ComponentLoader, SuiteLoader

public class CastorParser
extends java.lang.Object

Reads the contents of a given XML file using Castor XML. TODO Refactor and write test cases.

Since:
Raccoon v1.0
Version:
$Id: CastorParser.java,v 1.1 2004/08/08 20:19:15 crouvrais Exp $
Author:
Cedric ROUVRAIS

Field Summary
static java.lang.String DEFAULT_MAPPING_FILE_NAME
          The Castor XML mapping file used by this component.
protected  StdResolver mStdResolver
          The URI Resolver used to locate the XML file that has to be loaded.
 
Constructor Summary
CastorParser()
           
 
Method Summary
 java.lang.Object marshal(java.io.InputStream pResourceAsStream, java.net.URL pMappingFileURL, java.lang.Class pXmlClass)
          Reads the given input stream and instanciates a java bean using Castor XML.
 java.lang.Object marshal(java.lang.Object pSource, java.lang.Object pSourceType, java.lang.Class pOutputFormat)
          Converts a given object to the specified output instance.
 java.lang.Object marshal(java.io.Reader pXmlReader, java.net.URL pMappingFileURL, java.lang.Class pXmlClass)
          Reads the given input stream and instanciates a java bean using Castor XML.
 void unmarshal(java.lang.Object pSource, java.net.URL pMappingFileURL, java.io.OutputStream pOutputStream)
          Converts the given java bean into an XML Stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_MAPPING_FILE_NAME

public static final java.lang.String DEFAULT_MAPPING_FILE_NAME
The Castor XML mapping file used by this component.

See Also:
Constant Field Values

mStdResolver

protected StdResolver mStdResolver
The URI Resolver used to locate the XML file that has to be loaded.

See Also:
marshal(java.lang.Object, java.lang.Object, java.lang.Class)
Constructor Detail

CastorParser

public CastorParser()
Method Detail

marshal

public java.lang.Object marshal(java.lang.Object pSource,
                                java.lang.Object pSourceType,
                                java.lang.Class pOutputFormat)
                         throws RaccoonException,
                                java.lang.UnsupportedOperationException
Converts a given object to the specified output instance.

Parameters:
pSource - the input object that is the source for the conversion process.
pSourceType - the type of the object, can be a class instance, a Castor XML Mapping file (URL to the file), ...
pOutputFormat - the output class desired
Returns:
the instanciated object that is an instance of pOutputFormat
Throws:
RaccoonException - the source couldn't be converted to the output format.
java.lang.UnsupportedOperationException - if the pOutputFormat isn't supported.

marshal

public java.lang.Object marshal(java.io.InputStream pResourceAsStream,
                                java.net.URL pMappingFileURL,
                                java.lang.Class pXmlClass)
                         throws RaccoonException
Reads the given input stream and instanciates a java bean using Castor XML.

Parameters:
pResourceAsStream - the XML input stream.
pMappingFileURL - the URL of the mapping file that Castor XML should use.
pXmlClass - the class of that is desired from the parsing of the XML File.
Returns:
the instanciated object that should be an instance of pXmlClass
Throws:
RaccoonException - if the parameters are inconsistent or if the XML file is invalid.

marshal

public java.lang.Object marshal(java.io.Reader pXmlReader,
                                java.net.URL pMappingFileURL,
                                java.lang.Class pXmlClass)
                         throws RaccoonException
Reads the given input stream and instanciates a java bean using Castor XML.

Parameters:
pXmlReader - the XML input stream.
pMappingFileURL - the URL of the mapping file that Castor XML should use.
pXmlClass - the class of that is desired from the parsing of the XML File.
Returns:
the instanciated object that should be an instance of pXmlClass
Throws:
RaccoonException - if the parameters are inconsistent or if the XML file is invalid.

unmarshal

public void unmarshal(java.lang.Object pSource,
                      java.net.URL pMappingFileURL,
                      java.io.OutputStream pOutputStream)
               throws RaccoonException
Converts the given java bean into an XML Stream.

Parameters:
pSource - the java bean input source
pMappingFileURL - the XML Mapping file for Castor XML
pOutputStream - the output stream that is to receive the XML string.
Throws:
RaccoonException - if the conversion operation fails.


Copyright null null. All Rights Reserved.