net.sf.morph.lang.languages
Class BaseLanguage

java.lang.Object
  extended by net.sf.morph.lang.languages.BaseLanguage
All Implemented Interfaces:
DecoratedLanguage, Language
Direct Known Subclasses:
LanguageDecorator, SimpleLanguage

public abstract class BaseLanguage
extends java.lang.Object
implements DecoratedLanguage

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.

Since:
Nov 28, 2004
Author:
Matt Sgarlata

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

BaseLanguage

public BaseLanguage()
Create a new BaseLanguage.

Method Detail

isPropertyImpl

protected abstract boolean isPropertyImpl(java.lang.String expression)
                                   throws java.lang.Exception
Implement isProperty(expression).

Parameters:
expression -
Returns:
boolean
Throws:
java.lang.Exception

getTypeImpl

protected abstract java.lang.Class getTypeImpl(java.lang.Object target,
                                               java.lang.String expression)
                                        throws java.lang.Exception
Implement getType(target, expression).

Parameters:
target - bean
expression - to read
Returns:
Class
Throws:
java.lang.Exception

getImpl

protected abstract java.lang.Object getImpl(java.lang.Object target,
                                            java.lang.String expression)
                                     throws java.lang.Exception
Implement get(target, expression).

Parameters:
target - bean
expression - to get
Returns:
Object
Throws:
java.lang.Exception

setImpl

protected abstract void setImpl(java.lang.Object target,
                                java.lang.String expression,
                                java.lang.Object value)
                         throws java.lang.Exception
Implement set(target, expression, value).

Parameters:
target - bean
expression - to set
value - to set
Throws:
java.lang.Exception

isProperty

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

Specified by:
isProperty in interface Language
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

getType

public final 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.

Specified by:
getType in interface Language
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

get

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

Specified by:
get in interface Language
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

public final void set(java.lang.Object target,
                      java.lang.String expression,
                      java.lang.Object value)
               throws LanguageException
Sets the information indicated by expression on target.value will be automatically converted to a type appropriate for the given expression.

Specified by:
set in interface DecoratedLanguage
Specified by:
set in interface Language
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 is empty or not a valid expression

get

public final java.lang.Object get(java.lang.Object target,
                                  java.lang.String expression,
                                  java.lang.Class destinationClass)
                           throws LanguageException,
                                  TransformationException
Retrieve the information indicated by expression from target as the type indicated by destinationClass.

Specified by:
get in interface DecoratedLanguage
Parameters:
target - the object from which information will be retrieved
expression - an expression specifying which information to retrieve
destinationClass - indicates the type that should be returned by this method
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 is empty or not a valid expression
TransformationException - if an error occurs while converting the requested information to the type indicated by destinationClass

get

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
Retrieve the information indicated by expression from target as the type indicated by destinationClass.

Specified by:
get in interface DecoratedLanguage
Parameters:
target - the object from which information will be retrieved
expression - an expression specifying which information to retrieve
destinationClass - indicates the type that should be returned by this method
locale - indicates the locale in which the conversion to type destinationClass should be performed, if applicable
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 is empty or not a valid expression
TransformationException - if an error occurs while converting the requested information to the type indicated by destinationClass

get

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
Retrieve the information indicated by expression from target as the type indicated by destinationClass.

Specified by:
get in interface DecoratedLanguage
Parameters:
target - the object from which information will be retrieved
expression - an expression specifying which information to retrieve
locale - indicates the locale in which the conversion to type destinationClass should be performed, if applicable
destinationClass - indicates the type that should be returned by this method
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 is empty or not a valid expression
TransformationException - if an error occurs while converting the requested information to the type indicated by destinationClass

set

public void set(java.lang.Object target,
                java.lang.String expression,
                java.lang.Object value,
                java.util.Locale locale)
         throws LanguageException,
                TransformationException
Sets the information indicated by expression on target.value will be automatically converted to a type appropriate for the given expression.

Specified by:
set in interface DecoratedLanguage
Parameters:
target - the object that will be modified
expression - an expression specifying which information will be modified
value - the information to be changed
locale - indicates the locale in which the conversion to type destinationClass should be performed, if applicable
Throws:
LanguageException - if target is null or
an error occurrs while evaluating an otherwise valid expression
InvalidExpressionException - if expression is empty or not a valid expression
TransformationException - if an error occurs while converting value to the appropriate type

getConverter

public Converter getConverter()
Get the Converter.

Returns:
Converter

setConverter

public void setConverter(Converter converter)
Set the Converter.

Parameters:
converter - to set

getLanguageName

public java.lang.String getLanguageName()
Get the languageName.

Returns:
String

setLanguageName

public void setLanguageName(java.lang.String languageName)
Set the languageName.

Parameters:
languageName - the String to set

toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object


Copyright © 2004-2008.