Package com.cognite.client.util
Class ParseValue
- java.lang.Object
-
- com.cognite.client.util.ParseValue
-
public class ParseValue extends Object
This class hosts methods for parsingValueobjects to various target types (String, double, etc.). This can be helpful in particular when working with CDF.Raw and Json (parsed toStruct).
-
-
Constructor Summary
Constructors Constructor Description ParseValue()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleanparseBoolean(com.google.protobuf.Value rawValue)Tries to parse aValueto aBoolean.static doubleparseDouble(com.google.protobuf.Value rawValue)Tries to parse aValueto adouble.static longparseLong(com.google.protobuf.Value rawValue)Tries to parse aValueto along.static StringparseString(com.google.protobuf.Value rawValue)Tries to parse aValueto aStringrepresentation.
-
-
-
Method Detail
-
parseString
public static String parseString(com.google.protobuf.Value rawValue)
Tries to parse aValueto aStringrepresentation.- Parameters:
rawValue- the value to parse- Returns:
- the string representation
-
parseDouble
public static double parseDouble(com.google.protobuf.Value rawValue) throws NumberFormatExceptionTries to parse aValueto adouble. If the Value has a numeric or string representation the parsing will succeed as long as theValueis within the Double range. Will throw aNumberFormatExceptionif 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 NumberFormatExceptionTries to parse aValueto along. If the Value has a numeric or string representation the parsing will succeed as long as theValueis within the long range. Will throw aNumberFormatExceptionif 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 ExceptionTries to parse aValueto aBoolean. If the Value has a boolean, numeric or string representation the parsing will succeed. A boolValuerepresentation is parsed directly. A StringValuerepresentation returns true if the string argument is not null and equal to, ignoring case, the string "true". A numericValuerepresentation returns true if the number equals "1". Will throw anExceptionif parsing is unsuccessful.- Parameters:
rawValue- the value to parse- Returns:
- the boolean representation
- Throws:
Exception
-
-