private LiteralRestriction buildLiteralRestriction( final RuleBuildContext context,
final InternalReadAccessor extractor,
final LiteralRestrictionDescr literalRestrictionDescr ) {
FieldValue field = null;
ValueType vtype = extractor.getValueType();
try {
String value = literalRestrictionDescr.getText().trim();
MVEL.COMPILER_OPT_ALLOW_NAKED_METH_CALL = true;
MVEL.COMPILER_OPT_ALLOW_OVERRIDE_ALL_PROPHANDLING = true;
MVEL.COMPILER_OPT_ALLOW_RESOLVE_INNERCLASSES_WITH_DOTNOTATION = true;
MVEL.COMPILER_OPT_SUPPORT_JAVA_STYLE_CLASS_LITERALS = true;
MVELDialectRuntimeData data = (MVELDialectRuntimeData) context.getPkg().getDialectRuntimeRegistry().getDialectData( "mvel" );
ParserConfiguration pconf = data.getParserConfiguration();
ParserContext pctx = new ParserContext( pconf );
Object o = MVEL.executeExpression( MVEL.compileExpression( value,
pctx ) );
if ( o != null ) {
if ( vtype == null ) {
// was a compilation problem else where, so guess valuetype so we can continue
vtype = ValueType.determineValueType( o.getClass() );
} else {
// if the value is of type String coerce the object to a String
if ( vtype.getClassType() == String.class ) {
o = o.toString();
}
}
}