net.sf.morph.lang
Interface Language

All Known Subinterfaces:
DecoratedLanguage
All Known Implementing Classes:
BaseLanguage, LanguageDecorator, SimpleLanguage

public interface Language

Defines a syntax for expressions that can be used to access and change properties (bean or indexed) inside a target object. This is similar to the expression languages found in the JSTL EL, the Spring framework, Struts, and Velocity. Below are some example expressions.

JSTL EL example:
myBean.myMap.myProperty

Spring example:
myBean.myMap["myProperty"]

Since:
Nov 14, 2004
Author:
Matt Sgarlata

Method Summary
 java.lang.Object get(java.lang.Object target, java.lang.String expression)
          Retrieve the property indicated by expression from target.
 java.lang.Class getType(java.lang.Object target, java.lang.String expression)
          Specifies the least restrictive type that may be assigned to property indicated by the given expression.
 boolean isProperty(java.lang.String expression)
          Indicates whether the given expression refers to a direct property of a target object.
 void set(java.lang.Object target, java.lang.String expression, java.lang.Object value)
          Sets the property indicated by expression on target.
 

Method Detail

getType

java.lang.Class getType(java.lang.Object target,
                        java.lang.String expression)
                        throws LanguageException
Specifies the least restrictive type that may be assigned to property indicated by the given expression. If any type can be assigned to the property, this method returns Object.class.

Parameters:
target - the target being analyzed
expression - indicates the property of target that is to be analyzed
Returns:
the least restrictive type that may be assigned to the property identified by expression
Throws:
LanguageException - if target is null or
an error occurrs while evaluating an otherwise valid expression
InvalidExpressionException - if expression not a valid expression

isProperty

boolean isProperty(java.lang.String expression)
                   throws LanguageException
Indicates whether the given expression refers to a direct property of a target object.

Parameters:
expression - the expression to evaluate
Returns:
true, if the expression references a direct property of the target object or
false, otherwise
Throws:
LanguageException - an error occurrs while evaluating an otherwise valid expression
InvalidExpressionException - if expression not a valid expression

get

java.lang.Object get(java.lang.Object target,
                     java.lang.String expression)
                     throws LanguageException
Retrieve the property indicated by expression from target.

Parameters:
target - the object from which information will be retrieved
expression - an expression specifying which information to retrieve
Returns:
the information indicated by expression from target
Throws:
LanguageException - if target is null or
an error occurrs while evaluating an otherwise valid expression
InvalidExpressionException - if expression not a valid expression

set

void set(java.lang.Object target,
         java.lang.String expression,
         java.lang.Object value)
         throws LanguageException
Sets the property indicated by expression on target.

Parameters:
target - the object that will be modified
expression - an expression specifying which information will be modified
value - the information to be changed
Throws:
LanguageException - if target is null or
an error occurrs while evaluating an otherwise valid expression
InvalidExpressionException - if expression not a valid expression


Copyright © 2004-2008.