com.dyuproject.protostuff
Class CollectionSchema<V>

java.lang.Object
  extended by com.dyuproject.protostuff.CollectionSchema<V>
All Implemented Interfaces:
Schema<java.util.Collection<V>>
Direct Known Subclasses:
MessageCollectionSchema

public abstract class CollectionSchema<V>
extends java.lang.Object
implements Schema<java.util.Collection<V>>

A schema for standard jdk collections. Null values are not serialized/written. If your application relies on Object.equals(Object), it will fail when a serialized collection contains null values (The deserialized collection will not contained the null value). MapSchema on the otherhand can contain both null keys and null values and still succeeding on Object.equals(Object).

Author:
David Yu
Date created:
Jan 26, 2011

Nested Class Summary
static class CollectionSchema.MessageFactories
           
static interface CollectionSchema.MessageFactory
          Creates new Collection messages.
 
Field Summary
static java.lang.String FIELD_NAME_VALUE
           
 CollectionSchema.MessageFactory messageFactory
          Factory for creating Collection messages.
 Pipe.Schema<java.util.Collection<V>> pipeSchema
           
 
Constructor Summary
CollectionSchema()
           
CollectionSchema(CollectionSchema.MessageFactory messageFactory)
           
 
Method Summary
protected abstract  void addValueFrom(Input input, java.util.Collection<V> collection)
          Adds the value from the input into the Collection.
 java.lang.String getFieldName(int number)
           
 int getFieldNumber(java.lang.String name)
           
 boolean isInitialized(java.util.Collection<V> map)
           
 void mergeFrom(Input input, java.util.Collection<V> message)
           
 java.lang.String messageFullName()
           
 java.lang.String messageName()
           
 java.util.Collection<V> newMessage()
           
protected abstract  void transferValue(Pipe pipe, Input input, Output output, int number, boolean repeated)
          Transfers the value from the input to the output.
 java.lang.Class<? super java.util.Collection<V>> typeClass()
           
 void writeTo(Output output, java.util.Collection<V> message)
           
protected abstract  void writeValueTo(Output output, int fieldNumber, V value, boolean repeated)
          Writes the value to the output.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FIELD_NAME_VALUE

public static final java.lang.String FIELD_NAME_VALUE
See Also:
Constant Field Values

messageFactory

public final CollectionSchema.MessageFactory messageFactory
Factory for creating Collection messages.


pipeSchema

public final Pipe.Schema<java.util.Collection<V>> pipeSchema
Constructor Detail

CollectionSchema

public CollectionSchema()

CollectionSchema

public CollectionSchema(CollectionSchema.MessageFactory messageFactory)
Method Detail

addValueFrom

protected abstract void addValueFrom(Input input,
                                     java.util.Collection<V> collection)
                              throws java.io.IOException
Adds the value from the input into the Collection.

Throws:
java.io.IOException

writeValueTo

protected abstract void writeValueTo(Output output,
                                     int fieldNumber,
                                     V value,
                                     boolean repeated)
                              throws java.io.IOException
Writes the value to the output.

Throws:
java.io.IOException

transferValue

protected abstract void transferValue(Pipe pipe,
                                      Input input,
                                      Output output,
                                      int number,
                                      boolean repeated)
                               throws java.io.IOException
Transfers the value from the input to the output.

Throws:
java.io.IOException

getFieldName

public final java.lang.String getFieldName(int number)
Specified by:
getFieldName in interface Schema<java.util.Collection<V>>

getFieldNumber

public final int getFieldNumber(java.lang.String name)
Specified by:
getFieldNumber in interface Schema<java.util.Collection<V>>

isInitialized

public final boolean isInitialized(java.util.Collection<V> map)
Specified by:
isInitialized in interface Schema<java.util.Collection<V>>

messageFullName

public final java.lang.String messageFullName()
Specified by:
messageFullName in interface Schema<java.util.Collection<V>>

messageName

public final java.lang.String messageName()
Specified by:
messageName in interface Schema<java.util.Collection<V>>

typeClass

public final java.lang.Class<? super java.util.Collection<V>> typeClass()
Specified by:
typeClass in interface Schema<java.util.Collection<V>>

newMessage

public final java.util.Collection<V> newMessage()
Specified by:
newMessage in interface Schema<java.util.Collection<V>>

mergeFrom

public void mergeFrom(Input input,
                      java.util.Collection<V> message)
               throws java.io.IOException
Specified by:
mergeFrom in interface Schema<java.util.Collection<V>>
Throws:
java.io.IOException

writeTo

public void writeTo(Output output,
                    java.util.Collection<V> message)
             throws java.io.IOException
Specified by:
writeTo in interface Schema<java.util.Collection<V>>
Throws:
java.io.IOException


Copyright © 2009-2012. All Rights Reserved.