Package adams.core.base
Class BaseRegExp
- java.lang.Object
-
- adams.core.base.BaseObject
-
- adams.core.base.AbstractBaseString
-
- adams.core.base.BaseRegExp
-
- All Implemented Interfaces:
CloneHandler<BaseObject>
,HelpProvider
,Serializable
,Comparable
public class BaseRegExp extends AbstractBaseString implements HelpProvider
Wrapper for a regular expression string to be editable in the GOE. Basically the same as BaseString, but checks whether the string represents a valid regular expression.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected Pattern
m_Pattern
for performing pattern matching.static String
MATCH_ALL
the match-all expression.-
Fields inherited from class adams.core.base.BaseObject
m_Internal, m_Properties, SUFFIX_DISPLAY, SUFFIX_VALUE
-
-
Constructor Summary
Constructors Constructor Description BaseRegExp()
Initializes the string with length 0.BaseRegExp(String s)
Initializes the object with the string to parse.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected String
convert(String value)
Converts the string according to the specified conversion.static String
escape(String s)
Escapes special characters in the string to be used in regular expressions.String
getHelpDescription()
Returns a long help description, e.g., used in tiptexts.String
getHelpIcon()
Returns the name of a help icon, e.g., used for buttons.String
getHelpTitle()
Returns a short title for the help, e.g., used for buttons.String
getHelpURL()
Returns a URL with additional information.String
getTipText()
Returns a tool tip for the GUI editor (ignored if null is returned).boolean
isEmpty()
Checks whether the expression empty.boolean
isMatch(String s)
Checks whether the string matches the regular expression.boolean
isMatchAll()
Checks whether the expression is the match-all expression.boolean
isValid(String value)
Checks whether the string value is a valid presentation for this class.static BaseRegExp
listToRegExp(List<String> values)
Turns the list of values into a regular expression of the format: "^(value1|value2|...)$".Pattern
patternValue()
Returns the expression as compiled pattern.String
stringValue()
Returns the backquoted String value.-
Methods inherited from class adams.core.base.AbstractBaseString
getValue, initialize, length, setValue
-
Methods inherited from class adams.core.base.BaseObject
compareTo, equals, getClone, getInternal, getTemplates, getUnicode, hasFavoritesSupport, hashCode, isValidUnicode, newInstance, setUnicode, toObjectArray, toObjectArray, toString, toStringArray, toStringList
-
-
-
-
Field Detail
-
MATCH_ALL
public static final String MATCH_ALL
the match-all expression.- See Also:
- Constant Field Values
-
m_Pattern
protected Pattern m_Pattern
for performing pattern matching.
-
-
Constructor Detail
-
BaseRegExp
public BaseRegExp()
Initializes the string with length 0.
-
BaseRegExp
public BaseRegExp(String s)
Initializes the object with the string to parse.- Parameters:
s
- the string to parse
-
-
Method Detail
-
isValid
public boolean isValid(String value)
Checks whether the string value is a valid presentation for this class.- Overrides:
isValid
in classAbstractBaseString
- Parameters:
value
- the string value to check- Returns:
- always true
-
convert
protected String convert(String value)
Converts the string according to the specified conversion.
Implementation performs no conversion, merely initializes the pattern matcher.- Overrides:
convert
in classAbstractBaseString
- Parameters:
value
- the string to convert- Returns:
- the converted string
- See Also:
m_Pattern
-
stringValue
public String stringValue()
Returns the backquoted String value.- Overrides:
stringValue
in classAbstractBaseString
- Returns:
- the backquoted String value
-
patternValue
public Pattern patternValue()
Returns the expression as compiled pattern.- Returns:
- the pattern
-
getTipText
public String getTipText()
Returns a tool tip for the GUI editor (ignored if null is returned).- Specified by:
getTipText
in classAbstractBaseString
- Returns:
- the tool tip
-
isMatch
public boolean isMatch(String s)
Checks whether the string matches the regular expression.- Parameters:
s
- the string to check against regexp- Returns:
- true if the string matches the regexp
-
isMatchAll
public boolean isMatchAll()
Checks whether the expression is the match-all expression.- Returns:
- true if the match-all expression
-
isEmpty
public boolean isEmpty()
Checks whether the expression empty.- Overrides:
isEmpty
in classAbstractBaseString
- Returns:
- true if empty expression
-
escape
public static String escape(String s)
Escapes special characters in the string to be used in regular expressions. Characters escaped with backslash: \|.?()[]- Parameters:
s
- the string to escape- Returns:
- the escaped string
-
listToRegExp
public static BaseRegExp listToRegExp(List<String> values)
Turns the list of values into a regular expression of the format: "^(value1|value2|...)$".- Parameters:
values
- the list to convert- Returns:
- the regular expression
-
getHelpURL
public String getHelpURL()
Returns a URL with additional information.- Specified by:
getHelpURL
in interfaceHelpProvider
- Returns:
- the URL, null if not available
-
getHelpDescription
public String getHelpDescription()
Returns a long help description, e.g., used in tiptexts.- Specified by:
getHelpDescription
in interfaceHelpProvider
- Returns:
- the help text, null if not available
-
getHelpTitle
public String getHelpTitle()
Returns a short title for the help, e.g., used for buttons.- Specified by:
getHelpTitle
in interfaceHelpProvider
- Returns:
- the short title, null if not available
-
getHelpIcon
public String getHelpIcon()
Returns the name of a help icon, e.g., used for buttons.- Specified by:
getHelpIcon
in interfaceHelpProvider
- Returns:
- the icon name, null if not available
-
-