|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.univocity.parsers.conversions.Conversions
public class Conversions
This class provides default instances of common implementations if com.univocity.parsers.conversions.Conversion, as well as useful methods for obtaining new instances of these.
| Method Summary | ||
|---|---|---|
static FormattedBigDecimalConversion |
formatToBigDecimal(BigDecimal defaultValueForNullString,
String... numberFormats)
Returns a new instance of FormattedBigDecimalConversion |
|
static FormattedBigDecimalConversion |
formatToBigDecimal(BigDecimal defaultValueForNullString,
String stringIfNull,
String... numberFormats)
Returns a new instance of FormattedBigDecimalConversion |
|
static FormattedBigDecimalConversion |
formatToBigDecimal(String... numberFormats)
Returns a new instance of FormattedBigDecimalConversion |
|
static
|
formatToNumber(Class<T> numberType,
String... numberFormats)
Returns a new instance of NumericConversion |
|
static NumericConversion<Number> |
formatToNumber(String... numberFormats)
Returns a new instance of NumericConversion |
|
static RegexConversion |
replace(String replaceRegex,
String replacement)
Returns a new instance of RegexConversion |
|
static ToStringConversion |
string()
Returns a singleton instance of ToStringConversion |
|
static BigDecimalConversion |
toBigDecimal()
Returns a new instance of BigDecimalConversion |
|
static BigIntegerConversion |
toBigInteger()
Returns a new instance of BigIntegerConversion |
|
static BooleanConversion |
toBoolean()
Returns a new instance of BooleanConversion that converts the string "true" to true, and the String "false" to false. |
|
static BooleanConversion |
toBoolean(Boolean defaultValueForNullString,
String defaultValueForNullBoolean,
String[] valuesForTrue,
String[] valuesForFalse)
Returns a new instance of BooleanConversion |
|
static BooleanConversion |
toBoolean(Boolean defaultValueForNullString,
String defaultValueForNullBoolean,
String valueForTrue,
String valueForFalse)
Returns a new instance of BooleanConversion |
|
static BooleanConversion |
toBoolean(String[] valuesForTrue,
String[] valuesForFalse)
Returns a new instance of BooleanConversion |
|
static BooleanConversion |
toBoolean(String valueForTrue,
String valueForFalse)
Returns a new instance of BooleanConversion |
|
static ByteConversion |
toByte()
Returns a new instance of ByteConversion |
|
static CalendarConversion |
toCalendar(Calendar dateIfNull,
String... dateFormats)
Returns a new instance of CalendarConversion |
|
static CalendarConversion |
toCalendar(Calendar dateIfNull,
String stringIfNull,
String... dateFormats)
Returns a new instance of CalendarConversion |
|
static CalendarConversion |
toCalendar(Locale locale,
Calendar dateIfNull,
String... dateFormats)
Returns a new instance of CalendarConversion |
|
static CalendarConversion |
toCalendar(Locale locale,
Calendar dateIfNull,
String stringIfNull,
String... dateFormats)
Returns a new instance of CalendarConversion |
|
static CalendarConversion |
toCalendar(Locale locale,
String... dateFormats)
Returns a new instance of CalendarConversion |
|
static CalendarConversion |
toCalendar(String... dateFormats)
Returns a new instance of CalendarConversion |
|
static CharacterConversion |
toChar()
Returns a new instance of CharacterConversion |
|
static CharacterConversion |
toChar(Character defaultValueForNullString)
Returns a new instance of CharacterConversion |
|
static CharacterConversion |
toChar(Character defaultValueForNullString,
String defaultValueForNullChar)
Returns a new instance of CharacterConversion |
|
static DateConversion |
toDate(Date dateIfNull,
String... dateFormats)
Returns a new instance of DateConversion |
|
static DateConversion |
toDate(Date dateIfNull,
String stringIfNull,
String... dateFormats)
Returns a new instance of DateConversion |
|
static DateConversion |
toDate(Locale locale,
Date dateIfNull,
String... dateFormats)
Returns a new instance of DateConversion |
|
static DateConversion |
toDate(Locale locale,
Date dateIfNull,
String stringIfNull,
String... dateFormats)
Returns a new instance of DateConversion |
|
static DateConversion |
toDate(Locale locale,
String... dateFormats)
Returns a new instance of DateConversion |
|
static DateConversion |
toDate(String... dateFormats)
Returns a new instance of DateConversion |
|
static DoubleConversion |
toDouble()
Returns a new instance of DoubleConversion |
|
static
|
toEnum(Class<T> enumType)
Returns a new instance of EnumConversion |
|
static
|
toEnum(Class<T> enumType,
EnumSelector... selectors)
Returns a new instance of EnumConversion |
|
static
|
toEnum(Class<T> enumType,
String customEnumElement,
EnumSelector... selectors)
Returns a new instance of EnumConversion |
|
static
|
toEnum(Class<T> enumType,
T valueIfStringIsNull,
String valueIfEnumIsNull,
String customEnumElement,
EnumSelector... selectors)
Returns a new instance of EnumConversion |
|
static FloatConversion |
toFloat()
Returns a new instance of FloatConversion |
|
static IntegerConversion |
toInteger()
Returns a new instance of IntegerConversion |
|
static LongConversion |
toLong()
Returns a new instance of LongConversion |
|
static LowerCaseConversion |
toLowerCase()
Returns a singleton instance of LowerCaseConversion |
|
static NullStringConversion |
toNull(String... nullRepresentations)
Returns a new instance of NullStringConversion |
|
static ShortConversion |
toShort()
Returns a new instance of ShortConversion |
|
static UpperCaseConversion |
toUpperCase()
Returns a singleton instance of UpperCaseConversion |
|
static TrimConversion |
trim()
Returns a singleton instance of TrimConversion |
|
static TrimConversion |
trim(int length)
Returns a TrimConversion that limits the output to a fixed length |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static ToStringConversion string()
ToStringConversion
ToStringConversionpublic static UpperCaseConversion toUpperCase()
UpperCaseConversion
UpperCaseConversionpublic static LowerCaseConversion toLowerCase()
LowerCaseConversion
LowerCaseConversionpublic static TrimConversion trim()
TrimConversion
TrimConversionpublic static TrimConversion trim(int length)
TrimConversion that limits the output to a fixed length
length - the maximum length a value can contain. Characters after this limit will
be discarded.
public static RegexConversion replace(String replaceRegex,
String replacement)
RegexConversion
replaceRegex - the regular expression used to match contents of a given input Stringreplacement - the replacement content to replace any contents matched by the given regular expression
RegexConversion created with the given parameters.public static NullStringConversion toNull(String... nullRepresentations)
NullStringConversion
nullRepresentations - the sequence of Strings that represent a null value.
NullStringConversion created with the given parameters.
public static DateConversion toDate(Locale locale,
String... dateFormats)
DateConversion
locale - the Locale that determines how the date mask should be formatted.dateFormats - list of acceptable date patterns. The first pattern in this sequence will be used to convert a Date into a String in DateConversion.revert(Date).
DateConversion created with the given parameters.public static DateConversion toDate(String... dateFormats)
DateConversion
dateFormats - list of acceptable date patterns. The first pattern in this sequence will be used to convert a Date into a String in DateConversion.revert(Date).
DateConversion created with the given parameters.
public static DateConversion toDate(Locale locale,
Date dateIfNull,
String... dateFormats)
DateConversion
locale - the Locale that determines how the date mask should be formatted.dateIfNull - default Date value to be returned when the input String is null. Used when ObjectConversion.execute(String) is invoked.dateFormats - list of acceptable date patterns. The first pattern in this sequence will be used to convert a Date into a String in DateConversion.revert(Date).
DateConversion created with the given parameters.
public static DateConversion toDate(Date dateIfNull,
String... dateFormats)
DateConversion
dateIfNull - default Date value to be returned when the input String is null. Used when ObjectConversion.execute(String) is invoked.dateFormats - list of acceptable date patterns. The first pattern in this sequence will be used to convert a Date into a String in DateConversion.revert(Date).
DateConversion created with the given parameters.
public static DateConversion toDate(Locale locale,
Date dateIfNull,
String stringIfNull,
String... dateFormats)
DateConversion
locale - the Locale that determines how the date mask should be formatted.dateIfNull - default Date value to be returned when the input String is null. Used when ObjectConversion.execute(String) is invoked.stringIfNull - default String value to be returned when a Date input is null. Used when DateConversion.revert(Date) is invoked.dateFormats - list of acceptable date patterns. The first pattern in this sequence will be used to convert a Date into a String in DateConversion.revert(Date).
DateConversion created with the given parameters.
public static DateConversion toDate(Date dateIfNull,
String stringIfNull,
String... dateFormats)
DateConversion
dateIfNull - default Date value to be returned when the input String is null. Used when ObjectConversion.execute(String) is invoked.stringIfNull - default String value to be returned when a Date input is null. Used when DateConversion.revert(Date) is invoked.dateFormats - list of acceptable date patterns. The first pattern in this sequence will be used to convert a Date into a String in DateConversion.revert(Date).
DateConversion created with the given parameters.
public static CalendarConversion toCalendar(Locale locale,
String... dateFormats)
CalendarConversion
locale - the Locale that determines how the date mask should be formatted.dateFormats - list of acceptable date patterns. The first pattern in this sequence will be used to convert a Calendar into a String in CalendarConversion.revert(Calendar).
CalendarConversion created with the given parameters.public static CalendarConversion toCalendar(String... dateFormats)
CalendarConversion
dateFormats - list of acceptable date patterns. The first pattern in this sequence will be used to convert a Calendar into a String in CalendarConversion.revert(Calendar).
CalendarConversion created with the given parameters.
public static CalendarConversion toCalendar(Locale locale,
Calendar dateIfNull,
String... dateFormats)
CalendarConversion
locale - the Locale that determines how the date mask should be formatted.dateIfNull - default Calendar value to be returned when the input String is null. Used when ObjectConversion.execute(String) is invoked.dateFormats - list of acceptable date patterns. The first pattern in this sequence will be used to convert a Calendar into a String in CalendarConversion.revert(Calendar).
CalendarConversion created with the given parameters.
public static CalendarConversion toCalendar(Calendar dateIfNull,
String... dateFormats)
CalendarConversion
dateIfNull - default Calendar value to be returned when the input String is null. Used when ObjectConversion.execute(String) is invoked.dateFormats - list of acceptable date patterns. The first pattern in this sequence will be used to convert a Calendar into a String in CalendarConversion.revert(Calendar).
CalendarConversion created with the given parameters.
public static CalendarConversion toCalendar(Locale locale,
Calendar dateIfNull,
String stringIfNull,
String... dateFormats)
CalendarConversion
locale - the Locale that determines how the date mask should be formatted.dateIfNull - default Calendar value to be returned when the input String is null. Used when ObjectConversion.execute(String) is invoked.stringIfNull - default String value to be returned when a Date input is null. Used when CalendarConversion.revert(Calendar) is invoked.dateFormats - list of acceptable date patterns. The first pattern in this sequence will be used to convert a Calendar into a String in CalendarConversion.revert(Calendar).
CalendarConversion created with the given parameters.
public static CalendarConversion toCalendar(Calendar dateIfNull,
String stringIfNull,
String... dateFormats)
CalendarConversion
dateIfNull - default Calendar value to be returned when the input String is null. Used when ObjectConversion.execute(String) is invoked.stringIfNull - default String value to be returned when a Date input is null. Used when CalendarConversion.revert(Calendar) is invoked.dateFormats - list of acceptable date patterns. The first pattern in this sequence will be used to convert a Calendar into a String in CalendarConversion.revert(Calendar).
CalendarConversion created with the given parameters.public static ByteConversion toByte()
ByteConversion
ByteConversionpublic static ShortConversion toShort()
ShortConversion
ShortConversionpublic static IntegerConversion toInteger()
IntegerConversion
IntegerConversionpublic static LongConversion toLong()
LongConversion
LongConversionpublic static BigIntegerConversion toBigInteger()
BigIntegerConversion
BigIntegerConversionpublic static FloatConversion toFloat()
FloatConversion
FloatConversionpublic static DoubleConversion toDouble()
DoubleConversion
DoubleConversionpublic static BigDecimalConversion toBigDecimal()
BigDecimalConversion
BigDecimalConversionpublic static NumericConversion<Number> formatToNumber(String... numberFormats)
NumericConversion
numberFormats - list of acceptable numeric patterns. The first pattern in this sequence will be used to convert a Number into a String in NumericConversion.revert(Number).
NumericConversion that supports the given number formats
public static <T extends Number> NumericConversion<T> formatToNumber(Class<T> numberType,
String... numberFormats)
NumericConversion
T - type of numbernumberType - type of number to be returned. The resulting instance of Number will be cast to the expected type.numberFormats - list of acceptable numeric patterns. The first pattern in this sequence will be used to convert a Number into a String in NumericConversion.revert(Number).
NumericConversion that supports the given number formatspublic static FormattedBigDecimalConversion formatToBigDecimal(String... numberFormats)
FormattedBigDecimalConversion
numberFormats - list of acceptable numeric patterns. The first pattern in this sequence will be used to convert a BigDecimal into a String in NumericConversion.revert(Number).
FormattedBigDecimalConversion that supports the given number formats
public static FormattedBigDecimalConversion formatToBigDecimal(BigDecimal defaultValueForNullString,
String... numberFormats)
FormattedBigDecimalConversion
defaultValueForNullString - default BigDecimal to be returned when the input String is null. Used when ObjectConversion.execute(String) is invoked.numberFormats - list of acceptable numeric patterns. The first pattern in this sequence will be used to convert a BigDecimal into a String in NumericConversion.revert(Number).
FormattedBigDecimalConversion that supports the given number formats
public static FormattedBigDecimalConversion formatToBigDecimal(BigDecimal defaultValueForNullString,
String stringIfNull,
String... numberFormats)
FormattedBigDecimalConversion
defaultValueForNullString - default BigDecimal to be returned when the input String is null. Used when ObjectConversion.execute(String) is invoked.stringIfNull - default String value to be returned when a BigDecimal input is null. Used when FormattedBigDecimalConversion#revert(BigDecimal) is invoked.numberFormats - list of acceptable numeric patterns. The first pattern in this sequence will be used to convert a BigDecimal into a String in NumericConversion.revert(Number).
FormattedBigDecimalConversion that supports the given number formats
public static BooleanConversion toBoolean(Boolean defaultValueForNullString,
String defaultValueForNullBoolean,
String[] valuesForTrue,
String[] valuesForFalse)
BooleanConversion
defaultValueForNullString - default Boolean value to be returned when the input String is null. Used when ObjectConversion.execute(String) is invoked.defaultValueForNullBoolean - default String value to be returned when a Boolean input is null. Used when BooleanConversion.revert(Boolean) is invoked.valuesForTrue - Strings that identify the boolean value true. The first element will be returned when executing BooleanConversion.revert(true)valuesForFalse - Strings that identify the boolean value false. The first element will be returned when executing BooleanConversion.revert(false)
BooleanConversion with support for multiple representations of true and false
public static BooleanConversion toBoolean(Boolean defaultValueForNullString,
String defaultValueForNullBoolean,
String valueForTrue,
String valueForFalse)
BooleanConversion
defaultValueForNullString - default Boolean value to be returned when the input String is null. Used when ObjectConversion.execute(String) is invoked.defaultValueForNullBoolean - default String value to be returned when a Boolean input is null. Used when BooleanConversion.revert(Boolean) is invoked.valueForTrue - String that identify the boolean value true.valueForFalse - String that identify the boolean value false.
BooleanConversion with support for multiple representations of true and false
public static BooleanConversion toBoolean(String[] valuesForTrue,
String[] valuesForFalse)
BooleanConversion
valuesForTrue - Strings that identify the boolean value true. The first element will be returned when executing BooleanConversion.revert(true)valuesForFalse - Strings that identify the boolean value false. The first element will be returned when executing BooleanConversion.revert(false)
BooleanConversion with support for multiple representations of true and falsepublic static BooleanConversion toBoolean()
BooleanConversion that converts the string "true" to true, and the String "false" to false.
BooleanConversion with support for multiple representations of true and false
public static BooleanConversion toBoolean(String valueForTrue,
String valueForFalse)
BooleanConversion
valueForTrue - String that identifies the boolean value true.valueForFalse - String that identifies the boolean value false.
BooleanConversion with support for multiple representations of true and falsepublic static CharacterConversion toChar()
CharacterConversion
CharacterConversion
public static CharacterConversion toChar(Character defaultValueForNullString,
String defaultValueForNullChar)
CharacterConversion
defaultValueForNullString - default Character value to be returned when the input String is null. Used when ObjectConversion.execute(String) is invoked.defaultValueForNullChar - default String value to be returned when a Character input is null. Used when CharacterConversion#revert(Character) is invoked.
CharacterConversionpublic static CharacterConversion toChar(Character defaultValueForNullString)
CharacterConversion
defaultValueForNullString - default Character value to be returned when the input String is null. Used when ObjectConversion.execute(String) is invoked.
CharacterConversionpublic static <T extends Enum<T>> EnumConversion<T> toEnum(Class<T> enumType)
EnumConversion
T - the enum typeenumType - the enumeration type to be converted from/to String
EnumConversion
public static <T extends Enum<T>> EnumConversion<T> toEnum(Class<T> enumType,
EnumSelector... selectors)
EnumConversion
T - the enum typeenumType - the enumeration type to be converted from/to Stringselectors - the selection elements of the enumeration to use for matching Strings.
EnumConversion
public static <T extends Enum<T>> EnumConversion<T> toEnum(Class<T> enumType,
String customEnumElement,
EnumSelector... selectors)
EnumConversion
T - the enum typeenumType - the enumeration type to be converted from/to StringcustomEnumElement - name of custom element of the enumeration (attribute or method) whose values should be used to match equivalent Strings.selectors - the selection elements of the enumeration to use for matching Strings.
EnumConversion
public static <T extends Enum<T>> EnumConversion<T> toEnum(Class<T> enumType,
T valueIfStringIsNull,
String valueIfEnumIsNull,
String customEnumElement,
EnumSelector... selectors)
EnumConversion
T - the enum typeenumType - the enumeration type to be converted from/to StringvalueIfStringIsNull - the default enumeration constant to use if the input String is nullvalueIfEnumIsNull - the default String value to use if the input enum constant is nullcustomEnumElement - name of custom element of the enumeration (attribute or method) whose values should be used to match equivalent Strings.selectors - the selection elements of the enumeration to use for matching Strings.
EnumConversion
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||