Input: Attempts to create a temporary directory that did not exist previously . [CODESPLIT] static private File getOrCreateTempDirectory ( boolean deleteOnExit ) throws ExtractException { // return the single instance if already created if ( ( TEMP_DIRECTORY != null ) && TEMP_DIRECTORY . exists ( ) ) { return TEMP_DIRECTORY ; } // use jvm supplied temp directory in case multiple jvms compete //        try { //            Path tempDirectory = Files.createTempDirectory("jne."); //            File tempDirectoryAsFile = tempDirectory.toFile(); //            if (deleteOnExit) { //                tempDirectoryAsFile.deleteOnExit(); //            } //            return tempDirectoryAsFile; //        } catch (IOException e) { //            throw new ExtractException("Unable to create temporary dir", e); //        } // use totally unique name to avoid race conditions try { Path baseDir = Paths . get ( System . getProperty ( "java.io.tmpdir" ) ) ; Path tempDirectory = baseDir . resolve ( "jne." + UUID . randomUUID ( ) . toString ( ) ) ; Files . createDirectories ( tempDirectory ) ; File tempDirectoryAsFile = tempDirectory . toFile ( ) ; if ( deleteOnExit ) { tempDirectoryAsFile . deleteOnExit ( ) ; } // save temp directory so its only exactracted once TEMP_DIRECTORY = tempDirectoryAsFile ; return TEMP_DIRECTORY ; } catch ( IOException e ) { throw new ExtractException ( "Unable to create temporary dir" , e ) ; } //        File baseDir = new File(System.getProperty("java.io.tmpdir")); //        String baseName = System.currentTimeMillis() + "-"; // //        for (int counter = 0; counter < TEMP_DIR_ATTEMPTS; counter++) { //            File d = new File(baseDir, baseName + counter); //            if (d.mkdirs()) { //                // schedule this directory to be deleted on exit //                if (deleteOnExit) { //                    d.deleteOnExit(); //                } //                tempDirectory = d; //                return d; //            } //        } // //        throw new ExtractException("Failed to create temporary directory within " + TEMP_DIR_ATTEMPTS + " attempts (tried " + baseName + "0 to " + baseName + (TEMP_DIR_ATTEMPTS - 1) + ')'); }


Input: Log for a particular level using the <code > ARRAY_MARKER< / code > . [CODESPLIT] @ Override /* package private */ void log ( final LogLevel level , final String event , final String message , final String [ ] dataKeys , final Object [ ] dataValues , final Throwable throwable ) { if ( shouldLog ( level ) ) { final String [ ] augmentedDataKeys = Arrays . copyOf ( dataKeys , dataKeys . length + 2 ) ; final Object [ ] augmentedDataValues = Arrays . copyOf ( dataValues , dataValues . length + 2 ) ; augmentedDataKeys [ augmentedDataKeys . length - 2 ] = "_skipped" ; augmentedDataKeys [ augmentedDataKeys . length - 1 ] = "_lastLogTime" ; augmentedDataValues [ augmentedDataValues . length - 2 ] = _skipped . getAndSet ( 0 ) ; augmentedDataValues [ augmentedDataValues . length - 1 ] = _lastLogTime . getAndSet ( _clock . instant ( ) ) ; super . log ( level , event , message , augmentedDataKeys , augmentedDataValues , throwable ) ; } }


Input: Log for a particular level using the <code > LISTS_MARKER< / code > . [CODESPLIT] @ Override /* package private */ void log ( final LogLevel level , final String event , final List < String > dataKeys , final List < Object > dataValues , final List < String > contextKeys , final List < Object > contextValues , final Throwable throwable ) { if ( shouldLog ( level ) ) { dataKeys . add ( "_skipped" ) ; dataKeys . add ( "_lastLogTime" ) ; dataValues . add ( _skipped . getAndSet ( 0 ) ) ; dataValues . add ( _lastLogTime . getAndSet ( _clock . instant ( ) ) ) ; super . log ( level , event , dataKeys , dataValues , contextKeys , contextValues , throwable ) ; } }


Input: Construct an immutable map from one key - value pair . Although this is more convenient than the static factory methods this method does not capture the instance being logged . [CODESPLIT] public static LogValueMap of ( final String k1 , final Object v1 ) { return builder ( ) . put ( k1 , v1 ) . build ( ) ; }


Input: CHECKSTYLE . OFF : ParameterNumber - Provided for compatibility wth ImmutableMap . of [CODESPLIT] public static LogValueMap of ( final String k1 , final Object v1 , final String k2 , final Object v2 , final String k3 , final Object v3 , final String k4 , final Object v4 , final String k5 , final Object v5 ) { return builder ( ) . put ( k1 , v1 ) . put ( k2 , v2 ) . put ( k3 , v3 ) . put ( k4 , v4 ) . put ( k5 , v5 ) . build ( ) ; }


Input: Create a new log event at the trace level . The provided <code > Consumer< / code > populates a <code > DeferredLogBuilder< / code > to define the log event . The consumer may not be invoked if it is not necessary . Therefore it is important not to include side - effects in the provided <code > Consumer< / code > . [CODESPLIT] public void trace ( final Consumer < DeferredLogBuilder > consumer ) { if ( _slf4jLogger . isTraceEnabled ( ) ) { final LogBuilder logBuilder = new DefaultLogBuilder ( this , LogLevel . TRACE ) ; consumer . accept ( logBuilder ) ; logBuilder . log ( ) ; } }


Input: Log a message at the trace level . Default values are used for all other parameters . [CODESPLIT] public void trace ( @ Nullable final String message ) { log ( LogLevel . TRACE , DEFAULT_EVENT , message , EMPTY_STRING_ARRAY , EMPTY_OBJECT_ARRAY , DEFAULT_THROWABLE ) ; }


Input: Log a message with a <code > Throwable< / code > at the trace level . Default values are used for all other parameters . [CODESPLIT] public void trace ( @ Nullable final String message , @ Nullable final Throwable throwable ) { log ( LogLevel . TRACE , DEFAULT_EVENT , message , EMPTY_STRING_ARRAY , EMPTY_OBJECT_ARRAY , throwable ) ; }


Input: Log a message for a canonical event at the trace level . Default values are used for all other parameters . [CODESPLIT] public void trace ( @ Nullable final String event , @ Nullable final String message ) { log ( LogLevel . TRACE , event , message , EMPTY_STRING_ARRAY , EMPTY_OBJECT_ARRAY , DEFAULT_THROWABLE ) ; }


Input: Log a message for a canonical event with supporting key - value pairs at the trace level . [CODESPLIT] public void trace ( @ Nullable final String event , @ Nullable final String message , @ Nullable final Map < String , Object > data , @ Nullable final Throwable throwable ) { if ( getSlf4jLogger ( ) . isTraceEnabled ( ) ) { LogLevel . TRACE . log ( getSlf4jLogger ( ) , event , createKeysFromCollection ( data == null ? Collections . emptyList ( ) : data . keySet ( ) , MESSAGE_DATA_KEY ) , createValuesFromCollection ( data == null ? Collections . emptyList ( ) : data . values ( ) , message ) , throwable ) ; } }


Input: Log a message for a canonical event with supporting key - value pairs at the trace level . [CODESPLIT] public void trace ( @ Nullable final String event , @ Nullable final String message , @ Nullable final String [ ] dataKeys , @ Nullable final Object ... dataValues ) { final Throwable throwable = extractThrowable ( dataKeys , dataValues ) ; log ( LogLevel . TRACE , event , message , dataKeys , chompArray ( dataValues , throwable == null ? 0 : 1 ) , throwable ) ; }


Input: Log a message for a canonical event with supporting key - value pairs and a <code > Throwable< / code > at the trace level . This method is provided only for efficiency over the var - args method above as it avoids an array creation during invocation . [CODESPLIT] public void trace ( @ Nullable final String event , @ Nullable final String message , @ Nullable final String dataKey1 , @ Nullable final Object dataValue1 , @ Nullable final Throwable throwable ) { if ( getSlf4jLogger ( ) . isTraceEnabled ( ) ) { LogLevel . TRACE . log ( getSlf4jLogger ( ) , event , createKeysFromArgs ( MESSAGE_DATA_KEY , dataKey1 ) , createValuesFromArgs ( message , dataValue1 ) , throwable ) ; } }


Input: Create a new log event at the debug level . The provided <code > Consumer< / code > populates a <code > DeferredLogBuilder< / code > to define the log event . The consumer may not be invoked if it is not necessary . Therefore it is important not to include side - effects in the provided <code > Consumer< / code > . [CODESPLIT] public void debug ( final Consumer < DeferredLogBuilder > consumer ) { if ( _slf4jLogger . isDebugEnabled ( ) ) { final LogBuilder logBuilder = new DefaultLogBuilder ( this , LogLevel . DEBUG ) ; consumer . accept ( logBuilder ) ; logBuilder . log ( ) ; } }


Input: Log a message at the debug level . Default values are used for all other parameters . [CODESPLIT] public void debug ( @ Nullable final String message ) { log ( LogLevel . DEBUG , DEFAULT_EVENT , message , EMPTY_STRING_ARRAY , EMPTY_OBJECT_ARRAY , DEFAULT_THROWABLE ) ; }


Input: Log a message with a <code > Throwable< / code > at the debug level . Default values are used for all other parameters . [CODESPLIT] public void debug ( @ Nullable final String message , @ Nullable final Throwable throwable ) { log ( LogLevel . DEBUG , DEFAULT_EVENT , message , EMPTY_STRING_ARRAY , EMPTY_OBJECT_ARRAY , throwable ) ; }


Input: Log a message for a canonical event at the debug level . Default values are used for all other parameters . [CODESPLIT] public void debug ( @ Nullable final String event , @ Nullable final String message ) { log ( LogLevel . DEBUG , event , message , EMPTY_STRING_ARRAY , EMPTY_OBJECT_ARRAY , DEFAULT_THROWABLE ) ; }


Input: Log a message for a canonical event with supporting key - value pairs at the debug level . [CODESPLIT] public void debug ( @ Nullable final String event , @ Nullable final String message , @ Nullable final Map < String , Object > data , @ Nullable final Throwable throwable ) { if ( getSlf4jLogger ( ) . isDebugEnabled ( ) ) { LogLevel . DEBUG . log ( getSlf4jLogger ( ) , event , createKeysFromCollection ( data == null ? Collections . emptyList ( ) : data . keySet ( ) , MESSAGE_DATA_KEY ) , createValuesFromCollection ( data == null ? Collections . emptyList ( ) : data . values ( ) , message ) , throwable ) ; } }


Input: Log a message for a canonical event with supporting key - value pairs at the debug level . [CODESPLIT] public void debug ( @ Nullable final String event , @ Nullable final String message , @ Nullable final String [ ] dataKeys , @ Nullable final Object ... dataValues ) { final Throwable throwable = extractThrowable ( dataKeys , dataValues ) ; log ( LogLevel . DEBUG , event , message , dataKeys , chompArray ( dataValues , throwable == null ? 0 : 1 ) , throwable ) ; }


Input: Log a message for a canonical event with supporting key - value pairs and a <code > Throwable< / code > at the debug level . This method is provided only for efficiency over the var - args method above as it avoids an array creation during invocation . [CODESPLIT] public void debug ( @ Nullable final String event , @ Nullable final String message , @ Nullable final String dataKey1 , @ Nullable final Object dataValue1 , @ Nullable final Throwable throwable ) { if ( getSlf4jLogger ( ) . isDebugEnabled ( ) ) { LogLevel . DEBUG . log ( getSlf4jLogger ( ) , event , createKeysFromArgs ( MESSAGE_DATA_KEY , dataKey1 ) , createValuesFromArgs ( message , dataValue1 ) , throwable ) ; } }


Input: Create a new log event at the info level . The provided <code > Consumer< / code > populates a <code > DeferredLogBuilder< / code > to define the log event . The consumer may not be invoked if it is not necessary . Therefore it is important not to include side - effects in the provided <code > Consumer< / code > . [CODESPLIT] public void info ( final Consumer < DeferredLogBuilder > consumer ) { if ( _slf4jLogger . isInfoEnabled ( ) ) { final LogBuilder logBuilder = new DefaultLogBuilder ( this , LogLevel . INFO ) ; consumer . accept ( logBuilder ) ; logBuilder . log ( ) ; } }


Input: Log a message at the info level . Default values are used for all other parameters . [CODESPLIT] public void info ( @ Nullable final String message ) { log ( LogLevel . INFO , DEFAULT_EVENT , message , EMPTY_STRING_ARRAY , EMPTY_OBJECT_ARRAY , DEFAULT_THROWABLE ) ; }


Input: Log a message for a canonical event at the info level . Default values are used for all other parameters . [CODESPLIT] public void info ( @ Nullable final String event , @ Nullable final String message ) { log ( LogLevel . INFO , event , message , EMPTY_STRING_ARRAY , EMPTY_OBJECT_ARRAY , DEFAULT_THROWABLE ) ; }


Input: Log a message for a canonical event with a <code > Throwable< / code > at the info level . Default values are used for all other parameters . [CODESPLIT] public void info ( @ Nullable final String event , @ Nullable final String message , @ Nullable final Throwable throwable ) { log ( LogLevel . INFO , event , message , EMPTY_STRING_ARRAY , EMPTY_OBJECT_ARRAY , throwable ) ; }


Input: Log a message for a canonical event with supporting key - value pairs at the info level . [CODESPLIT] public void info ( @ Nullable final String event , @ Nullable final String message , @ Nullable final Map < String , Object > data , @ Nullable final Throwable throwable ) { if ( getSlf4jLogger ( ) . isInfoEnabled ( ) ) { LogLevel . INFO . log ( getSlf4jLogger ( ) , event , createKeysFromCollection ( data == null ? Collections . emptyList ( ) : data . keySet ( ) , MESSAGE_DATA_KEY ) , createValuesFromCollection ( data == null ? Collections . emptyList ( ) : data . values ( ) , message ) , throwable ) ; } }


Input: Log a message for a canonical event with supporting key - value pairs at the info level . [CODESPLIT] public void info ( @ Nullable final String event , @ Nullable final String message , @ Nullable final String [ ] dataKeys , @ Nullable final Object ... dataValues ) { final Throwable throwable = extractThrowable ( dataKeys , dataValues ) ; log ( LogLevel . INFO , event , message , dataKeys , chompArray ( dataValues , throwable == null ? 0 : 1 ) , throwable ) ; }


Input: Log a message for a canonical event with supporting key - value pairs at the info level . This method is provided only for efficiency over the var - args method above as it avoids an array creation during invocation . [CODESPLIT] public void info ( @ Nullable final String event , @ Nullable final String message , @ Nullable final String dataKey1 , @ Nullable final String dataKey2 , @ Nullable final Object dataValue1 , @ Nullable final Object dataValue2 ) { info ( event , message , dataKey1 , dataKey2 , dataValue1 , dataValue2 , DEFAULT_THROWABLE ) ; }


Input: Log a message for a canonical event with supporting key - value pairs and a <code > Throwable< / code > at the info level . This method is provided only for efficiency over the var - args method above as it avoids an array creation during invocation . [CODESPLIT] public void info ( @ Nullable final String event , @ Nullable final String message , @ Nullable final String dataKey1 , @ Nullable final String dataKey2 , @ Nullable final Object dataValue1 , @ Nullable final Object dataValue2 , @ Nullable final Throwable throwable ) { if ( getSlf4jLogger ( ) . isInfoEnabled ( ) ) { LogLevel . INFO . log ( getSlf4jLogger ( ) , event , createKeysFromArgs ( MESSAGE_DATA_KEY , dataKey1 , dataKey2 ) , createValuesFromArgs ( message , dataValue1 , dataValue2 ) , throwable ) ; } }


Input: Create a new log event at the warn level . The provided <code > Consumer< / code > populates a <code > DeferredLogBuilder< / code > to define the log event . The consumer may not be invoked if it is not necessary . Therefore it is important not to include side - effects in the provided <code > Consumer< / code > . [CODESPLIT] public void warn ( final Consumer < DeferredLogBuilder > consumer ) { if ( _slf4jLogger . isWarnEnabled ( ) ) { final LogBuilder logBuilder = new DefaultLogBuilder ( this , LogLevel . WARN ) ; consumer . accept ( logBuilder ) ; logBuilder . log ( ) ; } }


Input: Log a message at the warn level . Default values are used for all other parameters . [CODESPLIT] public void warn ( @ Nullable final String message ) { log ( LogLevel . WARN , DEFAULT_EVENT , message , EMPTY_STRING_ARRAY , EMPTY_OBJECT_ARRAY , DEFAULT_THROWABLE ) ; }


Input: Log a message for a canonical event at the warn level . Default values are used for all other parameters . [CODESPLIT] public void warn ( @ Nullable final String event , @ Nullable final String message ) { log ( LogLevel . WARN , event , message , EMPTY_STRING_ARRAY , EMPTY_OBJECT_ARRAY , DEFAULT_THROWABLE ) ; }


Input: Log a message for a canonical event with a <code > Throwable< / code > at the warn level . Default values are used for all other parameters . [CODESPLIT] public void warn ( @ Nullable final String event , @ Nullable final String message , @ Nullable final Throwable throwable ) { log ( LogLevel . WARN , event , message , EMPTY_STRING_ARRAY , EMPTY_OBJECT_ARRAY , throwable ) ; }


Input: Log a message for a canonical event with supporting key - value pairs at the warn level . [CODESPLIT] public void warn ( @ Nullable final String event , @ Nullable final String message , @ Nullable final Map < String , Object > data ) { warn ( event , message , data , DEFAULT_THROWABLE ) ; }


Input: Log a message for a canonical event with supporting key - value pairs at the warn level . [CODESPLIT] public void warn ( @ Nullable final String event , @ Nullable final String message , @ Nullable final Map < String , Object > data , @ Nullable final Throwable throwable ) { if ( getSlf4jLogger ( ) . isWarnEnabled ( ) ) { LogLevel . WARN . log ( getSlf4jLogger ( ) , event , createKeysFromCollection ( data == null ? Collections . emptyList ( ) : data . keySet ( ) , MESSAGE_DATA_KEY ) , createValuesFromCollection ( data == null ? Collections . emptyList ( ) : data . values ( ) , message ) , throwable ) ; } }


Input: Log a message for a canonical event with supporting key - value pairs at the warn level . [CODESPLIT] public void warn ( @ Nullable final String event , @ Nullable final String message , @ Nullable final String [ ] dataKeys , @ Nullable final Object ... dataValues ) { final Throwable throwable = extractThrowable ( dataKeys , dataValues ) ; log ( LogLevel . WARN , event , message , dataKeys , chompArray ( dataValues , throwable == null ? 0 : 1 ) , throwable ) ; }


Input: Log a message for a canonical event with supporting key - value pairs and a <code > Throwable< / code > at the warn level . This method is provided only for efficiency over the var - args method above as it avoids an array creation during invocation . [CODESPLIT] public void warn ( @ Nullable final String event , @ Nullable final String message , @ Nullable final String dataKey1 , @ Nullable final String dataKey2 , @ Nullable final Object dataValue1 , @ Nullable final Object dataValue2 , @ Nullable final Throwable throwable ) { if ( getSlf4jLogger ( ) . isWarnEnabled ( ) ) { LogLevel . WARN . log ( getSlf4jLogger ( ) , event , createKeysFromArgs ( MESSAGE_DATA_KEY , dataKey1 , dataKey2 ) , createValuesFromArgs ( message , dataValue1 , dataValue2 ) , throwable ) ; } }


Input: Create a new log event at the error level . The provided <code > Consumer< / code > populates a <code > DeferredLogBuilder< / code > to define the log event . The consumer may not be invoked if it is not necessary . Therefore it is important not to include side - effects in the provided <code > Consumer< / code > . [CODESPLIT] public void error ( final Consumer < DeferredLogBuilder > consumer ) { if ( _slf4jLogger . isErrorEnabled ( ) ) { final LogBuilder logBuilder = new DefaultLogBuilder ( this , LogLevel . ERROR ) ; consumer . accept ( logBuilder ) ; logBuilder . log ( ) ; } }


Input: Log a message at the error level . Default values are used for all other parameters . [CODESPLIT] public void error ( @ Nullable final String message ) { log ( LogLevel . ERROR , DEFAULT_EVENT , message , EMPTY_STRING_ARRAY , EMPTY_OBJECT_ARRAY , DEFAULT_THROWABLE ) ; }


Input: Log a message with a <code > Throwable< / code > at the error level . Default values are used for all other parameters . [CODESPLIT] public void error ( @ Nullable final String message , @ Nullable final Throwable throwable ) { log ( LogLevel . ERROR , DEFAULT_EVENT , message , EMPTY_STRING_ARRAY , EMPTY_OBJECT_ARRAY , throwable ) ; }


Input: Log a message for a canonical event at the error level . Default values are used for all other parameters . [CODESPLIT] public void error ( @ Nullable final String event , @ Nullable final String message ) { log ( LogLevel . ERROR , event , message , EMPTY_STRING_ARRAY , EMPTY_OBJECT_ARRAY , DEFAULT_THROWABLE ) ; }


Input: Log a message for a canonical event with supporting key - value pairs at the error level . [CODESPLIT] public void error ( @ Nullable final String event , @ Nullable final String message , @ Nullable final Map < String , Object > data , @ Nullable final Throwable throwable ) { if ( getSlf4jLogger ( ) . isErrorEnabled ( ) ) { LogLevel . ERROR . log ( getSlf4jLogger ( ) , event , createKeysFromCollection ( data == null ? Collections . emptyList ( ) : data . keySet ( ) , MESSAGE_DATA_KEY ) , createValuesFromCollection ( data == null ? Collections . emptyList ( ) : data . values ( ) , message ) , throwable ) ; } }


Input: Log a message for a canonical event with supporting key - value pairs at the error level . [CODESPLIT] public void error ( @ Nullable final String event , @ Nullable final String message , @ Nullable final String [ ] dataKeys , @ Nullable final Object ... dataValues ) { final Throwable throwable = extractThrowable ( dataKeys , dataValues ) ; log ( LogLevel . ERROR , event , message , dataKeys , chompArray ( dataValues , throwable == null ? 0 : 1 ) , throwable ) ; }


Input: Log a message for a canonical event with supporting key - value pairs and a <code > Throwable< / code > at the error level . This method is provided only for efficiency over the var - args method above as it avoids an array creation during invocation . [CODESPLIT] public void error ( @ Nullable final String event , @ Nullable final String message , @ Nullable final String dataKey1 , @ Nullable final Object dataValue1 , @ Nullable final Throwable throwable ) { if ( getSlf4jLogger ( ) . isErrorEnabled ( ) ) { LogLevel . ERROR . log ( getSlf4jLogger ( ) , event , createKeysFromArgs ( MESSAGE_DATA_KEY , dataKey1 ) , createValuesFromArgs ( message , dataValue1 ) , throwable ) ; } }


Input: / * package private [CODESPLIT] void log ( final LogLevel level , @ Nullable final String event , @ Nullable final String message , @ Nullable final String [ ] dataKeys , @ Nullable final Object [ ] dataValues , @ Nullable final Throwable throwable ) { level . log ( getSlf4jLogger ( ) , event , createKeysFromArray ( dataKeys , MESSAGE_DATA_KEY ) , createValuesFromArray ( dataValues , message ) , throwable ) ; }


Input: / * package private [CODESPLIT] void log ( final LogLevel level , @ Nullable final String event , final List < String > dataKeys , final List < Object > dataValues , final List < String > contextKeys , final List < Object > contextValues , @ Nullable final Throwable throwable ) { level . log ( getSlf4jLogger ( ) , event , dataKeys , dataValues , contextKeys , contextValues , throwable ) ; }


Input: / * package private [CODESPLIT] static @ Nullable String [ ] createKeysFromCollection ( @ Nullable final Collection < String > collection , @ Nullable final String ... keys ) { if ( isNullOrEmpty ( keys ) ) { return collection == null ? null : collection . toArray ( new String [ collection . size ( ) ] ) ; } if ( isNullOrEmpty ( collection ) ) { return keys ; } final String [ ] combined = new String [ collection . size ( ) + keys . length ] ; for ( int i = 0 ; i < keys . length ; ++ i ) { combined [ i ] = keys [ i ] ; } int i = 0 ; for ( final String item : collection ) { combined [ keys . length + i ++ ] = item ; } return combined ; }


Input: / * package private [CODESPLIT] static @ Nullable Object [ ] createValuesFromCollection ( @ Nullable final Collection < Object > collection , @ Nullable final Object ... values ) { if ( isNullOrEmpty ( values ) ) { return collection == null ? null : collection . toArray ( new Object [ collection . size ( ) ] ) ; } if ( isNullOrEmpty ( collection ) ) { return values ; } final Object [ ] combined = new Object [ collection . size ( ) + values . length ] ; for ( int i = 0 ; i < values . length ; ++ i ) { combined [ i ] = values [ i ] ; } int i = 0 ; for ( final Object item : collection ) { combined [ values . length + i ++ ] = item ; } return combined ; }


Input: / * package private [CODESPLIT] static @ Nullable String [ ] createKeysFromArray ( @ Nullable final String [ ] array , @ Nullable final String ... keys ) { if ( isNullOrEmpty ( keys ) ) { return array ; } if ( isNullOrEmpty ( array ) ) { return keys ; } final String [ ] combined = Arrays . copyOf ( keys , array . length + keys . length ) ; for ( int i = 0 ; i < array . length ; ++ i ) { combined [ keys . length + i ] = array [ i ] ; } return combined ; }


Input: / * package private [CODESPLIT] static @ Nullable Object [ ] createValuesFromArray ( @ Nullable final Object [ ] array , @ Nullable final Object ... values ) { if ( isNullOrEmpty ( values ) ) { return array ; } if ( isNullOrEmpty ( array ) ) { return values ; } final Object [ ] combined = Arrays . copyOf ( values , array . length + values . length ) ; for ( int i = 0 ; i < array . length ; ++ i ) { combined [ values . length + i ] = array [ i ] ; } return combined ; }


Input: / * package private [CODESPLIT] static @ Nullable Throwable extractThrowable ( @ Nullable final String [ ] keys , @ Nullable final Object [ ] values ) { final int keyLength = keys == null ? 0 : keys . length ; if ( values != null && values . length == keyLength + 1 ) { final int throwableIndex = values . length - 1 ; if ( values [ throwableIndex ] instanceof Throwable ) { return ( Throwable ) values [ throwableIndex ] ; } } return null ; }


Input: / * package private [CODESPLIT] static @ Nullable Object [ ] chompArray ( @ Nullable final Object [ ] in , final int count ) { if ( count == 0 || in == null ) { return in ; } return Arrays . copyOf ( in , in . length - count ) ; }


Input: Serialize an event . [CODESPLIT] public String serialize ( final ILoggingEvent event , final String eventName , @ Nullable final Map < String , ? extends Object > map ) throws Exception { 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" ) ; if ( map != null ) { for ( final Map . Entry < String , ? extends Object > entry : map . entrySet ( ) ) { if ( StenoSerializationHelper . isSimpleType ( entry . getValue ( ) ) ) { jsonGenerator . writeObjectField ( entry . getKey ( ) , entry . getValue ( ) ) ; } else { jsonGenerator . writeFieldName ( entry . getKey ( ) ) ; _objectMapper . writeValue ( jsonGenerator , entry . getValue ( ) ) ; } } } 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 ( ) ; }


Input: Serialize an event . [CODESPLIT] public String serialize ( final ILoggingEvent event , final String eventName ) throws Exception { 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" ) ; jsonGenerator . writeObjectField ( "message" , event . getFormattedMessage ( ) ) ; 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 ( ) ; }


Input: Before outputting the message inject additional context . [CODESPLIT] @ Before ( "call(* com.arpnetworking.steno.LogBuilder.log())" ) public void addToContextLineAndMethod ( final JoinPoint joinPoint ) { final SourceLocation sourceLocation = joinPoint . getSourceLocation ( ) ; final LogBuilder targetLogBuilder = ( LogBuilder ) joinPoint . getTarget ( ) ; targetLogBuilder . addContext ( "line" , String . valueOf ( sourceLocation . getLine ( ) ) ) ; targetLogBuilder . addContext ( "file" , sourceLocation . getFileName ( ) ) ; targetLogBuilder . addContext ( "class" , sourceLocation . getWithinType ( ) ) ; }


Input: Start writing the Steno JSON wrapper . [CODESPLIT] public static void startStenoWrapper ( final ILoggingEvent event , final String eventName , final JsonGenerator jsonGenerator , final ObjectMapper objectMapper ) throws IOException { final StenoSerializationHelper . StenoLevel level = StenoSerializationHelper . StenoLevel . findByLogbackLevel ( event . getLevel ( ) ) ; jsonGenerator . writeStartObject ( ) ; jsonGenerator . writeObjectField ( "time" , ISO_DATE_TIME_FORMATTER . format ( Instant . ofEpochMilli ( event . getTimeStamp ( ) ) ) ) ; jsonGenerator . writeObjectField ( "name" , eventName ) ; jsonGenerator . writeObjectField ( "level" , level . name ( ) ) ; }


Input: Complete writing the Steno JSON wrapper . [CODESPLIT] public static void endStenoWrapper ( final ILoggingEvent event , final String eventName , final JsonGenerator jsonGenerator , final ObjectMapper objectMapper , final StenoEncoder encoder ) throws IOException { endStenoWrapper ( event , eventName , Collections . emptyList ( ) , Collections . emptyList ( ) , jsonGenerator , objectMapper , encoder ) ; }


Input: Complete writing the Steno JSON wrapper . [CODESPLIT] 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 { 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 ( ' ' ) ; jsonGenerator . flush ( ) ; }


Input: Write specified key - value pairs into the current block . [CODESPLIT] 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 { 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 ) ; } } } } }


Input: Write a <code > Throwable< / code > via <code > IThrowableProxy< / code > as JSON . [CODESPLIT] public static void writeThrowable ( final IThrowableProxy throwableProxy , final JsonGenerator jsonGenerator , final ObjectMapper objectMapper ) throws IOException { if ( throwableProxy != null ) { jsonGenerator . writeObjectFieldStart ( "exception" ) ; serializeThrowable ( throwableProxy , jsonGenerator , objectMapper ) ; jsonGenerator . writeEndObject ( ) ; } }


Input: 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 . [CODESPLIT] public static void serializeThrowable ( final IThrowableProxy throwableProxy , final JsonGenerator jsonGenerator , final ObjectMapper objectMapper ) throws IOException { 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 ( ) ; }


Input: Create a context based on the <code > StenoEncoder< / code > configuration . [CODESPLIT] 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 ) { 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 ; }


Input: Determine if an object represents a primitive Json type . These include instances of <code > Number< / code > <code > String< / code > and <code > Boolean< / code > . [CODESPLIT] public static boolean isSimpleType ( @ Nullable final Object obj ) { 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 ; }


Input: Return a Steno <code > Logger< / code > for a context class . [CODESPLIT] public static Logger getLogger ( final Class < ? > clazz ) { return new Logger ( org . slf4j . LoggerFactory . getLogger ( clazz ) ) ; }


Input: Return a rate limited Steno <code > Logger< / code > for a context class . [CODESPLIT] public static Logger getRateLimitLogger ( final Class < ? > clazz , final Duration duration ) { return new RateLimitLogger ( org . slf4j . LoggerFactory . getLogger ( clazz ) , duration ) ; }


Input: Return a Steno <code > Logger< / code > for a context name . [CODESPLIT] public static Logger getLogger ( final String name ) { return new Logger ( org . slf4j . LoggerFactory . getLogger ( name ) ) ; }


Input: Return a rate limited Steno <code > Logger< / code > for a context name . [CODESPLIT] public static Logger getRateLimitLogger ( final String name , final Duration duration ) { return new RateLimitLogger ( org . slf4j . LoggerFactory . getLogger ( name ) , duration ) ; }


Input: Return a rate limited Steno <code > Logger< / code > for an already instantiated <code > org . slf4j . Logger< / code > instance . [CODESPLIT] public static Logger getRateLimitLogger ( final org . slf4j . Logger logger , final Duration duration ) { return new RateLimitLogger ( logger , duration ) ; }


Input: 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 > } . [CODESPLIT] public void setRedactEnabled ( final boolean redactEnabled ) { 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 ; }


Input: Enables / Disables output of null for redacted fields when serializing complex objects . [CODESPLIT] public void setRedactNull ( final boolean redactNull ) { if ( _redactEnabled ) { final SimpleFilterProvider simpleFilterProvider = new SimpleFilterProvider ( ) ; simpleFilterProvider . addFilter ( RedactionFilter . REDACTION_FILTER_ID , new RedactionFilter ( ! redactNull ) ) ; _objectMapper . setFilterProvider ( simpleFilterProvider ) ; } _redactNull = redactNull ; }


Input: Create a context based on the <code > KeyValueEncoder< / code > configuration . [CODESPLIT] public static Map < String , Object > createContext ( final KeyValueEncoder encoder , final ILoggingEvent event , @ Nullable final List < String > contextKeys , @ Nullable final List < Object > contextValues ) { 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 ; }


Input: { [CODESPLIT] @ Override public byte [ ] encode ( final ILoggingEvent event ) { 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 ) ; }


Input: Determine whether the <code > marker< / code > represents an array event . [CODESPLIT] protected boolean isArrayStenoEvent ( @ Nullable final Marker marker ) { return marker != null && marker . contains ( StenoMarker . ARRAY_MARKER ) ; }


Input: Determine whether the <code > marker< / code > represents a JSON array event . [CODESPLIT] protected boolean isArrayJsonStenoEvent ( @ Nullable final Marker marker ) { return marker != null && marker . contains ( StenoMarker . ARRAY_JSON_MARKER ) ; }


Input: Determine whether the <code > marker< / code > represents a map event . [CODESPLIT] protected boolean isMapStenoEvent ( @ Nullable final Marker marker ) { return marker != null && marker . contains ( StenoMarker . MAP_MARKER ) ; }


Input: Determine whether the <code > marker< / code > represents a JSON map event . [CODESPLIT] protected boolean isMapJsonStenoEvent ( @ Nullable final Marker marker ) { return marker != null && marker . contains ( StenoMarker . MAP_JSON_MARKER ) ; }


Input: Determine whether the <code > marker< / code > represents an object event . [CODESPLIT] protected boolean isObjectStenoEvent ( @ Nullable final Marker marker ) { return marker != null && marker . contains ( StenoMarker . OBJECT_MARKER ) ; }


Input: Determine whether the <code > marker< / code > represents a JSON object event . [CODESPLIT] protected boolean isObjectJsonStenoEvent ( @ Nullable final Marker marker ) { return marker != null && marker . contains ( StenoMarker . OBJECT_JSON_MARKER ) ; }


Input: Determine whether the <code > marker< / code > represents a lists event . [CODESPLIT] protected boolean isListsStenoEvent ( @ Nullable final Marker marker ) { return marker != null && marker . contains ( StenoMarker . LISTS_MARKER ) ; }


Input: Generate a Steno log compatible representation . [CODESPLIT] @ LogValue public Object toLogValue ( ) { return LogValueMapFactory . < String , Object > builder ( ) . put ( "logBuilder" , _logBuilder ) . put ( "duration" , _duration ) . put ( "lastLogTime" , _lastLogTime ) . put ( "skipped" , _skipped ) . build ( ) ; }


Input: Serialize an event . [CODESPLIT] public String serialize ( final ILoggingEvent event , final String eventName , @ Nullable final Object data ) throws Exception { final String jsonData = _objectMapper . writeValueAsString ( data ) ; return _objectAsJsonStrategy . serialize ( event , eventName , jsonData ) ; }


Input: Create a format <code > String< / code > compatible with <code > MessageFormatter< / code > . [CODESPLIT] protected String buildFormatString ( @ Nullable final String name , @ Nullable final String [ ] keys ) { 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 ( ) ; }


Input: Escape all <code > String< / code > instances . [CODESPLIT] protected Object [ ] escapeStringValues ( final Object [ ] values ) { 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 ; }


Input: / * package private [CODESPLIT] String createMessage ( final ILoggingEvent event , @ Nullable final String eventName , @ Nullable final String [ ] keys , @ Nullable final Object [ ] values ) { final String formatString = buildFormatString ( eventName , keys ) ; final LoggingEventWrapper eventWrapper = new LoggingEventWrapper ( event , formatString , values ) ; return layout . doLayout ( eventWrapper ) ; }


Input: / * package private [CODESPLIT] Map < String , Object > createSafeContext ( final ILoggingEvent event ) { return createSafeContext ( event , Collections . emptyList ( ) , Collections . emptyList ( ) ) ; }


Input: / * package private [CODESPLIT] Map < String , Object > createSafeContext ( final ILoggingEvent event , @ Nullable final List < String > contextKeys , @ Nullable final List < Object > contextValues ) { return KeyValueSerializationHelper . createContext ( this , event , contextKeys , contextValues ) ; }


Input: Return the the message formatted with arguments . Implemented as suggested in : [CODESPLIT] public String getFormattedMessage ( ) { if ( _formattedMessage != null ) { return _formattedMessage ; } if ( _argumentArray != null ) { _formattedMessage = MessageFormatter . arrayFormat ( _message , _argumentArray ) . getMessage ( ) ; } else { _formattedMessage = _message ; } return _formattedMessage ; }


Input: { @inheritDoc } [CODESPLIT] @ Override @ Deprecated public void serializeAsField ( final Object pojo , final JsonGenerator jgen , final SerializerProvider prov , final BeanPropertyWriter writer ) throws Exception { 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 ) ; } } }


Input: Serialize an event . [CODESPLIT] public String serialize ( final ILoggingEvent event , final String eventName , final String jsonData ) throws Exception { 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 ( ) ; }


Input: Retrieve the relevant caller data adjusted for Steno logger wrapping . [CODESPLIT] protected StackTraceElement getCallerData ( final ILoggingEvent loggingEvent ) { 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 ; }


Input: Serialize an event . [CODESPLIT] 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 { 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 ( ) ; }


Input: Serialize an event . [CODESPLIT] public String serialize ( final ILoggingEvent event , final String eventName , @ Nullable final String [ ] keys , @ Nullable final Object [ ] values ) throws Exception { 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 ( ) ; }


Input: Create a serialization safe context based on the <code > StenoEncoder< / code > configuration . [CODESPLIT] public static Map < String , Object > createSafeContext ( final StenoEncoder encoder , final ILoggingEvent event , final ObjectMapper objectMapper ) { return createSafeContext ( encoder , event , objectMapper , Collections . emptyList ( ) , Collections . emptyList ( ) ) ; }


Input: Create a serialization safe context based on the <code > StenoEncoder< / code > configuration . [CODESPLIT] 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 ) { return StenoSerializationHelper . createContext ( encoder , event , objectMapper , contextKeys , contextValues ) ; }


Input: Safely serialize a value . [CODESPLIT] public static void safeEncodeValue ( final StringBuilder encoder , @ Nullable final Object value ) { 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 ( ) ) ; } }


Input: / * package private [CODESPLIT] static void safeEncodeThrowable ( final StringBuilder encoder , final Throwable throwable ) { 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 ( "}" ) ; }


Input: / * package private [CODESPLIT] static void safeEncodeMap ( final StringBuilder encoder , final Map < ? , ? > valueAsMap ) { 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 , ' ' ) ; } }


Input: / * package private [CODESPLIT] static void safeEncodeList ( final StringBuilder encoder , final List < ? > valueAsList ) { encoder . append ( "[" ) ; for ( Object listValue : valueAsList ) { safeEncodeValue ( encoder , listValue ) ; encoder . append ( "," ) ; } if ( valueAsList . isEmpty ( ) ) { encoder . append ( "]" ) ; } else { encoder . setCharAt ( encoder . length ( ) - 1 , ' ' ) ; } }


Input: / * package private [CODESPLIT] static void safeEncodeArray ( final StringBuilder encoder , final Object value ) { 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 , ' ' ) ; } }


Input: / * package private [CODESPLIT] static void safeEncodeLogValueMap ( final StringBuilder encoder , final LogValueMapFactory . LogValueMap logValueMap ) { 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 ) ; }


Input: If values size hit { @link #MAX } then query will be split ( size % MAX + [ 1 ] ) [CODESPLIT] @ Override public int delete ( List < ? > values , boolean shouldNotify ) throws StormException { 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 ; }


Input: Initialise the warehouse path . <p > This method can be overridden to provide additional initialisations . < / p > [CODESPLIT] protected void init ( ) throws Throwable { metastoreLocation = temporaryFolder . newFolder ( "metastore" ) ; conf . setVar ( ConfVars . METASTOREWAREHOUSE , metastoreLocation . getAbsolutePath ( ) ) ; }


Input: Create a new database with the specified name . [CODESPLIT] public void createDatabase ( String databaseName ) throws TException { 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 ( ) ; } }


Input: we should clear it [CODESPLIT] protected void checkMappings ( int arrayPosition ) { final int index = positions . indexOfValue ( arrayPosition ) ; if ( index >= 0 ) { positions . removeAt ( index ) ; } }


Input: Opens new SQLite connection and closes previous if it was not closed [CODESPLIT] public void open ( @ Nullable SQLiteOpenCallbacks callbacks ) throws SQLiteException { if ( isOpen ( ) ) { close ( ) ; } initDB ( Storm . getApplicationContext ( ) , mInfo . name , mInfo . version , new ArrayList <> ( mCached . values ( ) ) , mInfo . pragma , callbacks ) ; }


Input: Counts number of rows in specified query . If { @link ru . noties . storm . query . Selection } is null then counts all rows in Class table . [CODESPLIT] public int count ( Class < ? > clazz , @ Nullable Selection selection ) { 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 ; }


Input: 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 () } [CODESPLIT] public void init ( Context applicationContext , boolean isDebug ) { 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 ; }


Input: Registers { [CODESPLIT] public < T , IC extends InstanceCreator < T > > void registerInstanceCreator ( @ NonNull Class < T > clazz , @ NonNull IC ics ) { mInstanceCreators . register ( clazz , ics ) ; }


Input: 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 . [CODESPLIT] public < T > void registerTypeSerializer ( Class < T > who , AbsSerializer < T > serializer ) { //noinspection unchecked mSerializers . put ( who , ( AbsSerializer < Object > ) serializer ) ; }


Input: Parses the save attr . [CODESPLIT] public static String parseSaveAttr ( final Cell cell , final Map < String , String > saveCommentsMap ) { 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 "" ; }


Input: Save data to object in context . [CODESPLIT] public static void saveDataToObjectInContext ( final Map < String , Object > context , final String saveAttr , final String strValue , final ExpressionEngine engine ) { 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 ) ; } }


Input: reload the data from context to websheet row . [CODESPLIT] public static void refreshSheetRowFromContext ( final Map < String , Object > context , final String fullSaveAttr , final Row row , final ExpressionEngine engine ) { 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 ) ; } } }


Input: Parses the save attr string . [CODESPLIT] public static String parseSaveAttrString ( final String strValue ) { 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 "" ; }


Input: Gets the save attr list from row . [CODESPLIT] public static String getSaveAttrListFromRow ( final Row row ) { 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 ; }


Input: Gets the save attr from list . [CODESPLIT] public static String getSaveAttrFromList ( final int columnIndex , final String saveAttrs ) { 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 ; }


Input: get the columnIndex from saveAttr . saveAttr format as : $columnIndex = xxxxxxx [CODESPLIT] public static String getColumnIndexFromSaveAttr ( final String saveAttr ) { 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 ; }


Input: Checks if is checks for save attr . [CODESPLIT] public static boolean isHasSaveAttr ( final Cell cell ) { Cell saveAttrCell = cell . getRow ( ) . getCell ( TieConstants . HIDDEN_SAVE_OBJECTS_COLUMN ) ; if ( saveAttrCell != null ) { return isHasSaveAttr ( cell , saveAttrCell . getStringCellValue ( ) ) ; } return false ; }


Input: Checks if is checks for save attr . [CODESPLIT] public static boolean isHasSaveAttr ( final Cell cell , final String saveAttrs ) { 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 ; }


Input: Sets the save objects in hidden column . [CODESPLIT] public static void setSaveObjectsInHiddenColumn ( final Row row , final String saveAttr ) { Cell cell = row . getCell ( TieConstants . HIDDEN_SAVE_OBJECTS_COLUMN , MissingCellPolicy . CREATE_NULL_AS_BLANK ) ; cell . setCellValue ( saveAttr ) ; }


Input: Sets the save attrs for sheet . [CODESPLIT] public static void setSaveAttrsForSheet ( final Sheet sheet , final int minRowNum , final int maxRowNum , final Map < String , String > saveCommentsMap ) { for ( Row row : sheet ) { int rowIndex = row . getRowNum ( ) ; if ( ( rowIndex >= minRowNum ) && ( rowIndex <= maxRowNum ) ) { setSaveAttrsForRow ( row , saveCommentsMap ) ; } } }


Input: Sets the save attrs for row . [CODESPLIT] public static void setSaveAttrsForRow ( final Row row , final Map < String , String > saveCommentsMap ) { 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 ( ) ) ; } }


Input: Prepare context and attrs for cell . [CODESPLIT] public static String prepareContextAndAttrsForCell ( Cell poiCell , String fullName , CellHelper cellHelper ) { 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 ; }


Input: / * ( non - Javadoc ) [CODESPLIT] @ SuppressWarnings ( "rawtypes" ) @ Override public List getSerListFromCtObjChart ( final Object ctObjChart ) { if ( ctObjChart instanceof CTPieChart ) { return ( ( CTPieChart ) ctObjChart ) . getSerList ( ) ; } return this . getEmptySerlist ( ) ; }


Input: / * ( non - Javadoc ) [CODESPLIT] @ Override public final CTShapeProperties getShapePropertiesFromCTSer ( final Object ctObjSer ) { if ( ctObjSer instanceof CTPieSer ) { return ( ( CTPieSer ) ctObjSer ) . getSpPr ( ) ; } return null ; }


Input: / * ( non - Javadoc ) [CODESPLIT] @ Override public final CTNumDataSource getCTNumDataSourceFromCTSer ( final Object ctObjSer ) { if ( ctObjSer instanceof CTPieSer ) { return ( ( CTPieSer ) ctObjSer ) . getVal ( ) ; } return null ; }


Input:
/ * ( non - Javadoc ) [CODESPLIT] @ Override public final List < CTDPt > getDPtListFromCTSer ( final Object ctObjSer ) { 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 ( ) ; }


Input: convert string to int ( length ) . [CODESPLIT] protected final int calcLength ( final String lengthStr ) { try { return Integer . parseInt ( lengthStr ) ; } catch ( Exception ex ) { LOG . log ( Level . FINE , "canot calcLength :" + ex . getLocalizedMessage ( ) , ex ) ; } return 0 ; }


Input: / * ( non - Javadoc ) [CODESPLIT] @ Override public final Object getAsObject ( final FacesContext context , final UIComponent component , final String value ) { 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 ; }


Input: Fmt number . [CODESPLIT] private String fmtNumber ( final double d ) { if ( Double . compare ( d % 1 , 0 ) == 0 ) { return String . format ( "%d" , ( int ) d ) ; } else { return String . format ( "%.2f" , d ) ; } }


Input: / * ( non - Javadoc ) [CODESPLIT] @ Override public final String getAsString ( final FacesContext context , final UIComponent component , final Object value ) { 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 ; }


Input: save the cell before serialize . [CODESPLIT] private void writeObject ( final java . io . ObjectOutputStream out ) throws IOException { saveList = new ArrayList <> ( ) ; for ( Map . Entry < Cell , String > entry : this . getMap ( ) . entrySet ( ) ) { saveList . add ( new SerialKey ( new SerialCellAddress ( entry . getKey ( ) ) , entry . getValue ( ) ) ) ; } out . defaultWriteObject ( ) ; }


Input: recover the cell reference to the sheet . [CODESPLIT] public void recover ( final Sheet sheet ) { 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 ( ) ) ; } }


Input: Put shift attrs . [CODESPLIT] public final void putShiftAttrs ( final String fullName , final ConfigRangeAttrs attrs , final RowsMapping unitRowsMapping ) { attrs . setUnitRowsMapping ( unitRowsMapping ) ; this . shiftMap . put ( fullName , attrs ) ; }


Input: Set up workbook . Also create evaluation wrapper . [CODESPLIT] public void setWb ( final Workbook pWb ) { this . getSerialWb ( ) . setWb ( pWb ) ; this . wbWrapper = XSSFEvaluationWorkbook . create ( ( XSSFWorkbook ) pWb ) ; }


Input: Return evaluation wrapper if needed . [CODESPLIT] public XSSFEvaluationWorkbook getWbWrapper ( ) { if ( ( this . wbWrapper == null ) && ( this . getWb ( ) != null ) ) { this . wbWrapper = XSSFEvaluationWorkbook . create ( ( XSSFWorkbook ) this . getWb ( ) ) ; } return wbWrapper ; }


Input: get formulaevaluator . [CODESPLIT] public FormulaEvaluator getFormulaEvaluator ( ) { if ( ( this . formulaEvaluator == null ) && ( this . getWb ( ) != null ) ) { this . formulaEvaluator = this . getWb ( ) . getCreationHelper ( ) . createFormulaEvaluator ( ) ; } return formulaEvaluator ; }


Input: recalculate max coulumn count across sheets in the workbook . [CODESPLIT] public void reCalcMaxColCounts ( ) { 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 ; }


Input: load web sheet from inputStream file with data object . [CODESPLIT] public int loadWebSheet ( final InputStream inputStream , final Map < String , Object > pDataContext ) { return this . getHelper ( ) . getWebSheetLoader ( ) . loadWorkbook ( inputStream , pDataContext ) ; }


Input: load web sheet from giving workbook with data object . [CODESPLIT] public int loadWebSheet ( final Workbook pWb , final Map < String , Object > pDataContext ) { return this . getHelper ( ) . getWebSheetLoader ( ) . loadWorkbook ( pWb , pDataContext ) ; }


Input: Triggered when user switch the tab . This will load different tab ( sheet ) as the current sheet . [CODESPLIT] public void onTabChange ( final TabChangeEvent event ) { String tabName = event . getTab ( ) . getTitle ( ) ; loadWorkSheetByTabName ( tabName ) ; }


Input: load worksheet by tab name . [CODESPLIT] public int loadWorkSheetByTabName ( final String tabName ) { 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 ; }


Input: download current workbook . [CODESPLIT] public void doExport ( ) { 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 ; }


Input: Save the current workbooks . [CODESPLIT] public void doSave ( ) { this . setSubmitMde ( false ) ; if ( ! this . getHelper ( ) . getValidationHandler ( ) . preValidation ( ) ) { LOG . fine ( "Validation failded before saving" ) ; return ; } processSave ( ) ; this . getHelper ( ) . getWebSheetLoader ( ) . setUnsavedStatus ( RequestContext . getCurrentInstance ( ) , false ) ; }


Input:
Submit the current workbooks . [CODESPLIT] public void doSubmit ( ) { 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 ) ; }


Input: populate component . [CODESPLIT] public void populateComponent ( final ComponentSystemEvent event ) { 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 ( ) ) ; }


Input: Gets the current sheet config . [CODESPLIT] public SheetConfiguration getCurrentSheetConfig ( ) { String currentTabName = this . getCurrent ( ) . getCurrentTabName ( ) ; if ( currentTabName == null ) { return null ; } return this . getSheetConfigMap ( ) . get ( currentTabName ) ; }


Input: load the bean from saving . [CODESPLIT] private void readObject ( final java . io . ObjectInputStream in ) throws IOException { try { in . defaultReadObject ( ) ; recover ( ) ; } catch ( EncryptedDocumentException | ClassNotFoundException e ) { LOG . log ( Level . SEVERE , " error in readObject of serialWorkbook : " + e . getLocalizedMessage ( ) , e ) ; } }


Input: / * ( non - Javadoc ) [CODESPLIT] @ Override public final Object getAsObject ( final FacesContext context , final UIComponent component , final String value ) { 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 ) ; } }


Input: / * ( non - Javadoc ) [CODESPLIT] @ Override public final String getAsString ( final FacesContext context , final UIComponent component , final Object value ) { 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 ) ; } }


Input: Gets the locale . [CODESPLIT] private Locale getLocale ( final FacesContext context , final UIComponent component ) { String localeStr = ( String ) component . getAttributes ( ) . get ( TieConstants . COMPONENT_ATTR_LOCALE ) ; if ( localeStr == null ) { return context . getViewRoot ( ) . getLocale ( ) ; } return Locale . forLanguageTag ( localeStr ) ; }


Input:
Return picture to web front end . [CODESPLIT] public StreamedContent getPicture ( ) { 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 ( ) ) ) ; } }


Input: Gets the cell helper . [CODESPLIT] public final CellHelper getCellHelper ( ) { if ( ( this . cellHelper == null ) && ( this . parent != null ) ) { this . cellHelper = new CellHelper ( parent ) ; } return cellHelper ; }


Input: Gets the pic helper . [CODESPLIT] public final PicturesHelper getPicHelper ( ) { if ( ( this . picHelper == null ) && ( this . parent != null ) ) { this . picHelper = new PicturesHelper ( parent ) ; } return picHelper ; }


Input: Gets the validation handler . [CODESPLIT] public final ValidationHandler getValidationHandler ( ) { if ( ( this . validationHandler == null ) && ( this . parent != null ) ) { this . validationHandler = new ValidationHandler ( parent ) ; } return validationHandler ; }


Input: Gets the chart helper . [CODESPLIT] public final ChartHelper getChartHelper ( ) { if ( ( this . chartHelper == null ) && ( this . parent != null ) ) { this . chartHelper = new ChartHelper ( parent ) ; } return chartHelper ; }


Input: Convert shared formulas . [CODESPLIT] public static Ptg [ ] convertSharedFormulas ( final Ptg [ ] ptgs , final ShiftFormulaRef shiftFormulaRef ) { 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 ( ) ] ) ; }


Input: 3d ( reference to other sheet ) is not supported . only 2d ( within the sheet ) is supported . [CODESPLIT] public static int getFirstSupportedRowNumFromPtg ( final Object ptg ) { 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 ; }


Input:
Convert ptg . [CODESPLIT] private static Ptg [ ] convertPtg ( final Ptg [ ] ptgs , final int position , final ShiftFormulaRef shiftFormulaRef , final Object ptg ) { 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 ( ) ) ; }


Input:
Convert ptg for watch list . [CODESPLIT] private static Ptg [ ] convertPtgForWatchList ( final Ptg [ ] ptgs , final int position , final ShiftFormulaRef shiftFormulaRef , final Object ptg , final byte originalOperandClass , final int currentRow ) { 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 ) ; }


Input: Single ptg . [CODESPLIT] private static Ptg [ ] singlePtg ( final Object ptg , final byte originalOperandClass , final int formulaChanged ) { 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 ; }


Input: Gets the rows list . [CODESPLIT] private static List < SerialRow > getRowsList ( final int currentRow , final List < RowsMapping > currentRowsMappingList ) { 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 ; }


Input: assemble rowslist from rowsmapping . [CODESPLIT] private static List < SerialRow > assembleRowsListFromRowsMapping ( final List < SerialRow > all , final List < SerialRow > current ) { 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 ; }


Input: Fixup ref relative row one to one . [CODESPLIT] protected static Object fixupRefRelativeRowOneToOne ( final Object ptg , final Row newRow ) { 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 ( ) ) ; } } }


Input:
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 . [CODESPLIT] protected static Ptg [ ] fixupRefRelativeRowOneToMany ( final Object ptg , final byte originalOperandClass , final List < SerialRow > rowList , final Ptg [ ] ptgs , final int position ) { 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 ; }


Input: Builds the dynamic row for ref ptg base . [CODESPLIT] private static void buildDynamicRowForRefPtgBase ( final Object ptg , final byte originalOperandClass , final List < SerialRow > rowList , final Ptg [ ] newPtg , final boolean includeParenthesis ) { 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 ; } } }


Input: Builds the dynamic row for area ptg base . [CODESPLIT] private static void buildDynamicRowForAreaPtgBase ( final Object ptg , final byte originalOperandClass , final List < SerialRow > rowList , final Ptg [ ] newPtg ) { 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 ; } } }


Input: check is current ptg followed by valueOperationPtg . valueOperationPtg include : Add SubStract Multiply Divide etc . [CODESPLIT] private static boolean isFollowedByValueOperator ( final Ptg [ ] ptgs , final int position ) { 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 ; }


Input: retrieve background color for plot area . [CODESPLIT] public static XColor getBgColor ( final CTPlotArea ctPlot , final ThemesTable themeTable ) { 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 ) ) ; } }


Input: get line color of line chart from CTLineSer . [CODESPLIT] public static XColor geColorFromSpPr ( final int index , final CTShapeProperties ctSpPr , final ThemesTable themeTable , final boolean isLineColor ) { 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 ) ; } }


Input:
Find automatic fill color . [CODESPLIT] private static XColor findAutomaticFillColor ( final ThemesTable themeTable , final CTSolidColorFillProperties colorFill ) { // 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 ; }


Input:
assemble xssfcolor with tint / lumoff / lummod / alpha to xcolor . [CODESPLIT] private static XColor assembleXcolor ( final XSSFColor bcolor , final double preTint , final int lumOff , final int lumMod , final int alphaInt ) { 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 ) ; }


Input: retrieve xcolor from scheme color . [CODESPLIT] private static XColor getXColorFromSchemeClr ( final CTSchemeColor ctsColor , final ThemesTable themeTable ) { if ( ctsColor . getVal ( ) != null ) { return getXColorWithSchema ( ctsColor . getVal ( ) . toString ( ) , 0 , ctsColor , themeTable ) ; } return null ; }


Input: Get xcolor with color schema name . Normally the names are accent1 to 7 . Sometimes also have lumOff / lumMod / alphaInt setting . [CODESPLIT] private static XColor getXColorWithSchema ( final String colorSchema , final double preTint , final CTSchemeColor ctsColor , final ThemesTable themeTable ) { 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 ) ; }


Input: get xcolor from ctsRgbColor . [CODESPLIT] private static XColor getXColorFromRgbClr ( final CTSRgbColor ctrColor ) { 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 ) ; }


Input: Get xcolor for automatic fill setting . This is the default setting in Excel for chart colors . Normally the colors will be accent1 to 7 . [CODESPLIT] private static XColor getXColorWithAutomaticFill ( final int index , final ThemesTable themeTable ) { int reminder = ( index + 1 ) % AUTOCOLORSIZE ; if ( reminder == 0 ) { reminder = AUTOCOLORSIZE ; } String schema = AUTOCOLORNAME + reminder ; double tint = getAutomaticTint ( index ) ; return getXColorWithSchema ( schema , tint , null , themeTable ) ; }


Input: 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 ) [CODESPLIT] private static double getAutomaticTint ( final int index ) { 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 ] ; } }