Class ParseValue

java.lang.Object
com.cognite.client.util.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 Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    parseBoolean(com.google.protobuf.Value rawValue)
    Tries to parse a Value to a Boolean.
    static double
    parseDouble(com.google.protobuf.Value rawValue)
    Tries to parse a Value to a double.
    static long
    parseLong(com.google.protobuf.Value rawValue)
    Tries to parse a Value to a long.
    static String
    parseString(com.google.protobuf.Value rawValue)
    Tries to parse a Value to a String representation.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ParseValue

      public ParseValue()
  • Method Details

    • 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