Class Text

All Implemented Interfaces:
TypeIO, TypeIOConstructor, Type, TypeConstructor

public class Text extends SimpleType

A plain old string. Very permissive, will allow any input to be converted in to a string.

  • Field Details

    • IO_CHARSET

      public static final Charset IO_CHARSET
  • Constructor Details

    • Text

      public Text()
  • Method Details

    • coerce

      public Object coerce(Object value)

      Convert the given value in to a string

      Parameters:
      value - The value to coerce
      Returns:
      A value that conforms to this type
      Throws:
      CoercionException - if value is null
    • internalType

      public Class<?> internalType()
      Description copied from interface: Type

      The underlying java class used to represent this type.

    • estimateSize

      public int estimateSize(Object entry)
      Description copied from interface: Type

      Estimate the number of bytes used to serialize the given value to an output stream.

      Parameters:
      entry - the value of this type to measure. Must be of Type.internalType() or a ClassCastException is going to happen
      Returns:
      the estimated number of bytes, or zero if no estimation was possible.
    • toBytes

      public void toBytes(DataOutputStream os, Object toWrite) throws IOException
      Throws:
      IOException
    • fromBytes

      public Object fromBytes(DataInputStream in) throws IOException
      Throws:
      IOException
    • read

      public Object read(ByteBuffer buffer)
      Description copied from interface: TypeIO

      Read a value from the given byte buffer

    • write

      public void write(ByteBuffer buffer, Object value)
      Description copied from interface: TypeIO

      Write a value out to the given byte buffer