Package org.beanio.types.xml
Class AbstractXmlCalendarTypeHandler
- java.lang.Object
-
- org.beanio.types.LocaleSupport
-
- org.beanio.types.DateTypeHandlerSupport
-
- org.beanio.types.CalendarTypeHandler
-
- org.beanio.types.xml.AbstractXmlCalendarTypeHandler
-
- All Implemented Interfaces:
java.lang.Cloneable
,ConfigurableTypeHandler
,TypeHandler
- Direct Known Subclasses:
XmlCalendarDateTimeTypeHandler
,XmlCalendarDateTypeHandler
,XmlCalendarTimeTypeHandler
public abstract class AbstractXmlCalendarTypeHandler extends CalendarTypeHandler
Base class forCalendar
type handlers based on the W3C XML Schema datatype specification.- Since:
- 2.1.0
-
-
Field Summary
Fields Modifier and Type Field Description protected static javax.xml.datatype.DatatypeFactory
dataTypeFactory
-
Fields inherited from class org.beanio.types.DateTypeHandlerSupport
lenient, pattern, timeZone
-
Fields inherited from class org.beanio.types.LocaleSupport
locale
-
Fields inherited from interface org.beanio.types.ConfigurableTypeHandler
FORMAT_SETTING
-
Fields inherited from interface org.beanio.types.TypeHandler
NIL
-
-
Constructor Summary
Constructors Constructor Description AbstractXmlCalendarTypeHandler()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract java.lang.String
format(java.lang.Object value)
Formats a Java object into field text.protected abstract javax.xml.namespace.QName
getDatatypeQName()
Returns the expected XML Schema data type whenparse
is called.protected int
getTimeZoneOffset(java.util.Date date)
Returns the time zone offset in minutes for the given date, orDatatypeConstants.FIELD_UNDEFINED
if a time zone was not configured.boolean
isLenientDatatype()
Returns whether data type validation is skipped when parsing field text.boolean
isTimeZoneAllowed()
Returns whether time zone information is allowed when parsing field text.protected java.util.Calendar
newCalendar()
Creates a new calendar using the configured time zone (if set).java.util.Calendar
parse(java.lang.String text)
Parses field text into a Java object.void
setLenientDatatype(boolean lenientDatatype)
Sets whether data type validation is skipped when parsing field text.void
setTimeZoneAllowed(boolean timeZoneAllowed)
Sets whether time zone information is allowed when parsing field text.-
Methods inherited from class org.beanio.types.CalendarTypeHandler
formatCalendar, getType
-
Methods inherited from class org.beanio.types.DateTypeHandlerSupport
createDateFormat, createDefaultDateFormat, formatDate, getPattern, getTimeZone, getTimeZoneId, isLenient, newInstance, parseDate, setLenient, setPattern, setTimeZoneId
-
Methods inherited from class org.beanio.types.LocaleSupport
getLocale, setLocale
-
-
-
-
Method Detail
-
parse
public java.util.Calendar parse(java.lang.String text) throws TypeConversionException
Description copied from interface:TypeHandler
Parses field text into a Java object.- Specified by:
parse
in interfaceTypeHandler
- Overrides:
parse
in classCalendarTypeHandler
- Parameters:
text
- the field text to parse, which may be null if the field was not passed in the record- Returns:
- the parsed Java object
- Throws:
TypeConversionException
- if the text cannot be parsed
-
format
public abstract java.lang.String format(java.lang.Object value)
Description copied from interface:TypeHandler
Formats a Java object into field text.- Specified by:
format
in interfaceTypeHandler
- Overrides:
format
in classCalendarTypeHandler
- Parameters:
value
- the Java object to format, which may be null- Returns:
- the formatted field text, or
null
to indicate the value is not present, orTypeHandler.NIL
for XML formatted streams
-
getDatatypeQName
protected abstract javax.xml.namespace.QName getDatatypeQName()
Returns the expected XML Schema data type whenparse
is called.- Returns:
- the expected XML schema data type
QName
-
newCalendar
protected java.util.Calendar newCalendar()
Creates a new calendar using the configured time zone (if set).- Returns:
- a new
Calendar
instance
-
getTimeZoneOffset
protected int getTimeZoneOffset(java.util.Date date)
Returns the time zone offset in minutes for the given date, orDatatypeConstants.FIELD_UNDEFINED
if a time zone was not configured.- Parameters:
date
- the date on which to determine the time zone offset- Returns:
- the time zone offset in minutes, or
DatatypeConstants.FIELD_UNDEFINED
-
isTimeZoneAllowed
public boolean isTimeZoneAllowed()
Returns whether time zone information is allowed when parsing field text. Defaults totrue
.- Returns:
true
if time zone information is allowed when parsing field text
-
setTimeZoneAllowed
public void setTimeZoneAllowed(boolean timeZoneAllowed)
Sets whether time zone information is allowed when parsing field text. Defaults totrue
.- Parameters:
timeZoneAllowed
-true
if time zone information is allowed when parsing field text
-
isLenientDatatype
public boolean isLenientDatatype()
Returns whether data type validation is skipped when parsing field text. Set tofalse
by default, aTypeConversionException
is thrown when a XML dateTime type handler is used to parse a XML date or XML time, or a XML date handler is used to parse a XML dateTime field, etc.- Returns:
true
if data type validation is skipped
-
setLenientDatatype
public void setLenientDatatype(boolean lenientDatatype)
Sets whether data type validation is skipped when parsing field text. Set tofalse
by default, aTypeConversionException
is thrown when a XML dateTime type handler is used to parse a XML date or XML time, or a XML date handler is used to parse a XML dateTime field, etc.- Parameters:
lenientDatatype
-true
if data type validation is skipped
-
-