Class TypeCodes


  • public final class TypeCodes
    extends Object
    TypeCodes maps between Type and the code used to prefix its json serialisation.
    • Method Detail

      • encode

        public static String encode​(int propertyType,
                                    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​(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,
                                     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 String decodeName​(int split,
                                        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.