diff options
Diffstat (limited to 'poi-ooxml/src')
-rw-r--r-- | poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFDataValidation.java | 83 | ||||
-rw-r--r-- | poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/VerticalAlign.java | 2 |
2 files changed, 45 insertions, 40 deletions
diff --git a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFDataValidation.java b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFDataValidation.java index 4cc723ee2c..a284c96bde 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFDataValidation.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFDataValidation.java @@ -16,6 +16,7 @@ ==================================================================== */ package org.apache.poi.xssf.usermodel; +import java.util.Collections; import java.util.HashMap; import java.util.Map; @@ -34,49 +35,53 @@ import org.openxmlformats.schemas.spreadsheetml.x2006.main.STDataValidationOpera public class XSSFDataValidation implements DataValidation { private static final int MAX_TEXT_LENGTH = 255; - private CTDataValidation ctDataValidation; - private XSSFDataValidationConstraint validationConstraint; - private CellRangeAddressList regions; + private final CTDataValidation ctDataValidation; + private final XSSFDataValidationConstraint validationConstraint; + private final CellRangeAddressList regions; - static Map<Integer, STDataValidationOperator.Enum> operatorTypeMappings = new HashMap<>(); - static Map<STDataValidationOperator.Enum, Integer> operatorTypeReverseMappings = new HashMap<>(); - static Map<Integer, STDataValidationType.Enum> validationTypeMappings = new HashMap<>(); - static Map<STDataValidationType.Enum, Integer> validationTypeReverseMappings = new HashMap<>(); - static Map<Integer, STDataValidationErrorStyle.Enum> errorStyleMappings = new HashMap<>(); - static Map<STDataValidationErrorStyle.Enum, Integer> reverseErrorStyleMappings; + static final Map<Integer, STDataValidationOperator.Enum> operatorTypeMappings; + static final Map<STDataValidationOperator.Enum, Integer> operatorTypeReverseMappings; + static final Map<Integer, STDataValidationType.Enum> validationTypeMappings; + static final Map<STDataValidationType.Enum, Integer> validationTypeReverseMappings; + static final Map<Integer, STDataValidationErrorStyle.Enum> errorStyleMappings; + static final Map<STDataValidationErrorStyle.Enum, Integer> reverseErrorStyleMappings; static { - errorStyleMappings.put(DataValidation.ErrorStyle.INFO, STDataValidationErrorStyle.INFORMATION); - errorStyleMappings.put(DataValidation.ErrorStyle.STOP, STDataValidationErrorStyle.STOP); - errorStyleMappings.put(DataValidation.ErrorStyle.WARNING, STDataValidationErrorStyle.WARNING); - - reverseErrorStyleMappings = MapUtils.invertMap(errorStyleMappings); - - operatorTypeMappings.put(DataValidationConstraint.OperatorType.BETWEEN,STDataValidationOperator.BETWEEN); - operatorTypeMappings.put(DataValidationConstraint.OperatorType.NOT_BETWEEN,STDataValidationOperator.NOT_BETWEEN); - operatorTypeMappings.put(DataValidationConstraint.OperatorType.EQUAL,STDataValidationOperator.EQUAL); - operatorTypeMappings.put(DataValidationConstraint.OperatorType.NOT_EQUAL,STDataValidationOperator.NOT_EQUAL); - operatorTypeMappings.put(DataValidationConstraint.OperatorType.GREATER_THAN,STDataValidationOperator.GREATER_THAN); - operatorTypeMappings.put(DataValidationConstraint.OperatorType.GREATER_OR_EQUAL,STDataValidationOperator.GREATER_THAN_OR_EQUAL); - operatorTypeMappings.put(DataValidationConstraint.OperatorType.LESS_THAN,STDataValidationOperator.LESS_THAN); - operatorTypeMappings.put(DataValidationConstraint.OperatorType.LESS_OR_EQUAL,STDataValidationOperator.LESS_THAN_OR_EQUAL); - - for( Map.Entry<Integer,STDataValidationOperator.Enum> entry : operatorTypeMappings.entrySet() ) { - operatorTypeReverseMappings.put(entry.getValue(),entry.getKey()); - } - validationTypeMappings.put(DataValidationConstraint.ValidationType.FORMULA,STDataValidationType.CUSTOM); - validationTypeMappings.put(DataValidationConstraint.ValidationType.DATE,STDataValidationType.DATE); - validationTypeMappings.put(DataValidationConstraint.ValidationType.DECIMAL,STDataValidationType.DECIMAL); - validationTypeMappings.put(DataValidationConstraint.ValidationType.LIST,STDataValidationType.LIST); - validationTypeMappings.put(DataValidationConstraint.ValidationType.ANY,STDataValidationType.NONE); - validationTypeMappings.put(DataValidationConstraint.ValidationType.TEXT_LENGTH,STDataValidationType.TEXT_LENGTH); - validationTypeMappings.put(DataValidationConstraint.ValidationType.TIME,STDataValidationType.TIME); - validationTypeMappings.put(DataValidationConstraint.ValidationType.INTEGER,STDataValidationType.WHOLE); - - for( Map.Entry<Integer,STDataValidationType.Enum> entry : validationTypeMappings.entrySet() ) { - validationTypeReverseMappings.put(entry.getValue(),entry.getKey()); - } + final HashMap<Integer, STDataValidationErrorStyle.Enum> esMappings = new HashMap<>(); + esMappings.put(DataValidation.ErrorStyle.INFO, STDataValidationErrorStyle.INFORMATION); + esMappings.put(DataValidation.ErrorStyle.STOP, STDataValidationErrorStyle.STOP); + esMappings.put(DataValidation.ErrorStyle.WARNING, STDataValidationErrorStyle.WARNING); + errorStyleMappings = Collections.unmodifiableMap(esMappings); + + reverseErrorStyleMappings = Collections.unmodifiableMap(MapUtils.invertMap(esMappings)); + + final Map<Integer, STDataValidationOperator.Enum> otMappings = new HashMap<>(); + otMappings.put(DataValidationConstraint.OperatorType.BETWEEN,STDataValidationOperator.BETWEEN); + otMappings.put(DataValidationConstraint.OperatorType.NOT_BETWEEN,STDataValidationOperator.NOT_BETWEEN); + otMappings.put(DataValidationConstraint.OperatorType.EQUAL,STDataValidationOperator.EQUAL); + otMappings.put(DataValidationConstraint.OperatorType.NOT_EQUAL,STDataValidationOperator.NOT_EQUAL); + otMappings.put(DataValidationConstraint.OperatorType.GREATER_THAN,STDataValidationOperator.GREATER_THAN); + otMappings.put(DataValidationConstraint.OperatorType.GREATER_OR_EQUAL,STDataValidationOperator.GREATER_THAN_OR_EQUAL); + otMappings.put(DataValidationConstraint.OperatorType.LESS_THAN,STDataValidationOperator.LESS_THAN); + otMappings.put(DataValidationConstraint.OperatorType.LESS_OR_EQUAL,STDataValidationOperator.LESS_THAN_OR_EQUAL); + operatorTypeMappings = Collections.unmodifiableMap(otMappings); + + operatorTypeReverseMappings = Collections.unmodifiableMap(MapUtils.invertMap(otMappings)); + + final Map<Integer, STDataValidationType.Enum> vtMappings = new HashMap<>(); + vtMappings.put(DataValidationConstraint.ValidationType.FORMULA,STDataValidationType.CUSTOM); + vtMappings.put(DataValidationConstraint.ValidationType.DATE,STDataValidationType.DATE); + vtMappings.put(DataValidationConstraint.ValidationType.DECIMAL,STDataValidationType.DECIMAL); + vtMappings.put(DataValidationConstraint.ValidationType.LIST,STDataValidationType.LIST); + vtMappings.put(DataValidationConstraint.ValidationType.ANY,STDataValidationType.NONE); + vtMappings.put(DataValidationConstraint.ValidationType.TEXT_LENGTH,STDataValidationType.TEXT_LENGTH); + vtMappings.put(DataValidationConstraint.ValidationType.TIME,STDataValidationType.TIME); + vtMappings.put(DataValidationConstraint.ValidationType.INTEGER,STDataValidationType.WHOLE); + validationTypeMappings = Collections.unmodifiableMap(vtMappings); + + validationTypeReverseMappings = Collections.unmodifiableMap(MapUtils.invertMap(validationTypeMappings)); + } XSSFDataValidation(CellRangeAddressList regions,CTDataValidation ctDataValidation) { diff --git a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/VerticalAlign.java b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/VerticalAlign.java index 64f34cbb20..8e6df981b4 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/VerticalAlign.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/VerticalAlign.java @@ -45,7 +45,7 @@ public enum VerticalAlign { */ SUBSCRIPT(3); - private static Map<Integer, VerticalAlign> imap = new HashMap<>(); + private static final Map<Integer, VerticalAlign> imap = new HashMap<>(); static { for (VerticalAlign p : values()) { |