Java Doc for Ognl.java in  » Scripting » OGNL » ognl » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Scripting » OGNL » ognl 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   ognl.Ognl

Ognl
abstract public class Ognl (Code)

This class provides static methods for parsing and interpreting OGNL expressions.

The simplest use of the Ognl class is to get the value of an expression from an object, without extra context or pre-parsing.

 import ognl.Ognl;
 import ognl.OgnlException;
 try {
 result = Ognl.getValue(expression, root);
 } catch (OgnlException ex) {
 // Report error or recover
 }
 

This will parse the expression given and evaluate it against the root object given, returning the result. If there is an error in the expression, such as the property is not found, the exception is encapsulated into an ognl.OgnlException OgnlException .

Other more sophisticated uses of Ognl can pre-parse expressions. This provides two advantages: in the case of user-supplied expressions it allows you to catch parse errors before evaluation and it allows you to cache parsed expressions into an AST for better speed during repeated use. The pre-parsed expression is always returned as an Object to simplify use for programs that just wish to store the value for repeated use and do not care that it is an AST. If it does care it can always safely cast the value to an AST type.

The Ognl class also takes a context map as one of the parameters to the set and get methods. This allows you to put your own variables into the available namespace for OGNL expressions. The default context contains only the #root and #context keys, which are required to be present. The addDefaultContext(Object, Map) method will alter an existing Map to put the defaults in. Here is an example that shows how to extract the documentName property out of the root object and append a string with the current user name in parens:

 private Map	context = new HashMap();
 public void setUserName(String value)
 {
 context.put("userName", value);
 }
 try {
 // get value using our own custom context map
 result = Ognl.getValue("documentName + \" (\" + ((#userName == null) ? \"<nobody>\" : #userName) + \")\"", context, root);
 } catch (OgnlException ex) {
 // Report error or recover
 }
 

author:
   Luke Blanshard (blanshlu@netscape.net)
author:
   Drew Davidson (drew@ognl.org)
version:
   27 June 1999




Method Summary
public static  MapaddDefaultContext(Object root, Map context)
     Appends the standard naming context for evaluating an OGNL expression into the context given so that cached maps can be used as a context.
Parameters:
  root - the root of the object graph
Parameters:
  context - the context to which OGNL context will be added.
public static  MapaddDefaultContext(Object root, ClassResolver classResolver, Map context)
     Appends the standard naming context for evaluating an OGNL expression into the context given so that cached maps can be used as a context.
Parameters:
  root - the root of the object graph
Parameters:
  context - the context to which OGNL context will be added.
public static  MapaddDefaultContext(Object root, ClassResolver classResolver, TypeConverter converter, Map context)
     Appends the standard naming context for evaluating an OGNL expression into the context given so that cached maps can be used as a context.
Parameters:
  root - the root of the object graph
Parameters:
  context - the context to which OGNL context will be added.
public static  MapaddDefaultContext(Object root, ClassResolver classResolver, TypeConverter converter, MemberAccess memberAccess, Map context)
     Appends the standard naming context for evaluating an OGNL expression into the context given so that cached maps can be used as a context.
Parameters:
  root - the root of the object graph
Parameters:
  context - the context to which OGNL context will be added.
public static  MapcreateDefaultContext(Object root)
     Creates and returns a new standard naming context for evaluating an OGNL expression.
public static  MapcreateDefaultContext(Object root, ClassResolver classResolver)
     Creates and returns a new standard naming context for evaluating an OGNL expression.
public static  MapcreateDefaultContext(Object root, ClassResolver classResolver, TypeConverter converter)
     Creates and returns a new standard naming context for evaluating an OGNL expression.
public static  MapcreateDefaultContext(Object root, ClassResolver classResolver, TypeConverter converter, MemberAccess memberAccess)
     Creates and returns a new standard naming context for evaluating an OGNL expression.
public static  ClassResolvergetClassResolver(Map context)
    
public static  EvaluationgetLastEvaluation(Map context)
    
public static  MemberAccessgetMemberAccess(Map context)
    
public static  ObjectgetRoot(Map context)
    
public static  TypeConvertergetTypeConverter(Map context)
    
public static  ObjectgetValue(Object tree, Map context, Object root)
     Evaluates the given OGNL expression tree to extract a value from the given root object.
public static  ObjectgetValue(Object tree, Map context, Object root, Class resultType)
     Evaluates the given OGNL expression tree to extract a value from the given root object.
public static  ObjectgetValue(String expression, Map context, Object root)
    
public static  ObjectgetValue(String expression, Map context, Object root, Class resultType)
    
public static  ObjectgetValue(Object tree, Object root)
     Evaluates the given OGNL expression tree to extract a value from the given root object.
public static  ObjectgetValue(Object tree, Object root, Class resultType)
     Evaluates the given OGNL expression tree to extract a value from the given root object.
public static  ObjectgetValue(String expression, Object root)
     Convenience method that combines calls to parseExpression and getValue.
public static  ObjectgetValue(String expression, Object root, Class resultType)
     Convenience method that combines calls to parseExpression and getValue.
public static  booleanisConstant(Object tree, Map context)
    
public static  booleanisConstant(String expression, Map context)
    
public static  booleanisConstant(Object tree)
    
public static  booleanisConstant(String expression)
    
public static  booleanisSimpleNavigationChain(Object tree, Map context)
    
public static  booleanisSimpleNavigationChain(String expression, Map context)
    
public static  booleanisSimpleNavigationChain(Object tree)
    
public static  booleanisSimpleNavigationChain(String expression)
    
public static  booleanisSimpleProperty(Object tree, Map context)
    
public static  booleanisSimpleProperty(String expression, Map context)
    
public static  booleanisSimpleProperty(Object tree)
    
public static  booleanisSimpleProperty(String expression)
    
public static  ObjectparseExpression(String expression)
     Parses the given OGNL expression and returns a tree representation of the expression that can be used by Ognl static methods.
public static  voidsetClassResolver(Map context, ClassResolver classResolver)
    
public static  voidsetMemberAccess(Map context, MemberAccess memberAccess)
    
public static  voidsetRoot(Map context, Object root)
    
public static  voidsetTypeConverter(Map context, TypeConverter converter)
    
public static  voidsetValue(Object tree, Map context, Object root, Object value)
     Evaluates the given OGNL expression tree to insert a value into the object graph rooted at the given root object.
public static  voidsetValue(String expression, Map context, Object root, Object value)
     Evaluates the given OGNL expression to insert a value into the object graph rooted at the given root object given the context.
public static  voidsetValue(Object tree, Object root, Object value)
     Evaluates the given OGNL expression tree to insert a value into the object graph rooted at the given root object.
public static  voidsetValue(String expression, Object root, Object value)
     Convenience method that combines calls to parseExpression and setValue.



Method Detail
addDefaultContext
public static Map addDefaultContext(Object root, Map context)(Code)
Appends the standard naming context for evaluating an OGNL expression into the context given so that cached maps can be used as a context.
Parameters:
  root - the root of the object graph
Parameters:
  context - the context to which OGNL context will be added. Context Map with the keys root and contextset appropriately



addDefaultContext
public static Map addDefaultContext(Object root, ClassResolver classResolver, Map context)(Code)
Appends the standard naming context for evaluating an OGNL expression into the context given so that cached maps can be used as a context.
Parameters:
  root - the root of the object graph
Parameters:
  context - the context to which OGNL context will be added. Context Map with the keys root and contextset appropriately



addDefaultContext
public static Map addDefaultContext(Object root, ClassResolver classResolver, TypeConverter converter, Map context)(Code)
Appends the standard naming context for evaluating an OGNL expression into the context given so that cached maps can be used as a context.
Parameters:
  root - the root of the object graph
Parameters:
  context - the context to which OGNL context will be added. Context Map with the keys root and contextset appropriately



addDefaultContext
public static Map addDefaultContext(Object root, ClassResolver classResolver, TypeConverter converter, MemberAccess memberAccess, Map context)(Code)
Appends the standard naming context for evaluating an OGNL expression into the context given so that cached maps can be used as a context.
Parameters:
  root - the root of the object graph
Parameters:
  context - the context to which OGNL context will be added. Context Map with the keys root and contextset appropriately



createDefaultContext
public static Map createDefaultContext(Object root)(Code)
Creates and returns a new standard naming context for evaluating an OGNL expression.
Parameters:
  root - the root of the object graph a new Map with the keys root and contextset appropriately



createDefaultContext
public static Map createDefaultContext(Object root, ClassResolver classResolver)(Code)
Creates and returns a new standard naming context for evaluating an OGNL expression.
Parameters:
  root - the root of the object graph a new OgnlContext with the keys root and contextset appropriately



createDefaultContext
public static Map createDefaultContext(Object root, ClassResolver classResolver, TypeConverter converter)(Code)
Creates and returns a new standard naming context for evaluating an OGNL expression.
Parameters:
  root - the root of the object graph a new Map with the keys root and contextset appropriately



createDefaultContext
public static Map createDefaultContext(Object root, ClassResolver classResolver, TypeConverter converter, MemberAccess memberAccess)(Code)
Creates and returns a new standard naming context for evaluating an OGNL expression.
Parameters:
  root - the root of the object graph a new Map with the keys root and contextset appropriately



getClassResolver
public static ClassResolver getClassResolver(Map context)(Code)



getLastEvaluation
public static Evaluation getLastEvaluation(Map context)(Code)



getMemberAccess
public static MemberAccess getMemberAccess(Map context)(Code)



getRoot
public static Object getRoot(Map context)(Code)



getTypeConverter
public static TypeConverter getTypeConverter(Map context)(Code)



getValue
public static Object getValue(Object tree, Map context, Object root) throws OgnlException(Code)
Evaluates the given OGNL expression tree to extract a value from the given root object. The default context is set for the given context and root via addDefaultContext().
Parameters:
  tree - the OGNL expression tree to evaluate, as returned by parseExpression()
Parameters:
  context - the naming context for the evaluation
Parameters:
  root - the root object for the OGNL expression the result of evaluating the expression
throws:
  MethodFailedException - if the expression called a method which failed
throws:
  NoSuchPropertyException - if the expression referred to a nonexistent property
throws:
  InappropriateExpressionException - if the expression can't be used in this context
throws:
  OgnlException - if there is a pathological environmental problem



getValue
public static Object getValue(Object tree, Map context, Object root, Class resultType) throws OgnlException(Code)
Evaluates the given OGNL expression tree to extract a value from the given root object. The default context is set for the given context and root via addDefaultContext().
Parameters:
  tree - the OGNL expression tree to evaluate, as returned by parseExpression()
Parameters:
  context - the naming context for the evaluation
Parameters:
  root - the root object for the OGNL expression
Parameters:
  resultType - the converted type of the resultant object, using the context's type converter the result of evaluating the expression
throws:
  MethodFailedException - if the expression called a method which failed
throws:
  NoSuchPropertyException - if the expression referred to a nonexistent property
throws:
  InappropriateExpressionException - if the expression can't be used in this context
throws:
  OgnlException - if there is a pathological environmental problem



getValue
public static Object getValue(String expression, Map context, Object root) throws OgnlException(Code)
Evaluates the given OGNL expression to extract a value from the given root object in a given context
See Also:   Ognl.parseExpression(String)
See Also:   Ognl.getValue(Object,Object)
Parameters:
  expression - the OGNL expression to be parsed
Parameters:
  context - the naming context for the evaluation
Parameters:
  root - the root object for the OGNL expression the result of evaluating the expression
throws:
  MethodFailedException - if the expression called a method which failed
throws:
  NoSuchPropertyException - if the expression referred to a nonexistent property
throws:
  InappropriateExpressionException - if the expression can't be used in this context
throws:
  OgnlException - if there is a pathological environmental problem



getValue
public static Object getValue(String expression, Map context, Object root, Class resultType) throws OgnlException(Code)
Evaluates the given OGNL expression to extract a value from the given root object in a given context
See Also:   Ognl.parseExpression(String)
See Also:   Ognl.getValue(Object,Object)
Parameters:
  expression - the OGNL expression to be parsed
Parameters:
  context - the naming context for the evaluation
Parameters:
  root - the root object for the OGNL expression
Parameters:
  resultType - the converted type of the resultant object, using the context's type converter the result of evaluating the expression
throws:
  MethodFailedException - if the expression called a method which failed
throws:
  NoSuchPropertyException - if the expression referred to a nonexistent property
throws:
  InappropriateExpressionException - if the expression can't be used in this context
throws:
  OgnlException - if there is a pathological environmental problem



getValue
public static Object getValue(Object tree, Object root) throws OgnlException(Code)
Evaluates the given OGNL expression tree to extract a value from the given root object.
Parameters:
  tree - the OGNL expression tree to evaluate, as returned by parseExpression()
Parameters:
  root - the root object for the OGNL expression the result of evaluating the expression
throws:
  MethodFailedException - if the expression called a method which failed
throws:
  NoSuchPropertyException - if the expression referred to a nonexistent property
throws:
  InappropriateExpressionException - if the expression can't be used in this context
throws:
  OgnlException - if there is a pathological environmental problem



getValue
public static Object getValue(Object tree, Object root, Class resultType) throws OgnlException(Code)
Evaluates the given OGNL expression tree to extract a value from the given root object.
Parameters:
  tree - the OGNL expression tree to evaluate, as returned by parseExpression()
Parameters:
  root - the root object for the OGNL expression
Parameters:
  resultType - the converted type of the resultant object, using the context's type converter the result of evaluating the expression
throws:
  MethodFailedException - if the expression called a method which failed
throws:
  NoSuchPropertyException - if the expression referred to a nonexistent property
throws:
  InappropriateExpressionException - if the expression can't be used in this context
throws:
  OgnlException - if there is a pathological environmental problem



getValue
public static Object getValue(String expression, Object root) throws OgnlException(Code)
Convenience method that combines calls to parseExpression and getValue.
See Also:   Ognl.parseExpression(String)
See Also:   Ognl.getValue(Object,Object)
Parameters:
  expression - the OGNL expression to be parsed
Parameters:
  root - the root object for the OGNL expression the result of evaluating the expression
throws:
  ExpressionSyntaxException - if the expression is malformed
throws:
  MethodFailedException - if the expression called a method which failed
throws:
  NoSuchPropertyException - if the expression referred to a nonexistent property
throws:
  InappropriateExpressionException - if the expression can't be used in this context
throws:
  OgnlException - if there is a pathological environmental problem



getValue
public static Object getValue(String expression, Object root, Class resultType) throws OgnlException(Code)
Convenience method that combines calls to parseExpression and getValue.
See Also:   Ognl.parseExpression(String)
See Also:   Ognl.getValue(Object,Object)
Parameters:
  expression - the OGNL expression to be parsed
Parameters:
  root - the root object for the OGNL expression
Parameters:
  resultType - the converted type of the resultant object, using the context's type converter the result of evaluating the expression
throws:
  ExpressionSyntaxException - if the expression is malformed
throws:
  MethodFailedException - if the expression called a method which failed
throws:
  NoSuchPropertyException - if the expression referred to a nonexistent property
throws:
  InappropriateExpressionException - if the expression can't be used in this context
throws:
  OgnlException - if there is a pathological environmental problem



isConstant
public static boolean isConstant(Object tree, Map context) throws OgnlException(Code)



isConstant
public static boolean isConstant(String expression, Map context) throws OgnlException(Code)



isConstant
public static boolean isConstant(Object tree) throws OgnlException(Code)



isConstant
public static boolean isConstant(String expression) throws OgnlException(Code)



isSimpleNavigationChain
public static boolean isSimpleNavigationChain(Object tree, Map context) throws OgnlException(Code)



isSimpleNavigationChain
public static boolean isSimpleNavigationChain(String expression, Map context) throws OgnlException(Code)



isSimpleNavigationChain
public static boolean isSimpleNavigationChain(Object tree) throws OgnlException(Code)



isSimpleNavigationChain
public static boolean isSimpleNavigationChain(String expression) throws OgnlException(Code)



isSimpleProperty
public static boolean isSimpleProperty(Object tree, Map context) throws OgnlException(Code)



isSimpleProperty
public static boolean isSimpleProperty(String expression, Map context) throws OgnlException(Code)



isSimpleProperty
public static boolean isSimpleProperty(Object tree) throws OgnlException(Code)



isSimpleProperty
public static boolean isSimpleProperty(String expression) throws OgnlException(Code)



parseExpression
public static Object parseExpression(String expression) throws OgnlException(Code)
Parses the given OGNL expression and returns a tree representation of the expression that can be used by Ognl static methods.
Parameters:
  expression - the OGNL expression to be parsed a tree representation of the expression
throws:
  ExpressionSyntaxException - if the expression is malformed
throws:
  OgnlException - if there is a pathological environmental problem



setClassResolver
public static void setClassResolver(Map context, ClassResolver classResolver)(Code)



setMemberAccess
public static void setMemberAccess(Map context, MemberAccess memberAccess)(Code)



setRoot
public static void setRoot(Map context, Object root)(Code)



setTypeConverter
public static void setTypeConverter(Map context, TypeConverter converter)(Code)



setValue
public static void setValue(Object tree, Map context, Object root, Object value) throws OgnlException(Code)
Evaluates the given OGNL expression tree to insert a value into the object graph rooted at the given root object. The default context is set for the given context and root via addDefaultContext().
Parameters:
  tree - the OGNL expression tree to evaluate, as returned by parseExpression()
Parameters:
  context - the naming context for the evaluation
Parameters:
  root - the root object for the OGNL expression
Parameters:
  value - the value to insert into the object graph
throws:
  MethodFailedException - if the expression called a method which failed
throws:
  NoSuchPropertyException - if the expression referred to a nonexistent property
throws:
  InappropriateExpressionException - if the expression can't be used in this context
throws:
  OgnlException - if there is a pathological environmental problem



setValue
public static void setValue(String expression, Map context, Object root, Object value) throws OgnlException(Code)
Evaluates the given OGNL expression to insert a value into the object graph rooted at the given root object given the context.
Parameters:
  expression - the OGNL expression to be parsed
Parameters:
  root - the root object for the OGNL expression
Parameters:
  context - the naming context for the evaluation
Parameters:
  value - the value to insert into the object graph
throws:
  MethodFailedException - if the expression called a method which failed
throws:
  NoSuchPropertyException - if the expression referred to a nonexistent property
throws:
  InappropriateExpressionException - if the expression can't be used in this context
throws:
  OgnlException - if there is a pathological environmental problem



setValue
public static void setValue(Object tree, Object root, Object value) throws OgnlException(Code)
Evaluates the given OGNL expression tree to insert a value into the object graph rooted at the given root object.
Parameters:
  tree - the OGNL expression tree to evaluate, as returned by parseExpression()
Parameters:
  root - the root object for the OGNL expression
Parameters:
  value - the value to insert into the object graph
throws:
  MethodFailedException - if the expression called a method which failed
throws:
  NoSuchPropertyException - if the expression referred to a nonexistent property
throws:
  InappropriateExpressionException - if the expression can't be used in this context
throws:
  OgnlException - if there is a pathological environmental problem



setValue
public static void setValue(String expression, Object root, Object value) throws OgnlException(Code)
Convenience method that combines calls to parseExpression and setValue.
See Also:   Ognl.parseExpression(String)
See Also:   Ognl.setValue(Object,Object,Object)
Parameters:
  expression - the OGNL expression to be parsed
Parameters:
  root - the root object for the OGNL expression
Parameters:
  value - the value to insert into the object graph
throws:
  ExpressionSyntaxException - if the expression is malformed
throws:
  MethodFailedException - if the expression called a method which failed
throws:
  NoSuchPropertyException - if the expression referred to a nonexistent property
throws:
  InappropriateExpressionException - if the expression can't be used in this context
throws:
  OgnlException - if there is a pathological environmental problem



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.