Package com.upokecenter.cbor
Class CBORTypeMapper
java.lang.Object
com.upokecenter.cbor.CBORTypeMapper
Holds converters to customize the serialization and deserialization behavior
of
CBORObject.FromObject and CBORObject#ToObject, as well as
type filters for ToObject.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T> CBORTypeMapperAddConverter(Type type, ICBORConverter<T> converter) Registers an object that converts objects of a given type to CBOR objects (called a CBOR converter).AddTypeName(String name) Adds the fully qualified name of a Java or.NET type for use in type matching.AddTypePrefix(String prefix) Adds a prefix of a Java or.NET type for use in type matching.booleanFilterTypeName(String typeName) Returns whether the given Java or.NET type name fits the filters given in this mapper.
-
Constructor Details
-
CBORTypeMapper
public CBORTypeMapper()Initializes a new instance of theCBORTypeMapperclass.
-
-
Method Details
-
AddConverter
Registers an object that converts objects of a given type to CBOR objects (called a CBOR converter). If the CBOR converter converts to and from CBOR objects, it should implement the ICBORToFromConverter interface and provide ToCBORObject and FromCBORObject methods. If the CBOR converter only supports converting to (not from) CBOR objects, it should implement the ICBORConverter interface and provide a ToCBORObject method.- Type Parameters:
T- Must be the same as the "type" parameter.- Parameters:
type- A Type object specifying the type that the converter converts to CBOR objects.converter- The parameterconverteris an ICBORConverter object.- Returns:
- This object.
- Throws:
NullPointerException- The parametertypeorconverteris null.IllegalArgumentException- Converter doesn't contain a proper ToCBORObject method".
-
FilterTypeName
Returns whether the given Java or.NET type name fits the filters given in this mapper.- Parameters:
typeName- The fully qualified name of a Java or.NET class (e.g.,java.math.BigIntegerorSystem.Globalization.CultureInfo).- Returns:
- Either
trueif the given Java or.NET type name fits the filters given in this mapper, orfalseotherwise.
-
AddTypePrefix
Adds a prefix of a Java or.NET type for use in type matching. A type matches a prefix if its fully qualified name is or begins with that prefix, using codepoint-by-codepoint (case-sensitive) matching.- Parameters:
prefix- The prefix of a Java or.NET type (e.g., `java.math.` or `System.Globalization`).- Returns:
- This object.
- Throws:
NullPointerException- The parameterprefixis null.IllegalArgumentException- The parameterprefixis empty.
-
AddTypeName
Adds the fully qualified name of a Java or.NET type for use in type matching.- Parameters:
name- The fully qualified name of a Java or.NET class (e.g.,java.math.BigIntegerorSystem.Globalization.CultureInfo).- Returns:
- This object.
- Throws:
NullPointerException- The parameternameis null.IllegalArgumentException- The parameternameis empty.
-