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 Patternm_Patternfor performing pattern matching.static StringMATCH_ALLthe 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 Stringconvert(String value)Converts the string according to the specified conversion.static Stringescape(String s)Escapes special characters in the string to be used in regular expressions.StringgetHelpDescription()Returns a long help description, e.g., used in tiptexts.StringgetHelpIcon()Returns the name of a help icon, e.g., used for buttons.StringgetHelpTitle()Returns a short title for the help, e.g., used for buttons.StringgetHelpURL()Returns a URL with additional information.StringgetTipText()Returns a tool tip for the GUI editor (ignored if null is returned).booleanisEmpty()Checks whether the expression empty.booleanisMatch(String s)Checks whether the string matches the regular expression.booleanisMatchAll()Checks whether the expression is the match-all expression.booleanisValid(String value)Checks whether the string value is a valid presentation for this class.static BaseRegExplistToRegExp(List<String> values)Turns the list of values into a regular expression of the format: "^(value1|value2|...)$".PatternpatternValue()Returns the expression as compiled pattern.StringstringValue()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:
isValidin 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:
convertin 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:
stringValuein 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:
getTipTextin 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:
isEmptyin 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:
getHelpURLin interfaceHelpProvider- Returns:
- the URL, null if not available
-
getHelpDescription
public String getHelpDescription()
Returns a long help description, e.g., used in tiptexts.- Specified by:
getHelpDescriptionin 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:
getHelpTitlein 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:
getHelpIconin interfaceHelpProvider- Returns:
- the icon name, null if not available
-
-