Top Description Fields Constructors Methods
jdk.internal.joptsimple.util

public Class RegexMatcher

extends Object
implements ValueConverter<String>
Class Inheritance
All Implemented Interfaces
jdk.internal.joptsimple.ValueConverter
Imports
java.util.Locale, java.util.regex.Pattern, jdk.internal.joptsimple.ValueConversionException, .ValueConverter

Ensures that values entirely match a regular expression.
Author
Paul Holser

Field Summary

Modifier and TypeField and Description
private final Pattern

Constructor Summary

AccessConstructor and Description
public
RegexMatcher(String
the regular expression pattern
pattern
,
int
modifying regex flags
flags
)

Creates a matcher that uses the given regular expression, modified by the given flags.

Method Summary

Modifier and TypeMethod and Description
public String
convert(String
the string to convert
value
)

Implements jdk.internal.joptsimple.ValueConverter.convert.

Converts the given string value into a Java type.
private void
public static ValueConverter<String>

Returns:

the new converter
regex
(String
the regular expression pattern
pattern
)

Gives a matcher that uses the given regular expression.

public String
valuePattern()

Implements jdk.internal.joptsimple.ValueConverter.valuePattern.

Gives a string that describes the pattern of the values this converter expects, if any.
public Class<String>
valueType()

Implements jdk.internal.joptsimple.ValueConverter.valueType.

Gives the class of the type of values this converter converts to.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

patternback to summary
private final Pattern pattern

Constructor Detail

RegexMatcherback to summary
public RegexMatcher(String pattern, int flags)

Creates a matcher that uses the given regular expression, modified by the given flags.

Parameters
pattern:String

the regular expression pattern

flags:int

modifying regex flags

Exceptions
IllegalArgumentException:
if bit values other than those corresponding to the defined match flags are set in flags
PatternSyntaxException:
if the expression's syntax is invalid

Method Detail

convertback to summary
public String convert(String value)

Implements jdk.internal.joptsimple.ValueConverter.convert.

Doc from jdk.internal.joptsimple.ValueConverter.convert.

Converts the given string value into a Java type.

Parameters
value:String

the string to convert

Returns:String

the converted value

raiseValueConversionFailureback to summary
private void raiseValueConversionFailure(String value)
regexback to summary
public static ValueConverter<String> regex(String pattern)

Gives a matcher that uses the given regular expression.

Parameters
pattern:String

the regular expression pattern

Returns:ValueConverter<String>

the new converter

Exceptions
PatternSyntaxException:
if the expression's syntax is invalid
valuePatternback to summary
public String valuePattern()

Implements jdk.internal.joptsimple.ValueConverter.valuePattern.

Doc from jdk.internal.joptsimple.ValueConverter.valuePattern.

Gives a string that describes the pattern of the values this converter expects, if any. For example, a date converter can respond with a date format string.

Returns:String

a value pattern, or null if there's nothing interesting here

valueTypeback to summary
public Class<String> valueType()

Implements jdk.internal.joptsimple.ValueConverter.valueType.

Doc from jdk.internal.joptsimple.ValueConverter.valueType.

Gives the class of the type of values this converter converts to.

Returns:Class<String>

the target class for conversion