org.apache.ignite.internal.binary

## Class BinaryContext

- java.lang.Object
- - org.apache.ignite.internal.binary.BinaryContext

    public class BinaryContext
    extends Object

Binary context.

### Constructor Summary

Constructors
Constructor and Description
`BinaryContext(BinaryMetadataHandler metaHnd, IgniteConfiguration igniteCfg, IgniteLogger log)`

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`static String` `affinityFieldName(Class cls)`
`String` `affinityKeyFieldName(int typeId)` Get affinity key field name for type.
`byte` `collectionType(Class<? extends Collection> cls)`
`IgniteConfiguration` `configuration()`
`void` `configure(BinaryMarshaller marsh, IgniteConfiguration cfg)`
`BinaryFieldImpl` `createField(int typeId, String fieldName)` Create binary field.
`static BinaryIdMapper` `defaultIdMapper()`
`static BinaryInternalMapper` `defaultMapper()`
`static BinaryNameMapper` `defaultNameMapper()`
`BinaryClassDescriptor` `descriptorForClass(Class<?> cls, boolean deserialize, boolean failIfUnregistered)`
`BinaryClassDescriptor` `descriptorForTypeId(boolean userType, int typeId, ClassLoader ldr, boolean deserialize)`
`int` `fieldId(int typeId, String fieldName)`
`BinaryIdentityResolver` `identity(int typeId)`
`boolean` `isCompactFooter()`
`IgniteLogger` `log()`
`byte` `mapType(Class<? extends Map> cls)`
`BinaryMarshaller` `marshaller()`
`Collection<BinaryType>` `metadata()`
`BinaryType` `metadata(int typeId)`
`BinaryType` `metadata(int typeId, int schemaId)`
`BinaryMetadata` `metadata0(int typeId)`
`boolean` `mustDeserialize(Class cls)` Check whether class must be deserialized anyway.
`void` `onUndeploy(ClassLoader ldr)` Undeployment callback invoked when class loader is being undeployed.
`BinaryClassDescriptor` `registerPredefinedType(Class<?> cls, int id)`
`BinaryClassDescriptor` `registerPredefinedType(Class<?> cls, int id, String affFieldName, boolean registered)`
`boolean` `registerUserClassName(int typeId, String clsName)` Register "type ID to class name" mapping on all nodes to allow for mapping requests resolution form client.
`void` `registerUserType(String clsName, BinaryInternalMapper mapper, BinarySerializer serializer, BinaryIdentityResolver identity, String affKeyFieldName, boolean isEnum, Map<String,Integer> enumMap)`
`void` `registerUserTypesSchema()` Register user types schemas.
`BinarySchemaRegistry` `schemaRegistry(int typeId)` Get schema registry for type ID.
`int` `typeId(String typeName)`
`void` `unregisterBinarySchemas()` Unregister all binary schemas.
`void` `unregisterUserTypeDescriptors()` Unregisters the user types descriptors.
`void` `updateMetadata(int typeId, BinaryMetadata meta, boolean failIfUnregistered)`
`String` `userTypeName(String clsName)`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### BinaryContext

    public BinaryContext(BinaryMetadataHandler metaHnd,
                         IgniteConfiguration igniteCfg,
                         IgniteLogger log)

Parameters:
  `metaHnd` - Meta data handler.
  `igniteCfg` - Ignite configuration.
  `log` - Logger.

### Method Detail

#### log

    public IgniteLogger log()

Returns:
  Logger.

#### marshaller

    public BinaryMarshaller marshaller()

Returns:
  Marshaller.

#### mustDeserialize

    public boolean mustDeserialize(Class cls)

Check whether class must be deserialized anyway.

Parameters:
  `cls` - Class.
Returns:
  `True` if must be deserialized.

#### configuration

    public IgniteConfiguration configuration()

Returns:
  Ignite configuration.

#### configure

    public void configure(BinaryMarshaller marsh,
                          IgniteConfiguration cfg)
                   throws BinaryObjectException

Parameters:
  `marsh` - Binary marshaller.
  `cfg` - Configuration.
Throws:
  `BinaryObjectException` - In case of error.

#### defaultMapper

    public static BinaryInternalMapper defaultMapper()

Returns:
  Internal mapper used as default.

#### defaultIdMapper

    public static BinaryIdMapper defaultIdMapper()

Returns:
  ID mapper used as default.

#### defaultNameMapper

    public static BinaryNameMapper defaultNameMapper()

Returns:
  Name mapper used as default.

#### descriptorForClass

    public BinaryClassDescriptor descriptorForClass(Class<?> cls,
                                                    boolean deserialize,
                                                    boolean failIfUnregistered)
                                             throws BinaryObjectException

Parameters:
  `cls` - Class.
  `failIfUnregistered` - Throw exception if class isn't registered.
Returns:
  Class descriptor.
Throws:
  `BinaryObjectException` - In case of error.

#### descriptorForTypeId

    public BinaryClassDescriptor descriptorForTypeId(boolean userType,
                                                     int typeId,
                                                     ClassLoader ldr,
                                                     boolean deserialize)

Parameters:
  `userType` - User type or not.
  `typeId` - Type ID.
  `ldr` - Class loader.
Returns:
  Class descriptor.

#### collectionType

    public byte collectionType(Class<? extends Collection> cls)

Parameters:
  `cls` - Collection class.
Returns:
  Collection type ID.

#### mapType

    public byte mapType(Class<? extends Map> cls)

Parameters:
  `cls` - Map class.
Returns:
  Map type ID.

#### typeId

    public int typeId(String typeName)

Parameters:
  `typeName` - Type name.
Returns:
  Type ID.

#### fieldId

    public int fieldId(int typeId,
                       String fieldName)

Parameters:
  `typeId` - Type ID.
  `fieldName` - Field name.
Returns:
  Field ID.

#### userTypeName

    public String userTypeName(String clsName)

Parameters:
  `clsName` - Class name.
Returns:
  Type name.

#### affinityFieldName

    public static String affinityFieldName(Class cls)

Parameters:
  `cls` - Class to get affinity field for.
Returns:
  Affinity field name or `null` if field name was not found.

#### registerPredefinedType

    public BinaryClassDescriptor registerPredefinedType(Class<?> cls,
                                                        int id)

Parameters:
  `cls` - Class.
  `id` - Type ID.
Returns:
  GridBinaryClassDescriptor.

#### registerPredefinedType

    public BinaryClassDescriptor registerPredefinedType(Class<?> cls,
                                                        int id,
                                                        String affFieldName,
                                                        boolean registered)

Parameters:
  `cls` - Class.
  `id` - Type ID.
  `affFieldName` - Affinity field name.
Returns:
  GridBinaryClassDescriptor.

#### registerUserType

    public void registerUserType(String clsName,
                                 BinaryInternalMapper mapper,
                                 @Nullable
                                 BinarySerializer serializer,
                                 @Nullable
                                 BinaryIdentityResolver identity,
                                 @Nullable
                                 String affKeyFieldName,
                                 boolean isEnum,
                                 @Nullable
                                 Map<String,Integer> enumMap)
                          throws BinaryObjectException

Parameters:
  `clsName` - Class name.
  `mapper` - ID mapper.
  `serializer` - Serializer.
  `identity` - Type identity.
  `affKeyFieldName` - Affinity key field name.
  `isEnum` - If enum.
  `enumMap` - Enum name to ordinal mapping.
Throws:
  `BinaryObjectException` - In case of error.

#### registerUserTypesSchema

    public void registerUserTypesSchema()

Register user types schemas.

#### registerUserClassName

    public boolean registerUserClassName(int typeId,
                                         String clsName)

Register "type ID to class name" mapping on all nodes to allow for mapping requests resolution form client. Other `BinaryContext`'s "register" methods and method `descriptorForClass(Class, boolean, boolean)` already call this functionality so use this method only when registering class names whose `Class` is unknown.

Parameters:
  `typeId` - Type ID.
  `clsName` - Class Name.
Returns:
  `True` if the mapping was registered successfully.

#### createField

    public BinaryFieldImpl createField(int typeId,
                                       String fieldName)

Create binary field.

Parameters:
  `typeId` - Type ID.
  `fieldName` - Field name.
Returns:
  Binary field.

#### metadata

    @Nullable
    public BinaryType metadata(int typeId)
                                  throws BinaryObjectException

Parameters:
  `typeId` - Type ID.
Returns:
  Meta data.
Throws:
  `BinaryObjectException` - In case of error.

#### metadata0

    @Nullable
    public BinaryMetadata metadata0(int typeId)
                                       throws BinaryObjectException

Parameters:
  `typeId` - Type ID
Returns:
  Meta data.
Throws:
  `BinaryObjectException` - In case of error.

#### metadata

    public Collection<BinaryType> metadata()
                                    throws BinaryObjectException

Returns:
  All metadata known to this node.
Throws:
  `BinaryObjectException`

#### metadata

    public BinaryType metadata(int typeId,
                               int schemaId)
                        throws BinaryObjectException

Parameters:
  `typeId` - Type ID.
  `schemaId` - Schema ID.
Returns:
  Meta data.
Throws:
  `BinaryObjectException` - In case of error.

#### affinityKeyFieldName

    public String affinityKeyFieldName(int typeId)

Get affinity key field name for type. First consult to predefined configuration, then delegate to metadata.

Parameters:
  `typeId` - Type ID.
Returns:
  Affinity key field name.

#### identity

    public BinaryIdentityResolver identity(int typeId)

Parameters:
  `typeId` - Type ID.
Returns:
  Type identity.

#### updateMetadata

    public void updateMetadata(int typeId,
                               BinaryMetadata meta,
                               boolean failIfUnregistered)
                        throws BinaryObjectException

Parameters:
  `typeId` - Type ID.
  `meta` - Meta data.
  `failIfUnregistered` - Fail if unregistered.
Throws:
  `BinaryObjectException` - In case of error.

#### isCompactFooter

    public boolean isCompactFooter()

Returns:
  Whether field IDs should be skipped in footer or not.

#### schemaRegistry

    public BinarySchemaRegistry schemaRegistry(int typeId)

Get schema registry for type ID.

Parameters:
  `typeId` - Type ID.
Returns:
  Schema registry for type ID.

#### unregisterBinarySchemas

    public void unregisterBinarySchemas()

Unregister all binary schemas.

#### unregisterUserTypeDescriptors

    public void unregisterUserTypeDescriptors()

Unregisters the user types descriptors.

#### onUndeploy

    public void onUndeploy(ClassLoader ldr)

Undeployment callback invoked when class loader is being undeployed. Some marshallers may want to clean their internal state that uses the undeployed class loader somehow.

Parameters:
  `ldr` - Class loader being undeployed.

2018 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Database and Caching Platform | : ver. 2.7.5
Release Date | : June 4 2019