Class ParseValue


  • public class ParseValue
    extends Object
    This class hosts methods for parsing Value objects to various target types (String, double, etc.). This can be helpful in particular when working with CDF.Raw and Json (parsed to Struct).
    • Constructor Detail

      • ParseValue

        public ParseValue()
    • Method Detail

      • parseString

        public static String parseString​(com.google.protobuf.Value rawValue)
        Tries to parse a Value to a String representation.
        Parameters:
        rawValue - the value to parse
        Returns:
        the string representation
      • parseDouble

        public static double parseDouble​(com.google.protobuf.Value rawValue)
                                  throws NumberFormatException
        Tries to parse a Value to a double. If the Value has a numeric or string representation the parsing will succeed as long as the Value is within the Double range. Will throw a NumberFormatException if parsing is unsuccessful.
        Parameters:
        rawValue - the value to parse
        Returns:
        the double representation
        Throws:
        NumberFormatException
      • parseLong

        public static long parseLong​(com.google.protobuf.Value rawValue)
                              throws NumberFormatException
        Tries to parse a Value to a long. If the Value has a numeric or string representation the parsing will succeed as long as the Value is within the long range. Will throw a NumberFormatException if parsing is unsuccessful.
        Parameters:
        rawValue - the value to parse
        Returns:
        the long representation
        Throws:
        NumberFormatException
      • parseBoolean

        public static boolean parseBoolean​(com.google.protobuf.Value rawValue)
                                    throws Exception
        Tries to parse a Value to a Boolean. If the Value has a boolean, numeric or string representation the parsing will succeed. A bool Value representation is parsed directly. A String Value representation returns true if the string argument is not null and equal to, ignoring case, the string "true". A numeric Value representation returns true if the number equals "1". Will throw an Exception if parsing is unsuccessful.
        Parameters:
        rawValue - the value to parse
        Returns:
        the boolean representation
        Throws:
        Exception