public static LogValueMap of(final String k1, final Object v1) {
        return builder()
                .put(k1, v1)
                .build();
    }

public static LogValueMap of ( final String k1 , final Object v1 ) { return builder ( ) . put ( k1 , v1 ) . build ( ) ; }

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.

@since 1.9.2

@param k1 Key one.
@param v1 Value one.
@return New LogValueMap.

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 .


public void trace(@Nullable final String message) {
        log(LogLevel.TRACE, DEFAULT_EVENT, message, EMPTY_STRING_ARRAY, EMPTY_OBJECT_ARRAY, DEFAULT_THROWABLE);
    }

public void trace ( @ Nullable final String message ) { log ( LogLevel . TRACE , DEFAULT_EVENT , message , EMPTY_STRING_ARRAY , EMPTY_OBJECT_ARRAY , DEFAULT_THROWABLE ) ; }

Log a message at the trace level. Default values are used for all other
parameters.

This method is also found in the SLF4J Logger. It is
intended to simplify migration; however, it's use is not recommended
as it lacks an identifying event and typically includes serialized
as opposed to structured data.

@since 1.3.0

@param message The message to be logged.

Log a message at the trace level . Default values are used for all other parameters .


public void trace(@Nullable final String event, @Nullable final String message) {
        log(LogLevel.TRACE, event, message, EMPTY_STRING_ARRAY, EMPTY_OBJECT_ARRAY, DEFAULT_THROWABLE);
    }

public void trace ( @ Nullable final String event , @ Nullable final String message ) { log ( LogLevel . TRACE , event , message , EMPTY_STRING_ARRAY , EMPTY_OBJECT_ARRAY , DEFAULT_THROWABLE ) ; }

Log a message for a canonical event at the trace level. Default values
are used for all other parameters.

@since 1.3.0

@param event The canonical event that occurred.
@param message The message to be logged.

Log a message for a canonical event at the trace level . Default values are used for all other parameters .


public void debug(@Nullable final String message) {
        log(LogLevel.DEBUG, DEFAULT_EVENT, message, EMPTY_STRING_ARRAY, EMPTY_OBJECT_ARRAY, DEFAULT_THROWABLE);
    }

public void debug ( @ Nullable final String message ) { log ( LogLevel . DEBUG , DEFAULT_EVENT , message , EMPTY_STRING_ARRAY , EMPTY_OBJECT_ARRAY , DEFAULT_THROWABLE ) ; }

Log a message at the debug level. Default values are used for all other
parameters.

This method is also found in the SLF4J Logger. It is
intended to simplify migration; however, it's use is not recommended
as it lacks an identifying event and typically includes serialized
as opposed to structured data.

@since 1.3.0

@param message The message to be logged.

Log a message at the debug level . Default values are used for all other parameters .


public void debug(@Nullable final String event, @Nullable final String message) {
        log(LogLevel.DEBUG, event, message, EMPTY_STRING_ARRAY, EMPTY_OBJECT_ARRAY, DEFAULT_THROWABLE);
    }

public void debug ( @ Nullable final String event , @ Nullable final String message ) { log ( LogLevel . DEBUG , event , message , EMPTY_STRING_ARRAY , EMPTY_OBJECT_ARRAY , DEFAULT_THROWABLE ) ; }

Log a message for a canonical event at the debug level. Default values
are used for all other parameters.

@since 1.3.0

@param event The canonical event that occurred.
@param message The message to be logged.

Log a message for a canonical event at the debug level . Default values are used for all other parameters .


public void info(@Nullable final String message) {
        log(LogLevel.INFO, DEFAULT_EVENT, message, EMPTY_STRING_ARRAY, EMPTY_OBJECT_ARRAY, DEFAULT_THROWABLE);
    }

public void info ( @ Nullable final String message ) { log ( LogLevel . INFO , DEFAULT_EVENT , message , EMPTY_STRING_ARRAY , EMPTY_OBJECT_ARRAY , DEFAULT_THROWABLE ) ; }

Log a message at the info level. Default values are used for all other
parameters.

This method is also found in the SLF4J Logger. It is
intended to simplify migration; however, it's use is not recommended
as it lacks an identifying event and typically includes serialized
as opposed to structured data.

@since 1.3.0

@param message The message to be logged.

Log a message at the info level . Default values are used for all other parameters .


public void info(@Nullable final String event, @Nullable final String message) {
        log(LogLevel.INFO, event, message, EMPTY_STRING_ARRAY, EMPTY_OBJECT_ARRAY, DEFAULT_THROWABLE);
    }

public void info ( @ Nullable final String event , @ Nullable final String message ) { log ( LogLevel . INFO , event , message , EMPTY_STRING_ARRAY , EMPTY_OBJECT_ARRAY , DEFAULT_THROWABLE ) ; }

Log a message for a canonical event at the info level. Default values
are used for all other parameters.

@since 1.3.0

@param event The canonical event that occurred.
@param message The message to be logged.

Log a message for a canonical event at the info level . Default values are used for all other parameters .


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);
    }

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 ) ; }

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.

@since 1.3.0

@param event The canonical event that occurred.
@param message The message to be logged.
@param dataKey1 First data name.
@param dataKey2 Second data name.
@param dataValue1 First data value.
@param dataValue2 Second data value.

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 .


public void warn(@Nullable final String message) {
        log(LogLevel.WARN, DEFAULT_EVENT, message, EMPTY_STRING_ARRAY, EMPTY_OBJECT_ARRAY, DEFAULT_THROWABLE);
    }

public void warn ( @ Nullable final String message ) { log ( LogLevel . WARN , DEFAULT_EVENT , message , EMPTY_STRING_ARRAY , EMPTY_OBJECT_ARRAY , DEFAULT_THROWABLE ) ; }

Log a message at the warn level. Default values are used for all other
parameters.

This method is also found in the SLF4J Logger. It is
intended to simplify migration; however, it's use is not recommended
as it lacks an identifying event and typically includes serialized
as opposed to structured data.

@since 1.3.0

@param message The message to be logged.

Log a message at the warn level . Default values are used for all other parameters .


public void warn(@Nullable final String event, @Nullable final String message) {
        log(LogLevel.WARN, event, message, EMPTY_STRING_ARRAY, EMPTY_OBJECT_ARRAY, DEFAULT_THROWABLE);
    }

public void warn ( @ Nullable final String event , @ Nullable final String message ) { log ( LogLevel . WARN , event , message , EMPTY_STRING_ARRAY , EMPTY_OBJECT_ARRAY , DEFAULT_THROWABLE ) ; }

Log a message for a canonical event at the warn level. Default values
are used for all other parameters.

@since 1.3.0

@param event The canonical event that occurred.
@param message The message to be logged.

Log a message for a canonical event at the warn level . Default values are used for all other parameters .


public void error(@Nullable final String message) {
        log(LogLevel.ERROR, DEFAULT_EVENT, message, EMPTY_STRING_ARRAY, EMPTY_OBJECT_ARRAY, DEFAULT_THROWABLE);
    }

public void error ( @ Nullable final String message ) { log ( LogLevel . ERROR , DEFAULT_EVENT , message , EMPTY_STRING_ARRAY , EMPTY_OBJECT_ARRAY , DEFAULT_THROWABLE ) ; }

Log a message at the error level. Default values are used for all other
parameters.

This method is also found in the SLF4J Logger. It is
intended to simplify migration; however, it's use is not recommended
as it lacks an identifying event and typically includes serialized
as opposed to structured data.

@since 1.3.0

@param message The message to be logged.

Log a message at the error level . Default values are used for all other parameters .


public void error(@Nullable final String event, @Nullable final String message) {
        log(LogLevel.ERROR, event, message, EMPTY_STRING_ARRAY, EMPTY_OBJECT_ARRAY, DEFAULT_THROWABLE);
    }

public void error ( @ Nullable final String event , @ Nullable final String message ) { log ( LogLevel . ERROR , event , message , EMPTY_STRING_ARRAY , EMPTY_OBJECT_ARRAY , DEFAULT_THROWABLE ) ; }

Log a message for a canonical event at the error level. Default values
are used for all other parameters.

@since 1.3.0

@param event The canonical event that occurred.
@param message The message to be logged.

Log a message for a canonical event at the error level . Default values are used for all other parameters .


@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());
    }

Before outputting the message inject additional context.

@param joinPoint The JoinPoint.

Before outputting the message inject additional context .


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());
    }

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 ( ) ) ; }

Start writing the Steno JSON wrapper.

@since 1.8.0

@param event Instance of ILoggingEvent.
@param eventName The name of the event.
@param jsonGenerator JsonGenerator instance.
@param objectMapper ObjectMapper instance.
@throws java.io.IOException If writing JSON fails.


public static void writeKeyValuePairs(
            @Nullable final List<String> keys,
            @Nullable final List<Object> values,
            final JsonGenerator jsonGenerator,
            final ObjectMapper objectMapper,
            final StenoEncoder encoder)
            throws IOException {
        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);
                    }
                }
            }
        }
    }

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 ) ; } } } } }

Write specified key-value pairs into the current block.

@since 1.7.0
@param keys The List of keys.
@param values The List of values.
@param jsonGenerator JsonGenerator instance.
@param objectMapper ObjectMapper instance.
@param encoder Instance of StenoEncoder.
@throws IOException If writing JSON fails.

Write specified key - value pairs into the current block .


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();
    }

This function assumes the field object has already been started for this throwable, this only fills in
the fields in the 'exception' or equivalent object and does not create the field in the containing object.

@since 1.7.0
@param throwableProxy Throwable to serialize
@param jsonGenerator  JsonGenerator instance after exception object is started
@param objectMapper ObjectMapper instance.
@throws IOException If writing the Throwable as JSON fails.

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 .


@LogValue
    public Object toLogValue() {
        return LogValueMapFactory.<String, Object>builder()
                .put("logBuilder", _logBuilder)
                .put("duration", _duration)
                .put("lastLogTime", _lastLogTime)
                .put("skipped", _skipped)
                .build();
    }

@ LogValue public Object toLogValue ( ) { return LogValueMapFactory . < String , Object > builder ( ) . put ( "logBuilder" , _logBuilder ) . put ( "duration" , _duration ) . put ( "lastLogTime" , _lastLogTime ) . put ( "skipped" , _skipped ) . build ( ) ; }

Generate a Steno log compatible representation.

@since 1.9.0

@return Steno log compatible representation.

Generate a Steno log compatible representation .


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;
    }

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 ; }

Retrieve the relevant caller data adjusted for Steno logger wrapping.

@param loggingEvent The ILoggingEvent instance.
@return The relevant caller data adjusted for Steno logger wrapping.

Retrieve the relevant caller data adjusted for Steno logger wrapping .


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());
        }
    }

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 ( ) ) ; } }

Safely serialize a value.

@since 1.11.2
@param encoder The StenoEncoder instance.
@param value The Object instance to safely serialize.


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();
    }
  }

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 ( ) ; } }

Create a new database with the specified name.

@param databaseName Database name.
@throws TException If an error occurs creating the database.

Create a new database with the specified name .


protected void checkMappings(int arrayPosition) {
        final int index = positions.indexOfValue(arrayPosition);
        if (index >= 0) {
            positions.removeAt(index);
        }
    }

protected void checkMappings ( int arrayPosition ) { final int index = positions . indexOfValue ( arrayPosition ) ; if ( index >= 0 ) { positions . removeAt ( index ) ; } }


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 "";
	}

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 "" ; }

Parses the save attr.

@param cell
the cell
@param saveCommentsMap
the save comments map
@return the string


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);
		}
	}

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 ) ; } }

Save data to object in context.

@param context
the context
@param saveAttr
the save attr
@param strValue
the str value
@param engine
the engine


public static void 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);
			}
		}
	}

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 ) ; } } }

reload the data from context to websheet row.

@param context
context.
@param fullSaveAttr
full saveattr.
@param row
row.
@param engine
engine.

reload the data from context to websheet row .


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 "";
	}

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 "" ; }

Parses the save attr string.

@param strValue
the str value
@return the string


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;
	}

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 ; }

Gets the save attr list from row.

@param row
the row
@return the save attr list from row


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;
	}

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 ; }

Gets the save attr from list.

@param columnIndex
the column index
@param saveAttrs
the save attrs
@return the save attr from list


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);
	}

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 ) ; }

Sets the save objects in hidden column.

@param row
the row
@param saveAttr
the save attr

Sets the save objects in hidden column .


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);
			}
		}
	}

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 ) ; } } }

Sets the save attrs for sheet.

@param sheet
the sheet
@param minRowNum
the min row num
@param maxRowNum
the max row num
@param saveCommentsMap
the save comments map


public static void 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());
		}
	}

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 ( ) ) ; } }

Sets the save attrs for row.

@param row
the row
@param saveCommentsMap
the save comments map


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;
	}

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 ; }

Prepare context and attrs for cell.

@param poiCell
the poi cell
@param fullName
the full name
@param cellHelper
the cell helper
@return the string


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);
		}
	}

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 ) ; } }

Fmt number.

@param d
the d
@return the string


public final void putShiftAttrs(final String fullName,
			final ConfigRangeAttrs attrs,
			final RowsMapping unitRowsMapping) {
		attrs.setUnitRowsMapping(unitRowsMapping);
		this.shiftMap.put(fullName, attrs);
	}

public final void putShiftAttrs ( final String fullName , final ConfigRangeAttrs attrs , final RowsMapping unitRowsMapping ) { attrs . setUnitRowsMapping ( unitRowsMapping ) ; this . shiftMap . put ( fullName , attrs ) ; }

Put shift attrs.

@param fullName
the full name
@param attrs
the attrs
@param unitRowsMapping
the unit rows mapping


public void setWb(final Workbook pWb) {

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

public void setWb ( final Workbook pWb ) { this . getSerialWb ( ) . setWb ( pWb ) ; this . wbWrapper = XSSFEvaluationWorkbook . create ( ( XSSFWorkbook ) pWb ) ; }

Set up workbook. Also create evaluation wrapper.

@param pWb
workbook.

Set up workbook . Also create evaluation wrapper .


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

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

Return evaluation wrapper if needed.

@return wbwrapper.


public FormulaEvaluator getFormulaEvaluator() {
		if ((this.formulaEvaluator == null) && (this.getWb() != null)) {
			this.formulaEvaluator = this.getWb().getCreationHelper()
					.createFormulaEvaluator();
		}
		return formulaEvaluator;
	}

public FormulaEvaluator getFormulaEvaluator ( ) { if ( ( this . formulaEvaluator == null ) && ( this . getWb ( ) != null ) ) { this . formulaEvaluator = this . getWb ( ) . getCreationHelper ( ) . createFormulaEvaluator ( ) ; } return formulaEvaluator ; }

get formulaevaluator.

@return formulaevaluator.


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;
	}

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 ; }

recalculate max coulumn count across sheets in the workbook.

recalculate max coulumn count across sheets in the workbook .


public int loadWebSheet(final InputStream inputStream,
			final Map<String, Object> pDataContext) {
		return this.getHelper().getWebSheetLoader()
				.loadWorkbook(inputStream, pDataContext);
	}

public int loadWebSheet ( final InputStream inputStream , final Map < String , Object > pDataContext ) { return this . getHelper ( ) . getWebSheetLoader ( ) . loadWorkbook ( inputStream , pDataContext ) ; }

load web sheet from inputStream file with data object.

@param inputStream
input stream file.
@param pDataContext
data object.
@return 1 (success) -1 (failed)

load web sheet from inputStream file with data object .


public int loadWebSheet(final Workbook pWb,
			final Map<String, Object> pDataContext) {
		return this.getHelper().getWebSheetLoader().loadWorkbook(pWb,
				pDataContext);
	}

public int loadWebSheet ( final Workbook pWb , final Map < String , Object > pDataContext ) { return this . getHelper ( ) . getWebSheetLoader ( ) . loadWorkbook ( pWb , pDataContext ) ; }

load web sheet from giving workbook with data object.

@param pWb
workbook.
@param pDataContext
data object.
@return 1 (success) -1 (failed)

load web sheet from giving workbook with data object .


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;
	}

load worksheet by tab name.

@param tabName
tab name.
@return 1 success. -1 failed.


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;
	}

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
;
}


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);
	}

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
)
;
}


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);
	}


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());
	}

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 ( ) ) ; }

populate component.

@param event
component system event.


public SheetConfiguration getCurrentSheetConfig() {
		String currentTabName = this.getCurrent().getCurrentTabName();
		if (currentTabName == null) {
			return null;
		}
		return this.getSheetConfigMap().get(currentTabName);
	}

public SheetConfiguration getCurrentSheetConfig ( ) { String currentTabName = this . getCurrent ( ) . getCurrentTabName ( ) ; if ( currentTabName == null ) { return null ; } return this . getSheetConfigMap ( ) . get ( currentTabName ) ; }

Gets the current sheet config.

@return the currentSheetConfig


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);
		}
	}

load the bean from saving.

@param in
inputstream.
@throws IOException
io exception.


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);

	}

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 ) ; }

Gets the locale.

@param context
the context
@param component
the component
@return the locale


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()));
		}
	}

Return picture to web front end.

@return empty (phase is render_response) or real picture ( browser
request).


public final CellHelper getCellHelper() {
		if ((this.cellHelper == null) && (this.parent != null)) {
			this.cellHelper = new CellHelper(parent);
		}
		return cellHelper;
	}

public final CellHelper getCellHelper ( ) { if ( ( this . cellHelper == null ) && ( this . parent != null ) ) { this . cellHelper = new CellHelper ( parent ) ; } return cellHelper ; }

Gets the cell helper.

@return the cellHelper


public final PicturesHelper getPicHelper() {
		if ((this.picHelper == null) && (this.parent != null)) {
			this.picHelper = new PicturesHelper(parent);
		}
		return picHelper;
	}

public final PicturesHelper getPicHelper ( ) { if ( ( this . picHelper == null ) && ( this . parent != null ) ) { this . picHelper = new PicturesHelper ( parent ) ; } return picHelper ; }

Gets the pic helper.

@return the picHelper


public final ValidationHandler getValidationHandler() {
		if ((this.validationHandler == null) && (this.parent != null)) {
			this.validationHandler = new ValidationHandler(parent);
		}
		return validationHandler;
	}

public final ValidationHandler getValidationHandler ( ) { if ( ( this . validationHandler == null ) && ( this . parent != null ) ) { this . validationHandler = new ValidationHandler ( parent ) ; } return validationHandler ; }

Gets the validation handler.

@return the validationHandler


public final ChartHelper getChartHelper() {
		if ((this.chartHelper == null) && (this.parent != null)) {
			this.chartHelper = new ChartHelper(parent);
		}
		return chartHelper;
	}

public final ChartHelper getChartHelper ( ) { if ( ( this . chartHelper == null ) && ( this . parent != null ) ) { this . chartHelper = new ChartHelper ( parent ) ; } return chartHelper ; }

Gets the chart helper.

@return the chartHelper


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()]);
	}

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 ( ) ] ) ; }

Convert shared formulas.

@param ptgs
the ptgs
@param shiftFormulaRef
the shift formula ref
@return the ptg[]


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());

	}

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
(
)
)
;
}

Convert ptg.

@param ptgs
the ptgs
@param position
the position
@param shiftFormulaRef
the shift formula ref
@param ptg
the ptg
@return the ptg[]


private static Ptg[] 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);
	}

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
==
)
||
(
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
)
;
}

Convert ptg for watch list.

@param ptgs
the ptgs
@param position
the position
@param shiftFormulaRef
the shift formula ref
@param ptg
the ptg
@param originalOperandClass
the original operand class
@param currentRow
the current row
@return the ptg[]


private static Ptg[] 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;
	}

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 ; }

Single ptg.

@param ptg
the ptg
@param originalOperandClass
the original operand class
@param formulaChanged
the formula changed
@return the ptg[]


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;
	}

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 ; }

Gets the rows list.

@param currentRow
the current row
@param currentRowsMappingList
the current rows mapping list
@return the rows list


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;
	}

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 ; }

assemble rowslist from rowsmapping.

@param all
list all rows.
@param current
current row list.
@return the list


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());
			}
		}

	}

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 ( ) ) ; } } }

Fixup ref relative row one to one.

@param ptg
the ptg
@param newRow
the new row
@return the object


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;
			}
		}
	}

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 ; } } }

Builds the dynamic row for ref ptg base.

@param ptg
the ptg
@param originalOperandClass
the original operand class
@param rowList
the row list
@param newPtg
the new ptg
@param includeParenthesis
the include parenthesis

Builds the dynamic row for ref ptg base .


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;
			}
		}
	}

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 ; } } }

Builds the dynamic row for area ptg base.

@param ptg
the ptg
@param originalOperandClass
the original operand class
@param rowList
the row list
@param newPtg
the new ptg

Builds the dynamic row for area ptg base .


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));
		}
	}

public
static
XColor
getBgColor
(
final
CTPlotArea
ctPlot
,
final
ThemesTable
themeTable
)
{
CTSolidColorFillProperties
colorFill
=
;
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
!=
)
{
return
xcolor
;
}
else
{
return
new
XColor
(
new
XSSFColor
(
Color
.
WHITE
)
)
;
}
}

retrieve background color for plot area.

@param ctPlot
plot area instance.
@param themeTable
theme table contain theme color.
@return xssfcolor with alpha setting.

retrieve background color for plot area .


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);
		}

	}

public
static
XColor
geColorFromSpPr
(
final
int
index
,
final
CTShapeProperties
ctSpPr
,
final
ThemesTable
themeTable
,
final
boolean
isLineColor
)
{
CTSolidColorFillProperties
colorFill
=
;
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
!=
)
{
return
xcolor
;
}
else
{
return
getXColorWithAutomaticFill
(
index
,
themeTable
)
;
}
}

get line color of line chart from CTLineSer.

@param index
line index.
@param ctSpPr
the ct sp pr
@param themeTable
themeTable.
@param isLineColor
is line color.
@return xcolor.

get line color of line chart from CTLineSer .


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;
	}

Find automatic fill color.

@param themeTable
the theme table
@param colorFill
the color fill
@return the x color


private static XColor getXColorFromSchemeClr(
			final CTSchemeColor ctsColor, final ThemesTable themeTable) {
		if (ctsColor.getVal() != null) {
			return getXColorWithSchema(ctsColor.getVal().toString(), 0,
					ctsColor, themeTable);
		}
		return null;
	}

private static XColor getXColorFromSchemeClr ( final CTSchemeColor ctsColor , final ThemesTable themeTable ) { if ( ctsColor . getVal ( ) != null ) { return getXColorWithSchema ( ctsColor . getVal ( ) . toString ( ) , 0 , ctsColor , themeTable ) ; } return null ; }

retrieve xcolor from scheme color.

@param ctsColor
scheme color
@param themeTable
theme table
@return xcolor


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);
	}

private
static
XColor
getXColorFromRgbClr
(
final
CTSRgbColor
ctrColor
)
{
XSSFColor
bcolor
=
;
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
;
}
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
)
;
}

get xcolor from ctsRgbColor.

@param ctrColor
ctsRgbColor
@return xcolor


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);
	}

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 ) ; }

Get xcolor for automatic fill setting. This is the default setting in
Excel for chart colors. Normally the colors will be accent1 to 7.

@param index
line index.
@param themeTable
theme table.
@return xcolor.

Get xcolor for automatic fill setting . This is the default setting in Excel for chart colors . Normally the colors will be accent1 to 7 .


public static Color xssfClrToClr(final XSSFColor xssfColor) {
		short[] rgb = getTripletFromXSSFColor(xssfColor);
		return new Color(rgb[0], rgb[1], rgb[2]);
	}

public static Color xssfClrToClr ( final XSSFColor xssfColor ) { short [ ] rgb = getTripletFromXSSFColor ( xssfColor ) ; return new Color ( rgb [ 0 ] , rgb [ 1 ] , rgb [ 2 ] ) ; }

convert xssf color to color.

@param xssfColor
xssf color
@return color


public static short[] getTripletFromXSSFColor(
			final XSSFColor xssfColor) {

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

Convert xssfcolor to triple let numbers.

@param xssfColor
xssf color.
@return triple lets.

Convert xssfcolor to triple let numbers .


static String getBgColorFromCell(final Workbook wb, final Cell poiCell,
			final CellStyle cellStyle) {

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

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

Gets the bg color from cell.

@param wb
the wb
@param poiCell
the poi cell
@param cellStyle
the cell style
@return the bg color from cell


private static String findComponentNameFromClass(
			final UIComponent component) {

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

	}

private static String findComponentNameFromClass ( final UIComponent component ) { String cname = component . getClass ( ) . getSimpleName ( ) ; if ( supportComponents . contains ( cname ) ) { return cname ; } return null ; }

find component according it's class.

@param component
component.
@return component name.


public static void populateAttributes(final UIComponent component,
			final FacesCell fcell,
			final Map<String, Map<String, String>> defaultControlMap) {

		List<CellFormAttributes> inputAttrs = fcell.getInputAttrs();
		String cname = findComponentNameFromClass(component);
		if (cname == null) {
			return;
		}

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

	}

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

populate attributes.

@param component
component obj.
@param fcell
facescell.
@param defaultControlMap
default control map.


private static AttributesType matchParaMeterOfMethod(final Object obj,
			final String methodName) {

		for (AttributesType attr : AttributesType.values()) {
			try {
				obj.getClass().getMethod(methodName,
						new Class[] { attr.clazz });
				return attr;

			} catch (Exception ex) {
				LOG.log(Level.FINE, " error in matchParaMeterOfMethod = "
						+ ex.getLocalizedMessage(), ex);
			}
		}
		return null;
	}

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

match parameter of method.

@param obj
object.
@param methodName
method name.
@return index of paraMatchArray if mached. otherwise return -1.


public static void setObjectProperty(final Object obj,
			final String propertyName, final String propertyValue,
			final boolean ignoreNonExisting) {
		try {

			String methodName = "set"
					+ Character.toUpperCase(propertyName.charAt(0))
					+ propertyName.substring(1);
			AttributesType parameterType = matchParaMeterOfMethod(obj,
					methodName);
			if (parameterType != null) {
				Method method = obj.getClass().getMethod(methodName,
						new Class[] { parameterType.clazz });
				method.invoke(obj,
						convertToObject(parameterType, propertyValue));
			}
		} catch (Exception e) {
			String msg = "failed to set property '" + propertyName
					+ "' to value '" + propertyValue + "' for object "
					+ obj;
			if (ignoreNonExisting) {
				LOG.log(Level.FINE, msg, e);
			} else {
				LOG.warning(msg);
				throw new IllegalArgumentException(e);
			}
		}
	}

public
static
void
setObjectProperty
(
final
Object
obj
,
final
String
propertyName
,
final
String
propertyValue
,
final
boolean
ignoreNonExisting
)
{
try
{
String
methodName
=
"set"
+
Character
.
toUpperCase
(
propertyName
.
charAt
(
0
)
)
+
propertyName
.
substring
(
1
)
;
AttributesType
parameterType
=
matchParaMeterOfMethod
(
obj
,
methodName
)
;
if
(
parameterType
!=
)
{
Method
method
=
obj
.
getClass
(
)
.
getMethod
(
methodName
,
new
Class
[
]
{
parameterType
.
clazz
}
)
;
method
.
invoke
(
obj
,
convertToObject
(
parameterType
,
propertyValue
)
)
;
}
}
catch
(
Exception
e
)
{
String
msg
=
"failed to set property '"
+
propertyName
+
"' to value '"
+
propertyValue
+
"' for object "
+
obj
;
if
(
ignoreNonExisting
)
{
LOG
.
log
(
Level
.
FINE
,
msg
,
e
)
;
}
else
{
LOG
.
warning
(
msg
)
;
throw
new
IllegalArgumentException
(
e
)
;
}
}
}

set object property.

@param obj
object.
@param propertyName
property name.
@param propertyValue
value.
@param ignoreNonExisting
true if ignore non exist property.


public static String getObjectPropertyValue(final Object obj,
			final String propertyName, final boolean ignoreNonExisting) {
		try {
			Method method = obj.getClass()
					.getMethod("get"
							+ Character.toUpperCase(propertyName.charAt(0))
							+ propertyName.substring(1));
			return (String) method.invoke(obj);
		} catch (Exception e) {
			String msg = "failed to get property '" + propertyName
					+ "' for object " + obj;
			if (ignoreNonExisting) {
				LOG.log(Level.FINE, msg, e);
			} else {
				LOG.warning(msg);
				throw new IllegalArgumentException(e);
			}
		}
		return null;
	}

public
static
String
getObjectPropertyValue
(
final
Object
obj
,
final
String
propertyName
,
final
boolean
ignoreNonExisting
)
{
try
{
Method
method
=
obj
.
getClass
(
)
.
getMethod
(
"get"
+
Character
.
toUpperCase
(
propertyName
.
charAt
(
0
)
)
+
propertyName
.
substring
(
1
)
)
;
return
(
String
)
method
.
invoke
(
obj
)
;
}
catch
(
Exception
e
)
{
String
msg
=
"failed to get property '"
+
propertyName
+
"' for object "
+
obj
;
if
(
ignoreNonExisting
)
{
LOG
.
log
(
Level
.
FINE
,
msg
,
e
)
;
}
else
{
LOG
.
warning
(
msg
)
;
throw
new
IllegalArgumentException
(
e
)
;
}
}
return
;
}

get object property value.

@param obj
object.
@param propertyName
property name.
@param ignoreNonExisting
true ignore no existing.
@return perperty value.


public static void setupControlAttributes(final int originRowIndex,
			final FacesCell fcell, final Cell poiCell,
			final SheetConfiguration sheetConfig,
			final CellAttributesMap cellAttributesMap) {
		int rowIndex = originRowIndex;
		if (rowIndex < 0) {
			rowIndex = poiCell.getRowIndex();
		}

		String skey = poiCell.getSheet().getSheetName() + "!" + CellUtility
				.getCellIndexNumberKey(poiCell.getColumnIndex(), rowIndex);

		Map<String, String> commentMap = cellAttributesMap
				.getTemplateCommentMap().get("$$");
		if (commentMap != null) {
			String comment = commentMap.get(skey);
			if (comment != null) {
				CommandUtility.createCellComment(poiCell, comment,
						sheetConfig.getFinalCommentMap());
			}
		}

		String widgetType = cellAttributesMap.getCellInputType().get(skey);
		if (widgetType != null) {
			fcell.setControl(widgetType.toLowerCase());

			fcell.setInputAttrs(
					cellAttributesMap.getCellInputAttributes().get(skey));
			fcell.setSelectItemAttrs(cellAttributesMap
					.getCellSelectItemsAttributes().get(skey));
			fcell.setDatePattern(
					cellAttributesMap.getCellDatePattern().get(skey));
		}

	}

public static void setupControlAttributes ( final int originRowIndex , final FacesCell fcell , final Cell poiCell , final SheetConfiguration sheetConfig , final CellAttributesMap cellAttributesMap ) { int rowIndex = originRowIndex ; if ( rowIndex < 0 ) { rowIndex = poiCell . getRowIndex ( ) ; } String skey = poiCell . getSheet ( ) . getSheetName ( ) + "!" + CellUtility . getCellIndexNumberKey ( poiCell . getColumnIndex ( ) , rowIndex ) ; Map < String , String > commentMap = cellAttributesMap . getTemplateCommentMap ( ) . get ( "$$" ) ; if ( commentMap != null ) { String comment = commentMap . get ( skey ) ; if ( comment != null ) { CommandUtility . createCellComment ( poiCell , comment , sheetConfig . getFinalCommentMap ( ) ) ; } } String widgetType = cellAttributesMap . getCellInputType ( ) . get ( skey ) ; if ( widgetType != null ) { fcell . setControl ( widgetType . toLowerCase ( ) ) ; fcell . setInputAttrs ( cellAttributesMap . getCellInputAttributes ( ) . get ( skey ) ) ; fcell . setSelectItemAttrs ( cellAttributesMap . getCellSelectItemsAttributes ( ) . get ( skey ) ) ; fcell . setDatePattern ( cellAttributesMap . getCellDatePattern ( ) . get ( skey ) ) ; } }

Setup control attributes.

@param originRowIndex
the origin row index
@param fcell
the fcell
@param poiCell
the poi cell
@param sheetConfig
the sheet config
@param cellAttributesMap
the cell attributes map


public static List<CellFormAttributes> findCellValidateAttributes(
			final Map<String, List<CellFormAttributes>> validateMaps,
			final int originRowIndex,
			final Cell cell) {
		String key = cell.getSheet().getSheetName() + "!" + CellUtility
				.getCellIndexNumberKey(cell.getColumnIndex(), originRowIndex);

		return validateMaps.get(key);
	}

public static List < CellFormAttributes > findCellValidateAttributes ( final Map < String , List < CellFormAttributes > > validateMaps , final int originRowIndex , final Cell cell ) { String key = cell . getSheet ( ) . getSheetName ( ) + "!" + CellUtility . getCellIndexNumberKey ( cell . getColumnIndex ( ) , originRowIndex ) ; return validateMaps . get ( key ) ; }

Find cell validate attributes.

@param validateMaps
validateMaps.
@param originRowIndex
original Row Index from facesRow.
@param cell
cell.
@return list.


public final void setupFacesCellPictureCharts(final Sheet sheet1,
			final FacesCell fcell, final Cell cell, final String fId) {
		if (parent.getPicturesMap() != null) {
			setupFacesCellPicture(sheet1, fcell, cell, fId);
		}
		if (parent.getCharsData().getChartsMap() != null) {
			setupFacesCellCharts(sheet1, fcell, cell, fId);
		}
	}

public final void setupFacesCellPictureCharts ( final Sheet sheet1 , final FacesCell fcell , final Cell cell , final String fId ) { if ( parent . getPicturesMap ( ) != null ) { setupFacesCellPicture ( sheet1 , fcell , cell , fId ) ; } if ( parent . getCharsData ( ) . getChartsMap ( ) != null ) { setupFacesCellCharts ( sheet1 , fcell , cell , fId ) ; } }

Setup faces cell picture charts.

@param sheet1
the sheet 1
@param fcell
the fcell
@param cell
the cell
@param fId
the f id


private void setupFacesCellCharts(final Sheet sheet1,
			final FacesCell fcell, final Cell cell, final String fId) {
		try {
			String chartId = parent.getCharsData().getChartPositionMap()
					.get(fId);
			if (chartId != null) {
				BufferedImage img = parent.getCharsData().getChartsMap()
						.get(chartId);
				if (img != null) {
					fcell.setContainChart(true);
					fcell.setChartId(chartId);
					fcell.setChartStyle(PicturesUtility.generateChartStyle(
							sheet1, fcell, cell, chartId,
							parent.getCharsData().getChartAnchorsMap()));
				}
			}
		} catch (Exception ex) {
			LOG.log(Level.SEVERE,
					"setupFacesCell Charts error = " + ex.getMessage(), ex);
		}
	}

private
void
setupFacesCellCharts
(
final
Sheet
sheet1
,
final
FacesCell
fcell
,
final
Cell
cell
,
final
String
fId
)
{
try
{
String
chartId
=
parent
.
getCharsData
(
)
.
getChartPositionMap
(
)
.
get
(
fId
)
;
if
(
chartId
!=
)
{
BufferedImage
img
=
parent
.
getCharsData
(
)
.
getChartsMap
(
)
.
get
(
chartId
)
;
if
(
img
!=
)
{
fcell
.
setContainChart
(
true
)
;
fcell
.
setChartId
(
chartId
)
;
fcell
.
setChartStyle
(
PicturesUtility
.
generateChartStyle
(
sheet1
,
fcell
,
cell
,
chartId
,
parent
.
getCharsData
(
)
.
getChartAnchorsMap
(
)
)
)
;
}
}
}
catch
(
Exception
ex
)
{
LOG
.
log
(
Level
.
SEVERE
,
"setupFacesCell Charts error = "
+
ex
.
getMessage
(
)
,
ex
)
;
}
}

Setup faces cell charts.

@param sheet1
the sheet 1
@param fcell
the fcell
@param cell
the cell
@param fId
the f id


private void setupFacesCellPicture(final Sheet sheet1,
			final FacesCell fcell, final Cell cell, final String fId) {
		try {
			Picture pic = parent.getPicturesMap().get(fId);
			if (pic != null) {
				fcell.setContainPic(true);
				fcell.setPictureId(fId);
				fcell.setPictureStyle(PicturesUtility
						.generatePictureStyle(sheet1, fcell, cell, pic));
			}
		} catch (Exception ex) {
			LOG.log(Level.SEVERE,
					"setupFacesCell Picture error = " + ex.getMessage(),
					ex);
		}
	}

private
void
setupFacesCellPicture
(
final
Sheet
sheet1
,
final
FacesCell
fcell
,
final
Cell
cell
,
final
String
fId
)
{
try
{
Picture
pic
=
parent
.
getPicturesMap
(
)
.
get
(
fId
)
;
if
(
pic
!=
)
{
fcell
.
setContainPic
(
true
)
;
fcell
.
setPictureId
(
fId
)
;
fcell
.
setPictureStyle
(
PicturesUtility
.
generatePictureStyle
(
sheet1
,
fcell
,
cell
,
pic
)
)
;
}
}
catch
(
Exception
ex
)
{
LOG
.
log
(
Level
.
SEVERE
,
"setupFacesCell Picture error = "
+
ex
.
getMessage
(
)
,
ex
)
;
}
}

Setup faces cell picture.

@param sheet1
the sheet 1
@param fcell
the fcell
@param cell
the cell
@param fId
the f id


private void initChartsMap(final Workbook wb) {
		try {
			if (wb instanceof XSSFWorkbook) {
				initXSSFChartsMap((XSSFWorkbook) wb, parent.getCharsData());
			}
		} catch (Exception e) {
			LOG.log(Level.SEVERE, "getChartsMap Error Exception = "
					+ e.getLocalizedMessage(), e);
		}
	}

private
void
initChartsMap
(
final
Workbook
wb
)
{
try
{
if
(
wb
instanceof
XSSFWorkbook
)
{
initXSSFChartsMap
(
(
XSSFWorkbook
)
wb
,
parent
.
getCharsData
(
)
)
;
}
}
catch
(
Exception
e
)
{
LOG
.
log
(
Level
.
SEVERE
,
"getChartsMap Error Exception = "
+
e
.
getLocalizedMessage
(
)
,
e
)
;
}
}

initial chart map for specified workbook.

@param wb
specified workbook.

initial chart map for specified workbook .


private String getPieTitle(final ChartData chartData) {
		for (ChartSeries chartSeries : chartData.getSeriesList()) {
			if (chartSeries != null) {
				return getParsedCellValue(chartSeries.getSeriesLabel());
			}
		}
		return "";

	}

private String getPieTitle ( final ChartData chartData ) { for ( ChartSeries chartSeries : chartData . getSeriesList ( ) ) { if ( chartSeries != null ) { return getParsedCellValue ( chartSeries . getSeriesLabel ( ) ) ; } } return "" ; }

return pie chart title from chartData.

@param chartData
ChartData object.
@return title (String).


public final void setSeriesStyle(final JFreeChart chart,
			final int seriesIndex, final String style) {
		if (chart != null && style != null) {
			BasicStroke stroke = ChartUtility.toStroke(style);

			Plot plot = chart.getPlot();
			if (plot instanceof CategoryPlot) {
				CategoryPlot categoryPlot = chart.getCategoryPlot();
				CategoryItemRenderer cir = categoryPlot.getRenderer();
				try {
					cir.setSeriesStroke(seriesIndex, stroke); // series line
																// style
				} catch (Exception e) {
					LOG.log(Level.SEVERE,
							"Error setting style '" + style
									+ "' for series '"
									+ Integer.toString(seriesIndex)
									+ "' of chart '" + chart.toString()
									+ "': " + e.getLocalizedMessage(),
							e);
				}
			} else if (plot instanceof XYPlot) {
				XYPlot xyPlot = chart.getXYPlot();
				XYItemRenderer xyir = xyPlot.getRenderer();
				try {
					xyir.setSeriesStroke(seriesIndex, stroke); // series line
																// style
				} catch (Exception e) {
					LOG.log(Level.SEVERE,
							"Error setting style '" + style
									+ "' for series '"
									+ Integer.toString(seriesIndex)
									+ "' of chart '" + chart.toString()
									+ "': " + e.getLocalizedMessage(),
							e);
				}
			} else {
				LOG.log(Level.FINE, "setSeriesColor() unsupported plot: {}",
						plot.toString());
			}
		}
	}

public
final
void
setSeriesStyle
(
final
JFreeChart
chart
,
final
int
seriesIndex
,
final
String
style
)
{
if
(
chart
!=
&&
style
!=
)
{
BasicStroke
stroke
=
ChartUtility
.
toStroke
(
style
)
;
Plot
plot
=
chart
.
getPlot
(
)
;
if
(
plot
instanceof
CategoryPlot
)
{
CategoryPlot
categoryPlot
=
chart
.
getCategoryPlot
(
)
;
CategoryItemRenderer
cir
=
categoryPlot
.
getRenderer
(
)
;
try
{
cir
.
setSeriesStroke
(
seriesIndex
,
stroke
)
;
// series line
// style
}
catch
(
Exception
e
)
{
LOG
.
log
(
Level
.
SEVERE
,
"Error setting style '"
+
style
+
"' for series '"
+
Integer
.
toString
(
seriesIndex
)
+
"' of chart '"
+
chart
.
toString
(
)
+
"': "
+
e
.
getLocalizedMessage
(
)
,
e
)
;
}
}
else
if
(
plot
instanceof
XYPlot
)
{
XYPlot
xyPlot
=
chart
.
getXYPlot
(
)
;
XYItemRenderer
xyir
=
xyPlot
.
getRenderer
(
)
;
try
{
xyir
.
setSeriesStroke
(
seriesIndex
,
stroke
)
;
// series line
// style
}
catch
(
Exception
e
)
{
LOG
.
log
(
Level
.
SEVERE
,
"Error setting style '"
+
style
+
"' for series '"
+
Integer
.
toString
(
seriesIndex
)
+
"' of chart '"
+
chart
.
toString
(
)
+
"': "
+
e
.
getLocalizedMessage
(
)
,
e
)
;
}
}
else
{
LOG
.
log
(
Level
.
FINE
,
"setSeriesColor() unsupported plot: {}"
,
plot
.
toString
(
)
)
;
}
}
}

Set color of series.

@param chart
JFreeChart.
@param seriesIndex
Index of series to set color of (0 = first series)
@param style
One of STYLE_xxx.


public JFreeChart createPie3DChart(final ChartData chartData) {

		// create the chart...
		final JFreeChart chart = ChartFactory.createPieChart3D(
				getPieTitle(chartData), // chart title
				createPieDataset(chartData), // data
				true, // include legend
				false, // tooltips
				false // urls
		);

		setupPieStyle(chart, chartData);

		return chart;

	}

public
JFreeChart
createPie3DChart
(
final
ChartData
chartData
)
{
// create the chart...
final
JFreeChart
chart
=
ChartFactory
.
createPieChart3D
(
getPieTitle
(
chartData
)
,
// chart title
createPieDataset
(
chartData
)
,
// data
true
,
// include legend
false
,
// tooltips
false
// urls
)
;
setupPieStyle
(
chart
,
chartData
)
;
return
chart
;
}

create pie 3d chart.

@param chartData
chart data.
@return jfreechart.


private void setupBarStyle(final JFreeChart chart,
			final ChartData chartData) {
		setupStyle(chart, chartData);
		CategoryPlot plot = (CategoryPlot) chart.getPlot();
		BarRenderer renderer = (BarRenderer) plot.getRenderer();
		renderer.setBarPainter(new StandardBarPainter());
		renderer.setItemMargin(TieConstants.DEFAULT_BAR_STYLE_ITEM_MARGIN);

		plot.setForegroundAlpha(
				TieConstants.DEFAULT_BARSTYLE_FOREGROUND_ALPHA);
	}

private void setupBarStyle ( final JFreeChart chart , final ChartData chartData ) { setupStyle ( chart , chartData ) ; CategoryPlot plot = ( CategoryPlot ) chart . getPlot ( ) ; BarRenderer renderer = ( BarRenderer ) plot . getRenderer ( ) ; renderer . setBarPainter ( new StandardBarPainter ( ) ) ; renderer . setItemMargin ( TieConstants . DEFAULT_BAR_STYLE_ITEM_MARGIN ) ; plot . setForegroundAlpha ( TieConstants . DEFAULT_BARSTYLE_FOREGROUND_ALPHA ) ; }

finalize the style for barchart. This will call setupStyle common first.

@param chart
jfreechart.
@param chartData
contain information gathered from excel chart object.

finalize the style for barchart . This will call setupStyle common first .


private void initXSSFChartsMap(final XSSFWorkbook wb,
			final ChartsData chartsData) {

		initAnchorsMap(wb, chartsData);
		Map<String, ClientAnchor> anchorMap = chartsData
				.getChartAnchorsMap();

		Map<String, BufferedImage> chartMap = chartsData.getChartsMap();
		Map<String, ChartData> chartDataMap = chartsData.getChartDataMap();
		chartMap.clear();
		chartDataMap.clear();

		for (int i = 0; i < wb.getNumberOfSheets(); i++) {
			XSSFSheet sheet = wb.getSheetAt(i);
			XSSFDrawing drawing = sheet.createDrawingPatriarch();
			List<XSSFChart> charts = drawing.getCharts();
			if ((charts != null) && (!charts.isEmpty())) {
				for (XSSFChart chart : charts) {
					generateSingleXSSFChart(chart,
							getChartIdFromParent(chart,
									sheet.getSheetName()),
							sheet, anchorMap, chartMap, chartDataMap);
				}
			}
		}

	}

private void initXSSFChartsMap ( final XSSFWorkbook wb , final ChartsData chartsData ) { initAnchorsMap ( wb , chartsData ) ; Map < String , ClientAnchor > anchorMap = chartsData . getChartAnchorsMap ( ) ; Map < String , BufferedImage > chartMap = chartsData . getChartsMap ( ) ; Map < String , ChartData > chartDataMap = chartsData . getChartDataMap ( ) ; chartMap . clear ( ) ; chartDataMap . clear ( ) ; for ( int i = 0 ; i < wb . getNumberOfSheets ( ) ; i ++ ) { XSSFSheet sheet = wb . getSheetAt ( i ) ; XSSFDrawing drawing = sheet . createDrawingPatriarch ( ) ; List < XSSFChart > charts = drawing . getCharts ( ) ; if ( ( charts != null ) && ( ! charts . isEmpty ( ) ) ) { for ( XSSFChart chart : charts ) { generateSingleXSSFChart ( chart , getChartIdFromParent ( chart , sheet . getSheetName ( ) ) , sheet , anchorMap , chartMap , chartDataMap ) ; } } } }

initial chart map for XSSF format file. XSSF file is actually the only
format in POI support chart object.

@param wb
xssf workbook.
@param chartsData
the charts data

initial chart map for XSSF format file . XSSF file is actually the only format in POI support chart object .


private String getChartIdFromParent(final XSSFChart chart,
			final String sheetName) {
		if (chart.getParent() != null) {
			for (RelationPart rp : chart.getParent().getRelationParts()) {
				if (rp.getDocumentPart() == chart) {
					return sheetName + "!" + rp.getRelationship().getId();
				}
			}
		}
		return null;
	}

private String getChartIdFromParent ( final XSSFChart chart , final String sheetName ) { if ( chart . getParent ( ) != null ) { for ( RelationPart rp : chart . getParent ( ) . getRelationParts ( ) ) { if ( rp . getDocumentPart ( ) == chart ) { return sheetName + "!" + rp . getRelationship ( ) . getId ( ) ; } } } return null ; }

Gets the chart id from parent.

@param chart
the chart
@param sheetName
the sheet name
@return the chart id from parent