mirror of https://github.com/apache/poi.git
make it harder to modify metadata in maps
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1921337 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
ab68210d2a
commit
88a0d4ecf3
|
@ -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);
|
||||
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);
|
||||
|
||||
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);
|
||||
reverseErrorStyleMappings = Collections.unmodifiableMap(MapUtils.invertMap(esMappings));
|
||||
|
||||
for( Map.Entry<Integer,STDataValidationOperator.Enum> entry : operatorTypeMappings.entrySet() ) {
|
||||
operatorTypeReverseMappings.put(entry.getValue(),entry.getKey());
|
||||
}
|
||||
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);
|
||||
|
||||
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);
|
||||
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));
|
||||
|
||||
for( Map.Entry<Integer,STDataValidationType.Enum> entry : validationTypeMappings.entrySet() ) {
|
||||
validationTypeReverseMappings.put(entry.getValue(),entry.getKey());
|
||||
}
|
||||
}
|
||||
|
||||
XSSFDataValidation(CellRangeAddressList regions,CTDataValidation ctDataValidation) {
|
||||
|
|
|
@ -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()) {
|
||||
|
|
Loading…
Reference in New Issue