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 usagestatic 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 stringExtraJson(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 databasevoid
_set(ExtraJson other)
Synchronize the values of two matching POJOs which represent the same DB recordboolean
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 stringstatic 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 keyHash
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 lookupExtraJson.JsonMap
getValue()
Returns the value mapint
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 keyvoid
set_hash(Hash _hash)
Set the _hash of the pojo used for indexing itvoid
setId(int id)
Set the surrogate or natural primary key id for the lookupvoid
setValue(ExtraJson.JsonMap map)
Sets the value mapint
size()
The size of the value mapcom.fasterxml.jackson.databind.node.ObjectNode
toJsonNode()
Convert the pojo into a JsonNodejava.lang.String
toJsonString()
Convert the pojo into a Json stringjava.lang.String
toString()
-
Field Details
-
Constructor Details
-
ExtraJson
public ExtraJson()Instantiates a new Extra json. -
ExtraJson
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.NullPointerExceptionInstantiates 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.IllegalArgumentExceptionInstantiates 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 deserializationjava.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
Description copied from interface:HashLookupPojo
Get the _hash of the "object lookup" pojo used for indexing it.- Specified by:
get_hash
in interfaceHashLookupPojo<ExtraJson>
- Returns:
- the Hash of the object lookup
-
set_hash
Description copied from interface:HashLookupPojo
Set the _hash of the pojo used for indexing it- Specified by:
set_hash
in interfaceHashLookupPojo<ExtraJson>
- Parameters:
_hash
- the hash to set
-
hashCode
public int hashCode()- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object o)- Overrides:
equals
in classjava.lang.Object
-
put
public com.fasterxml.jackson.databind.JsonNode put(java.lang.String key, com.fasterxml.jackson.databind.JsonNode value) throws java.lang.IllegalStateExceptionPut the provided json node in the value map using the provided key- Parameters:
key
- the keyvalue
- 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 classjava.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 -
setId
public void setId(int id)Description copied from interface:DbPojo
Set the surrogate or natural primary key id for the lookup -
getValue
Returns the value map- Returns:
- the value
-
setValue
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 interfaceHashLookupPojo<ExtraJson>
- Returns:
- true if the hash has already been calculated, false if not
-
_match
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 interfaceHashLookupPojo<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 interfaceDbPojo
- Returns:
- a JsonNode representing the serialization of this pojo
-
toJsonString
public java.lang.String toJsonString() throws com.fasterxml.jackson.core.JsonProcessingExceptionDescription copied from interface:DbPojo
Convert the pojo into a Json string- Specified by:
toJsonString
in interfaceDbPojo
- 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 -
_set
Description copied from interface:HashLookupPojo
Synchronize the values of two matching POJOs which represent the same DB record- Specified by:
_set
in interfaceHashLookupPojo<ExtraJson>
- Parameters:
other
- the other pojo representing the same DB record, which the values should be taken from
-