Search in sources :

Example 1 with FillPatternType

use of org.apache.poi.ss.usermodel.FillPatternType in project poi by apache.

the class CellUtil method getFillPattern.

/**
     * Utility method that returns the named FillPatternType value form the given map.
     *
     * @param properties map of named properties (String -> Object)
     * @param name property name
     * @return FillPatternType style if set, otherwise {@link FillPatternType#NO_FILL}
     * @since POI 3.15 beta 3
     */
private static FillPatternType getFillPattern(Map<String, Object> properties, String name) {
    Object value = properties.get(name);
    FillPatternType pattern;
    if (value instanceof FillPatternType) {
        pattern = (FillPatternType) value;
    } else // @deprecated 3.15 beta 2. getFillPattern will only work on FillPatternType enums instead of codes in the future.
    if (value instanceof Short) {
        if (log.check(POILogger.WARN)) {
            log.log(POILogger.WARN, "Deprecation warning: CellUtil properties map uses Short values for " + name + ". Should use FillPatternType enums instead.");
        }
        short code = ((Short) value).shortValue();
        pattern = FillPatternType.forInt(code);
    } else if (value == null) {
        pattern = FillPatternType.NO_FILL;
    } else {
        throw new RuntimeException("Unexpected fill pattern style class. Must be FillPatternType or Short (deprecated).");
    }
    return pattern;
}
Also used : FillPatternType(org.apache.poi.ss.usermodel.FillPatternType)

Aggregations

FillPatternType (org.apache.poi.ss.usermodel.FillPatternType)1