com.codemesh.terp.eval.converters
Class ToRegex
java.lang.Object
com.codemesh.terp.eval.converters.ToRegex
- All Implemented Interfaces:
- Converter<java.util.regex.Pattern>
public class ToRegex
- extends java.lang.Object
- implements Converter<java.util.regex.Pattern>
A converter for regular expression patterns.
This converter is registered with the terp framework under two
aliases: ^regex and ^pattern.
In addition to being able converting strings to patterns, this type
can also handle maps. The only additional benefit that the map
conversion offers is the ability to specify case sensitivity.
The map converter understands the following entry names:
- caseinsensitive: boolean flag governing whether pattern is case-insensitive.
- casesensitive: boolean flag governing whether pattern is case-sensitive.
Use one of casesensitive and caseinsensitive. If both are used,
casesensitive overrules caseinsensitive.
- pattern, regex, or string: synonyms for the regular expression that should be
compiled. Expected to be a string, but may be a regular expression pattern, in which case
the pattern is the result of the conversion.
|
Method Summary |
java.util.regex.Pattern |
fromObject(java.lang.Object obj,
TerpContext ctx)
Converts the given object into an object of the target type. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
CASE_INSENSITIVE
public static final java.lang.String CASE_INSENSITIVE
- See Also:
- Constant Field Values
CASE_SENSITIVE
public static final java.lang.String CASE_SENSITIVE
- See Also:
- Constant Field Values
PATTERN
public static final java.lang.String PATTERN
- See Also:
- Constant Field Values
STRING
public static final java.lang.String STRING
- See Also:
- Constant Field Values
REGEX
public static final java.lang.String REGEX
- See Also:
- Constant Field Values
ToRegex
public ToRegex()
fromObject
public java.util.regex.Pattern fromObject(java.lang.Object obj,
TerpContext ctx)
- Description copied from interface:
Converter
- Converts the given object into an object of the target type.
Conversions can be implemented in any way that makes sense.
Normally, converters will return null for null, but some converters
may choose to interpret null as an indicator to return a
default-initialized target object. An example of this type
of conversion is the ShellExecutor. null simply indicates that
no preference overrides of any kind have been provided.
- Specified by:
fromObject in interface Converter<java.util.regex.Pattern>
- Parameters:
obj - the source object.ctx - the context in which the conversion takes place.
- Returns:
- an instance of the target type or null.
Copyright © 2008-2012 by Codemesh, Inc. All Rights Reserved.