raccoon.core.badhnati.xml
Class XmlParser

java.lang.Object
  extended by raccoon.core.types.AbsComponent
      extended by raccoon.core.types.AbsLoadable
          extended by raccoon.core.types.AbsConfigurableLoadable
              extended by raccoon.core.badhnati.xml.XmlParser
All Implemented Interfaces:
IBadhnAti, IXmlToMessage, IBaseComponent, IConfigurable, ILoadable, ILogable

public class XmlParser
extends AbsConfigurableLoadable
implements IXmlToMessage

The parser that converts IMessage instances into an XML String or vice-versa.

Since:
Raccoon v1.0
Version:
$Id: XmlParser.java,v 1.2 2004/08/11 21:15:42 crouvrais Exp $
Author:
Cedric ROUVRAIS

Field Summary
static java.lang.String PTY_FAST_MODE
          The fast XML Rendering mode property.
static java.lang.String PTY_XML_INDENTATION
          The indentation
 
Fields inherited from class raccoon.core.types.AbsConfigurableLoadable
mConfigurableManager
 
Fields inherited from class raccoon.core.types.AbsLoadable
mIsLoaded
 
Fields inherited from class raccoon.core.types.AbsComponent
mIsInError
 
Constructor Summary
XmlParser()
          Default constructor.
 
Method Summary
 void configureParameters()
          Configures the various parameters for this component.
 IFactory getFactory()
          Retrieves the factory to create new message instances used.
 int getXmlIndentation()
          Retrieves the number of spaces used for the XML indentation.
 boolean isFastMode()
          Indicates whether the Renderer is in fast mode.
 void load()
          Invoked by the service manager to start this component once it has been configured.
 IMessage marshal(org.xml.sax.InputSource pXmlSource)
          Converts a given XML compliant string into a IMessage instance.
 IMessage marshal(java.io.Reader pXmlReader)
          Converts a given XML compliant string into a RvMsgBase instance.
 IMessage marshal(java.lang.String pXmlMsg)
          Converts a given XML compliant string into a IMessage instance.
 void setFactory(IFactory pFactory)
          Defines the factory instance to use.
 void setFastMode(boolean pFastMode)
          Defines the rendering mode.
 void setXmlIndentation(int pXmlIndentation)
          Defines the number of spaces to use for the XML indentation.
 void unload()
          Invoked by the service manager to stop this component.
 java.lang.String unmarshal(IMessage pMessage)
          Converts the provided IMessage instance into an XML String representation.
 
Methods inherited from class raccoon.core.types.AbsConfigurableLoadable
isStable, setConfigurableManager, setLogger
 
Methods inherited from class raccoon.core.types.AbsLoadable
getLog, isInError, isInitialised, isRunning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PTY_FAST_MODE

public static final java.lang.String PTY_FAST_MODE
The fast XML Rendering mode property.

See Also:
Constant Field Values

PTY_XML_INDENTATION

public static final java.lang.String PTY_XML_INDENTATION
The indentation

See Also:
Constant Field Values
Constructor Detail

XmlParser

public XmlParser()
Default constructor.

Method Detail

isFastMode

public boolean isFastMode()
Indicates whether the Renderer is in fast mode.

Returns:
true if in fast mode.

setFastMode

public void setFastMode(boolean pFastMode)
                 throws ResourceNotFoundException
Defines the rendering mode.

Parameters:
pFastMode - true if fast XML generation is required (not beautiful)
Throws:
ResourceNotFoundException - if there is an internal error.

configureParameters

public void configureParameters()
Configures the various parameters for this component. This method should configure the instance of IConfigurableManager provided during the invocation of AbsConfigurableLoadable.setConfigurableManager(IConfigurableManager).

Specified by:
configureParameters in interface IConfigurable
Overrides:
configureParameters in class AbsConfigurableLoadable

getXmlIndentation

public int getXmlIndentation()
Retrieves the number of spaces used for the XML indentation.

Returns:
the number of spaces, -1 if using default.

setXmlIndentation

public void setXmlIndentation(int pXmlIndentation)
                       throws java.lang.IllegalArgumentException,
                              RaccoonException
Defines the number of spaces to use for the XML indentation.

Parameters:
pXmlIndentation - the number of spaces when indenting the XML string.
Throws:
java.lang.IllegalArgumentException - if the indentation isn't greater than 0
RaccoonException - if this component is already running: the component can't be changed. Error code is ErrorCodes.COMPONENT_INITIALISED

getFactory

public IFactory getFactory()
Retrieves the factory to create new message instances used.

Returns:
the factory implementation used by this parser.

setFactory

public void setFactory(IFactory pFactory)
                throws RaccoonException
Defines the factory instance to use.

Parameters:
pFactory - the factory implementation to create new message instances.
Throws:
RaccoonException - if this service is already running.

marshal

public IMessage marshal(java.lang.String pXmlMsg)
                 throws RaccoonException
Converts a given XML compliant string into a IMessage instance.

Specified by:
marshal in interface IXmlToMessage
Parameters:
pXmlMsg - the XML string
Returns:
the IMessage instance.
Throws:
RaccoonException - if the XML string is invalid.

marshal

public IMessage marshal(java.io.Reader pXmlReader)
                 throws RaccoonException
Converts a given XML compliant string into a RvMsgBase instance.

Specified by:
marshal in interface IXmlToMessage
Parameters:
pXmlReader - the XML reader
Returns:
the IMessage instance.
Throws:
RaccoonException - if the XML string is invalid.

marshal

public IMessage marshal(org.xml.sax.InputSource pXmlSource)
                 throws RaccoonException
Converts a given XML compliant string into a IMessage instance.

Specified by:
marshal in interface IXmlToMessage
Parameters:
pXmlSource - the XML input source to use.
Returns:
the IMessage instance.
Throws:
RaccoonException - if the XML string is invalid.

unmarshal

public java.lang.String unmarshal(IMessage pMessage)
Converts the provided IMessage instance into an XML String representation.

Specified by:
unmarshal in interface IXmlToMessage
Parameters:
pMessage - the message to be converted
Returns:
the result of the conversion

load

public void load()
          throws LoadableException
Invoked by the service manager to start this component once it has been configured. When extended bare in mind that the member variable mIsInitialised should be set to false and then set to true once all the init code has been performed.

Specified by:
load in interface ILoadable
Overrides:
load in class AbsConfigurableLoadable
Throws:
LoadableException - if this component isn't initialisable or is already running.

unload

public void unload()
            throws LoadableException
Invoked by the service manager to stop this component. When extended bare in mind that the member variable mIsInitialised should be set to true and then set to false once all the init code has been performed.

Specified by:
unload in interface ILoadable
Overrides:
unload in class AbsLoadable
Throws:
LoadableException - if the composant isn't running or if it isn't an initialisable component.


Copyright null null. All Rights Reserved.