Class UObject


  • public class UObject
    extends java.lang.Object
    Class provides ways to deal with unconstrained (untyped) data. In order to be able to work with very large amounts of data there is a way to store this data in file, wrap it by UObject (through JsonTokenStream) and process it as a stream of json tokens (like open/close of maps/arrays, map keys, long/ double/text/boolean/null values).
    • Constructor Detail

      • UObject

        public UObject​(java.lang.Object obj)
        Creates instance of UObject from File, byte[], char[], JsonTokenStream, JsonNode, POJO, Map, List or scalar.
      • UObject

        public UObject​(JsonTokenStream jts,
                       java.util.List<java.lang.String> rootPath)
        Creates instance of UObject from JsonTokenStream with specified root path modifier.
      • UObject

        public UObject​(UObject parent,
                       java.lang.String... relativePath)
        Creates instance of UObject from another UObject with specified root path modifier.
    • Method Detail

      • fromJsonString

        public static UObject fromJsonString​(java.lang.String json)
        Returns:
        instance of UObject created from Jackson tree parsed from JSON text
      • getPlacedStream

        public JsonTokenStream getPlacedStream()
                                        throws java.io.IOException
        Setting up internal JsonTokenStream before usage.
        Throws:
        java.io.IOException
      • getRootPath

        public java.util.List<java.lang.String> getRootPath()
        Root path specified in order to shift starting point of working subtree inside actual data described by internal JsonTokenStream.
        Returns:
        null in case of UObject created for not JsonTokenStream
      • isJsonNode

        public boolean isJsonNode()
        Returns:
        true in case UObject was created from Jackson tree rather than from plain maps, lists, scalars, POJOs or JsonTokenStream
      • isTokenStream

        public boolean isTokenStream()
        Returns:
        true in case UObject was created from JsonTokenStream
      • asJsonNode

        public JsonNode asJsonNode()
        Returns:
        Jackson tree representation of this object
      • isList

        public boolean isList()
        Returns:
        true in case this object is list of something, for JsonTokenStream it will always be false
      • asList

        public java.util.List<UObject> asList()
        Returns:
        list representation of this object
      • isMap

        public boolean isMap()
        Returns:
        true in case this object is mapping of something, for JsonTokenStream it will always be false
      • asMap

        public java.util.Map<java.lang.String,​UObject> asMap()
        Returns:
        map representation of this object
      • isInteger

        public boolean isInteger()
        Returns:
        true in case this object is integer, for JsonTokenStream it will always be false
      • isLong

        public boolean isLong()
        Returns:
        true in case this object is long, for JsonTokenStream it will always be false
      • isString

        public boolean isString()
        Returns:
        true in case this object is text, for JsonTokenStream it will always be false
      • isDouble

        public boolean isDouble()
        Returns:
        true in case this object is floating, for JsonTokenStream it will always be false
      • isBoolean

        public boolean isBoolean()
        Returns:
        true in case this object is boolean, for JsonTokenStream it will always be false
      • isNull

        public boolean isNull()
        Returns:
        true in case this object is null, for JsonTokenStream it will always be false
      • asScalar

        public <T> T asScalar()
        Returns:
        scalar representation of this object
      • asInstance

        public <T> T asInstance()
        Returns:
        POJO representation of this object
      • asClassInstance

        public <T> T asClassInstance​(java.lang.Class<T> retType)
        Returns:
        POJO representation of this object of type retType
      • asClassInstance

        public <T> T asClassInstance​(TypeReference<T> retType)
        Returns:
        POJO representation of this object of type retType
      • write

        public void write​(JsonGenerator jgen)
                   throws java.io.IOException
        Writing inner data into output token stream (generator). Method closes inner JsonTokenStream if it's used. So you don't need to worry about it.
        Throws:
        java.io.IOException
      • write

        public void write​(java.io.OutputStream os)
                   throws java.io.IOException
        Writing inner data into output stream. Method closes inner JsonTokenStream if it's used. So you don't need to worry about it.
        Throws:
        java.io.IOException
      • write

        public void write​(java.io.Writer w)
                   throws java.io.IOException
        Writing inner data into writer. Method closes inner JsonTokenStream if it's used. So you don't need to worry about it.
        Throws:
        java.io.IOException
      • toJsonString

        public java.lang.String toJsonString()
        Returns:
        JSON text representation of this object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • getSizeInBytes

        public long getSizeInBytes()
                            throws java.io.IOException
        Returns:
        Real size of UObject as if it was stored in byte array.
        Throws:
        java.io.IOException
      • transformObjectToObject

        public static <T> T transformObjectToObject​(java.lang.Object obj,
                                                    java.lang.Class<T> retType)
        Helper method for transformation POJO into POJO of another type.
      • transformStringToObject

        public static <T> T transformStringToObject​(java.lang.String json,
                                                    java.lang.Class<T> retType)
        Helper method for transformation JSON text into POJO.
      • transformObjectToObject

        public static <T> T transformObjectToObject​(java.lang.Object obj,
                                                    TypeReference<T> retType)
        Helper method for transformation POJO into POJO of another type.
      • transformStringToObject

        public static <T> T transformStringToObject​(java.lang.String json,
                                                    TypeReference<T> retType)
        Helper method for transformation JSON text into POJO.
      • transformJacksonToObject

        public static <T> T transformJacksonToObject​(JsonNode node,
                                                     java.lang.Class<T> retType)
        Helper method for transformation Jackson tree into POJO.
      • transformJacksonToObject

        public static <T> T transformJacksonToObject​(JsonNode node,
                                                     TypeReference<T> retType)
        Helper method for transformation Jackson tree into POJO.
      • transformObjectToString

        public static java.lang.String transformObjectToString​(java.lang.Object obj)
        Helper method for transformation POJO into JSON text.
      • transformJacksonToString

        public static java.lang.String transformJacksonToString​(JsonNode node)
        Helper method for transformation Jackson tree into JSON text.
      • transformObjectToJackson

        public static JsonNode transformObjectToJackson​(java.lang.Object obj)
        Helper method for transformation POJO into Jackson tree.
      • transformStringToJackson

        public static JsonNode transformStringToJackson​(java.lang.String json)
        Helper method for transformation JSON text into Jackson tree.