- java.lang.Object
-
- com.pervasive.datarush.schema.TypePattern
-
public class TypePattern extends Object
Describes a pattern which identifies a text data type. Values which match the pattern can be assumed to be of the associated data type.TypePattern
objects are used in conjunction withPatternBasedDiscovery
to discover schemas for text files.A number of patterns are pre-defined for common types.
-
-
Field Summary
Fields Modifier and Type Field Description static TypePattern
BOOLEAN_PATTERN
A pattern declaring a mapping toTextTypes.TRUE_FALSE
.static TypePattern
DATE_PATTERN
A pattern declaring a mapping toTextTypes.ISO_DATE
.static TypePattern
DOUBLE_PATTERN
A pattern declaring a mapping toTextTypes.JAVA_DOUBLE
.static TypePattern
DURATION_PATTERN
A pattern declaring a mapping toTextTypes.JAVA_DURATION
.static TypePattern
INT_PATTERN
A pattern declaring a mapping toTextTypes.JAVA_INT
.static TypePattern
IP4ADDRESS_PATTERN
A pattern declaring a mapping toTextTypes.TEXT_IPV4ADDRESS
.static TypePattern
IP6ADDRESS_PATTERN
A pattern declaring a mapping toTextTypes.TEXT_IPV6ADDRESS
.static TypePattern
LONG_PATTERN
A pattern declaring a mapping toTextTypes.JAVA_LONG
.static TypePattern
MONEY_PATTERN
A pattern declaring a mapping toTextTypes.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 toTextTypes.JAVA_PERIOD
.static TypePattern
TIME_PATTERN
A pattern declaring a mapping toTextTypes.ISO_TIMEOFDAY
.static TypePattern
TIMESTAMP_PATTERN
A pattern declaring a mapping toTextTypes.ISO_TIMESTAMP
.
-
Constructor Summary
Constructors Constructor Description TypePattern(String pattern, TextDataType type)
Declares the given pattern identifies values of the specified type.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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.
-
-
-
Field Detail
-
INT_PATTERN
public static final TypePattern INT_PATTERN
A pattern declaring a mapping toTextTypes.JAVA_INT
. Matches values containing an optional sign and between 1 and 9 digits.
-
LONG_PATTERN
public static final TypePattern LONG_PATTERN
A pattern declaring a mapping toTextTypes.JAVA_LONG
. Matches values containing an optional sign and between 1 and 18 digits.
-
MONEY_PATTERN
public static final TypePattern MONEY_PATTERN
A pattern declaring a mapping toTextTypes.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.
-
DOUBLE_PATTERN
public static final TypePattern DOUBLE_PATTERN
A pattern declaring a mapping toTextTypes.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).
-
DATE_PATTERN
public static final TypePattern DATE_PATTERN
A pattern declaring a mapping toTextTypes.ISO_DATE
. Matches values roughly conforming to the form of ISO-8601 dates.- The year may be any number of digits.
- The month and day must be 1 or 2 digits.
-
TIME_PATTERN
public static final TypePattern TIME_PATTERN
A pattern declaring a mapping toTextTypes.ISO_TIMEOFDAY
. Matches values roughly conforming to the form of ISO-8601 times without zone offset.- The hour, minute, second must be 1 or 2 digits.
- A subsecond qualifier on the time may optionally be present.
-
TIMESTAMP_PATTERN
public static final TypePattern TIMESTAMP_PATTERN
A pattern declaring a mapping toTextTypes.ISO_TIMESTAMP
. Matches values roughly conforming to the form of ISO-8601 timestamps.- The year may be any number of digits.
- The month and day must be 1 or 2 digits.
- The date/time value is separated by either a 'T' or a space (' ').
- The hour, minute, second must be 1 or 2 digits.
- A subsecond qualifier on the time may optionally be present.
- A timezone identifier, either in the form 'Z' or explicit offset, may optionally be present.
-
BOOLEAN_PATTERN
public static final TypePattern BOOLEAN_PATTERN
A pattern declaring a mapping toTextTypes.TRUE_FALSE
. Matches the values"true"
and"false"
case-insensitively.
-
IP4ADDRESS_PATTERN
public static final TypePattern IP4ADDRESS_PATTERN
A pattern declaring a mapping toTextTypes.TEXT_IPV4ADDRESS
. Matches values conforming to standard Ipv4 addresses in dotted form.
-
IP6ADDRESS_PATTERN
public static final TypePattern IP6ADDRESS_PATTERN
A pattern declaring a mapping toTextTypes.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.html
-
DURATION_PATTERN
public static final TypePattern DURATION_PATTERN
A pattern declaring a mapping toTextTypes.JAVA_DURATION
. Matches values conforming to a Java Duration.
-
PERIOD_PATTERN
public static final TypePattern PERIOD_PATTERN
A pattern declaring a mapping toTextTypes.JAVA_PERIOD
. Matches values conforming to a Java Period.
-
-
Constructor Detail
-
TypePattern
public TypePattern(String pattern, TextDataType type)
Declares the given pattern identifies values of the specified type. Patterns are specified as regular expressions which must match the entire value.- Parameters:
pattern
- the regular expression to be matchedtype
- the external data type implied by the pattern
-
-
Method Detail
-
matches
public boolean matches(String value)
Indicates if the given value matches the pattern.- Parameters:
value
- the value to test- Returns:
true
if the value matches the pattern and should be considered to have the associated typefalse
otherwise.
-
getPattern
public String getPattern()
Gets the pattern used for the mapping.- Returns:
- the regular expression used to test for matches
-
getType
public TextDataType getType()
Gets the type implied by the mapping.- Returns:
- the external data type matching values can be assumed to have
-
-