Class YamlUtil
-
Method Summary
Modifier and TypeMethodDescriptionstatic ObjectdeserializeFromStream(InputStream content) Deserializes a content stream, which contains a single YAML document.static BooleanCasts a parsed YAML object to a boolean, if it is a bool.static DoubleobjToFloat(Object obj) Casts a parsed YAML object to a double, if it is a float.static IntegerCasts a parsed YAML object to an int32, if it is an int.objToMapping(Object obj) Casts a parsed YAML object to a map/dictionary, if it is a mapping.static Collection<Object>objToSequence(Object obj) Casts a parsed YAML object to a collection, if it is a sequence.static StringobjToString(Object obj) Casts a parsed YAML object to a string, if it is a string.
-
Method Details
-
deserializeFromStream
Deserializes a content stream, which contains a single YAML document.This method returns a regular object. To get access to concrete types in the document, use the
objTo*family of functions from this class.- Parameters:
-
content- YAML document content stream to parse - Returns:
- the parsed object
-
objToMapping
Casts a parsed YAML object to a map/dictionary, if it is a mapping. Otherwise, returnsnull.- Parameters:
-
obj- parsed YAML object to cast - Returns:
-
mapping or
null
-
objToSequence
Casts a parsed YAML object to a collection, if it is a sequence. Otherwise, returnsnull.- Parameters:
-
obj- parsed YAML object to cast - Returns:
-
sequence or
null
-
objToString
Casts a parsed YAML object to a string, if it is a string. Otherwise, returnsnull.If the object in the YAML document had an explicit type tag, which is not str, then this method won't do any conversions and will just return
null.- Parameters:
-
obj- parsed YAML object to cast - Returns:
-
string or
null
-
objToBool
Casts a parsed YAML object to a boolean, if it is a bool. Otherwise, returnsnull.If the object in the YAML document had an explicit type tag, which is not bool, then this method won't do any conversions and will just return
null.- Parameters:
-
obj- parsed YAML object to cast - Returns:
-
boolean or
null
-
objToInt
Casts a parsed YAML object to an int32, if it is an int. Otherwise, returnsnull.If the object in the YAML document had an explicit type tag, which is not int, then this method won't do any conversions and will just return
null.If the value does not fit into int32, then this method will also return
null.- Parameters:
-
obj- parsed YAML object to cast - Returns:
-
int32 or
null
-
objToFloat
Casts a parsed YAML object to a double, if it is a float. Otherwise, returnsnull.If the object in the YAML document had an explicit type tag, which is not float, then this method won't do any conversions and will just return
null.If the value does not fit into int32, then this method will also return
null.- Parameters:
-
obj- parsed YAML object to cast - Returns:
-
double or
null
-