com.cedarsoft.serialization.stax
Class AbstractStaxBasedSerializer<T,C,S>

java.lang.Object
  extended by com.cedarsoft.serialization.AbstractSerializer<T,C,S,javax.xml.stream.XMLStreamReader,javax.xml.stream.XMLStreamException>
      extended by com.cedarsoft.serialization.stax.AbstractStaxBasedSerializer<T,C,S>
Type Parameters:
T - the type
C - the type of the context
S - the object to serialize to
All Implemented Interfaces:
PluggableSerializer<T,C,S,javax.xml.stream.XMLStreamReader,javax.xml.stream.XMLStreamException>, Serializer<T,C>
Direct Known Subclasses:
AbstractStaxMateSerializer, AbstractStaxSerializer

public abstract class AbstractStaxBasedSerializer<T,C,S>
extends AbstractSerializer<T,C,S,javax.xml.stream.XMLStreamReader,javax.xml.stream.XMLStreamException>


Nested Class Summary
static interface AbstractStaxBasedSerializer.CB
           
 
Field Summary
 
Fields inherited from interface com.cedarsoft.serialization.Serializer
PI_TARGET_FORMAT
 
Constructor Summary
protected AbstractStaxBasedSerializer(java.lang.String defaultElementName, VersionRange formatVersionRange)
           
 
Method Summary
protected  void closeTag(javax.xml.stream.XMLStreamReader reader)
           
 T deserialize(java.io.InputStream in, C context)
          Deserializes the object from the input stream
protected  void ensureTag(javax.xml.stream.XMLStreamReader deserializeFrom, java.lang.String tagName)
           
protected  java.lang.String getChildText(javax.xml.stream.XMLStreamReader reader, java.lang.String tagName)
           
protected  java.lang.String getProcessingInstructionData(javax.xml.stream.XMLStreamReader reader, java.lang.String piTarget)
           
protected  java.lang.String getText(javax.xml.stream.XMLStreamReader reader)
          Returns the text and closes the tag
protected  void nextTag(javax.xml.stream.XMLStreamReader reader, java.lang.String tagName)
           
protected  void visitChildren(javax.xml.stream.XMLStreamReader streamReader, AbstractStaxBasedSerializer.CB callback)
          Attention! The current element will be closed!
 
Methods inherited from class com.cedarsoft.serialization.AbstractSerializer
deserialize, getDefaultElementName, getFormatVersion, getFormatVersionRange, serialize, serializeToByteArray, verifyDelegatingSerializerVersion
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.cedarsoft.serialization.PluggableSerializer
deserialize, serialize
 
Methods inherited from interface com.cedarsoft.serialization.Serializer
serialize
 

Constructor Detail

AbstractStaxBasedSerializer

protected AbstractStaxBasedSerializer(@NotNull@NonNls
                                      java.lang.String defaultElementName,
                                      @NotNull
                                      VersionRange formatVersionRange)
Method Detail

deserialize

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

Parameters:
in - the input stream
context - the context (optional)
Returns:
the deserialized object
Throws:
java.io.IOException

getProcessingInstructionData

@NotNull
@NonNls
protected java.lang.String getProcessingInstructionData(@NotNull
                                                                       javax.xml.stream.XMLStreamReader reader,
                                                                       @NotNull@NonNls
                                                                       java.lang.String piTarget)
                                                 throws javax.xml.stream.XMLStreamException
Throws:
javax.xml.stream.XMLStreamException

ensureTag

protected void ensureTag(@NotNull
                         javax.xml.stream.XMLStreamReader deserializeFrom,
                         @NotNull@NonNls
                         java.lang.String tagName)

getText

@NotNull
protected java.lang.String getText(@NotNull
                                           javax.xml.stream.XMLStreamReader reader)
                            throws javax.xml.stream.XMLStreamException
Returns the text and closes the tag

Parameters:
reader - the reader
Returns:
the text
Throws:
javax.xml.stream.XMLStreamException

getChildText

@NotNull
protected java.lang.String getChildText(@NotNull
                                                javax.xml.stream.XMLStreamReader reader,
                                                @NotNull@NonNls
                                                java.lang.String tagName)
                                 throws javax.xml.stream.XMLStreamException
Throws:
javax.xml.stream.XMLStreamException

closeTag

protected void closeTag(@NotNull
                        javax.xml.stream.XMLStreamReader reader)
                 throws javax.xml.stream.XMLStreamException
Throws:
javax.xml.stream.XMLStreamException

nextTag

protected void nextTag(@NotNull
                       javax.xml.stream.XMLStreamReader reader,
                       @NotNull@NonNls
                       java.lang.String tagName)
                throws javax.xml.stream.XMLStreamException
Throws:
javax.xml.stream.XMLStreamException

visitChildren

protected void visitChildren(@NotNull
                             javax.xml.stream.XMLStreamReader streamReader,
                             @NotNull
                             AbstractStaxBasedSerializer.CB callback)
                      throws javax.xml.stream.XMLStreamException,
                             java.io.IOException
Attention! The current element will be closed!

Parameters:
streamReader - the stream reader
callback - the callback
Throws:
javax.xml.stream.XMLStreamException
java.io.IOException


Copyright © 2009 cedarsoft GmbH. All Rights Reserved.