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 Stringdecode(BsonReader reader, DecoderContext decoderContext)Decodes a BSON value from the given reader into an instance of the type parameterT.voidencode(BsonWriter writer, String value, EncoderContext encoderContext)Encode an instance of the type parameterTinto a BSON value.Class<String>getEncoderClass()Returns the Class instance that this encodes.BsonTypegetRepresentation()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:RepresentationConfigurableGets the BsonRepresentation.- Specified by:
getRepresentationin interfaceRepresentationConfigurable<String>- Returns:
- the BsonRepresentation
-
withRepresentation
public Codec<String> withRepresentation(BsonType representation)
Description copied from interface:RepresentationConfigurableReturns an immutable codec with the given representation. If the provided representation is not supported an exception will be thrown.- Specified by:
withRepresentationin 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:EncoderEncode an instance of the type parameterTinto a BSON value.
-
decode
public String decode(BsonReader reader, DecoderContext decoderContext)
Description copied from interface:DecoderDecodes a BSON value from the given reader into an instance of the type parameterT.
-
getEncoderClass
public Class<String> getEncoderClass()
Description copied from interface:EncoderReturns the Class instance that this encodes. This is necessary because Java does not reify generic types.- Specified by:
getEncoderClassin interfaceEncoder<String>- Returns:
- the Class instance that this encodes.
-
-