|
31 | 31 | */
|
32 | 32 | public abstract class AbstractXmlCalendarTypeHandler extends CalendarTypeHandler {
|
33 | 33 |
|
34 |
| - protected static final DatatypeFactory dataTypeFactory; |
| 34 | + private static final String DATE_TIME = "dateTime"; |
| 35 | + private static final String INVALID_XML = "Invalid XML "; |
| 36 | + protected static final DatatypeFactory dataTypeFactory; |
35 | 37 | static {
|
36 | 38 | try {
|
37 | 39 | dataTypeFactory = DatatypeFactory.newInstance();
|
@@ -67,20 +69,20 @@ public Calendar parse(String text) throws TypeConversionException {
|
67 | 69 | try {
|
68 | 70 | XMLGregorianCalendar xcal = dataTypeFactory.newXMLGregorianCalendar(text);
|
69 | 71 | if (!lenientDatatype && type != null && !xcal.getXMLSchemaType().equals(type)) {
|
70 |
| - throw new TypeConversionException("Invalid XML " + type.getLocalPart()); |
| 72 | + throw new TypeConversionException(INVALID_XML + type.getLocalPart()); |
71 | 73 | }
|
72 | 74 |
|
73 | 75 | if (!isTimeZoneAllowed() && xcal.getTimezone() != DatatypeConstants.FIELD_UNDEFINED) {
|
74 |
| - String typeName = type == null ? "dateTime" : type.getLocalPart(); |
75 |
| - throw new TypeConversionException("Invalid XML " + typeName + |
| 76 | + String typeName = type == null ? DATE_TIME : type.getLocalPart(); |
| 77 | + throw new TypeConversionException(INVALID_XML + typeName + |
76 | 78 | ", time zone not allowed");
|
77 | 79 | }
|
78 | 80 |
|
79 | 81 | return xcal.toGregorianCalendar();
|
80 | 82 | }
|
81 | 83 | catch (IllegalArgumentException ex) {
|
82 |
| - String typeName = type == null ? "dateTime" : type.getLocalPart(); |
83 |
| - throw new TypeConversionException("Invalid XML " + typeName); |
| 84 | + String typeName = type == null ? DATE_TIME : type.getLocalPart(); |
| 85 | + throw new TypeConversionException(INVALID_XML + typeName); |
84 | 86 | }
|
85 | 87 | }
|
86 | 88 |
|
|
0 commit comments