|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.morph.lang.languages.BaseLanguage
public abstract class BaseLanguage
A convenient base class for Languages that takes care of exception
handling and logging. Also exposes the
DecoratedLanguage
interface while only requiring
subclasses to implement the methods in Language
.
Constructor Summary | |
---|---|
BaseLanguage()
Create a new BaseLanguage. |
Method Summary | |
---|---|
java.lang.Object |
get(java.lang.Object target,
java.lang.String expression)
Retrieve the property indicated by expression from
target . |
java.lang.Object |
get(java.lang.Object target,
java.lang.String expression,
java.lang.Class destinationClass)
Retrieve the information indicated by expression from
target as the type indicated by
destinationClass . |
java.lang.Object |
get(java.lang.Object target,
java.lang.String expression,
java.lang.Class destinationClass,
java.util.Locale locale)
Retrieve the information indicated by expression from
target as the type indicated by
destinationClass . |
java.lang.Object |
get(java.lang.Object target,
java.lang.String expression,
java.util.Locale locale,
java.lang.Class destinationClass)
Retrieve the information indicated by expression from
target as the type indicated by
destinationClass . |
Converter |
getConverter()
Get the Converter. |
protected abstract java.lang.Object |
getImpl(java.lang.Object target,
java.lang.String expression)
Implement get(target, expression) . |
java.lang.String |
getLanguageName()
Get the languageName. |
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 . |
protected abstract java.lang.Class |
getTypeImpl(java.lang.Object target,
java.lang.String expression)
Implement getType(target, expression) . |
boolean |
isProperty(java.lang.String expression)
Indicates whether the given expression refers to a direct property of a target object. |
protected abstract boolean |
isPropertyImpl(java.lang.String expression)
Implement isProperty(expression) . |
void |
set(java.lang.Object target,
java.lang.String expression,
java.lang.Object value)
Sets the information indicated by expression on
target .value will be automatically
converted to a type appropriate for the given expression . |
void |
set(java.lang.Object target,
java.lang.String expression,
java.lang.Object value,
java.util.Locale locale)
Sets the information indicated by expression on
target .value will be automatically
converted to a type appropriate for the given expression . |
void |
setConverter(Converter converter)
Set the Converter. |
protected abstract void |
setImpl(java.lang.Object target,
java.lang.String expression,
java.lang.Object value)
Implement set(target, expression, value) . |
void |
setLanguageName(java.lang.String languageName)
Set the languageName. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public BaseLanguage()
Method Detail |
---|
protected abstract boolean isPropertyImpl(java.lang.String expression) throws java.lang.Exception
isProperty(expression)
.
expression
-
java.lang.Exception
protected abstract java.lang.Class getTypeImpl(java.lang.Object target, java.lang.String expression) throws java.lang.Exception
getType(target, expression)
.
target
- beanexpression
- to read
java.lang.Exception
protected abstract java.lang.Object getImpl(java.lang.Object target, java.lang.String expression) throws java.lang.Exception
get(target, expression)
.
target
- beanexpression
- to get
java.lang.Exception
protected abstract void setImpl(java.lang.Object target, java.lang.String expression, java.lang.Object value) throws java.lang.Exception
set(target, expression, value)
.
target
- beanexpression
- to setvalue
- to set
java.lang.Exception
public final boolean isProperty(java.lang.String expression) throws LanguageException
isProperty
in interface Language
expression
- the expression to evaluate
true
, if the expression references a direct
property of the target object or false
, otherwise
LanguageException
- an error occurrs while evaluating an otherwise valid
expression
InvalidExpressionException
- if expression
not a valid expressionpublic final java.lang.Class getType(java.lang.Object target, java.lang.String expression) throws LanguageException
expression
. If any type can be
assigned to the property, this method returns Object.class
.
getType
in interface Language
target
- the target being analyzedexpression
- indicates the property of target
that is to be
analyzed
expression
LanguageException
- if target
is null
or InvalidExpressionException
- if expression
not a valid expressionpublic final java.lang.Object get(java.lang.Object target, java.lang.String expression) throws LanguageException
expression
from
target
.
get
in interface Language
target
- the object from which information will be retrievedexpression
- an expression specifying which information to retrieve
expression
from
target
LanguageException
- if target
is null
or InvalidExpressionException
- if expression
not a valid expressionpublic final void set(java.lang.Object target, java.lang.String expression, java.lang.Object value) throws LanguageException
expression
on
target
.value
will be automatically
converted to a type appropriate for the given expression
.
set
in interface DecoratedLanguage
set
in interface Language
target
- the object that will be modifiedexpression
- an expression specifying which information will be modifiedvalue
- the information to be changed
LanguageException
- if target
is null
or InvalidExpressionException
- if expression
is empty or not a valid
expressionpublic final java.lang.Object get(java.lang.Object target, java.lang.String expression, java.lang.Class destinationClass) throws LanguageException, TransformationException
expression
from
target
as the type indicated by
destinationClass
.
get
in interface DecoratedLanguage
target
- the object from which information will be retrievedexpression
- an expression specifying which information to retrievedestinationClass
- indicates the type that should be returned by this method
expression
from
target
LanguageException
- if target
is null
or InvalidExpressionException
- if expression
is empty or not a valid
expression
TransformationException
- if an error occurs while converting the requested information
to the type indicated by destinationClass
public final java.lang.Object get(java.lang.Object target, java.lang.String expression, java.lang.Class destinationClass, java.util.Locale locale) throws LanguageException, TransformationException
expression
from
target
as the type indicated by
destinationClass
.
get
in interface DecoratedLanguage
target
- the object from which information will be retrievedexpression
- an expression specifying which information to retrievedestinationClass
- indicates the type that should be returned by this methodlocale
- indicates the locale in which the conversion to type
destinationClass
should be performed, if
applicable
expression
from
target
LanguageException
- if target
is null
or InvalidExpressionException
- if expression
is empty or not a valid
expression
TransformationException
- if an error occurs while converting the requested information
to the type indicated by destinationClass
public final java.lang.Object get(java.lang.Object target, java.lang.String expression, java.util.Locale locale, java.lang.Class destinationClass) throws LanguageException, TransformationException
expression
from
target
as the type indicated by
destinationClass
.
get
in interface DecoratedLanguage
target
- the object from which information will be retrievedexpression
- an expression specifying which information to retrievelocale
- indicates the locale in which the conversion to type
destinationClass
should be performed, if
applicabledestinationClass
- indicates the type that should be returned by this method
expression
from
target
LanguageException
- if target
is null
or InvalidExpressionException
- if expression
is empty or not a valid
expression
TransformationException
- if an error occurs while converting the requested information
to the type indicated by destinationClass
public void set(java.lang.Object target, java.lang.String expression, java.lang.Object value, java.util.Locale locale) throws LanguageException, TransformationException
expression
on
target
.value
will be automatically
converted to a type appropriate for the given expression
.
set
in interface DecoratedLanguage
target
- the object that will be modifiedexpression
- an expression specifying which information will be modifiedvalue
- the information to be changedlocale
- indicates the locale in which the conversion to type
destinationClass
should be performed, if
applicable
LanguageException
- if target
is null
or InvalidExpressionException
- if expression
is empty or not a valid
expression
TransformationException
- if an error occurs while converting value
to
the appropriate typepublic Converter getConverter()
public void setConverter(Converter converter)
converter
- to setpublic java.lang.String getLanguageName()
public void setLanguageName(java.lang.String languageName)
languageName
- the String to setpublic java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |