terp - the Codemesh Modular
Template Interpreter v1.3.309

com.codemesh.terp.eval.converters
Class ToRegex

java.lang.Object
  extended by 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:


Field Summary
static java.lang.String CASE_INSENSITIVE
           
static java.lang.String CASE_SENSITIVE
           
static java.lang.String PATTERN
           
static java.lang.String REGEX
           
static java.lang.String STRING
           
 
Constructor Summary
ToRegex()
           
 
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
 

Field Detail

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
Constructor Detail

ToRegex

public ToRegex()
Method Detail

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.

terp - the Codemesh Modular
Template Interpreter v1.3.309

Copyright © 2008-2012 by Codemesh, Inc. All Rights Reserved.