Platform SDK Java 8.5 API Reference

com.genesyslab.platform.commons.collections.processor
Class KeyValueAbstractOutputFilter

java.lang.Object
  extended by com.genesyslab.platform.commons.collections.processor.KeyValueAbstractOutputFilter
All Implemented Interfaces:
KeyValueOutputFilter

public abstract class KeyValueAbstractOutputFilter
extends java.lang.Object
implements KeyValueOutputFilter

"Base" implementation of KeyValueOutputFilter interface. Default behavior of this class is to print everything.

See Also:
KeyValuePrinter

Constructor Summary
KeyValueAbstractOutputFilter()
           
 
Method Summary
 java.lang.String appendKeyValuePair(java.lang.StringBuffer buf, java.lang.String key, java.lang.Object value, KeyValuePrinterContext context)
          "Entry point" method for key-value pair output.
 void configure(KeyValueCollection options)
          Configuration for filter.
protected  java.lang.String doAppendKeyValuePair(java.lang.StringBuffer buf, java.lang.String key, java.lang.Object value, KeyValuePrinterContext context)
          Default implementation of key-value pair output.
protected  void doAppendPairKey(java.lang.StringBuffer buf, java.lang.String key, java.lang.Object value, KeyValuePrinterContext context)
          Default implementation of pair key output.
protected  void doAppendPairKeyType(java.lang.StringBuffer buf, java.lang.String key, java.lang.Object value, KeyValuePrinterContext context)
          Default implementation of pair key type mark output.
protected  java.lang.String doAppendPairValue(java.lang.StringBuffer buf, java.lang.String key, java.lang.Object value, KeyValuePrinterContext context)
          Default implementation of value output function.
 boolean isFilteredOut(java.lang.String key, java.lang.Object value, KeyValuePrinterContext context)
          Evaluates that some key-value pair should be skipped on log print or not.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

KeyValueAbstractOutputFilter

public KeyValueAbstractOutputFilter()
Method Detail

configure

public void configure(KeyValueCollection options)
Configuration for filter.

Specified by:
configure in interface KeyValueOutputFilter
Parameters:
options - Collection with configuration data

isFilteredOut

public boolean isFilteredOut(java.lang.String key,
                             java.lang.Object value,
                             KeyValuePrinterContext context)
Evaluates that some key-value pair should be skipped on log print or not. Printing logic is following:
     if (! isFilteredOut(key, value, context)) {
         String rest = appendKeyValuePair(
             buffer, key, value, context
         );
         
         if (rest != null) {
             buffer.append(rest);
         }
     }
 

Specified by:
isFilteredOut in interface KeyValueOutputFilter
Parameters:
key - Pair string key
value - Pair value
context - Printer context
Returns:
false (by default) - any key-value should be printed

appendKeyValuePair

public java.lang.String appendKeyValuePair(java.lang.StringBuffer buf,
                                           java.lang.String key,
                                           java.lang.Object value,
                                           KeyValuePrinterContext context)
"Entry point" method for key-value pair output. It is called right after false value return from isFilteredOut(...).

This default implementation of the interface method performs following operations:

"Small hierarchy of protected methods" means following default implementation of key-value formatting logic:
   - doAppendKeyValuePair() = doAppendPairKey() + " = " + doAppendPairValue()
     -- doAppendPairKey() = "'" + <key> + "'" + doAppendPairKeyType()
       --- doAppendPairKeyType() = " [int]" || " [str]" || " [bstr]" || " [lst]" || ...
     -- doAppendPairValue() = <int-value> || "<str-value>" || ...
 
So, if it is required to have some filter to hide passwords or part of credit card numbers, to truncate long binary data, or unpack some structures, etc, it is enough to override doAppendPairValue() and perform appropriate value output.

Output of inner KeyValueCollection lists is a special case. This method does not print it recursively. Inner lists are handled outside. It outputs some prefix and, optionally, returns some value for delayed output. Returned value will be appended right after inner list filtering.

Specified by:
appendKeyValuePair in interface KeyValueOutputFilter
Parameters:
buf - Output buffer
key - Pair string key
value - Pair value
context - Printer context
Returns:
value for delayed output or null
See Also:
isFilteredOut(String, Object, KeyValuePrinterContext)

doAppendKeyValuePair

protected java.lang.String doAppendKeyValuePair(java.lang.StringBuffer buf,
                                                java.lang.String key,
                                                java.lang.Object value,
                                                KeyValuePrinterContext context)
Default implementation of key-value pair output. It is called from default implementation of appendKeyValuePair() right after indentation, and by default it outputs following components:
   doAppendPairKey() + " = " + doAppendPairValue()
 

Parameters:
buf - Output buffer
key - Pair string key
value - Pair value
context - Printer context
Returns:
value for delayed output or null
See Also:
appendKeyValuePair(StringBuffer, String, Object, KeyValuePrinterContext), doAppendPairKey(StringBuffer, String, Object, KeyValuePrinterContext), doAppendPairValue(StringBuffer, String, Object, KeyValuePrinterContext)

doAppendPairKey

protected void doAppendPairKey(java.lang.StringBuffer buf,
                               java.lang.String key,
                               java.lang.Object value,
                               KeyValuePrinterContext context)
Default implementation of pair key output. It is called from default implementation of doAppendKeyValuePair(), and by default it outputs following components:
   "'" + <key> + "'" + doAppendPairKeyType()
 

Parameters:
buf - Output buffer
key - Pair string key
value - Pair value
context - Printer context
See Also:
doAppendKeyValuePair(StringBuffer, String, Object, KeyValuePrinterContext), doAppendPairKeyType(StringBuffer, String, Object, KeyValuePrinterContext)

doAppendPairKeyType

protected void doAppendPairKeyType(java.lang.StringBuffer buf,
                                   java.lang.String key,
                                   java.lang.Object value,
                                   KeyValuePrinterContext context)
Default implementation of pair key type mark output. It is called from default implementation of doAppendKeyValuePair(), and by default if value is not null it outputs following values depending on value type:
   " [int]" || " [str]" || " [bstr]" || " [lst]" || ...
 

Parameters:
buf - Output buffer
key - Pair string key
value - Pair value
context - Printer context
See Also:
doAppendPairKey(StringBuffer, String, Object, KeyValuePrinterContext)

doAppendPairValue

protected java.lang.String doAppendPairValue(java.lang.StringBuffer buf,
                                             java.lang.String key,
                                             java.lang.Object value,
                                             KeyValuePrinterContext context)
Default implementation of value output function. So, custom filter should override this method to perform required value representation.

Special note about output of KeyValueCollection values: this method outputs some prefix before context and returns some tail (or null). Contained values will be handled separately with specified filters set and increased indent.

Parameters:
buf - Output buffer
key - Pair string key
value - Pair value
context - Printer context
Returns:
value for delayed output or null
See Also:
Hex.appendBytesStr(StringBuffer, byte[], boolean, int)

Platform SDK Java 8.5 API Reference

Send comments on this topicTechpubs.webadmin@genesys.com.
Document version: 8.5.302.00
Copyright © 2006–2017 Genesys Telecommunications Laboratories, Inc. All rights reserved.