Package org.bson.codecs
Class StringCodec
- java.lang.Object
-
- org.bson.codecs.StringCodec
-
-
Constructor Summary
Constructors Constructor Description StringCodec()
Constructs a StringCodec with a String representation.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
decode(BsonReader reader, DecoderContext decoderContext)
Decodes a BSON value from the given reader into an instance of the type parameterT
.void
encode(BsonWriter writer, String value, EncoderContext encoderContext)
Encode an instance of the type parameterT
into a BSON value.Class<String>
getEncoderClass()
Returns the Class instance that this encodes.BsonType
getRepresentation()
Gets the BsonRepresentation.Codec<String>
withRepresentation(BsonType representation)
Returns an immutable codec with the given representation.
-
-
-
Method Detail
-
getRepresentation
public BsonType getRepresentation()
Description copied from interface:RepresentationConfigurable
Gets the BsonRepresentation.- Specified by:
getRepresentation
in interfaceRepresentationConfigurable<String>
- Returns:
- the BsonRepresentation
-
withRepresentation
public Codec<String> withRepresentation(BsonType representation)
Description copied from interface:RepresentationConfigurable
Returns an immutable codec with the given representation. If the provided representation is not supported an exception will be thrown.- Specified by:
withRepresentation
in interfaceRepresentationConfigurable<String>
- Parameters:
representation
- the BsonRepresentation.- Returns:
- a new Codec with the correct representation.
-
encode
public void encode(BsonWriter writer, String value, EncoderContext encoderContext)
Description copied from interface:Encoder
Encode an instance of the type parameterT
into a BSON value.
-
decode
public String decode(BsonReader reader, DecoderContext decoderContext)
Description copied from interface:Decoder
Decodes a BSON value from the given reader into an instance of the type parameterT
.
-
getEncoderClass
public Class<String> getEncoderClass()
Description copied from interface:Encoder
Returns the Class instance that this encodes. This is necessary because Java does not reify generic types.- Specified by:
getEncoderClass
in interfaceEncoder<String>
- Returns:
- the Class instance that this encodes.
-
-