com.cedarsoft.utils.serialization
Class AbstractSerializer<T>

java.lang.Object
  extended by com.cedarsoft.utils.serialization.AbstractSerializer<T>
Type Parameters:
T - the type
All Implemented Interfaces:
ExtendedSerializer<T>, Serializer<T,Lookup>

public abstract class AbstractSerializer<T>
extends java.lang.Object
implements ExtendedSerializer<T>


Field Summary
protected static java.lang.String LINE_SEPARATOR
           
 
Constructor Summary
protected AbstractSerializer(java.lang.String defaultElementName)
           
 
Method Summary
abstract  T deserialize(org.jdom.Element element, Lookup context)
          Deserializes the object from the diven document
 T deserialize(java.io.InputStream in)
          Deserializes the object
 T deserialize(java.io.InputStream in, Lookup context)
          Deserializes the object from the input stream
protected  java.lang.String getDefaultElementName()
           
abstract  void serialize(org.jdom.Element element, T object, Lookup context)
          Serializes the object to the given element
 byte[] serialize(T object)
          Serializes the given object
 void serialize(T object, java.io.OutputStream out)
          Serializes the object to the output stream
 void serialize(T object, java.io.OutputStream out, Lookup context)
          Serializes the object to the given output stream
 org.jdom.Element serializeToElement(T object, Lookup context)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LINE_SEPARATOR

@NotNull
@NonNls
protected static final java.lang.String LINE_SEPARATOR
See Also:
Constant Field Values
Constructor Detail

AbstractSerializer

protected AbstractSerializer(@NotNull@NonNls
                             java.lang.String defaultElementName)
Method Detail

serializeToElement

@NotNull
public org.jdom.Element serializeToElement(@NotNull
                                                   T object,
                                                   @Nullable
                                                   Lookup context)
                                    throws java.io.IOException
Throws:
java.io.IOException

serialize

public void serialize(@NotNull
                      T object,
                      @NotNull
                      java.io.OutputStream out,
                      @Nullable
                      Lookup context)
               throws java.io.IOException
Description copied from interface: Serializer
Serializes the object to the given output stream

Specified by:
serialize in interface Serializer<T,Lookup>
Parameters:
object - the object
out - the out stream
context - the context (optional)
Throws:
java.io.IOException

getDefaultElementName

@NotNull
@NonNls
protected java.lang.String getDefaultElementName()

deserialize

@NotNull
public T deserialize(@NotNull
                             java.io.InputStream in,
                             @Nullable
                             Lookup context)
              throws java.io.IOException
Description copied from interface: Serializer
Deserializes the object from the input stream

Specified by:
deserialize in interface Serializer<T,Lookup>
Parameters:
in - the input stream
context - the context (optional)
Returns:
the deserialized object
Throws:
java.io.IOException

serialize

@NotNull
public byte[] serialize(@NotNull
                                T object)
                 throws java.io.IOException
Description copied from interface: ExtendedSerializer
Serializes the given object

Specified by:
serialize in interface ExtendedSerializer<T>
Parameters:
object - the object
Returns:
the serialized object
Throws:
java.io.IOException

serialize

public void serialize(@NotNull
                      T object,
                      @NotNull
                      java.io.OutputStream out)
               throws java.io.IOException
Description copied from interface: ExtendedSerializer
Serializes the object to the output stream

Specified by:
serialize in interface ExtendedSerializer<T>
Parameters:
object - the object
out - the out stream
Throws:
java.io.IOException

deserialize

@NotNull
public T deserialize(@NotNull
                             java.io.InputStream in)
              throws java.io.IOException
Description copied from interface: ExtendedSerializer
Deserializes the object

Specified by:
deserialize in interface ExtendedSerializer<T>
Parameters:
in - the input stream
Returns:
the deserialized object
Throws:
java.io.IOException

serialize

public abstract void serialize(@NotNull
                               org.jdom.Element element,
                               @NotNull
                               T object,
                               @NotNull
                               Lookup context)
                        throws java.io.IOException
Serializes the object to the given element

Parameters:
element - the element
object - the object
context - the context
Throws:
java.io.IOException

deserialize

@NotNull
public abstract T deserialize(@NotNull
                                      org.jdom.Element element,
                                      @NotNull
                                      Lookup context)
                       throws java.io.IOException
Deserializes the object from the diven document

Parameters:
element - the element
context - the context
Returns:
the deserialized object
Throws:
java.io.IOException


Copyright © 2009 cedarsoft GmbH. All Rights Reserved.