public abstract class PersistableDefault extends java.lang.Object implements Persistable, Printable
Modifier and Type | Field and Description |
---|---|
protected static boolean |
DEFAULT_MATCH_ALL_FIELD_MODIFIERS |
protected static java.lang.String |
DEFAULT_VALUE |
protected boolean |
enabled |
protected static java.lang.String |
FAILED_RETRIEVE_VALUE |
protected java.util.Map<java.lang.String,java.lang.String> |
fieldNameToPersistKeyMap
a cache holding the Map of (fieldName, persistKey)
|
protected int |
ignoredFiledModifiers
The field's modifiers to check to tell if this field will be ignored; The check depends also on
matchAllFieldModifiers .The filed's modifiers is a combination of bits, such as Modifier.FINAL | Modifier.STATIC etc. If matchAllFieldModifiers is true, then ignore the filed if the it's modifiers fit all bits set in ignoredFiledModifiers .Otherwise, ignore the filed if the it's modifiers fit one of bits set in ignoredFiledModifiers . |
protected boolean |
matchAllFieldModifiers
If it is true, then ignore the filed if it's modifiers fit all bits set in
ignoredFiledModifiers . |
protected static int |
MODIFIER_CONSTANT |
protected static int |
MODIFIER_NONE |
protected Persistable |
parent |
protected java.util.Map<java.lang.String,java.lang.Object> |
persistKeyToFieldValueMap
a cache holding the Map of (persistKey, fieldValue)
|
protected int |
tabulation |
protected int |
threshold |
protected boolean |
thresholdEnabled |
protected static java.lang.String |
UNKNOWN_VALUE |
CONTAINER_ELEMENT
DATA_BIGGER_THAN_THRESHOLD
Modifier | Constructor and Description |
---|---|
|
PersistableDefault() |
protected |
PersistableDefault(int ignoredFiledModifiers)
Construct a PersistableDefault with modifier to filter the field for persisting.
|
protected |
PersistableDefault(int ignoredFiledModifiers,
boolean matchAllFieldModifiers)
Construct a PersistableDefault with modifier to filter the field for persisting.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object obj)
If
The parameter obj is also a Persistable.
|
java.util.Map<java.lang.String,java.lang.Object> |
getContents()
This method use Java reflection to get the value of the field defined in
getPersitableFields() . |
java.util.Map<java.lang.String,java.lang.Object> |
getContents(java.util.Map<java.lang.String,java.lang.String> elementAlternativeValues,
java.util.Set<java.lang.String> ignoredFields,
boolean includeContainer)
Turn the Persistable hierarchical contents Map (
Persistable.getContents() ) into a flat-key Map. |
java.lang.Object |
getField(java.lang.String persistKey)
Get the field's value of this Persistable object according to the persist-key.
The field name can be got from Persistable.getPersitableFields() according to the persist-key, then the value will be got of that field. |
java.lang.String |
getFlatKey()
A Persistable object can contain other Persistable objects, it is an hierarchical structure.
|
Persistable |
getParent() |
java.util.Map<java.lang.String,java.lang.String> |
getPersitableFields()
This default implementation get all the declared fields
Class.getDeclaredFields() and
put their name as 'fieldName' and 'persistKey' into the 'persistableFields Map'. |
int |
getTabulation() |
static java.lang.String |
getTagName(java.lang.String className)
Convert a full qualified class name into a tag name.
|
int |
getThreshold() |
protected boolean |
ignoreFieldForPersist(java.lang.reflect.Field field) |
boolean |
isEnabled()
Tell us if this object will be persisted or not.
|
boolean |
isIgnoredContentCache() |
boolean |
isThresholdEnabled()
If enabled, then the data bigger than the 'threshold' will not be printed out.
|
void |
setEnabled(boolean enabled)
Sometimes, we don't want to persist an object, we disable it.
|
boolean |
setField(java.lang.String persistKey,
java.lang.Object value)
Set the field's value of this Persistable object to the persist-key.
The field name can be got from Persistable.getPersitableFields() according to the persist-key, then the value will be set to that field. |
void |
setIgnoredContentCache(boolean ignoredContentCache) |
void |
setParent(Persistable parent)
|
void |
setTabulation(int tabulation) |
void |
setThreshold(int threshold) |
void |
setThresholdEnabled(boolean thresholdEnabled)
Enable/disable the "threshold ability".
If enabled, then the data bigger than the 'threshold' will not be printed out. |
java.lang.String |
toString() |
protected static final java.lang.String UNKNOWN_VALUE
protected static final java.lang.String DEFAULT_VALUE
protected static final java.lang.String FAILED_RETRIEVE_VALUE
protected java.util.Map<java.lang.String,java.lang.String> fieldNameToPersistKeyMap
protected java.util.Map<java.lang.String,java.lang.Object> persistKeyToFieldValueMap
protected boolean enabled
protected Persistable parent
protected int tabulation
protected int threshold
protected boolean thresholdEnabled
protected static final int MODIFIER_NONE
protected static final int MODIFIER_CONSTANT
protected int ignoredFiledModifiers
matchAllFieldModifiers
.matchAllFieldModifiers
is true, then ignore the filed if the it's modifiers fit all bits set in ignoredFiledModifiers
.ignoredFiledModifiers
.matchAllFieldModifiers
protected static final boolean DEFAULT_MATCH_ALL_FIELD_MODIFIERS
protected boolean matchAllFieldModifiers
ignoredFiledModifiers
.
Otherwise, ignore the filed if the it's modifiers fit one of bits set in ignoredFiledModifiers
.ignoredFiledModifiers
public PersistableDefault()
protected PersistableDefault(int ignoredFiledModifiers)
Note: This constructor is protected, and it is suggested to call it in a constructor without parameter to keep the consistency between "pickle" and "unpickle". If user makes it public in a child class and create a Persistable object with it, then inconsistency may happen between "pickle" and "unpickle", because "unpickle" uses the constructor without parameter, which is different than this one.
ignoredFiledModifiers
- int, the modifier used to filter the field for persisting.ignoredFiledModifiers
protected PersistableDefault(int ignoredFiledModifiers, boolean matchAllFieldModifiers)
Note: This constructor is protected, and it is suggested to call it in a constructor without parameter to keep the consistency between "pickle" and "unpickle". If user makes it public in a child class and create a Persistable object with it, then inconsistency may happen between "pickle" and "unpickle", because "unpickle" uses the constructor without parameter, which is different than this one.
ignoredFiledModifiers
- int, the modifier used to filter the field for persisting.matchAllFieldModifiers
- boolean, to match all bits or one of bits set in 'ignoredFiledModifiers'.ignoredFiledModifiers
public java.util.Map<java.lang.String,java.lang.String> getPersitableFields()
Class.getDeclaredFields()
and
put their name as 'fieldName' and 'persistKey' into the 'persistableFields Map'. But if
ignoreFieldForPersist(Field)
returns true, then that field will not get into 'persistableFields Map'.getPersitableFields
in interface Persistable
ignoreFieldForPersist(Field)
protected boolean ignoreFieldForPersist(java.lang.reflect.Field field)
field
- Field, the field to test.getPersitableFields()
public java.util.Map<java.lang.String,java.lang.Object> getContents()
getPersitableFields()
.getContents
in interface Persistable
public java.lang.Object getField(java.lang.String persistKey)
Persistable
Persistable.getPersitableFields()
according to the persist-key, then the value will be got of that field.getField
in interface Persistable
persistKey
- String, the persist-key (it can be tag-name in XML, key-string in JSON etc.). refer to Persistable.getPersitableFields()
.public boolean setField(java.lang.String persistKey, java.lang.Object value)
Persistable
Persistable.getPersitableFields()
according to the persist-key, then the value will be set to that field.setField
in interface Persistable
persistKey
- String, the persist-key (it can be tag-name in XML, key-string in JSON etc.). refer to Persistable.getPersitableFields()
.value
- Object, the value to setpublic boolean isEnabled()
Persistable
isEnabled
in interface Persistable
public void setEnabled(boolean enabled)
Persistable
setEnabled
in interface Persistable
enabled
- boolean, if true, this object will be persisted; otherwise, will not.public void setParent(Persistable parent)
Persistable
Persistor
and Verifier
can work correctly.setParent
in interface Persistable
parent
- Persistable,public Persistable getParent()
getParent
in interface Persistable
public static java.lang.String getTagName(java.lang.String className)
className
- String the full qualified class name.public java.lang.String getFlatKey()
Persistable
getFlatKey
in interface Persistable
#getContents(Map, Set)
public java.util.Map<java.lang.String,java.lang.Object> getContents(java.util.Map<java.lang.String,java.lang.String> elementAlternativeValues, java.util.Set<java.lang.String> ignoredFields, boolean includeContainer)
Persistable
Persistable.getContents()
) into a flat-key Map.getContents
in interface Persistable
elementAlternativeValues
- MapignoredFields
- SetIf this Set contains a field 'Response.Request', then all its children will be ignored, such as: Response.Request.Headers Response.Request.MessageBody ...
includeContainer
- boolean, in, if the Persistable Object itself should be considered as part of the whole contents.(Response.ID, "FFE3543545JLFS") (Response.Headers, "{Date=Tue, 06 DEC 2016 03:08:12 GMT}") (Response.Request.Headers, "{Content-Length=4574, Via=1.1 inetgw38 (squid)}")
public void setThreshold(int threshold)
setThreshold
in interface Printable
threshold
- int, the size of the data too big to print.public int getThreshold()
getThreshold
in interface Printable
public boolean isThresholdEnabled()
Printable
isThresholdEnabled
in interface Printable
public void setThresholdEnabled(boolean thresholdEnabled)
Printable
setThresholdEnabled
in interface Printable
public int getTabulation()
getTabulation
in interface Printable
public void setTabulation(int tabulation)
setTabulation
in interface Printable
tabulation
- int, The number of tabulation to print before the actual message.public boolean isIgnoredContentCache()
public void setIgnoredContentCache(boolean ignoredContentCache)
public java.lang.String toString()
toString
in class java.lang.Object
public boolean equals(java.lang.Object obj)
getPersitableFields()
are same
getPersitableFields()
are same
equals
in class java.lang.Object
Copyright © SAS Institute. All Rights Reserved.