Class TypeCodes


  • public final class TypeCodes
    extends java.lang.Object
    TypeCodes maps between Type and the code used to prefix its json serialisation.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String EMPTY_ARRAY  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String decodeName​(int split, java.lang.String jsonString)
      Decode the property name encoded into a jsonString given its split.
      static int decodeType​(int split, java.lang.String jsonString)
      Decode the type encoded into jsonString given its split.
      static java.lang.String encode​(int propertyType, java.lang.String propertyName)
      Encodes the given propertyName of the given propertyType into a json string, which is prefixed with a type code.
      static int split​(java.lang.String jsonString)
      Splits a jsonString, which is prefixed with a type code at the location where the prefix ends.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • encode

        public static java.lang.String encode​(int propertyType,
                                              java.lang.String propertyName)
        Encodes the given propertyName of the given propertyType into a json string, which is prefixed with a type code.
        Parameters:
        propertyType - type of the property
        propertyName - name of the property
        Returns:
        type code prefixed json string
      • split

        public static int split​(java.lang.String jsonString)
        Splits a jsonString, which is prefixed with a type code at the location where the prefix ends.
        Parameters:
        jsonString - json string to split
        Returns:
        the location where the prefix ends or -1 if no prefix is present
      • decodeType

        public static int decodeType​(int split,
                                     java.lang.String jsonString)
        Decode the type encoded into jsonString given its split.
        Parameters:
        split - split of the json string
        jsonString - json string
        Returns:
        decoded type. PropertyType.UNDEFINED if none or split is not within jsonString.
      • decodeName

        public static java.lang.String decodeName​(int split,
                                                  java.lang.String jsonString)
        Decode the property name encoded into a jsonString given its split.
        Parameters:
        split - split of the json string
        jsonString - json string
        Returns:
        decoded property name. Or jsonString if split is not with jsonString.