public class TypePattern extends Object
TypePattern
objects are used in conjunction
with PatternBasedDiscovery
to discover schemas
for text files.
A number of patterns are pre-defined for common types.
Modifier and Type | Field and Description |
---|---|
static TypePattern |
BOOLEAN_PATTERN
A pattern declaring a mapping to
TextTypes.TRUE_FALSE . |
static TypePattern |
DATE_PATTERN
A pattern declaring a mapping to
TextTypes.ISO_DATE . |
static TypePattern |
DOUBLE_PATTERN
A pattern declaring a mapping to
TextTypes.JAVA_DOUBLE . |
static TypePattern |
DURATION_PATTERN
A pattern declaring a mapping to
TextTypes.JAVA_DURATION . |
static TypePattern |
INT_PATTERN
A pattern declaring a mapping to
TextTypes.JAVA_INT . |
static TypePattern |
IP4ADDRESS_PATTERN
A pattern declaring a mapping to
TextTypes.TEXT_IPV4ADDRESS . |
static TypePattern |
IP6ADDRESS_PATTERN
A pattern declaring a mapping to
TextTypes.TEXT_IPV6ADDRESS . |
static TypePattern |
LONG_PATTERN
A pattern declaring a mapping to
TextTypes.JAVA_LONG . |
static TypePattern |
MONEY_PATTERN
A pattern declaring a mapping to
TextTypes.JAVA_MONEY
Matches vales containing an optional sign followed by an optional currency symbol,
followed by up to 16 digits before an optional decimal point
and up to 2 more digits. |
static TypePattern |
PERIOD_PATTERN
A pattern declaring a mapping to
TextTypes.JAVA_PERIOD . |
static TypePattern |
TIME_PATTERN
A pattern declaring a mapping to
TextTypes.ISO_TIMEOFDAY . |
static TypePattern |
TIMESTAMP_PATTERN
A pattern declaring a mapping to
TextTypes.ISO_TIMESTAMP . |
Constructor and Description |
---|
TypePattern(String pattern,
TextDataType type)
Declares the given pattern identifies values of the specified type.
|
Modifier and Type | Method and Description |
---|---|
String |
getPattern()
Gets the pattern used for the mapping.
|
TextDataType |
getType()
Gets the type implied by the mapping.
|
boolean |
matches(String value)
Indicates if the given value matches the pattern.
|
public static final TypePattern INT_PATTERN
TextTypes.JAVA_INT
.
Matches values containing an optional sign and between 1 and 9 digits.public static final TypePattern LONG_PATTERN
TextTypes.JAVA_LONG
.
Matches values containing an optional sign and between 1 and 18 digits.public static final TypePattern MONEY_PATTERN
TextTypes.JAVA_MONEY
Matches vales containing an optional sign followed by an optional currency symbol,
followed by up to 16 digits before an optional decimal point
and up to 2 more digits. Can also use optional US or EU style grouping notation.
Also allows for accounting notation allowing parenthesis instead of a negative sign.public static final TypePattern DOUBLE_PATTERN
TextTypes.JAVA_DOUBLE
.
Matches values containing an optional sign and any number of digits with
a decimal point ('.') embedded. Values may also have an optional exponent
suffix ('E-2', for example).public static final TypePattern DATE_PATTERN
TextTypes.ISO_DATE
.
Matches values roughly conforming to the form of ISO-8601 dates.
public static final TypePattern TIME_PATTERN
TextTypes.ISO_TIMEOFDAY
.
Matches values roughly conforming to the form of ISO-8601 times without zone offset.
public static final TypePattern TIMESTAMP_PATTERN
TextTypes.ISO_TIMESTAMP
.
Matches values roughly conforming to the form of ISO-8601 timestamps.
public static final TypePattern BOOLEAN_PATTERN
TextTypes.TRUE_FALSE
.
Matches the values "true"
and "false"
case-insensitively.public static final TypePattern IP4ADDRESS_PATTERN
TextTypes.TEXT_IPV4ADDRESS
.
Matches values conforming to standard Ipv4 addresses in dotted form.public static final TypePattern IP6ADDRESS_PATTERN
TextTypes.TEXT_IPV6ADDRESS
.
Matches values conforming to standard Ipv6 addresses in IETF standard form.
This includes compressed forms.
Regular Expression from http://home.deds.nl/~aeron/regex/java.htmlpublic static final TypePattern DURATION_PATTERN
TextTypes.JAVA_DURATION
.
Matches values conforming to a Java Duration.public static final TypePattern PERIOD_PATTERN
TextTypes.JAVA_PERIOD
.
Matches values conforming to a Java Period.public TypePattern(String pattern, TextDataType type)
pattern
- the regular expression to be matchedtype
- the external data type implied by the patternpublic boolean matches(String value)
value
- the value to testtrue
if the value matches the pattern
and should be considered to have the associated type
false
otherwise.public String getPattern()
public TextDataType getType()
Copyright © 2019 Actian Corporation. All rights reserved.