Class ExtraJson

java.lang.Object
tenapull.data.entity.objectLookup.ExtraJson
All Implemented Interfaces:
java.lang.Comparable<ExtraJson>, DbPojo, HashLookupPojo<ExtraJson>

@Entity(name="ExtraJson")
public class ExtraJson
extends java.lang.Object
implements HashLookupPojo<ExtraJson>
Represents a reusable extra json lookup, for any unexpected json returned from the Nessus API
  • Nested Class Summary

    Nested Classes 
    Modifier and Type Class Description
    static class  ExtraJson.Converter
    Hibernate converter.
    static class  ExtraJson.JsonMap
    A wrapper for the map representing the key-value pairs of the ExtraJson.
  • Field Summary

    Fields 
    Modifier and Type Field Description
    static ExtraJson.Converter converter
    A singleton instance of the DB converter for static utility usage
    static HashLookupDao<ExtraJson> dao
    The dao for ExtraJson
  • Constructor Summary

    Constructors 
    Constructor Description
    ExtraJson()
    Instantiates a new Extra json.
    ExtraJson​(java.lang.String jsonStr)
    Instantiates a new Extra json by deserializing a string
    ExtraJson​(java.util.Map<java.lang.String,​com.fasterxml.jackson.databind.JsonNode> value)
    Instantiates a new Extra json using a map of string keys and JsonNodes.
    ExtraJson​(ExtraJson copyExceptId)
    Instantiates a new Extra json, copying the value map of the passed ExtraJson
  • Method Summary

    Modifier and Type Method Description
    boolean _isHashCalculated()
    Shortcut for the StringHashLookupDao to determine what approach to most efficiently use to find a matching value for this lookup.
    boolean _match​(ExtraJson other)
    Determine if this pojo represents the same DB record as another POJO of the same type.
    void _prepare()
    Perform any operations necessary to prepare this pojo for insertion or updating in the database
    void _set​(ExtraJson other)
    Synchronize the values of two matching POJOs which represent the same DB record
    boolean equals​(java.lang.Object o)  
    static java.lang.String escapeString​(java.lang.String str)
    Static utility method for creating a Json escape string of a given string
    static java.lang.String escapeStringNoQuotes​(java.lang.String str)
    Static utility method for creating a Json escape string of a given string, but omitting the leading and trailing quotation marks.
    com.fasterxml.jackson.databind.JsonNode get​(java.lang.String key)
    Get the json node in the value map at the provided key
    Hash get_hash()
    Get the _hash of the "object lookup" pojo used for indexing it.
    int getId()
    Get the surrogate or natural primary key id for the lookup
    ExtraJson.JsonMap getValue()
    Returns the value map
    int hashCode()  
    com.fasterxml.jackson.databind.JsonNode put​(java.lang.String key, com.fasterxml.jackson.databind.JsonNode value)
    Put the provided json node in the value map using the provided key
    void set_hash​(Hash _hash)
    Set the _hash of the pojo used for indexing it
    void setId​(int id)
    Set the surrogate or natural primary key id for the lookup
    void setValue​(ExtraJson.JsonMap map)
    Sets the value map
    int size()
    The size of the value map
    com.fasterxml.jackson.databind.node.ObjectNode toJsonNode()
    Convert the pojo into a JsonNode
    java.lang.String toJsonString()
    Convert the pojo into a Json string
    java.lang.String toString()  

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface tenapull.data.entity.template.HashLookupPojo

    compareTo
  • Field Details

  • Constructor Details

    • ExtraJson

      public ExtraJson()
      Instantiates a new Extra json.
    • ExtraJson

      public ExtraJson​(ExtraJson copyExceptId)
      Instantiates a new Extra json, copying the value map of the passed ExtraJson
      Parameters:
      copyExceptId - the ExtraJson to copy the value map from
    • ExtraJson

      public ExtraJson​(java.util.Map<java.lang.String,​com.fasterxml.jackson.databind.JsonNode> value) throws java.lang.NullPointerException
      Instantiates a new Extra json using a map of string keys and JsonNodes.
      Parameters:
      value - the map to copy
      Throws:
      java.lang.NullPointerException - if the value is null
    • ExtraJson

      public ExtraJson​(java.lang.String jsonStr) throws com.fasterxml.jackson.core.JsonProcessingException, java.lang.IllegalArgumentException
      Instantiates a new Extra json by deserializing a string
      Parameters:
      jsonStr - the json str to deserialize
      Throws:
      com.fasterxml.jackson.core.JsonProcessingException - if there is a JsonProcessingException while deserialization
      java.lang.IllegalArgumentException - if the deserialized JsonNode is something other than an ObjectNode
  • Method Details

    • escapeString

      public static java.lang.String escapeString​(java.lang.String str)
      Static utility method for creating a Json escape string of a given string
      Parameters:
      str - the string to escape
      Returns:
      the JSON-escaped string
    • escapeStringNoQuotes

      public static java.lang.String escapeStringNoQuotes​(java.lang.String str)
      Static utility method for creating a Json escape string of a given string, but omitting the leading and trailing quotation marks.
      Parameters:
      str - the string to escape
      Returns:
      the JSON-escaped string without enclosing quotation marks
    • get_hash

      public Hash get_hash()
      Description copied from interface: HashLookupPojo
      Get the _hash of the "object lookup" pojo used for indexing it.
      Specified by:
      get_hash in interface HashLookupPojo<ExtraJson>
      Returns:
      the Hash of the object lookup
    • set_hash

      public void set_hash​(Hash _hash)
      Description copied from interface: HashLookupPojo
      Set the _hash of the pojo used for indexing it
      Specified by:
      set_hash in interface HashLookupPojo<ExtraJson>
      Parameters:
      _hash - the hash to set
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class java.lang.Object
    • equals

      public boolean equals​(java.lang.Object o)
      Overrides:
      equals in class java.lang.Object
    • put

      public com.fasterxml.jackson.databind.JsonNode put​(java.lang.String key, com.fasterxml.jackson.databind.JsonNode value) throws java.lang.IllegalStateException
      Put the provided json node in the value map using the provided key
      Parameters:
      key - the key
      value - the value
      Returns:
      the json node
      Throws:
      java.lang.IllegalStateException - the illegal state exception
    • get

      public com.fasterxml.jackson.databind.JsonNode get​(java.lang.String key)
      Get the json node in the value map at the provided key
      Parameters:
      key - the key
      Returns:
      the json node
    • toString

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

      public int size()
      The size of the value map
      Returns:
      the int
    • getId

      public int getId()
      Description copied from interface: DbPojo
      Get the surrogate or natural primary key id for the lookup
      Specified by:
      getId in interface DbPojo
      Returns:
      the id
    • setId

      public void setId​(int id)
      Description copied from interface: DbPojo
      Set the surrogate or natural primary key id for the lookup
      Specified by:
      setId in interface DbPojo
      Parameters:
      id - the id
    • getValue

      public ExtraJson.JsonMap getValue()
      Returns the value map
      Returns:
      the value
    • setValue

      public void setValue​(ExtraJson.JsonMap map) throws java.lang.NullPointerException
      Sets the value map
      Parameters:
      map - the map
      Throws:
      java.lang.NullPointerException - the null pointer exception
    • _isHashCalculated

      public boolean _isHashCalculated()
      Description copied from interface: HashLookupPojo
      Shortcut for the StringHashLookupDao to determine what approach to most efficiently use to find a matching value for this lookup. If the hash is already calculated, it is most efficient to use the hash. If it is not, it may be more efficient to use the _match method
      Specified by:
      _isHashCalculated in interface HashLookupPojo<ExtraJson>
      Returns:
      true if the hash has already been calculated, false if not
    • _match

      public boolean _match​(ExtraJson other)
      Description copied from interface: HashLookupPojo
      Determine if this pojo represents the same DB record as another POJO of the same type. Note that this is NOT the same as the equals() method (though it may be in certain cases). Equals may be used to determine if two pojos of the same type contain all of the same values, regardless of whether they represent the same DB record (depending on implementation) while _match determines only if they represent the same DB record even if some of the values may not be equivalent. In many cases the two methods may be the same, but their purpose is different.
      Specified by:
      _match in interface HashLookupPojo<ExtraJson>
      Parameters:
      other - other pojo to match
      Returns:
      true if the two pojos represent the same DB record, false if not
    • toJsonNode

      public com.fasterxml.jackson.databind.node.ObjectNode toJsonNode()
      Description copied from interface: DbPojo
      Convert the pojo into a JsonNode
      Specified by:
      toJsonNode in interface DbPojo
      Returns:
      a JsonNode representing the serialization of this pojo
    • toJsonString

      public java.lang.String toJsonString() throws com.fasterxml.jackson.core.JsonProcessingException
      Description copied from interface: DbPojo
      Convert the pojo into a Json string
      Specified by:
      toJsonString in interface DbPojo
      Returns:
      a string representing the Json serialization of this pojo
      Throws:
      com.fasterxml.jackson.core.JsonProcessingException
    • _prepare

      public void _prepare()
      Description copied from interface: DbPojo
      Perform any operations necessary to prepare this pojo for insertion or updating in the database
      Specified by:
      _prepare in interface DbPojo
    • _set

      public void _set​(ExtraJson other)
      Description copied from interface: HashLookupPojo
      Synchronize the values of two matching POJOs which represent the same DB record
      Specified by:
      _set in interface HashLookupPojo<ExtraJson>
      Parameters:
      other - the other pojo representing the same DB record, which the values should be taken from