com.dyuproject.protostuff.runtime
Class MappedSchema<T>

java.lang.Object
  extended by com.dyuproject.protostuff.runtime.MappedSchema<T>
All Implemented Interfaces:
Schema<T>
Direct Known Subclasses:
RuntimeSchema

public abstract class MappedSchema<T>
extends java.lang.Object
implements Schema<T>

Base class for schemas that maps fields by number and name. For fast initialization, the last field number is provided in the constructor.

Author:
David Yu
Date created:
Nov 10, 2009

Nested Class Summary
static class MappedSchema.Field<T>
          Represents a field of a message/pojo.
 
Field Summary
protected  MappedSchema.Field<T>[] fields
           
protected  java.util.Map<java.lang.String,MappedSchema.Field<T>> fieldsByName
           
protected  MappedSchema.Field<T>[] fieldsByNumber
           
protected  Pipe.Schema<T> pipeSchema
           
protected  java.lang.Class<T> typeClass
           
 
Constructor Summary
MappedSchema(java.lang.Class<T> typeClass, java.util.Collection<MappedSchema.Field<T>> fields, int lastFieldNumber)
           
MappedSchema(java.lang.Class<T> typeClass, java.util.Map<java.lang.String,MappedSchema.Field<T>> fieldsByName, int lastFieldNumber)
           
MappedSchema(java.lang.Class<T> typeClass, MappedSchema.Field<T>[] fields, int lastFieldNumber)
           
 
Method Summary
 int getFieldCount()
          Returns the message's total number of fields.
 java.lang.String getFieldName(int number)
           
 int getFieldNumber(java.lang.String name)
           
 Pipe.Schema<T> getPipeSchema()
          Returns the pipe schema linked to this.
 void mergeFrom(Input input, T message)
           
 java.lang.String messageFullName()
           
 java.lang.String messageName()
           
 java.lang.Class<T> typeClass()
           
 void writeTo(Output output, T message)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.dyuproject.protostuff.Schema
isInitialized, newMessage
 

Field Detail

typeClass

protected final java.lang.Class<T> typeClass

fields

protected final MappedSchema.Field<T>[] fields

fieldsByNumber

protected final MappedSchema.Field<T>[] fieldsByNumber

fieldsByName

protected final java.util.Map<java.lang.String,MappedSchema.Field<T>> fieldsByName

pipeSchema

protected final Pipe.Schema<T> pipeSchema
Constructor Detail

MappedSchema

public MappedSchema(java.lang.Class<T> typeClass,
                    MappedSchema.Field<T>[] fields,
                    int lastFieldNumber)

MappedSchema

public MappedSchema(java.lang.Class<T> typeClass,
                    java.util.Collection<MappedSchema.Field<T>> fields,
                    int lastFieldNumber)

MappedSchema

public MappedSchema(java.lang.Class<T> typeClass,
                    java.util.Map<java.lang.String,MappedSchema.Field<T>> fieldsByName,
                    int lastFieldNumber)
Method Detail

getFieldCount

public int getFieldCount()
Returns the message's total number of fields.


typeClass

public java.lang.Class<T> typeClass()
Specified by:
typeClass in interface Schema<T>

messageName

public java.lang.String messageName()
Specified by:
messageName in interface Schema<T>

messageFullName

public java.lang.String messageFullName()
Specified by:
messageFullName in interface Schema<T>

getFieldName

public java.lang.String getFieldName(int number)
Specified by:
getFieldName in interface Schema<T>

getFieldNumber

public int getFieldNumber(java.lang.String name)
Specified by:
getFieldNumber in interface Schema<T>

mergeFrom

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

writeTo

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

getPipeSchema

public Pipe.Schema<T> getPipeSchema()
Returns the pipe schema linked to this.



Copyright © 2009-2014. All Rights Reserved.