Class 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 with PatternBasedDiscovery to discover schemas for text files.

    A number of patterns are pre-defined for common types.

    • Field Detail

      • INT_PATTERN

        public static final TypePattern INT_PATTERN
        A pattern declaring a mapping to TextTypes.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 to TextTypes.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 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. 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 to 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).
      • DATE_PATTERN

        public static final TypePattern DATE_PATTERN
        A pattern declaring a mapping to TextTypes.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 to TextTypes.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 to TextTypes.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 to TextTypes.TRUE_FALSE. Matches the values "true" and "false" case-insensitively.
      • IP4ADDRESS_PATTERN

        public static final TypePattern IP4ADDRESS_PATTERN
        A pattern declaring a mapping to TextTypes.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 to 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.html
      • DURATION_PATTERN

        public static final TypePattern DURATION_PATTERN
        A pattern declaring a mapping to TextTypes.JAVA_DURATION. Matches values conforming to a Java Duration.
      • PERIOD_PATTERN

        public static final TypePattern PERIOD_PATTERN
        A pattern declaring a mapping to TextTypes.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 matched
        type - 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 type false 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