signature:
public class StenoSerializationHelper { /** * Complete writing the Steno JSON wrapper .
 * @ since 1.8.0
 * @ param event Instance of < code > ILoggingEvent < / code > .
 * @ param eventName The name of the event .
 * @ param jsonGenerator < code > JsonGenerator < / code > instance .
 * @ param objectMapper < code > ObjectMapper < / code > instance .
 * @ param encoder < code > StenoEncoder < / code > instance .
 * @ throws IOException If writing JSON fails . */
public static void endStenoWrapper ( final ILoggingEvent event , final String eventName , final JsonGenerator jsonGenerator , final ObjectMapper objectMapper , final StenoEncoder encoder ) throws IOException { } }

implementation: endStenoWrapper ( event , eventName , Collections . emptyList ( ) , Collections . emptyList ( ) , jsonGenerator , objectMapper , encoder ) ;


signature:
public class StenoSerializationHelper { /** * Complete writing the Steno JSON wrapper .
 * @ since 1.8.0
 * @ param event Instance of < code > ILoggingEvent < / code > .
 * @ param eventName The name of the event .
 * @ param contextKeys The < code > List < / code > of context keys .
 * @ param contextValues The < code > List < / code > of context values .
 * @ param jsonGenerator < code > JsonGenerator < / code > instance .
 * @ param objectMapper < code > ObjectMapper < / code > instance .
 * @ param encoder < code > StenoEncoder < / code > instance .
 * @ throws IOException If writing JSON fails . */
public static void endStenoWrapper ( final ILoggingEvent event , final String eventName , @ Nullable final List < String > contextKeys , @ Nullable final List < Object > contextValues , final JsonGenerator jsonGenerator , final ObjectMapper objectMapper , final StenoEncoder encoder ) throws IOException { } }

implementation:
jsonGenerator . writeFieldName ( "context" ) ; objectMapper . writeValue ( jsonGenerator , StenoSerializationHelper . createContext ( encoder , event , objectMapper , contextKeys , contextValues ) ) ; jsonGenerator . writeObjectField ( "id" , StenoSerializationHelper . createId ( ) ) ; jsonGenerator . writeObjectField ( "version" , "0" ) ; jsonGenerator . writeEndObject ( ) ; // End log message
jsonGenerator . writeRaw ( '\n' ) ; jsonGenerator . flush ( ) ;


signature:
public class StenoSerializationHelper { /** * Write specified key - value pairs into the current block .
 * @ since 1.7.0
 * @ param keys The < code > List < / code > of keys .
 * @ param values The < code > List < / code > of values .
 * @ param jsonGenerator < code > JsonGenerator < / code > instance .
 * @ param objectMapper < code > ObjectMapper < / code > instance .
 * @ param encoder Instance of < code > StenoEncoder < / code > .
 * @ throws IOException If writing JSON fails . */
public static void writeKeyValuePairs ( @ Nullable final List < String > keys , @ Nullable final List < Object > values , final JsonGenerator jsonGenerator , final ObjectMapper objectMapper , final StenoEncoder encoder ) throws IOException { } }

implementation: if ( keys != null ) { final int contextValuesLength = values == null ? 0 : values . size ( ) ; for ( int i = 0 ; i < keys . size ( ) ; ++ i ) { final String key = keys . get ( i ) ; if ( i >= contextValuesLength ) { jsonGenerator . writeObjectField ( key , null ) ; } else { final Object value = values . get ( i ) ; if ( isSimpleType ( value ) ) { jsonGenerator . writeObjectField ( key , value ) ; } else { jsonGenerator . writeFieldName ( key ) ; objectMapper . writeValue ( jsonGenerator , value ) ; } } } }


signature:
public class StenoSerializationHelper { /** * Write a < code > Throwable < / code > via < code > IThrowableProxy < / code > as JSON .
 * @ since 1.7.0
 * @ param throwableProxy Throwable to serialize
 * @ param jsonGenerator < code > JsonGenerator < / code > instance .
 * @ param objectMapper < code > ObjectMapper < / code > instance .
 * @ throws IOException If writing JSON fails . */
public static void writeThrowable ( final IThrowableProxy throwableProxy , final JsonGenerator jsonGenerator , final ObjectMapper objectMapper ) throws IOException { } }

implementation: if ( throwableProxy != null ) { jsonGenerator . writeObjectFieldStart ( "exception" ) ; serializeThrowable ( throwableProxy , jsonGenerator , objectMapper ) ; jsonGenerator . writeEndObject ( ) ; }


signature:
public class StenoSerializationHelper { /** * This function assumes the field object has already been started for this throwable , this only fills in
 * the fields in the ' exception ' or equivalent object and does not create the field in the containing object .
 * @ since 1.7.0
 * @ param throwableProxy Throwable to serialize
 * @ param jsonGenerator < code > JsonGenerator < / code > instance after exception object is started
 * @ param objectMapper < code > ObjectMapper < / code > instance .
 * @ throws IOException If writing the < code > Throwable < / code > as JSON fails . */
public static void serializeThrowable ( final IThrowableProxy throwableProxy , final JsonGenerator jsonGenerator , final ObjectMapper objectMapper ) throws IOException { } }

implementation:
jsonGenerator . writeStringField ( "type" , throwableProxy . getClassName ( ) ) ; jsonGenerator . writeStringField ( "message" , throwableProxy . getMessage ( ) ) ; jsonGenerator . writeArrayFieldStart ( "backtrace" ) ; for ( final StackTraceElementProxy ste : throwableProxy . getStackTraceElementProxyArray ( ) ) { jsonGenerator . writeString ( ste . toString ( ) ) ; } jsonGenerator . writeEndArray ( ) ; jsonGenerator . writeObjectFieldStart ( "data" ) ; if ( throwableProxy instanceof ThrowableProxy ) { final JsonNode jsonNode = objectMapper . valueToTree ( ( ( ThrowableProxy ) throwableProxy ) . getThrowable ( ) ) ; for ( final Iterator < Map . Entry < String , JsonNode > > iterator = jsonNode . fields ( ) ; iterator . hasNext ( ) ; ) { final Map . Entry < String , JsonNode > field = iterator . next ( ) ; jsonGenerator . writeFieldName ( field . getKey ( ) ) ; objectMapper . writeValue ( jsonGenerator , field . getValue ( ) ) ; } } // Although Throwable has a final getSuppressed which cannot return a null array , the
// proxy in Logback provides no such guarantees .
if ( throwableProxy . getSuppressed ( ) != null && throwableProxy . getSuppressed ( ) . length > 0 ) { jsonGenerator . writeArrayFieldStart ( "suppressed" ) ; for ( final IThrowableProxy suppressed : throwableProxy . getSuppressed ( ) ) { jsonGenerator . writeStartObject ( ) ; serializeThrowable ( suppressed , jsonGenerator , objectMapper ) ; jsonGenerator . writeEndObject ( ) ; } jsonGenerator . writeEndArray ( ) ; } if ( throwableProxy . getCause ( ) != null ) { jsonGenerator . writeObjectFieldStart ( "cause" ) ; serializeThrowable ( throwableProxy . getCause ( ) , jsonGenerator , objectMapper ) ; jsonGenerator . writeEndObject ( ) ; } jsonGenerator . writeEndObject ( ) ;


signature:
public class StenoSerializationHelper { /** * Create a context based on the < code > StenoEncoder < / code > configuration .
 * @ since 1.7.0
 * @ param encoder The < code > StenoEncoder < / code > instance .
 * @ param event The < code > ILoggingEvent < / code > instance .
 * @ param objectMapper < code > ObjectMapper < / code > instance .
 * @ param contextKeys The additional user provided context keys .
 * @ param contextValues The additional user provided context values matching the keys .
 * @ return < code > Map < / code > with event context . */
public static Map < String , Object > createContext ( final StenoEncoder encoder , final ILoggingEvent event , final ObjectMapper objectMapper , @ Nullable final List < String > contextKeys , @ Nullable final List < Object > contextValues ) { } }

implementation: final Map < String , Object > context = new LinkedHashMap < > ( ) ; if ( encoder . isInjectContextHost ( ) ) { context . put ( "host" , StenoSerializationHelper . HOST_CONVERTER . convert ( event ) ) ; } if ( encoder . isInjectContextProcess ( ) ) { context . put ( "processId" , StenoSerializationHelper . PROCESS_CONVERTER . convert ( event ) ) ; } if ( encoder . isInjectContextThread ( ) ) { context . put ( "threadId" , StenoSerializationHelper . THREAD_CONVERTER . convert ( event ) ) ; } if ( encoder . isInjectContextLogger ( ) ) { if ( encoder . isCompressLoggerName ( ) ) { context . put ( "logger" , StenoSerializationHelper . CONDENSED_LOGGER_CONVERTER . convert ( event ) ) ; } else { context . put ( "logger" , StenoSerializationHelper . LOGGER_CONVERTER . convert ( event ) ) ; } } if ( encoder . isInjectContextFile ( ) ) { context . put ( "file" , StenoSerializationHelper . FILE_CONVERTER . convert ( event ) ) ; } if ( encoder . isInjectContextClass ( ) ) { context . put ( "class" , StenoSerializationHelper . CLASS_CONVERTER . convert ( event ) ) ; } if ( encoder . isInjectContextMethod ( ) ) { context . put ( "method" , StenoSerializationHelper . METHOD_CONVERTER . convert ( event ) ) ; } if ( encoder . isInjectContextLine ( ) ) { context . put ( "line" , StenoSerializationHelper . LINE_CONVERTER . convert ( event ) ) ; } final Iterator < String > injectContextMdcIterator = encoder . iteratorForInjectContextMdc ( ) ; while ( injectContextMdcIterator . hasNext ( ) ) { final String key = injectContextMdcIterator . next ( ) ; final String value = event . getMDCPropertyMap ( ) . get ( key ) ; context . put ( key , value ) ; } if ( contextKeys != null ) { final int contextValuesLength = contextValues == null ? 0 : contextValues . size ( ) ; for ( int i = 0 ; i < contextKeys . size ( ) ; ++ i ) { final String key = contextKeys . get ( i ) ; final Object value = i < contextValuesLength ? contextValues . get ( i ) : null ; context . put ( key , value ) ; } } return context ;


signature:
public class StenoSerializationHelper { /** * Determine if an object represents a primitive Json type . These include
 * instances of < code > Number < / code > , < code > String < / code > and < code > Boolean < / code > .
 * @ since 1.7.0
 * @ param obj The < code > Object < / code > to analyze .
 * @ return < code > True < / code > if and only if the < code > Object < / code > is a simple type . */
public static boolean isSimpleType ( @ Nullable final Object obj ) { } }

implementation: if ( obj == null ) { return true ; } final Class < ? > objClass = obj . getClass ( ) ; if ( String . class . isAssignableFrom ( objClass ) ) { return true ; } if ( Number . class . isAssignableFrom ( objClass ) ) { return true ; } if ( Boolean . class . isAssignableFrom ( objClass ) ) { return true ; } return false ;


signature:
public class LoggerFactory { /** * Return a Steno < code > Logger < / code > for a context class .
 * @ param clazz The < code > Logger < / code > context class .
 * @ return Steno < code > Logger < / code > instance . */
public static Logger getLogger ( final Class < ? > clazz ) { } }

implementation: return new Logger ( org . slf4j . LoggerFactory . getLogger ( clazz ) ) ;


signature:
public class LoggerFactory { /** * Return a rate limited Steno < code > Logger < / code > for a context class .
 * @ param clazz The < code > Logger < / code > context class .
 * @ param duration Minimum time between log message output .
 * @ return Steno < code > Logger < / code > instance . */
public static Logger getRateLimitLogger ( final Class < ? > clazz , final Duration duration ) { } }

implementation: return new RateLimitLogger ( org . slf4j . LoggerFactory . getLogger ( clazz ) , duration ) ;


signature:
public class LoggerFactory { /** * Return a Steno < code > Logger < / code > for a context name .
 * @ param name The < code > Logger < / code > context name .
 * @ return Steno < code > Logger < / code > instance . */
public static Logger getLogger ( final String name ) { } }

implementation: return new Logger ( org . slf4j . LoggerFactory . getLogger ( name ) ) ;


signature:
public class LoggerFactory { /** * Return a rate limited Steno < code > Logger < / code > for a context name .
 * @ param name The < code > Logger < / code > context name .
 * @ param duration Minimum time between log message output .
 * @ return Steno < code > Logger < / code > instance . */
public static Logger getRateLimitLogger ( final String name , final Duration duration ) { } }

implementation: return new RateLimitLogger ( org . slf4j . LoggerFactory . getLogger ( name ) , duration ) ;


signature:
public class LoggerFactory { /** * Return a rate limited Steno < code > Logger < / code > for an already instantiated < code > org . slf4j . Logger < / code >
 * instance .
 * @ param logger The < code > org . slf4j . Logger < / code > instance .
 * @ param duration Minimum time between log message output .
 * @ return Steno < code > Logger < / code > instance . */
public static Logger getRateLimitLogger ( final org . slf4j . Logger logger , final Duration duration ) { } }

implementation: return new RateLimitLogger ( logger , duration ) ;


signature:
public class StenoEncoder { /** * Enables / Disables redaction support when serializing complex objects . Redacted fields / properties marked
 * with the @ LogRedact annotation will be output as a string with the value " { @ code < REDACTED > } " .
 * @ param redactEnabled - true to filter out redacted fields
 * @ since 1.1.0 */
public void setRedactEnabled ( final boolean redactEnabled ) { } }

implementation: final SimpleFilterProvider simpleFilterProvider = new SimpleFilterProvider ( ) ; if ( redactEnabled ) { simpleFilterProvider . addFilter ( RedactionFilter . REDACTION_FILTER_ID , new RedactionFilter ( ! _redactNull ) ) ; } else { simpleFilterProvider . addFilter ( RedactionFilter . REDACTION_FILTER_ID , SimpleBeanPropertyFilter . serializeAllExcept ( Collections . < String > emptySet ( ) ) ) ; } _objectMapper . setFilterProvider ( simpleFilterProvider ) ; _redactEnabled = redactEnabled ;


signature:
public class StenoEncoder { /** * Enables / Disables output of null for redacted fields when serializing complex objects .
 * @ param redactNull - true to redact null values , assuming redactEnabled is true
 * @ since 1.1.0 */
public void setRedactNull ( final boolean redactNull ) { } }

implementation: if ( _redactEnabled ) { final SimpleFilterProvider simpleFilterProvider = new SimpleFilterProvider ( ) ; simpleFilterProvider . addFilter ( RedactionFilter . REDACTION_FILTER_ID , new RedactionFilter ( ! redactNull ) ) ; _objectMapper . setFilterProvider ( simpleFilterProvider ) ; } _redactNull = redactNull ;


signature:
public class KeyValueSerializationHelper { /** * Create a context based on the < code > KeyValueEncoder < / code > configuration .
 * @ since 1.9.0
 * @ param encoder The < code > KeyValueEncoder < / code > instance .
 * @ param event The < code > ILoggingEvent < / code > instance .
 * @ param contextKeys The additional user provided context keys .
 * @ param contextValues The additional user provided context values matching the keys .
 * @ return < code > Map < / code > with event context . */
public static Map < String , Object > createContext ( final KeyValueEncoder encoder , final ILoggingEvent event , @ Nullable final List < String > contextKeys , @ Nullable final List < Object > contextValues ) { } }

implementation: final Map < String , Object > context = new LinkedHashMap < > ( ) ; context . put ( "host" , KeyValueSerializationHelper . HOST_CONVERTER . convert ( event ) ) ; context . put ( "processId" , KeyValueSerializationHelper . PROCESS_CONVERTER . convert ( event ) ) ; context . put ( "threadId" , KeyValueSerializationHelper . THREAD_CONVERTER . convert ( event ) ) ; if ( contextKeys != null ) { final int contextValuesLength = contextValues == null ? 0 : contextValues . size ( ) ; for ( int i = 0 ; i < contextKeys . size ( ) ; ++ i ) { final String key = contextKeys . get ( i ) ; final Object value = i < contextValuesLength ? contextValues . get ( i ) : null ; context . put ( key , value ) ; } } return context ;


signature:
public class BaseLoggingEncoder { /** * { @ inheritDoc } */
@ Override public byte [ ] encode ( final ILoggingEvent event ) { } }

implementation: final Marker marker = event . getMarker ( ) ; final String name = event . getMessage ( ) ; final Object [ ] argumentArray = event . getArgumentArray ( ) ; String output ; try { output = encodeAsString ( event , marker , name , argumentArray ) ; } catch ( final EncodingException ee ) { output = encodeAsString ( event , ee ) ; } return encodeString ( output ) ;


signature:
public class BaseLoggingEncoder { /** * Determine whether the < code > marker < / code > represents an array event .
 * @ since 1.0.0
 * @ param marker The < code > Marker < / code > instance to evaluate .
 * @ return True if and only if < code > marker < / code > represents an array event . */
protected boolean isArrayStenoEvent ( @ Nullable final Marker marker ) { } }

implementation: return marker != null && marker . contains ( StenoMarker . ARRAY_MARKER ) ;


signature:
public class BaseLoggingEncoder { /** * Determine whether the < code > marker < / code > represents a JSON array event .
 * @ since 1.0.4
 * @ param marker The < code > Marker < / code > instance to evaluate .
 * @ return True if and only if < code > marker < / code > represents a JSON array event . */
protected boolean isArrayJsonStenoEvent ( @ Nullable final Marker marker ) { } }

implementation: return marker != null && marker . contains ( StenoMarker . ARRAY_JSON_MARKER ) ;


signature:
public class BaseLoggingEncoder { /** * Determine whether the < code > marker < / code > represents a map event .
 * @ since 1.0.4
 * @ param marker The < code > Marker < / code > instance to evaluate .
 * @ return True if and only if < code > marker < / code > represents an array event . */
protected boolean isMapStenoEvent ( @ Nullable final Marker marker ) { } }

implementation: return marker != null && marker . contains ( StenoMarker . MAP_MARKER ) ;


signature:
public class BaseLoggingEncoder { /** * Determine whether the < code > marker < / code > represents a JSON map event .
 * @ since 1.0.4
 * @ param marker The < code > Marker < / code > instance to evaluate .
 * @ return True if and only if < code > marker < / code > represents a JSON map event . */
protected boolean isMapJsonStenoEvent ( @ Nullable final Marker marker ) { } }

implementation: return marker != null && marker . contains ( StenoMarker . MAP_JSON_MARKER ) ;


signature:
public class BaseLoggingEncoder { /** * Determine whether the < code > marker < / code > represents an object event .
 * @ since 1.1.0
 * @ param marker The < code > Marker < / code > instance to evaluate .
 * @ return True if and only if < code > marker < / code > represents an object event . */
protected boolean isObjectStenoEvent ( @ Nullable final Marker marker ) { } }

implementation: return marker != null && marker . contains ( StenoMarker . OBJECT_MARKER ) ;


signature:
public class BaseLoggingEncoder { /** * Determine whether the < code > marker < / code > represents a JSON object event .
 * @ since 1.1.0
 * @ param marker The < code > Marker < / code > instance to evaluate .
 * @ return True if and only if < code > marker < / code > represents a JSON object event . */
protected boolean isObjectJsonStenoEvent ( @ Nullable final Marker marker ) { } }

implementation: return marker != null && marker . contains ( StenoMarker . OBJECT_JSON_MARKER ) ;


signature:
public class BaseLoggingEncoder { /** * Determine whether the < code > marker < / code > represents a lists event .
 * @ since 1.3.0
 * @ param marker The < code > Marker < / code > instance to evaluate .
 * @ return True if and only if < code > marker < / code > represents a lists event . */
protected boolean isListsStenoEvent ( @ Nullable final Marker marker ) { } }

implementation: return marker != null && marker . contains ( StenoMarker . LISTS_MARKER ) ;


signature:
public class RateLimitLogBuilder { /** * Generate a Steno log compatible representation .
 * @ since 1.9.0
 * @ return Steno log compatible representation . */
@ LogValue public Object toLogValue ( ) { } }

implementation: return LogValueMapFactory . < String , Object > builder ( ) . put ( "logBuilder" , _logBuilder ) . put ( "duration" , _duration ) . put ( "lastLogTime" , _lastLogTime ) . put ( "skipped" , _skipped ) . build ( ) ;


signature:
public class ObjectSerialziationStrategy { /** * Serialize an event .
 * @ param event The event .
 * @ param eventName The event name .
 * @ param data The message data < code > Object < / code > .
 * @ return Serialization of message as a < code > String < / code > .
 * @ throws Exception Serialization may throw any < code > Exception < / code > . */
public String serialize ( final ILoggingEvent event , final String eventName , @ Nullable final Object data ) throws Exception { } }

implementation: final String jsonData = _objectMapper . writeValueAsString ( data ) ; return _objectAsJsonStrategy . serialize ( event , eventName , jsonData ) ;


signature:
public class KeyValueEncoder { /** * Create a format < code > String < / code > compatible with < code > MessageFormatter < / code > .
 * @ param name The name .
 * @ param keys The argument keys .
 * @ return The format < code > String < / code > . */
protected String buildFormatString ( @ Nullable final String name , @ Nullable final String [ ] keys ) { } }

implementation: final String effectiveName = name == null ? _logEventName : name ; final StringWriter stringWriter = new StringWriter ( ) ; stringWriter . append ( "name=\"" ) . append ( effectiveName ) . append ( "\"" ) ; if ( keys != null && keys . length > 0 ) { for ( final String key : keys ) { stringWriter . append ( ", " ) . append ( key ) . append ( "=\"{}\"" ) ; } } return stringWriter . toString ( ) ;


signature:
public class KeyValueEncoder { /** * Escape all < code > String < / code > instances .
 * @ param values Arguments to encode .
 * @ return Encoded arguments . */
protected Object [ ] escapeStringValues ( final Object [ ] values ) { } }

implementation:
final Object [ ] escapedValues = new Object [ values . length ] ; for ( int i = 0 ; i < values . length ; i ++ ) { Object value = values [ i ] ; // Instance of check implies value is not null
if ( value instanceof String ) { value = ( ( String ) value ) . replaceAll ( "\"" , "\\\\\"" ) ; } escapedValues [ i ] = value ; } return escapedValues ;


signature:
public class KeyValueEncoder { /** * / * package private */
String createMessage ( final ILoggingEvent event , @ Nullable final String eventName , @ Nullable final String [ ] keys , @ Nullable final Object [ ] values ) { } }

implementation: final String formatString = buildFormatString ( eventName , keys ) ; final LoggingEventWrapper eventWrapper = new LoggingEventWrapper ( event , formatString , values ) ; return layout . doLayout ( eventWrapper ) ;


signature:
public class KeyValueEncoder { /** * / * package private */
Map < String , Object > createSafeContext ( final ILoggingEvent event ) { } }

implementation: return createSafeContext ( event , Collections . emptyList ( ) , Collections . emptyList ( ) ) ;


signature:
public class KeyValueEncoder { /** * / * package private */
Map < String , Object > createSafeContext ( final ILoggingEvent event , @ Nullable final List < String > contextKeys , @ Nullable final List < Object > contextValues ) { } }

implementation: return KeyValueSerializationHelper . createContext ( this , event , contextKeys , contextValues ) ;


signature:
public class LoggingEventWrapper { /** * Return the the message formatted with arguments . Implemented as suggested in :
 * http : / / jira . qos . ch / browse / LBCLASSIC - 47
 * @ return The formatted message . */
public String getFormattedMessage ( ) { } }

implementation: if ( _formattedMessage != null ) { return _formattedMessage ; } if ( _argumentArray != null ) { _formattedMessage = MessageFormatter . arrayFormat ( _message , _argumentArray ) . getMessage ( ) ; } else { _formattedMessage = _message ; } return _formattedMessage ;


signature:
public class RedactionFilter { /** * { @ inheritDoc }
 * @ deprecated Provided for compatibility with deprecated method in Jackson . */
@ Override @ Deprecated public void serializeAsField ( final Object pojo , final JsonGenerator jgen , final SerializerProvider prov , final BeanPropertyWriter writer ) throws Exception { } }

implementation:
if ( writer . getAnnotation ( LogRedact . class ) == null ) { super . serializeAsField ( pojo , jgen , prov , writer ) ; } else { // since 2.3
if ( _allowNull && writer . get ( pojo ) == null ) { super . serializeAsField ( pojo , jgen , prov , writer ) ; } else { jgen . writeStringField ( writer . getSerializedName ( ) . getValue ( ) , REDACTION_STRING ) ; } }


signature:
public class ObjectAsJsonSerialziationStrategy { /** * Serialize an event .
 * @ param event The event .
 * @ param eventName The event name .
 * @ param jsonData The message data as serialized JSON .
 * @ return Serialization of message as a < code > String < / code > .
 * @ throws Exception Serialization may throw any < code > Exception < / code > . */
public String serialize ( final ILoggingEvent event , final String eventName , final String jsonData ) throws Exception { } }

implementation:
final StringWriter jsonWriter = new StringWriter ( ) ; final JsonGenerator jsonGenerator = _jsonFactory . createGenerator ( jsonWriter ) ; // Start wrapper
StenoSerializationHelper . startStenoWrapper ( event , eventName , jsonGenerator , _objectMapper ) ; // Write event data
jsonGenerator . writeFieldName ( "data" ) ; if ( jsonData == null ) { jsonGenerator . writeStartObject ( ) ; jsonGenerator . writeEndObject ( ) ; } else { jsonGenerator . writeRawValue ( jsonData ) ; } // TODO ( vkoskela ) : Support writing null objects as - is via configuration [ ISSUE - 4]
// e . g . " data " : null - - although this is not supported by the current Steno specification
// Output throwable
StenoSerializationHelper . writeThrowable ( event . getThrowableProxy ( ) , jsonGenerator , _objectMapper ) ; // End wrapper
StenoSerializationHelper . endStenoWrapper ( event , eventName , jsonGenerator , _objectMapper , _encoder ) ; return jsonWriter . toString ( ) ;


signature:
public class AbstractStenoCallerConverter { /** * Retrieve the relevant caller data adjusted for Steno logger wrapping .
 * @ param loggingEvent The < code > ILoggingEvent < / code > instance .
 * @ return The relevant caller data adjusted for Steno logger wrapping . */
protected StackTraceElement getCallerData ( final ILoggingEvent loggingEvent ) { } }

implementation: final StackTraceElement [ ] callerData = loggingEvent . getCallerData ( ) ; if ( callerData != null ) { for ( int i = 0 ; i < callerData . length ; ++ i ) { final String callerClassName = callerData [ i ] . getClassName ( ) ; if ( ! callerClassName . startsWith ( STENO_CLASS_NAME_PREFIX ) ) { return callerData [ i ] ; } } } return null ;


signature:
public class ListsSerialziationStrategy { /** * Serialize an event .
 * @ param event The event .
 * @ param eventName The event name .
 * @ param dataKeys The message data keys .
 * @ param dataValues The message data values .
 * @ param contextKeys The message context keys .
 * @ param contextValues The message context values .
 * @ return Serialization of message as a < code > String < / code > .
 * @ throws Exception Serialization may throw any < code > Exception < / code > . */
public String serialize ( final ILoggingEvent event , final String eventName , @ Nullable final List < String > dataKeys , @ Nullable final List < Object > dataValues , @ Nullable final List < String > contextKeys , @ Nullable final List < Object > contextValues ) throws Exception { } }

implementation:
final StringWriter jsonWriter = new StringWriter ( ) ; final JsonGenerator jsonGenerator = _jsonFactory . createGenerator ( jsonWriter ) ; // Start wrapper
StenoSerializationHelper . startStenoWrapper ( event , eventName , jsonGenerator , _objectMapper ) ; // Write event data
jsonGenerator . writeObjectFieldStart ( "data" ) ; StenoSerializationHelper . writeKeyValuePairs ( dataKeys , dataValues , jsonGenerator , _objectMapper , _encoder ) ; jsonGenerator . writeEndObject ( ) ; // End ' data ' field
// Output throwable
StenoSerializationHelper . writeThrowable ( event . getThrowableProxy ( ) , jsonGenerator , _objectMapper ) ; // End wrapper
StenoSerializationHelper . endStenoWrapper ( event , eventName , contextKeys , contextValues , jsonGenerator , _objectMapper , _encoder ) ; return jsonWriter . toString ( ) ;


signature:
public class ArraySerialziationStrategy { /** * Serialize an event .
 * @ param event The event .
 * @ param eventName The event name .
 * @ param keys The message keys .
 * @ param values The message values .
 * @ return Serialization of message as a < code > String < / code > .
 * @ throws Exception Serialization may throw any < code > Exception < / code > . */
public String serialize ( final ILoggingEvent event , final String eventName , @ Nullable final String [ ] keys , @ Nullable final Object [ ] values ) throws Exception { } }

implementation:
final StringWriter jsonWriter = new StringWriter ( ) ; final JsonGenerator jsonGenerator = _jsonFactory . createGenerator ( jsonWriter ) ; // Start wrapper
StenoSerializationHelper . startStenoWrapper ( event , eventName , jsonGenerator , _objectMapper ) ; // Write event data
jsonGenerator . writeObjectFieldStart ( "data" ) ; final int argsLength = values == null ? 0 : values . length ; if ( keys != null ) { for ( int i = 0 ; i < keys . length ; i ++ ) { if ( i >= argsLength ) { jsonGenerator . writeObjectField ( keys [ i ] , null ) ; } else if ( StenoSerializationHelper . isSimpleType ( values [ i ] ) ) { jsonGenerator . writeObjectField ( keys [ i ] , values [ i ] ) ; } else { jsonGenerator . writeFieldName ( keys [ i ] ) ; _objectMapper . writeValue ( jsonGenerator , values [ i ] ) ; } } } jsonGenerator . writeEndObject ( ) ; // End ' data ' field
// Output throwable
StenoSerializationHelper . writeThrowable ( event . getThrowableProxy ( ) , jsonGenerator , _objectMapper ) ; // End wrapper
StenoSerializationHelper . endStenoWrapper ( event , eventName , jsonGenerator , _objectMapper , _encoder ) ; return jsonWriter . toString ( ) ;


signature:
public class SafeSerializationHelper { /** * Create a serialization safe context based on the < code > StenoEncoder < / code > configuration .
 * @ since 1.11.2
 * @ param encoder The < code > StenoEncoder < / code > instance .
 * @ param event The < code > ILoggingEvent < / code > instance .
 * @ param objectMapper < code > ObjectMapper < / code > instance .
 * @ return < code > Map < / code > with event context . */
public static Map < String , Object > createSafeContext ( final StenoEncoder encoder , final ILoggingEvent event , final ObjectMapper objectMapper ) { } }

implementation: return createSafeContext ( encoder , event , objectMapper , Collections . emptyList ( ) , Collections . emptyList ( ) ) ;


signature:
public class SafeSerializationHelper { /** * Create a serialization safe context based on the < code > StenoEncoder < / code > configuration .
 * @ since 1.11.2
 * @ param encoder The < code > StenoEncoder < / code > instance .
 * @ param event The < code > ILoggingEvent < / code > instance .
 * @ param objectMapper < code > ObjectMapper < / code > instance .
 * @ param contextKeys The additional user provided context keys .
 * @ param contextValues The additional user provided context values matching the keys .
 * @ return < code > Map < / code > with event context . */
public static Map < String , Object > createSafeContext ( final StenoEncoder encoder , final ILoggingEvent event , final ObjectMapper objectMapper , @ Nullable final List < String > contextKeys , @ Nullable final List < Object > contextValues ) { } }

implementation: return StenoSerializationHelper . createContext ( encoder , event , objectMapper , contextKeys , contextValues ) ;


signature:
public class SafeSerializationHelper { /** * Safely serialize a value .
 * @ since 1.11.2
 * @ param encoder The < code > StenoEncoder < / code > instance .
 * @ param value The < code > Object < / code > instance to safely serialize . */
public static void safeEncodeValue ( final StringBuilder encoder , @ Nullable final Object value ) { } }

implementation: if ( value == null ) { encoder . append ( "null" ) ; } else if ( value instanceof Map ) { safeEncodeMap ( encoder , ( Map < ? , ? > ) value ) ; } else if ( value instanceof List ) { safeEncodeList ( encoder , ( List < ? > ) value ) ; } else if ( value . getClass ( ) . isArray ( ) ) { safeEncodeArray ( encoder , value ) ; } else if ( value instanceof LogValueMapFactory . LogValueMap ) { safeEncodeLogValueMap ( encoder , ( LogValueMapFactory . LogValueMap ) value ) ; } else if ( value instanceof Throwable ) { safeEncodeThrowable ( encoder , ( Throwable ) value ) ; } else if ( StenoSerializationHelper . isSimpleType ( value ) ) { if ( value instanceof Boolean ) { encoder . append ( BooleanNode . valueOf ( ( Boolean ) value ) . toString ( ) ) ; } else if ( value instanceof Double ) { encoder . append ( DoubleNode . valueOf ( ( Double ) value ) . toString ( ) ) ; } else if ( value instanceof Float ) { encoder . append ( FloatNode . valueOf ( ( Float ) value ) . toString ( ) ) ; } else if ( value instanceof Long ) { encoder . append ( LongNode . valueOf ( ( Long ) value ) . toString ( ) ) ; } else if ( value instanceof Integer ) { encoder . append ( IntNode . valueOf ( ( Integer ) value ) . toString ( ) ) ; } else { encoder . append ( new TextNode ( value . toString ( ) ) . toString ( ) ) ; } } else { safeEncodeValue ( encoder , LogReferenceOnly . of ( value ) . toLogValue ( ) ) ; }


signature:
public class SafeSerializationHelper { /** * / * package private */
static void safeEncodeThrowable ( final StringBuilder encoder , final Throwable throwable ) { } }

implementation: encoder . append ( "{\"type\":\"" ) . append ( throwable . getClass ( ) . getName ( ) ) . append ( "\",\"message\":" ) ; safeEncodeValue ( encoder , throwable . getMessage ( ) ) ; encoder . append ( ",\"backtrace\":[" ) ; for ( final StackTraceElement ste : throwable . getStackTrace ( ) ) { safeEncodeValue ( encoder , ste . toString ( ) ) ; encoder . append ( "," ) ; } if ( throwable . getStackTrace ( ) . length == 0 ) { encoder . append ( "]" ) ; } else { encoder . setCharAt ( encoder . length ( ) - 1 , ']' ) ; } encoder . append ( ",\"data\":{" ) ; if ( throwable . getSuppressed ( ) . length > 0 ) { encoder . append ( "\"suppressed\":[" ) ; for ( final Throwable suppressed : throwable . getSuppressed ( ) ) { safeEncodeThrowable ( encoder , suppressed ) ; encoder . append ( "," ) ; } encoder . setCharAt ( encoder . length ( ) - 1 , ']' ) ; encoder . append ( "," ) ; } if ( throwable . getCause ( ) != null ) { encoder . append ( "\"cause\":" ) ; safeEncodeThrowable ( encoder , throwable . getCause ( ) ) ; encoder . append ( "," ) ; } if ( encoder . charAt ( encoder . length ( ) - 1 ) == ',' ) { encoder . setCharAt ( encoder . length ( ) - 1 , '}' ) ; } else { encoder . append ( "}" ) ; } encoder . append ( "}" ) ;


signature:
public class SafeSerializationHelper { /** * / * package private */
static void safeEncodeMap ( final StringBuilder encoder , final Map < ? , ? > valueAsMap ) { } }

implementation: encoder . append ( "{" ) ; for ( Map . Entry < ? , ? > entry : valueAsMap . entrySet ( ) ) { encoder . append ( "\"" ) . append ( entry . getKey ( ) . toString ( ) ) . append ( "\":" ) ; safeEncodeValue ( encoder , entry . getValue ( ) ) ; encoder . append ( "," ) ; } if ( valueAsMap . isEmpty ( ) ) { encoder . append ( "}" ) ; } else { encoder . setCharAt ( encoder . length ( ) - 1 , '}' ) ; }


signature:
public class SafeSerializationHelper { /** * / * package private */
static void safeEncodeList ( final StringBuilder encoder , final List < ? > valueAsList ) { } }

implementation: encoder . append ( "[" ) ; for ( Object listValue : valueAsList ) { safeEncodeValue ( encoder , listValue ) ; encoder . append ( "," ) ; } if ( valueAsList . isEmpty ( ) ) { encoder . append ( "]" ) ; } else { encoder . setCharAt ( encoder . length ( ) - 1 , ']' ) ; }


signature:
public class SafeSerializationHelper { /** * / * package private */
static void safeEncodeArray ( final StringBuilder encoder , final Object value ) { } }

implementation: encoder . append ( "[" ) ; for ( int i = 0 ; i < Array . getLength ( value ) ; ++ i ) { safeEncodeValue ( encoder , Array . get ( value , i ) ) ; encoder . append ( "," ) ; } if ( Array . getLength ( value ) == 0 ) { encoder . append ( "]" ) ; } else { encoder . setCharAt ( encoder . length ( ) - 1 , ']' ) ; }


signature:
public class SafeSerializationHelper { /** * / * package private */
static void safeEncodeLogValueMap ( final StringBuilder encoder , final LogValueMapFactory . LogValueMap logValueMap ) { } }

implementation: final Map < String , Object > safeLogValueMap = new LinkedHashMap < > ( ) ; final Optional < Object > target = logValueMap . getTarget ( ) ; safeLogValueMap . put ( "_id" , target . isPresent ( ) ? Integer . toHexString ( System . identityHashCode ( target . get ( ) ) ) : null ) ; safeLogValueMap . put ( "_class" , target . isPresent ( ) ? target . get ( ) . getClass ( ) . getName ( ) : null ) ; safeEncodeValue ( encoder , safeLogValueMap ) ;


signature:
public class DeleteImpl { /** * If values ' size hit { @ link # MAX } , then query will be split ( size % MAX + [ 1 ] )
 * { @ inheritDoc } */
@ Override public int delete ( List < ? > values , boolean shouldNotify ) throws StormException { } }

implementation: final CachedTable table = super . getCachedTable ( values ) ; FieldHolder primaryKey ; try { primaryKey = getPrimaryKey ( table ) ; } catch ( NoPrimaryKeyFoundException e ) { throw new StormException ( e ) ; } final List < Selection > selections = new ArrayList < > ( ) ; final int size = values . size ( ) ; int x = size / MAX ; final int steps = x == 0 ? 1 : size % MAX != 0 ? x + 1 : x ; if ( steps > 1 ) { for ( int i = 0 , end = MAX , start = 0 ; i < steps ; i ++ , start = end , end += Math . min ( size - ( MAX * i ) , MAX ) ) { selections . add ( getSelection ( primaryKey , values . subList ( start , end ) ) ) ; } } else { selections . add ( getSelection ( primaryKey , values ) ) ; } int result = 0 ; beginTransaction ( ) ; try { for ( Selection selection : selections ) { result += deleteInner ( table . getTableName ( ) , selection ) ; } setTransactionSuccessful ( ) ; } finally { endTransaction ( ) ; } if ( shouldNotify && result > 0 ) { manager . notifyChange ( table . getNotificationUri ( ) ) ; } return result ;


signature:
public class BeejuJUnitRule { /** * Initialise the warehouse path .
 * This method can be overridden to provide additional initialisations .
 * @ throws Throwable If the initialisation fails . */
protected void init ( ) throws Throwable { } }

implementation: metastoreLocation = temporaryFolder . newFolder ( "metastore" ) ; conf . setVar ( ConfVars . METASTOREWAREHOUSE , metastoreLocation . getAbsolutePath ( ) ) ;


signature:
public class BeejuJUnitRule { /** * Create a new database with the specified name .
 * @ param databaseName Database name .
 * @ throws TException If an error occurs creating the database . */
public void createDatabase ( String databaseName ) throws TException { } }

implementation: HiveMetaStoreClient client = new HiveMetaStoreClient ( conf ( ) ) ; String databaseFolder = new File ( temporaryFolder . getRoot ( ) , databaseName ) . toURI ( ) . toString ( ) ; try { client . createDatabase ( new Database ( databaseName , null , databaseFolder , null ) ) ; } finally { client . close ( ) ; }


signature:
public class AbsObjectPool { /** * we should clear it */
protected void checkMappings ( int arrayPosition ) { } }

implementation: final int index = positions . indexOfValue ( arrayPosition ) ; if ( index >= 0 ) { positions . removeAt ( index ) ; }


signature:
public class DatabaseManager { /** * Opens new SQLite connection and closes previous if it was not closed
 * @ param callbacks { @ link ru . noties . storm . SQLiteOpenCallbacks } to be called
 * after main < code > create < / code > , < code > update < / code > and < code > open < / code >
 * methods ware executed
 * @ throws SQLiteException if there was an error during operation */
public void open ( @ Nullable SQLiteOpenCallbacks callbacks ) throws SQLiteException { } }

implementation: if ( isOpen ( ) ) { close ( ) ; } initDB ( Storm . getApplicationContext ( ) , mInfo . name , mInfo . version , new ArrayList < > ( mCached . values ( ) ) , mInfo . pragma , callbacks ) ;


signature:
public class DatabaseManager { /** * Counts number of rows in specified query . If { @ link ru . noties . storm . query . Selection } is null
 * then counts all rows in Class table .
 * @ param clazz table class
 * @ param selection { @ link ru . noties . storm . query . Selection }
 * @ return number of rows from executed query */
public int count ( Class < ? > clazz , @ Nullable Selection selection ) { } }

implementation: final String tableName = getTableName ( clazz ) ; final boolean hasSelection = selection != null ; final Cursor cursor = mDataBase . query ( tableName , new String [ ] { "count(1)" } , hasSelection ? selection . getSelection ( ) : null , hasSelection ? selection . getSelectionArgs ( ) : null , null , null , null , "1" ) ; if ( cursor == null ) { return 0 ; } final int result ; if ( cursor . moveToFirst ( ) ) { result = cursor . getInt ( 0 ) ; } else { result = 0 ; } cursor . close ( ) ; return result ;


signature:
public class Storm { /** * The main entry point for the Storm library .
 * Should be called only once - Application ' s onCreate ( ) is a good start
 * This method won ' t open any SQLite database connections . See { @ link DatabaseManager # open ( ) }
 * @ param applicationContext { @ link android . content . Context } of an { @ link android . app . Application }
 * @ param isDebug flag to indicate that current build is debug ,
 * may be helpful when debugging as Storm
 * will throw { @ link java . lang . Exception } more aggressively
 * @ throws java . lang . AssertionError if this method was already called */
public void init ( Context applicationContext , boolean isDebug ) { } }

implementation: if ( mIsInitCalled ) { throw new AssertionError ( "init() has already been called" ) ; } mApplicationContext = applicationContext ; mFieldValueGetterFactory = new FieldValueGetterFactory ( ) ; mFieldValueSetterFactory = new FieldValueSetterFactory ( ) ; mCursorValueProviderFactory = new CursorValueProviderFactory ( ) ; mContentValuesSetterFactory = new ContentValuesSetterFactory ( ) ; mIsDebug = isDebug ; mIsInitCalled = true ;


signature:
public class Storm { /** * Registers { @ link ru . noties . storm . InstanceCreator } for the specified { @ link java . lang . Class } .
 * It may be helpful and performance wise if , for example , an { @ link java . lang . Object }
 * has no empty constructor or has very specific constructor ,
 * or if construction of an Object via Reflection is not desired
 * ( default { @ link ru . noties . storm . InstanceCreator } for
 * all objects is { @ link ru . noties . storm . ReflectionInstanceCreator } )
 * @ param clazz to be registered
 * @ param ics instance of { @ link ru . noties . storm . InstanceCreator }
 * @ param < T > Type of object that { @ link ru . noties . storm . InstanceCreator } will handle
 * @ param < IC > { @ link ru . noties . storm . InstanceCreator } of type T */
public < T , IC extends InstanceCreator < T > > void registerInstanceCreator ( @ NonNull Class < T > clazz , @ NonNull IC ics ) { } }

implementation: mInstanceCreators . register ( clazz , ics ) ;


signature:
public class Storm { /** * Registers Type serializer ( aka not supported SQLite types ) { @ link ru . noties . storm . sd . AbsSerializer }
 * As a matter of fact { @ link ru . noties . storm . sd . AbsSerializer } has only one method that
 * indicates what SQLite type ( { @ link ru . noties . storm . FieldType } ) this type will represent .
 * Methods < code > serialize < / code > and < code > deserialize < / code >
 * are not in the inheritance tree . This is done due to the autoboxing issue .
 * If you wish to supply your own TypeSerializer you should definitely extend one of the following :
 * { @ link ru . noties . storm . sd . ShortSerializer }
 * { @ link ru . noties . storm . sd . IntSerializer }
 * { @ link ru . noties . storm . sd . LongSerializer }
 * { @ link ru . noties . storm . sd . FloatSerializer }
 * { @ link ru . noties . storm . sd . DoubleSerializer }
 * { @ link ru . noties . storm . sd . StringSerializer }
 * { @ link ru . noties . storm . sd . ByteArraySerializer }
 * { @ link ru . noties . storm . sd . BooleanSerializer }
 * Additionally you could easily register Serialization
 * for an Enum { @ link ru . noties . storm . sd . EnumSerializer }
 * @ param who Class to be registered
 * @ param serializer { @ link ru . noties . storm . sd . AbsSerializer }
 * @ param < T > Type to be linked with */
public < T > void registerTypeSerializer ( Class < T > who , AbsSerializer < T > serializer ) { } }

implementation:
// noinspection unchecked
mSerializers . put ( who , ( AbsSerializer < Object > ) serializer ) ;


signature:
public class SaveAttrsUtility { /** * Parses the save attr .
 * @ param cell
 * the cell
 * @ param saveCommentsMap
 * the save comments map
 * @ return the string */
public static String parseSaveAttr ( final Cell cell , final Map < String , String > saveCommentsMap ) { } }

implementation: if ( cell != null ) { String key = cell . getSheet ( ) . getSheetName ( ) + "!" + CellUtility . getCellIndexNumberKey ( cell . getColumnIndex ( ) , cell . getRowIndex ( ) ) ; String saveAttr = null ; if ( saveCommentsMap != null ) { saveAttr = ParserUtility . getStringBetweenBracket ( saveCommentsMap . get ( key ) ) ; } if ( ( saveAttr == null ) && ( cell . getCellTypeEnum ( ) == CellType . STRING ) ) { saveAttr = SaveAttrsUtility . parseSaveAttrString ( cell . getStringCellValue ( ) ) ; } if ( ( saveAttr != null ) && ( ! saveAttr . isEmpty ( ) ) ) { return TieConstants . CELL_ADDR_PRE_FIX + cell . getColumnIndex ( ) + "=" + saveAttr + "," ; } } return "" ;


signature:
public class SaveAttrsUtility { /** * Save data to object in context .
 * @ param context
 * the context
 * @ param saveAttr
 * the save attr
 * @ param strValue
 * the str value
 * @ param engine
 * the engine */
public static void saveDataToObjectInContext ( final Map < String , Object > context , final String saveAttr , final String strValue , final ExpressionEngine engine ) { } }

implementation: int index = saveAttr . lastIndexOf ( '.' ) ; if ( index > 0 ) { String strObject = saveAttr . substring ( 0 , index ) ; String strMethod = saveAttr . substring ( index + 1 ) ; strObject = TieConstants . METHOD_PREFIX + strObject + TieConstants . METHOD_END ; Object object = CommandUtility . evaluate ( strObject , context , engine ) ; CellControlsUtility . setObjectProperty ( object , strMethod , strValue , true ) ; }


signature:
public class SaveAttrsUtility { /** * reload the data from context to websheet row .
 * @ param context
 * context .
 * @ param fullSaveAttr
 * full saveattr .
 * @ param row
 * row .
 * @ param engine
 * engine . */
public static void refreshSheetRowFromContext ( final Map < String , Object > context , final String fullSaveAttr , final Row row , final ExpressionEngine engine ) { } }

implementation: if ( ! fullSaveAttr . startsWith ( TieConstants . CELL_ADDR_PRE_FIX ) ) { return ; } int ipos = fullSaveAttr . indexOf ( '=' ) ; if ( ipos > 0 ) { String columnIndex = fullSaveAttr . substring ( 1 , ipos ) ; String saveAttr = fullSaveAttr . substring ( ipos + 1 ) ; Cell cell = row . getCell ( Integer . parseInt ( columnIndex ) ) ; if ( cell . getCellTypeEnum ( ) != CellType . FORMULA ) { CommandUtility . evaluateNormalCells ( cell , TieConstants . METHOD_PREFIX + saveAttr + TieConstants . METHOD_END , context , engine ) ; } }


signature:
public class SaveAttrsUtility { /** * Parses the save attr string .
 * @ param strValue
 * the str value
 * @ return the string */
public static String parseSaveAttrString ( final String strValue ) { } }

implementation: if ( strValue != null ) { int first = strValue . indexOf ( TieConstants . METHOD_PREFIX ) ; int last = strValue . lastIndexOf ( TieConstants . METHOD_PREFIX ) ; int end = strValue . lastIndexOf ( TieConstants . METHOD_END ) ; if ( ( first >= 0 ) && ( first == last ) && ( end > 1 ) ) { return strValue . substring ( first + 2 , end ) ; } } return "" ;


signature:
public class SaveAttrsUtility { /** * Gets the save attr list from row .
 * @ param row
 * the row
 * @ return the save attr list from row */
public static String getSaveAttrListFromRow ( final Row row ) { } }

implementation: if ( row != null ) { Cell cell = row . getCell ( TieConstants . HIDDEN_SAVE_OBJECTS_COLUMN ) ; if ( cell != null ) { String str = cell . getStringCellValue ( ) ; if ( ( str != null ) && ( ! str . isEmpty ( ) ) ) { return str ; } } } return null ;


signature:
public class SaveAttrsUtility { /** * Gets the save attr from list .
 * @ param columnIndex
 * the column index
 * @ param saveAttrs
 * the save attrs
 * @ return the save attr from list */
public static String getSaveAttrFromList ( final int columnIndex , final String saveAttrs ) { } }

implementation: if ( ( saveAttrs != null ) && ( ! saveAttrs . isEmpty ( ) ) ) { String str = TieConstants . CELL_ADDR_PRE_FIX + columnIndex + "=" ; int istart = saveAttrs . indexOf ( str ) ; if ( istart >= 0 ) { int iend = saveAttrs . indexOf ( ',' , istart ) ; if ( iend > istart ) { return saveAttrs . substring ( istart + str . length ( ) , iend ) ; } } } return null ;


signature:
public class SaveAttrsUtility { /** * get the columnIndex from saveAttr . saveAttr format as : $ columnIndex = xxxxx
 * @ param saveAttr
 * saveAttr
 * @ return columnIndex String */
public static String getColumnIndexFromSaveAttr ( final String saveAttr ) { } }

implementation: if ( ( saveAttr != null ) && ( ! saveAttr . isEmpty ( ) ) ) { int iend = saveAttr . indexOf ( '=' ) ; if ( iend > 0 ) { int istart = saveAttr . indexOf ( '$' ) ; if ( iend > istart ) { return saveAttr . substring ( istart + 1 , iend ) ; } } } return null ;


signature:
public class SaveAttrsUtility { /** * Checks if is checks for save attr .
 * @ param cell
 * the cell
 * @ return true , if is checks for save attr */
public static boolean isHasSaveAttr ( final Cell cell ) { } }

implementation: Cell saveAttrCell = cell . getRow ( ) . getCell ( TieConstants . HIDDEN_SAVE_OBJECTS_COLUMN ) ; if ( saveAttrCell != null ) { return isHasSaveAttr ( cell , saveAttrCell . getStringCellValue ( ) ) ; } return false ;


signature:
public class SaveAttrsUtility { /** * Checks if is checks for save attr .
 * @ param cell
 * the cell
 * @ param saveAttrs
 * the save attrs
 * @ return true , if is checks for save attr */
public static boolean isHasSaveAttr ( final Cell cell , final String saveAttrs ) { } }

implementation: if ( cell != null ) { int columnIndex = cell . getColumnIndex ( ) ; String str = TieConstants . CELL_ADDR_PRE_FIX + columnIndex + "=" ; if ( ( saveAttrs != null ) && ( saveAttrs . indexOf ( str ) >= 0 ) ) { return true ; } } return false ;


signature:
public class SaveAttrsUtility { /** * Sets the save objects in hidden column .
 * @ param row
 * the row
 * @ param saveAttr
 * the save attr */
public static void setSaveObjectsInHiddenColumn ( final Row row , final String saveAttr ) { } }

implementation: Cell cell = row . getCell ( TieConstants . HIDDEN_SAVE_OBJECTS_COLUMN , MissingCellPolicy . CREATE_NULL_AS_BLANK ) ; cell . setCellValue ( saveAttr ) ;


signature:
public class SaveAttrsUtility { /** * Sets the save attrs for sheet .
 * @ param sheet
 * the sheet
 * @ param minRowNum
 * the min row num
 * @ param maxRowNum
 * the max row num
 * @ param saveCommentsMap
 * the save comments map */
public static void setSaveAttrsForSheet ( final Sheet sheet , final int minRowNum , final int maxRowNum , final Map < String , String > saveCommentsMap ) { } }

implementation: for ( Row row : sheet ) { int rowIndex = row . getRowNum ( ) ; if ( ( rowIndex >= minRowNum ) && ( rowIndex <= maxRowNum ) ) { setSaveAttrsForRow ( row , saveCommentsMap ) ; } }


signature:
public class SaveAttrsUtility { /** * Sets the save attrs for row .
 * @ param row
 * the row
 * @ param saveCommentsMap
 * the save comments map */
public static void setSaveAttrsForRow ( final Row row , final Map < String , String > saveCommentsMap ) { } }

implementation: StringBuilder saveAttr = new StringBuilder ( ) ; for ( Cell cell : row ) { String sAttr = parseSaveAttr ( cell , saveCommentsMap ) ; if ( ! sAttr . isEmpty ( ) ) { saveAttr . append ( sAttr ) ; } } if ( saveAttr . length ( ) > 0 ) { SaveAttrsUtility . setSaveObjectsInHiddenColumn ( row , saveAttr . toString ( ) ) ; }


signature:
public class SaveAttrsUtility { /** * Prepare context and attrs for cell .
 * @ param poiCell
 * the poi cell
 * @ param fullName
 * the full name
 * @ param cellHelper
 * the cell helper
 * @ return the string */
public static String prepareContextAndAttrsForCell ( Cell poiCell , String fullName , CellHelper cellHelper ) { } }

implementation: if ( fullName == null ) { return null ; } String saveAttrList = SaveAttrsUtility . getSaveAttrListFromRow ( poiCell . getRow ( ) ) ; if ( saveAttrList != null ) { String saveAttr = SaveAttrsUtility . getSaveAttrFromList ( poiCell . getColumnIndex ( ) , saveAttrList ) ; if ( saveAttr != null ) { cellHelper . restoreDataContext ( fullName ) ; return saveAttr ; } } return null ;


signature:
public class PieChart { /** * ( non - Javadoc )
 * @ see org . tiefaces . components . websheet . chart . objects . ChartObject #
 * getSerListFromCtObjChart ( java . lang . Object ) */
@ SuppressWarnings ( "rawtypes" ) @ Override public List getSerListFromCtObjChart ( final Object ctObjChart ) { } }

implementation: if ( ctObjChart instanceof CTPieChart ) { return ( ( CTPieChart ) ctObjChart ) . getSerList ( ) ; } return this . getEmptySerlist ( ) ;


signature:
public class PieChart { /** * ( non - Javadoc )
 * @ see org . tiefaces . components . websheet . chart . objects . ChartObject #
 * getShapePropertiesFromCTSer ( java . lang . Object ) */
@ Override public final CTShapeProperties getShapePropertiesFromCTSer ( final Object ctObjSer ) { } }

implementation: if ( ctObjSer instanceof CTPieSer ) { return ( ( CTPieSer ) ctObjSer ) . getSpPr ( ) ; } return null ;


signature:
public class PieChart { /** * ( non - Javadoc )
 * @ see org . tiefaces . components . websheet . chart . objects . ChartObject #
 * getCTNumDataSourceFromCTSer ( java . lang . Object ) */
@ Override public final CTNumDataSource getCTNumDataSourceFromCTSer ( final Object ctObjSer ) { } }

implementation: if ( ctObjSer instanceof CTPieSer ) { return ( ( CTPieSer ) ctObjSer ) . getVal ( ) ; } return null ;


signature:
public class PieChart { /** * ( non - Javadoc )
 * @ see org . tiefaces . components . websheet . chart . objects . ChartObject #
 * getDPtListFromCTSer ( java . lang . Object ) */
@ Override public final List < CTDPt > getDPtListFromCTSer ( final Object ctObjSer ) { } }

implementation:
if ( ctObjSer instanceof CTPieSer ) { List < CTDPt > dptList = ( ( CTPieSer ) ctObjSer ) . getDPtList ( ) ; if ( dptList == null ) { // return empty list instead of null for pie .
// this will ensure pie create valueColorList in serial object .
dptList = new ArrayList < > ( ) ; } return dptList ; } return this . getEmptyDptlist ( ) ;


signature:
public class ConfigCommand { /** * convert string to int ( length ) .
 * @ param lengthStr
 * String .
 * @ return int length . */
protected final int calcLength ( final String lengthStr ) { } }

implementation: try { return Integer . parseInt ( lengthStr ) ; } catch ( Exception ex ) { LOG . log ( Level . FINE , "canot calcLength :" + ex . getLocalizedMessage ( ) , ex ) ; } return 0 ;


signature:
public class TieSheetNumberConverter { /** * ( non - Javadoc )
 * @ see javax . faces . convert . Converter # getAsObject ( javax . faces . context .
 * FacesContext , javax . faces . component . UIComponent , java . lang . String ) */
@ Override public final Object getAsObject ( final FacesContext context , final UIComponent component , final String value ) { } }

implementation: Double doubleValue = 0.0 ; String symbol = "" ; String strValue = value ; try { symbol = ( String ) component . getAttributes ( ) . get ( TieConstants . CELL_DATA_SYMBOL ) ; if ( ( symbol != null ) && ( symbol . equals ( TieConstants . CELL_FORMAT_PERCENTAGE_SYMBOL ) && strValue != null ) ) { strValue = strValue . trim ( ) ; if ( strValue . endsWith ( TieConstants . CELL_FORMAT_PERCENTAGE_SYMBOL ) ) { doubleValue = Double . valueOf ( strValue . substring ( 0 , strValue . length ( ) - 1 ) ) / TieConstants . CELL_FORMAT_PERCENTAGE_VALUE ; strValue = doubleValue . toString ( ) ; } } } catch ( Exception ex ) { LOG . log ( Level . SEVERE , "error in getAsObject of TieSheetNumberConverter : " + ex . getLocalizedMessage ( ) , ex ) ; } return strValue ;


signature:
public class TieSheetNumberConverter { /** * Fmt number .
 * @ param d
 * the d
 * @ return the string */
private String fmtNumber ( final double d ) { } }

implementation: if ( Double . compare ( d % 1 , 0 ) == 0 ) { return String . format ( "%d" , ( int ) d ) ; } else { return String . format ( "%.2f" , d ) ; }


signature:
public class TieSheetNumberConverter { /** * ( non - Javadoc )
 * @ see javax . faces . convert . Converter # getAsString ( javax . faces . context .
 * FacesContext , javax . faces . component . UIComponent , java . lang . Object ) */
@ Override public final String getAsString ( final FacesContext context , final UIComponent component , final Object value ) { } }

implementation: String strValue = null ; String symbol = "" ; try { strValue = ( String ) value ; symbol = ( String ) component . getAttributes ( ) . get ( TieConstants . CELL_DATA_SYMBOL ) ; if ( ( symbol != null ) && ( symbol . equals ( TieConstants . CELL_FORMAT_PERCENTAGE_SYMBOL ) ) && ( value != null ) && ! ( ( String ) value ) . isEmpty ( ) ) { Double doubleValue = Double . valueOf ( ( String ) value ) * TieConstants . CELL_FORMAT_PERCENTAGE_VALUE ; strValue = fmtNumber ( doubleValue ) + TieConstants . CELL_FORMAT_PERCENTAGE_SYMBOL ; } } catch ( Exception ex ) { LOG . log ( Level . SEVERE , "error in getAsString of TieSheetNumberConverter : " + ex . getLocalizedMessage ( ) , ex ) ; } return strValue ;


signature:
public class SerialCellMap { /** * save the cell before serialize .
 * @ param out
 * outputstream .
 * @ throws IOException
 * io exception . */
private void writeObject ( final java . io . ObjectOutputStream out ) throws IOException { } }

implementation: saveList = new ArrayList < > ( ) ; for ( Map . Entry < Cell , String > entry : this . getMap ( ) . entrySet ( ) ) { saveList . add ( new SerialKey ( new SerialCellAddress ( entry . getKey ( ) ) , entry . getValue ( ) ) ) ; } out . defaultWriteObject ( ) ;


signature:
public class SerialCellMap { /** * recover the cell reference to the sheet .
 * @ param sheet sheet . */
public void recover ( final Sheet sheet ) { } }

implementation: if ( ! this . getMap ( ) . isEmpty ( ) ) { map . clear ( ) ; } for ( SerialKey entry : this . saveList ) { SerialCellAddress skey = entry . getKey ( ) ; map . put ( sheet . getRow ( skey . getRow ( ) ) . getCell ( skey . getColumn ( ) ) , entry . getValue ( ) ) ; }


signature:
public class ConfigBuildRef { /** * Put shift attrs .
 * @ param fullName
 * the full name
 * @ param attrs
 * the attrs
 * @ param unitRowsMapping
 * the unit rows mapping */
public final void putShiftAttrs ( final String fullName , final ConfigRangeAttrs attrs , final RowsMapping unitRowsMapping ) { } }

implementation: attrs . setUnitRowsMapping ( unitRowsMapping ) ; this . shiftMap . put ( fullName , attrs ) ;


signature:
public class TieWebSheetBean { /** * Set up workbook . Also create evaluation wrapper .
 * @ param pWb
 * workbook . */
public void setWb ( final Workbook pWb ) { } }

implementation: this . getSerialWb ( ) . setWb ( pWb ) ; this . wbWrapper = XSSFEvaluationWorkbook . create ( ( XSSFWorkbook ) pWb ) ;


signature:
public class TieWebSheetBean { /** * Return evaluation wrapper if needed .
 * @ return wbwrapper . */
public XSSFEvaluationWorkbook getWbWrapper ( ) { } }

implementation: if ( ( this . wbWrapper == null ) && ( this . getWb ( ) != null ) ) { this . wbWrapper = XSSFEvaluationWorkbook . create ( ( XSSFWorkbook ) this . getWb ( ) ) ; } return wbWrapper ;


signature:
public class TieWebSheetBean { /** * get formulaevaluator .
 * @ return formulaevaluator . */
public FormulaEvaluator getFormulaEvaluator ( ) { } }

implementation: if ( ( this . formulaEvaluator == null ) && ( this . getWb ( ) != null ) ) { this . formulaEvaluator = this . getWb ( ) . getCreationHelper ( ) . createFormulaEvaluator ( ) ; } return formulaEvaluator ;


signature:
public class TieWebSheetBean { /** * recalculate max coulumn count across sheets in the workbook . */
public void reCalcMaxColCounts ( ) { } }

implementation: if ( ( this . getSheetConfigMap ( ) == null ) || ( this . getSheetConfigMap ( ) . isEmpty ( ) ) ) { this . maxColCounts = 0 ; return ; } int maxColumns = 0 ; for ( SheetConfiguration sheetConfig : this . getSheetConfigMap ( ) . values ( ) ) { int counts = sheetConfig . getHeaderCellRange ( ) . getRightCol ( ) - sheetConfig . getHeaderCellRange ( ) . getLeftCol ( ) + 1 ; if ( maxColumns < counts ) { maxColumns = counts ; } } this . maxColCounts = maxColumns ;


signature:
public class TieWebSheetBean { /** * load web sheet from inputStream file with data object .
 * @ param inputStream
 * input stream file .
 * @ param pDataContext
 * data object .
 * @ return 1 ( success ) - 1 ( failed ) */
public int loadWebSheet ( final InputStream inputStream , final Map < String , Object > pDataContext ) { } }

implementation: return this . getHelper ( ) . getWebSheetLoader ( ) . loadWorkbook ( inputStream , pDataContext ) ;


signature:
public class TieWebSheetBean { /** * load web sheet from giving workbook with data object .
 * @ param pWb
 * workbook .
 * @ param pDataContext
 * data object .
 * @ return 1 ( success ) - 1 ( failed ) */
public int loadWebSheet ( final Workbook pWb , final Map < String , Object > pDataContext ) { } }

implementation: return this . getHelper ( ) . getWebSheetLoader ( ) . loadWorkbook ( pWb , pDataContext ) ;


signature:
public class TieWebSheetBean { /** * Triggered when user switch the tab . This will load different tab ( sheet )
 * as the current sheet .
 * @ param event
 * tabchange event . */
public void onTabChange ( final TabChangeEvent event ) { } }

implementation: String tabName = event . getTab ( ) . getTitle ( ) ; loadWorkSheetByTabName ( tabName ) ;


signature:
public class TieWebSheetBean { /** * load worksheet by tab name .
 * @ param tabName
 * tab name .
 * @ return 1 success . - 1 failed . */
public int loadWorkSheetByTabName ( final String tabName ) { } }

implementation: try { int sheetId = this . getHelper ( ) . getWebSheetLoader ( ) . findTabIndexWithName ( tabName ) ; if ( ( getSheetConfigMap ( ) != null ) && ( sheetId < getSheetConfigMap ( ) . size ( ) ) ) { this . getHelper ( ) . getWebSheetLoader ( ) . loadWorkSheet ( tabName ) ; setActiveTabIndex ( sheetId ) ; } return 1 ; } catch ( Exception ex ) { LOG . log ( Level . SEVERE , "loadWorkSheetByTabName failed. error = " + ex . getMessage ( ) , ex ) ; } return - 1 ;


signature:
public class TieWebSheetBean { /** * download current workbook . */
public void doExport ( ) { } }

implementation: try { String fileName = this . getExportFileName ( ) ; ByteArrayOutputStream out = new ByteArrayOutputStream ( ) ; this . getWb ( ) . write ( out ) ; InputStream stream = new BufferedInputStream ( new ByteArrayInputStream ( out . toByteArray ( ) ) ) ; exportFile = new DefaultStreamedContent ( stream , "application/force-download" , fileName ) ; } catch ( Exception e ) { LOG . log ( Level . SEVERE , "Error in export file : " + e . getLocalizedMessage ( ) , e ) ; } return ;


signature:
public class TieWebSheetBean { /** * Save the current workbooks . */
public void doSave ( ) { } }

implementation: this . setSubmitMde ( false ) ; if ( ! this . getHelper ( ) . getValidationHandler ( ) . preValidation ( ) ) { LOG . fine ( "Validation failded before saving" ) ; return ; } processSave ( ) ; this . getHelper ( ) . getWebSheetLoader ( ) . setUnsavedStatus ( RequestContext . getCurrentInstance ( ) , false ) ;


signature:
public class TieWebSheetBean { /** * Submit the current workbooks . */
public void doSubmit ( ) { } }

implementation:
this . setSubmitMde ( true ) ; // validation may behavior differently depend on the submit mode .
// e . g . when submit mode = false , empty fields or value not changed cells
// don ' t need to pass the validation rule . This allow partial save the form .
// when submit mode = true , all cells need to pass the validation .
if ( ! this . getHelper ( ) . getValidationHandler ( ) . preValidation ( ) ) { LOG . fine ( "Validation failed before saving" ) ; return ; } processSubmit ( ) ; this . getHelper ( ) . getWebSheetLoader ( ) . setUnsavedStatus ( RequestContext . getCurrentInstance ( ) , false ) ; this . setSubmitMde ( false ) ;


signature:
public class TieWebSheetBean { /** * populate component .
 * @ param event
 * component system event . */
public void populateComponent ( final ComponentSystemEvent event ) { } }

implementation: UIComponent component = event . getComponent ( ) ; int [ ] rowcol = CellUtility . getRowColFromComponentAttributes ( component ) ; int row = rowcol [ 0 ] ; int col = rowcol [ 1 ] ; FacesCell fcell = CellUtility . getFacesCellFromBodyRow ( row , col , this . getBodyRows ( ) , this . getCurrent ( ) . getCurrentTopRow ( ) , this . getCurrent ( ) . getCurrentLeftColumn ( ) ) ; CellControlsUtility . populateAttributes ( component , fcell , this . getCellDefaultControl ( ) ) ;


signature:
public class TieWebSheetBean { /** * Gets the current sheet config .
 * @ return the currentSheetConfig */
public SheetConfiguration getCurrentSheetConfig ( ) { } }

implementation: String currentTabName = this . getCurrent ( ) . getCurrentTabName ( ) ; if ( currentTabName == null ) { return null ; } return this . getSheetConfigMap ( ) . get ( currentTabName ) ;


signature:
public class TieWebSheetBean { /** * load the bean from saving .
 * @ param in
 * inputstream .
 * @ throws IOException
 * io exception . */
private void readObject ( final java . io . ObjectInputStream in ) throws IOException { } }

implementation: try { in . defaultReadObject ( ) ; recover ( ) ; } catch ( EncryptedDocumentException | ClassNotFoundException e ) { LOG . log ( Level . SEVERE , " error in readObject of serialWorkbook : " + e . getLocalizedMessage ( ) , e ) ; }


signature:
public class DateTimeCustomConverter { /** * ( non - Javadoc )
 * @ see javax . faces . convert . Converter # getAsObject ( javax . faces . context .
 * FacesContext , javax . faces . component . UIComponent , java . lang . String ) */
@ Override public final Object getAsObject ( final FacesContext context , final UIComponent component , final String value ) { } }

implementation: if ( value == null ) { return null ; } String pattern = ( String ) component . getAttributes ( ) . get ( "pattern" ) ; SimpleDateFormat formatter = new SimpleDateFormat ( pattern , getLocale ( context , component ) ) ; try { return formatter . parse ( value ) ; } catch ( Exception e ) { throw new ConverterException ( "ConverterException = " + e . getLocalizedMessage ( ) , e ) ; }


signature:
public class DateTimeCustomConverter { /** * ( non - Javadoc )
 * @ see javax . faces . convert . Converter # getAsString ( javax . faces . context .
 * FacesContext , javax . faces . component . UIComponent , java . lang . Object ) */
@ Override public final String getAsString ( final FacesContext context , final UIComponent component , final Object value ) { } }

implementation: if ( value == null ) { return "" ; } if ( value instanceof String ) { return ( String ) value ; } if ( context == null || component == null ) { throw new NullPointerException ( ) ; } try { String pattern = ( String ) component . getAttributes ( ) . get ( TieConstants . WIDGET_ATTR_PATTERN ) ; SimpleDateFormat dateFormat = new SimpleDateFormat ( pattern , getLocale ( context , component ) ) ; return dateFormat . format ( value ) ; } catch ( Exception e ) { throw new ConverterException ( e ) ; }


signature:
public class DateTimeCustomConverter { /** * Gets the locale .
 * @ param context
 * the context
 * @ param component
 * the component
 * @ return the locale */
private Locale getLocale ( final FacesContext context , final UIComponent component ) { } }

implementation: String localeStr = ( String ) component . getAttributes ( ) . get ( TieConstants . COMPONENT_ATTR_LOCALE ) ; if ( localeStr == null ) { return context . getViewRoot ( ) . getLocale ( ) ; } return Locale . forLanguageTag ( localeStr ) ;


signature:
public class TieWebSheetPicturesService { /** * Return picture to web front end .
 * @ return empty ( phase is render _ response ) or real picture ( browser
 * request ) . */
public StreamedContent getPicture ( ) { } }

implementation:
FacesContext context = FacesContext . getCurrentInstance ( ) ; if ( context . getCurrentPhaseId ( ) == PhaseId . RENDER_RESPONSE ) { // So , we ' re rendering the HTML . Return a stub StreamedContent so
// that it will generate right URL .
LOG . fine ( " return empty picture" ) ; return new DefaultStreamedContent ( ) ; } else { // So , browser is requesting the image . Return a real
// StreamedContent with the image bytes .
String pictureId = context . getExternalContext ( ) . getRequestParameterMap ( ) . get ( "pictureViewId" ) ; PictureData picData = ( PictureData ) FacesContext . getCurrentInstance ( ) . getExternalContext ( ) . getSessionMap ( ) . get ( pictureId ) ; FacesContext . getCurrentInstance ( ) . getExternalContext ( ) . getSessionMap ( ) . remove ( pictureId ) ; LOG . fine ( " return real picture and remove session" ) ; return new DefaultStreamedContent ( new ByteArrayInputStream ( picData . getData ( ) ) ) ; }


signature:
public class TieWebSheetBeanHelper { /** * Gets the cell helper .
 * @ return the cellHelper */
public final CellHelper getCellHelper ( ) { } }

implementation: if ( ( this . cellHelper == null ) && ( this . parent != null ) ) { this . cellHelper = new CellHelper ( parent ) ; } return cellHelper ;


signature:
public class TieWebSheetBeanHelper { /** * Gets the pic helper .
 * @ return the picHelper */
public final PicturesHelper getPicHelper ( ) { } }

implementation: if ( ( this . picHelper == null ) && ( this . parent != null ) ) { this . picHelper = new PicturesHelper ( parent ) ; } return picHelper ;


signature:
public class TieWebSheetBeanHelper { /** * Gets the validation handler .
 * @ return the validationHandler */
public final ValidationHandler getValidationHandler ( ) { } }

implementation: if ( ( this . validationHandler == null ) && ( this . parent != null ) ) { this . validationHandler = new ValidationHandler ( parent ) ; } return validationHandler ;


signature:
public class TieWebSheetBeanHelper { /** * Gets the chart helper .
 * @ return the chartHelper */
public final ChartHelper getChartHelper ( ) { } }

implementation: if ( ( this . chartHelper == null ) && ( this . parent != null ) ) { this . chartHelper = new ChartHelper ( parent ) ; } return chartHelper ;


signature:
public class ShiftFormulaUtility { /** * Convert shared formulas .
 * @ param ptgs
 * the ptgs
 * @ param shiftFormulaRef
 * the shift formula ref
 * @ return the ptg [ ] */
public static Ptg [ ] convertSharedFormulas ( final Ptg [ ] ptgs , final ShiftFormulaRef shiftFormulaRef ) { } }

implementation: List < Ptg > newPtgList = new ArrayList < > ( ) ; Object ptg ; for ( int k = 0 ; k < ptgs . length ; ++ k ) { ptg = ptgs [ k ] ; newPtgList . addAll ( Arrays . asList ( convertPtg ( ptgs , k , shiftFormulaRef , ptg ) ) ) ; } return newPtgList . toArray ( new Ptg [ newPtgList . size ( ) ] ) ;


signature:
public class ShiftFormulaUtility { /** * 3d ( reference to other sheet ) is not supported . only 2d ( within the
 * sheet ) is supported .
 * @ param ptg
 * input ptg object .
 * @ return - 1 if not a supported ptg . Int row number . */
public static int getFirstSupportedRowNumFromPtg ( final Object ptg ) { } }

implementation: int rCode = - 1 ; if ( ptg instanceof RefPtgBase ) { if ( ! ( ptg instanceof Ref3DPxg ) && ! ( ptg instanceof Ref3DPtg ) ) { rCode = ( ( RefPtgBase ) ptg ) . getRow ( ) ; } } else if ( ptg instanceof AreaPtgBase && ! ( ptg instanceof Area3DPxg ) && ! ( ptg instanceof Area3DPtg ) ) { rCode = ( ( AreaPtgBase ) ptg ) . getFirstRow ( ) ; } return rCode ;


signature:
public class ShiftFormulaUtility { /** * Convert ptg .
 * @ param ptgs
 * the ptgs
 * @ param position
 * the position
 * @ param shiftFormulaRef
 * the shift formula ref
 * @ param ptg
 * the ptg
 * @ return the ptg [ ] */
private static Ptg [ ] convertPtg ( final Ptg [ ] ptgs , final int position , final ShiftFormulaRef shiftFormulaRef , final Object ptg ) { } }

implementation:
byte originalOperandClass = - 1 ; if ( ! ( ( Ptg ) ptg ) . isBaseToken ( ) ) { originalOperandClass = ( ( Ptg ) ptg ) . getPtgClass ( ) ; } int currentRow ; currentRow = getFirstSupportedRowNumFromPtg ( ptg ) ; if ( ( currentRow >= 0 ) && shiftFormulaRef . getWatchList ( ) . contains ( currentRow ) ) { return convertPtgForWatchList ( ptgs , position , shiftFormulaRef , ptg , originalOperandClass , currentRow ) ; } // no need change ptg
if ( ( ptg instanceof AttrPtg ) && ( shiftFormulaRef . getFormulaChanged ( ) > 1 ) ) { AttrPtg newPtg = ( AttrPtg ) ptg ; if ( newPtg . isSum ( ) ) { FuncVarPtg fptg = FuncVarPtg . create ( "sum" , shiftFormulaRef . getFormulaChanged ( ) ) ; return singlePtg ( fptg , fptg . getPtgClass ( ) , shiftFormulaRef . getFormulaChanged ( ) ) ; } } return singlePtg ( ptg , originalOperandClass , shiftFormulaRef . getFormulaChanged ( ) ) ;


signature:
public class ShiftFormulaUtility { /** * Convert ptg for watch list .
 * @ param ptgs
 * the ptgs
 * @ param position
 * the position
 * @ param shiftFormulaRef
 * the shift formula ref
 * @ param ptg
 * the ptg
 * @ param originalOperandClass
 * the original operand class
 * @ param currentRow
 * the current row
 * @ return the ptg [ ] */
private static Ptg [ ] convertPtgForWatchList ( final Ptg [ ] ptgs , final int position , final ShiftFormulaRef shiftFormulaRef , final Object ptg , final byte originalOperandClass , final int currentRow ) { } }

implementation:
List < SerialRow > rowlist = getRowsList ( currentRow , shiftFormulaRef . getCurrentRowsMappingList ( ) ) ; if ( ( rowlist == null ) || ( rowlist . isEmpty ( ) ) ) { // no need change ptg
return singlePtg ( ptg , originalOperandClass , - 1 ) ; } shiftFormulaRef . setFormulaChanged ( 1 ) ; // one to one or has no round brackets
if ( ( rowlist . size ( ) == 1 ) || ( ( position + 1 ) >= ptgs . length ) || ! ( ptgs [ position + 1 ] instanceof ParenthesisPtg ) ) { // change ptg one to one
// return changed ptg
return singlePtg ( fixupRefRelativeRowOneToOne ( ptg , rowlist . get ( 0 ) . getRow ( ) ) , originalOperandClass , - 1 ) ; } shiftFormulaRef . setFormulaChanged ( rowlist . size ( ) ) ; return fixupRefRelativeRowOneToMany ( ptg , originalOperandClass , rowlist , ptgs , position ) ;


signature:
public class ShiftFormulaUtility { /** * Single ptg .
 * @ param ptg
 * the ptg
 * @ param originalOperandClass
 * the original operand class
 * @ param formulaChanged
 * the formula changed
 * @ return the ptg [ ] */
private static Ptg [ ] singlePtg ( final Object ptg , final byte originalOperandClass , final int formulaChanged ) { } }

implementation: Ptg [ ] newPtg = new Ptg [ 1 ] ; if ( originalOperandClass != ( - 1 ) ) { ( ( Ptg ) ptg ) . setClass ( originalOperandClass ) ; } Object ptgAfter = ptg ; if ( ptg instanceof FuncVarPtg ) { FuncVarPtg fptg = ( FuncVarPtg ) ptg ; if ( ( formulaChanged > 0 ) && ( fptg . getNumberOfOperands ( ) != formulaChanged ) ) { ptgAfter = FuncVarPtg . create ( ( ( FuncVarPtg ) ptg ) . getName ( ) , formulaChanged ) ; } } newPtg [ 0 ] = ( Ptg ) ptgAfter ; return newPtg ;


signature:
public class ShiftFormulaUtility { /** * Gets the rows list .
 * @ param currentRow
 * the current row
 * @ param currentRowsMappingList
 * the current rows mapping list
 * @ return the rows list */
private static List < SerialRow > getRowsList ( final int currentRow , final List < RowsMapping > currentRowsMappingList ) { } }

implementation: List < SerialRow > all = null ; int size = currentRowsMappingList . size ( ) ; for ( RowsMapping rowsmapping : currentRowsMappingList ) { List < SerialRow > current = rowsmapping . get ( currentRow ) ; if ( current != null ) { if ( size == 1 ) { return current ; } all = assembleRowsListFromRowsMapping ( all , current ) ; } } return all ;


signature:
public class ShiftFormulaUtility { /** * assemble rowslist from rowsmapping .
 * @ param all
 * list all rows .
 * @ param current
 * current row list .
 * @ return the list */
private static List < SerialRow > assembleRowsListFromRowsMapping ( final List < SerialRow > all , final List < SerialRow > current ) { } }

implementation: List < SerialRow > list ; if ( all == null ) { list = new ArrayList < > ( ) ; list . addAll ( current ) ; } else { list = all ; for ( SerialRow row : current ) { if ( ! all . contains ( row ) ) { list . add ( row ) ; } } } return list ;


signature:
public class ShiftFormulaUtility { /** * Fixup ref relative row one to one .
 * @ param ptg
 * the ptg
 * @ param newRow
 * the new row
 * @ return the object */
protected static Object fixupRefRelativeRowOneToOne ( final Object ptg , final Row newRow ) { } }

implementation: if ( ptg instanceof RefPtgBase ) { if ( ptg instanceof Ref3DPxg ) { Ref3DPxg ref3dPxg = ( Ref3DPxg ) ptg ; Ref3DPxg new3dpxg = new Ref3DPxg ( ref3dPxg . getExternalWorkbookNumber ( ) , new SheetIdentifier ( null , new NameIdentifier ( ref3dPxg . getSheetName ( ) , false ) ) , new CellReference ( newRow . getRowNum ( ) , ref3dPxg . getColumn ( ) ) ) ; new3dpxg . setClass ( ref3dPxg . getPtgClass ( ) ) ; new3dpxg . setColRelative ( ref3dPxg . isColRelative ( ) ) ; new3dpxg . setRowRelative ( ref3dPxg . isRowRelative ( ) ) ; new3dpxg . setLastSheetName ( ref3dPxg . getLastSheetName ( ) ) ; return new3dpxg ; } else { RefPtgBase refPtgBase = ( RefPtgBase ) ptg ; return new RefPtg ( newRow . getRowNum ( ) , refPtgBase . getColumn ( ) , refPtgBase . isRowRelative ( ) , refPtgBase . isColRelative ( ) ) ; } } else { if ( ptg instanceof Area3DPxg ) { Area3DPxg area3dPxg = ( Area3DPxg ) ptg ; Area3DPxg new3dpxg = new Area3DPxg ( area3dPxg . getExternalWorkbookNumber ( ) , new SheetIdentifier ( null , new NameIdentifier ( area3dPxg . getSheetName ( ) , false ) ) , area3dPxg . format2DRefAsString ( ) ) ; new3dpxg . setClass ( area3dPxg . getPtgClass ( ) ) ; new3dpxg . setFirstColRelative ( area3dPxg . isFirstColRelative ( ) ) ; new3dpxg . setLastColRelative ( area3dPxg . isLastColRelative ( ) ) ; int shiftRow = newRow . getRowNum ( ) - area3dPxg . getFirstRow ( ) ; new3dpxg . setFirstRow ( area3dPxg . getFirstRow ( ) + shiftRow ) ; new3dpxg . setLastRow ( area3dPxg . getLastRow ( ) + shiftRow ) ; new3dpxg . setFirstRowRelative ( area3dPxg . isFirstRowRelative ( ) ) ; new3dpxg . setLastRowRelative ( area3dPxg . isLastRowRelative ( ) ) ; new3dpxg . setLastSheetName ( area3dPxg . getLastSheetName ( ) ) ; return new3dpxg ; } else { AreaPtgBase areaPtgBase = ( AreaPtgBase ) ptg ; int shiftRow = newRow . getRowNum ( ) - areaPtgBase . getFirstRow ( ) ; return new AreaPtg ( areaPtgBase . getFirstRow ( ) + shiftRow , areaPtgBase . getLastRow ( ) + shiftRow , areaPtgBase . getFirstColumn ( ) , areaPtgBase . getLastColumn ( ) , areaPtgBase . isFirstRowRelative ( ) , areaPtgBase . isLastRowRelative ( ) , areaPtgBase . isFirstColRelative ( ) , areaPtgBase . isLastColRelative ( ) ) ; } }


signature:
public class ShiftFormulaUtility { /** * Change formula ptg by replace one ref with multiple ref . We require user
 * follow the rule to define dynamic formula . e . g . If cell reference in
 * formula maybe become multiple cells , then should use round brackets
 * around it .
 * Case 1 : = ( A1 ) + A2 + A3 Case 2 : = SUM ( ( A1 ) ) Case 3 : = SUM ( ( A1 : A2 ) )
 * @ param ptg
 * the ptg
 * @ param originalOperandClass
 * the original operand class
 * @ param rowList
 * the row list
 * @ param ptgs
 * the ptgs
 * @ param position
 * the position
 * @ return the ptg [ ] */
protected static Ptg [ ] fixupRefRelativeRowOneToMany ( final Object ptg , final byte originalOperandClass , final List < SerialRow > rowList , final Ptg [ ] ptgs , final int position ) { } }

implementation:
int size = rowList . size ( ) ; Ptg [ ] newPtg = null ; // if followedby valueoperator , then change to multiple ptg plus Add
// e . g . ( A1 ) - - > ( A1 + A2)
if ( isFollowedByValueOperator ( ptgs , position ) ) { if ( ptg instanceof RefPtgBase ) { newPtg = new Ptg [ size + 1 ] ; buildDynamicRowForRefPtgBase ( ptg , originalOperandClass , rowList , newPtg , false ) ; newPtg [ rowList . size ( ) ] = AddPtg . instance ; } } else { // otherwise change to mutiple ptg plus parenth
// e . g . SUM ( ( A1 ) ) - - > SUM ( ( A1 ) , ( A2 ) )
// SUM ( ( A1 : B1 ) ) - - > SUM ( ( A1 : B1 ) , ( A2 : B2 ) )
newPtg = new Ptg [ ( size * 2 ) - 1 ] ; if ( ptg instanceof RefPtgBase ) { buildDynamicRowForRefPtgBase ( ptg , originalOperandClass , rowList , newPtg , true ) ; } else { buildDynamicRowForAreaPtgBase ( ptg , originalOperandClass , rowList , newPtg ) ; } } return newPtg ;


signature:
public class ShiftFormulaUtility { /** * Builds the dynamic row for ref ptg base .
 * @ param ptg
 * the ptg
 * @ param originalOperandClass
 * the original operand class
 * @ param rowList
 * the row list
 * @ param newPtg
 * the new ptg
 * @ param includeParenthesis
 * the include parenthesis */
private static void buildDynamicRowForRefPtgBase ( final Object ptg , final byte originalOperandClass , final List < SerialRow > rowList , final Ptg [ ] newPtg , final boolean includeParenthesis ) { } }

implementation: RefPtgBase refPtg = ( RefPtgBase ) ptg ; int unitSize = 1 ; if ( includeParenthesis ) { unitSize = 2 ; } for ( int i = 0 ; i < rowList . size ( ) ; i ++ ) { Row row = rowList . get ( i ) . getRow ( ) ; if ( refPtg instanceof Ref3DPxg ) { Ref3DPxg ref3dPxg = ( Ref3DPxg ) refPtg ; Ref3DPxg new3dpxg = new Ref3DPxg ( ref3dPxg . getExternalWorkbookNumber ( ) , new SheetIdentifier ( null , new NameIdentifier ( ref3dPxg . getSheetName ( ) , false ) ) , new CellReference ( row . getRowNum ( ) , ref3dPxg . getColumn ( ) ) ) ; new3dpxg . setClass ( originalOperandClass ) ; new3dpxg . setColRelative ( ref3dPxg . isColRelative ( ) ) ; new3dpxg . setRowRelative ( ref3dPxg . isRowRelative ( ) ) ; new3dpxg . setLastSheetName ( ref3dPxg . getLastSheetName ( ) ) ; newPtg [ i * unitSize ] = new3dpxg ; } else { RefPtgBase refPtgBase = refPtg ; newPtg [ i * unitSize ] = new RefPtg ( row . getRowNum ( ) , refPtgBase . getColumn ( ) , refPtgBase . isRowRelative ( ) , refPtgBase . isColRelative ( ) ) ; } if ( ( unitSize == 2 ) && ( i < ( rowList . size ( ) - 1 ) ) ) { newPtg [ i * unitSize + 1 ] = ParenthesisPtg . instance ; } }


signature:
public class ShiftFormulaUtility { /** * Builds the dynamic row for area ptg base .
 * @ param ptg
 * the ptg
 * @ param originalOperandClass
 * the original operand class
 * @ param rowList
 * the row list
 * @ param newPtg
 * the new ptg */
private static void buildDynamicRowForAreaPtgBase ( final Object ptg , final byte originalOperandClass , final List < SerialRow > rowList , final Ptg [ ] newPtg ) { } }

implementation: AreaPtgBase areaPtg = ( AreaPtgBase ) ptg ; int originFirstRow = areaPtg . getFirstRow ( ) ; int originLastRow = areaPtg . getLastRow ( ) ; int unitSize = 2 ; for ( int i = 0 ; i < rowList . size ( ) ; i ++ ) { Row row = rowList . get ( i ) . getRow ( ) ; int shiftRow = row . getRowNum ( ) - originFirstRow ; if ( ptg instanceof Area3DPxg ) { Area3DPxg area3dPxg = ( Area3DPxg ) ptg ; Area3DPxg new3dpxg = new Area3DPxg ( area3dPxg . getExternalWorkbookNumber ( ) , new SheetIdentifier ( null , new NameIdentifier ( area3dPxg . getSheetName ( ) , false ) ) , area3dPxg . format2DRefAsString ( ) ) ; new3dpxg . setClass ( originalOperandClass ) ; new3dpxg . setFirstColRelative ( area3dPxg . isFirstColRelative ( ) ) ; new3dpxg . setLastColRelative ( area3dPxg . isLastColRelative ( ) ) ; new3dpxg . setFirstRow ( originFirstRow + shiftRow ) ; new3dpxg . setLastRow ( originLastRow + shiftRow ) ; new3dpxg . setFirstRowRelative ( area3dPxg . isFirstRowRelative ( ) ) ; new3dpxg . setLastRowRelative ( area3dPxg . isLastRowRelative ( ) ) ; new3dpxg . setLastSheetName ( area3dPxg . getLastSheetName ( ) ) ; newPtg [ i * unitSize ] = new3dpxg ; } else { AreaPtgBase areaPtgBase = ( AreaPtgBase ) ptg ; newPtg [ i * unitSize ] = new AreaPtg ( originFirstRow + shiftRow , originLastRow + shiftRow , areaPtgBase . getFirstColumn ( ) , areaPtgBase . getLastColumn ( ) , areaPtgBase . isFirstRowRelative ( ) , areaPtgBase . isLastRowRelative ( ) , areaPtgBase . isFirstColRelative ( ) , areaPtgBase . isLastColRelative ( ) ) ; } if ( i < ( rowList . size ( ) - 1 ) ) { newPtg [ i * unitSize + 1 ] = ParenthesisPtg . instance ; } }


signature:
public class ShiftFormulaUtility { /** * check is current ptg followed by valueOperationPtg . valueOperationPtg
 * include : Add , SubStract , Multiply , Divide etc .
 * @ param ptgs
 * the ptgs
 * @ param position
 * the position
 * @ return true , if is followed by value operator */
private static boolean isFollowedByValueOperator ( final Ptg [ ] ptgs , final int position ) { } }

implementation: for ( int i = position ; i < ptgs . length ; i ++ ) { Object ptg = ptgs [ position ] ; if ( ptg instanceof OperationPtg ) { return ptg instanceof ValueOperatorPtg ; } else if ( ptg instanceof AttrPtg ) { return false ; } } return false ;


signature:
public class ColorUtility { /** * retrieve background color for plot area .
 * @ param ctPlot
 * plot area instance .
 * @ param themeTable
 * theme table contain theme color .
 * @ return xssfcolor with alpha setting . */
public static XColor getBgColor ( final CTPlotArea ctPlot , final ThemesTable themeTable ) { } }

implementation: CTSolidColorFillProperties colorFill = null ; try { colorFill = ctPlot . getSpPr ( ) . getSolidFill ( ) ; } catch ( Exception ex ) { LOG . log ( Level . FINE , "No entry in bgcolor for solidFill" , ex ) ; } XColor xcolor = findAutomaticFillColor ( themeTable , colorFill ) ; if ( xcolor != null ) { return xcolor ; } else { return new XColor ( new XSSFColor ( Color . WHITE ) ) ; }


signature:
public class ColorUtility { /** * get line color of line chart from CTLineSer .
 * @ param index
 * line index .
 * @ param ctSpPr
 * the ct sp pr
 * @ param themeTable
 * themeTable .
 * @ param isLineColor
 * is line color .
 * @ return xcolor . */
public static XColor geColorFromSpPr ( final int index , final CTShapeProperties ctSpPr , final ThemesTable themeTable , final boolean isLineColor ) { } }

implementation: CTSolidColorFillProperties colorFill = null ; try { if ( isLineColor ) { colorFill = ctSpPr . getLn ( ) . getSolidFill ( ) ; } else { colorFill = ctSpPr . getSolidFill ( ) ; } } catch ( Exception ex ) { LOG . log ( Level . FINE , "No entry for solidFill" , ex ) ; } XColor xcolor = findAutomaticFillColor ( themeTable , colorFill ) ; if ( xcolor != null ) { return xcolor ; } else { return getXColorWithAutomaticFill ( index , themeTable ) ; }


signature:
public class ColorUtility { /** * Find automatic fill color .
 * @ param themeTable
 * the theme table
 * @ param colorFill
 * the color fill
 * @ return the x color */
private static XColor findAutomaticFillColor ( final ThemesTable themeTable , final CTSolidColorFillProperties colorFill ) { } }

implementation:
// if there ' s no solidFill , then use automaticFill color
if ( colorFill == null ) { return null ; } CTSchemeColor ctsColor = colorFill . getSchemeClr ( ) ; if ( ctsColor != null ) { return getXColorFromSchemeClr ( ctsColor , themeTable ) ; } else { CTSRgbColor ctrColor = colorFill . getSrgbClr ( ) ; if ( ctrColor != null ) { return getXColorFromRgbClr ( ctrColor ) ; } } return null ;


signature:
public class ColorUtility { /** * assemble xssfcolor with tint / lumoff / lummod / alpha to xcolor .
 * @ param bcolor
 * xssfcolor
 * @ param preTint
 * tint
 * @ param lumOff
 * lumOff
 * @ param lumMod
 * lummod
 * @ param alphaInt
 * alpha
 * @ return xcolor */
private static XColor assembleXcolor ( final XSSFColor bcolor , final double preTint , final int lumOff , final int lumMod , final int alphaInt ) { } }

implementation:
if ( bcolor == null ) { return null ; } double tint = preTint ; if ( Double . compare ( tint , 0 ) == 0 ) { // no preTint
if ( lumOff > 0 ) { tint = lumOff / MILLION_NUMBERS ; } else { if ( lumMod > 0 ) { tint = - 1 * ( lumMod / MILLION_NUMBERS ) ; } } } bcolor . setTint ( tint ) ; double alpha = 0 ; if ( alphaInt > 0 ) { alpha = alphaInt / MILLION_NUMBERS ; } return new XColor ( bcolor , alpha ) ;


signature:
public class ColorUtility { /** * retrieve xcolor from scheme color .
 * @ param ctsColor
 * scheme color
 * @ param themeTable
 * theme table
 * @ return xcolor */
private static XColor getXColorFromSchemeClr ( final CTSchemeColor ctsColor , final ThemesTable themeTable ) { } }

implementation: if ( ctsColor . getVal ( ) != null ) { return getXColorWithSchema ( ctsColor . getVal ( ) . toString ( ) , 0 , ctsColor , themeTable ) ; } return null ;


signature:
public class ColorUtility { /** * Get xcolor with color schema name . Normally the names are accent1 to 7.
 * Sometimes also have lumOff / lumMod / alphaInt setting .
 * @ param colorSchema
 * color schema
 * @ param preTint
 * tint
 * @ param ctsColor
 * ctsColor instance .
 * @ param themeTable
 * themeTable .
 * @ return xcolor . */
private static XColor getXColorWithSchema ( final String colorSchema , final double preTint , final CTSchemeColor ctsColor , final ThemesTable themeTable ) { } }

implementation: int colorIndex = getThemeIndexFromName ( colorSchema ) ; if ( colorIndex < 0 ) { return null ; } XSSFColor bcolor = themeTable . getThemeColor ( colorIndex ) ; if ( bcolor == null ) { return null ; } int lumOff = 0 ; int lumMod = 0 ; int alphaInt = 0 ; if ( ctsColor != null ) { try { lumOff = ctsColor . getLumOffArray ( 0 ) . getVal ( ) ; } catch ( Exception ex ) { LOG . log ( Level . FINE , "No lumOff entry" , ex ) ; } try { lumMod = ctsColor . getLumModArray ( 0 ) . getVal ( ) ; } catch ( Exception ex ) { LOG . log ( Level . FINE , "No lumMod entry" , ex ) ; } try { alphaInt = ctsColor . getAlphaArray ( 0 ) . getVal ( ) ; } catch ( Exception ex ) { LOG . log ( Level . FINE , "No alpha entry" , ex ) ; } } return assembleXcolor ( bcolor , preTint , lumOff , lumMod , alphaInt ) ;


signature:
public class ColorUtility { /** * get xcolor from ctsRgbColor .
 * @ param ctrColor
 * ctsRgbColor
 * @ return xcolor */
private static XColor getXColorFromRgbClr ( final CTSRgbColor ctrColor ) { } }

implementation: XSSFColor bcolor = null ; try { byte [ ] rgb = ctrColor . getVal ( ) ; bcolor = new XSSFColor ( rgb ) ; } catch ( Exception ex ) { LOG . log ( Level . SEVERE , "Cannot get rgb color error = " + ex . getLocalizedMessage ( ) , ex ) ; return null ; } int lumOff = 0 ; int lumMod = 0 ; int alphaStr = 0 ; try { lumOff = ctrColor . getLumOffArray ( 0 ) . getVal ( ) ; } catch ( Exception ex ) { LOG . log ( Level . FINE , "No lumOff entry" , ex ) ; } try { lumMod = ctrColor . getLumModArray ( 0 ) . getVal ( ) ; } catch ( Exception ex ) { LOG . log ( Level . FINE , "No lumMod entry" , ex ) ; } try { alphaStr = ctrColor . getAlphaArray ( 0 ) . getVal ( ) ; } catch ( Exception ex ) { LOG . log ( Level . FINE , "No alpha entry" , ex ) ; } return assembleXcolor ( bcolor , 0 , lumOff , lumMod , alphaStr ) ;


signature:
public class ColorUtility { /** * Get xcolor for automatic fill setting . This is the default setting in
 * Excel for chart colors . Normally the colors will be accent1 to 7.
 * @ param index
 * line index .
 * @ param themeTable
 * theme table .
 * @ return xcolor . */
private static XColor getXColorWithAutomaticFill ( final int index , final ThemesTable themeTable ) { } }

implementation: int reminder = ( index + 1 ) % AUTOCOLORSIZE ; if ( reminder == 0 ) { reminder = AUTOCOLORSIZE ; } String schema = AUTOCOLORNAME + reminder ; double tint = getAutomaticTint ( index ) ; return getXColorWithSchema ( schema , tint , null , themeTable ) ;


signature:
public class ColorUtility { /** * Get automatic tint number for specified index line . The default automatic
 * color only have 6 colors . If there are more than 6 lines then use tint
 * for next round , e . g . color7 = color1 + tint ( 0.25)
 * @ param index
 * line index .
 * @ return tint . */
private static double getAutomaticTint ( final int index ) { } }

implementation: final double [ ] idxArray = { 0 , 0.25 , 0.5 , - 0.25 , - 0.5 , 0.1 , 0.3 , - 0.1 , - 0.3 } ; int i = index / AUTOCOLORSIZE ; if ( i >= idxArray . length ) { return 0 ; } else { return idxArray [ i ] ; }


signature:
public class ColorUtility { /** * convert xssf color to color .
 * @ param xssfColor
 * xssf color
 * @ return color */
public static Color xssfClrToClr ( final XSSFColor xssfColor ) { } }

implementation: short [ ] rgb = getTripletFromXSSFColor ( xssfColor ) ; return new Color ( rgb [ 0 ] , rgb [ 1 ] , rgb [ 2 ] ) ;


signature:
public class ColorUtility { /** * Return index number for giving index name . e . g . tx1 return 1.
 * @ param idxName
 * theme index name .
 * @ return index number . */
private static int getThemeIndexFromName ( final String idxName ) { } }

implementation: final String [ ] idxArray = { "bg1" , "tx1" , "bg2" , "tx2" , "accent1" , "accent2" , "accent3" , "accent4" , "accent5" , "accent6" , "hlink" , "folHlink" } ; try { for ( int i = 0 ; i < idxArray . length ; i ++ ) { if ( idxArray [ i ] . equalsIgnoreCase ( idxName ) ) { return i ; } } } catch ( Exception ex ) { LOG . log ( Level . SEVERE , "error in getThemeIndexFromName :" + ex . getLocalizedMessage ( ) , ex ) ; } return - 1 ;


signature:
public class ColorUtility { /** * Convert xssfcolor to triple let numbers .
 * @ param xssfColor
 * xssf color .
 * @ return triple lets . */
public static short [ ] getTripletFromXSSFColor ( final XSSFColor xssfColor ) { } }

implementation:
short [ ] rgbfix = { RGB8BITS , RGB8BITS , RGB8BITS } ; if ( xssfColor != null ) { byte [ ] rgb = xssfColor . getRGBWithTint ( ) ; if ( rgb == null ) { rgb = xssfColor . getRGB ( ) ; } // Bytes are signed , so values of 128 + are negative !
// 0 : red , 1 : green , 2 : blue
rgbfix [ 0 ] = ( short ) ( ( rgb [ 0 ] < 0 ) ? ( rgb [ 0 ] + RGB8BITS ) : rgb [ 0 ] ) ; rgbfix [ 1 ] = ( short ) ( ( rgb [ 1 ] < 0 ) ? ( rgb [ 1 ] + RGB8BITS ) : rgb [ 1 ] ) ; rgbfix [ 2 ] = ( short ) ( ( rgb [ 2 ] < 0 ) ? ( rgb [ 2 ] + RGB8BITS ) : rgb [ 2 ] ) ; } return rgbfix ;


signature:
public class ColorUtility { /** * Gets the bg color from cell .
 * @ param wb
 * the wb
 * @ param poiCell
 * the poi cell
 * @ param cellStyle
 * the cell style
 * @ return the bg color from cell */
static String getBgColorFromCell ( final Workbook wb , final Cell poiCell , final CellStyle cellStyle ) { } }

implementation:
String style = "" ; if ( poiCell instanceof HSSFCell ) { int bkColorIndex = cellStyle . getFillForegroundColor ( ) ; HSSFColor color = HSSFColor . getIndexHash ( ) . get ( bkColorIndex ) ; if ( color != null ) { // correct color for customPalette
HSSFPalette palette = ( ( HSSFWorkbook ) wb ) . getCustomPalette ( ) ; HSSFColor color2 = palette . getColor ( bkColorIndex ) ; if ( ! color . getHexString ( ) . equalsIgnoreCase ( color2 . getHexString ( ) ) ) { color = color2 ; } style = "background-color:rgb(" + FacesUtility . strJoin ( color . getTriplet ( ) , "," ) + ");" ; } } else if ( poiCell instanceof XSSFCell ) { XSSFColor color = ( ( XSSFCell ) poiCell ) . getCellStyle ( ) . getFillForegroundColorColor ( ) ; if ( color != null ) { style = "background-color:rgb(" + FacesUtility . strJoin ( getTripletFromXSSFColor ( color ) , "," ) + ");" ; } } return style ;


signature:
public class CellControlsUtility { /** * find component according it ' s class .
 * @ param component
 * component .
 * @ return component name . */
private static String findComponentNameFromClass ( final UIComponent component ) { } }

implementation: String cname = component . getClass ( ) . getSimpleName ( ) ; if ( supportComponents . contains ( cname ) ) { return cname ; } return null ;


signature:
public class CellControlsUtility { /** * populate attributes .
 * @ param component
 * component obj .
 * @ param fcell
 * facescell .
 * @ param defaultControlMap
 * default control map . */
public static void populateAttributes ( final UIComponent component , final FacesCell fcell , final Map < String , Map < String , String > > defaultControlMap ) { } }

implementation: List < CellFormAttributes > inputAttrs = fcell . getInputAttrs ( ) ; String cname = findComponentNameFromClass ( component ) ; if ( cname == null ) { return ; } Map < String , String > defaultMap = defaultControlMap . get ( cname ) ; if ( defaultMap == null ) { defaultMap = new HashMap < > ( ) ; defaultControlMap . put ( cname , defaultMap ) ; } for ( Map . Entry < String , String > entry : defaultMap . entrySet ( ) ) { setObjectProperty ( component , entry . getKey ( ) , entry . getValue ( ) , true ) ; } for ( CellFormAttributes attr : inputAttrs ) { String propertyName = attr . getType ( ) ; String propertyValue = attr . getValue ( ) ; if ( ! defaultMap . containsKey ( propertyName ) ) { String defaultValue = getObjectPropertyValue ( component , propertyName , true ) ; defaultMap . put ( propertyName , defaultValue ) ; } setObjectProperty ( component , propertyName , propertyValue , true ) ; }


signature:
public class CellControlsUtility { /** * match parameter of method .
 * @ param obj
 * object .
 * @ param methodName
 * method name .
 * @ return index of paraMatchArray if mached . otherwise return - 1. */
private static AttributesType matchParaMeterOfMethod ( final Object obj , final String methodName ) { } }

implementation: for ( AttributesType attr : AttributesType . values ( ) ) { try { obj . getClass ( ) . getMethod ( methodName , new Class [ ] { attr . clazz } ) ; return attr ; } catch ( Exception ex ) { LOG . log ( Level . FINE , " error in matchParaMeterOfMethod = " + ex . getLocalizedMessage ( ) , ex ) ; } } return null ;