com.dyuproject.protostuff.runtime
Class DefaultIdStrategy

java.lang.Object
  extended by com.dyuproject.protostuff.runtime.IdStrategy
      extended by com.dyuproject.protostuff.runtime.DefaultIdStrategy

public final class DefaultIdStrategy
extends IdStrategy

The FQCN(fully qualified class name) will serve as the id (string). Does not need any registration in the user-code (works out-of-the-box). The size of serialized representation may be not very efficient.

Author:
Leo Romanoff, David Yu

Nested Class Summary
 
Nested classes/interfaces inherited from class com.dyuproject.protostuff.runtime.IdStrategy
IdStrategy.Factory, IdStrategy.UnknownTypeException
 
Constructor Summary
DefaultIdStrategy()
           
 
Method Summary
protected  CollectionSchema.MessageFactory getCollectionFactory(java.lang.Class<?> clazz)
          Returns the CollectionSchema.MessageFactory.
protected  EnumIO<? extends java.lang.Enum<?>> getEnumIO(java.lang.Class<?> enumClass)
          Returns the EnumIO.
protected  MapSchema.MessageFactory getMapFactory(java.lang.Class<?> clazz)
          Returns the MapSchema.MessageFactory.
<T> HasSchema<T>
getSchemaWrapper(java.lang.Class<T> typeClass, boolean create)
          Returns the schema wrapper.
 boolean isRegistered(java.lang.Class<?> typeClass)
          Returns true if the typeClass is explicitly registered.
<T> boolean
map(java.lang.Class<? super T> baseClass, java.lang.Class<T> typeClass)
          Used by RuntimeSchema.map(Class, Class).
<T> boolean
register(java.lang.Class<T> typeClass, Schema<T> schema)
          Used by RuntimeSchema.register(Class, Schema).
protected  java.lang.Class<?> resolveArrayComponentTypeFrom(Input input, boolean nonConcrete)
           
protected  CollectionSchema.MessageFactory resolveCollectionFrom(Input input)
           
protected  EnumIO<?> resolveEnumFrom(Input input)
           
protected  MapSchema.MessageFactory resolveMapFrom(Input input)
           
protected
<T> HasSchema<T>
resolvePojoFrom(Input input, int fieldNumber)
           
protected  void transferArrayId(Input input, Output output, int fieldNumber, boolean nonConcrete)
           
protected  void transferCollectionId(Input input, Output output, int fieldNumber)
           
protected  void transferEnumId(Input input, Output output, int fieldNumber)
           
protected  void transferMapId(Input input, Output output, int fieldNumber)
           
protected
<T> HasSchema<T>
transferPojoId(Input input, Output output, int fieldNumber)
           
protected  void writeArrayIdTo(Output output, java.lang.Class<?> componentType)
           
protected  void writeCollectionIdTo(Output output, int fieldNumber, java.lang.Class<?> clazz)
           
protected  void writeEnumIdTo(Output output, int fieldNumber, java.lang.Class<?> clazz)
           
protected  void writeMapIdTo(Output output, int fieldNumber, java.lang.Class<?> clazz)
           
protected
<T> Schema<T>
writeMessageIdTo(Output output, int fieldNumber, Message<T> message)
           
protected
<T> Schema<T>
writePojoIdTo(Output output, int fieldNumber, java.lang.Class<T> clazz)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultIdStrategy

public DefaultIdStrategy()
Method Detail

register

public <T> boolean register(java.lang.Class<T> typeClass,
                            Schema<T> schema)
Used by RuntimeSchema.register(Class, Schema).


map

public <T> boolean map(java.lang.Class<? super T> baseClass,
                       java.lang.Class<T> typeClass)
Used by RuntimeSchema.map(Class, Class).


isRegistered

public boolean isRegistered(java.lang.Class<?> typeClass)
Description copied from class: IdStrategy
Returns true if the typeClass is explicitly registered.

Specified by:
isRegistered in class IdStrategy

getSchemaWrapper

public <T> HasSchema<T> getSchemaWrapper(java.lang.Class<T> typeClass,
                                         boolean create)
Description copied from class: IdStrategy
Returns the schema wrapper. The caller is responsible that the typeClass is a pojo (e.g not an enum/array/etc).

Specified by:
getSchemaWrapper in class IdStrategy

getEnumIO

protected EnumIO<? extends java.lang.Enum<?>> getEnumIO(java.lang.Class<?> enumClass)
Description copied from class: IdStrategy
Returns the EnumIO. The callers (internal field factories) are responsible that the class provided is an enum class.

Specified by:
getEnumIO in class IdStrategy

getCollectionFactory

protected CollectionSchema.MessageFactory getCollectionFactory(java.lang.Class<?> clazz)
Description copied from class: IdStrategy
Returns the CollectionSchema.MessageFactory. The callers (internal field factories) are responsible that the class provided implements Collection.

Specified by:
getCollectionFactory in class IdStrategy

getMapFactory

protected MapSchema.MessageFactory getMapFactory(java.lang.Class<?> clazz)
Description copied from class: IdStrategy
Returns the MapSchema.MessageFactory. The callers (internal field factories}) are responsible that the class provided implements .

Specified by:
getMapFactory in class IdStrategy

writeCollectionIdTo

protected void writeCollectionIdTo(Output output,
                                   int fieldNumber,
                                   java.lang.Class<?> clazz)
                            throws java.io.IOException
Specified by:
writeCollectionIdTo in class IdStrategy
Throws:
java.io.IOException

transferCollectionId

protected void transferCollectionId(Input input,
                                    Output output,
                                    int fieldNumber)
                             throws java.io.IOException
Specified by:
transferCollectionId in class IdStrategy
Throws:
java.io.IOException

resolveCollectionFrom

protected CollectionSchema.MessageFactory resolveCollectionFrom(Input input)
                                                         throws java.io.IOException
Specified by:
resolveCollectionFrom in class IdStrategy
Throws:
java.io.IOException

writeMapIdTo

protected void writeMapIdTo(Output output,
                            int fieldNumber,
                            java.lang.Class<?> clazz)
                     throws java.io.IOException
Specified by:
writeMapIdTo in class IdStrategy
Throws:
java.io.IOException

transferMapId

protected void transferMapId(Input input,
                             Output output,
                             int fieldNumber)
                      throws java.io.IOException
Specified by:
transferMapId in class IdStrategy
Throws:
java.io.IOException

resolveMapFrom

protected MapSchema.MessageFactory resolveMapFrom(Input input)
                                           throws java.io.IOException
Specified by:
resolveMapFrom in class IdStrategy
Throws:
java.io.IOException

writeEnumIdTo

protected void writeEnumIdTo(Output output,
                             int fieldNumber,
                             java.lang.Class<?> clazz)
                      throws java.io.IOException
Specified by:
writeEnumIdTo in class IdStrategy
Throws:
java.io.IOException

transferEnumId

protected void transferEnumId(Input input,
                              Output output,
                              int fieldNumber)
                       throws java.io.IOException
Specified by:
transferEnumId in class IdStrategy
Throws:
java.io.IOException

resolveEnumFrom

protected EnumIO<?> resolveEnumFrom(Input input)
                             throws java.io.IOException
Specified by:
resolveEnumFrom in class IdStrategy
Throws:
java.io.IOException

writePojoIdTo

protected <T> Schema<T> writePojoIdTo(Output output,
                                      int fieldNumber,
                                      java.lang.Class<T> clazz)
                           throws java.io.IOException
Specified by:
writePojoIdTo in class IdStrategy
Throws:
java.io.IOException

transferPojoId

protected <T> HasSchema<T> transferPojoId(Input input,
                                          Output output,
                                          int fieldNumber)
                               throws java.io.IOException
Specified by:
transferPojoId in class IdStrategy
Throws:
java.io.IOException

resolvePojoFrom

protected <T> HasSchema<T> resolvePojoFrom(Input input,
                                           int fieldNumber)
                                throws java.io.IOException
Specified by:
resolvePojoFrom in class IdStrategy
Throws:
java.io.IOException

writeMessageIdTo

protected <T> Schema<T> writeMessageIdTo(Output output,
                                         int fieldNumber,
                                         Message<T> message)
                              throws java.io.IOException
Specified by:
writeMessageIdTo in class IdStrategy
Throws:
java.io.IOException

writeArrayIdTo

protected void writeArrayIdTo(Output output,
                              java.lang.Class<?> componentType)
                       throws java.io.IOException
Specified by:
writeArrayIdTo in class IdStrategy
Throws:
java.io.IOException

transferArrayId

protected void transferArrayId(Input input,
                               Output output,
                               int fieldNumber,
                               boolean nonConcrete)
                        throws java.io.IOException
Specified by:
transferArrayId in class IdStrategy
Throws:
java.io.IOException

resolveArrayComponentTypeFrom

protected java.lang.Class<?> resolveArrayComponentTypeFrom(Input input,
                                                           boolean nonConcrete)
                                                    throws java.io.IOException
Specified by:
resolveArrayComponentTypeFrom in class IdStrategy
Throws:
java.io.IOException


Copyright © 2009-2012. All Rights Reserved.