public final class SerializationContextImpl extends java.lang.Object implements SerializationContext
| Modifier and Type | Field and Description |
|---|---|
private Configuration |
configuration |
private java.util.Map<java.lang.String,FileDescriptor> |
fileDescriptors |
private java.util.Map<java.lang.String,GenericDescriptor> |
genericDescriptors |
private static Log |
log |
private java.util.Map<java.lang.Class<?>,BaseMarshallerDelegate<?>> |
marshallersByClass |
private java.util.Map<java.lang.String,BaseMarshallerDelegate<?>> |
marshallersByName |
private DescriptorParser |
parser |
private java.util.concurrent.locks.Lock |
readLock |
private java.util.concurrent.locks.ReentrantReadWriteLock |
readWriteLock |
private java.util.Map<java.lang.Integer,java.lang.String> |
typeIds |
private java.util.concurrent.locks.Lock |
writeLock |
| Constructor and Description |
|---|
SerializationContextImpl(Configuration configuration) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
canMarshall(java.lang.Class clazz)
Checks if the given type (message or enum) can be marshalled.
|
boolean |
canMarshall(java.lang.String descriptorFullName)
Checks if the given type (message or enum) can be marshalled.
|
Configuration |
getConfiguration() |
EnumDescriptor |
getEnumDescriptor(java.lang.String fullName) |
java.util.Map<java.lang.String,FileDescriptor> |
getFileDescriptors()
Obtain the registered file descriptors.
|
<T> BaseMarshaller<T> |
getMarshaller(java.lang.Class<T> clazz) |
<T> BaseMarshaller<T> |
getMarshaller(java.lang.String descriptorFullName) |
<T> BaseMarshallerDelegate<T> |
getMarshallerDelegate(java.lang.Class<T> clazz) |
<T> BaseMarshallerDelegate<T> |
getMarshallerDelegate(java.lang.String descriptorFullName) |
Descriptor |
getMessageDescriptor(java.lang.String fullName) |
java.lang.Integer |
getTypeIdByName(java.lang.String descriptorFullName)
Obtains the associated numeric type id, if one was defined.
|
java.lang.String |
getTypeNameById(java.lang.Integer typeId)
Obtains the type name associated with a numeric type id.
|
private void |
registerFileDescriptor(FileDescriptor fileDescriptor) |
<T> void |
registerMarshaller(BaseMarshaller<T> marshaller)
Register a type marshaller.
|
void |
registerProtoFiles(FileDescriptorSource source) |
private void |
unregisterFileDescriptorTypes(FileDescriptor fileDescriptor) |
void |
unregisterProtoFile(java.lang.String fileName)
Unregisters a file.
|
private static final Log log
private final java.util.concurrent.locks.ReentrantReadWriteLock readWriteLock
private final java.util.concurrent.locks.Lock readLock
private final java.util.concurrent.locks.Lock writeLock
private final Configuration configuration
private final DescriptorParser parser
private final java.util.Map<java.lang.String,FileDescriptor> fileDescriptors
private final java.util.Map<java.lang.Integer,java.lang.String> typeIds
private final java.util.Map<java.lang.String,GenericDescriptor> genericDescriptors
private final java.util.Map<java.lang.String,BaseMarshallerDelegate<?>> marshallersByName
private final java.util.Map<java.lang.Class<?>,BaseMarshallerDelegate<?>> marshallersByClass
public SerializationContextImpl(Configuration configuration)
public Configuration getConfiguration()
getConfiguration in interface SerializationContextpublic java.util.Map<java.lang.String,FileDescriptor> getFileDescriptors()
SerializationContextgetFileDescriptors in interface SerializationContextpublic void registerProtoFiles(FileDescriptorSource source) throws java.io.IOException, DescriptorParserException
registerProtoFiles in interface SerializationContextjava.io.IOExceptionDescriptorParserExceptionpublic void unregisterProtoFile(java.lang.String fileName)
SerializationContextunregisterProtoFile in interface SerializationContextprivate void registerFileDescriptor(FileDescriptor fileDescriptor)
private void unregisterFileDescriptorTypes(FileDescriptor fileDescriptor)
public Descriptor getMessageDescriptor(java.lang.String fullName)
getMessageDescriptor in interface SerializationContextpublic EnumDescriptor getEnumDescriptor(java.lang.String fullName)
getEnumDescriptor in interface SerializationContextpublic <T> void registerMarshaller(BaseMarshaller<T> marshaller)
SerializationContextregisterMarshaller in interface SerializationContextT - the Java type of the object being handled by the marshallermarshaller - the marshaller instancepublic boolean canMarshall(java.lang.Class clazz)
SerializationContextcanMarshall in interface SerializationContextclazz - the object or enum class to checktrue if a marshaller exists, false otherwisepublic boolean canMarshall(java.lang.String descriptorFullName)
SerializationContextcanMarshall in interface SerializationContextdescriptorFullName - the fully qualified name of the protobuf definition to checktrue if a marshaller exists, false otherwisepublic <T> BaseMarshaller<T> getMarshaller(java.lang.String descriptorFullName)
getMarshaller in interface SerializationContextpublic <T> BaseMarshaller<T> getMarshaller(java.lang.Class<T> clazz)
getMarshaller in interface SerializationContextpublic <T> BaseMarshallerDelegate<T> getMarshallerDelegate(java.lang.String descriptorFullName)
public <T> BaseMarshallerDelegate<T> getMarshallerDelegate(java.lang.Class<T> clazz)
public java.lang.String getTypeNameById(java.lang.Integer typeId)
SerializationContextgetTypeNameById in interface SerializationContexttypeId - the numeric type idpublic java.lang.Integer getTypeIdByName(java.lang.String descriptorFullName)
SerializationContextgetTypeIdByName in interface SerializationContextdescriptorFullName - the fully qualified type namenull if no type id is associated with the type