Class YamlUtil

java.lang.Object
com.itextpdf.pdfocr.onnx.util.YamlUtil

public final class YamlUtil extends Object
Functions for working with YAML documents.
  • Method Details

    • deserializeFromStream

      public static Object deserializeFromStream (InputStream content)
      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

      public static Map<Object,Object> objToMapping (Object obj)
      Casts a parsed YAML object to a map/dictionary, if it is a mapping. Otherwise, returns null.
      Parameters:
      obj - parsed YAML object to cast
      Returns:
      mapping or null
    • objToSequence

      public static Collection<Object> objToSequence (Object obj)
      Casts a parsed YAML object to a collection, if it is a sequence. Otherwise, returns null.
      Parameters:
      obj - parsed YAML object to cast
      Returns:
      sequence or null
    • objToString

      public static String objToString (Object obj)
      Casts a parsed YAML object to a string, if it is a string. Otherwise, returns null.

      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

      public static Boolean objToBool (Object obj)
      Casts a parsed YAML object to a boolean, if it is a bool. Otherwise, returns null.

      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

      public static Integer objToInt (Object obj)
      Casts a parsed YAML object to an int32, if it is an int. Otherwise, returns null.

      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

      public static Double objToFloat (Object obj)
      Casts a parsed YAML object to a double, if it is a float. Otherwise, returns null.

      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