Package org.beanio.internal.util
Class Settings
- java.lang.Object
-
- org.beanio.internal.util.Settings
-
public class Settings extends java.lang.Object
Settings
is used to load and store BeanIO configuration settings. All settings are global within the JVM (or actually the class loader).Default BeanIO settings can be overridden using a property file named
beanio.properties
The file will be loaded from the current working directory or from anywhere on the classpath. The default configuration filename can be overridden using the System propertyorg.beanio.configuration
.Configuration settings can be further overridden by any System property of the same name when the configuration file is loaded.
- Since:
- 1.0
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
ALLOW_PROTECTED_PROPERTY_ACCESS
Whether non-public fields and methods may be made accessible.static java.lang.String
CREATE_MISSING_BEANS
Whether version 2.0.0 style unmarshalling should be supported which instantiates bean objects for missing fields and records during unmarshalling.static java.lang.String
DEFAULT_DATE_FORMAT
The default date format pattern for fields assigned type aliasDate
static java.lang.String
DEFAULT_DATETIME_FORMAT
The default date format pattern for fields assigned type aliasDateTime
or of typejava.util.Date
static java.lang.String
DEFAULT_FIELD_MIN_OCCURS
The default minOccurs setting for a field (after appending the stream format)static java.lang.String
DEFAULT_GROUP_MIN_OCCURS
The default minOccurs setting for a group.static java.lang.String
DEFAULT_LOCALE
The default locale used by type handlersstatic java.lang.String
DEFAULT_MARSHALLING_ENABLED
Whether a configured field default is marshalled for null property values.static java.lang.String
DEFAULT_RECORD_MIN_OCCURS
The default minOccurs setting for a record.static java.lang.String
DEFAULT_TIME_FORMAT
The default date format pattern for fields assigned type aliasTime
static java.lang.String
DEFAULT_XML_TYPE
The default XML type for a field definition, set toelement
orattribute
.static java.lang.String
DEFAULT_XSI_NAMESPACE_PREFIX
The default namespace prefix for 'http://www.w3.org/2001/XMLSchema-instance'static java.lang.String
ERROR_IF_NULL_PRIMITIVE
Whether null field values should throw an exception if bound to a primitivestatic java.lang.String
FIXED_LENGTH_CHARSET
A charset used for fixed length stream data.static java.lang.String
FIXED_LENGTH_COUNT_MODE
Whether record length for fixed length data format is counted by characters or bytes.static java.lang.String
LAZY_IF_EMPTY
Whether objects are lazily instantiated if Strings are empty, rather than just null.static java.lang.String
NULL_ESCAPING_ENABLED
Whether the null character can be escaped using\0
when property escaping is enabled.static java.lang.String
PROPERTY_ACCESSOR_METHOD
The method of property access to use, 'reflection' (default) or 'asm' is supportedstatic java.lang.String
PROPERTY_ESCAPING_ENABLED
Whether property values support the following escape sequences:\\
- Backslash\n
- Line Feed\r
- Carriage Return\t
- Tab\f
- Form Feed\0
- Nullstatic java.lang.String
PROPERTY_SUBSTITUTION_ENABLED
Whether property substitution is enabled for mapping filesstatic java.lang.String
SORT_XML_COMPONENTS_BY_POSITION
Whether XML components should be sorted by position.static java.lang.String
STREAM_FACTORY_CLASS
This property is set to the fully qualified class name of the default stream factory implementationstatic java.lang.String
USE_DEFAULT_IF_MISSING
Whether default field values apply to missing fieldsstatic java.lang.String
VALIDATE_ON_MARSHAL
Whether to validate marshalled fields.static java.lang.String
XML_WRITER_UPDATE_STATE_USING_DELTA
Used for Spring Batch integration.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
getBoolean(java.lang.String key)
Returns the boolean value of a BeanIO configuration setting.static Settings
getInstance()
Returns theSettings
instance.static Settings
getInstance(java.lang.ClassLoader classLoader)
Returns theSettings
instance.int
getInt(java.lang.String key, int defaultValue)
Returns a BeanIO configuration setting as an integer.java.lang.String
getProperty(java.lang.String key)
Returns a BeanIO configuration setting.
-
-
-
Field Detail
-
STREAM_FACTORY_CLASS
public static final java.lang.String STREAM_FACTORY_CLASS
This property is set to the fully qualified class name of the default stream factory implementation- See Also:
- Constant Field Values
-
DEFAULT_LOCALE
public static final java.lang.String DEFAULT_LOCALE
The default locale used by type handlers- See Also:
- Constant Field Values
-
DEFAULT_DATE_FORMAT
public static final java.lang.String DEFAULT_DATE_FORMAT
The default date format pattern for fields assigned type aliasDate
- See Also:
- Constant Field Values
-
DEFAULT_DATETIME_FORMAT
public static final java.lang.String DEFAULT_DATETIME_FORMAT
The default date format pattern for fields assigned type aliasDateTime
or of typejava.util.Date
- See Also:
- Constant Field Values
-
DEFAULT_TIME_FORMAT
public static final java.lang.String DEFAULT_TIME_FORMAT
The default date format pattern for fields assigned type aliasTime
- See Also:
- Constant Field Values
-
PROPERTY_ESCAPING_ENABLED
public static final java.lang.String PROPERTY_ESCAPING_ENABLED
Whether property values support the following escape sequences:\\
- Backslash\n
- Line Feed\r
- Carriage Return\t
- Tab\f
- Form Feed\0
- Null
A backslash preceding any other character is ignored.
Set to
false
to disable.- Since:
- 1.2
- See Also:
- Constant Field Values
-
NULL_ESCAPING_ENABLED
public static final java.lang.String NULL_ESCAPING_ENABLED
Whether the null character can be escaped using\0
when property escaping is enabled.- See Also:
- Constant Field Values
-
PROPERTY_SUBSTITUTION_ENABLED
public static final java.lang.String PROPERTY_SUBSTITUTION_ENABLED
Whether property substitution is enabled for mapping files- See Also:
- Constant Field Values
-
DEFAULT_XML_TYPE
public static final java.lang.String DEFAULT_XML_TYPE
The default XML type for a field definition, set toelement
orattribute
.- See Also:
- Constant Field Values
-
DEFAULT_XSI_NAMESPACE_PREFIX
public static final java.lang.String DEFAULT_XSI_NAMESPACE_PREFIX
The default namespace prefix for 'http://www.w3.org/2001/XMLSchema-instance'- See Also:
- Constant Field Values
-
XML_WRITER_UPDATE_STATE_USING_DELTA
public static final java.lang.String XML_WRITER_UPDATE_STATE_USING_DELTA
Used for Spring Batch integration. Set to 'true' to have the XmlWriter only update the execution context (state) with changes since the last update. At the time of writing, it's not known whether Spring Batch will create a new ExecutionContext every time state is updated, or if the current context is used. Disabled by default until proven the optimization will not impact state updates.- See Also:
- Constant Field Values
-
DEFAULT_MARSHALLING_ENABLED
public static final java.lang.String DEFAULT_MARSHALLING_ENABLED
Whether a configured field default is marshalled for null property values. The default configuration sets this property totrue
.- Since:
- 1.2.2
- See Also:
- Constant Field Values
-
FIXED_LENGTH_COUNT_MODE
public static final java.lang.String FIXED_LENGTH_COUNT_MODE
Whether record length for fixed length data format is counted by characters or bytes. The default value ischars
, which counts record length as a number of characters. The other option isbytes
, which is useful for Asian language users who want to count Asian characters as two bytes wide. The latter option must be paired with a matching setting ofFIXED_LENGTH_CHARSET
to work properly.- See Also:
- Constant Field Values
-
FIXED_LENGTH_CHARSET
public static final java.lang.String FIXED_LENGTH_CHARSET
A charset used for fixed length stream data. Must be matched correctly ifFIXED_LENGTH_COUNT_MODE
option is setbytes
. The default value isutf-8
.- See Also:
- Constant Field Values
-
DEFAULT_GROUP_MIN_OCCURS
public static final java.lang.String DEFAULT_GROUP_MIN_OCCURS
The default minOccurs setting for a group.- See Also:
- Constant Field Values
-
DEFAULT_RECORD_MIN_OCCURS
public static final java.lang.String DEFAULT_RECORD_MIN_OCCURS
The default minOccurs setting for a record.- See Also:
- Constant Field Values
-
DEFAULT_FIELD_MIN_OCCURS
public static final java.lang.String DEFAULT_FIELD_MIN_OCCURS
The default minOccurs setting for a field (after appending the stream format)- See Also:
- Constant Field Values
-
PROPERTY_ACCESSOR_METHOD
public static final java.lang.String PROPERTY_ACCESSOR_METHOD
The method of property access to use, 'reflection' (default) or 'asm' is supported- See Also:
- Constant Field Values
-
CREATE_MISSING_BEANS
public static final java.lang.String CREATE_MISSING_BEANS
Whether version 2.0.0 style unmarshalling should be supported which instantiates bean objects for missing fields and records during unmarshalling. This behavior is not recommended.- See Also:
- Constant Field Values
-
LAZY_IF_EMPTY
public static final java.lang.String LAZY_IF_EMPTY
Whether objects are lazily instantiated if Strings are empty, rather than just null.- Since:
- 2.1.0
- See Also:
- Constant Field Values
-
ERROR_IF_NULL_PRIMITIVE
public static final java.lang.String ERROR_IF_NULL_PRIMITIVE
Whether null field values should throw an exception if bound to a primitive- Since:
- 2.1.0
- See Also:
- Constant Field Values
-
USE_DEFAULT_IF_MISSING
public static final java.lang.String USE_DEFAULT_IF_MISSING
Whether default field values apply to missing fields- Since:
- 2.1.0
- See Also:
- Constant Field Values
-
SORT_XML_COMPONENTS_BY_POSITION
public static final java.lang.String SORT_XML_COMPONENTS_BY_POSITION
Whether XML components should be sorted by position. Helpful for use with annotations where fields and methods may not be ordered by their position in the stream.- Since:
- 2.1.0
- See Also:
- Constant Field Values
-
ALLOW_PROTECTED_PROPERTY_ACCESS
public static final java.lang.String ALLOW_PROTECTED_PROPERTY_ACCESS
Whether non-public fields and methods may be made accessible.- See Also:
- Constant Field Values
-
VALIDATE_ON_MARSHAL
public static final java.lang.String VALIDATE_ON_MARSHAL
Whether to validate marshalled fields.- Since:
- 3.0.0
- See Also:
- Constant Field Values
-
-
Method Detail
-
getProperty
public java.lang.String getProperty(java.lang.String key)
Returns a BeanIO configuration setting.- Parameters:
key
- the name of the setting- Returns:
- the value of the setting, or null if the name is invalid
-
getBoolean
public boolean getBoolean(java.lang.String key)
Returns the boolean value of a BeanIO configuration setting.- Parameters:
key
- the property key- Returns:
- true if the property value is "true" (case insensitive), or false if the property is any other value
-
getInt
public int getInt(java.lang.String key, int defaultValue)
Returns a BeanIO configuration setting as an integer.- Parameters:
key
- the property keydefaultValue
- the default value if the setting wasn't configured or invalid- Returns:
- the
int
property value ordefaultValue
-
getInstance
public static Settings getInstance()
Returns theSettings
instance.- Returns:
- the Settings
-
getInstance
public static Settings getInstance(java.lang.ClassLoader classLoader)
Returns theSettings
instance.- Parameters:
classLoader
- theClassLoader
to use for loading classpath resources- Returns:
- the Settings
- Since:
- 2.0
-
-