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 classExtraJson.ConverterHibernate converter.static classExtraJson.JsonMapA wrapper for the map representing the key-value pairs of the ExtraJson. -
Field Summary
Fields Modifier and Type Field Description static ExtraJson.ConverterconverterA singleton instance of the DB converter for static utility usagestatic HashLookupDao<ExtraJson>daoThe 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 recordbooleanequals(java.lang.Object o)static java.lang.StringescapeString(java.lang.String str)Static utility method for creating a Json escape string of a given stringstatic java.lang.StringescapeStringNoQuotes(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.JsonNodeget(java.lang.String key)Get the json node in the value map at the provided keyHashget_hash()Get the _hash of the "object lookup" pojo used for indexing it.intgetId()Get the surrogate or natural primary key id for the lookupExtraJson.JsonMapgetValue()Returns the value mapinthashCode()com.fasterxml.jackson.databind.JsonNodeput(java.lang.String key, com.fasterxml.jackson.databind.JsonNode value)Put the provided json node in the value map using the provided keyvoidset_hash(Hash _hash)Set the _hash of the pojo used for indexing itvoidsetId(int id)Set the surrogate or natural primary key id for the lookupvoidsetValue(ExtraJson.JsonMap map)Sets the value mapintsize()The size of the value mapcom.fasterxml.jackson.databind.node.ObjectNodetoJsonNode()Convert the pojo into a JsonNodejava.lang.StringtoJsonString()Convert the pojo into a Json stringjava.lang.StringtoString()
-
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:HashLookupPojoGet the _hash of the "object lookup" pojo used for indexing it.- Specified by:
get_hashin interfaceHashLookupPojo<ExtraJson>- Returns:
- the Hash of the object lookup
-
set_hash
Description copied from interface:HashLookupPojoSet the _hash of the pojo used for indexing it- Specified by:
set_hashin interfaceHashLookupPojo<ExtraJson>- Parameters:
_hash- the hash to set
-
hashCode
public int hashCode()- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object o)- Overrides:
equalsin 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:
toStringin classjava.lang.Object
-
size
public int size()The size of the value map- Returns:
- the int
-
getId
public int getId()Description copied from interface:DbPojoGet the surrogate or natural primary key id for the lookup -
setId
public void setId(int id)Description copied from interface:DbPojoSet 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:HashLookupPojoShortcut 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:
_isHashCalculatedin interfaceHashLookupPojo<ExtraJson>- Returns:
- true if the hash has already been calculated, false if not
-
_match
Description copied from interface:HashLookupPojoDetermine 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:
_matchin 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:DbPojoConvert the pojo into a JsonNode- Specified by:
toJsonNodein 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:DbPojoConvert the pojo into a Json string- Specified by:
toJsonStringin 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:DbPojoPerform any operations necessary to prepare this pojo for insertion or updating in the database -
_set
Description copied from interface:HashLookupPojoSynchronize the values of two matching POJOs which represent the same DB record- Specified by:
_setin interfaceHashLookupPojo<ExtraJson>- Parameters:
other- the other pojo representing the same DB record, which the values should be taken from
-