net.sf.jsefa.rbf
Class RbfSerializerImpl<L extends RbfLowLevelSerializer>

java.lang.Object
  extended by net.sf.jsefa.rbf.RbfSerializerImpl<L>
Type Parameters:
L - the type of the RbfLowLevelSerializer
All Implemented Interfaces:
RbfSerializer, Serializer
Direct Known Subclasses:
CsvSerializerImpl, FlrSerializerImpl

public abstract class RbfSerializerImpl<L extends RbfLowLevelSerializer>
extends Object
implements RbfSerializer

Abstract implementation of Serializer for RBF formats.

Author:
Norman Lahme-Huetig

Constructor Summary
protected RbfSerializerImpl(RbfConfiguration<?> config, Map<Class<?>,RbfEntryPoint> entryPoints, L lowLevelSerializer)
          Constructs a new RbfSerializerImpl.
 
Method Summary
 void close(boolean closeWriter)
          Closes the serialization stream.
 void flush()
          Flushes the stream.
 L getLowLevelSerializer()
          Returns a low level serializer.
 void open(Writer writer)
          Opens a new serialization stream based on the given writer.
 void write(Object object)
          Writes the given object.
protected abstract  void writePrefix(String prefix)
          Writes the prefix.
protected abstract  void writeSimpleValue(Object value, SimpleTypeMapping<?> mapping)
          Writes the given value as a simple value using the simple type mapping.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RbfSerializerImpl

protected RbfSerializerImpl(RbfConfiguration<?> config,
                            Map<Class<?>,RbfEntryPoint> entryPoints,
                            L lowLevelSerializer)
Constructs a new RbfSerializerImpl.

Parameters:
config - the configuration
entryPoints - a map which maps object types to entry points.
lowLevelSerializer - the low level serializer
Method Detail

open

public final void open(Writer writer)
Opens a new serialization stream based on the given writer.

Specified by:
open in interface Serializer
Parameters:
writer - the writer to base the stream on

write

public final void write(Object object)
Writes the given object.

Specified by:
write in interface Serializer
Parameters:
object - the object to write

flush

public void flush()
Flushes the stream.

Specified by:
flush in interface Serializer

close

public final void close(boolean closeWriter)
Closes the serialization stream. The underlying writer will be closed only if closeWriter is true, too.

Specified by:
close in interface Serializer
Parameters:
closeWriter - if true, the underlying writer will be closed, too.

getLowLevelSerializer

public L getLowLevelSerializer()
Returns a low level serializer.

Specified by:
getLowLevelSerializer in interface RbfSerializer
Specified by:
getLowLevelSerializer in interface Serializer
Returns:
a low level serializer.

writeSimpleValue

protected abstract void writeSimpleValue(Object value,
                                         SimpleTypeMapping<?> mapping)
Writes the given value as a simple value using the simple type mapping.

Parameters:
value - the value to write
mapping - the simple type mapping

writePrefix

protected abstract void writePrefix(String prefix)
Writes the prefix.

Parameters:
prefix - the prefix


Copyright © 2014. All rights reserved.