Class Codec<T>

java.lang.Object
tripleplay.syncdb.Codec<T>
Direct Known Subclasses:
Codec.EnumC

public abstract class Codec<T> extends Object
Handles encoding/decoding properties to/from strings.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    Codec.EnumC<E extends Enum<E>>
    A codec for enums which encodes to/from Enum.name.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Codec<Boolean>
    A codec for booleans.
    static final Codec<Integer>
    A codec for ints.
    static final Codec<int[]>
    A codec for int arrays.
    static final Codec<Long>
    A codec for longs.
    static final Codec<String>
    A codec for strings.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract T
    decode(String data)
    Decodes the supplied string into a value.
    decode(String data, T defval)
    Decodes the supplied string into a value.
    abstract String
    encode(T value)
    Encodes the supplied value to a string.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • STRING

      public static final Codec<String> STRING
      A codec for strings. The identity codec.
    • INT

      public static final Codec<Integer> INT
      A codec for ints.
    • INTS

      public static final Codec<int[]> INTS
      A codec for int arrays.
    • LONG

      public static final Codec<Long> LONG
      A codec for longs.
    • BOOLEAN

      public static final Codec<Boolean> BOOLEAN
      A codec for booleans. Encodes to the string t or f.
  • Constructor Details

    • Codec

      public Codec()
  • Method Details

    • encode

      public abstract String encode(T value)
      Encodes the supplied value to a string.
    • decode

      public abstract T decode(String data)
      Decodes the supplied string into a value. May freak out if data is null.
    • decode

      public T decode(String data, T defval)
      Decodes the supplied string into a value. Returns defval if data is null.