net.sourceforge.xmote.encoding
Class EncodingFactory

java.lang.Object
  extended by net.sourceforge.xmote.encoding.EncodingFactory

public class EncodingFactory
extends java.lang.Object

Singleton factory that stores all IEncoding implementations and is the entry point for encoding/decoding.

Author:
Jason Rush

Method Summary
 void addEncoding(IEncoding encoding)
          Adds an IEncoding implementation.
 java.lang.Object decode(org.jdom.Element root)
          Find the decoding implementation and decode the supplied Element.
 org.jdom.Element encode(java.lang.Object object)
          Find the encoding implementation and encode the supplied object.
static EncodingFactory getInstance()
           
protected  void initialize()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

initialize

protected void initialize()

getInstance

public static EncodingFactory getInstance()
Returns:
the instance

addEncoding

public void addEncoding(IEncoding encoding)
Adds an IEncoding implementation. The encoding is prepended to the list of encodings to ensure the ObjectEncoding is always the last encoding checked.

Parameters:
encoding -

encode

public org.jdom.Element encode(java.lang.Object object)
                        throws EncodingException
Find the encoding implementation and encode the supplied object.

Parameters:
object - The Object to encode.
Returns:
The encoded value as an Element.
Throws:
EncodingException - if a problem is encountered during encoding or if no matching encoding was found.

decode

public java.lang.Object decode(org.jdom.Element root)
                        throws EncodingException
Find the decoding implementation and decode the supplied Element.

Parameters:
root - The Element to decode.
Returns:
The decoded Object.
Throws:
EncodingException - if a problem is encountered during decodinhg or if no matching decoding was found.


Copyright (C) 2007 Jason Rush. All Rights Reserved.