|
Platform SDK Java 8.5 API Reference | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.genesyslab.platform.commons.collections.processor.KeyValuePrinter
public class KeyValuePrinter
This class manages the output of key-value collection to logs. The output is managed by filters. There is number of them, namely: copy, hide, skip, truncate and encrypt. Their usage is defined by two TKVLists. First one is for general options (like default filter and password for encryption). Second is mapping of keys in TKV for output and name of filter to apply.
Without any configuration default filter is "truncate".
KeyValueCollection kvOptions = new KeyValueCollection();
KeyValueCollection kvData = new KeyValueCollection();
kvData.addString("Password", KeyValuePrinter.HIDE_FILTER_NAME);
KeyValuePrinter hidePrinter = new KeyValuePrinter(kvOptions, kvData);
KeyValuePrinter.setDefaultPrinter(hidePrinter);
KeyValueCollection col = new KeyValueCollection();
col.addString("Password", "asdfg");
col.addString("qqwee", "dfdg");
System.out.println(col.toString());
Output is:
KVList:
'Password' [output supressed]
'qqwee' [str] = "dfdg"
KeyValueCollection kvData = new KeyValueCollection();
KeyValueCollection kvPPfilter = new KeyValueCollection();
KeyValueCollection kvPPOptions = new KeyValueCollection();
kvPPfilter.addString(KeyValuePrinter.CUSTOM_FILTER_TYPE, "PrefixPostfixFilter");
kvPPOptions.addString(PrefixPostfixFilter.KEY_PREFIX_STRING, "<###");
kvPPOptions.addString(PrefixPostfixFilter.VALUE_POSTFIX_STRING, "###>");
kvPPOptions.addString(PrefixPostfixFilter.KEY_POSTFIX_STRING, ">");
kvPPOptions.addString(PrefixPostfixFilter.VALUE_PREFIX_STRING, "<");
kvPPfilter.addList(KeyValuePrinter.CUSTOM_FILTER_OPTIONS, kvPPOptions);
kvData.addList("test", kvPPfilter);
KeyValuePrinter.setDefaultPrinter(
new KeyValuePrinter(new KeyValueCollection(), kvData));
KeyValueCollection col = new KeyValueCollection();
col.addString("qqwee", "d2f3d4g5");
col.addString("test", "tratata");
System.out.println(col.toString());
KVList:
'qqwee' [str] = "d2f3d4g5"
<###'test'> [str] = <"tratata"###>
Field Summary | |
---|---|
static java.lang.String |
COPY_FILTER_NAME
"Copy" filter just outputs data as is. |
static java.lang.String |
CUSTOM_FILTER_NAME
Key value for adding user defined custom filter to filter set. |
static java.lang.String |
CUSTOM_FILTER_OPTIONS
Custom filter options, which will be passed to KeyValueOutputFilter.configure()
method of custom filter class. |
static java.lang.String |
CUSTOM_FILTER_TYPE
Fully-qualified name of custom filter class type with public default constructor. |
static java.lang.String |
DEF_FILTER_OPTION
String option. |
static java.lang.String |
FILTER_NAME
|
static java.lang.String |
HIDE_FILTER_NAME
"Hide" filter doesn't show the data, but key is present in output. |
static java.lang.String |
HIDE_FIRST_CHARACTERS_COUNT
|
static java.lang.String |
HIDE_FIRST_FILTER_NAME
|
static java.lang.String |
HIDE_LAST_CHARACTERS_COUNT
|
static java.lang.String |
HIDE_LAST_FILTER_NAME
|
static java.lang.String |
SKIP_FILTER_NAME
"Skip" filter doesn't show either key or data. |
static java.lang.String |
TAG_FILTER_NAME
"tag()" filter tags the value of the key. |
static java.lang.String |
TRUNCATE_FILTER_NAME
"Truncate" filter cuts the binary data off if it's longer then some threshold |
static java.lang.String |
TRUNCATE_THRESHOLD_OPTION
Integer option. |
static java.lang.String |
UNHIDE_FIRST_CHARACTERS_COUNT
|
static java.lang.String |
UNHIDE_FIRST_FILTER_NAME
|
static java.lang.String |
UNHIDE_LAST_CHARACTERS_COUNT
|
static java.lang.String |
UNHIDE_LAST_FILTER_NAME
|
Constructor Summary | |
---|---|
KeyValuePrinter(KeyValueCollection options,
KeyValueCollection data)
Creates a new printer. |
Method Summary | |
---|---|
void |
appendValue(java.lang.StringBuffer buf,
KeyValueCollection list)
Appends string representation of TKV list to given buffer by applying configured set of filters to the list. |
void |
appendValue(java.lang.StringBuffer buf,
KeyValueCollection list,
int indent)
Appends string representation of TKV list to given buffer by applying configured set of filters to the list. |
void |
appendValue(java.lang.StringBuffer buf,
java.lang.String key,
java.lang.Object value)
Appends string representation of key/value pair to given buffer by applying configured set of filters to the list. |
void |
appendValue(java.lang.StringBuffer buf,
java.lang.String key,
java.lang.Object value,
int indent)
Appends string representation of key/value pair to given buffer by applying configured set of filters to the list. |
static KeyValuePrinter |
getDefaultPrinter()
Gets default printer for this VM. |
static void |
setDefaultPrinter(KeyValuePrinter printer)
Sets default printer for this VM. |
java.lang.String |
toString(KeyValueCollection kvList)
Creates string representation of TKV list applying configured set of filters. |
java.lang.String |
toString(java.lang.String key,
java.lang.Object value)
Creates string representation of key/value pair applying configured set of filters. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String DEF_FILTER_OPTION
public static final java.lang.String TRUNCATE_THRESHOLD_OPTION
public static final java.lang.String COPY_FILTER_NAME
public static final java.lang.String HIDE_FILTER_NAME
public static final java.lang.String SKIP_FILTER_NAME
public static final java.lang.String TRUNCATE_FILTER_NAME
public static final java.lang.String TAG_FILTER_NAME
public static final java.lang.String HIDE_FIRST_FILTER_NAME
public static final java.lang.String HIDE_FIRST_CHARACTERS_COUNT
public static final java.lang.String HIDE_LAST_FILTER_NAME
public static final java.lang.String HIDE_LAST_CHARACTERS_COUNT
public static final java.lang.String UNHIDE_FIRST_FILTER_NAME
public static final java.lang.String UNHIDE_FIRST_CHARACTERS_COUNT
public static final java.lang.String UNHIDE_LAST_FILTER_NAME
public static final java.lang.String UNHIDE_LAST_CHARACTERS_COUNT
public static final java.lang.String FILTER_NAME
public static final java.lang.String CUSTOM_FILTER_NAME
CUSTOM_FILTER_TYPE
,
and CUSTOM_FILTER_OPTIONS
pairs.
public static final java.lang.String CUSTOM_FILTER_TYPE
public static final java.lang.String CUSTOM_FILTER_OPTIONS
KeyValueOutputFilter.configure()
method of custom filter class.
Constructor Detail |
---|
public KeyValuePrinter(KeyValueCollection options, KeyValueCollection data)
options
- global options for the printerdata
- individual key-filter mappingMethod Detail |
---|
public static KeyValuePrinter getDefaultPrinter()
public static void setDefaultPrinter(KeyValuePrinter printer)
printer
- default (singleton) printerpublic java.lang.String toString(KeyValueCollection kvList)
kvList
- list to output
public java.lang.String toString(java.lang.String key, java.lang.Object value)
key
- name of value to convertvalue
- value to convert
public void appendValue(java.lang.StringBuffer buf, KeyValueCollection list)
buf
- buffer to append the list tolist
- list to outputpublic void appendValue(java.lang.StringBuffer buf, KeyValueCollection list, int indent)
buf
- buffer to append the list tolist
- list to outputpublic void appendValue(java.lang.StringBuffer buf, java.lang.String key, java.lang.Object value)
buf
- buffer to append the list tokey
- name of value to convertvalue
- value to convertpublic void appendValue(java.lang.StringBuffer buf, java.lang.String key, java.lang.Object value, int indent)
buf
- buffer to append the list tokey
- name of value to convertvalue
- value to convert
|
Platform SDK Java 8.5 API Reference | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |