diff --git a/README.mdown b/README.mdown index d17e56f..0416960 100644 --- a/README.mdown +++ b/README.mdown @@ -75,4 +75,4 @@ For more details see the [API Javadocs][6]. [3]: http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/expressions.html#d0e11927 [4]: http://github.com/abhin4v/spelhelper/blob/master/src/main/java/net/abhinavsarkar/spelhelper/ImplicitMethods.java [5]: http://github.com/abhin4v/spelhelper/blob/master/src/main/java/net/abhinavsarkar/spelhelper/ExtensionFunctions.java -[6]: http://github.com/abhin4v/spelhelper/raw/master/apidocs/net/abhinavsarkar/spelhelper/package-summary.html \ No newline at end of file +[6]: http://abhin4v.github.com/spelhelper/net/abhinavsarkar/spelhelper/package-summary.html \ No newline at end of file diff --git a/apidocs/allclasses-frame.html b/apidocs/allclasses-frame.html deleted file mode 100644 index beab58c..0000000 --- a/apidocs/allclasses-frame.html +++ /dev/null @@ -1,36 +0,0 @@ - - - -
- - -ExtensionFunctions
- -ImplicitMethods - -SpelHelper - - |
-
ExtensionFunctions
- -ImplicitMethods - -SpelHelper - - |
-
-
-
|
-- - | -||||||||
- PREV - NEXT | -- FRAMES - NO FRAMES - - - - - | -
-
-
|
--Code hosted at github - | -||||||||
- PREV - NEXT | -- FRAMES - NO FRAMES - - - - - | -
-
-
|
-- - | -||||||||
- PREV - NEXT | -- FRAMES - NO FRAMES - - - - - | -
-
-
|
--Code hosted at github - | -||||||||
- PREV - NEXT | -- FRAMES - NO FRAMES - - - - - | -
-
-
|
-- - | -||||||||
- PREV - NEXT | -- FRAMES - NO FRAMES - - - - - | -
- ---Each package has a page that contains a list of its classes and interfaces, with a summary for each. This page can contain four categories:
-
-- Interfaces (italic)
- Classes
- Enums
- Exceptions
- Errors
- Annotation Types
- -- --Each class, interface, nested class and nested interface has its own separate page. Each of these pages has three sections consisting of a class/interface description, summary tables, and detailed member descriptions:
-
-Each summary entry contains the first sentence from the detailed description for that item. The summary entries are alphabetical, while the detailed descriptions are in the order they appear in the source code. This preserves the logical groupings established by the programmer.- Class inheritance diagram
- Direct Subclasses
- All Known Subinterfaces
- All Known Implementing Classes
- Class/interface declaration
- Class/interface description -
-
- Nested Class Summary
- Field Summary
- Constructor Summary
- Method Summary -
-
- Field Detail
- Constructor Detail
- Method Detail
- -- --Each annotation type has its own separate page with the following sections:
-
-- Annotation Type declaration
- Annotation Type description
- Required Element Summary
- Optional Element Summary
- Element Detail
- ---Each enum has its own separate page with the following sections:
-
-- Enum declaration
- Enum description
- Enum Constant Summary
- Enum Constant Detail
-Each documented package, class and interface has its own Use page. This page describes what packages, classes, methods, constructors and fields use any part of the given class or package. Given a class or interface A, its Use page includes subclasses of A, fields declared as A, methods that return A, and methods and constructors with parameters of type A. You can access this page by first going to the package, class or interface, then clicking on the "Use" link in the navigation bar.-
-There is a Class Hierarchy page for all packages, plus a hierarchy for each package. Each hierarchy page contains a list of classes and a list of interfaces. The classes are organized by inheritance structure starting with-java.lang.Object
. The interfaces do not inherit fromjava.lang.Object
.-
-- When viewing the Overview page, clicking on "Tree" displays the hierarchy for all packages.
- When viewing a particular package, class or interface page, clicking "Tree" displays the hierarchy for only that package.
-The Deprecated API page lists all of the API that have been deprecated. A deprecated API is not recommended for use, generally due to improvements, and a replacement API is usually given. Deprecated APIs may be removed in future implementations.-
-The Index contains an alphabetic list of all classes, interfaces, constructors, methods, and fields.-
-
-
-
-
-This help file applies to API documentation generated using the standard doclet.
-
-
-
-
-
|
--Code hosted at github - | -||||||||
- PREV - NEXT | -- FRAMES - NO FRAMES - - - - - | -
-
-
|
-- - | -||||||||
- PREV - NEXT | -- FRAMES - NO FRAMES - - - - - | -
distinct
on the List
class.
-drop
on the List
class.
-expressionString
in the context
-of root element rootElement
and gives back a result of type
-desiredType
.
-expressionString
in the provided
-context evaluationContext
and gives back a result of type
-desiredType
.
-List
of the arguments provided.
-Map
using the List
of keys
-provided as the first argument and the List
of values provided
-as the second argument.
-clazz
so that they
-can be called by their simple name from SpEL expressions.
-clazz
as functions
-which can be called from SpEL expressions.
-clazz
as implicit
-methods for the class of the first parameter of the methods.
-reversed
on the List
class.
-Set
of the arguments provided.
-sorted
on the List
class.
-take
on the List
class.
-
-
-
|
--Code hosted at github - | -||||||||
- PREV - NEXT | -- FRAMES - NO FRAMES - - - - - | -
-
-
|
-- - | -||||||||
- PREV CLASS - NEXT CLASS | -- FRAMES - NO FRAMES - - - - - | -||||||||
- SUMMARY: NESTED | FIELD | CONSTR | METHOD | --DETAIL: FIELD | CONSTR | METHOD | -
-java.lang.Object - net.abhinavsarkar.spelhelper.ExtensionFunctions --
public final class ExtensionFunctions
-
Provides some extension functions to create some basic collection types
-inline in SpEL expressions.
-These functions are automatically registered with SpelHelper
.
See Also: -Spring Docs on extension functions
-- -
-
-Method Summary | -||
---|---|---|
-static
- |
-list(T... args)
-
-- Creates an unmodifiable List of the arguments provided. |
-|
-static
- |
-map(List<? extends K> keys,
- List<? extends V> values)
-
-- Creates an unmodifiable Map using the List of keys
-provided as the first argument and the List of values provided
-as the second argument. |
-|
-static
- |
-set(T... args)
-
-- Creates an unmodifiable Set of the arguments provided. |
-
Methods inherited from class java.lang.Object | -
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
-
-Method Detail | -
---|
-public static <T> List<T> list(T... args)-
Creates an unmodifiable List
of the arguments provided.
Example use: "#list('one', 'two', 'three')"
-
T
- Type of the arguments provided.args
- Arguments to create list of.
--public static <T> Set<T> set(T... args)-
Creates an unmodifiable Set
of the arguments provided.
Example use: "#set('one', 'two', 'three')"
-
T
- Type of the arguments provided.args
- Arguments to create set of.
--public static <K,V> Map<K,V> map(List<? extends K> keys, - List<? extends V> values)-
Creates an unmodifiable Map
using the List
of keys
-provided as the first argument and the List
of values provided
-as the second argument.
Example use: "#map(#list('one', 'two', 'three'), #list(1, 2, 3))"
-
K
- Type of the keys of the map.V
- Type of the values of map.keys
- List of the keys.values
- List of the values.
-IllegalArgumentException
- if the number of keys and the number of
-values is not equal.
-
-
|
--Code hosted at github - | -||||||||
- PREV CLASS - NEXT CLASS | -- FRAMES - NO FRAMES - - - - - | -||||||||
- SUMMARY: NESTED | FIELD | CONSTR | METHOD | --DETAIL: FIELD | CONSTR | METHOD | -
-
-
|
-- - | -||||||||
- PREV CLASS - NEXT CLASS | -- FRAMES - NO FRAMES - - - - - | -||||||||
- SUMMARY: NESTED | FIELD | CONSTR | METHOD | --DETAIL: FIELD | CONSTR | METHOD | -
-java.lang.Object - net.abhinavsarkar.spelhelper.ImplicitMethods --
public final class ImplicitMethods
-Provides some implicit methods which can be invoked on the instances of -class of the first parameter of the method inside a SpEL expression. -
- -
-
-Constructor Summary | -|
---|---|
ImplicitMethods()
-
-- |
-
-Method Summary | -||
---|---|---|
-static
- |
-distinct(List<? extends T> list)
-
-- Provides implicit method distinct on the List class. |
-|
-static
- |
-drop(List<T> list,
- int n)
-
-- Provides implicit method drop on the List class. |
-|
-static
- |
-reversed(List<? extends T> list)
-
-- Provides implicit method reversed on the List class. |
-|
-static
- |
-sorted(List<? extends T> list)
-
-- Provides implicit method sorted on the List class. |
-|
-static
- |
-take(List<T> list,
- int n)
-
-- Provides implicit method take on the List class. |
-
Methods inherited from class java.lang.Object | -
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
-
-Constructor Detail | -
---|
-public ImplicitMethods()-
-Method Detail | -
---|
-public static <T> Set<T> distinct(List<? extends T> list)-
Provides implicit method distinct
on the List
class.
Example: "#list('a','b','a').distinct()" //should return List('a','b')
With implicit property support provided by SpelHelper
this can
-also be written as:
"#list('a','b','a').distinct" //same output as earlier
-
T
- Type of the list's elements.list
- The list to call this method upon.
-Set
containing the distinct items of the list.-public static <T extends Comparable<? super T>> List<T> sorted(List<? extends T> list)-
Provides implicit method sorted
on the List
class.
Example: "#list('c','b','a').sorted()" //should return List('a','b','c')
With implicit property support provided by SpelHelper
this can
-also be written as:
"#list('c','b','a').sorted" //same output as earlier
-
T
- Type of the list's elements.list
- The list to call this method upon.
-List
containing the sorted items
-of the list.Collections.sort(List)
-public static <T> List<T> reversed(List<? extends T> list)-
Provides implicit method reversed
on the List
class.
Example: "#list('c','b','a').reversed()" //should return List('a','b','c')
With implicit property support provided by SpelHelper
this can
-also be written as:
"#list('c','b','a').reversed" //same output as earlier
-
T
- Type of the list's elements.list
- The list to call this method upon.
-List
containing the items of the
-list in reverse order.Collections.reverse(List)
-public static <T> List<T> take(List<T> list, - int n)-
Provides implicit method take
on the List
class.
Example: "#list('c','b','a').take(2)" //should return List('a','b')
-
T
- Type of the list's elements.list
- The list to call this method upon.n
- Number of items to take from the list.
-List
containing the first n
items
-of the list.-public static <T> List<T> drop(List<T> list, - int n)-
Provides implicit method drop
on the List
class.
Example: "#list('c','b','a').drop(2)" //should return List('a')
-
T
- Type of the list's elements.list
- The list to call this method upon.n
- Number of items to drop from the list.
-List
containing the items after the
-first n
items of the list.
-
-
|
--Code hosted at github - | -||||||||
- PREV CLASS - NEXT CLASS | -- FRAMES - NO FRAMES - - - - - | -||||||||
- SUMMARY: NESTED | FIELD | CONSTR | METHOD | --DETAIL: FIELD | CONSTR | METHOD | -
-
-
|
-- - | -||||||||
- PREV CLASS - NEXT CLASS | -- FRAMES - NO FRAMES - - - - - | -||||||||
- SUMMARY: NESTED | FIELD | CONSTR | METHOD | --DETAIL: FIELD | CONSTR | METHOD | -
-java.lang.Object - net.abhinavsarkar.spelhelper.SpelHelper --
public final class SpelHelper
-
SpelHelper provides additional functionalities to work with -Spring Expression Language (SpEL).
- -The addition functionalities provided are:
- -Implicit Methods
- -Implicit methods allow one to registers methods with SpelHelper and attach -them to particular classes. After that, when that method is called on an -object of that particular class inside a SpEL expression, SpelHelper -redirects the method call to the registered method.
- -Example: ImplicitMethods.sorted(List)
method is automatically
-registered by SpelHelper. The class that the method should be invoked for
-is the type of the first parameter of the method. In this case, the class is
-List
.
So when an expression like "#list(1,4,2).sorted()"
is evaluated, the
-ImplicitMethods.sorted(List)
method is invoked with the list as its
-first parameter and its return value is used in further evaluation of the
-expression.
See registerImplicitMethodsFromClass(Class)
.
Implicit Properties
- -Implicit properties allow one to treat no argument methods of an object -as properties of the object. SpelHelper intercepts the property resolution -of SpEL and if the property name is same as some no-arg method of the target -object then it invokes the method on the object and provides its return value -as the property value for further evaluation of the expression.
- -Example: Using implicit properties, the example of implicit methods can be
-written as: "#list(1,4,2).sorted"
- dropping the parens - and it will return
-the same value as the last example.
Implicit property resolution considers both the actual methods of the object -and the implicit methods registered on the object's class.
- -Simplified extension functions
- -SpEL allows to register extension function on the context by providing a
-name and a Method
object. SpelHelper simplifies this by taking a class
-and registering all the public static
methods of the class which do not
-have a void
return type. The methods are registered by their simple name.
Example: All the methods of ExtensionFunctions
class are automatically
-registered by SpelHelper. Hence the method ExtensionFunctions.list(Object...)
-can be called from inside a SpEL expression using the function call syntax:
-"#list(1,2,3)
".
See registerFunctionsFromClass(Class)
.
Simplified constructors
- -SpEL allows calling constructors from inside a SpEL expression using the
-new
operator. But they have to be called with their full name like:
-"new org.example.Foo('bar')"
. SpelHelper simplifies this by taking a class
-and registering all its public constructors to the SpEL context by their
-simple name.
Example: After registering the org.example.Foo
class with SpelHelper, its
-constructor can be called from inside a SpEL expression by: "new Foo('bar')"
.
See registerConstructorsFromClass(Class)
.
In addition to all the above functionalities, SpelHelper automatically registers
-some extension functions and implicit methods which are always available in
-the SpEL expressions evaluated through SpelHelper. See ExtensionFunctions
-and ImplicitMethods
for further details.
- -
-
-Constructor Summary | -|
---|---|
SpelHelper()
-
-- Creates an instance of SpelHelper. |
-
-Method Summary | -||
---|---|---|
-
- |
-evalExpression(String expressionString,
- EvaluationContext evaluationContext,
- Class<T> desiredType)
-
-- Evaluates a SpEL expression expressionString in the provided
-context evaluationContext and gives back a result of type
-desiredType . |
-|
-
- |
-evalExpression(String expressionString,
- Object rootElement,
- Class<T> desiredType)
-
-- Evaluates a SpEL expression expressionString in the context
-of root element rootElement and gives back a result of type
-desiredType . |
-|
-
- |
-evalExpressions(String[] expressionStrings,
- EvaluationContext evaluationContext,
- Class<T> desiredType)
-
-- Evaluates multiple SpEL expressions and returns the result of the last -expression. |
-|
-
- |
-evalExpressions(String[] expressionStrings,
- Object rootElement,
- Class<T> desiredType)
-
-- Evaluates multiple SpEL expressions and returns the result of the last -expression. |
-|
-static EvaluationContext |
-getCurrentContext()
-
-- Returns the current evaluation context. |
-|
- Constructor<?> |
-lookupImplicitConstructor(String lookup)
-
-- Looks up an implicit constructor registered with this instance. |
-|
- Method |
-lookupImplicitMethod(String lookup)
-
-- Looks up an implicit method registered with this instance. |
-|
- SpelHelper |
-registerConstructorsFromClass(Class<?> clazz)
-
-- Registers the public constructors of the class clazz so that they
-can be called by their simple name from SpEL expressions. |
-|
- SpelHelper |
-registerFunctionsFromClass(Class<?> clazz)
-
-- Registers the public static methods in the class clazz as functions
-which can be called from SpEL expressions. |
-|
- SpelHelper |
-registerImplicitMethodsFromClass(Class<?> clazz)
-
-- Registers the public static methods in the class clazz as implicit
-methods for the class of the first parameter of the methods. |
-
Methods inherited from class java.lang.Object | -
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
-
-Constructor Detail | -
---|
-public SpelHelper()-
-
-Method Detail | -
---|
-public SpelHelper registerImplicitMethodsFromClass(Class<?> clazz)-
Registers the public static methods in the class clazz
as implicit
-methods for the class of the first parameter of the methods.
Only registers the public static methods with non void return type and at -least one argument.
--
clazz
- The class to register the methods from.
-ImplicitMethods
-public SpelHelper registerFunctionsFromClass(Class<?> clazz)-
Registers the public static methods in the class clazz
as functions
-which can be called from SpEL expressions.
-The functions are registered with the simple name of the methods.
Only registers the public static methods with non void return type.
--
clazz
- The class to register the functions from.
-ExtensionFunctions
-public SpelHelper registerConstructorsFromClass(Class<?> clazz)-
clazz
so that they
-can be called by their simple name from SpEL expressions.
--
clazz
- The class to register the constructors from.
--public <T> T evalExpression(String expressionString, - Object rootElement, - Class<T> desiredType)-
expressionString
in the context
-of root element rootElement
and gives back a result of type
-desiredType
.
--
T
- The type of the result desired.expressionString
- The SpEL expression to evaluate.rootElement
- The root element in context of which the expression
-is to be evaluated.desiredType
- The class of the result desired.
-ExpressionParser.parseExpression(String)
,
-Expression.getValue(EvaluationContext, Class)
-public <T> T evalExpression(String expressionString, - EvaluationContext evaluationContext, - Class<T> desiredType)-
expressionString
in the provided
-context evaluationContext
and gives back a result of type
-desiredType
.
--
T
- The type of the result desired.expressionString
- The SpEL expression to evaluate.evaluationContext
- The context in which the expression is to be evaluated.desiredType
- The class of the result desired.
-ExpressionParser.parseExpression(String)
,
-Expression.getValue(EvaluationContext, Class)
-public <T> T evalExpressions(String[] expressionStrings, - Object rootElement, - Class<T> desiredType)-
-
T
- The type of the result desired.expressionStrings
- The SpEL expressions to evaluate.rootElement
- The root element in context of which the expressions
-are to be evaluated.desiredType
- The class of the result desired.
-evalExpression(String, EvaluationContext, Class)
,
-evalExpression(String, Object, Class)
-public <T> T evalExpressions(String[] expressionStrings, - EvaluationContext evaluationContext, - Class<T> desiredType)-
-
T
- The type of the result desired.expressionStrings
- The SpEL expressions to evaluate.evaluationContext
- The context in which the expression is to be evaluated.desiredType
- The class of the result desired.
-evalExpression(String, EvaluationContext, Class)
,
-evalExpression(String, Object, Class)
-public Method lookupImplicitMethod(String lookup)-
-
lookup
- key to lookup which should be of form:
-method.getParameterTypes()[0].getName() + "." + method.getName()
--public Constructor<?> lookupImplicitConstructor(String lookup)-
-
lookup
- key to lookup which should be of form:
-constructor.getDeclaringClass().getSimpleName()
- + Arrays.toString(constructor.getParameterTypes())
--public static EvaluationContext getCurrentContext()-
-
-
-
|
--Code hosted at github - | -||||||||
- PREV CLASS - NEXT CLASS | -- FRAMES - NO FRAMES - - - - - | -||||||||
- SUMMARY: NESTED | FIELD | CONSTR | METHOD | --DETAIL: FIELD | CONSTR | METHOD | -
-
-
|
-- - | -||||||||
- PREV - NEXT | -- FRAMES - NO FRAMES - - - - - | -
-
-
-
|
--Code hosted at github - | -||||||||
- PREV - NEXT | -- FRAMES - NO FRAMES - - - - - | -
-
-
|
-- - | -||||||||
- PREV - NEXT | -- FRAMES - NO FRAMES - - - - - | -
-
-
-
|
--Code hosted at github - | -||||||||
- PREV - NEXT | -- FRAMES - NO FRAMES - - - - - | -
-
-
|
-- - | -||||||||
- PREV - NEXT | -- FRAMES - NO FRAMES - - - - - | -
-Uses of SpelHelper in net.abhinavsarkar.spelhelper | -
---|
- -
Methods in net.abhinavsarkar.spelhelper that return SpelHelper | -|
---|---|
- SpelHelper |
-SpelHelper.registerConstructorsFromClass(Class<?> clazz)
-
-- Registers the public constructors of the class clazz so that they
-can be called by their simple name from SpEL expressions. |
-
- SpelHelper |
-SpelHelper.registerFunctionsFromClass(Class<?> clazz)
-
-- Registers the public static methods in the class clazz as functions
-which can be called from SpEL expressions. |
-
- SpelHelper |
-SpelHelper.registerImplicitMethodsFromClass(Class<?> clazz)
-
-- Registers the public static methods in the class clazz as implicit
-methods for the class of the first parameter of the methods. |
-
-
-
-
|
--Code hosted at github - | -||||||||
- PREV - NEXT | -- FRAMES - NO FRAMES - - - - - | -
-Classes
-
- -ExtensionFunctions - -ImplicitMethods - -SpelHelper |
-
-
-
|
-- - | -||||||||
- PREV PACKAGE - NEXT PACKAGE | -- FRAMES - NO FRAMES - - - - - | -
-Class Summary | -|
---|---|
ExtensionFunctions | -Provides some extension functions to create some basic collection types -inline in SpEL expressions. | -
ImplicitMethods | -Provides some implicit methods which can be invoked on the instances of -class of the first parameter of the method inside a SpEL expression. | -
SpelHelper | -SpelHelper provides additional functionalities to work with -[Spring Expression Language (SpEL)][1]. | -
-
-
-
|
--Code hosted at github - | -||||||||
- PREV PACKAGE - NEXT PACKAGE | -- FRAMES - NO FRAMES - - - - - | -
-
-
|
-- - | -||||||||
- PREV - NEXT | -- FRAMES - NO FRAMES - - - - - | -
-
-
|
--Code hosted at github - | -||||||||
- PREV - NEXT | -- FRAMES - NO FRAMES - - - - - | -
-
-
|
-- - | -||||||||
- PREV - NEXT | -- FRAMES - NO FRAMES - - - - - | -
-Classes in net.abhinavsarkar.spelhelper used by net.abhinavsarkar.spelhelper | -|
---|---|
SpelHelper
-
- - SpelHelper provides additional functionalities to work with -[Spring Expression Language (SpEL)][1]. |
-
-
-
-
|
--Code hosted at github - | -||||||||
- PREV - NEXT | -- FRAMES - NO FRAMES - - - - - | -
-
-
|
-- - | -||||||||
- PREV - NEXT | -- FRAMES - NO FRAMES - - - - - | -
-
-
|
--Code hosted at github - | -||||||||
- PREV - NEXT | -- FRAMES - NO FRAMES - - - - - | -