ognl-2.7.3.orig/0000755000175000017500000000000011237553172013323 5ustar drazzibdrazzibognl-2.7.3.orig/docs/0000755000175000017500000000000011237553172014253 5ustar drazzibdrazzibognl-2.7.3.orig/docs/index.html0000644000175000017500000000272310633051645016251 0ustar drazzibdrazzib

OGNL stands for Object-Graph Navigation Language; it is an expression language for getting and setting properties of Java objects. You use the same expression for both getting and setting the value of a property.

The ognl.Ognl class contains convenience methods for evaluating OGNL expressions. You can do this in two stages, parsing an expression into an internal form and then using that internal form to either set or get the value of a property; or you can do it in a single stage, and get or set a property using the String form of the expression directly.

OGNL started out as a way to set up associations between UI components and controllers using property names. As the desire for more complicated associations grew, Drew Davidson created what he called KVCL, for Key-Value Coding Language, egged on by Luke Blanshard. Luke then reimplemented the language using ANTLR, came up with the new name, and, egged on by Drew, filled it out to its current state. Later on Luke again reimplemented the language using JavaCC. Further maintenance on all the code is done by Drew (with spiritual guidance from Luke).

We pronounce OGNL as a word, like the last syllables of a drunken pronunciation of "orthogonal."

ognl-2.7.3.orig/pom.xml0000644000175000017500000001203611017307302014626 0ustar drazzibdrazzib 4.0.0 ognl ognl jar 2.7.3 OGNL - Object Graph Navigation Library 1997 http://ognl.org OpenSymphony http://www.opensymphony.com jira http://jira.opensymphony.com/browse/OGNL junit junit 3.8.1 test org.easymock easymock 2.3 test jboss javassist 3.7.ga src/java src/test/java org.apache.maven.plugins maven-compiler-plugin 1.4 1.4 compile-tests process-test-sources testCompile 1.5 1.5 org.apache.maven.plugins maven-surefire-plugin 2.3 **/OgnlTestCase.java **/*$* org.apache.maven.plugins maven-jar-plugin true true org.apache.maven.plugins maven-source-plugin true true jar org.apache.maven.plugins maven-javadoc-plugin true true jar org.apache.maven.plugins maven-clean-plugin 2.1.1 opensymphony OpenSymphony Maven Repository scp://maven2.opensymphony.com/opt/repository/maven2 opencomponentry.com scpexe://opencomponentry.com/var/www/vhosts/opencomponentry.com/httpdocs/repository/m2-snapshot-repo ognl-2.7.3.orig/build.xml0000644000175000017500000000525310617163774015157 0ustar drazzibdrazzib ognl-2.7.3.orig/LICENSE.txt0000644000175000017500000000500310561411075015136 0ustar drazzibdrazzib/* ==================================================================== * The OpenSymphony Software License, Version 1.1 * * (this license is derived and fully compatible with the Apache Software * License - see http://www.apache.org/LICENSE.txt) * * Copyright (c) 2001-2004 The OpenSymphony Group. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, * if any, must include the following acknowledgment: * "This product includes software developed by the * OpenSymphony Group (http://www.opensymphony.com/)." * Alternately, this acknowledgment may appear in the software itself, * if and wherever such third-party acknowledgments normally appear. * * 4. The names "OpenSymphony" and "The OpenSymphony Group" * must not be used to endorse or promote products derived from this * software without prior written permission. For written * permission, please contact license@opensymphony.com . * * 5. Products derived from this software may not be called "OpenSymphony" * or "OGNL", nor may "OpenSymphony" or "OGNL" appear in their * name, without prior written permission of the OpenSymphony Group. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== */ognl-2.7.3.orig/lib/0000755000175000017500000000000011237553153014070 5ustar drazzibdrazzibognl-2.7.3.orig/OGNL.iws0000644000175000017500000015431411017307302014602 0ustar drazzibdrazzib localhost 5050 ognl-2.7.3.orig/www/0000755000175000017500000000000011237553153014146 5ustar drazzibdrazzibognl-2.7.3.orig/www/index.html0000644000175000017500000000303310633051645016140 0ustar drazzibdrazzib Project Home Page

OGNL

OGNL stands for Object-Graph Navigation Language; it is an expression language for getting and setting properties of Java objects. You use the same expression for both getting and setting the value of a property.

The ognl.Ognl class contains convenience methods for evaluating OGNL expressions. You can do this in two stages, parsing an expression into an internal form and then using that internal form to either set or get the value of a property; or you can do it in a single stage, and get or set a property using the String form of the expression directly.

OGNL started out as a way to set up associations between UI components and controllers using property names. As the desire for more complicated associations grew, Drew Davidson created what he called KVCL, for Key-Value Coding Language, egged on by Luke Blanshard. Luke then reimplemented the language using ANTLR, came up with the new name, and, egged on by Drew, filled it out to its current state. Later on Luke again reimplemented the language using JavaCC. Further maintenance on all the code is done by Drew (with spiritual guidance from Luke).

We pronounce OGNL as a word, like the last syllables of a drunken pronunciation of "orthogonal."

WebWork's homepage is http://www.opensymphony.com/ognl

ognl-2.7.3.orig/www/project_tools.html0000644000175000017500000000046610561411075017723 0ustar drazzibdrazzib
OpenSymphony
Documentation
Bug Tracker
Wiki
ognl-2.7.3.orig/build.properties0000644000175000017500000000007310671763055016544 0ustar drazzibdrazzibname = ognl fullname = OGNL version = 2.7.2 package = ognl ognl-2.7.3.orig/OGNL.ipr0000644000175000017500000005072111017307302014567 0ustar drazzibdrazzib ognl-2.7.3.orig/docbook/0000755000175000017500000000000011237553153014742 5ustar drazzibdrazzibognl-2.7.3.orig/docbook/style/0000755000175000017500000000000011237553153016102 5ustar drazzibdrazzibognl-2.7.3.orig/docbook/style/html-xsl.template0000644000175000017500000000253010561411075021402 0ustar drazzibdrazzib 1 #E0E0E0 ../images/navigation/ 1 ../images/admon/ ../images/callouts/ _self ../docbook.css ognl-2.7.3.orig/docbook/style/fop-xsl.template0000644000175000017500000000645010561411075021227 0ustar drazzibdrazzib pt 0.25in #CCCCCC solid 0.25pt #EEEEEE 2pt 2pt 2pt 2pt 0.8em 1em 1.2em start common-images/ 1 common-images/ pt pt bold false always standard-images/callouts/ ognl-2.7.3.orig/docbook/style/docbook.css0000644000175000017500000000417310561411075020234 0ustar drazzibdrazzibbody { background-color: #FFFFFF; font-family: Verdana, Helvetica, sans-serif; font-size: 80%; } A { color: #003399; } A:active { color: #003399; } A:visited { color: #888888; } .table table { border-color: #000000; border-width: 1px; border-collapse: collapse; margin-left: 20px; margin-right: 0px; } .note table { border-width: 0px; border-collapse: collapse; } td, th, span { font-family: Verdana, Helvetica, sans-serif; font-size: 80%; } td, th { padding-top: 1px; padding-left: 3px; padding-bottom: 1px; padding-right: 5px; border-color: #000000; border-width: 1px; } thead th { background-color: #666699; color: #ffffff; } img { border: 0; } p, ol, ul, li, dl, dt, dd, blockquote { color: #000000; } blockquote { margin-right: 0px; } h1, h2, h3, h4, h5, h6 { font-weight:500; margin-top:10px; padding-top:15px; } h1 { font-size: 180%; } h2 { font-size: 160%; } h3 { font-size: 130%; font-weight: bold; } h4 { font-size: 110%; font-weight: bold; } h5 { font-size: 100%; font-style: italic; } h6 { font-size: 100%; font-style: italic; } tt { font-family: "Courier New", Courier, monospace; font-size: 120%; } pre { padding: 5px; border-style: solid; border-width: 1px; border-color: #CCCCCC; background-color: #F4F4F4; } ul, ol, li { list-style: disc; } hr { width: 100%; height: 1px; background-color: #CCCCCC; border-width: 0px; padding: 0px; color: #CCCCCC; } .table .title { margin-left: 20px; margin-right: 0px; } .variablelist { padding-top: 0; padding-bottom: 0; } .itemizedlist, UL { padding-top: 0; padding-bottom: 0; } .term { font-weight:bold; font-size: 85%; } .programlisting { margin-left: 20px; margin-right: 0px; } .sidebar { border-style: solid; border-width: 1px; border-color: #cccccc; background-color: #eeeeee; padding-top: 5px; padding-left: 5px; padding-bottom: 5px; padding-right: 5px; } ognl-2.7.3.orig/docbook/DeveloperGuide.xml0000644000175000017500000004411310561411075020365 0ustar drazzibdrazzib OGNL Developer Guide Drew Davidson
drew@ognl.org
2004 OGNL Technology, Inc.
Introduction OGNL as a language allows for the navigation of Java objects through a concise syntax that allows for specifying, where possible, symmetrically settable and gettable values. The language specifies a syntax that attempts to provide as high a level of abstraction as possible for navigating object graphs; this usually means specifying paths through and to JavaBeans properties, collection indices, etc. rather than directly accessing property getters and setters (collectively know as accessors). The normal usage of OGNL is to embed the language inside of other constructs to provide a place for flexible binding of values from one place to another. An example of this is a web application where values need to be bound from a model of some sort to data transfer objects that are operated on by a view. Another example is an XML configuration file wherein values are generated via expressions which are then bound to configured objects.
Embedding OGNL The ognl.Ognl class contains convenience methods for evaluating OGNL expressions. You can do this in two stages, parsing an expression into an internal form and then using that internal form to either set or get the value of a property; or you can do it in a single stage, and get or set a property using the String form of the expression directly. It is more efficient to pre-compile the expression to it's parsed form, however, and this is the recommended usage. OGNL expressions can be evaluated without any external context, or they can be provided with an execution environment that sets up custom extensions to modify the way that expressions are evaluated. The following example illustrates how to encapsulate the parsing of an OGNL expression within an object so that execution will be more efficient. The class then takes an OgnlContext and a root object to evaluate against. Expression Class import ognl.Ognl; import ognl.OgnlContext; public class OgnlExpression { private Object expression; public OgnlExpression(String expressionString) throws OgnlException { super(); expression = Ognl.parseExpression(expressionString); } public Object getExpression() { return expression; } public Object getValue(OgnlContext context, Object rootObject) throws OgnlException { return Ognl.getValue(getExpression(), context, rootObject); } public void setValue(OgnlContext context, Object rootObject, Object value) throws OgnlException { Ognl.setValue(getExpression(), context, rootObject, value); } }
Extending OGNL OGNL expressions are not evaluated in a static environment, as Java programs are. Expressions are not compiled to bytecode at the expression level based on static class reachability. The same expression can have multiple paths through an object graph depending upon the root object specified and the dynamic results of the navigation. Objects that are delegated to handle all of the access to properties of objects, elements of collections, methods of objects, resolution of class names to classes and converting between types are collectively known as OGNL extensions. The following chapters delve more deeply into these extensions and provide a roadmap as to how they are used within OGNL to customize the dynamic runtime environment to suit the needs of the embedding program.
Property Accessors When navigating an OGNL expression many of the elements that are found are properties. Properties can be many things depending on the object being accessed. Most of the time these property names resolve to JavaBeans properties that conform to the set/get pattern. Other objects (such as Map) access properties as keyed values. Regardless of access methodology the OGNL syntax remains the same. Under the hood, however, there are PropertyAccessor objects that handle the conversion of property name to an actual access to an objects' properties. public interface PropertyAccessor { Object getProperty( Map context, Object target, Object name ) throws OgnlException; void setProperty( Map context, Object target, Object name, Object value ) throws OgnlException; } You can set a property accessor on a class-by-class basis using OgnlRuntime.setPropertyAccessor(). There are default property accessors for Object (which uses JavaBeans patterns to extract properties) and Map (which uses the property name as a key). Method Accessors Method calls are another area where OGNL needs to do lookups for methods based on dynamic information. The MethodAccessor interface provides a hook into how OGNL calls a method. When a static or instance method is requested the implementor of this interface is called to actually execute the method. public interface MethodAccessor { Object callStaticMethod( Map context, Class targetClass, String methodName, List args ) throws MethodFailedException; Object callMethod( Map context, Object target, String methodName, List args ) throws MethodFailedException; } You can set a method accessor on a class-by-class basis using OgnlRuntime.setMethodAccessor(). The is a default method accessor for Object (which simply finds an appropriate method based on method name and argument types and uses reflection to call the method). Elements Accessors Since iteration is a built-in function of OGNL and many objects support the idea of iterating over the contents of an object (i.e. the object.{ ... } syntax) OGNL provides a hook into how iteration is done. The ElementsAccessor interface defines how iteration is done based on a source object. Simple examples could be a Collection elements accessor, which would simply public interface ElementsAccessor { public Enumeration getElements( Object target ) throws OgnlException; } You can set a method accessor on a class-by-class basis using OgnlRuntime.setElementsAccessor(). There are default elements accessors for Object (which returns an Enumeration of itself as the only object), Map (which iterates over the values in the Map), and Collection (which uses the collection's iterator()). One clever use of ElementsAccessors is the NumberElementsAccessor class which allows for generating numeric sequences from 0 to the target value. For example the expression (100).{ #this } will generate a list of 100 integers ranged 0..99. Class References In the sections on accessing static field and static methods it stated that classes must be full-specified in between the class reference specifier (@<classname>@<field|method>@). This is not entirely true; the default ClassResolver simply looks up the name of the class and assumes that it is fully specified. The ClassResolver interface is included in the OGNL context to perform lookup of classes when an expression is evaluated. This makes it possible to specify, for example, a list of imports that are specific to a particular setValue() or getValue() context in order to look up classes. It also makes class references agreeably short because you don't have to full specify a class name. public interface ClassResolver { public Class classForName(Map context, String className) throws ClassNotFoundException; } You can set a class resolver on a context basis using the Ognl methods addDefaultContext() and createDefaultContext(). Type Conversion When performing set operations on properties or calling methods it is often the case that the values you want to set have a different type from the expected type of the class. OGNL supports a context variable (set by OgnlRuntime.setTypeConverter(Map context, TypeConverter typeConverter)) that will allow types to be converted from one to another. The default type converter that is uses is the ognl.DefaultTypeConverter, which will convert among numeric types (Integer, Long, Short, Double, Float, BigInteger, BigDecimal, and their primitive equivalents), string types (String, Character) and Boolean. Should you need specialized type conversion (one popular example is in Servlets where you have a String[] from an HttpServletRequest.getParameters() and you want to set values with it in other objects; a custom type converter can be written (most likely subclassing ognl.DefaultTypeConverter) to convert String[] to whatever is necessary. public interface TypeConverter { public Object convertValue(Map context, Object target, Member member, String propertyName, Object value, Class toType); } Note that ognl.DefaultTypeConverter is much easier to subclass; it implements TypeConverter and calls it's own convertValue(Map context, Object value, Class toType) method and already provides the numeric conversions. For example, the above converter (i.e. converting String[] to int[] for a list of identifier parameters in a request) implemented as a subclass of ognl.DefaultTypeConverter: HttpServletRequest request; Map context = Ognl.createDefaultContext(this); /* Create an anonymous inner class to handle special conversion */ Ognl.setTypeConverter(context, new ognl.DefaultTypeConverter() { public Object convertValue(Map context, Object value, Class toType) { Object result = null; if ((toType == int[].class) && (value instanceof String[].class)) { String sa = (String[])value; int[] ia = new int[sa.length]; for (int i = 0; i < sa.length; i++) { Integer cv; cv = (Integer)super.convertValue(context, sa[i], Integer.class); ia[i] = cv.intValue(); } result = ia; } else { result = super.convertValue(context, value, toType); } return result; } }); /* Setting values within this OGNL context will use the above-defined TypeConverter */ Ognl.setValue("identifiers", context, this, request.getParameterValues("identifier")); Member Access Normally in Java the only members of a class (fields, methods) that can be accessed are the ones defined with public access. OGNL includes an interface that you can set globally (using OgnlContext.setMemberAccessManager()) that allows you to modify the runtime in Java 2 to allow access to private, protected and package protected fields and methods. Included in the OGNL package is the DefaultMemberAccess class. It contains a constructor that allows you to selectively lower the protection on any private, protected or package protected members using the AccessibleObject interface in Java2. The default class can be subclasses to select different objects for which accessibility is allowed. public interface MemberAccess { public Object setup( Member member ); public void restore( Member member, Object state ); public boolean isAccessible( Member member ); } Null Handler When navigating a chain sometimes properties or methods will evaluate to null, causing subsequent properties or method calls to fail with NullPointerExceptions. Most of the time this behaviour is correct (as it is with Java), but sometimes you want to be able to dynamically substitute another object in place of null. The NullHandler interface allows you to specify on a class-by-class basis how nulls are handled within OGNL expressions. Implementing this interface allows you to intercept when methods return null and properties evaluate to null and allow you to substitute a new value. Since you are given the source of the method or property a really clever implementor might write the property back to the object so that subsequent invocations do not return or evaluate to null. public interface NullHandler { public Object nullMethodResult(Map context, Object target, String methodName, List args); public Object nullPropertyValue(Map context, Object target, Object property); } NullHandler implementors are registered with OGNL using the OgnlRuntime.setNullHandler() method. Other API features
Tracing Evaluations As of OGNL 2.5.0 the OgnlContext object can automatically tracks evaluations of expressions. This tracking is kept in the OgnlContext as currentEvaluation during the evaluation. After execution you can access the last evaluation through the lastEvaluation property of OgnlContext. The tracing feature is turned off by default. If you wish to turn it on there is a setTraceEvaluations() method on OgnlContext that you can call. Any method accessor, elements accessor, type converter, property accessor or null handler may find this useful to give context to the operation being performed. The Evaluation object is itself a tree and can be traversed up, down and left and right through siblings to determine the exact circumstances of an evaluation. In addition the Evaluation object tracks the node that was performing the operation, the source object on which that operation was being performed and the result of the operation. If an exception is thrown during execution the user can get the last evaluation's last descendent to find out exactly which subexpression caused the error. The execption is also tracked in the Evaluation.
ognl-2.7.3.orig/docbook/images/0000755000175000017500000000000011237553153016207 5ustar drazzibdrazzibognl-2.7.3.orig/docbook/images/admon/0000755000175000017500000000000011237553153017305 5ustar drazzibdrazzibognl-2.7.3.orig/docbook/images/admon/warning.png0000644000175000017500000000120110561411075021445 0ustar drazzibdrazzib‰PNG  IHDRàw=øsBIT|dˆ pHYs  ÒÝ~ü tEXtSoftwareMacromedia Fireworks MX»‘*$tEXtCreation Time05/15/03ßR@ÿÕIDATxœ–¯“£0†Ÿí¬H8HäÉÚ“HdW®Ü?¡¶r%çj‘+³nO¦ŽsÔ\™ºÆ}'J{åJí7Ã$3ɼÏ÷~ùÅ“ˆ7¢m[œs·†ÏÇ1A Ž=Ýl·[ê÷wâݧʹÁ€×W~¾¼ Cd ´ÖRf™X¥ä£Ÿ‰"ù( ±Ö^iõÖZ1ÆH¹XL¿„”ëõ¤0ÆÈf¹¼[¼)Ëä ÐZf®A ú'œ2«ùH €,Á;÷rMhšF6y>Z–¢:ÏÅ ¢ËRfÎ9¶Eì÷Pý[‘î÷´uÍ ?‰Î@¨ÆǘÿŒ'¢NXÉĤ΀)“ç]pÑNLqpÊþ!ÀT»§ÅVýc<Ã4yIïLv°~°»𬔚äÀ¿.`?ð¯E›$„qÌ, CÔÛ¢È P@xÑŸûÄÓ”*ÏYdÙñ=°ÖŠÞlÄD‘÷øk5Hå™S§©”ëµ4MÓ¿M­µòQb‚à¡«úò$R¬Vgñ«÷àp8ˆÖú!H¦R¬Vþ§çd¤\¾²xÿ¯‰UJ¾»û¨­ºÌ‡ÄEDnþU8ç0ŸŸ´UåÝ]ó8f‘e$I28þaûö0º0ò=IEND®B`‚ognl-2.7.3.orig/docbook/images/admon/caution.gif0000644000175000017500000000201710561411075021431 0ustar drazzibdrazzibGIF87a÷!!11BBZZcckkss{{„„„„sŒŒŒŒsŒŒŒ””””s””{œœœœsœœ{œœ”œœœ¥¥¥¥c¥¥œ¥¥¥µµµµZµµcµµµ½½½½cÎÎÎÎÎÖÖÖÖÎÖÖÖÞÞÞÞ1ÞÞ9ÞÞBçççç1çç9çççïïïïï÷÷÷÷÷÷÷÷1÷÷÷ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ,ôuH° Áƒ_Ä@È ‰6DHB $N$ø¢Á 4>pиña (e|ˆ¸QGE(YÀéaäD`ÊèP 8j’,XÑEJt@ÃP?MºeH›œL)ƒ‚€%¸ªd)ð¥Ø üäJC¨Ž¨geŒp`-[ tÄààÆYÌ«b 16|ø‹ÀÁÙÜûÁoÊ "ؕтd‚‰=àHÉ)UDF¸W4Ê  „•áÂÂ热-—X«ÂöÆÄ‹¹B¾Ý²åÎÄ'†Æ¡:ùo ·Ä ÂùÀ€;ognl-2.7.3.orig/docbook/images/admon/important.gif0000644000175000017500000000207110561411075022004 0ustar drazzibdrazzibGIF87a÷)))999BB1BBBJJJRRRZZ)ccccRccckkBkkkssR{{{„„„ŒŒŒŒ9ŒŒ{ŒŒŒ””Z””Œ”””œœZœœcœœ{œœœ¥¥c¥¥„¥¥”¥¥œ¥¥¥­­!­­9­­k­­{­­„­­Œ­­¥­­­µµJµµRµµŒµµµ½½½½Z½½„½½œ½½½ÆÆÆÆZÆÆÆÎÎsÎÎÎÖÖÖÖRÖÖcÖÖkÖÖÖÞÞÞÞ!ÞÞ1ÞÞ9ÞÞRÞÞÞçççç!çç)çç1ççZççcçç{çççïïïïïï1ïïBïïï÷÷÷÷÷÷1÷÷9÷÷J÷÷÷ÿÿÿÿÿÿÿÿ!ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ,þ·Hp‰Aƒ*ܲĆˆ ""BÄae!A+3,|Ò¤cG,à°È0ƒ‡$WRªT©CƒˆŠ ­dˆÑd¥Í”ML¸ˆ9Ó& |Üܰs Ž5WR@AR•M< ¸$J› ˜rSG 8Pܼ"i'c9,Ù""ÈØLd‹ÇOW¾`ÂØ+D2ÜÍ«2$þ<öG+ Æ;ÖÈ;$3¾ùÄÂ%ŠElqÁõæ 9æÞ¬»¥Ç‡±Ìá b­•:nB`jà‡M,0жö@؇/nò… 7µ ½)R¡ˆ „ó0r¡ 5žŒ}Â"ƒ ’­ET@A¤=‘*¨X‹žª ø'ÒO;ognl-2.7.3.orig/docbook/images/admon/tip.png0000644000175000017500000000135710561411075020610 0ustar drazzibdrazzib‰PNG  IHDRµVÆsBIT|dˆ pHYs  ÒÝ~ü tEXtSoftwareMacromedia Fireworks MX»‘*$tEXtCreation Time05/15/03ßR@ÿCIDATxœ­V¡¿ª0þîýÝ€m4ˆÄÙ°A$ZmV£Ñè¿ jä6£4‰ÐFsÍÅ­Aƒ¶| >½÷ù~Û9;ß¾³>´Ö/@)õ0gYÖ+Kñõ,°BEÓ4[[3¦”‚R Ã0zã|t)©ëiš‚sÞ²m„”eÙ~…`Œ|߇뺯‘(¥°ßïaš&<σã8Cbyž#MS˜¦‰ù|>LR×5v»(¥ð}0ÿB)…$I@Át:½7꿨ªJ‡a¨Ç£îƒ”RGQ¤¥”½>]1ZÆ˜Ž¢HWUÕ¹¸ª*½^¯µã8z¹\ö59ŸÏíÜg#•sŽ ST×5Š¢@Q½>–eRŠ,ËîÓÅӇá7 ÎçóÃ.ûT‡aتýÎ9<Ï<ØívÛ* „ Þ:Ã0à8¤”—‚mrØw ÇÑ4½\.ŸúK)u†×3y«Õê©Ú>´$eY:. ŒÇãÿ#!„ü*ÀHž)ù)ªªº’X–B¤”o%ɲ ¾ï_H€R ÎùÛšÞcÛö•¤äyþ’Óé˲ڦö \ŠÇó›ÍæÁþдâ8†³ÙìåÞ(H’AçøéˆÆq$Š¢ìÿ€——Œ1Œã€'†ívû_É„(¥hÛø-Ó¾ïî6´m[æyfY‚ ð«”’0 oöÇqLš¦ À1æBàno­Ek#ÕZ£”"I„,˲,ÔuMÛ¶7𦠀ççg„h­Ù¸ ÃÃáà+QJ±ßï‹tµÖ4MC–eäyÎáp¸‘±#w«ªê}’¯Ù¯-ÀZËét¢ï{æy¦ª*‚ @)Å0 >1@dY†”ÒÇ6ó<ÿ±i]סµ¦( „¾/Ó4QÖZ„~up*Ú¸F¹^ÃYƲ,~Rƒ @kM’$>éur÷ÈáJ¦Ž¤,KŽÇ#ÖZà"€ Èóœ$IÃiš¾%é(ŠØÄqìRUUq8ØíväyNUUh­±Ö²ßïzT]×(¥.H)ý,Àų,ãt:¡µö¢ˆ××ׇÓR¾›Ýñx¼ñöq Ãyžýúw­ëÚWîeš¦)}ß“$‰—éw’}Fß÷c¼û&+¥Bxö…{ö^UŸíö|>¯eY®Ó4ý•Mw]·¾½½­]×}ˆß}eVUÅ8ŽdYöñ6w`Œ¡ë:¿ÿ³|ïÀEÿÎð’$ñ]³Ý:ßɲìîWÆ—ã8b­¥išq÷E!¥üc…¿ÿT6G.î×IEND®B`‚ognl-2.7.3.orig/docbook/images/admon/tip.gif0000644000175000017500000000200510561411075020560 0ustar drazzibdrazzibGIF87a÷  !!!"""###$$$%%%&&&'''((()))***+++,,,---...///000111222333444555666777888999:::;;;<<<===>>>???@@@AAABBBCCCDDDEEEFFFGGGHHHIIIJJJKKKLLLMMMNNNOOOPPPQQQRRRSSSTTTUUUVVVWWWXXXYYYZZZ[[[\\\]]]^^^___```aaabbbcccdddeeefffggghhhiiijjjkkklllmmmnnnooopppqqqrrrssstttuuuvvvwwwxxxyyyzzz{{{|||}}}~~~€€€‚‚‚ƒƒƒ„„„………†††‡‡‡ˆˆˆ‰‰‰ŠŠŠ‹‹‹ŒŒŒŽŽŽ‘‘‘’’’“““”””•••–––———˜˜˜™™™ššš›››œœœžžžŸŸŸ   ¡¡¡¢¢¢£££¤¤¤¥¥¥¦¦¦§§§¨¨¨©©©ªªª«««¬¬¬­­­®®®¯¯¯°°°±±±²²²³³³´´´µµµ¶¶¶···¸¸¸¹¹¹ººº»»»¼¼¼½½½¾¾¾¿¿¿ÀÀÀÁÁÁÂÂÂÃÃÃÄÄÄÅÅÅÆÆÆÇÇÇÈÈÈÉÉÉÊÊÊËËËÌÌÌÍÍÍÎÎÎÏÏÏÐÐÐÑÑÑÒÒÒÓÓÓÔÔÔÕÕÕÖÖÖ×××ØØØÙÙÙÚÚÚÛÛÛÜÜÜÝÝÝÞÞÞßßßàààáááâââãããäääåååæææçççèèèéééêêêëëëìììíííîîîïïïðððñññòòòóóóôôôõõõööö÷÷÷øøøùùùúúúûûûüüüýýýþþþÿÿÿ,êÿ HðœAƒ*xÎX)J¥"BtvoaÂ{½&ž»·±!%JÎ,2„èM¤3ˆïQêUQä¿s¥j)TÙK!Ìs W&tVªåÀ{{B¬ÁY°TI†¥ˆ¼7‚¥yF•¹Ð›Ñ…*‰^UÈhϪ k…„é“`Ö”xŽÒËž )åH»vä[¨?ÇÐ]ØömÝ÷ôªåëö&VÁ½¹ý'öð^…¥Bþ³êxpBÀ#ÏD¬°WÍVñ2 ±g-O¼z3&™ £ÖkQ«ÐÙk‘ý='Û˜ËÉ”=x"m‹çŠŒ|ü_@;ognl-2.7.3.orig/docbook/images/admon/important.png0000644000175000017500000000153110561411075022023 0ustar drazzibdrazzib‰PNG  IHDRàw=øsBIT|dˆ pHYs  ÒÝ~ü tEXtSoftwareMacromedia Fireworks MX»‘*$tEXtCreation Time05/15/03ßR@ÿ­IDATxœV-«0þ®óDp‰‰Ì¹ÖDòçj++OöäÉÊÊ«äu}î*9®qE\qûG¦@ûÞ7“Èf÷›ÝìOžˆˆðʲ¼Ù³mû®Þ¯{F‹¢@Q0Æ@q’µÿRJH)Áë´ñÔåA]×HÓyžÃqjx^!Šå,[¢( T•@Ç÷ ʲD’$"G¶½r T„4e°¬ßˆ¢èÊ›+‚º®±^¯!e…Éd Ϋ»Æ[TÇn7c>Â0< èÇã‘V«}}½n–1 åÒ£×׈‡[y»>>f´Ýn[³t"ȲŒ’dNÆðNÅåÒ#€¦SÙ{ÎNq<£Ãá@DD£6îJeðýº7,J=Ÿ¾‹‚÷óçÆcƒ<ÿŒ@k ƪÁ uݳAÇqp‘±7rcö(˲©¥>>???@@@AAABBBCCCDDDEEEFFFGGGHHHIIIJJJKKKLLLMMMNNNOOOPPPQQQRRRSSSTTTUUUVVVWWWXXXYYYZZZ[[[\\\]]]^^^___```aaabbbcccdddeeefffggghhhiiijjjkkklllmmmnnnooopppqqqrrrssstttuuuvvvwwwxxxyyyzzz{{{|||}}}~~~€€€‚‚‚ƒƒƒ„„„………†††‡‡‡ˆˆˆ‰‰‰ŠŠŠ‹‹‹ŒŒŒŽŽŽ‘‘‘’’’“““”””•••–––———˜˜˜™™™ššš›››œœœžžžŸŸŸ   ¡¡¡¢¢¢£££¤¤¤¥¥¥¦¦¦§§§¨¨¨©©©ªªª«««¬¬¬­­­®®®¯¯¯°°°±±±²²²³³³´´´µµµ¶¶¶···¸¸¸¹¹¹ººº»»»¼¼¼½½½¾¾¾¿¿¿ÀÀÀÁÁÁÂÂÂÃÃÃÄÄÄÅÅÅÆÆÆÇÇÇÈÈÈÉÉÉÊÊÊËËËÌÌÌÍÍÍÎÎÎÏÏÏÐÐÐÑÑÑÒÒÒÓÓÓÔÔÔÕÕÕÖÖÖ×××ØØØÙÙÙÚÚÚÛÛÛÜÜÜÝÝÝÞÞÞßßßàààáááâââãããäääåååæææçççèèèéééêêêëëëìììíííîîîïïïðððñññòòòóóóôôôõõõööö÷÷÷øøøùùùúúúûûûüüüýýýþþþÿÿÿ,þÿ HðœAƒ*Ø«¥R:[˜ð1F¥¬{Çñœ1J”&R<÷ÐÅÎ(ÕZø®ÔÊ“[öªHi&L‚5 :+u³b)“öL¸S`Q‚ÆzÕRÚËÛA„ÿJ‹êí5k¥ÕræÍš3F„ F¤tnë9© · <—Ò˜³9M½u élF²ßQ£E‰”=5k-5öޤ·»Sîáz˜Ò¿wÖ=ëQb½sTö¸$eJ{Jq\³Ç«±=@žýWËšÀZ!×lž3ƦÂR±Æ<-%3!c[BŽ*òŸÓã'{ÙÆšxèÎá¯yýǨøÀ^” Süj l¿ÃÄŠQî9o;µ6‡‰$HÜÚ;ognl-2.7.3.orig/docbook/images/admon/caution.png0000644000175000017500000000132610561411075021452 0ustar drazzibdrazzib‰PNG  IHDRàw=øsBIT|dˆ pHYs  ÒÝ~ü tEXtSoftwareMacromedia Fireworks MX»‘*$tEXtCreation Time05/15/03ßR@ÿ*IDATxœµ•­“³0ÆŸ;…Ì9"‘•Ôµ2’ʺžìŸ€<[ùÊÊV"‘Ä]$u ϵ\âZ·¯”R>ʉۙ 3 Ùß>ûoDDøC{ÿí…²,aŒù@žç8ÿAÊx2d2 Ïs¤i„Í&c qM‚L”e )#A΄Pà<‡”ò5„^X–e´Û…t½út½¢µ’dKQt ­õàýQMZR9Ààv³çB$`L+‹|¿ÿ¢óyñ1È÷AÛ-¨(ì£$ÙPE½JzÖyHE±h¥$ AÈu-¬Þ¯!‡C7]=”±ÓË€ÛÍT…?uÒÕÔ}† œ«Ž£Ù ` àð¼NhâXÕ¤™“; ¯ Ïƹ}~|ØÕgÏ…žû|8-œŽ¸îà+•@!MS pž7ÇÏ `øö£ÇF…­]pÎ-€1† `Œ€R«±ð°ZÙüŒñ!åËå¾ï75°uÙö*ÑÚ¦ÇqìÀõ9¢O,—Ÿð}ßn>Ï€Öš¢è@I²!"ÖšƒÝÎÎ羿۟óyAû}HY–ÏA£d)8»Ÿy^³êzØÈPJ´#¯ì¨ÿfŒ”Œ%UW”€ËÅ™UÜ¢°ÎçóuÇù( Ä`ì!޽9ãþÈ'ÚJ„HîJê‚ !O´•(Äå2«Zq8ò_• Z»÷>e“5$MSpÎ'9€ÿI9•SüÞIEND®B`‚ognl-2.7.3.orig/docbook/images/admon/warning.gif0000644000175000017500000000203410561411075021433 0ustar drazzibdrazzibGIF87a÷!)1BJRZks{„Œ””{{œRRœZZœ{{¥¥99¥JJ¥„„¥””¥¥¥­­11­””µµ))µŒŒµœœµ¥¥µµµ½½­­½µµÆÆÆÆÆÆÎÎÎÎ))ÖÖ))ÖÖÖÞÞÞÞçç!!çççïïïïï÷÷÷÷ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ,þyÈCŒƒâ Èp`Š6Dœ¸a‡… аp#‡ÇQ\̈#E…Ž Sæ@q#ÁPªL‰"ƒK"NªìðÀ…J–SpT9‚@€2C^”!éÇðù3Œ 3shÀ@Œ™7 ÀðÕÄœz {5kŒdeKvæŒÌ‹5+‚öŽÍšC ‚ûÎÑ€ªJºYg0@€,ŠSjˆêuf 8@ ˜Ùa@€3T¾˜ ƒGèÑ;¨P}¡µ@NNIã2C"tïÎñÂ͸ag}Q;ãmÑ7fDŸ>£…oçu˜À½;w ¶ ;ognl-2.7.3.orig/docbook/images/callouts/0000755000175000017500000000000011237553153020035 5ustar drazzibdrazzibognl-2.7.3.orig/docbook/images/callouts/9.png0000644000175000017500000000071510561411075020711 0ustar drazzibdrazzib‰PNG  IHDR Vu\çsBIT|dˆ pHYs  ÒÝ~ü tEXtSoftwareMacromedia Fireworks MX»‘*$tEXtCreation Time05/15/03ßR@ÿ!IDATxœeR!’Ã0 ܹ)445L‹:þaÊû€~ ß-Èõ•°u&e Sظ‰›Î-’vµ’F6¸ƒª²iVUÅ›¦¡ªÒÌJ HÒ̘R" sŽÎ¹’Ç9ÏóÇP×5PD¨ªÌ9sš&ö}ÿe23BU y¿ß9Ž#E„Þ{š¯×kÑ»®#¶îØ÷=÷ rÎÿ¦ü À 9gœÏgˆ¼÷!À{_ôçó‰vx<H)aš&¬ëŠeY°®ë¾‡ãñˆ÷û X–—Ë¥ˆÃ0àõz•üt:ûSJ43†X×5I2ÆXô¶m 3û"U•$9Ï3o·[᫪ú;ë&îM"Râí:ã8~nC×uŒ1Ò9GaŒ‘mÛ~}_’þz’ÌIEND®B`‚ognl-2.7.3.orig/docbook/images/callouts/1.png0000644000175000017500000000054510561411075020702 0ustar drazzibdrazzib‰PNG  IHDR Vu\çsBIT|dˆ pHYs  ÒÝ~ü tEXtSoftwareMacromedia Fireworks MX»‘*$tEXtCreation Time05/15/03ßR@ÿ¹IDATxœR± Ã0 #2yôG~‘ü“ð9!_dõ z €FvhS4iZ„€Q¤QÐ ¡ÖšH*笜³Hªµ¦ˆØe‚$¹»H €(¥¤qß=I¹ûÓ1™™Öu=p$‚™½Éišä/þçí4Ï󥤆Þ;ÎØ¶í‹€Þ;†ËÉ ¥”ÛâR †ZëmC­?Ϻ,ËõY÷à>ƒ:×!¸Ï×03‘TJI)¥Ë×xQ¥Ù5øšIEND®B`‚ognl-2.7.3.orig/docbook/images/callouts/8.gif0000644000175000017500000000033410561411075020666 0ustar drazzibdrazzibGIF89a Äÿÿÿ÷÷÷ïïïçççÞÞÞÖÖÖ½½½µµµ­­­¥¥¥™™™„„„sssfffZZZRRRJJJBBB333)))!!!ÿÿÿ!ù, Y "ÏD=‰( †Y”+ bä&DaX˜$.H€7`¸-Ldx4dæ0È]\—(Æx@œØdÂàB{@ C`,ŽÛE1(®>K*•T )"!;ognl-2.7.3.orig/docbook/images/callouts/11.png0000644000175000017500000000063210561411075020760 0ustar drazzibdrazzib‰PNG  IHDR Vu\çsBIT|dˆ pHYs  ÒÝ~ü tEXtSoftwareMacromedia Fireworks MX»‘*$tEXtCreation Time05/15/03ßR@ÿîIDATxœ…‘!΃@F_«ŠBP³Ü€ +‘¤I jïÀ%8 (ÂÖÐcàÀ¡[Ä}Uÿ¶…?é—Œšy™·³Ib“çó @ÇÛè#UUÉ#@€’$Qß÷Ÿ#ò€µVÆeYæk­u]÷ Ôu­Ëå¢išäœ“1FÎ9-Ë"@§ÓIó[jÉó\I’h2™È#çœBïŠ:ïŸþ ÝÿÈ_³$ó–qaçAIEND®B`‚ognl-2.7.3.orig/docbook/images/callouts/7.gif0000644000175000017500000000032310561411075020663 0ustar drazzibdrazzibGIF89a Äÿÿÿ÷÷÷ïïïçççÖÖÖ½½½µµµ­­­™™™ŒŒŒZZZRRRJJJBBB333)))ÿÿÿ!ù, P Ëó0G ÁAo9ƒ¨LÇ ““`2¸MF¡t8„“Eà”PƒT’tP‡6˜H  #h*Aú®­‰äQ…;ognl-2.7.3.orig/docbook/images/callouts/13.png0000644000175000017500000000072710561411075020767 0ustar drazzibdrazzib‰PNG  IHDR Vu\çsBIT|dˆ pHYs  ÒÝ~ü tEXtSoftwareMacromedia Fireworks MX»‘*$tEXtCreation Time05/15/03ßR@ÿ+IDATxœ•‘¯ŠQ…?eô1ˆ`™ O ·È-&ÛLð†y€ëKïãØŒ>Â`±Ù… ËÙâŠînØýà×¾ÎùÕ$‰ëõšårÉår¡Ùl2N‡¼¡yž øqyžë$É{¯8޵Ýn•¦©¬µ*ËReYj0È{ÿ ÔBj·Ûìv;:Y–Ñï÷¹^¯t»]¢(b>Ÿs<i4Ô‹¢ ª*f³‡Ã€ÅbA«ÕÂ9Çù|¦ª*Š¢ ~¿ßØl6Ï^iš²Z­˜L&ŒF#¾¼^¯Çw²,ÃÃétb¿ßðô$É9'@ãñXI’(Š"9çäœSÇoK!I!c~Õ£Â{@’n·›¼÷²Ö*IYk当%©öúé¿Pÿ ð æ:å |¼:IEND®B`‚ognl-2.7.3.orig/docbook/images/callouts/4.png0000644000175000017500000000063210561411075020702 0ustar drazzibdrazzib‰PNG  IHDR Vu\çsBIT|dˆ pHYs  ÒÝ~ü tEXtSoftwareMacromedia Fireworks MX»‘*$tEXtCreation Time05/15/03ßR@ÿîIDATxœm‘-®…0„'WUVR‰¬î.*‘, `µˆ’ ‘l¥ÔV‚;rž¸[xLrÌÉ|ç'VZו]×ÑZKk-½÷\–¥¶$)"ôÞÀUÖZj­ €Î9–R~ÀÓì½'IÃpõœsb]×›Yk}M«L)ñ3Ï3jÍóŒmÛpžš¦ hšæšÐ÷=K)ÔZSDþmPJñsÒmÛbGÄaŒcÐ4Í}ÍùpoZ–åö8êF]o'Å ù’ çÌÂ-ùæ°ïû+T›sοàδSJtÎQkM¥sŒ1RD®Ÿþ>ÅuÍ¢FIEND®B`‚ognl-2.7.3.orig/docbook/images/callouts/3.png0000644000175000017500000000064110561411075020701 0ustar drazzibdrazzib‰PNG  IHDR Vu\çsBIT|dˆ pHYs  ÒÝ~ü tEXtSoftwareMacromedia Fireworks MX»‘*$tEXtCreation Time05/15/03ßR@ÿõIDATxœu’±mÃ@ E‰T,¹ƒ+·þÓÈ­-à5n q¥· N¥ÚåK‘è"9 øüä'?ïÈL¦iBAD ‰išÈÌ= h­! 3ÃÝ‘„$Ü3C­µ/Bföäˆ`Û6ÖueÛ6æy&":)3±R f†™ñ|>i­áîDã8v¼”‚íÕ÷×ëµÿß ’°]çñÕZi­±®+GÜÝÿ&HbG2óÔÁÝÏ’î÷;Ç™æyæõz } Ã`{Ün7{<&É$Ùår±eY:> ƒýZk­•Ì$3©µž¼ÈÌãöít­o3u㎧QJéÿwŸˆaV]ÒIEND®B`‚ognl-2.7.3.orig/docbook/images/callouts/14.png0000644000175000017500000000067210561411075020767 0ustar drazzibdrazzib‰PNG  IHDR Vu\çsBIT|dˆ pHYs  ÒÝ~ü tEXtSoftwareMacromedia Fireworks MX»‘*$tEXtCreation Time05/15/03ßR@ÿIDATxœ•‘1Šƒ`…¿¤"áGÄBì’6Ý_iãŸô}Ïår`Y×5ûýžqNÓ”õzÍãñÀ÷}”RTUõZp]—Ÿ4MÃõzŶm6› «Õ Ïóæ?’eÙ4’$‰Äq<û1R¥Ô,ÒweY6Åú¾ßï8Žó±é_ ñ0Ýr…‚IEND®B`‚ognl-2.7.3.orig/docbook/images/callouts/9.gif0000644000175000017500000000033710561411075020672 0ustar drazzibdrazzibGIF89a Äÿÿÿ÷÷÷ïïïçççÞÞÞÖÖÖ½½½µµµ­­­¥¥¥™™™ŒŒŒ{{{sssfffZZZRRRJJJBBB333)))!!!ÿÿÿ!ù, \ "UAH ”e×õN‚eR É ¯c <^Š[&Ìz™‰åÅ /âëb ‡¬+‹Á3¨$P‰&¯EžAŽE% c^Q+ r"!;ognl-2.7.3.orig/docbook/images/callouts/2.gif0000644000175000017500000000032510561411075020660 0ustar drazzibdrazzibGIF89a Äÿÿÿ÷÷÷ïïïçççÞÞÞÖÖÖÌÌ̵µµ¥¥¥™™™ŒŒŒ{{{sssfffJJJ333)))!!!ÿÿÿ!ù, R É3MOˆÀðTÁÏ0¾Q1ÆT= Q¨D‚0Å«¢XÀF2`”)Õ18h)KfÀYVÆã!I^‰|à¶ÂU›(øÈ¦V!;ognl-2.7.3.orig/docbook/images/callouts/15.png0000644000175000017500000000074010561411075020764 0ustar drazzibdrazzib‰PNG  IHDR Vu\çsBIT|dˆ pHYs  ÒÝ~ü tEXtSoftwareMacromedia Fireworks MX»‘*$tEXtCreation Time05/15/03ßR@ÿ4IDATxœ…‘¡ŽÂPE$¤ BCÏÔ!0¤Š`°¾÷ ²²Hý€þ 8þ‹åH @quWìnC±'¹ÉL273¹S“$Þ8œÏgšÍ&£Ñß÷© œs ÃP@E«ÕJïÔ$)ÏsÂ0d0Ðh4ØívÄq @Qø¾_öH’µVÖZE¡$IAYÇq,@Î9IR`³ÙÐív9 ‡C<Ïc±XÐëõØn·Ô_¯ǃõzÍåràz½²\.ÇÌçsŒ1Ün·oƒçyc*AL&¦Ó)­V €çóYnB’¢( (Šd­U»ÝÖ~¿—sNÖZʲL’„$ÝïwAð鯒$)c-ÿe™f³YeУ4M?ÿð~žçœN':ý~Ÿ¿|þã ç0âú”ÚoXIEND®B`‚ognl-2.7.3.orig/docbook/images/callouts/5.gif0000644000175000017500000000033010561411075020657 0ustar drazzibdrazzibGIF89a Äÿÿÿ÷÷÷ïïïçççÞÞÞÌÌÌ­­­¥¥¥™™™ŒŒŒ„„„ZZZJJJ333)))!!!ÿÿÿ!ù, U " 5I B#9ÎãH !6Sà 39Ã$ ÑPPs¡NÁ †’èä¡&Xed1D ¤B"ãA¸NÜD!F~ªöé°­H4)"!;ognl-2.7.3.orig/docbook/images/callouts/8.png0000644000175000017500000000066710561411075020716 0ustar drazzibdrazzib‰PNG  IHDR Vu\çsBIT|dˆ pHYs  ÒÝ~ü tEXtSoftwareMacromedia Fireworks MX»‘*$tEXtCreation Time05/15/03ßR@ÿ IDATxœmR¡²Ã ¼©:{2¶¸J$™úü@¿†ø“‘•èºÊÈX$"‚º}ª×æ½w3̰ì.sìAøªeYcÄ0 Ä¡ªßÔZBˆÐuDİs¥”Á{o¤ªbÛ6¬ëŠœ3º®3Sk ¤ª&! µf¢R n·›ñ)%œT•Þõz½lÏÌÄÌ´ï»ÍóLÔ÷½Ý@D¸ßï(¥X[Ìl3ã`Ç­5ÄB@­Ó4 ßé¨*rΆ—e9`çN×ëÕz|>Ÿt>Ÿiº\.ôx<ŒŸ¦‰±23RJ(¥ ÖŠ”’½Ábýop¿—sµÖÏàÞ¥ª!@D "ðÞÿù?w!Cˆï}IEND®B`‚ognl-2.7.3.orig/docbook/images/callouts/4.gif0000644000175000017500000000032410561411075020661 0ustar drazzibdrazzibGIF89a Äÿÿÿ÷÷÷ïïïçççÞÞÞ­­­¥¥¥™™™ŒŒŒsssfffZZZRRRJJJ333)))!!!ÿÿÿ!ù, Q Ìó4†( å>å bë6@â:AáRšÎu°Q ÁPq-’ÀrÒ„(D“2i)T"ÃNü£Hˆ€£LP¼ÁºLyTƒC2q¤E!;ognl-2.7.3.orig/docbook/images/callouts/10.gif0000644000175000017500000000034510561411075020741 0ustar drazzibdrazzibGIF89a Äÿÿÿ÷÷÷ïïïçççÞÞÞÖÖÖÌÌ̽½½µµµ¥¥¥™™™ŒŒŒ„„„sssfffRRRJJJ333)))!!!ÿÿÿ!ù, b *UEK BTQ—%„Y"ÇðHÄDÈ!. Âe‰…Æ%˜”.—gÀq¡n°,BÀ|/M±1P" ìsQ¨( ËóAQ9 @,XX;+$2 *!;ognl-2.7.3.orig/docbook/images/callouts/7.png0000644000175000017500000000061110561411075020702 0ustar drazzibdrazzib‰PNG  IHDR Vu\çsBIT|dˆ pHYs  ÒÝ~ü tEXtSoftwareMacromedia Fireworks MX»‘*$tEXtCreation Time05/15/03ßR@ÿÝIDATxœm‘±­†0 „­¿r™2 ‹ÒP¦LÉLY #P¦d¬’Òå½ÁƒÀ'Y‘ûì\7J)ˆ1BD "!`]W˜ÙUC`fˆ1Â9ïýãtÎAUÑZûo˜çD„u]ÑSkAUaf mÛ@D¯ðÞ£µv‰rΠ{â¥ôbª RÕWqŒf†þŽ™¿j­(¥¼òÌŒß0 tGUIDhYêÇ‘¨WJ)ÁÌŽñÝ„”ÒakáñدuDä°ö}Ç4MŸnÅ;É9CUÁÌ`fˆÈµâɆWRF™"IEND®B`‚ognl-2.7.3.orig/docbook/images/callouts/6.gif0000644000175000017500000000033610561411075020666 0ustar drazzibdrazzibGIF89a Äÿÿÿ÷÷÷ïïïçççÞÞÞÌÌ̽½½­­­¥¥¥™™™ŒŒŒ„„„sssfffRRRJJJ333)))!!!ÿÿÿ!ù, [ N=ˆ(eM‘ bk!ÂPT.†`2@\ [ðd×@P¨R\•¨…P°T ¬Í€p²²¥!HX.EàhIhK$0bŸ* Nr"!;ognl-2.7.3.orig/docbook/images/callouts/10.png0000644000175000017500000000072610561411075020763 0ustar drazzibdrazzib‰PNG  IHDR Vu\çsBIT|dˆ pHYs  ÒÝ~ü tEXtSoftwareMacromedia Fireworks MX»‘*$tEXtCreation Time05/15/03ßR@ÿ*IDATxœm’!ŽAEPë F‘ŒlKÝ9Žà¹À\c.0à-;á€c㸈ƽUÛ »û“2•zU•ú%ÞÔ÷=fFUUxï13º®#ç\j0Mf†÷žªª„sŽBÇqüÌ ç1FbŒ„Ç‘”÷û¦i!sFûýžº®™¦  @1F$Ѷ-ã8"‰®ëÐz½.+GbŒ Ã@Û¶HĄ̂ë3cv>Ÿ%I¯×KߪëZÏçS’t»Ý$I‹ÅB—ËE3ý£wx>Ÿäg«Õêp½^µ\.KçïIf¦Ùv»ý5M#ï½v»N§“‡6›ÊY%‘R¢ï{¼÷¤”È93 fösÖwã$}„sIÅ—bÜï×pΧû¾ÿx/møÿ¤mǽIEND®B`‚ognl-2.7.3.orig/docbook/images/callouts/13.gif0000644000175000017500000000032510561411075020742 0ustar drazzibdrazzibGIF89a Äÿÿÿ÷÷÷ïïïåååÝÝÝÓÓÓÌÌ̺ºº´´´¡¡¡™™™ŒŒŒ„„„vvvfffZZZRRRLLL???:::333ÿÿÿ!ù, R äb *cÑ4 # DŒ†"q !‚Y¢µŒH  0 FÄt r` •‹Ãaí(®Ř 0&• ƒ®êûÿ)!;ognl-2.7.3.orig/docbook/images/callouts/1.gif0000644000175000017500000000022310561411075020654 0ustar drazzibdrazzibGIF89a ³ÿÿÿ÷÷÷çççÌÌ̵µµ¥¥¥™™™ŒŒŒJJJ333)))ÿÿÿ!ù, @€`ÒZÉ Dj £€‰0}à1€M "+{ `Q“ Û»Pô1p¿`F ¸åêŒ|-“ä•`5’;ognl-2.7.3.orig/docbook/images/callouts/3.gif0000644000175000017500000000032710561411075020663 0ustar drazzibdrazzibGIF89a Äÿÿÿ÷÷÷ïïïçççÞÞÞÖÖÖÌÌ̵µµ­­­™™™ŒŒŒ„„„sssfffZZZ333)))ÿÿÿ!ù, T ÉEOˆÀðLÒóHÓ3ŒoD„ÕÅdÂH"€ÆPñšD Îäp6"L;m”°¦C81¦d…@&X,9D € =V(¬jcg(*"!;ognl-2.7.3.orig/docbook/images/callouts/15.gif0000644000175000017500000000032310561411075020742 0ustar drazzibdrazzibGIF89a Äÿÿÿøøøîîîààà×××ÌÌÌÄÄļ¼¼µµµ¨¨¨™™™„„„{{{sssfffRRRMMMAAA333!!!ÿÿÿ!ù, P E‚ãHLW{1©@EÐÕ4,>O°P¾Æ… ²4   x-[ŠÅ¤1 T¢Ê%ê0HãâxX„Çe ’¹\‹Ô âª(R#ˆïãC;ognl-2.7.3.orig/docbook/images/callouts/12.gif0000644000175000017500000000032510561411075020741 0ustar drazzibdrazzibGIF89a ÄÿÿÿôôôðððæææÜÜÜÌÌÌÄÄľ¾¾µµµ¦¦¦™™™ƒƒƒsssfff\\\QQQDDD:::333))) ÿÿÿ!ù, R  ä$¨2YÛJ‚Š`‡3 ©”4 „)™É¡‘¹™€˜Y^ …K†!²T!Zd"”Èc=Q ®–…à("•IcPïûÿ!;ognl-2.7.3.orig/docbook/images/callouts/14.gif0000644000175000017500000000031710561411075020744 0ustar drazzibdrazzibGIF89a ÄÿÿÿøøøïïïãããßßßÖÖÖÌÌÌÅÅŽ½½´´´°°°¦¦¦™™™‹‹‹ƒƒƒ{{{fffXXXLLL:::333 ÿÿÿ!ù, L ErãXLX[-iaA,IÌ(9„Q‡E`È¥ xI-„10$,bâX /‘Ãc¡HÖj“c5L8µVœèxz;ognl-2.7.3.orig/docbook/images/callouts/11.gif0000644000175000017500000000031410561411075020736 0ustar drazzibdrazzibGIF89a ÄÿÿÿðððåååÛÛÛÔÔÔÌÌ̳³³®®®¢¢¢™™™†††{{{fffSSSCCC;;;333)))ÿÿÿ!ù, I Š‚0ž@SaØt O±–ŒŠD `—H¢( †¦!²,˜ˆò!¢<£J‡Èq•²^“E†œ 2æ@ŒÁM…;ognl-2.7.3.orig/docbook/images/callouts/6.png0000644000175000017500000000070610561411075020706 0ustar drazzibdrazzib‰PNG  IHDR Vu\çsBIT|dˆ pHYs  ÒÝ~ü tEXtSoftwareMacromedia Fireworks MX»‘*$tEXtCreation Time05/15/03ßR@ÿIDATxœe’¡±Ã@ D÷$&j¨ ˵d˜"Ò€[t.à ;¹ìÀ S˜Â6àO.þ1iW;7OnjžgžN'šÍŒ}ß3ç¼µ$ìûž€ªJ3k}J‰µÖÏÂÖœs¦»³ÖÊR E¤-E1Ïs3Ã@w§ªRUéîL)5}š&b›^JaΙfÆ”RKß>íGUy¿ßµVˆ–eÁ»ŽÇ#@DUm 뺲”Bº;‡ahºˆð÷p8´´Ûí†ëõ x>ŸX–»Ý®éûýÈ9·„óùLwg×uìºî ÷8ŽDD|‘ˆF/—K››ÙV’_øDä!3㺮ŸÃ½¯=MSÃ)"L)qGFDû/ö$3_V!éIEND®B`‚ognl-2.7.3.orig/docbook/images/callouts/2.png0000644000175000017500000000062610561411075020703 0ustar drazzibdrazzib‰PNG  IHDR Vu\çsBIT|dˆ pHYs  ÒÝ~ü tEXtSoftwareMacromedia Fireworks MX»‘*$tEXtCreation Time05/15/03ßR@ÿêIDATxœmR¡À0 4x`X|[t,Pز@¨2A·(-4,4¼ÿZ©– bûìËÙÂswÖZ €!†€µVºû]F!I3#ŠE„)%ÆÇÍìàî£8ÆÈÞ;ÍŒ×uñ8†ÈÝ)¥”ÑiÛ6öÞØÝùÌ—RøÓZ“ÛÌLzï""rž§˜™¤”F¾µ&¢ª£ÃÓo ˲Œ˜ªò0Ï3ÍŒû¾ó™WUÊS›§»s]×Ï©¯OçœéîÌ9pš¦W³—¬µVšÙËïICÖ¯Å}Q‹{žF)…¨ªTÕÏÓø¬E)ÝÏIEND®B`‚ognl-2.7.3.orig/docbook/images/callouts/5.png0000644000175000017500000000062410561411075020704 0ustar drazzibdrazzib‰PNG  IHDR Vu\çsBIT|dˆ pHYs  ÒÝ~ü tEXtSoftwareMacromedia Fireworks MX»‘*$tEXtCreation Time05/15/03ßR@ÿèIDATxœm’!’Æ …3«b:ƒÄ"3uÍ-8’ pdoR]‰­Œ¤î­jþý3àË<^B¢”U…÷Î9¨*rÎ轿oÌ ª f†ˆ@DB€ˆ€™¡ªh­ýª "‚ªâiðdŒDAïTkM3¿gcæœAO‡Ø÷Çq ¥4Áª òÞÿRJˆ1âº.”RÞ{fžRJ“3›€ŸmÛè 3£ó<ßzYºïû­×u¥¯ŸŽ1"„€ÖÚ$)ç<ÛJDH)ÁÌÐ{G­ιÙÖqp£ÖÑ™÷¹ðm5~ÚË*Å…Àä3IEND®B`‚ognl-2.7.3.orig/docbook/images/navigation/0000755000175000017500000000000011237553153020346 5ustar drazzibdrazzibognl-2.7.3.orig/docbook/images/navigation/next.gif0000644000175000017500000000061110561411075022004 0ustar drazzibdrazzibGIF89aÕêêõØØìÕÕÿ××çÔÔáÌÌÿÄÄÿ½½ÿºº÷¸¸ü³³ù¯¯ÿ¯¯òªªø¦¦î¤¤÷ðššõ••í™™™ŒŒÿ猌މ‰Ø……ãƒƒàƒƒÏ‹‹‹Þ€€ÄÂ||Õ„„„zzÏyyºuuÄ|||rr½pp¶nn´ssskk­hh¤ff™fff^^‹[[ƒXX{XXXRRRGGGBBBÿÿÿ!ù4,¦@špH,4r)$)™GÒâ %’ X•:4$²­pRPH0³âf2‘Þ¤‰@`€`83ÀP.(þs3B‚  #™34( ¢ #)ª›I²%-¹3B1·)*Â'%!¸/.iC23ÍÎÍ!!&-/ÊU2)Éb41*Ö[0"á[1aÜBåéKA;ognl-2.7.3.orig/docbook/images/navigation/home.gif0000644000175000017500000000032510561411075021760 0ustar drazzibdrazzibGIF89a³ÿÿÿÿÿ™ÌÌÌÿÌÿ™Ì™„„„™fÿf™ÿÿÿ!ù ,‚pÉ9ÏLIÑ]ƒ^ òq]1háHA¡gJJ¬+¼§8׊Ü0…ªÔ'ÏgªeÓé„ÒZÅf€úÄi„Yãv\K L1—{›¦äøoôVî›®°'dmgk€zcƒ uc†.‚|dy{nššw=›‹`£¤¤;ognl-2.7.3.orig/docbook/images/navigation/prev.png0000644000175000017500000000127210561411075022025 0ustar drazzibdrazzib‰PNG  IHDR‰ sBIT|dˆ pHYs  ÒÝ~ü tEXtSoftwareMacromedia Fireworks MX»‘*$tEXtCreation Time05/15/03ßR@ÿIDATxœ­Ô¿kÛ@Æñ¯d[qœÊÄt 4à-„1 ¼²d2:tê¥t*Át-…N…‚¡ÿ@À£B 4d „L5¥PÛ˜ˆÈò]e[²ãëàæ‡‰IdÒg”^>'ÝûÞiJ)þgô8E¥R)öª‚årYe³Ù¸ÞÃ`¥RQ››ïB<´,K­­½¦Ýöq]÷i ã8*Ÿ/"eÈ奛 :Ž£VVvp]IÆêÛM´;c£jµ««/hµ®8=mÒnK #Ãùù²Ù,¦iNRJ„!°,KKªV³Èç‹ “B×M`Käri Ã`w÷;™L†Tê¡×ëáyGG¯Hú>êð°Âúú<ïê«×Á4ŸcšýIaRŸÂ¢(Äó":aNê¹Ü€ÑèŠ Ð€E¤`}@g84¦@ßÿƒçyt»›gÉåe´ýýêàà-Ÿþ­Ñï·év›„áoÒÆº>ùÌñxH1=Rw›ÂÞÞžÚÙùFøþ/¤ü”-R©g¤Ó÷OL¸ŒÇC..lÛž4å:ÕjU+‹j{û+šv»aºž¢Ù<¾‡ÍŠ6ë¶) jkë Bü¤Û­ÓlcÛ¶œ9µ¶mk''ïH$gþæÜà5zvö™LæÅ\`ò¡—¶mk…Ba®øÑƒwï®3³)OÉ_<ˆê˜½º#1IEND®B`‚ognl-2.7.3.orig/docbook/images/navigation/up.png0000644000175000017500000000126210561411075021474 0ustar drazzibdrazzib‰PNG  IHDR‰ sBIT|dˆ pHYs  ÒÝ~ü tEXtSoftwareMacromedia Fireworks MX»‘*$tEXtCreation Time05/15/03ßR@ÿIDATxœ­”AkA†ŸYã®Æìj6B±$¡…â=¡B[˜У¿Áú z*¼õÒœ =ô–CÉ5½yª? §Ü½*Vãf­»«;=4±ÐDmM_˜aÞyf¾ùf>¡”bžz=@"˜çÕæÚí@¼ãää3ƒówWJÍl•JEU³é«ÓÓSu­©þ™',•J*—{=lm¨×ë‹…\,U>ÿ €Ñh‰D–hôÛÛN1Œ±\\|¡P(Š©@)¥ÊåÞ0ÿÀu[XÖS2™g˜&hZÏsXY ‘N›˜¦Îùù!åòkq x ¾1öñý+R©'lnîG°m›n· €®X]M²¶çììÕjUL€RÊ[÷‘ɼ$|R©Çìì<'}€ëºt»]êõòÄ—N?IJLlÛæèèH,Ôjµ[?@ÊWj}}ÈjÄã£Q˜fóíþ-M›E$b¡ë1–—ub1ß×±,súþâëiZxÒ‡¦yOà¿j.0üÿ ô<‡^ï Çqñ}`N›‘pœ_o®ÓùŽRÉäÛ¶Á\^ö¢$è÷û‹[­¯´Z¿Ç†™ ƒ;ŠÃ}õS úê8qûkIEND®B`‚ognl-2.7.3.orig/docbook/images/navigation/up.gif0000644000175000017500000000112310561411075021451 0ustar drazzibdrazzibGIF89aæÿÿÿõõÿïïÿêêýßßÿ××ÿ××þÌÌÿÅÅüÅÅûÃÃ÷ÃÃÿ¿¿µµÿ¶¶ñµµþ°°þ°°ÿ´´´µµ´­­ñªªø¦¦õ¦¦ô¥¥í¡¡ä››ö™™ÿ››ì››ç––â””ï••á’’åššššš™ŒŒÿŽŽéŒŒîƒƒßƒƒÞƒƒÐ‚‚Ï}}Ô{{Ñ{{Ò||¾zz¹~~~}}}ttÄttÃss¾ss¿tt®pp¸tttmm¯ttsmm§mm¦ff™ffšgggggffff^^‹[[„YY€YYYYYXXYRRRJJKJJJCCDCCCÿÿÿ!ùM,°€M‚ƒƒ„ˆ‰‚1"ŠM? ‘ˆH ˜ƒJ%  L((%§¨‘L,34($$ŠL79==2$  #ˆÁ=BEE;&%++)0ƒLààCE Ì7° =|6@Tˆ€Ãà*Hý0HÄGê© Ç$I’(;ognl-2.7.3.orig/docbook/images/navigation/next.png0000644000175000017500000000123510561411075022026 0ustar drazzibdrazzib‰PNG  IHDR‰ sBIT|dˆ pHYs  ÒÝ~ü tEXtSoftwareMacromedia Fireworks MX»‘*$tEXtCreation Time05/15/03ßR@ÿñIDATxœ­Ô¿kÛ@Àñ¯bY–bj—›.ž“=BH²8ƒ2t-1]K ù3ºštpi PÚ5t-¡“éÝcq2‡ZÆÂ’-ôÛgu±18îú¶»{÷y»ã”,ËøŸ±!“Ôl6¥«JÕjU•NN>I¡Ò aŽÛ4µ¨¨ë:ù|€Ãئù(*V*Êe0 €££ÏÔëõ•¨Òjµ²R©Àp8$Š¢¥„Z­ÆÁÁ[nnÆX–G’¤\_¿áòò;•ʦò¯–J¥ù†0„ñx¹b¹¼<"Ïl&"dÿ§§/¹¸ø–mm=W6&“ a¸ØP(@š ÒTE÷…†C˜L6™NgıC;ìì¼ãì콞•¨–e1ßw&D„ï§„át^À0T|?eéÁo‚`°ò¼UÏóè÷#â8ÆqF„á˜éÔ[$¨OÐ4Ï…mwçëww?h·¿²½ýBPmÛf0pqœA`Ç.B,Î@Óž¢ªºþŒ(aÛ]’Ä%—Óé÷Òétæ ú¾ÏÕÕë•í?ÄÞÞ9³Y<Ÿ[…(2¿išÙîî{§‡ëþzɇ],)„×bÒ ¦iÁÛÛ/k1i0IºÝó¿bª 躮’—ò/ñ+õå¦@¬IEND®B`‚ognl-2.7.3.orig/docbook/images/navigation/prev.gif0000644000175000017500000000060510561411075022005 0ustar drazzibdrazzibGIF89aÕÿÿÿôôÿïïÿêêýßßÿ××ÿÌÌÿÅÅüÃÃøÃÃÿ¿¿µµÿ¶¶ñ°°ÿ´´´­­ñªªø¦¦õ¥¥í¡¡ä™™ÿ››ö››ì››ç””ï••á’’å™™™ŒŒÿŽŽéŒŒîƒƒÞ‚‚Ï}}Ô{{Ñ||¾zz¹}}}ttÃss¾tt®pp¸mm¯mm¦sssff™fff^^‹[[„YYXXXRRRJJJCCCÿÿÿ!ù6,¢@›pH,6ri+¹˜ÇÍC %:™Zu˜(0@Úm‚`˜ˆÂL€‚@8dB™‹Eg¹d4aÀQè7, … y ……Z%¦ 'a.&++($##$(--h63±'-11/¼Ç01¾64²Ã05ÑÒÒF5"*/ËP5)½[DÜÚUÑßEâåHA;ognl-2.7.3.orig/docbook/images/navigation/home.png0000644000175000017500000000060510561411075022000 0ustar drazzibdrazzib‰PNG  IHDR‰ sBIT|dˆ pHYs  ÒÝ~ü tEXtSoftwareMacromedia Fireworks MX»‘*$tEXtCreation Time05/15/03ßR@ÿÙIDATxœÓí ƒ …á—¦u']„%p&˜éô¢|éM” —LjHbv¹ sAù\1W,v ±­ƒ óÉ߉þs,.tº Ö˜÷¾Aƒ=LR‚#,U7éœa±Ü]ž ËØ %mî V£ù! kí2Ö&ÍöÐZû&©ßtë6ŽÝœó=Þ=¦8ßÇñS.mÞ ÒÉçÿò^²{Â~Ž©g«úʪÀAsȼÞGÇ`/aÄÂÄס„ˆœ5Öë+ËH£æÍbI2_MmX¹Þ/IEND®B`‚ognl-2.7.3.orig/docbook/LanguageGuide.xml0000644000175000017500000021735110561411075020171 0ustar drazzibdrazzib OGNL Language Guide Drew Davidson
drew@ognl.org
2004 OGNL Technology, Inc.
Introduction OGNL stands for Object Graph Navigation Language. It is an expression and binding language for getting and setting properties of Java objects. Normally the same expression is used for both getting and setting the value of a property. We pronounce OGNL as a word, like the last syllables of a drunken pronunciation of "orthogonal." Many people have asked exactly what OGNL is good for. Several of the uses to which OGNL has been applied are: A binding language between GUI elements (textfield, combobox, etc.) to model objects. Transformations are made easier by OGNL's TypeConverter mechanism to convert values from one type to another (String to numeric types, for example). A data source language to map between table columns and a Swing TableModel. A binding language between web components and the underlying model objects (WebOGNL, Tapestry, WebWork, WebObjects). A more expressive replacement for the property-getting language used by the Jakarata Commons BeanUtils package or JSTL's EL (which only allow simple property navigation and rudimentary indexed properties). Most of what you can do in Java is possible in OGNL, plus other extras such as list projection and selection and lambda expressions. History OGNL started out as a way to set up associations between UI components and controllers using property names. As the desire for more complicated associations grew, Drew Davidson created what he called KVCL, for Key-Value Coding Language, egged on by Luke Blanshard. Luke then reimplemented the language using ANTLR, came up with the new name, and, egged on by Drew, filled it out to its current state. Later on Luke again reimplemented the language using JavaCC. Further maintenance on all the code is done by Drew (with spiritual guidance from Luke). Syntax Simple OGNL expressions are very simple. The language has become quite rich with features, but you don't generally need to worry about the more complicated parts of the language: the simple cases have remained that way. For example, to get at the name property of an object, the OGNL expression is simply name. To get at the text property of the object returned by the headline property, the OGNL expression is headline.text. What is a property? Roughly, an OGNL property is the same as a bean property, which means that a pair of get/set methods, or alternatively a field, defines a property (the full story is a bit more complicated, since properties differ for different kinds of objects; see below for a full explanation). The fundamental unit of an OGNL expression is the navigation chain, usually just called "chain." The simplest chains consist of the following parts: <acronym>OGNL</acronym> Expression Parts Expression Element Part Example Property names like the name and headline.text examples above Method Calls hashCode() to return the current object's hash code Array Indices listeners[0] to return the first of the current object's list of listeners
All OGNL expressions are evaluated in the context of a current object, and a chain simply uses the result of the previous link in the chain as the current object for the next one. You can extend a chain as long as you like. For example, this chain: name.toCharArray()[0].numericValue.toString() This expression follows these steps to evaluate: extracts the name property of the initial, or root, object (which the user provides to OGNL through the OGNL context) calls the toCharArray() method on the resulting String extracts the first character (the one at index 0) from the resulting array gets the numericValue property from that character (the character is represented as a Character object, and the Character class has a method called getNumericValue()). calls toString() on the resulting Integer object. The final result of this expression is the String returned by the last toString() call. Note that this example can only be used to get a value from an object, not to set a value. Passing the above expression to the Ognl.setValue() method would cause an InappropriateExpressionException to be thrown, because the last link in the chain is neither a property name nor an array index. This is enough syntax to do the vast majority of what you ever need to do.
Expressions This section outlines the details the elements of OGNL's expressions.
Constants OGNL has the following kinds of constants: String literals, as in Java (with the addition of single quotes): delimited by single- or double-quotes, with the full set of character escapes. Character literals, also as in Java: delimited by single-quotes, also with the full set of escapes. Numeric literals, with a few more kinds than Java. In addition to Java's ints, longs, floats and doubles, OGNL lets you specify BigDecimals with a "b" or "B" suffix, and BigIntegers with an "h" or "H" suffix (think "huge"---we chose "h" for BigIntegers because it does not interfere with hexadecimal digits). Boolean (true and false) literals. The null literal.
Referring to Properties OGNL treats different kinds of objects differently in its handling of property references. Maps treat all property references as element lookups or storage, with the property name as the key. Lists and arrays treat numeric properties similarly, with the property name as the index, but string properties the same way ordinary objects do. Ordinary objects (that is, all other kinds) only can handle string properties and do so by using "get" and "set" methods (or "is" and "set"), if the object has them, or a field with the given name otherwise. Note the new terminology here. Property "names" can be of any type, not just Strings. But to refer to non-String properties, you must use what we have been calling the "index" notation. For example, to get the length of an array, you can use this expression: array.length But to get at element 0 of the array, you must use an expression like this: array[0] Note that Java collections have some special properties associated with them. See for these properties.
Indexing As discussed above, the "indexing" notation is actually just property reference, though a computed form of property reference rather than a constant one. For example, OGNL internally treats the "array.length" expression exactly the same as this expression: array["length"] And this expression would have the same result (though not the same internal form): array["len" + "gth"]
Array and List Indexing For Java arrays and Lists indexing is fairly simple, just like in Java. An integer index is given and that element is the referrent. If the index is out of bounds of the array or List and IndexOutOfBoundsException is thrown, just as in Java.
JavaBeans Indexed Properties JavaBeans supports the concept of Indexed properties. Specifically this means that an object has a set of methods that follow the following pattern: public PropertyType[] getPropertyName() public void setPropertyName(PropertyType[] anArray) public PropertyType getPropertyName(int index) public void setPropertyName(int index, PropertyType value) OGNL can interpret this and provide seamless access to the property through the indexing notation. References such as someProperty[2] are automatically routed through the correct indexed property accessor (in the above case through getSomeProperty(2) or setSomeProperty(2, value)). If there is no indexed property accessor a property is found with the name someProperty and the index is applied to that.
OGNL Object Indexed Properties OGNL extends the concept of indexed properties to include indexing with arbitrary objects, not just integers as with JavaBeans Indexed Properties. When finding properties as candidates for object indexing, OGNL looks for patterns of methods with the following signature: public PropertyType getPropertyName(IndexType index) public void setPropertyName(IndexType index, PropertyType value) The PropertyType and IndexType must match each other in the corresponding set and get methods. An actual example of using Object Indexed Properties is with the Servlet API: the Session object has two methods for getting and setting arbitrary attributes: public Object getAttribute(String name) public void setAttribute(String name, Object value) An OGNL expression that can both get and set one of these attributes is session.attribute["foo"]
Calling Methods OGNL calls methods a little differently from the way Java does, because OGNL is interpreted and must choose the right method at run time, with no extra type information aside from the actual arguments supplied. OGNL always chooses the most specific method it can find whose types match the supplied arguments; if there are two or more methods that are equally specific and match the given arguments, one of them will be chosen arbitrarily. In particular, a null argument matches all non-primitive types, and so is most likely to result in an unexpected method being called. Note that the arguments to a method are separated by commas, and so the comma operator cannot be used unless it is enclosed in parentheses. For example, method( ensureLoaded(), name ) is a call to a 2-argument method, while method( (ensureLoaded(), name) ) is a call to a 1-argument method.
Variable References OGNL has a simple variable scheme, which lets you store intermediate results and use them again, or just name things to make an expression easier to understand. All variables in OGNL are global to the entire expression. You refer to a variable using a number sign in front of its name, like this: #var OGNL also stores the current object at every point in the evaluation of an expression in the this variable, where it can be referred to like any other variable. For example, the following expression operates on the number of listeners, returning twice the number if it is more than 100, or 20 more than the number otherwise: listeners.size().(#this > 100? 2*#this : 20+#this) OGNL can be invoked with a map that defines initial values for variables. The standard way of invoking OGNL defines the variables root (which holds the initial, or root, object), and context (which holds the Map of variables itself). To assign a value to a variable explicitly, simply write an assignment statement with a variable reference on the left-hand side: #var = 99
Parenthetical Expressions As you would expect, an expression enclosed in parentheses is evaluated as a unit, separately from any surrounding operators. This can be used to force an evaluation order different from the one that would be implied by OGNL operator precedences. It is also the only way to use the comma operator in a method argument.
Chained Subexpressions If you use a parenthetical expression after a dot, the object that is current at the dot is used as the current object throughout the parenthetical expression. For example, headline.parent.(ensureLoaded(), name) traverses through the headline and parent properties, ensures that the parent is loaded and then returns (or sets) the parent's name. Top-level expressions can also be chained in this way. The result of the expression is the right-most expression element. ensureLoaded(), name This will call ensureLoaded() on the root object, then get the name property of the root object as the result of the expression.
Collection Construction
Lists To create a list of objects, enclose a list of expressions in curly braces. As with method arguments, these expressions cannot use the comma operator unless it is enclosed in parentheses. Here is an example: name in { null,"Untitled" } This tests whether the name property is null or equal to "Untitled". The syntax described above will create a instanceof the List interface. The exact subclass is not defined.
Native Arrays Sometimes you want to create Java native arrays, such as int[] or Integer[]. OGNL supports the creation of these similarly to the way that constructors are normally called, but allows initialization of the native array from either an existing list or a given size of the array. new int[] { 1, 2, 3 } This creates a new int array consisting of three integers 1, 2 and 3. To create an array with all null or 0 elements, use the alternative size constructor new int[5] This creates an int array with 5 slots, all initialized to zero.
Maps Maps can also be created using a special syntax. #{ "foo" : "foo value", "bar" : "bar value" } This creates a Map initialized with mappings for "foo" and "bar". Advanced users who wish to select the specific Map class can specify that class before the opening curly brace #@java.util.LinkedHashMap@{ "foo" : "foo value", "bar" : "bar value" } The above example will create an instance of the JDK 1.4 class LinkedHashMap, ensuring the the insertion order of the elements is preserved.
Projecting Across Collections OGNL provides a simple way to call the same method or extract the same property from each element in a collection and store the results in a new collection. We call this "projection," from the database term for choosing a subset of columns from a table. For example, this expression: listeners.{delegate} returns a list of all the listeners' delegates. See the coercion section for how OGNL treats various kinds of objects as collections. During a projection the #this variable refers to the current element of the iteration. objects.{ #this instanceof String ? #this : #this.toString()} The above would produce a new list of elements from the objects list as string values.
Selecting From Collections OGNL provides a simple way to use an expression to choose some elements from a collection and save the results in a new collection. We call this "selection," from the database term for choosing a subset of rows from a table. For example, this expression: listeners.{? #this instanceof ActionListener} returns a list of all those listeners that are instances of the ActionListener class. See the coercion section for how OGNL treats various kinds of objects as collections.
Selecting First Match In order to get the first match from a list of matches, you could use indexing such as listeners.{? true }[0]. However, this is cumbersome because if the match does not return any results (or if the result list is empty) you will get an ArrayIndexOutOfBoundsException. The selection syntax is also available to select only the first match and return it as a list. If the match does not succeed for any elements an empty list is the result. objects.{^ #this instanceof String } Will return the first element contained in objects that is an instance of the String class.
Selecting Last Match Similar to getting the first match, sometimes you want to get the last element that matched. objects.{$ #this instanceof String } This will return the last element contained in objects that is an instanceof the String class
Calling Constructors You can create new objects as in Java, with the new operator. One difference is that you must specify the fully qualified class name for classes other than those in the java.lang package.This is only true with the default ClassResolver in place. With a custom class resolver packages can be mapped in such a way that more Java-like references to classes can be made. Refer to the OGNL Developer's Guide for details on using ClassResolver class. (for example, new java.util.ArrayList(), rather than simply new ArrayList()). OGNL chooses the right constructor to call using the same procedure it uses for overloaded method calls.
Calling Static Methods You can call a static method using the syntax @class@method(args). If you leave out class, it defaults to java.lang.Math, to make it easier to call min and max methods. If you specify the class, you must give the fully qualified name. If you have an instance of a class whose static method you wish to call, you can call the method through the object as if it was an instance method. If the method name is overloaded, OGNL chooses the right static method to call using the same procedure it uses for overloaded instance methods.
Getting Static Fields You can refer to a static field using the syntax @class@field. The class must be fully qualified.
Expression Evaluation If you follow an OGNL expression with a parenthesized expression, without a dot in front of the parentheses, OGNL will try to treat the result of the first expression as another expression to evaluate, and will use the result of the parenthesized expression as the root object for that evaluation. The result of the first expression may be any object; if it is an AST, OGNL assumes it is the parsed form of an expression and simply interprets it; otherwise, OGNL takes the string value of the object and parses that string to get the AST to interpret. For example, this expression #fact(30H) looks up the fact variable, and interprets the value of that variable as an OGNL expression using the BigInteger representation of 30 as the root object. See below for an example of setting the fact variable with an expression that returns the factorial of its argument. Note that there is an ambiguity in OGNL's syntax between this double evaluation operator and a method call. OGNL resolves this ambiguity by calling anything that looks like a method call, a method call. For example, if the current object had a fact property that held an OGNL factorial expression, you could not use this approach to call it fact(30H) because OGNL would interpret this as a call to the fact method. You could force the interpretation you want by surrounding the property reference by parentheses: (fact)(30H)
Pseudo-Lambda Expressions OGNL has a simplified lambda-expression syntax, which lets you write simple functions. It is not a full-blown lambda calculus, because there are no closures---all variables in OGNL have global scope and extent. For example, here is an OGNL expression that declares a recursive factorial function, and then calls it: #fact = :[#this<=1? 1 : #this*#fact(#this-1)], #fact(30H) The lambda expression is everything inside the brackets. The #this variable holds the argument to the expression, which is initially 30H, and is then one less for each successive call to the expression. OGNL treats lambda expressions as constants. The value of a lambda expression is the AST that OGNL uses as the parsed form of the contained expression.
Pseudo-Properties for Collections There are some special properties of collections that OGNL makes available. The reason for this is that the collections do not follow JavaBeans patterns for method naming; therefore the size(), length(), etc. methods must be called instead of more intuitively referring to these as properties. OGNL corrects this by exposing certain pseudo-properties as if they were built-in. Special Collections Pseudo-Properties Collection Special Properties Collection (inherited by Map, List & Set) sizeThe size of the collectionisEmptyEvaluates to true if the collection is empty List iteratorEvalutes to an Iterator over the List. Map keysEvalutes to a Set of all keys in the Map.valuesEvaluates to a Collection of all values in the Map.These properties, plus size and isEmpty, are different than the indexed form of access for Maps (i.e. someMap["size"] gets the "size" key from the map, whereas someMap.size gets the size of the Map. Set iteratorEvalutes to an Iterator over the Set. Iterator nextEvalutes to the next object from the Iterator.hasNextEvaluates to true if there is a next object available from the Iterator. Enumeration nextEvalutes to the next object from the Enumeration.hasNextEvaluates to true if there is a next object available from the Enumeration.nextElementSynonym for next.hasMoreElementsSynonym for hasNext.
Operators that differ from Java's operators For the most part, OGNL's operators are borrowed from Java and work similarly to Java's operators. See the OGNL Reference for a complete discussion. Here we describe OGNL operators that are not in Java, or that are different from Java. The comma (,) or sequence operator. This operator is borrowed from C. The comma is used to separate two independent expressions. The value of the second of these expressions is the value of the comma expression. Here is an example: ensureLoaded(), name When this expression is evaluated, the ensureLoaded method is called (presumably to make sure that all parts of the object are in memory), then the name property is retrieved (if getting the value) or replaced (if setting). List construction with curly braces ({}). You can create a list in-line by enclosing the values in curly braces, as in this example: { null, true, false } The in operator (and not in, its negation). This is a containment test, to see if a value is in a collection. For example, name in {null,"Untitled"} || name See the OGNL reference for a full list of operations
Setting values versus getting values As stated before, some values that are gettable are not also settable because of the nature of the expression. For example, names[0].location is a settable expression - the final component of the expression resolves to a settable property. However, some expressions, such as names[0].length + 1 are not settable because they do not resolve to a settable property in an object. It is simply a computed value. If you try to evaluate this expression using any of the Ognl.setValue() methods it will fail with an InappropriateExpressionException. It is also possible to set variables using get expressions that include the '=' operator. This is useful when a get expression needs to set a variable as a side effect of execution.
Coercing Objects to Types Here we describe how OGNL interprets objects as various types. See below for how OGNL coerces objects to booleans, numbers, integers, and collections.
Interpreting Objects as Booleans Any object can be used where a boolean is required. OGNL interprets objects as booleans like this: If the object is a Boolean, its value is extracted and returned If the object is a Number, its double-precision floating-point value is compared with zero; non-zero is treated as true, zero as false. If the object is a Character, its boolean value is true if and only if its char value is non-zero. Otherwise, its boolean value is true if and only if it is non-null.
Interpreting Objects as Numbers Numerical operators try to treat their arguments as numbers. The basic primitive-type wrapper classes (Integer, Double, and so on, including Character and Boolean, which are treated as integers), and the "big" numeric classes from the java.math package (BigInteger and BigDecimal), are recognized as special numeric types. Given an object of some other class, OGNL tries to parse the object's string value as a number. Numerical operators that take two arguments use the following algorithm to decide what type the result should be. The type of the actual result may be wider, if the result does not fit in the given type. If both arguments are of the same type, the result will be of the same type if possible. If either argument is not of a recognized numeric class, it will be treated as if it was a Double for the rest of this algorithm. If both arguments are approximations to real numbers (Float, Double, or BigDecimal), the result will be the wider type. If both arguments are integers (Boolean, Byte, Character, Short, Integer, Long, or BigInteger), the result will be the wider type. If one argument is a real type and the other an integer type, the result will be the real type if the integer is narrower than "int"; BigDecimal if the integer is BigInteger; or the wider of the real type and Double otherwise.
Interpreting Objects as Integers Operators that work only on integers, like the bit-shifting operators, treat their arguments as numbers, except that BigDecimals and BigIntegers are operated on as BigIntegers and all other kinds of numbers are operated on as Longs. For the BigInteger case, the result of these operators remains a BigInteger; for the Long case, the result is expressed as the same type of the arguments, if it fits, or as a Long otherwise.
Interpreting Objects as Collections The projection and selection operators (e1.{e2} and e1.{?e2}), and the in operator, all treat one of their arguments as a collection and walk it. This is done differently depending on the class of the argument: Java arrays are walked from front to back Members of java.util.Collection are walked by walking their iterators Members of java.util.Map are walked by walking iterators over their values Members of java.util.Iterator and java.util.Enumeration are walked by iterating them Members of java.lang.Number are "walked" by returning integers less than the given number starting with zero All other objects are treated as singleton collections containing only themselves
<acronym>OGNL</acronym> Language Reference This section has a fairly detailed treatment of OGNL's syntax and implementation. See below for a complete table of OGNL's operators, a section on how OGNL coerces objects to various types, and a detailed description of OGNL's basic expressions.
Operators OGNL borrows most of Java's operators, and adds a few new ones. For the most part, OGNL's treatment of a given operator is the same as Java's, with the important caveat that OGNL is essentially a typeless language. What that means is that every value in OGNL is a Java object, and OGNL attempts to coerce from each object a meaning appropriate to the situation it is used in (see the section on coercion). The following table lists OGNL operators in reverse precedence order. When more than one operator is listed in the same box, these operators have the same precedence and are evaluated in left-to-right order. <acronym>OGNL</acronym> Operators Operator getValue() Notes setValue() Notes e1, e2Sequence operator Both e1 and e2 are evaluated with the same source object, and the result of e2 is returned. getValue is called on e1, and then setValue is called on e2. e1 = e2Assignment operator getValue is called on e2, and then setValue is called on e1 with the result of e2 as the target object. Cannot be the top-level expression for setValue. e1 ? e2 : e3Conditional operator getValue is called on e1 and the result is interpreted as a boolean. getValue is then called on either e2 or e3, depending on whether the result of e1 was true or false respectively, and the result is returned. getValue is called on e1, and then setValue is called on either e2 or e3. e1 || e2e1 or e2Logical or operator getValue is called on e1 and the result is interpreted as a boolean. If true, that result is returned; if false, getValue is called on e2 and its value is returned. getValue is called on e1; if false, setValue is called on e2. Note that e1 being true prevents any further setting from taking place. e1 && e2e1 and e2Logical and operator getValue is called on e1 and the result is interpreted as a boolean. If false, that result is returned; if true, getValue is called on e2 and its value is returned. getValue is called on e1; if true, setValue is called on e2. Note that e1 being false prevents any further setting from taking place. e1 | e2e1 bor e2Bitwise or operator e1 and e2 are interpreted as integers and the result is an integer. Cannot be the top-level expression passed to setValue. e1 ^ e2e1 xor e2Bitwise exclusive-or operator e1 and e2 are interpreted as integers and the result is an integer. Cannot be the top-level expression passed to setValue. e1 & e2e1 band e2Bitwise and operator e1 and e2 are interpreted as integers and the result is an integer. Cannot be the top-level expression passed to setValue. e1 == e2e1 eq e2Equality teste1 != e2e1 neq e2Inequality test Equality is tested for as follows. If either value is null, they are equal if and only if both are null. If they are the same object or the equals() method says they are equal, they are equal. If they are both Numbers, they are equal if their values as double-precision floating point numbers are equal. Otherwise, they are not equal. These rules make numbers compare equal more readily than they would normally, if just using the equals method. Cannot be the top-level expression passed to setValue. e1 < e2e1 lt e2Less than comparisone1 <= e2e1 lte e2Less than or equals comparisone1 > e2e1 gt e2Greater than comparisone1 >= e2e1 gte e2Greater than or equals comparisone1 in e2List membership comparisone1 not in e2List non-membership comparison The ordering operators compare with compareTo() if their arguments are non-numeric and implement Comparable; otherwise, the arguments are interpreted as numbers and compared numerically. The in operator is not from Java; it tests for inclusion of e1 in e2, where e2 is interpreted as a collection. This test is not efficient: it iterates the collection. However, it uses the standard OGNL equality test. Cannot be the top-level expression passed to setValue. e1 << e2e1 shl e2Bit shift lefte1 >> e2e1 shr e2Bit shift righte1 >>> e2e1 ushr e2Logical shift right e1 and e2 are interpreted as integers and the result is an integer. Cannot be the top-level expression passed to setValue. e1 + e2Additione1 - e2Subtraction The plus operator concatenates strings if its arguments are non-numeric; otherwise it interprets its arguments as numbers and adds them. The minus operator always works on numbers. Cannot be the top-level expression passed to setValue. e1* e2Multiplicatione1 / e2Divisione1 % e2Remainder Multiplication, division, which interpret their arguments as numbers, and remainder, which interprets its arguments as integers. Cannot be the top-level expression passed to setValue. + eUnary plus- eUnary minus! enot eLogical not~ eBitwise note instanceof classClass membership Unary plus is a no-op, it simply returns the value of its argument. Unary minus interprets its argument as a number. Logical not interprets its argument as a boolean. Bitwise not interprets its argument as an integer. The class argument to instanceof is the fully qualified name of a Java class. Cannot be the top-level expression passed to setValue. e.method(args)Method calle.propertyPropertye1[ e2 ]Indexe1.{ e2 }Projectione1.{? e2 }Selectione1.(e2)Subexpression evaluatione1(e2)Expression evaluation Generally speaking, navigation chains are evaluated by evaluating the first expression, then evaluating the second one with the result of the first as the source object. Some of these forms can be passed as top-level expressions to setValue and others cannot. Only those chains that end in property references (e.property), indexes (e1[e2]), and subexpressions (e1.(e2)) can be; and expression evaluations can be as well. For the chains, getValue is called on the left-hand expression (e or e1), and then setValue is called on the rest with the result as the target object. constantConstant( e )Parenthesized expressionmethod(args)Method callpropertyProperty reference[ e ]Index reference{ e, ... }List creation#variableContext variable reference@class@method(args)Static method reference@class@fieldStatic field referencenew class(args)Constructor callnew array-component-class[] { e, ... }Array creation#{ e1 : e2, ... }Map creation#@classname@{ e1 : e2, ... }Map creation with specific subclass:[ e ]Lambda expression definition Basic expressions Only property references (property), indexes ([e]), and variable references (#variable) can be passed as top-level expressions to setValue. For indexes, getValue is called on e, and then the result is used as the property "name" (which might be a String or any other kind of object) to set in the current target object. Variable and property references are set more directly. These operators are listed in reverse precedence order
ognl-2.7.3.orig/OGNL.iml0000644000175000017500000002273111017307302014556 0ustar drazzibdrazzib ognl-2.7.3.orig/docbook.properties0000644000175000017500000000141510633055306017055 0ustar drazzibdrazzib#======================================================================= # DocBook XML processor setup #======================================================================= docbook.xml.version=4.2 docbook.xml.base=docbook-xml-4.2 docbook.xml.path=extlib/docbook-xml-4.2 #======================================================================= # DocBook XSL processor setup #======================================================================= docbook.xsl.version=1.69.1 docbook.xsl.base=docbook-xsl-1.69.1 docbook.xsl.path=extlib/docbook-xsl-1.69.1 #======================================================================= # FOP setup #======================================================================= fop.version=0.20.5 fop.base=fop-0.20.5 fop.path=extlib/fop-0.20.5 ognl-2.7.3.orig/src/0000755000175000017500000000000011237553170014110 5ustar drazzibdrazzibognl-2.7.3.orig/src/test/0000755000175000017500000000000011237553167015075 5ustar drazzibdrazzibognl-2.7.3.orig/src/test/java/0000755000175000017500000000000011237553167016016 5ustar drazzibdrazzibognl-2.7.3.orig/src/test/java/ognl/0000755000175000017500000000000011237553167016755 5ustar drazzibdrazzibognl-2.7.3.orig/src/test/java/ognl/TestOgnlException.java0000644000175000017500000000115010720370235023220 0ustar drazzibdrazzibpackage ognl; import junit.framework.TestCase; /** * Tests {@link OgnlException}. */ public class TestOgnlException extends TestCase { public void test_Throwable_Reason() { try { throwException(); } catch (OgnlException e) { assertTrue(NumberFormatException.class.isInstance(e.getReason())); } } void throwException() throws OgnlException { try { Integer.parseInt("45ac"); } catch (NumberFormatException et) { throw new OgnlException("Unable to parse input string.", et); } } } ognl-2.7.3.orig/src/test/java/ognl/TestOgnlRuntime.java0000644000175000017500000002025510744211276022721 0ustar drazzibdrazzibpackage ognl; import junit.framework.TestCase; import org.ognl.test.objects.*; import java.beans.PropertyDescriptor; import java.io.Serializable; import java.lang.reflect.Method; import java.util.Arrays; import java.util.List; /** * Tests various methods / functionality of {@link ognl.OgnlRuntime}. */ public class TestOgnlRuntime extends TestCase { public void test_Get_Super_Or_Interface_Class() throws Exception { ListSource list = new ListSourceImpl(); Method m = OgnlRuntime.getReadMethod(list.getClass(), "total"); assertNotNull(m); assertEquals(ListSource.class, OgnlRuntime.getCompiler().getSuperOrInterfaceClass(m, list.getClass())); } public void test_Get_Private_Class() throws Exception { List list = Arrays.asList(new String[]{"hello", "world"}); Method m = OgnlRuntime.getReadMethod(list.getClass(), "iterator"); assertNotNull(m); assertEquals(Iterable.class, OgnlRuntime.getCompiler().getSuperOrInterfaceClass(m, list.getClass())); } public void test_Complicated_Inheritance() throws Exception { IForm form = new FormImpl(); Method m = OgnlRuntime.getWriteMethod(form.getClass(), "clientId"); assertNotNull(m); assertEquals(IComponent.class, OgnlRuntime.getCompiler().getSuperOrInterfaceClass(m, form.getClass())); } public void test_Get_Read_Method() throws Exception { Method m = OgnlRuntime.getReadMethod(Bean2.class, "pageBreakAfter"); assertNotNull(m); assertEquals("isPageBreakAfter", m.getName()); } class TestGetters { public boolean isEditorDisabled() { return false; } public boolean isDisabled() { return true; } public boolean isNotAvailable() { return false; } public boolean isAvailable() { return true; } } public void test_Get_Read_Method_Multiple() throws Exception { Method m = OgnlRuntime.getReadMethod(TestGetters.class, "disabled"); assertNotNull(m); assertEquals("isDisabled", m.getName()); } public void test_Get_Read_Method_Multiple_Boolean_Getters() throws Exception { Method m = OgnlRuntime.getReadMethod(TestGetters.class, "available"); assertNotNull(m); assertEquals("isAvailable", m.getName()); m = OgnlRuntime.getReadMethod(TestGetters.class, "notAvailable"); assertNotNull(m); assertEquals("isNotAvailable", m.getName()); } public void test_Find_Method_Mixed_Boolean_Getters() throws Exception { Method m = OgnlRuntime.getReadMethod(GetterMethods.class, "allowDisplay"); assertNotNull(m); assertEquals("getAllowDisplay", m.getName()); } public void test_Get_Appropriate_Method() throws Exception { ListSource list = new ListSourceImpl(); OgnlContext context = (OgnlContext) Ognl.createDefaultContext(null); Object ret = OgnlRuntime.callMethod(context, list, "addValue", new String[] {null}); assert ret != null; } public void test_Call_Static_Method_Invalid_Class() { try { OgnlContext context = (OgnlContext) Ognl.createDefaultContext(null); OgnlRuntime.callStaticMethod(context, "made.up.Name", "foo", null); fail("ClassNotFoundException should have been thrown by previous reference to class."); } catch (Exception et) { assertTrue(MethodFailedException.class.isInstance(et)); assertTrue(et.getMessage().indexOf("made.up.Name") > -1); } } public void test_Setter_Returns() throws Exception { OgnlContext context = (OgnlContext) Ognl.createDefaultContext(null); SetterReturns root = new SetterReturns(); Method m = OgnlRuntime.getWriteMethod(root.getClass(), "value"); assertTrue(m != null); Ognl.setValue("value", context, root, "12__"); assertEquals(Ognl.getValue("value", context, root), "12__"); } public void test_Call_Method_VarArgs() throws Exception { OgnlContext context = (OgnlContext) Ognl.createDefaultContext(null); GenericService service = new GenericServiceImpl(); GameGenericObject argument = new GameGenericObject(); Object[] args = OgnlRuntime.getObjectArrayPool().create(2); args[0] = argument; assertEquals("Halo 3", OgnlRuntime.callMethod(context, service, "getFullMessageFor", args)); } public void test_Class_Cache_Inspector() throws Exception { OgnlRuntime.clearCache(); assertEquals(0, OgnlRuntime._propertyDescriptorCache.getSize()); Root root = new Root(); OgnlContext context = (OgnlContext) Ognl.createDefaultContext(null); Node expr = Ognl.compileExpression(context, root, "property.bean3.value != null"); assertTrue((Boolean)expr.getAccessor().get(context, root)); int size = OgnlRuntime._propertyDescriptorCache.getSize(); assertTrue(size > 0); OgnlRuntime.clearCache(); assertEquals(0, OgnlRuntime._propertyDescriptorCache.getSize()); // now register class cache prevention OgnlRuntime.setClassCacheInspector(new TestCacheInspector()); expr = Ognl.compileExpression(context, root, "property.bean3.value != null"); assertTrue((Boolean)expr.getAccessor().get(context, root)); assertEquals((size - 1), OgnlRuntime._propertyDescriptorCache.getSize()); } class TestCacheInspector implements ClassCacheInspector { public boolean shouldCache(Class type) { if (type == null || type == Root.class) return false; return true; } } public void test_Set_Generic_Parameter_Types() throws Exception { OgnlContext context = (OgnlContext) Ognl.createDefaultContext(null); Method m = OgnlRuntime.getSetMethod(context, GenericCracker.class, "param"); assertNotNull(m); Class[] types = m.getParameterTypes(); assertEquals(1, types.length); assertEquals(Integer.class, types[0]); } public void test_Get_Generic_Parameter_Types() throws Exception { OgnlContext context = (OgnlContext) Ognl.createDefaultContext(null); Method m = OgnlRuntime.getGetMethod(context, GenericCracker.class, "param"); assertNotNull(m); assertEquals(Integer.class, m.getReturnType()); } public void test_Find_Parameter_Types() throws Exception { OgnlContext context = (OgnlContext) Ognl.createDefaultContext(null); Method m = OgnlRuntime.getSetMethod(context, GameGeneric.class, "ids"); assertNotNull(m); Class[] types = OgnlRuntime.findParameterTypes(GameGeneric.class, m); assertEquals(1, types.length); assertEquals(new Long[0].getClass(), types[0]); } public void test_Find_Parameter_Types_Superclass() throws Exception { OgnlContext context = (OgnlContext) Ognl.createDefaultContext(null); Method m = OgnlRuntime.getSetMethod(context, BaseGeneric.class, "ids"); assertNotNull(m); Class[] types = OgnlRuntime.findParameterTypes(BaseGeneric.class, m); assertEquals(1, types.length); assertEquals(new Serializable[0].getClass(), types[0]); } public void test_Get_Declared_Methods_With_Synthetic_Methods() throws Exception { List result = OgnlRuntime.getDeclaredMethods(SubclassSyntheticObject.class, "list", false); // synthetic method would be "public volatile java.util.List org.ognl.test.objects.SubclassSyntheticObject.getList()", // causing method return size to be 3 assertEquals(2, result.size()); } public void test_Get_Property_Descriptors_With_Synthetic_Methods() throws Exception { PropertyDescriptor pd = OgnlRuntime.getPropertyDescriptor(SubclassSyntheticObject.class, "list"); assert pd != null; assert OgnlRuntime.isMethodCallable(pd.getReadMethod()); } } ognl-2.7.3.orig/src/test/java/ognl/InExpressionTest.java0000644000175000017500000000102010720374205023065 0ustar drazzibdrazzibpackage ognl; import junit.framework.TestCase; /** * Test for OGNL-118. */ public class InExpressionTest extends TestCase { public void test_String_In() throws Exception { OgnlContext context = (OgnlContext) Ognl.createDefaultContext(null); Object node = Ognl.parseExpression("#name in {\"Greenland\", \"Austin\", \"Africa\", \"Rome\"}"); Object root = null; context.put("name", "Austin"); assertEquals(Boolean.TRUE, Ognl.getValue(node, context, root)); } } ognl-2.7.3.orig/src/test/java/org/0000755000175000017500000000000011237553167016605 5ustar drazzibdrazzibognl-2.7.3.orig/src/test/java/org/ognl/0000755000175000017500000000000011237553167017544 5ustar drazzibdrazzibognl-2.7.3.orig/src/test/java/org/ognl/test/0000755000175000017500000000000011237553170020515 5ustar drazzibdrazzibognl-2.7.3.orig/src/test/java/org/ognl/test/PropertyTest.java0000644000175000017500000002260210713112566024044 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package org.ognl.test; import junit.framework.TestSuite; import org.ognl.test.objects.*; import java.text.SimpleDateFormat; import java.util.Arrays; public class PropertyTest extends OgnlTestCase { public static final SimpleDateFormat DATETIME_FORMAT = new SimpleDateFormat("MM/dd/yyyy hh:mm a 'CST'"); public static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("MM/dd/yyyy"); public static final String VALUE = "foo"; private static Root ROOT = new Root(); private static BaseBean BEAN = new FirstBean(); private static PropertyHolder PROPERTY = new PropertyHolder(); private static Object[][] TESTS = { { ROOT, "testString != null && !false", Boolean.TRUE}, { ROOT, "!getRenderNavigation() and !getReadonly()", Boolean.TRUE }, { ROOT, "!bean2.pageBreakAfter", Boolean.TRUE}, { ROOT, "map", ROOT.getMap() }, { ROOT, "map.test", ROOT }, { ROOT, "map[\"test\"]", ROOT }, { ROOT, "map[\"te\" + \"st\"]", ROOT }, { ROOT, "map[(\"s\" + \"i\") + \"ze\"]", ROOT.getMap().get(Root.SIZE_STRING) }, { ROOT, "map[\"size\"]", ROOT.getMap().get(Root.SIZE_STRING) }, { ROOT, "map[@org.ognl.test.objects.Root@SIZE_STRING]", ROOT.getMap().get(Root.SIZE_STRING) }, { ROOT, "stringValue != null && stringValue.length() > 0", Boolean.FALSE}, { ROOT, "indexedStringValue != null && indexedStringValue.length() > 0", Boolean.TRUE}, { ROOT.getMap(), "list", ROOT.getList() }, { ROOT, "map.array[0]", new Integer(ROOT.getArray()[0]) }, { ROOT, "map.list[1]", ROOT.getList().get(1) }, { ROOT, "map[^]", new Integer(99) }, { ROOT, "map[$]", null }, { ROOT.getMap(), "array[$]", new Integer(ROOT.getArray()[ROOT.getArray().length-1]) }, { ROOT, "[\"map\"]", ROOT.getMap() }, { ROOT.getArray(), "length", new Integer(ROOT.getArray().length) }, { ROOT, "getMap().list[|]", ROOT.getList().get(ROOT.getList().size()/2) }, { ROOT, "map.(array[2] + size())", new Integer(ROOT.getArray()[2] + ROOT.getMap().size()) }, { ROOT, "map.(#this)", ROOT.getMap() }, { ROOT, "map.(#this != null ? #this['size'] : null)", ROOT.getMap().get(Root.SIZE_STRING) }, { ROOT, "map[^].(#this == null ? 'empty' : #this)", new Integer(99) }, { ROOT, "map[$].(#this == null ? 'empty' : #this)", "empty" }, { ROOT, "map[$].(#root == null ? 'empty' : #root)", ROOT }, { ROOT, "((selected != null) && (currLocale.toString() == selected.toString())) ? 'first' : 'second'", "first" }, { ROOT, "{stringValue, getMap()}", Arrays.asList(new Object[]{ROOT.getStringValue(), ROOT.getMap()})}, { ROOT, "{'stringValue', map[\"test\"].map[\"size\"]}", Arrays.asList(new Object[]{"stringValue", ROOT.getMap().get("size")}) }, { ROOT, "property.bean3.value + '(this.checked)'", "100(this.checked)"}, { ROOT, "getIndexedProperty(property.bean3.map[\"bar\"])", ROOT.getArray()}, { ROOT, "getProperty().getBean3()", ((Bean2)ROOT.getProperty()).getBean3()}, { ROOT, "intValue", new Integer(0), new Integer(2), new Integer(2) }, { ROOT, "! booleanValue", Boolean.TRUE}, { ROOT, "booleanValue", Boolean.FALSE, Boolean.TRUE, Boolean.TRUE}, { ROOT, "! disabled", new Boolean(false)}, { ROOT, "disabled || readonly", Boolean.TRUE}, { ROOT, "property.bean3.value != null", Boolean.TRUE}, { ROOT, "\"background-color:blue; width:\" + (currentLocaleVerbosity / 2) + \"px\"", "background-color:blue; width:43px"}, { ROOT, "renderNavigation ? '' : 'noborder'", "noborder" }, { ROOT, "format('key', array)", "formatted" }, { ROOT, "format('key', intValue)", "formatted" }, { ROOT, "format('key', map.size)", "formatted" }, { ROOT, "'disableButton(this,\"' + map.get('button-testing') + '\");clearElement("testFtpMessage")'", "disableButton(this,'null');clearElement('testFtpMessage')" }, { ROOT.getMap(), "!disableWarning", Boolean.TRUE}, { ROOT.getMap(), "get('value').bean3.value", new Integer(((Bean2)ROOT.getMap().get("value")).getBean3().getValue())}, { ROOT.getMap(), "\"Tapestry\".toCharArray()[2]", new Character('p')}, { ROOT.getMap(), "nested.deep.last", Boolean.TRUE}, { ROOT, "'last ' + getCurrentClass(@org.ognl.test.PropertyTest@VALUE)", "last foo stop"}, { ROOT, "@org.ognl.test.PropertyTest@formatValue(property.millis, true, true)", formatValue((int)((Bean2)ROOT.getProperty()).getMillis(), true, true) }, { ROOT, "nullObject || !readonly", Boolean.TRUE }, { ROOT, "testDate == null ? '-' : @org.ognl.test.PropertyTest@DATETIME_FORMAT.format(testDate)", DATETIME_FORMAT.format(ROOT.getTestDate()) }, { ROOT, "disabled ? 'disabled' : 'othernot'", "disabled" }, { BEAN, "two.getMessage(active ? 'ACT' : 'INA')", "[ACT]"}, { BEAN, "hasChildren('aaa')", Boolean.TRUE}, { BEAN, "two.hasChildren('aa')", Boolean.FALSE}, { BEAN, "two.hasChildren('a')", Boolean.FALSE}, { ROOT, "sorted ? (readonly ? 'currentSortDesc' : 'currentSortAsc') : 'currentSortNone'", "currentSortAsc"}, { ROOT, "getAsset( (width?'Yes':'No')+'Icon' )", "YesIcon"}, { ROOT, "flyingMonkey", Boolean.TRUE}, { ROOT, "expiration == null ? '' : @org.ognl.test.PropertyTest@DATE_FORMAT.format(expiration)", ""}, { ROOT, "printDelivery ? 'javascript:toggle(' + bean2.id + ');' : ''", "javascript:toggle(1);"}, { ROOT, "openTransitionWin", Boolean.FALSE}, { ROOT, "b.methodOfB(a.methodOfA(b)-1)", new Integer(0)}, { ROOT, "disabled", Boolean.TRUE}, { PROPERTY, "value", ""}, { PROPERTY, "search", "foo" } }; public static String formatValue(int millis, boolean b1, boolean b2) { return millis + "-formatted"; } /*=================================================================== Public static methods ===================================================================*/ public static TestSuite suite() { TestSuite result = new TestSuite(); for (int i = 0; i < TESTS.length; i++) { if (TESTS[i].length == 5) { result.addTest(new PropertyTest((String)TESTS[i][1], TESTS[i][0], (String)TESTS[i][1], TESTS[i][2], TESTS[i][3], TESTS[i][4])); } else result.addTest(new PropertyTest((String)TESTS[i][1], TESTS[i][0], (String)TESTS[i][1], TESTS[i][2])); } return result; } /*=================================================================== Constructors ===================================================================*/ public PropertyTest() { super(); } public PropertyTest(String name) { super(name); } public PropertyTest(String name, Object root, String expressionString, Object expectedResult, Object setValue, Object expectedAfterSetResult) { super(name, root, expressionString, expectedResult, setValue, expectedAfterSetResult); } public PropertyTest(String name, Object root, String expressionString, Object expectedResult, Object setValue) { super(name, root, expressionString, expectedResult, setValue); } public PropertyTest(String name, Object root, String expressionString, Object expectedResult) { super(name, root, expressionString, expectedResult); } } ognl-2.7.3.orig/src/test/java/org/ognl/test/MethodWithConversionTest.java0000644000175000017500000001133510610173637026345 0ustar drazzibdrazzib// -------------------------------------------------------------------------- // Copyright (c) 2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. // -------------------------------------------------------------------------- package org.ognl.test; import junit.framework.TestSuite; import org.ognl.test.objects.Simple; public class MethodWithConversionTest extends OgnlTestCase { private static Simple SIMPLE = new Simple(); private static Object[][] TESTS = { // Method call with conversion { SIMPLE, "setValues(new Integer(10), \"10.56\", new Double(34.225))", null }, { SIMPLE, "stringValue", "10" }, { SIMPLE, "stringValue", "10", new Character('x'), "x" }, { SIMPLE, "setStringValue('x')", null }, // set by calling setStringValue() directly { SIMPLE, "floatValue", new Float(10.56) }, { SIMPLE, "getValueIsTrue(rootValue)", Boolean.TRUE}, { SIMPLE, "messages.format('Testing', one, two, three)", "blah" } }; /* * =================================================================== Public static methods * =================================================================== */ public static TestSuite suite() { TestSuite result = new TestSuite(); for(int i = 0; i < TESTS.length; i++) { if (TESTS[i].length == 3) { result.addTest(new MethodWithConversionTest((String) TESTS[i][1], TESTS[i][0], (String) TESTS[i][1], TESTS[i][2])); } else { if (TESTS[i].length == 4) { result.addTest(new MethodWithConversionTest((String) TESTS[i][1], TESTS[i][0], (String) TESTS[i][1], TESTS[i][2], TESTS[i][3])); } else { if (TESTS[i].length == 5) { result.addTest(new MethodWithConversionTest((String) TESTS[i][1], TESTS[i][0], (String) TESTS[i][1], TESTS[i][2], TESTS[i][3], TESTS[i][4])); } else { throw new RuntimeException("don't understand TEST format"); } } } } return result; } /* * =================================================================== Constructors * =================================================================== */ public MethodWithConversionTest() { super(); } public MethodWithConversionTest(String name) { super(name); } public MethodWithConversionTest(String name, Object root, String expressionString, Object expectedResult, Object setValue, Object expectedAfterSetResult) { super(name, root, expressionString, expectedResult, setValue, expectedAfterSetResult); } public MethodWithConversionTest(String name, Object root, String expressionString, Object expectedResult, Object setValue) { super(name, root, expressionString, expectedResult, setValue); } public MethodWithConversionTest(String name, Object root, String expressionString, Object expectedResult) { super(name, root, expressionString, expectedResult); } } ognl-2.7.3.orig/src/test/java/org/ognl/test/SimplePropertyTreeTest.java0000644000175000017500000001003510655141672026040 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package org.ognl.test; import junit.framework.TestSuite; import ognl.Ognl; public class SimplePropertyTreeTest extends OgnlTestCase { private static Object[][] TESTS = { { "name", Boolean.TRUE }, { "foo", Boolean.TRUE }, { "name[i]", Boolean.FALSE }, { "name + foo", Boolean.FALSE }, { "name.foo", Boolean.FALSE }, { "name.foo.bar", Boolean.FALSE }, { "name.{? foo }", Boolean.FALSE }, { "name.( foo )", Boolean.FALSE } }; /*=================================================================== Public static methods ===================================================================*/ public static TestSuite suite() { TestSuite result = new TestSuite(); for (int i = 0; i < TESTS.length; i++) { result.addTest(new SimplePropertyTreeTest((String)TESTS[i][0] + " (" + TESTS[i][1] + ")", null, (String)TESTS[i][0], TESTS[i][1])); } return result; } /*=================================================================== Constructors ===================================================================*/ public SimplePropertyTreeTest() { super(); } public SimplePropertyTreeTest(String name) { super(name); } public SimplePropertyTreeTest(String name, Object root, String expressionString, Object expectedResult, Object setValue, Object expectedAfterSetResult) { super(name, root, expressionString, expectedResult, setValue, expectedAfterSetResult); } public SimplePropertyTreeTest(String name, Object root, String expressionString, Object expectedResult, Object setValue) { super(name, root, expressionString, expectedResult, setValue); } public SimplePropertyTreeTest(String name, Object root, String expressionString, Object expectedResult) { super(name, root, expressionString, expectedResult); } /*=================================================================== Overridden methods ===================================================================*/ protected void runTest() throws Exception { assertTrue(Ognl.isSimpleProperty(getExpression(), _context) == ((Boolean)getExpectedResult()).booleanValue()); } } ognl-2.7.3.orig/src/test/java/org/ognl/test/SetterTest.java0000644000175000017500000001352510632543423023472 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package org.ognl.test; import junit.framework.TestSuite; import ognl.InappropriateExpressionException; import ognl.NoSuchPropertyException; import org.ognl.test.objects.Root; import java.util.HashMap; import java.util.HashSet; import java.util.Set; public class SetterTest extends OgnlTestCase { private static Root ROOT = new Root(); static Set _list = new HashSet(); static { _list.add("Test1"); } private static Object[][] TESTS = { // Setting values { ROOT.getMap(), "newValue", null, new Integer(101) }, { ROOT, "settableList[0]", "foo", "quux" }, // absolute indexes { ROOT, "settableList[0]", "quux" }, { ROOT, "settableList[2]", "baz", "quux" }, { ROOT, "settableList[2]", "quux" }, { ROOT, "settableList[$]", "quux", "oompa" }, // special indexes { ROOT, "settableList[$]", "oompa" }, { ROOT, "settableList[^]", "quux", "oompa" }, { ROOT, "settableList[^]", "oompa" }, { ROOT, "settableList[|]", "bar", "oompa" }, { ROOT, "settableList[|]", "oompa" }, { ROOT, "map.newValue", new Integer(101), new Integer(555) }, { ROOT, "map", ROOT.getMap(), new HashMap(), NoSuchPropertyException.class }, { ROOT.getMap(), "newValue2 || put(\"newValue2\",987), newValue2", new Integer(987), new Integer(1002) }, { ROOT, "map.(someMissingKey || newValue)", new Integer(555), new Integer(666) }, { ROOT.getMap(), "newValue || someMissingKey", new Integer(666), new Integer(666) }, // no setting happens! { ROOT, "map.(newValue && aKey)", null, new Integer(54321)}, { ROOT, "map.(someMissingKey && newValue)", null, null }, // again, no setting { null, "0", new Integer(0), null, InappropriateExpressionException.class }, // illegal for setting, no property { ROOT, "map[0]=\"map.newValue\", map[0](#this)", new Integer(666), new Integer(888) }, { ROOT, "selectedList", null, _list, IllegalArgumentException.class}, { ROOT, "openTransitionWin", Boolean.FALSE, Boolean.TRUE} }; /*=================================================================== Public static methods ===================================================================*/ public static TestSuite suite() { TestSuite result = new TestSuite(); for (int i = 0; i < TESTS.length; i++) { if (TESTS[i].length == 3) { result.addTest(new SetterTest((String)TESTS[i][1], TESTS[i][0], (String)TESTS[i][1], TESTS[i][2])); } else { if (TESTS[i].length == 4) { result.addTest(new SetterTest((String)TESTS[i][1], TESTS[i][0], (String)TESTS[i][1], TESTS[i][2], TESTS[i][3])); } else { if (TESTS[i].length == 5) { result.addTest(new SetterTest((String)TESTS[i][1], TESTS[i][0], (String)TESTS[i][1], TESTS[i][2], TESTS[i][3], TESTS[i][4])); } else { throw new RuntimeException("don't understand TEST format"); } } } } return result; } /*=================================================================== Constructors ===================================================================*/ public SetterTest() { super(); } public SetterTest(String name) { super(name); } public SetterTest(String name, Object root, String expressionString, Object expectedResult, Object setValue, Object expectedAfterSetResult) { super(name, root, expressionString, expectedResult, setValue, expectedAfterSetResult); } public SetterTest(String name, Object root, String expressionString, Object expectedResult, Object setValue) { super(name, root, expressionString, expectedResult, setValue); } public SetterTest(String name, Object root, String expressionString, Object expectedResult) { super(name, root, expressionString, expectedResult); } } ognl-2.7.3.orig/src/test/java/org/ognl/test/NumberFormatExceptionTest.java0000644000175000017500000001406310566476144026515 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package org.ognl.test; import junit.framework.TestSuite; import ognl.OgnlException; import org.ognl.test.objects.Simple; import java.math.BigDecimal; import java.math.BigInteger; public class NumberFormatExceptionTest extends OgnlTestCase { private static Simple SIMPLE = new Simple(); private static Object[][] TESTS = { // NumberFormatException handling (default is to throw NumberFormatException on bad string conversions) { SIMPLE, "floatValue", new Float(0f), new Float(10f), new Float(10f) }, { SIMPLE, "floatValue", new Float(10f), "x10x", OgnlException.class }, { SIMPLE, "intValue", new Integer(0), new Integer(34), new Integer(34) }, { SIMPLE, "intValue", new Integer(34), "foobar", OgnlException.class }, { SIMPLE, "intValue", new Integer(34), "", OgnlException.class }, { SIMPLE, "intValue", new Integer(34), " \t", OgnlException.class }, { SIMPLE, "intValue", new Integer(34), " \t1234\t\t", new Integer(1234) }, { SIMPLE, "bigIntValue", BigInteger.valueOf(0), BigInteger.valueOf(34), BigInteger.valueOf(34) }, { SIMPLE, "bigIntValue", BigInteger.valueOf(34), null, null }, { SIMPLE, "bigIntValue", null, "", OgnlException.class }, { SIMPLE, "bigIntValue", null, "foobar", OgnlException.class }, { SIMPLE, "bigDecValue", new BigDecimal(0.0), new BigDecimal(34.55), new BigDecimal(34.55) }, { SIMPLE, "bigDecValue", new BigDecimal(34.55), null, null }, { SIMPLE, "bigDecValue", null, "", OgnlException.class }, { SIMPLE, "bigDecValue", null, "foobar", OgnlException.class } }; /*=================================================================== Public static methods ===================================================================*/ public static TestSuite suite() { TestSuite result = new TestSuite(); for (int i = 0; i < TESTS.length; i++) { if (TESTS[i].length == 3) { result.addTest(new NumberFormatExceptionTest((String)TESTS[i][1], TESTS[i][0], (String)TESTS[i][1], TESTS[i][2])); } else { if (TESTS[i].length == 4) { result.addTest(new NumberFormatExceptionTest((String)TESTS[i][1], TESTS[i][0], (String)TESTS[i][1], TESTS[i][2], TESTS[i][3])); } else { if (TESTS[i].length == 5) { result.addTest(new NumberFormatExceptionTest((String)TESTS[i][1], TESTS[i][0], (String)TESTS[i][1], TESTS[i][2], TESTS[i][3], TESTS[i][4])); } else { throw new RuntimeException("don't understand TEST format"); } } } } return result; } /*=================================================================== Constructors ===================================================================*/ public NumberFormatExceptionTest() { super(); } public NumberFormatExceptionTest(String name) { super(name); } public NumberFormatExceptionTest(String name, Object root, String expressionString, Object expectedResult, Object setValue, Object expectedAfterSetResult) { super(name, root, expressionString, expectedResult, setValue, expectedAfterSetResult); } public NumberFormatExceptionTest(String name, Object root, String expressionString, Object expectedResult, Object setValue) { super(name, root, expressionString, expectedResult, setValue); } public NumberFormatExceptionTest(String name, Object root, String expressionString, Object expectedResult) { super(name, root, expressionString, expectedResult); } } ognl-2.7.3.orig/src/test/java/org/ognl/test/enhance/0000755000175000017500000000000011237553170022116 5ustar drazzibdrazzibognl-2.7.3.orig/src/test/java/org/ognl/test/enhance/TestExpressionCompiler.java0000644000175000017500000001404310713163323027450 0ustar drazzibdrazzib/** * */ package org.ognl.test.enhance; import junit.framework.TestCase; import ognl.Node; import ognl.Ognl; import ognl.OgnlContext; import ognl.enhance.ExpressionCompiler; import ognl.enhance.OgnlExpressionCompiler; import org.ognl.test.objects.*; import java.util.Collection; import java.util.HashMap; import java.util.Map; /** * Tests functionality of {@link ExpressionCompiler}. */ public class TestExpressionCompiler extends TestCase { OgnlExpressionCompiler _compiler; OgnlContext _context = (OgnlContext) Ognl.createDefaultContext(null); public void setUp() { _compiler = new ExpressionCompiler(); } public void test_Get_Property_Access() throws Throwable { Node expr = (Node)Ognl.parseExpression("bean2"); Bean1 root = new Bean1(); _compiler.compileExpression(_context, expr, root); assertNotNull(expr.getAccessor().get(_context, root)); } public void test_Get_Indexed_Property() throws Throwable { Node expr = (Node)Ognl.parseExpression("bean2.bean3.indexedValue[25]"); Bean1 root = new Bean1(); assertNull(Ognl.getValue(expr, _context, root)); _compiler.compileExpression(_context, expr, root); assertNull(expr.getAccessor().get(_context, root)); } public void test_Set_Indexed_Property() throws Throwable { Node expr = (Node)Ognl.parseExpression("bean2.bean3.indexedValue[25]"); Bean1 root = new Bean1(); assertNull(Ognl.getValue(expr, _context, root)); _compiler.compileExpression(_context, expr, root); expr.getAccessor().set(_context, root, "test string"); assertEquals("test string", expr.getAccessor().get(_context, root)); } public void test_Expression() throws Throwable { Node expr = (Node)Ognl.parseExpression("bean2.bean3.value <= 24"); Bean1 root = new Bean1(); assertEquals(Boolean.FALSE, Ognl.getValue(expr, _context, root)); _compiler.compileExpression(_context, expr, root); assertEquals(Boolean.FALSE, expr.getAccessor().get(_context, root)); } public void test_Get_Context_Property() throws Throwable { _context.put("key", "foo"); Node expr = (Node)Ognl.parseExpression("bean2.bean3.map[#key]"); Bean1 root = new Bean1(); assertEquals("bar", Ognl.getValue(expr, _context, root)); _compiler.compileExpression(_context, expr, root); assertEquals("bar", expr.getAccessor().get(_context, root)); _context.put("key", "bar"); assertEquals("baz", Ognl.getValue(expr, _context, root)); assertEquals("baz", expr.getAccessor().get(_context, root)); } public void test_Set_Context_Property() throws Throwable { _context.put("key", "foo"); Node expr = (Node)Ognl.parseExpression("bean2.bean3.map[#key]"); Bean1 root = new Bean1(); _compiler.compileExpression(_context, expr, root); assertEquals("bar", expr.getAccessor().get(_context, root)); _context.put("key", "bar"); assertEquals("baz", expr.getAccessor().get(_context, root)); expr.getAccessor().set(_context, root, "bam"); assertEquals("bam", expr.getAccessor().get(_context, root)); } public void test_Property_Index() throws Throwable { Root root = new Root(); Node expr = (Node) Ognl.compileExpression(_context, root, "{index + 1}"); Object ret = expr.getAccessor().get(_context, root); assertTrue(Collection.class.isInstance(ret)); } public void test_Root_Expression_Inheritance() throws Throwable { Inherited obj1 = new TestInherited1(); Inherited obj2 = new TestInherited2(); Node expr = (Node) Ognl.compileExpression(_context, obj1, "myString"); assertEquals(expr.getAccessor().get(_context, obj1), "inherited1"); assertEquals(expr.getAccessor().get(_context, obj2), "inherited2"); } public void test_Create_Empty_Collection() throws Throwable { Node expr = (Node) Ognl.compileExpression(_context, null, "{}"); Object ret = expr.getAccessor().get(_context, null); assertNotNull(ret); assertTrue(Collection.class.isAssignableFrom(ret.getClass())); } public String getKey() { return "key"; } public void test_Indexed_Property() throws Throwable { Map map = new HashMap(); map.put("key", "value"); Node expression = Ognl.compileExpression(_context, this, "key"); assertEquals("key", expression.getAccessor().get(_context, this)); } IndexedMapObject mapObject = new IndexedMapObject("propertyValue"); public IndexedMapObject getObject() { return mapObject; } public String getPropertyKey() { return "property"; } public void test_Indexed_Map_Property() throws Throwable { assertEquals("propertyValue", Ognl.getValue("object[propertyKey]", this)); _context.clear(); Node expression = Ognl.compileExpression(_context, this, "object[#this.propertyKey]"); assertEquals("propertyValue", expression.getAccessor().get(_context, this)); _context.clear(); expression = Ognl.compileExpression(_context, this, "object[propertyKey]"); assertEquals("propertyValue", expression.getAccessor().get(_context, this)); } public void test_Set_Generic_Property() throws Exception { _context.clear(); GenericRoot root = new GenericRoot(); Node node = Ognl.compileExpression(_context, root, "cracker.param"); assertEquals(null, node.getAccessor().get(_context, root)); node.getAccessor().set(_context, root, new Integer(0)); assertEquals(new Integer(0), node.getAccessor().get(_context, root)); node.getAccessor().set(_context, root, new Integer(12)); assertEquals(new Integer(12), node.getAccessor().get(_context, root)); } } ognl-2.7.3.orig/src/test/java/org/ognl/test/ArrayCreationTest.java0000644000175000017500000001330610621705703024763 0ustar drazzibdrazzib// -------------------------------------------------------------------------- // Copyright (c) 2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. // -------------------------------------------------------------------------- package org.ognl.test; import junit.framework.TestSuite; import ognl.ExpressionSyntaxException; import org.ognl.test.objects.Entry; import org.ognl.test.objects.Root; import org.ognl.test.objects.Simple; public class ArrayCreationTest extends OgnlTestCase { private static Root ROOT = new Root(); private static Object[][] TESTS = { // Array creation { ROOT, "new String[] { \"one\", \"two\" }", new String[] { "one", "two" } }, { ROOT, "new String[] { 1, 2 }", new String[] { "1", "2" } }, { ROOT, "new Integer[] { \"1\", 2, \"3\" }", new Integer[] { new Integer(1), new Integer(2), new Integer(3) } }, { ROOT, "new String[10]", new String[10] }, { ROOT, "new Object[4] { #root, #this }", ExpressionSyntaxException.class }, { ROOT, "new Object[4]", new Object[4] }, { ROOT, "new Object[] { #root, #this }", new Object[] { ROOT, ROOT } }, { ROOT, "new org.ognl.test.objects.Simple[] { new org.ognl.test.objects.Simple(), new org.ognl.test.objects.Simple(\"foo\", 1.0f, 2) }", new Simple[] { new Simple(), new Simple("foo", 1.0f, 2) } }, { ROOT, "new org.ognl.test.objects.Simple[5]", new Simple[5] }, { ROOT, "new org.ognl.test.objects.Simple(new Object[5])", new Simple(new Object[5]) }, { ROOT, "new org.ognl.test.objects.Simple(new String[5])", new Simple(new String[5]) }, { ROOT, "objectIndex ? new org.ognl.test.objects.Entry[] { new org.ognl.test.objects.Entry(), new org.ognl.test.objects.Entry()} " + ": new org.ognl.test.objects.Entry[] { new org.ognl.test.objects.Entry(), new org.ognl.test.objects.Entry()} ", new Entry[] { new Entry(), new Entry()} } }; /* * =================================================================== Public static methods * =================================================================== */ public static TestSuite suite() { TestSuite result = new TestSuite(); for(int i = 0; i < TESTS.length; i++) { if (TESTS[i].length == 3) { result.addTest(new ArrayCreationTest((String) TESTS[i][1], TESTS[i][0], (String) TESTS[i][1], TESTS[i][2])); } else { if (TESTS[i].length == 4) { result.addTest(new ArrayCreationTest((String) TESTS[i][1], TESTS[i][0], (String) TESTS[i][1], TESTS[i][2], TESTS[i][3])); } else { if (TESTS[i].length == 5) { result.addTest(new ArrayCreationTest((String) TESTS[i][1], TESTS[i][0], (String) TESTS[i][1], TESTS[i][2], TESTS[i][3], TESTS[i][4])); } else { throw new RuntimeException("don't understand TEST format"); } } } } return result; } /* * =================================================================== Constructors * =================================================================== */ public ArrayCreationTest() { super(); } public ArrayCreationTest(String name) { super(name); } public ArrayCreationTest(String name, Object root, String expressionString, Object expectedResult, Object setValue, Object expectedAfterSetResult) { super(name, root, expressionString, expectedResult, setValue, expectedAfterSetResult); } public ArrayCreationTest(String name, Object root, String expressionString, Object expectedResult, Object setValue) { super(name, root, expressionString, expectedResult, setValue); } public ArrayCreationTest(String name, Object root, String expressionString, Object expectedResult) { super(name, root, expressionString, expectedResult); } } ognl-2.7.3.orig/src/test/java/org/ognl/test/CorrectedObjectNullHandler.java0000644000175000017500000000552510566476144026572 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package org.ognl.test; import ognl.NullHandler; import java.util.Map; public class CorrectedObjectNullHandler extends Object implements NullHandler { private String defaultValue; /*=================================================================== Constructors ===================================================================*/ public CorrectedObjectNullHandler(String defaultValue) { super(); this.defaultValue = defaultValue; } /*=================================================================== TypeConverter interface (overridden) ===================================================================*/ public Object nullMethodResult(Map context, Object target, String methodName, Object[] args) { if (methodName.equals("getStringValue")) { return defaultValue; } return null; } public Object nullPropertyValue(Map context, Object target, Object property) { Object result = null; if (property.equals("stringValue")) { return defaultValue; } return null; } } ognl-2.7.3.orig/src/test/java/org/ognl/test/ObjectIndexedPropertyTest.java0000644000175000017500000001277710601313711026477 0ustar drazzibdrazzib// -------------------------------------------------------------------------- // Copyright (c) 2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. // -------------------------------------------------------------------------- package org.ognl.test; import junit.framework.TestSuite; import ognl.OgnlException; import org.ognl.test.objects.Bean1; import org.ognl.test.objects.ObjectIndexed; public class ObjectIndexedPropertyTest extends OgnlTestCase { private static ObjectIndexed OBJECT_INDEXED = new ObjectIndexed(); private static Bean1 root = new Bean1(); private static Object[][] TESTS = { // Arbitrary indexed properties {OBJECT_INDEXED, "attributes[\"bar\"]", "baz"}, // get non-indexed property through // attributes Map {OBJECT_INDEXED, "attribute[\"foo\"]", "bar"}, // get indexed property {OBJECT_INDEXED, "attribute[\"bar\"]", "baz", "newValue", "newValue"}, // set // indexed // property {OBJECT_INDEXED, "attribute[\"bar\"]", "newValue"},// get indexed property back to // confirm {OBJECT_INDEXED, "attributes[\"bar\"]", "newValue"}, // get property back through Map // to confirm {OBJECT_INDEXED, "attribute[\"other\"].attribute[\"bar\"]", "baz"}, // get indexed // property from // indexed, then // through other {OBJECT_INDEXED, "attribute[\"other\"].attributes[\"bar\"]", "baz"}, // get property // back through // Map to // confirm {OBJECT_INDEXED, "attribute[$]", OgnlException.class}, // illegal DynamicSubscript // access to object indexed // property {root, "bean2.bean3.indexedValue[25]", null} }; /* * =================================================================== Public static methods * =================================================================== */ public static TestSuite suite() { TestSuite result = new TestSuite(); for (int i = 0; i < TESTS.length; i++) { if (TESTS[i].length == 3) { result.addTest(new ObjectIndexedPropertyTest((String) TESTS[i][1], TESTS[i][0], (String) TESTS[i][1], TESTS[i][2])); } else { if (TESTS[i].length == 4) { result.addTest(new ObjectIndexedPropertyTest((String) TESTS[i][1], TESTS[i][0], (String) TESTS[i][1], TESTS[i][2], TESTS[i][3])); } else { if (TESTS[i].length == 5) { result.addTest(new ObjectIndexedPropertyTest((String) TESTS[i][1], TESTS[i][0], (String) TESTS[i][1], TESTS[i][2], TESTS[i][3], TESTS[i][4])); } else { throw new RuntimeException("don't understand TEST format"); } } } } return result; } /* * =================================================================== Constructors * =================================================================== */ public ObjectIndexedPropertyTest() { super(); } public ObjectIndexedPropertyTest(String name) { super(name); } public ObjectIndexedPropertyTest(String name, Object root, String expressionString, Object expectedResult, Object setValue, Object expectedAfterSetResult) { super(name, root, expressionString, expectedResult, setValue, expectedAfterSetResult); } public ObjectIndexedPropertyTest(String name, Object root, String expressionString, Object expectedResult, Object setValue) { super(name, root, expressionString, expectedResult, setValue); } public ObjectIndexedPropertyTest(String name, Object root, String expressionString, Object expectedResult) { super(name, root, expressionString, expectedResult); } } ognl-2.7.3.orig/src/test/java/org/ognl/test/PropertyArithmeticAndLogicalOperatorsTest.java0000644000175000017500000001007210704232420031661 0ustar drazzibdrazzibpackage org.ognl.test; import junit.framework.TestSuite; import org.ognl.test.objects.Root; import org.ognl.test.objects.SimpleNumeric; import org.ognl.test.objects.TestModel; import java.util.Arrays; /** * */ public class PropertyArithmeticAndLogicalOperatorsTest extends OgnlTestCase { private static Root ROOT = new Root(); private static TestModel MODEL = new TestModel(); private static SimpleNumeric NUMERIC = new SimpleNumeric(); private static Object[][] TESTS = { { ROOT, "objectIndex > 0", Boolean.TRUE}, { ROOT, "false", Boolean.FALSE}, { ROOT, "!false || true", Boolean.TRUE}, { ROOT, "property.bean3.value >= 24", Boolean.TRUE}, { ROOT, "genericIndex-1", new Integer(1)}, { ROOT, "((renderNavigation ? 0 : 1) + map.size) * theInt", new Integer(((ROOT.getRenderNavigation() ? 0 : 1 ) + ROOT.getMap().size()) * ROOT.getTheInt())}, { ROOT, "{theInt + 1}", Arrays.asList(new Integer(ROOT.getTheInt() + 1)) }, { MODEL, "(unassignedCopyModel.optionCount > 0 && canApproveCopy) || entry.copy.size() > 0", Boolean.TRUE }, { ROOT, " !(printDelivery || @Boolean@FALSE)", Boolean.FALSE}, { ROOT, "(getIndexedProperty('nested').size - 1) > genericIndex", Boolean.FALSE}, { ROOT, "(getIndexedProperty('nested').size + 1) >= genericIndex", Boolean.TRUE}, { ROOT, "(getIndexedProperty('nested').size + 1) == genericIndex", Boolean.TRUE}, { ROOT, "(getIndexedProperty('nested').size + 1) < genericIndex", Boolean.FALSE}, { ROOT, "map.size * genericIndex", new Integer(ROOT.getMap().size() * ((Integer)ROOT.getGenericIndex()).intValue())}, { ROOT, "property == property", Boolean.TRUE}, { ROOT, "property.bean3.value % 2 == 0", Boolean.TRUE}, { ROOT, "genericIndex % 3 == 0", Boolean.FALSE}, { ROOT, "genericIndex % theInt == property.bean3.value", Boolean.FALSE}, { ROOT, "theInt / 100.0", ROOT.getTheInt() / 100.0}, { ROOT, "@java.lang.Long@valueOf('100') == @java.lang.Long@valueOf('100')", Boolean.TRUE}, { NUMERIC, "budget - timeBilled", new Double(NUMERIC.getBudget() - NUMERIC.getTimeBilled())}, { NUMERIC, "(budget % tableSize) == 0", Boolean.TRUE} }; public static TestSuite suite() { TestSuite result = new TestSuite(); for (int i = 0; i < TESTS.length; i++) { if (TESTS[i].length == 5) { result.addTest(new PropertyArithmeticAndLogicalOperatorsTest((String)TESTS[i][1], TESTS[i][0], (String)TESTS[i][1], TESTS[i][2], TESTS[i][3], TESTS[i][4])); } else result.addTest(new PropertyArithmeticAndLogicalOperatorsTest((String)TESTS[i][1], TESTS[i][0], (String)TESTS[i][1], TESTS[i][2])); } return result; } /*=================================================================== Constructors ===================================================================*/ public PropertyArithmeticAndLogicalOperatorsTest() { super(); } public PropertyArithmeticAndLogicalOperatorsTest(String name) { super(name); } public PropertyArithmeticAndLogicalOperatorsTest(String name, Object root, String expressionString, Object expectedResult, Object setValue, Object expectedAfterSetResult) { super(name, root, expressionString, expectedResult, setValue, expectedAfterSetResult); } public PropertyArithmeticAndLogicalOperatorsTest(String name, Object root, String expressionString, Object expectedResult, Object setValue) { super(name, root, expressionString, expectedResult, setValue); } public PropertyArithmeticAndLogicalOperatorsTest(String name, Object root, String expressionString, Object expectedResult) { super(name, root, expressionString, expectedResult); } } ognl-2.7.3.orig/src/test/java/org/ognl/test/OperatorTest.java0000644000175000017500000001121110577301171024005 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package org.ognl.test; import junit.framework.TestSuite; public class OperatorTest extends OgnlTestCase { private static Object[][] TESTS = { {null, "\"one\" > \"two\"", Boolean.FALSE}, {null, "\"one\" >= \"two\"", Boolean.FALSE}, {null, "\"one\" < \"two\"", Boolean.TRUE}, {null, "\"one\" <= \"two\"", Boolean.TRUE}, {null, "\"one\" == \"two\"", Boolean.FALSE}, {null, "\"o\" > \"o\"", Boolean.FALSE}, {null, "\"o\" gt \"o\"", Boolean.FALSE}, {null, "\"o\" >= \"o\"", Boolean.TRUE}, {null, "\"o\" gte \"o\"", Boolean.TRUE}, {null, "\"o\" < \"o\"", Boolean.FALSE}, {null, "\"o\" lt \"o\"", Boolean.FALSE}, {null, "\"o\" <= \"o\"", Boolean.TRUE}, {null, "\"o\" lte \"o\"", Boolean.TRUE}, {null, "\"o\" == \"o\"", Boolean.TRUE}, {null, "\"o\" eq \"o\"", Boolean.TRUE}, }; /*=================================================================== Public static methods ===================================================================*/ public static TestSuite suite() { TestSuite result = new TestSuite(); for (int i = 0; i < TESTS.length; i++) { if (TESTS[i].length == 3) { result.addTest(new OperatorTest((String) TESTS[i][1], TESTS[i][0], (String) TESTS[i][1], TESTS[i][2])); } else { if (TESTS[i].length == 4) { result.addTest(new OperatorTest((String) TESTS[i][1], TESTS[i][0], (String) TESTS[i][1], TESTS[i][2], TESTS[i][3])); } else { if (TESTS[i].length == 5) { result.addTest(new OperatorTest((String) TESTS[i][1], TESTS[i][0], (String) TESTS[i][1], TESTS[i][2], TESTS[i][3], TESTS[i][4])); } else { throw new RuntimeException("don't understand TEST format"); } } } } return result; } /*=================================================================== Constructors ===================================================================*/ public OperatorTest() { super(); } public OperatorTest(String name) { super(name); } public OperatorTest(String name, Object root, String expressionString, Object expectedResult, Object setValue, Object expectedAfterSetResult) { super(name, root, expressionString, expectedResult, setValue, expectedAfterSetResult); } public OperatorTest(String name, Object root, String expressionString, Object expectedResult, Object setValue) { super(name, root, expressionString, expectedResult, setValue); } public OperatorTest(String name, Object root, String expressionString, Object expectedResult) { super(name, root, expressionString, expectedResult); } } ognl-2.7.3.orig/src/test/java/org/ognl/test/PropertySetterTest.java0000644000175000017500000000375710754136360025250 0ustar drazzibdrazzibpackage org.ognl.test; import junit.framework.TestCase; import ognl.Node; import ognl.Ognl; import ognl.OgnlContext; import java.util.Map; /** * Tests being able to set property on object with interface that doesn't define * setter. See OGNL-115. */ public class PropertySetterTest extends TestCase { private Map map; private TestObject testObject = new TestObject("propertyValue"); private String propertyKey = "property"; public interface TestInterface { public String getProperty(); } public class TestObject implements TestInterface { private String property; private Integer integerProperty = 1; public TestObject(String property) { this.property = property; } public String getProperty() { return property; } public void setProperty(String property) { this.property = property; } public Integer getIntegerProperty() { return integerProperty; } } public Map getMap() { return map; } public String getKey() { return "key"; } public TestObject getObject() { return testObject; } public TestInterface getInterfaceObject() { return testObject; } public String getPropertyKey() { return propertyKey; } public void testEnhancedOgnl() throws Exception { OgnlContext context = (OgnlContext)Ognl.createDefaultContext(null); Node expression = Ognl.compileExpression(context, this, "interfaceObject.property"); Ognl.setValue(expression, context, this, "hello"); assertEquals("hello", getObject().getProperty() ); // Fails if an interface is defined, but succeeds if not context.clear(); expression = Ognl.compileExpression(context, this.getObject(), "property"); Ognl.setValue(expression, context, this.getObject(), "hello"); assertEquals("hello", getObject().getProperty() ); } } ognl-2.7.3.orig/src/test/java/org/ognl/test/PropertyNotFoundTest.java0000644000175000017500000001323210745155540025524 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package org.ognl.test; import junit.framework.TestSuite; import ognl.OgnlContext; import ognl.OgnlException; import ognl.OgnlRuntime; import ognl.PropertyAccessor; import java.util.Map; public class PropertyNotFoundTest extends OgnlTestCase { private static final Blah BLAH = new Blah(); private static Object[][] TESTS = { {BLAH, "webwork.token.name", OgnlException.class, "W value", OgnlException.class}, }; /*=================================================================== Public static classes ===================================================================*/ public static class Blah { String x; String y; public String getX() { return x; } public void setX(String x) { this.x = x; } public String getY() { return y; } public void setY(String y) { this.y = y; } } public static class BlahPropertyAccessor implements PropertyAccessor { public void setProperty(Map context, Object target, Object name, Object value) throws OgnlException { } public Object getProperty(Map context, Object target, Object name) throws OgnlException { if ("x".equals(name) || "y".equals(name)) { return OgnlRuntime.getProperty((OgnlContext) context, target, name); } return null; } public String getSourceAccessor(OgnlContext context, Object target, Object index) { return index.toString(); } public String getSourceSetter(OgnlContext context, Object target, Object index) { return index.toString(); } } /*=================================================================== Public static methods ===================================================================*/ public static TestSuite suite() { TestSuite result = new TestSuite(); for (int i = 0; i < TESTS.length; i++) { if (TESTS[i].length == 3) { result.addTest(new PropertyNotFoundTest((String) TESTS[i][1], TESTS[i][0], (String) TESTS[i][1], TESTS[i][2])); } else { if (TESTS[i].length == 4) { result.addTest(new PropertyNotFoundTest((String) TESTS[i][1], TESTS[i][0], (String) TESTS[i][1], TESTS[i][2], TESTS[i][3])); } else { if (TESTS[i].length == 5) { result.addTest(new PropertyNotFoundTest((String) TESTS[i][1], TESTS[i][0], (String) TESTS[i][1], TESTS[i][2], TESTS[i][3], TESTS[i][4])); } else { throw new RuntimeException("don't understand TEST format"); } } } } return result; } /*=================================================================== Constructors ===================================================================*/ public PropertyNotFoundTest() { super(); } public PropertyNotFoundTest(String name) { super(name); } public PropertyNotFoundTest(String name, Object root, String expressionString, Object expectedResult, Object setValue, Object expectedAfterSetResult) { super(name, root, expressionString, expectedResult, setValue, expectedAfterSetResult); } public PropertyNotFoundTest(String name, Object root, String expressionString, Object expectedResult, Object setValue) { super(name, root, expressionString, expectedResult, setValue); } public PropertyNotFoundTest(String name, Object root, String expressionString, Object expectedResult) { super(name, root, expressionString, expectedResult); } protected void setUp() { super.setUp(); OgnlRuntime.setPropertyAccessor(Blah.class, new BlahPropertyAccessor()); } } ognl-2.7.3.orig/src/test/java/org/ognl/test/ProtectedInnerClassTest.java0000644000175000017500000000717210566476144026153 0ustar drazzibdrazzib// -------------------------------------------------------------------------- // Copyright (c) 2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. // -------------------------------------------------------------------------- package org.ognl.test; import junit.framework.TestSuite; import org.ognl.test.objects.Root; public class ProtectedInnerClassTest extends OgnlTestCase { private static Root ROOT = new Root(); private static Object[][] TESTS = { // member access of inner class (Arrays.asList() returned protected inner class) { ROOT, "list.size()", new Integer(ROOT.getList().size()) }, { ROOT, "list[0]", ROOT.getList().get(0) }, }; /* * =================================================================== Public static methods * =================================================================== */ public static TestSuite suite() { TestSuite result = new TestSuite(); for(int i = 0; i < TESTS.length; i++) { result.addTest(new ProtectedInnerClassTest((String) TESTS[i][1], TESTS[i][0], (String) TESTS[i][1], TESTS[i][2])); } return result; } /* * =================================================================== Constructors * =================================================================== */ public ProtectedInnerClassTest() { super(); } public ProtectedInnerClassTest(String name) { super(name); } public ProtectedInnerClassTest(String name, Object root, String expressionString, Object expectedResult, Object setValue, Object expectedAfterSetResult) { super(name, root, expressionString, expectedResult, setValue, expectedAfterSetResult); } public ProtectedInnerClassTest(String name, Object root, String expressionString, Object expectedResult, Object setValue) { super(name, root, expressionString, expectedResult, setValue); } public ProtectedInnerClassTest(String name, Object root, String expressionString, Object expectedResult) { super(name, root, expressionString, expectedResult); } } ognl-2.7.3.orig/src/test/java/org/ognl/test/NestedMethodTest.java0000644000175000017500000001062710566476144024622 0ustar drazzibdrazzib// -------------------------------------------------------------------------- // Copyright (c) 2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. // -------------------------------------------------------------------------- package org.ognl.test; import junit.framework.TestSuite; import org.ognl.test.objects.Component; public class NestedMethodTest extends OgnlTestCase { private static Component COMPONENT = new Component(); private static Object[][] TESTS = { // Expression in a method call argument { COMPONENT, "toDisplay.pictureUrl", COMPONENT.getToDisplay().getPictureUrl() }, { COMPONENT, "page.createRelativeAsset(toDisplay.pictureUrl)", COMPONENT.getPage().createRelativeAsset(COMPONENT.getToDisplay().getPictureUrl()) }, }; /* * =================================================================== Public static methods * =================================================================== */ public static TestSuite suite() { TestSuite result = new TestSuite(); for(int i = 0; i < TESTS.length; i++) { if (TESTS[i].length == 3) { result.addTest(new NestedMethodTest((String) TESTS[i][1], TESTS[i][0], (String) TESTS[i][1], TESTS[i][2])); } else { if (TESTS[i].length == 4) { result.addTest(new NestedMethodTest((String) TESTS[i][1], TESTS[i][0], (String) TESTS[i][1], TESTS[i][2], TESTS[i][3])); } else { if (TESTS[i].length == 5) { result.addTest(new NestedMethodTest((String) TESTS[i][1], TESTS[i][0], (String) TESTS[i][1], TESTS[i][2], TESTS[i][3], TESTS[i][4])); } else { throw new RuntimeException("don't understand TEST format"); } } } } return result; } /* * =================================================================== Constructors * =================================================================== */ public NestedMethodTest() { super(); } public NestedMethodTest(String name) { super(name); } public NestedMethodTest(String name, Object root, String expressionString, Object expectedResult, Object setValue, Object expectedAfterSetResult) { super(name, root, expressionString, expectedResult, setValue, expectedAfterSetResult); } public NestedMethodTest(String name, Object root, String expressionString, Object expectedResult, Object setValue) { super(name, root, expressionString, expectedResult, setValue); } public NestedMethodTest(String name, Object root, String expressionString, Object expectedResult) { super(name, root, expressionString, expectedResult); } } ognl-2.7.3.orig/src/test/java/org/ognl/test/QuotingTest.java0000644000175000017500000001023410640044053023636 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package org.ognl.test; import junit.framework.TestSuite; public class QuotingTest extends OgnlTestCase { private static Object[][] TESTS = { // Quoting { null, "`c`", new Character('c') }, { null, "'s'", new Character('s') }, { null, "'string'", "string" }, { null, "\"string\"", "string" }, { null, "'' + 'bar'", "bar"}, { null, "'yyyy年MM月dd日'", "yyyy年MM月dd日"} }; /*=================================================================== Public static methods ===================================================================*/ public static TestSuite suite() { TestSuite result = new TestSuite(); for (int i = 0; i < TESTS.length; i++) { if (TESTS[i].length == 3) { result.addTest(new QuotingTest((String)TESTS[i][1], TESTS[i][0], (String)TESTS[i][1], TESTS[i][2])); } else { if (TESTS[i].length == 4) { result.addTest(new QuotingTest((String)TESTS[i][1], TESTS[i][0], (String)TESTS[i][1], TESTS[i][2], TESTS[i][3])); } else { if (TESTS[i].length == 5) { result.addTest(new QuotingTest((String)TESTS[i][1], TESTS[i][0], (String)TESTS[i][1], TESTS[i][2], TESTS[i][3], TESTS[i][4])); } else { throw new RuntimeException("don't understand TEST format"); } } } } return result; } /*=================================================================== Constructors ===================================================================*/ public QuotingTest() { super(); } public QuotingTest(String name) { super(name); } public QuotingTest(String name, Object root, String expressionString, Object expectedResult, Object setValue, Object expectedAfterSetResult) { super(name, root, expressionString, expectedResult, setValue, expectedAfterSetResult); } public QuotingTest(String name, Object root, String expressionString, Object expectedResult, Object setValue) { super(name, root, expressionString, expectedResult, setValue); } public QuotingTest(String name, Object root, String expressionString, Object expectedResult) { super(name, root, expressionString, expectedResult); } } ognl-2.7.3.orig/src/test/java/org/ognl/test/PrivateMemberTest.java0000644000175000017500000000701110566476144024772 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package org.ognl.test; import junit.framework.TestCase; import junit.framework.TestSuite; import ognl.DefaultMemberAccess; import ognl.Ognl; import ognl.OgnlContext; import ognl.OgnlException; /** * This is a test program for private access in OGNL. * shows the failures and a summary. */ public class PrivateMemberTest extends TestCase { private String _privateProperty = "private value"; protected OgnlContext context; /*=================================================================== Public static methods ===================================================================*/ public static TestSuite suite() { return new TestSuite(PrivateMemberTest.class); } /*=================================================================== Constructors ===================================================================*/ public PrivateMemberTest(String name) { super(name); } /*=================================================================== Public methods ===================================================================*/ private String getPrivateProperty() { return _privateProperty; } public void testPrivateAccessor() throws OgnlException { assertEquals(Ognl.getValue("privateProperty", context, this), getPrivateProperty()); } public void testPrivateField() throws OgnlException { assertEquals(Ognl.getValue("_privateProperty", context, this), _privateProperty); } /*=================================================================== Overridden methods ===================================================================*/ public void setUp() { context = (OgnlContext)Ognl.createDefaultContext(null); context.setMemberAccess(new DefaultMemberAccess(true)); } } ognl-2.7.3.orig/src/test/java/org/ognl/test/OgnlTestCase.java0000644000175000017500000002050310723604233023707 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package org.ognl.test; import junit.framework.TestCase; import ognl.Ognl; import ognl.OgnlContext; import ognl.SimpleNode; import java.io.PrintWriter; import java.io.StringWriter; import java.lang.reflect.Array; public class OgnlTestCase extends TestCase { protected OgnlContext _context; private String _expressionString; private SimpleNode _expression; private Object _expectedResult; private Object _root; protected boolean _compileExpressions = true; private boolean hasSetValue; private Object setValue; private boolean hasExpectedAfterSetResult; private Object expectedAfterSetResult; /*=================================================================== Public static methods ===================================================================*/ /** * Returns true if object1 is equal to object2 in either the * sense that they are the same object or, if both are non-null * if they are equal in the equals() sense. */ public static boolean isEqual(Object object1, Object object2) { boolean result = false; if (object1 == object2) { result = true; } else { if ((object1 != null) && object1.getClass().isArray()) { if ((object2 != null) && object2.getClass().isArray() && (object2.getClass() == object1.getClass())) { result = (Array.getLength(object1) == Array.getLength(object2)); if (result) { for (int i = 0, icount = Array.getLength(object1); result && (i < icount); i++) { result = isEqual(Array.get(object1, i), Array.get(object2, i)); } } } } else { result = (object1 != null) && (object2 != null) && object1.equals(object2); } } return result; } /*=================================================================== Constructors ===================================================================*/ public OgnlTestCase() { super(); } public OgnlTestCase(String name) { super(name); } public OgnlTestCase(String name, Object root, String expressionString, Object expectedResult, Object setValue, Object expectedAfterSetResult) { this(name, root, expressionString, expectedResult, setValue); this.hasExpectedAfterSetResult = true; this.expectedAfterSetResult = expectedAfterSetResult; } public OgnlTestCase(String name, Object root, String expressionString, Object expectedResult, Object setValue) { this(name, root, expressionString, expectedResult); this.hasSetValue = true; this.setValue = setValue; } public OgnlTestCase(String name, Object root, String expressionString, Object expectedResult) { this(name); this._root = root; this._expressionString = expressionString; this._expectedResult = expectedResult; } /*=================================================================== Public methods ===================================================================*/ public String getExpressionDump(SimpleNode node) { StringWriter writer = new StringWriter(); node.dump(new PrintWriter(writer), " "); return writer.toString(); } public String getExpressionString() { return _expressionString; } public SimpleNode getExpression() throws Exception { if (_expression == null) { _expression = (SimpleNode) Ognl.parseExpression(_expressionString); } if (_compileExpressions) { _expression = (SimpleNode) Ognl.compileExpression(_context, _root, _expressionString); } return _expression; } public Object getExpectedResult() { return _expectedResult; } public static void assertEquals(Object expected, Object actual) { if (expected != null && expected.getClass().isArray() && actual != null && actual.getClass().isArray()) { TestCase.assertEquals(Array.getLength(expected), Array.getLength(actual)); int length = Array.getLength(expected); for (int i = 0; i < length; i++) { Object aexpected = Array.get(expected, i); Object aactual = Array.get(actual, i); if (aexpected != null && aactual != null && Boolean.class.isAssignableFrom(aexpected.getClass())) { TestCase.assertEquals(aexpected.toString(), aactual.toString()); } else OgnlTestCase.assertEquals(aexpected, aactual); } } else if (expected != null && actual != null && Character.class.isInstance(expected) && Character.class.isInstance(actual)) { TestCase.assertEquals(((Character) expected).charValue(), ((Character) actual).charValue()); } else { TestCase.assertEquals(expected, actual); } } /*=================================================================== Overridden methods ===================================================================*/ protected void runTest() throws Exception { Object testedResult = null; try { SimpleNode expr; testedResult = _expectedResult; expr = getExpression(); assertEquals(_expectedResult, Ognl.getValue(expr, _context, _root)); if (hasSetValue) { testedResult = hasExpectedAfterSetResult ? expectedAfterSetResult : setValue; Ognl.setValue(expr, _context, _root, setValue); assertEquals(testedResult, Ognl.getValue(expr, _context, _root)); } } catch (Exception ex) { System.out.println("Caught exception " + ex); if (NullPointerException.class.isInstance(ex)) ex.printStackTrace(); if (RuntimeException.class.isInstance(ex) && ((RuntimeException) ex).getCause() != null && Exception.class.isAssignableFrom(((RuntimeException) ex).getCause().getClass())) ex = (Exception) ((RuntimeException) ex).getCause(); if (testedResult instanceof Class) { assertTrue(Exception.class.isAssignableFrom((Class) testedResult)); } else throw ex; } } protected void setUp() { _context = (OgnlContext) Ognl.createDefaultContext(null); } } ognl-2.7.3.orig/src/test/java/org/ognl/test/PrimitiveArrayTest.java0000644000175000017500000001163410600650435025167 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package org.ognl.test; import junit.framework.TestSuite; import org.ognl.test.objects.Root; public class PrimitiveArrayTest extends OgnlTestCase { private static Root ROOT = new Root(); private static Object[][] TESTS = { // Primitive array creation {ROOT, "new boolean[5]", new boolean[5]}, {ROOT, "new boolean[] { true, false }", new boolean[]{true, false}}, {ROOT, "new boolean[] { 0, 1, 5.5 }", new boolean[]{false, true, true}}, {ROOT, "new char[] { 'a', 'b' }", new char[]{'a', 'b'}}, {ROOT, "new char[] { 10, 11 }", new char[]{(char) 10, (char) 11}}, {ROOT, "new byte[] { 1, 2 }", new byte[]{1, 2}}, {ROOT, "new short[] { 1, 2 }", new short[]{1, 2}}, {ROOT, "new int[six]", new int[ROOT.six]}, {ROOT, "new int[#root.six]", new int[ROOT.six]}, {ROOT, "new int[6]", new int[6]}, {ROOT, "new int[] { 1, 2 }", new int[]{1, 2}}, {ROOT, "new long[] { 1, 2 }", new long[]{1, 2}}, {ROOT, "new float[] { 1, 2 }", new float[]{1, 2}}, {ROOT, "new double[] { 1, 2 }", new double[]{1, 2}}, }; /*=================================================================== Public static methods ===================================================================*/ public static TestSuite suite() { TestSuite result = new TestSuite(); for (int i = 0; i < TESTS.length; i++) { if (TESTS[i].length == 3) { result.addTest(new PrimitiveArrayTest((String) TESTS[i][1], TESTS[i][0], (String) TESTS[i][1], TESTS[i][2])); } else { if (TESTS[i].length == 4) { result.addTest(new PrimitiveArrayTest((String) TESTS[i][1], TESTS[i][0], (String) TESTS[i][1], TESTS[i][2], TESTS[i][3])); } else { if (TESTS[i].length == 5) { result.addTest(new PrimitiveArrayTest((String) TESTS[i][1], TESTS[i][0], (String) TESTS[i][1], TESTS[i][2], TESTS[i][3], TESTS[i][4])); } else { throw new RuntimeException("don't understand TEST format"); } } } } return result; } /*=================================================================== Constructors ===================================================================*/ public PrimitiveArrayTest() { super(); } public PrimitiveArrayTest(String name) { super(name); } public PrimitiveArrayTest(String name, Object root, String expressionString, Object expectedResult, Object setValue, Object expectedAfterSetResult) { super(name, root, expressionString, expectedResult, setValue, expectedAfterSetResult); } public PrimitiveArrayTest(String name, Object root, String expressionString, Object expectedResult, Object setValue) { super(name, root, expressionString, expectedResult, setValue); } public PrimitiveArrayTest(String name, Object root, String expressionString, Object expectedResult) { super(name, root, expressionString, expectedResult); } } ognl-2.7.3.orig/src/test/java/org/ognl/test/GenericsTest.java0000644000175000017500000000276610720370235023765 0ustar drazzibdrazzibpackage org.ognl.test; import junit.framework.TestSuite; import org.ognl.test.objects.BaseGeneric; import org.ognl.test.objects.GameGeneric; import org.ognl.test.objects.GameGenericObject; import org.ognl.test.objects.GenericRoot; /** * Tests java >= 1.5 generics support in ognl. */ public class GenericsTest extends OgnlTestCase { static GenericRoot ROOT = new GenericRoot(); static BaseGeneric GENERIC = new GameGeneric(); static Object[][] TESTS = { /* { ROOT, "cracker.param", null, new Integer(2), new Integer(2)}, */ { GENERIC, "ids", null, new Long[] {1l, 101l}, new Long[] {1l, 101l}}, /* { GENERIC, "ids", new Long[] {1l, 101l}, new String[] {"2", "34"}, new Long[]{2l, 34l}}, */ }; public static TestSuite suite() { TestSuite result = new TestSuite(); for(int i = 0; i < TESTS.length; i++) { if (TESTS[i].length == 5) { result.addTest(new GenericsTest((String) TESTS[i][1] + " (" + TESTS[i][2] + ")", TESTS[i][0], (String) TESTS[i][1], TESTS[i][2], TESTS[i][3], TESTS[i][4])); } } return result; } public GenericsTest(String name, Object root, String expressionString, Object expectedResult, Object setValue, Object expectedAfterSetResult) { super(name, root, expressionString, expectedResult, setValue, expectedAfterSetResult); } } ognl-2.7.3.orig/src/test/java/org/ognl/test/StaticsAndConstructorsTest.java0000644000175000017500000001564510776755160026733 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package org.ognl.test; import junit.framework.TestSuite; import org.ognl.test.objects.Root; import org.ognl.test.objects.Simple; public class StaticsAndConstructorsTest extends OgnlTestCase { private static Root ROOT = new Root(); private static Object[][] TESTS = { { "@java.lang.Class@forName(\"java.lang.Object\")", Object.class }, { "@java.lang.Integer@MAX_VALUE", new Integer(Integer.MAX_VALUE) }, { "@@max(3,4)", new Integer(4) }, { "new java.lang.StringBuffer().append(55).toString()", "55" }, { "class", ROOT.getClass() }, { "@org.ognl.test.objects.Root@class", ROOT.getClass() }, { "class.getName()", ROOT.getClass().getName() }, { "@org.ognl.test.objects.Root@class.getName()", ROOT.getClass().getName() }, { "@org.ognl.test.objects.Root@class.name", ROOT.getClass().getName() }, { "class.getSuperclass()", ROOT.getClass().getSuperclass() }, { "class.superclass", ROOT.getClass().getSuperclass() }, { "class.name", ROOT.getClass().getName() }, { "getStaticInt()", new Integer(Root.getStaticInt()) }, { "@org.ognl.test.objects.Root@getStaticInt()", new Integer(Root.getStaticInt()) }, { "new org.ognl.test.objects.Simple(property).getStringValue()", new Simple().getStringValue() }, { "new org.ognl.test.objects.Simple(map['test'].property).getStringValue()", new Simple().getStringValue() }, { "map.test.getCurrentClass(@org.ognl.test.StaticsAndConstructorsTest@KEY.toString())", "size stop"}, { "new org.ognl.test.StaticsAndConstructorsTest$IntWrapper(index)", new IntWrapper(ROOT.getIndex()) }, { "new org.ognl.test.StaticsAndConstructorsTest$IntObjectWrapper(index)", new IntObjectWrapper(ROOT.getIndex()) }, { "new org.ognl.test.StaticsAndConstructorsTest$A(#root)", new A(ROOT)}, {"@org.ognl.test.StaticsAndConstructorsTest$Animals@values().length != 2", Boolean.TRUE}, {"isOk(@org.ognl.test.objects.SimpleEnum@ONE, null)", Boolean.TRUE}, }; public static final String KEY = "size"; public static class IntWrapper { public IntWrapper(int value) { this.value = value; } private final int value; public String toString() { return Integer.toString(value); } public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; IntWrapper that = (IntWrapper) o; return value == that.value; } } public static class IntObjectWrapper { public IntObjectWrapper(Integer value) { this.value = value; } private final Integer value; public String toString() { return value.toString(); } public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; IntObjectWrapper that = (IntObjectWrapper) o; return value.equals(that.value); } } public static class A { String key = "A"; public A(Root root) { } public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; A a = (A) o; if (key != null ? !key.equals(a.key) : a.key != null) return false; return true; } } public enum Animals { Dog, Cat, Wallabee, Bear } /*=================================================================== Public static methods ===================================================================*/ public static TestSuite suite() { TestSuite result = new TestSuite(); for (int i = 0; i < TESTS.length; i++) { result.addTest(new StaticsAndConstructorsTest((String)TESTS[i][0] + " (" + TESTS[i][1] + ")", ROOT, (String)TESTS[i][0], TESTS[i][1])); } return result; } /*=================================================================== Constructors ===================================================================*/ public StaticsAndConstructorsTest() { super(); } public StaticsAndConstructorsTest(String name) { super(name); } public StaticsAndConstructorsTest(String name, Object root, String expressionString, Object expectedResult, Object setValue, Object expectedAfterSetResult) { super(name, root, expressionString, expectedResult, setValue, expectedAfterSetResult); } public StaticsAndConstructorsTest(String name, Object root, String expressionString, Object expectedResult, Object setValue) { super(name, root, expressionString, expectedResult, setValue); } public StaticsAndConstructorsTest(String name, Object root, String expressionString, Object expectedResult) { super(name, root, expressionString, expectedResult); } } ognl-2.7.3.orig/src/test/java/org/ognl/test/ASTMethodTest.java0000644000175000017500000000451710713163323024012 0ustar drazzibdrazzibpackage org.ognl.test; import junit.framework.TestCase; import ognl.*; import ognl.enhance.ExpressionCompiler; import org.ognl.test.objects.Bean2; import org.ognl.test.objects.Bean3; import org.ognl.test.objects.Root; import java.util.Map; /** * Tests {@link ognl.ASTMethod}. */ public class ASTMethodTest extends TestCase { public void test_Context_Types() throws Throwable { ASTMethod p = new ASTMethod(0); p.setMethodName("get"); ASTConst pRef = new ASTConst(0); pRef.setValue("value"); p.jjtAddChild(pRef, 0); Root root = new Root(); OgnlContext context = (OgnlContext) Ognl.createDefaultContext(null); context.setRoot(root.getMap()); context.setCurrentObject(root.getMap()); context.setCurrentType(root.getMap().getClass()); assertEquals(p.toGetSourceString(context, root.getMap()), ".get(\"value\")"); assertEquals(context.getCurrentType(), Object.class); assertEquals(root.getMap().get("value"), context.getCurrentObject()); assert Map.class.isAssignableFrom(context.getCurrentAccessor()); assert Map.class.isAssignableFrom(context.getPreviousType()); assert context.getPreviousAccessor() == null; assertEquals(OgnlRuntime.getCompiler().castExpression(context, p, ".get(\"value\")"), ".get(\"value\")"); assert context.get(ExpressionCompiler.PRE_CAST) == null; // now test one context level further to see casting work properly on base object types ASTProperty prop = new ASTProperty(0); ASTConst propRef = new ASTConst(0); propRef.setValue("bean3"); prop.jjtAddChild(propRef, 0); Bean2 val = (Bean2)root.getMap().get("value"); assertEquals(prop.toGetSourceString(context, root.getMap().get("value")), ".getBean3()"); assertEquals(context.getCurrentObject(), val.getBean3()); assertEquals(context.getCurrentType(), Bean3.class); assertEquals(context.getCurrentAccessor(), Bean2.class); assertEquals(Object.class, context.getPreviousType()); assert Map.class.isAssignableFrom(context.getPreviousAccessor()); assertEquals(OgnlRuntime.getCompiler().castExpression(context, prop, ".getBean3()"), ").getBean3()"); } } ognl-2.7.3.orig/src/test/java/org/ognl/test/InheritedMethodsTest.java0000644000175000017500000000212510566476144025470 0ustar drazzibdrazzib/** * */ package org.ognl.test; import junit.framework.TestCase; import ognl.Node; import ognl.Ognl; import ognl.OgnlContext; import org.ognl.test.objects.BaseBean; import org.ognl.test.objects.FirstBean; import org.ognl.test.objects.Root; import org.ognl.test.objects.SecondBean; /** * Tests functionality of casting inherited method expressions. * */ public class InheritedMethodsTest extends TestCase { private static Root ROOT = new Root(); public void test_Base_Inheritance() throws Exception { OgnlContext context = (OgnlContext)Ognl.createDefaultContext(null); String expression = "map.bean.name"; BaseBean first = new FirstBean(); BaseBean second = new SecondBean(); ROOT.getMap().put("bean", first); Node node = Ognl.compileExpression(context, ROOT, expression); assertEquals(first.getName(), node.getAccessor().get(context, ROOT)); ROOT.getMap().put("bean", second); assertEquals(second.getName(), node.getAccessor().get(context, ROOT)); } } ognl-2.7.3.orig/src/test/java/org/ognl/test/ProjectionSelectionTest.java0000644000175000017500000001033710566476144026217 0ustar drazzibdrazzib// -------------------------------------------------------------------------- // Copyright (c) 2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. // -------------------------------------------------------------------------- package org.ognl.test; import junit.framework.TestSuite; import org.ognl.test.objects.Root; import java.math.BigInteger; import java.util.Arrays; public class ProjectionSelectionTest extends OgnlTestCase { private static Root ROOT = new Root(); private static Object[][] TESTS = { // Projection, selection { ROOT, "array.{class}", Arrays.asList(new Class[] { Integer.class, Integer.class, Integer.class, Integer.class }) }, { ROOT, "map.array.{? #this > 2 }", Arrays.asList(new Integer[] { new Integer(3), new Integer(4) }) }, { ROOT, "map.array.{^ #this > 2 }", Arrays.asList(new Integer[] { new Integer(3) }) }, { ROOT, "map.array.{$ #this > 2 }", Arrays.asList(new Integer[] { new Integer(4) }) }, { ROOT, "map.array[*].{?true} instanceof java.util.Collection", Boolean.TRUE }, { null, "#fact=1, 30H.{? #fact = #fact * (#this+1), false }, #fact", new BigInteger("265252859812191058636308480000000") }, }; /* * =================================================================== Public static methods * =================================================================== */ public static TestSuite suite() { TestSuite result = new TestSuite(); for(int i = 0; i < TESTS.length; i++) { result.addTest(new ProjectionSelectionTest((String) TESTS[i][1], TESTS[i][0], (String) TESTS[i][1], TESTS[i][2])); } return result; } /* * =================================================================== Constructors * =================================================================== */ public ProjectionSelectionTest() { super(); } public ProjectionSelectionTest(String name) { super(name); } public ProjectionSelectionTest(String name, Object root, String expressionString, Object expectedResult, Object setValue, Object expectedAfterSetResult) { super(name, root, expressionString, expectedResult, setValue, expectedAfterSetResult); } public ProjectionSelectionTest(String name, Object root, String expressionString, Object expectedResult, Object setValue) { super(name, root, expressionString, expectedResult, setValue); } public ProjectionSelectionTest(String name, Object root, String expressionString, Object expectedResult) { super(name, root, expressionString, expectedResult); } } ognl-2.7.3.orig/src/test/java/org/ognl/test/ArithmeticAndLogicalOperatorsTest.java0000644000175000017500000002201610634650771030134 0ustar drazzibdrazzib// -------------------------------------------------------------------------- // Copyright (c) 2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. // -------------------------------------------------------------------------- package org.ognl.test; import junit.framework.TestSuite; import java.math.BigDecimal; public class ArithmeticAndLogicalOperatorsTest extends OgnlTestCase { private static Object[][] TESTS = { // Double-valued arithmetic expressions { "-1d", new Double(-1) }, { "+1d", new Double(1) }, { "--1f", new Double(1) }, { "2*2.0", new Double(4.0) }, { "5/2.", new Double(2.5) }, { "5+2D", new Double(7) }, { "5f-2F", new Double(3.0) }, { "5.+2*3", new Double(11) }, { "(5.+2)*3", new Double(21) }, // BigDecimal-valued arithmetic expressions { "-1b", new Integer(-1) }, { "+1b", new Integer(1) }, { "--1b", new Integer(1) }, { "2*2.0b", new Double(4.0) }, { "5/2.B", new Integer(2) }, { "5.0B/2", new Double(2.5) }, { "5+2b", new Integer(7) }, { "5-2B", new Integer(3) }, { "5.+2b*3", new Double(11) }, { "(5.+2b)*3", new Double(21) }, // Integer-valued arithmetic expressions { "-1", new Integer(-1) }, { "+1", new Integer(1) }, { "--1", new Integer(1) }, { "2*2", new Integer(4) }, { "5/2", new Integer(2) }, { "5+2", new Integer(7) }, { "5-2", new Integer(3) }, { "5+2*3", new Integer(11) }, { "(5+2)*3", new Integer(21) }, { "~1", new Integer(~1) }, { "5%2", new Integer(1) }, { "5<<2", new Integer(20) }, { "5>>2", new Integer(1) }, { "5>>1+1", new Integer(1) }, { "-5>>>2", new Integer(-5 >>> 2)}, { "-5L>>>2", new Long(-5L >>> 2) }, { "5. & 3", new Long(1) }, { "5 ^3", new Integer(6) }, { "5l&3|5^3", new Long(7) }, { "5&(3|5^3)", new Long(5) }, { "true ? 1 : 1/0", new Integer(1) }, // BigInteger-valued arithmetic expressions { "-1h", Integer.valueOf(-1) }, { "+1H", Integer.valueOf(1) }, { "--1h", Integer.valueOf(1) }, { "2h*2", Integer.valueOf(4) }, { "5/2h", Integer.valueOf(2) }, { "5h+2", Integer.valueOf(7) }, { "5-2h", Integer.valueOf(3) }, { "5+2H*3", Integer.valueOf(11) }, { "(5+2H)*3", Integer.valueOf(21) }, { "~1h", Integer.valueOf(~1) }, { "5h%2", Integer.valueOf(1) }, { "5h<<2", Integer.valueOf(20) }, { "5h>>2", Integer.valueOf(1) }, { "5h>>1+1", Integer.valueOf(1) }, { "-5h>>>2", Integer.valueOf(-2) }, { "5.b & 3", new Long(1) }, { "5h ^3", Integer.valueOf(6) }, { "5h&3|5^3", new Long(7) }, { "5H&(3|5^3)", new Long(5) }, // Logical expressions { "!1", Boolean.FALSE }, { "!null", Boolean.TRUE }, { "5<2", Boolean.FALSE }, { "5>2", Boolean.TRUE }, { "5<=5", Boolean.TRUE }, { "5>=3", Boolean.TRUE }, { "5<-5>>>2", Boolean.TRUE }, { "5==5.0", Boolean.TRUE }, { "5!=5.0", Boolean.FALSE }, { "null in {true,false,null}", Boolean.TRUE }, { "null not in {true,false,null}", Boolean.FALSE }, { "null in {true,false,null}.toArray()", Boolean.TRUE }, { "5 in {true,false,null}", Boolean.FALSE }, { "5 not in {true,false,null}", Boolean.TRUE }, { "5 instanceof java.lang.Integer", Boolean.TRUE }, { "5. instanceof java.lang.Integer", Boolean.FALSE }, { "!false || true", Boolean.TRUE}, { "!(true && true)", Boolean.FALSE}, { "(1 > 0 && true) || 2 > 0", Boolean.TRUE}, // Logical expressions (string versions) { "2 or 0", Integer.valueOf(2)}, { "1 and 0", Integer.valueOf(0) }, { "1 bor 0", new Integer(1) }, { "true && 12", Integer.valueOf(12)}, { "1 xor 0", new Integer(1) }, { "1 band 0", new Long(0) }, { "1 eq 1", Boolean.TRUE }, { "1 neq 1", Boolean.FALSE }, { "1 lt 5", Boolean.TRUE }, { "1 lte 5", Boolean.TRUE }, { "1 gt 5", Boolean.FALSE }, { "1 gte 5", Boolean.FALSE }, { "1 lt 5", Boolean.TRUE }, { "1 shl 2", new Integer(4) }, { "4 shr 2", new Integer(1) }, { "4 ushr 2", new Integer(1) }, { "not null", Boolean.TRUE }, { "not 1", Boolean.FALSE }, { "#x > 0", Boolean.TRUE }, { "#x < 0", Boolean.FALSE }, { "#x == 0", Boolean.FALSE }, { "#x == 1", Boolean.TRUE }, { "0 > #x", Boolean.FALSE }, { "0 < #x", Boolean.TRUE }, { "0 == #x", Boolean.FALSE }, { "1 == #x", Boolean.TRUE }, { "\"1\" > 0", Boolean.TRUE }, { "\"1\" < 0", Boolean.FALSE }, { "\"1\" == 0", Boolean.FALSE }, { "\"1\" == 1", Boolean.TRUE }, { "0 > \"1\"", Boolean.FALSE }, { "0 < \"1\"", Boolean.TRUE }, { "0 == \"1\"", Boolean.FALSE }, { "1 == \"1\"", Boolean.TRUE }, { "#x + 1", "11" }, { "1 + #x", "11" }, { "#y == 1", Boolean.TRUE }, { "#y == \"1\"", Boolean.TRUE }, { "#y + \"1\"", "11" }, { "\"1\" + #y", "11" } }; /* * =================================================================== Public static methods * =================================================================== */ public static TestSuite suite() { TestSuite result = new TestSuite(); for(int i = 0; i < TESTS.length; i++) { result.addTest(new ArithmeticAndLogicalOperatorsTest((String) TESTS[i][0] + " (" + TESTS[i][1] + ")", null, (String) TESTS[i][0], TESTS[i][1])); } return result; } /* * =================================================================== Constructors * =================================================================== */ public ArithmeticAndLogicalOperatorsTest() { super(); } public ArithmeticAndLogicalOperatorsTest(String name) { super(name); } public ArithmeticAndLogicalOperatorsTest(String name, Object root, String expressionString, Object expectedResult, Object setValue, Object expectedAfterSetResult) { super(name, root, expressionString, expectedResult, setValue, expectedAfterSetResult); } public ArithmeticAndLogicalOperatorsTest(String name, Object root, String expressionString, Object expectedResult, Object setValue) { super(name, root, expressionString, expectedResult, setValue); } public ArithmeticAndLogicalOperatorsTest(String name, Object root, String expressionString, Object expectedResult) { super(name, root, expressionString, expectedResult); } /* * =================================================================== Overridden methods * =================================================================== */ protected void setUp() { super.setUp(); _context.put("x", "1"); _context.put("y", new BigDecimal(1)); } } ognl-2.7.3.orig/src/test/java/org/ognl/test/PrivateAccessorTest.java0000644000175000017500000001223310566476144025327 0ustar drazzibdrazzib// -------------------------------------------------------------------------- // Copyright (c) 2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. // -------------------------------------------------------------------------- package org.ognl.test; import junit.framework.TestSuite; import ognl.DefaultMemberAccess; import org.ognl.test.objects.Root; public class PrivateAccessorTest extends OgnlTestCase { private static Root ROOT = new Root(); private static Object[][] TESTS = { // Using private get/set methods { ROOT, "getPrivateAccessorIntValue()", new Integer(67) }, { ROOT, "privateAccessorIntValue", new Integer(67) }, { ROOT, "privateAccessorIntValue", new Integer(67), new Integer(100) }, { ROOT, "privateAccessorIntValue2", new Integer(67) }, { ROOT, "privateAccessorIntValue2", new Integer(67), new Integer(100) }, { ROOT, "privateAccessorIntValue3", new Integer(67) }, { ROOT, "privateAccessorIntValue3", new Integer(67), new Integer(100) }, { ROOT, "privateAccessorBooleanValue", Boolean.TRUE }, { ROOT, "privateAccessorBooleanValue", Boolean.TRUE, Boolean.FALSE }, }; /* * =================================================================== Public static methods * =================================================================== */ public static TestSuite suite() { TestSuite result = new TestSuite(); for(int i = 0; i < TESTS.length; i++) { if (TESTS[i].length == 3) { result.addTest(new PrivateAccessorTest((String) TESTS[i][1], TESTS[i][0], (String) TESTS[i][1], TESTS[i][2])); } else { if (TESTS[i].length == 4) { result.addTest(new PrivateAccessorTest((String) TESTS[i][1], TESTS[i][0], (String) TESTS[i][1], TESTS[i][2], TESTS[i][3])); } else { if (TESTS[i].length == 5) { result.addTest(new PrivateAccessorTest((String) TESTS[i][1], TESTS[i][0], (String) TESTS[i][1], TESTS[i][2], TESTS[i][3], TESTS[i][4])); } else { throw new RuntimeException("don't understand TEST format"); } } } } return result; } /* * =================================================================== Constructors * =================================================================== */ public PrivateAccessorTest() { super(); } public PrivateAccessorTest(String name) { super(name); } public PrivateAccessorTest(String name, Object root, String expressionString, Object expectedResult, Object setValue, Object expectedAfterSetResult) { super(name, root, expressionString, expectedResult, setValue, expectedAfterSetResult); } public PrivateAccessorTest(String name, Object root, String expressionString, Object expectedResult, Object setValue) { super(name, root, expressionString, expectedResult, setValue); } public PrivateAccessorTest(String name, Object root, String expressionString, Object expectedResult) { super(name, root, expressionString, expectedResult); } /* * =================================================================== Overridden methods * =================================================================== */ public void setUp() { super.setUp(); _context.setMemberAccess(new DefaultMemberAccess(true)); _compileExpressions = false; } } ognl-2.7.3.orig/src/test/java/org/ognl/test/MapCreationTest.java0000644000175000017500000001250410604045342024416 0ustar drazzibdrazzib// -------------------------------------------------------------------------- // Copyright (c) 2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. // -------------------------------------------------------------------------- package org.ognl.test; import junit.framework.TestSuite; import org.ognl.test.objects.Root; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.Map; import java.util.TreeMap; public class MapCreationTest extends OgnlTestCase { private static Root ROOT = new Root(); private static Map fooBarMap1; private static Map fooBarMap2; private static Map fooBarMap3; private static Map fooBarMap4; private static Map fooBarMap5; static { fooBarMap1 = new HashMap(); fooBarMap1.put("foo", "bar"); fooBarMap2 = new HashMap(); fooBarMap2.put("foo", "bar"); fooBarMap2.put("bar", "baz"); fooBarMap3 = new HashMap(); fooBarMap3.put("foo", null); fooBarMap3.put("bar", "baz"); fooBarMap4 = new LinkedHashMap(); fooBarMap4.put("foo", "bar"); fooBarMap4.put("bar", "baz"); fooBarMap5 = new TreeMap(); fooBarMap5.put("foo", "bar"); fooBarMap5.put("bar", "baz"); } private static Object[][] TESTS = { // Map creation {ROOT, "#{ \"foo\" : \"bar\" }", fooBarMap1}, {ROOT, "#{ \"foo\" : \"bar\", \"bar\" : \"baz\" }", fooBarMap2}, {ROOT, "#{ \"foo\", \"bar\" : \"baz\" }", fooBarMap3}, {ROOT, "#@java.util.LinkedHashMap@{ \"foo\" : \"bar\", \"bar\" : \"baz\" }", fooBarMap4}, {ROOT, "#@java.util.TreeMap@{ \"foo\" : \"bar\", \"bar\" : \"baz\" }", fooBarMap5}, }; /* * =================================================================== Public static methods * =================================================================== */ public static TestSuite suite() { TestSuite result = new TestSuite(); for (int i = 0; i < TESTS.length; i++) { if (TESTS[i].length == 3) { result .addTest(new MapCreationTest((String) TESTS[i][1], TESTS[i][0], (String) TESTS[i][1], TESTS[i][2])); } else { if (TESTS[i].length == 4) { result.addTest(new MapCreationTest((String) TESTS[i][1], TESTS[i][0], (String) TESTS[i][1], TESTS[i][2], TESTS[i][3])); } else { if (TESTS[i].length == 5) { result.addTest(new MapCreationTest((String) TESTS[i][1], TESTS[i][0], (String) TESTS[i][1], TESTS[i][2], TESTS[i][3], TESTS[i][4])); } else { throw new RuntimeException("don't understand TEST format"); } } } } return result; } /* * =================================================================== Constructors * =================================================================== */ public MapCreationTest() { super(); } public MapCreationTest(String name) { super(name); } public MapCreationTest(String name, Object root, String expressionString, Object expectedResult, Object setValue, Object expectedAfterSetResult) { super(name, root, expressionString, expectedResult, setValue, expectedAfterSetResult); } public MapCreationTest(String name, Object root, String expressionString, Object expectedResult, Object setValue) { super(name, root, expressionString, expectedResult, setValue); } public MapCreationTest(String name, Object root, String expressionString, Object expectedResult) { super(name, root, expressionString, expectedResult); } } ognl-2.7.3.orig/src/test/java/org/ognl/test/MemberAccessTest.java0000644000175000017500000001255210723604233024552 0ustar drazzibdrazzib// -------------------------------------------------------------------------- // Copyright (c) 2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. // -------------------------------------------------------------------------- package org.ognl.test; import junit.framework.TestSuite; import ognl.DefaultMemberAccess; import ognl.OgnlException; import org.ognl.test.objects.Simple; import java.lang.reflect.Member; import java.lang.reflect.Method; import java.util.Map; public class MemberAccessTest extends OgnlTestCase { private static Simple ROOT = new Simple(); private static Object[][] TESTS = { {"@Runtime@getRuntime()", OgnlException.class}, {"@System@getProperty('java.specification.version')", System.getProperty("java.specification.version")}, {"bigIntValue", OgnlException.class}, {"bigIntValue", OgnlException.class, new Integer(25), OgnlException.class}, {"getBigIntValue()", OgnlException.class}, {"stringValue", ROOT.getStringValue()}, }; /* * =================================================================== Public static methods * =================================================================== */ public static TestSuite suite() { TestSuite result = new TestSuite(); for (int i = 0; i < TESTS.length; i++) { result.addTest(new MemberAccessTest((String) TESTS[i][0] + " (" + TESTS[i][1] + ")", ROOT, (String) TESTS[i][0], TESTS[i][1])); } return result; } /* * =================================================================== Constructors * =================================================================== */ public MemberAccessTest() { super(); } public MemberAccessTest(String name) { super(name); } public MemberAccessTest(String name, Object root, String expressionString, Object expectedResult, Object setValue, Object expectedAfterSetResult) { super(name, root, expressionString, expectedResult, setValue, expectedAfterSetResult); } public MemberAccessTest(String name, Object root, String expressionString, Object expectedResult, Object setValue) { super(name, root, expressionString, expectedResult, setValue); } public MemberAccessTest(String name, Object root, String expressionString, Object expectedResult) { super(name, root, expressionString, expectedResult); } /* * =================================================================== Overridden methods * =================================================================== */ public void setUp() { super.setUp(); /* Should allow access at all to the Simple class except for the bigIntValue property */ _context.setMemberAccess(new DefaultMemberAccess(false) { public boolean isAccessible(Map context, Object target, Member member, String propertyName) { if (target == Runtime.class) { return false; } if (target instanceof Simple) { if (propertyName != null) { return !propertyName.equals("bigIntValue") && super.isAccessible(context, target, member, propertyName); } else { if (member instanceof Method) { return !member.getName().equals("getBigIntValue") && !member.getName().equals("setBigIntValue") && super.isAccessible(context, target, member, propertyName); } } } return super.isAccessible(context, target, member, propertyName); } }); } } ognl-2.7.3.orig/src/test/java/org/ognl/test/IndexedPropertyTest.java0000644000175000017500000001270410673567723025365 0ustar drazzibdrazzib// -------------------------------------------------------------------------- // Copyright (c) 2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. // -------------------------------------------------------------------------- package org.ognl.test; import junit.framework.TestSuite; import org.ognl.test.objects.Indexed; import org.ognl.test.objects.Root; public class IndexedPropertyTest extends OgnlTestCase { private static Indexed INDEXED = new Indexed(); private static Root ROOT = new Root(); private static Object[][] TESTS = { // Indexed properties {INDEXED, "values", INDEXED.getValues()}, // gets String[] {INDEXED, "[\"values\"]", INDEXED.getValues()}, // String[] {INDEXED.getValues(), "[0]", INDEXED.getValues()[0]}, // "foo" {INDEXED, "getValues()[0]", INDEXED.getValues()[0]}, // "foo" directly from array {INDEXED, "values[0]", INDEXED.getValues(0)}, // "foo" + "xxx" {INDEXED, "values[^]", INDEXED.getValues(0)}, // "foo" + "xxx" {INDEXED, "values[|]", INDEXED.getValues(1)}, // "bar" + "xxx" {INDEXED, "values[$]", INDEXED.getValues(2)}, // "baz" + "xxx" {INDEXED, "values[1]", "bar" + "xxx", "xxxx" + "xxx", "xxxx" + "xxx"}, // set through setValues(int, String) {INDEXED, "values[1]", "xxxx" + "xxx"}, // getValues(int) again to check if setValues(int, String) was called {INDEXED, "setValues(2, \"xxxx\")", null}, // was "baz" -> "xxxx" {INDEXED, "getTitle(list.size)", "Title count 3"}, {INDEXED, "source.total", 1}, {ROOT, "indexer.line[index]", "line:1"}, {INDEXED, "list[2].longValue()", new Long(3)}, {ROOT, "map.value.id", new Long(1)}, {INDEXED, "property['hoodak']", null, "random string", "random string"} }; /* * =================================================================== Public static methods * =================================================================== */ public static TestSuite suite() { TestSuite result = new TestSuite(); for (int i = 0; i < TESTS.length; i++) { if (TESTS[i].length == 3) { result.addTest(new IndexedPropertyTest((String) TESTS[i][1], TESTS[i][0], (String) TESTS[i][1], TESTS[i][2])); } else { if (TESTS[i].length == 4) { result.addTest(new IndexedPropertyTest((String) TESTS[i][1], TESTS[i][0], (String) TESTS[i][1], TESTS[i][2], TESTS[i][3])); } else { if (TESTS[i].length == 5) { result.addTest(new IndexedPropertyTest((String) TESTS[i][1], TESTS[i][0], (String) TESTS[i][1], TESTS[i][2], TESTS[i][3], TESTS[i][4])); } else { throw new RuntimeException("don't understand TEST format"); } } } } return result; } /* * =================================================================== Constructors * =================================================================== */ public IndexedPropertyTest() { super(); } public IndexedPropertyTest(String name) { super(name); } public IndexedPropertyTest(String name, Object root, String expressionString, Object expectedResult, Object setValue, Object expectedAfterSetResult) { super(name, root, expressionString, expectedResult, setValue, expectedAfterSetResult); } public IndexedPropertyTest(String name, Object root, String expressionString, Object expectedResult, Object setValue) { super(name, root, expressionString, expectedResult, setValue); } public IndexedPropertyTest(String name, Object root, String expressionString, Object expectedResult) { super(name, root, expressionString, expectedResult); } } ognl-2.7.3.orig/src/test/java/org/ognl/test/NullStringCatenationTest.java0000644000175000017500000001226010655141672026333 0ustar drazzibdrazzib// -------------------------------------------------------------------------- // Copyright (c) 2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. // -------------------------------------------------------------------------- package org.ognl.test; import junit.framework.TestSuite; import org.ognl.test.objects.Root; public class NullStringCatenationTest extends OgnlTestCase { public static final String MESSAGE = "blarney"; private static Root ROOT = new Root(); private static Object[][] TESTS = { // Null string catenation {ROOT, "\"bar\" + null", "barnull"}, // Catenate null to a string {ROOT, "\"bar\" + nullObject", "barnull"}, // Catenate null to a string {ROOT, "20.56 + nullObject", NullPointerException.class}, // Catenate null to a number {ROOT, "(true ? 'tabHeader' : '') + (false ? 'tabHeader' : '')", "tabHeader"}, {ROOT, "theInt == 0 ? '5%' : theInt + '%'", "6%"}, {ROOT, "'width:' + width + ';'", "width:238px;" }, {ROOT, "theLong + '_' + index", "4_1"}, {ROOT, "'javascript:' + @org.ognl.test.NullStringCatenationTest@MESSAGE", "javascript:blarney" }, {ROOT, "printDelivery ? '' : 'javascript:deliverySelected(' + property.carrier + ',' + currentDeliveryId + ')'", "" }, {ROOT, "bean2.id + '_' + theInt", "1_6" } }; /* * =================================================================== Public static methods * =================================================================== */ public static TestSuite suite() { TestSuite result = new TestSuite(); for (int i = 0; i < TESTS.length; i++) { if (TESTS[i].length == 3) { result.addTest(new NullStringCatenationTest((String) TESTS[i][1], TESTS[i][0], (String) TESTS[i][1], TESTS[i][2])); } else { if (TESTS[i].length == 4) { result.addTest(new NullStringCatenationTest((String) TESTS[i][1], TESTS[i][0], (String) TESTS[i][1], TESTS[i][2], TESTS[i][3])); } else { if (TESTS[i].length == 5) { result.addTest(new NullStringCatenationTest((String) TESTS[i][1], TESTS[i][0], (String) TESTS[i][1], TESTS[i][2], TESTS[i][3], TESTS[i][4])); } else { throw new RuntimeException("don't understand TEST format"); } } } } return result; } /* * =================================================================== Constructors * =================================================================== */ public NullStringCatenationTest() { super(); } public NullStringCatenationTest(String name) { super(name); } public NullStringCatenationTest(String name, Object root, String expressionString, Object expectedResult, Object setValue, Object expectedAfterSetResult) { super(name, root, expressionString, expectedResult, setValue, expectedAfterSetResult); } public NullStringCatenationTest(String name, Object root, String expressionString, Object expectedResult, Object setValue) { super(name, root, expressionString, expectedResult, setValue); } public NullStringCatenationTest(String name, Object root, String expressionString, Object expectedResult) { super(name, root, expressionString, expectedResult); } } ognl-2.7.3.orig/src/test/java/org/ognl/test/ArrayElementsTest.java0000644000175000017500000001432410623606175025001 0ustar drazzibdrazzib// -------------------------------------------------------------------------- // Copyright (c) 2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. // -------------------------------------------------------------------------- package org.ognl.test; import junit.framework.TestSuite; import ognl.TypeConverter; import org.ognl.test.objects.Root; import java.util.Arrays; public class ArrayElementsTest extends OgnlTestCase { private static String[] STRING_ARRAY = new String[]{"hello", "world"}; private static int[] INT_ARRAY = new int[]{10, 20}; private static Root ROOT = new Root(); private static Object[][] TESTS = { // Array elements test {STRING_ARRAY, "length", new Integer(2)}, {STRING_ARRAY, "#root[1]", "world"}, {INT_ARRAY, "#root[1]", new Integer(20)}, {INT_ARRAY, "#root[1]", new Integer(20), "50", new Integer(50)}, {INT_ARRAY, "#root[1]", new Integer(50), new String[]{"50", "100"}, new Integer(50)}, {ROOT, "intValue", new Integer(0), new String[]{"50", "100"}, new Integer(50)}, {ROOT, "array", ROOT.getArray(), new String[]{"50", "100"}, new int[]{50, 100}}, {null, "\"{Hello}\".toCharArray()[6]", new Character('}')}, {null, "\"Tapestry\".toCharArray()[2]", new Character('p')}, {null, "{'1','2','3'}", Arrays.asList(new Object[]{new Character('1'), new Character('2'), new Character('3')})}, {null, "{ true, !false }", Arrays.asList(new Boolean[] { Boolean.TRUE, Boolean.TRUE }) } }; /* * =================================================================== Private static methods * =================================================================== */ /* * =================================================================== Public static methods * =================================================================== */ public static TestSuite suite() { TestSuite result = new TestSuite(); for (int i = 0; i < TESTS.length; i++) { if (TESTS[i].length == 3) { result.addTest(new ArrayElementsTest((String) TESTS[i][1], TESTS[i][0], (String) TESTS[i][1], TESTS[i][2])); } else { if (TESTS[i].length == 4) { result.addTest(new ArrayElementsTest((String) TESTS[i][1], TESTS[i][0], (String) TESTS[i][1], TESTS[i][2], TESTS[i][3])); } else { if (TESTS[i].length == 5) { result.addTest(new ArrayElementsTest((String) TESTS[i][1], TESTS[i][0], (String) TESTS[i][1], TESTS[i][2], TESTS[i][3], TESTS[i][4])); } else { throw new RuntimeException("don't understand TEST format"); } } } } return result; } /* * =================================================================== Constructors * =================================================================== */ public ArrayElementsTest() { super(); } public ArrayElementsTest(String name) { super(name); } public ArrayElementsTest(String name, Object root, String expressionString, Object expectedResult, Object setValue, Object expectedAfterSetResult) { super(name, root, expressionString, expectedResult, setValue, expectedAfterSetResult); } public ArrayElementsTest(String name, Object root, String expressionString, Object expectedResult, Object setValue) { super(name, root, expressionString, expectedResult, setValue); } public ArrayElementsTest(String name, Object root, String expressionString, Object expectedResult) { super(name, root, expressionString, expectedResult); } /* * =================================================================== Overridden methods * =================================================================== */ protected void setUp() { TypeConverter arrayConverter; super.setUp(); /** arrayConverter = new DefaultTypeConverter() { public Object convertValue(Map context, Object target, Member member, String propertyName, Object value, Class toType) { if (value.getClass().isArray()) { if (!toType.isArray()) { value = Array.get(value, 0); } } return super.convertValue(context, target, member, propertyName, value, toType); } }; _context.setTypeConverter(arrayConverter); */ } } ognl-2.7.3.orig/src/test/java/org/ognl/test/ConstantTest.java0000644000175000017500000001154610640044053024010 0ustar drazzibdrazzib// -------------------------------------------------------------------------- // Copyright (c) 2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. // -------------------------------------------------------------------------- package org.ognl.test; import junit.framework.TestSuite; import ognl.ExpressionSyntaxException; import java.util.Arrays; public class ConstantTest extends OgnlTestCase { private static Object[][] TESTS = { { "12345", new Integer(12345) }, { "0x100", new Integer(256) }, { "0xfE", new Integer(254) }, { "01000", new Integer(512) }, { "1234L", new Integer(1234) }, { "12.34", new Double(12.34) }, { ".1234", new Double(.12340000000000) }, { "12.34f", Double.valueOf(12.34) }, { "12.", new Double(12) }, { "12e+1d", new Double(120) }, { "'x'", new Character('x') }, { "'\\n'", new Character('\n') }, { "'\\u048c'", new Character('\u048c')}, { "'\\47'", new Character('\47') }, { "'\\367'", new Character('\367') }, { "'\\367", ExpressionSyntaxException.class }, { "'\\x'", ExpressionSyntaxException.class }, { "\"hello world\"", "hello world" }, { "\"\\u00a0\\u0068ell\\'o\\\\\\n\\r\\f\\t\\b\\\"\\167orld\\\"\"", "\u00a0hell'o\\\n\r\f\t\b\"world\"" }, { "\"hello world", ExpressionSyntaxException.class }, { "\"hello\\x world\"", ExpressionSyntaxException.class }, { "null", null }, { "true", Boolean.TRUE }, { "false", Boolean.FALSE }, { "{ false, true, null, 0, 1. }", Arrays.asList(new Object[] { Boolean.FALSE, Boolean.TRUE, null, new Integer(0), new Double(1) }) }, { "'HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\"'", "HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\"" }, }; /* * =================================================================== Public static methods * =================================================================== */ public static TestSuite suite() { TestSuite result = new TestSuite(); for(int i = 0; i < TESTS.length; i++) { result.addTest(new ConstantTest((String) TESTS[i][0] + " (" + TESTS[i][1] + ")", null, (String) TESTS[i][0], TESTS[i][1])); } return result; } /* * =================================================================== Constructors * =================================================================== */ public ConstantTest() { super(); } public ConstantTest(String name) { super(name); } public ConstantTest(String name, Object root, String expressionString, Object expectedResult, Object setValue, Object expectedAfterSetResult) { super(name, root, expressionString, expectedResult, setValue, expectedAfterSetResult); } public ConstantTest(String name, Object root, String expressionString, Object expectedResult, Object setValue) { super(name, root, expressionString, expectedResult, setValue); } public ConstantTest(String name, Object root, String expressionString, Object expectedResult) { super(name, root, expressionString, expectedResult); } } ognl-2.7.3.orig/src/test/java/org/ognl/test/ASTPropertyTest.java0000644000175000017500000002512110754136360024416 0ustar drazzibdrazzibpackage org.ognl.test; import junit.framework.TestCase; import ognl.*; import static org.ognl.test.OgnlTestCase.isEqual; import org.ognl.test.objects.*; import java.util.List; import java.util.Map; /** * Tests functionality of {@link ognl.ASTProperty}. */ public class ASTPropertyTest extends TestCase { public void test_Get_Indexed_Property_Type() throws Exception { ASTProperty p = new ASTProperty(0); p.setIndexedAccess(false); ASTConst pRef = new ASTConst(0); pRef.setValue("nested"); pRef.jjtSetParent(p); p.jjtAddChild(pRef, 0); Map root = new Root().getMap(); OgnlContext context = (OgnlContext) Ognl.createDefaultContext(null); context.setRoot(root); context.setCurrentObject(root); context.setCurrentNode(pRef); assertEquals(root.getClass(), context.getCurrentType()); assertEquals(null, context.getPreviousType()); assertEquals(root, context.getCurrentObject()); assertEquals(null, context.getCurrentAccessor()); assertEquals(null, context.getPreviousAccessor()); int type = p.getIndexedPropertyType(context, root); assertEquals(OgnlRuntime.INDEXED_PROPERTY_NONE, type); assertEquals(root.getClass(), context.getCurrentType()); assertEquals(null, context.getPreviousType()); assertEquals(null, context.getCurrentAccessor()); assertEquals(null, context.getPreviousAccessor()); } public void test_Get_Value_Body() throws Exception { ASTProperty p = new ASTProperty(0); p.setIndexedAccess(false); ASTConst pRef = new ASTConst(0); pRef.setValue("nested"); pRef.jjtSetParent(p); p.jjtAddChild(pRef, 0); Map root = new Root().getMap(); OgnlContext context = (OgnlContext) Ognl.createDefaultContext(null); context.setRoot(root); context.setCurrentObject(root); context.setCurrentNode(pRef); assertEquals(root.getClass(), context.getCurrentType()); assertEquals(null, context.getPreviousType()); assertEquals(root, context.getCurrentObject()); assertEquals(null, context.getCurrentAccessor()); assertEquals(null, context.getPreviousAccessor()); Object value = p.getValue(context, root); assertEquals(root.get("nested"), value); assertEquals(root.getClass(), context.getCurrentType()); assertEquals(null, context.getPreviousType()); assertEquals(null, context.getCurrentAccessor()); assertEquals(null, context.getPreviousAccessor()); } public void test_Get_Source() throws Throwable { ASTProperty p = new ASTProperty(0); p.setIndexedAccess(false); ASTConst pRef = new ASTConst(0); pRef.setValue("nested"); pRef.jjtSetParent(p); p.jjtAddChild(pRef, 0); Map root = new Root().getMap(); OgnlContext context = (OgnlContext) Ognl.createDefaultContext(null); context.setRoot(root); context.setCurrentObject(root); context.setCurrentNode(pRef); assertEquals(".get(\"nested\")", p.toGetSourceString(context, root)); assertEquals(Object.class, context.getCurrentType()); assertEquals(Map.class, context.getCurrentAccessor()); assertEquals(root.getClass(), context.getPreviousType()); assertEquals(null, context.getPreviousAccessor()); assertEquals(root.get("nested"), context.getCurrentObject()); assert Map.class.isAssignableFrom(context.getCurrentAccessor()); assertEquals(root.getClass(), context.getPreviousType()); assertEquals(null, context.getPreviousAccessor()); } public void test_Set_Source() throws Throwable { ASTProperty p = new ASTProperty(0); p.setIndexedAccess(false); ASTConst pRef = new ASTConst(0); pRef.setValue("nested"); pRef.jjtSetParent(p); p.jjtAddChild(pRef, 0); Map root = new Root().getMap(); OgnlContext context = (OgnlContext) Ognl.createDefaultContext(null); context.setRoot(root); context.setCurrentObject(root); context.setCurrentNode(pRef); assertEquals(".put(\"nested\", $3)", p.toSetSourceString(context, root)); assertEquals(Object.class, context.getCurrentType()); assertEquals(root.get("nested"), context.getCurrentObject()); assert Map.class.isAssignableFrom(context.getCurrentAccessor()); assertEquals(root.getClass(), context.getPreviousType()); assertEquals(null, context.getPreviousAccessor()); } public void test_Indexed_Object_Type() throws Throwable { //ASTChain chain = new ASTChain(0); ASTProperty listp = new ASTProperty(0); listp.setIndexedAccess(false); //listp.jjtSetParent(chain); ASTConst listc = new ASTConst(0); listc.setValue("list"); listc.jjtSetParent(listp); listp.jjtAddChild(listc, 0); //chain.jjtAddChild(listp, 0); ASTProperty p = new ASTProperty(0); p.setIndexedAccess(true); ASTProperty pindex = new ASTProperty(0); ASTConst pRef = new ASTConst(0); pRef.setValue("genericIndex"); pRef.jjtSetParent(pindex); pindex.jjtAddChild(pRef, 0); p.jjtAddChild(pindex, 0); //chain.jjtAddChild(p, 1); Root root = new Root(); OgnlContext context = (OgnlContext) Ognl.createDefaultContext(null); context.setRoot(root); context.setCurrentObject(root); context.setCurrentNode(listp); assertEquals(".getList()", listp.toGetSourceString(context, root)); assertEquals(List.class, context.getCurrentType()); assertEquals(Root.class, context.getCurrentAccessor()); assertEquals(null, context.getPreviousAccessor()); assertEquals(root.getClass(), context.getPreviousType()); assertEquals(root.getList(), context.getCurrentObject()); // re test with chain context = (OgnlContext) Ognl.createDefaultContext(null); context.setRoot(root); context.setCurrentObject(root); ASTChain chain = new ASTChain(0); listp.jjtSetParent(chain); chain.jjtAddChild(listp, 0); context.setCurrentNode(chain); assertEquals(".getList()", chain.toGetSourceString(context, root)); assertEquals(List.class, context.getCurrentType()); assertEquals(Root.class, context.getCurrentAccessor()); assertEquals(null, context.getPreviousAccessor()); assertEquals(Root.class, context.getPreviousType()); assertEquals(root.getList(), context.getCurrentObject()); // test with only getIndex assertEquals(".get(ognl.OgnlOps#getIntValue(((org.ognl.test.objects.Root)$2)..getGenericIndex().toString()))", p.toGetSourceString(context, root.getList())); assertEquals(root.getArray(), context.getCurrentObject()); assertEquals(Object.class, context.getCurrentType()); } public void test_Complicated_List() throws Exception { Root root = new Root(); OgnlContext context = (OgnlContext)Ognl.createDefaultContext(null); SimpleNode node = (SimpleNode) Ognl.compileExpression(context, root, "{ new org.ognl.test.objects.MenuItem('Home', 'Main', " + "{ new org.ognl.test.objects.MenuItem('Help', 'Help'), " + "new org.ognl.test.objects.MenuItem('Contact', 'Contact') }), " // end first item + "new org.ognl.test.objects.MenuItem('UserList', getMessages().getMessage('menu.members')), " + "new org.ognl.test.objects.MenuItem('account/BetSlipList', getMessages().getMessage('menu.account'), " + "{ new org.ognl.test.objects.MenuItem('account/BetSlipList', 'My Bets'), " + "new org.ognl.test.objects.MenuItem('account/TransactionList', 'My Transactions') }), " + "new org.ognl.test.objects.MenuItem('About', 'About'), " + "new org.ognl.test.objects.MenuItem('admin/Admin', getMessages().getMessage('menu.admin'), " + "{ new org.ognl.test.objects.MenuItem('admin/AddEvent', 'Add event'), " + "new org.ognl.test.objects.MenuItem('admin/AddResult', 'Add result') })}"); assertTrue(List.class.isAssignableFrom(node.getAccessor().get(context, root).getClass())); } public void test_Set_Chain_Indexed_Property() throws Exception { Root root = new Root(); OgnlContext context = (OgnlContext) Ognl.createDefaultContext(null); context.setRoot(root); context.setCurrentObject(root); SimpleNode node = (SimpleNode) Ognl.parseExpression("tab.searchCriteriaSelections[index1][index2]"); node.setValue(context, root, Boolean.FALSE); } public void test_Set_Generic_Property() throws Exception { GenericRoot root = new GenericRoot(); OgnlContext context = (OgnlContext) Ognl.createDefaultContext(null); context.setRoot(root); context.setCurrentObject(root); SimpleNode node = (SimpleNode) Ognl.parseExpression("cracker.param"); node.setValue(context, root, "0"); assertEquals( new Integer(0), root.getCracker().getParam()); node.setValue(context, root, "10"); assertEquals(new Integer(10), root.getCracker().getParam()); } public void test_Get_Generic_Property() throws Exception { GenericRoot root = new GenericRoot(); OgnlContext context = (OgnlContext) Ognl.createDefaultContext(null); context.setRoot(root); context.setCurrentObject(root); SimpleNode node = (SimpleNode) Ognl.parseExpression("cracker.param"); node.setValue(context, root, "0"); assertEquals(new Integer(0), node.getValue(context, root)); node.setValue(context, root, "10"); assertEquals(new Integer(10), node.getValue(context, root)); } public void test_Set_Get_Multiple_Generic_Types_Property() throws Exception { BaseGeneric root = new GameGeneric(); OgnlContext context = (OgnlContext) Ognl.createDefaultContext(null); context.setRoot(root); context.setCurrentObject(root); SimpleNode node = (SimpleNode) Ognl.parseExpression("ids"); node.setValue(context, root, new String[] {"0", "20", "43"}); isEqual(new Long[] {new Long(0), new Long(20), new Long(43)}, root.getIds()); isEqual(node.getValue(context, root), root.getIds()); } } ognl-2.7.3.orig/src/test/java/org/ognl/test/CompilingPropertyAccessor.java0000644000175000017500000002362510566476144026552 0ustar drazzibdrazzib// -------------------------------------------------------------------------- // Copyright (c) 1998-2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. // -------------------------------------------------------------------------- package org.ognl.test; import javassist.ClassPool; import javassist.CtClass; import javassist.CtMethod; import javassist.LoaderClassPath; import ognl.ObjectPropertyAccessor; import ognl.OgnlContext; import ognl.OgnlException; import ognl.OgnlRuntime; import ognl.enhance.ContextClassLoader; import ognl.enhance.EnhancedClassLoader; import org.ognl.test.util.NameFactory; import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.util.HashMap; import java.util.IdentityHashMap; import java.util.Map; /** * Implementation of PropertyAccessor that uses Javassist to compile a property accessor * specifically tailored to the property. */ public class CompilingPropertyAccessor extends ObjectPropertyAccessor { private static NameFactory NAME_FACTORY = new NameFactory("ognl.PropertyAccessor", "v"); private static Getter NotFoundGetter = new Getter() { public Object get(OgnlContext context, Object target, String propertyName) { return null; } }; private static Getter DefaultGetter = new Getter() { public Object get(OgnlContext context, Object target, String propertyName) { try { return OgnlRuntime.getMethodValue(context, target, propertyName, true); } catch (Exception ex) { throw new RuntimeException(ex); } } }; private static Map pools = new HashMap(); private static Map loaders = new HashMap(); private static java.util.IdentityHashMap PRIMITIVE_WRAPPER_CLASSES = new IdentityHashMap(); private java.util.IdentityHashMap seenGetMethods = new java.util.IdentityHashMap(); static { PRIMITIVE_WRAPPER_CLASSES.put(Boolean.TYPE, Boolean.class); PRIMITIVE_WRAPPER_CLASSES.put(Boolean.class, Boolean.TYPE); PRIMITIVE_WRAPPER_CLASSES.put(Byte.TYPE, Byte.class); PRIMITIVE_WRAPPER_CLASSES.put(Byte.class, Byte.TYPE); PRIMITIVE_WRAPPER_CLASSES.put(Character.TYPE, Character.class); PRIMITIVE_WRAPPER_CLASSES.put(Character.class, Character.TYPE); PRIMITIVE_WRAPPER_CLASSES.put(Short.TYPE, Short.class); PRIMITIVE_WRAPPER_CLASSES.put(Short.class, Short.TYPE); PRIMITIVE_WRAPPER_CLASSES.put(Integer.TYPE, Integer.class); PRIMITIVE_WRAPPER_CLASSES.put(Integer.class, Integer.TYPE); PRIMITIVE_WRAPPER_CLASSES.put(Long.TYPE, Long.class); PRIMITIVE_WRAPPER_CLASSES.put(Long.class, Long.TYPE); PRIMITIVE_WRAPPER_CLASSES.put(Float.TYPE, Float.class); PRIMITIVE_WRAPPER_CLASSES.put(Float.class, Float.TYPE); PRIMITIVE_WRAPPER_CLASSES.put(Double.TYPE, Double.class); PRIMITIVE_WRAPPER_CLASSES.put(Double.class, Double.TYPE); } public static Class getPrimitiveWrapperClass(Class primitiveClass) { return (Class) PRIMITIVE_WRAPPER_CLASSES.get(primitiveClass); } public interface Getter { public Object get(OgnlContext context, Object target, String propertyName); } public static Getter generateGetter(OgnlContext context, String code) throws OgnlException { String className = NAME_FACTORY.getNewClassName(); try { ClassPool pool = (ClassPool) pools.get(context.getClassResolver()); EnhancedClassLoader loader = (EnhancedClassLoader) loaders.get(context.getClassResolver()); CtClass newClass; CtClass ognlContextClass; CtClass objectClass; CtClass stringClass; CtMethod method; byte[] byteCode; Class compiledClass; if ((pool == null) || (loader == null)) { ClassLoader classLoader = new ContextClassLoader(OgnlContext.class.getClassLoader(), context); pool = ClassPool.getDefault(); pool.insertClassPath(new LoaderClassPath(classLoader)); pools.put(context.getClassResolver(), pool); loader = new EnhancedClassLoader(classLoader); loaders.put(context.getClassResolver(), loader); } newClass = pool.makeClass(className); ognlContextClass = pool.get(OgnlContext.class.getName()); objectClass = pool.get(Object.class.getName()); stringClass = pool.get(String.class.getName()); newClass.addInterface(pool.get(Getter.class.getName())); method = new CtMethod(objectClass, "get", new CtClass[] { ognlContextClass, objectClass, stringClass }, newClass); method.setBody("{" + code + "}"); newClass.addMethod(method); byteCode = newClass.toBytecode(); compiledClass = loader.defineClass(className, byteCode); return (Getter) compiledClass.newInstance(); } catch (Throwable ex) { throw new OgnlException("Cannot create class", ex); } } private Getter getGetter(OgnlContext context, Object target, String propertyName) throws OgnlException { Getter result; Class targetClass = target.getClass(); Map propertyMap; if ((propertyMap = (Map) seenGetMethods.get(targetClass)) == null) { propertyMap = new HashMap(101); seenGetMethods.put(targetClass, propertyMap); } if ((result = (Getter) propertyMap.get(propertyName)) == null) { try { Method method = OgnlRuntime.getGetMethod(context, targetClass, propertyName); if (method != null) { if (Modifier.isPublic(method.getModifiers())) { if (method.getReturnType().isPrimitive()) { propertyMap.put(propertyName, result = generateGetter(context, "java.lang.Object\t\tresult;\n" + targetClass.getName() + "\t" + "t0 = (" + targetClass.getName() + ")$2;\n" + "\n" + "try {\n" + " result = new " + getPrimitiveWrapperClass(method.getReturnType()).getName() + "(t0." + method.getName() + "());\n" + "} catch (java.lang.Exception ex) {\n" + " throw new java.lang.RuntimeException(ex);\n" + "}\n" + "return result;")); } else { propertyMap.put(propertyName, result = generateGetter(context, "java.lang.Object\t\tresult;\n" + targetClass.getName() + "\t" + "t0 = (" + targetClass.getName() + ")$2;\n" + "\n" + "try {\n" + " result = t0." + method.getName() + "();\n" + "} catch (java.lang.Exception ex) {\n" + " throw new java.lang.RuntimeException(ex);\n" + "}\n" + "return result;")); } } else { propertyMap.put(propertyName, result = DefaultGetter); } } else { propertyMap.put(propertyName, result = NotFoundGetter); } } catch (Exception ex) { throw new OgnlException("getting getter", ex); } } return result; } /** * Returns OgnlRuntime.NotFound if the property does not exist. */ public Object getPossibleProperty(Map context, Object target, String name) throws OgnlException { Object result; OgnlContext ognlContext = (OgnlContext) context; if (context.get("_compile") != null) { Getter getter = getGetter(ognlContext, target, name); if (getter != NotFoundGetter) { result = getter.get(ognlContext, target, name); } else { try { result = OgnlRuntime.getFieldValue(ognlContext, target, name, true); } catch (Exception ex) { throw new OgnlException(name, ex); } } } else { result = super.getPossibleProperty(context, target, name); } return result; } } ognl-2.7.3.orig/src/test/java/org/ognl/test/accessors/0000755000175000017500000000000011237553170022502 5ustar drazzibdrazzibognl-2.7.3.orig/src/test/java/org/ognl/test/accessors/ListPropertyAccessorTest.java0000644000175000017500000000471310604045342030347 0ustar drazzibdrazzibpackage org.ognl.test.accessors; import junit.framework.TestCase; import ognl.ListPropertyAccessor; import ognl.Ognl; import ognl.OgnlContext; import ognl.enhance.ExpressionCompiler; import org.ognl.test.objects.ListSource; import org.ognl.test.objects.ListSourceImpl; import org.ognl.test.objects.Root; import java.util.List; /** * Tests functionality of various built in object accessors. */ public class ListPropertyAccessorTest extends TestCase { public void test_Get_Source_String_Number_Index() { ListPropertyAccessor pa = new ListPropertyAccessor(); Root root = new Root(); OgnlContext context = (OgnlContext) Ognl.createDefaultContext(null); context.setRoot(root); context.setCurrentObject(root); context.setCurrentType(Integer.TYPE); assertEquals(".get(0)", pa.getSourceAccessor(context, root.getList(), "0")); assertEquals(List.class, context.getCurrentAccessor()); assertEquals(Object.class, context.getCurrentType()); assertEquals(Integer.TYPE, context.getPreviousType()); assertEquals(null, context.getPreviousAccessor()); } public void test_Get_Source_Object_Number_Index() { ListPropertyAccessor pa = new ListPropertyAccessor(); Root root = new Root(); OgnlContext context = (OgnlContext) Ognl.createDefaultContext(null); context.setRoot(root); context.setCurrentObject(root); context.setCurrentType(Integer.class); assertEquals(".get(indexValue.intValue())", pa.getSourceAccessor(context, root.getList(), "indexValue")); assertEquals(List.class, context.getCurrentAccessor()); assertEquals(Object.class, context.getCurrentType()); assertEquals(Integer.class, context.getPreviousType()); assertEquals(null, context.getPreviousAccessor()); } public void test_List_To_Object_Property_Accessor_Read() throws Exception { ListPropertyAccessor pa = new ListPropertyAccessor(); ListSource list = new ListSourceImpl(); OgnlContext context = (OgnlContext) Ognl.createDefaultContext(null); context.setRoot(list); context.setCurrentObject(list); assertEquals(".getTotal()", pa.getSourceAccessor(context, list, "total")); assertNull(context.get(ExpressionCompiler.PRE_CAST)); assertEquals(int.class, context.getCurrentType()); assertEquals(ListSource.class, context.getCurrentAccessor()); } } ognl-2.7.3.orig/src/test/java/org/ognl/test/InterfaceInheritanceTest.java0000644000175000017500000001400110723604233026262 0ustar drazzibdrazzib// -------------------------------------------------------------------------- // Copyright (c) 2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. // -------------------------------------------------------------------------- package org.ognl.test; import junit.framework.TestSuite; import ognl.OgnlRuntime; import org.ognl.test.objects.*; import java.util.List; public class InterfaceInheritanceTest extends OgnlTestCase { private static Root ROOT = new Root(); static { ROOT.getBeans().setBean("testBean", new Bean1()); ROOT.getBeans().setBean("evenOdd", new EvenOdd()); List list = new ListSourceImpl(); list.add("test1"); ROOT.getMap().put("customList", list); } private static Object[][] TESTS = { {ROOT, "myMap", ROOT.getMyMap()}, {ROOT, "myMap.test", ROOT}, {ROOT.getMyMap(), "list", ROOT.getList()}, {ROOT, "myMap.array[0]", new Integer(ROOT.getArray()[0])}, {ROOT, "myMap.list[1]", ROOT.getList().get(1)}, {ROOT, "myMap[^]", new Integer(99)}, {ROOT, "myMap[$]", null}, {ROOT.getMyMap(), "array[$]", new Integer(ROOT.getArray()[ROOT.getArray().length - 1])}, {ROOT, "[\"myMap\"]", ROOT.getMyMap()}, {ROOT, "myMap[null]", null}, {ROOT, "myMap[#x = null]", null}, {ROOT, "myMap.(null,test)", ROOT}, {ROOT, "myMap[null] = 25", new Integer(25)}, {ROOT, "myMap[null]", new Integer(25), new Integer(50), new Integer(50)}, {ROOT, "beans.testBean", ROOT.getBeans().getBean("testBean")}, {ROOT, "beans.evenOdd.next", "even"}, {ROOT, "map.comp.form.clientId", "form1"}, {ROOT, "map.comp.getCount(genericIndex)", Integer.valueOf(0)}, {ROOT, "map.customList.total", Integer.valueOf(1)}, {ROOT, "myTest.theMap['key']", "value" }, {ROOT, "contentProvider.hasChildren(property)", Boolean.TRUE}, {ROOT, "objectIndex instanceof java.lang.Object", Boolean.TRUE} }; /* * =================================================================== Public static methods * =================================================================== */ public static TestSuite suite() { TestSuite result = new TestSuite(); for (int i = 0; i < TESTS.length; i++) { if (TESTS[i].length == 3) { result.addTest(new InterfaceInheritanceTest((String) TESTS[i][1], TESTS[i][0], (String) TESTS[i][1], TESTS[i][2])); } else { if (TESTS[i].length == 4) { result.addTest(new InterfaceInheritanceTest((String) TESTS[i][1], TESTS[i][0], (String) TESTS[i][1], TESTS[i][2], TESTS[i][3])); } else { if (TESTS[i].length == 5) { result.addTest(new InterfaceInheritanceTest((String) TESTS[i][1], TESTS[i][0], (String) TESTS[i][1], TESTS[i][2], TESTS[i][3], TESTS[i][4])); } else { throw new RuntimeException("don't understand TEST format"); } } } } return result; } /* * =================================================================== Constructors * =================================================================== */ public InterfaceInheritanceTest() { super(); } public InterfaceInheritanceTest(String name) { super(name); } public InterfaceInheritanceTest(String name, Object root, String expressionString, Object expectedResult, Object setValue, Object expectedAfterSetResult) { super(name, root, expressionString, expectedResult, setValue, expectedAfterSetResult); } public InterfaceInheritanceTest(String name, Object root, String expressionString, Object expectedResult, Object setValue) { super(name, root, expressionString, expectedResult, setValue); } public InterfaceInheritanceTest(String name, Object root, String expressionString, Object expectedResult) { super(name, root, expressionString, expectedResult); } public void setUp() { super.setUp(); OgnlRuntime.setPropertyAccessor(BeanProvider.class, new BeanProviderAccessor()); } } ognl-2.7.3.orig/src/test/java/org/ognl/test/CollectionDirectPropertyTest.java0000644000175000017500000001303510602106173027205 0ustar drazzibdrazzib// -------------------------------------------------------------------------- // Copyright (c) 2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. // -------------------------------------------------------------------------- package org.ognl.test; import junit.framework.TestSuite; import org.ognl.test.objects.Root; import java.util.Arrays; public class CollectionDirectPropertyTest extends OgnlTestCase { private static Root ROOT = new Root(); private static Object[][] TESTS = { // Collection direct properties {Arrays.asList(new String[]{"hello", "world"}), "size", new Integer(2)}, {Arrays.asList(new String[]{"hello", "world"}), "isEmpty", Boolean.FALSE}, {Arrays.asList(new String[]{}), "isEmpty", Boolean.TRUE}, {Arrays.asList(new String[]{"hello", "world"}), "iterator.next", "hello"}, {Arrays.asList(new String[]{"hello", "world"}), "iterator.hasNext", Boolean.TRUE}, {Arrays.asList(new String[]{"hello", "world"}), "#it = iterator, #it.next, #it.next, #it.hasNext", Boolean.FALSE}, {Arrays.asList(new String[]{"hello", "world"}), "#it = iterator, #it.next, #it.next", "world"}, {Arrays.asList(new String[]{"hello", "world"}), "size", new Integer(2)}, {ROOT, "map[\"test\"]", ROOT}, {ROOT, "map.size", new Integer(ROOT.getMap().size())}, {ROOT, "map.keySet", ROOT.getMap().keySet()}, {ROOT, "map.values", ROOT.getMap().values()}, {ROOT, "map.keys.size", new Integer(ROOT.getMap().keySet().size())}, {ROOT, "map[\"size\"]", ROOT.getMap().get("size")}, {ROOT, "map.isEmpty", ROOT.getMap().isEmpty() ? Boolean.TRUE : Boolean.FALSE}, {ROOT, "map[\"isEmpty\"]", null}, }; /* * =================================================================== Public static methods * =================================================================== */ public static TestSuite suite() { TestSuite result = new TestSuite(); for (int i = 0; i < TESTS.length; i++) { if (TESTS[i].length == 3) { result.addTest(new CollectionDirectPropertyTest((String) TESTS[i][1], TESTS[i][0], (String) TESTS[i][1], TESTS[i][2])); } else { if (TESTS[i].length == 4) { result.addTest(new CollectionDirectPropertyTest((String) TESTS[i][1], TESTS[i][0], (String) TESTS[i][1], TESTS[i][2], TESTS[i][3])); } else { if (TESTS[i].length == 5) { result.addTest(new CollectionDirectPropertyTest((String) TESTS[i][1], TESTS[i][0], (String) TESTS[i][1], TESTS[i][2], TESTS[i][3], TESTS[i][4])); } else { throw new RuntimeException("don't understand TEST format"); } } } } return result; } /* * =================================================================== Constructors * =================================================================== */ public CollectionDirectPropertyTest() { super(); } public CollectionDirectPropertyTest(String name) { super(name); } public CollectionDirectPropertyTest(String name, Object root, String expressionString, Object expectedResult, Object setValue, Object expectedAfterSetResult) { super(name, root, expressionString, expectedResult, setValue, expectedAfterSetResult); } public CollectionDirectPropertyTest(String name, Object root, String expressionString, Object expectedResult, Object setValue) { super(name, root, expressionString, expectedResult, setValue); } public CollectionDirectPropertyTest(String name, Object root, String expressionString, Object expectedResult) { super(name, root, expressionString, expectedResult); } } ognl-2.7.3.orig/src/test/java/org/ognl/test/LambdaExpressionTest.java0000644000175000017500000001033510577301171025460 0ustar drazzibdrazzib// -------------------------------------------------------------------------- // Copyright (c) 2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. // -------------------------------------------------------------------------- package org.ognl.test; import junit.framework.TestSuite; import java.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; public class LambdaExpressionTest extends OgnlTestCase { private static Object[][] TESTS = { // Lambda expressions {null, "#a=:[33](20).longValue().{0}.toArray().length", new Integer(33)}, {null, "#fact=:[#this<=1? 1 : #fact(#this-1) * #this], #fact(30)", new Integer(1409286144)}, {null, "#fact=:[#this<=1? 1 : #fact(#this-1) * #this], #fact(30L)", new Long(-8764578968847253504L)}, {null, "#fact=:[#this<=1? 1 : #fact(#this-1) * #this], #fact(30h)", new BigInteger("265252859812191058636308480000000")}, {null, "#bump = :[ #this.{ #this + 1 } ], (#bump)({ 1, 2, 3 })", new ArrayList(Arrays.asList(new Integer[]{new Integer(2), new Integer(3), new Integer(4)}))}, {null, "#call = :[ \"calling \" + [0] + \" on \" + [1] ], (#call)({ \"x\", \"y\" })", "calling x on y"}, }; /* * =================================================================== Public static methods * =================================================================== */ public static TestSuite suite() { TestSuite result = new TestSuite(); for (int i = 0; i < TESTS.length; i++) { result.addTest(new LambdaExpressionTest((String) TESTS[i][1], TESTS[i][0], (String) TESTS[i][1], TESTS[i][2])); } return result; } /* * =================================================================== Constructors * =================================================================== */ public LambdaExpressionTest() { super(); } public LambdaExpressionTest(String name) { super(name); } public LambdaExpressionTest(String name, Object root, String expressionString, Object expectedResult, Object setValue, Object expectedAfterSetResult) { super(name, root, expressionString, expectedResult, setValue, expectedAfterSetResult); } public LambdaExpressionTest(String name, Object root, String expressionString, Object expectedResult, Object setValue) { super(name, root, expressionString, expectedResult, setValue); } public LambdaExpressionTest(String name, Object root, String expressionString, Object expectedResult) { super(name, root, expressionString, expectedResult); } } ognl-2.7.3.orig/src/test/java/org/ognl/test/objects/0000755000175000017500000000000011237553170022146 5ustar drazzibdrazzibognl-2.7.3.orig/src/test/java/org/ognl/test/objects/Bean2.java0000644000175000017500000000533410635626430023746 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package org.ognl.test.objects; public class Bean2 extends Object { private Bean3 bean3 = new Bean3(); private boolean _pageBreakAfter = false; public Long getId() { return 1l; } public Bean3 getBean3() { return bean3; } public long getMillis() { return 1000 * 60 * 2; } public boolean isCarrier() { return false; } public boolean isPageBreakAfter() { return _pageBreakAfter; } public void setPageBreakAfter(boolean value) { _pageBreakAfter = value; } public void togglePageBreakAfter() { _pageBreakAfter ^= true; } public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Bean2 bean2 = (Bean2) o; if (_pageBreakAfter != bean2._pageBreakAfter) return false; return true; } public int hashCode() { return (_pageBreakAfter ? 1 : 0); } } ognl-2.7.3.orig/src/test/java/org/ognl/test/objects/IContentProvider.java0000644000175000017500000000021110613454527026244 0ustar drazzibdrazzibpackage org.ognl.test.objects; import java.util.List; /** * */ public interface IContentProvider { public List getElements(); } ognl-2.7.3.orig/src/test/java/org/ognl/test/objects/GetterMethods.java0000644000175000017500000000051610655140337025571 0ustar drazzibdrazzibpackage org.ognl.test.objects; /** * */ public class GetterMethods { private int theInt = 1; public boolean isAllowDisplay(Object something) { return true; } public int getAllowDisplay() { return theInt; } public void setAllowDisplay(int val) { theInt = val; } } ognl-2.7.3.orig/src/test/java/org/ognl/test/objects/Root.java0000644000175000017500000003077210744214073023743 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package org.ognl.test.objects; import ognl.DynamicSubscript; import java.util.*; public class Root extends Object { public static final String SIZE_STRING = "size"; public static final int STATIC_INT = 23; private int[] array = { 1, 2, 3, 4 }; private Map map = new HashMap(23); private MyMap myMap = new MyMapImpl(); private List list = Arrays.asList(new Object[] { null, this, array }); private List settableList = new ArrayList(Arrays.asList(new Object[] { "foo", "bar", "baz" })); private int index = 1; private int intValue = 0; private String stringValue; private int yetAnotherIntValue = 46; private boolean privateAccessorBooleanValue = true; private int privateAccessorIntValue = 67; private int privateAccessorIntValue2 = 67; private int privateAccessorIntValue3 = 67; public String anotherStringValue = "foo"; public int anotherIntValue = 123; public int six = 6; private boolean _disabled; private Locale _selected = Locale.getDefault(); private List> _booleanValues = new ArrayList>(); private boolean[] _booleanArray = {true, false, true, true}; private List _list; private int verbosity = 87; private BeanProvider _beanProvider = new BeanProviderImpl(); private boolean _render; private Boolean _readOnly = Boolean.FALSE; private Integer _objIndex = new Integer(1); private Object _genericObjIndex = new Integer(2); private Date _date = new Date(); private boolean _openWindow = false; private ITreeContentProvider _contentProvider = new TreeContentProvider(); private Indexed _indexed = new Indexed(); private SearchTab _tab = new SearchTab(); /*=================================================================== Public static methods ===================================================================*/ public static int getStaticInt() { return STATIC_INT; } /*=================================================================== Constructors ===================================================================*/ public Root() { super(); } /*=================================================================== Private methods ===================================================================*/ { map.put( "test", this ); map.put( "array", array ); map.put( "list", list ); map.put( "size", new Integer(5000) ); map.put( DynamicSubscript.first, new Integer(99) ); map.put( "baz", array); map.put("value", new Bean2()); map.put("bar", new Bean3()); map.put(new Long(82), "StringStuff=someValue"); IFormComponent comp = new FormComponentImpl(); comp.setClientId("formComponent"); IForm form = new FormImpl(); form.setClientId("form1"); comp.setForm(form); map.put("comp", comp); Map newMap = new HashMap(); Map chain = new HashMap(); newMap.put("deep", chain); chain.put("last", Boolean.TRUE); map.put("nested", newMap); /* make myMap identical */ myMap.putAll( map ); List bool1 = new ArrayList(); bool1.add(Boolean.TRUE); bool1.add(Boolean.FALSE); bool1.add(Boolean.TRUE); _booleanValues.add(bool1); List bool2 = new ArrayList(); bool2.add(Boolean.TRUE); bool2.add(Boolean.FALSE); bool2.add(Boolean.TRUE); _booleanValues.add(bool2); } private boolean isPrivateAccessorBooleanValue() { return privateAccessorBooleanValue; } private void setPrivateAccessorBooleanValue(boolean value) { privateAccessorBooleanValue = value; } private int getPrivateAccessorIntValue() { return privateAccessorIntValue; } private void setPrivateAccessorIntValue(int value) { privateAccessorIntValue = value; } /*=================================================================== Protected methods ===================================================================*/ protected int getPrivateAccessorIntValue2() { return privateAccessorIntValue2; } protected void setPrivateAccessorIntValue2(int value) { privateAccessorIntValue2 = value; } /*=================================================================== Package protected methods ===================================================================*/ int getPrivateAccessorIntValue3() { return privateAccessorIntValue3; } void setPrivateAccessorIntValue3(int value) { privateAccessorIntValue3 = value; } /*=================================================================== Public methods ===================================================================*/ public int[] getArray() { return array; } public boolean[] getBooleanArray() { return _booleanArray; } public void setArray(int[] value) { array = value; } public String format(String key, Object value) { return format(key, new Object[] { value }); } public String format(String key, Object[] value) { return "formatted"; } public String getCurrentClass(String value) { return value + " stop"; } public Messages getMessages() { return new Messages(map); } public Map getMap() { return map; } public MyMap getMyMap() { return myMap; } public List getList() { return list; } public Object getAsset(String key) { return key; } public List getSettableList() { return settableList; } public int getIndex() { return index; } public Integer getObjectIndex() { return _objIndex; } public Integer getNullIndex() { return null; } public Object getGenericIndex() { return _genericObjIndex; } public int getIntValue() { return intValue; } public void setIntValue(int value) { intValue = value; } public int getTheInt() { return six; } public String getStringValue() { return stringValue; } public void setStringValue(String value) { stringValue = value; } public String getIndexedStringValue() { return "array"; } public Object getNullObject() { return null; } public String getTestString() { return "wiggle"; } public Object getProperty() { return new Bean2(); } public Bean2 getBean2() { return new Bean2(); } public Object getIndexedProperty(String name) { return myMap.get(name); } public Indexed getIndexer() { return _indexed; } public BeanProvider getBeans() { return _beanProvider; } public boolean getBooleanValue() { return _disabled; } public void setBooleanValue(boolean value) { _disabled = value; } public boolean getDisabled() { return _disabled; } public void setDisabled(boolean disabled) { _disabled = disabled; } public Locale getSelected() { return _selected; } public void setSelected(Locale locale) { _selected = locale; } public Locale getCurrLocale() { return Locale.getDefault(); } public int getCurrentLocaleVerbosity() { return verbosity; } public boolean getRenderNavigation() { return _render; } public void setSelectedList(List selected) { _list = selected; } public List getSelectedList() { return _list; } public Boolean getReadonly() { return _readOnly; } public void setReadonly(Boolean value) { _readOnly = value; } public Object getSelf() { return this; } public Date getTestDate() { return _date; } public String getWidth() { return "238px"; } public Long getTheLong() { return new Long(4); } public boolean isSorted() { return true; } public TestClass getMyTest() { return new TestImpl(); } public ITreeContentProvider getContentProvider() { return _contentProvider; } public boolean isPrintDelivery() { return true; } public Long getCurrentDeliveryId() { return 1l; } public Boolean isFlyingMonkey() { return Boolean.TRUE; } public Boolean isDumb() { return Boolean.FALSE; } public Date getExpiration() { return null; } public Long getMapKey() { return new Long(82); } public Object getArrayValue() { return new Object[] {new Integer("2"), new Integer("2")}; } public List getResult() { List list = new ArrayList(); list.add(new Object[]{new Integer("2"), new Integer("2")}); list.add(new Object[]{new Integer("2"), new Integer("2")}); list.add(new Object[]{new Integer("2"), new Integer("2")}); return list; } public boolean isEditorDisabled() { return false; } public boolean isDisabled() { return true; } public boolean isOpenTransitionWin() { return _openWindow; } public void setOpenTransitionWin(boolean value) { _openWindow = value; } public boolean isOk(SimpleEnum value, String otherValue) { return true; } public List> getBooleanValues() { return _booleanValues; } public int getIndex1() { return 1; } public int getIndex2() { return 1; } public SearchTab getTab() { return _tab; } public void setTab(SearchTab tab) { _tab = tab; } public static class A { public int methodOfA(B b) { return 0; } public int getIntValue() { return 1; } } public static class B { public int methodOfB(int i) { return 0; } } public A getA() { return new A(); } public B getB() { return new B(); } } ognl-2.7.3.orig/src/test/java/org/ognl/test/objects/Copy.java0000644000175000017500000000016610616716326023732 0ustar drazzibdrazzibpackage org.ognl.test.objects; /** * */ public class Copy { public int size() { return 1; } } ognl-2.7.3.orig/src/test/java/org/ognl/test/objects/SearchTab.java0000644000175000017500000000332310712710134024636 0ustar drazzibdrazzibpackage org.ognl.test.objects; import java.util.ArrayList; import java.util.Arrays; import java.util.List; /** * Test for OGNL-131. */ public class SearchTab { /** * Flags stating which search criteria are selected */ private List> searchCriteriaSelections = new ArrayList>(); { searchCriteriaSelections.add(Arrays.asList(Boolean.TRUE, Boolean.FALSE, Boolean.FALSE)); searchCriteriaSelections.add(Arrays.asList(Boolean.FALSE, Boolean.TRUE, Boolean.TRUE)); } public List> getSearchCriteriaSelections(){ return this.searchCriteriaSelections; } public void setSearchCriteriaSelections(List> selections){ this.searchCriteriaSelections = selections; } /** * Filters that can be applied to this tabs searches */ private List searchCriteria = new ArrayList(); { searchCriteria.add(new SearchCriteria("Crittery critters")); searchCriteria.add(new SearchCriteria("Woodland creatures")); } public List getSearchCriteria(){ return this.searchCriteria; } public void setSearchCriteria(List searchCriteria){ this.searchCriteria = searchCriteria; } /** * 2D list of options available for each criteria */ private List> searchCriteriaOptions = new ArrayList>(); public List> getSearchCriteriaOptions() { return this.searchCriteriaOptions; } public void setSearchCriteriaOptions(List> searchCriteriaOptions) { this.searchCriteriaOptions = searchCriteriaOptions; } } ognl-2.7.3.orig/src/test/java/org/ognl/test/objects/BeanProviderAccessor.java0000644000175000017500000000373010745155540027061 0ustar drazzibdrazzib/** * */ package org.ognl.test.objects; import ognl.*; import ognl.enhance.ExpressionCompiler; import ognl.enhance.UnsupportedCompilationException; import java.util.Map; /** * Implementation of provider that works with {@link BeanProvider} instances. */ public class BeanProviderAccessor extends ObjectPropertyAccessor implements PropertyAccessor { public Object getProperty(Map context, Object target, Object name) throws OgnlException { BeanProvider provider = (BeanProvider)target; String beanName = (String)name; return provider.getBean(beanName); } /** * Returns true if the name matches a bean provided by the provider. * Otherwise invokes the super implementation. * **/ public boolean hasGetProperty(Map context, Object target, Object oname) throws OgnlException { BeanProvider provider = (BeanProvider)target; String beanName = ((String)oname).replaceAll("\"", ""); return provider.getBean(beanName) != null; } public String getSourceAccessor(OgnlContext context, Object target, Object name) { BeanProvider provider = (BeanProvider)target; String beanName = ((String)name).replaceAll("\"", ""); if (provider.getBean(beanName) != null) { context.setCurrentAccessor(BeanProvider.class); context.setCurrentType(provider.getBean(beanName).getClass()); ExpressionCompiler.addCastString(context, "((" + OgnlRuntime.getCompiler().getInterfaceClass(provider.getBean(beanName).getClass()).getName() + ")"); return ".getBean(\"" + beanName + "\"))"; } return super.getSourceAccessor(context, target, name); } public String getSourceSetter(OgnlContext context, Object target, Object name) { throw new UnsupportedCompilationException("Can't set beans on BeanProvider."); } } ognl-2.7.3.orig/src/test/java/org/ognl/test/objects/EvenOdd.java0000644000175000017500000000114410572153323024332 0ustar drazzibdrazzibpackage org.ognl.test.objects; /** * */ public class EvenOdd { private boolean even = true; /** * Returns "even" or "odd". Whatever it returns on one invocation, it will * return the opposite on the next. By default, the first value returned is * "even". */ public String getNext() { String result = even ? "even" : "odd"; even = !even; return result; } public boolean isEven() { return even; } /** * Overrides the even flag. */ public void setEven(boolean value) { even = value; } } ognl-2.7.3.orig/src/test/java/org/ognl/test/objects/SearchCriteria.java0000644000175000017500000000042610712710134025673 0ustar drazzibdrazzibpackage org.ognl.test.objects; /** * Test for OGNL-131. */ public class SearchCriteria { String _displayName; public SearchCriteria(String name) { _displayName = name; } public String getDisplayName() { return _displayName; } } ognl-2.7.3.orig/src/test/java/org/ognl/test/objects/Cracker.java0000644000175000017500000000030610713163323024355 0ustar drazzibdrazzibpackage org.ognl.test.objects; import java.io.Serializable; /** * Generic test object. */ public interface Cracker{ T getParam(); void setParam(T param); } ognl-2.7.3.orig/src/test/java/org/ognl/test/objects/BaseGeneric.java0000644000175000017500000000140110713163323025147 0ustar drazzibdrazzibpackage org.ognl.test.objects; import java.io.Serializable; /** * Used to test ognl handling of java generics. */ public class BaseGeneric { E _value; GenericService _service; protected I[] ids; public BaseGeneric() { _service = new GenericServiceImpl(); } public void setIds(I[] ids) { this.ids = ids; } public I[] getIds() { return this.ids; } public String getMessage() { return "Message"; } public E getValue() { return _value; } public GenericService getService() { return _service; } public String format(Object value) { return value.toString(); } } ognl-2.7.3.orig/src/test/java/org/ognl/test/objects/TestImpl.java0000644000175000017500000000044610611511321024541 0ustar drazzibdrazzibpackage org.ognl.test.objects; import java.util.HashMap; import java.util.Map; /** * */ public class TestImpl extends TestClass { public Map getTheMap() { Map map = new HashMap(); map.put("key", "value"); return map; } } ognl-2.7.3.orig/src/test/java/org/ognl/test/objects/FormComponentImpl.java0000644000175000017500000000042610604045342026415 0ustar drazzibdrazzibpackage org.ognl.test.objects; /** * */ public class FormComponentImpl extends ComponentImpl implements IFormComponent { IForm _form; public IForm getForm() { return _form; } public void setForm(IForm form) { _form = form; } } ognl-2.7.3.orig/src/test/java/org/ognl/test/objects/Bean3.java0000644000175000017500000000647210566476144023763 0ustar drazzibdrazzib// -------------------------------------------------------------------------- // Copyright (c) 2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. // -------------------------------------------------------------------------- package org.ognl.test.objects; import java.util.HashMap; import java.util.Map; public class Bean3 extends Object { private int value = 100; private Map map; { map = new HashMap(); map.put("foo", "bar"); map.put("bar", "baz"); } private String _nullValue; private Object _indexValue; public int getValue() { return value; } public void setValue(int value) { this.value = value; } public Object getIndexedValue(int index) { return _indexValue; } public void setIndexedValue(int index, Object value) { _indexValue = value; } public Map getMap() { return map; } public void setNullValue(String value) { _nullValue = value; } public String getNullValue() { return _nullValue; } /* (non-Javadoc) * @see java.lang.Object#hashCode() */ public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((_indexValue == null) ? 0 : _indexValue.hashCode()); return result; } /* (non-Javadoc) * @see java.lang.Object#equals(java.lang.Object) */ public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; final Bean3 other = (Bean3) obj; if (_indexValue == null) { if (other._indexValue != null) return false; } else if (!_indexValue.equals(other._indexValue)) return false; return true; } } ognl-2.7.3.orig/src/test/java/org/ognl/test/objects/SubclassSyntheticObject.java0000644000175000017500000000035210744211276027612 0ustar drazzibdrazzibpackage org.ognl.test.objects; import java.util.ArrayList; /** * Simple subclass. */ public class SubclassSyntheticObject extends BaseSyntheticObject { public ArrayList getList() { return new ArrayList(); } } ognl-2.7.3.orig/src/test/java/org/ognl/test/objects/Inherited.java0000644000175000017500000000014510611754366024731 0ustar drazzibdrazzibpackage org.ognl.test.objects; /** * */ public interface Inherited { String getMyString(); } ognl-2.7.3.orig/src/test/java/org/ognl/test/objects/GenericCracker.java0000644000175000017500000000041310713163323025651 0ustar drazzibdrazzibpackage org.ognl.test.objects; /** * */ public class GenericCracker implements Cracker { Integer _param; public Integer getParam() { return _param; } public void setParam(Integer param) { _param = param; } } ognl-2.7.3.orig/src/test/java/org/ognl/test/objects/ComponentSubclass.java0000644000175000017500000000040010604045342026437 0ustar drazzibdrazzibpackage org.ognl.test.objects; /** * */ public class ComponentSubclass extends ComponentImpl { int _count = 0; public int getCount() { return _count; } public void setCount(int count) { _count = count; } } ognl-2.7.3.orig/src/test/java/org/ognl/test/objects/ObjectIndexed.java0000644000175000017500000000374010561411075025520 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package org.ognl.test.objects; public class ObjectIndexed extends BaseObjectIndexed { public ObjectIndexed() { super(); setAttribute("foo", "bar"); setAttribute("bar", "baz"); setAttribute("other", new OtherObjectIndexed()); } } ognl-2.7.3.orig/src/test/java/org/ognl/test/objects/OtherObjectIndexed.java0000644000175000017500000000366110561411075026524 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package org.ognl.test.objects; public class OtherObjectIndexed extends BaseObjectIndexed { public OtherObjectIndexed() { super(); setAttribute("foo", "bar"); setAttribute("bar", "baz"); } } ognl-2.7.3.orig/src/test/java/org/ognl/test/objects/BeanProvider.java0000644000175000017500000000061710566476144025406 0ustar drazzibdrazzib/** * */ package org.ognl.test.objects; /** * Test interface to be used with a custom propery accessor. */ public interface BeanProvider { /** * Gets a bean by name. * @param name * @return */ Object getBean(String name); /** * Sets a new bean mapping. * @param name * @param bean */ void setBean(String name, Object bean); } ognl-2.7.3.orig/src/test/java/org/ognl/test/objects/TreeContentProvider.java0000644000175000017500000000073210613454527026763 0ustar drazzibdrazzibpackage org.ognl.test.objects; import java.util.Collection; import java.util.Collections; import java.util.List; /** * */ public class TreeContentProvider implements ITreeContentProvider { public Collection getChildren(Object parentElement) { return Collections.EMPTY_LIST; } public boolean hasChildren(Object parentElement) { return true; } public List getElements() { return Collections.EMPTY_LIST; } } ognl-2.7.3.orig/src/test/java/org/ognl/test/objects/Model.java0000644000175000017500000000020110616716326024046 0ustar drazzibdrazzibpackage org.ognl.test.objects; /** * */ public class Model { public int getOptionCount() { return 1; } } ognl-2.7.3.orig/src/test/java/org/ognl/test/objects/ComponentImpl.java0000644000175000017500000000070110604045342025565 0ustar drazzibdrazzibpackage org.ognl.test.objects; /** * */ public class ComponentImpl implements IComponent { String _clientId; int _count = 0; public String getClientId() { return _clientId; } public void setClientId(String id) { _clientId = id; } public int getCount(String index) { return _count; } public void setCount(String index, int count) { _count = count; } } ognl-2.7.3.orig/src/test/java/org/ognl/test/objects/MyMapImpl.java0000644000175000017500000000570410561411075024660 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package org.ognl.test.objects; import java.util.*; /** This tests the interface inheritence test. This test implements MyMap->Map but extends Object, therefore should be coded using MapPropertyAccessor instead of ObjectPropertyAccessor. */ public class MyMapImpl extends Object implements MyMap { private Map map = new HashMap(); public void clear() { map.clear(); } public boolean containsKey(Object key) { return map.containsKey(key); } public boolean containsValue(Object value) { return map.containsValue(value); } public Set entrySet() { return map.entrySet(); } public boolean equals(Object o) { return map.equals(o); } public Object get(Object key) { return map.get(key); } public int hashCode() { return map.hashCode(); } public boolean isEmpty() { return map.isEmpty(); } public Set keySet() { return map.keySet(); } public Object put(Object key, Object value) { return map.put(key, value); } public void putAll(Map t) { map.putAll(t); } public Object remove(Object key) { return map.remove(key); } public int size() { return map.size(); } public Collection values() { return map.values(); } public String getDescription() { return "MyMap implementation"; } } ognl-2.7.3.orig/src/test/java/org/ognl/test/objects/CorrectedObject.java0000644000175000017500000000413210655141672026055 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package org.ognl.test.objects; public class CorrectedObject { public CorrectedObject() { } public void setStringValue(String value) { } public String getStringValue() { return null; } public String getIndexedStringValue(String key) { return null; } public void setIndexedStringValue(String key, String value) { } } ognl-2.7.3.orig/src/test/java/org/ognl/test/objects/PropertyHolder.java0000644000175000017500000000115110713112566025767 0ustar drazzibdrazzibpackage org.ognl.test.objects; /** * Simple class used to test various kind of property resolutions. */ public class PropertyHolder { String _value = ""; String _search = "foo"; public String getValue() { return _value; } public void setValue(String value) { _value = value; } public boolean hasValue() { return _value != null && _value.length() > 0; } public void setSearch(String value) { _search = value; } public String getSearch() { return _search; } public void search() { } } ognl-2.7.3.orig/src/test/java/org/ognl/test/objects/ListSourceImpl.java0000644000175000017500000000062210651175157025733 0ustar drazzibdrazzibpackage org.ognl.test.objects; import java.util.ArrayList; /** * */ public class ListSourceImpl extends ArrayList implements ListSource { public ListSourceImpl() { } public int getTotal() { return super.size(); } public Object addValue(Object value) { return super.add(value); } public Object getName() { return null; } } ognl-2.7.3.orig/src/test/java/org/ognl/test/objects/TestInherited2.java0000644000175000017500000000025210611754366025652 0ustar drazzibdrazzibpackage org.ognl.test.objects; /** * */ public class TestInherited2 implements Inherited { public String getMyString() { return "inherited2"; } } ognl-2.7.3.orig/src/test/java/org/ognl/test/objects/TestClass.java0000644000175000017500000000012010611511321024672 0ustar drazzibdrazzibpackage org.ognl.test.objects; /** * */ public abstract class TestClass { } ognl-2.7.3.orig/src/test/java/org/ognl/test/objects/Entry.java0000644000175000017500000000101510621705703024104 0ustar drazzibdrazzibpackage org.ognl.test.objects; /** * */ public class Entry { private int _size = 1; public int size() { return _size; } public Copy getCopy() { return new Copy(); } public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Entry entry = (Entry) o; return _size == entry._size; } public int hashCode() { return _size; } } ognl-2.7.3.orig/src/test/java/org/ognl/test/objects/FormImpl.java0000644000175000017500000000016110604045342024526 0ustar drazzibdrazzibpackage org.ognl.test.objects; /** * */ public class FormImpl extends ComponentImpl implements IForm { } ognl-2.7.3.orig/src/test/java/org/ognl/test/objects/GameGenericObject.java0000644000175000017500000000054610707375101026310 0ustar drazzibdrazzibpackage org.ognl.test.objects; /** * */ public class GameGenericObject implements GenericObject { public GameGenericObject() { super(); } public int getId() { return 20; } public String getDisplayName() { return "Halo 3"; } public String getHappy() { return "happy"; } } ognl-2.7.3.orig/src/test/java/org/ognl/test/objects/Component.java0000644000175000017500000000535110561411075024753 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package org.ognl.test.objects; public class Component extends Object { private URLStorage toDisplay = new URLStorage(); private Page page = new Page(); public static class URLStorage extends Object { private String pictureUrl = "http://www.picturespace.com/pictures/100"; public String getPictureUrl() { return pictureUrl; } public void setPictureUrl(String value) { pictureUrl = value; } } public static class Page extends Object { public Object createRelativeAsset(String value) { return "/toplevel/" + value; } } public Component() { super(); } public Page getPage() { return page; } public void setPage(Page value) { page = value; } public URLStorage getToDisplay() { return toDisplay; } public void setToDisplay(URLStorage value) { toDisplay = value; } } ognl-2.7.3.orig/src/test/java/org/ognl/test/objects/MyMap.java0000644000175000017500000000372710561411075024041 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package org.ognl.test.objects; import java.util.*; /** This tests the interface inheritence test. This is a subinterface of Map and therefore should inherit the Map property accessor. */ public interface MyMap extends Map { public String getDescription(); } ognl-2.7.3.orig/src/test/java/org/ognl/test/objects/GenericService.java0000644000175000017500000000035510707375101025706 0ustar drazzibdrazzibpackage org.ognl.test.objects; /** * */ public interface GenericService { String getFullMessageFor(PersonGenericObject person, Object...arguments); String getFullMessageFor(GameGenericObject game, Object...arguments); } ognl-2.7.3.orig/src/test/java/org/ognl/test/objects/GenericRoot.java0000644000175000017500000000070610713163323025227 0ustar drazzibdrazzibpackage org.ognl.test.objects; /** * */ public class GenericRoot { Root _root = new Root(); GenericCracker _cracker = new GenericCracker(); public Root getRoot() { return _root; } public void setRoot(Root root) { _root = root; } public GenericCracker getCracker() { return _cracker; } public void setCracker(GenericCracker cracker) { _cracker = cracker; } } ognl-2.7.3.orig/src/test/java/org/ognl/test/objects/IFormComponent.java0000644000175000017500000000027210604045342025703 0ustar drazzibdrazzibpackage org.ognl.test.objects; /** * */ public interface IFormComponent extends IComponent { String getClientId(); IForm getForm(); void setForm(IForm form); } ognl-2.7.3.orig/src/test/java/org/ognl/test/objects/SecondBean.java0000644000175000017500000000025010566476144025020 0ustar drazzibdrazzib/** * */ package org.ognl.test.objects; /** */ public class SecondBean extends BaseBean { public String getName() { return "SecondBean"; } } ognl-2.7.3.orig/src/test/java/org/ognl/test/objects/IndexedSetObject.java0000644000175000017500000000126010776755160026205 0ustar drazzibdrazzibpackage org.ognl.test.objects; import java.util.HashMap; /** * Test for OGNL-119. */ public class IndexedSetObject { private final HashMap things = new HashMap(); public IndexedSetObject() { things.put("x", new Container(1)); } public Object getThing(String index) { return things.get(index); } public void setThing(String index, Object value) { things.put(index, value); } public static class Container { private int val; public Container(int val) { this.val = val; } public int getVal() { return val; } public void setVal(int val) { this.val = val; } } } ognl-2.7.3.orig/src/test/java/org/ognl/test/objects/Two.java0000644000175000017500000000036110613456137023564 0ustar drazzibdrazzibpackage org.ognl.test.objects; /** * */ public class Two { public String getMessage(String mes) { return "[" + mes + "]"; } public boolean hasChildren(String name) { return name.length() > 2; } } ognl-2.7.3.orig/src/test/java/org/ognl/test/objects/GameGeneric.java0000644000175000017500000000030510712710134025145 0ustar drazzibdrazzibpackage org.ognl.test.objects; /** * */ public class GameGeneric extends BaseGeneric { public GameGeneric() { _value = new GameGenericObject(); } } ognl-2.7.3.orig/src/test/java/org/ognl/test/objects/PersonGenericObject.java0000644000175000017500000000035710705207045026704 0ustar drazzibdrazzibpackage org.ognl.test.objects; /** * */ public class PersonGenericObject implements GenericObject { public int getId() { return 1; } public String getDisplayName() { return "Henry Collins"; } } ognl-2.7.3.orig/src/test/java/org/ognl/test/objects/ListSource.java0000644000175000017500000000026010651175157025107 0ustar drazzibdrazzibpackage org.ognl.test.objects; /** * */ public interface ListSource { public int getTotal(); public Object addValue(Object value); public Object getName(); } ognl-2.7.3.orig/src/test/java/org/ognl/test/objects/BaseIndexed.java0000644000175000017500000000027210630111064025151 0ustar drazzibdrazzibpackage org.ognl.test.objects; /** * Class used to test inheritance. */ public class BaseIndexed { public Object getLine(int index) { return "line:" + index; } } ognl-2.7.3.orig/src/test/java/org/ognl/test/objects/BeanProviderImpl.java0000644000175000017500000000077210566476144026232 0ustar drazzibdrazzib/** * */ package org.ognl.test.objects; import java.io.Serializable; import java.util.HashMap; import java.util.Map; /** * Implementation of {@link BeanProvider}. */ public class BeanProviderImpl implements Serializable, BeanProvider { private Map _map = new HashMap(); public BeanProviderImpl() {} public Object getBean(String name) { return _map.get(name); } public void setBean(String name, Object bean) { _map.put(name, bean); } } ognl-2.7.3.orig/src/test/java/org/ognl/test/objects/SimpleEnum.java0000644000175000017500000000036210620513277025067 0ustar drazzibdrazzibpackage org.ognl.test.objects; /** * */ public enum SimpleEnum { ONE (1); private int _value; private SimpleEnum(int value) { _value = value; } public int getValue() { return _value; } } ognl-2.7.3.orig/src/test/java/org/ognl/test/objects/IForm.java0000644000175000017500000000013610604045342024017 0ustar drazzibdrazzibpackage org.ognl.test.objects; /** * */ public interface IForm extends IComponent { } ognl-2.7.3.orig/src/test/java/org/ognl/test/objects/BaseObjectIndexed.java0000644000175000017500000000507310561411075026314 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package org.ognl.test.objects; import java.util.*; public class BaseObjectIndexed extends Object { private Map attributes = new HashMap(); public BaseObjectIndexed() { super(); } public Map getAttributes() { return attributes; } public Object getAttribute(String name) { return attributes.get(name); } public void setAttribute(String name, Object value) { attributes.put(name, value); } /* allow testing property name where types do not match */ public Object getOtherAttribute(String name) { return null; } public void setOtherAttribute(Object someObject, Object foo) { /* do nothing */ } /* test whether get only is found */ public Object getSecondaryAttribute(Object name) { return attributes.get(name); } } ognl-2.7.3.orig/src/test/java/org/ognl/test/objects/TestInherited1.java0000644000175000017500000000025210611754366025651 0ustar drazzibdrazzibpackage org.ognl.test.objects; /** * */ public class TestInherited1 implements Inherited { public String getMyString() { return "inherited1"; } } ognl-2.7.3.orig/src/test/java/org/ognl/test/objects/MenuItem.java0000644000175000017500000000154510600650435024534 0ustar drazzibdrazzibpackage org.ognl.test.objects; import java.util.ArrayList; import java.util.List; /** * */ public class MenuItem { private String page; private String label; private List children = new ArrayList(); public MenuItem(String page, String label){ this(page, label, new ArrayList()); } public MenuItem(String page, String label, List children){ this.page = page; this.label = label; this.children = children; } public List getChildren() { return children; } public String getLabel() { return label; } public String getPage() { return page; } public String toString(){ StringBuffer sb = new StringBuffer("MenuItem["); sb.append("page="+getPage()); sb.append(",label="+getLabel()); sb.append(",children="+getChildren().size()); sb.append("]"); return sb.toString(); } } ognl-2.7.3.orig/src/test/java/org/ognl/test/objects/IComponent.java0000644000175000017500000000033210604045342025054 0ustar drazzibdrazzibpackage org.ognl.test.objects; /** * */ public interface IComponent { String getClientId(); void setClientId(String id); int getCount(String index); void setCount(String index, int count); } ognl-2.7.3.orig/src/test/java/org/ognl/test/objects/BaseSyntheticObject.java0000644000175000017500000000040710744211276026706 0ustar drazzibdrazzibpackage org.ognl.test.objects; import java.util.ArrayList; import java.util.List; /** * Used to test OGNL-136 use of synthetic methods. */ public abstract class BaseSyntheticObject { protected List getList() { return new ArrayList(); } } ognl-2.7.3.orig/src/test/java/org/ognl/test/objects/Indexed.java0000644000175000017500000000653410673567723024415 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package org.ognl.test.objects; import java.util.*; public class Indexed extends BaseIndexed { private String[] _values = new String[] { "foo", "bar", "baz" }; private List _list = new ArrayList(); private ListSource _source = new ListSourceImpl(); private Map _props = new HashMap(); public Indexed() { _list.add(new Integer(1)); _list.add(new Integer(2)); _list.add(new Integer(3)); _source.addValue(new Bean2()); } public Indexed(String[] values) { _values = values; } /* Indexed property "_values" */ public String[] getValues() { return _values; } public void setValues(String[] value) { _values = value; } /** This method returns the string from the array and appends "xxx" to distinguish the "get" method from the direct array access. */ public String getValues(int index) { return _values[index] + "xxx"; } public void setValues(int index, String value) { if (value.endsWith("xxx")) { _values[index] = value.substring(0, value.length() - 3); } else { _values[index] = value; } } public Collection getList() { return _list; } public String getTitle(int count) { return "Title count " + count; } public ListSource getSource() { return _source; } public void setProperty(String property, Object value) { _props.put(property, value); } public Object getProperty(String property) { return _props.get(property); } } ognl-2.7.3.orig/src/test/java/org/ognl/test/objects/Messages.java0000644000175000017500000000124610610173637024563 0ustar drazzibdrazzibpackage org.ognl.test.objects; import java.util.Map; /** * */ public class Messages { Map _source; public Messages(Map source) { _source = source; } public String getMessage(String key) { return (String)_source.get(key); } public String format(String key, Object[] parms) { return "foo"; } public String format(String key, Object param1, Object param2, Object param3) { return "blah"; } public String format(String key, Object param1) { return "first"; } public String format(String key, Object param1, Object param2) { return "haha"; } } ognl-2.7.3.orig/src/test/java/org/ognl/test/objects/BaseBean.java0000644000175000017500000000104610613456137024454 0ustar drazzibdrazzib/** * */ package org.ognl.test.objects; /** * Base class used to test inheritance class casting. */ public abstract class BaseBean { public abstract String getName(); public boolean getActive() { return true; } public boolean isActive2() { return true; } public Two getTwo() { return new Two(); } public String getMessage(String mes) { return "[" + mes + "]"; } public boolean hasChildren(String name) { return name.length() > 2; } } ognl-2.7.3.orig/src/test/java/org/ognl/test/objects/IndexedMapObject.java0000644000175000017500000000051510646471653026167 0ustar drazzibdrazzibpackage org.ognl.test.objects; /** * Simple object used to test indexed map references using "#this" references. */ public class IndexedMapObject { String property; public IndexedMapObject(String property) { this.property = property; } public String getProperty() { return property; } } ognl-2.7.3.orig/src/test/java/org/ognl/test/objects/GenericServiceImpl.java0000644000175000017500000000063110707375101026525 0ustar drazzibdrazzibpackage org.ognl.test.objects; /** * */ public class GenericServiceImpl implements GenericService { public String getFullMessageFor(GameGenericObject game, Object... arguments) { game.getHappy(); return game.getDisplayName(); } public String getFullMessageFor(PersonGenericObject person, Object... arguments) { return person.getDisplayName(); } } ognl-2.7.3.orig/src/test/java/org/ognl/test/objects/GenericObject.java0000644000175000017500000000026510705207045025513 0ustar drazzibdrazzibpackage org.ognl.test.objects; /** * Used by {@link BaseGeneric} to reference a class type. */ public interface GenericObject { int getId(); String getDisplayName(); } ognl-2.7.3.orig/src/test/java/org/ognl/test/objects/FirstBean.java0000644000175000017500000000025310566476144024677 0ustar drazzibdrazzib/** * */ package org.ognl.test.objects; /** */ public class FirstBean extends BaseBean { public String getName() { return "FirstBean"; } } ognl-2.7.3.orig/src/test/java/org/ognl/test/objects/Bean1.java0000644000175000017500000000360010561411075023732 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package org.ognl.test.objects; public class Bean1 extends Object { private Bean2 bean2 = new Bean2(); public Bean2 getBean2() { return bean2; } } ognl-2.7.3.orig/src/test/java/org/ognl/test/objects/SetterReturns.java0000644000175000017500000000042710617170224025641 0ustar drazzibdrazzibpackage org.ognl.test.objects; /** * */ public class SetterReturns { private String _value = ""; public String getValue() { return _value; } public SetterReturns setValue(String value) { _value += value; return this; } } ognl-2.7.3.orig/src/test/java/org/ognl/test/objects/SimpleNumeric.java0000644000175000017500000000053310704232420025554 0ustar drazzibdrazzibpackage org.ognl.test.objects; /** * Used for {@link org.ognl.test.PropertyArithmeticAndLogicalOperatorsTest}. */ public class SimpleNumeric { public double getBudget() { return 140; } public double getTimeBilled() { return 24.12; } public String getTableSize() { return "10"; } } ognl-2.7.3.orig/src/test/java/org/ognl/test/objects/ITreeContentProvider.java0000644000175000017500000000037510613454527027077 0ustar drazzibdrazzibpackage org.ognl.test.objects; import java.util.Collection; /** * */ public interface ITreeContentProvider extends IContentProvider { public Collection getChildren(Object parentElement); public boolean hasChildren(Object parentElement); } ognl-2.7.3.orig/src/test/java/org/ognl/test/objects/TestModel.java0000644000175000017500000000055010616716326024715 0ustar drazzibdrazzibpackage org.ognl.test.objects; /** * */ public class TestModel { public Copy getCopy() { return new Copy(); } public Model getUnassignedCopyModel() { return new Model(); } public boolean isCanApproveCopy() { return true; } public Entry getEntry() { return new Entry(); } } ognl-2.7.3.orig/src/test/java/org/ognl/test/objects/Simple.java0000644000175000017500000001255510704244757024260 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package org.ognl.test.objects; import org.ognl.test.OgnlTestCase; import java.math.BigDecimal; import java.math.BigInteger; import java.util.HashMap; import java.util.Map; public class Simple extends Object { private String stringValue = "test"; private float floatValue; private int intValue; private boolean booleanValue; private BigInteger bigIntValue = BigInteger.valueOf(0); private BigDecimal bigDecValue = new BigDecimal(0.0); private Root root = new Root(); private Bean3 _bean; private Bean2 _bean2; private Object[] _array; private Messages _messages; public Simple() { Map src = new HashMap(); src.put("test", "This is a test"); _messages = new Messages(src); } public Simple(Bean3 bean) { _bean = bean; } public Simple(Bean2 bean) { _bean2 = bean; } public Simple(Object[] values) { super(); } public Simple(String stringValue, float floatValue, int intValue) { super(); this.stringValue = stringValue; this.floatValue = floatValue; this.intValue = intValue; } public void setValues(String stringValue, float floatValue, int intValue) { this.stringValue = stringValue; this.floatValue = floatValue; this.intValue = intValue; } public String getStringValue() { return stringValue; } public void setStringValue(String value) { stringValue = value; } public float getFloatValue() { return floatValue; } public void setFloatValue(float value) { floatValue = value; } public int getIntValue() { return intValue; } public void setIntValue(int value) { intValue = value; } public boolean getValueIsTrue(Object currValue) { return true; } public boolean getBooleanValue() { return booleanValue; } public void setBooleanValue(boolean value) { booleanValue = value; } public BigInteger getBigIntValue() { return bigIntValue; } public void setArray(Object[] values) { _array = values; } public Object[] getArray() { return _array; } public void setBigIntValue(BigInteger value) { bigIntValue = value; } public BigDecimal getBigDecValue() { return bigDecValue; } public void setBigDecValue(BigDecimal value) { bigDecValue = value; } public Root getRootValue() { return root; } public Messages getMessages() { return _messages; } public int getOne() { return 1; } public int getTwo() { return 2; } public int getThree() { return 3; } public int getTestValue(int val) { return val + 1; } public boolean isEditorDisabled() { return false; } public boolean isDisabled() { return true; } public GetterMethods getMethodsTest() { return new GetterMethods(); } public String getDisplayValue(int val) { return "test"; } public boolean equals(Object other) { boolean result = false; if (other instanceof Simple) { Simple os = (Simple)other; result = OgnlTestCase.isEqual(os.getStringValue(), getStringValue()) && (os.getIntValue() == getIntValue()); } return result; } public boolean isThisVarArgsWorking(Object...arguments) { return true; } } ognl-2.7.3.orig/src/test/java/org/ognl/test/NumericConversionTest.java0000644000175000017500000002710110720370235025664 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package org.ognl.test; import junit.framework.TestSuite; import ognl.OgnlException; import ognl.OgnlOps; import java.math.BigDecimal; import java.math.BigInteger; public class NumericConversionTest extends OgnlTestCase { private static Object[][] TESTS = { /* To Integer.class */ {"55", Integer.class, new Integer(55)}, {new Integer(55), Integer.class, new Integer(55)}, {new Double(55), Integer.class, new Integer(55)}, {Boolean.TRUE, Integer.class, new Integer(1)}, {new Byte((byte) 55), Integer.class, new Integer(55)}, {new Character((char) 55), Integer.class, new Integer(55)}, {new Short((short) 55), Integer.class, new Integer(55)}, {new Long(55), Integer.class, new Integer(55)}, {new Float(55), Integer.class, new Integer(55)}, {new BigInteger("55"), Integer.class, new Integer(55)}, {new BigDecimal("55"), Integer.class, new Integer(55)}, /* To Double.class */ {"55.1234", Double.class, new Double(55.1234)}, {new Integer(55), Double.class, new Double(55)}, {new Double(55.1234), Double.class, new Double(55.1234)}, {Boolean.TRUE, Double.class, new Double(1)}, {new Byte((byte) 55), Double.class, new Double(55)}, {new Character((char) 55), Double.class, new Double(55)}, {new Short((short) 55), Double.class, new Double(55)}, {new Long(55), Double.class, new Double(55)}, {new Float(55.1234), Double.class, new Double(55.1234), new Integer(4)}, {new BigInteger("55"), Double.class, new Double(55)}, {new BigDecimal("55.1234"), Double.class, new Double(55.1234)}, /* To Boolean.class */ {"true", Boolean.class, Boolean.TRUE}, {new Integer(55), Boolean.class, Boolean.TRUE}, {new Double(55), Boolean.class, Boolean.TRUE}, {Boolean.TRUE, Boolean.class, Boolean.TRUE}, {new Byte((byte) 55), Boolean.class, Boolean.TRUE}, {new Character((char) 55), Boolean.class, Boolean.TRUE}, {new Short((short) 55), Boolean.class, Boolean.TRUE}, {new Long(55), Boolean.class, Boolean.TRUE}, {new Float(55), Boolean.class, Boolean.TRUE}, {new BigInteger("55"), Boolean.class, Boolean.TRUE}, {new BigDecimal("55"), Boolean.class, Boolean.TRUE}, /* To Byte.class */ {"55", Byte.class, new Byte((byte) 55)}, {new Integer(55), Byte.class, new Byte((byte) 55)}, {new Double(55), Byte.class, new Byte((byte) 55)}, {Boolean.TRUE, Byte.class, new Byte((byte) 1)}, {new Byte((byte) 55), Byte.class, new Byte((byte) 55)}, {new Character((char) 55), Byte.class, new Byte((byte) 55)}, {new Short((short) 55), Byte.class, new Byte((byte) 55)}, {new Long(55), Byte.class, new Byte((byte) 55)}, {new Float(55), Byte.class, new Byte((byte) 55)}, {new BigInteger("55"), Byte.class, new Byte((byte) 55)}, {new BigDecimal("55"), Byte.class, new Byte((byte) 55)}, /* To Character.class */ {"55", Character.class, new Character((char) 55)}, {new Integer(55), Character.class, new Character((char) 55)}, {new Double(55), Character.class, new Character((char) 55)}, {Boolean.TRUE, Character.class, new Character((char) 1)}, {new Byte((byte) 55), Character.class, new Character((char) 55)}, {new Character((char) 55), Character.class, new Character((char) 55)}, {new Short((short) 55), Character.class, new Character((char) 55)}, {new Long(55), Character.class, new Character((char) 55)}, {new Float(55), Character.class, new Character((char) 55)}, {new BigInteger("55"), Character.class, new Character((char) 55)}, {new BigDecimal("55"), Character.class, new Character((char) 55)}, /* To Short.class */ {"55", Short.class, new Short((short) 55)}, {new Integer(55), Short.class, new Short((short) 55)}, {new Double(55), Short.class, new Short((short) 55)}, {Boolean.TRUE, Short.class, new Short((short) 1)}, {new Byte((byte) 55), Short.class, new Short((short) 55)}, {new Character((char) 55), Short.class, new Short((short) 55)}, {new Short((short) 55), Short.class, new Short((short) 55)}, {new Long(55), Short.class, new Short((short) 55)}, {new Float(55), Short.class, new Short((short) 55)}, {new BigInteger("55"), Short.class, new Short((short) 55)}, {new BigDecimal("55"), Short.class, new Short((short) 55)}, /* To Long.class */ {"55", Long.class, new Long(55)}, {new Integer(55), Long.class, new Long(55)}, {new Double(55), Long.class, new Long(55)}, {Boolean.TRUE, Long.class, new Long(1)}, {new Byte((byte) 55), Long.class, new Long(55)}, {new Character((char) 55), Long.class, new Long(55)}, {new Short((short) 55), Long.class, new Long(55)}, {new Long(55), Long.class, new Long(55)}, {new Float(55), Long.class, new Long(55)}, {new BigInteger("55"), Long.class, new Long(55)}, {new BigDecimal("55"), Long.class, new Long(55)}, /* To Float.class */ {"55.1234", Float.class, new Float(55.1234)}, {new Integer(55), Float.class, new Float(55)}, {new Double(55.1234), Float.class, new Float(55.1234)}, {Boolean.TRUE, Float.class, new Float(1)}, {new Byte((byte) 55), Float.class, new Float(55)}, {new Character((char) 55), Float.class, new Float(55)}, {new Short((short) 55), Float.class, new Float(55)}, {new Long(55), Float.class, new Float(55)}, {new Float(55.1234), Float.class, new Float(55.1234)}, {new BigInteger("55"), Float.class, new Float(55)}, {new BigDecimal("55.1234"), Float.class, new Float(55.1234)}, /* To BigInteger.class */ {"55", BigInteger.class, new BigInteger("55")}, {new Integer(55), BigInteger.class, new BigInteger("55")}, {new Double(55), BigInteger.class, new BigInteger("55")}, {Boolean.TRUE, BigInteger.class, new BigInteger("1")}, {new Byte((byte) 55), BigInteger.class, new BigInteger("55")}, {new Character((char) 55), BigInteger.class, new BigInteger("55")}, {new Short((short) 55), BigInteger.class, new BigInteger("55")}, {new Long(55), BigInteger.class, new BigInteger("55")}, {new Float(55), BigInteger.class, new BigInteger("55")}, {new BigInteger("55"), BigInteger.class, new BigInteger("55")}, {new BigDecimal("55"), BigInteger.class, new BigInteger("55")}, /* To BigDecimal.class */ {"55.1234", BigDecimal.class, new BigDecimal("55.1234")}, {new Integer(55), BigDecimal.class, new BigDecimal("55")}, {new Double(55.1234), BigDecimal.class, new BigDecimal("55.1234"), new Integer(4)}, {Boolean.TRUE, BigDecimal.class, new BigDecimal("1")}, {new Byte((byte) 55), BigDecimal.class, new BigDecimal("55")}, {new Character((char) 55), BigDecimal.class, new BigDecimal("55")}, {new Short((short) 55), BigDecimal.class, new BigDecimal("55")}, {new Long(55), BigDecimal.class, new BigDecimal("55")}, {new Float(55.1234), BigDecimal.class, new BigDecimal("55.1234"), new Integer(4)}, {new BigInteger("55"), BigDecimal.class, new BigDecimal("55")}, {new BigDecimal("55.1234"), BigDecimal.class, new BigDecimal("55.1234")}, }; private Object value; private Class toClass; private Object expectedValue; private int scale; /*=================================================================== Public static methods ===================================================================*/ public static TestSuite suite() { TestSuite result = new TestSuite(); for (int i = 0; i < TESTS.length; i++) { result.addTest(new NumericConversionTest(TESTS[i][0], (Class) TESTS[i][1], TESTS[i][2], (TESTS[i].length > 3) ? ((Integer) TESTS[i][3]).intValue() : -1)); } return result; } /*=================================================================== Constructors ===================================================================*/ public NumericConversionTest(Object value, Class toClass, Object expectedValue, int scale) { super(value + " [" + value.getClass().getName() + "] -> " + toClass.getName() + " == " + expectedValue + " [" + expectedValue.getClass().getName() + "]" + ((scale >= 0) ? (" (to within " + scale + " decimal places)") : "")); this.value = value; this.toClass = toClass; this.expectedValue = expectedValue; this.scale = scale; } /*=================================================================== Overridden methods ===================================================================*/ protected void runTest() throws OgnlException { Object result; result = OgnlOps.convertValue(value, toClass); if (!isEqual(result, expectedValue)) { if (scale >= 0) { double scalingFactor = Math.pow(10, scale), v1 = ((Number) value).doubleValue() * scalingFactor, v2 = ((Number) expectedValue).doubleValue() * scalingFactor; assertTrue((int) v1 == (int) v2); } else { fail(); } } } } ognl-2.7.3.orig/src/test/java/org/ognl/test/ClassMethodTest.java0000644000175000017500000000773510646475141024446 0ustar drazzibdrazzib// -------------------------------------------------------------------------- // Copyright (c) 2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. // -------------------------------------------------------------------------- package org.ognl.test; import junit.framework.TestSuite; import org.ognl.test.objects.CorrectedObject; public class ClassMethodTest extends OgnlTestCase { private static CorrectedObject CORRECTED = new CorrectedObject(); private static Object[][] TESTS = { // Methods on Class { CORRECTED, "getClass().getName()", CORRECTED.getClass().getName() }, { CORRECTED, "getClass().getInterfaces()", CORRECTED.getClass().getInterfaces() }, { CORRECTED, "getClass().getInterfaces().length", new Integer(CORRECTED.getClass().getInterfaces().length) }, { null, "@System@class.getInterfaces()", System.class.getInterfaces() }, { null, "@Class@class.getName()", Class.class.getName() }, { null, "@java.awt.image.ImageObserver@class.getName()", java.awt.image.ImageObserver.class.getName() }, }; /* * =================================================================== Public static methods * =================================================================== */ public static TestSuite suite() { TestSuite result = new TestSuite(); for(int i = 0; i < TESTS.length; i++) { result.addTest(new ClassMethodTest((String) TESTS[i][1], TESTS[i][0], (String) TESTS[i][1], TESTS[i][2])); } return result; } /* * =================================================================== Constructors * =================================================================== */ public ClassMethodTest() { super(); } public ClassMethodTest(String name) { super(name); } public ClassMethodTest(String name, Object root, String expressionString, Object expectedResult, Object setValue, Object expectedAfterSetResult) { super(name, root, expressionString, expectedResult, setValue, expectedAfterSetResult); } public ClassMethodTest(String name, Object root, String expressionString, Object expectedResult, Object setValue) { super(name, root, expressionString, expectedResult, setValue); } public ClassMethodTest(String name, Object root, String expressionString, Object expectedResult) { super(name, root, expressionString, expectedResult); } } ognl-2.7.3.orig/src/test/java/org/ognl/test/MethodTest.java0000644000175000017500000001122110712710134023425 0ustar drazzibdrazzib// -------------------------------------------------------------------------- // Copyright (c) 2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. // -------------------------------------------------------------------------- package org.ognl.test; import junit.framework.TestSuite; import org.ognl.test.objects.*; public class MethodTest extends OgnlTestCase { private static Simple ROOT = new Simple(); private static ListSource LIST = new ListSourceImpl(); private static BaseGeneric GENERIC = new GameGeneric(); private static Object[][] TESTS = { { "hashCode()", new Integer(ROOT.hashCode()) } , { "getBooleanValue() ? \"here\" : \"\"", ""}, { "getValueIsTrue(!false) ? \"\" : \"here\" ", ""}, { "messages.format('ShowAllCount', one)", "foo"}, { "getTestValue(@org.ognl.test.objects.SimpleEnum@ONE.value)", new Integer(2)}, { "@org.ognl.test.MethodTest@getA().isProperty()", Boolean.FALSE}, { "isDisabled()", Boolean.TRUE}, { "isEditorDisabled()", Boolean.FALSE}, { LIST, "addValue(name)", Boolean.TRUE}, { "getDisplayValue(methodsTest.allowDisplay)", "test"}, { "isThisVarArgsWorking(three, rootValue)", Boolean.TRUE}, { GENERIC, "service.getFullMessageFor(value, null)", "Halo 3"} }; public static class A { public boolean isProperty() { return false; } } public static A getA() { return new A(); } /* * =================================================================== Public static methods * =================================================================== */ public static TestSuite suite() { TestSuite result = new TestSuite(); for(int i = 0; i < TESTS.length; i++) { if (TESTS[i].length == 3) { result.addTest(new MethodTest((String) TESTS[i][1] + " (" + TESTS[i][2] + ")", TESTS[i][0], (String) TESTS[i][1], TESTS[i][2])); } else { result.addTest(new MethodTest((String) TESTS[i][0] + " (" + TESTS[i][1] + ")", ROOT, (String) TESTS[i][0], TESTS[i][1])); } } return result; } /* * =================================================================== Constructors * =================================================================== */ public MethodTest() { super(); } public MethodTest(String name) { super(name); } public MethodTest(String name, Object root, String expressionString, Object expectedResult, Object setValue, Object expectedAfterSetResult) { super(name, root, expressionString, expectedResult, setValue, expectedAfterSetResult); } public MethodTest(String name, Object root, String expressionString, Object expectedResult, Object setValue) { super(name, root, expressionString, expectedResult, setValue); } public MethodTest(String name, Object root, String expressionString, Object expectedResult) { super(name, root, expressionString, expectedResult); } } ognl-2.7.3.orig/src/test/java/org/ognl/test/ObjectIndexedTest.java0000644000175000017500000001367310561411075024735 0ustar drazzibdrazzibpackage org.ognl.test; import junit.framework.TestCase; import junit.framework.TestSuite; import ognl.Ognl; import ognl.OgnlContext; import ognl.OgnlException; import ognl.OgnlRuntime; import ognl.SimpleNode; public class ObjectIndexedTest extends TestCase { protected OgnlContext context; /*=================================================================== Public static classes ===================================================================*/ public static interface TestInterface { String getSunk(String index); void setSunk(String index, String sunk); } public static class Test1 extends Object implements TestInterface { public String getSunk(String index) { return "foo"; } public void setSunk(String index, String sunk) { /* do nothing */ } } public static class Test2 extends Test1 { public String getSunk(String index) { return "foo"; } public void setSunk(String index, String sunk) { /* do nothing */ } } public static class Test3 extends Test1 { public String getSunk(String index) { return "foo"; } public void setSunk(String index, String sunk) { /* do nothing */ } public String getSunk(Object index) { return null; } } public static class Test4 extends Test1 { public String getSunk(String index) { return "foo"; } public void setSunk(String index, String sunk) { /* do nothing */ } public void setSunk(Object index, String sunk) { /* do nothing */ } } public static class Test5 extends Test1 { public String getSunk(String index) { return "foo"; } public void setSunk(String index, String sunk) { /* do nothing */ } public String getSunk(Object index) { return null; } public void setSunk(Object index, String sunk) { /* do nothing */ } } /*=================================================================== Public static methods ===================================================================*/ public static TestSuite suite() { return new TestSuite(ObjectIndexedTest.class); } /*=================================================================== Constructors ===================================================================*/ public ObjectIndexedTest() { super(); } public ObjectIndexedTest(String name) { super(name); } /*=================================================================== Public methods ===================================================================*/ public void testPropertyDescriptorReflection() throws Exception { OgnlRuntime.getPropertyDescriptor(java.util.AbstractList.class, ""); OgnlRuntime.getPropertyDescriptor(java.util.AbstractSequentialList.class, ""); OgnlRuntime.getPropertyDescriptor(java.lang.reflect.Array.class, ""); OgnlRuntime.getPropertyDescriptor(java.util.ArrayList.class, ""); OgnlRuntime.getPropertyDescriptor(java.util.BitSet.class, ""); OgnlRuntime.getPropertyDescriptor(java.util.Calendar.class, ""); OgnlRuntime.getPropertyDescriptor(java.lang.reflect.Field.class, ""); OgnlRuntime.getPropertyDescriptor(java.util.LinkedList.class, ""); OgnlRuntime.getPropertyDescriptor(java.util.List.class, ""); OgnlRuntime.getPropertyDescriptor(java.util.Iterator.class, ""); OgnlRuntime.getPropertyDescriptor(java.lang.ThreadLocal.class, ""); OgnlRuntime.getPropertyDescriptor(java.net.URL.class, ""); OgnlRuntime.getPropertyDescriptor(java.util.Vector.class, ""); } public void testObjectIndexAccess() throws OgnlException { SimpleNode expression = (SimpleNode)Ognl.parseExpression("#ka.sunk[#root]"); context.put("ka", new Test1()); Ognl.getValue(expression, context, "aksdj"); } public void testObjectIndexInSubclass() throws OgnlException { SimpleNode expression = (SimpleNode)Ognl.parseExpression("#ka.sunk[#root]"); context.put("ka", new Test2()); Ognl.getValue(expression, context, "aksdj"); } public void testMultipleObjectIndexGetters() throws OgnlException { SimpleNode expression = (SimpleNode)Ognl.parseExpression("#ka.sunk[#root]"); context.put("ka", new Test3()); try { Ognl.getValue(expression, context, new Test3()); fail(); } catch (OgnlException ex) { /* Should throw */ } } public void testMultipleObjectIndexSetters() throws OgnlException { SimpleNode expression = (SimpleNode)Ognl.parseExpression("#ka.sunk[#root]"); context.put("ka", new Test4()); try { Ognl.getValue(expression, context, "aksdj"); fail(); } catch (OgnlException ex) { /* Should throw */ } } public void testMultipleObjectIndexMethodPairs() throws OgnlException { SimpleNode expression = (SimpleNode)Ognl.parseExpression("#ka.sunk[#root]"); context.put("ka", new Test5()); try { Ognl.getValue(expression, context, "aksdj"); fail(); } catch (OgnlException ex) { /* Should throw */ } } /*=================================================================== Overridden methods ===================================================================*/ protected void setUp() { context = (OgnlContext)Ognl.createDefaultContext(null); } }ognl-2.7.3.orig/src/test/java/org/ognl/test/SimpleNavigationChainTreeTest.java0000644000175000017500000000762510600650435027261 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package org.ognl.test; import junit.framework.TestSuite; import ognl.Ognl; public class SimpleNavigationChainTreeTest extends OgnlTestCase { private static Object[][] TESTS = { {"name", Boolean.TRUE}, {"name[i]", Boolean.FALSE}, {"name + foo", Boolean.FALSE}, {"name.foo", Boolean.TRUE} }; /*=================================================================== Public static methods ===================================================================*/ public static TestSuite suite() { TestSuite result = new TestSuite(); for (int i = 0; i < TESTS.length; i++) { result.addTest(new SimpleNavigationChainTreeTest((String) TESTS[i][0] + " (" + TESTS[i][1] + ")", null, (String) TESTS[i][0], TESTS[i][1])); } return result; } /*=================================================================== Constructors ===================================================================*/ public SimpleNavigationChainTreeTest() { super(); } public SimpleNavigationChainTreeTest(String name) { super(name); } public SimpleNavigationChainTreeTest(String name, Object root, String expressionString, Object expectedResult, Object setValue, Object expectedAfterSetResult) { super(name, root, expressionString, expectedResult, setValue, expectedAfterSetResult); } public SimpleNavigationChainTreeTest(String name, Object root, String expressionString, Object expectedResult, Object setValue) { super(name, root, expressionString, expectedResult, setValue); } public SimpleNavigationChainTreeTest(String name, Object root, String expressionString, Object expectedResult) { super(name, root, expressionString, expectedResult); } /*=================================================================== Overridden methods ===================================================================*/ protected void runTest() throws Exception { assertTrue(Ognl.isSimpleNavigationChain(getExpression(), _context) == ((Boolean) getExpectedResult()).booleanValue()); } } ognl-2.7.3.orig/src/test/java/org/ognl/test/IndexAccessTest.java0000644000175000017500000001256310776755160024432 0ustar drazzibdrazzib// -------------------------------------------------------------------------- // Copyright (c) 2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. // -------------------------------------------------------------------------- package org.ognl.test; import junit.framework.TestSuite; import ognl.MethodFailedException; import ognl.NoSuchPropertyException; import org.ognl.test.objects.IndexedSetObject; import org.ognl.test.objects.Root; public class IndexAccessTest extends OgnlTestCase { private static Root ROOT = new Root(); private static IndexedSetObject INDEXED_SET = new IndexedSetObject(); private static Object[][] TESTS = { {ROOT, "list[index]", ROOT.getList().get(ROOT.getIndex())}, {ROOT, "list[objectIndex]", ROOT.getList().get(ROOT.getObjectIndex().intValue())}, {ROOT, "array[objectIndex]", ROOT.getArray()[ROOT.getObjectIndex().intValue()] }, {ROOT, "array[getObjectIndex()]", ROOT.getArray()[ROOT.getObjectIndex().intValue()] }, {ROOT, "array[genericIndex]", ROOT.getArray()[((Integer)ROOT.getGenericIndex()).intValue()] }, {ROOT, "booleanArray[self.objectIndex]", Boolean.FALSE }, {ROOT, "booleanArray[getObjectIndex()]", Boolean.FALSE }, {ROOT, "booleanArray[nullIndex]", NoSuchPropertyException.class}, {ROOT, "list[size() - 1]", MethodFailedException.class}, {ROOT, "(index == (array.length - 3)) ? 'toggle toggleSelected' : 'toggle'", "toggle toggleSelected"}, {ROOT, "\"return toggleDisplay('excdisplay\"+index+\"', this)\"", "return toggleDisplay('excdisplay1', this)"}, {ROOT, "map[mapKey].split('=')[0]", "StringStuff"}, {ROOT, "booleanValues[index1][index2]", Boolean.FALSE}, {ROOT, "tab.searchCriteria[index1].displayName", "Woodland creatures"}, {ROOT, "tab.searchCriteriaSelections[index1][index2]", Boolean.TRUE}, {ROOT, "tab.searchCriteriaSelections[index1][index2]", Boolean.TRUE, Boolean.FALSE, Boolean.FALSE}, {ROOT, "map['bar'].value", 100, 50, 50}, {INDEXED_SET, "thing[\"x\"].val", 1, 2, 2} }; /* * =================================================================== Public static methods * =================================================================== */ public static TestSuite suite() { TestSuite result = new TestSuite(); for (int i = 0; i < TESTS.length; i++) { if (TESTS[i].length == 5) { result.addTest(new IndexAccessTest((String) TESTS[i][1], TESTS[i][0], (String) TESTS[i][1], TESTS[i][2], TESTS[i][3], TESTS[i][4])); } else { result.addTest(new IndexAccessTest((String) TESTS[i][1], TESTS[i][0], (String) TESTS[i][1], TESTS[i][2])); } } return result; } /* * =================================================================== Constructors * =================================================================== */ public IndexAccessTest() { super(); } public IndexAccessTest(String name) { super(name); } public IndexAccessTest(String name, Object root, String expressionString, Object expectedResult, Object setValue, Object expectedAfterSetResult) { super(name, root, expressionString, expectedResult, setValue, expectedAfterSetResult); } public IndexAccessTest(String name, Object root, String expressionString, Object expectedResult, Object setValue) { super(name, root, expressionString, expectedResult, setValue); } public IndexAccessTest(String name, Object root, String expressionString, Object expectedResult) { super(name, root, expressionString, expectedResult); } public void setUp() { super.setUp(); } } ognl-2.7.3.orig/src/test/java/org/ognl/test/ShortCircuitingExpressionTest.java0000644000175000017500000000752510566476144027442 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package org.ognl.test; import junit.framework.TestSuite; import ognl.NoSuchPropertyException; import ognl.OgnlException; public class ShortCircuitingExpressionTest extends OgnlTestCase { private static Object[][] TESTS = { { "#root ? someProperty : 99", new Integer(99) }, { "#root ? 99 : someProperty", OgnlException.class }, { "(#x=99)? #x.someProperty : #x", NoSuchPropertyException.class }, { "#xyzzy.doubleValue()", NullPointerException.class }, { "#xyzzy && #xyzzy.doubleValue()", null }, { "(#x=99) && #x.doubleValue()", new Double(99) }, { "#xyzzy || 101", new Integer(101) }, { "99 || 101", new Integer(99) }, }; /*=================================================================== Public static methods ===================================================================*/ public static TestSuite suite() { TestSuite result = new TestSuite(); for (int i = 0; i < TESTS.length; i++) { result.addTest(new ShortCircuitingExpressionTest((String)TESTS[i][0] + " (" + TESTS[i][1] + ")", null, (String)TESTS[i][0], TESTS[i][1])); } return result; } /*=================================================================== Constructors ===================================================================*/ public ShortCircuitingExpressionTest() { super(); } public ShortCircuitingExpressionTest(String name) { super(name); } public ShortCircuitingExpressionTest(String name, Object root, String expressionString, Object expectedResult, Object setValue, Object expectedAfterSetResult) { super(name, root, expressionString, expectedResult, setValue, expectedAfterSetResult); } public ShortCircuitingExpressionTest(String name, Object root, String expressionString, Object expectedResult, Object setValue) { super(name, root, expressionString, expectedResult, setValue); } public ShortCircuitingExpressionTest(String name, Object root, String expressionString, Object expectedResult) { super(name, root, expressionString, expectedResult); } } ognl-2.7.3.orig/src/test/java/org/ognl/test/PrimitiveNullHandlingTest.java0000644000175000017500000001176410655141672026504 0ustar drazzibdrazzib// -------------------------------------------------------------------------- // Copyright (c) 2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. // -------------------------------------------------------------------------- package org.ognl.test; import junit.framework.TestSuite; import org.ognl.test.objects.Simple; public class PrimitiveNullHandlingTest extends OgnlTestCase { private static Simple SIMPLE = new Simple(); static { SIMPLE.setFloatValue(10.56f); SIMPLE.setIntValue(34); } private static Object[][] TESTS = { // Primitive null handling { SIMPLE, "floatValue", new Float(10.56f), null, new Float(0f) }, // set float to // null, should // yield 0.0f { SIMPLE, "intValue", new Integer(34), null, new Integer(0) },// set int to null, // should yield 0 { SIMPLE, "booleanValue", Boolean.FALSE, Boolean.TRUE, Boolean.TRUE },// set boolean // to TRUE, // should yield // true { SIMPLE, "booleanValue", Boolean.TRUE, null, Boolean.FALSE }, // set boolean to null, // should yield false }; /* * =================================================================== Public static methods * =================================================================== */ public static TestSuite suite() { TestSuite result = new TestSuite(); for(int i = 0; i < TESTS.length; i++) { if (TESTS[i].length == 3) { result.addTest(new PrimitiveNullHandlingTest((String) TESTS[i][1], TESTS[i][0], (String) TESTS[i][1], TESTS[i][2])); } else { if (TESTS[i].length == 4) { result.addTest(new PrimitiveNullHandlingTest((String) TESTS[i][1], TESTS[i][0], (String) TESTS[i][1], TESTS[i][2], TESTS[i][3])); } else { if (TESTS[i].length == 5) { result.addTest(new PrimitiveNullHandlingTest((String) TESTS[i][1], TESTS[i][0], (String) TESTS[i][1], TESTS[i][2], TESTS[i][3], TESTS[i][4])); } else { throw new RuntimeException("don't understand TEST format"); } } } } return result; } /* * =================================================================== Constructors * =================================================================== */ public PrimitiveNullHandlingTest() { super(); } public PrimitiveNullHandlingTest(String name) { super(name); } public PrimitiveNullHandlingTest(String name, Object root, String expressionString, Object expectedResult, Object setValue, Object expectedAfterSetResult) { super(name, root, expressionString, expectedResult, setValue, expectedAfterSetResult); } public PrimitiveNullHandlingTest(String name, Object root, String expressionString, Object expectedResult, Object setValue) { super(name, root, expressionString, expectedResult, setValue); } public PrimitiveNullHandlingTest(String name, Object root, String expressionString, Object expectedResult) { super(name, root, expressionString, expectedResult); } } ognl-2.7.3.orig/src/test/java/org/ognl/test/SetterWithConversionTest.java0000644000175000017500000001246410561411075026373 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package org.ognl.test; import junit.framework.TestSuite; import org.ognl.test.objects.Root; public class SetterWithConversionTest extends OgnlTestCase { private static Root ROOT = new Root(); private static Object[][] TESTS = { // Property set with conversion { ROOT, "intValue", new Integer(0), new Double(6.5), new Integer(6) }, { ROOT, "intValue", new Integer(6), new Double(1025.87645), new Integer(1025) }, { ROOT, "intValue", new Integer(1025), "654", new Integer(654) }, { ROOT, "stringValue", null, new Integer(25), "25" }, { ROOT, "stringValue", "25", new Float(100.25), "100.25" }, { ROOT, "anotherStringValue", "foo", new Integer(0), "0" }, { ROOT, "anotherStringValue", "0", new Double(0.5), "0.5" }, { ROOT, "anotherIntValue", new Integer(123), "5", new Integer(5) }, { ROOT, "anotherIntValue", new Integer(5), new Double(100.25), new Integer(100) }, // { ROOT, "anotherIntValue", new Integer(100), new String[] { "55" }, new Integer(55)}, // { ROOT, "yetAnotherIntValue", new Integer(46), new String[] { "55" }, new Integer(55)}, }; /*=================================================================== Public static methods ===================================================================*/ public static TestSuite suite() { TestSuite result = new TestSuite(); for (int i = 0; i < TESTS.length; i++) { if (TESTS[i].length == 3) { result.addTest(new SetterWithConversionTest((String)TESTS[i][1], TESTS[i][0], (String)TESTS[i][1], TESTS[i][2])); } else { if (TESTS[i].length == 4) { result.addTest(new SetterWithConversionTest((String)TESTS[i][1], TESTS[i][0], (String)TESTS[i][1], TESTS[i][2], TESTS[i][3])); } else { if (TESTS[i].length == 5) { result.addTest(new SetterWithConversionTest((String)TESTS[i][1], TESTS[i][0], (String)TESTS[i][1], TESTS[i][2], TESTS[i][3], TESTS[i][4])); } else { throw new RuntimeException("don't understand TEST format"); } } } } return result; } /*=================================================================== Constructors ===================================================================*/ public SetterWithConversionTest() { super(); } public SetterWithConversionTest(String name) { super(name); } public SetterWithConversionTest(String name, Object root, String expressionString, Object expectedResult, Object setValue, Object expectedAfterSetResult) { super(name, root, expressionString, expectedResult, setValue, expectedAfterSetResult); } public SetterWithConversionTest(String name, Object root, String expressionString, Object expectedResult, Object setValue) { super(name, root, expressionString, expectedResult, setValue); } public SetterWithConversionTest(String name, Object root, String expressionString, Object expectedResult) { super(name, root, expressionString, expectedResult); } } ognl-2.7.3.orig/src/test/java/org/ognl/test/ASTChainTest.java0000644000175000017500000000124410776755160023625 0ustar drazzibdrazzibpackage org.ognl.test; import junit.framework.TestCase; import ognl.Ognl; import ognl.OgnlContext; import org.ognl.test.objects.IndexedSetObject; /** * Tests for {@link ognl.ASTChain}. */ public class ASTChainTest extends TestCase { public void test_Get_Indexed_Value() throws Exception { OgnlContext context = (OgnlContext) Ognl.createDefaultContext(null); IndexedSetObject root = new IndexedSetObject(); String expr = "thing[\"x\"].val"; assertEquals(1, Ognl.getValue(expr, context, root)); Ognl.setValue(expr, context, root, new Integer(2)); assertEquals(2, Ognl.getValue(expr, context, root)); } } ognl-2.7.3.orig/src/test/java/org/ognl/test/util/0000755000175000017500000000000011237553170021472 5ustar drazzibdrazzibognl-2.7.3.orig/src/test/java/org/ognl/test/util/EnhancedClassLoader.java0000644000175000017500000000457410561411075026165 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package org.ognl.test.util; public class EnhancedClassLoader extends ClassLoader { /*=================================================================== Constructors ===================================================================*/ public EnhancedClassLoader(ClassLoader parentClassLoader) { super(parentClassLoader); } /*=================================================================== Overridden methods ===================================================================*/ public Class defineClass(String enhancedClassName, byte[] byteCode) { return defineClass(enhancedClassName, byteCode, 0, byteCode.length); } } ognl-2.7.3.orig/src/test/java/org/ognl/test/util/NameFactory.java0000644000175000017500000000524010561411075024542 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package org.ognl.test.util; public class NameFactory extends Object { private String classBaseName; private int classNameCounter = 0; private String variableBaseName; private int variableNameCounter = 0; /*=================================================================== Constructors ===================================================================*/ public NameFactory(String classBaseName, String variableBaseName) { super(); this.classBaseName = classBaseName; this.variableBaseName = variableBaseName; } /*=================================================================== Public methods ===================================================================*/ public String getNewClassName() { return classBaseName + classNameCounter++; } public String getNewVariableName() { return variableBaseName + variableNameCounter++; } } ognl-2.7.3.orig/src/test/java/org/ognl/test/util/ContextClassLoader.java0000644000175000017500000000520410561411075026073 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package org.ognl.test.util; import ognl.OgnlContext; public class ContextClassLoader extends ClassLoader { private OgnlContext context; /*=================================================================== Constructors ===================================================================*/ public ContextClassLoader(ClassLoader parentClassLoader, OgnlContext context) { super(parentClassLoader); this.context = context; } /*=================================================================== Overridden methods ===================================================================*/ protected Class findClass(String name) throws ClassNotFoundException { if ((context != null) && (context.getClassResolver() != null)) { return context.getClassResolver().classForName(name, context); } return super.findClass(name); } } ognl-2.7.3.orig/src/test/java/org/ognl/test/ConstantTreeTest.java0000644000175000017500000001051610566476144024645 0ustar drazzibdrazzib// -------------------------------------------------------------------------- // Copyright (c) 2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. // -------------------------------------------------------------------------- package org.ognl.test; import junit.framework.TestSuite; import ognl.Ognl; public class ConstantTreeTest extends OgnlTestCase { public static int nonFinalStaticVariable = 15; private static Object[][] TESTS = { { "true", Boolean.TRUE }, { "55", Boolean.TRUE }, { "@java.awt.Color@black", Boolean.TRUE }, { "@org.ognl.test.ConstantTreeTest@nonFinalStaticVariable", Boolean.FALSE }, { "@org.ognl.test.ConstantTreeTest@nonFinalStaticVariable + 10", Boolean.FALSE }, { "55 + 24 + @java.awt.Event@ALT_MASK", Boolean.TRUE }, { "name", Boolean.FALSE }, { "name[i]", Boolean.FALSE }, { "name[i].property", Boolean.FALSE }, { "name.{? foo }", Boolean.FALSE }, { "name.{ foo }", Boolean.FALSE }, { "name.{ 25 }", Boolean.FALSE } }; /* * =================================================================== Public static methods * =================================================================== */ public static TestSuite suite() { TestSuite result = new TestSuite(); for(int i = 0; i < TESTS.length; i++) { result.addTest(new ConstantTreeTest((String) TESTS[i][0] + " (" + TESTS[i][1] + ")", null, (String) TESTS[i][0], TESTS[i][1])); } return result; } /* * =================================================================== Overridden methods * =================================================================== */ protected void runTest() throws Exception { assertTrue(Ognl.isConstant(getExpression(), _context) == ((Boolean) getExpectedResult()).booleanValue()); } /* * =================================================================== Constructors * =================================================================== */ public ConstantTreeTest() { super(); } public ConstantTreeTest(String name) { super(name); } public ConstantTreeTest(String name, Object root, String expressionString, Object expectedResult, Object setValue, Object expectedAfterSetResult) { super(name, root, expressionString, expectedResult, setValue, expectedAfterSetResult); } public ConstantTreeTest(String name, Object root, String expressionString, Object expectedResult, Object setValue) { super(name, root, expressionString, expectedResult, setValue); } public ConstantTreeTest(String name, Object root, String expressionString, Object expectedResult) { super(name, root, expressionString, expectedResult); } } ognl-2.7.3.orig/src/test/java/org/ognl/test/NullHandlerTest.java0000644000175000017500000001155410655141672024441 0ustar drazzibdrazzib// -------------------------------------------------------------------------- // Copyright (c) 2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. // -------------------------------------------------------------------------- package org.ognl.test; import junit.framework.TestSuite; import ognl.OgnlRuntime; import org.ognl.test.objects.CorrectedObject; public class NullHandlerTest extends OgnlTestCase { private static CorrectedObject CORRECTED = new CorrectedObject(); private static Object[][] TESTS = { // NullHandler { CORRECTED, "stringValue", "corrected" }, { CORRECTED, "getStringValue()", "corrected" }, { CORRECTED, "#root.stringValue", "corrected" }, { CORRECTED, "#root.getStringValue()", "corrected" }, }; /* * =================================================================== Public static methods * =================================================================== */ public static TestSuite suite() { TestSuite result = new TestSuite(); for(int i = 0; i < TESTS.length; i++) { if (TESTS[i].length == 3) { result .addTest(new NullHandlerTest((String) TESTS[i][1], TESTS[i][0], (String) TESTS[i][1], TESTS[i][2])); } else { if (TESTS[i].length == 4) { result.addTest(new NullHandlerTest((String) TESTS[i][1], TESTS[i][0], (String) TESTS[i][1], TESTS[i][2], TESTS[i][3])); } else { if (TESTS[i].length == 5) { result.addTest(new NullHandlerTest((String) TESTS[i][1], TESTS[i][0], (String) TESTS[i][1], TESTS[i][2], TESTS[i][3], TESTS[i][4])); } else { throw new RuntimeException("don't understand TEST format"); } } } } return result; } /* * =================================================================== Constructors * =================================================================== */ public NullHandlerTest() { super(); } public NullHandlerTest(String name) { super(name); } public NullHandlerTest(String name, Object root, String expressionString, Object expectedResult, Object setValue, Object expectedAfterSetResult) { super(name, root, expressionString, expectedResult, setValue, expectedAfterSetResult); } public NullHandlerTest(String name, Object root, String expressionString, Object expectedResult, Object setValue) { super(name, root, expressionString, expectedResult, setValue); } public NullHandlerTest(String name, Object root, String expressionString, Object expectedResult) { super(name, root, expressionString, expectedResult); } /* * =================================================================== Overridden methods * =================================================================== */ public void setUp() { super.setUp(); _compileExpressions = false; OgnlRuntime.setNullHandler(CorrectedObject.class, new CorrectedObjectNullHandler("corrected")); } } ognl-2.7.3.orig/src/test/java/org/ognl/test/Performance.java0000644000175000017500000003467710744172440023641 0ustar drazzibdrazzib// -------------------------------------------------------------------------- // Copyright (c) 2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. // -------------------------------------------------------------------------- package org.ognl.test; import ognl.Ognl; import ognl.OgnlContext; import ognl.OgnlException; import ognl.SimpleNode; import org.ognl.test.objects.Bean1; import java.io.Serializable; import java.lang.reflect.Method; import java.text.DecimalFormat; import java.text.NumberFormat; public class Performance extends Object { private static int MAX_ITERATIONS = -1; private static boolean ITERATIONS_MODE; private static long MAX_TIME = -1L; private static boolean TIME_MODE; private static NumberFormat FACTOR_FORMAT = new DecimalFormat("0.000"); private String _name; private OgnlContext _context = (OgnlContext) Ognl.createDefaultContext(null); private Bean1 _root = new Bean1(); private SimpleNode _expression; private SimpleNode _compiledExpression; private Method _method; private int _iterations; private Serializable _mvelCompiled; private String _expressionString; private boolean _isMvel = false; private long t0; private long t1; /* * =================================================================== Private static classes * =================================================================== */ private static class Results { int iterations; long time; boolean mvel; public Results(int iterations, long time, boolean mvel) { super(); this.iterations = iterations; this.time = time; this.mvel = mvel; } public String getFactor(Results otherResults) { String ret = null; if (TIME_MODE) { float factor = 0; if (iterations < otherResults.iterations) { factor = Math.max((float) otherResults.iterations, (float) iterations) / Math.min((float) otherResults.iterations, (float) iterations); } else { factor = Math.min((float) otherResults.iterations, (float) iterations) / Math.max((float) otherResults.iterations, (float) iterations); } ret = FACTOR_FORMAT.format(factor); if (iterations > otherResults.iterations) ret += " times faster than "; else ret += " times slower than "; } else { float factor = Math.max((float) otherResults.time, (float) time) / Math.min((float) otherResults.time, (float) time); ret = FACTOR_FORMAT.format(factor); if (time < otherResults.time) ret += " times faster than "; else ret += " times slower than "; } return ret; } } /* * =================================================================== Public static methods * =================================================================== */ public static void main(String[] args) { for(int i = 0; i < args.length; i++) { if (args[i].equals("-time")) { TIME_MODE = true; MAX_TIME = Long.parseLong(args[++i]); } else if (args[i].equals("-iterations")) { ITERATIONS_MODE = true; MAX_ITERATIONS = Integer.parseInt(args[++i]); } } if (!TIME_MODE && !ITERATIONS_MODE) { TIME_MODE = true; MAX_TIME = 1500; } try { Performance[] tests = new Performance[] { new Performance("Constant", "100 + 20 * 5", "testConstantExpression"), //new Performance("Constant", "100 + 20 * 5", "testConstantExpression", false), new Performance("Single Property", "bean2", "testSinglePropertyExpression"), new Performance("Property Navigation", "bean2.bean3.value", "testPropertyNavigationExpression"), /*new Performance("Property Setting with context key", "bean2.bean3.nullValue", "testPropertyNavigationSetting"), new Performance("Property Setting with context key", "bean2.bean3.nullValue", "testPropertyNavigationSetting", true), */ new Performance("Property Navigation and Comparison", "bean2.bean3.value <= 24", "testPropertyNavigationAndComparisonExpression"), /* new Performance("Property Navigation with Indexed Access", "bean2.bean3.indexedValue[25]", "testIndexedPropertyNavigationExpression"), new Performance("Property Navigation with Indexed Access", "bean2.bean3.indexedValue[25]", "testIndexedPropertyNavigationExpression", true), */ new Performance("Property Navigation with Map Access", "bean2.bean3.map['foo']", "testPropertyNavigationWithMapExpression"), /* new Performance("Property Navigation with Map value set", "bean2.bean3.map['foo']", "testPropertyNavigationWithMapSetting"), new Performance("Property Navigation with Map value set", "bean2.bean3.map['foo']", "testPropertyNavigationWithMapSetting", true) */ }; boolean timeMode = TIME_MODE; boolean iterMode = ITERATIONS_MODE; long maxTime = MAX_TIME; int maxIterations = MAX_ITERATIONS; //TIME_MODE = false; //ITERATIONS_MODE = true; //maxIterations = 1000; runTests(tests, false); TIME_MODE = timeMode; ITERATIONS_MODE = iterMode; MAX_TIME = maxTime; MAX_ITERATIONS = maxIterations; System.out.println("\n\n============================================================================\n"); Thread.sleep(2500); runTests(tests, true); //Thread.sleep(2000); System.out.println("\n\n============================================================================\n"); // runTests(tests); } catch (Exception ex) { ex.printStackTrace(); } } static void runTests(Performance[] tests, boolean output) throws Exception { for(int i = 0; i < tests.length; i++) { Performance perf = tests[i]; try { Results javaResults = perf.testJava(), interpretedResults = perf.testExpression(false), compiledResults = perf.testExpression(true); if (!output) return; System.out.println((compiledResults.mvel ? "MVEL" : "OGNL") + " " + perf.getName() + ": " + perf.getExpression().toString()); System.out.println(" java: " + javaResults.iterations + " iterations in " + javaResults.time + " ms"); System.out.println(" compiled: " + compiledResults.iterations + " iterations in " + compiledResults.time + " ms (" + compiledResults.getFactor(javaResults) + "java)"); System.out.println("interpreted: " + interpretedResults.iterations + " iterations in " + interpretedResults.time + " ms (" + interpretedResults.getFactor(javaResults) + "java)"); System.out.println(); } catch (OgnlException ex) { ex.printStackTrace(); } } } /* * =================================================================== Constructors * =================================================================== */ public Performance(String name, String expressionString, String javaMethodName) throws Exception { this(name, expressionString, javaMethodName, false); } public Performance(String name, String expressionString, String javaMethodName, boolean mvel) throws Exception { _name = name; _isMvel = mvel; _expressionString = expressionString; try { _method = getClass().getMethod(javaMethodName, new Class[] {}); } catch (Exception ex) { throw new OgnlException("java method not found", ex); } if (!_isMvel) { _expression = (SimpleNode) Ognl.parseExpression(expressionString); _compiledExpression = (SimpleNode) Ognl.compileExpression(_context, _root, expressionString); Ognl.getValue(_expression, _context, _root); _context.put("contextValue", "cvalue"); } else { //_mvelCompiled = MVEL.compileExpression(expressionString); } } /* * =================================================================== Protected methods * =================================================================== */ protected void startTest() { _iterations = 0; t0 = t1 = System.currentTimeMillis(); } protected Results endTest() { return new Results(_iterations, t1 - t0, _isMvel); } protected boolean done() { _iterations++; t1 = System.currentTimeMillis(); if (TIME_MODE) { return (t1 - t0) >= MAX_TIME; } else { if (ITERATIONS_MODE) { return _iterations >= MAX_ITERATIONS; } else { throw new RuntimeException("no maximums specified"); } } } /* * =================================================================== Public methods * =================================================================== */ public String getName() { return _name; } public String getExpression() { return _expressionString; } public Results testExpression(boolean compiled) throws Exception { startTest(); do { if (!_isMvel) { if (compiled) Ognl.getValue(_compiledExpression.getAccessor(), _context, _root); else Ognl.getValue(_expression, _context, _root); } else { /* if (compiled) MVEL.executeExpression(_mvelCompiled, _root); else MVEL.eval(_expressionString, _root);*/ } } while(!done()); return endTest(); } public Results testJava() throws OgnlException { try { return (Results) _method.invoke(this, new Object[] {}); } catch (Exception ex) { throw new OgnlException("invoking java method '" + _method.getName() + "'", ex); } } public Results testConstantExpression() throws OgnlException { startTest(); do { int result = 100 + 20 * 5; } while(!done()); return endTest(); } public Results testSinglePropertyExpression() throws OgnlException { startTest(); do { _root.getBean2(); } while(!done()); return endTest(); } public Results testPropertyNavigationExpression() throws OgnlException { startTest(); do { _root.getBean2().getBean3().getValue(); } while(!done()); return endTest(); } public Results testPropertyNavigationSetting() throws OgnlException { startTest(); do { _root.getBean2().getBean3().setNullValue("a value"); } while(!done()); return endTest(); } public Results testPropertyNavigationAndComparisonExpression() throws OgnlException { startTest(); do { boolean result = _root.getBean2().getBean3().getValue() < 24; } while(!done()); return endTest(); } public Results testIndexedPropertyNavigationExpression() throws OgnlException { startTest(); do { _root.getBean2().getBean3().getIndexedValue(25); } while(!done()); return endTest(); } public Results testPropertyNavigationWithMapSetting() throws OgnlException { startTest(); do { _root.getBean2().getBean3().getMap().put("bam", "bam"); } while(!done()); return endTest(); } public Results testPropertyNavigationWithMapExpression() throws OgnlException { startTest(); do { _root.getBean2().getBean3().getMap().get("foo"); } while(!done()); return endTest(); } } ognl-2.7.3.orig/src/test/java/org/ognl/test/ContextVariableTest.java0000644000175000017500000000727410611506566025326 0ustar drazzibdrazzib// -------------------------------------------------------------------------- // Copyright (c) 2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. // -------------------------------------------------------------------------- package org.ognl.test; import junit.framework.TestSuite; import org.ognl.test.objects.Simple; public class ContextVariableTest extends OgnlTestCase { private static Object ROOT = new Simple(); private static Object[][] TESTS = { // Naming and referring to names {"#root", ROOT}, // Special root reference {"#this", ROOT}, // Special this reference {"#f=5, #s=6, #f + #s", new Integer(11)}, { "#six=(#five=5, 6), #five + #six", new Integer(11)}, }; /* * =================================================================== Public static methods * =================================================================== */ public static TestSuite suite() { TestSuite result = new TestSuite(); for (int i = 0; i < TESTS.length; i++) { result.addTest(new ContextVariableTest((String) TESTS[i][0] + " (" + TESTS[i][1] + ")", ROOT, (String) TESTS[i][0], TESTS[i][1])); } return result; } /* * =================================================================== Constructors * =================================================================== */ public ContextVariableTest() { super(); } public ContextVariableTest(String name) { super(name); } public ContextVariableTest(String name, Object root, String expressionString, Object expectedResult, Object setValue, Object expectedAfterSetResult) { super(name, root, expressionString, expectedResult, setValue, expectedAfterSetResult); } public ContextVariableTest(String name, Object root, String expressionString, Object expectedResult, Object setValue) { super(name, root, expressionString, expectedResult, setValue); } public ContextVariableTest(String name, Object root, String expressionString, Object expectedResult) { super(name, root, expressionString, expectedResult); } } ognl-2.7.3.orig/src/java/0000755000175000017500000000000011237553170015031 5ustar drazzibdrazzibognl-2.7.3.orig/src/java/ognl/0000755000175000017500000000000011237553172015772 5ustar drazzibdrazzibognl-2.7.3.orig/src/java/ognl/NumericTypes.java0000644000175000017500000000626410561411075021266 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 1998-2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package ognl; /** * This interface defines some useful constants for describing the various possible * numeric types of OGNL. * @author Luke Blanshard (blanshlu@netscape.net) * @author Drew Davidson (drew@ognl.org) */ public interface NumericTypes { // Order does matter here... see the getNumericType methods in ognl.g. /** Type tag meaning boolean. */ int BOOL = 0; /** Type tag meaning byte. */ int BYTE = 1; /** Type tag meaning char. */ int CHAR = 2; /** Type tag meaning short. */ int SHORT = 3; /** Type tag meaning int. */ int INT = 4; /** Type tag meaning long. */ int LONG = 5; /** Type tag meaning java.math.BigInteger. */ int BIGINT = 6; /** Type tag meaning float. */ int FLOAT = 7; /** Type tag meaning double. */ int DOUBLE = 8; /** Type tag meaning java.math.BigDecimal. */ int BIGDEC = 9; /** Type tag meaning something other than a number. */ int NONNUMERIC = 10; /** * The smallest type tag that represents reals as opposed to integers. You can see * whether a type tag represents reals or integers by comparing the tag to this * constant: all tags less than this constant represent integers, and all tags * greater than or equal to this constant represent reals. Of course, you must also * check for NONNUMERIC, which means it is not a number at all. */ int MIN_REAL_TYPE = FLOAT; } ognl-2.7.3.orig/src/java/ognl/ASTSelectLast.java0000644000175000017500000000635110566476144021264 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 1998-2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package ognl; import ognl.enhance.UnsupportedCompilationException; import java.util.ArrayList; import java.util.Enumeration; import java.util.List; /** * @author Luke Blanshard (blanshlu@netscape.net) * @author Drew Davidson (drew@ognl.org) */ class ASTSelectLast extends SimpleNode { public ASTSelectLast(int id) { super(id); } public ASTSelectLast(OgnlParser p, int id) { super(p, id); } protected Object getValueBody( OgnlContext context, Object source ) throws OgnlException { Node expr = _children[0]; List answer = new ArrayList(); ElementsAccessor elementsAccessor = OgnlRuntime.getElementsAccessor( OgnlRuntime.getTargetClass(source) ); for ( Enumeration e = elementsAccessor.getElements(source); e.hasMoreElements(); ) { Object next = e.nextElement(); if (OgnlOps.booleanValue(expr.getValue(context, next))) { answer.clear(); answer.add(next); } } return answer; } public String toString() { return "{$ " + _children[0] + " }"; } public String toGetSourceString(OgnlContext context, Object target) { throw new UnsupportedCompilationException("Eval expressions not supported as native java yet."); } public String toSetSourceString(OgnlContext context, Object target) { throw new UnsupportedCompilationException("Eval expressions not supported as native java yet."); } } ognl-2.7.3.orig/src/java/ognl/ASTEval.java0000644000175000017500000000721710566476144020112 0ustar drazzibdrazzib// -------------------------------------------------------------------------- // Copyright (c) 1998-2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. // -------------------------------------------------------------------------- package ognl; import ognl.enhance.UnsupportedCompilationException; /** * @author Luke Blanshard (blanshlu@netscape.net) * @author Drew Davidson (drew@ognl.org) */ class ASTEval extends SimpleNode { public ASTEval(int id) { super(id); } public ASTEval(OgnlParser p, int id) { super(p, id); } protected Object getValueBody(OgnlContext context, Object source) throws OgnlException { Object result, expr = _children[0].getValue(context, source), previousRoot = context.getRoot(); Node node; source = _children[1].getValue(context, source); node = (expr instanceof Node) ? (Node) expr : (Node) Ognl.parseExpression(expr.toString()); try { context.setRoot(source); result = node.getValue(context, source); } finally { context.setRoot(previousRoot); } return result; } protected void setValueBody(OgnlContext context, Object target, Object value) throws OgnlException { Object expr = _children[0].getValue(context, target), previousRoot = context.getRoot(); Node node; target = _children[1].getValue(context, target); node = (expr instanceof Node) ? (Node) expr : (Node) Ognl.parseExpression(expr.toString()); try { context.setRoot(target); node.setValue(context, target, value); } finally { context.setRoot(previousRoot); } } public String toString() { return "(" + _children[0] + ")(" + _children[1] + ")"; } public String toGetSourceString(OgnlContext context, Object target) { throw new UnsupportedCompilationException("Eval expressions not supported as native java yet."); } public String toSetSourceString(OgnlContext context, Object target) { throw new UnsupportedCompilationException("Map expressions not supported as native java yet."); } } ognl-2.7.3.orig/src/java/ognl/ASTBitNegate.java0000644000175000017500000000520510634650771021054 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 1998-2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package ognl; /** * @author Luke Blanshard (blanshlu@netscape.net) * @author Drew Davidson (drew@ognl.org) */ class ASTBitNegate extends NumericExpression { public ASTBitNegate(int id) { super(id); } public ASTBitNegate(OgnlParser p, int id) { super(p, id); } protected Object getValueBody( OgnlContext context, Object source ) throws OgnlException { return OgnlOps.bitNegate( _children[0].getValue(context, source) ); } public String toString() { return "~" + _children[0]; } public String toGetSourceString(OgnlContext context, Object target) { String source = _children[0].toGetSourceString(context, target); if (!ASTBitNegate.class.isInstance(_children[0])) { return "~(" + super.coerceToNumeric(source, context, _children[0]) + ")"; } else { return "~(" + source + ")"; } } } ognl-2.7.3.orig/src/java/ognl/IteratorElementsAccessor.java0000644000175000017500000000422010561411075023576 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 1998-2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package ognl; import java.util.*; /** * Implementation of the ElementsAccessor interface for Iterators, which simply returns * the target iterator itself. * @author Luke Blanshard (blanshlu@netscape.net) * @author Drew Davidson (drew@ognl.org) */ public class IteratorElementsAccessor implements ElementsAccessor { public Enumeration getElements( Object target ) { return new IteratorEnumeration( (Iterator)target ); } } ognl-2.7.3.orig/src/java/ognl/ASTBitOr.java0000644000175000017500000000472010566476144020236 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 1998-2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package ognl; /** * @author Luke Blanshard (blanshlu@netscape.net) * @author Drew Davidson (drew@ognl.org) */ class ASTBitOr extends NumericExpression { public ASTBitOr(int id) { super(id); } public ASTBitOr(OgnlParser p, int id) { super(p, id); } public void jjtClose() { flattenTree(); } protected Object getValueBody( OgnlContext context, Object source ) throws OgnlException { Object result = _children[0].getValue( context, source ); for ( int i=1; i < _children.length; ++i ) result = OgnlOps.binaryOr( result, _children[i].getValue(context, source) ); return result; } public String getExpressionOperator(int index) { return "|"; } } ognl-2.7.3.orig/src/java/ognl/EnumerationIterator.java0000644000175000017500000000443210561411075022632 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 1998-2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package ognl; import java.util.*; /** * Object that implements Iterator from an Enumeration * @author Luke Blanshard (blanshlu@netscape.net) * @author Drew Davidson (drew@ognl.org) */ public class EnumerationIterator implements Iterator { private Enumeration e; public EnumerationIterator(Enumeration e) { super(); this.e = e; } public boolean hasNext() { return e.hasMoreElements(); } public Object next() { return e.nextElement(); } public void remove() { throw new UnsupportedOperationException("remove() not supported by Enumeration"); } } ognl-2.7.3.orig/src/java/ognl/OgnlParserConstants.java0000644000175000017500000000525710746450726022624 0ustar drazzibdrazzib/* Generated By:JJTree&JavaCC: Do not edit this line. OgnlParserConstants.java */ package ognl; /** * Token literal values and constants. * Generated by org.javacc.parser.OtherFilesGen#start() */ public interface OgnlParserConstants { /** End of File. */ int EOF = 0; /** RegularExpression Id. */ int IDENT = 64; /** RegularExpression Id. */ int LETTER = 65; /** RegularExpression Id. */ int DIGIT = 66; /** RegularExpression Id. */ int DYNAMIC_SUBSCRIPT = 67; /** RegularExpression Id. */ int ESC = 71; /** RegularExpression Id. */ int CHAR_LITERAL = 73; /** RegularExpression Id. */ int BACK_CHAR_ESC = 74; /** RegularExpression Id. */ int BACK_CHAR_LITERAL = 76; /** RegularExpression Id. */ int STRING_ESC = 77; /** RegularExpression Id. */ int STRING_LITERAL = 79; /** RegularExpression Id. */ int INT_LITERAL = 80; /** RegularExpression Id. */ int FLT_LITERAL = 81; /** RegularExpression Id. */ int DEC_FLT = 82; /** RegularExpression Id. */ int DEC_DIGITS = 83; /** RegularExpression Id. */ int EXPONENT = 84; /** RegularExpression Id. */ int FLT_SUFF = 85; /** Lexical state. */ int DEFAULT = 0; /** Lexical state. */ int WithinCharLiteral = 1; /** Lexical state. */ int WithinBackCharLiteral = 2; /** Lexical state. */ int WithinStringLiteral = 3; /** Literal token values. */ String[] tokenImage = { "", "\",\"", "\"=\"", "\"?\"", "\":\"", "\"||\"", "\"or\"", "\"&&\"", "\"and\"", "\"|\"", "\"bor\"", "\"^\"", "\"xor\"", "\"&\"", "\"band\"", "\"==\"", "\"eq\"", "\"!=\"", "\"neq\"", "\"<\"", "\"lt\"", "\">\"", "\"gt\"", "\"<=\"", "\"lte\"", "\">=\"", "\"gte\"", "\"in\"", "\"not\"", "\"<<\"", "\"shl\"", "\">>\"", "\"shr\"", "\">>>\"", "\"ushr\"", "\"+\"", "\"-\"", "\"*\"", "\"/\"", "\"%\"", "\"~\"", "\"!\"", "\"instanceof\"", "\".\"", "\"(\"", "\")\"", "\"true\"", "\"false\"", "\"null\"", "\"#this\"", "\"#root\"", "\"#\"", "\"[\"", "\"]\"", "\"{\"", "\"}\"", "\"@\"", "\"new\"", "\"$\"", "\" \"", "\"\\t\"", "\"\\f\"", "\"\\r\"", "\"\\n\"", "", "", "", "", "\"`\"", "\"\\\'\"", "\"\\\"\"", "", "", "\"\\\'\"", "", "", "\"`\"", "", "", "\"\\\"\"", "", "", "", "", "", "", }; } ognl-2.7.3.orig/src/java/ognl/ASTLessEq.java0000644000175000017500000000475310566476144020421 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 1998-2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package ognl; /** * @author Luke Blanshard (blanshlu@netscape.net) * @author Drew Davidson (drew@ognl.org) */ class ASTLessEq extends ComparisonExpression { public ASTLessEq(int id) { super(id); } public ASTLessEq(OgnlParser p, int id) { super(p, id); } protected Object getValueBody( OgnlContext context, Object source ) throws OgnlException { Object v1 = _children[0].getValue( context, source ); Object v2 = _children[1].getValue( context, source ); return OgnlOps.greater( v1, v2 )? Boolean.FALSE : Boolean.TRUE; } public String getExpressionOperator(int index) { return "<="; } public String getComparisonFunction() { return "!ognl.OgnlOps.greater"; } } ognl-2.7.3.orig/src/java/ognl/ASTNot.java0000644000175000017500000000547510655154670017763 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 1998-2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package ognl; /** * @author Luke Blanshard (blanshlu@netscape.net) * @author Drew Davidson (drew@ognl.org) */ class ASTNot extends BooleanExpression { public ASTNot(int id) { super(id); } public ASTNot(OgnlParser p, int id) { super(p, id); } protected Object getValueBody( OgnlContext context, Object source ) throws OgnlException { return OgnlOps.booleanValue( _children[0].getValue(context, source) ) ? Boolean.FALSE : Boolean.TRUE; } public String getExpressionOperator(int index) { return "!"; } public String toGetSourceString(OgnlContext context, Object target) { try { String srcString = super.toGetSourceString(context, target); if (srcString == null || srcString.trim().length() < 1) srcString = "null"; context.setCurrentType(Boolean.TYPE); return "(! ognl.OgnlOps.booleanValue(" + srcString + ") )"; } catch (Throwable t) { throw OgnlOps.castToRuntime(t); } } } ognl-2.7.3.orig/src/java/ognl/DefaultMemberAccess.java0000644000175000017500000001241710561411075022472 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 1998-2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package ognl; import java.lang.reflect.*; import java.util.*; /** * This class provides methods for setting up and restoring * access in a Field. Java 2 provides access utilities for setting * and getting fields that are non-public. This object provides * coarse-grained access controls to allow access to private, protected * and package protected members. This will apply to all classes * and members. * * @author Luke Blanshard (blanshlu@netscape.net) * @author Drew Davidson (drew@ognl.org) * @version 15 October 1999 */ public class DefaultMemberAccess implements MemberAccess { public boolean allowPrivateAccess = false; public boolean allowProtectedAccess = false; public boolean allowPackageProtectedAccess = false; /*=================================================================== Constructors ===================================================================*/ public DefaultMemberAccess(boolean allowAllAccess) { this(allowAllAccess, allowAllAccess, allowAllAccess); } public DefaultMemberAccess(boolean allowPrivateAccess, boolean allowProtectedAccess, boolean allowPackageProtectedAccess) { super(); this.allowPrivateAccess = allowPrivateAccess; this.allowProtectedAccess = allowProtectedAccess; this.allowPackageProtectedAccess = allowPackageProtectedAccess; } /*=================================================================== Public methods ===================================================================*/ public boolean getAllowPrivateAccess() { return allowPrivateAccess; } public void setAllowPrivateAccess(boolean value) { allowPrivateAccess = value; } public boolean getAllowProtectedAccess() { return allowProtectedAccess; } public void setAllowProtectedAccess(boolean value) { allowProtectedAccess = value; } public boolean getAllowPackageProtectedAccess() { return allowPackageProtectedAccess; } public void setAllowPackageProtectedAccess(boolean value) { allowPackageProtectedAccess = value; } /*=================================================================== MemberAccess interface ===================================================================*/ public Object setup(Map context, Object target, Member member, String propertyName) { Object result = null; if (isAccessible(context, target, member, propertyName)) { AccessibleObject accessible = (AccessibleObject)member; if (!accessible.isAccessible()) { result = Boolean.TRUE; accessible.setAccessible(true); } } return result; } public void restore(Map context, Object target, Member member, String propertyName, Object state) { if (state != null) { ((AccessibleObject)member).setAccessible(((Boolean)state).booleanValue()); } } /** Returns true if the given member is accessible or can be made accessible by this object. */ public boolean isAccessible(Map context, Object target, Member member, String propertyName) { int modifiers = member.getModifiers(); boolean result = Modifier.isPublic(modifiers); if (!result) { if (Modifier.isPrivate(modifiers)) { result = getAllowPrivateAccess(); } else { if (Modifier.isProtected(modifiers)) { result = getAllowProtectedAccess(); } else { result = getAllowPackageProtectedAccess(); } } } return result; } } ognl-2.7.3.orig/src/java/ognl/OgnlException.java0000644000175000017500000001313610720370235021410 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 1998-2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package ognl; import java.lang.reflect.Method; /** * Superclass for OGNL exceptions, incorporating an optional encapsulated exception. * * @author Luke Blanshard (blanshlu@netscape.net) * @author Drew Davidson (drew@ognl.org) */ public class OgnlException extends Exception { // cache initCause method - if available..to be used during throwable constructor // to properly setup superclass. static Method _initCause; static { try { _initCause = OgnlException.class.getMethod("initCause", new Class[] { Throwable.class}); } catch (NoSuchMethodException e) { /** ignore */ } } /** * The root evaluation of the expression when the exception was thrown */ private Evaluation _evaluation; /** * Why this exception was thrown. * @serial */ private Throwable _reason; /** Constructs an OgnlException with no message or encapsulated exception. */ public OgnlException() { this( null, null ); } /** * Constructs an OgnlException with the given message but no encapsulated exception. * @param msg the exception's detail message */ public OgnlException( String msg ) { this( msg, null ); } /** * Constructs an OgnlException with the given message and encapsulated exception. * @param msg the exception's detail message * @param reason the encapsulated exception */ public OgnlException( String msg, Throwable reason ) { super( msg ); this._reason = reason; if (_initCause != null) { try { _initCause.invoke(this, new Object[] { reason }); } catch (Exception t) { /** ignore */ } } } /** * Returns the encapsulated exception, or null if there is none. * @return the encapsulated exception */ public Throwable getReason() { return _reason; } /** * Returns the Evaluation that was the root evaluation when the exception was * thrown. * @return The {@link Evaluation}. */ public Evaluation getEvaluation() { return _evaluation; } /** * Sets the Evaluation that was current when this exception was thrown. * * @param value The {@link Evaluation}. */ public void setEvaluation(Evaluation value) { _evaluation = value; } /** * Returns a string representation of this exception. * @return a string representation of this exception */ public String toString() { if ( _reason == null ) return super.toString(); return super.toString() + " [" + _reason + "]"; } /** * Prints the stack trace for this (and possibly the encapsulated) exception on * System.err. */ public void printStackTrace() { printStackTrace( System.err ); } /** * Prints the stack trace for this (and possibly the encapsulated) exception on the * given print stream. */ public void printStackTrace(java.io.PrintStream s) { synchronized (s) { super.printStackTrace(s); if ( _reason != null ) { s.println( "/-- Encapsulated exception ------------\\" ); _reason.printStackTrace(s); s.println( "\\--------------------------------------/" ); } } } /** * Prints the stack trace for this (and possibly the encapsulated) exception on the * given print writer. */ public void printStackTrace(java.io.PrintWriter s) { synchronized (s) { super.printStackTrace(s); if ( _reason != null ) { s.println( "/-- Encapsulated exception ------------\\" ); _reason.printStackTrace(s); s.println( "\\--------------------------------------/" ); } } } } ognl-2.7.3.orig/src/java/ognl/EnumerationElementsAccessor.java0000644000175000017500000000425310561411075024301 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 1998-2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package ognl; import java.util.Enumeration; /** * Implementation of the ElementsAccessor interface for Enumerations, which returns an * iterator that passes its calls through to the target Enumeration. * @author Luke Blanshard (blanshlu@netscape.net) * @author Drew Davidson (drew@ognl.org) */ public class EnumerationElementsAccessor implements ElementsAccessor { public Enumeration getElements( Object target ) { return (Enumeration)target; } } ognl-2.7.3.orig/src/java/ognl/MethodAccessor.java0000644000175000017500000000641710723604233021542 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 1998-2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package ognl; import java.util.Map; /** * This interface defines methods for calling methods in a target object. * Methods are broken up into static and instance methods for convenience. * indexes into the target object, which must be an array. * * @author Luke Blanshard (blanshlu@netscape.net) * @author Drew Davidson (drew@ognl.org) */ public interface MethodAccessor { /** * Calls the static method named with the arguments given on the class given. * @param context expression context in which the method should be called * @param targetClass the object in which the method exists * @param methodName the name of the method * @param args the arguments to the method * * @return result of calling the method * @exception MethodFailedException if there is an error calling the method */ Object callStaticMethod( Map context, Class targetClass, String methodName, Object[] args ) throws MethodFailedException; /** * Calls the method named with the arguments given. * @param context expression context in which the method should be called * @param target the object in which the method exists * @param methodName the name of the method * @param args the arguments to the method * @return result of calling the method * @exception MethodFailedException if there is an error calling the method */ Object callMethod( Map context, Object target, String methodName, Object[] args ) throws MethodFailedException; } ognl-2.7.3.orig/src/java/ognl/ListPropertyAccessor.java0000644000175000017500000002507510776755160023021 0ustar drazzibdrazzib// -------------------------------------------------------------------------- // Copyright (c) 1998-2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. // -------------------------------------------------------------------------- package ognl; import java.lang.reflect.Method; import java.util.*; /** * Implementation of PropertyAccessor that uses numbers and dynamic subscripts as properties to * index into Lists. * * @author Luke Blanshard (blanshlu@netscape.net) * @author Drew Davidson (drew@ognl.org) */ public class ListPropertyAccessor extends ObjectPropertyAccessor implements PropertyAccessor { public Object getProperty(Map context, Object target, Object name) throws OgnlException { List list = (List) target; if (name instanceof String) { Object result = null; if (name.equals("size")) { result = new Integer(list.size()); } else { if (name.equals("iterator")) { result = list.iterator(); } else { if (name.equals("isEmpty") || name.equals("empty")) { result = list.isEmpty() ? Boolean.TRUE : Boolean.FALSE; } else { result = super.getProperty(context, target, name); } } } return result; } if (name instanceof Number) return list.get(((Number) name).intValue()); if (name instanceof DynamicSubscript) { int len = list.size(); switch(((DynamicSubscript) name).getFlag()) { case DynamicSubscript.FIRST: return len > 0 ? list.get(0) : null; case DynamicSubscript.MID: return len > 0 ? list.get(len / 2) : null; case DynamicSubscript.LAST: return len > 0 ? list.get(len - 1) : null; case DynamicSubscript.ALL: return new ArrayList(list); } } throw new NoSuchPropertyException(target, name); } public void setProperty(Map context, Object target, Object name, Object value) throws OgnlException { if (name instanceof String && ((String)name).indexOf("$") < 0) { super.setProperty(context, target, name, value); return; } List list = (List) target; if (name instanceof Number) { list.set(((Number) name).intValue(), value); return; } if (name instanceof DynamicSubscript) { int len = list.size(); switch(((DynamicSubscript) name).getFlag()) { case DynamicSubscript.FIRST: if (len > 0) list.set(0, value); return; case DynamicSubscript.MID: if (len > 0) list.set(len / 2, value); return; case DynamicSubscript.LAST: if (len > 0) list.set(len - 1, value); return; case DynamicSubscript.ALL: { if (!(value instanceof Collection)) throw new OgnlException("Value must be a collection"); list.clear(); list.addAll((Collection) value); return; } } } throw new NoSuchPropertyException(target, name); } public Class getPropertyClass(OgnlContext context, Object target, Object index) { if (index instanceof String) { String key = ((String)index).replaceAll("\"", ""); if (key.equals("size")) { return int.class; } else { if (key.equals("iterator")) { return Iterator.class; } else { if (key.equals("isEmpty") || key.equals("empty")) { return boolean.class; } else { return super.getPropertyClass(context, target, index); } } } } if (index instanceof Number) return Object.class; return null; } public String getSourceAccessor(OgnlContext context, Object target, Object index) { String indexStr = index.toString().replaceAll("\"", ""); if (String.class.isInstance(index)) { if (indexStr.equals("size")) { context.setCurrentAccessor(List.class); context.setCurrentType(int.class); return ".size()"; } else { if (indexStr.equals("iterator")) { context.setCurrentAccessor(List.class); context.setCurrentType(Iterator.class); return ".iterator()"; } else { if (indexStr.equals("isEmpty") || indexStr.equals("empty")) { context.setCurrentAccessor(List.class); context.setCurrentType(boolean.class); return ".isEmpty()"; } } } } // TODO: This feels really inefficient, must be some better way // check if the index string represents a method on a custom class implementing java.util.List instead.. if (context.getCurrentObject() != null && !Number.class.isInstance(context.getCurrentObject())) { try { Method m = OgnlRuntime.getReadMethod(target.getClass(), indexStr); if (m != null) return super.getSourceAccessor(context, target, index); } catch (Throwable t) { throw OgnlOps.castToRuntime(t); } } context.setCurrentAccessor(List.class); // need to convert to primitive for list index access // System.out.println("Curent type: " + context.getCurrentType() + " current object type " + context.getCurrentObject().getClass()); if (!context.getCurrentType().isPrimitive() && Number.class.isAssignableFrom(context.getCurrentType())) { indexStr += "." + OgnlRuntime.getNumericValueGetter(context.getCurrentType()); } else if (context.getCurrentObject() != null && Number.class.isAssignableFrom(context.getCurrentObject().getClass()) && !context.getCurrentType().isPrimitive()) { // means it needs to be cast first as well String toString = String.class.isInstance(index) && context.getCurrentType() != Object.class ? "" : ".toString()"; indexStr = "ognl.OgnlOps#getIntValue(" + indexStr + toString + ")"; } context.setCurrentType(Object.class); return ".get(" + indexStr + ")"; } public String getSourceSetter(OgnlContext context, Object target, Object index) { String indexStr = index.toString().replaceAll("\"", ""); // TODO: This feels really inefficient, must be some better way // check if the index string represents a method on a custom class implementing java.util.List instead.. /* System.out.println("Listpropertyaccessor setter using index: " + index + " and current object: " + context.getCurrentObject() + " number is current object? " + Number.class.isInstance(context.getCurrentObject()));*/ if (context.getCurrentObject() != null && !Number.class.isInstance(context.getCurrentObject())) { try { Method m = OgnlRuntime.getWriteMethod(target.getClass(), indexStr); if (m != null || !context.getCurrentType().isPrimitive()) { System.out.println("super source setter returned: " + super.getSourceSetter(context, target, index)); return super.getSourceSetter(context, target, index); } } catch (Throwable t) { throw OgnlOps.castToRuntime(t); } } /* if (String.class.isInstance(index)) { context.setCurrentAccessor(List.class); return ""; }*/ context.setCurrentAccessor(List.class); // need to convert to primitive for list index access if (!context.getCurrentType().isPrimitive() && Number.class.isAssignableFrom(context.getCurrentType())) { indexStr += "." + OgnlRuntime.getNumericValueGetter(context.getCurrentType()); } else if (context.getCurrentObject() != null && Number.class.isAssignableFrom(context.getCurrentObject().getClass()) && !context.getCurrentType().isPrimitive()) { // means it needs to be cast first as well String toString = String.class.isInstance(index) && context.getCurrentType() != Object.class ? "" : ".toString()"; indexStr = "ognl.OgnlOps#getIntValue(" + indexStr + toString + ")"; } context.setCurrentType(Object.class); return ".set(" + indexStr + ", $3)"; } } ognl-2.7.3.orig/src/java/ognl/IteratorPropertyAccessor.java0000644000175000017500000000576510561411075023665 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 1998-2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package ognl; import java.util.*; /** * Implementation of PropertyAccessor that provides "property" reference to * "next" and "hasNext". * @author Luke Blanshard (blanshlu@netscape.net) * @author Drew Davidson (drew@ognl.org) */ public class IteratorPropertyAccessor extends ObjectPropertyAccessor implements PropertyAccessor // This is here to make javadoc show this class as an implementor { public Object getProperty( Map context, Object target, Object name ) throws OgnlException { Object result; Iterator iterator = (Iterator)target; if ( name instanceof String ) { if (name.equals("next")) { result = iterator.next(); } else { if (name.equals("hasNext")) { result = iterator.hasNext() ? Boolean.TRUE : Boolean.FALSE; } else { result = super.getProperty( context, target, name ); } } } else { result = super.getProperty(context, target, name); } return result; } public void setProperty( Map context, Object target, Object name, Object value ) throws OgnlException { throw new IllegalArgumentException( "can't set property " + name + " on Iterator" ); } } ognl-2.7.3.orig/src/java/ognl/ASTXor.java0000644000175000017500000000471310566476144017771 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 1998-2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package ognl; /** * @author Luke Blanshard (blanshlu@netscape.net) * @author Drew Davidson (drew@ognl.org) */ class ASTXor extends NumericExpression { public ASTXor(int id) { super(id); } public ASTXor(OgnlParser p, int id) { super(p, id); } public void jjtClose() { flattenTree(); } protected Object getValueBody( OgnlContext context, Object source ) throws OgnlException { Object result = _children[0].getValue( context, source ); for ( int i=1; i < _children.length; ++i ) result = OgnlOps.binaryXor( result, _children[i].getValue(context, source) ); return result; } public String getExpressionOperator(int index) { return "^"; } } ognl-2.7.3.orig/src/java/ognl/ExpressionSyntaxException.java0000644000175000017500000000415310577301171024061 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 1998-2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package ognl; /** * Exception thrown if a malformed OGNL expression is encountered. * * @author Luke Blanshard (blanshlu@netscape.net) * @author Drew Davidson (drew@ognl.org) */ public class ExpressionSyntaxException extends OgnlException { public ExpressionSyntaxException( String expression, Throwable reason ) { super( "Malformed OGNL expression: " + expression, reason ); } } ognl-2.7.3.orig/src/java/ognl/ASTUnsignedShiftRight.java0000644000175000017500000000657410646473765023005 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 1998-2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package ognl; /** * @author Luke Blanshard (blanshlu@netscape.net) * @author Drew Davidson (drew@ognl.org) */ class ASTUnsignedShiftRight extends NumericExpression { public ASTUnsignedShiftRight(int id) { super(id); } public ASTUnsignedShiftRight(OgnlParser p, int id) { super(p, id); } protected Object getValueBody( OgnlContext context, Object source ) throws OgnlException { Object v1 = _children[0].getValue( context, source ); Object v2 = _children[1].getValue( context, source ); return OgnlOps.unsignedShiftRight( v1, v2 ); } public String getExpressionOperator(int index) { return ">>>"; } public String toGetSourceString(OgnlContext context, Object target) { String result = ""; try { String child1 = OgnlRuntime.getChildSource(context, target, _children[0]); child1 = coerceToNumeric(child1, context, _children[0]); String child2 = OgnlRuntime.getChildSource(context, target, _children[1]); child2 = coerceToNumeric(child2, context, _children[1]); Object v1 = _children[0].getValue(context, target); int type = OgnlOps.getNumericType(v1); if (type <= OgnlOps.INT) { child1 = "(int)" + child1; child2 = "(int)" + child2; } result = child1 + " >>> " + child2; context.setCurrentType(Integer.TYPE); context.setCurrentObject(getValueBody(context, target)); } catch (Throwable t) { throw OgnlOps.castToRuntime(t); } return result; } } ognl-2.7.3.orig/src/java/ognl/enhance/0000755000175000017500000000000011237553170017371 5ustar drazzibdrazzibognl-2.7.3.orig/src/java/ognl/enhance/EnhancedClassLoader.java0000644000175000017500000000456610566476144024102 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package ognl.enhance; public class EnhancedClassLoader extends ClassLoader { /*=================================================================== Constructors ===================================================================*/ public EnhancedClassLoader(ClassLoader parentClassLoader) { super(parentClassLoader); } /*=================================================================== Overridden methods ===================================================================*/ public Class defineClass(String enhancedClassName, byte[] byteCode) { return defineClass(enhancedClassName, byteCode, 0, byteCode.length); } } ognl-2.7.3.orig/src/java/ognl/enhance/LocalReference.java0000644000175000017500000000115510604045342023101 0ustar drazzibdrazzibpackage ognl.enhance; /** * Container class for {@link OgnlExpressionCompiler} generated local method * block references. */ public interface LocalReference { /** * The name of the assigned variable reference. * * @return The name of the reference as it will be when compiled. */ String getName(); /** * The expression that sets the value, ie the part after refName = . * @return The setting expression. */ String getExpression(); /** * The type of reference. * @return The type. */ Class getType(); } ognl-2.7.3.orig/src/java/ognl/enhance/ExpressionCompiler.java0000644000175000017500000006413310776755160024107 0ustar drazzibdrazzibpackage ognl.enhance; import javassist.*; import ognl.*; import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.util.*; /** * Responsible for managing/providing functionality related to compiling generated java source * expressions via bytecode enhancements for a given ognl expression. */ public class ExpressionCompiler implements OgnlExpressionCompiler { /** * Key used to store any java source string casting statements in the {@link OgnlContext} during * class compilation. */ public static final String PRE_CAST = "_preCast"; /** * {@link ClassLoader} instances. */ protected Map _loaders = new HashMap(); /** * Javassist class definition poool. */ protected ClassPool _pool; protected int _classCounter = 0; /** * Default constructor, does nothing. */ public ExpressionCompiler() { } /** * Used by {@link #castExpression(ognl.OgnlContext, ognl.Node, String)} to store the cast java * source string in to the current {@link OgnlContext}. This will either add to the existing * string present if it already exists or create a new instance and store it using the static key * of {@link #PRE_CAST}. * * @param context * The current execution context. * @param cast * The java source string to store in to the context. */ public static void addCastString(OgnlContext context, String cast) { String value = (String) context.get(PRE_CAST); if (value != null) value = cast + value; else value = cast; context.put(PRE_CAST, value); } /** * Returns the appropriate casting expression (minus parens) for the specified class type. * *

* For instance, if given an {@link Integer} object the string "java.lang.Integer" * would be returned. For an array of primitive ints "int[]" and so on.. *

* * @param type The class to cast a string expression for. * @return The converted raw string version of the class name. */ public static String getCastString(Class type) { if (type == null) return null; return type.isArray() ? type.getComponentType().getName() + "[]" : type.getName(); } /** * Convenience method called by many different property/method resolving AST types to get a root expression * resolving string for the given node. The callers are mostly ignorant and rely on this method to properly * determine if the expression should be cast at all and take the appropriate actions if it should. * * @param expression * The node to check and generate a root expression to if necessary. * @param root * The root object for this execution. * @param context * The current execution context. * @return Either an empty string or a root path java source string compatible with javassist compilations * from the root object up to the specified {@link Node}. */ public static String getRootExpression(Node expression, Object root, OgnlContext context) { String rootExpr = ""; if (!shouldCast(expression)) return rootExpr; if ((!ASTList.class.isInstance(expression) && !ASTVarRef.class.isInstance(expression) && !ASTStaticMethod.class.isInstance(expression) && !ASTStaticField.class.isInstance(expression) && !ASTConst.class.isInstance(expression) && !ExpressionNode.class.isInstance(expression) && !ASTCtor.class.isInstance(expression) && !ASTStaticMethod.class.isInstance(expression) && root != null) || (root != null && ASTRootVarRef.class.isInstance(expression))) { Class castClass = OgnlRuntime.getCompiler().getRootExpressionClass(expression, context); if (castClass.isArray() || ASTRootVarRef.class.isInstance(expression) || ASTThisVarRef.class.isInstance(expression)) { rootExpr = "((" + getCastString(castClass) + ")$2)"; if (ASTProperty.class.isInstance(expression) && !((ASTProperty) expression).isIndexedAccess()) rootExpr += "."; } else if ((ASTProperty.class.isInstance(expression) && ((ASTProperty) expression).isIndexedAccess()) || ASTChain.class.isInstance(expression)) { rootExpr = "((" + getCastString(castClass) + ")$2)"; } else { rootExpr = "((" + getCastString(castClass) + ")$2)."; } } return rootExpr; } /** * Used by {@link #getRootExpression(ognl.Node, Object, ognl.OgnlContext)} to determine if the expression * needs to be cast at all. * * @param expression * The node to check against. * @return Yes if the node type should be cast - false otherwise. */ public static boolean shouldCast(Node expression) { if (ASTChain.class.isInstance(expression)) { Node child = expression.jjtGetChild(0); if (ASTConst.class.isInstance(child) || ASTStaticMethod.class.isInstance(child) || ASTStaticField.class.isInstance(child) || (ASTVarRef.class.isInstance(child) && !ASTRootVarRef.class.isInstance(child))) return false; } return !ASTConst.class.isInstance(expression); } public String castExpression(OgnlContext context, Node expression, String body) { // ok - so this looks really f-ed up ...and it is ..eh if you can do it better I'm all for it :) if (context.getCurrentAccessor() == null || context.getPreviousType() == null || context.getCurrentAccessor().isAssignableFrom(context.getPreviousType()) || (context.getCurrentType() != null && context.getCurrentObject() != null && context.getCurrentType().isAssignableFrom(context.getCurrentObject().getClass()) && context.getCurrentAccessor().isAssignableFrom(context.getPreviousType())) || body == null || body.trim().length() < 1 || (context.getCurrentType() != null && context.getCurrentType().isArray() && (context.getPreviousType() == null || context.getPreviousType() != Object.class)) || ASTOr.class.isInstance(expression) || ASTAnd.class.isInstance(expression) || ASTRootVarRef.class.isInstance(expression) || context.getCurrentAccessor() == Class.class || (context.get(ExpressionCompiler.PRE_CAST) != null && ((String) context.get(ExpressionCompiler.PRE_CAST)).startsWith("new")) || ASTStaticField.class.isInstance(expression) || ASTStaticMethod.class.isInstance(expression) || (OrderedReturn.class.isInstance(expression) && ((OrderedReturn) expression).getLastExpression() != null)) return body; /* System.out.println("castExpression() with expression " + expression + " expr class: " + expression.getClass() + " currentType is: " + context.getCurrentType() + " previousType: " + context.getPreviousType() + "\n current Accessor: " + context.getCurrentAccessor() + " previous Accessor: " + context.getPreviousAccessor() + " current object " + context.getCurrentObject());*/ ExpressionCompiler.addCastString(context, "((" + ExpressionCompiler.getCastString(context.getCurrentAccessor()) + ")"); return ")" + body; } public String getClassName(Class clazz) { if (clazz.getName().equals("java.util.AbstractList$Itr")) return Iterator.class.getName(); if (Modifier.isPublic(clazz.getModifiers()) && clazz.isInterface()) return clazz.getName(); Class[] intf = clazz.getInterfaces(); for (int i = 0; i < intf.length; i++) { if (intf[i].getName().indexOf("util.List") > 0) return intf[i].getName(); else if (intf[i].getName().indexOf("Iterator") > 0) return intf[i].getName(); } if (clazz.getSuperclass() != null && clazz.getSuperclass().getInterfaces().length > 0) return getClassName(clazz.getSuperclass()); return clazz.getName(); } public Class getSuperOrInterfaceClass(Method m, Class clazz) { if (clazz.getInterfaces() != null && clazz.getInterfaces().length > 0) { Class[] intfs = clazz.getInterfaces(); Class intClass; for (int i = 0; i < intfs.length; i++) { intClass = getSuperOrInterfaceClass(m, intfs[i]); if (intClass != null) return intClass; if (Modifier.isPublic(intfs[i].getModifiers()) && containsMethod(m, intfs[i])) return intfs[i]; } } if (clazz.getSuperclass() != null) { Class superClass = getSuperOrInterfaceClass(m, clazz.getSuperclass()); if (superClass != null) return superClass; } if (Modifier.isPublic(clazz.getModifiers()) && containsMethod(m, clazz)) return clazz; return null; } /** * Helper utility method used by compiler to help resolve class->method mappings * during method calls to {@link OgnlExpressionCompiler#getSuperOrInterfaceClass(java.lang.reflect.Method, Class)}. * * @param m * The method to check for existance of. * @param clazz * The class to check for the existance of a matching method definition to the method passed in. * @return True if the class contains the specified method, false otherwise. */ public boolean containsMethod(Method m, Class clazz) { Method[] methods = clazz.getMethods(); if (methods == null) return false; for (int i = 0; i < methods.length; i++) { if (methods[i].getName().equals(m.getName()) && methods[i].getReturnType() == m.getReturnType()) { Class[] parms = m.getParameterTypes(); if (parms == null) continue; Class[] mparms = methods[i].getParameterTypes(); if (mparms == null || mparms.length != parms.length) continue; boolean parmsMatch = true; for (int p = 0; p < parms.length; p++) { if (parms[p] != mparms[p]) { parmsMatch = false; break; } } if (!parmsMatch) continue; Class[] exceptions = m.getExceptionTypes(); if (exceptions == null) continue; Class[] mexceptions = methods[i].getExceptionTypes(); if (mexceptions == null || mexceptions.length != exceptions.length) continue; boolean exceptionsMatch = true; for (int e = 0; e < exceptions.length; e++) { if (exceptions[e] != mexceptions[e]) { exceptionsMatch = false; break; } } if (!exceptionsMatch) continue; return true; } } return false; } public Class getInterfaceClass(Class clazz) { if (clazz.getName().equals("java.util.AbstractList$Itr")) return Iterator.class; if (Modifier.isPublic(clazz.getModifiers()) && clazz.isInterface() || clazz.isPrimitive()) return clazz; Class[] intf = clazz.getInterfaces(); for (int i = 0; i < intf.length; i++) { if (List.class.isAssignableFrom(intf[i])) return List.class; else if (Iterator.class.isAssignableFrom(intf[i])) return Iterator.class; else if (Map.class.isAssignableFrom(intf[i])) return Map.class; else if (Set.class.isAssignableFrom(intf[i])) return Set.class; else if (Collection.class.isAssignableFrom(intf[i])) return Collection.class; } if (clazz.getSuperclass() != null && clazz.getSuperclass().getInterfaces().length > 0) return getInterfaceClass(clazz.getSuperclass()); return clazz; } public Class getRootExpressionClass(Node rootNode, OgnlContext context) { if (context.getRoot() == null) return null; Class ret = context.getRoot().getClass(); if (context.getFirstAccessor() != null && context.getFirstAccessor().isInstance(context.getRoot())) { ret = context.getFirstAccessor(); } return ret; } /* (non-Javadoc) * @see ognl.enhance.OgnlExpressionCompiler#compileExpression(ognl.OgnlContext, ognl.Node, java.lang.Object) */ public void compileExpression(OgnlContext context, Node expression, Object root) throws Exception { // System.out.println("Compiling expr class " + expression.getClass().getName() + " and root " + root); if (expression.getAccessor() != null) return; String getBody, setBody; EnhancedClassLoader loader = getClassLoader(context); ClassPool pool = getClassPool(context, loader); CtClass newClass = pool.makeClass(expression.getClass().getName() + expression.hashCode() + _classCounter++ + "Accessor"); newClass.addInterface(getCtClass(ExpressionAccessor.class)); CtClass ognlClass = getCtClass(OgnlContext.class); CtClass objClass = getCtClass(Object.class); CtMethod valueGetter = new CtMethod(objClass, "get", new CtClass[]{ognlClass, objClass}, newClass); CtMethod valueSetter = new CtMethod(CtClass.voidType, "set", new CtClass[]{ognlClass, objClass, objClass}, newClass); CtField nodeMember = null; // will only be set if uncompilable exception is thrown CtClass nodeClass = getCtClass(Node.class); CtMethod setExpression = null; try { getBody = generateGetter(context, newClass, objClass, pool, valueGetter, expression, root); } catch (UnsupportedCompilationException uc) { //uc.printStackTrace(); nodeMember = new CtField(nodeClass, "_node", newClass); newClass.addField(nodeMember); getBody = generateOgnlGetter(newClass, valueGetter, nodeMember); if (setExpression == null) { setExpression = CtNewMethod.setter("setExpression", nodeMember); newClass.addMethod(setExpression); } } try { setBody = generateSetter(context, newClass, objClass, pool, valueSetter, expression, root); } catch (UnsupportedCompilationException uc) { //uc.printStackTrace(); if (nodeMember == null) { nodeMember = new CtField(nodeClass, "_node", newClass); newClass.addField(nodeMember); } setBody = generateOgnlSetter(newClass, valueSetter, nodeMember); if (setExpression == null) { setExpression = CtNewMethod.setter("setExpression", nodeMember); newClass.addMethod(setExpression); } } try { newClass.addConstructor(CtNewConstructor.defaultConstructor(newClass)); Class clazz = pool.toClass(newClass); newClass.detach(); expression.setAccessor((ExpressionAccessor) clazz.newInstance()); // need to set expression on node if the field was just defined. if (nodeMember != null) { expression.getAccessor().setExpression(expression); } } catch (Throwable t) { //t.printStackTrace(); throw new RuntimeException("Error compiling expression on object " + root + " with expression node " + expression + " getter body: " + getBody + " setter body: " + setBody, t); } } protected String generateGetter(OgnlContext context, CtClass newClass, CtClass objClass, ClassPool pool, CtMethod valueGetter, Node expression, Object root) throws Exception { String pre = ""; String post = ""; String body; context.setRoot(root); // the ExpressionAccessor API has to reference the generic Object class for get/set operations, so this sets up that known // type beforehand context.remove(PRE_CAST); // Recursively generate the java source code representation of the top level expression String getterCode = expression.toGetSourceString(context, root); if (getterCode == null || getterCode.trim().length() <= 0 && !ASTVarRef.class.isAssignableFrom(expression.getClass())) getterCode = "null"; String castExpression = (String) context.get(PRE_CAST); if (context.getCurrentType() == null || context.getCurrentType().isPrimitive() || Character.class.isAssignableFrom(context.getCurrentType()) || Object.class == context.getCurrentType()) { pre = pre + " ($w) ("; post = post + ")"; } String rootExpr = !getterCode.equals("null") ? getRootExpression(expression, root, context) : ""; String noRoot = (String) context.remove("_noRoot"); if (noRoot != null) rootExpr = ""; createLocalReferences(context, pool, newClass, objClass, valueGetter.getParameterTypes()); if (OrderedReturn.class.isInstance(expression) && ((OrderedReturn) expression).getLastExpression() != null) { body = "{ " + (ASTMethod.class.isInstance(expression) || ASTChain.class.isInstance(expression) ? rootExpr : "") + (castExpression != null ? castExpression : "") + ((OrderedReturn) expression).getCoreExpression() + " return " + pre + ((OrderedReturn) expression).getLastExpression() + post + ";}"; } else { body = "{ return " + pre + (castExpression != null ? castExpression : "") + rootExpr + getterCode + post + ";}"; } body = body.replaceAll("\\.\\.", "."); // System.out.println("Getter Body: ===================================\n" + body); valueGetter.setBody(body); newClass.addMethod(valueGetter); return body; } public String createLocalReference(OgnlContext context, String expression, Class type) { String referenceName = "ref" + context.incrementLocalReferenceCounter(); context.addLocalReference(referenceName, new LocalReferenceImpl(referenceName, expression, type)); String castString = ""; if (!type.isPrimitive()) castString = "(" + ExpressionCompiler.getCastString(type) + ") "; return castString + referenceName + "($$)"; } void createLocalReferences(OgnlContext context, ClassPool pool, CtClass clazz, CtClass objClass, CtClass[] params) throws CannotCompileException, NotFoundException { Map referenceMap = context.getLocalReferences(); if (referenceMap == null || referenceMap.size() < 1) return; Iterator it = referenceMap.values().iterator(); while (it.hasNext()) { LocalReference ref = (LocalReference) it.next(); String widener = ref.getType().isPrimitive() ? " " : " ($w) "; String body = "{"; body += " return " + widener + ref.getExpression() + ";"; body += "}"; body = body.replaceAll("\\.\\.", "."); // System.out.println("adding method " + ref.getName() + " with body:\n" + body + " and return type: " + ref.getType()); CtMethod method = new CtMethod(pool.get(getCastString(ref.getType())), ref.getName(), params, clazz); method.setBody(body); clazz.addMethod(method); it.remove(); } } protected String generateSetter(OgnlContext context, CtClass newClass, CtClass objClass, ClassPool pool, CtMethod valueSetter, Node expression, Object root) throws Exception { if (ExpressionNode.class.isInstance(expression) || ASTConst.class.isInstance(expression)) throw new UnsupportedCompilationException("Can't compile expression/constant setters."); context.setRoot(root); context.remove(PRE_CAST); String body; String setterCode = expression.toSetSourceString(context, root); String castExpression = (String) context.get(PRE_CAST); if (setterCode == null || setterCode.trim().length() < 1) throw new UnsupportedCompilationException("Can't compile null setter body."); if (root == null) throw new UnsupportedCompilationException("Can't compile setters with a null root object."); String pre = getRootExpression(expression, root, context); String noRoot = (String) context.remove("_noRoot"); if (noRoot != null) pre = ""; createLocalReferences(context, pool, newClass, objClass, valueSetter.getParameterTypes()); body = "{" + (castExpression != null ? castExpression : "") + pre + setterCode + ";}"; body = body.replaceAll("\\.\\.", "."); // System.out.println("Setter Body: ===================================\n" + body); valueSetter.setBody(body); newClass.addMethod(valueSetter); return body; } /** * Fail safe getter creation when normal compilation fails. * * @param clazz * The javassist class the new method should be attached to. * @param valueGetter * The method definition the generated code will be contained within. * @param node * The root expression node. * @return The generated source string for this method, the method will still be * added via the javassist API either way so this is really a convenience * for exception reporting / debugging. * @throws Exception * If a javassist error occurs. */ protected String generateOgnlGetter(CtClass clazz, CtMethod valueGetter, CtField node) throws Exception { String body = "return " + node.getName() + ".getValue($1, $2);"; valueGetter.setBody(body); clazz.addMethod(valueGetter); return body; } /** * Fail safe setter creation when normal compilation fails. * * @param clazz * The javassist class the new method should be attached to. * @param valueSetter * The method definition the generated code will be contained within. * @param node * The root expression node. * @return The generated source string for this method, the method will still be * added via the javassist API either way so this is really a convenience * for exception reporting / debugging. * @throws Exception * If a javassist error occurs. */ protected String generateOgnlSetter(CtClass clazz, CtMethod valueSetter, CtField node) throws Exception { String body = node.getName() + ".setValue($1, $2, $3);"; valueSetter.setBody(body); clazz.addMethod(valueSetter); return body; } /** * Creates a {@link ClassLoader} instance compatible with the javassist classloader and normal * OGNL class resolving semantics. * * @param context * The current execution context. * * @return The created {@link ClassLoader} instance. */ protected EnhancedClassLoader getClassLoader(OgnlContext context) { EnhancedClassLoader ret = (EnhancedClassLoader) _loaders.get(context.getClassResolver()); if (ret != null) return ret; ClassLoader classLoader = new ContextClassLoader(OgnlContext.class.getClassLoader(), context); ret = new EnhancedClassLoader(classLoader); _loaders.put(context.getClassResolver(), ret); return ret; } /** * Loads a new class definition via javassist for the specified class. * * @param searchClass * The class to load. * @return The javassist class equivalent. * * @throws NotFoundException When the class definition can't be found. */ protected CtClass getCtClass(Class searchClass) throws NotFoundException { return _pool.get(searchClass.getName()); } /** * Gets either a new or existing {@link ClassPool} for use in compiling javassist * classes. A new class path object is inserted in to the returned {@link ClassPool} using * the passed in loader instance if a new pool needs to be created. * * @param context * The current execution context. * @param loader * The {@link ClassLoader} instance to use - as returned by {@link #getClassLoader(ognl.OgnlContext)}. * @return The existing or new {@link ClassPool} instance. */ protected ClassPool getClassPool(OgnlContext context, EnhancedClassLoader loader) { if (_pool != null) return _pool; _pool = ClassPool.getDefault(); _pool.insertClassPath(new LoaderClassPath(loader.getParent())); return _pool; } } ognl-2.7.3.orig/src/java/ognl/enhance/LocalReferenceImpl.java0000644000175000017500000000322610633051645023731 0ustar drazzibdrazzibpackage ognl.enhance; /** * Implementation of {@link LocalReference}. */ public class LocalReferenceImpl implements LocalReference { String _name; Class _type; String _expression; public LocalReferenceImpl(String name, String expression, Class type) { _name = name; _type = type; _expression = expression; } public String getName() { return _name; } public String getExpression() { return _expression; } public Class getType() { return _type; } public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; LocalReferenceImpl that = (LocalReferenceImpl) o; if (_expression != null ? !_expression.equals(that._expression) : that._expression != null) return false; if (_name != null ? !_name.equals(that._name) : that._name != null) return false; if (_type != null ? !_type.equals(that._type) : that._type != null) return false; return true; } public int hashCode() { int result; result = (_name != null ? _name.hashCode() : 0); result = 31 * result + (_type != null ? _type.hashCode() : 0); result = 31 * result + (_expression != null ? _expression.hashCode() : 0); return result; } public String toString() { return "LocalReferenceImpl[" + "_name='" + _name + '\'' + '\n' + ", _type=" + _type + '\n' + ", _expression='" + _expression + '\'' + '\n' + ']'; } } ognl-2.7.3.orig/src/java/ognl/enhance/OgnlExpressionCompiler.java0000644000175000017500000001313310633051645024706 0ustar drazzibdrazzib/** * */ package ognl.enhance; import ognl.Node; import ognl.OgnlContext; import java.lang.reflect.Method; /** * Core interface implemented by expression compiler instances. */ public interface OgnlExpressionCompiler { /** Static constant used in conjunction with {@link OgnlContext} to store temporary references. */ String ROOT_TYPE = "-ognl-root-type"; /** * The core method executed to compile a specific expression. It is expected that this expression * always return a {@link Node} with a non null {@link ognl.Node#getAccessor()} instance - unless an exception * is thrown by the method or the statement wasn't compilable in this instance because of missing/null objects * in the expression. These instances may in some cases continue to call this compilation method until the expression * is resolvable. * * @param context * The context of execution. * @param expression * The pre-parsed root expression node to compile. * @param root * The root object for the expression - may be null in many instances so some implementations * may exit * @throws Exception * If an error occurs compiling the expression and no strategy has been implemented to handle incremental * expression compilation for incomplete expression members. */ void compileExpression(OgnlContext context, Node expression, Object root) throws Exception; /** * Gets a javassist safe class string for the given class instance. This is especially * useful for handling array vs. normal class casting strings. * * @param clazz * The class to get a string equivalent javassist compatible string reference for. * * @return The string equivalent of the class. */ String getClassName(Class clazz); /** * Used in places where the preferred {@link #getSuperOrInterfaceClass(java.lang.reflect.Method, Class)} isn't possible * because the method isn't known for a class. Attempts to upcast the given class to the next available non-private accessible * class so that compiled expressions can reference the interface class of an instance so as not to be compiled in to overly * specific statements. * * @param clazz * The class to attempt to find a compatible interface for. * @return The same class if no higher level interface could be matched against or the interface equivalent class. */ Class getInterfaceClass(Class clazz); /** * For the given {@link Method} and class finds the highest level interface class this combination can be cast to. * * @param m * The method the class must implement. * @param clazz * The current class being worked with. * @return The highest level interface / class that the referenced {@link Method} is declared in. */ Class getSuperOrInterfaceClass(Method m, Class clazz); /** * For a given root object type returns the base class type to be used in root referenced expressions. This * helps in some instances where the root objects themselves are compiled javassist instances that need more generic * class equivalents to cast to. * * @param rootNode * The root expression node. * @param context * The current execution context. * @return The root expression class type to cast to for this node. */ Class getRootExpressionClass(Node rootNode, OgnlContext context); /** * Used primarily by AST types like {@link ognl.ASTChain} where foo.bar.id type references * may need to be cast multiple times in order to properly resolve the members in a compiled statement. * *

* This method should be using the various {@link ognl.OgnlContext#getCurrentType()} / {@link ognl.OgnlContext#getCurrentAccessor()} methods * to inspect the type stack and properly cast to the right classes - but only when necessary. *

* * @param context * The current execution context. * @param expression * The node being checked for casting. * @param body * The java source string generated by the given node. * @return The body string parameter plus any additional casting syntax needed to make the expression * resolvable. */ String castExpression(OgnlContext context, Node expression, String body); /** * Method is used for expressions where multiple inner parameter method calls in generated java source strings * cause javassit failures. It is hacky and cumbersome to have to generate expressions this way but it's the only * current known way to make javassist happy. * *

* Takes an expression block generated by a node and creates a new method on the base object being compiled so that * sufficiently complicated sub expression blocks can be broken out in to distinct methods to be referenced by the core * accessor / setter methods in the base compiled root object. *

* * @param context * The current execution context. * @param expression * The java source expression to dump in to a seperate method reference. * @param type * The return type that should be specified for the new method. * @return The method name that will be used to reference the sub expression in place of the actual sub expression * itself. */ String createLocalReference(OgnlContext context, String expression, Class type); } ognl-2.7.3.orig/src/java/ognl/enhance/ContextClassLoader.java0000644000175000017500000000517610566476144024017 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package ognl.enhance; import ognl.OgnlContext; public class ContextClassLoader extends ClassLoader { private OgnlContext context; /*=================================================================== Constructors ===================================================================*/ public ContextClassLoader(ClassLoader parentClassLoader, OgnlContext context) { super(parentClassLoader); this.context = context; } /*=================================================================== Overridden methods ===================================================================*/ protected Class findClass(String name) throws ClassNotFoundException { if ((context != null) && (context.getClassResolver() != null)) { return context.getClassResolver().classForName(name, context); } return super.findClass(name); } } ognl-2.7.3.orig/src/java/ognl/enhance/ExpressionAccessor.java0000644000175000017500000000303310633051645024054 0ustar drazzibdrazzib/** * */ package ognl.enhance; import ognl.Node; import ognl.OgnlContext; /** * Provides pure java expression paths to get/set values from an ognl expression. This * is achieved by taking an existing {@link Node} parsed expression and using bytecode * enhancements to do the same work using pure java vs the ognl interpreter. */ public interface ExpressionAccessor { /** * Gets the value represented by this expression path, if any. * * @param context * The standard ognl context used for variable substitution/etc. * @param target * The root object this expression is meant for. * @return * The evaluated value, if any. */ Object get(OgnlContext context, Object target); /** * Sets the value represented by this expression path, if possible. * * @param context * The standard ognl context used for variable substitution/etc. * @param target * The root object this expression is meant for. * @param value * The new value to set if this expression references a settable property. */ void set(OgnlContext context, Object target, Object value); /** * Used to set the original root expression node on instances where the compiled version * has to fall back to interpreted syntax because of compilation failures. * * @param expression * The root expression node used to generate this accessor. */ void setExpression(Node expression); } ognl-2.7.3.orig/src/java/ognl/enhance/UnsupportedCompilationException.java0000644000175000017500000000124410655154670026650 0ustar drazzibdrazzibpackage ognl.enhance; /** * Thrown during bytecode enhancement conversions of ognl expressions to indicate * that a certain expression isn't currently supported as a pure java bytecode enhanced * version. * *

* If this exception is thrown it is expected that ognl will fall back to default ognl * evaluation of the expression. *

* * @author jkuhnert */ public class UnsupportedCompilationException extends RuntimeException { public UnsupportedCompilationException(String message) { super(message); } public UnsupportedCompilationException(String message, Throwable cause) { super(message, cause); } } ognl-2.7.3.orig/src/java/ognl/enhance/OrderedReturn.java0000644000175000017500000000141310633051645023016 0ustar drazzibdrazzibpackage ognl.enhance; import ognl.Node; /** * Marks an ognl expression {@link Node} as needing to have the return portion of a * getter method happen in a specific part of the generated expression vs just having * the whole expression returned in one chunk. */ public interface OrderedReturn { /** * Get the core expression to execute first before any return foo logic is started. * * @return The core standalone expression that shouldn't be pre-pended with a return keyword. */ String getCoreExpression(); /** * Gets the last expression to be pre-pended with a return <expression> block. * * @return The expression representing the return portion of a statement; */ String getLastExpression(); } ognl-2.7.3.orig/src/java/ognl/TokenMgrError.java0000644000175000017500000001053410746450726021405 0ustar drazzibdrazzib/* Generated By:JavaCC: Do not edit this line. TokenMgrError.java Version 4.1 */ /* JavaCCOptions: */ package ognl; /** Token Manager Error. */ public class TokenMgrError extends Error { /* * Ordinals for various reasons why an Error of this type can be thrown. */ /** * Lexical error occurred. */ static final int LEXICAL_ERROR = 0; /** * An attempt was made to create a second instance of a static token manager. */ static final int STATIC_LEXER_ERROR = 1; /** * Tried to change to an invalid lexical state. */ static final int INVALID_LEXICAL_STATE = 2; /** * Detected (and bailed out of) an infinite loop in the token manager. */ static final int LOOP_DETECTED = 3; /** * Indicates the reason why the exception is thrown. It will have * one of the above 4 values. */ int errorCode; /** * Replaces unprintable characters by their escaped (or unicode escaped) * equivalents in the given string */ protected static final String addEscapes(String str) { StringBuffer retval = new StringBuffer(); char ch; for (int i = 0; i < str.length(); i++) { switch (str.charAt(i)) { case 0 : continue; case '\b': retval.append("\\b"); continue; case '\t': retval.append("\\t"); continue; case '\n': retval.append("\\n"); continue; case '\f': retval.append("\\f"); continue; case '\r': retval.append("\\r"); continue; case '\"': retval.append("\\\""); continue; case '\'': retval.append("\\\'"); continue; case '\\': retval.append("\\\\"); continue; default: if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) { String s = "0000" + Integer.toString(ch, 16); retval.append("\\u" + s.substring(s.length() - 4, s.length())); } else { retval.append(ch); } continue; } } return retval.toString(); } /** * Returns a detailed message for the Error when it is thrown by the * token manager to indicate a lexical error. * Parameters : * EOFSeen : indicates if EOF caused the lexical error * curLexState : lexical state in which this error occurred * errorLine : line number when the error occurred * errorColumn : column number when the error occurred * errorAfter : prefix that was seen before this error occurred * curchar : the offending character * Note: You can customize the lexical error message by modifying this method. */ protected static String LexicalError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar) { return("Lexical error at line " + errorLine + ", column " + errorColumn + ". Encountered: " + (EOFSeen ? " " : ("\"" + addEscapes(String.valueOf(curChar)) + "\"") + " (" + (int)curChar + "), ") + "after : \"" + addEscapes(errorAfter) + "\""); } /** * You can also modify the body of this method to customize your error messages. * For example, cases like LOOP_DETECTED and INVALID_LEXICAL_STATE are not * of end-users concern, so you can return something like : * * "Internal Error : Please file a bug report .... " * * from this method for such cases in the release version of your parser. */ public String getMessage() { return super.getMessage(); } /* * Constructors of various flavors follow. */ /** No arg constructor. */ public TokenMgrError() { } /** Constructor with message and reason. */ public TokenMgrError(String message, int reason) { super(message); errorCode = reason; } /** Full Constructor. */ public TokenMgrError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar, int reason) { this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason); } } /* JavaCC - OriginalChecksum=fc24e4c222ec3f01f7c4dd2c636977da (do not edit this line) */ ognl-2.7.3.orig/src/java/ognl/ExpressionNode.java0000644000175000017500000001327610632543423021607 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 1998-2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package ognl; import ognl.enhance.ExpressionCompiler; /** * @author Luke Blanshard (blanshlu@netscape.net) * @author Drew Davidson (drew@ognl.org) */ public abstract class ExpressionNode extends SimpleNode { public ExpressionNode(int i) { super(i); } public ExpressionNode(OgnlParser p, int i) { super(p, i); } /** Returns true iff this node is constant without respect to the children. */ public boolean isNodeConstant( OgnlContext context ) throws OgnlException { return false; } public boolean isConstant( OgnlContext context ) throws OgnlException { boolean result = isNodeConstant(context); if ((_children != null) && (_children.length > 0)) { result = true; for ( int i=0; result && (i < _children.length); ++i ) { if (_children[i] instanceof SimpleNode) { result = ((SimpleNode)_children[i]).isConstant( context ); } else { result = false; } } } return result; } public String getExpressionOperator(int index) { throw new RuntimeException("unknown operator for " + OgnlParserTreeConstants.jjtNodeName[_id]); } public String toString() { String result = (_parent == null) ? "" : "("; if ((_children != null) && (_children.length > 0)) { for ( int i = 0; i < _children.length; ++i ) { if (i > 0) { result += " " + getExpressionOperator(i) + " "; } result += _children[i].toString(); } } if (_parent != null) { result = result + ")"; } return result; } public String toGetSourceString(OgnlContext context, Object target) { String result = (_parent == null || NumericExpression.class.isAssignableFrom(_parent.getClass())) ? "" : "("; if ((_children != null) && (_children.length > 0)) { for ( int i = 0; i < _children.length; ++i ) { if (i > 0) { result += " " + getExpressionOperator(i) + " "; } String value = _children[i].toGetSourceString(context, target); if ((ASTProperty.class.isInstance(_children[i]) || ASTMethod.class.isInstance(_children[i]) || ASTSequence.class.isInstance(_children[i]) || ASTChain.class.isInstance(_children[i])) && value != null && value.trim().length() > 0) { String pre = null; if (ASTMethod.class.isInstance(_children[i])) { pre = (String)context.get("_currentChain"); } if (pre == null) pre = ""; String cast = (String)context.remove(ExpressionCompiler.PRE_CAST); if (cast == null) cast = ""; value = cast + ExpressionCompiler.getRootExpression(_children[i], context.getRoot(), context) + pre + value; } result += value; } } if (_parent != null && !NumericExpression.class.isAssignableFrom(_parent.getClass())) { result = result + ")"; } return result; } public String toSetSourceString(OgnlContext context, Object target) { String result = (_parent == null) ? "" : "("; if ((_children != null) && (_children.length > 0)) { for ( int i = 0; i < _children.length; ++i ) { if (i > 0) { result += " " + getExpressionOperator(i) + " "; } result += _children[i].toSetSourceString(context, target); } } if (_parent != null) { result = result + ")"; } return result; } } ognl-2.7.3.orig/src/java/ognl/OgnlParserTreeConstants.java0000644000175000017500000000445610746450726023444 0ustar drazzibdrazzib/* Generated By:JavaCC: Do not edit this line. OgnlParserTreeConstants.java Version 4.1d1 */ package ognl; public interface OgnlParserTreeConstants { public int JJTVOID = 0; public int JJTSEQUENCE = 1; public int JJTASSIGN = 2; public int JJTTEST = 3; public int JJTOR = 4; public int JJTAND = 5; public int JJTBITOR = 6; public int JJTXOR = 7; public int JJTBITAND = 8; public int JJTEQ = 9; public int JJTNOTEQ = 10; public int JJTLESS = 11; public int JJTGREATER = 12; public int JJTLESSEQ = 13; public int JJTGREATEREQ = 14; public int JJTIN = 15; public int JJTNOTIN = 16; public int JJTSHIFTLEFT = 17; public int JJTSHIFTRIGHT = 18; public int JJTUNSIGNEDSHIFTRIGHT = 19; public int JJTADD = 20; public int JJTSUBTRACT = 21; public int JJTMULTIPLY = 22; public int JJTDIVIDE = 23; public int JJTREMAINDER = 24; public int JJTNEGATE = 25; public int JJTBITNEGATE = 26; public int JJTNOT = 27; public int JJTINSTANCEOF = 28; public int JJTCHAIN = 29; public int JJTEVAL = 30; public int JJTCONST = 31; public int JJTTHISVARREF = 32; public int JJTROOTVARREF = 33; public int JJTVARREF = 34; public int JJTLIST = 35; public int JJTMAP = 36; public int JJTKEYVALUE = 37; public int JJTSTATICFIELD = 38; public int JJTCTOR = 39; public int JJTPROPERTY = 40; public int JJTSTATICMETHOD = 41; public int JJTMETHOD = 42; public int JJTPROJECT = 43; public int JJTSELECT = 44; public int JJTSELECTFIRST = 45; public int JJTSELECTLAST = 46; public String[] jjtNodeName = { "void", "Sequence", "Assign", "Test", "Or", "And", "BitOr", "Xor", "BitAnd", "Eq", "NotEq", "Less", "Greater", "LessEq", "GreaterEq", "In", "NotIn", "ShiftLeft", "ShiftRight", "UnsignedShiftRight", "Add", "Subtract", "Multiply", "Divide", "Remainder", "Negate", "BitNegate", "Not", "Instanceof", "Chain", "Eval", "Const", "ThisVarRef", "RootVarRef", "VarRef", "List", "Map", "KeyValue", "StaticField", "Ctor", "Property", "StaticMethod", "Method", "Project", "Select", "SelectFirst", "SelectLast", }; } /* JavaCC - OriginalChecksum=effe3edc2df093c4b217c61a43612af5 (do not edit this line) */ ognl-2.7.3.orig/src/java/ognl/DefaultTypeConverter.java0000644000175000017500000000461610561411075022754 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 1998-2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package ognl; import java.lang.reflect.Member; import java.util.Map; /** * Default type conversion. Converts among numeric types and also strings. * @author Luke Blanshard (blanshlu@netscape.net) * @author Drew Davidson (drew@ognl.org) */ public class DefaultTypeConverter implements TypeConverter { public DefaultTypeConverter() { super(); } public Object convertValue(Map context, Object value, Class toType) { return OgnlOps.convertValue(value, toType); } public Object convertValue(Map context, Object target, Member member, String propertyName, Object value, Class toType) { return convertValue(context, value, toType); } } ognl-2.7.3.orig/src/java/ognl/ObjectNullHandler.java0000644000175000017500000000445010561411075022171 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 1998-2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package ognl; import java.util.*; /** * Implementation of NullHandler that returns null in all cases, * so that NullPointerException will be thrown by the caller. * @author Luke Blanshard (blanshlu@netscape.net) * @author Drew Davidson (drew@ognl.org) */ public class ObjectNullHandler implements NullHandler { /* NullHandler interface */ public Object nullMethodResult(Map context, Object target, String methodName, Object[] args) { return null; } public Object nullPropertyValue(Map context, Object target, Object property) { return null; } } ognl-2.7.3.orig/src/java/ognl/ClassCacheInspector.java0000644000175000017500000000077610634773332022531 0ustar drazzibdrazzibpackage ognl; /** * Optional interface that may be registered with {@link OgnlRuntime#setClassCacheInspector(ClassCacheInspector)} as * a means to disallow caching of specific class types. */ public interface ClassCacheInspector { /** * Invoked just before storing a class type within a cache instance. * * @param type * The class that is to be stored. * * @return True if the class can be cached, false otherwise. */ boolean shouldCache(Class type); } ognl-2.7.3.orig/src/java/ognl/package.html0000644000175000017500000000473310561411075020254 0ustar drazzibdrazzib OGNL Overview

OGNL stands for Object-Graph Navigation Language; it is an expression language for getting and setting properties of Java objects. You use the same expression for both getting and setting the value of a property.

OGNL started out as a way to set up associations between UI components and controllers using property names. As the desire for more complicated associations grew, Drew Davidson created what he called KVCL, for Key-Value Coding Language, egged on by Luke Blanshard. Luke then reimplemented the language using ANTLR, came up with the new name, and, egged on by Drew, filled it out to its current state.

We pronounce OGNL as a word, like the last syllables of a drunken pronunciation of "orthogonal" or like "ogg-null".

ognl-2.7.3.orig/src/java/ognl/ClassResolver.java0000644000175000017500000000410110561411075021412 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 1998-2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package ognl; import java.util.Map; /** * This interface defines an object that will resolve a class from a string * and a ognl context table. * @author Luke Blanshard (blanshlu@netscape.net) * @author Drew Davidson (drew@ognl.org) */ public interface ClassResolver { public Class classForName(String className, Map context) throws ClassNotFoundException; } ognl-2.7.3.orig/src/java/ognl/ASTInstanceof.java0000644000175000017500000000653110646475141021305 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 2002, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package ognl; /** * @author Luke Blanshard (blanshlu@netscape.net) * @author Drew Davidson (drew@ognl.org) */ public class ASTInstanceof extends SimpleNode implements NodeType { private String targetType; public ASTInstanceof(int id) { super(id); } public ASTInstanceof(OgnlParser p, int id) { super(p, id); } void setTargetType( String targetType ) { this.targetType = targetType; } protected Object getValueBody( OgnlContext context, Object source ) throws OgnlException { Object value = _children[0].getValue( context, source ); return OgnlRuntime.isInstance(context, value, targetType) ? Boolean.TRUE : Boolean.FALSE; } public String toString() { return _children[0] + " instanceof " + targetType; } public Class getGetterClass() { return boolean.class; } public Class getSetterClass() { return null; } public String toGetSourceString(OgnlContext context, Object target) { try { String ret = ""; if (ASTConst.class.isInstance(_children[0])) ret = ((Boolean)getValueBody(context, target)).toString(); else ret = _children[0].toGetSourceString(context, target) + " instanceof " + targetType; context.setCurrentType(Boolean.TYPE); return ret; } catch (Throwable t) { throw OgnlOps.castToRuntime(t); } } public String toSetSourceString(OgnlContext context, Object target) { return toGetSourceString(context, target); } } ognl-2.7.3.orig/src/java/ognl/ASTGreater.java0000644000175000017500000000475110566476144020614 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 1998-2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package ognl; /** * @author Luke Blanshard (blanshlu@netscape.net) * @author Drew Davidson (drew@ognl.org) */ class ASTGreater extends ComparisonExpression { public ASTGreater(int id) { super(id); } public ASTGreater(OgnlParser p, int id) { super(p, id); } protected Object getValueBody( OgnlContext context, Object source ) throws OgnlException { Object v1 = _children[0].getValue( context, source ); Object v2 = _children[1].getValue( context, source ); return OgnlOps.greater( v1, v2 )? Boolean.TRUE : Boolean.FALSE; } public String getExpressionOperator(int index) { return ">"; } public String getComparisonFunction() { return "ognl.OgnlOps.greater"; } } ognl-2.7.3.orig/src/java/ognl/EvaluationPool.java0000644000175000017500000001136710561411075021600 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 1998-2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package ognl; import java.util.*; public final class EvaluationPool extends Object { private List evaluations = new ArrayList(); private int size = 0; private int created = 0; private int recovered = 0; private int recycled = 0; public EvaluationPool() { this(0); } public EvaluationPool(int initialSize) { super(); for (int i = 0; i < initialSize; i++) { evaluations.add(new Evaluation(null, null)); } created = size = initialSize; } /** Returns an Evaluation that contains the node, source and whether it is a set operation. If there are no Evaluation objects in the pool one is created and returned. */ public Evaluation create(SimpleNode node, Object source) { return create(node, source, false); } /** Returns an Evaluation that contains the node, source and whether it is a set operation. If there are no Evaluation objects in the pool one is created and returned. */ public synchronized Evaluation create(SimpleNode node, Object source, boolean setOperation) { Evaluation result; if (size > 0) { result = (Evaluation)evaluations.remove(size - 1); result.init(node, source, setOperation); size--; recovered++; } else { result = new Evaluation(node, source, setOperation); created++; } return result; } /** Recycles an Evaluation */ public synchronized void recycle(Evaluation value) { if (value != null) { value.reset(); evaluations.add(value); size++; recycled++; } } /** Recycles an of Evaluation and all of it's siblings and children. */ public void recycleAll(Evaluation value) { if (value != null) { recycleAll(value.getNext()); recycleAll(value.getFirstChild()); recycle(value); } } /** Recycles a List of Evaluation objects */ public void recycleAll(List value) { if (value != null) { for (int i = 0, icount = value.size(); i < icount; i++) { recycle((Evaluation)value.get(i)); } } } /** Returns the number of items in the pool */ public int getSize() { return size; } /** Returns the number of items this pool has created since it's construction. */ public int getCreatedCount() { return created; } /** Returns the number of items this pool has recovered from the pool since its construction. */ public int getRecoveredCount() { return recovered; } /** Returns the number of items this pool has recycled since it's construction. */ public int getRecycledCount() { return recycled; } } ognl-2.7.3.orig/src/java/ognl/ElementsAccessor.java0000644000175000017500000000553610561411075022077 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 1998-2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package ognl; import java.util.Enumeration; /** * This interface defines a method for getting the "elements" of an object, which means * any objects that naturally would be considered to be contained by the object. So for a * collection, you would expect this method to return all the objects in that collection; * while for an ordinary object you would expect this method to return just that object. * *

An implementation of this interface will often require that its target objects all * be of some particular type. For example, the MapElementsAccessor class requires that * its targets all implement the Map interface. * @author Luke Blanshard (blanshlu@netscape.net) * @author Drew Davidson (drew@ognl.org) */ public interface ElementsAccessor { /** * Returns an iterator over the elements of the given target object. * @param target the object to get the elements of * @return an iterator over the elements of the given object * @exception OgnlException if there is an error getting the given object's elements */ public Enumeration getElements( Object target ) throws OgnlException; } ognl-2.7.3.orig/src/java/ognl/ASTStaticMethod.java0000644000175000017500000002333410723604233021574 0ustar drazzibdrazzib// -------------------------------------------------------------------------- // Copyright (c) 1998-2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. // -------------------------------------------------------------------------- package ognl; import ognl.enhance.ExpressionCompiler; import ognl.enhance.UnsupportedCompilationException; import java.lang.reflect.Method; /** * @author Luke Blanshard (blanshlu@netscape.net) * @author Drew Davidson (drew@ognl.org) */ public class ASTStaticMethod extends SimpleNode implements NodeType { private String _className; private String _methodName; private Class _getterClass; public ASTStaticMethod(int id) { super(id); } public ASTStaticMethod(OgnlParser p, int id) { super(p, id); } /** Called from parser action. */ void init(String className, String methodName) { _className = className; _methodName = methodName; } protected Object getValueBody(OgnlContext context, Object source) throws OgnlException { Object[] args = OgnlRuntime.getObjectArrayPool().create(jjtGetNumChildren()); Object root = context.getRoot(); try { for(int i = 0, icount = args.length; i < icount; ++i) args[i] = _children[i].getValue(context, root); return OgnlRuntime.callStaticMethod(context, _className, _methodName, args); } finally { OgnlRuntime.getObjectArrayPool().recycle(args); } } public Class getGetterClass() { return _getterClass; } public Class getSetterClass() { return _getterClass; } public String toString() { String result = "@" + _className + "@" + _methodName; result = result + "("; if ((_children != null) && (_children.length > 0)) { for(int i = 0; i < _children.length; i++) { if (i > 0) { result = result + ", "; } result = result + _children[i]; } } result = result + ")"; return result; } public String toGetSourceString(OgnlContext context, Object target) { String result = _className + "#" + _methodName + "("; try { Class clazz = OgnlRuntime.classForName(context, _className); Method m = OgnlRuntime.getMethod(context, clazz, _methodName, _children, true); if (clazz == null || m == null) throw new UnsupportedCompilationException("Unable to find class/method combo " + _className + " / " + _methodName); if (!context.getMemberAccess().isAccessible(context, clazz, m, _methodName)) { throw new UnsupportedCompilationException("Method is not accessible, check your jvm runtime security settings. " + "For static class method " + _className + " / " + _methodName); } if ((_children != null) && (_children.length > 0)) { Class[] parms = m.getParameterTypes(); for(int i = 0; i < _children.length; i++) { if (i > 0) { result = result + ", "; } Class prevType = context.getCurrentType(); Object value = _children[i].getValue(context, context.getRoot()); String parmString = _children[i].toGetSourceString(context, context.getRoot()); if (parmString == null || parmString.trim().length() < 1) parmString = "null"; // to undo type setting of constants when used as method parameters if (ASTConst.class.isInstance(_children[i])) { context.setCurrentType(prevType); } parmString = ExpressionCompiler.getRootExpression(_children[i], context.getRoot(), context) + parmString; String cast = ""; if (ExpressionCompiler.shouldCast(_children[i])) { cast = (String)context.remove(ExpressionCompiler.PRE_CAST); } if (cast == null) cast = ""; if (!ASTConst.class.isInstance(_children[i])) parmString = cast + parmString; Class valueClass = value != null ? value.getClass() : null; if (NodeType.class.isAssignableFrom(_children[i].getClass())) valueClass = ((NodeType)_children[i]).getGetterClass(); if (valueClass != parms[i]) { if (parms[i].isArray()) { parmString = OgnlRuntime.getCompiler() .createLocalReference(context, "(" + ExpressionCompiler.getCastString(parms[i]) + ")ognl.OgnlOps.toArray(" + parmString + ", " + parms[i].getComponentType().getName() + ".class, true)", parms[i] ); } else if (parms[i].isPrimitive()) { Class wrapClass = OgnlRuntime.getPrimitiveWrapperClass(parms[i]); parmString = OgnlRuntime.getCompiler().createLocalReference(context, "((" + wrapClass.getName() + ")ognl.OgnlOps.convertValue(" + parmString + "," + wrapClass.getName() + ".class, true))." + OgnlRuntime.getNumericValueGetter(wrapClass), parms[i] ); } else if (parms[i] != Object.class) { parmString = OgnlRuntime.getCompiler() .createLocalReference(context, "(" + parms[i].getName() + ")ognl.OgnlOps.convertValue(" + parmString + "," + parms[i].getName() + ".class)", parms[i] ); } else if ((NodeType.class.isInstance(_children[i]) && ((NodeType)_children[i]).getGetterClass() != null && Number.class.isAssignableFrom(((NodeType)_children[i]).getGetterClass())) || valueClass.isPrimitive()) { parmString = " ($w) " + parmString; } else if (valueClass.isPrimitive()) { parmString = "($w) " + parmString; } } result += parmString; } } result += ")"; try { Object contextObj = getValueBody(context, target); context.setCurrentObject(contextObj); } catch (Throwable t) { // ignore } if (m != null) { _getterClass = m.getReturnType(); context.setCurrentType(m.getReturnType()); context.setCurrentAccessor(OgnlRuntime.getCompiler().getSuperOrInterfaceClass(m, m.getDeclaringClass())); } } catch (Throwable t) { throw OgnlOps.castToRuntime(t); } return result; } public String toSetSourceString(OgnlContext context, Object target) { return toGetSourceString(context, target); } } ognl-2.7.3.orig/src/java/ognl/CollectionElementsAccessor.java0000644000175000017500000000417110561411075024105 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 1998-2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package ognl; import java.util.*; /** * Implementation of ElementsAccessor that returns a collection's iterator. * @author Luke Blanshard (blanshlu@netscape.net) * @author Drew Davidson (drew@ognl.org) */ public class CollectionElementsAccessor implements ElementsAccessor { public Enumeration getElements( Object target ) { return new IteratorEnumeration( ((Collection)target).iterator() ); } } ognl-2.7.3.orig/src/java/ognl/Node.java0000644000175000017500000000761510566476144017542 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 1998-2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package ognl; import ognl.enhance.ExpressionAccessor; /** JJTree interface for AST nodes, as modified to handle the OGNL operations getValue and setValue. JJTree's original comment: All AST nodes must implement this interface. It provides basic machinery for constructing the parent and child relationships between nodes. @author Luke Blanshard (blanshlu@netscape.net) @author Drew Davidson (drew@ognl.org) */ public interface Node extends JavaSource { /** This method is called after the node has been made the current node. It indicates that child nodes can now be added to it. */ public void jjtOpen(); /** This method is called after all the child nodes have been added. */ public void jjtClose(); /** This pair of methods are used to inform the node of its parent. */ public void jjtSetParent(Node n); public Node jjtGetParent(); /** This method tells the node to add its argument to the node's list of children. */ public void jjtAddChild(Node n, int i); /** This method returns a child node. The children are numbered from zero, left to right. */ public Node jjtGetChild(int i); /** Return the number of children the node has. */ public int jjtGetNumChildren(); // OGNL additions to Node: /** * Extracts the value from the given source object that is appropriate for this node * within the given context. */ public Object getValue( OgnlContext context, Object source ) throws OgnlException; /** * Sets the given value in the given target as appropriate for this node within the * given context. */ public void setValue( OgnlContext context, Object target, Object value ) throws OgnlException; /** * Gets the compiled bytecode enhanced expression accessor for getting/setting values. * * @return The accessor for this node, or null if none has been compiled for it. */ ExpressionAccessor getAccessor(); /** * Sets a new compiled accessor for this node expression. * * @param accessor The compiled representation of this node. */ void setAccessor(ExpressionAccessor accessor); } ognl-2.7.3.orig/src/java/ognl/ASTEq.java0000644000175000017500000000472210566476144017566 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 1998-2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package ognl; /** * @author Luke Blanshard (blanshlu@netscape.net) * @author Drew Davidson (drew@ognl.org) */ class ASTEq extends ComparisonExpression { public ASTEq(int id) { super(id); } public ASTEq(OgnlParser p, int id) { super(p, id); } protected Object getValueBody( OgnlContext context, Object source ) throws OgnlException { Object v1 = _children[0].getValue( context, source ); Object v2 = _children[1].getValue( context, source ); return OgnlOps.equal( v1, v2 )? Boolean.TRUE : Boolean.FALSE; } public String getExpressionOperator(int index) { return "=="; } public String getComparisonFunction() { return "ognl.OgnlOps.equal"; } } ognl-2.7.3.orig/src/java/ognl/NumericExpression.java0000644000175000017500000000527110704232420022310 0ustar drazzibdrazzib/** * */ package ognl; import ognl.enhance.ExpressionCompiler; /** * Base class for numeric expressions. */ public abstract class NumericExpression extends ExpressionNode implements NodeType { protected Class _getterClass; public NumericExpression(int id) { super(id); } public NumericExpression(OgnlParser p, int id) { super(p, id); } public Class getGetterClass() { if (_getterClass != null) return _getterClass; return Double.TYPE; } public Class getSetterClass() { return null; } public String toGetSourceString(OgnlContext context, Object target) { Object value = null; String result = ""; try { value = getValueBody(context, target); if (value != null) _getterClass = value.getClass(); for (int i=0; i < _children.length; i++) { if (i > 0) result += " " + getExpressionOperator(i) + " "; String str = OgnlRuntime.getChildSource(context, target, _children[i]); result += coerceToNumeric(str, context, _children[i]); } } catch (Throwable t) { throw OgnlOps.castToRuntime(t); } return result; } public String coerceToNumeric(String source, OgnlContext context, Node child) { String ret = source; Object value = context.getCurrentObject(); if (ASTConst.class.isInstance(child) && value != null) { return value.toString(); } if (context.getCurrentType() != null && !context.getCurrentType().isPrimitive() && context.getCurrentObject() != null && Number.class.isInstance(context.getCurrentObject())) { ret = "((" + ExpressionCompiler.getCastString(context.getCurrentObject().getClass()) + ")" + ret + ")"; ret += "." + OgnlRuntime.getNumericValueGetter(context.getCurrentObject().getClass()); } else if (context.getCurrentType() != null && context.getCurrentType().isPrimitive() && (ASTConst.class.isInstance(child) || NumericExpression.class.isInstance(child))) { ret += OgnlRuntime.getNumericLiteral(context.getCurrentType()); } else if (context.getCurrentType() != null && String.class.isAssignableFrom(context.getCurrentType())) { ret = "Double.parseDouble(" + ret + ")"; context.setCurrentType(Double.TYPE); } if (NumericExpression.class.isInstance(child)) ret = "(" + ret + ")"; return ret; } } ognl-2.7.3.orig/src/java/ognl/JJTOgnlParserState.java0000644000175000017500000000642410746450726022275 0ustar drazzibdrazzib/* Generated By:JavaCC: Do not edit this line. JJTOgnlParserState.java Version 4.1d1 */ package ognl; public class JJTOgnlParserState { private java.util.List nodes; private java.util.List marks; private int sp; // number of nodes on stack private int mk; // current mark private boolean node_created; public JJTOgnlParserState() { nodes = new java.util.ArrayList(); marks = new java.util.ArrayList(); sp = 0; mk = 0; } /* Determines whether the current node was actually closed and pushed. This should only be called in the final user action of a node scope. */ public boolean nodeCreated() { return node_created; } /* Call this to reinitialize the node stack. It is called automatically by the parser's ReInit() method. */ public void reset() { nodes.clear(); marks.clear(); sp = 0; mk = 0; } /* Returns the root node of the AST. It only makes sense to call this after a successful parse. */ public Node rootNode() { return (Node)nodes.get(0); } /* Pushes a node on to the stack. */ public void pushNode(Node n) { nodes.add(n); ++sp; } /* Returns the node on the top of the stack, and remove it from the stack. */ public Node popNode() { if (--sp < mk) { mk = ((Integer)marks.remove(marks.size()-1)).intValue(); } return (Node)nodes.remove(nodes.size()-1); } /* Returns the node currently on the top of the stack. */ public Node peekNode() { return (Node)nodes.get(nodes.size()-1); } /* Returns the number of children on the stack in the current node scope. */ public int nodeArity() { return sp - mk; } public void clearNodeScope(Node n) { while (sp > mk) { popNode(); } mk = ((Integer)marks.remove(marks.size()-1)).intValue(); } public void openNodeScope(Node n) { marks.add(new Integer(mk)); mk = sp; n.jjtOpen(); } /* A definite node is constructed from a specified number of children. That number of nodes are popped from the stack and made the children of the definite node. Then the definite node is pushed on to the stack. */ public void closeNodeScope(Node n, int num) { mk = ((Integer)marks.remove(marks.size()-1)).intValue(); while (num-- > 0) { Node c = popNode(); c.jjtSetParent(n); n.jjtAddChild(c, num); } n.jjtClose(); pushNode(n); node_created = true; } /* A conditional node is constructed if its condition is true. All the nodes that have been pushed since the node was opened are made children of the conditional node, which is then pushed on to the stack. If the condition is false the node is not constructed and they are left on the stack. */ public void closeNodeScope(Node n, boolean condition) { if (condition) { int a = nodeArity(); mk = ((Integer)marks.remove(marks.size()-1)).intValue(); while (a-- > 0) { Node c = popNode(); c.jjtSetParent(n); n.jjtAddChild(c, a); } n.jjtClose(); pushNode(n); node_created = true; } else { mk = ((Integer)marks.remove(marks.size()-1)).intValue(); node_created = false; } } } /* JavaCC - OriginalChecksum=61071c68a05e7c9104307c34a2e37165 (do not edit this line) */ ognl-2.7.3.orig/src/java/ognl/ASTCtor.java0000644000175000017500000002773010646473765020141 0ustar drazzibdrazzib// -------------------------------------------------------------------------- // Copyright (c) 1998-2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. // -------------------------------------------------------------------------- package ognl; import ognl.enhance.ExpressionCompiler; import java.lang.reflect.Array; import java.lang.reflect.Constructor; import java.util.List; /** * @author Luke Blanshard (blanshlu@netscape.net) * @author Drew Davidson (drew@ognl.org) */ public class ASTCtor extends SimpleNode { private String className; private boolean isArray; public ASTCtor(int id) { super(id); } public ASTCtor(OgnlParser p, int id) { super(p, id); } /** Called from parser action. */ void setClassName(String className) { this.className = className; } void setArray(boolean value) { isArray = value; } public boolean isArray() { return isArray; } protected Object getValueBody(OgnlContext context, Object source) throws OgnlException { Object result, root = context.getRoot(); int count = jjtGetNumChildren(); Object[] args = OgnlRuntime.getObjectArrayPool().create(count); try { for(int i = 0; i < count; ++i) { args[i] = _children[i].getValue(context, root); } if (isArray) { if (args.length == 1) { try { Class componentClass = OgnlRuntime.classForName(context, className); List sourceList = null; int size; if (args[0] instanceof List) { sourceList = (List) args[0]; size = sourceList.size(); } else { size = (int) OgnlOps.longValue(args[0]); } result = Array.newInstance(componentClass, size); if (sourceList != null) { TypeConverter converter = context.getTypeConverter(); for(int i = 0, icount = sourceList.size(); i < icount; i++) { Object o = sourceList.get(i); if ((o == null) || componentClass.isInstance(o)) { Array.set(result, i, o); } else { Array.set(result, i, converter.convertValue(context, null, null, null, o, componentClass)); } } } } catch (ClassNotFoundException ex) { throw new OgnlException("array component class '" + className + "' not found", ex); } } else { throw new OgnlException("only expect array size or fixed initializer list"); } } else { result = OgnlRuntime.callConstructor(context, className, args); } return result; } finally { OgnlRuntime.getObjectArrayPool().recycle(args); } } public String toString() { String result = "new " + className; if (isArray) { if (_children[0] instanceof ASTConst) { result = result + "[" + _children[0] + "]"; } else { result = result + "[] " + _children[0]; } } else { result = result + "("; if ((_children != null) && (_children.length > 0)) { for(int i = 0; i < _children.length; i++) { if (i > 0) { result = result + ", "; } result = result + _children[i]; } } result = result + ")"; } return result; } public String toGetSourceString(OgnlContext context, Object target) { String result = "new " + className; Class clazz = null; Object ctorValue = null; try { clazz = OgnlRuntime.classForName(context, className); ctorValue = this.getValueBody(context, target); context.setCurrentObject(ctorValue); if (clazz != null && ctorValue != null) { context.setCurrentType(ctorValue.getClass()); context.setCurrentAccessor(ctorValue.getClass()); } if (isArray) context.put("_ctorClass", clazz); } catch (Throwable t) { throw OgnlOps.castToRuntime(t); } try { if (isArray) { if (_children[0] instanceof ASTConst) { result = result + "[" + _children[0].toGetSourceString(context, target) + "]"; } else if (ASTProperty.class.isInstance(_children[0])) { result = result + "[" + ExpressionCompiler.getRootExpression(_children[0], target, context) + _children[0].toGetSourceString(context, target) + "]"; } else if (ASTChain.class.isInstance(_children[0])) { result = result + "[" + _children[0].toGetSourceString(context, target) + "]"; } else { result = result + "[] "+ _children[0].toGetSourceString(context, target); } } else { result = result + "("; if ((_children != null) && (_children.length > 0)) { Object[] values = new Object[_children.length]; String[] expressions = new String[_children.length]; Class[] types = new Class[_children.length]; // first populate arrays with child values for(int i = 0; i < _children.length; i++) { Object objValue = _children[i].getValue(context, context.getRoot()); String value = _children[i].toGetSourceString(context, target); if (!ASTRootVarRef.class.isInstance(_children[i])) { value = ExpressionCompiler.getRootExpression(_children[i], target, context) + value; } String cast = ""; if (ExpressionCompiler.shouldCast(_children[i])) { cast = (String)context.remove(ExpressionCompiler.PRE_CAST); } if (cast == null) cast = ""; if (!ASTConst.class.isInstance(_children[i])) value = cast + value; values[i] = objValue; expressions[i] = value; types[i] = context.getCurrentType(); } // now try and find a matching constructor Constructor[] cons = clazz.getConstructors(); Constructor ctor = null; Class[] ctorParamTypes = null; for (int i=0; i < cons.length; i++) { Class[] ctorTypes = cons[i].getParameterTypes(); if (OgnlRuntime.areArgsCompatible(values, ctorTypes) && (ctor == null || OgnlRuntime.isMoreSpecific(ctorTypes, ctorParamTypes))) { ctor = cons[i]; ctorParamTypes = ctorTypes; } } if (ctor == null) ctor = OgnlRuntime.getConvertedConstructorAndArgs(context, clazz, OgnlRuntime.getConstructors(clazz), values, new Object[values.length]); if (ctor == null) throw new NoSuchMethodException("Unable to find constructor appropriate for arguments in class: " + clazz); ctorParamTypes = ctor.getParameterTypes(); // now loop over child values again and build up the actual source string for(int i = 0; i < _children.length; i++) { if (i > 0) { result = result + ", "; } String value = expressions[i]; if (types[i].isPrimitive()) { String literal = OgnlRuntime.getNumericLiteral(types[i]); if (literal != null) value += literal; } if (ctorParamTypes[i] != types[i]) { if (values[i] != null && !types[i].isPrimitive() && !values[i].getClass().isArray() && !ASTConst.class.isInstance(_children[i])) { value = "(" + OgnlRuntime.getCompiler().getInterfaceClass(values[i].getClass()).getName() + ")" + value; } else if (!ASTConst.class.isInstance(_children[i]) || (ASTConst.class.isInstance(_children[i]) && !types[i].isPrimitive())) { if (!types[i].isArray() && types[i].isPrimitive() && !ctorParamTypes[i].isPrimitive()) value = "new " + ExpressionCompiler.getCastString(OgnlRuntime.getPrimitiveWrapperClass(types[i])) + "(" + value + ")"; else value = " ($w) " + value; } } result += value; } } result = result + ")"; } context.setCurrentType(ctorValue != null ? ctorValue.getClass() : clazz); context.setCurrentAccessor(clazz); context.setCurrentObject(ctorValue); } catch (Throwable t) { throw OgnlOps.castToRuntime(t); } context.remove("_ctorClass"); return result; } public String toSetSourceString(OgnlContext context, Object target) { return ""; } } ognl-2.7.3.orig/src/java/ognl/ObjectArrayPool.java0000644000175000017500000001435210561411075021673 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 1998-2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package ognl; import java.util.*; public final class ObjectArrayPool extends Object { private IntHashMap pools = new IntHashMap(23); public static class SizePool extends Object { private List arrays = new ArrayList(); private int arraySize; private int size; private int created = 0; private int recovered = 0; private int recycled = 0; public SizePool(int arraySize) { this(arraySize, 0); } public SizePool(int arraySize, int initialSize) { super(); this.arraySize = arraySize; for (int i = 0; i < initialSize; i++) { arrays.add(new Object[arraySize]); } created = size = initialSize; } public int getArraySize() { return arraySize; } public Object[] create() { Object[] result; if (size > 0) { result = (Object[])arrays.remove(size - 1); size--; recovered++; } else { result = new Object[arraySize]; created++; } return result; } public synchronized void recycle(Object[] value) { if (value != null) { if (value.length != arraySize) { throw new IllegalArgumentException("recycled array size " + value.length + " inappropriate for pool array size " + arraySize); } Arrays.fill(value, null); arrays.add(value); size++; recycled++; } else { throw new IllegalArgumentException("cannot recycle null object"); } } /** Returns the number of items in the pool */ public int getSize() { return size; } /** Returns the number of items this pool has created since it's construction. */ public int getCreatedCount() { return created; } /** Returns the number of items this pool has recovered from the pool since its construction. */ public int getRecoveredCount() { return recovered; } /** Returns the number of items this pool has recycled since it's construction. */ public int getRecycledCount() { return recycled; } } public ObjectArrayPool() { super(); } public IntHashMap getSizePools() { return pools; } public synchronized SizePool getSizePool(int arraySize) { SizePool result = (SizePool)pools.get(arraySize); if (result == null) { pools.put(arraySize, result = new SizePool(arraySize)); } return result; } public synchronized Object[] create(int arraySize) { return getSizePool(arraySize).create(); } public synchronized Object[] create(Object singleton) { Object[] result = create(1); result[0] = singleton; return result; } public synchronized Object[] create(Object object1, Object object2) { Object[] result = create(2); result[0] = object1; result[1] = object2; return result; } public synchronized Object[] create(Object object1, Object object2, Object object3) { Object[] result = create(3); result[0] = object1; result[1] = object2; result[2] = object3; return result; } public synchronized Object[] create(Object object1, Object object2, Object object3, Object object4) { Object[] result = create(4); result[0] = object1; result[1] = object2; result[2] = object3; result[3] = object4; return result; } public synchronized Object[] create(Object object1, Object object2, Object object3, Object object4, Object object5) { Object[] result = create(5); result[0] = object1; result[1] = object2; result[2] = object3; result[3] = object4; result[4] = object5; return result; } public synchronized void recycle(Object[] value) { if (value != null) { getSizePool(value.length).recycle(value); } } } ognl-2.7.3.orig/src/java/ognl/ASTAdd.java0000644000175000017500000003044110746447753017712 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 1998-2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package ognl; import ognl.enhance.ExpressionCompiler; import java.math.BigDecimal; import java.math.BigInteger; /** * @author Luke Blanshard (blanshlu@netscape.net) * @author Drew Davidson (drew@ognl.org) */ class ASTAdd extends NumericExpression { public ASTAdd(int id) { super(id); } public ASTAdd(OgnlParser p, int id) { super(p, id); } public void jjtClose() { flattenTree(); } protected Object getValueBody( OgnlContext context, Object source ) throws OgnlException { Object result = _children[0].getValue( context, source ); for ( int i=1; i < _children.length; ++i ) result = OgnlOps.add( result, _children[i].getValue(context, source) ); return result; } public String getExpressionOperator(int index) { return "+"; } boolean isWider(NodeType type, NodeType lastType) { if (lastType == null) return true; //System.out.println("checking isWider(" + type.getGetterClass() + " , " + lastType.getGetterClass() + ")"); if (String.class.isAssignableFrom(lastType.getGetterClass())) return false; if (String.class.isAssignableFrom(type.getGetterClass())) return true; if (_parent != null && String.class.isAssignableFrom(type.getGetterClass())) return true; if (String.class.isAssignableFrom(lastType.getGetterClass()) && Object.class == type.getGetterClass()) return false; if (_parent != null && String.class.isAssignableFrom(lastType.getGetterClass())) return false; else if (_parent == null && String.class.isAssignableFrom(lastType.getGetterClass())) return true; else if (_parent == null && String.class.isAssignableFrom(type.getGetterClass())) return false; if (BigDecimal.class.isAssignableFrom(type.getGetterClass()) || BigInteger.class.isAssignableFrom(type.getGetterClass())) return true; if (BigDecimal.class.isAssignableFrom(lastType.getGetterClass()) || BigInteger.class.isAssignableFrom(lastType.getGetterClass())) return false; if (Double.class.isAssignableFrom(type.getGetterClass())) return true; if (Integer.class.isAssignableFrom(type.getGetterClass()) && Double.class.isAssignableFrom(lastType.getGetterClass())) return false; if (Float.class.isAssignableFrom(type.getGetterClass()) && Integer.class.isAssignableFrom(lastType.getGetterClass())) return true; return true; } public String toGetSourceString(OgnlContext context, Object target) { try { String result = ""; NodeType lastType = null; // go through once to determine the ultimate type if ((_children != null) && (_children.length > 0)) { Class currType = context.getCurrentType(); Class currAccessor = context.getCurrentAccessor(); Object cast = context.get(ExpressionCompiler.PRE_CAST); for ( int i = 0; i < _children.length; ++i ) { _children[i].toGetSourceString(context, target); if (NodeType.class.isInstance(_children[i]) && ((NodeType)_children[i]).getGetterClass() != null && isWider((NodeType)_children[i], lastType)) { lastType = (NodeType)_children[i]; } } context.put(ExpressionCompiler.PRE_CAST, cast); context.setCurrentType(currType); context.setCurrentAccessor(currAccessor); } // reset context since previous children loop would have changed it context.setCurrentObject(target); if ((_children != null) && (_children.length > 0)) { for ( int i = 0; i < _children.length; ++i ) { if (i > 0) result += " " + getExpressionOperator(i) + " "; String expr = _children[i].toGetSourceString(context, target); if ((expr != null && "null".equals(expr)) || (!ASTConst.class.isInstance(_children[i]) && (expr == null || expr.trim().length() <= 0))) { expr = "null"; } //System.out.println("astadd child class: " + _children[i].getClass().getName() + " and return expr: " + expr); if (ASTProperty.class.isInstance(_children[i])) { expr = ExpressionCompiler.getRootExpression(_children[i], context.getRoot(), context) + expr; context.setCurrentAccessor(context.getRoot().getClass()); } else if (ASTMethod.class.isInstance(_children[i])) { String chain = (String)context.get("_currentChain"); String rootExpr = ExpressionCompiler.getRootExpression(_children[i], context.getRoot(), context); //System.out.println("astadd chains is >>" + chain + "<< and rootExpr is >>" + rootExpr + "<<"); // dirty fix for overly aggressive casting dot operations if (rootExpr.endsWith(".") && chain != null && chain.startsWith(").")) { chain = chain.substring(1, chain.length()); } expr = rootExpr + (chain != null ? chain + "." : "") + expr; context.setCurrentAccessor(context.getRoot().getClass()); } else if (ExpressionNode.class.isInstance(_children[i])) { expr = "(" + expr + ")"; } else if ((_parent == null || !ASTChain.class.isInstance(_parent)) && ASTChain.class.isInstance(_children[i])) { String rootExpr = ExpressionCompiler.getRootExpression(_children[i], context.getRoot(), context); if (!ASTProperty.class.isInstance(_children[i].jjtGetChild(0)) && rootExpr.endsWith(")") && expr.startsWith(")")) expr = expr.substring(1, expr.length()); expr = rootExpr + expr; context.setCurrentAccessor(context.getRoot().getClass()); String cast = (String)context.remove(ExpressionCompiler.PRE_CAST); if (cast == null) cast = ""; expr = cast + expr; } // turn quoted characters into quoted strings if (context.getCurrentType() != null && context.getCurrentType() == Character.class && ASTConst.class.isInstance(_children[i])) { expr = expr.replaceAll("'", "\""); context.setCurrentType(String.class); } else { if (!ASTVarRef.class.isAssignableFrom(_children[i].getClass()) && !ASTProperty.class.isInstance(_children[i]) && !ASTMethod.class.isInstance(_children[i]) && !ASTSequence.class.isInstance(_children[i]) && !ASTChain.class.isInstance(_children[i]) && !NumericExpression.class.isAssignableFrom(_children[i].getClass()) && !ASTStaticField.class.isInstance(_children[i]) && !ASTStaticMethod.class.isInstance(_children[i]) && !ASTTest.class.isInstance(_children[i])) { if (lastType != null && String.class.isAssignableFrom(lastType.getGetterClass())) { //System.out.println("Input expr >>" + expr + "<<"); expr = expr.replaceAll(""", "\""); expr = expr.replaceAll("\"", "'"); expr = "\"" + expr + "\""; //System.out.println("Expr now >>" + expr + "<<"); } } } result += expr; // hanlde addition for numeric types when applicable or just string concatenation if ( (lastType == null || !String.class.isAssignableFrom(lastType.getGetterClass())) && !ASTConst.class.isAssignableFrom(_children[i].getClass()) && !NumericExpression.class.isAssignableFrom(_children[i].getClass())) { if (context.getCurrentType() != null && Number.class.isAssignableFrom(context.getCurrentType()) && !ASTMethod.class.isInstance(_children[i])) { if (ASTVarRef.class.isInstance(_children[i]) || ASTProperty.class.isInstance(_children[i]) || ASTChain.class.isInstance(_children[i])) result += "."; result += OgnlRuntime.getNumericValueGetter(context.getCurrentType()); context.setCurrentType(OgnlRuntime.getPrimitiveWrapperClass(context.getCurrentType())); } } if (lastType != null) context.setCurrentAccessor(lastType.getGetterClass()); } } if (_parent == null || ASTSequence.class.isAssignableFrom(_parent.getClass())) { if (_getterClass != null && String.class.isAssignableFrom(_getterClass)) _getterClass = Object.class; } else { context.setCurrentType(_getterClass); } try { Object contextObj = getValueBody(context, target); context.setCurrentObject(contextObj); } catch (Throwable t) { throw OgnlOps.castToRuntime(t); } return result; } catch (Throwable t) { throw OgnlOps.castToRuntime(t); } } } ognl-2.7.3.orig/src/java/ognl/MemberAccess.java0000644000175000017500000000524410561411075021165 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 1998-2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package ognl; import java.lang.reflect.Member; import java.util.Map; /** * This interface provides a hook for preparing for accessing members * of objects. The Java2 version of this method can allow access * to otherwise inaccessable members, such as private fields. * * @author Luke Blanshard (blanshlu@netscape.net) * @author Drew Davidson (drew@ognl.org) * @version 15 October 1999 */ public interface MemberAccess { /** Sets the member up for accessibility */ public Object setup(Map context, Object target, Member member, String propertyName); /** Restores the member from the previous setup call. */ public void restore(Map context, Object target, Member member, String propertyName, Object state); /** Returns true if the given member is accessible or can be made accessible by this object. */ public boolean isAccessible(Map context, Object target, Member member, String propertyName); } ognl-2.7.3.orig/src/java/ognl/ASTMultiply.java0000644000175000017500000000473610566476144021045 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 1998-2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package ognl; /** * @author Luke Blanshard (blanshlu@netscape.net) * @author Drew Davidson (drew@ognl.org) */ class ASTMultiply extends NumericExpression { public ASTMultiply(int id) { super(id); } public ASTMultiply(OgnlParser p, int id) { super(p, id); } public void jjtClose() { flattenTree(); } protected Object getValueBody( OgnlContext context, Object source ) throws OgnlException { Object result = _children[0].getValue( context, source ); for ( int i=1; i < _children.length; ++i ) result = OgnlOps.multiply( result, _children[i].getValue(context, source) ); return result; } public String getExpressionOperator(int index) { return "*"; } } ognl-2.7.3.orig/src/java/ognl/ASTGreaterEq.java0000644000175000017500000000474210566476144021102 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 1998-2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package ognl; /** * @author Luke Blanshard (blanshlu@netscape.net) * @author Drew Davidson (drew@ognl.org) */ class ASTGreaterEq extends ComparisonExpression { public ASTGreaterEq(int id) { super(id); } public ASTGreaterEq(OgnlParser p, int id) { super(p, id); } protected Object getValueBody( OgnlContext context, Object source ) throws OgnlException { Object v1 = _children[0].getValue( context, source ); Object v2 = _children[1].getValue( context, source ); return OgnlOps.less( v1, v2 )? Boolean.FALSE : Boolean.TRUE; } public String getExpressionOperator(int index) { return ">="; } public String getComparisonFunction() { return "!ognl.OgnlOps.less"; } } ognl-2.7.3.orig/src/java/ognl/ASTBitAnd.java0000644000175000017500000000520010634650771020346 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 1998-2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package ognl; /** * @author Luke Blanshard (blanshlu@netscape.net) * @author Drew Davidson (drew@ognl.org) */ class ASTBitAnd extends NumericExpression { public ASTBitAnd(int id) { super(id); } public ASTBitAnd(OgnlParser p, int id) { super(p, id); } public void jjtClose() { flattenTree(); } protected Object getValueBody( OgnlContext context, Object source ) throws OgnlException { Object result = _children[0].getValue( context, source ); for ( int i=1; i < _children.length; ++i ) result = OgnlOps.binaryAnd( result, _children[i].getValue(context, source) ); return result; } public String getExpressionOperator(int index) { return "&"; } public String coerceToNumeric(String source, OgnlContext context, Node child) { return "(long)" + super.coerceToNumeric(source, context, child); } } ognl-2.7.3.orig/src/java/ognl/internal/0000755000175000017500000000000011237553170017604 5ustar drazzibdrazzibognl-2.7.3.orig/src/java/ognl/internal/ClassCache.java0000644000175000017500000000053210713163323022433 0ustar drazzibdrazzibpackage ognl.internal; import ognl.ClassCacheInspector; /** * This is a highly specialized map for storing values keyed by Class objects. */ public interface ClassCache { void setClassInspector(ClassCacheInspector inspector); void clear(); int getSize(); Object get(Class key); Object put(Class key, Object value); } ognl-2.7.3.orig/src/java/ognl/internal/Entry.java0000644000175000017500000000101410713163323021537 0ustar drazzibdrazzibpackage ognl.internal; /** * Used by {@link ClassCacheImpl} to store entries in the cache. */ class Entry { Entry next; Class key; Object value; public Entry(Class key, Object value) { this.key = key; this.value = value; } public String toString() { return "Entry[" + "next=" + next + '\n' + ", key=" + key + '\n' + ", value=" + value + '\n' + ']'; } } ognl-2.7.3.orig/src/java/ognl/internal/ClassCacheImpl.java0000644000175000017500000000553210713163323023262 0ustar drazzibdrazzibpackage ognl.internal; import ognl.ClassCacheInspector; import java.util.Arrays; /** * Implementation of {@link ClassCache}. */ public class ClassCacheImpl implements ClassCache { /* this MUST be a power of 2 */ private static final int TABLE_SIZE = 512; /* ...and now you see why. The table size is used as a mask for generating hashes */ private static final int TABLE_SIZE_MASK = TABLE_SIZE - 1; private Entry[] _table; private ClassCacheInspector _classInspector; private int _size = 0; public ClassCacheImpl() { _table = new Entry[TABLE_SIZE]; } public void setClassInspector(ClassCacheInspector inspector) { _classInspector = inspector; } public void clear() { for (int i=0; i < _table.length; i++) { _table[i] = null; } _size = 0; } public int getSize() { return _size; } public final Object get(Class key) { Object result = null; int i = key.hashCode() & TABLE_SIZE_MASK; for (Entry entry = _table[i]; entry != null; entry = entry.next) { if (entry.key == key) { result = entry.value; break; } } return result; } public final Object put(Class key, Object value) { if (_classInspector != null && !_classInspector.shouldCache(key)) return value; Object result = null; int i = key.hashCode() & TABLE_SIZE_MASK; Entry entry = _table[i]; if (entry == null) { _table[i] = new Entry(key, value); _size++; } else { if (entry.key == key) { result = entry.value; entry.value = value; } else { while (true) { if (entry.key == key) { /* replace value */ result = entry.value; entry.value = value; break; } else { if (entry.next == null) { /* add value */ entry.next = new Entry(key, value); break; } } entry = entry.next; } } } return result; } public String toString() { return "ClassCacheImpl[" + "_table=" + (_table == null ? null : Arrays.asList(_table)) + '\n' + ", _classInspector=" + _classInspector + '\n' + ", _size=" + _size + '\n' + ']'; } } ognl-2.7.3.orig/src/java/ognl/ASTAssign.java0000644000175000017500000001314210604045342020422 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 1998-2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package ognl; import ognl.enhance.OrderedReturn; import ognl.enhance.UnsupportedCompilationException; /** * @author Luke Blanshard (blanshlu@netscape.net) * @author Drew Davidson (drew@ognl.org) */ class ASTAssign extends SimpleNode { public ASTAssign(int id) { super(id); } public ASTAssign(OgnlParser p, int id) { super(p, id); } protected Object getValueBody( OgnlContext context, Object source ) throws OgnlException { Object result = _children[1].getValue( context, source ); _children[0].setValue( context, source, result ); return result; } public String toString() { return _children[0] + " = " + _children[1]; } public String toGetSourceString(OgnlContext context, Object target) { String result = ""; String first = _children[0].toGetSourceString(context, target); String second = ""; if (ASTProperty.class.isInstance(_children[1])) { second += "((" + OgnlRuntime.getCompiler().getClassName(target.getClass()) + ")$2)."; } second += _children[1].toGetSourceString(context, target); if (ASTSequence.class.isAssignableFrom(_children[1].getClass())) { ASTSequence seq = (ASTSequence)_children[1]; context.setCurrentType(Object.class); String core = seq.getCoreExpression(); if (core.endsWith(";")) core = core.substring(0, core.lastIndexOf(";")); second = OgnlRuntime.getCompiler().createLocalReference(context, "ognl.OgnlOps.returnValue(($w)" + core + ", ($w) " + seq.getLastExpression() + ")", Object.class); } if (NodeType.class.isInstance(_children[1]) && !ASTProperty.class.isInstance(_children[1]) && ((NodeType)_children[1]).getGetterClass() != null && !OrderedReturn.class.isInstance(_children[1])) { second = "new " + ((NodeType)_children[1]).getGetterClass().getName() + "(" + second + ")"; } if (OrderedReturn.class.isAssignableFrom(_children[0].getClass()) && ((OrderedReturn)_children[0]).getCoreExpression() != null) { context.setCurrentType(Object.class); result = first + second + ")"; // System.out.println("building ordered ret from child[0] with result of:" + result); result = OgnlRuntime.getCompiler().createLocalReference(context, "ognl.OgnlOps.returnValue(($w)" + result + ", ($w)" + ((OrderedReturn)_children[0]).getLastExpression() + ")", Object.class); } return result; } public String toSetSourceString(OgnlContext context, Object target) { String result = ""; result += _children[0].toSetSourceString(context, target); if (ASTProperty.class.isInstance(_children[1])) { result += "((" + OgnlRuntime.getCompiler().getClassName(target.getClass()) + ")$2)."; } String value =_children[1].toSetSourceString(context, target); if (value == null) throw new UnsupportedCompilationException("Value for assignment is null, can't enhance statement to bytecode."); if (ASTSequence.class.isAssignableFrom(_children[1].getClass())) { ASTSequence seq = (ASTSequence)_children[1]; result = seq.getCoreExpression() + result; value = seq.getLastExpression(); } if (NodeType.class.isInstance(_children[1]) && !ASTProperty.class.isInstance(_children[1]) && ((NodeType)_children[1]).getGetterClass() != null) { value = "new " + ((NodeType)_children[1]).getGetterClass().getName() + "(" + value + ")"; } return result + value + ")"; } } ognl-2.7.3.orig/src/java/ognl/ObjectMethodAccessor.java0000644000175000017500000000616610651175157022702 0ustar drazzibdrazzib// -------------------------------------------------------------------------- // Copyright (c) 1998-2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. // -------------------------------------------------------------------------- package ognl; import java.util.List; import java.util.Map; /** * Implementation of PropertyAccessor that uses reflection on the target object's class to find a * field or a pair of set/get methods with the given property name. * * @author Luke Blanshard (blanshlu@netscape.net) * @author Drew Davidson (drew@ognl.org) */ public class ObjectMethodAccessor implements MethodAccessor { /* MethodAccessor interface */ public Object callStaticMethod(Map context, Class targetClass, String methodName, Object[] args) throws MethodFailedException { List methods = OgnlRuntime.getMethods(targetClass, methodName, true); return OgnlRuntime.callAppropriateMethod((OgnlContext) context, targetClass, null, methodName, null, methods, args); } public Object callMethod(Map context, Object target, String methodName, Object[] args) throws MethodFailedException { Class targetClass = (target == null) ? null : target.getClass(); List methods = OgnlRuntime.getMethods(targetClass, methodName, false); if ((methods == null) || (methods.size() == 0)) { methods = OgnlRuntime.getMethods(targetClass, methodName, true); } return OgnlRuntime.callAppropriateMethod((OgnlContext) context, target, target, methodName, null, methods, args); } } ognl-2.7.3.orig/src/java/ognl/ASTList.java0000644000175000017500000002011610720374205020112 0ustar drazzibdrazzib// -------------------------------------------------------------------------- // Copyright (c) 1998-2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. // -------------------------------------------------------------------------- package ognl; import ognl.enhance.ExpressionCompiler; import ognl.enhance.UnsupportedCompilationException; import java.util.ArrayList; import java.util.List; /** * @author Luke Blanshard (blanshlu@netscape.net) * @author Drew Davidson (drew@ognl.org) */ public class ASTList extends SimpleNode implements NodeType { public ASTList(int id) { super(id); } public ASTList(OgnlParser p, int id) { super(p, id); } protected Object getValueBody(OgnlContext context, Object source) throws OgnlException { List answer = new ArrayList(jjtGetNumChildren()); for(int i = 0; i < jjtGetNumChildren(); ++i) answer.add(_children[i].getValue(context, source)); return answer; } public Class getGetterClass() { return null; } public Class getSetterClass() { return null; } public String toString() { String result = "{ "; for(int i = 0; i < jjtGetNumChildren(); ++i) { if (i > 0) { result = result + ", "; } result = result + _children[i].toString(); } return result + " }"; } public String toGetSourceString(OgnlContext context, Object target) { String result = ""; boolean array = false; if (_parent != null && ASTCtor.class.isInstance(_parent) && ((ASTCtor)_parent).isArray()) { array = true; } context.setCurrentType(List.class); context.setCurrentAccessor(List.class); if (!array) { if (jjtGetNumChildren() < 1) return "java.util.Arrays.asList( new Object[0])"; result += "java.util.Arrays.asList( new Object[] "; } result += "{ "; try { for(int i = 0; i < jjtGetNumChildren(); ++i) { if (i > 0) { result = result + ", "; } Class prevType = context.getCurrentType(); Object objValue = _children[i].getValue(context, context.getRoot()); String value = _children[i].toGetSourceString(context, target); // to undo type setting of constants when used as method parameters if (ASTConst.class.isInstance(_children[i])) { context.setCurrentType(prevType); } value = ExpressionCompiler.getRootExpression(_children[i], target, context) + value; String cast = ""; if (ExpressionCompiler.shouldCast(_children[i])) { cast = (String)context.remove(ExpressionCompiler.PRE_CAST); } if (cast == null) cast = ""; if (!ASTConst.class.isInstance(_children[i])) value = cast + value; Class ctorClass = (Class)context.get("_ctorClass"); if (array && ctorClass != null && !ctorClass.isPrimitive()) { Class valueClass = value != null ? value.getClass() : null; if (NodeType.class.isAssignableFrom(_children[i].getClass())) valueClass = ((NodeType)_children[i]).getGetterClass(); if (valueClass != null && ctorClass.isArray()) { value = OgnlRuntime.getCompiler().createLocalReference(context, "(" + ExpressionCompiler.getCastString(ctorClass) + ")ognl.OgnlOps.toArray(" + value + ", " + ctorClass.getComponentType().getName() + ".class, true)", ctorClass ); } else if (ctorClass.isPrimitive()) { Class wrapClass = OgnlRuntime.getPrimitiveWrapperClass(ctorClass); value = OgnlRuntime.getCompiler().createLocalReference(context, "((" + wrapClass.getName() + ")ognl.OgnlOps.convertValue(" + value + "," + wrapClass.getName() + ".class, true))." + OgnlRuntime.getNumericValueGetter(wrapClass), ctorClass ); } else if (ctorClass != Object.class) { value = OgnlRuntime.getCompiler().createLocalReference(context, "(" + ctorClass.getName() + ")ognl.OgnlOps.convertValue(" + value + "," + ctorClass.getName() + ".class)", ctorClass ); } else if ((NodeType.class.isInstance(_children[i]) && ((NodeType)_children[i]).getGetterClass() != null && Number.class.isAssignableFrom(((NodeType)_children[i]).getGetterClass())) || valueClass.isPrimitive()) { value = " ($w) (" + value + ")"; } else if (valueClass.isPrimitive()) { value = "($w) (" + value + ")"; } } else if (ctorClass == null || !ctorClass.isPrimitive()) { value = " ($w) (" + value + ")"; } if (objValue == null || value.length() <= 0) value = "null"; result += value; } } catch (Throwable t) { throw OgnlOps.castToRuntime(t); } context.setCurrentType(List.class); context.setCurrentAccessor(List.class); result += "}"; if (!array) result += ")"; return result; } public String toSetSourceString(OgnlContext context, Object target) { throw new UnsupportedCompilationException("Can't generate setter for ASTList."); } } ognl-2.7.3.orig/src/java/ognl/ASTSelectFirst.java0000644000175000017500000000634210566476144021450 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 1998-2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package ognl; import ognl.enhance.UnsupportedCompilationException; import java.util.ArrayList; import java.util.Enumeration; import java.util.List; /** * @author Luke Blanshard (blanshlu@netscape.net) * @author Drew Davidson (drew@ognl.org) */ class ASTSelectFirst extends SimpleNode { public ASTSelectFirst(int id) { super(id); } public ASTSelectFirst(OgnlParser p, int id) { super(p, id); } protected Object getValueBody( OgnlContext context, Object source ) throws OgnlException { Node expr = _children[0]; List answer = new ArrayList(); ElementsAccessor elementsAccessor = OgnlRuntime.getElementsAccessor( OgnlRuntime.getTargetClass(source) ); for (Enumeration e = elementsAccessor.getElements(source); e.hasMoreElements(); ) { Object next = e.nextElement(); if (OgnlOps.booleanValue(expr.getValue(context, next))) { answer.add(next); break; } } return answer; } public String toString() { return "{^ " + _children[0] + " }"; } public String toGetSourceString(OgnlContext context, Object target) { throw new UnsupportedCompilationException("Eval expressions not supported as native java yet."); } public String toSetSourceString(OgnlContext context, Object target) { throw new UnsupportedCompilationException("Eval expressions not supported as native java yet."); } } ognl-2.7.3.orig/src/java/ognl/TypeConverter.java0000644000175000017500000000562510561411075021450 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 1998-2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package ognl; import java.lang.reflect.Member; import java.util.Map; /** * Interface for accessing the type conversion facilities within a context. * @author Luke Blanshard (blanshlu@netscape.net) * @author Drew Davidson (drew@ognl.org) */ public interface TypeConverter { /** * Converts the given value to a given type. The OGNL context, target, member and * name of property being set are given. This method should be able to handle * conversion in general without any context, target, member or property name specified. * @param context OGNL context under which the conversion is being done * @param target target object in which the property is being set * @param member member (Constructor, Method or Field) being set * @param propertyName property name being set * @param value value to be converted * @param toType type to which value is converted * @return Converted value of type toType or TypeConverter.NoConversionPossible to indicate that the conversion was not possible. */ public Object convertValue(Map context, Object target, Member member, String propertyName, Object value, Class toType); } ognl-2.7.3.orig/src/java/ognl/InappropriateExpressionException.java0000644000175000017500000000432410561411075025406 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 1998-2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package ognl; /** * Exception thrown if an OGNL expression is evaluated in the wrong context; the usual * case is when an expression that does not end in a property reference is passed to * setValue. * @author Luke Blanshard (blanshlu@netscape.net) * @author Drew Davidson (drew@ognl.org) */ public class InappropriateExpressionException extends OgnlException { public InappropriateExpressionException( Node tree ) { super( "Inappropriate OGNL expression: " + tree ); } } ognl-2.7.3.orig/src/java/ognl/ASTProject.java0000644000175000017500000000614410566476144020627 0ustar drazzibdrazzib// -------------------------------------------------------------------------- // Copyright (c) 1998-2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. // -------------------------------------------------------------------------- package ognl; import ognl.enhance.UnsupportedCompilationException; import java.util.ArrayList; import java.util.Enumeration; import java.util.List; /** * @author Luke Blanshard (blanshlu@netscape.net) * @author Drew Davidson (drew@ognl.org) */ class ASTProject extends SimpleNode { public ASTProject(int id) { super(id); } public ASTProject(OgnlParser p, int id) { super(p, id); } protected Object getValueBody(OgnlContext context, Object source) throws OgnlException { Node expr = _children[0]; List answer = new ArrayList(); ElementsAccessor elementsAccessor = OgnlRuntime.getElementsAccessor(OgnlRuntime.getTargetClass(source)); for(Enumeration e = elementsAccessor.getElements(source); e.hasMoreElements();) { answer.add(expr.getValue(context, e.nextElement())); } return answer; } public String toString() { return "{ " + _children[0] + " }"; } public String toGetSourceString(OgnlContext context, Object target) { throw new UnsupportedCompilationException("Projection expressions not supported as native java yet."); } public String toSetSourceString(OgnlContext context, Object target) { throw new UnsupportedCompilationException("Projection expressions not supported as native java yet."); } } ognl-2.7.3.orig/src/java/ognl/ArrayElementsAccessor.java0000644000175000017500000000472510745155540023103 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 1998-2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package ognl; import java.lang.reflect.Array; import java.util.Enumeration; /** * Implementation of ElementsAccessor that returns an iterator over a Java array. * @author Luke Blanshard (blanshlu@netscape.net) * @author Drew Davidson (drew@ognl.org) */ public class ArrayElementsAccessor implements ElementsAccessor { public Enumeration getElements( final Object target ) { return new Enumeration() { private int count = Array.getLength( target ); private int index = 0; public boolean hasMoreElements() { return index < count; } public Object nextElement() { return Array.get( target, index++ ); } }; } } ognl-2.7.3.orig/src/java/ognl/DefaultClassResolver.java0000644000175000017500000000541510561411075022730 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 1998-2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package ognl; import java.util.*; /** * Default class resolution. Uses Class.forName() to look up classes by name. * It also looks in the "java.lang" package if the class named does not give * a package specifier, allowing easier usage of these classes. * @author Luke Blanshard (blanshlu@netscape.net) * @author Drew Davidson (drew@ognl.org) */ public class DefaultClassResolver extends Object implements ClassResolver { private Map classes = new HashMap(101); public DefaultClassResolver() { super(); } public Class classForName(String className, Map context) throws ClassNotFoundException { Class result = null; if ((result = (Class)classes.get(className)) == null) { try { result = Class.forName(className); } catch (ClassNotFoundException ex) { if (className.indexOf('.') == -1) { result = Class.forName("java.lang." + className); classes.put("java.lang." + className, result); } } classes.put(className, result); } return result; } } ognl-2.7.3.orig/src/java/ognl/ObjectIndexedPropertyDescriptor.java0000644000175000017500000001223010561411075025140 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 1998-2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package ognl; import java.beans.*; import java.lang.reflect.*; /** *

PropertyDescriptor subclass that describes an indexed set of read/write * methods to get a property. Unlike IndexedPropertyDescriptor this allows * the "key" to be an arbitrary object rather than just an int. Consequently * it does not have a "readMethod" or "writeMethod" because it only expects * a pattern like:

*
 *    public void setProperty(KeyType, ValueType);
 *    public ValueType getProperty(KeyType);
 *
*

and does not require the methods that access it as an array. OGNL can * get away with this without losing functionality because if the object * does expose the properties they are most probably in a Map and that case * is handled by the normal OGNL property accessors. *

*

For example, if an object were to have methods that accessed and "attributes" * property it would be natural to index them by String rather than by integer * and expose the attributes as a map with a different property name: *

 *    public void setAttribute(String name, Object value);
 *    public Object getAttribute(String name);
 *    public Map getAttributes();
 *
*

Note that the index get/set is called get/set Attribute * whereas the collection getter is called Attributes. This * case is handled unambiguously by the OGNL property accessors because the * set/getAttribute methods are detected by this object and the * "attributes" case is handled by the MapPropertyAccessor. * Therefore OGNL expressions calling this code would be handled in the * following way: *

* * * * * * * * * * * * * * * * * * * * *
OGNL ExpressionHandling
attribute["name"]Handled by an index getter, like getAttribute(String).
attribute["name"] = valueHandled by an index setter, like setAttribute(String, Object).
attributes["name"]Handled by MapPropertyAccessor via a Map.get(). This * will not go through the index get accessor. *
attributes["name"] = valueHandled by MapPropertyAccessor via a Map.put(). This * will not go through the index set accessor. *
* @author Luke Blanshard (blanshlu@netscape.net) * @author Drew Davidson (drew@ognl.org) */ public class ObjectIndexedPropertyDescriptor extends PropertyDescriptor { private Method indexedReadMethod; private Method indexedWriteMethod; private Class propertyType; public ObjectIndexedPropertyDescriptor(String propertyName, Class propertyType, Method indexedReadMethod, Method indexedWriteMethod) throws IntrospectionException { super(propertyName, null, null); this.propertyType = propertyType; this.indexedReadMethod = indexedReadMethod; this.indexedWriteMethod = indexedWriteMethod; } public Method getIndexedReadMethod() { return indexedReadMethod; } public Method getIndexedWriteMethod() { return indexedWriteMethod; } public Class getPropertyType() { return propertyType; } } ognl-2.7.3.orig/src/java/ognl/ASTRootVarRef.java0000644000175000017500000000612610611754366021246 0ustar drazzibdrazzib// -------------------------------------------------------------------------- // Copyright (c) 1998-2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. // -------------------------------------------------------------------------- package ognl; import ognl.enhance.ExpressionCompiler; /** * @author Luke Blanshard (blanshlu@netscape.net) * @author Drew Davidson (drew@ognl.org) */ public class ASTRootVarRef extends ASTVarRef { public ASTRootVarRef(int id) { super(id); } public ASTRootVarRef(OgnlParser p, int id) { super(p, id); } protected Object getValueBody(OgnlContext context, Object source) throws OgnlException { return context.getRoot(); } protected void setValueBody(OgnlContext context, Object target, Object value) throws OgnlException { context.setRoot(value); } public String toString() { return "#root"; } public String toGetSourceString(OgnlContext context, Object target) { if (target != null) _getterClass = target.getClass(); if (_getterClass != null) { context.setCurrentType(_getterClass); } if (_parent == null || (_getterClass != null && _getterClass.isArray())) return ""; else return ExpressionCompiler.getRootExpression(this, target, context); } public String toSetSourceString(OgnlContext context, Object target) { if (_parent == null || (_getterClass != null && _getterClass.isArray())) return ""; else return "$3"; } } ognl-2.7.3.orig/src/java/ognl/OgnlContext.java0000644000175000017500000005726510754136360021117 0ustar drazzibdrazzib// -------------------------------------------------------------------------- // Copyright (c) 1998-2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. // -------------------------------------------------------------------------- package ognl; import ognl.enhance.LocalReference; import java.util.*; /** * This class defines the execution context for an OGNL expression * * @author Luke Blanshard (blanshlu@netscape.net) * @author Drew Davidson (drew@ognl.org) */ public class OgnlContext extends Object implements Map { public static final String CONTEXT_CONTEXT_KEY = "context"; public static final String ROOT_CONTEXT_KEY = "root"; public static final String THIS_CONTEXT_KEY = "this"; public static final String TRACE_EVALUATIONS_CONTEXT_KEY = "_traceEvaluations"; public static final String LAST_EVALUATION_CONTEXT_KEY = "_lastEvaluation"; public static final String KEEP_LAST_EVALUATION_CONTEXT_KEY = "_keepLastEvaluation"; public static final String CLASS_RESOLVER_CONTEXT_KEY = "_classResolver"; public static final String TYPE_CONVERTER_CONTEXT_KEY = "_typeConverter"; public static final String MEMBER_ACCESS_CONTEXT_KEY = "_memberAccess"; private static final String PROPERTY_KEY_PREFIX = "ognl"; private static boolean DEFAULT_TRACE_EVALUATIONS = false; private static boolean DEFAULT_KEEP_LAST_EVALUATION = false; public static final ClassResolver DEFAULT_CLASS_RESOLVER = new DefaultClassResolver(); public static final TypeConverter DEFAULT_TYPE_CONVERTER = new DefaultTypeConverter(); public static final MemberAccess DEFAULT_MEMBER_ACCESS = new DefaultMemberAccess(false); private static Map RESERVED_KEYS = new HashMap(11); private Object _root; private Object _currentObject; private Node _currentNode; private boolean _traceEvaluations = DEFAULT_TRACE_EVALUATIONS; private Evaluation _rootEvaluation; private Evaluation _currentEvaluation; private Evaluation _lastEvaluation; private boolean _keepLastEvaluation = DEFAULT_KEEP_LAST_EVALUATION; private Map _values = new HashMap(23); private ClassResolver _classResolver = DEFAULT_CLASS_RESOLVER; private TypeConverter _typeConverter = DEFAULT_TYPE_CONVERTER; private MemberAccess _memberAccess = DEFAULT_MEMBER_ACCESS; static { String s; RESERVED_KEYS.put(CONTEXT_CONTEXT_KEY, null); RESERVED_KEYS.put(ROOT_CONTEXT_KEY, null); RESERVED_KEYS.put(THIS_CONTEXT_KEY, null); RESERVED_KEYS.put(TRACE_EVALUATIONS_CONTEXT_KEY, null); RESERVED_KEYS.put(LAST_EVALUATION_CONTEXT_KEY, null); RESERVED_KEYS.put(KEEP_LAST_EVALUATION_CONTEXT_KEY, null); RESERVED_KEYS.put(CLASS_RESOLVER_CONTEXT_KEY, null); RESERVED_KEYS.put(TYPE_CONVERTER_CONTEXT_KEY, null); RESERVED_KEYS.put(MEMBER_ACCESS_CONTEXT_KEY, null); try { if ((s = System.getProperty(PROPERTY_KEY_PREFIX + ".traceEvaluations")) != null) { DEFAULT_TRACE_EVALUATIONS = Boolean.valueOf(s.trim()).booleanValue(); } if ((s = System.getProperty(PROPERTY_KEY_PREFIX + ".keepLastEvaluation")) != null) { DEFAULT_KEEP_LAST_EVALUATION = Boolean.valueOf(s.trim()).booleanValue(); } } catch (SecurityException ex) { // restricted access environment, just keep defaults } } private List _typeStack = new ArrayList(); private List _accessorStack = new ArrayList(); private int _localReferenceCounter = 0; private Map _localReferenceMap = null; /** * Constructs a new OgnlContext with the default class resolver, type converter and member * access. */ public OgnlContext() { } /** * Constructs a new OgnlContext with the given class resolver, type converter and member access. * If any of these parameters is null the default will be used. */ public OgnlContext(ClassResolver classResolver, TypeConverter typeConverter, MemberAccess memberAccess) { this(); if (classResolver != null) { this._classResolver = classResolver; } if (typeConverter != null) { this._typeConverter = typeConverter; } if (memberAccess != null) { this._memberAccess = memberAccess; } } public OgnlContext(Map values) { super(); this._values = values; } public OgnlContext(ClassResolver classResolver, TypeConverter typeConverter, MemberAccess memberAccess, Map values) { this(classResolver, typeConverter, memberAccess); this._values = values; } public void setValues(Map value) { for(Iterator it = value.keySet().iterator(); it.hasNext();) { Object k = it.next(); _values.put(k, value.get(k)); } } public Map getValues() { return _values; } public void setClassResolver(ClassResolver value) { if (value == null) { throw new IllegalArgumentException("cannot set ClassResolver to null"); } _classResolver = value; } public ClassResolver getClassResolver() { return _classResolver; } public void setTypeConverter(TypeConverter value) { if (value == null) { throw new IllegalArgumentException("cannot set TypeConverter to null"); } _typeConverter = value; } public TypeConverter getTypeConverter() { return _typeConverter; } public void setMemberAccess(MemberAccess value) { if (value == null) { throw new IllegalArgumentException("cannot set MemberAccess to null"); } _memberAccess = value; } public MemberAccess getMemberAccess() { return _memberAccess; } public void setRoot(Object value) { _root = value; _accessorStack.clear(); _typeStack.clear(); _currentObject = value; if (_currentObject != null) { setCurrentType(_currentObject.getClass()); } } public Object getRoot() { return _root; } public boolean getTraceEvaluations() { return _traceEvaluations; } public void setTraceEvaluations(boolean value) { _traceEvaluations = value; } public Evaluation getLastEvaluation() { return _lastEvaluation; } public void setLastEvaluation(Evaluation value) { _lastEvaluation = value; } /** * This method can be called when the last evaluation has been used and can be returned for * reuse in the free pool maintained by the runtime. This is not a necessary step, but is useful * for keeping memory usage down. This will recycle the last evaluation and then set the last * evaluation to null. */ public void recycleLastEvaluation() { OgnlRuntime.getEvaluationPool().recycleAll(_lastEvaluation); _lastEvaluation = null; } /** * Returns true if the last evaluation that was done on this context is retained and available * through getLastEvaluation(). The default is true. */ public boolean getKeepLastEvaluation() { return _keepLastEvaluation; } /** * Sets whether the last evaluation that was done on this context is retained and available * through getLastEvaluation(). The default is true. */ public void setKeepLastEvaluation(boolean value) { _keepLastEvaluation = value; } public void setCurrentObject(Object value) { _currentObject = value; } public Object getCurrentObject() { return _currentObject; } public void setCurrentAccessor(Class type) { _accessorStack.add(type); } public Class getCurrentAccessor() { if (_accessorStack.isEmpty()) return null; return (Class) _accessorStack.get(_accessorStack.size() - 1); } public Class getPreviousAccessor() { if (_accessorStack.isEmpty()) return null; if (_accessorStack.size() > 1) return (Class) _accessorStack.get(_accessorStack.size() - 2); else return null; } public Class getFirstAccessor() { if (_accessorStack.isEmpty()) return null; return (Class)_accessorStack.get(0); } /** * Gets the current class type being evaluated on the stack, as set by {@link #setCurrentType(Class)}. * * @return The current object type, may be null. */ public Class getCurrentType() { if (_typeStack.isEmpty()) return null; return (Class) _typeStack.get(_typeStack.size() - 1); } public void setCurrentType(Class type) { _typeStack.add(type); } /** * Represents the last known object type on the evaluation stack, will be the value of * the last known {@link #getCurrentType()}. * * @return The previous type of object on the stack, may be null. */ public Class getPreviousType() { if (_typeStack.isEmpty()) return null; if (_typeStack.size() > 1) return (Class)_typeStack.get(_typeStack.size() - 2); else return null; } public void setPreviousType(Class type) { if (_typeStack.isEmpty() || _typeStack.size() < 2) return; _typeStack.set(_typeStack.size() - 2, type); } public Class getFirstType() { if (_typeStack.isEmpty()) return null; return (Class)_typeStack.get(0); } public void setCurrentNode(Node value) { _currentNode = value; } public Node getCurrentNode() { return _currentNode; } /** * Gets the current Evaluation from the top of the stack. This is the Evaluation that is in * process of evaluating. */ public Evaluation getCurrentEvaluation() { return _currentEvaluation; } public void setCurrentEvaluation(Evaluation value) { _currentEvaluation = value; } /** * Gets the root of the evaluation stack. This Evaluation contains the node representing the * root expression and the source is the root source object. */ public Evaluation getRootEvaluation() { return _rootEvaluation; } public void setRootEvaluation(Evaluation value) { _rootEvaluation = value; } /** * Returns the Evaluation at the relative index given. This should be zero or a negative number * as a relative reference back up the evaluation stack. Therefore getEvaluation(0) returns the * current Evaluation. */ public Evaluation getEvaluation(int relativeIndex) { Evaluation result = null; if (relativeIndex <= 0) { result = _currentEvaluation; while((++relativeIndex < 0) && (result != null)) { result = result.getParent(); } } return result; } /** * Pushes a new Evaluation onto the stack. This is done before a node evaluates. When evaluation * is complete it should be popped from the stack via popEvaluation(). */ public void pushEvaluation(Evaluation value) { if (_currentEvaluation != null) { _currentEvaluation.addChild(value); } else { setRootEvaluation(value); } setCurrentEvaluation(value); } /** * Pops the current Evaluation off of the top of the stack. This is done after a node has * completed its evaluation. */ public Evaluation popEvaluation() { Evaluation result; result = _currentEvaluation; setCurrentEvaluation(result.getParent()); if (_currentEvaluation == null) { setLastEvaluation(getKeepLastEvaluation() ? result : null); setRootEvaluation(null); setCurrentNode(null); } return result; } public int incrementLocalReferenceCounter() { return ++_localReferenceCounter; } public void addLocalReference(String key, LocalReference reference) { if (_localReferenceMap == null) { _localReferenceMap = new LinkedHashMap(); } _localReferenceMap.put(key, reference); } public Map getLocalReferences() { return _localReferenceMap; } /* ================= Map interface ================= */ public int size() { return _values.size(); } public boolean isEmpty() { return _values.isEmpty(); } public boolean containsKey(Object key) { return _values.containsKey(key); } public boolean containsValue(Object value) { return _values.containsValue(value); } public Object get(Object key) { Object result; if (RESERVED_KEYS.containsKey(key)) { if (key.equals(OgnlContext.THIS_CONTEXT_KEY)) { result = getCurrentObject(); } else { if (key.equals(OgnlContext.ROOT_CONTEXT_KEY)) { result = getRoot(); } else { if (key.equals(OgnlContext.CONTEXT_CONTEXT_KEY)) { result = this; } else { if (key.equals(OgnlContext.TRACE_EVALUATIONS_CONTEXT_KEY)) { result = getTraceEvaluations() ? Boolean.TRUE : Boolean.FALSE; } else { if (key.equals(OgnlContext.LAST_EVALUATION_CONTEXT_KEY)) { result = getLastEvaluation(); } else { if (key.equals(OgnlContext.KEEP_LAST_EVALUATION_CONTEXT_KEY)) { result = getKeepLastEvaluation() ? Boolean.TRUE : Boolean.FALSE; } else { if (key.equals(OgnlContext.CLASS_RESOLVER_CONTEXT_KEY)) { result = getClassResolver(); } else { if (key.equals(OgnlContext.TYPE_CONVERTER_CONTEXT_KEY)) { result = getTypeConverter(); } else { if (key.equals(OgnlContext.MEMBER_ACCESS_CONTEXT_KEY)) { result = getMemberAccess(); } else { throw new IllegalArgumentException("unknown reserved key '" + key + "'"); } } } } } } } } } } else { result = _values.get(key); } return result; } public Object put(Object key, Object value) { Object result; if (RESERVED_KEYS.containsKey(key)) { if (key.equals(OgnlContext.THIS_CONTEXT_KEY)) { result = getCurrentObject(); setCurrentObject(value); } else { if (key.equals(OgnlContext.ROOT_CONTEXT_KEY)) { result = getRoot(); setRoot(value); } else { if (key.equals(OgnlContext.CONTEXT_CONTEXT_KEY)) { throw new IllegalArgumentException("can't change " + OgnlContext.CONTEXT_CONTEXT_KEY + " in context"); } else { if (key.equals(OgnlContext.TRACE_EVALUATIONS_CONTEXT_KEY)) { result = getTraceEvaluations() ? Boolean.TRUE : Boolean.FALSE; setTraceEvaluations(OgnlOps.booleanValue(value)); } else { if (key.equals(OgnlContext.LAST_EVALUATION_CONTEXT_KEY)) { result = getLastEvaluation(); _lastEvaluation = (Evaluation) value; } else { if (key.equals(OgnlContext.KEEP_LAST_EVALUATION_CONTEXT_KEY)) { result = getKeepLastEvaluation() ? Boolean.TRUE : Boolean.FALSE; setKeepLastEvaluation(OgnlOps.booleanValue(value)); } else { if (key.equals(OgnlContext.CLASS_RESOLVER_CONTEXT_KEY)) { result = getClassResolver(); setClassResolver((ClassResolver) value); } else { if (key.equals(OgnlContext.TYPE_CONVERTER_CONTEXT_KEY)) { result = getTypeConverter(); setTypeConverter((TypeConverter) value); } else { if (key.equals(OgnlContext.MEMBER_ACCESS_CONTEXT_KEY)) { result = getMemberAccess(); setMemberAccess((MemberAccess) value); } else { throw new IllegalArgumentException("unknown reserved key '" + key + "'"); } } } } } } } } } } else { result = _values.put(key, value); } return result; } public Object remove(Object key) { Object result; if (RESERVED_KEYS.containsKey(key)) { if (key.equals(OgnlContext.THIS_CONTEXT_KEY)) { result = getCurrentObject(); setCurrentObject(null); } else { if (key.equals(OgnlContext.ROOT_CONTEXT_KEY)) { result = getRoot(); setRoot(null); } else { if (key.equals(OgnlContext.CONTEXT_CONTEXT_KEY)) { throw new IllegalArgumentException("can't remove " + OgnlContext.CONTEXT_CONTEXT_KEY + " from context"); } else { if (key.equals(OgnlContext.TRACE_EVALUATIONS_CONTEXT_KEY)) { throw new IllegalArgumentException("can't remove " + OgnlContext.TRACE_EVALUATIONS_CONTEXT_KEY + " from context"); } else { if (key.equals(OgnlContext.LAST_EVALUATION_CONTEXT_KEY)) { result = _lastEvaluation; setLastEvaluation(null); } else { if (key.equals(OgnlContext.KEEP_LAST_EVALUATION_CONTEXT_KEY)) { throw new IllegalArgumentException("can't remove " + OgnlContext.KEEP_LAST_EVALUATION_CONTEXT_KEY + " from context"); } else { if (key.equals(OgnlContext.CLASS_RESOLVER_CONTEXT_KEY)) { result = getClassResolver(); setClassResolver(null); } else { if (key.equals(OgnlContext.TYPE_CONVERTER_CONTEXT_KEY)) { result = getTypeConverter(); setTypeConverter(null); } else { if (key.equals(OgnlContext.MEMBER_ACCESS_CONTEXT_KEY)) { result = getMemberAccess(); setMemberAccess(null); } else { throw new IllegalArgumentException("unknown reserved key '" + key + "'"); } } } } } } } } } } else { result = _values.remove(key); } return result; } public void putAll(Map t) { for(Iterator it = t.keySet().iterator(); it.hasNext();) { Object k = it.next(); put(k, t.get(k)); } } public void clear() { _values.clear(); _typeStack.clear(); _accessorStack.clear(); _localReferenceCounter = 0; if (_localReferenceMap != null) { _localReferenceMap.clear(); } setRoot(null); setCurrentObject(null); setRootEvaluation(null); setCurrentEvaluation(null); setLastEvaluation(null); setCurrentNode(null); setClassResolver(DEFAULT_CLASS_RESOLVER); setTypeConverter(DEFAULT_TYPE_CONVERTER); setMemberAccess(DEFAULT_MEMBER_ACCESS); } public Set keySet() { /* Should root, currentObject, classResolver, typeConverter & memberAccess be included here? */ return _values.keySet(); } public Collection values() { /* Should root, currentObject, classResolver, typeConverter & memberAccess be included here? */ return _values.values(); } public Set entrySet() { /* Should root, currentObject, classResolver, typeConverter & memberAccess be included here? */ return _values.entrySet(); } public boolean equals(Object o) { return _values.equals(o); } public int hashCode() { return _values.hashCode(); } } ognl-2.7.3.orig/src/java/ognl/ASTOr.java0000644000175000017500000001430110655154670017567 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 1998-2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package ognl; import ognl.enhance.ExpressionCompiler; import ognl.enhance.UnsupportedCompilationException; /** * @author Luke Blanshard (blanshlu@netscape.net) * @author Drew Davidson (drew@ognl.org) */ public class ASTOr extends BooleanExpression { public ASTOr(int id) { super(id); } public ASTOr(OgnlParser p, int id) { super(p, id); } public void jjtClose() { flattenTree(); } protected Object getValueBody(OgnlContext context, Object source) throws OgnlException { Object result = null; int last = _children.length - 1; for (int i = 0; i <= last; ++i) { result = _children[i].getValue(context, source); if (i != last && OgnlOps.booleanValue(result)) break; } return result; } protected void setValueBody(OgnlContext context, Object target, Object value) throws OgnlException { int last = _children.length - 1; for (int i = 0; i < last; ++i) { Object v = _children[i].getValue(context, target); if (OgnlOps.booleanValue(v)) return; } _children[last].setValue(context, target, value); } public String getExpressionOperator(int index) { return "||"; } public Class getGetterClass() { return null; } public String toGetSourceString(OgnlContext context, Object target) { if (_children.length != 2) throw new UnsupportedCompilationException("Can only compile boolean expressions with two children."); String result = "("; try { String first = OgnlRuntime.getChildSource(context, target, _children[0]); if (!OgnlRuntime.isBoolean(first)) first = OgnlRuntime.getCompiler().createLocalReference(context, first, context.getCurrentType()); Class firstType = context.getCurrentType(); String second = OgnlRuntime.getChildSource(context, target, _children[1]); if (!OgnlRuntime.isBoolean(second)) second = OgnlRuntime.getCompiler().createLocalReference(context, second, context.getCurrentType()); Class secondType = context.getCurrentType(); boolean mismatched = (firstType.isPrimitive() && !secondType.isPrimitive()) || (!firstType.isPrimitive() && secondType.isPrimitive()) ? true : false; result += "ognl.OgnlOps.booleanValue(" + first + ")"; result += " ? "; result += (mismatched ? " ($w) " : "") + first; result += " : "; result += (mismatched ? " ($w) " : "") + second; result += ")"; context.setCurrentObject(target); context.setCurrentType(Boolean.TYPE); } catch (Throwable t) { throw OgnlOps.castToRuntime(t); } return result; } public String toSetSourceString(OgnlContext context, Object target) { if (_children.length != 2) throw new UnsupportedCompilationException("Can only compile boolean expressions with two children."); String pre = (String) context.get("_currentChain"); if (pre == null) pre = ""; String result = ""; try { _children[0].getValue(context, target); String first = ExpressionCompiler.getRootExpression(_children[0], context.getRoot(), context) + pre + _children[0].toGetSourceString(context, target); if (!OgnlRuntime.isBoolean(first)) first = OgnlRuntime.getCompiler().createLocalReference(context, first, Object.class); _children[1].getValue(context, target); String second = ExpressionCompiler.getRootExpression(_children[1], context.getRoot(), context) + pre + _children[1].toSetSourceString(context, target); if (!OgnlRuntime.isBoolean(second)) second = OgnlRuntime.getCompiler().createLocalReference(context, second, context.getCurrentType()); result += "ognl.OgnlOps.booleanValue(" + first + ")"; result += " ? "; result += first; result += " : "; result += second; context.setCurrentObject(target); context.setCurrentType(Boolean.TYPE); } catch (Throwable t) { throw OgnlOps.castToRuntime(t); } return result; } } ognl-2.7.3.orig/src/java/ognl/ASTChain.java0000644000175000017500000004570010776755160020245 0ustar drazzibdrazzib// -------------------------------------------------------------------------- // Copyright (c) 1998-2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. // -------------------------------------------------------------------------- package ognl; import ognl.enhance.ExpressionCompiler; import ognl.enhance.OrderedReturn; import ognl.enhance.UnsupportedCompilationException; import java.lang.reflect.Array; /** * @author Luke Blanshard (blanshlu@netscape.net) * @author Drew Davidson (drew@ognl.org) */ public class ASTChain extends SimpleNode implements NodeType, OrderedReturn { private Class _getterClass; private Class _setterClass; private String _lastExpression; private String _coreExpression; public ASTChain(int id) { super(id); } public ASTChain(OgnlParser p, int id) { super(p, id); } public String getLastExpression() { return _lastExpression; } public String getCoreExpression() { return _coreExpression; } public void jjtClose() { flattenTree(); } protected Object getValueBody(OgnlContext context, Object source) throws OgnlException { Object result = source; for(int i = 0, ilast = _children.length - 1; i <= ilast; ++i) { boolean handled = false; if (i < ilast) { if (_children[i] instanceof ASTProperty) { ASTProperty propertyNode = (ASTProperty) _children[i]; int indexType = propertyNode.getIndexedPropertyType(context, result); if ((indexType != OgnlRuntime.INDEXED_PROPERTY_NONE) && (_children[i + 1] instanceof ASTProperty)) { ASTProperty indexNode = (ASTProperty) _children[i + 1]; if (indexNode.isIndexedAccess()) { Object index = indexNode.getProperty(context, result); if (index instanceof DynamicSubscript) { if (indexType == OgnlRuntime.INDEXED_PROPERTY_INT) { Object array = propertyNode.getValue(context, result); int len = Array.getLength(array); switch(((DynamicSubscript) index).getFlag()) { case DynamicSubscript.ALL: result = Array.newInstance(array.getClass().getComponentType(), len); System.arraycopy(array, 0, result, 0, len); handled = true; i++; break; case DynamicSubscript.FIRST: index = new Integer((len > 0) ? 0 : -1); break; case DynamicSubscript.MID: index = new Integer((len > 0) ? (len / 2) : -1); break; case DynamicSubscript.LAST: index = new Integer((len > 0) ? (len - 1) : -1); break; } } else { if (indexType == OgnlRuntime.INDEXED_PROPERTY_OBJECT) { throw new OgnlException( "DynamicSubscript '" + indexNode + "' not allowed for object indexed property '" + propertyNode + "'"); } } } if (!handled) { result = OgnlRuntime.getIndexedProperty(context, result, propertyNode.getProperty(context, result).toString(), index); handled = true; i++; } } } } } if (!handled) { result = _children[i].getValue(context, result); } } return result; } protected void setValueBody(OgnlContext context, Object target, Object value) throws OgnlException { boolean handled = false; for(int i = 0, ilast = _children.length - 2; i <= ilast; ++i) { if (i <= ilast) { if (_children[i] instanceof ASTProperty) { ASTProperty propertyNode = (ASTProperty) _children[i]; int indexType = propertyNode.getIndexedPropertyType(context, target); if ((indexType != OgnlRuntime.INDEXED_PROPERTY_NONE) && (_children[i + 1] instanceof ASTProperty)) { ASTProperty indexNode = (ASTProperty) _children[i + 1]; if (indexNode.isIndexedAccess()) { Object index = indexNode.getProperty(context, target); if (index instanceof DynamicSubscript) { if (indexType == OgnlRuntime.INDEXED_PROPERTY_INT) { Object array = propertyNode.getValue(context, target); int len = Array.getLength(array); switch(((DynamicSubscript) index).getFlag()) { case DynamicSubscript.ALL: System.arraycopy(target, 0, value, 0, len); handled = true; i++; break; case DynamicSubscript.FIRST: index = new Integer((len > 0) ? 0 : -1); break; case DynamicSubscript.MID: index = new Integer((len > 0) ? (len / 2) : -1); break; case DynamicSubscript.LAST: index = new Integer((len > 0) ? (len - 1) : -1); break; } } else { if (indexType == OgnlRuntime.INDEXED_PROPERTY_OBJECT) { throw new OgnlException("DynamicSubscript '" + indexNode + "' not allowed for object indexed property '" + propertyNode + "'"); } } } if (!handled && i == ilast) { OgnlRuntime.setIndexedProperty(context, target, propertyNode.getProperty(context, target).toString(), index, value); handled = true; i++; } else if (!handled) { target = OgnlRuntime.getIndexedProperty(context, target, propertyNode.getProperty(context, target).toString(), index); i++; continue; } } } } } if (!handled) { target = _children[i].getValue(context, target); } } if (!handled) { _children[_children.length - 1].setValue(context, target, value); } } public boolean isSimpleNavigationChain(OgnlContext context) throws OgnlException { boolean result = false; if ((_children != null) && (_children.length > 0)) { result = true; for(int i = 0; result && (i < _children.length); i++) { if (_children[i] instanceof SimpleNode) { result = ((SimpleNode) _children[i]).isSimpleProperty(context); } else { result = false; } } } return result; } public Class getGetterClass() { return _getterClass; } public Class getSetterClass() { return _setterClass; } public String toString() { String result = ""; if ((_children != null) && (_children.length > 0)) { for(int i = 0; i < _children.length; i++) { if (i > 0) { if (!(_children[i] instanceof ASTProperty) || !((ASTProperty) _children[i]).isIndexedAccess()) { result = result + "."; } } result += _children[i].toString(); } } return result; } public String toGetSourceString(OgnlContext context, Object target) { String prevChain = (String)context.get("_currentChain"); if (target != null) { context.setCurrentObject(target); context.setCurrentType(target.getClass()); } String result = ""; NodeType _lastType = null; boolean ordered = false; boolean constructor = false; try { if ((_children != null) && (_children.length > 0)) { for(int i = 0; i < _children.length; i++) { /* System.out.println("astchain child: " + _children[i].getClass().getName() + " with current object target " + context.getCurrentObject() + " current type: " + context.getCurrentType());*/ String value = _children[i].toGetSourceString(context, context.getCurrentObject()); // System.out.println("astchain child returned >> " + value + " <<"); if (ASTCtor.class.isInstance(_children[i])) constructor = true; if (NodeType.class.isInstance(_children[i]) && ((NodeType)_children[i]).getGetterClass() != null) { _lastType = (NodeType)_children[i]; } // System.out.println("Astchain i: " + i + " currentobj : " + context.getCurrentObject() + " and root: " + context.getRoot()); if (!ASTVarRef.class.isInstance(_children[i]) && !constructor && !(OrderedReturn.class.isInstance(_children[i]) && ((OrderedReturn)_children[i]).getLastExpression() != null) && (_parent == null || !ASTSequence.class.isInstance(_parent))) { value = OgnlRuntime.getCompiler().castExpression(context, _children[i], value); } /*System.out.println("astchain value now : " + value + " with index " + i + " current type " + context.getCurrentType() + " current accessor " + context.getCurrentAccessor() + " prev type " + context.getPreviousType() + " prev accessor " + context.getPreviousAccessor());*/ if (OrderedReturn.class.isInstance(_children[i]) && ((OrderedReturn)_children[i]).getLastExpression() != null) { ordered = true; OrderedReturn or = (OrderedReturn)_children[i]; if (or.getCoreExpression() == null || or.getCoreExpression().trim().length() <= 0) result = ""; else result += or.getCoreExpression(); _lastExpression = or.getLastExpression(); if (context.get(ExpressionCompiler.PRE_CAST) != null) { _lastExpression = context.remove(ExpressionCompiler.PRE_CAST) + _lastExpression; } } else if (ASTOr.class.isInstance(_children[i]) || ASTAnd.class.isInstance(_children[i]) || ASTCtor.class.isInstance(_children[i]) || (ASTStaticField.class.isInstance(_children[i]) && _parent == null)) { context.put("_noRoot", "true"); result = value; } else { result += value; } context.put("_currentChain", result); } } } catch (Throwable t) { throw OgnlOps.castToRuntime(t); } if (_lastType != null) { _getterClass = _lastType.getGetterClass(); _setterClass = _lastType.getSetterClass(); } if (ordered) { _coreExpression = result; } context.put("_currentChain", prevChain); return result; } public String toSetSourceString(OgnlContext context, Object target) { String prevChain = (String)context.get("_currentChain"); String prevChild = (String)context.get("_lastChild"); if (prevChain != null) throw new UnsupportedCompilationException("Can't compile nested chain expressions."); if (target != null) { context.setCurrentObject(target); context.setCurrentType(target.getClass()); } String result = ""; NodeType _lastType = null; boolean constructor = false; try { if ((_children != null) && (_children.length > 0)) { if (ASTConst.class.isInstance(_children[0])) { throw new UnsupportedCompilationException("Can't modify constant values."); } for(int i = 0; i < _children.length; i++) { // System.out.println("astchain setsource child[" + i + "] : " + _children[i].getClass().getName()); if (i == (_children.length -1)) { context.put("_lastChild", "true"); } String value = _children[i].toSetSourceString(context, context.getCurrentObject()); //if (value == null || value.trim().length() <= 0) // return ""; // System.out.println("astchain setter child returned >> " + value + " <<"); if (ASTCtor.class.isInstance(_children[i])) constructor = true; if (NodeType.class.isInstance(_children[i]) && ((NodeType)_children[i]).getGetterClass() != null) { _lastType = (NodeType)_children[i]; } if (!ASTVarRef.class.isInstance(_children[i]) && !constructor && !(OrderedReturn.class.isInstance(_children[i]) && ((OrderedReturn)_children[i]).getLastExpression() != null) && (_parent == null || !ASTSequence.class.isInstance(_parent))) { value = OgnlRuntime.getCompiler().castExpression(context, _children[i], value); } // System.out.println("astchain setter after cast value is: " + value); /*if (!constructor && !OrderedReturn.class.isInstance(_children[i]) && (_parent == null || !ASTSequence.class.isInstance(_parent))) { value = OgnlRuntime.getCompiler().castExpression(context, _children[i], value); }*/ if (ASTOr.class.isInstance(_children[i]) || ASTAnd.class.isInstance(_children[i]) || ASTCtor.class.isInstance(_children[i]) || ASTStaticField.class.isInstance(_children[i])) { context.put("_noRoot", "true"); result = value; } else result += value; context.put("_currentChain", result); } } } catch (Throwable t) { throw OgnlOps.castToRuntime(t); } context.put("_lastChild", prevChild); context.put("_currentChain", prevChain); if (_lastType != null) _setterClass = _lastType.getSetterClass(); return result; } } ognl-2.7.3.orig/src/java/ognl/IteratorEnumeration.java0000644000175000017500000000427410561411075022636 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 1998-2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package ognl; import java.util.*; /** * Maps an Iterator to an Enumeration * @author Luke Blanshard (blanshlu@netscape.net) * @author Drew Davidson (drew@ognl.org) */ public class IteratorEnumeration extends Object implements Enumeration { private Iterator it; public IteratorEnumeration(Iterator it) { super(); this.it = it; } public boolean hasMoreElements() { return it.hasNext(); } public Object nextElement() { return it.next(); } } ognl-2.7.3.orig/src/java/ognl/NullHandler.java0000644000175000017500000000461010561411075021040 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 1998-2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package ognl; import java.util.Map; /** * Interface for handling null results from Chains. * Object has the opportunity to substitute an object for the * null and continue. * @author Luke Blanshard (blanshlu@netscape.net) * @author Drew Davidson (drew@ognl.org) */ public interface NullHandler { /** Method called on target returned null. */ public Object nullMethodResult(Map context, Object target, String methodName, Object[] args); /** Property in target evaluated to null. Property can be a constant String property name or a DynamicSubscript. */ public Object nullPropertyValue(Map context, Object target, Object property); } ognl-2.7.3.orig/src/java/ognl/ASTSelect.java0000644000175000017500000000623710566476144020443 0ustar drazzibdrazzib// -------------------------------------------------------------------------- // Copyright (c) 1998-2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. // -------------------------------------------------------------------------- package ognl; import ognl.enhance.UnsupportedCompilationException; import java.util.ArrayList; import java.util.Enumeration; import java.util.List; /** * @author Luke Blanshard (blanshlu@netscape.net) * @author Drew Davidson (drew@ognl.org) */ class ASTSelect extends SimpleNode { public ASTSelect(int id) { super(id); } public ASTSelect(OgnlParser p, int id) { super(p, id); } protected Object getValueBody(OgnlContext context, Object source) throws OgnlException { Node expr = _children[0]; List answer = new ArrayList(); ElementsAccessor elementsAccessor = OgnlRuntime.getElementsAccessor(OgnlRuntime.getTargetClass(source)); for(Enumeration e = elementsAccessor.getElements(source); e.hasMoreElements();) { Object next = e.nextElement(); if (OgnlOps.booleanValue(expr.getValue(context, next))) answer.add(next); } return answer; } public String toString() { return "{? " + _children[0] + " }"; } public String toGetSourceString(OgnlContext context, Object target) { throw new UnsupportedCompilationException("Eval expressions not supported as native java yet."); } public String toSetSourceString(OgnlContext context, Object target) { throw new UnsupportedCompilationException("Eval expressions not supported as native java yet."); } } ognl-2.7.3.orig/src/java/ognl/ASTVarRef.java0000644000175000017500000001034210606013631020360 0ustar drazzibdrazzib// -------------------------------------------------------------------------- // Copyright (c) 1998-2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. // -------------------------------------------------------------------------- package ognl; import ognl.enhance.OrderedReturn; import ognl.enhance.UnsupportedCompilationException; /** * @author Luke Blanshard (blanshlu@netscape.net) * @author Drew Davidson (drew@ognl.org) */ public class ASTVarRef extends SimpleNode implements NodeType, OrderedReturn { private String _name; protected Class _getterClass; protected String _core; protected String _last; public ASTVarRef(int id) { super(id); } public ASTVarRef(OgnlParser p, int id) { super(p, id); } void setName(String name) { this._name = name; } protected Object getValueBody(OgnlContext context, Object source) throws OgnlException { return context.get(_name); } protected void setValueBody(OgnlContext context, Object target, Object value) throws OgnlException { context.put(_name, value); } public Class getGetterClass() { return _getterClass; } public Class getSetterClass() { return null; } public String getCoreExpression() { return _core; } public String getLastExpression() { return _last; } public String toString() { return "#" + _name; } public String toGetSourceString(OgnlContext context, Object target) { Object value = context.get(_name); if (value != null) { _getterClass = value.getClass(); } context.setCurrentType(_getterClass); context.setCurrentAccessor(context.getClass()); context.setCurrentObject(value); //context.setRoot(context.get(_name)); if (context.getCurrentObject() == null) throw new UnsupportedCompilationException("Current context object is null, can't compile var reference."); String pre = ""; String post = ""; if (context.getCurrentType() != null) { pre = "((" + OgnlRuntime.getCompiler().getInterfaceClass(context.getCurrentType()).getName() + ")"; post = ")"; } if (_parent != null && ASTAssign.class.isInstance(_parent)) { _core = "$1.put(\"" + _name + "\","; _last = pre + "$1.get(\"" + _name + "\")" + post; return _core; } return pre + "$1.get(\"" + _name + "\")" + post; } public String toSetSourceString(OgnlContext context, Object target) { return toGetSourceString(context, target); } } ognl-2.7.3.orig/src/java/ognl/OgnlOps.java0000644000175000017500000011022610673567723020232 0ustar drazzibdrazzib// -------------------------------------------------------------------------- // Copyright (c) 1998-2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. // -------------------------------------------------------------------------- package ognl; import ognl.enhance.UnsupportedCompilationException; import java.lang.reflect.Array; import java.math.BigDecimal; import java.math.BigInteger; import java.util.Enumeration; /** * This is an abstract class with static methods that define the operations of OGNL. * * @author Luke Blanshard (blanshlu@netscape.net) * @author Drew Davidson (drew@ognl.org) */ public abstract class OgnlOps implements NumericTypes { /** * Compares two objects for equality, even if it has to convert one of them to the other type. * If both objects are numeric they are converted to the widest type and compared. If one is * non-numeric and one is numeric the non-numeric is converted to double and compared to the * double numeric value. If both are non-numeric and Comparable and the types are compatible * (i.e. v1 is of the same or superclass of v2's type) they are compared with * Comparable.compareTo(). If both values are non-numeric and not Comparable or of incompatible * classes this will throw and IllegalArgumentException. * * @param v1 * First value to compare * @param v2 * second value to compare * @return integer describing the comparison between the two objects. A negative number * indicates that v1 < v2. Positive indicates that v1 > v2. Zero indicates v1 == v2. * @throws IllegalArgumentException * if the objects are both non-numeric yet of incompatible types or do not implement * Comparable. */ public static int compareWithConversion(Object v1, Object v2) { int result; if (v1 == v2) { result = 0; } else { int t1 = getNumericType(v1), t2 = getNumericType(v2), type = getNumericType(t1, t2, true); switch(type) { case BIGINT: result = bigIntValue(v1).compareTo(bigIntValue(v2)); break; case BIGDEC: result = bigDecValue(v1).compareTo(bigDecValue(v2)); break; case NONNUMERIC: if ((t1 == NONNUMERIC) && (t2 == NONNUMERIC)) { if ((v1 instanceof Comparable) && v1.getClass().isAssignableFrom(v2.getClass())) { result = ((Comparable) v1).compareTo(v2); break; } else { throw new IllegalArgumentException("invalid comparison: " + v1.getClass().getName() + " and " + v2.getClass().getName()); } } // else fall through case FLOAT: case DOUBLE: double dv1 = doubleValue(v1), dv2 = doubleValue(v2); return (dv1 == dv2) ? 0 : ((dv1 < dv2) ? -1 : 1); default: long lv1 = longValue(v1), lv2 = longValue(v2); return (lv1 == lv2) ? 0 : ((lv1 < lv2) ? -1 : 1); } } return result; } /** * Returns true if object1 is equal to object2 in either the sense that they are the same object * or, if both are non-null if they are equal in the equals() sense. * * @param object1 * First object to compare * @param object2 * Second object to compare * @return true if v1 == v2 */ public static boolean isEqual(Object object1, Object object2) { boolean result = false; if (object1 == object2) { result = true; } else { if ((object1 != null) && object1.getClass().isArray()) { if ((object2 != null) && object2.getClass().isArray() && (object2.getClass() == object1.getClass())) { result = (Array.getLength(object1) == Array.getLength(object2)); if (result) { for(int i = 0, icount = Array.getLength(object1); result && (i < icount); i++) { result = isEqual(Array.get(object1, i), Array.get(object2, i)); } } } } else { // Check for converted equivalence first, then equals() equivalence result = (object1 != null) && (object2 != null) && (object1.equals(object2) || (compareWithConversion(object1, object2) == 0)); } } return result; } public static boolean booleanValue(boolean value) { return value; } public static boolean booleanValue(int value) { return value > 0; } public static boolean booleanValue(float value) { return value > 0; } public static boolean booleanValue(long value) { return value > 0; } public static boolean booleanValue(double value) { return value > 0; } /** * Evaluates the given object as a boolean: if it is a Boolean object, it's easy; if it's a * Number or a Character, returns true for non-zero objects; and otherwise returns true for * non-null objects. * * @param value * an object to interpret as a boolean * @return the boolean value implied by the given object */ public static boolean booleanValue(Object value) { if (value == null) return false; Class c = value.getClass(); if (c == Boolean.class) return ((Boolean) value).booleanValue(); // if ( c == String.class ) // return ((String)value).length() > 0; if (c == Character.class) return ((Character) value).charValue() != 0; if (value instanceof Number) return ((Number) value).doubleValue() != 0; return true; // non-null } /** * Evaluates the given object as a long integer. * * @param value * an object to interpret as a long integer * @return the long integer value implied by the given object * @throws NumberFormatException * if the given object can't be understood as a long integer */ public static long longValue(Object value) throws NumberFormatException { if (value == null) return 0L; Class c = value.getClass(); if (c.getSuperclass() == Number.class) return ((Number) value).longValue(); if (c == Boolean.class) return ((Boolean) value).booleanValue() ? 1 : 0; if (c == Character.class) return ((Character) value).charValue(); return Long.parseLong(stringValue(value, true)); } /** * Evaluates the given object as a double-precision floating-point number. * * @param value * an object to interpret as a double * @return the double value implied by the given object * @throws NumberFormatException * if the given object can't be understood as a double */ public static double doubleValue(Object value) throws NumberFormatException { if (value == null) return 0.0; Class c = value.getClass(); if (c.getSuperclass() == Number.class) return ((Number) value).doubleValue(); if (c == Boolean.class) return ((Boolean) value).booleanValue() ? 1 : 0; if (c == Character.class) return ((Character) value).charValue(); String s = stringValue(value, true); return (s.length() == 0) ? 0.0 : Double.parseDouble(s); } /** * Evaluates the given object as a BigInteger. * * @param value * an object to interpret as a BigInteger * @return the BigInteger value implied by the given object * @throws NumberFormatException * if the given object can't be understood as a BigInteger */ public static BigInteger bigIntValue(Object value) throws NumberFormatException { if (value == null) return BigInteger.valueOf(0L); Class c = value.getClass(); if (c == BigInteger.class) return (BigInteger) value; if (c == BigDecimal.class) return ((BigDecimal) value).toBigInteger(); if (c.getSuperclass() == Number.class) return BigInteger.valueOf(((Number) value).longValue()); if (c == Boolean.class) return BigInteger.valueOf(((Boolean) value).booleanValue() ? 1 : 0); if (c == Character.class) return BigInteger.valueOf(((Character) value).charValue()); return new BigInteger(stringValue(value, true)); } /** * Evaluates the given object as a BigDecimal. * * @param value * an object to interpret as a BigDecimal * @return the BigDecimal value implied by the given object * @throws NumberFormatException * if the given object can't be understood as a BigDecimal */ public static BigDecimal bigDecValue(Object value) throws NumberFormatException { if (value == null) return BigDecimal.valueOf(0L); Class c = value.getClass(); if (c == BigDecimal.class) return (BigDecimal) value; if (c == BigInteger.class) return new BigDecimal((BigInteger) value); if (c == Boolean.class) return BigDecimal.valueOf(((Boolean) value).booleanValue() ? 1 : 0); if (c == Character.class) return BigDecimal.valueOf(((Character) value).charValue()); return new BigDecimal(stringValue(value, true)); } /** * Evaluates the given object as a String and trims it if the trim flag is true. * * @param value * an object to interpret as a String * @return the String value implied by the given object as returned by the toString() method, or * "null" if the object is null. */ public static String stringValue(Object value, boolean trim) { String result; if (value == null) { result = OgnlRuntime.NULL_STRING; } else { result = value.toString(); if (trim) { result = result.trim(); } } return result; } /** * Evaluates the given object as a String. * * @param value * an object to interpret as a String * @return the String value implied by the given object as returned by the toString() method, or * "null" if the object is null. */ public static String stringValue(Object value) { return stringValue(value, false); } /** * Returns a constant from the NumericTypes interface that represents the numeric type of the * given object. * * @param value * an object that needs to be interpreted as a number * @return the appropriate constant from the NumericTypes interface */ public static int getNumericType(Object value) { if (value != null) { Class c = value.getClass(); if (c == Integer.class) return INT; if (c == Double.class) return DOUBLE; if (c == Boolean.class) return BOOL; if (c == Byte.class) return BYTE; if (c == Character.class) return CHAR; if (c == Short.class) return SHORT; if (c == Long.class) return LONG; if (c == Float.class) return FLOAT; if (c == BigInteger.class) return BIGINT; if (c == BigDecimal.class) return BIGDEC; } return NONNUMERIC; } public static Object toArray(char value, Class toType) { return toArray(new Character(value), toType); } public static Object toArray(byte value, Class toType) { return toArray(new Byte(value), toType); } public static Object toArray(int value, Class toType) { return toArray(new Integer(value), toType); } public static Object toArray(long value, Class toType) { return toArray(new Long(value), toType); } public static Object toArray(float value, Class toType) { return toArray(new Float(value), toType); } public static Object toArray(double value, Class toType) { return toArray(new Double(value), toType); } public static Object toArray(boolean value, Class toType) { return toArray(new Boolean(value), toType); } public static Object convertValue(char value, Class toType) { return convertValue(new Character(value), toType); } public static Object convertValue(byte value, Class toType) { return convertValue(new Byte(value), toType); } public static Object convertValue(int value, Class toType) { return convertValue(new Integer(value), toType); } public static Object convertValue(long value, Class toType) { return convertValue(new Long(value), toType); } public static Object convertValue(float value, Class toType) { return convertValue(new Float(value), toType); } public static Object convertValue(double value, Class toType) { return convertValue(new Double(value), toType); } public static Object convertValue(boolean value, Class toType) { return convertValue(new Boolean(value), toType); } //////////////////////////////////////////////////////////////// public static Object convertValue(char value, Class toType, boolean preventNull) { return convertValue(new Character(value), toType, preventNull); } public static Object convertValue(byte value, Class toType, boolean preventNull) { return convertValue(new Byte(value), toType, preventNull); } public static Object convertValue(int value, Class toType, boolean preventNull) { return convertValue(new Integer(value), toType, preventNull); } public static Object convertValue(long value, Class toType, boolean preventNull) { return convertValue(new Long(value), toType, preventNull); } public static Object convertValue(float value, Class toType, boolean preventNull) { return convertValue(new Float(value), toType, preventNull); } public static Object convertValue(double value, Class toType, boolean preventNull) { return convertValue(new Double(value), toType, preventNull); } public static Object convertValue(boolean value, Class toType, boolean preventNull) { return convertValue(new Boolean(value), toType, preventNull); } ///////////////////////////////////////////////////////////////// public static Object toArray(char value, Class toType, boolean preventNull) { return toArray(new Character(value), toType, preventNull); } public static Object toArray(byte value, Class toType, boolean preventNull) { return toArray(new Byte(value), toType, preventNull); } public static Object toArray(int value, Class toType, boolean preventNull) { return toArray(new Integer(value), toType, preventNull); } public static Object toArray(long value, Class toType, boolean preventNull) { return toArray(new Long(value), toType, preventNull); } public static Object toArray(float value, Class toType, boolean preventNull) { return toArray(new Float(value), toType, preventNull); } public static Object toArray(double value, Class toType, boolean preventNull) { return toArray(new Double(value), toType, preventNull); } public static Object toArray(boolean value, Class toType, boolean preventNull) { return toArray(new Boolean(value), toType, preventNull); } /** * Returns the value converted numerically to the given class type This method also detects when * arrays are being converted and converts the components of one array to the type of the other. * * @param value * an object to be converted to the given type * @param toType * class type to be converted to * @return converted value of the type given, or value if the value cannot be converted to the * given type. */ public static Object convertValue(Object value, Class toType) { return convertValue(value, toType, false); } public static Object toArray(Object value, Class toType) { return toArray(value, toType, false); } public static Object toArray(Object value, Class toType, boolean preventNulls) { if (value == null) return null; Object result = null; if (value.getClass().isArray() && toType.isAssignableFrom(value.getClass().getComponentType())) return value; if (!value.getClass().isArray()) { if (toType == Character.TYPE) return stringValue(value).toCharArray(); Object arr = Array.newInstance(toType, 1); Array.set(arr, 0, convertValue(value, toType, preventNulls)); return arr; } result = Array.newInstance(toType, Array.getLength(value)); for(int i = 0, icount = Array.getLength(value); i < icount; i++) { Array.set(result, i, convertValue(Array.get(value, i), toType)); } if (result == null && preventNulls) return value; return result; } public static Object convertValue(Object value, Class toType, boolean preventNulls) { Object result = null; if (value != null && toType.isAssignableFrom(value.getClass())) return value; if (value != null) { /* If array -> array then convert components of array individually */ if (value.getClass().isArray() && toType.isArray()) { Class componentType = toType.getComponentType(); result = Array.newInstance(componentType, Array.getLength(value)); for(int i = 0, icount = Array.getLength(value); i < icount; i++) { Array.set(result, i, convertValue(Array.get(value, i), componentType)); } } else if (value.getClass().isArray() && !toType.isArray()) { return convertValue(Array.get(value, 0), toType); } else if (!value.getClass().isArray() && toType.isArray()){ if (toType.getComponentType() == Character.TYPE) { result = stringValue(value).toCharArray(); } else if (toType.getComponentType() == Object.class) { return new Object[] { value }; } } else { if ((toType == Integer.class) || (toType == Integer.TYPE)) { result = new Integer((int) longValue(value)); } if ((toType == Double.class) || (toType == Double.TYPE)) result = new Double(doubleValue(value)); if ((toType == Boolean.class) || (toType == Boolean.TYPE)) result = booleanValue(value) ? Boolean.TRUE : Boolean.FALSE; if ((toType == Byte.class) || (toType == Byte.TYPE)) result = new Byte((byte) longValue(value)); if ((toType == Character.class) || (toType == Character.TYPE)) result = new Character((char) longValue(value)); if ((toType == Short.class) || (toType == Short.TYPE)) result = new Short((short) longValue(value)); if ((toType == Long.class) || (toType == Long.TYPE)) result = new Long(longValue(value)); if ((toType == Float.class) || (toType == Float.TYPE)) result = new Float(doubleValue(value)); if (toType == BigInteger.class) result = bigIntValue(value); if (toType == BigDecimal.class) result = bigDecValue(value); if (toType == String.class) result = stringValue(value); } } else { if (toType.isPrimitive()) { result = OgnlRuntime.getPrimitiveDefaultValue(toType); } else if (preventNulls && toType == Boolean.class) { result = Boolean.FALSE; } else if (preventNulls && Number.class.isAssignableFrom(toType)){ result = OgnlRuntime.getNumericDefaultValue(toType); } } if (result == null && preventNulls) return value; if (value != null && result == null) { throw new IllegalArgumentException("Unable to convert type " + value.getClass().getName() + " of " + value + " to type of " + toType.getName()); } return result; } /** * Converts the specified value to a primitive integer value. * *
    *
  • Null values will cause a -1 to be returned.
  • *
  • {@link Number} instances have their intValue() methods invoked.
  • *
  • All other types result in calling Integer.parseInt(value.toString());
  • *
* * @param value * The object to get the value of. * @return A valid integer. */ public static int getIntValue(Object value) { try { if (value == null) return -1; if (Number.class.isInstance(value)) { return ((Number)value).intValue(); } String str = String.class.isInstance(value) ? (String)value : value.toString(); return Integer.parseInt(str); } catch (Throwable t) { throw new RuntimeException("Error converting " + value + " to integer:", t); } } /** * Returns the constant from the NumericTypes interface that best expresses the type of a * numeric operation on the two given objects. * * @param v1 * one argument to a numeric operator * @param v2 * the other argument * @return the appropriate constant from the NumericTypes interface */ public static int getNumericType(Object v1, Object v2) { return getNumericType(v1, v2, false); } /** * Returns the constant from the NumericTypes interface that best expresses the type of an * operation, which can be either numeric or not, on the two given types. * * @param t1 * type of one argument to an operator * @param t2 * type of the other argument * @param canBeNonNumeric * whether the operator can be interpreted as non-numeric * @return the appropriate constant from the NumericTypes interface */ public static int getNumericType(int t1, int t2, boolean canBeNonNumeric) { if (t1 == t2) return t1; if (canBeNonNumeric && (t1 == NONNUMERIC || t2 == NONNUMERIC || t1 == CHAR || t2 == CHAR)) return NONNUMERIC; if (t1 == NONNUMERIC) t1 = DOUBLE; // Try to interpret strings as doubles... if (t2 == NONNUMERIC) t2 = DOUBLE; // Try to interpret strings as doubles... if (t1 >= MIN_REAL_TYPE) { if (t2 >= MIN_REAL_TYPE) return Math.max(t1, t2); if (t2 < INT) return t1; if (t2 == BIGINT) return BIGDEC; return Math.max(DOUBLE, t1); } else if (t2 >= MIN_REAL_TYPE) { if (t1 < INT) return t2; if (t1 == BIGINT) return BIGDEC; return Math.max(DOUBLE, t2); } else return Math.max(t1, t2); } /** * Returns the constant from the NumericTypes interface that best expresses the type of an * operation, which can be either numeric or not, on the two given objects. * * @param v1 * one argument to an operator * @param v2 * the other argument * @param canBeNonNumeric * whether the operator can be interpreted as non-numeric * @return the appropriate constant from the NumericTypes interface */ public static int getNumericType(Object v1, Object v2, boolean canBeNonNumeric) { return getNumericType(getNumericType(v1), getNumericType(v2), canBeNonNumeric); } /** * Returns a new Number object of an appropriate type to hold the given integer value. The type * of the returned object is consistent with the given type argument, which is a constant from * the NumericTypes interface. * * @param type * the nominal numeric type of the result, a constant from the NumericTypes interface * @param value * the integer value to convert to a Number object * @return a Number object with the given value, of type implied by the type argument */ public static Number newInteger(int type, long value) { switch(type) { case BOOL: case CHAR: case INT: return new Integer((int) value); case FLOAT: if ((long) (float) value == value) { return new Float((float) value); } // else fall through: case DOUBLE: if ((long) (double) value == value) { return new Double((double) value); } // else fall through: case LONG: return new Long(value); case BYTE: return new Byte((byte) value); case SHORT: return new Short((short) value); default: return BigInteger.valueOf(value); } } /** * Returns a new Number object of an appropriate type to hold the given real value. The type of * the returned object is always either Float or Double, and is only Float if the given type tag * (a constant from the NumericTypes interface) is FLOAT. * * @param type * the nominal numeric type of the result, a constant from the NumericTypes interface * @param value * the real value to convert to a Number object * @return a Number object with the given value, of type implied by the type argument */ public static Number newReal(int type, double value) { if (type == FLOAT) return new Float((float) value); return new Double(value); } public static Object binaryOr(Object v1, Object v2) { int type = getNumericType(v1, v2); if (type == BIGINT || type == BIGDEC) return bigIntValue(v1).or(bigIntValue(v2)); return newInteger(type, longValue(v1) | longValue(v2)); } public static Object binaryXor(Object v1, Object v2) { int type = getNumericType(v1, v2); if (type == BIGINT || type == BIGDEC) return bigIntValue(v1).xor(bigIntValue(v2)); return newInteger(type, longValue(v1) ^ longValue(v2)); } public static Object binaryAnd(Object v1, Object v2) { int type = getNumericType(v1, v2); if (type == BIGINT || type == BIGDEC) return bigIntValue(v1).and(bigIntValue(v2)); return newInteger(type, longValue(v1) & longValue(v2)); } public static boolean equal(Object v1, Object v2) { if (v1 == null) return v2 == null; if (v1 == v2 || isEqual(v1, v2)) return true; if (v1 instanceof Number && v2 instanceof Number) return ((Number) v1).doubleValue() == ((Number) v2).doubleValue(); return false; } public static boolean less(Object v1, Object v2) { return compareWithConversion(v1, v2) < 0; } public static boolean greater(Object v1, Object v2) { return compareWithConversion(v1, v2) > 0; } public static boolean in(Object v1, Object v2) throws OgnlException { if (v2 == null) // A null collection is always treated as empty return false; ElementsAccessor elementsAccessor = OgnlRuntime.getElementsAccessor(OgnlRuntime.getTargetClass(v2)); for(Enumeration e = elementsAccessor.getElements(v2); e.hasMoreElements();) { Object o = e.nextElement(); if (equal(v1, o)) return true; } return false; } public static Object shiftLeft(Object v1, Object v2) { int type = getNumericType(v1); if (type == BIGINT || type == BIGDEC) return bigIntValue(v1).shiftLeft((int) longValue(v2)); return newInteger(type, longValue(v1) << (int) longValue(v2)); } public static Object shiftRight(Object v1, Object v2) { int type = getNumericType(v1); if (type == BIGINT || type == BIGDEC) return bigIntValue(v1).shiftRight((int) longValue(v2)); return newInteger(type, longValue(v1) >> (int) longValue(v2)); } public static Object unsignedShiftRight(Object v1, Object v2) { int type = getNumericType(v1); if (type == BIGINT || type == BIGDEC) return bigIntValue(v1).shiftRight((int) longValue(v2)); if (type <= INT) return newInteger(INT, ((int) longValue(v1)) >>> (int) longValue(v2)); return newInteger(type, longValue(v1) >>> (int) longValue(v2)); } public static Object add(Object v1, Object v2) { int type = getNumericType(v1, v2, true); switch(type) { case BIGINT: return bigIntValue(v1).add(bigIntValue(v2)); case BIGDEC: return bigDecValue(v1).add(bigDecValue(v2)); case FLOAT: case DOUBLE: return newReal(type, doubleValue(v1) + doubleValue(v2)); case NONNUMERIC: int t1 = getNumericType(v1), t2 = getNumericType(v2); if (((t1 != NONNUMERIC) && (v2 == null)) || ((t2 != NONNUMERIC) && (v1 == null))) { throw new NullPointerException("Can't add values " + v1 + " , " + v2); } return stringValue(v1) + stringValue(v2); default: return newInteger(type, longValue(v1) + longValue(v2)); } } public static Object subtract(Object v1, Object v2) { int type = getNumericType(v1, v2); switch(type) { case BIGINT: return bigIntValue(v1).subtract(bigIntValue(v2)); case BIGDEC: return bigDecValue(v1).subtract(bigDecValue(v2)); case FLOAT: case DOUBLE: return newReal(type, doubleValue(v1) - doubleValue(v2)); default: return newInteger(type, longValue(v1) - longValue(v2)); } } public static Object multiply(Object v1, Object v2) { int type = getNumericType(v1, v2); switch(type) { case BIGINT: return bigIntValue(v1).multiply(bigIntValue(v2)); case BIGDEC: return bigDecValue(v1).multiply(bigDecValue(v2)); case FLOAT: case DOUBLE: return newReal(type, doubleValue(v1) * doubleValue(v2)); default: return newInteger(type, longValue(v1) * longValue(v2)); } } public static Object divide(Object v1, Object v2) { int type = getNumericType(v1, v2); switch(type) { case BIGINT: return bigIntValue(v1).divide(bigIntValue(v2)); case BIGDEC: return bigDecValue(v1).divide(bigDecValue(v2), BigDecimal.ROUND_HALF_EVEN); case FLOAT: case DOUBLE: return newReal(type, doubleValue(v1) / doubleValue(v2)); default: return newInteger(type, longValue(v1) / longValue(v2)); } } public static Object remainder(Object v1, Object v2) { int type = getNumericType(v1, v2); switch(type) { case BIGDEC: case BIGINT: return bigIntValue(v1).remainder(bigIntValue(v2)); default: return newInteger(type, longValue(v1) % longValue(v2)); } } public static Object negate(Object value) { int type = getNumericType(value); switch(type) { case BIGINT: return bigIntValue(value).negate(); case BIGDEC: return bigDecValue(value).negate(); case FLOAT: case DOUBLE: return newReal(type, -doubleValue(value)); default: return newInteger(type, -longValue(value)); } } public static Object bitNegate(Object value) { int type = getNumericType(value); switch(type) { case BIGDEC: case BIGINT: return bigIntValue(value).not(); default: return newInteger(type, ~longValue(value)); } } public static String getEscapeString(String value) { StringBuffer result = new StringBuffer(); for(int i = 0, icount = value.length(); i < icount; i++) { result.append(getEscapedChar(value.charAt(i))); } return new String(result); } public static String getEscapedChar(char ch) { String result; switch(ch) { case '\b': result = "\b"; break; case '\t': result = "\\t"; break; case '\n': result = "\\n"; break; case '\f': result = "\\f"; break; case '\r': result = "\\r"; break; case '\"': result = "\\\""; break; case '\'': result = "\\\'"; break; case '\\': result = "\\\\"; break; default: if (Character.isISOControl(ch)) { String hc = Integer.toString((int) ch, 16); int hcl = hc.length(); result = "\\u"; if (hcl < 4) { if (hcl == 3) { result = result + "0"; } else { if (hcl == 2) { result = result + "00"; } else { result = result + "000"; } } } result = result + hc; } else { result = new String(ch + ""); } break; } return result; } public static Object returnValue(Object ignore, Object returnValue) { return returnValue; } /** * Utility method that converts incoming exceptions to {@link RuntimeException} * instances - or casts them if they already are. * * @param t * The exception to cast. * @return The exception cast to a {@link RuntimeException}. */ public static RuntimeException castToRuntime(Throwable t) { if (RuntimeException.class.isInstance(t)) return (RuntimeException)t; if (OgnlException.class.isInstance(t)) throw new UnsupportedCompilationException("Error evluating expression: " + t.getMessage(), t); return new RuntimeException(t); } } ognl-2.7.3.orig/src/java/ognl/DynamicSubscript.java0000644000175000017500000000613110561411075022113 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 1998-2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package ognl; /** * This class has predefined instances that stand for OGNL's special "dynamic subscripts" * for getting at the first, middle, or last elements of a list. In OGNL expressions, * these subscripts look like special kinds of array indexes: [^] means the first element, * [$] means the last, [|] means the middle, and [*] means the whole list. * @author Luke Blanshard (blanshlu@netscape.net) * @author Drew Davidson (drew@ognl.org) */ public class DynamicSubscript { public static final int FIRST = 0; public static final int MID = 1; public static final int LAST = 2; public static final int ALL = 3; public static final DynamicSubscript first = new DynamicSubscript(FIRST); public static final DynamicSubscript mid = new DynamicSubscript(MID); public static final DynamicSubscript last = new DynamicSubscript(LAST); public static final DynamicSubscript all = new DynamicSubscript(ALL); private int flag; private DynamicSubscript( int flag ) { this.flag = flag; } public int getFlag() { return flag; } public String toString() { switch (flag) { case FIRST: return "^"; case MID: return "|"; case LAST: return "$"; case ALL: return "*"; default: return "?"; // Won't happen } } } ognl-2.7.3.orig/src/java/ognl/ASTMethod.java0000644000175000017500000005035410776755160020444 0ustar drazzibdrazzib//-------------------------------------------------------------------------- //Copyright (c) 1998-2004, Drew Davidson and Luke Blanshard //All rights reserved. //Redistribution and use in source and binary forms, with or without //modification, are permitted provided that the following conditions are //met: //Redistributions of source code must retain the above copyright notice, //this list of conditions and the following disclaimer. //Redistributions in binary form must reproduce the above copyright //notice, this list of conditions and the following disclaimer in the //documentation and/or other materials provided with the distribution. //Neither the name of the Drew Davidson nor the names of its contributors //may be used to endorse or promote products derived from this software //without specific prior written permission. //THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS //"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT //LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS //FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE //COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, //INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, //BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS //OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED //AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, //OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF //THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH //DAMAGE. //-------------------------------------------------------------------------- package ognl; import ognl.enhance.ExpressionCompiler; import ognl.enhance.OrderedReturn; import ognl.enhance.UnsupportedCompilationException; import java.lang.reflect.Method; /** * @author Luke Blanshard (blanshlu@netscape.net) * @author Drew Davidson (drew@ognl.org) */ public class ASTMethod extends SimpleNode implements OrderedReturn, NodeType { private String _methodName; private String _lastExpression; private String _coreExpression; private Class _getterClass; public ASTMethod(int id) { super(id); } public ASTMethod(OgnlParser p, int id) { super(p, id); } /** Called from parser action. */ public void setMethodName(String methodName) { _methodName = methodName; } /** * Returns the method name that this node will call. */ public String getMethodName() { return _methodName; } protected Object getValueBody(OgnlContext context, Object source) throws OgnlException { Object[] args = OgnlRuntime.getObjectArrayPool().create(jjtGetNumChildren()); try { Object result, root = context.getRoot(); for(int i = 0, icount = args.length; i < icount; ++i) { args[i] = _children[i].getValue(context, root); } result = OgnlRuntime.callMethod(context, source, _methodName, args); if (result == null) { NullHandler nh = OgnlRuntime.getNullHandler(OgnlRuntime.getTargetClass(source)); result = nh.nullMethodResult(context, source, _methodName, args); } return result; } finally { OgnlRuntime.getObjectArrayPool().recycle(args); } } public String getLastExpression() { return _lastExpression; } public String getCoreExpression() { return _coreExpression; } public Class getGetterClass() { return _getterClass; } public Class getSetterClass() { return _getterClass; } public String toString() { String result = _methodName; result = result + "("; if ((_children != null) && (_children.length > 0)) { for(int i = 0; i < _children.length; i++) { if (i > 0) { result = result + ", "; } result = result + _children[i]; } } result = result + ")"; return result; } public String toGetSourceString(OgnlContext context, Object target) { /* System.out.println("methodName is " + _methodName + " for target " + target + " target class: " + (target != null ? target.getClass() : null) + " current type: " + context.getCurrentType());*/ if (target == null) throw new UnsupportedCompilationException("Target object is null."); String post = ""; String result = null; Method m = null; try { m = OgnlRuntime.getMethod(context, context.getCurrentType() != null ? context.getCurrentType() : target.getClass(), _methodName, _children, false); if (m == null) m = OgnlRuntime.getReadMethod(target.getClass(), _methodName, _children != null ? _children.length : -1); if (m == null) { m = OgnlRuntime.getWriteMethod(target.getClass(), _methodName, _children != null ? _children.length : -1); if (m != null) { context.setCurrentType(m.getReturnType()); context.setCurrentAccessor(OgnlRuntime.getCompiler().getSuperOrInterfaceClass(m, m.getDeclaringClass())); _coreExpression = toSetSourceString(context, target); if (_coreExpression == null || _coreExpression.length() < 1) throw new UnsupportedCompilationException("can't find suitable getter method"); _coreExpression += ";"; _lastExpression = "null"; return _coreExpression; } return ""; } else { _getterClass = m.getReturnType(); } // TODO: This is a hacky workaround until javassist supports varargs method invocations boolean varArgs = OgnlRuntime.isJdk15() && m.isVarArgs(); if (varArgs) { throw new UnsupportedCompilationException("Javassist does not currently support varargs method calls"); } result = "." + m.getName() + "("; if ((_children != null) && (_children.length > 0)) { Class[] parms = m.getParameterTypes(); String prevCast = (String)context.remove(ExpressionCompiler.PRE_CAST); /* System.out.println("before children methodName is " + _methodName + " for target " + target + " target class: " + (target != null ? target.getClass() : null) + " current type: " + context.getCurrentType() + " and previous type: " + context.getPreviousType());*/ for(int i = 0; i < _children.length; i++) { if (i > 0) { result = result + ", "; } Class prevType = context.getCurrentType(); context.setCurrentObject(context.getRoot()); context.setCurrentType(context.getRoot() != null ? context.getRoot().getClass() : null); context.setCurrentAccessor(null); context.setPreviousType(null); Object value = _children[i].getValue(context, context.getRoot()); String parmString = _children[i].toGetSourceString(context, context.getRoot()); if (parmString == null || parmString.trim().length() < 1) parmString = "null"; // to undo type setting of constants when used as method parameters if (ASTConst.class.isInstance(_children[i])) { context.setCurrentType(prevType); } parmString = ExpressionCompiler.getRootExpression(_children[i], context.getRoot(), context) + parmString; String cast = ""; if (ExpressionCompiler.shouldCast(_children[i])) { cast = (String)context.remove(ExpressionCompiler.PRE_CAST); } if (cast == null) cast = ""; if (!ASTConst.class.isInstance(_children[i])) parmString = cast + parmString; Class valueClass = value != null ? value.getClass() : null; if (NodeType.class.isAssignableFrom(_children[i].getClass())) valueClass = ((NodeType)_children[i]).getGetterClass(); if ((!varArgs || varArgs && (i + 1) < parms.length) && valueClass != parms[i]) { if (parms[i].isArray()) { parmString = OgnlRuntime.getCompiler().createLocalReference(context, "(" + ExpressionCompiler.getCastString(parms[i]) + ")ognl.OgnlOps#toArray(" + parmString + ", " + parms[i].getComponentType().getName() + ".class, true)", parms[i] ); } else if (parms[i].isPrimitive()) { Class wrapClass = OgnlRuntime.getPrimitiveWrapperClass(parms[i]); parmString = OgnlRuntime.getCompiler().createLocalReference(context, "((" + wrapClass.getName() + ")ognl.OgnlOps#convertValue(" + parmString + "," + wrapClass.getName() + ".class, true))." + OgnlRuntime.getNumericValueGetter(wrapClass), parms[i] ); } else if (parms[i] != Object.class) { parmString = OgnlRuntime.getCompiler().createLocalReference(context, "(" + parms[i].getName() + ")ognl.OgnlOps#convertValue(" + parmString + "," + parms[i].getName() + ".class)", parms[i] ); } else if ((NodeType.class.isInstance(_children[i]) && ((NodeType)_children[i]).getGetterClass() != null && Number.class.isAssignableFrom(((NodeType)_children[i]).getGetterClass())) || (valueClass != null && valueClass.isPrimitive())) { parmString = " ($w) " + parmString; } else if (valueClass != null && valueClass.isPrimitive()) { parmString = "($w) " + parmString; } } result += parmString; } if (prevCast != null) { context.put(ExpressionCompiler.PRE_CAST, prevCast); } } } catch (Throwable t) { throw OgnlOps.castToRuntime(t); } try { Object contextObj = getValueBody(context, target); context.setCurrentObject(contextObj); } catch (Throwable t) { throw OgnlOps.castToRuntime(t); } result += ")" + post; if (m.getReturnType() == void.class) { _coreExpression = result + ";"; _lastExpression = "null"; } context.setCurrentType(m.getReturnType()); context.setCurrentAccessor(OgnlRuntime.getCompiler().getSuperOrInterfaceClass(m, m.getDeclaringClass())); return result; } public String toSetSourceString(OgnlContext context, Object target) { /*System.out.println("current type: " + context.getCurrentType() + " target:" + target + " " + context.getCurrentObject() + " last child? " + lastChild(context));*/ Method m = OgnlRuntime.getWriteMethod(context.getCurrentType() != null ? context.getCurrentType() : target.getClass(), _methodName, _children != null ? _children.length : -1); if (m == null) { throw new UnsupportedCompilationException("Unable to determine setter method generation for " + _methodName); } String post = ""; String result = "." + m.getName() + "("; if (m.getReturnType() != void.class && m.getReturnType().isPrimitive() && (_parent == null || !ASTTest.class.isInstance(_parent))) { Class wrapper = OgnlRuntime.getPrimitiveWrapperClass(m.getReturnType()); ExpressionCompiler.addCastString(context, "new " + wrapper.getName() + "("); post = ")"; _getterClass = wrapper; } boolean varArgs = OgnlRuntime.isJdk15() && m.isVarArgs(); if (varArgs) { throw new UnsupportedCompilationException("Javassist does not currently support varargs method calls"); } try { /* if (lastChild(context) && m.getParameterTypes().length > 0 && _children.length <= 0) throw new UnsupportedCompilationException("Unable to determine setter method generation for " + m); */ if ((_children != null) && (_children.length > 0)) { Class[] parms = m.getParameterTypes(); String prevCast = (String)context.remove(ExpressionCompiler.PRE_CAST); for(int i = 0; i < _children.length; i++) { if (i > 0) { result += ", "; } Class prevType = context.getCurrentType(); context.setCurrentObject(context.getRoot()); context.setCurrentType(context.getRoot() != null ? context.getRoot().getClass() : null); context.setCurrentAccessor(null); context.setPreviousType(null); Object value = _children[i].getValue(context, context.getRoot()); String parmString = _children[i].toSetSourceString(context, context.getRoot()); if (context.getCurrentType() == Void.TYPE || context.getCurrentType() == void.class) throw new UnsupportedCompilationException("Method argument can't be a void type."); if (parmString == null || parmString.trim().length() < 1) { if (ASTProperty.class.isInstance(_children[i]) || ASTMethod.class.isInstance(_children[i]) || ASTStaticMethod.class.isInstance(_children[i]) || ASTChain.class.isInstance(_children[i])) throw new UnsupportedCompilationException("ASTMethod setter child returned null from a sub property expression."); parmString = "null"; } // to undo type setting of constants when used as method parameters if (ASTConst.class.isInstance(_children[i])) { context.setCurrentType(prevType); } parmString = ExpressionCompiler.getRootExpression(_children[i], context.getRoot(), context) + parmString; String cast = ""; if (ExpressionCompiler.shouldCast(_children[i])) { cast = (String)context.remove(ExpressionCompiler.PRE_CAST); } if (cast == null) cast = ""; parmString = cast + parmString; Class valueClass = value != null ? value.getClass() : null; if (NodeType.class.isAssignableFrom(_children[i].getClass())) valueClass = ((NodeType)_children[i]).getGetterClass(); if (valueClass != parms[i]) { if (parms[i].isArray()) { parmString = OgnlRuntime.getCompiler().createLocalReference(context, "(" + ExpressionCompiler.getCastString(parms[i]) + ")ognl.OgnlOps#toArray(" + parmString + ", " + parms[i].getComponentType().getName() + ".class)", parms[i] ); } else if (parms[i].isPrimitive()) { Class wrapClass = OgnlRuntime.getPrimitiveWrapperClass(parms[i]); parmString = OgnlRuntime.getCompiler().createLocalReference(context, "((" + wrapClass.getName() + ")ognl.OgnlOps#convertValue(" + parmString + "," + wrapClass.getName() + ".class, true))." + OgnlRuntime.getNumericValueGetter(wrapClass), parms[i] ); } else if (parms[i] != Object.class) { parmString = OgnlRuntime.getCompiler().createLocalReference(context, "(" + parms[i].getName() + ")ognl.OgnlOps#convertValue(" + parmString + "," + parms[i].getName() + ".class)", parms[i] ); } else if ((NodeType.class.isInstance(_children[i]) && ((NodeType)_children[i]).getGetterClass() != null && Number.class.isAssignableFrom(((NodeType)_children[i]).getGetterClass())) || (valueClass != null && valueClass.isPrimitive())) { parmString = " ($w) " + parmString; } else if (valueClass != null && valueClass.isPrimitive()) { parmString = "($w) " + parmString; } } result += parmString; } if (prevCast != null) { context.put(ExpressionCompiler.PRE_CAST, prevCast); } } } catch (Throwable t) { throw OgnlOps.castToRuntime(t); } try { Object contextObj = getValueBody(context, target); context.setCurrentObject(contextObj); } catch (Throwable t) { // ignore } context.setCurrentType(m.getReturnType()); context.setCurrentAccessor(OgnlRuntime.getCompiler().getSuperOrInterfaceClass(m, m.getDeclaringClass())); return result + ")" + post; } } ognl-2.7.3.orig/src/java/ognl/MapPropertyAccessor.java0000644000175000017500000001346210776755160022620 0ustar drazzibdrazzib// -------------------------------------------------------------------------- // Copyright (c) 1998-2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. // -------------------------------------------------------------------------- package ognl; import java.util.Collection; import java.util.Map; import java.util.Set; /** * Implementation of PropertyAccessor that sets and gets properties by storing and looking up values * in Maps. * * @author Luke Blanshard (blanshlu@netscape.net) * @author Drew Davidson (drew@ognl.org) */ public class MapPropertyAccessor implements PropertyAccessor { public Object getProperty(Map context, Object target, Object name) throws OgnlException { Object result; Map map = (Map) target; Node currentNode = ((OgnlContext) context).getCurrentNode().jjtGetParent(); boolean indexedAccess = false; if (currentNode == null) { throw new OgnlException("node is null for '" + name + "'"); } if (!(currentNode instanceof ASTProperty)) { currentNode = currentNode.jjtGetParent(); } if (currentNode instanceof ASTProperty) { indexedAccess = ((ASTProperty) currentNode).isIndexedAccess(); } if ((name instanceof String) && !indexedAccess) { if (name.equals("size")) { result = new Integer(map.size()); } else { if (name.equals("keys") || name.equals("keySet")) { result = map.keySet(); } else { if (name.equals("values")) { result = map.values(); } else { if (name.equals("isEmpty")) { result = map.isEmpty() ? Boolean.TRUE : Boolean.FALSE; } else { result = map.get(name); } } } } } else { result = map.get(name); } return result; } public void setProperty(Map context, Object target, Object name, Object value) throws OgnlException { Map map = (Map) target; map.put(name, value); } public String getSourceAccessor(OgnlContext context, Object target, Object index) { Node currentNode = ((OgnlContext) context).getCurrentNode().jjtGetParent(); boolean indexedAccess = false; if (currentNode == null) throw new RuntimeException("node is null for '" + index + "'"); if (!(currentNode instanceof ASTProperty)) currentNode = currentNode.jjtGetParent(); if (currentNode instanceof ASTProperty) indexedAccess = ((ASTProperty) currentNode).isIndexedAccess(); String indexStr = index.toString(); context.setCurrentAccessor(Map.class); context.setCurrentType(Object.class); if (String.class.isInstance(index) && !indexedAccess) { String key = indexStr.replaceAll("\"", ""); if (key.equals("size")) { context.setCurrentType(int.class); return ".size()"; } else if (key.equals("keys") || key.equals("keySet")) { context.setCurrentType(Set.class); return ".keySet()"; } else if (key.equals("values")) { context.setCurrentType(Collection.class); return ".values()"; } else if (key.equals("isEmpty")) { context.setCurrentType(boolean.class); return ".isEmpty()"; } } return ".get(" + indexStr + ")"; } public String getSourceSetter(OgnlContext context, Object target, Object index) { context.setCurrentAccessor(Map.class); context.setCurrentType(Object.class); String indexStr = index.toString(); if (String.class.isInstance(index)) { String key = indexStr.replaceAll("\"", ""); if (key.equals("size")) return ""; else if (key.equals("keys") || key.equals("keySet")) return ""; else if (key.equals("values")) return ""; else if (key.equals("isEmpty")) return ""; } return ".put(" + indexStr + ", $3)"; } } ognl-2.7.3.orig/src/java/ognl/ComparisonExpression.java0000644000175000017500000000447010646473765023050 0ustar drazzibdrazzib/** * */ package ognl; import ognl.enhance.UnsupportedCompilationException; /** * Base class for types that compare values. */ public abstract class ComparisonExpression extends BooleanExpression { public ComparisonExpression(int id) { super(id); } public ComparisonExpression(OgnlParser p, int id) { super(p, id); } public abstract String getComparisonFunction(); public String toGetSourceString(OgnlContext context, Object target) { if (target == null) throw new UnsupportedCompilationException("Current target is null, can't compile."); try { Object value = getValueBody(context, target); if (value != null && Boolean.class.isAssignableFrom(value.getClass())) _getterClass = Boolean.TYPE; else if (value != null) _getterClass = value.getClass(); else _getterClass = Boolean.TYPE; // iterate over children to make numeric type detection work properly OgnlRuntime.getChildSource(context, target, _children[0]); OgnlRuntime.getChildSource(context, target, _children[1]); // System.out.println("comparison expression currentType: " + context.getCurrentType() + " previousType: " + context.getPreviousType()); boolean conversion = OgnlRuntime.shouldConvertNumericTypes(context); String result = conversion ? "(" + getComparisonFunction() + "( ($w) (" : "("; result += OgnlRuntime.getChildSource(context, target, _children[0], conversion) + " " + (conversion ? "), ($w) " : getExpressionOperator(0)) + " " + OgnlRuntime.getChildSource(context, target, _children[1], conversion); result += conversion ? ")" : ""; context.setCurrentType(Boolean.TYPE); result += ")"; return result; } catch (NullPointerException e) { // expected to happen in some instances throw new UnsupportedCompilationException("evaluation resulted in null expression."); } catch (Throwable t) { throw OgnlOps.castToRuntime(t); } } } ognl-2.7.3.orig/src/java/ognl/ASTNotEq.java0000644000175000017500000000474210655154670020245 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 1998-2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package ognl; /** * @author Luke Blanshard (blanshlu@netscape.net) * @author Drew Davidson (drew@ognl.org) */ class ASTNotEq extends ComparisonExpression { public ASTNotEq(int id) { super(id); } public ASTNotEq(OgnlParser p, int id) { super(p, id); } protected Object getValueBody( OgnlContext context, Object source ) throws OgnlException { Object v1 = _children[0].getValue( context, source ); Object v2 = _children[1].getValue( context, source ); return OgnlOps.equal( v1, v2 ) ? Boolean.FALSE : Boolean.TRUE; } public String getExpressionOperator(int index) { return "!="; } public String getComparisonFunction() { return "!ognl.OgnlOps.equal"; } } ognl-2.7.3.orig/src/java/ognl/ASTConst.java0000644000175000017500000001511010754136663020276 0ustar drazzibdrazzib// -------------------------------------------------------------------------- // Copyright (c) 1998-2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. // -------------------------------------------------------------------------- package ognl; import ognl.enhance.UnsupportedCompilationException; import java.math.BigDecimal; import java.math.BigInteger; /** * @author Luke Blanshard (blanshlu@netscape.net) * @author Drew Davidson (drew@ognl.org) */ public class ASTConst extends SimpleNode implements NodeType { private Object value; private Class _getterClass; public ASTConst(int id) { super(id); } public ASTConst(OgnlParser p, int id) { super(p, id); } /** Called from parser actions. */ public void setValue(Object value) { this.value = value; } public Object getValue() { return value; } protected Object getValueBody(OgnlContext context, Object source) throws OgnlException { return this.value; } public boolean isNodeConstant(OgnlContext context) throws OgnlException { return true; } public Class getGetterClass() { if (_getterClass == null) return null; return _getterClass; } public Class getSetterClass() { return null; } public String toString() { String result; if (value == null) { result = "null"; } else { if (value instanceof String) { result = '\"' + OgnlOps.getEscapeString(value.toString()) + '\"'; } else { if (value instanceof Character) { result = '\'' + OgnlOps.getEscapedChar(((Character) value).charValue()) + '\''; } else { result = value.toString(); if (value instanceof Long) { result = result + "L"; } else { if (value instanceof BigDecimal) { result = result + "B"; } else { if (value instanceof BigInteger) { result = result + "H"; } else { if (value instanceof Node) { result = ":[ " + result + " ]"; } } } } } } } return result; } public String toGetSourceString(OgnlContext context, Object target) { if (value == null && _parent != null && ExpressionNode.class.isInstance(_parent)) { context.setCurrentType(null); return "null"; } else if (value == null) { context.setCurrentType(null); return ""; } _getterClass = value.getClass(); Object retval = value; if (_parent != null && ASTProperty.class.isInstance(_parent)) { context.setCurrentObject(value); return value.toString(); } else if (value != null && Number.class.isAssignableFrom(value.getClass())) { context.setCurrentType(OgnlRuntime.getPrimitiveWrapperClass(value.getClass())); context.setCurrentObject(value); return value.toString(); } else if (!(_parent != null && value != null && NumericExpression.class.isAssignableFrom(_parent.getClass())) && String.class.isAssignableFrom(value.getClass())) { context.setCurrentType(String.class); retval = '\"' + OgnlOps.getEscapeString(value.toString()) + '\"'; context.setCurrentObject(retval.toString()); return retval.toString(); } else if (Character.class.isInstance(value)) { Character val = (Character)value; context.setCurrentType(Character.class); if (Character.isLetterOrDigit(val.charValue())) retval = "'" + ((Character) value).charValue() + "'"; else retval = "'" + OgnlOps.getEscapedChar(((Character) value).charValue()) + "'"; context.setCurrentObject(retval); return retval.toString(); } if (Boolean.class.isAssignableFrom(value.getClass())) { _getterClass = Boolean.TYPE; context.setCurrentType(Boolean.TYPE); context.setCurrentObject(value); return value.toString(); } return value.toString(); } public String toSetSourceString(OgnlContext context, Object target) { if (_parent == null) throw new UnsupportedCompilationException("Can't modify constant values."); return toGetSourceString(context, target); } } ognl-2.7.3.orig/src/java/ognl/ASTKeyValue.java0000644000175000017500000000473310566476144020750 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 1998-2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package ognl; /** * @author Luke Blanshard (blanshlu@netscape.net) * @author Drew Davidson (drew@ognl.org) */ class ASTKeyValue extends SimpleNode { public ASTKeyValue(int id) { super(id); } public ASTKeyValue(OgnlParser p, int id) { super(p, id); } protected Node getKey() { return _children[0]; } protected Node getValue() { return (jjtGetNumChildren() > 1) ? _children[1] : null; } /** Returns null because this is a parser construct and does not evaluate */ protected Object getValueBody( OgnlContext context, Object source ) throws OgnlException { return null; } public String toString() { return getKey() + " -> " + getValue(); } } ognl-2.7.3.orig/src/java/ognl/ASTMap.java0000644000175000017500000001074710566476144017742 0ustar drazzibdrazzib// -------------------------------------------------------------------------- // Copyright (c) 1998-2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. // -------------------------------------------------------------------------- package ognl; import ognl.enhance.UnsupportedCompilationException; import java.util.HashMap; import java.util.Map; /** * @author Luke Blanshard (blanshlu@netscape.net) * @author Drew Davidson (drew@ognl.org) */ class ASTMap extends SimpleNode { private static Class DEFAULT_MAP_CLASS; private String className; static { /* Try to get LinkedHashMap; if older JDK than 1.4 use HashMap */ try { DEFAULT_MAP_CLASS = Class.forName("java.util.LinkedHashMap"); } catch (ClassNotFoundException ex) { DEFAULT_MAP_CLASS = HashMap.class; } } public ASTMap(int id) { super(id); } public ASTMap(OgnlParser p, int id) { super(p, id); } protected void setClassName(String value) { className = value; } protected Object getValueBody(OgnlContext context, Object source) throws OgnlException { Map answer; if (className == null) { try { answer = (Map) DEFAULT_MAP_CLASS.newInstance(); } catch (Exception ex) { /* This should never happen */ throw new OgnlException("Default Map class '" + DEFAULT_MAP_CLASS.getName() + "' instantiation error", ex); } } else { try { answer = (Map) OgnlRuntime.classForName(context, className).newInstance(); } catch (Exception ex) { throw new OgnlException("Map implementor '" + className + "' not found", ex); } } for(int i = 0; i < jjtGetNumChildren(); ++i) { ASTKeyValue kv = (ASTKeyValue) _children[i]; Node k = kv.getKey(), v = kv.getValue(); answer.put(k.getValue(context, source), (v == null) ? null : v.getValue(context, source)); } return answer; } public String toString() { String result = "#"; if (className != null) { result = result + "@" + className + "@"; } result = result + "{ "; for(int i = 0; i < jjtGetNumChildren(); ++i) { ASTKeyValue kv = (ASTKeyValue) _children[i]; if (i > 0) { result = result + ", "; } result = result + kv.getKey() + " : " + kv.getValue(); } return result + " }"; } public String toGetSourceString(OgnlContext context, Object target) { throw new UnsupportedCompilationException("Map expressions not supported as native java yet."); } public String toSetSourceString(OgnlContext context, Object target) { throw new UnsupportedCompilationException("Map expressions not supported as native java yet."); } } ognl-2.7.3.orig/src/java/ognl/NumberElementsAccessor.java0000644000175000017500000000515010561411075023240 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 1998-2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package ognl; import java.util.*; /** * Implementation of ElementsAccessor that returns an iterator over integers from 0 up to * the given target. * @author Luke Blanshard (blanshlu@netscape.net) * @author Drew Davidson (drew@ognl.org) */ public class NumberElementsAccessor implements ElementsAccessor, NumericTypes { public Enumeration getElements( final Object target ) { return new Enumeration() { private int type = OgnlOps.getNumericType( target ); private long next = 0; private long finish = OgnlOps.longValue( target ); public boolean hasMoreElements() { return next < finish; } public Object nextElement() { if ( next >= finish ) throw new NoSuchElementException(); return OgnlOps.newInteger( type, next++ ); } }; } } ognl-2.7.3.orig/src/java/ognl/SimpleNode.java0000644000175000017500000002700310776755160020706 0ustar drazzibdrazzib// -------------------------------------------------------------------------- // Copyright (c) 1998-2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. // -------------------------------------------------------------------------- package ognl; import ognl.enhance.ExpressionAccessor; import java.io.PrintWriter; import java.io.Serializable; /** * @author Luke Blanshard (blanshlu@netscape.net) * @author Drew Davidson (drew@ognl.org) */ public abstract class SimpleNode implements Node, Serializable { protected Node _parent; protected Node[] _children; protected int _id; protected OgnlParser _parser; private boolean _constantValueCalculated; private volatile boolean _hasConstantValue; private Object _constantValue; private ExpressionAccessor _accessor; public SimpleNode(int i) { _id = i; } public SimpleNode(OgnlParser p, int i) { this(i); _parser = p; } public void jjtOpen() { } public void jjtClose() { } public void jjtSetParent(Node n) { _parent = n; } public Node jjtGetParent() { return _parent; } public void jjtAddChild(Node n, int i) { if (_children == null) { _children = new Node[i + 1]; } else if (i >= _children.length) { Node c[] = new Node[i + 1]; System.arraycopy(_children, 0, c, 0, _children.length); _children = c; } _children[i] = n; } public Node jjtGetChild(int i) { return _children[i]; } public int jjtGetNumChildren() { return (_children == null) ? 0 : _children.length; } /* * You can override these two methods in subclasses of SimpleNode to customize the way the node * appears when the tree is dumped. If your output uses more than one line you should override * toString(String), otherwise overriding toString() is probably all you need to do. */ public String toString() { return OgnlParserTreeConstants.jjtNodeName[_id]; } // OGNL additions public String toString(String prefix) { return prefix + OgnlParserTreeConstants.jjtNodeName[_id] + " " + toString(); } public String toGetSourceString(OgnlContext context, Object target) { return toString(); } public String toSetSourceString(OgnlContext context, Object target) { return toString(); } /* * Override this method if you want to customize how the node dumps out its children. */ public void dump(PrintWriter writer, String prefix) { writer.println(toString(prefix)); if (_children != null) { for (int i = 0; i < _children.length; ++i) { SimpleNode n = (SimpleNode) _children[i]; if (n != null) { n.dump(writer, prefix + " "); } } } } public int getIndexInParent() { int result = -1; if (_parent != null) { int icount = _parent.jjtGetNumChildren(); for (int i = 0; i < icount; i++) { if (_parent.jjtGetChild(i) == this) { result = i; break; } } } return result; } public Node getNextSibling() { Node result = null; int i = getIndexInParent(); if (i >= 0) { int icount = _parent.jjtGetNumChildren(); if (i < icount) { result = _parent.jjtGetChild(i + 1); } } return result; } protected Object evaluateGetValueBody(OgnlContext context, Object source) throws OgnlException { context.setCurrentObject(source); context.setCurrentNode(this); if (!_constantValueCalculated) { _constantValueCalculated = true; boolean constant = isConstant(context); if (constant) { _constantValue = getValueBody(context, source); } _hasConstantValue = constant; } return _hasConstantValue ? _constantValue : getValueBody(context, source); } protected void evaluateSetValueBody(OgnlContext context, Object target, Object value) throws OgnlException { context.setCurrentObject(target); context.setCurrentNode(this); setValueBody(context, target, value); } public final Object getValue(OgnlContext context, Object source) throws OgnlException { Object result = null; if (context.getTraceEvaluations()) { EvaluationPool pool = OgnlRuntime.getEvaluationPool(); Throwable evalException = null; Evaluation evaluation = pool.create(this, source); context.pushEvaluation(evaluation); try { result = evaluateGetValueBody(context, source); } catch (OgnlException ex) { evalException = ex; throw ex; } catch (RuntimeException ex) { evalException = ex; throw ex; } finally { Evaluation eval = context.popEvaluation(); eval.setResult(result); if (evalException != null) { eval.setException(evalException); } if ((evalException == null) && (context.getRootEvaluation() == null) && !context.getKeepLastEvaluation()) { pool.recycleAll(eval); } } } else { result = evaluateGetValueBody(context, source); } return result; } /** Subclasses implement this method to do the actual work of extracting the appropriate value from the source object. */ protected abstract Object getValueBody(OgnlContext context, Object source) throws OgnlException; public final void setValue(OgnlContext context, Object target, Object value) throws OgnlException { if (context.getTraceEvaluations()) { EvaluationPool pool = OgnlRuntime.getEvaluationPool(); Throwable evalException = null; Evaluation evaluation = pool.create(this, target, true); context.pushEvaluation(evaluation); try { evaluateSetValueBody(context, target, value); } catch (OgnlException ex) { evalException = ex; ex.setEvaluation(evaluation); throw ex; } catch (RuntimeException ex) { evalException = ex; throw ex; } finally { Evaluation eval = context.popEvaluation(); if (evalException != null) { eval.setException(evalException); } if ((evalException == null) && (context.getRootEvaluation() == null) && !context.getKeepLastEvaluation()) { pool.recycleAll(eval); } } } else { evaluateSetValueBody(context, target, value); } } /** * Subclasses implement this method to do the actual work of setting the appropriate value in the target object. The default implementation throws an * InappropriateExpressionException, meaning that it cannot be a set expression. */ protected void setValueBody(OgnlContext context, Object target, Object value) throws OgnlException { throw new InappropriateExpressionException(this); } /** Returns true iff this node is constant without respect to the children. */ public boolean isNodeConstant(OgnlContext context) throws OgnlException { return false; } public boolean isConstant(OgnlContext context) throws OgnlException { return isNodeConstant(context); } public boolean isNodeSimpleProperty(OgnlContext context) throws OgnlException { return false; } public boolean isSimpleProperty(OgnlContext context) throws OgnlException { return isNodeSimpleProperty(context); } public boolean isSimpleNavigationChain(OgnlContext context) throws OgnlException { return isSimpleProperty(context); } protected boolean lastChild(OgnlContext context) { return _parent == null || context.get("_lastChild") != null; } /** * This method may be called from subclasses' jjtClose methods. It flattens the tree under this node by eliminating any children that are of the same class as this * node and copying their children to this node. */ protected void flattenTree() { boolean shouldFlatten = false; int newSize = 0; for (int i = 0; i < _children.length; ++i) if (_children[i].getClass() == getClass()) { shouldFlatten = true; newSize += _children[i].jjtGetNumChildren(); } else ++newSize; if (shouldFlatten) { Node[] newChildren = new Node[newSize]; int j = 0; for (int i = 0; i < _children.length; ++i) { Node c = _children[i]; if (c.getClass() == getClass()) { for (int k = 0; k < c.jjtGetNumChildren(); ++k) newChildren[j++] = c.jjtGetChild(k); } else newChildren[j++] = c; } if (j != newSize) throw new Error("Assertion error: " + j + " != " + newSize); _children = newChildren; } } public ExpressionAccessor getAccessor() { return _accessor; } public void setAccessor(ExpressionAccessor accessor) { _accessor = accessor; } } ognl-2.7.3.orig/src/java/ognl/SetPropertyAccessor.java0000644000175000017500000000573710566476144022643 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 1998-2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package ognl; import java.util.Map; import java.util.Set; /** * Implementation of PropertyAccessor that uses numbers and dynamic subscripts as * properties to index into Lists. * @author Luke Blanshard (blanshlu@netscape.net) * @author Drew Davidson (drew@ognl.org) */ public class SetPropertyAccessor extends ObjectPropertyAccessor implements PropertyAccessor // This is here to make javadoc show this class as an implementor { public Object getProperty( Map context, Object target, Object name ) throws OgnlException { Set set = (Set)target; if ( name instanceof String ) { Object result; if (name.equals("size")) { result = new Integer(set.size()); } else { if (name.equals("iterator")) { result = set.iterator(); } else { if (name.equals("isEmpty")) { result = set.isEmpty() ? Boolean.TRUE : Boolean.FALSE; } else { result = super.getProperty( context, target, name ); } } } return result; } throw new NoSuchPropertyException( target, name ); } } ognl-2.7.3.orig/src/java/ognl/ObjectPropertyAccessor.java0000644000175000017500000002731410776755160023312 0ustar drazzibdrazzib// -------------------------------------------------------------------------- // Copyright (c) 1998-2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. // -------------------------------------------------------------------------- package ognl; import ognl.enhance.ExpressionCompiler; import ognl.enhance.UnsupportedCompilationException; import java.beans.IntrospectionException; import java.lang.reflect.Field; import java.lang.reflect.Method; import java.util.Map; /** * Implementation of PropertyAccessor that uses reflection on the target object's class to find a * field or a pair of set/get methods with the given property name. * * @author Luke Blanshard (blanshlu@netscape.net) * @author Drew Davidson (drew@ognl.org) */ public class ObjectPropertyAccessor implements PropertyAccessor { /** * Returns OgnlRuntime.NotFound if the property does not exist. */ public Object getPossibleProperty(Map context, Object target, String name) throws OgnlException { Object result; OgnlContext ognlContext = (OgnlContext) context; try { if ((result = OgnlRuntime.getMethodValue(ognlContext, target, name, true)) == OgnlRuntime.NotFound) { result = OgnlRuntime.getFieldValue(ognlContext, target, name, true); } } catch (IntrospectionException ex) { throw new OgnlException(name, ex); } catch (OgnlException ex) { throw ex; } catch (Exception ex) { throw new OgnlException(name, ex); } return result; } /** * Returns OgnlRuntime.NotFound if the property does not exist. */ public Object setPossibleProperty(Map context, Object target, String name, Object value) throws OgnlException { Object result = null; OgnlContext ognlContext = (OgnlContext) context; try { if (!OgnlRuntime.setMethodValue(ognlContext, target, name, value, true)) { result = OgnlRuntime.setFieldValue(ognlContext, target, name, value) ? null : OgnlRuntime.NotFound; } if (result == OgnlRuntime.NotFound) { Method m = OgnlRuntime.getWriteMethod(target.getClass(), name); if (m != null) { result = m.invoke(target, new Object[] { value}); } } } catch (IntrospectionException ex) { throw new OgnlException(name, ex); } catch (OgnlException ex) { throw ex; } catch (Exception ex) { throw new OgnlException(name, ex); } return result; } public boolean hasGetProperty(OgnlContext context, Object target, Object oname) throws OgnlException { try { return OgnlRuntime.hasGetProperty(context, target, oname); } catch (IntrospectionException ex) { throw new OgnlException("checking if " + target + " has gettable property " + oname, ex); } } public boolean hasGetProperty(Map context, Object target, Object oname) throws OgnlException { return hasGetProperty((OgnlContext) context, target, oname); } public boolean hasSetProperty(OgnlContext context, Object target, Object oname) throws OgnlException { try { return OgnlRuntime.hasSetProperty(context, target, oname); } catch (IntrospectionException ex) { throw new OgnlException("checking if " + target + " has settable property " + oname, ex); } } public boolean hasSetProperty(Map context, Object target, Object oname) throws OgnlException { return hasSetProperty((OgnlContext) context, target, oname); } public Object getProperty(Map context, Object target, Object oname) throws OgnlException { Object result = null; String name = oname.toString(); result = getPossibleProperty(context, target, name); if (result == OgnlRuntime.NotFound) { throw new NoSuchPropertyException(target, name); } return result; } public void setProperty(Map context, Object target, Object oname, Object value) throws OgnlException { String name = oname.toString(); Object result = setPossibleProperty(context, target, name, value); if (result == OgnlRuntime.NotFound) { throw new NoSuchPropertyException(target, name); } } public Class getPropertyClass(OgnlContext context, Object target, Object index) { try { Method m = OgnlRuntime.getReadMethod(target.getClass(), index.toString()); if (m == null) { if (String.class.isAssignableFrom(index.getClass()) && !target.getClass().isArray()) { String key = ((String) index).replaceAll("\"", ""); try { Field f = target.getClass().getField(key); if (f != null) { return f.getType(); } } catch (NoSuchFieldException e) { return null; } } return null; } return m.getReturnType(); } catch (Throwable t) { throw OgnlOps.castToRuntime(t); } } public String getSourceAccessor(OgnlContext context, Object target, Object index) { try { String methodName = index.toString().replaceAll("\"", ""); Method m = OgnlRuntime.getReadMethod(target.getClass(), methodName); // try last ditch effort of checking if they were trying to do reflection via a return method value if (m == null && context.getCurrentObject() != null) m = OgnlRuntime.getReadMethod(target.getClass(), context.getCurrentObject().toString().replaceAll("\"", "")); //System.out.println("tried to get read method from target: " + target.getClass() + " with methodName:" + methodName + " result: " + m); // try to get field if no method could be found if (m == null) { try { if (String.class.isAssignableFrom(index.getClass()) && !target.getClass().isArray()) { Field f = target.getClass().getField(methodName); if (f != null) { context.setCurrentType(f.getType()); context.setCurrentAccessor(f.getDeclaringClass()); return "." + f.getName(); } } } catch (NoSuchFieldException e) { // ignore } return ""; } context.setCurrentType(m.getReturnType()); context.setCurrentAccessor(OgnlRuntime.getCompiler().getSuperOrInterfaceClass(m, m.getDeclaringClass())); return "." + m.getName() + "()"; } catch (Throwable t) { throw OgnlOps.castToRuntime(t); } } public String getSourceSetter(OgnlContext context, Object target, Object index) { try { String methodName = index.toString().replaceAll("\"", ""); Method m = OgnlRuntime.getWriteMethod(target.getClass(), methodName); if (m == null && context.getCurrentObject() != null && context.getCurrentObject().toString() != null) { m = OgnlRuntime.getWriteMethod(target.getClass(), context.getCurrentObject().toString().replaceAll("\"", "")); } if (m == null || m.getParameterTypes() == null || m.getParameterTypes().length <= 0) throw new UnsupportedCompilationException("Unable to determine setting expression on " + context.getCurrentObject() + " with index of " + index); Class parm = m.getParameterTypes()[0]; String conversion; if (m.getParameterTypes().length > 1) throw new UnsupportedCompilationException("Object property accessors can only support single parameter setters."); if (parm.isPrimitive()) { Class wrapClass = OgnlRuntime.getPrimitiveWrapperClass(parm); conversion = OgnlRuntime.getCompiler().createLocalReference(context, "((" + wrapClass.getName() + ")ognl.OgnlOps#convertValue($3," + wrapClass.getName() + ".class, true))." + OgnlRuntime.getNumericValueGetter(wrapClass), parm); } else if (parm.isArray()) { conversion = OgnlRuntime.getCompiler().createLocalReference(context, "(" + ExpressionCompiler.getCastString(parm) + ")ognl.OgnlOps#toArray($3," + parm.getComponentType().getName() + ".class)", parm); } else { conversion = OgnlRuntime.getCompiler().createLocalReference(context, "(" + parm.getName()+ ")ognl.OgnlOps#convertValue($3," + parm.getName() + ".class)", parm); } context.setCurrentType(m.getReturnType()); context.setCurrentAccessor(OgnlRuntime.getCompiler().getSuperOrInterfaceClass(m, m.getDeclaringClass())); return "." + m.getName() + "(" + conversion + ")"; } catch (Throwable t) { throw OgnlOps.castToRuntime(t); } } } ognl-2.7.3.orig/src/java/ognl/ognl.jjt0000644000175000017500000004460710561411075017447 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 1998-2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- /* * This file defines the syntax of OGNL, the Object-Graph Navigation Language. This * language was devised by Drew Davidson, who called it Key-Value Coding Language. Luke * Blanshard then made up the new name and reimplemented it using ANTLR, refining and * polishing the language a bit on the way. Drew maintained the system for a couple of * years; then Luke converted the ANTLR grammar to JavaCC, to eliminate the run-time * dependency on ANTLR. * * See package.html for a description of the language. */ options { // Parser options LOOKAHEAD = 1; STATIC = false; JAVA_UNICODE_ESCAPE = true; UNICODE_INPUT = true; // Tree options MULTI = true; NODE_DEFAULT_VOID = true; } PARSER_BEGIN(OgnlParser) package ognl; import java.math.*; /** * OgnlParser is a JavaCC parser class; it translates OGNL expressions into abstract * syntax trees (ASTs) that can then be interpreted by the getValue and setValue methods. */ public class OgnlParser { } PARSER_END(OgnlParser) /** * This is the top-level construct of OGNL. */ Node topLevelExpression() : {} { expression() { return jjtree.rootNode(); } } // sequence (level 14) void expression() : {} { assignmentExpression() ( "," assignmentExpression() #Sequence(2) )* } // assignment expression (level 13) void assignmentExpression() : {} { conditionalTestExpression() [ "=" assignmentExpression() #Assign(2) ] } // conditional test (level 12) void conditionalTestExpression() : {} { logicalOrExpression() [ "?" conditionalTestExpression() ":" conditionalTestExpression() #Test(3) ] } // logical or (||) (level 11) void logicalOrExpression() : {} { logicalAndExpression() (("||" | "or") logicalAndExpression() #Or(2) )* } // logical and (&&) (level 10) void logicalAndExpression() : {} { inclusiveOrExpression() (("&&" | "and") inclusiveOrExpression() #And(2) )* } // bitwise or non-short-circuiting or (|) (level 9) void inclusiveOrExpression() : {} { exclusiveOrExpression() (("|" | "bor") exclusiveOrExpression() #BitOr(2) )* } // exclusive or (^) (level 8) void exclusiveOrExpression() : {} { andExpression() (("^" | "xor") andExpression() #Xor(2) )* } // bitwise or non-short-circuiting and (&) (level 7) void andExpression() : {} { equalityExpression() (("&" | "band") equalityExpression() #BitAnd(2) )* } // equality/inequality (==/!=) (level 6) void equalityExpression() : {} { relationalExpression() ( ("==" | "eq") relationalExpression() #Eq(2) | ("!=" | "neq") relationalExpression() #NotEq(2) )* } // boolean relational expressions (level 5) void relationalExpression() : {} { shiftExpression() ( ("<" | "lt") shiftExpression() #Less(2) | (">" | "gt") shiftExpression() #Greater(2) | ("<=" | "lte") shiftExpression() #LessEq(2) | (">=" | "gte") shiftExpression() #GreaterEq(2) | "in" shiftExpression() #In(2) | "not" "in" shiftExpression() #NotIn(2) )* } // bit shift expressions (level 4) void shiftExpression() : {} { additiveExpression() ( ("<<" | "shl") additiveExpression() #ShiftLeft(2) | (">>" | "shr") additiveExpression() #ShiftRight(2) | (">>>" | "ushr") additiveExpression() #UnsignedShiftRight(2) )* } // binary addition/subtraction (level 3) void additiveExpression() : {} { multiplicativeExpression() ( "+" multiplicativeExpression() #Add(2) | "-" multiplicativeExpression() #Subtract(2) )* } // multiplication/division/remainder (level 2) void multiplicativeExpression() : {} { unaryExpression() ( "*" unaryExpression() #Multiply(2) | "/" unaryExpression() #Divide(2) | "%" unaryExpression() #Remainder(2) )* } // unary (level 1) void unaryExpression() : { StringBuffer sb; Token t; ASTInstanceof ionode; } { ( "-" unaryExpression() #Negate(1) | "+" unaryExpression() // Just leave it there | "~" unaryExpression() #BitNegate(1) | ("!" | "not") unaryExpression() #Not(1) | navigationChain() [ "instanceof" t = { sb = new StringBuffer(t.image); ionode = jjtThis; } #Instanceof(1) ( "." t = { sb.append('.').append( t.image ); } )* { ionode.setTargetType( new String(sb) ); } ] ) } // navigation chain: property references, method calls, projections, selections, etc. void navigationChain() : {} { primaryExpression() ( "." ( /* Prevent the "eval" ambiguity from issuing a warning; see discussion below. */ ( LOOKAHEAD(2) methodCall() | propertyName() ) // Also handle "{", which requires a lookahead of 2. | ( LOOKAHEAD(2) projection() | selection() ) | "(" expression() ")" ) #Chain(2) | index() #Chain(2) | "(" expression() ")" #Eval(2) /* Using parentheses to indicate evaluation of the current object makes this language ambiguous, because the expression "ident(args)" could be seen as a single method call or as a property name followed by an evaluation. We always put the method call first and turn off the ambiguity warning; we always want to interpret this as a method call. */ )* } void primaryExpression() : { Token t; String className = null; } { ( ( | | | | ) { jjtThis.setValue( token_source.literalValue ); } #Const(0) | "true" { jjtThis.setValue( Boolean.TRUE ); } #Const(0) | "false" { jjtThis.setValue( Boolean.FALSE ); } #Const(0) | "null" #Const(0) // Null is the default value in an ASTConst | LOOKAHEAD(2) "#this" { jjtThis.setName( "this" ); } #ThisVarRef(0) | LOOKAHEAD(2) "#root" { jjtThis.setName( "root" ); } #RootVarRef(0) | LOOKAHEAD(2) "#" t= { jjtThis.setName( t.image ); } #VarRef(0) | LOOKAHEAD(2) ":" "[" expression() "]" { jjtThis.setValue( jjtThis.jjtGetChild(0) ); } #Const(1) | staticReference() | LOOKAHEAD(2) constructorCall() | // Prevent the "eval" ambiguity from issuing a warning; see discussion elsewhere. ( LOOKAHEAD(2) methodCall() | propertyName() ) | index() | "(" expression() ")" | "{" [assignmentExpression() ("," assignmentExpression())*] #List "}" | LOOKAHEAD(2) ( "#" (className=classReference())? "{" [keyValueExpression() ("," keyValueExpression())*] { jjtThis.setClassName(className); } "}" ) #Map ) } void keyValueExpression() : {} { ( assignmentExpression() (":" assignmentExpression())? ) #KeyValue } void staticReference() : { String className = "java.lang.Math"; Token t; } { className=classReference() ( // Prevent the "eval" ambiguity from issuing a warning; see discussion elsewhere. LOOKAHEAD(2) staticMethodCall( className ) | t= { jjtThis.init( className, t.image ); } #StaticField(0) ) } String classReference(): { String result = "java.lang.Math"; } { "@" ( result=className() )? "@" { return result; } } String className(): { Token t; StringBuffer result; } { t= { result = new StringBuffer( t.image ); } ( "." t= { result.append('.').append( t.image ); } )* { return new String(result); } } void constructorCall() #Ctor : { String className; Token t; StringBuffer sb; } { "new" className=className() ( LOOKAHEAD(2) ( "(" [ assignmentExpression() ( "," assignmentExpression() )* ] ")" { jjtThis.setClassName(className); } ) | LOOKAHEAD(2) ( "[" "]" "{" [assignmentExpression() ("," assignmentExpression())*] #List "}" { jjtThis.setClassName(className); jjtThis.setArray(true); } ) | LOOKAHEAD(2) ( "[" assignmentExpression() "]" { jjtThis.setClassName(className); jjtThis.setArray(true); } ) ) } void propertyName() #Property : { Token t; } { t= { jjtThis.setValue( t.image ); } #Const } void staticMethodCall( String className ) #StaticMethod : { Token t; } { t= "(" [ assignmentExpression() ( "," assignmentExpression() )* ] ")" { jjtThis.init( className, t.image ); } } void methodCall() #Method : { Token t; } { t= "(" [ assignmentExpression() ( "," assignmentExpression() )* ] ")" { jjtThis.setMethodName( t.image ); } } /** * Apply an expression to all elements of a collection, creating a new collection * as the result. */ void projection() #Project : {} { "{" expression() "}" } void selection() : {} { LOOKAHEAD(2) selectAll() | LOOKAHEAD(2) selectFirst() | LOOKAHEAD(2) selectLast() } /** * Apply a boolean expression to all elements of a collection, creating a new collection * containing those elements for which the expression returned true. */ void selectAll() #Select : {} { "{" "?" expression() "}" } /** * Apply a boolean expression to all elements of a collection, creating a new collection * containing those elements for the first element for which the expression returned true. */ void selectFirst() #SelectFirst : {} { "{" "^" expression() "}" } /** * Apply a boolean expression to all elements of a collection, creating a new collection * containing those elements for the first element for which the expression returned true. */ void selectLast() #SelectLast : {} { "{" "$" expression() "}" } void index() #Property : {} { "[" expression() "]" { jjtThis.setIndexedAccess(true); } | { jjtThis.setValue( token_source.literalValue ); } #Const { jjtThis.setIndexedAccess(true); } } // LEXER PRODUCTIONS TOKEN_MGR_DECLS: { /** Holds the last value computed by a constant token. */ Object literalValue; /** Holds the last character escaped or in a character literal. */ private char charValue; /** Holds char literal start token. */ private char charLiteralStartQuote; /** Holds the last string literal parsed. */ private StringBuffer stringBuffer; /** Converts an escape sequence into a character value. */ private char escapeChar() { int ofs = image.length() - 1; switch ( image.charAt(ofs) ) { case 'n': return '\n'; case 'r': return '\r'; case 't': return '\t'; case 'b': return '\b'; case 'f': return '\f'; case '\\': return '\\'; case '\'': return '\''; case '\"': return '\"'; } // Otherwise, it's an octal number. Find the backslash and convert. while ( image.charAt(--ofs) != '\\' ) {} int value = 0; while ( ++ofs < image.length() ) value = (value << 3) | (image.charAt(ofs) - '0'); return (char) value; } private Object makeInt() { Object result; String s = image.toString(); int base = 10; if ( s.charAt(0) == '0' ) base = (s.length() > 1 && (s.charAt(1) == 'x' || s.charAt(1) == 'X'))? 16 : 8; if ( base == 16 ) s = s.substring(2); // Trim the 0x off the front switch ( s.charAt(s.length()-1) ) { case 'l': case 'L': result = Long.valueOf( s.substring(0,s.length()-1), base ); break; case 'h': case 'H': result = new BigInteger( s.substring(0,s.length()-1), base ); break; default: result = Integer.valueOf( s, base ); break; } return result; } private Object makeFloat() { String s = image.toString(); switch ( s.charAt(s.length()-1) ) { case 'f': case 'F': return Float.valueOf( s ); case 'b': case 'B': return new BigDecimal( s.substring(0,s.length()-1) ); case 'd': case 'D': default: return Double.valueOf( s ); } } } // Whitespace -- ignored SKIP: { " " | "\t" | "\f" | "\r" | "\n" } // An identifier. TOKEN: { < IDENT: (|)* > | < #LETTER: [ "\u0024", "\u0041"-"\u005a", "\u005f", "\u0061"-"\u007a", "\u00c0"-"\u00d6", "\u00d8"-"\u00f6", "\u00f8"-"\u00ff", "\u0100"-"\u1fff", "\u3040"-"\u318f", "\u3300"-"\u337f", "\u3400"-"\u3d2d", "\u4e00"-"\u9fff", "\uf900"-"\ufaff" ] > | < #DIGIT: [ "\u0030"-"\u0039", "\u0660"-"\u0669", "\u06f0"-"\u06f9", "\u0966"-"\u096f", "\u09e6"-"\u09ef", "\u0a66"-"\u0a6f", "\u0ae6"-"\u0aef", "\u0b66"-"\u0b6f", "\u0be7"-"\u0bef", "\u0c66"-"\u0c6f", "\u0ce6"-"\u0cef", "\u0d66"-"\u0d6f", "\u0e50"-"\u0e59", "\u0ed0"-"\u0ed9", "\u1040"-"\u1049" ] > } /** * Token for "dynamic subscripts", which are one of: [^], [|], [$], and [*]. The * appropriate constant from the DynamicSubscript class is stored in the token manager's * "value" field. */ TOKEN: { < DYNAMIC_SUBSCRIPT: "[" ["^","|","$","*"] "]" > { switch (image.charAt(1)) { case '^': literalValue = DynamicSubscript.first; break; case '|': literalValue = DynamicSubscript.mid; break; case '$': literalValue = DynamicSubscript.last; break; case '*': literalValue = DynamicSubscript.all; break; } } } /** * Character and string literals, whose object value is stored in the token manager's * "literalValue" field. */ MORE: { "`" : WithinBackCharLiteral | "'" { stringBuffer = new StringBuffer(); }: WithinCharLiteral | "\"" { stringBuffer = new StringBuffer(); }: WithinStringLiteral } MORE: { < ESC: "\\" ( ["n","r","t","b","f","\\","'","`","\""] | (["0"-"3"])? ["0"-"7"] (["0"-"7"])? ) > { charValue = escapeChar(); stringBuffer.append(charValue); } | < (~["'","\\"]) > { charValue = image.charAt( image.length()-1 ); stringBuffer.append(charValue); } } TOKEN: { < CHAR_LITERAL: "'"> { if (stringBuffer.length() == 1) { literalValue = new Character( charValue ); } else { literalValue = new String( stringBuffer ); } } : DEFAULT } MORE: { < BACK_CHAR_ESC: > { charValue = escapeChar(); } | < (~["`","\\"]) > { charValue = image.charAt( image.length()-1 ); } } TOKEN: { < BACK_CHAR_LITERAL: "`"> { literalValue = new Character( charValue ); }: DEFAULT } MORE: { < STRING_ESC: > { stringBuffer.append( escapeChar() ); } | < (~["\"","\\"]) > { stringBuffer.append( image.charAt(image.length()-1) ); } } TOKEN: { { literalValue = new String( stringBuffer ); } : DEFAULT } /** * Integer or real Numeric literal, whose object value is stored in the token manager's * "literalValue" field. */ TOKEN: { < INT_LITERAL: ( "0" (["0"-"7"])* | ["1"-"9"] (["0"-"9"])* | "0" ["x","X"] (["0"-"9","a"-"f","A"-"F"])+ ) (["l","L","h","H"])? > { literalValue = makeInt(); } | < FLT_LITERAL: ( ()? ()? | ()? | ) > { literalValue = makeFloat(); } | < #DEC_FLT: (["0"-"9"])+ "." (["0"-"9"])* | "." (["0"-"9"])+ > | < #DEC_DIGITS: (["0"-"9"])+ > | < #EXPONENT: ["e","E"] (["+","-"])? (["0"-"9"])+ > | < #FLT_SUFF: ["d","D","f","F","b","B"] > } ognl-2.7.3.orig/src/java/ognl/JavaCharStream.java0000644000175000017500000003550310746450726021503 0ustar drazzibdrazzib/* Generated By:JavaCC: Do not edit this line. JavaCharStream.java Version 4.1 */ /* JavaCCOptions:STATIC=false */ package ognl; /** * An implementation of interface CharStream, where the stream is assumed to * contain only ASCII characters (with java-like unicode escape processing). */ public class JavaCharStream { /** Whether parser is static. */ public static final boolean staticFlag = false; static final int hexval(char c) throws java.io.IOException { switch(c) { case '0' : return 0; case '1' : return 1; case '2' : return 2; case '3' : return 3; case '4' : return 4; case '5' : return 5; case '6' : return 6; case '7' : return 7; case '8' : return 8; case '9' : return 9; case 'a' : case 'A' : return 10; case 'b' : case 'B' : return 11; case 'c' : case 'C' : return 12; case 'd' : case 'D' : return 13; case 'e' : case 'E' : return 14; case 'f' : case 'F' : return 15; } throw new java.io.IOException(); // Should never come here } /** Position in buffer. */ public int bufpos = -1; int bufsize; int available; int tokenBegin; protected int bufline[]; protected int bufcolumn[]; protected int column = 0; protected int line = 1; protected boolean prevCharIsCR = false; protected boolean prevCharIsLF = false; protected java.io.Reader inputStream; protected char[] nextCharBuf; protected char[] buffer; protected int maxNextCharInd = 0; protected int nextCharInd = -1; protected int inBuf = 0; protected int tabSize = 8; protected void setTabSize(int i) { tabSize = i; } protected int getTabSize(int i) { return tabSize; } protected void ExpandBuff(boolean wrapAround) { char[] newbuffer = new char[bufsize + 2048]; int newbufline[] = new int[bufsize + 2048]; int newbufcolumn[] = new int[bufsize + 2048]; try { if (wrapAround) { System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin); System.arraycopy(buffer, 0, newbuffer, bufsize - tokenBegin, bufpos); buffer = newbuffer; System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin); System.arraycopy(bufline, 0, newbufline, bufsize - tokenBegin, bufpos); bufline = newbufline; System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin); System.arraycopy(bufcolumn, 0, newbufcolumn, bufsize - tokenBegin, bufpos); bufcolumn = newbufcolumn; bufpos += (bufsize - tokenBegin); } else { System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin); buffer = newbuffer; System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin); bufline = newbufline; System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin); bufcolumn = newbufcolumn; bufpos -= tokenBegin; } } catch (Throwable t) { throw new Error(t.getMessage()); } available = (bufsize += 2048); tokenBegin = 0; } protected void FillBuff() throws java.io.IOException { int i; if (maxNextCharInd == 4096) maxNextCharInd = nextCharInd = 0; try { if ((i = inputStream.read(nextCharBuf, maxNextCharInd, 4096 - maxNextCharInd)) == -1) { inputStream.close(); throw new java.io.IOException(); } else maxNextCharInd += i; return; } catch(java.io.IOException e) { if (bufpos != 0) { --bufpos; backup(0); } else { bufline[bufpos] = line; bufcolumn[bufpos] = column; } throw e; } } protected char ReadByte() throws java.io.IOException { if (++nextCharInd >= maxNextCharInd) FillBuff(); return nextCharBuf[nextCharInd]; } /** @return starting character for token. */ public char BeginToken() throws java.io.IOException { if (inBuf > 0) { --inBuf; if (++bufpos == bufsize) bufpos = 0; tokenBegin = bufpos; return buffer[bufpos]; } tokenBegin = 0; bufpos = -1; return readChar(); } protected void AdjustBuffSize() { if (available == bufsize) { if (tokenBegin > 2048) { bufpos = 0; available = tokenBegin; } else ExpandBuff(false); } else if (available > tokenBegin) available = bufsize; else if ((tokenBegin - available) < 2048) ExpandBuff(true); else available = tokenBegin; } protected void UpdateLineColumn(char c) { column++; if (prevCharIsLF) { prevCharIsLF = false; line += (column = 1); } else if (prevCharIsCR) { prevCharIsCR = false; if (c == '\n') { prevCharIsLF = true; } else line += (column = 1); } switch (c) { case '\r' : prevCharIsCR = true; break; case '\n' : prevCharIsLF = true; break; case '\t' : column--; column += (tabSize - (column % tabSize)); break; default : break; } bufline[bufpos] = line; bufcolumn[bufpos] = column; } /** Read a character. */ public char readChar() throws java.io.IOException { if (inBuf > 0) { --inBuf; if (++bufpos == bufsize) bufpos = 0; return buffer[bufpos]; } char c; if (++bufpos == available) AdjustBuffSize(); if ((buffer[bufpos] = c = ReadByte()) == '\\') { UpdateLineColumn(c); int backSlashCnt = 1; for (;;) // Read all the backslashes { if (++bufpos == available) AdjustBuffSize(); try { if ((buffer[bufpos] = c = ReadByte()) != '\\') { UpdateLineColumn(c); // found a non-backslash char. if ((c == 'u') && ((backSlashCnt & 1) == 1)) { if (--bufpos < 0) bufpos = bufsize - 1; break; } backup(backSlashCnt); return '\\'; } } catch(java.io.IOException e) { if (backSlashCnt > 1) backup(backSlashCnt-1); return '\\'; } UpdateLineColumn(c); backSlashCnt++; } // Here, we have seen an odd number of backslash's followed by a 'u' try { while ((c = ReadByte()) == 'u') ++column; buffer[bufpos] = c = (char)(hexval(c) << 12 | hexval(ReadByte()) << 8 | hexval(ReadByte()) << 4 | hexval(ReadByte())); column += 4; } catch(java.io.IOException e) { throw new Error("Invalid escape character at line " + line + " column " + column + "."); } if (backSlashCnt == 1) return c; else { backup(backSlashCnt - 1); return '\\'; } } else { UpdateLineColumn(c); return c; } } /** * @deprecated * @see #getEndColumn */ public int getColumn() { return bufcolumn[bufpos]; } /** * @deprecated * @see #getEndLine */ public int getLine() { return bufline[bufpos]; } /** Get end column. */ public int getEndColumn() { return bufcolumn[bufpos]; } /** Get end line. */ public int getEndLine() { return bufline[bufpos]; } /** @return column of token start */ public int getBeginColumn() { return bufcolumn[tokenBegin]; } /** @return line number of token start */ public int getBeginLine() { return bufline[tokenBegin]; } /** Retreat. */ public void backup(int amount) { inBuf += amount; if ((bufpos -= amount) < 0) bufpos += bufsize; } /** Constructor. */ public JavaCharStream(java.io.Reader dstream, int startline, int startcolumn, int buffersize) { inputStream = dstream; line = startline; column = startcolumn - 1; available = bufsize = buffersize; buffer = new char[buffersize]; bufline = new int[buffersize]; bufcolumn = new int[buffersize]; nextCharBuf = new char[4096]; } /** Constructor. */ public JavaCharStream(java.io.Reader dstream, int startline, int startcolumn) { this(dstream, startline, startcolumn, 4096); } /** Constructor. */ public JavaCharStream(java.io.Reader dstream) { this(dstream, 1, 1, 4096); } /** Reinitialise. */ public void ReInit(java.io.Reader dstream, int startline, int startcolumn, int buffersize) { inputStream = dstream; line = startline; column = startcolumn - 1; if (buffer == null || buffersize != buffer.length) { available = bufsize = buffersize; buffer = new char[buffersize]; bufline = new int[buffersize]; bufcolumn = new int[buffersize]; nextCharBuf = new char[4096]; } prevCharIsLF = prevCharIsCR = false; tokenBegin = inBuf = maxNextCharInd = 0; nextCharInd = bufpos = -1; } /** Reinitialise. */ public void ReInit(java.io.Reader dstream, int startline, int startcolumn) { ReInit(dstream, startline, startcolumn, 4096); } /** Reinitialise. */ public void ReInit(java.io.Reader dstream) { ReInit(dstream, 1, 1, 4096); } /** Constructor. */ public JavaCharStream(java.io.InputStream dstream, String encoding, int startline, int startcolumn, int buffersize) throws java.io.UnsupportedEncodingException { this(encoding == null ? new java.io.InputStreamReader(dstream) : new java.io.InputStreamReader(dstream, encoding), startline, startcolumn, buffersize); } /** Constructor. */ public JavaCharStream(java.io.InputStream dstream, int startline, int startcolumn, int buffersize) { this(new java.io.InputStreamReader(dstream), startline, startcolumn, 4096); } /** Constructor. */ public JavaCharStream(java.io.InputStream dstream, String encoding, int startline, int startcolumn) throws java.io.UnsupportedEncodingException { this(dstream, encoding, startline, startcolumn, 4096); } /** Constructor. */ public JavaCharStream(java.io.InputStream dstream, int startline, int startcolumn) { this(dstream, startline, startcolumn, 4096); } /** Constructor. */ public JavaCharStream(java.io.InputStream dstream, String encoding) throws java.io.UnsupportedEncodingException { this(dstream, encoding, 1, 1, 4096); } /** Constructor. */ public JavaCharStream(java.io.InputStream dstream) { this(dstream, 1, 1, 4096); } /** Reinitialise. */ public void ReInit(java.io.InputStream dstream, String encoding, int startline, int startcolumn, int buffersize) throws java.io.UnsupportedEncodingException { ReInit(encoding == null ? new java.io.InputStreamReader(dstream) : new java.io.InputStreamReader(dstream, encoding), startline, startcolumn, buffersize); } /** Reinitialise. */ public void ReInit(java.io.InputStream dstream, int startline, int startcolumn, int buffersize) { ReInit(new java.io.InputStreamReader(dstream), startline, startcolumn, buffersize); } /** Reinitialise. */ public void ReInit(java.io.InputStream dstream, String encoding, int startline, int startcolumn) throws java.io.UnsupportedEncodingException { ReInit(dstream, encoding, startline, startcolumn, 4096); } /** Reinitialise. */ public void ReInit(java.io.InputStream dstream, int startline, int startcolumn) { ReInit(dstream, startline, startcolumn, 4096); } /** Reinitialise. */ public void ReInit(java.io.InputStream dstream, String encoding) throws java.io.UnsupportedEncodingException { ReInit(dstream, encoding, 1, 1, 4096); } /** Reinitialise. */ public void ReInit(java.io.InputStream dstream) { ReInit(dstream, 1, 1, 4096); } /** @return token image as String */ public String GetImage() { if (bufpos >= tokenBegin) return new String(buffer, tokenBegin, bufpos - tokenBegin + 1); else return new String(buffer, tokenBegin, bufsize - tokenBegin) + new String(buffer, 0, bufpos + 1); } /** @return suffix */ public char[] GetSuffix(int len) { char[] ret = new char[len]; if ((bufpos + 1) >= len) System.arraycopy(buffer, bufpos - len + 1, ret, 0, len); else { System.arraycopy(buffer, bufsize - (len - bufpos - 1), ret, 0, len - bufpos - 1); System.arraycopy(buffer, 0, ret, len - bufpos - 1, bufpos + 1); } return ret; } /** Set buffers back to null when finished. */ public void Done() { nextCharBuf = null; buffer = null; bufline = null; bufcolumn = null; } /** * Method to adjust line and column numbers for the start of a token. */ public void adjustBeginLineColumn(int newLine, int newCol) { int start = tokenBegin; int len; if (bufpos >= tokenBegin) { len = bufpos - tokenBegin + inBuf + 1; } else { len = bufsize - tokenBegin + bufpos + 1 + inBuf; } int i = 0, j = 0, k = 0; int nextColDiff = 0, columnDiff = 0; while (i < len && bufline[j = start % bufsize] == bufline[k = ++start % bufsize]) { bufline[j] = newLine; nextColDiff = columnDiff + bufcolumn[k] - bufcolumn[j]; bufcolumn[j] = newCol + columnDiff; columnDiff = nextColDiff; i++; } if (i < len) { bufline[j] = newLine++; bufcolumn[j] = newCol + columnDiff; while (i++ < len) { if (bufline[j = start % bufsize] != bufline[++start % bufsize]) bufline[j] = newLine++; else bufline[j] = newLine; } } line = bufline[j]; column = bufcolumn[j]; } } /* JavaCC - OriginalChecksum=7ef64849e2b59fe6d1ffdca3bf0ddd2b (do not edit this line) */ ognl-2.7.3.orig/src/java/ognl/ASTShiftRight.java0000644000175000017500000000455110566476144021274 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 1998-2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package ognl; /** * @author Luke Blanshard (blanshlu@netscape.net) * @author Drew Davidson (drew@ognl.org) */ class ASTShiftRight extends NumericExpression { public ASTShiftRight(int id) { super(id); } public ASTShiftRight(OgnlParser p, int id) { super(p, id); } protected Object getValueBody( OgnlContext context, Object source ) throws OgnlException { Object v1 = _children[0].getValue( context, source ); Object v2 = _children[1].getValue( context, source ); return OgnlOps.shiftRight( v1, v2 ); } public String getExpressionOperator(int index) { return ">>"; } } ognl-2.7.3.orig/src/java/ognl/ASTIn.java0000644000175000017500000000704710720374205017555 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 1998-2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package ognl; import ognl.enhance.UnsupportedCompilationException; /** * @author Luke Blanshard (blanshlu@netscape.net) * @author Drew Davidson (drew@ognl.org) */ class ASTIn extends SimpleNode implements NodeType { public ASTIn(int id) { super(id); } public ASTIn(OgnlParser p, int id) { super(p, id); } protected Object getValueBody( OgnlContext context, Object source ) throws OgnlException { Object v1 = _children[0].getValue( context, source ); Object v2 = _children[1].getValue( context, source ); return OgnlOps.in( v1, v2 )? Boolean.TRUE : Boolean.FALSE; } public String toString() { return _children[0] + " in " + _children[1]; } public Class getGetterClass() { return Boolean.TYPE; } public Class getSetterClass() { return null; } public String toGetSourceString(OgnlContext context, Object target) { try { String result = "ognl.OgnlOps.in( ($w) "; result += OgnlRuntime.getChildSource(context, target, _children[0]) + ", ($w) " + OgnlRuntime.getChildSource(context, target, _children[1]); result += ")"; context.setCurrentType(Boolean.TYPE); return result; } catch (NullPointerException e) { // expected to happen in some instances e.printStackTrace(); throw new UnsupportedCompilationException("evaluation resulted in null expression."); } catch (Throwable t) { throw OgnlOps.castToRuntime(t); } } public String toSetSourceString(OgnlContext context, Object target) { throw new UnsupportedCompilationException("Map expressions not supported as native java yet."); } } ognl-2.7.3.orig/src/java/ognl/OgnlParser.java0000644000175000017500000030546310746450726020731 0ustar drazzibdrazzib/* Generated By:JJTree&JavaCC: Do not edit this line. OgnlParser.java */ package ognl; /** * OgnlParser is a JavaCC parser class; it translates OGNL expressions into abstract * syntax trees (ASTs) that can then be interpreted by the getValue and setValue methods. */ public class OgnlParser/*@bgen(jjtree)*/implements OgnlParserTreeConstants, OgnlParserConstants {/*@bgen(jjtree)*/ protected JJTOgnlParserState jjtree = new JJTOgnlParserState(); /** * This is the top-level construct of OGNL. */ final public Node topLevelExpression() throws ParseException { expression(); jj_consume_token(0); {if (true) return jjtree.rootNode();} throw new Error("Missing return statement in function"); } // sequence (level 14) final public void expression() throws ParseException { assignmentExpression(); label_1: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 1: ; break; default: jj_la1[0] = jj_gen; break label_1; } jj_consume_token(1); ASTSequence jjtn001 = new ASTSequence(JJTSEQUENCE); boolean jjtc001 = true; jjtree.openNodeScope(jjtn001); try { assignmentExpression(); } catch (Throwable jjte001) { if (jjtc001) { jjtree.clearNodeScope(jjtn001); jjtc001 = false; } else { jjtree.popNode(); } if (jjte001 instanceof RuntimeException) { {if (true) throw (RuntimeException)jjte001;} } if (jjte001 instanceof ParseException) { {if (true) throw (ParseException)jjte001;} } {if (true) throw (Error)jjte001;} } finally { if (jjtc001) { jjtree.closeNodeScope(jjtn001, 2); } } } } // assignment expression (level 13) final public void assignmentExpression() throws ParseException { conditionalTestExpression(); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 2: jj_consume_token(2); ASTAssign jjtn001 = new ASTAssign(JJTASSIGN); boolean jjtc001 = true; jjtree.openNodeScope(jjtn001); try { assignmentExpression(); } catch (Throwable jjte001) { if (jjtc001) { jjtree.clearNodeScope(jjtn001); jjtc001 = false; } else { jjtree.popNode(); } if (jjte001 instanceof RuntimeException) { {if (true) throw (RuntimeException)jjte001;} } if (jjte001 instanceof ParseException) { {if (true) throw (ParseException)jjte001;} } {if (true) throw (Error)jjte001;} } finally { if (jjtc001) { jjtree.closeNodeScope(jjtn001, 2); } } break; default: jj_la1[1] = jj_gen; ; } } // conditional test (level 12) final public void conditionalTestExpression() throws ParseException { logicalOrExpression(); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 3: jj_consume_token(3); conditionalTestExpression(); jj_consume_token(4); ASTTest jjtn001 = new ASTTest(JJTTEST); boolean jjtc001 = true; jjtree.openNodeScope(jjtn001); try { conditionalTestExpression(); } catch (Throwable jjte001) { if (jjtc001) { jjtree.clearNodeScope(jjtn001); jjtc001 = false; } else { jjtree.popNode(); } if (jjte001 instanceof RuntimeException) { {if (true) throw (RuntimeException)jjte001;} } if (jjte001 instanceof ParseException) { {if (true) throw (ParseException)jjte001;} } {if (true) throw (Error)jjte001;} } finally { if (jjtc001) { jjtree.closeNodeScope(jjtn001, 3); } } break; default: jj_la1[2] = jj_gen; ; } } // logical or (||) (level 11) final public void logicalOrExpression() throws ParseException { logicalAndExpression(); label_2: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 5: case 6: ; break; default: jj_la1[3] = jj_gen; break label_2; } switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 5: jj_consume_token(5); break; case 6: jj_consume_token(6); break; default: jj_la1[4] = jj_gen; jj_consume_token(-1); throw new ParseException(); } ASTOr jjtn001 = new ASTOr(JJTOR); boolean jjtc001 = true; jjtree.openNodeScope(jjtn001); try { logicalAndExpression(); } catch (Throwable jjte001) { if (jjtc001) { jjtree.clearNodeScope(jjtn001); jjtc001 = false; } else { jjtree.popNode(); } if (jjte001 instanceof RuntimeException) { {if (true) throw (RuntimeException)jjte001;} } if (jjte001 instanceof ParseException) { {if (true) throw (ParseException)jjte001;} } {if (true) throw (Error)jjte001;} } finally { if (jjtc001) { jjtree.closeNodeScope(jjtn001, 2); } } } } // logical and (&&) (level 10) final public void logicalAndExpression() throws ParseException { inclusiveOrExpression(); label_3: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 7: case 8: ; break; default: jj_la1[5] = jj_gen; break label_3; } switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 7: jj_consume_token(7); break; case 8: jj_consume_token(8); break; default: jj_la1[6] = jj_gen; jj_consume_token(-1); throw new ParseException(); } ASTAnd jjtn001 = new ASTAnd(JJTAND); boolean jjtc001 = true; jjtree.openNodeScope(jjtn001); try { inclusiveOrExpression(); } catch (Throwable jjte001) { if (jjtc001) { jjtree.clearNodeScope(jjtn001); jjtc001 = false; } else { jjtree.popNode(); } if (jjte001 instanceof RuntimeException) { {if (true) throw (RuntimeException)jjte001;} } if (jjte001 instanceof ParseException) { {if (true) throw (ParseException)jjte001;} } {if (true) throw (Error)jjte001;} } finally { if (jjtc001) { jjtree.closeNodeScope(jjtn001, 2); } } } } // bitwise or non-short-circuiting or (|) (level 9) final public void inclusiveOrExpression() throws ParseException { exclusiveOrExpression(); label_4: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 9: case 10: ; break; default: jj_la1[7] = jj_gen; break label_4; } switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 9: jj_consume_token(9); break; case 10: jj_consume_token(10); break; default: jj_la1[8] = jj_gen; jj_consume_token(-1); throw new ParseException(); } ASTBitOr jjtn001 = new ASTBitOr(JJTBITOR); boolean jjtc001 = true; jjtree.openNodeScope(jjtn001); try { exclusiveOrExpression(); } catch (Throwable jjte001) { if (jjtc001) { jjtree.clearNodeScope(jjtn001); jjtc001 = false; } else { jjtree.popNode(); } if (jjte001 instanceof RuntimeException) { {if (true) throw (RuntimeException)jjte001;} } if (jjte001 instanceof ParseException) { {if (true) throw (ParseException)jjte001;} } {if (true) throw (Error)jjte001;} } finally { if (jjtc001) { jjtree.closeNodeScope(jjtn001, 2); } } } } // exclusive or (^) (level 8) final public void exclusiveOrExpression() throws ParseException { andExpression(); label_5: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 11: case 12: ; break; default: jj_la1[9] = jj_gen; break label_5; } switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 11: jj_consume_token(11); break; case 12: jj_consume_token(12); break; default: jj_la1[10] = jj_gen; jj_consume_token(-1); throw new ParseException(); } ASTXor jjtn001 = new ASTXor(JJTXOR); boolean jjtc001 = true; jjtree.openNodeScope(jjtn001); try { andExpression(); } catch (Throwable jjte001) { if (jjtc001) { jjtree.clearNodeScope(jjtn001); jjtc001 = false; } else { jjtree.popNode(); } if (jjte001 instanceof RuntimeException) { {if (true) throw (RuntimeException)jjte001;} } if (jjte001 instanceof ParseException) { {if (true) throw (ParseException)jjte001;} } {if (true) throw (Error)jjte001;} } finally { if (jjtc001) { jjtree.closeNodeScope(jjtn001, 2); } } } } // bitwise or non-short-circuiting and (&) (level 7) final public void andExpression() throws ParseException { equalityExpression(); label_6: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 13: case 14: ; break; default: jj_la1[11] = jj_gen; break label_6; } switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 13: jj_consume_token(13); break; case 14: jj_consume_token(14); break; default: jj_la1[12] = jj_gen; jj_consume_token(-1); throw new ParseException(); } ASTBitAnd jjtn001 = new ASTBitAnd(JJTBITAND); boolean jjtc001 = true; jjtree.openNodeScope(jjtn001); try { equalityExpression(); } catch (Throwable jjte001) { if (jjtc001) { jjtree.clearNodeScope(jjtn001); jjtc001 = false; } else { jjtree.popNode(); } if (jjte001 instanceof RuntimeException) { {if (true) throw (RuntimeException)jjte001;} } if (jjte001 instanceof ParseException) { {if (true) throw (ParseException)jjte001;} } {if (true) throw (Error)jjte001;} } finally { if (jjtc001) { jjtree.closeNodeScope(jjtn001, 2); } } } } // equality/inequality (==/!=) (level 6) final public void equalityExpression() throws ParseException { relationalExpression(); label_7: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 15: case 16: case 17: case 18: ; break; default: jj_la1[13] = jj_gen; break label_7; } switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 15: case 16: switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 15: jj_consume_token(15); break; case 16: jj_consume_token(16); break; default: jj_la1[14] = jj_gen; jj_consume_token(-1); throw new ParseException(); } ASTEq jjtn001 = new ASTEq(JJTEQ); boolean jjtc001 = true; jjtree.openNodeScope(jjtn001); try { relationalExpression(); } catch (Throwable jjte001) { if (jjtc001) { jjtree.clearNodeScope(jjtn001); jjtc001 = false; } else { jjtree.popNode(); } if (jjte001 instanceof RuntimeException) { {if (true) throw (RuntimeException)jjte001;} } if (jjte001 instanceof ParseException) { {if (true) throw (ParseException)jjte001;} } {if (true) throw (Error)jjte001;} } finally { if (jjtc001) { jjtree.closeNodeScope(jjtn001, 2); } } break; case 17: case 18: switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 17: jj_consume_token(17); break; case 18: jj_consume_token(18); break; default: jj_la1[15] = jj_gen; jj_consume_token(-1); throw new ParseException(); } ASTNotEq jjtn002 = new ASTNotEq(JJTNOTEQ); boolean jjtc002 = true; jjtree.openNodeScope(jjtn002); try { relationalExpression(); } catch (Throwable jjte002) { if (jjtc002) { jjtree.clearNodeScope(jjtn002); jjtc002 = false; } else { jjtree.popNode(); } if (jjte002 instanceof RuntimeException) { {if (true) throw (RuntimeException)jjte002;} } if (jjte002 instanceof ParseException) { {if (true) throw (ParseException)jjte002;} } {if (true) throw (Error)jjte002;} } finally { if (jjtc002) { jjtree.closeNodeScope(jjtn002, 2); } } break; default: jj_la1[16] = jj_gen; jj_consume_token(-1); throw new ParseException(); } } } // boolean relational expressions (level 5) final public void relationalExpression() throws ParseException { shiftExpression(); label_8: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 19: case 20: case 21: case 22: case 23: case 24: case 25: case 26: case 27: case 28: ; break; default: jj_la1[17] = jj_gen; break label_8; } switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 19: case 20: switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 19: jj_consume_token(19); break; case 20: jj_consume_token(20); break; default: jj_la1[18] = jj_gen; jj_consume_token(-1); throw new ParseException(); } ASTLess jjtn001 = new ASTLess(JJTLESS); boolean jjtc001 = true; jjtree.openNodeScope(jjtn001); try { shiftExpression(); } catch (Throwable jjte001) { if (jjtc001) { jjtree.clearNodeScope(jjtn001); jjtc001 = false; } else { jjtree.popNode(); } if (jjte001 instanceof RuntimeException) { {if (true) throw (RuntimeException)jjte001;} } if (jjte001 instanceof ParseException) { {if (true) throw (ParseException)jjte001;} } {if (true) throw (Error)jjte001;} } finally { if (jjtc001) { jjtree.closeNodeScope(jjtn001, 2); } } break; case 21: case 22: switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 21: jj_consume_token(21); break; case 22: jj_consume_token(22); break; default: jj_la1[19] = jj_gen; jj_consume_token(-1); throw new ParseException(); } ASTGreater jjtn002 = new ASTGreater(JJTGREATER); boolean jjtc002 = true; jjtree.openNodeScope(jjtn002); try { shiftExpression(); } catch (Throwable jjte002) { if (jjtc002) { jjtree.clearNodeScope(jjtn002); jjtc002 = false; } else { jjtree.popNode(); } if (jjte002 instanceof RuntimeException) { {if (true) throw (RuntimeException)jjte002;} } if (jjte002 instanceof ParseException) { {if (true) throw (ParseException)jjte002;} } {if (true) throw (Error)jjte002;} } finally { if (jjtc002) { jjtree.closeNodeScope(jjtn002, 2); } } break; case 23: case 24: switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 23: jj_consume_token(23); break; case 24: jj_consume_token(24); break; default: jj_la1[20] = jj_gen; jj_consume_token(-1); throw new ParseException(); } ASTLessEq jjtn003 = new ASTLessEq(JJTLESSEQ); boolean jjtc003 = true; jjtree.openNodeScope(jjtn003); try { shiftExpression(); } catch (Throwable jjte003) { if (jjtc003) { jjtree.clearNodeScope(jjtn003); jjtc003 = false; } else { jjtree.popNode(); } if (jjte003 instanceof RuntimeException) { {if (true) throw (RuntimeException)jjte003;} } if (jjte003 instanceof ParseException) { {if (true) throw (ParseException)jjte003;} } {if (true) throw (Error)jjte003;} } finally { if (jjtc003) { jjtree.closeNodeScope(jjtn003, 2); } } break; case 25: case 26: switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 25: jj_consume_token(25); break; case 26: jj_consume_token(26); break; default: jj_la1[21] = jj_gen; jj_consume_token(-1); throw new ParseException(); } ASTGreaterEq jjtn004 = new ASTGreaterEq(JJTGREATEREQ); boolean jjtc004 = true; jjtree.openNodeScope(jjtn004); try { shiftExpression(); } catch (Throwable jjte004) { if (jjtc004) { jjtree.clearNodeScope(jjtn004); jjtc004 = false; } else { jjtree.popNode(); } if (jjte004 instanceof RuntimeException) { {if (true) throw (RuntimeException)jjte004;} } if (jjte004 instanceof ParseException) { {if (true) throw (ParseException)jjte004;} } {if (true) throw (Error)jjte004;} } finally { if (jjtc004) { jjtree.closeNodeScope(jjtn004, 2); } } break; case 27: jj_consume_token(27); ASTIn jjtn005 = new ASTIn(JJTIN); boolean jjtc005 = true; jjtree.openNodeScope(jjtn005); try { shiftExpression(); } catch (Throwable jjte005) { if (jjtc005) { jjtree.clearNodeScope(jjtn005); jjtc005 = false; } else { jjtree.popNode(); } if (jjte005 instanceof RuntimeException) { {if (true) throw (RuntimeException)jjte005;} } if (jjte005 instanceof ParseException) { {if (true) throw (ParseException)jjte005;} } {if (true) throw (Error)jjte005;} } finally { if (jjtc005) { jjtree.closeNodeScope(jjtn005, 2); } } break; case 28: jj_consume_token(28); jj_consume_token(27); ASTNotIn jjtn006 = new ASTNotIn(JJTNOTIN); boolean jjtc006 = true; jjtree.openNodeScope(jjtn006); try { shiftExpression(); } catch (Throwable jjte006) { if (jjtc006) { jjtree.clearNodeScope(jjtn006); jjtc006 = false; } else { jjtree.popNode(); } if (jjte006 instanceof RuntimeException) { {if (true) throw (RuntimeException)jjte006;} } if (jjte006 instanceof ParseException) { {if (true) throw (ParseException)jjte006;} } {if (true) throw (Error)jjte006;} } finally { if (jjtc006) { jjtree.closeNodeScope(jjtn006, 2); } } break; default: jj_la1[22] = jj_gen; jj_consume_token(-1); throw new ParseException(); } } } // bit shift expressions (level 4) final public void shiftExpression() throws ParseException { additiveExpression(); label_9: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 29: case 30: case 31: case 32: case 33: case 34: ; break; default: jj_la1[23] = jj_gen; break label_9; } switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 29: case 30: switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 29: jj_consume_token(29); break; case 30: jj_consume_token(30); break; default: jj_la1[24] = jj_gen; jj_consume_token(-1); throw new ParseException(); } ASTShiftLeft jjtn001 = new ASTShiftLeft(JJTSHIFTLEFT); boolean jjtc001 = true; jjtree.openNodeScope(jjtn001); try { additiveExpression(); } catch (Throwable jjte001) { if (jjtc001) { jjtree.clearNodeScope(jjtn001); jjtc001 = false; } else { jjtree.popNode(); } if (jjte001 instanceof RuntimeException) { {if (true) throw (RuntimeException)jjte001;} } if (jjte001 instanceof ParseException) { {if (true) throw (ParseException)jjte001;} } {if (true) throw (Error)jjte001;} } finally { if (jjtc001) { jjtree.closeNodeScope(jjtn001, 2); } } break; case 31: case 32: switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 31: jj_consume_token(31); break; case 32: jj_consume_token(32); break; default: jj_la1[25] = jj_gen; jj_consume_token(-1); throw new ParseException(); } ASTShiftRight jjtn002 = new ASTShiftRight(JJTSHIFTRIGHT); boolean jjtc002 = true; jjtree.openNodeScope(jjtn002); try { additiveExpression(); } catch (Throwable jjte002) { if (jjtc002) { jjtree.clearNodeScope(jjtn002); jjtc002 = false; } else { jjtree.popNode(); } if (jjte002 instanceof RuntimeException) { {if (true) throw (RuntimeException)jjte002;} } if (jjte002 instanceof ParseException) { {if (true) throw (ParseException)jjte002;} } {if (true) throw (Error)jjte002;} } finally { if (jjtc002) { jjtree.closeNodeScope(jjtn002, 2); } } break; case 33: case 34: switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 33: jj_consume_token(33); break; case 34: jj_consume_token(34); break; default: jj_la1[26] = jj_gen; jj_consume_token(-1); throw new ParseException(); } ASTUnsignedShiftRight jjtn003 = new ASTUnsignedShiftRight(JJTUNSIGNEDSHIFTRIGHT); boolean jjtc003 = true; jjtree.openNodeScope(jjtn003); try { additiveExpression(); } catch (Throwable jjte003) { if (jjtc003) { jjtree.clearNodeScope(jjtn003); jjtc003 = false; } else { jjtree.popNode(); } if (jjte003 instanceof RuntimeException) { {if (true) throw (RuntimeException)jjte003;} } if (jjte003 instanceof ParseException) { {if (true) throw (ParseException)jjte003;} } {if (true) throw (Error)jjte003;} } finally { if (jjtc003) { jjtree.closeNodeScope(jjtn003, 2); } } break; default: jj_la1[27] = jj_gen; jj_consume_token(-1); throw new ParseException(); } } } // binary addition/subtraction (level 3) final public void additiveExpression() throws ParseException { multiplicativeExpression(); label_10: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 35: case 36: ; break; default: jj_la1[28] = jj_gen; break label_10; } switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 35: jj_consume_token(35); ASTAdd jjtn001 = new ASTAdd(JJTADD); boolean jjtc001 = true; jjtree.openNodeScope(jjtn001); try { multiplicativeExpression(); } catch (Throwable jjte001) { if (jjtc001) { jjtree.clearNodeScope(jjtn001); jjtc001 = false; } else { jjtree.popNode(); } if (jjte001 instanceof RuntimeException) { {if (true) throw (RuntimeException)jjte001;} } if (jjte001 instanceof ParseException) { {if (true) throw (ParseException)jjte001;} } {if (true) throw (Error)jjte001;} } finally { if (jjtc001) { jjtree.closeNodeScope(jjtn001, 2); } } break; case 36: jj_consume_token(36); ASTSubtract jjtn002 = new ASTSubtract(JJTSUBTRACT); boolean jjtc002 = true; jjtree.openNodeScope(jjtn002); try { multiplicativeExpression(); } catch (Throwable jjte002) { if (jjtc002) { jjtree.clearNodeScope(jjtn002); jjtc002 = false; } else { jjtree.popNode(); } if (jjte002 instanceof RuntimeException) { {if (true) throw (RuntimeException)jjte002;} } if (jjte002 instanceof ParseException) { {if (true) throw (ParseException)jjte002;} } {if (true) throw (Error)jjte002;} } finally { if (jjtc002) { jjtree.closeNodeScope(jjtn002, 2); } } break; default: jj_la1[29] = jj_gen; jj_consume_token(-1); throw new ParseException(); } } } // multiplication/division/remainder (level 2) final public void multiplicativeExpression() throws ParseException { unaryExpression(); label_11: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 37: case 38: case 39: ; break; default: jj_la1[30] = jj_gen; break label_11; } switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 37: jj_consume_token(37); ASTMultiply jjtn001 = new ASTMultiply(JJTMULTIPLY); boolean jjtc001 = true; jjtree.openNodeScope(jjtn001); try { unaryExpression(); } catch (Throwable jjte001) { if (jjtc001) { jjtree.clearNodeScope(jjtn001); jjtc001 = false; } else { jjtree.popNode(); } if (jjte001 instanceof RuntimeException) { {if (true) throw (RuntimeException)jjte001;} } if (jjte001 instanceof ParseException) { {if (true) throw (ParseException)jjte001;} } {if (true) throw (Error)jjte001;} } finally { if (jjtc001) { jjtree.closeNodeScope(jjtn001, 2); } } break; case 38: jj_consume_token(38); ASTDivide jjtn002 = new ASTDivide(JJTDIVIDE); boolean jjtc002 = true; jjtree.openNodeScope(jjtn002); try { unaryExpression(); } catch (Throwable jjte002) { if (jjtc002) { jjtree.clearNodeScope(jjtn002); jjtc002 = false; } else { jjtree.popNode(); } if (jjte002 instanceof RuntimeException) { {if (true) throw (RuntimeException)jjte002;} } if (jjte002 instanceof ParseException) { {if (true) throw (ParseException)jjte002;} } {if (true) throw (Error)jjte002;} } finally { if (jjtc002) { jjtree.closeNodeScope(jjtn002, 2); } } break; case 39: jj_consume_token(39); ASTRemainder jjtn003 = new ASTRemainder(JJTREMAINDER); boolean jjtc003 = true; jjtree.openNodeScope(jjtn003); try { unaryExpression(); } catch (Throwable jjte003) { if (jjtc003) { jjtree.clearNodeScope(jjtn003); jjtc003 = false; } else { jjtree.popNode(); } if (jjte003 instanceof RuntimeException) { {if (true) throw (RuntimeException)jjte003;} } if (jjte003 instanceof ParseException) { {if (true) throw (ParseException)jjte003;} } {if (true) throw (Error)jjte003;} } finally { if (jjtc003) { jjtree.closeNodeScope(jjtn003, 2); } } break; default: jj_la1[31] = jj_gen; jj_consume_token(-1); throw new ParseException(); } } } // unary (level 1) final public void unaryExpression() throws ParseException { StringBuffer sb; Token t; ASTInstanceof ionode; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 36: jj_consume_token(36); ASTNegate jjtn001 = new ASTNegate(JJTNEGATE); boolean jjtc001 = true; jjtree.openNodeScope(jjtn001); try { unaryExpression(); } catch (Throwable jjte001) { if (jjtc001) { jjtree.clearNodeScope(jjtn001); jjtc001 = false; } else { jjtree.popNode(); } if (jjte001 instanceof RuntimeException) { {if (true) throw (RuntimeException)jjte001;} } if (jjte001 instanceof ParseException) { {if (true) throw (ParseException)jjte001;} } {if (true) throw (Error)jjte001;} } finally { if (jjtc001) { jjtree.closeNodeScope(jjtn001, 1); } } break; case 35: jj_consume_token(35); unaryExpression(); break; case 40: jj_consume_token(40); ASTBitNegate jjtn002 = new ASTBitNegate(JJTBITNEGATE); boolean jjtc002 = true; jjtree.openNodeScope(jjtn002); try { unaryExpression(); } catch (Throwable jjte002) { if (jjtc002) { jjtree.clearNodeScope(jjtn002); jjtc002 = false; } else { jjtree.popNode(); } if (jjte002 instanceof RuntimeException) { {if (true) throw (RuntimeException)jjte002;} } if (jjte002 instanceof ParseException) { {if (true) throw (ParseException)jjte002;} } {if (true) throw (Error)jjte002;} } finally { if (jjtc002) { jjtree.closeNodeScope(jjtn002, 1); } } break; case 28: case 41: switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 41: jj_consume_token(41); break; case 28: jj_consume_token(28); break; default: jj_la1[32] = jj_gen; jj_consume_token(-1); throw new ParseException(); } ASTNot jjtn003 = new ASTNot(JJTNOT); boolean jjtc003 = true; jjtree.openNodeScope(jjtn003); try { unaryExpression(); } catch (Throwable jjte003) { if (jjtc003) { jjtree.clearNodeScope(jjtn003); jjtc003 = false; } else { jjtree.popNode(); } if (jjte003 instanceof RuntimeException) { {if (true) throw (RuntimeException)jjte003;} } if (jjte003 instanceof ParseException) { {if (true) throw (ParseException)jjte003;} } {if (true) throw (Error)jjte003;} } finally { if (jjtc003) { jjtree.closeNodeScope(jjtn003, 1); } } break; case 4: case 44: case 46: case 47: case 48: case 49: case 50: case 51: case 52: case 54: case 56: case 57: case IDENT: case DYNAMIC_SUBSCRIPT: case CHAR_LITERAL: case BACK_CHAR_LITERAL: case STRING_LITERAL: case INT_LITERAL: case FLT_LITERAL: navigationChain(); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 42: jj_consume_token(42); t = jj_consume_token(IDENT); ASTInstanceof jjtn004 = new ASTInstanceof(JJTINSTANCEOF); boolean jjtc004 = true; jjtree.openNodeScope(jjtn004); try { jjtree.closeNodeScope(jjtn004, 1); jjtc004 = false; sb = new StringBuffer(t.image); ionode = jjtn004; } finally { if (jjtc004) { jjtree.closeNodeScope(jjtn004, 1); } } label_12: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 43: ; break; default: jj_la1[33] = jj_gen; break label_12; } jj_consume_token(43); t = jj_consume_token(IDENT); sb.append('.').append( t.image ); } ionode.setTargetType( new String(sb) ); break; default: jj_la1[34] = jj_gen; ; } break; default: jj_la1[35] = jj_gen; jj_consume_token(-1); throw new ParseException(); } } // navigation chain: property references, method calls, projections, selections, etc. final public void navigationChain() throws ParseException { primaryExpression(); label_13: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 43: case 44: case 52: case DYNAMIC_SUBSCRIPT: ; break; default: jj_la1[36] = jj_gen; break label_13; } switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 43: jj_consume_token(43); ASTChain jjtn001 = new ASTChain(JJTCHAIN); boolean jjtc001 = true; jjtree.openNodeScope(jjtn001); try { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case IDENT: if (jj_2_1(2)) { methodCall(); } else { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case IDENT: propertyName(); break; default: jj_la1[37] = jj_gen; jj_consume_token(-1); throw new ParseException(); } } break; case 54: if (jj_2_2(2)) { projection(); } else { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 54: selection(); break; default: jj_la1[38] = jj_gen; jj_consume_token(-1); throw new ParseException(); } } break; case 44: jj_consume_token(44); expression(); jj_consume_token(45); break; default: jj_la1[39] = jj_gen; jj_consume_token(-1); throw new ParseException(); } } catch (Throwable jjte001) { if (jjtc001) { jjtree.clearNodeScope(jjtn001); jjtc001 = false; } else { jjtree.popNode(); } if (jjte001 instanceof RuntimeException) { {if (true) throw (RuntimeException)jjte001;} } if (jjte001 instanceof ParseException) { {if (true) throw (ParseException)jjte001;} } {if (true) throw (Error)jjte001;} } finally { if (jjtc001) { jjtree.closeNodeScope(jjtn001, 2); } } break; case 52: case DYNAMIC_SUBSCRIPT: ASTChain jjtn002 = new ASTChain(JJTCHAIN); boolean jjtc002 = true; jjtree.openNodeScope(jjtn002); try { index(); } catch (Throwable jjte002) { if (jjtc002) { jjtree.clearNodeScope(jjtn002); jjtc002 = false; } else { jjtree.popNode(); } if (jjte002 instanceof RuntimeException) { {if (true) throw (RuntimeException)jjte002;} } if (jjte002 instanceof ParseException) { {if (true) throw (ParseException)jjte002;} } {if (true) throw (Error)jjte002;} } finally { if (jjtc002) { jjtree.closeNodeScope(jjtn002, 2); } } break; case 44: jj_consume_token(44); expression(); ASTEval jjtn003 = new ASTEval(JJTEVAL); boolean jjtc003 = true; jjtree.openNodeScope(jjtn003); try { jj_consume_token(45); } finally { if (jjtc003) { jjtree.closeNodeScope(jjtn003, 2); } } break; default: jj_la1[40] = jj_gen; jj_consume_token(-1); throw new ParseException(); } } } final public void primaryExpression() throws ParseException { Token t; String className = null; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case CHAR_LITERAL: case BACK_CHAR_LITERAL: case STRING_LITERAL: case INT_LITERAL: case FLT_LITERAL: switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case CHAR_LITERAL: jj_consume_token(CHAR_LITERAL); break; case BACK_CHAR_LITERAL: jj_consume_token(BACK_CHAR_LITERAL); break; case STRING_LITERAL: jj_consume_token(STRING_LITERAL); break; case INT_LITERAL: jj_consume_token(INT_LITERAL); break; case FLT_LITERAL: jj_consume_token(FLT_LITERAL); break; default: jj_la1[41] = jj_gen; jj_consume_token(-1); throw new ParseException(); } ASTConst jjtn001 = new ASTConst(JJTCONST); boolean jjtc001 = true; jjtree.openNodeScope(jjtn001); try { jjtree.closeNodeScope(jjtn001, 0); jjtc001 = false; jjtn001.setValue( token_source.literalValue ); } finally { if (jjtc001) { jjtree.closeNodeScope(jjtn001, 0); } } break; case 46: jj_consume_token(46); ASTConst jjtn002 = new ASTConst(JJTCONST); boolean jjtc002 = true; jjtree.openNodeScope(jjtn002); try { jjtree.closeNodeScope(jjtn002, 0); jjtc002 = false; jjtn002.setValue( Boolean.TRUE ); } finally { if (jjtc002) { jjtree.closeNodeScope(jjtn002, 0); } } break; case 47: jj_consume_token(47); ASTConst jjtn003 = new ASTConst(JJTCONST); boolean jjtc003 = true; jjtree.openNodeScope(jjtn003); try { jjtree.closeNodeScope(jjtn003, 0); jjtc003 = false; jjtn003.setValue( Boolean.FALSE ); } finally { if (jjtc003) { jjtree.closeNodeScope(jjtn003, 0); } } break; case 48: ASTConst jjtn004 = new ASTConst(JJTCONST); boolean jjtc004 = true; jjtree.openNodeScope(jjtn004); try { jj_consume_token(48); } finally { if (jjtc004) { jjtree.closeNodeScope(jjtn004, 0); } } break; default: jj_la1[48] = jj_gen; if (jj_2_4(2)) { jj_consume_token(49); ASTThisVarRef jjtn005 = new ASTThisVarRef(JJTTHISVARREF); boolean jjtc005 = true; jjtree.openNodeScope(jjtn005); try { jjtree.closeNodeScope(jjtn005, 0); jjtc005 = false; jjtn005.setName( "this" ); } finally { if (jjtc005) { jjtree.closeNodeScope(jjtn005, 0); } } } else if (jj_2_5(2)) { jj_consume_token(50); ASTRootVarRef jjtn006 = new ASTRootVarRef(JJTROOTVARREF); boolean jjtc006 = true; jjtree.openNodeScope(jjtn006); try { jjtree.closeNodeScope(jjtn006, 0); jjtc006 = false; jjtn006.setName( "root" ); } finally { if (jjtc006) { jjtree.closeNodeScope(jjtn006, 0); } } } else if (jj_2_6(2)) { jj_consume_token(51); t = jj_consume_token(IDENT); ASTVarRef jjtn007 = new ASTVarRef(JJTVARREF); boolean jjtc007 = true; jjtree.openNodeScope(jjtn007); try { jjtree.closeNodeScope(jjtn007, 0); jjtc007 = false; jjtn007.setName( t.image ); } finally { if (jjtc007) { jjtree.closeNodeScope(jjtn007, 0); } } } else if (jj_2_7(2)) { jj_consume_token(4); jj_consume_token(52); expression(); jj_consume_token(53); ASTConst jjtn008 = new ASTConst(JJTCONST); boolean jjtc008 = true; jjtree.openNodeScope(jjtn008); try { jjtree.closeNodeScope(jjtn008, 1); jjtc008 = false; jjtn008.setValue( jjtn008.jjtGetChild(0) ); } finally { if (jjtc008) { jjtree.closeNodeScope(jjtn008, 1); } } } else { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 56: staticReference(); break; default: jj_la1[49] = jj_gen; if (jj_2_8(2)) { constructorCall(); } else { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case IDENT: if (jj_2_3(2)) { methodCall(); } else { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case IDENT: propertyName(); break; default: jj_la1[42] = jj_gen; jj_consume_token(-1); throw new ParseException(); } } break; case 52: case DYNAMIC_SUBSCRIPT: index(); break; case 44: jj_consume_token(44); expression(); jj_consume_token(45); break; case 54: jj_consume_token(54); ASTList jjtn009 = new ASTList(JJTLIST); boolean jjtc009 = true; jjtree.openNodeScope(jjtn009); try { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 4: case 28: case 35: case 36: case 40: case 41: case 44: case 46: case 47: case 48: case 49: case 50: case 51: case 52: case 54: case 56: case 57: case IDENT: case DYNAMIC_SUBSCRIPT: case CHAR_LITERAL: case BACK_CHAR_LITERAL: case STRING_LITERAL: case INT_LITERAL: case FLT_LITERAL: assignmentExpression(); label_14: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 1: ; break; default: jj_la1[43] = jj_gen; break label_14; } jj_consume_token(1); assignmentExpression(); } break; default: jj_la1[44] = jj_gen; ; } } catch (Throwable jjte009) { if (jjtc009) { jjtree.clearNodeScope(jjtn009); jjtc009 = false; } else { jjtree.popNode(); } if (jjte009 instanceof RuntimeException) { {if (true) throw (RuntimeException)jjte009;} } if (jjte009 instanceof ParseException) { {if (true) throw (ParseException)jjte009;} } {if (true) throw (Error)jjte009;} } finally { if (jjtc009) { jjtree.closeNodeScope(jjtn009, true); } } jj_consume_token(55); break; default: jj_la1[50] = jj_gen; if (jj_2_9(2)) { ASTMap jjtn010 = new ASTMap(JJTMAP); boolean jjtc010 = true; jjtree.openNodeScope(jjtn010); try { jj_consume_token(51); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 56: className = classReference(); break; default: jj_la1[45] = jj_gen; ; } jj_consume_token(54); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 4: case 28: case 35: case 36: case 40: case 41: case 44: case 46: case 47: case 48: case 49: case 50: case 51: case 52: case 54: case 56: case 57: case IDENT: case DYNAMIC_SUBSCRIPT: case CHAR_LITERAL: case BACK_CHAR_LITERAL: case STRING_LITERAL: case INT_LITERAL: case FLT_LITERAL: keyValueExpression(); label_15: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 1: ; break; default: jj_la1[46] = jj_gen; break label_15; } jj_consume_token(1); keyValueExpression(); } break; default: jj_la1[47] = jj_gen; ; } jjtn010.setClassName(className); jj_consume_token(55); } catch (Throwable jjte010) { if (jjtc010) { jjtree.clearNodeScope(jjtn010); jjtc010 = false; } else { jjtree.popNode(); } if (jjte010 instanceof RuntimeException) { {if (true) throw (RuntimeException)jjte010;} } if (jjte010 instanceof ParseException) { {if (true) throw (ParseException)jjte010;} } {if (true) throw (Error)jjte010;} } finally { if (jjtc010) { jjtree.closeNodeScope(jjtn010, true); } } } else { jj_consume_token(-1); throw new ParseException(); } } } } } } } final public void keyValueExpression() throws ParseException { ASTKeyValue jjtn001 = new ASTKeyValue(JJTKEYVALUE); boolean jjtc001 = true; jjtree.openNodeScope(jjtn001); try { assignmentExpression(); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 4: jj_consume_token(4); assignmentExpression(); break; default: jj_la1[51] = jj_gen; ; } } catch (Throwable jjte001) { if (jjtc001) { jjtree.clearNodeScope(jjtn001); jjtc001 = false; } else { jjtree.popNode(); } if (jjte001 instanceof RuntimeException) { {if (true) throw (RuntimeException)jjte001;} } if (jjte001 instanceof ParseException) { {if (true) throw (ParseException)jjte001;} } {if (true) throw (Error)jjte001;} } finally { if (jjtc001) { jjtree.closeNodeScope(jjtn001, true); } } } final public void staticReference() throws ParseException { String className = "java.lang.Math"; Token t; className = classReference(); if (jj_2_10(2)) { staticMethodCall(className); } else { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case IDENT: t = jj_consume_token(IDENT); ASTStaticField jjtn001 = new ASTStaticField(JJTSTATICFIELD); boolean jjtc001 = true; jjtree.openNodeScope(jjtn001); try { jjtree.closeNodeScope(jjtn001, 0); jjtc001 = false; jjtn001.init( className, t.image ); } finally { if (jjtc001) { jjtree.closeNodeScope(jjtn001, 0); } } break; default: jj_la1[52] = jj_gen; jj_consume_token(-1); throw new ParseException(); } } } final public String classReference() throws ParseException { String result = "java.lang.Math"; jj_consume_token(56); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case IDENT: result = className(); break; default: jj_la1[53] = jj_gen; ; } jj_consume_token(56); {if (true) return result;} throw new Error("Missing return statement in function"); } final public String className() throws ParseException { Token t; StringBuffer result; t = jj_consume_token(IDENT); result = new StringBuffer( t.image ); label_16: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 43: ; break; default: jj_la1[54] = jj_gen; break label_16; } jj_consume_token(43); t = jj_consume_token(IDENT); result.append('.').append( t.image ); } {if (true) return new String(result);} throw new Error("Missing return statement in function"); } final public void constructorCall() throws ParseException { /*@bgen(jjtree) Ctor */ ASTCtor jjtn000 = new ASTCtor(JJTCTOR); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000);String className; Token t; StringBuffer sb; try { jj_consume_token(57); className = className(); if (jj_2_11(2)) { jj_consume_token(44); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 4: case 28: case 35: case 36: case 40: case 41: case 44: case 46: case 47: case 48: case 49: case 50: case 51: case 52: case 54: case 56: case 57: case IDENT: case DYNAMIC_SUBSCRIPT: case CHAR_LITERAL: case BACK_CHAR_LITERAL: case STRING_LITERAL: case INT_LITERAL: case FLT_LITERAL: assignmentExpression(); label_17: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 1: ; break; default: jj_la1[55] = jj_gen; break label_17; } jj_consume_token(1); assignmentExpression(); } break; default: jj_la1[56] = jj_gen; ; } jj_consume_token(45); jjtree.closeNodeScope(jjtn000, true); jjtc000 = false; jjtn000.setClassName(className); } else if (jj_2_12(2)) { jj_consume_token(52); jj_consume_token(53); jj_consume_token(54); ASTList jjtn001 = new ASTList(JJTLIST); boolean jjtc001 = true; jjtree.openNodeScope(jjtn001); try { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 4: case 28: case 35: case 36: case 40: case 41: case 44: case 46: case 47: case 48: case 49: case 50: case 51: case 52: case 54: case 56: case 57: case IDENT: case DYNAMIC_SUBSCRIPT: case CHAR_LITERAL: case BACK_CHAR_LITERAL: case STRING_LITERAL: case INT_LITERAL: case FLT_LITERAL: assignmentExpression(); label_18: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 1: ; break; default: jj_la1[57] = jj_gen; break label_18; } jj_consume_token(1); assignmentExpression(); } break; default: jj_la1[58] = jj_gen; ; } } catch (Throwable jjte001) { if (jjtc001) { jjtree.clearNodeScope(jjtn001); jjtc001 = false; } else { jjtree.popNode(); } if (jjte001 instanceof RuntimeException) { {if (true) throw (RuntimeException)jjte001;} } if (jjte001 instanceof ParseException) { {if (true) throw (ParseException)jjte001;} } {if (true) throw (Error)jjte001;} } finally { if (jjtc001) { jjtree.closeNodeScope(jjtn001, true); } } jj_consume_token(55); jjtree.closeNodeScope(jjtn000, true); jjtc000 = false; jjtn000.setClassName(className); jjtn000.setArray(true); } else if (jj_2_13(2)) { jj_consume_token(52); assignmentExpression(); jj_consume_token(53); jjtree.closeNodeScope(jjtn000, true); jjtc000 = false; jjtn000.setClassName(className); jjtn000.setArray(true); } else { jj_consume_token(-1); throw new ParseException(); } } catch (Throwable jjte000) { if (jjtc000) { jjtree.clearNodeScope(jjtn000); jjtc000 = false; } else { jjtree.popNode(); } if (jjte000 instanceof RuntimeException) { {if (true) throw (RuntimeException)jjte000;} } if (jjte000 instanceof ParseException) { {if (true) throw (ParseException)jjte000;} } {if (true) throw (Error)jjte000;} } finally { if (jjtc000) { jjtree.closeNodeScope(jjtn000, true); } } } final public void propertyName() throws ParseException { /*@bgen(jjtree) Property */ ASTProperty jjtn000 = new ASTProperty(JJTPROPERTY); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000);Token t; try { t = jj_consume_token(IDENT); ASTConst jjtn001 = new ASTConst(JJTCONST); boolean jjtc001 = true; jjtree.openNodeScope(jjtn001); try { jjtree.closeNodeScope(jjtn001, true); jjtc001 = false; jjtn001.setValue( t.image ); } finally { if (jjtc001) { jjtree.closeNodeScope(jjtn001, true); } } } finally { if (jjtc000) { jjtree.closeNodeScope(jjtn000, true); } } } final public void staticMethodCall(String className) throws ParseException { /*@bgen(jjtree) StaticMethod */ ASTStaticMethod jjtn000 = new ASTStaticMethod(JJTSTATICMETHOD); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000);Token t; try { t = jj_consume_token(IDENT); jj_consume_token(44); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 4: case 28: case 35: case 36: case 40: case 41: case 44: case 46: case 47: case 48: case 49: case 50: case 51: case 52: case 54: case 56: case 57: case IDENT: case DYNAMIC_SUBSCRIPT: case CHAR_LITERAL: case BACK_CHAR_LITERAL: case STRING_LITERAL: case INT_LITERAL: case FLT_LITERAL: assignmentExpression(); label_19: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 1: ; break; default: jj_la1[59] = jj_gen; break label_19; } jj_consume_token(1); assignmentExpression(); } break; default: jj_la1[60] = jj_gen; ; } jj_consume_token(45); jjtree.closeNodeScope(jjtn000, true); jjtc000 = false; jjtn000.init( className, t.image ); } catch (Throwable jjte000) { if (jjtc000) { jjtree.clearNodeScope(jjtn000); jjtc000 = false; } else { jjtree.popNode(); } if (jjte000 instanceof RuntimeException) { {if (true) throw (RuntimeException)jjte000;} } if (jjte000 instanceof ParseException) { {if (true) throw (ParseException)jjte000;} } {if (true) throw (Error)jjte000;} } finally { if (jjtc000) { jjtree.closeNodeScope(jjtn000, true); } } } final public void methodCall() throws ParseException { /*@bgen(jjtree) Method */ ASTMethod jjtn000 = new ASTMethod(JJTMETHOD); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000);Token t; try { t = jj_consume_token(IDENT); jj_consume_token(44); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 4: case 28: case 35: case 36: case 40: case 41: case 44: case 46: case 47: case 48: case 49: case 50: case 51: case 52: case 54: case 56: case 57: case IDENT: case DYNAMIC_SUBSCRIPT: case CHAR_LITERAL: case BACK_CHAR_LITERAL: case STRING_LITERAL: case INT_LITERAL: case FLT_LITERAL: assignmentExpression(); label_20: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 1: ; break; default: jj_la1[61] = jj_gen; break label_20; } jj_consume_token(1); assignmentExpression(); } break; default: jj_la1[62] = jj_gen; ; } jj_consume_token(45); jjtree.closeNodeScope(jjtn000, true); jjtc000 = false; jjtn000.setMethodName( t.image ); } catch (Throwable jjte000) { if (jjtc000) { jjtree.clearNodeScope(jjtn000); jjtc000 = false; } else { jjtree.popNode(); } if (jjte000 instanceof RuntimeException) { {if (true) throw (RuntimeException)jjte000;} } if (jjte000 instanceof ParseException) { {if (true) throw (ParseException)jjte000;} } {if (true) throw (Error)jjte000;} } finally { if (jjtc000) { jjtree.closeNodeScope(jjtn000, true); } } } /** * Apply an expression to all elements of a collection, creating a new collection * as the result. */ final public void projection() throws ParseException { /*@bgen(jjtree) Project */ ASTProject jjtn000 = new ASTProject(JJTPROJECT); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000); try { jj_consume_token(54); expression(); jj_consume_token(55); } catch (Throwable jjte000) { if (jjtc000) { jjtree.clearNodeScope(jjtn000); jjtc000 = false; } else { jjtree.popNode(); } if (jjte000 instanceof RuntimeException) { {if (true) throw (RuntimeException)jjte000;} } if (jjte000 instanceof ParseException) { {if (true) throw (ParseException)jjte000;} } {if (true) throw (Error)jjte000;} } finally { if (jjtc000) { jjtree.closeNodeScope(jjtn000, true); } } } final public void selection() throws ParseException { if (jj_2_14(2)) { selectAll(); } else if (jj_2_15(2)) { selectFirst(); } else if (jj_2_16(2)) { selectLast(); } else { jj_consume_token(-1); throw new ParseException(); } } /** * Apply a boolean expression to all elements of a collection, creating a new collection * containing those elements for which the expression returned true. */ final public void selectAll() throws ParseException { /*@bgen(jjtree) Select */ ASTSelect jjtn000 = new ASTSelect(JJTSELECT); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000); try { jj_consume_token(54); jj_consume_token(3); expression(); jj_consume_token(55); } catch (Throwable jjte000) { if (jjtc000) { jjtree.clearNodeScope(jjtn000); jjtc000 = false; } else { jjtree.popNode(); } if (jjte000 instanceof RuntimeException) { {if (true) throw (RuntimeException)jjte000;} } if (jjte000 instanceof ParseException) { {if (true) throw (ParseException)jjte000;} } {if (true) throw (Error)jjte000;} } finally { if (jjtc000) { jjtree.closeNodeScope(jjtn000, true); } } } /** * Apply a boolean expression to all elements of a collection, creating a new collection * containing those elements for the first element for which the expression returned true. */ final public void selectFirst() throws ParseException { /*@bgen(jjtree) SelectFirst */ ASTSelectFirst jjtn000 = new ASTSelectFirst(JJTSELECTFIRST); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000); try { jj_consume_token(54); jj_consume_token(11); expression(); jj_consume_token(55); } catch (Throwable jjte000) { if (jjtc000) { jjtree.clearNodeScope(jjtn000); jjtc000 = false; } else { jjtree.popNode(); } if (jjte000 instanceof RuntimeException) { {if (true) throw (RuntimeException)jjte000;} } if (jjte000 instanceof ParseException) { {if (true) throw (ParseException)jjte000;} } {if (true) throw (Error)jjte000;} } finally { if (jjtc000) { jjtree.closeNodeScope(jjtn000, true); } } } /** * Apply a boolean expression to all elements of a collection, creating a new collection * containing those elements for the first element for which the expression returned true. */ final public void selectLast() throws ParseException { /*@bgen(jjtree) SelectLast */ ASTSelectLast jjtn000 = new ASTSelectLast(JJTSELECTLAST); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000); try { jj_consume_token(54); jj_consume_token(58); expression(); jj_consume_token(55); } catch (Throwable jjte000) { if (jjtc000) { jjtree.clearNodeScope(jjtn000); jjtc000 = false; } else { jjtree.popNode(); } if (jjte000 instanceof RuntimeException) { {if (true) throw (RuntimeException)jjte000;} } if (jjte000 instanceof ParseException) { {if (true) throw (ParseException)jjte000;} } {if (true) throw (Error)jjte000;} } finally { if (jjtc000) { jjtree.closeNodeScope(jjtn000, true); } } } final public void index() throws ParseException { /*@bgen(jjtree) Property */ ASTProperty jjtn000 = new ASTProperty(JJTPROPERTY); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000); try { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 52: jj_consume_token(52); expression(); jj_consume_token(53); jjtree.closeNodeScope(jjtn000, true); jjtc000 = false; jjtn000.setIndexedAccess(true); break; case DYNAMIC_SUBSCRIPT: jj_consume_token(DYNAMIC_SUBSCRIPT); ASTConst jjtn001 = new ASTConst(JJTCONST); boolean jjtc001 = true; jjtree.openNodeScope(jjtn001); try { jjtree.closeNodeScope(jjtn001, true); jjtc001 = false; jjtn001.setValue( token_source.literalValue ); } finally { if (jjtc001) { jjtree.closeNodeScope(jjtn001, true); } } jjtree.closeNodeScope(jjtn000, true); jjtc000 = false; jjtn000.setIndexedAccess(true); break; default: jj_la1[63] = jj_gen; jj_consume_token(-1); throw new ParseException(); } } catch (Throwable jjte000) { if (jjtc000) { jjtree.clearNodeScope(jjtn000); jjtc000 = false; } else { jjtree.popNode(); } if (jjte000 instanceof RuntimeException) { {if (true) throw (RuntimeException)jjte000;} } if (jjte000 instanceof ParseException) { {if (true) throw (ParseException)jjte000;} } {if (true) throw (Error)jjte000;} } finally { if (jjtc000) { jjtree.closeNodeScope(jjtn000, true); } } } private boolean jj_2_1(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_1(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(0, xla); } } private boolean jj_2_2(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_2(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(1, xla); } } private boolean jj_2_3(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_3(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(2, xla); } } private boolean jj_2_4(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_4(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(3, xla); } } private boolean jj_2_5(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_5(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(4, xla); } } private boolean jj_2_6(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_6(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(5, xla); } } private boolean jj_2_7(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_7(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(6, xla); } } private boolean jj_2_8(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_8(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(7, xla); } } private boolean jj_2_9(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_9(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(8, xla); } } private boolean jj_2_10(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_10(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(9, xla); } } private boolean jj_2_11(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_11(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(10, xla); } } private boolean jj_2_12(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_12(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(11, xla); } } private boolean jj_2_13(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_13(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(12, xla); } } private boolean jj_2_14(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_14(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(13, xla); } } private boolean jj_2_15(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_15(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(14, xla); } } private boolean jj_2_16(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_16(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(15, xla); } } private boolean jj_3R_56() { if (jj_scan_token(48)) return true; return false; } private boolean jj_3R_55() { if (jj_scan_token(47)) return true; return false; } private boolean jj_3R_54() { if (jj_scan_token(46)) return true; return false; } private boolean jj_3R_31() { if (jj_3R_27()) return true; return false; } private boolean jj_3_13() { if (jj_scan_token(52)) return true; if (jj_3R_27()) return true; return false; } private boolean jj_3R_53() { Token xsp; xsp = jj_scanpos; if (jj_scan_token(73)) { jj_scanpos = xsp; if (jj_scan_token(76)) { jj_scanpos = xsp; if (jj_scan_token(79)) { jj_scanpos = xsp; if (jj_scan_token(80)) { jj_scanpos = xsp; if (jj_scan_token(81)) return true; } } } } return false; } private boolean jj_3R_26() { if (jj_3R_27()) return true; return false; } private boolean jj_3R_52() { Token xsp; xsp = jj_scanpos; if (jj_3R_53()) { jj_scanpos = xsp; if (jj_3R_54()) { jj_scanpos = xsp; if (jj_3R_55()) { jj_scanpos = xsp; if (jj_3R_56()) { jj_scanpos = xsp; if (jj_3_4()) { jj_scanpos = xsp; if (jj_3_5()) { jj_scanpos = xsp; if (jj_3_6()) { jj_scanpos = xsp; if (jj_3_7()) { jj_scanpos = xsp; if (jj_3R_57()) { jj_scanpos = xsp; if (jj_3_8()) { jj_scanpos = xsp; if (jj_3R_58()) { jj_scanpos = xsp; if (jj_3R_59()) { jj_scanpos = xsp; if (jj_3R_60()) { jj_scanpos = xsp; if (jj_3R_61()) { jj_scanpos = xsp; if (jj_3_9()) return true; } } } } } } } } } } } } } } return false; } private boolean jj_3R_42() { if (jj_3R_43()) return true; return false; } private boolean jj_3_12() { if (jj_scan_token(52)) return true; if (jj_scan_token(53)) return true; return false; } private boolean jj_3_11() { if (jj_scan_token(44)) return true; Token xsp; xsp = jj_scanpos; if (jj_3R_26()) jj_scanpos = xsp; if (jj_scan_token(45)) return true; return false; } private boolean jj_3R_67() { if (jj_scan_token(DYNAMIC_SUBSCRIPT)) return true; return false; } private boolean jj_3_2() { if (jj_3R_22()) return true; return false; } private boolean jj_3R_66() { if (jj_scan_token(52)) return true; return false; } private boolean jj_3R_64() { Token xsp; xsp = jj_scanpos; if (jj_3R_66()) { jj_scanpos = xsp; if (jj_3R_67()) return true; } return false; } private boolean jj_3_1() { if (jj_3R_21()) return true; return false; } private boolean jj_3R_23() { if (jj_scan_token(57)) return true; if (jj_3R_32()) return true; return false; } private boolean jj_3R_41() { if (jj_3R_42()) return true; return false; } private boolean jj_3R_30() { if (jj_scan_token(54)) return true; if (jj_scan_token(58)) return true; return false; } private boolean jj_3R_32() { if (jj_scan_token(IDENT)) return true; return false; } private boolean jj_3R_51() { if (jj_3R_52()) return true; return false; } private boolean jj_3R_29() { if (jj_scan_token(54)) return true; if (jj_scan_token(11)) return true; return false; } private boolean jj_3R_40() { if (jj_3R_41()) return true; return false; } private boolean jj_3R_33() { if (jj_scan_token(56)) return true; return false; } private boolean jj_3R_63() { if (jj_3R_65()) return true; return false; } private boolean jj_3R_28() { if (jj_scan_token(54)) return true; if (jj_scan_token(3)) return true; return false; } private boolean jj_3R_50() { if (jj_3R_51()) return true; return false; } private boolean jj_3R_39() { if (jj_3R_40()) return true; return false; } private boolean jj_3_10() { if (jj_3R_25()) return true; return false; } private boolean jj_3R_24() { if (jj_3R_33()) return true; return false; } private boolean jj_3R_49() { Token xsp; xsp = jj_scanpos; if (jj_scan_token(41)) { jj_scanpos = xsp; if (jj_scan_token(28)) return true; } return false; } private boolean jj_3R_48() { if (jj_scan_token(40)) return true; return false; } private boolean jj_3_16() { if (jj_3R_30()) return true; return false; } private boolean jj_3R_47() { if (jj_scan_token(35)) return true; return false; } private boolean jj_3_15() { if (jj_3R_29()) return true; return false; } private boolean jj_3R_38() { if (jj_3R_39()) return true; return false; } private boolean jj_3R_46() { if (jj_scan_token(36)) return true; return false; } private boolean jj_3_14() { if (jj_3R_28()) return true; return false; } private boolean jj_3R_62() { if (jj_3R_33()) return true; return false; } private boolean jj_3R_45() { Token xsp; xsp = jj_scanpos; if (jj_3R_46()) { jj_scanpos = xsp; if (jj_3R_47()) { jj_scanpos = xsp; if (jj_3R_48()) { jj_scanpos = xsp; if (jj_3R_49()) { jj_scanpos = xsp; if (jj_3R_50()) return true; } } } } return false; } private boolean jj_3R_37() { if (jj_3R_38()) return true; return false; } private boolean jj_3R_22() { if (jj_scan_token(54)) return true; if (jj_3R_31()) return true; return false; } private boolean jj_3_9() { if (jj_scan_token(51)) return true; Token xsp; xsp = jj_scanpos; if (jj_3R_24()) jj_scanpos = xsp; if (jj_scan_token(54)) return true; return false; } private boolean jj_3R_36() { if (jj_3R_37()) return true; return false; } private boolean jj_3R_61() { if (jj_scan_token(54)) return true; return false; } private boolean jj_3R_60() { if (jj_scan_token(44)) return true; return false; } private boolean jj_3R_59() { if (jj_3R_64()) return true; return false; } private boolean jj_3_3() { if (jj_3R_21()) return true; return false; } private boolean jj_3R_21() { if (jj_scan_token(IDENT)) return true; if (jj_scan_token(44)) return true; return false; } private boolean jj_3R_58() { Token xsp; xsp = jj_scanpos; if (jj_3_3()) { jj_scanpos = xsp; if (jj_3R_63()) return true; } return false; } private boolean jj_3R_35() { if (jj_3R_36()) return true; return false; } private boolean jj_3R_44() { if (jj_3R_45()) return true; return false; } private boolean jj_3_8() { if (jj_3R_23()) return true; return false; } private boolean jj_3R_57() { if (jj_3R_62()) return true; return false; } private boolean jj_3R_34() { if (jj_3R_35()) return true; return false; } private boolean jj_3_7() { if (jj_scan_token(4)) return true; if (jj_scan_token(52)) return true; return false; } private boolean jj_3R_25() { if (jj_scan_token(IDENT)) return true; if (jj_scan_token(44)) return true; return false; } private boolean jj_3_6() { if (jj_scan_token(51)) return true; if (jj_scan_token(IDENT)) return true; return false; } private boolean jj_3_5() { if (jj_scan_token(50)) return true; return false; } private boolean jj_3R_27() { if (jj_3R_34()) return true; return false; } private boolean jj_3_4() { if (jj_scan_token(49)) return true; return false; } private boolean jj_3R_65() { if (jj_scan_token(IDENT)) return true; return false; } private boolean jj_3R_43() { if (jj_3R_44()) return true; return false; } /** Generated Token Manager. */ public OgnlParserTokenManager token_source; JavaCharStream jj_input_stream; /** Current token. */ public Token token; /** Next token. */ public Token jj_nt; private int jj_ntk; private Token jj_scanpos, jj_lastpos; private int jj_la; /** Whether we are looking ahead. */ private boolean jj_lookingAhead = false; private boolean jj_semLA; private int jj_gen; final private int[] jj_la1 = new int[64]; static private int[] jj_la1_0; static private int[] jj_la1_1; static private int[] jj_la1_2; static { jj_la1_init_0(); jj_la1_init_1(); jj_la1_init_2(); } private static void jj_la1_init_0() { jj_la1_0 = new int[] {0x2,0x4,0x8,0x60,0x60,0x180,0x180,0x600,0x600,0x1800,0x1800,0x6000,0x6000,0x78000,0x18000,0x60000,0x78000,0x1ff80000,0x180000,0x600000,0x1800000,0x6000000,0x1ff80000,0xe0000000,0x60000000,0x80000000,0x0,0xe0000000,0x0,0x0,0x0,0x0,0x10000000,0x0,0x0,0x10000010,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x2,0x10000010,0x0,0x2,0x10000010,0x0,0x0,0x0,0x10,0x0,0x0,0x0,0x2,0x10000010,0x2,0x10000010,0x2,0x10000010,0x2,0x10000010,0x0,}; } private static void jj_la1_init_1() { jj_la1_1 = new int[] {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x7,0x0,0x1,0x6,0x7,0x18,0x18,0xe0,0xe0,0x200,0x800,0x400,0x35fd318,0x101800,0x0,0x400000,0x401000,0x101800,0x0,0x0,0x0,0x35fd318,0x1000000,0x0,0x35fd318,0x1c000,0x1000000,0x501000,0x0,0x0,0x0,0x800,0x0,0x35fd318,0x0,0x35fd318,0x0,0x35fd318,0x0,0x35fd318,0x100000,}; } private static void jj_la1_init_2() { jj_la1_2 = new int[] {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x39209,0x8,0x1,0x0,0x1,0x8,0x39200,0x1,0x0,0x39209,0x0,0x0,0x39209,0x39200,0x0,0x9,0x0,0x1,0x1,0x0,0x0,0x39209,0x0,0x39209,0x0,0x39209,0x0,0x39209,0x8,}; } final private JJCalls[] jj_2_rtns = new JJCalls[16]; private boolean jj_rescan = false; private int jj_gc = 0; /** Constructor with InputStream. */ public OgnlParser(java.io.InputStream stream) { this(stream, null); } /** Constructor with InputStream and supplied encoding */ public OgnlParser(java.io.InputStream stream, String encoding) { try { jj_input_stream = new JavaCharStream(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); } token_source = new OgnlParserTokenManager(jj_input_stream); token = new Token(); jj_ntk = -1; jj_gen = 0; for (int i = 0; i < 64; i++) jj_la1[i] = -1; for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); } /** Reinitialise. */ public void ReInit(java.io.InputStream stream) { ReInit(stream, null); } /** Reinitialise. */ public void ReInit(java.io.InputStream stream, String encoding) { try { jj_input_stream.ReInit(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); } token_source.ReInit(jj_input_stream); token = new Token(); jj_ntk = -1; jjtree.reset(); jj_gen = 0; for (int i = 0; i < 64; i++) jj_la1[i] = -1; for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); } /** Constructor. */ public OgnlParser(java.io.Reader stream) { jj_input_stream = new JavaCharStream(stream, 1, 1); token_source = new OgnlParserTokenManager(jj_input_stream); token = new Token(); jj_ntk = -1; jj_gen = 0; for (int i = 0; i < 64; i++) jj_la1[i] = -1; for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); } /** Reinitialise. */ public void ReInit(java.io.Reader stream) { jj_input_stream.ReInit(stream, 1, 1); token_source.ReInit(jj_input_stream); token = new Token(); jj_ntk = -1; jjtree.reset(); jj_gen = 0; for (int i = 0; i < 64; i++) jj_la1[i] = -1; for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); } /** Constructor with generated Token Manager. */ public OgnlParser(OgnlParserTokenManager tm) { token_source = tm; token = new Token(); jj_ntk = -1; jj_gen = 0; for (int i = 0; i < 64; i++) jj_la1[i] = -1; for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); } /** Reinitialise. */ public void ReInit(OgnlParserTokenManager tm) { token_source = tm; token = new Token(); jj_ntk = -1; jjtree.reset(); jj_gen = 0; for (int i = 0; i < 64; i++) jj_la1[i] = -1; for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); } private Token jj_consume_token(int kind) throws ParseException { Token oldToken; if ((oldToken = token).next != null) token = token.next; else token = token.next = token_source.getNextToken(); jj_ntk = -1; if (token.kind == kind) { jj_gen++; if (++jj_gc > 100) { jj_gc = 0; for (int i = 0; i < jj_2_rtns.length; i++) { JJCalls c = jj_2_rtns[i]; while (c != null) { if (c.gen < jj_gen) c.first = null; c = c.next; } } } return token; } token = oldToken; jj_kind = kind; throw generateParseException(); } static private final class LookaheadSuccess extends java.lang.Error { } final private LookaheadSuccess jj_ls = new LookaheadSuccess(); private boolean jj_scan_token(int kind) { if (jj_scanpos == jj_lastpos) { jj_la--; if (jj_scanpos.next == null) { jj_lastpos = jj_scanpos = jj_scanpos.next = token_source.getNextToken(); } else { jj_lastpos = jj_scanpos = jj_scanpos.next; } } else { jj_scanpos = jj_scanpos.next; } if (jj_rescan) { int i = 0; Token tok = token; while (tok != null && tok != jj_scanpos) { i++; tok = tok.next; } if (tok != null) jj_add_error_token(kind, i); } if (jj_scanpos.kind != kind) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) throw jj_ls; return false; } /** Get the next Token. */ final public Token getNextToken() { if (token.next != null) token = token.next; else token = token.next = token_source.getNextToken(); jj_ntk = -1; jj_gen++; return token; } /** Get the specific Token. */ final public Token getToken(int index) { Token t = jj_lookingAhead ? jj_scanpos : token; for (int i = 0; i < index; i++) { if (t.next != null) t = t.next; else t = t.next = token_source.getNextToken(); } return t; } private int jj_ntk() { if ((jj_nt=token.next) == null) return (jj_ntk = (token.next=token_source.getNextToken()).kind); else return (jj_ntk = jj_nt.kind); } private java.util.List jj_expentries = new java.util.ArrayList(); private int[] jj_expentry; private int jj_kind = -1; private int[] jj_lasttokens = new int[100]; private int jj_endpos; private void jj_add_error_token(int kind, int pos) { if (pos >= 100) return; if (pos == jj_endpos + 1) { jj_lasttokens[jj_endpos++] = kind; } else if (jj_endpos != 0) { jj_expentry = new int[jj_endpos]; for (int i = 0; i < jj_endpos; i++) { jj_expentry[i] = jj_lasttokens[i]; } jj_entries_loop: for (java.util.Iterator it = jj_expentries.iterator(); it.hasNext();) { int[] oldentry = (int[])(it.next()); if (oldentry.length == jj_expentry.length) { for (int i = 0; i < jj_expentry.length; i++) { if (oldentry[i] != jj_expentry[i]) { continue jj_entries_loop; } } jj_expentries.add(jj_expentry); break jj_entries_loop; } } if (pos != 0) jj_lasttokens[(jj_endpos = pos) - 1] = kind; } } /** Generate ParseException. */ public ParseException generateParseException() { jj_expentries.clear(); boolean[] la1tokens = new boolean[86]; if (jj_kind >= 0) { la1tokens[jj_kind] = true; jj_kind = -1; } for (int i = 0; i < 64; i++) { if (jj_la1[i] == jj_gen) { for (int j = 0; j < 32; j++) { if ((jj_la1_0[i] & (1< jj_gen) { jj_la = p.arg; jj_lastpos = jj_scanpos = p.first; switch (i) { case 0: jj_3_1(); break; case 1: jj_3_2(); break; case 2: jj_3_3(); break; case 3: jj_3_4(); break; case 4: jj_3_5(); break; case 5: jj_3_6(); break; case 6: jj_3_7(); break; case 7: jj_3_8(); break; case 8: jj_3_9(); break; case 9: jj_3_10(); break; case 10: jj_3_11(); break; case 11: jj_3_12(); break; case 12: jj_3_13(); break; case 13: jj_3_14(); break; case 14: jj_3_15(); break; case 15: jj_3_16(); break; } } p = p.next; } while (p != null); } catch(LookaheadSuccess ls) { } } jj_rescan = false; } private void jj_save(int index, int xla) { JJCalls p = jj_2_rtns[index]; while (p.gen > jj_gen) { if (p.next == null) { p = p.next = new JJCalls(); break; } p = p.next; } p.gen = jj_gen + xla - jj_la; p.first = token; p.arg = xla; } static final class JJCalls { int gen; Token first; int arg; JJCalls next; } } ognl-2.7.3.orig/src/java/ognl/Evaluation.java0000644000175000017500000002445310561411075020746 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 1998-2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package ognl; /** An Evaluation is and object that holds a node being evaluated and the source from which that node will take extract its value. It refers to child evaluations that occur as a result of the nodes' evaluation. */ public class Evaluation extends Object { private SimpleNode node; private Object source; private boolean setOperation; private Object result; private Throwable exception; private Evaluation parent; private Evaluation next; private Evaluation previous; private Evaluation firstChild; private Evaluation lastChild; /** Constructs a new "get" Evaluation from the node and source given. */ public Evaluation(SimpleNode node, Object source) { super(); this.node = node; this.source = source; } /** Constructs a new Evaluation from the node and source given. If setOperation is true this Evaluation represents a "set" as opposed to a "get". */ public Evaluation(SimpleNode node, Object source, boolean setOperation) { this(node, source); this.setOperation = setOperation; } /** Returns the SimpleNode for this Evaluation */ public SimpleNode getNode() { return node; } /** Sets the node of the evaluation. Normally applications do not need to set this. Notable exceptions to this rule are custom evaluators that choose between navigable objects (as in a multi-root evaluator where the navigable node is chosen at runtime). */ public void setNode(SimpleNode value) { node = value; } /** Returns the source object on which this Evaluation operated. */ public Object getSource() { return source; } /** Sets the source of the evaluation. Normally applications do not need to set this. Notable exceptions to this rule are custom evaluators that choose between navigable objects (as in a multi-root evaluator where the navigable node is chosen at runtime). */ public void setSource(Object value) { source = value; } /** Returns true if this Evaluation represents a set operation. */ public boolean isSetOperation() { return setOperation; } /** Marks the Evaluation as a set operation if the value is true, else marks it as a get operation. */ public void setSetOperation(boolean value) { setOperation = value; } /** Returns the result of the Evaluation, or null if it was a set operation. */ public Object getResult() { return result; } /** Sets the result of the Evaluation. This method is normally only used interally and should not be set without knowledge of what you are doing. */ public void setResult(Object value) { result = value; } /** Returns the exception that occurred as a result of evaluating the Evaluation, or null if no exception occurred. */ public Throwable getException() { return exception; } /** Sets the exception that occurred as a result of evaluating the Evaluation. This method is normally only used interally and should not be set without knowledge of what you are doing. */ public void setException(Throwable value) { exception = value; } /** Returns the parent evaluation of this evaluation. If this returns null then it is is the root evaluation of a tree. */ public Evaluation getParent() { return parent; } /** Returns the next sibling of this evaluation. Returns null if this is the last in a chain of evaluations. */ public Evaluation getNext() { return next; } /** Returns the previous sibling of this evaluation. Returns null if this is the first in a chain of evaluations. */ public Evaluation getPrevious() { return previous; } /** Returns the first child of this evaluation. Returns null if there are no children. */ public Evaluation getFirstChild() { return firstChild; } /** Returns the last child of this evaluation. Returns null if there are no children. */ public Evaluation getLastChild() { return lastChild; } /** Gets the first descendent. In any Evaluation tree this will the Evaluation that was first executed. */ public Evaluation getFirstDescendant() { if (firstChild != null) { return firstChild.getFirstDescendant(); } return this; } /** Gets the last descendent. In any Evaluation tree this will the Evaluation that was most recently executing. */ public Evaluation getLastDescendant() { if (lastChild != null) { return lastChild.getLastDescendant(); } return this; } /** Adds a child to the list of children of this evaluation. The parent of the child is set to the receiver and the children references are modified in the receiver to reflect the new child. The lastChild of the receiver is set to the child, and the firstChild is set also if child is the first (or only) child. */ public void addChild(Evaluation child) { if (firstChild == null) { firstChild = lastChild = child; } else { if (firstChild == lastChild) { firstChild.next = child; lastChild = child; lastChild.previous = firstChild; } else { child.previous = lastChild; lastChild.next = child; lastChild = child; } } child.parent = this; } /** Reinitializes this Evaluation to the parameters specified. */ public void init(SimpleNode node, Object source, boolean setOperation) { this.node = node; this.source = source; this.setOperation = setOperation; result = null; exception = null; parent = null; next = null; previous = null; firstChild = null; lastChild = null; } /** Resets this Evaluation to the initial state. */ public void reset() { init(null, null, false); } /** Produces a String value for the Evaluation. If compact is true then a more compact form of the description only including the node type and unique identifier is shown, else a full description including source and result are shown. If showChildren is true the child evaluations are printed using the depth string given as a prefix. */ public String toString(boolean compact, boolean showChildren, String depth) { String stringResult; if (compact) { stringResult = depth + "<" + node.getClass().getName() + " " + System.identityHashCode(this) + ">"; } else { String ss = (source != null) ? source.getClass().getName() : "null", rs = (result != null) ? result.getClass().getName() : "null"; stringResult = depth + "<" + node.getClass().getName() + ": [" + (setOperation ? "set" : "get") + "] source = " + ss + ", result = " + result + " [" + rs + "]>"; } if (showChildren) { Evaluation child = firstChild; stringResult += "\n"; while (child != null) { stringResult += child.toString(compact, depth + " "); child = child.next; } } return stringResult; } /** Produces a String value for the Evaluation. If compact is true then a more compact form of the description only including the node type and unique identifier is shown, else a full description including source and result are shown. Child evaluations are printed using the depth string given as a prefix. */ public String toString(boolean compact, String depth) { return toString(compact, true, depth); } /** Returns a String description of the Evaluation. */ public String toString() { return toString(false, ""); } } ognl-2.7.3.orig/src/java/ognl/PropertyAccessor.java0000644000175000017500000001242110745155540022144 0ustar drazzibdrazzib// -------------------------------------------------------------------------- // Copyright (c) 1998-2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. // -------------------------------------------------------------------------- package ognl; import java.util.Map; /** * This interface defines methods for setting and getting a property from a target object. A * "property" in this case is a named data value that takes the generic form of an Object---the same * definition as is used by beans. But the operational semantics of the term will vary by * implementation of this interface: a bean-style implementation will get and set properties as * beans do, by reflection on the target object's class, but other implementations are possible, * such as one that uses the property name as a key into a map. *

* An implementation of this interface will often require that its target objects all be of some * particular type. For example, the MapPropertyAccessor class requires that its targets all * implement the java.util.Map interface. *

* Note that the "name" of a property is represented by a generic Object. Some implementations may * require properties' names to be Strings, while others may allow them to be other types---for * example, ArrayPropertyAccessor treats Number names as indexes into the target object, which must * be an array. * * @author Luke Blanshard (blanshlu@netscape.net) * @author Drew Davidson (drew@ognl.org) */ public interface PropertyAccessor { /** * Extracts and returns the property of the given name from the given target object. * * @param context * The current execution context. * @param target * the object to get the property from * @param name * the name of the property to get. * * @return the current value of the given property in the given object * @exception OgnlException * if there is an error locating the property in the given object */ Object getProperty(Map context, Object target, Object name) throws OgnlException; /** * Sets the value of the property of the given name in the given target object. * * @param context * The current execution context. * @param target * the object to set the property in * @param name * the name of the property to set * @param value * the new value for the property. * * @exception OgnlException * if there is an error setting the property in the given object */ void setProperty(Map context, Object target, Object name, Object value) throws OgnlException; /** * Returns a java string representing the textual method that should be called to access a * particular element. (ie "get") * * @param context * The current execution context. * @param target * The current object target on the expression tree being evaluated. * @param index * The index object that will be placed inside the string to access the value. * * @return The source accessor method to call. */ String getSourceAccessor(OgnlContext context, Object target, Object index); /** * Returns a java string representing the textual method that should be called to set a * particular element. (ie "set") * * @param context * The current execution context. * @param target * The current object target on the expression tree being evaluated. * @param index * The index object that will be placed inside the string to set the value. * @return The source setter method to call. */ String getSourceSetter(OgnlContext context, Object target, Object index); } ognl-2.7.3.orig/src/java/ognl/ArrayPropertyAccessor.java0000644000175000017500000002105510754136360023145 0ustar drazzibdrazzib// -------------------------------------------------------------------------- // Copyright (c) 1998-2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. // -------------------------------------------------------------------------- package ognl; import java.lang.reflect.Array; import java.util.Map; /** * Implementation of PropertyAccessor that uses numbers and dynamic subscripts as properties to * index into Java arrays. * * @author Luke Blanshard (blanshlu@netscape.net) * @author Drew Davidson (drew@ognl.org) */ public class ArrayPropertyAccessor extends ObjectPropertyAccessor implements PropertyAccessor { public Object getProperty(Map context, Object target, Object name) throws OgnlException { Object result = null; if (name instanceof String) { if (name.equals("length")) { result = new Integer(Array.getLength(target)); } else { result = super.getProperty(context, target, name); } } else { Object index = name; if (index instanceof DynamicSubscript) { int len = Array.getLength(target); switch(((DynamicSubscript) index).getFlag()) { case DynamicSubscript.ALL: result = Array.newInstance(target.getClass().getComponentType(), len); System.arraycopy(target, 0, result, 0, len); break; case DynamicSubscript.FIRST: index = new Integer((len > 0) ? 0 : -1); break; case DynamicSubscript.MID: index = new Integer((len > 0) ? (len / 2) : -1); break; case DynamicSubscript.LAST: index = new Integer((len > 0) ? (len - 1) : -1); break; } } if (result == null) { if (index instanceof Number) { int i = ((Number) index).intValue(); result = (i >= 0) ? Array.get(target, i) : null; } else { throw new NoSuchPropertyException(target, index); } } } return result; } public void setProperty(Map context, Object target, Object name, Object value) throws OgnlException { Object index = name; boolean isNumber = (index instanceof Number); if (isNumber || (index instanceof DynamicSubscript)) { TypeConverter converter = ((OgnlContext) context).getTypeConverter(); Object convertedValue; convertedValue = converter.convertValue(context, target, null, name.toString(), value, target.getClass().getComponentType()); if (isNumber) { int i = ((Number) index).intValue(); if (i >= 0) { Array.set(target, i, convertedValue); } } else { int len = Array.getLength(target); switch(((DynamicSubscript) index).getFlag()) { case DynamicSubscript.ALL: System.arraycopy(target, 0, convertedValue, 0, len); return; case DynamicSubscript.FIRST: index = new Integer((len > 0) ? 0 : -1); break; case DynamicSubscript.MID: index = new Integer((len > 0) ? (len / 2) : -1); break; case DynamicSubscript.LAST: index = new Integer((len > 0) ? (len - 1) : -1); break; } } } else { if (name instanceof String) { super.setProperty(context, target, name, value); } else { throw new NoSuchPropertyException(target, index); } } } public String getSourceAccessor(OgnlContext context, Object target, Object index) { String indexStr = index.toString(); // need to convert to primitive for list index access // System.out.println("index class " + index.getClass() + " current type " + context.getCurrentType() + " current object class " + context.getCurrentObject().getClass()); if (context.getCurrentType() != null && !context.getCurrentType().isPrimitive() && Number.class.isAssignableFrom(context.getCurrentType())) { indexStr += "." + OgnlRuntime.getNumericValueGetter(context.getCurrentType()); } else if (context.getCurrentObject() != null && Number.class.isAssignableFrom(context.getCurrentObject().getClass()) && !context.getCurrentType().isPrimitive()) { // means it needs to be cast first as well String toString = String.class.isInstance(index) && context.getCurrentType() != Object.class ? "" : ".toString()"; indexStr = "ognl.OgnlOps#getIntValue(" + indexStr + toString + ")"; } context.setCurrentAccessor(target.getClass()); context.setCurrentType(target.getClass().getComponentType()); return "[" + indexStr + "]"; } public String getSourceSetter(OgnlContext context, Object target, Object index) { String indexStr = index.toString(); // need to convert to primitive for list index access if (context.getCurrentType() != null && !context.getCurrentType().isPrimitive() && Number.class.isAssignableFrom(context.getCurrentType())) { indexStr += "." + OgnlRuntime.getNumericValueGetter(context.getCurrentType()); } else if (context.getCurrentObject() != null && Number.class.isAssignableFrom(context.getCurrentObject().getClass()) && !context.getCurrentType().isPrimitive()) { // means it needs to be cast first as well String toString = String.class.isInstance(index) && context.getCurrentType() != Object.class ? "" : ".toString()"; indexStr = "ognl.OgnlOps#getIntValue(" + indexStr + toString + ")"; } Class type = target.getClass().isArray() ? target.getClass().getComponentType() : target.getClass(); context.setCurrentAccessor(target.getClass()); context.setCurrentType(target.getClass().getComponentType()); if (type.isPrimitive()) { Class wrapClass = OgnlRuntime.getPrimitiveWrapperClass(type); return "[" + indexStr + "]=((" + wrapClass.getName() + ")ognl.OgnlOps.convertValue($3," + wrapClass.getName() + ".class, true))." + OgnlRuntime.getNumericValueGetter(wrapClass); } else { return "[" + indexStr + "]=ognl.OgnlOps.convertValue($3," + type.getName() + ".class)"; } } } ognl-2.7.3.orig/src/java/ognl/OgnlParserTokenManager.java0000644000175000017500000014001210746450726023210 0ustar drazzibdrazzib/* Generated By:JJTree&JavaCC: Do not edit this line. OgnlParserTokenManager.java */ package ognl; import java.math.BigDecimal; import java.math.BigInteger; /** Token Manager. */ public class OgnlParserTokenManager implements OgnlParserConstants { /** Holds the last value computed by a constant token. */ Object literalValue; /** Holds the last character escaped or in a character literal. */ private char charValue; /** Holds char literal start token. */ private char charLiteralStartQuote; /** Holds the last string literal parsed. */ private StringBuffer stringBuffer; /** Converts an escape sequence into a character value. */ private char escapeChar() { int ofs = image.length() - 1; switch ( image.charAt(ofs) ) { case 'n': return '\n'; case 'r': return '\r'; case 't': return '\t'; case 'b': return '\b'; case 'f': return '\f'; case '\\': return '\\'; case '\'': return '\''; case '\"': return '\"'; } // Otherwise, it's an octal number. Find the backslash and convert. while ( image.charAt(--ofs) != '\\' ) {} int value = 0; while ( ++ofs < image.length() ) value = (value << 3) | (image.charAt(ofs) - '0'); return (char) value; } private Object makeInt() { Object result; String s = image.toString(); int base = 10; if ( s.charAt(0) == '0' ) base = (s.length() > 1 && (s.charAt(1) == 'x' || s.charAt(1) == 'X'))? 16 : 8; if ( base == 16 ) s = s.substring(2); // Trim the 0x off the front switch ( s.charAt(s.length()-1) ) { case 'l': case 'L': result = Long.valueOf( s.substring(0,s.length()-1), base ); break; case 'h': case 'H': result = new BigInteger( s.substring(0,s.length()-1), base ); break; default: result = Integer.valueOf( s, base ); break; } return result; } private Object makeFloat() { String s = image.toString(); switch ( s.charAt(s.length()-1) ) { case 'f': case 'F': return Float.valueOf( s ); case 'b': case 'B': return new BigDecimal( s.substring(0,s.length()-1) ); case 'd': case 'D': default: return Double.valueOf( s ); } } /** Debug output. */ public java.io.PrintStream debugStream = System.out; /** Set debug output. */ public void setDebugStream(java.io.PrintStream ds) { debugStream = ds; } private final int jjStopStringLiteralDfa_0(int pos, long active0, long active1) { switch (pos) { case 0: if ((active0 & 0x201c4055d555540L) != 0L) { jjmatchedKind = 64; return 1; } if ((active0 & 0x400000000000000L) != 0L) return 1; if ((active0 & 0x10000000000000L) != 0L) return 3; if ((active0 & 0x80000000000L) != 0L) return 9; return -1; case 1: if ((active0 & 0x201c00550045500L) != 0L) { if (jjmatchedPos != 1) { jjmatchedKind = 64; jjmatchedPos = 1; } return 1; } if ((active0 & 0x4000d510040L) != 0L) return 1; return -1; case 2: if ((active0 & 0x1c40400004000L) != 0L) { jjmatchedKind = 64; jjmatchedPos = 2; return 1; } if ((active0 & 0x200000155041500L) != 0L) return 1; return -1; case 3: if ((active0 & 0x1400400004000L) != 0L) return 1; if ((active0 & 0x840000000000L) != 0L) { jjmatchedKind = 64; jjmatchedPos = 3; return 1; } return -1; case 4: if ((active0 & 0x800000000000L) != 0L) return 1; if ((active0 & 0x40000000000L) != 0L) { jjmatchedKind = 64; jjmatchedPos = 4; return 1; } return -1; case 5: if ((active0 & 0x40000000000L) != 0L) { jjmatchedKind = 64; jjmatchedPos = 5; return 1; } return -1; case 6: if ((active0 & 0x40000000000L) != 0L) { jjmatchedKind = 64; jjmatchedPos = 6; return 1; } return -1; case 7: if ((active0 & 0x40000000000L) != 0L) { jjmatchedKind = 64; jjmatchedPos = 7; return 1; } return -1; case 8: if ((active0 & 0x40000000000L) != 0L) { jjmatchedKind = 64; jjmatchedPos = 8; return 1; } return -1; default : return -1; } } private final int jjStartNfa_0(int pos, long active0, long active1) { return jjMoveNfa_0(jjStopStringLiteralDfa_0(pos, active0, active1), pos + 1); } private int jjStopAtPos(int pos, int kind) { jjmatchedKind = kind; jjmatchedPos = pos; return pos + 1; } private int jjMoveStringLiteralDfa0_0() { switch(curChar) { case 33: jjmatchedKind = 41; return jjMoveStringLiteralDfa1_0(0x20000L); case 34: return jjStopAtPos(0, 70); case 35: jjmatchedKind = 51; return jjMoveStringLiteralDfa1_0(0x6000000000000L); case 36: return jjStartNfaWithStates_0(0, 58, 1); case 37: return jjStopAtPos(0, 39); case 38: jjmatchedKind = 13; return jjMoveStringLiteralDfa1_0(0x80L); case 39: return jjStopAtPos(0, 69); case 40: return jjStopAtPos(0, 44); case 41: return jjStopAtPos(0, 45); case 42: return jjStopAtPos(0, 37); case 43: return jjStopAtPos(0, 35); case 44: return jjStopAtPos(0, 1); case 45: return jjStopAtPos(0, 36); case 46: return jjStartNfaWithStates_0(0, 43, 9); case 47: return jjStopAtPos(0, 38); case 58: return jjStopAtPos(0, 4); case 60: jjmatchedKind = 19; return jjMoveStringLiteralDfa1_0(0x20800000L); case 61: jjmatchedKind = 2; return jjMoveStringLiteralDfa1_0(0x8000L); case 62: jjmatchedKind = 21; return jjMoveStringLiteralDfa1_0(0x282000000L); case 63: return jjStopAtPos(0, 3); case 64: return jjStopAtPos(0, 56); case 91: return jjStartNfaWithStates_0(0, 52, 3); case 93: return jjStopAtPos(0, 53); case 94: return jjStopAtPos(0, 11); case 96: return jjStopAtPos(0, 68); case 97: return jjMoveStringLiteralDfa1_0(0x100L); case 98: return jjMoveStringLiteralDfa1_0(0x4400L); case 101: return jjMoveStringLiteralDfa1_0(0x10000L); case 102: return jjMoveStringLiteralDfa1_0(0x800000000000L); case 103: return jjMoveStringLiteralDfa1_0(0x4400000L); case 105: return jjMoveStringLiteralDfa1_0(0x40008000000L); case 108: return jjMoveStringLiteralDfa1_0(0x1100000L); case 110: return jjMoveStringLiteralDfa1_0(0x201000010040000L); case 111: return jjMoveStringLiteralDfa1_0(0x40L); case 115: return jjMoveStringLiteralDfa1_0(0x140000000L); case 116: return jjMoveStringLiteralDfa1_0(0x400000000000L); case 117: return jjMoveStringLiteralDfa1_0(0x400000000L); case 120: return jjMoveStringLiteralDfa1_0(0x1000L); case 123: return jjStopAtPos(0, 54); case 124: jjmatchedKind = 9; return jjMoveStringLiteralDfa1_0(0x20L); case 125: return jjStopAtPos(0, 55); case 126: return jjStopAtPos(0, 40); default : return jjMoveNfa_0(0, 0); } } private int jjMoveStringLiteralDfa1_0(long active0) { try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { jjStopStringLiteralDfa_0(0, active0, 0L); return 1; } switch(curChar) { case 38: if ((active0 & 0x80L) != 0L) return jjStopAtPos(1, 7); break; case 60: if ((active0 & 0x20000000L) != 0L) return jjStopAtPos(1, 29); break; case 61: if ((active0 & 0x8000L) != 0L) return jjStopAtPos(1, 15); else if ((active0 & 0x20000L) != 0L) return jjStopAtPos(1, 17); else if ((active0 & 0x800000L) != 0L) return jjStopAtPos(1, 23); else if ((active0 & 0x2000000L) != 0L) return jjStopAtPos(1, 25); break; case 62: if ((active0 & 0x80000000L) != 0L) { jjmatchedKind = 31; jjmatchedPos = 1; } return jjMoveStringLiteralDfa2_0(active0, 0x200000000L); case 97: return jjMoveStringLiteralDfa2_0(active0, 0x800000004000L); case 101: return jjMoveStringLiteralDfa2_0(active0, 0x200000000040000L); case 104: return jjMoveStringLiteralDfa2_0(active0, 0x140000000L); case 110: if ((active0 & 0x8000000L) != 0L) { jjmatchedKind = 27; jjmatchedPos = 1; } return jjMoveStringLiteralDfa2_0(active0, 0x40000000100L); case 111: return jjMoveStringLiteralDfa2_0(active0, 0x10001400L); case 113: if ((active0 & 0x10000L) != 0L) return jjStartNfaWithStates_0(1, 16, 1); break; case 114: if ((active0 & 0x40L) != 0L) return jjStartNfaWithStates_0(1, 6, 1); return jjMoveStringLiteralDfa2_0(active0, 0x4400000000000L); case 115: return jjMoveStringLiteralDfa2_0(active0, 0x400000000L); case 116: if ((active0 & 0x100000L) != 0L) { jjmatchedKind = 20; jjmatchedPos = 1; } else if ((active0 & 0x400000L) != 0L) { jjmatchedKind = 22; jjmatchedPos = 1; } return jjMoveStringLiteralDfa2_0(active0, 0x2000005000000L); case 117: return jjMoveStringLiteralDfa2_0(active0, 0x1000000000000L); case 124: if ((active0 & 0x20L) != 0L) return jjStopAtPos(1, 5); break; default : break; } return jjStartNfa_0(0, active0, 0L); } private int jjMoveStringLiteralDfa2_0(long old0, long active0) { if (((active0 &= old0)) == 0L) return jjStartNfa_0(0, old0, 0L); try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { jjStopStringLiteralDfa_0(1, active0, 0L); return 2; } switch(curChar) { case 62: if ((active0 & 0x200000000L) != 0L) return jjStopAtPos(2, 33); break; case 100: if ((active0 & 0x100L) != 0L) return jjStartNfaWithStates_0(2, 8, 1); break; case 101: if ((active0 & 0x1000000L) != 0L) return jjStartNfaWithStates_0(2, 24, 1); else if ((active0 & 0x4000000L) != 0L) return jjStartNfaWithStates_0(2, 26, 1); break; case 104: return jjMoveStringLiteralDfa3_0(active0, 0x2000400000000L); case 108: if ((active0 & 0x40000000L) != 0L) return jjStartNfaWithStates_0(2, 30, 1); return jjMoveStringLiteralDfa3_0(active0, 0x1800000000000L); case 110: return jjMoveStringLiteralDfa3_0(active0, 0x4000L); case 111: return jjMoveStringLiteralDfa3_0(active0, 0x4000000000000L); case 113: if ((active0 & 0x40000L) != 0L) return jjStartNfaWithStates_0(2, 18, 1); break; case 114: if ((active0 & 0x400L) != 0L) return jjStartNfaWithStates_0(2, 10, 1); else if ((active0 & 0x1000L) != 0L) return jjStartNfaWithStates_0(2, 12, 1); else if ((active0 & 0x100000000L) != 0L) return jjStartNfaWithStates_0(2, 32, 1); break; case 115: return jjMoveStringLiteralDfa3_0(active0, 0x40000000000L); case 116: if ((active0 & 0x10000000L) != 0L) return jjStartNfaWithStates_0(2, 28, 1); break; case 117: return jjMoveStringLiteralDfa3_0(active0, 0x400000000000L); case 119: if ((active0 & 0x200000000000000L) != 0L) return jjStartNfaWithStates_0(2, 57, 1); break; default : break; } return jjStartNfa_0(1, active0, 0L); } private int jjMoveStringLiteralDfa3_0(long old0, long active0) { if (((active0 &= old0)) == 0L) return jjStartNfa_0(1, old0, 0L); try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { jjStopStringLiteralDfa_0(2, active0, 0L); return 3; } switch(curChar) { case 100: if ((active0 & 0x4000L) != 0L) return jjStartNfaWithStates_0(3, 14, 1); break; case 101: if ((active0 & 0x400000000000L) != 0L) return jjStartNfaWithStates_0(3, 46, 1); break; case 105: return jjMoveStringLiteralDfa4_0(active0, 0x2000000000000L); case 108: if ((active0 & 0x1000000000000L) != 0L) return jjStartNfaWithStates_0(3, 48, 1); break; case 111: return jjMoveStringLiteralDfa4_0(active0, 0x4000000000000L); case 114: if ((active0 & 0x400000000L) != 0L) return jjStartNfaWithStates_0(3, 34, 1); break; case 115: return jjMoveStringLiteralDfa4_0(active0, 0x800000000000L); case 116: return jjMoveStringLiteralDfa4_0(active0, 0x40000000000L); default : break; } return jjStartNfa_0(2, active0, 0L); } private int jjMoveStringLiteralDfa4_0(long old0, long active0) { if (((active0 &= old0)) == 0L) return jjStartNfa_0(2, old0, 0L); try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { jjStopStringLiteralDfa_0(3, active0, 0L); return 4; } switch(curChar) { case 97: return jjMoveStringLiteralDfa5_0(active0, 0x40000000000L); case 101: if ((active0 & 0x800000000000L) != 0L) return jjStartNfaWithStates_0(4, 47, 1); break; case 115: if ((active0 & 0x2000000000000L) != 0L) return jjStopAtPos(4, 49); break; case 116: if ((active0 & 0x4000000000000L) != 0L) return jjStopAtPos(4, 50); break; default : break; } return jjStartNfa_0(3, active0, 0L); } private int jjMoveStringLiteralDfa5_0(long old0, long active0) { if (((active0 &= old0)) == 0L) return jjStartNfa_0(3, old0, 0L); try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { jjStopStringLiteralDfa_0(4, active0, 0L); return 5; } switch(curChar) { case 110: return jjMoveStringLiteralDfa6_0(active0, 0x40000000000L); default : break; } return jjStartNfa_0(4, active0, 0L); } private int jjMoveStringLiteralDfa6_0(long old0, long active0) { if (((active0 &= old0)) == 0L) return jjStartNfa_0(4, old0, 0L); try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { jjStopStringLiteralDfa_0(5, active0, 0L); return 6; } switch(curChar) { case 99: return jjMoveStringLiteralDfa7_0(active0, 0x40000000000L); default : break; } return jjStartNfa_0(5, active0, 0L); } private int jjMoveStringLiteralDfa7_0(long old0, long active0) { if (((active0 &= old0)) == 0L) return jjStartNfa_0(5, old0, 0L); try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { jjStopStringLiteralDfa_0(6, active0, 0L); return 7; } switch(curChar) { case 101: return jjMoveStringLiteralDfa8_0(active0, 0x40000000000L); default : break; } return jjStartNfa_0(6, active0, 0L); } private int jjMoveStringLiteralDfa8_0(long old0, long active0) { if (((active0 &= old0)) == 0L) return jjStartNfa_0(6, old0, 0L); try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { jjStopStringLiteralDfa_0(7, active0, 0L); return 8; } switch(curChar) { case 111: return jjMoveStringLiteralDfa9_0(active0, 0x40000000000L); default : break; } return jjStartNfa_0(7, active0, 0L); } private int jjMoveStringLiteralDfa9_0(long old0, long active0) { if (((active0 &= old0)) == 0L) return jjStartNfa_0(7, old0, 0L); try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { jjStopStringLiteralDfa_0(8, active0, 0L); return 9; } switch(curChar) { case 102: if ((active0 & 0x40000000000L) != 0L) return jjStartNfaWithStates_0(9, 42, 1); break; default : break; } return jjStartNfa_0(8, active0, 0L); } private int jjStartNfaWithStates_0(int pos, int kind, int state) { jjmatchedKind = kind; jjmatchedPos = pos; try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { return pos + 1; } return jjMoveNfa_0(state, pos + 1); } static final long[] jjbitVec0 = { 0x1ff00000fffffffeL, 0xffffffffffffc000L, 0xffffffffL, 0x600000000000000L }; static final long[] jjbitVec2 = { 0x0L, 0x0L, 0x0L, 0xff7fffffff7fffffL }; static final long[] jjbitVec3 = { 0x0L, 0xffffffffffffffffL, 0xffffffffffffffffL, 0xffffffffffffffffL }; static final long[] jjbitVec4 = { 0xffffffffffffffffL, 0xffffffffffffffffL, 0xffffL, 0x0L }; static final long[] jjbitVec5 = { 0xffffffffffffffffL, 0xffffffffffffffffL, 0x0L, 0x0L }; static final long[] jjbitVec6 = { 0x3fffffffffffL, 0x0L, 0x0L, 0x0L }; private int jjMoveNfa_0(int startState, int curPos) { //int[] nextStates; // not used int startsAt = 0; jjnewStateCnt = 27; int i = 1; jjstateSet[0] = startState; //int j; // not used int kind = 0x7fffffff; for (;;) { if (++jjround == 0x7fffffff) ReInitRounds(); if (curChar < 64) { long l = 1L << curChar; do { switch(jjstateSet[--i]) { case 0: if ((0x3ff000000000000L & l) != 0L) jjCheckNAddStates(0, 5); else if (curChar == 46) jjCheckNAdd(9); else if (curChar == 36) { if (kind > 64) kind = 64; jjCheckNAdd(1); } if ((0x3fe000000000000L & l) != 0L) { if (kind > 80) kind = 80; jjCheckNAddTwoStates(6, 7); } else if (curChar == 48) { if (kind > 80) kind = 80; jjCheckNAddStates(6, 8); } break; case 1: if ((0x3ff001000000000L & l) == 0L) break; if (kind > 64) kind = 64; jjCheckNAdd(1); break; case 3: if ((0x41000000000L & l) != 0L) jjstateSet[jjnewStateCnt++] = 4; break; case 5: if ((0x3fe000000000000L & l) == 0L) break; if (kind > 80) kind = 80; jjCheckNAddTwoStates(6, 7); break; case 6: if ((0x3ff000000000000L & l) == 0L) break; if (kind > 80) kind = 80; jjCheckNAddTwoStates(6, 7); break; case 8: if (curChar == 46) jjCheckNAdd(9); break; case 9: if ((0x3ff000000000000L & l) == 0L) break; if (kind > 81) kind = 81; jjCheckNAddStates(9, 11); break; case 11: if ((0x280000000000L & l) != 0L) jjCheckNAdd(12); break; case 12: if ((0x3ff000000000000L & l) == 0L) break; if (kind > 81) kind = 81; jjCheckNAddTwoStates(12, 13); break; case 14: if ((0x3ff000000000000L & l) != 0L) jjCheckNAddStates(0, 5); break; case 15: if ((0x3ff000000000000L & l) != 0L) jjCheckNAddTwoStates(15, 16); break; case 16: if (curChar != 46) break; if (kind > 81) kind = 81; jjCheckNAddStates(12, 14); break; case 17: if ((0x3ff000000000000L & l) == 0L) break; if (kind > 81) kind = 81; jjCheckNAddStates(12, 14); break; case 18: if ((0x3ff000000000000L & l) != 0L) jjCheckNAddTwoStates(18, 19); break; case 20: if ((0x280000000000L & l) != 0L) jjCheckNAdd(21); break; case 21: if ((0x3ff000000000000L & l) == 0L) break; if (kind > 81) kind = 81; jjCheckNAddTwoStates(21, 13); break; case 22: if ((0x3ff000000000000L & l) != 0L) jjCheckNAddTwoStates(22, 13); break; case 23: if (curChar != 48) break; if (kind > 80) kind = 80; jjCheckNAddStates(6, 8); break; case 24: if ((0xff000000000000L & l) == 0L) break; if (kind > 80) kind = 80; jjCheckNAddTwoStates(24, 7); break; case 26: if ((0x3ff000000000000L & l) == 0L) break; if (kind > 80) kind = 80; jjCheckNAddTwoStates(26, 7); break; default : break; } } while(i != startsAt); } else if (curChar < 128) { long l = 1L << (curChar & 077); do { switch(jjstateSet[--i]) { case 0: if ((0x7fffffe87fffffeL & l) != 0L) { if (kind > 64) kind = 64; jjCheckNAdd(1); } else if (curChar == 91) jjstateSet[jjnewStateCnt++] = 3; break; case 1: if ((0x7fffffe87fffffeL & l) == 0L) break; if (kind > 64) kind = 64; jjCheckNAdd(1); break; case 2: if (curChar == 91) jjstateSet[jjnewStateCnt++] = 3; break; case 3: if ((0x1000000040000000L & l) != 0L) jjstateSet[jjnewStateCnt++] = 4; break; case 4: if (curChar == 93) kind = 67; break; case 7: if ((0x110000001100L & l) != 0L && kind > 80) kind = 80; break; case 10: if ((0x2000000020L & l) != 0L) jjAddStates(15, 16); break; case 13: if ((0x5400000054L & l) != 0L && kind > 81) kind = 81; break; case 19: if ((0x2000000020L & l) != 0L) jjAddStates(17, 18); break; case 25: if ((0x100000001000000L & l) != 0L) jjCheckNAdd(26); break; case 26: if ((0x7e0000007eL & l) == 0L) break; if (kind > 80) kind = 80; jjCheckNAddTwoStates(26, 7); break; default : break; } } while(i != startsAt); } else { int hiByte = (int)(curChar >> 8); int i1 = hiByte >> 6; long l1 = 1L << (hiByte & 077); int i2 = (curChar & 0xff) >> 6; long l2 = 1L << (curChar & 077); do { switch(jjstateSet[--i]) { case 0: case 1: if (!jjCanMove_0(hiByte, i1, i2, l1, l2)) break; if (kind > 64) kind = 64; jjCheckNAdd(1); break; default : break; } } while(i != startsAt); } if (kind != 0x7fffffff) { jjmatchedKind = kind; jjmatchedPos = curPos; kind = 0x7fffffff; } ++curPos; if ((i = jjnewStateCnt) == (startsAt = 27 - (jjnewStateCnt = startsAt))) return curPos; try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { return curPos; } } } private final int jjStopStringLiteralDfa_2(int pos, long active0, long active1) { switch (pos) { default : return -1; } } private final int jjStartNfa_2(int pos, long active0, long active1) { return jjMoveNfa_2(jjStopStringLiteralDfa_2(pos, active0, active1), pos + 1); } private int jjMoveStringLiteralDfa0_2() { switch(curChar) { case 96: return jjStopAtPos(0, 76); default : return jjMoveNfa_2(0, 0); } } static final long[] jjbitVec7 = { 0xfffffffffffffffeL, 0xffffffffffffffffL, 0xffffffffffffffffL, 0xffffffffffffffffL }; static final long[] jjbitVec8 = { 0x0L, 0x0L, 0xffffffffffffffffL, 0xffffffffffffffffL }; private int jjMoveNfa_2(int startState, int curPos) { //int[] nextStates; // not used int startsAt = 0; jjnewStateCnt = 6; int i = 1; jjstateSet[0] = startState; //int j; // not used int kind = 0x7fffffff; for (;;) { if (++jjround == 0x7fffffff) ReInitRounds(); if (curChar < 64) { long l = 1L << curChar; do { switch(jjstateSet[--i]) { case 0: if (kind > 75) kind = 75; break; case 1: if ((0x8400000000L & l) != 0L && kind > 74) kind = 74; break; case 2: if ((0xf000000000000L & l) != 0L) jjstateSet[jjnewStateCnt++] = 3; break; case 3: if ((0xff000000000000L & l) == 0L) break; if (kind > 74) kind = 74; jjstateSet[jjnewStateCnt++] = 4; break; case 4: if ((0xff000000000000L & l) != 0L && kind > 74) kind = 74; break; default : break; } } while(i != startsAt); } else if (curChar < 128) { long l = 1L << (curChar & 077); do { switch(jjstateSet[--i]) { case 0: if ((0xfffffffeefffffffL & l) != 0L) { if (kind > 75) kind = 75; } else if (curChar == 92) jjAddStates(19, 21); break; case 1: if ((0x14404510000000L & l) != 0L && kind > 74) kind = 74; break; case 5: if ((0xfffffffeefffffffL & l) != 0L && kind > 75) kind = 75; break; default : break; } } while(i != startsAt); } else { int hiByte = (int)(curChar >> 8); int i1 = hiByte >> 6; long l1 = 1L << (hiByte & 077); int i2 = (curChar & 0xff) >> 6; long l2 = 1L << (curChar & 077); do { switch(jjstateSet[--i]) { case 0: if (jjCanMove_1(hiByte, i1, i2, l1, l2) && kind > 75) kind = 75; break; default : break; } } while(i != startsAt); } if (kind != 0x7fffffff) { jjmatchedKind = kind; jjmatchedPos = curPos; kind = 0x7fffffff; } ++curPos; if ((i = jjnewStateCnt) == (startsAt = 6 - (jjnewStateCnt = startsAt))) return curPos; try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { return curPos; } } } private final int jjStopStringLiteralDfa_1(int pos, long active0, long active1) { switch (pos) { default : return -1; } } private final int jjStartNfa_1(int pos, long active0, long active1) { return jjMoveNfa_1(jjStopStringLiteralDfa_1(pos, active0, active1), pos + 1); } private int jjMoveStringLiteralDfa0_1() { switch(curChar) { case 39: return jjStopAtPos(0, 73); default : return jjMoveNfa_1(0, 0); } } private int jjMoveNfa_1(int startState, int curPos) { //int[] nextStates; // not used int startsAt = 0; jjnewStateCnt = 6; int i = 1; jjstateSet[0] = startState; //int j; // not used int kind = 0x7fffffff; for (;;) { if (++jjround == 0x7fffffff) ReInitRounds(); if (curChar < 64) { long l = 1L << curChar; do { switch(jjstateSet[--i]) { case 0: if ((0xffffff7fffffffffL & l) != 0L && kind > 72) kind = 72; break; case 1: if ((0x8400000000L & l) != 0L && kind > 71) kind = 71; break; case 2: if ((0xf000000000000L & l) != 0L) jjstateSet[jjnewStateCnt++] = 3; break; case 3: if ((0xff000000000000L & l) == 0L) break; if (kind > 71) kind = 71; jjstateSet[jjnewStateCnt++] = 4; break; case 4: if ((0xff000000000000L & l) != 0L && kind > 71) kind = 71; break; default : break; } } while(i != startsAt); } else if (curChar < 128) { long l = 1L << (curChar & 077); do { switch(jjstateSet[--i]) { case 0: if ((0xffffffffefffffffL & l) != 0L) { if (kind > 72) kind = 72; } else if (curChar == 92) jjAddStates(19, 21); break; case 1: if ((0x14404510000000L & l) != 0L && kind > 71) kind = 71; break; case 5: if ((0xffffffffefffffffL & l) != 0L && kind > 72) kind = 72; break; default : break; } } while(i != startsAt); } else { int hiByte = (int)(curChar >> 8); int i1 = hiByte >> 6; long l1 = 1L << (hiByte & 077); int i2 = (curChar & 0xff) >> 6; long l2 = 1L << (curChar & 077); do { switch(jjstateSet[--i]) { case 0: if (jjCanMove_1(hiByte, i1, i2, l1, l2) && kind > 72) kind = 72; break; default : break; } } while(i != startsAt); } if (kind != 0x7fffffff) { jjmatchedKind = kind; jjmatchedPos = curPos; kind = 0x7fffffff; } ++curPos; if ((i = jjnewStateCnt) == (startsAt = 6 - (jjnewStateCnt = startsAt))) return curPos; try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { return curPos; } } } private final int jjStopStringLiteralDfa_3(int pos, long active0, long active1) { switch (pos) { default : return -1; } } private final int jjStartNfa_3(int pos, long active0, long active1) { return jjMoveNfa_3(jjStopStringLiteralDfa_3(pos, active0, active1), pos + 1); } private int jjMoveStringLiteralDfa0_3() { switch(curChar) { case 34: return jjStopAtPos(0, 79); default : return jjMoveNfa_3(0, 0); } } private int jjMoveNfa_3(int startState, int curPos) { //int[] nextStates; // not used int startsAt = 0; jjnewStateCnt = 6; int i = 1; jjstateSet[0] = startState; //int j; // not used int kind = 0x7fffffff; for (;;) { if (++jjround == 0x7fffffff) ReInitRounds(); if (curChar < 64) { long l = 1L << curChar; do { switch(jjstateSet[--i]) { case 0: if ((0xfffffffbffffffffL & l) != 0L && kind > 78) kind = 78; break; case 1: if ((0x8400000000L & l) != 0L && kind > 77) kind = 77; break; case 2: if ((0xf000000000000L & l) != 0L) jjstateSet[jjnewStateCnt++] = 3; break; case 3: if ((0xff000000000000L & l) == 0L) break; if (kind > 77) kind = 77; jjstateSet[jjnewStateCnt++] = 4; break; case 4: if ((0xff000000000000L & l) != 0L && kind > 77) kind = 77; break; default : break; } } while(i != startsAt); } else if (curChar < 128) { long l = 1L << (curChar & 077); do { switch(jjstateSet[--i]) { case 0: if ((0xffffffffefffffffL & l) != 0L) { if (kind > 78) kind = 78; } else if (curChar == 92) jjAddStates(19, 21); break; case 1: if ((0x14404510000000L & l) != 0L && kind > 77) kind = 77; break; case 5: if ((0xffffffffefffffffL & l) != 0L && kind > 78) kind = 78; break; default : break; } } while(i != startsAt); } else { int hiByte = (int)(curChar >> 8); int i1 = hiByte >> 6; long l1 = 1L << (hiByte & 077); int i2 = (curChar & 0xff) >> 6; long l2 = 1L << (curChar & 077); do { switch(jjstateSet[--i]) { case 0: if (jjCanMove_1(hiByte, i1, i2, l1, l2) && kind > 78) kind = 78; break; default : break; } } while(i != startsAt); } if (kind != 0x7fffffff) { jjmatchedKind = kind; jjmatchedPos = curPos; kind = 0x7fffffff; } ++curPos; if ((i = jjnewStateCnt) == (startsAt = 6 - (jjnewStateCnt = startsAt))) return curPos; try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { return curPos; } } } static final int[] jjnextStates = { 15, 16, 18, 19, 22, 13, 24, 25, 7, 9, 10, 13, 17, 10, 13, 11, 12, 20, 21, 1, 2, 3, }; private static final boolean jjCanMove_0(int hiByte, int i1, int i2, long l1, long l2) { switch(hiByte) { case 0: return ((jjbitVec2[i2] & l2) != 0L); case 48: return ((jjbitVec3[i2] & l2) != 0L); case 49: return ((jjbitVec4[i2] & l2) != 0L); case 51: return ((jjbitVec5[i2] & l2) != 0L); case 61: return ((jjbitVec6[i2] & l2) != 0L); default : if ((jjbitVec0[i1] & l1) != 0L) return true; return false; } } private static final boolean jjCanMove_1(int hiByte, int i1, int i2, long l1, long l2) { switch(hiByte) { case 0: return ((jjbitVec8[i2] & l2) != 0L); default : if ((jjbitVec7[i1] & l1) != 0L) return true; return false; } } /** Token literal values. */ public static final String[] jjstrLiteralImages = { "", "\54", "\75", "\77", "\72", "\174\174", "\157\162", "\46\46", "\141\156\144", "\174", "\142\157\162", "\136", "\170\157\162", "\46", "\142\141\156\144", "\75\75", "\145\161", "\41\75", "\156\145\161", "\74", "\154\164", "\76", "\147\164", "\74\75", "\154\164\145", "\76\75", "\147\164\145", "\151\156", "\156\157\164", "\74\74", "\163\150\154", "\76\76", "\163\150\162", "\76\76\76", "\165\163\150\162", "\53", "\55", "\52", "\57", "\45", "\176", "\41", "\151\156\163\164\141\156\143\145\157\146", "\56", "\50", "\51", "\164\162\165\145", "\146\141\154\163\145", "\156\165\154\154", "\43\164\150\151\163", "\43\162\157\157\164", "\43", "\133", "\135", "\173", "\175", "\100", "\156\145\167", "\44", null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, }; /** Lexer state names. */ public static final String[] lexStateNames = { "DEFAULT", "WithinCharLiteral", "WithinBackCharLiteral", "WithinStringLiteral", }; /** Lex State array. */ public static final int[] jjnewLexState = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 2, 1, 3, -1, -1, 0, -1, -1, 0, -1, -1, 0, -1, -1, -1, -1, -1, -1, }; static final long[] jjtoToken = { 0x7ffffffffffffffL, 0x39209L, }; static final long[] jjtoSkip = { 0xf800000000000000L, 0x0L, }; static final long[] jjtoMore = { 0x0L, 0x6df0L, }; protected JavaCharStream input_stream; private final int[] jjrounds = new int[27]; private final int[] jjstateSet = new int[54]; private final StringBuffer image = new StringBuffer(); private int jjimageLen; private int lengthOfMatch; protected char curChar; /** Constructor. */ public OgnlParserTokenManager(JavaCharStream stream){ if (JavaCharStream.staticFlag) throw new Error("ERROR: Cannot use a static CharStream class with a non-static lexical analyzer."); input_stream = stream; } /** Constructor. */ public OgnlParserTokenManager(JavaCharStream stream, int lexState){ this(stream); SwitchTo(lexState); } /** Reinitialise parser. */ public void ReInit(JavaCharStream stream) { jjmatchedPos = jjnewStateCnt = 0; curLexState = defaultLexState; input_stream = stream; ReInitRounds(); } private void ReInitRounds() { int i; jjround = 0x80000001; for (i = 27; i-- > 0;) jjrounds[i] = 0x80000000; } /** Reinitialise parser. */ public void ReInit(JavaCharStream stream, int lexState) { ReInit(stream); SwitchTo(lexState); } /** Switch to specified lex state. */ public void SwitchTo(int lexState) { if (lexState >= 4 || lexState < 0) throw new TokenMgrError("Error: Ignoring invalid lexical state : " + lexState + ". State unchanged.", TokenMgrError.INVALID_LEXICAL_STATE); else curLexState = lexState; } protected Token jjFillToken() { final Token t; final String tokenImage; final int beginLine; final int endLine; final int beginColumn; final int endColumn; String im = jjstrLiteralImages[jjmatchedKind]; tokenImage = (im == null) ? input_stream.GetImage() : im; beginLine = input_stream.getBeginLine(); beginColumn = input_stream.getBeginColumn(); endLine = input_stream.getEndLine(); endColumn = input_stream.getEndColumn(); t = Token.newToken(jjmatchedKind, tokenImage); t.beginLine = beginLine; t.endLine = endLine; t.beginColumn = beginColumn; t.endColumn = endColumn; return t; } int curLexState = 0; int defaultLexState = 0; int jjnewStateCnt; int jjround; int jjmatchedPos; int jjmatchedKind; /** Get the next Token. */ public Token getNextToken() { Token matchedToken; int curPos = 0; EOFLoop : for (;;) { try { curChar = input_stream.BeginToken(); } catch(java.io.IOException e) { jjmatchedKind = 0; matchedToken = jjFillToken(); return matchedToken; } image.setLength(0); jjimageLen = 0; for (;;) { switch(curLexState) { case 0: try { input_stream.backup(0); while (curChar <= 32 && (0x100003600L & (1L << curChar)) != 0L) curChar = input_stream.BeginToken(); } catch (java.io.IOException e1) { continue EOFLoop; } jjmatchedKind = 0x7fffffff; jjmatchedPos = 0; curPos = jjMoveStringLiteralDfa0_0(); break; case 1: jjmatchedKind = 0x7fffffff; jjmatchedPos = 0; curPos = jjMoveStringLiteralDfa0_1(); break; case 2: jjmatchedKind = 0x7fffffff; jjmatchedPos = 0; curPos = jjMoveStringLiteralDfa0_2(); break; case 3: jjmatchedKind = 0x7fffffff; jjmatchedPos = 0; curPos = jjMoveStringLiteralDfa0_3(); break; } if (jjmatchedKind != 0x7fffffff) { if (jjmatchedPos + 1 < curPos) input_stream.backup(curPos - jjmatchedPos - 1); if ((jjtoToken[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L) { matchedToken = jjFillToken(); TokenLexicalActions(matchedToken); if (jjnewLexState[jjmatchedKind] != -1) curLexState = jjnewLexState[jjmatchedKind]; return matchedToken; } else if ((jjtoSkip[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L) { if (jjnewLexState[jjmatchedKind] != -1) curLexState = jjnewLexState[jjmatchedKind]; continue EOFLoop; } MoreLexicalActions(); if (jjnewLexState[jjmatchedKind] != -1) curLexState = jjnewLexState[jjmatchedKind]; curPos = 0; jjmatchedKind = 0x7fffffff; try { curChar = input_stream.readChar(); continue; } catch (java.io.IOException e1) { } } int error_line = input_stream.getEndLine(); int error_column = input_stream.getEndColumn(); String error_after = null; boolean EOFSeen = false; try { input_stream.readChar(); input_stream.backup(1); } catch (java.io.IOException e1) { EOFSeen = true; error_after = curPos <= 1 ? "" : input_stream.GetImage(); if (curChar == '\n' || curChar == '\r') { error_line++; error_column = 0; } else error_column++; } if (!EOFSeen) { input_stream.backup(1); error_after = curPos <= 1 ? "" : input_stream.GetImage(); } throw new TokenMgrError(EOFSeen, curLexState, error_line, error_column, error_after, curChar, TokenMgrError.LEXICAL_ERROR); } } } void MoreLexicalActions() { jjimageLen += (lengthOfMatch = jjmatchedPos + 1); switch(jjmatchedKind) { case 69 : image.append(input_stream.GetSuffix(jjimageLen)); jjimageLen = 0; stringBuffer = new StringBuffer(); break; case 70 : image.append(input_stream.GetSuffix(jjimageLen)); jjimageLen = 0; stringBuffer = new StringBuffer(); break; case 71 : image.append(input_stream.GetSuffix(jjimageLen)); jjimageLen = 0; charValue = escapeChar(); stringBuffer.append(charValue); break; case 72 : image.append(input_stream.GetSuffix(jjimageLen)); jjimageLen = 0; charValue = image.charAt( image.length()-1 ); stringBuffer.append(charValue); break; case 74 : image.append(input_stream.GetSuffix(jjimageLen)); jjimageLen = 0; charValue = escapeChar(); break; case 75 : image.append(input_stream.GetSuffix(jjimageLen)); jjimageLen = 0; charValue = image.charAt( image.length()-1 ); break; case 77 : image.append(input_stream.GetSuffix(jjimageLen)); jjimageLen = 0; stringBuffer.append( escapeChar() ); break; case 78 : image.append(input_stream.GetSuffix(jjimageLen)); jjimageLen = 0; stringBuffer.append( image.charAt(image.length()-1) ); break; default : break; } } void TokenLexicalActions(Token matchedToken) { switch(jjmatchedKind) { case 67 : image.append(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))); switch (image.charAt(1)) { case '^': literalValue = DynamicSubscript.first; break; case '|': literalValue = DynamicSubscript.mid; break; case '$': literalValue = DynamicSubscript.last; break; case '*': literalValue = DynamicSubscript.all; break; } break; case 73 : image.append(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))); if (stringBuffer.length() == 1) { literalValue = new Character( charValue ); } else { literalValue = new String( stringBuffer ); } break; case 76 : image.append(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))); literalValue = new Character( charValue ); break; case 79 : image.append(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))); literalValue = new String( stringBuffer ); break; case 80 : image.append(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))); literalValue = makeInt(); break; case 81 : image.append(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))); literalValue = makeFloat(); break; default : break; } } private void jjCheckNAdd(int state) { if (jjrounds[state] != jjround) { jjstateSet[jjnewStateCnt++] = state; jjrounds[state] = jjround; } } private void jjAddStates(int start, int end) { do { jjstateSet[jjnewStateCnt++] = jjnextStates[start]; } while (start++ != end); } private void jjCheckNAddTwoStates(int state1, int state2) { jjCheckNAdd(state1); jjCheckNAdd(state2); } private void jjCheckNAddStates(int start, int end) { do { jjCheckNAdd(jjnextStates[start]); } while (start++ != end); } } ognl-2.7.3.orig/src/java/ognl/MapElementsAccessor.java0000644000175000017500000000417610561411075022534 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 1998-2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package ognl; import java.util.*; /** * Implementation of ElementsAccessor that returns an iterator over the map's values. * @author Luke Blanshard (blanshlu@netscape.net) * @author Drew Davidson (drew@ognl.org) */ public class MapElementsAccessor implements ElementsAccessor { public Enumeration getElements( Object target ) { return new IteratorEnumeration( ((Map)target).values().iterator() ); } } ognl-2.7.3.orig/src/java/ognl/ASTRemainder.java0000644000175000017500000000454410641530755021122 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 1998-2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package ognl; /** * @author Luke Blanshard (blanshlu@netscape.net) * @author Drew Davidson (drew@ognl.org) */ class ASTRemainder extends NumericExpression { public ASTRemainder(int id) { super(id); } public ASTRemainder(OgnlParser p, int id) { super(p, id); } protected Object getValueBody( OgnlContext context, Object source ) throws OgnlException { Object v1 = _children[0].getValue( context, source ); Object v2 = _children[1].getValue( context, source ); return OgnlOps.remainder( v1, v2 ); } public String getExpressionOperator(int index) { return "%"; } } ognl-2.7.3.orig/src/java/ognl/ASTNotIn.java0000644000175000017500000000656210646473765020261 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 1998-2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package ognl; import ognl.enhance.UnsupportedCompilationException; /** * @author Luke Blanshard (blanshlu@netscape.net) * @author Drew Davidson (drew@ognl.org) */ class ASTNotIn extends SimpleNode implements NodeType { public ASTNotIn(int id) { super(id); } public ASTNotIn(OgnlParser p, int id) { super(p, id); } protected Object getValueBody( OgnlContext context, Object source ) throws OgnlException { Object v1 = _children[0].getValue( context, source ); Object v2 = _children[1].getValue( context, source ); return OgnlOps.in( v1, v2 )? Boolean.FALSE : Boolean.TRUE; } public String toString() { return _children[0] + " not in " + _children[1]; } public Class getGetterClass() { return Boolean.TYPE; } public Class getSetterClass() { return null; } public String toGetSourceString(OgnlContext context, Object target) { try { String result = "(! ognl.OgnlOps.in( ($w) "; result += OgnlRuntime.getChildSource(context, target, _children[0]) + ", ($w) " + OgnlRuntime.getChildSource(context, target, _children[1]); result += ") )"; context.setCurrentType(Boolean.TYPE); return result; } catch (NullPointerException e) { // expected to happen in some instances e.printStackTrace(); throw new UnsupportedCompilationException("evaluation resulted in null expression."); } catch (Throwable t) { throw OgnlOps.castToRuntime(t); } } } ognl-2.7.3.orig/src/java/ognl/ASTSubtract.java0000644000175000017500000000454010566476144021006 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 1998-2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package ognl; /** * @author Luke Blanshard (blanshlu@netscape.net) * @author Drew Davidson (drew@ognl.org) */ class ASTSubtract extends NumericExpression { public ASTSubtract(int id) { super(id); } public ASTSubtract(OgnlParser p, int id) { super(p, id); } protected Object getValueBody( OgnlContext context, Object source ) throws OgnlException { Object v1 = _children[0].getValue( context, source ); Object v2 = _children[1].getValue( context, source ); return OgnlOps.subtract( v1, v2 ); } public String getExpressionOperator(int index) { return "-"; } } ognl-2.7.3.orig/src/java/ognl/ASTStaticField.java0000644000175000017500000001427010646473765021420 0ustar drazzibdrazzib// -------------------------------------------------------------------------- // Copyright (c) 1998-2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. // -------------------------------------------------------------------------- package ognl; import java.lang.reflect.Field; import java.lang.reflect.Modifier; /** * @author Luke Blanshard (blanshlu@netscape.net) * @author Drew Davidson (drew@ognl.org) */ public class ASTStaticField extends SimpleNode implements NodeType { private String className; private String fieldName; private Class _getterClass; public ASTStaticField(int id) { super(id); } public ASTStaticField(OgnlParser p, int id) { super(p, id); } /** Called from parser action. */ void init(String className, String fieldName) { this.className = className; this.fieldName = fieldName; } protected Object getValueBody(OgnlContext context, Object source) throws OgnlException { return OgnlRuntime.getStaticField(context, className, fieldName); } public boolean isNodeConstant(OgnlContext context) throws OgnlException { boolean result = false; Exception reason = null; try { Class c = OgnlRuntime.classForName(context, className); /* * Check for virtual static field "class"; this cannot interfere with normal static * fields because it is a reserved word. It is considered constant. */ if (fieldName.equals("class")) { result = true; } else if (OgnlRuntime.isJdk15() && c.isEnum()) { result = true; } else { Field f = c.getField(fieldName); if (!Modifier.isStatic(f.getModifiers())) throw new OgnlException("Field " + fieldName + " of class " + className + " is not static"); result = Modifier.isFinal(f.getModifiers()); } } catch (ClassNotFoundException e) { reason = e; } catch (NoSuchFieldException e) { reason = e; } catch (SecurityException e) { reason = e; } if (reason != null) throw new OgnlException("Could not get static field " + fieldName + " from class " + className, reason); return result; } Class getFieldClass(OgnlContext context) throws OgnlException { Exception reason = null; try { Class c = OgnlRuntime.classForName(context, className); /* * Check for virtual static field "class"; this cannot interfere with normal static * fields because it is a reserved word. It is considered constant. */ if (fieldName.equals("class")) { return c; } else if (OgnlRuntime.isJdk15() && c.isEnum()) { return c; } else { Field f = c.getField(fieldName); return f.getType(); } } catch (ClassNotFoundException e) { reason = e; } catch (NoSuchFieldException e) { reason = e; } catch (SecurityException e) { reason = e; } if (reason != null) { throw new OgnlException("Could not get static field " + fieldName + " from class " + className, reason); } return null; } public Class getGetterClass() { return _getterClass; } public Class getSetterClass() { return _getterClass; } public String toString() { return "@" + className + "@" + fieldName; } public String toGetSourceString(OgnlContext context, Object target) { try { Object obj = OgnlRuntime.getStaticField(context, className, fieldName); context.setCurrentObject(obj); _getterClass = getFieldClass(context); context.setCurrentType(_getterClass); } catch (Throwable t) { throw OgnlOps.castToRuntime(t); } return className + "." + fieldName; } public String toSetSourceString(OgnlContext context, Object target) { try { Object obj = OgnlRuntime.getStaticField(context, className, fieldName); context.setCurrentObject(obj); _getterClass = getFieldClass(context); context.setCurrentType(_getterClass); } catch (Throwable t) { throw OgnlOps.castToRuntime(t); } return className + "." + fieldName; } } ognl-2.7.3.orig/src/java/ognl/ASTThisVarRef.java0000644000175000017500000000542410566476144021236 0ustar drazzibdrazzib// -------------------------------------------------------------------------- // Copyright (c) 1998-2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. // -------------------------------------------------------------------------- package ognl; import ognl.enhance.UnsupportedCompilationException; /** * @author Luke Blanshard (blanshlu@netscape.net) * @author Drew Davidson (drew@ognl.org) */ public class ASTThisVarRef extends ASTVarRef { public ASTThisVarRef(int id) { super(id); } public ASTThisVarRef(OgnlParser p, int id) { super(p, id); } protected Object getValueBody(OgnlContext context, Object source) throws OgnlException { return context.getCurrentObject(); } protected void setValueBody(OgnlContext context, Object target, Object value) throws OgnlException { context.setCurrentObject(value); } public String toString() { return "#this"; } public String toGetSourceString(OgnlContext context, Object target) { throw new UnsupportedCompilationException("Unable to compile this references."); } public String toSetSourceString(OgnlContext context, Object target) { throw new UnsupportedCompilationException("Unable to compile this references."); } } ognl-2.7.3.orig/src/java/ognl/NodeType.java0000644000175000017500000000073210633051645020363 0ustar drazzibdrazzib/** * */ package ognl; /** * Used by some of the {@link ognl.enhance.OgnlExpressionCompiler} logic to determine the object * type of {@link Node}s during expression evaluation. */ public interface NodeType { /** * The type returned from the expression - if any. * * @return The type. */ Class getGetterClass(); /** * The type used to set the value - if any. * * @return The type. */ Class getSetterClass(); } ognl-2.7.3.orig/src/java/ognl/ASTNegate.java0000644000175000017500000000510110634650771020410 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 1998-2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package ognl; /** * @author Luke Blanshard (blanshlu@netscape.net) * @author Drew Davidson (drew@ognl.org) */ class ASTNegate extends NumericExpression { public ASTNegate(int id) { super(id); } public ASTNegate(OgnlParser p, int id) { super(p, id); } protected Object getValueBody( OgnlContext context, Object source ) throws OgnlException { return OgnlOps.negate( _children[0].getValue(context, source) ); } public String toString() { return "-" + _children[0]; } public String toGetSourceString(OgnlContext context, Object target) { String source = _children[0].toGetSourceString(context, target); if (!ASTNegate.class.isInstance(_children[0])) { return "-" + source; } else { return "-(" + source + ")"; } } } ognl-2.7.3.orig/src/java/ognl/Ognl.java0000644000175000017500000011113010633051645017526 0ustar drazzibdrazzib// -------------------------------------------------------------------------- // Copyright (c) 1998-2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. // -------------------------------------------------------------------------- package ognl; import ognl.enhance.ExpressionAccessor; import java.io.StringReader; import java.util.Map; /** *

* 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 {@link 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 */ public abstract class Ognl { /** * Parses the given OGNL expression and returns a tree representation of the expression that can * be used by Ognl static methods. * * @param expression * the OGNL expression to be parsed * @return a tree representation of the expression * @throws ExpressionSyntaxException * if the expression is malformed * @throws OgnlException * if there is a pathological environmental problem */ public static Object parseExpression(String expression) throws OgnlException { try { OgnlParser parser = new OgnlParser(new StringReader(expression)); return parser.topLevelExpression(); } catch (ParseException e) { throw new ExpressionSyntaxException(expression, e); } catch (TokenMgrError e) { throw new ExpressionSyntaxException(expression, e); } } /** * Parses and compiles the given expression using the {@link ognl.enhance.OgnlExpressionCompiler} returned * from {@link ognl.OgnlRuntime#getCompiler()}. * * @param context * The context to use. * @param root * The root object for the given expression. * @param expression * The expression to compile. * * @return The node with a compiled accessor set on {@link ognl.Node#getAccessor()} if compilation * was successfull. In instances where compilation wasn't possible because of a partially null * expression the {@link ExpressionAccessor} instance may be null and the compilation of this expression * still possible at some as yet indertermined point in the future. * * @throws Exception If a compilation error occurs. */ public static Node compileExpression(OgnlContext context, Object root, String expression) throws Exception { Node expr = (Node)Ognl.parseExpression(expression); OgnlRuntime.compileExpression(context, expr, root); return expr; } /** * Creates and returns a new standard naming context for evaluating an OGNL expression. * * @param root * the root of the object graph * @return a new Map with the keys root and context set * appropriately */ public static Map createDefaultContext(Object root) { return addDefaultContext(root, null, null, null, new OgnlContext()); } /** * Creates and returns a new standard naming context for evaluating an OGNL expression. * * @param root * The root of the object graph. * @param classResolver * The resolver used to instantiate {@link Class} instances referenced in the expression. * * @return a new OgnlContext with the keys root and context set * appropriately */ public static Map createDefaultContext(Object root, ClassResolver classResolver) { return addDefaultContext(root, classResolver, null, null, new OgnlContext()); } /** * Creates and returns a new standard naming context for evaluating an OGNL expression. * * @param root * The root of the object graph. * @param classResolver * The resolver used to instantiate {@link Class} instances referenced in the expression. * @param converter * Converter used to convert return types of an expression in to their desired types. * * @return a new Map with the keys root and context set * appropriately */ public static Map createDefaultContext(Object root, ClassResolver classResolver, TypeConverter converter) { return addDefaultContext(root, classResolver, converter, null, new OgnlContext()); } /** * Creates and returns a new standard naming context for evaluating an OGNL expression. * * @param root * The root of the object graph. * @param classResolver * The resolver used to instantiate {@link Class} instances referenced in the expression. * @param converter * Converter used to convert return types of an expression in to their desired types. * @param memberAccess * Java security handling object to determine semantics for accessing normally private/protected * methods / fields. * @return a new Map with the keys root and context set * appropriately */ public static Map createDefaultContext(Object root, ClassResolver classResolver, TypeConverter converter, MemberAccess memberAccess) { return addDefaultContext(root, classResolver, converter, memberAccess, new OgnlContext()); } /** * Appends the standard naming context for evaluating an OGNL expression into the context given * so that cached maps can be used as a context. * * @param root * the root of the object graph * @param context * the context to which OGNL context will be added. * @return Context Map with the keys root and context set * appropriately */ public static Map addDefaultContext(Object root, Map context) { return addDefaultContext(root, null, null, null, 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. * * @param root * The root of the object graph. * @param classResolver * The resolver used to instantiate {@link Class} instances referenced in the expression. * @param context * The context to which OGNL context will be added. * * @return Context Map with the keys root and context set * appropriately */ public static Map addDefaultContext(Object root, ClassResolver classResolver, Map context) { return addDefaultContext(root, classResolver, null, null, 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. * * @param root * The root of the object graph. * @param classResolver * The resolver used to instantiate {@link Class} instances referenced in the expression. * @param converter * Converter used to convert return types of an expression in to their desired types. * @param context * The context to which OGNL context will be added. * * @return Context Map with the keys root and context set * appropriately */ public static Map addDefaultContext(Object root, ClassResolver classResolver, TypeConverter converter, Map context) { return addDefaultContext(root, classResolver, converter, null, 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. * * @param root * the root of the object graph * @param classResolver * The class loading resolver that should be used to resolve class references. * @param converter * The type converter to be used by default. * @param memberAccess * Definition for handling private/protected access. * @param context * Default context to use, if not an {@link OgnlContext} will be dumped into * a new {@link OgnlContext} object. * @return Context Map with the keys root and context set * appropriately */ public static Map addDefaultContext(Object root, ClassResolver classResolver, TypeConverter converter, MemberAccess memberAccess, Map context) { OgnlContext result; if (!(context instanceof OgnlContext)) { result = new OgnlContext(); result.setValues(context); } else { result = (OgnlContext) context; } if (classResolver != null) { result.setClassResolver(classResolver); } if (converter != null) { result.setTypeConverter(converter); } if (memberAccess != null) { result.setMemberAccess(memberAccess); } result.setRoot(root); return result; } /** * Configures the {@link ClassResolver} to use for the given context. Will be used during * expression parsing / execution to resolve class names. * * @param context * The context to place the resolver. * @param classResolver * The resolver to use to resolve classes. */ public static void setClassResolver(Map context, ClassResolver classResolver) { context.put(OgnlContext.CLASS_RESOLVER_CONTEXT_KEY, classResolver); } /** * Gets the previously stored {@link ClassResolver} for the given context - if any. * * @param context * The context to get the configured resolver from. * * @return The resolver instance, or null if none found. */ public static ClassResolver getClassResolver(Map context) { return (ClassResolver) context.get(OgnlContext.CLASS_RESOLVER_CONTEXT_KEY); } /** * Configures the type converter to use for a given context. This will be used * to convert into / out of various java class types. * * @param context * The context to configure it for. * @param converter * The converter to use. */ public static void setTypeConverter(Map context, TypeConverter converter) { context.put(OgnlContext.TYPE_CONVERTER_CONTEXT_KEY, converter); } /** * Gets the currently configured {@link TypeConverter} for the given context - if any. * * @param context * The context to get the converter from. * * @return The converter - or null if none found. */ public static TypeConverter getTypeConverter(Map context) { return (TypeConverter) context.get(OgnlContext.TYPE_CONVERTER_CONTEXT_KEY); } /** * Configures the specified context with a {@link MemberAccess} instance for * handling field/method protection levels. * * @param context * The context to configure. * @param memberAccess * The access resolver to configure the context with. */ public static void setMemberAccess(Map context, MemberAccess memberAccess) { context.put(OgnlContext.MEMBER_ACCESS_CONTEXT_KEY, memberAccess); } /** * Gets the currently stored {@link MemberAccess} object for the given context - if any. * * @param context * The context to get the object from. * * @return The configured {@link MemberAccess} instance in the specified context - or null if none found. */ public static MemberAccess getMemberAccess(Map context) { return (MemberAccess) context.get(OgnlContext.MEMBER_ACCESS_CONTEXT_KEY); } /** * Sets the root object to use for all expressions in the given context - doesn't necessarily replace * root object instances explicitly passed in to other expression resolving methods on this class. * * @param context * The context to store the root object in. * @param root * The root object. */ public static void setRoot(Map context, Object root) { context.put(OgnlContext.ROOT_CONTEXT_KEY, root); } /** * Gets the stored root object for the given context - if any. * * @param context * The context to get the root object from. * * @return The root object - or null if none found. */ public static Object getRoot(Map context) { return context.get(OgnlContext.ROOT_CONTEXT_KEY); } /** * Gets the last {@link Evaluation} executed on the given context. * * @param context * The context to get the evaluation from. * * @return The {@link Evaluation} - or null if none was found. */ public static Evaluation getLastEvaluation(Map context) { return (Evaluation) context.get(OgnlContext.LAST_EVALUATION_CONTEXT_KEY); } /** * 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(). * * @param tree * the OGNL expression tree to evaluate, as returned by parseExpression() * @param context * the naming context for the evaluation * @param root * the root object for the OGNL expression * @return 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 */ public static Object getValue(Object tree, Map context, Object root) throws OgnlException { return getValue(tree, context, root, null); } /** * 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(). * * @param tree * the OGNL expression tree to evaluate, as returned by parseExpression() * @param context * the naming context for the evaluation * @param root * the root object for the OGNL expression * @param resultType * the converted type of the resultant object, using the context's type converter * @return 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 */ public static Object getValue(Object tree, Map context, Object root, Class resultType) throws OgnlException { Object result; OgnlContext ognlContext = (OgnlContext) addDefaultContext(root, context); Node node = (Node)tree; if (node.getAccessor() != null) result = node.getAccessor().get(ognlContext, root); else result = node.getValue(ognlContext, root); if (resultType != null) { result = getTypeConverter(context).convertValue(context, root, null, null, result, resultType); } return result; } /** * Gets the value represented by the given pre-compiled expression on the specified root * object. * * @param expression * The pre-compiled expression, as found in {@link Node#getAccessor()}. * @param context * The ognl context. * @param root * The object to retrieve the expression value from. * @return * The value. */ public static Object getValue(ExpressionAccessor expression, OgnlContext context, Object root) { return expression.get(context, root); } /** * Gets the value represented by the given pre-compiled expression on the specified root * object. * * @param expression * The pre-compiled expression, as found in {@link Node#getAccessor()}. * @param context * The ognl context. * @param root * The object to retrieve the expression value from. * @param resultType * The desired object type that the return value should be converted to using the {@link #getTypeConverter(java.util.Map)} }. * @return * The value. */ public static Object getValue(ExpressionAccessor expression, OgnlContext context, Object root, Class resultType) { return getTypeConverter(context).convertValue(context, root, null, null, expression.get(context, root), resultType); } /** * Evaluates the given OGNL expression to extract a value from the given root object in a given * context * * @see #parseExpression(String) * @see #getValue(Object,Object) * @param expression * the OGNL expression to be parsed * @param context * the naming context for the evaluation * @param root * the root object for the OGNL expression * @return 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 */ public static Object getValue(String expression, Map context, Object root) throws OgnlException { return getValue(expression, context, root, null); } /** * Evaluates the given OGNL expression to extract a value from the given root object in a given * context * * @see #parseExpression(String) * @see #getValue(Object,Object) * @param expression * the OGNL expression to be parsed * @param context * the naming context for the evaluation * @param root * the root object for the OGNL expression * @param resultType * the converted type of the resultant object, using the context's type converter * @return 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 */ public static Object getValue(String expression, Map context, Object root, Class resultType) throws OgnlException { return getValue(parseExpression(expression), context, root, resultType); } /** * Evaluates the given OGNL expression tree to extract a value from the given root object. * * @param tree * the OGNL expression tree to evaluate, as returned by parseExpression() * @param root * the root object for the OGNL expression * @return 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 */ public static Object getValue(Object tree, Object root) throws OgnlException { return getValue(tree, root, null); } /** * Evaluates the given OGNL expression tree to extract a value from the given root object. * * @param tree * the OGNL expression tree to evaluate, as returned by parseExpression() * @param root * the root object for the OGNL expression * @param resultType * the converted type of the resultant object, using the context's type converter * @return 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 */ public static Object getValue(Object tree, Object root, Class resultType) throws OgnlException { return getValue(tree, createDefaultContext(root), root, resultType); } /** * Convenience method that combines calls to parseExpression and * getValue. * * @see #parseExpression(String) * @see #getValue(Object,Object) * @param expression * the OGNL expression to be parsed * @param root * the root object for the OGNL expression * @return 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 */ public static Object getValue(String expression, Object root) throws OgnlException { return getValue(expression, root, null); } /** * Convenience method that combines calls to parseExpression and * getValue. * * @see #parseExpression(String) * @see #getValue(Object,Object) * @param expression * the OGNL expression to be parsed * @param root * the root object for the OGNL expression * @param resultType * the converted type of the resultant object, using the context's type converter * @return 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 */ public static Object getValue(String expression, Object root, Class resultType) throws OgnlException { return getValue(parseExpression(expression), root, resultType); } /** * 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(). * * @param tree * the OGNL expression tree to evaluate, as returned by parseExpression() * @param context * the naming context for the evaluation * @param root * the root object for the OGNL expression * @param 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 */ public static void setValue(Object tree, Map context, Object root, Object value) throws OgnlException { OgnlContext ognlContext = (OgnlContext) addDefaultContext(root, context); Node n = (Node) tree; if (n.getAccessor() != null) { n.getAccessor().set(ognlContext, root, value); return; } n.setValue(ognlContext, root, value); } /** * Sets the value given using the pre-compiled expression on the specified root * object. * * @param expression * The pre-compiled expression, as found in {@link Node#getAccessor()}. * @param context * The ognl context. * @param root * The object to set the expression value on. * @param value * The value to set. */ public static void setValue(ExpressionAccessor expression, OgnlContext context, Object root, Object value) { expression.set(context, root, value); } /** * Evaluates the given OGNL expression to insert a value into the object graph rooted at the * given root object given the context. * * @param expression * the OGNL expression to be parsed * @param root * the root object for the OGNL expression * @param context * the naming context for the evaluation * @param 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 */ public static void setValue(String expression, Map context, Object root, Object value) throws OgnlException { setValue(parseExpression(expression), context, root, value); } /** * Evaluates the given OGNL expression tree to insert a value into the object graph rooted at * the given root object. * * @param tree * the OGNL expression tree to evaluate, as returned by parseExpression() * @param root * the root object for the OGNL expression * @param 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 */ public static void setValue(Object tree, Object root, Object value) throws OgnlException { setValue(tree, createDefaultContext(root), root, value); } /** * Convenience method that combines calls to parseExpression and * setValue. * * @see #parseExpression(String) * @see #setValue(Object,Object,Object) * @param expression * the OGNL expression to be parsed * @param root * the root object for the OGNL expression * @param 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 */ public static void setValue(String expression, Object root, Object value) throws OgnlException { setValue(parseExpression(expression), root, value); } /** * Checks if the specified {@link Node} instance represents a constant * expression. * * @param tree * The {@link Node} to check. * @param context * The context to use. * * @return True if the node is a constant - false otherwise. * @throws OgnlException If an error occurs checking the expression. */ public static boolean isConstant(Object tree, Map context) throws OgnlException { return ((SimpleNode) tree).isConstant((OgnlContext) addDefaultContext(null, context)); } /** * Checks if the specified expression represents a constant expression. * * @param expression * The expression to check. * @param context * The context to use. * * @return True if the node is a constant - false otherwise. * @throws OgnlException If an error occurs checking the expression. */ public static boolean isConstant(String expression, Map context) throws OgnlException { return isConstant(parseExpression(expression), context); } /** * Same as {@link #isConstant(Object, java.util.Map)} - only the {@link Map} context * is created for you. * * @param tree * The {@link Node} to check. * * @return True if the node represents a constant expression - false otherwise. * @throws OgnlException If an exception occurs. */ public static boolean isConstant(Object tree) throws OgnlException { return isConstant(tree, createDefaultContext(null)); } /** * Same as {@link #isConstant(String, java.util.Map)} - only the {@link Map} * instance is created for you. * * @param expression * The expression to check. * * @return True if the expression represents a constant - false otherwise. * @throws OgnlException If an exception occurs. */ public static boolean isConstant(String expression) throws OgnlException { return isConstant(parseExpression(expression), createDefaultContext(null)); } public static boolean isSimpleProperty(Object tree, Map context) throws OgnlException { return ((SimpleNode) tree).isSimpleProperty((OgnlContext) addDefaultContext(null, context)); } public static boolean isSimpleProperty(String expression, Map context) throws OgnlException { return isSimpleProperty(parseExpression(expression), context); } public static boolean isSimpleProperty(Object tree) throws OgnlException { return isSimpleProperty(tree, createDefaultContext(null)); } public static boolean isSimpleProperty(String expression) throws OgnlException { return isSimpleProperty(parseExpression(expression), createDefaultContext(null)); } public static boolean isSimpleNavigationChain(Object tree, Map context) throws OgnlException { return ((SimpleNode) tree).isSimpleNavigationChain((OgnlContext) addDefaultContext(null, context)); } public static boolean isSimpleNavigationChain(String expression, Map context) throws OgnlException { return isSimpleNavigationChain(parseExpression(expression), context); } public static boolean isSimpleNavigationChain(Object tree) throws OgnlException { return isSimpleNavigationChain(tree, createDefaultContext(null)); } public static boolean isSimpleNavigationChain(String expression) throws OgnlException { return isSimpleNavigationChain(parseExpression(expression), createDefaultContext(null)); } /** You can't make one of these. */ private Ognl() { } } ognl-2.7.3.orig/src/java/ognl/ASTLess.java0000644000175000017500000000473210566476144020130 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 1998-2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package ognl; /** * @author Luke Blanshard (blanshlu@netscape.net) * @author Drew Davidson (drew@ognl.org) */ class ASTLess extends ComparisonExpression { public ASTLess(int id) { super(id); } public ASTLess(OgnlParser p, int id) { super(p, id); } protected Object getValueBody( OgnlContext context, Object source ) throws OgnlException { Object v1 = _children[0].getValue( context, source ); Object v2 = _children[1].getValue( context, source ); return OgnlOps.less( v1, v2 )? Boolean.TRUE : Boolean.FALSE; } public String getExpressionOperator(int index) { return "<"; } public String getComparisonFunction() { return "ognl.OgnlOps.less"; } } ognl-2.7.3.orig/src/java/ognl/OgnlInvokePermission.java0000644000175000017500000000462310561411075022760 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 1998-2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package ognl; import java.security.*; /** * BasicPermission subclass that defines a permission token for invoking * methods within OGNL. This does not override any methods (except * constructors) and does not implement actions. It is similar in spirit * to the {@link java.lang.reflect.ReflectPermission} class in that it * guards access to methods. * @author Luke Blanshard (blanshlu@netscape.net) * @author Drew Davidson (drew@ognl.org) */ public class OgnlInvokePermission extends BasicPermission { public OgnlInvokePermission(String name) { super(name); } public OgnlInvokePermission(String name, String actions) { super(name, actions); } } ognl-2.7.3.orig/src/java/ognl/IntHashMap.java0000644000175000017500000002470410561411075020632 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 1998-2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package ognl; import java.util.*; /** * A Map that uses ints as the keys. *

Use just like any java.util.Map, except that the keys must be ints. * This is much faster than creating a new Integer for each access.

*

For non-Map access (faster) use the put(int, Object) method.

*

This class implements Map for convenience, but this is not the most * efficient usage.

* @see java.util.HashMap * @see java.util.Map */ public class IntHashMap extends Object implements Map { private Entry table[]; private int count; private int threshold; private float loadFactor; /*=================================================================== Private static classes ===================================================================*/ private static class IntHashMapIterator implements Iterator { boolean keys; int index; Entry table[]; Entry entry; IntHashMapIterator(Entry table[], boolean keys) { super(); this.table = table; this.keys = keys; this.index = table.length; } /*=================================================================== Iterator interface ===================================================================*/ public boolean hasNext() { if (entry != null) { return true; } while (index-- > 0) { if ((entry = table[index]) != null) { return true; } } return false; } public Object next() { if (entry == null) { while ((index-- > 0) && ((entry = table[index]) == null)) { /* do nothing */ } } if (entry != null) { Entry e = entry; entry = e.next; return keys ? new Integer(e.key) : e.value; } throw new NoSuchElementException("IntHashMapIterator"); } public void remove() { throw new UnsupportedOperationException("remove"); } } /*=================================================================== Public static classes ===================================================================*/ public static class Entry extends Object { int hash; int key; Object value; Entry next; public Entry() { super(); } } /*=================================================================== Constructors ===================================================================*/ public IntHashMap(int initialCapacity, float loadFactor) { super(); if (initialCapacity <= 0 || loadFactor <= 0.0) { throw new IllegalArgumentException(); } this.loadFactor = loadFactor; table = new Entry[initialCapacity]; threshold = (int)(initialCapacity * loadFactor); } public IntHashMap(int initialCapacity) { this(initialCapacity, 0.75f); } public IntHashMap() { this(101, 0.75f); } /*=================================================================== Protected methods ===================================================================*/ protected void rehash() { int oldCapacity = table.length; Entry oldTable[] = table; int newCapacity = oldCapacity * 2 + 1; Entry newTable[] = new Entry[newCapacity]; threshold = (int)(newCapacity * loadFactor); table = newTable; for (int i = oldCapacity ; i-- > 0 ;) { for (Entry old = oldTable[i] ; old != null;) { Entry e = old; int index = ( e.hash & 0x7FFFFFFF ) % newCapacity; old = old.next; e.next = newTable[index]; newTable[index] = e; } } } /*=================================================================== Public methods ===================================================================*/ public final boolean containsKey(int key) { int index = (key & 0x7FFFFFFF) % table.length; for (Entry e = table[index] ; e != null ; e = e.next) { if ((e.hash == key) && (e.key == key)) { return true; } } return false; } public final Object get(int key) { int index = (key & 0x7FFFFFFF) % table.length; for (Entry e = table[index] ; e != null ; e = e.next) { if ((e.hash == key) && (e.key == key)) { return e.value; } } return null; } public final Object put(int key, Object value) { int index = ( key & 0x7FFFFFFF ) % table.length; if (value == null) { throw new IllegalArgumentException(); } for (Entry e = table[index] ; e != null ; e = e.next) { if ((e.hash == key) && (e.key == key)) { Object old = e.value; e.value = value; return old; } } if (count >= threshold) { // Rehash the table if the threshold is exceeded. rehash(); return put(key, value); } Entry e = new Entry(); e.hash = key; e.key = key; e.value = value; e.next = table[index]; table[index] = e; ++count; return null; } public final Object remove(int key) { int index = (key & 0x7FFFFFFF) % table.length; for (Entry e = table[index], prev = null ; e != null ; prev = e, e = e.next) { if ((e.hash == key) && (e.key == key)) { if ( prev != null ) { prev.next = e.next; } else { table[index] = e.next; } --count; return e.value; } } return null; } /*=================================================================== Map interface ===================================================================*/ public int size() { return count; } public boolean isEmpty() { return count == 0; } public Object get(Object key) { if (!(key instanceof Number)) { throw new IllegalArgumentException("key is not an Number subclass"); } return get(((Number)key).intValue()); } public Object put(Object key, Object value) { if (!(key instanceof Number)) { throw new IllegalArgumentException( "key cannot be null" ); } return put(((Number)key).intValue(), value ); } public void putAll(Map otherMap) { for (Iterator it = otherMap.keySet().iterator(); it.hasNext();) { Object k = it.next(); put(k, otherMap.get(k)); } } public Object remove(Object key) { if (!(key instanceof Number)) { throw new IllegalArgumentException("key cannot be null"); } return remove(((Number)key).intValue()); } public void clear() { Entry tab[] = table; for (int index = tab.length; --index >= 0;) { tab[index] = null; } count = 0; } public boolean containsKey(Object key) { if (!(key instanceof Number)) { throw new InternalError( "key is not an Number subclass" ); } return containsKey(((Number)key).intValue()); } public boolean containsValue(Object value) { Entry tab[] = table; if (value == null) { throw new IllegalArgumentException(); } for (int i = tab.length ; i-- > 0;) { for (Entry e = tab[i] ; e != null ; e = e.next ) { if (e.value.equals(value)) { return true; } } } return false; } public Set keySet() { Set result = new HashSet(); for (Iterator it = new IntHashMapIterator(table, true); it.hasNext();) { result.add(it.next()); } return result; } public Collection values() { List result = new ArrayList(); for (Iterator it = new IntHashMapIterator(table, false); it.hasNext();) { result.add(it.next()); } return result; } public Set entrySet() { throw new UnsupportedOperationException("entrySet"); } } ognl-2.7.3.orig/src/java/ognl/BooleanExpression.java0000644000175000017500000000316210646473765022312 0ustar drazzibdrazzib/** * */ package ognl; import ognl.enhance.UnsupportedCompilationException; /** * Base class for boolean expressions. * * @author jkuhnert */ public abstract class BooleanExpression extends ExpressionNode implements NodeType { protected Class _getterClass; public BooleanExpression(int id) { super(id); } public BooleanExpression(OgnlParser p, int id) { super(p, id); } public Class getGetterClass() { return _getterClass; } public Class getSetterClass() { return null; } public String toGetSourceString(OgnlContext context, Object target) { try { Object value = getValueBody(context, target); if (value != null && Boolean.class.isAssignableFrom(value.getClass())) _getterClass = Boolean.TYPE; else if (value != null) _getterClass = value.getClass(); else _getterClass = Boolean.TYPE; String ret = super.toGetSourceString(context, target); if ("(false)".equals(ret)) return "false"; else if ("(true)".equals(ret)) return "true"; return ret; } catch (NullPointerException e) { // expected to happen in some instances e.printStackTrace(); throw new UnsupportedCompilationException("evaluation resulted in null expression."); } catch (Throwable t) { throw OgnlOps.castToRuntime(t); } } } ognl-2.7.3.orig/src/java/ognl/ASTAnd.java0000644000175000017500000001465010655154670017720 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 1998-2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package ognl; import ognl.enhance.ExpressionCompiler; import ognl.enhance.UnsupportedCompilationException; /** * @author Luke Blanshard (blanshlu@netscape.net) * @author Drew Davidson (drew@ognl.org) */ public class ASTAnd extends BooleanExpression { public ASTAnd(int id) { super(id); } public ASTAnd(OgnlParser p, int id) { super(p, id); } public void jjtClose() { flattenTree(); } protected Object getValueBody( OgnlContext context, Object source ) throws OgnlException { Object result = null; int last = _children.length - 1; for ( int i=0; i <= last; ++i ) { result = _children[i].getValue( context, source ); if ( i != last && ! OgnlOps.booleanValue(result) ) break; } return result; } protected void setValueBody( OgnlContext context, Object target, Object value ) throws OgnlException { int last = _children.length - 1; for ( int i=0; i < last; ++i ) { Object v = _children[i].getValue( context, target ); if ( ! OgnlOps.booleanValue(v) ) return; } _children[last].setValue( context, target, value ); } public String getExpressionOperator(int index) { return "&&"; } public Class getGetterClass() { return null; } public String toGetSourceString(OgnlContext context, Object target) { if (_children.length != 2) throw new UnsupportedCompilationException("Can only compile boolean expressions with two children."); String result = ""; try { String first = OgnlRuntime.getChildSource(context, target, _children[0]); if (!OgnlOps.booleanValue(context.getCurrentObject())) { throw new UnsupportedCompilationException("And expression can't be compiled until all conditions are true."); } if (!OgnlRuntime.isBoolean(first) && !context.getCurrentType().isPrimitive()) first = OgnlRuntime.getCompiler().createLocalReference(context, first, context.getCurrentType()); String second = OgnlRuntime.getChildSource(context, target, _children[1]); if (!OgnlRuntime.isBoolean(second) && !context.getCurrentType().isPrimitive()) second = OgnlRuntime.getCompiler().createLocalReference(context, second, context.getCurrentType()); result += "(ognl.OgnlOps.booleanValue(" + first + ")"; result += " ? "; result += " ($w) (" + second + ")"; result += " : "; result += " ($w) (" + first + ")"; result += ")"; context.setCurrentObject(target); context.setCurrentType(Object.class); } catch (NullPointerException e) { throw new UnsupportedCompilationException("evaluation resulted in null expression."); } catch (Throwable t) { throw OgnlOps.castToRuntime(t); } return result; } public String toSetSourceString(OgnlContext context, Object target) { if (_children.length != 2) throw new UnsupportedCompilationException("Can only compile boolean expressions with two children."); String pre = (String)context.get("_currentChain"); if (pre == null) pre = ""; String result = ""; try { if (!OgnlOps.booleanValue(_children[0].getValue(context, target))) { throw new UnsupportedCompilationException("And expression can't be compiled until all conditions are true."); } String first = ExpressionCompiler.getRootExpression(_children[0], context.getRoot(), context) + pre + _children[0].toGetSourceString(context, target); _children[1].getValue(context, target); String second = ExpressionCompiler.getRootExpression(_children[1], context.getRoot(), context) + pre + _children[1].toSetSourceString(context, target); if (!OgnlRuntime.isBoolean(first)) result += "if(ognl.OgnlOps.booleanValue(" + first + ")){"; else result += "if(" + first + "){"; result += second; result += "; } "; context.setCurrentObject(target); context.setCurrentType(Object.class); } catch (Throwable t) { throw OgnlOps.castToRuntime(t); } return result; } } ognl-2.7.3.orig/src/java/ognl/OgnlRuntime.java0000644000175000017500000030633310744211276021106 0ustar drazzibdrazzib// -------------------------------------------------------------------------- // Copyright (c) 1998-2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. // -------------------------------------------------------------------------- package ognl; import ognl.enhance.ExpressionCompiler; import ognl.enhance.OgnlExpressionCompiler; import ognl.internal.ClassCache; import ognl.internal.ClassCacheImpl; import java.beans.*; import java.lang.reflect.*; import java.math.BigDecimal; import java.math.BigInteger; import java.security.Permission; import java.util.*; /** * Utility class used by internal OGNL API to do various things like: * *
    *
  • Handles majority of reflection logic / caching.
  • *
  • Utility methods for casting strings / various numeric types used by {@link OgnlExpressionCompiler}.Core runtime configuration point for setting/using global {@link TypeConverter} / {@link OgnlExpressionCompiler} / * {@link NullHandler} instances / etc..
  • *
* * @author Luke Blanshard (blanshlu@netscape.net) * @author Drew Davidson (drew@ognl.org) */ public class OgnlRuntime { /** * Constant expression used to indicate that a given method / property couldn't be found * during reflection operations. */ public static final Object NotFound = new Object(); public static final List NotFoundList = new ArrayList(); public static final Map NotFoundMap = new HashMap(); public static final Object[] NoArguments = new Object[]{}; public static final Class[] NoArgumentTypes = new Class[]{}; /** * Token returned by TypeConverter for no conversion possible */ public static final Object NoConversionPossible = "ognl.NoConversionPossible"; /** * Not an indexed property */ public static int INDEXED_PROPERTY_NONE = 0; /** * JavaBeans IndexedProperty */ public static int INDEXED_PROPERTY_INT = 1; /** * OGNL ObjectIndexedProperty */ public static int INDEXED_PROPERTY_OBJECT = 2; /** * Constant string representation of null string. */ public static final String NULL_STRING = "" + null; /** * Java beans standard set method prefix. */ private static final String SET_PREFIX = "set"; /** * Java beans standard get method prefix. */ private static final String GET_PREFIX = "get"; /** * Java beans standard is boolean getter prefix. */ private static final String IS_PREFIX = "is"; /** * Prefix padding for hexadecimal numbers to HEX_LENGTH. */ private static final Map HEX_PADDING = new HashMap(); private static final int HEX_LENGTH = 8; /** * Returned by getUniqueDescriptor() when the object is null. */ private static final String NULL_OBJECT_STRING = ""; /** * Used to store the result of determining if current jvm is 1.5 language compatible. */ private static boolean _jdk15 = false; private static boolean _jdkChecked = false; static final ClassCache _methodAccessors = new ClassCacheImpl(); static final ClassCache _propertyAccessors = new ClassCacheImpl(); static final ClassCache _elementsAccessors = new ClassCacheImpl(); static final ClassCache _nullHandlers = new ClassCacheImpl(); static final ClassCache _propertyDescriptorCache = new ClassCacheImpl(); static final ClassCache _constructorCache = new ClassCacheImpl(); static final ClassCache _staticMethodCache = new ClassCacheImpl(); static final ClassCache _instanceMethodCache = new ClassCacheImpl(); static final ClassCache _invokePermissionCache = new ClassCacheImpl(); static final ClassCache _fieldCache = new ClassCacheImpl(); static final List _superclasses = new ArrayList(); /* Used by fieldCache lookup */ static final ClassCache[] _declaredMethods = new ClassCache[]{new ClassCacheImpl(), new ClassCacheImpl()}; static final Map _primitiveTypes = new HashMap(101); static final ClassCache _primitiveDefaults = new ClassCacheImpl(); static final Map _methodParameterTypesCache = new HashMap(101); static final Map _genericMethodParameterTypesCache = new HashMap(101); static final Map _ctorParameterTypesCache = new HashMap(101); static SecurityManager _securityManager = System.getSecurityManager(); static final EvaluationPool _evaluationPool = new EvaluationPool(); static final ObjectArrayPool _objectArrayPool = new ObjectArrayPool(); static final IntHashMap _methodAccessCache = new IntHashMap(); static final IntHashMap _methodPermCache = new IntHashMap(); static ClassCacheInspector _cacheInspector; /** * Expression compiler used by {@link Ognl#compileExpression(OgnlContext, Object, String)} calls. */ private static OgnlExpressionCompiler _compiler = new ExpressionCompiler(); private static IdentityHashMap PRIMITIVE_WRAPPER_CLASSES = new IdentityHashMap(); /** * Used to provide primitive type equivalent conversions into and out of * native / object types. */ static { PRIMITIVE_WRAPPER_CLASSES.put(Boolean.TYPE, Boolean.class); PRIMITIVE_WRAPPER_CLASSES.put(Boolean.class, Boolean.TYPE); PRIMITIVE_WRAPPER_CLASSES.put(Byte.TYPE, Byte.class); PRIMITIVE_WRAPPER_CLASSES.put(Byte.class, Byte.TYPE); PRIMITIVE_WRAPPER_CLASSES.put(Character.TYPE, Character.class); PRIMITIVE_WRAPPER_CLASSES.put(Character.class, Character.TYPE); PRIMITIVE_WRAPPER_CLASSES.put(Short.TYPE, Short.class); PRIMITIVE_WRAPPER_CLASSES.put(Short.class, Short.TYPE); PRIMITIVE_WRAPPER_CLASSES.put(Integer.TYPE, Integer.class); PRIMITIVE_WRAPPER_CLASSES.put(Integer.class, Integer.TYPE); PRIMITIVE_WRAPPER_CLASSES.put(Long.TYPE, Long.class); PRIMITIVE_WRAPPER_CLASSES.put(Long.class, Long.TYPE); PRIMITIVE_WRAPPER_CLASSES.put(Float.TYPE, Float.class); PRIMITIVE_WRAPPER_CLASSES.put(Float.class, Float.TYPE); PRIMITIVE_WRAPPER_CLASSES.put(Double.TYPE, Double.class); PRIMITIVE_WRAPPER_CLASSES.put(Double.class, Double.TYPE); } private static final Map NUMERIC_CASTS = new HashMap(); /** * Constant strings for casting different primitive types. */ static { NUMERIC_CASTS.put(Double.class, "(double)"); NUMERIC_CASTS.put(Float.class, "(float)"); NUMERIC_CASTS.put(Integer.class, "(int)"); NUMERIC_CASTS.put(Long.class, "(long)"); NUMERIC_CASTS.put(BigDecimal.class, "(double)"); NUMERIC_CASTS.put(BigInteger.class, ""); } private static final Map NUMERIC_VALUES = new HashMap(); /** * Constant strings for getting the primitive value of different * native types on the generic {@link Number} object interface. (or the less * generic BigDecimal/BigInteger types) */ static { NUMERIC_VALUES.put(Double.class, "doubleValue()"); NUMERIC_VALUES.put(Float.class, "floatValue()"); NUMERIC_VALUES.put(Integer.class, "intValue()"); NUMERIC_VALUES.put(Long.class, "longValue()"); NUMERIC_VALUES.put(Short.class, "shortValue()"); NUMERIC_VALUES.put(Byte.class, "byteValue()"); NUMERIC_VALUES.put(BigDecimal.class, "doubleValue()"); NUMERIC_VALUES.put(BigInteger.class, "doubleValue()"); NUMERIC_VALUES.put(Boolean.class, "booleanValue()"); } private static final Map NUMERIC_LITERALS = new HashMap(); /** * Numeric primitive literal string expressions. */ static { NUMERIC_LITERALS.put(Integer.class, ""); NUMERIC_LITERALS.put(Integer.TYPE, ""); NUMERIC_LITERALS.put(Long.class, "l"); NUMERIC_LITERALS.put(Long.TYPE, "l"); NUMERIC_LITERALS.put(BigInteger.class, "d"); NUMERIC_LITERALS.put(Float.class, "f"); NUMERIC_LITERALS.put(Float.TYPE, "f"); NUMERIC_LITERALS.put(Double.class, "d"); NUMERIC_LITERALS.put(Double.TYPE, "d"); NUMERIC_LITERALS.put(BigInteger.class, "d"); NUMERIC_LITERALS.put(BigDecimal.class, "d"); } private static final Map NUMERIC_DEFAULTS = new HashMap(); static { NUMERIC_DEFAULTS.put(Boolean.class, Boolean.FALSE); NUMERIC_DEFAULTS.put(Byte.class, new Byte((byte) 0)); NUMERIC_DEFAULTS.put(Short.class, new Short((short) 0)); NUMERIC_DEFAULTS.put(Character.class, new Character((char) 0)); NUMERIC_DEFAULTS.put(Integer.class, new Integer(0)); NUMERIC_DEFAULTS.put(Long.class, new Long(0L)); NUMERIC_DEFAULTS.put(Float.class, new Float(0.0f)); NUMERIC_DEFAULTS.put(Double.class, new Double(0.0)); NUMERIC_DEFAULTS.put(BigInteger.class, new BigInteger("0")); NUMERIC_DEFAULTS.put(BigDecimal.class, new BigDecimal(0.0)); } static { PropertyAccessor p = new ArrayPropertyAccessor(); setPropertyAccessor(Object.class, new ObjectPropertyAccessor()); setPropertyAccessor(byte[].class, p); setPropertyAccessor(short[].class, p); setPropertyAccessor(char[].class, p); setPropertyAccessor(int[].class, p); setPropertyAccessor(long[].class, p); setPropertyAccessor(float[].class, p); setPropertyAccessor(double[].class, p); setPropertyAccessor(Object[].class, p); setPropertyAccessor(List.class, new ListPropertyAccessor()); setPropertyAccessor(Map.class, new MapPropertyAccessor()); setPropertyAccessor(Set.class, new SetPropertyAccessor()); setPropertyAccessor(Iterator.class, new IteratorPropertyAccessor()); setPropertyAccessor(Enumeration.class, new EnumerationPropertyAccessor()); ElementsAccessor e = new ArrayElementsAccessor(); setElementsAccessor(Object.class, new ObjectElementsAccessor()); setElementsAccessor(byte[].class, e); setElementsAccessor(short[].class, e); setElementsAccessor(char[].class, e); setElementsAccessor(int[].class, e); setElementsAccessor(long[].class, e); setElementsAccessor(float[].class, e); setElementsAccessor(double[].class, e); setElementsAccessor(Object[].class, e); setElementsAccessor(Collection.class, new CollectionElementsAccessor()); setElementsAccessor(Map.class, new MapElementsAccessor()); setElementsAccessor(Iterator.class, new IteratorElementsAccessor()); setElementsAccessor(Enumeration.class, new EnumerationElementsAccessor()); setElementsAccessor(Number.class, new NumberElementsAccessor()); NullHandler nh = new ObjectNullHandler(); setNullHandler(Object.class, nh); setNullHandler(byte[].class, nh); setNullHandler(short[].class, nh); setNullHandler(char[].class, nh); setNullHandler(int[].class, nh); setNullHandler(long[].class, nh); setNullHandler(float[].class, nh); setNullHandler(double[].class, nh); setNullHandler(Object[].class, nh); MethodAccessor ma = new ObjectMethodAccessor(); setMethodAccessor(Object.class, ma); setMethodAccessor(byte[].class, ma); setMethodAccessor(short[].class, ma); setMethodAccessor(char[].class, ma); setMethodAccessor(int[].class, ma); setMethodAccessor(long[].class, ma); setMethodAccessor(float[].class, ma); setMethodAccessor(double[].class, ma); setMethodAccessor(Object[].class, ma); _primitiveTypes.put("boolean", Boolean.TYPE); _primitiveTypes.put("byte", Byte.TYPE); _primitiveTypes.put("short", Short.TYPE); _primitiveTypes.put("char", Character.TYPE); _primitiveTypes.put("int", Integer.TYPE); _primitiveTypes.put("long", Long.TYPE); _primitiveTypes.put("float", Float.TYPE); _primitiveTypes.put("double", Double.TYPE); _primitiveDefaults.put(Boolean.TYPE, Boolean.FALSE); _primitiveDefaults.put(Boolean.class, Boolean.FALSE); _primitiveDefaults.put(Byte.TYPE, new Byte((byte) 0)); _primitiveDefaults.put(Byte.class, new Byte((byte) 0)); _primitiveDefaults.put(Short.TYPE, new Short((short) 0)); _primitiveDefaults.put(Short.class, new Short((short) 0)); _primitiveDefaults.put(Character.TYPE, new Character((char) 0)); _primitiveDefaults.put(Integer.TYPE, new Integer(0)); _primitiveDefaults.put(Long.TYPE, new Long(0L)); _primitiveDefaults.put(Float.TYPE, new Float(0.0f)); _primitiveDefaults.put(Double.TYPE, new Double(0.0)); _primitiveDefaults.put(BigInteger.class, new BigInteger("0")); _primitiveDefaults.put(BigDecimal.class, new BigDecimal(0.0)); } /** * Clears all of the cached reflection information normally used * to improve the speed of expressions that operate on the same classes * or are executed multiple times. * *

* Warning: Calling this too often can be a huge performance * drain on your expressions - use with care. *

*/ public static void clearCache() { _methodParameterTypesCache.clear(); _ctorParameterTypesCache.clear(); _propertyDescriptorCache.clear(); _constructorCache.clear(); _staticMethodCache.clear(); _instanceMethodCache.clear(); _invokePermissionCache.clear(); _fieldCache.clear(); _superclasses.clear(); _declaredMethods[0].clear(); _declaredMethods[1].clear(); _methodAccessCache.clear(); } /** * Checks if the current jvm is java language >= 1.5 compatible. * * @return True if jdk15 features are present. */ public static boolean isJdk15() { if (_jdkChecked) return _jdk15; try { Class.forName("java.lang.annotation.Annotation"); _jdk15 = true; } catch (Exception e) { /* ignore */ } _jdkChecked = true; return _jdk15; } public static String getNumericValueGetter(Class type) { return (String) NUMERIC_VALUES.get(type); } public static Class getPrimitiveWrapperClass(Class primitiveClass) { return (Class) PRIMITIVE_WRAPPER_CLASSES.get(primitiveClass); } public static String getNumericCast(Class type) { return (String) NUMERIC_CASTS.get(type); } public static String getNumericLiteral(Class type) { return (String) NUMERIC_LITERALS.get(type); } public static void setCompiler(OgnlExpressionCompiler compiler) { _compiler = compiler; } public static OgnlExpressionCompiler getCompiler() { return _compiler; } public static void compileExpression(OgnlContext context, Node expression, Object root) throws Exception { _compiler.compileExpression(context, expression, root); } /** * Gets the "target" class of an object for looking up accessors that are registered on the * target. If the object is a Class object this will return the Class itself, else it will * return object's getClass() result. */ public static Class getTargetClass(Object o) { return (o == null) ? null : ((o instanceof Class) ? (Class) o : o.getClass()); } /** * Returns the base name (the class name without the package name prepended) of the object * given. */ public static String getBaseName(Object o) { return (o == null) ? null : getClassBaseName(o.getClass()); } /** * Returns the base name (the class name without the package name prepended) of the class given. */ public static String getClassBaseName(Class c) { String s = c.getName(); return s.substring(s.lastIndexOf('.') + 1); } public static String getClassName(Object o, boolean fullyQualified) { if (!(o instanceof Class)) { o = o.getClass(); } return getClassName((Class) o, fullyQualified); } public static String getClassName(Class c, boolean fullyQualified) { return fullyQualified ? c.getName() : getClassBaseName(c); } /** * Returns the package name of the object's class. */ public static String getPackageName(Object o) { return (o == null) ? null : getClassPackageName(o.getClass()); } /** * Returns the package name of the class given. */ public static String getClassPackageName(Class c) { String s = c.getName(); int i = s.lastIndexOf('.'); return (i < 0) ? null : s.substring(0, i); } /** * Returns a "pointer" string in the usual format for these things - 0x. */ public static String getPointerString(int num) { StringBuffer result = new StringBuffer(); String hex = Integer.toHexString(num), pad; Integer l = new Integer(hex.length()); // result.append(HEX_PREFIX); if ((pad = (String) HEX_PADDING.get(l)) == null) { StringBuffer pb = new StringBuffer(); for (int i = hex.length(); i < HEX_LENGTH; i++) { pb.append('0'); } pad = new String(pb); HEX_PADDING.put(l, pad); } result.append(pad); result.append(hex); return new String(result); } /** * Returns a "pointer" string in the usual format for these things - 0x for the * object given. This will always return a unique value for each object. */ public static String getPointerString(Object o) { return getPointerString((o == null) ? 0 : System.identityHashCode(o)); } /** * Returns a unique descriptor string that includes the object's class and a unique integer * identifier. If fullyQualified is true then the class name will be fully qualified to include * the package name, else it will be just the class' base name. */ public static String getUniqueDescriptor(Object object, boolean fullyQualified) { StringBuffer result = new StringBuffer(); if (object != null) { if (object instanceof Proxy) { Class interfaceClass = object.getClass().getInterfaces()[0]; result.append(getClassName(interfaceClass, fullyQualified)); result.append('^'); object = Proxy.getInvocationHandler(object); } result.append(getClassName(object, fullyQualified)); result.append('@'); result.append(getPointerString(object)); } else { result.append(NULL_OBJECT_STRING); } return new String(result); } /** * Returns a unique descriptor string that includes the object's class' base name and a unique * integer identifier. */ public static String getUniqueDescriptor(Object object) { return getUniqueDescriptor(object, false); } /** * Utility to convert a List into an Object[] array. If the list is zero elements this will * return a constant array; toArray() on List always returns a new object and this is wasteful * for our purposes. */ public static Object[] toArray(List list) { Object[] result; int size = list.size(); if (size == 0) { result = NoArguments; } else { result = getObjectArrayPool().create(list.size()); for (int i = 0; i < size; i++) { result[i] = list.get(i); } } return result; } /** * Returns the parameter types of the given method. */ public static Class[] getParameterTypes(Method m) { synchronized (_methodParameterTypesCache) { Class[] result; if ((result = (Class[]) _methodParameterTypesCache.get(m)) == null) { _methodParameterTypesCache.put(m, result = m.getParameterTypes()); } return result; } } /** * Finds the appropriate parameter types for the given {@link Method} and * {@link Class} instance of the type the method is associated with. Correctly * finds generic types if running in >= 1.5 jre as well. * * @param type The class type the method is being executed against. * @param m The method to find types for. * @return Array of parameter types for the given method. */ public static Class[] findParameterTypes(Class type, Method m) { if (type == null) { return getParameterTypes(m); } if (!isJdk15() || type.getGenericSuperclass() == null || !ParameterizedType.class.isInstance(type.getGenericSuperclass()) || m.getDeclaringClass().getTypeParameters() == null) { return getParameterTypes(m); } synchronized (_genericMethodParameterTypesCache) { Class[] types; if ((types = (Class[]) _genericMethodParameterTypesCache.get(m)) != null) { return types; } ParameterizedType param = (ParameterizedType)type.getGenericSuperclass(); Type[] genTypes = m.getGenericParameterTypes(); TypeVariable[] declaredTypes = m.getDeclaringClass().getTypeParameters(); types = new Class[genTypes.length]; typeSearch: for (int i=0; i < genTypes.length; i++) { TypeVariable paramType = null; if (TypeVariable.class.isInstance(genTypes[i])) { paramType = (TypeVariable)genTypes[i]; } else if (GenericArrayType.class.isInstance(genTypes[i])) { paramType = (TypeVariable) ((GenericArrayType)genTypes[i]).getGenericComponentType(); } else if (Class.class.isInstance(genTypes[i])) { types[i] = (Class) genTypes[i]; continue; } Class resolved = resolveType(param, paramType, declaredTypes); if (resolved != null) { if (GenericArrayType.class.isInstance(genTypes[i])) { resolved = Array.newInstance(resolved, 0).getClass(); } types[i] = resolved; continue; } types[i] = m.getParameterTypes()[i]; } _genericMethodParameterTypesCache.put(m, types); return types; } } static Class resolveType(ParameterizedType param, TypeVariable var, TypeVariable[] declaredTypes) { if (param.getActualTypeArguments().length < 1) return null; for (int i=0; i < declaredTypes.length; i++) { if (!TypeVariable.class.isInstance( param.getActualTypeArguments()[i]) && declaredTypes[i].getName().equals(var.getName())) { return (Class) param.getActualTypeArguments()[i]; } } /* for (int i=0; i < var.getBounds().length; i++) { Type t = var.getBounds()[i]; Class resolvedType = null; if (ParameterizedType.class.isInstance(t)) { ParameterizedType pparam = (ParameterizedType)t; for (int e=0; e < pparam.getActualTypeArguments().length; e++) { if (!TypeVariable.class.isInstance(pparam.getActualTypeArguments()[e])) continue; resolvedType = resolveType(pparam, (TypeVariable)pparam.getActualTypeArguments()[e], declaredTypes); } } else { resolvedType = findType(param.getActualTypeArguments(), (Class)t); } if (resolvedType != null) return resolvedType; } */ return null; } static Class findType(Type[] types, Class type) { for (int i = 0; i < types.length; i++) { if (Class.class.isInstance(types[i]) && type.isAssignableFrom((Class)types[i])) return (Class)types[i]; } return null; } /** * Returns the parameter types of the given method. */ public static Class[] getParameterTypes(Constructor c) { synchronized (_ctorParameterTypesCache) { Class[] result; if ((result = (Class[]) _ctorParameterTypesCache.get(c)) == null) { _ctorParameterTypesCache.put(c, result = c.getParameterTypes()); } return result; } } /** * Gets the SecurityManager that OGNL uses to determine permissions for invoking methods. * * @return SecurityManager for OGNL */ public static SecurityManager getSecurityManager() { return _securityManager; } /** * Sets the SecurityManager that OGNL uses to determine permissions for invoking methods. * * @param value SecurityManager to set */ public static void setSecurityManager(SecurityManager value) { _securityManager = value; } /** * Permission will be named "invoke..". */ public static Permission getPermission(Method method) { Permission result = null; Class mc = method.getDeclaringClass(); synchronized (_invokePermissionCache) { Map permissions = (Map) _invokePermissionCache.get(mc); if (permissions == null) { _invokePermissionCache.put(mc, permissions = new HashMap(101)); } if ((result = (Permission) permissions.get(method.getName())) == null) { result = new OgnlInvokePermission("invoke." + mc.getName() + "." + method.getName()); permissions.put(method.getName(), result); } } return result; } public static Object invokeMethod(Object target, Method method, Object[] argsArray) throws InvocationTargetException, IllegalAccessException { boolean syncInvoke = false; boolean checkPermission = false; int mHash = method.hashCode(); // only synchronize method invocation if it actually requires it synchronized(method) { if (_methodAccessCache.get(mHash) == null || _methodAccessCache.get(mHash) == Boolean.TRUE) { syncInvoke = true; } if (_securityManager != null && _methodPermCache.get(mHash) == null || _methodPermCache.get(mHash) == Boolean.FALSE) { checkPermission = true; } } Object result; boolean wasAccessible = true; if (syncInvoke) { synchronized(method) { if (checkPermission) { try { _securityManager.checkPermission(getPermission(method)); _methodPermCache.put(mHash, Boolean.TRUE); } catch (SecurityException ex) { _methodPermCache.put(mHash, Boolean.FALSE); throw new IllegalAccessException("Method [" + method + "] cannot be accessed."); } } if (!Modifier.isPublic(method.getModifiers()) || !Modifier.isPublic(method.getDeclaringClass().getModifiers())) { if (!(wasAccessible = ((AccessibleObject) method).isAccessible())) { ((AccessibleObject) method).setAccessible(true); _methodAccessCache.put(mHash, Boolean.TRUE); } else { _methodAccessCache.put(mHash, Boolean.FALSE); } } else { _methodAccessCache.put(mHash, Boolean.FALSE); } result = method.invoke(target, argsArray); if (!wasAccessible) { ((AccessibleObject) method).setAccessible(false); } } } else { if (checkPermission) { try { _securityManager.checkPermission(getPermission(method)); _methodPermCache.put(mHash, Boolean.TRUE); } catch (SecurityException ex) { _methodPermCache.put(mHash, Boolean.FALSE); throw new IllegalAccessException("Method [" + method + "] cannot be accessed."); } } result = method.invoke(target, argsArray); } return result; } /** * Gets the class for a method argument that is appropriate for looking up methods by * reflection, by looking for the standard primitive wrapper classes and exchanging for them * their underlying primitive class objects. Other classes are passed through unchanged. * * @param arg an object that is being passed to a method * @return the class to use to look up the method */ public static final Class getArgClass(Object arg) { if (arg == null) return null; Class c = arg.getClass(); if (c == Boolean.class) return Boolean.TYPE; else if (c.getSuperclass() == Number.class) { if (c == Integer.class) return Integer.TYPE; if (c == Double.class) return Double.TYPE; if (c == Byte.class) return Byte.TYPE; if (c == Long.class) return Long.TYPE; if (c == Float.class) return Float.TYPE; if (c == Short.class) return Short.TYPE; } else if (c == Character.class) return Character.TYPE; return c; } /** * Tells whether the given object is compatible with the given class ---that is, whether the * given object can be passed as an argument to a method or constructor whose parameter type is * the given class. If object is null this will return true because null is compatible with any * type. */ public static final boolean isTypeCompatible(Object object, Class c) { boolean result = true; if (object != null) { if (c.isPrimitive()) { if (getArgClass(object) != c) { result = false; } } else if (!c.isInstance(object)) { result = false; } } return result; } /** * Tells whether the given array of objects is compatible with the given array of classes---that * is, whether the given array of objects can be passed as arguments to a method or constructor * whose parameter types are the given array of classes. */ public static boolean areArgsCompatible(Object[] args, Class[] classes) { return areArgsCompatible(args, classes, null); } public static boolean areArgsCompatible(Object[] args, Class[] classes, Method m) { boolean result = true; boolean varArgs = m != null && isJdk15() && m.isVarArgs(); if (args.length != classes.length && !varArgs) { result = false; } else if (varArgs) { for (int index = 0, count = args.length; result && (index < count); ++index) { if (index >= classes.length){ break; } result = isTypeCompatible(args[index], classes[index]); if (!result && classes[index].isArray()) { result = isTypeCompatible(args[index], classes[index].getComponentType()); } } } else { for (int index = 0, count = args.length; result && (index < count); ++index) { result = isTypeCompatible(args[index], classes[index]); } } return result; } /** * Tells whether the first array of classes is more specific than the second. Assumes that the * two arrays are of the same length. */ public static final boolean isMoreSpecific(Class[] classes1, Class[] classes2) { for (int index = 0, count = classes1.length; index < count; ++index) { Class c1 = classes1[index], c2 = classes2[index]; if (c1 == c2) continue; else if (c1.isPrimitive()) return true; else if (c1.isAssignableFrom(c2)) return false; else if (c2.isAssignableFrom(c1)) return true; } // They are the same! So the first is not more specific than the second. return false; } public static String getModifierString(int modifiers) { String result; if (Modifier.isPublic(modifiers)) result = "public"; else if (Modifier.isProtected(modifiers)) result = "protected"; else if (Modifier.isPrivate(modifiers)) result = "private"; else result = ""; if (Modifier.isStatic(modifiers)) result = "static " + result; if (Modifier.isFinal(modifiers)) result = "final " + result; if (Modifier.isNative(modifiers)) result = "native " + result; if (Modifier.isSynchronized(modifiers)) result = "synchronized " + result; if (Modifier.isTransient(modifiers)) result = "transient " + result; return result; } public static Class classForName(OgnlContext context, String className) throws ClassNotFoundException { Class result = (Class) _primitiveTypes.get(className); if (result == null) { ClassResolver resolver; if ((context == null) || ((resolver = context.getClassResolver()) == null)) { resolver = OgnlContext.DEFAULT_CLASS_RESOLVER; } result = resolver.classForName(className, context); } if (result == null) throw new ClassNotFoundException("Unable to resolve class: " + className); return result; } public static boolean isInstance(OgnlContext context, Object value, String className) throws OgnlException { try { Class c = classForName(context, className); return c.isInstance(value); } catch (ClassNotFoundException e) { throw new OgnlException("No such class: " + className, e); } } public static Object getPrimitiveDefaultValue(Class forClass) { return _primitiveDefaults.get(forClass); } public static Object getNumericDefaultValue(Class forClass) { return NUMERIC_DEFAULTS.get(forClass); } public static Object getConvertedType(OgnlContext context, Object target, Member member, String propertyName, Object value, Class type) { return context.getTypeConverter().convertValue(context, target, member, propertyName, value, type); } public static boolean getConvertedTypes(OgnlContext context, Object target, Member member, String propertyName, Class[] parameterTypes, Object[] args, Object[] newArgs) { boolean result = false; if (parameterTypes.length == args.length) { result = true; for (int i = 0, ilast = parameterTypes.length - 1; result && (i <= ilast); i++) { Object arg = args[i]; Class type = parameterTypes[i]; if (isTypeCompatible(arg, type)) { newArgs[i] = arg; } else { Object v = getConvertedType(context, target, member, propertyName, arg, type); if (v == OgnlRuntime.NoConversionPossible) { result = false; } else { newArgs[i] = v; } } } } return result; } public static Method getConvertedMethodAndArgs(OgnlContext context, Object target, String propertyName, List methods, Object[] args, Object[] newArgs) { Method result = null; TypeConverter converter = context.getTypeConverter(); if ((converter != null) && (methods != null)) { for (int i = 0, icount = methods.size(); (result == null) && (i < icount); i++) { Method m = (Method) methods.get(i); Class[] parameterTypes = findParameterTypes(target != null ? target.getClass() : null, m);//getParameterTypes(m); if (getConvertedTypes(context, target, m, propertyName, parameterTypes, args, newArgs)) { result = m; } } } return result; } public static Constructor getConvertedConstructorAndArgs(OgnlContext context, Object target, List constructors, Object[] args, Object[] newArgs) { Constructor result = null; TypeConverter converter = context.getTypeConverter(); if ((converter != null) && (constructors != null)) { for (int i = 0, icount = constructors.size(); (result == null) && (i < icount); i++) { Constructor ctor = (Constructor) constructors.get(i); Class[] parameterTypes = getParameterTypes(ctor); if (getConvertedTypes(context, target, ctor, null, parameterTypes, args, newArgs)) { result = ctor; } } } return result; } /** * Gets the appropriate method to be called for the given target, method name and arguments. If * successful this method will return the Method within the target that can be called and the * converted arguments in actualArgs. If unsuccessful this method will return null and the * actualArgs will be empty. * * @param context The current execution context. * @param source Target object to run against or method name. * @param target Instance of object to be run against. * @param propertyName Name of property to get method of. * @param methods List of current known methods. * @param args Arguments originally passed in. * @param actualArgs Converted arguments. * * @return Best method match or null if none could be found. */ public static Method getAppropriateMethod(OgnlContext context, Object source, Object target, String propertyName, List methods, Object[] args, Object[] actualArgs) { Method result = null; Class[] resultParameterTypes = null; if (methods != null) { for (int i = 0, icount = methods.size(); i < icount; i++) { Method m = (Method) methods.get(i); Class typeClass = target != null ? target.getClass() : null; if (typeClass == null && source != null && Class.class.isInstance(source)) { typeClass = (Class)source; } Class[] mParameterTypes = findParameterTypes(typeClass, m); if (areArgsCompatible(args, mParameterTypes, m) && ((result == null) || isMoreSpecific(mParameterTypes, resultParameterTypes))) { result = m; resultParameterTypes = mParameterTypes; System.arraycopy(args, 0, actualArgs, 0, args.length); for (int j = 0; j < mParameterTypes.length; j++) { Class type = mParameterTypes[j]; if (type.isPrimitive() && (actualArgs[j] == null)) { actualArgs[j] = getConvertedType(context, source, result, propertyName, null, type); } } } } } if (result == null) { result = getConvertedMethodAndArgs(context, target, propertyName, methods, args, actualArgs); } return result; } public static Object callAppropriateMethod(OgnlContext context, Object source, Object target, String methodName, String propertyName, List methods, Object[] args) throws MethodFailedException { Throwable reason = null; Object[] actualArgs = _objectArrayPool.create(args.length); try { Method method = getAppropriateMethod(context, source, target, propertyName, methods, args, actualArgs); if ((method == null) || !isMethodAccessible(context, source, method, propertyName)) { StringBuffer buffer = new StringBuffer(); String className = ""; if (target != null) { className = target.getClass().getName() + "."; } for (int i = 0, ilast = args.length - 1; i <= ilast; i++) { Object arg = args[i]; buffer.append((arg == null) ? NULL_STRING : arg.getClass().getName()); if (i < ilast) { buffer.append(", "); } } throw new NoSuchMethodException(className + methodName + "(" + buffer + ")"); } Object[] convertedArgs = actualArgs; if (isJdk15() && method.isVarArgs()) { Class[] parmTypes = method.getParameterTypes(); // split arguments in to two dimensional array for varargs reflection invocation // where it is expected that the parameter passed in to invoke the method // will look like "new Object[] { arrayOfNonVarArgsArguments, arrayOfVarArgsArguments }" for (int i=0; i < parmTypes.length; i++) { if (parmTypes[i].isArray()) { convertedArgs = new Object[i + 1]; System.arraycopy(actualArgs, 0, convertedArgs, 0, convertedArgs.length); Object[] varArgs; // if they passed in varargs arguments grab them and dump in to new varargs array if (actualArgs.length > i) { ArrayList varArgsList = new ArrayList(); for (int j=i; j < actualArgs.length; j++) { if (actualArgs[j] != null) { varArgsList.add(actualArgs[j]); } } varArgs = varArgsList.toArray(); } else { varArgs = new Object[0]; } convertedArgs[i] = varArgs; break; } } } return invokeMethod(target, method, convertedArgs); } catch (NoSuchMethodException e) { reason = e; } catch (IllegalAccessException e) { reason = e; } catch (InvocationTargetException e) { reason = e.getTargetException(); } finally { _objectArrayPool.recycle(actualArgs); } throw new MethodFailedException(source, methodName, reason); } public static Object callStaticMethod(OgnlContext context, String className, String methodName, Object[] args) throws OgnlException { try { Class targetClass = classForName(context, className); if (targetClass == null) throw new ClassNotFoundException("Unable to resolve class with name " + className); MethodAccessor ma = getMethodAccessor(targetClass); return ma.callStaticMethod(context, targetClass, methodName, args); } catch (ClassNotFoundException ex) { throw new MethodFailedException(className, methodName, ex); } } /** * Invokes the specified method against the target object. * * @param context * The current execution context. * @param target * The object to invoke the method on. * @param methodName * Name of the method - as in "getValue" or "add", etc.. * @param propertyName * Name of the property to call instead? * @param args * Optional arguments needed for method. * @return Result of invoking method. * * @deprecated Use {@link #callMethod(OgnlContext, Object, String, Object[])} instead. * @throws OgnlException For lots of different reasons. */ public static Object callMethod(OgnlContext context, Object target, String methodName, String propertyName, Object[] args) throws OgnlException { return callMethod(context, target, methodName == null ? propertyName : methodName, args); } /** * Invokes the specified method against the target object. * * @param context * The current execution context. * @param target * The object to invoke the method on. * @param methodName * Name of the method - as in "getValue" or "add", etc.. * @param args * Optional arguments needed for method. * @return Result of invoking method. * * @throws OgnlException For lots of different reasons. */ public static Object callMethod(OgnlContext context, Object target, String methodName, Object[] args) throws OgnlException { if (target == null) throw new NullPointerException("target is null for method " + methodName); return getMethodAccessor(target.getClass()).callMethod(context, target, methodName, args); } public static Object callConstructor(OgnlContext context, String className, Object[] args) throws OgnlException { Throwable reason = null; Object[] actualArgs = args; try { Constructor ctor = null; Class[] ctorParameterTypes = null; Class target = classForName(context, className); List constructors = getConstructors(target); for (int i = 0, icount = constructors.size(); i < icount; i++) { Constructor c = (Constructor) constructors.get(i); Class[] cParameterTypes = getParameterTypes(c); if (areArgsCompatible(args, cParameterTypes) && (ctor == null || isMoreSpecific(cParameterTypes, ctorParameterTypes))) { ctor = c; ctorParameterTypes = cParameterTypes; } } if (ctor == null) { actualArgs = _objectArrayPool.create(args.length); if ((ctor = getConvertedConstructorAndArgs(context, target, constructors, args, actualArgs)) == null) { throw new NoSuchMethodException(); } } if (!context.getMemberAccess().isAccessible(context, target, ctor, null)) { throw new IllegalAccessException( "access denied to " + target.getName() + "()"); } return ctor.newInstance(actualArgs); } catch (ClassNotFoundException e) { reason = e; } catch (NoSuchMethodException e) { reason = e; } catch (IllegalAccessException e) { reason = e; } catch (InvocationTargetException e) { reason = e.getTargetException(); } catch (InstantiationException e) { reason = e; } finally { if (actualArgs != args) { _objectArrayPool.recycle(actualArgs); } } throw new MethodFailedException(className, "new", reason); } public static final Object getMethodValue(OgnlContext context, Object target, String propertyName) throws OgnlException, IllegalAccessException, NoSuchMethodException, IntrospectionException { return getMethodValue(context, target, propertyName, false); } /** * If the checkAccessAndExistence flag is true this method will check to see if the method * exists and if it is accessible according to the context's MemberAccess. If neither test * passes this will return NotFound. */ public static final Object getMethodValue(OgnlContext context, Object target, String propertyName, boolean checkAccessAndExistence) throws OgnlException, IllegalAccessException, NoSuchMethodException, IntrospectionException { Object result = null; Method m = getGetMethod(context, (target == null) ? null : target.getClass() , propertyName); if (m == null) m = getReadMethod((target == null) ? null : target.getClass(), propertyName, 0); if (checkAccessAndExistence) { if ((m == null) || !context.getMemberAccess().isAccessible(context, target, m, propertyName)) { result = NotFound; } } if (result == null) { if (m != null) { try { result = invokeMethod(target, m, NoArguments); } catch (InvocationTargetException ex) { throw new OgnlException(propertyName, ex.getTargetException()); } } else { throw new NoSuchMethodException(propertyName); } } return result; } public static boolean setMethodValue(OgnlContext context, Object target, String propertyName, Object value) throws OgnlException, IllegalAccessException, NoSuchMethodException, IntrospectionException { return setMethodValue(context, target, propertyName, value, false); } public static boolean setMethodValue(OgnlContext context, Object target, String propertyName, Object value, boolean checkAccessAndExistence) throws OgnlException, IllegalAccessException, NoSuchMethodException, IntrospectionException { boolean result = true; Method m = getSetMethod(context, (target == null) ? null : target.getClass(), propertyName); if (checkAccessAndExistence) { if ((m == null) || !context.getMemberAccess().isAccessible(context, target, m, propertyName)) { result = false; } } if (result) { if (m != null) { Object[] args = _objectArrayPool.create(value); try { callAppropriateMethod(context, target, target, m.getName(), propertyName, Collections.nCopies(1, m), args); } finally { _objectArrayPool.recycle(args); } } else { result = false; } } return result; } public static List getConstructors(Class targetClass) { List result; synchronized (_constructorCache) { if ((result = (List) _constructorCache.get(targetClass)) == null) { _constructorCache.put(targetClass, result = Arrays.asList(targetClass.getConstructors())); } } return result; } public static Map getMethods(Class targetClass, boolean staticMethods) { ClassCache cache = (staticMethods ? _staticMethodCache : _instanceMethodCache); Map result; synchronized (cache) { if ((result = (Map) cache.get(targetClass)) == null) { cache.put(targetClass, result = new HashMap(23)); for (Class c = targetClass; c != null; c = c.getSuperclass()) { Method[] ma = c.getDeclaredMethods(); for (int i = 0, icount = ma.length; i < icount; i++) { // skip over synthetic methods if (!isMethodCallable(ma[i])) continue; if (Modifier.isStatic(ma[i].getModifiers()) == staticMethods) { List ml = (List) result.get(ma[i].getName()); if (ml == null) result.put(ma[i].getName(), ml = new ArrayList()); ml.add(ma[i]); } } } } } return result; } public static List getMethods(Class targetClass, String name, boolean staticMethods) { return (List) getMethods(targetClass, staticMethods).get(name); } public static Map getFields(Class targetClass) { Map result; synchronized (_fieldCache) { if ((result = (Map) _fieldCache.get(targetClass)) == null) { Field fa[]; result = new HashMap(23); fa = targetClass.getDeclaredFields(); for (int i = 0; i < fa.length; i++) { result.put(fa[i].getName(), fa[i]); } _fieldCache.put(targetClass, result); } } return result; } public static Field getField(Class inClass, String name) { Field result = null; synchronized (_fieldCache) { Object o = getFields(inClass).get(name); if (o == null) { _superclasses.clear(); for (Class sc = inClass; (sc != null); sc = sc.getSuperclass()) { if ((o = getFields(sc).get(name)) == NotFound) break; _superclasses.add(sc); if ((result = (Field) o) != null) break; } /* * Bubble the found value (either cache miss or actual field) to all supeclasses * that we saw for quicker access next time. */ for (int i = 0, icount = _superclasses.size(); i < icount; i++) { getFields((Class) _superclasses.get(i)).put(name, (result == null) ? NotFound : result); } } else { if (o instanceof Field) { result = (Field) o; } else { if (result == NotFound) result = null; } } } return result; } public static Object getFieldValue(OgnlContext context, Object target, String propertyName) throws NoSuchFieldException { return getFieldValue(context, target, propertyName, false); } public static Object getFieldValue(OgnlContext context, Object target, String propertyName, boolean checkAccessAndExistence) throws NoSuchFieldException { Object result = null; Field f = getField((target == null) ? null : target.getClass(), propertyName); if (checkAccessAndExistence) { if ((f == null) || !context.getMemberAccess().isAccessible(context, target, f, propertyName)) { result = NotFound; } } if (result == null) { if (f == null) { throw new NoSuchFieldException(propertyName); } else { try { Object state = null; if (!Modifier.isStatic(f.getModifiers())) { state = context.getMemberAccess().setup(context, target, f, propertyName); result = f.get(target); context.getMemberAccess().restore(context, target, f, propertyName, state); } else throw new NoSuchFieldException(propertyName); } catch (IllegalAccessException ex) { throw new NoSuchFieldException(propertyName); } } } return result; } public static boolean setFieldValue(OgnlContext context, Object target, String propertyName, Object value) throws OgnlException { boolean result = false; try { Field f = getField((target == null) ? null : target.getClass(), propertyName); Object state; if ((f != null) && !Modifier.isStatic(f.getModifiers())) { state = context.getMemberAccess().setup(context, target, f, propertyName); try { if (isTypeCompatible(value, f.getType()) || ((value = getConvertedType(context, target, f, propertyName, value, f.getType())) != null)) { f.set(target, value); result = true; } } finally { context.getMemberAccess().restore(context, target, f, propertyName, state); } } } catch (IllegalAccessException ex) { throw new NoSuchPropertyException(target, propertyName, ex); } return result; } public static boolean isFieldAccessible(OgnlContext context, Object target, Class inClass, String propertyName) { return isFieldAccessible(context, target, getField(inClass, propertyName), propertyName); } public static boolean isFieldAccessible(OgnlContext context, Object target, Field field, String propertyName) { return context.getMemberAccess().isAccessible(context, target, field, propertyName); } public static boolean hasField(OgnlContext context, Object target, Class inClass, String propertyName) { Field f = getField(inClass, propertyName); return (f != null) && isFieldAccessible(context, target, f, propertyName); } public static Object getStaticField(OgnlContext context, String className, String fieldName) throws OgnlException { Exception reason = null; try { Class c = classForName(context, className); if (c == null) throw new OgnlException("Unable to find class " + className + " when resolving field name of " + fieldName); /* * Check for virtual static field "class"; this cannot interfere with normal static * fields because it is a reserved word. */ if (fieldName.equals("class")) { return c; } else if (OgnlRuntime.isJdk15() && c.isEnum()) { return Enum.valueOf(c, fieldName); } else { Field f = c.getField(fieldName); if (!Modifier.isStatic(f.getModifiers())) throw new OgnlException("Field " + fieldName + " of class " + className + " is not static"); return f.get(null); } } catch (ClassNotFoundException e) { reason = e; } catch (NoSuchFieldException e) { reason = e; } catch (SecurityException e) { reason = e; } catch (IllegalAccessException e) { reason = e; } throw new OgnlException("Could not get static field " + fieldName + " from class " + className, reason); } public static List getDeclaredMethods(Class targetClass, String propertyName, boolean findSets) { List result = null; ClassCache cache = _declaredMethods[findSets ? 0 : 1]; synchronized (cache) { Map propertyCache = (Map) cache.get(targetClass); if ((propertyCache == null) || ((result = (List) propertyCache.get(propertyName)) == null)) { String baseName = Character.toUpperCase(propertyName.charAt(0)) + propertyName.substring(1); for (Class c = targetClass; c != null; c = c.getSuperclass()) { Method[] methods = c.getDeclaredMethods(); for (int i = 0; i < methods.length; i++) { if (!isMethodCallable(methods[i])) continue; String ms = methods[i].getName(); if (ms.endsWith(baseName)) { boolean isSet = false, isIs = false; if ((isSet = ms.startsWith(SET_PREFIX)) || ms.startsWith(GET_PREFIX) || (isIs = ms.startsWith(IS_PREFIX))) { int prefixLength = (isIs ? 2 : 3); if (isSet == findSets) { if (baseName.length() == (ms.length() - prefixLength)) { if (result == null) { result = new ArrayList(); } result.add(methods[i]); } } } } } } if (propertyCache == null) { cache.put(targetClass, propertyCache = new HashMap(101)); } propertyCache.put(propertyName, (result == null) ? NotFoundList : result); } return (result == NotFoundList) ? null : result; } } /** * Convenience used to check if a method is volatile or synthetic so as to avoid * calling un-callable methods. * * @param m The method to check. * @return True if the method should be callable, false otherwise. */ static boolean isMethodCallable(Method m) { if ((isJdk15() && m.isSynthetic()) || Modifier.isVolatile(m.getModifiers())) return false; return true; } public static Method getGetMethod(OgnlContext context, Class targetClass, String propertyName) throws IntrospectionException, OgnlException { Method result = null; List methods = getDeclaredMethods(targetClass, propertyName, false /* find 'get' methods */); if (methods != null) { for (int i = 0, icount = methods.size(); i < icount; i++) { Method m = (Method) methods.get(i); Class[] mParameterTypes = findParameterTypes(targetClass, m); //getParameterTypes(m); if (mParameterTypes.length == 0) { result = m; break; } } } return result; } public static boolean isMethodAccessible(OgnlContext context, Object target, Method method, String propertyName) { return (method != null) && context.getMemberAccess().isAccessible(context, target, method, propertyName); } public static boolean hasGetMethod(OgnlContext context, Object target, Class targetClass, String propertyName) throws IntrospectionException, OgnlException { return isMethodAccessible(context, target, getGetMethod(context, targetClass, propertyName), propertyName); } public static Method getSetMethod(OgnlContext context, Class targetClass, String propertyName) throws IntrospectionException, OgnlException { Method result = null; List methods = getDeclaredMethods(targetClass, propertyName, true /* find 'set' methods */); if (methods != null) { for (int i = 0, icount = methods.size(); i < icount; i++) { Method m = (Method) methods.get(i); Class[] mParameterTypes = findParameterTypes(targetClass, m); //getParameterTypes(m); if (mParameterTypes.length == 1) { result = m; break; } } } return result; } public static final boolean hasSetMethod(OgnlContext context, Object target, Class targetClass, String propertyName) throws IntrospectionException, OgnlException { return isMethodAccessible(context, target, getSetMethod(context, targetClass, propertyName), propertyName); } public static final boolean hasGetProperty(OgnlContext context, Object target, Object oname) throws IntrospectionException, OgnlException { Class targetClass = (target == null) ? null : target.getClass(); String name = oname.toString(); return hasGetMethod(context, target, targetClass, name) || hasField(context, target, targetClass, name); } public static final boolean hasSetProperty(OgnlContext context, Object target, Object oname) throws IntrospectionException, OgnlException { Class targetClass = (target == null) ? null : target.getClass(); String name = oname.toString(); return hasSetMethod(context, target, targetClass, name) || hasField(context, target, targetClass, name); } private static final boolean indexMethodCheck(List methods) { boolean result = false; if (methods.size() > 0) { Method fm = (Method) methods.get(0); Class[] fmpt = getParameterTypes(fm); int fmpc = fmpt.length; Class lastMethodClass = fm.getDeclaringClass(); result = true; for (int i = 1; result && (i < methods.size()); i++) { Method m = (Method) methods.get(i); Class c = m.getDeclaringClass(); // Check to see if more than one method implemented per class if (lastMethodClass == c) { result = false; } else { Class[] mpt = getParameterTypes(fm); int mpc = fmpt.length; if (fmpc != mpc) { result = false; } for (int j = 0; j < fmpc; j++) { if (fmpt[j] != mpt[j]) { result = false; break; } } } lastMethodClass = c; } } return result; } static void findObjectIndexedPropertyDescriptors(Class targetClass, Map intoMap) throws OgnlException { Map allMethods = getMethods(targetClass, false); Map pairs = new HashMap(101); for (Iterator it = allMethods.keySet().iterator(); it.hasNext();) { String methodName = (String) it.next(); List methods = (List) allMethods.get(methodName); /* * Only process set/get where there is exactly one implementation of the method per * class and those implementations are all the same */ if (indexMethodCheck(methods)) { boolean isGet = false, isSet = false; Method m = (Method) methods.get(0); if (((isSet = methodName.startsWith(SET_PREFIX)) || (isGet = methodName.startsWith(GET_PREFIX))) && (methodName.length() > 3)) { String propertyName = Introspector.decapitalize(methodName.substring(3)); Class[] parameterTypes = getParameterTypes(m); int parameterCount = parameterTypes.length; if (isGet && (parameterCount == 1) && (m.getReturnType() != Void.TYPE)) { List pair = (List) pairs.get(propertyName); if (pair == null) { pairs.put(propertyName, pair = new ArrayList()); } pair.add(m); } if (isSet && (parameterCount == 2) && (m.getReturnType() == Void.TYPE)) { List pair = (List) pairs.get(propertyName); if (pair == null) { pairs.put(propertyName, pair = new ArrayList()); } pair.add(m); } } } } for (Iterator it = pairs.keySet().iterator(); it.hasNext();) { String propertyName = (String) it.next(); List methods = (List) pairs.get(propertyName); if (methods.size() == 2) { Method method1 = (Method) methods.get(0), method2 = (Method) methods.get(1), setMethod = (method1 .getParameterTypes().length == 2) ? method1 : method2, getMethod = (setMethod == method1) ? method2 : method1; Class keyType = getMethod.getParameterTypes()[0], propertyType = getMethod.getReturnType(); if (keyType == setMethod.getParameterTypes()[0]) { if (propertyType == setMethod.getParameterTypes()[1]) { ObjectIndexedPropertyDescriptor propertyDescriptor; try { propertyDescriptor = new ObjectIndexedPropertyDescriptor(propertyName, propertyType, getMethod, setMethod); } catch (Exception ex) { throw new OgnlException("creating object indexed property descriptor for '" + propertyName + "' in " + targetClass, ex); } intoMap.put(propertyName, propertyDescriptor); } } } } } /** * This method returns the property descriptors for the given class as a Map. * * @param targetClass The class to get the descriptors for. * @return Map map of property descriptors for class. * * @throws IntrospectionException on errors using {@link Introspector}. * @throws OgnlException On general errors. */ public static Map getPropertyDescriptors(Class targetClass) throws IntrospectionException, OgnlException { Map result; synchronized (_propertyDescriptorCache) { if ((result = (Map) _propertyDescriptorCache.get(targetClass)) == null) { PropertyDescriptor[] pda = Introspector.getBeanInfo(targetClass).getPropertyDescriptors(); result = new HashMap(101); for (int i = 0, icount = pda.length; i < icount; i++) { // workaround for Introspector bug 6528714 (bugs.sun.com) if (pda[i].getReadMethod() != null && !isMethodCallable(pda[i].getReadMethod())) { pda[i].setReadMethod(findClosestMatchingMethod(targetClass, pda[i].getReadMethod(), pda[i].getName(), pda[i].getPropertyType(), true)); } if (pda[i].getWriteMethod() != null && !isMethodCallable(pda[i].getWriteMethod())) { pda[i].setWriteMethod(findClosestMatchingMethod(targetClass, pda[i].getWriteMethod(), pda[i].getName(), pda[i].getPropertyType(), false)); } result.put(pda[i].getName(), pda[i]); } findObjectIndexedPropertyDescriptors(targetClass, result); _propertyDescriptorCache.put(targetClass, result); } } return result; } /** * This method returns a PropertyDescriptor for the given class and property name using a Map * lookup (using getPropertyDescriptorsMap()). */ public static PropertyDescriptor getPropertyDescriptor(Class targetClass, String propertyName) throws IntrospectionException, OgnlException { if (targetClass == null) return null; return (PropertyDescriptor) getPropertyDescriptors(targetClass).get(propertyName); } static Method findClosestMatchingMethod(Class targetClass, Method m, String propertyName, Class propertyType, boolean isReadMethod) { List methods = getDeclaredMethods(targetClass, propertyName, !isReadMethod); for (int i=0; i < methods.size(); i++) { Method method = (Method) methods.get(i); if (method.getName().equals(m.getName()) && m.getReturnType().isAssignableFrom(m.getReturnType()) && method.getReturnType() == propertyType && method.getParameterTypes().length == m.getParameterTypes().length) { return method; } } return m; } public static PropertyDescriptor[] getPropertyDescriptorsArray(Class targetClass) throws IntrospectionException { PropertyDescriptor[] result = null; if (targetClass != null) { synchronized (_propertyDescriptorCache) { if ((result = (PropertyDescriptor[]) _propertyDescriptorCache.get(targetClass)) == null) { _propertyDescriptorCache.put(targetClass, result = Introspector.getBeanInfo(targetClass) .getPropertyDescriptors()); } } } return result; } /** * Gets the property descriptor with the given name for the target class given. * * @param targetClass Class for which property descriptor is desired * @param name Name of property * @return PropertyDescriptor of the named property or null if the class has no property with * the given name */ public static PropertyDescriptor getPropertyDescriptorFromArray(Class targetClass, String name) throws IntrospectionException { PropertyDescriptor result = null; PropertyDescriptor[] pda = getPropertyDescriptorsArray(targetClass); for (int i = 0, icount = pda.length; (result == null) && (i < icount); i++) { if (pda[i].getName().compareTo(name) == 0) { result = pda[i]; } } return result; } public static void setMethodAccessor(Class cls, MethodAccessor accessor) { synchronized (_methodAccessors) { _methodAccessors.put(cls, accessor); } } public static MethodAccessor getMethodAccessor(Class cls) throws OgnlException { MethodAccessor answer = (MethodAccessor) getHandler(cls, _methodAccessors); if (answer != null) return answer; throw new OgnlException("No method accessor for " + cls); } public static void setPropertyAccessor(Class cls, PropertyAccessor accessor) { synchronized (_propertyAccessors) { _propertyAccessors.put(cls, accessor); } } public static PropertyAccessor getPropertyAccessor(Class cls) throws OgnlException { PropertyAccessor answer = (PropertyAccessor) getHandler(cls, _propertyAccessors); if (answer != null) return answer; throw new OgnlException("No property accessor for class " + cls); } public static ElementsAccessor getElementsAccessor(Class cls) throws OgnlException { ElementsAccessor answer = (ElementsAccessor) getHandler(cls, _elementsAccessors); if (answer != null) return answer; throw new OgnlException("No elements accessor for class " + cls); } public static void setElementsAccessor(Class cls, ElementsAccessor accessor) { synchronized (_elementsAccessors) { _elementsAccessors.put(cls, accessor); } } public static NullHandler getNullHandler(Class cls) throws OgnlException { NullHandler answer = (NullHandler) getHandler(cls, _nullHandlers); if (answer != null) return answer; throw new OgnlException("No null handler for class " + cls); } public static void setNullHandler(Class cls, NullHandler handler) { synchronized (_nullHandlers) { _nullHandlers.put(cls, handler); } } private static Object getHandler(Class forClass, ClassCache handlers) { Object answer = null; synchronized (handlers) { if ((answer = handlers.get(forClass)) == null) { Class keyFound; if (forClass.isArray()) { answer = handlers.get(Object[].class); keyFound = null; } else { keyFound = forClass; outer: for (Class c = forClass; c != null; c = c.getSuperclass()) { answer = handlers.get(c); if (answer == null) { Class[] interfaces = c.getInterfaces(); for (int index = 0, count = interfaces.length; index < count; ++index) { Class iface = interfaces[index]; answer = handlers.get(iface); if (answer == null) { /* Try super-interfaces */ answer = getHandler(iface, handlers); } if (answer != null) { keyFound = iface; break outer; } } } else { keyFound = c; break; } } } if (answer != null) { if (keyFound != forClass) { handlers.put(forClass, answer); } } } } return answer; } public static Object getProperty(OgnlContext context, Object source, Object name) throws OgnlException { PropertyAccessor accessor; if (source == null) { throw new OgnlException("source is null for getProperty(null, \"" + name + "\")"); } if ((accessor = getPropertyAccessor(getTargetClass(source))) == null) { throw new OgnlException("No property accessor for " + getTargetClass(source).getName()); } return accessor.getProperty(context, source, name); } public static void setProperty(OgnlContext context, Object target, Object name, Object value) throws OgnlException { PropertyAccessor accessor; if (target == null) { throw new OgnlException("target is null for setProperty(null, \"" + name + "\", " + value + ")"); } if ((accessor = getPropertyAccessor(getTargetClass(target))) == null) { throw new OgnlException("No property accessor for " + getTargetClass(target).getName()); } accessor.setProperty(context, target, name, value); } /** * Determines the index property type, if any. Returns INDEXED_PROPERTY_NONE if * the property is not index-accessible as determined by OGNL or JavaBeans. If it is indexable * then this will return whether it is a JavaBeans indexed property, conforming to the indexed * property patterns (returns INDEXED_PROPERTY_INT) or if it conforms to the * OGNL arbitrary object indexable (returns INDEXED_PROPERTY_OBJECT). */ public static int getIndexedPropertyType(OgnlContext context, Class sourceClass, String name) throws OgnlException { int result = INDEXED_PROPERTY_NONE; try { PropertyDescriptor pd = getPropertyDescriptor(sourceClass, name); if (pd != null) { if (pd instanceof IndexedPropertyDescriptor) { result = INDEXED_PROPERTY_INT; } else { if (pd instanceof ObjectIndexedPropertyDescriptor) { result = INDEXED_PROPERTY_OBJECT; } } } } catch (Exception ex) { throw new OgnlException("problem determining if '" + name + "' is an indexed property", ex); } return result; } public static Object getIndexedProperty(OgnlContext context, Object source, String name, Object index) throws OgnlException { Object[] args = _objectArrayPool.create(index); try { PropertyDescriptor pd = getPropertyDescriptor((source == null) ? null : source.getClass(), name); Method m; if (pd instanceof IndexedPropertyDescriptor) { m = ((IndexedPropertyDescriptor) pd).getIndexedReadMethod(); } else { if (pd instanceof ObjectIndexedPropertyDescriptor) { m = ((ObjectIndexedPropertyDescriptor) pd).getIndexedReadMethod(); } else { throw new OgnlException("property '" + name + "' is not an indexed property"); } } return callMethod(context, source, m.getName(), args); } catch (OgnlException ex) { throw ex; } catch (Exception ex) { throw new OgnlException("getting indexed property descriptor for '" + name + "'", ex); } finally { _objectArrayPool.recycle(args); } } public static void setIndexedProperty(OgnlContext context, Object source, String name, Object index, Object value) throws OgnlException { Object[] args = _objectArrayPool.create(index, value); try { PropertyDescriptor pd = getPropertyDescriptor((source == null) ? null : source.getClass(), name); Method m; if (pd instanceof IndexedPropertyDescriptor) { m = ((IndexedPropertyDescriptor) pd).getIndexedWriteMethod(); } else { if (pd instanceof ObjectIndexedPropertyDescriptor) { m = ((ObjectIndexedPropertyDescriptor) pd).getIndexedWriteMethod(); } else { throw new OgnlException("property '" + name + "' is not an indexed property"); } } callMethod(context, source, m.getName(), args); } catch (OgnlException ex) { throw ex; } catch (Exception ex) { throw new OgnlException("getting indexed property descriptor for '" + name + "'", ex); } finally { _objectArrayPool.recycle(args); } } public static EvaluationPool getEvaluationPool() { return _evaluationPool; } public static ObjectArrayPool getObjectArrayPool() { return _objectArrayPool; } /** * Registers the specified {@link ClassCacheInspector} with all class reflection based internal * caches. This may have a significant performance impact so be careful using this in production scenarios. * * @param inspector * The inspector instance that will be registered with all internal cache instances. */ public static void setClassCacheInspector(ClassCacheInspector inspector) { _cacheInspector = inspector; _propertyDescriptorCache.setClassInspector(_cacheInspector); _constructorCache.setClassInspector(_cacheInspector); _staticMethodCache.setClassInspector(_cacheInspector); _instanceMethodCache.setClassInspector(_cacheInspector); _invokePermissionCache.setClassInspector(_cacheInspector); _fieldCache.setClassInspector(_cacheInspector); _declaredMethods[0].setClassInspector(_cacheInspector); _declaredMethods[1].setClassInspector(_cacheInspector); } public static Method getMethod(OgnlContext context, Class target, String name, Node[] children, boolean includeStatic) throws Exception { Class[] parms; if (children != null && children.length > 0) { parms = new Class[children.length]; // used to reset context after loop Class currType = context.getCurrentType(); Class currAccessor = context.getCurrentAccessor(); Object cast = context.get(ExpressionCompiler.PRE_CAST); context.setCurrentObject(context.getRoot()); context.setCurrentType(context.getRoot() != null ? context.getRoot().getClass() : null); context.setCurrentAccessor(null); context.setPreviousType(null); for (int i=0; i < children.length; i++) { children[i].toGetSourceString(context, context.getRoot()); parms[i] = context.getCurrentType(); } context.put(ExpressionCompiler.PRE_CAST, cast); context.setCurrentType(currType); context.setCurrentAccessor(currAccessor); context.setCurrentObject(target); } else { parms = new Class[0]; } List methods = OgnlRuntime.getMethods(target, name, includeStatic); if (methods == null) return null; for (int i = 0; i < methods.size(); i++) { Method m = (Method) methods.get(i); boolean varArgs = isJdk15() && m.isVarArgs(); if (parms.length != m.getParameterTypes().length && !varArgs) continue; Class[] mparms = m.getParameterTypes(); boolean matched = true; for (int p = 0; p < mparms.length; p++) { if (varArgs && mparms[p].isArray()){ continue; } if (parms[p] == null) { matched = false; break; } if (parms[p] == mparms[p]) continue; if (mparms[p].isPrimitive() && Character.TYPE != mparms[p] && Byte.TYPE != mparms[p] && Number.class.isAssignableFrom(parms[p]) && OgnlRuntime.getPrimitiveWrapperClass(parms[p]) == mparms[p]) { continue; } matched = false; break; } if (matched) return m; } return null; } /** * Finds the best possible match for a method on the specified target class with a matching * name. * *

* The name matched will also try different combinations like is + name, has + name, get + name, etc.. *

* * @param target * The class to find a matching method against. * @param name * The name of the method. * @return The most likely matching {@link Method}, or null if none could be found. */ public static Method getReadMethod(Class target, String name) { return getReadMethod(target, name, -1); } public static Method getReadMethod(Class target, String name, int numParms) { try { name = name.replaceAll("\"", "").toLowerCase(); BeanInfo info = Introspector.getBeanInfo(target); MethodDescriptor[] methods = info.getMethodDescriptors(); // exact matches first Method m = null; for (int i = 0; i < methods.length; i++) { if (!isMethodCallable(methods[i].getMethod())) continue; if ((methods[i].getName().equalsIgnoreCase(name) || methods[i].getName().toLowerCase().equals(name) || methods[i].getName().toLowerCase().equals("get" + name) || methods[i].getName().toLowerCase().equals("has" + name) || methods[i].getName().toLowerCase().equals("is" + name)) && !methods[i].getName().startsWith("set")) { if (numParms > 0 && methods[i].getMethod().getParameterTypes().length == numParms) return methods[i].getMethod(); else if (numParms < 0) { if ((m != null && m.getParameterTypes().length > methods[i].getMethod().getParameterTypes().length) || m == null) { m = methods[i].getMethod(); } } } } if (m != null) return m; for (int i = 0; i < methods.length; i++) { if (!isMethodCallable(methods[i].getMethod())) continue; if (methods[i].getName().toLowerCase().endsWith(name) && !methods[i].getName().startsWith("set") && methods[i].getMethod().getReturnType() != Void.TYPE) { if (numParms > 0 && methods[i].getMethod().getParameterTypes().length == numParms) return methods[i].getMethod(); else if (numParms < 0) { if ((m != null && m.getParameterTypes().length > methods[i].getMethod().getParameterTypes().length) || m == null) { m = methods[i].getMethod(); } } } } if (m != null) return m; // try one last time adding a get to beginning if (!name.startsWith("get")) return OgnlRuntime.getReadMethod(target, "get" + name, numParms); } catch (Throwable t) { throw OgnlOps.castToRuntime(t); } return null; } public static Method getWriteMethod(Class target, String name) { return getWriteMethod(target, name, -1); } public static Method getWriteMethod(Class target, String name, int numParms) { try { name = name.replaceAll("\"", ""); BeanInfo info = Introspector.getBeanInfo(target); MethodDescriptor[] methods = info.getMethodDescriptors(); for (int i = 0; i < methods.length; i++) { if (!isMethodCallable(methods[i].getMethod())) continue; if ((methods[i].getName().equalsIgnoreCase(name) || methods[i].getName().toLowerCase().equals(name.toLowerCase()) || methods[i].getName().toLowerCase().equals("set" + name.toLowerCase())) && !methods[i].getName().startsWith("get")) { if (numParms > 0 && methods[i].getMethod().getParameterTypes().length == numParms) return methods[i].getMethod(); else if (numParms < 0) return methods[i].getMethod(); } } // try again on pure class Method[] cmethods = target.getClass().getMethods(); for (int i = 0; i < cmethods.length; i++) { if (!isMethodCallable(cmethods[i])) continue; if ((cmethods[i].getName().equalsIgnoreCase(name) || cmethods[i].getName().toLowerCase().equals(name.toLowerCase()) || cmethods[i].getName().toLowerCase().equals("set" + name.toLowerCase())) && !cmethods[i].getName().startsWith("get")) { if (numParms > 0 && cmethods[i].getParameterTypes().length == numParms) return cmethods[i]; else if (numParms < 0) return cmethods[i]; } } // try one last time adding a set to beginning if (!name.startsWith("set")) { return OgnlRuntime.getReadMethod(target, "set" + name, numParms); } } catch (Throwable t) { throw OgnlOps.castToRuntime(t); } return null; } public static PropertyDescriptor getProperty(Class target, String name) { try { BeanInfo info = Introspector.getBeanInfo(target); PropertyDescriptor[] pds = info.getPropertyDescriptors(); for (int i = 0; i < pds.length; i++) { if (pds[i].getName().equalsIgnoreCase(name) || pds[i].getName().toLowerCase().equals(name.toLowerCase()) || pds[i].getName().toLowerCase().endsWith(name.toLowerCase())) return pds[i]; } } catch (Throwable t) { throw OgnlOps.castToRuntime(t); } return null; } public static boolean isBoolean(String expression) { if (expression == null) return false; if ("true".equals(expression) || "false".equals(expression) || "!true".equals(expression) || "!false".equals(expression) || "(true)".equals(expression) || "!(true)".equals(expression) || "(false)".equals(expression) || "!(false)".equals(expression) || expression.startsWith("ognl.OgnlOps")) return true; return false; } /** * Compares the {@link OgnlContext#getCurrentType()} and {@link OgnlContext#getPreviousType()} class types * on the stack to determine if a numeric expression should force object conversion. *

*

* Normally used in conjunction with the forceConversion parameter of * {@link OgnlRuntime#getChildSource(OgnlContext,Object,Node,boolean)}. *

* * @param context The current context. * @return True, if the class types on the stack wouldn't be comparable in a pure numeric expression such as o1 >= o2. */ public static boolean shouldConvertNumericTypes(OgnlContext context) { if (context.getCurrentType() == null || context.getPreviousType() == null) return true; if (context.getCurrentType() == context.getPreviousType() && context.getCurrentType().isPrimitive() && context.getPreviousType().isPrimitive()) return false; return context.getCurrentType() != null && !context.getCurrentType().isArray() && context.getPreviousType() != null && !context.getPreviousType().isArray(); } /** * Attempts to get the java source string represented by the specific child expression * via the {@link JavaSource#toGetSourceString(OgnlContext,Object)} interface method. * * @param context The ognl context to pass to the child. * @param target The current object target to use. * @param child The child expression. * @return The result of calling {@link JavaSource#toGetSourceString(OgnlContext,Object)} plus additional * enclosures of {@link OgnlOps#convertValue(Object,Class,boolean)} for conversions. * @throws OgnlException Mandatory exception throwing catching.. (blehh) */ public static String getChildSource(OgnlContext context, Object target, Node child) throws OgnlException { return getChildSource(context, target, child, false); } /** * Attempts to get the java source string represented by the specific child expression * via the {@link JavaSource#toGetSourceString(OgnlContext,Object)} interface method. * * @param context The ognl context to pass to the child. * @param target The current object target to use. * @param child The child expression. * @param forceConversion If true, forces {@link OgnlOps#convertValue(Object,Class)} conversions on the objects. * @return The result of calling {@link JavaSource#toGetSourceString(OgnlContext,Object)} plus additional * enclosures of {@link OgnlOps#convertValue(Object,Class,boolean)} for conversions. * @throws OgnlException Mandatory exception throwing catching.. (blehh) */ public static String getChildSource(OgnlContext context, Object target, Node child, boolean forceConversion) throws OgnlException { String pre = (String) context.get("_currentChain"); if (pre == null) pre = ""; try { child.getValue(context, target); } catch (NullPointerException e) { // ignore } catch (ArithmeticException e) { context.setCurrentType(int.class); return "0"; } catch (Throwable t) { throw OgnlOps.castToRuntime(t); } String source = null; try { source = child.toGetSourceString(context, target); } catch (Throwable t) { throw OgnlOps.castToRuntime(t); } // handle root / method expressions that may not have proper root java source access if (!ASTConst.class.isInstance(child) && (target == null || context.getRoot() != target)) { source = pre + source; } if (context.getRoot() != null) { source = ExpressionCompiler.getRootExpression(child, context.getRoot(), context) + source; context.setCurrentAccessor(context.getRoot().getClass()); } if (ASTChain.class.isInstance(child)) { String cast = (String) context.remove(ExpressionCompiler.PRE_CAST); if (cast == null) cast = ""; source = cast + source; } if (source == null || source.trim().length() < 1) source = "null"; return source; } } ognl-2.7.3.orig/src/java/ognl/Token.java0000644000175000017500000000734310746450726017731 0ustar drazzibdrazzib/* Generated By:JavaCC: Do not edit this line. Token.java Version 4.1 */ /* JavaCCOptions:TOKEN_EXTENDS=,KEEP_LINE_COL=null */ package ognl; /** * Describes the input token stream. */ public class Token { /** * An integer that describes the kind of this token. This numbering * system is determined by JavaCCParser, and a table of these numbers is * stored in the file ...Constants.java. */ public int kind; /** The line number of the first character of this Token. */ public int beginLine; /** The column number of the first character of this Token. */ public int beginColumn; /** The line number of the last character of this Token. */ public int endLine; /** The column number of the last character of this Token. */ public int endColumn; /** * The string image of the token. */ public String image; /** * A reference to the next regular (non-special) token from the input * stream. If this is the last token from the input stream, or if the * token manager has not read tokens beyond this one, this field is * set to null. This is true only if this token is also a regular * token. Otherwise, see below for a description of the contents of * this field. */ public Token next; /** * This field is used to access special tokens that occur prior to this * token, but after the immediately preceding regular (non-special) token. * If there are no such special tokens, this field is set to null. * When there are more than one such special token, this field refers * to the last of these special tokens, which in turn refers to the next * previous special token through its specialToken field, and so on * until the first special token (whose specialToken field is null). * The next fields of special tokens refer to other special tokens that * immediately follow it (without an intervening regular token). If there * is no such token, this field is null. */ public Token specialToken; /** * An optional attribute value of the Token. * Tokens which are not used as syntactic sugar will often contain * meaningful values that will be used later on by the compiler or * interpreter. This attribute value is often different from the image. * Any subclass of Token that actually wants to return a non-null value can * override this method as appropriate. */ public Object getValue() { return null; } /** * No-argument contructor */ public Token() {} /** * Constructs a new token for the specified Image. */ public Token(int kind) { this(kind, null); } /** * Constructs a new token for the specified Image and Kind. */ public Token(int kind, String image) { this.kind = kind; this.image = image; } /** * Returns the image. */ public String toString() { return image; } /** * Returns a new Token object, by default. However, if you want, you * can create and return subclass objects based on the value of ofKind. * Simply add the cases to the switch for all those special cases. * For example, if you have a subclass of Token called IDToken that * you want to create if ofKind is ID, simply add something like : * * case MyParserConstants.ID : return new IDToken(ofKind, image); * * to the following switch statement. Then you can cast matchedToken * variable to the appropriate type and use sit in your lexical actions. */ public static Token newToken(int ofKind, String image) { switch(ofKind) { default : return new Token(ofKind, image); } } public static Token newToken(int ofKind) { return newToken(ofKind, null); } } /* JavaCC - OriginalChecksum=771cf4338e4d91b53163152263c004d8 (do not edit this line) */ ognl-2.7.3.orig/src/java/ognl/EnumerationPropertyAccessor.java0000644000175000017500000000617710561411075024360 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 1998-2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package ognl; import java.util.*; /** * Implementation of PropertyAccessor that provides "property" reference to * "nextElement" (aliases to "next" also) and "hasMoreElements" (also aliased * to "hasNext"). * @author Luke Blanshard (blanshlu@netscape.net) * @author Drew Davidson (drew@ognl.org) */ public class EnumerationPropertyAccessor extends ObjectPropertyAccessor implements PropertyAccessor // This is here to make javadoc show this class as an implementor { public Object getProperty( Map context, Object target, Object name ) throws OgnlException { Object result; Enumeration e = (Enumeration)target; if ( name instanceof String ) { if (name.equals("next") || name.equals("nextElement")) { result = e.nextElement(); } else { if (name.equals("hasNext") || name.equals("hasMoreElements")) { result = e.hasMoreElements() ? Boolean.TRUE : Boolean.FALSE; } else { result = super.getProperty( context, target, name ); } } } else { result = super.getProperty(context, target, name); } return result; } public void setProperty( Map context, Object target, Object name, Object value ) throws OgnlException { throw new IllegalArgumentException( "can't set property " + name + " on Enumeration" ); } } ognl-2.7.3.orig/src/java/ognl/ognl.jj0000644000175000017500000022376210746450726017277 0ustar drazzibdrazzib/*@bgen(jjtree) Generated By:JJTree: Do not edit this line. src/java/ognl/ognl.jj */ /*@egen*///-------------------------------------------------------------------------- // Copyright (c) 1998-2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- /* * This file defines the syntax of OGNL, the Object-Graph Navigation Language. This * language was devised by Drew Davidson, who called it Key-Value Coding Language. Luke * Blanshard then made up the new name and reimplemented it using ANTLR, refining and * polishing the language a bit on the way. Drew maintained the system for a couple of * years; then Luke converted the ANTLR grammar to JavaCC, to eliminate the run-time * dependency on ANTLR. * * See package.html for a description of the language. */ options { // Parser options LOOKAHEAD = 1; STATIC = false; JAVA_UNICODE_ESCAPE = true; UNICODE_INPUT = true; } PARSER_BEGIN(OgnlParser) package ognl; import java.math.*; /** * OgnlParser is a JavaCC parser class; it translates OGNL expressions into abstract * syntax trees (ASTs) that can then be interpreted by the getValue and setValue methods. */ public class OgnlParser/*@bgen(jjtree)*/implements OgnlParserTreeConstants/*@egen*/ {/*@bgen(jjtree)*/ protected JJTOgnlParserState jjtree = new JJTOgnlParserState(); /*@egen*/ } PARSER_END(OgnlParser) /** * This is the top-level construct of OGNL. */ Node topLevelExpression() : {} { expression() { return jjtree.rootNode(); } } // sequence (level 14) void expression() : {} { assignmentExpression() ( ","/*@bgen(jjtree) #Sequence( 2) */ { ASTSequence jjtn001 = new ASTSequence(JJTSEQUENCE); boolean jjtc001 = true; jjtree.openNodeScope(jjtn001); } try { /*@egen*/ assignmentExpression()/*@bgen(jjtree)*/ } catch (Throwable jjte001) { if (jjtc001) { jjtree.clearNodeScope(jjtn001); jjtc001 = false; } else { jjtree.popNode(); } if (jjte001 instanceof RuntimeException) { throw (RuntimeException)jjte001; } if (jjte001 instanceof ParseException) { throw (ParseException)jjte001; } throw (Error)jjte001; } finally { if (jjtc001) { jjtree.closeNodeScope(jjtn001, 2); } } /*@egen*/ )* } // assignment expression (level 13) void assignmentExpression() : {} { conditionalTestExpression() [ "="/*@bgen(jjtree) #Assign( 2) */ { ASTAssign jjtn001 = new ASTAssign(JJTASSIGN); boolean jjtc001 = true; jjtree.openNodeScope(jjtn001); } try { /*@egen*/ assignmentExpression()/*@bgen(jjtree)*/ } catch (Throwable jjte001) { if (jjtc001) { jjtree.clearNodeScope(jjtn001); jjtc001 = false; } else { jjtree.popNode(); } if (jjte001 instanceof RuntimeException) { throw (RuntimeException)jjte001; } if (jjte001 instanceof ParseException) { throw (ParseException)jjte001; } throw (Error)jjte001; } finally { if (jjtc001) { jjtree.closeNodeScope(jjtn001, 2); } } /*@egen*/ ] } // conditional test (level 12) void conditionalTestExpression() : {} { logicalOrExpression() [ "?" conditionalTestExpression() ":"/*@bgen(jjtree) #Test( 3) */ { ASTTest jjtn001 = new ASTTest(JJTTEST); boolean jjtc001 = true; jjtree.openNodeScope(jjtn001); } try { /*@egen*/ conditionalTestExpression()/*@bgen(jjtree)*/ } catch (Throwable jjte001) { if (jjtc001) { jjtree.clearNodeScope(jjtn001); jjtc001 = false; } else { jjtree.popNode(); } if (jjte001 instanceof RuntimeException) { throw (RuntimeException)jjte001; } if (jjte001 instanceof ParseException) { throw (ParseException)jjte001; } throw (Error)jjte001; } finally { if (jjtc001) { jjtree.closeNodeScope(jjtn001, 3); } } /*@egen*/ ] } // logical or (||) (level 11) void logicalOrExpression() : {} { logicalAndExpression() (("||" | "or")/*@bgen(jjtree) #Or( 2) */ { ASTOr jjtn001 = new ASTOr(JJTOR); boolean jjtc001 = true; jjtree.openNodeScope(jjtn001); } try { /*@egen*/ logicalAndExpression()/*@bgen(jjtree)*/ } catch (Throwable jjte001) { if (jjtc001) { jjtree.clearNodeScope(jjtn001); jjtc001 = false; } else { jjtree.popNode(); } if (jjte001 instanceof RuntimeException) { throw (RuntimeException)jjte001; } if (jjte001 instanceof ParseException) { throw (ParseException)jjte001; } throw (Error)jjte001; } finally { if (jjtc001) { jjtree.closeNodeScope(jjtn001, 2); } } /*@egen*/ )* } // logical and (&&) (level 10) void logicalAndExpression() : {} { inclusiveOrExpression() (("&&" | "and")/*@bgen(jjtree) #And( 2) */ { ASTAnd jjtn001 = new ASTAnd(JJTAND); boolean jjtc001 = true; jjtree.openNodeScope(jjtn001); } try { /*@egen*/ inclusiveOrExpression()/*@bgen(jjtree)*/ } catch (Throwable jjte001) { if (jjtc001) { jjtree.clearNodeScope(jjtn001); jjtc001 = false; } else { jjtree.popNode(); } if (jjte001 instanceof RuntimeException) { throw (RuntimeException)jjte001; } if (jjte001 instanceof ParseException) { throw (ParseException)jjte001; } throw (Error)jjte001; } finally { if (jjtc001) { jjtree.closeNodeScope(jjtn001, 2); } } /*@egen*/ )* } // bitwise or non-short-circuiting or (|) (level 9) void inclusiveOrExpression() : {} { exclusiveOrExpression() (("|" | "bor")/*@bgen(jjtree) #BitOr( 2) */ { ASTBitOr jjtn001 = new ASTBitOr(JJTBITOR); boolean jjtc001 = true; jjtree.openNodeScope(jjtn001); } try { /*@egen*/ exclusiveOrExpression()/*@bgen(jjtree)*/ } catch (Throwable jjte001) { if (jjtc001) { jjtree.clearNodeScope(jjtn001); jjtc001 = false; } else { jjtree.popNode(); } if (jjte001 instanceof RuntimeException) { throw (RuntimeException)jjte001; } if (jjte001 instanceof ParseException) { throw (ParseException)jjte001; } throw (Error)jjte001; } finally { if (jjtc001) { jjtree.closeNodeScope(jjtn001, 2); } } /*@egen*/ )* } // exclusive or (^) (level 8) void exclusiveOrExpression() : {} { andExpression() (("^" | "xor")/*@bgen(jjtree) #Xor( 2) */ { ASTXor jjtn001 = new ASTXor(JJTXOR); boolean jjtc001 = true; jjtree.openNodeScope(jjtn001); } try { /*@egen*/ andExpression()/*@bgen(jjtree)*/ } catch (Throwable jjte001) { if (jjtc001) { jjtree.clearNodeScope(jjtn001); jjtc001 = false; } else { jjtree.popNode(); } if (jjte001 instanceof RuntimeException) { throw (RuntimeException)jjte001; } if (jjte001 instanceof ParseException) { throw (ParseException)jjte001; } throw (Error)jjte001; } finally { if (jjtc001) { jjtree.closeNodeScope(jjtn001, 2); } } /*@egen*/ )* } // bitwise or non-short-circuiting and (&) (level 7) void andExpression() : {} { equalityExpression() (("&" | "band")/*@bgen(jjtree) #BitAnd( 2) */ { ASTBitAnd jjtn001 = new ASTBitAnd(JJTBITAND); boolean jjtc001 = true; jjtree.openNodeScope(jjtn001); } try { /*@egen*/ equalityExpression()/*@bgen(jjtree)*/ } catch (Throwable jjte001) { if (jjtc001) { jjtree.clearNodeScope(jjtn001); jjtc001 = false; } else { jjtree.popNode(); } if (jjte001 instanceof RuntimeException) { throw (RuntimeException)jjte001; } if (jjte001 instanceof ParseException) { throw (ParseException)jjte001; } throw (Error)jjte001; } finally { if (jjtc001) { jjtree.closeNodeScope(jjtn001, 2); } } /*@egen*/ )* } // equality/inequality (==/!=) (level 6) void equalityExpression() : {} { relationalExpression() ( ("==" | "eq")/*@bgen(jjtree) #Eq( 2) */ { ASTEq jjtn001 = new ASTEq(JJTEQ); boolean jjtc001 = true; jjtree.openNodeScope(jjtn001); } try { /*@egen*/ relationalExpression()/*@bgen(jjtree)*/ } catch (Throwable jjte001) { if (jjtc001) { jjtree.clearNodeScope(jjtn001); jjtc001 = false; } else { jjtree.popNode(); } if (jjte001 instanceof RuntimeException) { throw (RuntimeException)jjte001; } if (jjte001 instanceof ParseException) { throw (ParseException)jjte001; } throw (Error)jjte001; } finally { if (jjtc001) { jjtree.closeNodeScope(jjtn001, 2); } } /*@egen*/ | ("!=" | "neq")/*@bgen(jjtree) #NotEq( 2) */ { ASTNotEq jjtn002 = new ASTNotEq(JJTNOTEQ); boolean jjtc002 = true; jjtree.openNodeScope(jjtn002); } try { /*@egen*/ relationalExpression()/*@bgen(jjtree)*/ } catch (Throwable jjte002) { if (jjtc002) { jjtree.clearNodeScope(jjtn002); jjtc002 = false; } else { jjtree.popNode(); } if (jjte002 instanceof RuntimeException) { throw (RuntimeException)jjte002; } if (jjte002 instanceof ParseException) { throw (ParseException)jjte002; } throw (Error)jjte002; } finally { if (jjtc002) { jjtree.closeNodeScope(jjtn002, 2); } } /*@egen*/ )* } // boolean relational expressions (level 5) void relationalExpression() : {} { shiftExpression() ( ("<" | "lt")/*@bgen(jjtree) #Less( 2) */ { ASTLess jjtn001 = new ASTLess(JJTLESS); boolean jjtc001 = true; jjtree.openNodeScope(jjtn001); } try { /*@egen*/ shiftExpression()/*@bgen(jjtree)*/ } catch (Throwable jjte001) { if (jjtc001) { jjtree.clearNodeScope(jjtn001); jjtc001 = false; } else { jjtree.popNode(); } if (jjte001 instanceof RuntimeException) { throw (RuntimeException)jjte001; } if (jjte001 instanceof ParseException) { throw (ParseException)jjte001; } throw (Error)jjte001; } finally { if (jjtc001) { jjtree.closeNodeScope(jjtn001, 2); } } /*@egen*/ | (">" | "gt")/*@bgen(jjtree) #Greater( 2) */ { ASTGreater jjtn002 = new ASTGreater(JJTGREATER); boolean jjtc002 = true; jjtree.openNodeScope(jjtn002); } try { /*@egen*/ shiftExpression()/*@bgen(jjtree)*/ } catch (Throwable jjte002) { if (jjtc002) { jjtree.clearNodeScope(jjtn002); jjtc002 = false; } else { jjtree.popNode(); } if (jjte002 instanceof RuntimeException) { throw (RuntimeException)jjte002; } if (jjte002 instanceof ParseException) { throw (ParseException)jjte002; } throw (Error)jjte002; } finally { if (jjtc002) { jjtree.closeNodeScope(jjtn002, 2); } } /*@egen*/ | ("<=" | "lte")/*@bgen(jjtree) #LessEq( 2) */ { ASTLessEq jjtn003 = new ASTLessEq(JJTLESSEQ); boolean jjtc003 = true; jjtree.openNodeScope(jjtn003); } try { /*@egen*/ shiftExpression()/*@bgen(jjtree)*/ } catch (Throwable jjte003) { if (jjtc003) { jjtree.clearNodeScope(jjtn003); jjtc003 = false; } else { jjtree.popNode(); } if (jjte003 instanceof RuntimeException) { throw (RuntimeException)jjte003; } if (jjte003 instanceof ParseException) { throw (ParseException)jjte003; } throw (Error)jjte003; } finally { if (jjtc003) { jjtree.closeNodeScope(jjtn003, 2); } } /*@egen*/ | (">=" | "gte")/*@bgen(jjtree) #GreaterEq( 2) */ { ASTGreaterEq jjtn004 = new ASTGreaterEq(JJTGREATEREQ); boolean jjtc004 = true; jjtree.openNodeScope(jjtn004); } try { /*@egen*/ shiftExpression()/*@bgen(jjtree)*/ } catch (Throwable jjte004) { if (jjtc004) { jjtree.clearNodeScope(jjtn004); jjtc004 = false; } else { jjtree.popNode(); } if (jjte004 instanceof RuntimeException) { throw (RuntimeException)jjte004; } if (jjte004 instanceof ParseException) { throw (ParseException)jjte004; } throw (Error)jjte004; } finally { if (jjtc004) { jjtree.closeNodeScope(jjtn004, 2); } } /*@egen*/ | "in"/*@bgen(jjtree) #In( 2) */ { ASTIn jjtn005 = new ASTIn(JJTIN); boolean jjtc005 = true; jjtree.openNodeScope(jjtn005); } try { /*@egen*/ shiftExpression()/*@bgen(jjtree)*/ } catch (Throwable jjte005) { if (jjtc005) { jjtree.clearNodeScope(jjtn005); jjtc005 = false; } else { jjtree.popNode(); } if (jjte005 instanceof RuntimeException) { throw (RuntimeException)jjte005; } if (jjte005 instanceof ParseException) { throw (ParseException)jjte005; } throw (Error)jjte005; } finally { if (jjtc005) { jjtree.closeNodeScope(jjtn005, 2); } } /*@egen*/ | "not" "in"/*@bgen(jjtree) #NotIn( 2) */ { ASTNotIn jjtn006 = new ASTNotIn(JJTNOTIN); boolean jjtc006 = true; jjtree.openNodeScope(jjtn006); } try { /*@egen*/ shiftExpression()/*@bgen(jjtree)*/ } catch (Throwable jjte006) { if (jjtc006) { jjtree.clearNodeScope(jjtn006); jjtc006 = false; } else { jjtree.popNode(); } if (jjte006 instanceof RuntimeException) { throw (RuntimeException)jjte006; } if (jjte006 instanceof ParseException) { throw (ParseException)jjte006; } throw (Error)jjte006; } finally { if (jjtc006) { jjtree.closeNodeScope(jjtn006, 2); } } /*@egen*/ )* } // bit shift expressions (level 4) void shiftExpression() : {} { additiveExpression() ( ("<<" | "shl")/*@bgen(jjtree) #ShiftLeft( 2) */ { ASTShiftLeft jjtn001 = new ASTShiftLeft(JJTSHIFTLEFT); boolean jjtc001 = true; jjtree.openNodeScope(jjtn001); } try { /*@egen*/ additiveExpression()/*@bgen(jjtree)*/ } catch (Throwable jjte001) { if (jjtc001) { jjtree.clearNodeScope(jjtn001); jjtc001 = false; } else { jjtree.popNode(); } if (jjte001 instanceof RuntimeException) { throw (RuntimeException)jjte001; } if (jjte001 instanceof ParseException) { throw (ParseException)jjte001; } throw (Error)jjte001; } finally { if (jjtc001) { jjtree.closeNodeScope(jjtn001, 2); } } /*@egen*/ | (">>" | "shr")/*@bgen(jjtree) #ShiftRight( 2) */ { ASTShiftRight jjtn002 = new ASTShiftRight(JJTSHIFTRIGHT); boolean jjtc002 = true; jjtree.openNodeScope(jjtn002); } try { /*@egen*/ additiveExpression()/*@bgen(jjtree)*/ } catch (Throwable jjte002) { if (jjtc002) { jjtree.clearNodeScope(jjtn002); jjtc002 = false; } else { jjtree.popNode(); } if (jjte002 instanceof RuntimeException) { throw (RuntimeException)jjte002; } if (jjte002 instanceof ParseException) { throw (ParseException)jjte002; } throw (Error)jjte002; } finally { if (jjtc002) { jjtree.closeNodeScope(jjtn002, 2); } } /*@egen*/ | (">>>" | "ushr")/*@bgen(jjtree) #UnsignedShiftRight( 2) */ { ASTUnsignedShiftRight jjtn003 = new ASTUnsignedShiftRight(JJTUNSIGNEDSHIFTRIGHT); boolean jjtc003 = true; jjtree.openNodeScope(jjtn003); } try { /*@egen*/ additiveExpression()/*@bgen(jjtree)*/ } catch (Throwable jjte003) { if (jjtc003) { jjtree.clearNodeScope(jjtn003); jjtc003 = false; } else { jjtree.popNode(); } if (jjte003 instanceof RuntimeException) { throw (RuntimeException)jjte003; } if (jjte003 instanceof ParseException) { throw (ParseException)jjte003; } throw (Error)jjte003; } finally { if (jjtc003) { jjtree.closeNodeScope(jjtn003, 2); } } /*@egen*/ )* } // binary addition/subtraction (level 3) void additiveExpression() : {} { multiplicativeExpression() ( "+"/*@bgen(jjtree) #Add( 2) */ { ASTAdd jjtn001 = new ASTAdd(JJTADD); boolean jjtc001 = true; jjtree.openNodeScope(jjtn001); } try { /*@egen*/ multiplicativeExpression()/*@bgen(jjtree)*/ } catch (Throwable jjte001) { if (jjtc001) { jjtree.clearNodeScope(jjtn001); jjtc001 = false; } else { jjtree.popNode(); } if (jjte001 instanceof RuntimeException) { throw (RuntimeException)jjte001; } if (jjte001 instanceof ParseException) { throw (ParseException)jjte001; } throw (Error)jjte001; } finally { if (jjtc001) { jjtree.closeNodeScope(jjtn001, 2); } } /*@egen*/ | "-"/*@bgen(jjtree) #Subtract( 2) */ { ASTSubtract jjtn002 = new ASTSubtract(JJTSUBTRACT); boolean jjtc002 = true; jjtree.openNodeScope(jjtn002); } try { /*@egen*/ multiplicativeExpression()/*@bgen(jjtree)*/ } catch (Throwable jjte002) { if (jjtc002) { jjtree.clearNodeScope(jjtn002); jjtc002 = false; } else { jjtree.popNode(); } if (jjte002 instanceof RuntimeException) { throw (RuntimeException)jjte002; } if (jjte002 instanceof ParseException) { throw (ParseException)jjte002; } throw (Error)jjte002; } finally { if (jjtc002) { jjtree.closeNodeScope(jjtn002, 2); } } /*@egen*/ )* } // multiplication/division/remainder (level 2) void multiplicativeExpression() : {} { unaryExpression() ( "*"/*@bgen(jjtree) #Multiply( 2) */ { ASTMultiply jjtn001 = new ASTMultiply(JJTMULTIPLY); boolean jjtc001 = true; jjtree.openNodeScope(jjtn001); } try { /*@egen*/ unaryExpression()/*@bgen(jjtree)*/ } catch (Throwable jjte001) { if (jjtc001) { jjtree.clearNodeScope(jjtn001); jjtc001 = false; } else { jjtree.popNode(); } if (jjte001 instanceof RuntimeException) { throw (RuntimeException)jjte001; } if (jjte001 instanceof ParseException) { throw (ParseException)jjte001; } throw (Error)jjte001; } finally { if (jjtc001) { jjtree.closeNodeScope(jjtn001, 2); } } /*@egen*/ | "/"/*@bgen(jjtree) #Divide( 2) */ { ASTDivide jjtn002 = new ASTDivide(JJTDIVIDE); boolean jjtc002 = true; jjtree.openNodeScope(jjtn002); } try { /*@egen*/ unaryExpression()/*@bgen(jjtree)*/ } catch (Throwable jjte002) { if (jjtc002) { jjtree.clearNodeScope(jjtn002); jjtc002 = false; } else { jjtree.popNode(); } if (jjte002 instanceof RuntimeException) { throw (RuntimeException)jjte002; } if (jjte002 instanceof ParseException) { throw (ParseException)jjte002; } throw (Error)jjte002; } finally { if (jjtc002) { jjtree.closeNodeScope(jjtn002, 2); } } /*@egen*/ | "%"/*@bgen(jjtree) #Remainder( 2) */ { ASTRemainder jjtn003 = new ASTRemainder(JJTREMAINDER); boolean jjtc003 = true; jjtree.openNodeScope(jjtn003); } try { /*@egen*/ unaryExpression()/*@bgen(jjtree)*/ } catch (Throwable jjte003) { if (jjtc003) { jjtree.clearNodeScope(jjtn003); jjtc003 = false; } else { jjtree.popNode(); } if (jjte003 instanceof RuntimeException) { throw (RuntimeException)jjte003; } if (jjte003 instanceof ParseException) { throw (ParseException)jjte003; } throw (Error)jjte003; } finally { if (jjtc003) { jjtree.closeNodeScope(jjtn003, 2); } } /*@egen*/ )* } // unary (level 1) void unaryExpression() : { StringBuffer sb; Token t; ASTInstanceof ionode; } { ( "-"/*@bgen(jjtree) #Negate( 1) */ { ASTNegate jjtn001 = new ASTNegate(JJTNEGATE); boolean jjtc001 = true; jjtree.openNodeScope(jjtn001); } try { /*@egen*/ unaryExpression()/*@bgen(jjtree)*/ } catch (Throwable jjte001) { if (jjtc001) { jjtree.clearNodeScope(jjtn001); jjtc001 = false; } else { jjtree.popNode(); } if (jjte001 instanceof RuntimeException) { throw (RuntimeException)jjte001; } if (jjte001 instanceof ParseException) { throw (ParseException)jjte001; } throw (Error)jjte001; } finally { if (jjtc001) { jjtree.closeNodeScope(jjtn001, 1); } } /*@egen*/ | "+" unaryExpression() // Just leave it there | "~"/*@bgen(jjtree) #BitNegate( 1) */ { ASTBitNegate jjtn002 = new ASTBitNegate(JJTBITNEGATE); boolean jjtc002 = true; jjtree.openNodeScope(jjtn002); } try { /*@egen*/ unaryExpression()/*@bgen(jjtree)*/ } catch (Throwable jjte002) { if (jjtc002) { jjtree.clearNodeScope(jjtn002); jjtc002 = false; } else { jjtree.popNode(); } if (jjte002 instanceof RuntimeException) { throw (RuntimeException)jjte002; } if (jjte002 instanceof ParseException) { throw (ParseException)jjte002; } throw (Error)jjte002; } finally { if (jjtc002) { jjtree.closeNodeScope(jjtn002, 1); } } /*@egen*/ | ("!" | "not")/*@bgen(jjtree) #Not( 1) */ { ASTNot jjtn003 = new ASTNot(JJTNOT); boolean jjtc003 = true; jjtree.openNodeScope(jjtn003); } try { /*@egen*/ unaryExpression()/*@bgen(jjtree)*/ } catch (Throwable jjte003) { if (jjtc003) { jjtree.clearNodeScope(jjtn003); jjtc003 = false; } else { jjtree.popNode(); } if (jjte003 instanceof RuntimeException) { throw (RuntimeException)jjte003; } if (jjte003 instanceof ParseException) { throw (ParseException)jjte003; } throw (Error)jjte003; } finally { if (jjtc003) { jjtree.closeNodeScope(jjtn003, 1); } } /*@egen*/ | navigationChain() [ "instanceof" t = /*@bgen(jjtree) #Instanceof( 1) */ { ASTInstanceof jjtn004 = new ASTInstanceof(JJTINSTANCEOF); boolean jjtc004 = true; jjtree.openNodeScope(jjtn004); } try { /*@egen*//*@bgen(jjtree)*/ { jjtree.closeNodeScope(jjtn004, 1); jjtc004 = false; } /*@egen*/ { sb = new StringBuffer(t.image); ionode = jjtn004; }/*@bgen(jjtree)*/ } finally { if (jjtc004) { jjtree.closeNodeScope(jjtn004, 1); } } /*@egen*/ ( "." t = { sb.append('.').append( t.image ); } )* { ionode.setTargetType( new String(sb) ); } ] ) } // navigation chain: property references, method calls, projections, selections, etc. void navigationChain() : {} { primaryExpression() ( "."/*@bgen(jjtree) #Chain( 2) */ { ASTChain jjtn001 = new ASTChain(JJTCHAIN); boolean jjtc001 = true; jjtree.openNodeScope(jjtn001); } try { /*@egen*/ ( /* Prevent the "eval" ambiguity from issuing a warning; see discussion below. */ ( LOOKAHEAD(2) methodCall() | propertyName() ) // Also handle "{", which requires a lookahead of 2. | ( LOOKAHEAD(2) projection() | selection() ) | "(" expression() ")" )/*@bgen(jjtree)*/ } catch (Throwable jjte001) { if (jjtc001) { jjtree.clearNodeScope(jjtn001); jjtc001 = false; } else { jjtree.popNode(); } if (jjte001 instanceof RuntimeException) { throw (RuntimeException)jjte001; } if (jjte001 instanceof ParseException) { throw (ParseException)jjte001; } throw (Error)jjte001; } finally { if (jjtc001) { jjtree.closeNodeScope(jjtn001, 2); } } /*@egen*/ |/*@bgen(jjtree) #Chain( 2) */ { ASTChain jjtn002 = new ASTChain(JJTCHAIN); boolean jjtc002 = true; jjtree.openNodeScope(jjtn002); } try { /*@egen*/ index()/*@bgen(jjtree)*/ } catch (Throwable jjte002) { if (jjtc002) { jjtree.clearNodeScope(jjtn002); jjtc002 = false; } else { jjtree.popNode(); } if (jjte002 instanceof RuntimeException) { throw (RuntimeException)jjte002; } if (jjte002 instanceof ParseException) { throw (ParseException)jjte002; } throw (Error)jjte002; } finally { if (jjtc002) { jjtree.closeNodeScope(jjtn002, 2); } } /*@egen*/ | "(" expression()/*@bgen(jjtree) #Eval( 2) */ { ASTEval jjtn003 = new ASTEval(JJTEVAL); boolean jjtc003 = true; jjtree.openNodeScope(jjtn003); } try { /*@egen*/ ")"/*@bgen(jjtree)*/ } finally { if (jjtc003) { jjtree.closeNodeScope(jjtn003, 2); } } /*@egen*/ /* Using parentheses to indicate evaluation of the current object makes this language ambiguous, because the expression "ident(args)" could be seen as a single method call or as a property name followed by an evaluation. We always put the method call first and turn off the ambiguity warning; we always want to interpret this as a method call. */ )* } void primaryExpression() : { Token t; String className = null; } { ( ( | | | | )/*@bgen(jjtree) #Const( 0) */ { ASTConst jjtn001 = new ASTConst(JJTCONST); boolean jjtc001 = true; jjtree.openNodeScope(jjtn001); } try { /*@egen*//*@bgen(jjtree)*/ { jjtree.closeNodeScope(jjtn001, 0); jjtc001 = false; } /*@egen*/ { jjtn001.setValue( token_source.literalValue ); }/*@bgen(jjtree)*/ } finally { if (jjtc001) { jjtree.closeNodeScope(jjtn001, 0); } } /*@egen*/ | "true"/*@bgen(jjtree) #Const( 0) */ { ASTConst jjtn002 = new ASTConst(JJTCONST); boolean jjtc002 = true; jjtree.openNodeScope(jjtn002); } try { /*@egen*//*@bgen(jjtree)*/ { jjtree.closeNodeScope(jjtn002, 0); jjtc002 = false; } /*@egen*/ { jjtn002.setValue( Boolean.TRUE ); }/*@bgen(jjtree)*/ } finally { if (jjtc002) { jjtree.closeNodeScope(jjtn002, 0); } } /*@egen*/ | "false"/*@bgen(jjtree) #Const( 0) */ { ASTConst jjtn003 = new ASTConst(JJTCONST); boolean jjtc003 = true; jjtree.openNodeScope(jjtn003); } try { /*@egen*//*@bgen(jjtree)*/ { jjtree.closeNodeScope(jjtn003, 0); jjtc003 = false; } /*@egen*/ { jjtn003.setValue( Boolean.FALSE ); }/*@bgen(jjtree)*/ } finally { if (jjtc003) { jjtree.closeNodeScope(jjtn003, 0); } } /*@egen*/ |/*@bgen(jjtree) #Const( 0) */ { ASTConst jjtn004 = new ASTConst(JJTCONST); boolean jjtc004 = true; jjtree.openNodeScope(jjtn004); } try { /*@egen*/ "null"/*@bgen(jjtree)*/ } finally { if (jjtc004) { jjtree.closeNodeScope(jjtn004, 0); } } /*@egen*/ // Null is the default value in an ASTConst | LOOKAHEAD(2) "#this"/*@bgen(jjtree) #ThisVarRef( 0) */ { ASTThisVarRef jjtn005 = new ASTThisVarRef(JJTTHISVARREF); boolean jjtc005 = true; jjtree.openNodeScope(jjtn005); } try { /*@egen*//*@bgen(jjtree)*/ { jjtree.closeNodeScope(jjtn005, 0); jjtc005 = false; } /*@egen*/ { jjtn005.setName( "this" ); }/*@bgen(jjtree)*/ } finally { if (jjtc005) { jjtree.closeNodeScope(jjtn005, 0); } } /*@egen*/ | LOOKAHEAD(2) "#root"/*@bgen(jjtree) #RootVarRef( 0) */ { ASTRootVarRef jjtn006 = new ASTRootVarRef(JJTROOTVARREF); boolean jjtc006 = true; jjtree.openNodeScope(jjtn006); } try { /*@egen*//*@bgen(jjtree)*/ { jjtree.closeNodeScope(jjtn006, 0); jjtc006 = false; } /*@egen*/ { jjtn006.setName( "root" ); }/*@bgen(jjtree)*/ } finally { if (jjtc006) { jjtree.closeNodeScope(jjtn006, 0); } } /*@egen*/ | LOOKAHEAD(2) "#" t=/*@bgen(jjtree) #VarRef( 0) */ { ASTVarRef jjtn007 = new ASTVarRef(JJTVARREF); boolean jjtc007 = true; jjtree.openNodeScope(jjtn007); } try { /*@egen*//*@bgen(jjtree)*/ { jjtree.closeNodeScope(jjtn007, 0); jjtc007 = false; } /*@egen*/ { jjtn007.setName( t.image ); }/*@bgen(jjtree)*/ } finally { if (jjtc007) { jjtree.closeNodeScope(jjtn007, 0); } } /*@egen*/ | LOOKAHEAD(2) ":" "[" expression() "]"/*@bgen(jjtree) #Const( 1) */ { ASTConst jjtn008 = new ASTConst(JJTCONST); boolean jjtc008 = true; jjtree.openNodeScope(jjtn008); } try { /*@egen*//*@bgen(jjtree)*/ { jjtree.closeNodeScope(jjtn008, 1); jjtc008 = false; } /*@egen*/ { jjtn008.setValue( jjtn008.jjtGetChild(0) ); }/*@bgen(jjtree)*/ } finally { if (jjtc008) { jjtree.closeNodeScope(jjtn008, 1); } } /*@egen*/ | staticReference() | LOOKAHEAD(2) constructorCall() | // Prevent the "eval" ambiguity from issuing a warning; see discussion elsewhere. ( LOOKAHEAD(2) methodCall() | propertyName() ) | index() | "(" expression() ")" | "{"/*@bgen(jjtree) List */ { ASTList jjtn009 = new ASTList(JJTLIST); boolean jjtc009 = true; jjtree.openNodeScope(jjtn009); } try { /*@egen*/ [assignmentExpression() ("," assignmentExpression())*]/*@bgen(jjtree)*/ } catch (Throwable jjte009) { if (jjtc009) { jjtree.clearNodeScope(jjtn009); jjtc009 = false; } else { jjtree.popNode(); } if (jjte009 instanceof RuntimeException) { throw (RuntimeException)jjte009; } if (jjte009 instanceof ParseException) { throw (ParseException)jjte009; } throw (Error)jjte009; } finally { if (jjtc009) { jjtree.closeNodeScope(jjtn009, true); } } /*@egen*/ "}" | LOOKAHEAD(2)/*@bgen(jjtree) Map */ { ASTMap jjtn010 = new ASTMap(JJTMAP); boolean jjtc010 = true; jjtree.openNodeScope(jjtn010); } try { /*@egen*/ ( "#" (className=classReference())? "{" [keyValueExpression() ("," keyValueExpression())*] { jjtn010.setClassName(className); } "}" )/*@bgen(jjtree)*/ } catch (Throwable jjte010) { if (jjtc010) { jjtree.clearNodeScope(jjtn010); jjtc010 = false; } else { jjtree.popNode(); } if (jjte010 instanceof RuntimeException) { throw (RuntimeException)jjte010; } if (jjte010 instanceof ParseException) { throw (ParseException)jjte010; } throw (Error)jjte010; } finally { if (jjtc010) { jjtree.closeNodeScope(jjtn010, true); } } /*@egen*/ ) } void keyValueExpression() : {} {/*@bgen(jjtree) KeyValue */ { ASTKeyValue jjtn001 = new ASTKeyValue(JJTKEYVALUE); boolean jjtc001 = true; jjtree.openNodeScope(jjtn001); } try { /*@egen*/ ( assignmentExpression() (":" assignmentExpression())? )/*@bgen(jjtree)*/ } catch (Throwable jjte001) { if (jjtc001) { jjtree.clearNodeScope(jjtn001); jjtc001 = false; } else { jjtree.popNode(); } if (jjte001 instanceof RuntimeException) { throw (RuntimeException)jjte001; } if (jjte001 instanceof ParseException) { throw (ParseException)jjte001; } throw (Error)jjte001; } finally { if (jjtc001) { jjtree.closeNodeScope(jjtn001, true); } } /*@egen*/ } void staticReference() : { String className = "java.lang.Math"; Token t; } { className=classReference() ( // Prevent the "eval" ambiguity from issuing a warning; see discussion elsewhere. LOOKAHEAD(2) staticMethodCall( className ) | t=/*@bgen(jjtree) #StaticField( 0) */ { ASTStaticField jjtn001 = new ASTStaticField(JJTSTATICFIELD); boolean jjtc001 = true; jjtree.openNodeScope(jjtn001); } try { /*@egen*//*@bgen(jjtree)*/ { jjtree.closeNodeScope(jjtn001, 0); jjtc001 = false; } /*@egen*/ { jjtn001.init( className, t.image ); }/*@bgen(jjtree)*/ } finally { if (jjtc001) { jjtree.closeNodeScope(jjtn001, 0); } } /*@egen*/ ) } String classReference(): { String result = "java.lang.Math"; } { "@" ( result=className() )? "@" { return result; } } String className(): { Token t; StringBuffer result; } { t= { result = new StringBuffer( t.image ); } ( "." t= { result.append('.').append( t.image ); } )* { return new String(result); } } void constructorCall() : {/*@bgen(jjtree) Ctor */ ASTCtor jjtn000 = new ASTCtor(JJTCTOR); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000); /*@egen*/ String className; Token t; StringBuffer sb; } {/*@bgen(jjtree) Ctor */ try { /*@egen*/ "new" className=className() ( LOOKAHEAD(2) ( "(" [ assignmentExpression() ( "," assignmentExpression() )* ] ")"/*@bgen(jjtree)*/ { jjtree.closeNodeScope(jjtn000, true); jjtc000 = false; } /*@egen*/ { jjtn000.setClassName(className); } ) | LOOKAHEAD(2) ( "[" "]" "{"/*@bgen(jjtree) List */ { ASTList jjtn001 = new ASTList(JJTLIST); boolean jjtc001 = true; jjtree.openNodeScope(jjtn001); } try { /*@egen*/ [assignmentExpression() ("," assignmentExpression())*]/*@bgen(jjtree)*/ } catch (Throwable jjte001) { if (jjtc001) { jjtree.clearNodeScope(jjtn001); jjtc001 = false; } else { jjtree.popNode(); } if (jjte001 instanceof RuntimeException) { throw (RuntimeException)jjte001; } if (jjte001 instanceof ParseException) { throw (ParseException)jjte001; } throw (Error)jjte001; } finally { if (jjtc001) { jjtree.closeNodeScope(jjtn001, true); } } /*@egen*/ "}"/*@bgen(jjtree)*/ { jjtree.closeNodeScope(jjtn000, true); jjtc000 = false; } /*@egen*/ { jjtn000.setClassName(className); jjtn000.setArray(true); } ) | LOOKAHEAD(2) ( "[" assignmentExpression() "]"/*@bgen(jjtree)*/ { jjtree.closeNodeScope(jjtn000, true); jjtc000 = false; } /*@egen*/ { jjtn000.setClassName(className); jjtn000.setArray(true); } ) )/*@bgen(jjtree)*/ } catch (Throwable jjte000) { if (jjtc000) { jjtree.clearNodeScope(jjtn000); jjtc000 = false; } else { jjtree.popNode(); } if (jjte000 instanceof RuntimeException) { throw (RuntimeException)jjte000; } if (jjte000 instanceof ParseException) { throw (ParseException)jjte000; } throw (Error)jjte000; } finally { if (jjtc000) { jjtree.closeNodeScope(jjtn000, true); } } /*@egen*/ } void propertyName() : {/*@bgen(jjtree) Property */ ASTProperty jjtn000 = new ASTProperty(JJTPROPERTY); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000); /*@egen*/ Token t; } {/*@bgen(jjtree) Property */ try { /*@egen*/ t=/*@bgen(jjtree) Const */ { ASTConst jjtn001 = new ASTConst(JJTCONST); boolean jjtc001 = true; jjtree.openNodeScope(jjtn001); } try { /*@egen*//*@bgen(jjtree)*/ { jjtree.closeNodeScope(jjtn001, true); jjtc001 = false; } /*@egen*/ { jjtn001.setValue( t.image ); }/*@bgen(jjtree)*/ } finally { if (jjtc001) { jjtree.closeNodeScope(jjtn001, true); } } /*@egen*/ /*@bgen(jjtree)*/ } finally { if (jjtc000) { jjtree.closeNodeScope(jjtn000, true); } } /*@egen*/ } void staticMethodCall( String className ) : {/*@bgen(jjtree) StaticMethod */ ASTStaticMethod jjtn000 = new ASTStaticMethod(JJTSTATICMETHOD); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000); /*@egen*/ Token t; } {/*@bgen(jjtree) StaticMethod */ try { /*@egen*/ t= "(" [ assignmentExpression() ( "," assignmentExpression() )* ] ")"/*@bgen(jjtree)*/ { jjtree.closeNodeScope(jjtn000, true); jjtc000 = false; } /*@egen*/ { jjtn000.init( className, t.image ); }/*@bgen(jjtree)*/ } catch (Throwable jjte000) { if (jjtc000) { jjtree.clearNodeScope(jjtn000); jjtc000 = false; } else { jjtree.popNode(); } if (jjte000 instanceof RuntimeException) { throw (RuntimeException)jjte000; } if (jjte000 instanceof ParseException) { throw (ParseException)jjte000; } throw (Error)jjte000; } finally { if (jjtc000) { jjtree.closeNodeScope(jjtn000, true); } } /*@egen*/ } void methodCall() : {/*@bgen(jjtree) Method */ ASTMethod jjtn000 = new ASTMethod(JJTMETHOD); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000); /*@egen*/ Token t; } {/*@bgen(jjtree) Method */ try { /*@egen*/ t= "(" [ assignmentExpression() ( "," assignmentExpression() )* ] ")"/*@bgen(jjtree)*/ { jjtree.closeNodeScope(jjtn000, true); jjtc000 = false; } /*@egen*/ { jjtn000.setMethodName( t.image ); }/*@bgen(jjtree)*/ } catch (Throwable jjte000) { if (jjtc000) { jjtree.clearNodeScope(jjtn000); jjtc000 = false; } else { jjtree.popNode(); } if (jjte000 instanceof RuntimeException) { throw (RuntimeException)jjte000; } if (jjte000 instanceof ParseException) { throw (ParseException)jjte000; } throw (Error)jjte000; } finally { if (jjtc000) { jjtree.closeNodeScope(jjtn000, true); } } /*@egen*/ } /** * Apply an expression to all elements of a collection, creating a new collection * as the result. */ void projection() : {/*@bgen(jjtree) Project */ ASTProject jjtn000 = new ASTProject(JJTPROJECT); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000); /*@egen*/} {/*@bgen(jjtree) Project */ try { /*@egen*/ "{" expression() "}"/*@bgen(jjtree)*/ } catch (Throwable jjte000) { if (jjtc000) { jjtree.clearNodeScope(jjtn000); jjtc000 = false; } else { jjtree.popNode(); } if (jjte000 instanceof RuntimeException) { throw (RuntimeException)jjte000; } if (jjte000 instanceof ParseException) { throw (ParseException)jjte000; } throw (Error)jjte000; } finally { if (jjtc000) { jjtree.closeNodeScope(jjtn000, true); } } /*@egen*/ } void selection() : {} { LOOKAHEAD(2) selectAll() | LOOKAHEAD(2) selectFirst() | LOOKAHEAD(2) selectLast() } /** * Apply a boolean expression to all elements of a collection, creating a new collection * containing those elements for which the expression returned true. */ void selectAll() : {/*@bgen(jjtree) Select */ ASTSelect jjtn000 = new ASTSelect(JJTSELECT); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000); /*@egen*/} {/*@bgen(jjtree) Select */ try { /*@egen*/ "{" "?" expression() "}"/*@bgen(jjtree)*/ } catch (Throwable jjte000) { if (jjtc000) { jjtree.clearNodeScope(jjtn000); jjtc000 = false; } else { jjtree.popNode(); } if (jjte000 instanceof RuntimeException) { throw (RuntimeException)jjte000; } if (jjte000 instanceof ParseException) { throw (ParseException)jjte000; } throw (Error)jjte000; } finally { if (jjtc000) { jjtree.closeNodeScope(jjtn000, true); } } /*@egen*/ } /** * Apply a boolean expression to all elements of a collection, creating a new collection * containing those elements for the first element for which the expression returned true. */ void selectFirst() : {/*@bgen(jjtree) SelectFirst */ ASTSelectFirst jjtn000 = new ASTSelectFirst(JJTSELECTFIRST); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000); /*@egen*/} {/*@bgen(jjtree) SelectFirst */ try { /*@egen*/ "{" "^" expression() "}"/*@bgen(jjtree)*/ } catch (Throwable jjte000) { if (jjtc000) { jjtree.clearNodeScope(jjtn000); jjtc000 = false; } else { jjtree.popNode(); } if (jjte000 instanceof RuntimeException) { throw (RuntimeException)jjte000; } if (jjte000 instanceof ParseException) { throw (ParseException)jjte000; } throw (Error)jjte000; } finally { if (jjtc000) { jjtree.closeNodeScope(jjtn000, true); } } /*@egen*/ } /** * Apply a boolean expression to all elements of a collection, creating a new collection * containing those elements for the first element for which the expression returned true. */ void selectLast() : {/*@bgen(jjtree) SelectLast */ ASTSelectLast jjtn000 = new ASTSelectLast(JJTSELECTLAST); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000); /*@egen*/} {/*@bgen(jjtree) SelectLast */ try { /*@egen*/ "{" "$" expression() "}"/*@bgen(jjtree)*/ } catch (Throwable jjte000) { if (jjtc000) { jjtree.clearNodeScope(jjtn000); jjtc000 = false; } else { jjtree.popNode(); } if (jjte000 instanceof RuntimeException) { throw (RuntimeException)jjte000; } if (jjte000 instanceof ParseException) { throw (ParseException)jjte000; } throw (Error)jjte000; } finally { if (jjtc000) { jjtree.closeNodeScope(jjtn000, true); } } /*@egen*/ } void index() : {/*@bgen(jjtree) Property */ ASTProperty jjtn000 = new ASTProperty(JJTPROPERTY); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000); /*@egen*/} {/*@bgen(jjtree) Property */ try { /*@egen*/ "[" expression() "]"/*@bgen(jjtree)*/ { jjtree.closeNodeScope(jjtn000, true); jjtc000 = false; } /*@egen*/ { jjtn000.setIndexedAccess(true); } | /*@bgen(jjtree) Const */ { ASTConst jjtn001 = new ASTConst(JJTCONST); boolean jjtc001 = true; jjtree.openNodeScope(jjtn001); } try { /*@egen*//*@bgen(jjtree)*/ { jjtree.closeNodeScope(jjtn001, true); jjtc001 = false; } /*@egen*/ { jjtn001.setValue( token_source.literalValue ); }/*@bgen(jjtree)*/ } finally { if (jjtc001) { jjtree.closeNodeScope(jjtn001, true); } } /*@egen*/ /*@bgen(jjtree)*/ { jjtree.closeNodeScope(jjtn000, true); jjtc000 = false; } /*@egen*/ { jjtn000.setIndexedAccess(true); }/*@bgen(jjtree)*/ } catch (Throwable jjte000) { if (jjtc000) { jjtree.clearNodeScope(jjtn000); jjtc000 = false; } else { jjtree.popNode(); } if (jjte000 instanceof RuntimeException) { throw (RuntimeException)jjte000; } if (jjte000 instanceof ParseException) { throw (ParseException)jjte000; } throw (Error)jjte000; } finally { if (jjtc000) { jjtree.closeNodeScope(jjtn000, true); } } /*@egen*/ } // LEXER PRODUCTIONS TOKEN_MGR_DECLS: { /** Holds the last value computed by a constant token. */ Object literalValue; /** Holds the last character escaped or in a character literal. */ private char charValue; /** Holds char literal start token. */ private char charLiteralStartQuote; /** Holds the last string literal parsed. */ private StringBuffer stringBuffer; /** Converts an escape sequence into a character value. */ private char escapeChar() { int ofs = image.length() - 1; switch ( image.charAt(ofs) ) { case 'n': return '\n'; case 'r': return '\r'; case 't': return '\t'; case 'b': return '\b'; case 'f': return '\f'; case '\\': return '\\'; case '\'': return '\''; case '\"': return '\"'; } // Otherwise, it's an octal number. Find the backslash and convert. while ( image.charAt(--ofs) != '\\' ) {} int value = 0; while ( ++ofs < image.length() ) value = (value << 3) | (image.charAt(ofs) - '0'); return (char) value; } private Object makeInt() { Object result; String s = image.toString(); int base = 10; if ( s.charAt(0) == '0' ) base = (s.length() > 1 && (s.charAt(1) == 'x' || s.charAt(1) == 'X'))? 16 : 8; if ( base == 16 ) s = s.substring(2); // Trim the 0x off the front switch ( s.charAt(s.length()-1) ) { case 'l': case 'L': result = Long.valueOf( s.substring(0,s.length()-1), base ); break; case 'h': case 'H': result = new BigInteger( s.substring(0,s.length()-1), base ); break; default: result = Integer.valueOf( s, base ); break; } return result; } private Object makeFloat() { String s = image.toString(); switch ( s.charAt(s.length()-1) ) { case 'f': case 'F': return Float.valueOf( s ); case 'b': case 'B': return new BigDecimal( s.substring(0,s.length()-1) ); case 'd': case 'D': default: return Double.valueOf( s ); } } } // Whitespace -- ignored SKIP: { " " | "\t" | "\f" | "\r" | "\n" } // An identifier. TOKEN: { < IDENT: (|)* > | < #LETTER: [ "$", "A"-"Z", "_", "a"-"z", "\u00c0"-"\u00d6", "\u00d8"-"\u00f6", "\u00f8"-"\u00ff", "\u0100"-"\u1fff", "\u3040"-"\u318f", "\u3300"-"\u337f", "\u3400"-"\u3d2d", "\u4e00"-"\u9fff", "\uf900"-"\ufaff" ] > | < #DIGIT: [ "0"-"9", "\u0660"-"\u0669", "\u06f0"-"\u06f9", "\u0966"-"\u096f", "\u09e6"-"\u09ef", "\u0a66"-"\u0a6f", "\u0ae6"-"\u0aef", "\u0b66"-"\u0b6f", "\u0be7"-"\u0bef", "\u0c66"-"\u0c6f", "\u0ce6"-"\u0cef", "\u0d66"-"\u0d6f", "\u0e50"-"\u0e59", "\u0ed0"-"\u0ed9", "\u1040"-"\u1049" ] > } /** * Token for "dynamic subscripts", which are one of: [^], [|], [$], and [*]. The * appropriate constant from the DynamicSubscript class is stored in the token manager's * "value" field. */ TOKEN: { < DYNAMIC_SUBSCRIPT: "[" ["^","|","$","*"] "]" > { switch (image.charAt(1)) { case '^': literalValue = DynamicSubscript.first; break; case '|': literalValue = DynamicSubscript.mid; break; case '$': literalValue = DynamicSubscript.last; break; case '*': literalValue = DynamicSubscript.all; break; } } } /** * Character and string literals, whose object value is stored in the token manager's * "literalValue" field. */ MORE: { "`" : WithinBackCharLiteral | "'" { stringBuffer = new StringBuffer(); }: WithinCharLiteral | "\"" { stringBuffer = new StringBuffer(); }: WithinStringLiteral } MORE: { < ESC: "\\" ( ["n","r","t","b","f","\\","'","`","\""] | (["0"-"3"])? ["0"-"7"] (["0"-"7"])? ) > { charValue = escapeChar(); stringBuffer.append(charValue); } | < (~["'","\\"]) > { charValue = image.charAt( image.length()-1 ); stringBuffer.append(charValue); } } TOKEN: { < CHAR_LITERAL: "'"> { if (stringBuffer.length() == 1) { literalValue = new Character( charValue ); } else { literalValue = new String( stringBuffer ); } } : DEFAULT } MORE: { < BACK_CHAR_ESC: > { charValue = escapeChar(); } | < (~["`","\\"]) > { charValue = image.charAt( image.length()-1 ); } } TOKEN: { < BACK_CHAR_LITERAL: "`"> { literalValue = new Character( charValue ); }: DEFAULT } MORE: { < STRING_ESC: > { stringBuffer.append( escapeChar() ); } | < (~["\"","\\"]) > { stringBuffer.append( image.charAt(image.length()-1) ); } } TOKEN: { { literalValue = new String( stringBuffer ); } : DEFAULT } /** * Integer or real Numeric literal, whose object value is stored in the token manager's * "literalValue" field. */ TOKEN: { < INT_LITERAL: ( "0" (["0"-"7"])* | ["1"-"9"] (["0"-"9"])* | "0" ["x","X"] (["0"-"9","a"-"f","A"-"F"])+ ) (["l","L","h","H"])? > { literalValue = makeInt(); } | < FLT_LITERAL: ( ()? ()? | ()? | ) > { literalValue = makeFloat(); } | < #DEC_FLT: (["0"-"9"])+ "." (["0"-"9"])* | "." (["0"-"9"])+ > | < #DEC_DIGITS: (["0"-"9"])+ > | < #EXPONENT: ["e","E"] (["+","-"])? (["0"-"9"])+ > | < #FLT_SUFF: ["d","D","f","F","b","B"] > } ognl-2.7.3.orig/src/java/ognl/ASTSequence.java0000644000175000017500000001257510720374205020761 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 1998-2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package ognl; import ognl.enhance.ExpressionCompiler; import ognl.enhance.OrderedReturn; /** * @author Luke Blanshard (blanshlu@netscape.net) * @author Drew Davidson (drew@ognl.org) */ public class ASTSequence extends SimpleNode implements NodeType, OrderedReturn { private Class _getterClass; private String _lastExpression; private String _coreExpression; public ASTSequence(int id) { super(id); } public ASTSequence(OgnlParser p, int id) { super(p, id); } public void jjtClose() { flattenTree(); } protected Object getValueBody( OgnlContext context, Object source ) throws OgnlException { Object result = null; for ( int i=0; i < _children.length; ++i ) { result = _children[i].getValue( context, source ); } return result; // The result is just the last one we saw. } protected void setValueBody( OgnlContext context, Object target, Object value ) throws OgnlException { int last = _children.length - 1; for ( int i=0; i < last; ++i ) { _children[i].getValue( context, target ); } _children[last].setValue( context, target, value ); } public Class getGetterClass() { return _getterClass; } public Class getSetterClass() { return null; } public String getLastExpression() { return _lastExpression; } public String getCoreExpression() { return _coreExpression; } public String toString() { String result = ""; for ( int i=0; i < _children.length; ++i ) { if (i > 0) { result = result + ", "; } result = result + _children[i]; } return result; } public String toSetSourceString(OgnlContext context, Object target) { return ""; } public String toGetSourceString(OgnlContext context, Object target) { String result = ""; NodeType _lastType = null; for (int i = 0; i < _children.length; ++i) { //System.out.println("astsequence child : " + _children[i].getClass().getName()); String seqValue = _children[i].toGetSourceString(context, target); if ((i + 1) < _children.length && ASTOr.class.isInstance(_children[i])) { seqValue = "(" + seqValue + ")"; } if (i > 0 && ASTProperty.class.isInstance(_children[i]) && seqValue != null && seqValue.trim().length() > 0) { String pre = (String)context.get("_currentChain"); if (pre == null) pre = ""; seqValue = ExpressionCompiler.getRootExpression(_children[i], context.getRoot(), context) + pre + seqValue; context.setCurrentAccessor(context.getRoot().getClass()); } if ((i + 1) >= _children.length) { _coreExpression = result; _lastExpression = seqValue; } if (seqValue != null && seqValue.trim().length() > 0 && (i + 1) < _children.length) result += seqValue + ";"; else if (seqValue != null && seqValue.trim().length() > 0) result += seqValue; // set last known type from last child with a type if (NodeType.class.isInstance(_children[i]) && ((NodeType)_children[i]).getGetterClass() != null) _lastType = (NodeType)_children[i]; } if (_lastType != null) { _getterClass = _lastType.getGetterClass(); } return result; } } ognl-2.7.3.orig/src/java/ognl/ASTDivide.java0000644000175000017500000000453510566476144020427 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 1998-2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package ognl; /** * @author Luke Blanshard (blanshlu@netscape.net) * @author Drew Davidson (drew@ognl.org) */ class ASTDivide extends NumericExpression { public ASTDivide(int id) { super(id); } public ASTDivide(OgnlParser p, int id) { super(p, id); } protected Object getValueBody( OgnlContext context, Object source ) throws OgnlException { Object v1 = _children[0].getValue( context, source ); Object v2 = _children[1].getValue( context, source ); return OgnlOps.divide( v1, v2 ); } public String getExpressionOperator(int index) { return "/"; } } ognl-2.7.3.orig/src/java/ognl/NoSuchPropertyException.java0000644000175000017500000000550210577301171023456 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 1998-2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package ognl; /** * Exception thrown if a property is attempted to be extracted from an object that does * not have such a property. * * @author Luke Blanshard (blanshlu@netscape.net) * @author Drew Davidson (drew@ognl.org) */ public class NoSuchPropertyException extends OgnlException { private Object target; private Object name; public NoSuchPropertyException( Object target, Object name ) { super( getReason(target, name) ); } public NoSuchPropertyException( Object target, Object name, Throwable reason ) { super( getReason(target, name), reason ); this.target = target; this.name = name; } static String getReason(Object target, Object name) { String ret = null; if (target == null) ret = "null"; else if (target instanceof Class) ret = ((Class)target).getName(); else ret = target.getClass().getName(); ret += "." + name; return ret; } public Object getTarget() { return target; } public Object getName() { return name; } } ognl-2.7.3.orig/src/java/ognl/ASTShiftLeft.java0000644000175000017500000000454510566476144021114 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 1998-2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package ognl; /** * @author Luke Blanshard (blanshlu@netscape.net) * @author Drew Davidson (drew@ognl.org) */ class ASTShiftLeft extends NumericExpression { public ASTShiftLeft(int id) { super(id); } public ASTShiftLeft(OgnlParser p, int id) { super(p, id); } protected Object getValueBody( OgnlContext context, Object source ) throws OgnlException { Object v1 = _children[0].getValue( context, source ); Object v2 = _children[1].getValue( context, source ); return OgnlOps.shiftLeft( v1, v2 ); } public String getExpressionOperator(int index) { return "<<"; } } ognl-2.7.3.orig/src/java/ognl/ASTTest.java0000644000175000017500000001266710655154670020143 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 1998-2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package ognl; import ognl.enhance.UnsupportedCompilationException; /** * @author Luke Blanshard (blanshlu@netscape.net) * @author Drew Davidson (drew@ognl.org) */ class ASTTest extends ExpressionNode { public ASTTest(int id) { super(id); } public ASTTest(OgnlParser p, int id) { super(p, id); } protected Object getValueBody( OgnlContext context, Object source ) throws OgnlException { Object test = _children[0].getValue( context, source ); int branch = OgnlOps.booleanValue(test)? 1 : 2; return _children[branch].getValue( context, source ); } protected void setValueBody( OgnlContext context, Object target, Object value ) throws OgnlException { Object test = _children[0].getValue( context, target ); int branch = OgnlOps.booleanValue(test)? 1 : 2; _children[branch].setValue( context, target, value ); } public String getExpressionOperator(int index) { return (index == 1) ? "?" : ":"; } public String toGetSourceString(OgnlContext context, Object target) { if (target == null) throw new UnsupportedCompilationException("evaluation resulted in null expression."); if (_children.length != 3) throw new UnsupportedCompilationException("Can only compile test expressions with two children." + _children.length); String result = ""; try { String first = OgnlRuntime.getChildSource(context, target, _children[0]); if (!OgnlRuntime.isBoolean(first) && !context.getCurrentType().isPrimitive()) first = OgnlRuntime.getCompiler().createLocalReference(context, first, context.getCurrentType()); if (ExpressionNode.class.isInstance(_children[0])) { first = "(" + first + ")"; } String second = OgnlRuntime.getChildSource(context, target, _children[1]); Class secondType = context.getCurrentType(); if (!OgnlRuntime.isBoolean(second) && !context.getCurrentType().isPrimitive()) second = OgnlRuntime.getCompiler().createLocalReference(context, second, context.getCurrentType()); if (ExpressionNode.class.isInstance(_children[1])) { second = "(" + second + ")"; } String third = OgnlRuntime.getChildSource(context, target, _children[2]); Class thirdType = context.getCurrentType(); if (!OgnlRuntime.isBoolean(third) && !context.getCurrentType().isPrimitive()) third = OgnlRuntime.getCompiler().createLocalReference(context, third, context.getCurrentType()); if (ExpressionNode.class.isInstance(_children[2])) { third = "(" + third + ")"; } boolean mismatched = (secondType.isPrimitive() && !thirdType.isPrimitive()) || (!secondType.isPrimitive() && thirdType.isPrimitive()) ? true : false; result += "ognl.OgnlOps.booleanValue(" + first + ")"; result += " ? "; result += (mismatched ? " ($w) " : "") + second; result += " : "; result += (mismatched ? " ($w) " : "") + third; context.setCurrentObject(target); context.setCurrentType(mismatched ? Object.class : secondType); return result; } catch (NullPointerException e) { // expected to happen in some instances throw new UnsupportedCompilationException("evaluation resulted in null expression."); } catch (Throwable t) { throw OgnlOps.castToRuntime(t); } } } ognl-2.7.3.orig/src/java/ognl/JavaSource.java0000644000175000017500000000207610566476144020713 0ustar drazzibdrazzib/** * */ package ognl; import ognl.enhance.ExpressionAccessor; /** * Defines an object that can return a representation of itself and any objects it contains * in the form of a {@link String} embedded with literal java statements. * * @author jkuhnert */ public interface JavaSource { /** * Expected to return a java source representation of itself such that * it could be turned into a literal java expression to be compiled and * executed for {@link ExpressionAccessor#get(OgnlContext, Object)} calls. * * @return Literal java string representation of an object get. */ String toGetSourceString(OgnlContext context, Object target); /** * Expected to return a java source representation of itself such that * it could be turned into a literal java expression to be compiled and * executed for {@link ExpressionAccessor#get(OgnlContext, Object)} calls. * * @return Literal java string representation of an object get. */ String toSetSourceString(OgnlContext context, Object target); } ognl-2.7.3.orig/src/java/ognl/ObjectElementsAccessor.java0000644000175000017500000000475010561411075023223 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 1998-2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package ognl; import java.util.*; /** * Implementation of ElementsAccessor that returns a single-element iterator, containing * the original target object. * @author Luke Blanshard (blanshlu@netscape.net) * @author Drew Davidson (drew@ognl.org) */ public class ObjectElementsAccessor implements ElementsAccessor { public Enumeration getElements( Object target ) { final Object object = target; return new Enumeration() { private boolean seen = false; public boolean hasMoreElements() { return !seen; } public Object nextElement() { Object result = null; if (!seen) { result = object; seen = true; } return result; } }; } } ognl-2.7.3.orig/src/java/ognl/MethodFailedException.java0000644000175000017500000000440110577301171023034 0ustar drazzibdrazzib//-------------------------------------------------------------------------- // Copyright (c) 1998-2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. //-------------------------------------------------------------------------- package ognl; /** * Exception thrown if a method or constructor call fails. * * @author Luke Blanshard (blanshlu@netscape.net) * @author Drew Davidson (drew@ognl.org) */ public class MethodFailedException extends OgnlException { public MethodFailedException( Object source, String name) { super( "Method \"" + name + "\" failed for object " + source); } public MethodFailedException( Object source, String name, Throwable reason ) { super( "Method \"" + name + "\" failed for object " + source, reason ); } } ognl-2.7.3.orig/src/java/ognl/ParseException.java0000644000175000017500000001500610746450726021575 0ustar drazzibdrazzib/* Generated By:JavaCC: Do not edit this line. ParseException.java Version 4.1 */ /* JavaCCOptions:KEEP_LINE_COL=null */ package ognl; /** * This exception is thrown when parse errors are encountered. * You can explicitly create objects of this exception type by * calling the method generateParseException in the generated * parser. * * You can modify this class to customize your error reporting * mechanisms so long as you retain the public fields. */ public class ParseException extends Exception { /** * This constructor is used by the method "generateParseException" * in the generated parser. Calling this constructor generates * a new object of this type with the fields "currentToken", * "expectedTokenSequences", and "tokenImage" set. The boolean * flag "specialConstructor" is also set to true to indicate that * this constructor was used to create this object. * This constructor calls its super class with the empty string * to force the "toString" method of parent class "Throwable" to * print the error message in the form: * ParseException: */ public ParseException(Token currentTokenVal, int[][] expectedTokenSequencesVal, String[] tokenImageVal ) { super(""); specialConstructor = true; currentToken = currentTokenVal; expectedTokenSequences = expectedTokenSequencesVal; tokenImage = tokenImageVal; } /** * The following constructors are for use by you for whatever * purpose you can think of. Constructing the exception in this * manner makes the exception behave in the normal way - i.e., as * documented in the class "Throwable". The fields "errorToken", * "expectedTokenSequences", and "tokenImage" do not contain * relevant information. The JavaCC generated code does not use * these constructors. */ public ParseException() { super(); specialConstructor = false; } /** Constructor with message. */ public ParseException(String message) { super(message); specialConstructor = false; } /** * This variable determines which constructor was used to create * this object and thereby affects the semantics of the * "getMessage" method (see below). */ protected boolean specialConstructor; /** * This is the last token that has been consumed successfully. If * this object has been created due to a parse error, the token * followng this token will (therefore) be the first error token. */ public Token currentToken; /** * Each entry in this array is an array of integers. Each array * of integers represents a sequence of tokens (by their ordinal * values) that is expected at this point of the parse. */ public int[][] expectedTokenSequences; /** * This is a reference to the "tokenImage" array of the generated * parser within which the parse error occurred. This array is * defined in the generated ...Constants interface. */ public String[] tokenImage; /** * This method has the standard behavior when this object has been * created using the standard constructors. Otherwise, it uses * "currentToken" and "expectedTokenSequences" to generate a parse * error message and returns it. If this object has been created * due to a parse error, and you do not catch it (it gets thrown * from the parser), then this method is called during the printing * of the final stack trace, and hence the correct error message * gets displayed. */ public String getMessage() { if (!specialConstructor) { return super.getMessage(); } StringBuffer expected = new StringBuffer(); int maxSize = 0; for (int i = 0; i < expectedTokenSequences.length; i++) { if (maxSize < expectedTokenSequences[i].length) { maxSize = expectedTokenSequences[i].length; } for (int j = 0; j < expectedTokenSequences[i].length; j++) { expected.append(tokenImage[expectedTokenSequences[i][j]]).append(' '); } if (expectedTokenSequences[i][expectedTokenSequences[i].length - 1] != 0) { expected.append("..."); } expected.append(eol).append(" "); } String retval = "Encountered \""; Token tok = currentToken.next; for (int i = 0; i < maxSize; i++) { if (i != 0) retval += " "; if (tok.kind == 0) { retval += tokenImage[0]; break; } retval += " " + tokenImage[tok.kind]; retval += " \""; retval += add_escapes(tok.image); retval += " \""; tok = tok.next; } retval += "\" at line " + currentToken.next.beginLine + ", column " + currentToken.next.beginColumn; retval += "." + eol; if (expectedTokenSequences.length == 1) { retval += "Was expecting:" + eol + " "; } else { retval += "Was expecting one of:" + eol + " "; } retval += expected.toString(); return retval; } /** * The end of line string for this machine. */ protected String eol = System.getProperty("line.separator", "\n"); /** * Used to convert raw characters to their escaped version * when these raw version cannot be used as part of an ASCII * string literal. */ protected String add_escapes(String str) { StringBuffer retval = new StringBuffer(); char ch; for (int i = 0; i < str.length(); i++) { switch (str.charAt(i)) { case 0 : continue; case '\b': retval.append("\\b"); continue; case '\t': retval.append("\\t"); continue; case '\n': retval.append("\\n"); continue; case '\f': retval.append("\\f"); continue; case '\r': retval.append("\\r"); continue; case '\"': retval.append("\\\""); continue; case '\'': retval.append("\\\'"); continue; case '\\': retval.append("\\\\"); continue; default: if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) { String s = "0000" + Integer.toString(ch, 16); retval.append("\\u" + s.substring(s.length() - 4, s.length())); } else { retval.append(ch); } continue; } } return retval.toString(); } } /* JavaCC - OriginalChecksum=a0a2f59968d58ccc3e57dbd91056ba6e (do not edit this line) */ ognl-2.7.3.orig/src/java/ognl/ASTProperty.java0000644000175000017500000006363110776755160021052 0ustar drazzibdrazzib// -------------------------------------------------------------------------- // Copyright (c) 1998-2004, Drew Davidson and Luke Blanshard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // Neither the name of the Drew Davidson nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. // -------------------------------------------------------------------------- package ognl; import ognl.enhance.ExpressionCompiler; import ognl.enhance.UnsupportedCompilationException; import java.beans.IndexedPropertyDescriptor; import java.beans.PropertyDescriptor; import java.lang.reflect.Method; import java.util.Iterator; /** * @author Luke Blanshard (blanshlu@netscape.net) * @author Drew Davidson (drew@ognl.org) */ public class ASTProperty extends SimpleNode implements NodeType { private boolean _indexedAccess = false; private Class _getterClass; private Class _setterClass; public ASTProperty(int id) { super(id); } public void setIndexedAccess(boolean value) { _indexedAccess = value; } /** * Returns true if this property is itself an index reference. */ public boolean isIndexedAccess() { return _indexedAccess; } /** * Returns true if this property is described by an IndexedPropertyDescriptor and that if * followed by an index specifier it will call the index get/set methods rather than go through * property accessors. */ public int getIndexedPropertyType(OgnlContext context, Object source) throws OgnlException { Class type = context.getCurrentType(); Class prevType = context.getPreviousType(); try { if (!isIndexedAccess()) { Object property = getProperty(context, source); if (property instanceof String) { return OgnlRuntime.getIndexedPropertyType(context, (source == null) ? null : OgnlRuntime.getCompiler().getInterfaceClass(source.getClass()), (String) property); } } return OgnlRuntime.INDEXED_PROPERTY_NONE; } finally { context.setCurrentObject(source); context.setCurrentType(type); context.setPreviousType(prevType); } } public Object getProperty(OgnlContext context, Object source) throws OgnlException { return _children[0].getValue(context, context.getRoot()); } protected Object getValueBody(OgnlContext context, Object source) throws OgnlException { Object property = getProperty(context, source); Object result = OgnlRuntime.getProperty(context, source, property); if (result == null) { result = OgnlRuntime.getNullHandler(OgnlRuntime.getTargetClass(source)).nullPropertyValue(context, source, property); } return result; } protected void setValueBody(OgnlContext context, Object target, Object value) throws OgnlException { OgnlRuntime.setProperty(context, target, getProperty(context, target), value); } public boolean isNodeSimpleProperty(OgnlContext context) throws OgnlException { return (_children != null) && (_children.length == 1) && ((SimpleNode) _children[0]).isConstant(context); } public Class getGetterClass() { return _getterClass; } public Class getSetterClass() { return _setterClass; } public String toString() { String result; if (isIndexedAccess()) { result = "[" + _children[0] + "]"; } else { result = ((ASTConst) _children[0]).getValue().toString(); } return result; } public String toGetSourceString(OgnlContext context, Object target) { if (context.getCurrentObject() == null) throw new UnsupportedCompilationException("Current target is null."); String result = ""; Method m = null; try { /* System.out.println("astproperty is indexed? : " + isIndexedAccess() + " child: " + _children[0].getClass().getName() + " target: " + target.getClass().getName() + " current object: " + context.getCurrentObject().getClass().getName());*/ if (isIndexedAccess()) { Object value = _children[0].getValue(context, context.getRoot()); if (value == null || DynamicSubscript.class.isAssignableFrom(value.getClass())) throw new UnsupportedCompilationException("Value passed as indexed property was null or not supported."); // Get root cast string if the child is a type that needs it (like a nested ASTProperty) String srcString = _children[0].toGetSourceString(context, context.getRoot()); srcString = ExpressionCompiler.getRootExpression(_children[0], context.getRoot(), context) + srcString; if (ASTChain.class.isInstance(_children[0])) { String cast = (String)context.remove(ExpressionCompiler.PRE_CAST); if (cast != null) srcString = cast + srcString; } if (ASTConst.class.isInstance(_children[0]) && String.class.isInstance(context.getCurrentObject())) srcString = "\"" + srcString + "\""; // System.out.println("indexed getting with child srcString: " + srcString + " value class: " + value.getClass() + " and child: " + _children[0].getClass()); if (context.get("_indexedMethod") != null) { m = (Method)context.remove("_indexedMethod"); _getterClass = m.getReturnType(); Object indexedValue = OgnlRuntime.callMethod(context, target, m.getName(), new Object[]{value}); context.setCurrentType(_getterClass); context.setCurrentObject(indexedValue); context.setCurrentAccessor(OgnlRuntime.getCompiler().getSuperOrInterfaceClass(m, m.getDeclaringClass())); return "." + m.getName() + "(" + srcString + ")"; } else { PropertyAccessor p = OgnlRuntime.getPropertyAccessor(target.getClass()); // System.out.println("child value : " + _children[0].getValue(context, context.getCurrentObject()) + " using propaccessor " + p.getClass().getName() // + " and srcString " + srcString + " on target: " + target); Object currObj = context.getCurrentObject(); Class currType = context.getCurrentType(); Class prevType = context.getPreviousType(); Object indexVal = p.getProperty(context, target, value); // reset current object for accessor context.setCurrentObject(currObj); context.setCurrentType(currType); context.setPreviousType(prevType); /* System.out.println("astprop srcString: " + srcString + " from child class " + _children[0].getClass().getName() + " and indexVal " + indexVal + " propertyAccessor : " + p.getClass().getName() + " context obj " + context.getCurrentObject() + " context obj is array? : " + context.getCurrentObject().getClass().isArray() + " current type: " + context.getCurrentType());*/ if (ASTConst.class.isInstance(_children[0]) && Number.class.isInstance(context.getCurrentObject())) context.setCurrentType(OgnlRuntime.getPrimitiveWrapperClass(context.getCurrentObject().getClass())); result = p.getSourceAccessor(context, target, srcString); _getterClass = context.getCurrentType(); context.setCurrentObject(indexVal); return result; } } String name = ((ASTConst) _children[0]).getValue().toString(); if (!Iterator.class.isAssignableFrom(context.getCurrentObject().getClass()) || (Iterator.class.isAssignableFrom(context.getCurrentObject().getClass()) && name.indexOf("next") < 0)) { Object currObj = target; try { target = getValue(context, context.getCurrentObject()); } catch (NoSuchPropertyException e) { try { target = getValue(context, context.getRoot()); } catch (NoSuchPropertyException ex) { // ignore } } finally { context.setCurrentObject(currObj); } } PropertyDescriptor pd = OgnlRuntime.getPropertyDescriptor(context.getCurrentObject().getClass(), name); if (pd != null && pd.getReadMethod() != null && !context.getMemberAccess().isAccessible(context, context.getCurrentObject(), pd.getReadMethod(), name)) { throw new UnsupportedCompilationException("Member access forbidden for property " + name + " on class " + context.getCurrentObject().getClass()); } if (this.getIndexedPropertyType(context, context.getCurrentObject()) > 0 && pd != null) { // if an indexed method accessor need to use special property descriptors to find methods if (pd instanceof IndexedPropertyDescriptor) { m = ((IndexedPropertyDescriptor) pd).getIndexedReadMethod(); } else { if (pd instanceof ObjectIndexedPropertyDescriptor) m = ((ObjectIndexedPropertyDescriptor) pd).getIndexedReadMethod(); else throw new OgnlException("property '" + name + "' is not an indexed property"); } if (_parent == null) { // the above pd will be the wrong result sometimes, such as methods like getValue(int) vs String[] getValue() m = OgnlRuntime.getReadMethod(context.getCurrentObject().getClass(), name); result = m.getName() + "()"; _getterClass = m.getReturnType(); } else { context.put("_indexedMethod", m); } } else { /* System.out.println("astproperty trying to get " + name + " on object target: " + context.getCurrentObject().getClass().getName() + " current type " + context.getCurrentType() + " current accessor " + context.getCurrentAccessor() + " prev type " + context.getPreviousType() + " prev accessor " + context.getPreviousAccessor());*/ PropertyAccessor pa = OgnlRuntime.getPropertyAccessor(context.getCurrentObject().getClass()); if (context.getCurrentObject().getClass().isArray()) { if (pd == null) { pd = OgnlRuntime.getProperty(context.getCurrentObject().getClass(), name); if (pd != null && pd.getReadMethod() != null) { m = pd.getReadMethod(); result = pd.getName(); } else { _getterClass = int.class; context.setCurrentAccessor(context.getCurrentObject().getClass()); context.setCurrentType(int.class); result = "." + name; } } } else { if (pd != null && pd.getReadMethod() != null) { m = pd.getReadMethod(); result = "." + m.getName() + "()"; } else if (pa != null) { Object currObj = context.getCurrentObject(); Class currType = context.getCurrentType(); Class prevType = context.getPreviousType(); String srcString = _children[0].toGetSourceString(context, context.getRoot()); if (ASTConst.class.isInstance(_children[0]) && String.class.isInstance(context.getCurrentObject())) srcString = "\"" + srcString + "\""; context.setCurrentObject(currObj); context.setCurrentType(currType); context.setPreviousType(prevType); result = pa.getSourceAccessor(context, context.getCurrentObject(), srcString); _getterClass = context.getCurrentType(); } } } } catch (Throwable t) { throw OgnlOps.castToRuntime(t); } // set known property types for NodeType interface when possible if (m != null) { _getterClass = m.getReturnType(); context.setCurrentType(m.getReturnType()); context.setCurrentAccessor(OgnlRuntime.getCompiler().getSuperOrInterfaceClass(m, m.getDeclaringClass())); } context.setCurrentObject(target); return result; } Method getIndexedWriteMethod(PropertyDescriptor pd) { if (IndexedPropertyDescriptor.class.isInstance(pd)) { return ((IndexedPropertyDescriptor)pd).getIndexedWriteMethod(); } else if (ObjectIndexedPropertyDescriptor.class.isInstance(pd)) { return ((ObjectIndexedPropertyDescriptor)pd).getIndexedWriteMethod(); } return null; } public String toSetSourceString(OgnlContext context, Object target) { String result = ""; Method m = null; if (context.getCurrentObject() == null) throw new UnsupportedCompilationException("Current target is null."); /*System.out.println("astproperty(setter) is indexed? : " + isIndexedAccess() + " child: " + _children[0].getClass().getName() + " target: " + target.getClass().getName() + " children length: " + _children.length);*/ try { if (isIndexedAccess()) { Object value = _children[0].getValue(context, context.getRoot()); if (value == null) throw new UnsupportedCompilationException("Value passed as indexed property is null, can't enhance statement to bytecode."); String srcString = _children[0].toGetSourceString(context, context.getRoot()); srcString = ExpressionCompiler.getRootExpression(_children[0], context.getRoot(), context) + srcString; if (ASTChain.class.isInstance(_children[0])) { String cast = (String)context.remove(ExpressionCompiler.PRE_CAST); if (cast != null) srcString = cast + srcString; } if (ASTConst.class.isInstance(_children[0]) && String.class.isInstance(context.getCurrentObject())) { srcString = "\"" + srcString + "\""; } // System.out.println("astproperty setter using indexed value " + value + " and srcString: " + srcString); if (context.get("_indexedMethod") != null) { m = (Method)context.remove("_indexedMethod"); PropertyDescriptor pd = (PropertyDescriptor)context.remove("_indexedDescriptor"); boolean lastChild = lastChild(context); if (lastChild) { m = getIndexedWriteMethod(pd); if (m == null) throw new UnsupportedCompilationException("Indexed property has no corresponding write method."); } _setterClass = m.getParameterTypes()[0]; Object indexedValue = null; if (!lastChild) indexedValue = OgnlRuntime.callMethod(context, target, m.getName(), new Object[]{value}); context.setCurrentType(_setterClass); context.setCurrentAccessor(OgnlRuntime.getCompiler().getSuperOrInterfaceClass(m, m.getDeclaringClass())); if (!lastChild) { context.setCurrentObject(indexedValue); return "." + m.getName() + "(" + srcString + ")"; } else { return "." + m.getName() + "(" + srcString + ", $3)"; } } else { PropertyAccessor p = OgnlRuntime.getPropertyAccessor(target.getClass()); Object currObj = context.getCurrentObject(); Class currType = context.getCurrentType(); Class prevType = context.getPreviousType(); Object indexVal = p.getProperty(context, target, value); // reset current object for accessor context.setCurrentObject(currObj); context.setCurrentType(currType); context.setPreviousType(prevType); if (ASTConst.class.isInstance(_children[0]) && Number.class.isInstance(context.getCurrentObject())) context.setCurrentType(OgnlRuntime.getPrimitiveWrapperClass(context.getCurrentObject().getClass())); result = lastChild(context) ? p.getSourceSetter(context, target, srcString) : p.getSourceAccessor(context, target, srcString); /*System.out.println("ASTProperty using propertyaccessor and isLastChild? " + lastChild(context) + " generated source of: " + result + " using accessor class: " + p.getClass().getName());*/ //result = p.getSourceAccessor(context, target, srcString); _getterClass = context.getCurrentType(); context.setCurrentObject(indexVal); /* PropertyAccessor p = OgnlRuntime.getPropertyAccessor(target.getClass()); if (ASTConst.class.isInstance(_children[0]) && Number.class.isInstance(context.getCurrentObject())) { context.setCurrentType(OgnlRuntime.getPrimitiveWrapperClass(context.getCurrentObject().getClass())); } result = p.getSourceSetter(context, target, srcString); context.setCurrentObject(value); context.setCurrentType(_getterClass);*/ return result; } } String name = ((ASTConst) _children[0]).getValue().toString(); // System.out.println(" astprop(setter) : trying to set " + name + " on object target " + context.getCurrentObject().getClass().getName()); if (!Iterator.class.isAssignableFrom(context.getCurrentObject().getClass()) || (Iterator.class.isAssignableFrom(context.getCurrentObject().getClass()) && name.indexOf("next") < 0)) { Object currObj = target; try { target = getValue(context, context.getCurrentObject()); } catch (NoSuchPropertyException e) { try { target = getValue(context, context.getRoot()); } catch (NoSuchPropertyException ex) { } } finally { context.setCurrentObject(currObj); } } PropertyDescriptor pd = OgnlRuntime.getPropertyDescriptor(OgnlRuntime.getCompiler().getInterfaceClass(context.getCurrentObject().getClass()), name); if (pd != null) { Method pdMethod = lastChild(context) ? pd.getWriteMethod() : pd.getReadMethod(); if (pdMethod != null && !context.getMemberAccess().isAccessible(context, context.getCurrentObject(), pdMethod, name)) { throw new UnsupportedCompilationException("Member access forbidden for property " + name + " on class " + context.getCurrentObject().getClass()); } } if (pd != null && this.getIndexedPropertyType(context, context.getCurrentObject()) > 0) { // if an indexed method accessor need to use special property descriptors to find methods if (pd instanceof IndexedPropertyDescriptor) { IndexedPropertyDescriptor ipd = (IndexedPropertyDescriptor)pd; m = lastChild(context) ? ipd.getIndexedWriteMethod() : ipd.getIndexedReadMethod(); } else { if (pd instanceof ObjectIndexedPropertyDescriptor) { ObjectIndexedPropertyDescriptor opd = (ObjectIndexedPropertyDescriptor)pd; m = lastChild(context) ? opd.getIndexedWriteMethod() : opd.getIndexedReadMethod(); } else { throw new OgnlException("property '" + name + "' is not an indexed property"); } } if (_parent == null) { // the above pd will be the wrong result sometimes, such as methods like getValue(int) vs String[] getValue() m = OgnlRuntime.getWriteMethod(context.getCurrentObject().getClass(), name); Class parm = m.getParameterTypes()[0]; String cast = parm.isArray() ? ExpressionCompiler.getCastString(parm) : parm.getName(); result = m.getName() + "((" + cast + ")$3)"; _setterClass = parm; } else { context.put("_indexedMethod", m); context.put("_indexedDescriptor", pd); } } else { PropertyAccessor pa = OgnlRuntime.getPropertyAccessor(context.getCurrentObject().getClass()); /*System.out.println("astproperty trying to set " + name + " on object target: " + context.getCurrentObject().getClass().getName() + " using propertyaccessor type: " + pa);*/ if (target != null) _setterClass = target.getClass(); if (_parent != null && pd != null && pa == null) { m = pd.getReadMethod(); result = m.getName() + "()"; } else { if (context.getCurrentObject().getClass().isArray()) { result = ""; } else if (pa != null) { Object currObj = context.getCurrentObject(); //Class currType = context.getCurrentType(); //Class prevType = context.getPreviousType(); String srcString = _children[0].toGetSourceString(context, context.getRoot()); if (ASTConst.class.isInstance(_children[0]) && String.class.isInstance(context.getCurrentObject())) { srcString = "\"" + srcString + "\""; } context.setCurrentObject(currObj); //context.setCurrentType(currType); //context.setPreviousType(prevType); if (!lastChild(context)) { result = pa.getSourceAccessor(context, context.getCurrentObject(), srcString); } else { result = pa.getSourceSetter(context, context.getCurrentObject(), srcString); } _getterClass = context.getCurrentType(); } } } } catch (Throwable t) { throw OgnlOps.castToRuntime(t); } context.setCurrentObject(target); if (m != null) { context.setCurrentType(m.getReturnType()); context.setCurrentAccessor(OgnlRuntime.getCompiler().getSuperOrInterfaceClass(m, m.getDeclaringClass())); } return result; } } ognl-2.7.3.orig/docbook.xml0000644000175000017500000003405610633055306015470 0ustar drazzibdrazzib Cannot run docbook: DocBook XML is required at extlib/docbook-xml-4.2 Please download at: http://www.docbook.org/xml/4.2/docbook-xml-4.2.zip Cannot run docbook: DocBook XSL is required at extlib/docbook-xsl-1.65.1 Please download at: http://sourceforge.net/project/showfiles.php?group_id=21935&package_id=16608 Cannot run docbook: FOP is required at extlib/fop-0.20.5 Please download at: http://www.apache.org/dyn/closer.cgi/xml/fop Converting FO to PDF ... ognl-2.7.3.orig/osbuild.xml0000644000175000017500000001552210643500625015506 0ustar drazzibdrazzib