Author: amarkhel
Date: 2009-08-21 14:21:48 -0400 (Fri, 21 Aug 2009)
New Revision: 15266
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/ELReflectionUtils.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/ELVisitor.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/ParsingException.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/StringUtils.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AbstractArithmeticTreeNode.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AbstractBooleanTreeNode.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AbstractTreeNode.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstAndTreeNode.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstBracketSuffixTreeNode.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstChoiceTreeNode.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstDeferredExpressionTreeNode.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstDivTreeNode.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstEmptyTreeNode.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstEqualTreeNode.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstFalseTreeNode.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstFloatingPointTreeNode.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstFunctionTreeNode.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstGreaterThanEqualTreeNode.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstGreaterThanTreeNode.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstIdentifierTreeNode.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstIntegerTreeNode.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstLessThanEqualTreeNode.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstLessThanTreeNode.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstLiteralTreeNode.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstMethodSuffixTreeNode.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstMinusTreeNode.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstModTreeNode.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstMultTreeNode.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstNegativeTreeNode.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstNotEqualTreeNode.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstNotTreeNode.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstNullTreeNode.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstOrTreeNode.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstPlusTreeNode.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstPropertySuffixTreeNode.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstStringTreeNode.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstTrueTreeNode.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstValueTreeNode.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/ELNodeConstants.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/ITreeNode.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/parser/
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/parser/el/
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/parser/el/test/
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/parser/el/test/Bean.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/parser/el/test/Bean2.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/parser/el/test/ELParserTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/parser/el/test/UIComponent.java
Log:
Add ELParser
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/ELReflectionUtils.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/ELReflectionUtils.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/ELReflectionUtils.java 2009-08-21
18:21:48 UTC (rev 15266)
@@ -0,0 +1,780 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.cdk.parser.el;
+
+import java.beans.BeanInfo;
+import java.beans.IndexedPropertyDescriptor;
+import java.beans.IntrospectionException;
+import java.beans.Introspector;
+import java.beans.PropertyDescriptor;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jboss.el.parser.AstAnd;
+import org.jboss.el.parser.AstBracketSuffix;
+import org.jboss.el.parser.AstChoice;
+import org.jboss.el.parser.AstDeferredExpression;
+import org.jboss.el.parser.AstDiv;
+import org.jboss.el.parser.AstEmpty;
+import org.jboss.el.parser.AstEqual;
+import org.jboss.el.parser.AstFalse;
+import org.jboss.el.parser.AstFloatingPoint;
+import org.jboss.el.parser.AstFunction;
+import org.jboss.el.parser.AstGreaterThan;
+import org.jboss.el.parser.AstGreaterThanEqual;
+import org.jboss.el.parser.AstIdentifier;
+import org.jboss.el.parser.AstInteger;
+import org.jboss.el.parser.AstLessThan;
+import org.jboss.el.parser.AstLessThanEqual;
+import org.jboss.el.parser.AstLiteralExpression;
+import org.jboss.el.parser.AstMethodSuffix;
+import org.jboss.el.parser.AstMinus;
+import org.jboss.el.parser.AstMod;
+import org.jboss.el.parser.AstMult;
+import org.jboss.el.parser.AstNegative;
+import org.jboss.el.parser.AstNot;
+import org.jboss.el.parser.AstNotEqual;
+import org.jboss.el.parser.AstNull;
+import org.jboss.el.parser.AstOr;
+import org.jboss.el.parser.AstPlus;
+import org.jboss.el.parser.AstPropertySuffix;
+import org.jboss.el.parser.AstString;
+import org.jboss.el.parser.AstTrue;
+import org.jboss.el.parser.AstValue;
+import org.jboss.el.parser.Node;
+import org.richfaces.cdk.parser.el.node.AstAndTreeNode;
+import org.richfaces.cdk.parser.el.node.AstBracketSuffixTreeNode;
+import org.richfaces.cdk.parser.el.node.AstChoiceTreeNode;
+import org.richfaces.cdk.parser.el.node.AstDeferredExpressionTreeNode;
+import org.richfaces.cdk.parser.el.node.AstDivTreeNode;
+import org.richfaces.cdk.parser.el.node.AstEmptyTreeNode;
+import org.richfaces.cdk.parser.el.node.AstEqualTreeNode;
+import org.richfaces.cdk.parser.el.node.AstFalseTreeNode;
+import org.richfaces.cdk.parser.el.node.AstFloatingPointTreeNode;
+import org.richfaces.cdk.parser.el.node.AstFunctionTreeNode;
+import org.richfaces.cdk.parser.el.node.AstGreaterThanEqualTreeNode;
+import org.richfaces.cdk.parser.el.node.AstGreaterThanTreeNode;
+import org.richfaces.cdk.parser.el.node.AstIdentifierTreeNode;
+import org.richfaces.cdk.parser.el.node.AstIntegerTreeNode;
+import org.richfaces.cdk.parser.el.node.AstLessThanEqualTreeNode;
+import org.richfaces.cdk.parser.el.node.AstLessThanTreeNode;
+import org.richfaces.cdk.parser.el.node.AstLiteralTreeNode;
+import org.richfaces.cdk.parser.el.node.AstMethodSuffixTreeNode;
+import org.richfaces.cdk.parser.el.node.AstMinusTreeNode;
+import org.richfaces.cdk.parser.el.node.AstModTreeNode;
+import org.richfaces.cdk.parser.el.node.AstMultTreeNode;
+import org.richfaces.cdk.parser.el.node.AstNegativeTreeNode;
+import org.richfaces.cdk.parser.el.node.AstNotEqualTreeNode;
+import org.richfaces.cdk.parser.el.node.AstNotTreeNode;
+import org.richfaces.cdk.parser.el.node.AstNullTreeNode;
+import org.richfaces.cdk.parser.el.node.AstOrTreeNode;
+import org.richfaces.cdk.parser.el.node.AstPlusTreeNode;
+import org.richfaces.cdk.parser.el.node.AstPropertySuffixTreeNode;
+import org.richfaces.cdk.parser.el.node.AstStringTreeNode;
+import org.richfaces.cdk.parser.el.node.AstTrueTreeNode;
+import org.richfaces.cdk.parser.el.node.AstValueTreeNode;
+import org.richfaces.cdk.parser.el.node.ELNodeConstants;
+import org.richfaces.cdk.parser.el.node.ITreeNode;
+/**
+ * Class, that encapsulate all functionality, related to Reflection calls, such as
loading classes, get property descriptors etc...
+ * @author amarkhel
+ *
+ */
+public class ELReflectionUtils {
+
+ private static final Class<?>[] EMPTY_CLASS_PARAMETERS = new Class<?>[0];
+
+ /**
+ * This method determine type of parsed node and create wrapper for them, that extends
AbstractTreeNode. If node type is not recognized - throws ParsingException.
+ * @param child - parsed node
+ * @throws ParsingException - if node type is not recognized.
+ * @return wrapper for parsed node(if node type is recognized), that implement ITreeNode
interface.
+ */
+ public static ITreeNode determineNodeType(Node child) throws ParsingException {
+ ITreeNode treeNode = null;
+ if (child instanceof AstIdentifier) {
+ treeNode = new AstIdentifierTreeNode(child);
+ } else if (child instanceof AstValue) {
+ treeNode = new AstValueTreeNode(child);
+ } else if (child instanceof AstInteger) {
+ treeNode = new AstIntegerTreeNode(child);
+ } else if (child instanceof AstString) {
+ treeNode = new AstStringTreeNode(child);
+ } else if (child instanceof AstFunction) {
+ treeNode = new AstFunctionTreeNode(child);
+ } else if (child instanceof AstDeferredExpression) {
+ treeNode = new AstDeferredExpressionTreeNode(child);
+ } else if (child instanceof AstNot) {
+ treeNode = new AstNotTreeNode(child);
+ } else if (child instanceof AstChoice) {
+ treeNode = new AstChoiceTreeNode(child);
+ } else if (child instanceof AstEmpty) {
+ treeNode = new AstEmptyTreeNode(child);
+ } else if (child instanceof AstLiteralExpression) {
+ treeNode = new AstLiteralTreeNode(child);
+ } else if (child instanceof AstFalse) {
+ treeNode = new AstFalseTreeNode(child);
+ } else if (child instanceof AstTrue) {
+ treeNode = new AstTrueTreeNode(child);
+ } else if (child instanceof AstAnd) {
+ treeNode = new AstAndTreeNode(child);
+ } else if (child instanceof AstEqual) {
+ treeNode = new AstEqualTreeNode(child);
+ } else if (child instanceof AstGreaterThan) {
+ treeNode = new AstGreaterThanTreeNode(child);
+ } else if (child instanceof AstGreaterThanEqual) {
+ treeNode = new AstGreaterThanEqualTreeNode(child);
+ } else if (child instanceof AstLessThan) {
+ treeNode = new AstLessThanTreeNode(child);
+ } else if (child instanceof AstLessThanEqual) {
+ treeNode = new AstLessThanEqualTreeNode(child);
+ } else if (child instanceof AstNotEqual) {
+ treeNode = new AstNotEqualTreeNode(child);
+ } else if (child instanceof AstOr) {
+ treeNode = new AstOrTreeNode(child);
+ } else if (child instanceof AstDiv) {
+ treeNode = new AstDivTreeNode(child);
+ } else if (child instanceof AstMult) {
+ treeNode = new AstMultTreeNode(child);
+ } else if (child instanceof AstMod) {
+ treeNode = new AstModTreeNode(child);
+ } else if (child instanceof AstPlus) {
+ treeNode = new AstPlusTreeNode(child);
+ } else if (child instanceof AstMinus) {
+ treeNode = new AstMinusTreeNode(child);
+ } else if (child instanceof AstBracketSuffix) {
+ treeNode = new AstBracketSuffixTreeNode(child);
+ } else if (child instanceof AstNegative) {
+ treeNode = new AstNegativeTreeNode(child);
+ } else if (child instanceof AstNull) {
+ treeNode = new AstNullTreeNode(child);
+ } else if (child instanceof AstFloatingPoint) {
+ treeNode = new AstFloatingPointTreeNode(child);
+ } else if (child instanceof AstMethodSuffix) {
+ treeNode = new AstMethodSuffixTreeNode(child);
+ } else if (child instanceof AstPropertySuffix) {
+ treeNode = new AstPropertySuffixTreeNode(child);
+ } else if (child instanceof AstBracketSuffix) {
+ treeNode = new AstBracketSuffixTreeNode(child);
+ } else{
+ throw new ParsingException("Node " + child.getImage() + " is not
recognized;");
+ }
+ return treeNode;
+ }
+
+ /**
+ * This method return PropertyDescriptor by specified propertyName and clazz.
+ * @param clazz - class to search
+ * @param propertyName - propertyName to search
+ * @return property descriptor if found.
+ * @throws ParsingException if error occured.
+ */
+ private static PropertyDescriptor getPropertyDescriptor(Class<?> clazz, String
propertyName) throws ParsingException {
+
+ Map<String, PropertyDescriptor> descriptors =
resolvedProperties.get(clazz.getName());
+
+ if (descriptors == null) {
+ descriptors = resolveProperties(clazz);
+ resolvedProperties.put(clazz.getName(), descriptors);
+ }
+
+ return descriptors.get(propertyName);
+ }
+
+ /**
+ * This method resolve all properties of specified class.
+ * @param clazz - class to resolve
+ * @return Map<String, PropertyDescriptor>, populated by property descriptors.
+ * @throws ParsingException if error occured.
+ */
+ private static Map<String, PropertyDescriptor> resolveProperties(Class<?>
clazz) throws ParsingException {
+ final Map<String, PropertyDescriptor> descriptors = new HashMap<String,
PropertyDescriptor>();
+
+ new ClassWalkingLogic(clazz).walk(new ClassVisitor() {
+ public void visit(Class<?> clazz) throws ParsingException {
+ PropertyDescriptor[] pds = getPropertyDescriptors(clazz);
+ for (PropertyDescriptor descriptor : pds) {
+ descriptors.put(descriptor.getName(), descriptor);
+ }
+ }
+ });
+ return descriptors;
+ }
+
+ /**
+ * This method load specified class.
+ * @param className - class to load.
+ * @throws ClassNotFoundException if class not found.
+ * @return loaded class.
+ */
+ private static Class<?> loadClass(Class<?> className) throws
ClassNotFoundException {
+ Class<?> clazz = null;
+ try {
+ if (className.isPrimitive()) {
+ clazz = getPrimitiveWrapper(className);
+ } else {
+ clazz = loadClass(className.getName());
+ }
+ } catch (ClassNotFoundException e) {
+ throw e;
+ }
+
+ if (null == clazz) {
+ throw new ClassNotFoundException(className.getName());
+ }
+ return clazz;
+ }
+
+ /**
+ * This method load class by specified representation of class name..
+ * @param className - string representation of class.
+ * @throws ClassNotFoundException if class not found.
+ * @return loaded class.
+ */
+ private static Class<?> loadClass(String className) throws ClassNotFoundException
{
+ Class<?> clazz = null;
+ try {
+ clazz = Thread.currentThread().getContextClassLoader().loadClass(className);
+ } catch (ClassNotFoundException e) {
+ throw e;
+ }
+
+ if (null == clazz) {
+ throw new ClassNotFoundException(className);
+ }
+ return clazz;
+ }
+
+ private static Map<String, Map<String, PropertyDescriptor>>
resolvedProperties =
+ new HashMap<String, Map<String,PropertyDescriptor>>();
+
+ /**
+ * <p>Retrieve the property descriptors for the specified class,
+ * introspecting and caching them the first time a particular bean class
+ * is encountered.</p>
+ *
+ * <p><strong>FIXME</strong> - Does not work with
DynaBeans.</p>
+ *
+ * @param beanClass Bean class for which property descriptors are requested
+ * @return the property descriptors
+ * @throws ParsingException if error occured.
+ *
+ * @exception IllegalArgumentException if <code>beanClass</code> is null
+ */
+ private static PropertyDescriptor[] getPropertyDescriptors(Class<?> beanClass)
throws ParsingException {
+
+ if (beanClass == null) {
+ throw new IllegalArgumentException("No bean class specified");
+ }
+
+ // Look up any cached descriptors for this bean class
+ PropertyDescriptor[] descriptors = null;
+
+ // Introspect the bean and cache the generated descriptors
+ BeanInfo beanInfo = null;
+ try {
+ beanInfo = Introspector.getBeanInfo(beanClass);
+ } catch (IntrospectionException e) {
+ return (new PropertyDescriptor[0]);
+ }
+ descriptors = beanInfo.getPropertyDescriptors();
+ if (descriptors == null) {
+ descriptors = new PropertyDescriptor[0];
+ }
+ for (int i = 0; i < descriptors.length; i++) {
+ if (descriptors[i] instanceof IndexedPropertyDescriptor) {
+ IndexedPropertyDescriptor descriptor =
(IndexedPropertyDescriptor)descriptors[i];
+ String propName = descriptor.getName().substring(0, 1).toUpperCase() +
+ descriptor.getName().substring(1);
+
+ if (descriptor.getReadMethod() == null) {
+ String methodName = descriptor.getIndexedReadMethod() != null
+ ? descriptor.getIndexedReadMethod().getName()
+ : "get" + propName;
+ Method readMethod = getMatchingAccessibleMethod(beanClass,
+ methodName,
+ EMPTY_CLASS_PARAMETERS);
+ if (readMethod != null) {
+ try {
+ descriptor.setReadMethod(readMethod);
+ } catch(Exception e) {
+ }
+ }
+ }
+ }
+ }
+ return (descriptors);
+
+ }
+
+ /**
+ * <p>Find an accessible method that matches the given name and has compatible
parameters.
+ * Compatible parameters mean that every method parameter is assignable from
+ * the given parameters.
+ * In other words, it finds a method with the given name
+ * that will take the parameters given.<p>
+ *
+ * <p>This method is slightly undeterminstic since it loops
+ * through methods names and return the first matching method.</p>
+ *
+ * <p>This method is used by
+ * {@link
+ * #invokeMethod(Object object,String methodName,Object [] args,Class[]
parameterTypes)}.
+ *
+ * <p>This method can match primitive parameter by passing in wrapper classes.
+ * For example, a <code>Boolean</code> will match a primitive
<code>boolean</code>
+ * parameter.
+ *
+ * @param clazz find method in this class
+ * @param methodName find method with this name
+ * @param parameterTypes find method with compatible parameters
+ * @return The accessible method
+ * @throws ParsingException if error occured.
+ */
+ private static Method getMatchingAccessibleMethod(Class<?> clazz, String
methodName, Class<?>[] parameterTypes) throws ParsingException {
+ // see if we can find the method directly
+ // most of the time this works and it's much faster
+ try {
+
+ Method method = clazz.getMethod(methodName, parameterTypes);
+
+ setMethodAccessible(method); // Default access superclass workaround
+
+ return method;
+
+ } catch (NoSuchMethodException e) { /* SWALLOW */ }
+
+ // search through all methods
+ int paramSize = parameterTypes.length;
+ Method bestMatch = null;
+ Method[] methods = clazz.getMethods();
+ float bestMatchCost = Float.MAX_VALUE;
+ float myCost = Float.MAX_VALUE;
+ for (int i = 0, size = methods.length; i < size ; i++) {
+ if (methods[i].getName().equals(methodName)) {
+
+ // compare parameters
+ Class<?>[] methodsParams = methods[i].getParameterTypes();
+ int methodParamSize = methodsParams.length;
+ if (methodParamSize == paramSize) {
+ boolean match = true;
+ for (int n = 0 ; n < methodParamSize; n++) {
+ if (!isAssignmentCompatible(methodsParams[n], parameterTypes[n]))
{
+ match = false;
+ break;
+ }
+ }
+
+ if (match) {
+ // get accessible version of method
+ Method method = getAccessibleMethod(clazz, methods[i]);
+ if (method != null) {
+ setMethodAccessible(method); // Default access superclass
workaround
+ myCost =
getTotalTransformationCost(parameterTypes,method.getParameterTypes());
+ if ( myCost < bestMatchCost ) {
+ bestMatch = method;
+ bestMatchCost = myCost;
+ }
+ }
+
+ }
+ }
+ }
+ }
+
+ return bestMatch;
+ }
+
+ /**
+ * <p>Return an accessible method (that is, one that can be invoked via
+ * reflection) that implements the specified Method. If no such method
+ * can be found, return <code>null</code>.</p>
+ *
+ * @param clazz The class of the object
+ * @param method The method that we wish to call
+ * @return The accessible method
+ * @throws ParsingException if error occured.
+ */
+ private static Method getAccessibleMethod(Class<?> clazz, Method method) throws
ParsingException {
+
+ // Make sure we have a method to check
+ if (method == null) {
+ return (null);
+ }
+
+ // If the requested method is not public we cannot call it
+ if (!Modifier.isPublic(method.getModifiers())) {
+ return (null);
+ }
+
+ boolean sameClass = true;
+ if (clazz == null) {
+ clazz = method.getDeclaringClass();
+ } else {
+ sameClass = clazz.equals(method.getDeclaringClass());
+ if (!method.getDeclaringClass().isAssignableFrom(clazz)) {
+ throw new IllegalArgumentException(clazz.getName() +
+ " is not assignable from " +
method.getDeclaringClass().getName());
+ }
+ }
+
+ // If the class is public, we are done
+ if (Modifier.isPublic(clazz.getModifiers())) {
+ if (!sameClass &&
!Modifier.isPublic(method.getDeclaringClass().getModifiers())) {
+ setMethodAccessible(method); // Default access superclass workaround
+ }
+ return (method);
+ }
+
+ String methodName = method.getName();
+ Class<?>[] parameterTypes = method.getParameterTypes();
+
+ // Check the implemented interfaces and subinterfaces
+ method = getAccessibleMethodFromInterfaceNest(clazz, methodName,
parameterTypes);
+
+ // Check the superclass chain
+ if (method == null) {
+ method = getAccessibleMethodFromSuperclass(clazz, methodName,
parameterTypes);
+ }
+
+ return (method);
+
+ }
+
+ /**
+ * <p>Return an accessible method (that is, one that can be invoked via
+ * reflection) by scanning through the superclasses. If no such method
+ * can be found, return <code>null</code>.</p>
+ *
+ * @param clazz Class to be checked
+ * @param methodName Method name of the method we wish to call
+ * @param parameterTypes The parameter type signatures
+ */
+ private static Method getAccessibleMethodFromSuperclass(Class<?> clazz, String
methodName, Class<?>[] parameterTypes) {
+
+ Class<?> parentClazz = clazz.getSuperclass();
+ while (parentClazz != null) {
+ if (Modifier.isPublic(parentClazz.getModifiers())) {
+ try {
+ return parentClazz.getMethod(methodName, parameterTypes);
+ } catch (NoSuchMethodException e) {
+ return null;
+ }
+ }
+ parentClazz = parentClazz.getSuperclass();
+ }
+ return null;
+ }
+
+ /**
+ * <p>Return an accessible method (that is, one that can be invoked via
+ * reflection) that implements the specified method, by scanning through
+ * all implemented interfaces and subinterfaces. If no such method
+ * can be found, return <code>null</code>.</p>
+ *
+ * <p> There isn't any good reason why this method must be private.
+ * It is because there doesn't seem any reason why other classes should
+ * call this rather than the higher level methods.</p>
+ *
+ * @param clazz Parent class for the interfaces to be checked
+ * @param methodName Method name of the method we wish to call
+ * @param parameterTypes The parameter type signatures
+ */
+ private static Method getAccessibleMethodFromInterfaceNest(Class<?> clazz, String
methodName, Class<?>[] parameterTypes) {
+
+ Method method = null;
+
+ // Search up the superclass chain
+ for (; clazz != null; clazz = clazz.getSuperclass()) {
+
+ // Check the implemented interfaces of the parent class
+ Class<?>[] interfaces = clazz.getInterfaces();
+ for (int i = 0; i < interfaces.length; i++) {
+
+ // Is this interface public?
+ if (!Modifier.isPublic(interfaces[i].getModifiers())) {
+ continue;
+ }
+
+ // Does the method exist on this interface?
+ try {
+ method = interfaces[i].getDeclaredMethod(methodName,
parameterTypes);
+ } catch (NoSuchMethodException e) {
+ /* Swallow, if no method is found after the loop then this
+ * method returns null.
+ */
+ }
+ if (method != null) {
+ return method;
+ }
+
+ // Recursively check our parent interfaces
+ method = getAccessibleMethodFromInterfaceNest(interfaces[i], methodName,
parameterTypes);
+ if (method != null) {
+ return method;
+ }
+
+ }
+
+ }
+
+ // If we found a method return it
+ if (method != null) {
+ return (method);
+ }
+
+ // We did not find anything
+ return (null);
+
+ }
+
+ /**
+ * Returns the sum of the object transformation cost for each class in the source
+ * argument list.
+ * @param srcArgs The source arguments
+ * @param destArgs The destination arguments
+ * @return The total transformation cost
+ */
+ private static float getTotalTransformationCost(Class<?>[] srcArgs,
Class<?>[] destArgs) {
+
+ float totalCost = 0.0f;
+ for (int i = 0; i < srcArgs.length; i++) {
+ Class<?> srcClass, destClass;
+ srcClass = srcArgs[i];
+ destClass = destArgs[i];
+ totalCost += getObjectTransformationCost(srcClass, destClass);
+ }
+
+ return totalCost;
+ }
+
+ /**
+ * Gets the number of steps required needed to turn the source class into the
+ * destination class. This represents the number of steps in the object hierarchy
+ * graph.
+ * @param srcClass The source class
+ * @param destClass The destination class
+ * @return The cost of transforming an object
+ */
+ private static float getObjectTransformationCost(Class<?> srcClass, Class<?>
destClass) {
+ float cost = 0.0f;
+ while (destClass != null && !destClass.equals(srcClass)) {
+ if (destClass.isInterface() &&
isAssignmentCompatible(destClass,srcClass)) {
+ // slight penalty for interface match.
+ // we still want an exact match to override an interface match, but
+ // an interface match should override anything where we have to get a
+ // superclass.
+ cost += 0.25f;
+ break;
+ }
+ cost++;
+ destClass = destClass.getSuperclass();
+ }
+
+ /*
+ * If the destination class is null, we've travelled all the way up to
+ * an Object match. We'll penalize this by adding 1.5 to the cost.
+ */
+ if (destClass == null) {
+ cost += 1.5f;
+ }
+
+ return cost;
+ }
+
+ /**
+ * <p>Determine whether a type can be used as a parameter in a method
invocation.
+ * This method handles primitive conversions correctly.</p>
+ *
+ * <p>In order words, it will match a <code>Boolean</code> to a
<code>boolean</code>,
+ * a <code>Long</code> to a <code>long</code>,
+ * a <code>Float</code> to a <code>float</code>,
+ * a <code>Integer</code> to a <code>int</code>,
+ * and a <code>Double</code> to a <code>double</code>.
+ * Now logic widening matches are allowed.
+ * For example, a <code>Long</code> will not match a
<code>int</code>.
+ *
+ * @param parameterType the type of parameter accepted by the method
+ * @param parameterization the type of parameter being tested
+ *
+ * @return true if the assignement is compatible.
+ */
+ private static final boolean isAssignmentCompatible(Class<?> parameterType,
Class<?> parameterization) {
+ // try plain assignment
+ if (parameterType.isAssignableFrom(parameterization)) {
+ return true;
+ }
+
+ if (parameterType.isPrimitive()) {
+ // this method does *not* do widening - you must specify exactly
+ // is this the right behaviour?
+ Class<?> parameterWrapperClazz = getPrimitiveWrapper(parameterType);
+ if (parameterWrapperClazz != null) {
+ return parameterWrapperClazz.equals(parameterization);
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Gets the wrapper object class for the given primitive type class.
+ * For example, passing <code>boolean.class</code> returns
<code>Boolean.class</code>
+ * @param primitiveType the primitive type class for which a match is to be found
+ * @return the wrapper type associated with the given primitive
+ * or null if no match is found
+ */
+ private static Class<?> getPrimitiveWrapper(Class<?> primitiveType) {
+ // does anyone know a better strategy than comparing names?
+ if (boolean.class.equals(primitiveType)) {
+ return Boolean.class;
+ } else if (float.class.equals(primitiveType)) {
+ return Float.class;
+ } else if (long.class.equals(primitiveType)) {
+ return Long.class;
+ } else if (int.class.equals(primitiveType)) {
+ return Integer.class;
+ } else if (short.class.equals(primitiveType)) {
+ return Short.class;
+ } else if (byte.class.equals(primitiveType)) {
+ return Byte.class;
+ } else if (double.class.equals(primitiveType)) {
+ return Double.class;
+ } else if (char.class.equals(primitiveType)) {
+ return Character.class;
+ } else {
+
+ return null;
+ }
+ }
+
+ /**
+ * Try to make the method accessible
+ * @param method The source arguments
+ * @throws ParsingException if error occured during call setAccessible method.
+ */
+ private static void setMethodAccessible(Method method) throws ParsingException {
+ try {
+ //
+ // XXX Default access superclass workaround
+ //
+ // When a public class has a default access superclass
+ // with public methods, these methods are accessible.
+ // Calling them from compiled code works fine.
+ //
+ // Unfortunately, using reflection to invoke these methods
+ // seems to (wrongly) to prevent access even when the method
+ // modifer is public.
+ //
+ // The following workaround solves the problem but will only
+ // work from sufficiently privilages code.
+ //
+ // Better workarounds would be greatfully accepted.
+ //
+ method.setAccessible(true);
+
+ } catch (SecurityException se) {
+ throw new ParsingException("Cannot setAccessible on method. Therefore
cannot use jvm access bug workaround.", se);
+ }
+ }
+
+ /**
+ * Gets the name of read method for specified property name.
+ * @param propertyName - property to lookup
+ * @param visitor - ELVisitor instance
+ * @throws ParsingException - if property not found or class not found.
+ * @return String representation of read method of specified property.
+ */
+ public static String getReadMethodName(String propertyName, ELVisitor visitor) throws
ParsingException{
+ try{
+ Class<?> clazz = loadClass(visitor.getLastVariableType());
+ PropertyDescriptor propertyDescriptor = getPropertyDescriptor(clazz,
propertyName);
+ if (propertyDescriptor == null) {
+ throw new ParsingException("property: " + propertyName + " not
found in class: " + visitor.getLastVariableType());
+ }
+ Class<?> propertyType = propertyDescriptor.getPropertyType();
+ visitor.setLastVariableType(propertyType);
+ if (visitor.getLastVariableType().getName().compareTo(ELNodeConstants.JAVA_UTIL_MAP)
== 0) {
+ Method readMethod = propertyDescriptor.getReadMethod();
+ Type genericReturnType = readMethod.getGenericReturnType();
+ if (genericReturnType instanceof ParameterizedType) {
+ ParameterizedType type = (ParameterizedType) genericReturnType;
+ Type[] typeArguments = type.getActualTypeArguments();
+ visitor.setCollectionVariableType(((Class<?>) typeArguments[1]));
+ }
+ }
+ if (visitor.getLastVariableType().getName().compareTo(ELNodeConstants.JAVA_UTIL_LIST)
== 0) {
+ Method readMethod = propertyDescriptor.getReadMethod();
+ Type genericReturnType = readMethod.getGenericReturnType();
+ if (genericReturnType instanceof ParameterizedType) {
+ ParameterizedType type = (ParameterizedType) genericReturnType;
+ Type[] typeArguments = type.getActualTypeArguments();
+ visitor.setCollectionVariableType(((Class<?>) typeArguments[0]));
+ }
+ }
+ if
(visitor.getLastVariableType().getName().startsWith(ELNodeConstants.ARRAY_INDICATOR)) {
+ Method readMethod = propertyDescriptor.getReadMethod();
+ visitor.setCollectionVariableType(readMethod.getReturnType());
+ String className = visitor.getCollectionVariableType().getName().substring(0,
+ visitor.getCollectionVariableType().getName().length() - 1).substring(2);
+ visitor.setCollectionVariableType(loadClass(className));
+ }
+ return propertyDescriptor.getReadMethod().getName();
+ }catch(ClassNotFoundException cnfe){
+ throw new ParsingException(cnfe.getMessage());
+ }
+ }
+
+ static class ClassWalkingLogic {
+ private Class<?> clazz;
+
+ public ClassWalkingLogic(Class<?> clazz) {
+ super();
+ this.clazz = clazz;
+ }
+
+ public void walk(ClassVisitor visitor) throws ParsingException {
+ walkClass(clazz, visitor);
+ }
+
+ private void walkClass(Class<?> c, ClassVisitor visitor) throws ParsingException
{
+ if (c == null || Object.class.getName().equals(c.getName())) {
+ return;
+ }
+
+ Class<?>[] interfaces = c.getInterfaces();
+ for (Class<?> class1 : interfaces) {
+ walkClass(class1, visitor);
+ }
+ walkClass(c.getSuperclass(), visitor);
+
+ visitor.visit(c);
+ }
+ }
+
+ interface ClassVisitor {
+ public void visit(Class<?> clazz) throws ParsingException;
+ }
+}
Property changes on:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/ELReflectionUtils.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/ELVisitor.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/ELVisitor.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/ELVisitor.java 2009-08-21
18:21:48 UTC (rev 15266)
@@ -0,0 +1,163 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.cdk.parser.el;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.jboss.el.parser.AstLiteralExpression;
+import org.jboss.el.parser.ELParser;
+import org.jboss.el.parser.Node;
+import org.richfaces.cdk.parser.el.node.ITreeNode;
+/**
+ * Entry point for parsing EL expressions. @see parse() method.
+ * @author amarkhel
+ *
+ */
+public class ELVisitor {
+
+ private ELVisitor() {
+ }
+
+ private static ELVisitor elVisitor;
+
+ public static ELVisitor getInstance() {
+ if (elVisitor == null) {
+ elVisitor = new ELVisitor();
+ }
+ elVisitor.refresh();
+ return elVisitor;
+ }
+
+ String lastIndexValue = "null";
+
+ Class<?> lastVariableType = null;
+
+ Class<?> collectionVariableType = null;
+
+ List<Object> propertyResolved = new ArrayList<Object>();
+
+ boolean needConversion;
+
+ public boolean isNeedConversion() {
+ return needConversion;
+ }
+
+ public void setNeedConversion(boolean needConversion) {
+ this.needConversion = needConversion;
+ }
+
+ public String getLastIndexValue() {
+ return lastIndexValue;
+ }
+
+ public void setLastIndexValue(String lastIndexValue) {
+ this.lastIndexValue = lastIndexValue;
+ }
+
+ public Class<?> getLastVariableType() {
+ return lastVariableType;
+ }
+
+ public void setLastVariableType(Class<?> lastVariableType) {
+ this.lastVariableType = lastVariableType;
+ }
+
+ public Class<?> getCollectionVariableType() {
+ return collectionVariableType;
+ }
+
+ public void setCollectionVariableType(Class<?> collectionVariableType) {
+ this.collectionVariableType = collectionVariableType;
+ }
+
+ /**
+ * Parse specified EL expression and return Java code, that represent this expression
+ * @param expression - expression to resolve
+ * @param contextMap - Map<String, Class<?>> - context for search classes.
+ * @return generated Java code.
+ * @throws ParsingException - if error occurred during parsing.
+ */
+ public String parse(String expression, Map<String, Class<?>> contextMap)
throws ParsingException{
+ Node ret = ELParser.parse(expression);
+ return ELVisitor.getInstance().visit(ret, contextMap);
+ }
+
+ private String visit(Node node, Map<String, Class<?>> context) throws
ParsingException {
+ int numChildren = node.jjtGetNumChildren();
+ StringBuilder sb = new StringBuilder();
+ for (int i = 0; i < numChildren; i++) {
+ Node child = node.jjtGetChild(i);
+ if(child instanceof AstLiteralExpression){
+ this.setNeedConversion(true);
+ }
+ ITreeNode treeNode = ELReflectionUtils.determineNodeType(child);
+ treeNode.visit(sb, context, this);
+ if(i != numChildren -1){
+ sb.append(" + ");
+ }
+ }
+ return sb.toString();
+ }
+
+ /**
+ * Reset internal state of elVisitor instance. Called after each AstValue resolved and
parsed.
+ */
+ public void reset() {
+ lastIndexValue = "null";
+ lastVariableType = null;
+ collectionVariableType = null;
+ }
+
+ private void refresh() {
+ lastIndexValue = "null";
+ lastVariableType = null;
+ collectionVariableType = null;
+ needConversion = false;
+ propertyResolved = new ArrayList<Object>();
+ }
+
+ /**
+ * This method called after parse process handle AstValue node, to include special logic
in that case.
+ */
+ public void setValueHandled() {
+ propertyResolved.add(new Object());
+ }
+
+ /**
+ * This method called after AstValue node is completely parsed.
+ * NOTE: AstValue can be nested.
+ */
+ public void unSetValueHandled() {
+ if(propertyResolved.size() > 0){
+ propertyResolved.remove(propertyResolved.size() - 1);
+ }
+ }
+
+ /**
+ * This method determine if AstValue node now parsed, to include special logic.
+ * @return true if AstValue node now parsed, otherwise -false.
+ */
+ public boolean isValueHandled(){
+ return propertyResolved.size() > 0;
+ }
+}
Property changes on:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/ELVisitor.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/ParsingException.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/ParsingException.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/ParsingException.java 2009-08-21
18:21:48 UTC (rev 15266)
@@ -0,0 +1,58 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.cdk.parser.el;
+
+/**
+ * Parsing Exception
+ * @author amarkhel
+ *
+ */
+public class ParsingException extends Exception {
+
+ private static final long serialVersionUID = 6045782920008419804L;
+
+ public ParsingException() {
+ }
+
+ /**
+ * @param message
+ */
+ public ParsingException(String message) {
+ super(message);
+ }
+
+ /**
+ * @param cause
+ */
+ public ParsingException(Throwable cause) {
+ super(cause);
+ }
+
+ /**
+ * @param message
+ * @param cause
+ */
+ public ParsingException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+}
Property changes on:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/ParsingException.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/StringUtils.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/StringUtils.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/StringUtils.java 2009-08-21
18:21:48 UTC (rev 15266)
@@ -0,0 +1,87 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.cdk.parser.el;
+
+public class StringUtils {
+
+ static public String getEscapedString(final String text) {
+ StringBuffer buf = new StringBuffer();
+
+ int i = 0;
+ while (i < text.length()) {
+ char c = text.charAt(i);
+ if (isalnum(c)) {
+ buf.append(c);
+ } else {
+ switch (c) {
+ case '"':
+ buf.append("\\\"");
+ break;
+ case '\n':
+ buf.append("\\n");
+ break;
+ default:
+ buf.append(c);
+ break;
+ }
+ }
+ i++;
+ }
+ return buf.toString();
+ }
+
+ /**
+ * Returns true if the char isalpha() or isdigit().
+ */
+ public static boolean isalnum(char c) {
+ return (isalpha(c) || isdigit(c));
+ }
+
+ /**
+ * Returns true if the char isupper() or islower().
+ */
+ public static boolean isalpha(char c) {
+ return (isupper(c) || islower(c));
+ }
+
+ /**
+ * Returns true if the char is from 'A' to 'Z' inclusive.
+ */
+ public static boolean isupper(char c) {
+ return ((c >= 'A') && (c <= 'Z'));
+ }
+
+ /**
+ * Returns true if the char is from 'a' to 'z' inclusive.
+ */
+ public static boolean islower(char c) {
+ return ((c >= 'a') && (c <= 'z'));
+ }
+
+ /**
+ * Returns true if the char is from '0' to '9' inclusive.
+ */
+ public static boolean isdigit(char c) {
+ return ((c >= '0') && (c <= '9'));
+ }
+
+}
Property changes on:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/StringUtils.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AbstractArithmeticTreeNode.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AbstractArithmeticTreeNode.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AbstractArithmeticTreeNode.java 2009-08-21
18:21:48 UTC (rev 15266)
@@ -0,0 +1,66 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.cdk.parser.el.node;
+
+import java.util.Map;
+
+import org.jboss.el.parser.Node;
+import org.richfaces.cdk.parser.el.ELVisitor;
+import org.richfaces.cdk.parser.el.ParsingException;
+
+/**
+ * This class extend AbstractTreeNode and wrap any Arithmetic node.
+ * getOperator() method must be overridden in subclasses.
+ *
+ * @author amarkhel
+ *
+ */
+public abstract class AbstractArithmeticTreeNode extends AbstractTreeNode {
+
+ public AbstractArithmeticTreeNode(Node node) {
+ super(node);
+ }
+
+ @Override
+ public void visit(StringBuilder sb, Map<String, Class<?>> context, ELVisitor
visitor) throws ParsingException {
+ StringBuilder sb1 = new StringBuilder();
+ StringBuilder sb2 = new StringBuilder();
+
+ ITreeNode node1 = getChild(0);
+ node1.visit(sb1, context, visitor);
+ ITreeNode node2 = getChild(1);
+ node2.visit(sb2, context, visitor);
+ sb.append(ELNodeConstants.LEFT_BRACKET);
+ sb.append(sb1);
+ sb.append(getOperator());
+ sb.append(sb2);
+ sb.append(ELNodeConstants.RIGHT_BRACKET);
+ }
+
+ /**
+ * This abstract method return string representation of arithmetic operation.
+ *
+ * @return string representation of arithmetic operation of current node.
+ *
+ */
+ public abstract String getOperator();
+
+}
Property changes on:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AbstractArithmeticTreeNode.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AbstractBooleanTreeNode.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AbstractBooleanTreeNode.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AbstractBooleanTreeNode.java 2009-08-21
18:21:48 UTC (rev 15266)
@@ -0,0 +1,65 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.cdk.parser.el.node;
+
+import java.util.Map;
+
+import org.jboss.el.parser.Node;
+import org.richfaces.cdk.parser.el.ELVisitor;
+import org.richfaces.cdk.parser.el.ParsingException;
+/**
+ * This class extend AbstractTreeNode and wrap any Boolean node.
+ * getDelimiter() method must be overridden in subclasses.
+ *
+ * @author amarkhel
+ *
+ */
+public abstract class AbstractBooleanTreeNode extends AbstractTreeNode{
+
+ public AbstractBooleanTreeNode(Node node) {
+ super(node);
+ }
+
+ @Override
+ public void visit(StringBuilder sb, Map<String, Class<?>> context, ELVisitor
visitor) throws ParsingException {
+ StringBuilder sb1 = new StringBuilder();
+ StringBuilder sb2 = new StringBuilder();
+
+ ITreeNode node1 = getChild(0);
+ node1.visit(sb1, context, visitor);
+ ITreeNode node2 = getChild(1);
+ node2.visit(sb2, context, visitor);
+ sb.append(ELNodeConstants.LEFT_BRACKET);
+ sb.append(sb1);
+ sb.append(getDelimiter());
+ sb.append(sb2);
+ sb.append(ELNodeConstants.RIGHT_BRACKET);
+ }
+
+ /**
+ * This abstract method return string representation of comparison operation.
+ *
+ * @return string representation of comparison operation of current node.
+ *
+ */
+ public abstract String getDelimiter();
+
+}
Property changes on:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AbstractBooleanTreeNode.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AbstractTreeNode.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AbstractTreeNode.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AbstractTreeNode.java 2009-08-21
18:21:48 UTC (rev 15266)
@@ -0,0 +1,80 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.cdk.parser.el.node;
+
+import java.util.Map;
+
+import org.jboss.el.parser.Node;
+import org.richfaces.cdk.parser.el.ELReflectionUtils;
+import org.richfaces.cdk.parser.el.ELVisitor;
+import org.richfaces.cdk.parser.el.ParsingException;
+
+/**
+ * This abstract class implement some methods of ITreeNode interface to using in
subclasses.
+ *
+ * @author amarkhel
+ *
+ */
+public abstract class AbstractTreeNode implements ITreeNode {
+
+ public AbstractTreeNode(Node node){
+ this.node = node;
+ }
+
+ private Node node;
+
+ /**
+ * Return node of current wrapper.
+ * @return instance of org.jboss.el.parser.Node
+ *
+ */
+ public Node getNode() {
+ return node;
+ }
+
+ /**
+ * Visit current node. Generate Java code, that represent current node.
+ * @param stringBuilder instance to collect information.
+ * @param context - context to resolve beans
+ * @param visitor - ELVisitor
+ * @throws ParsingException - if error occurred during parsing process.
+ * @return instance of org.jboss.el.parser.Node
+ *
+ */
+ public ITreeNode getChild(int index) throws ParsingException{
+ Node childNode = getNode().jjtGetChild(index);
+ if (null != childNode) {
+ ITreeNode treeNode = ELReflectionUtils.determineNodeType(childNode);
+ return treeNode;
+ }else{
+ throw new ParsingException("Child node not found of node " +
node.getImage());
+ }
+ }
+
+ /**
+ * Return child of wrapped node by specified index. Abstract operation to override in
subclasses.
+ * @param index - index of child.
+ * @throws ParsingException - if error occurred(child not found).
+ * @return wrapper for child
+ *
+ */
+ public abstract void visit(StringBuilder sb, Map<String, Class<?>> context,
ELVisitor visitor) throws ParsingException;
+}
Property changes on:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AbstractTreeNode.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstAndTreeNode.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstAndTreeNode.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstAndTreeNode.java 2009-08-21
18:21:48 UTC (rev 15266)
@@ -0,0 +1,41 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.cdk.parser.el.node;
+
+import org.jboss.el.parser.Node;
+/**
+ * This class extend AbstractTreeNode and wrap AstAnd node.
+ *
+ * @author amarkhel
+ *
+ */
+public class AstAndTreeNode extends AbstractBooleanTreeNode{
+
+ public AstAndTreeNode(Node node) {
+ super(node);
+ }
+
+ @Override
+ public String getDelimiter() {
+ return ELNodeConstants.AND_DELIMITER;
+ }
+
+}
Property changes on:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstAndTreeNode.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstBracketSuffixTreeNode.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstBracketSuffixTreeNode.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstBracketSuffixTreeNode.java 2009-08-21
18:21:48 UTC (rev 15266)
@@ -0,0 +1,73 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.cdk.parser.el.node;
+
+import java.util.Map;
+
+import org.jboss.el.parser.Node;
+import org.richfaces.cdk.parser.el.ELVisitor;
+import org.richfaces.cdk.parser.el.ParsingException;
+/**
+ * This class extend AbstractTreeNode and wrap AstBracketSuffix node.
+ *
+ * @author amarkhel
+ *
+ */
+public class AstBracketSuffixTreeNode extends AbstractTreeNode {
+
+ public AstBracketSuffixTreeNode(Node node) {
+ super(node);
+ }
+
+ @Override
+ public void visit(StringBuilder sb, Map<String, Class<?>> context, ELVisitor
visitor) throws ParsingException {
+ ITreeNode node = getChild(0);
+ node.visit(sb, context, visitor);
+ String bracketSuffix = sb.toString();
+ if(visitor.isValueHandled()){
+ sb.setLength(0);
+ if (visitor.getLastVariableType() != null) {
+ if
(visitor.getLastVariableType().getName().startsWith(ELNodeConstants.ARRAY_INDICATOR)) {
+ sb.append(ELNodeConstants.LEFT_SQUARE_BRACKET);
+ sb.append(bracketSuffix);
+ sb.append(ELNodeConstants.RIGHT_SQUARE_BRACKET);
+ visitor.setLastVariableType(visitor.getCollectionVariableType());
+ }
+ if
((visitor.getLastVariableType().getName().compareTo(ELNodeConstants.JAVA_UTIL_LIST) == 0)
+ ||
(visitor.getLastVariableType().getName().compareTo(ELNodeConstants.JAVA_UTIL_MAP) == 0))
{
+ sb.append(ELNodeConstants.GET_FUNCTION);
+ sb.append(ELNodeConstants.LEFT_BRACKET);
+ sb.append(bracketSuffix);
+ sb.append(ELNodeConstants.RIGHT_BRACKET);
+ visitor.setLastVariableType(visitor.getCollectionVariableType());
+ }
+ } else {
+ sb.append(ELNodeConstants.GET_ELELMENT_BY_INDEX_FUNCTION);
+ sb.append(ELNodeConstants.LEFT_BRACKET);
+ sb.append(visitor.getLastIndexValue());
+ sb.append(ELNodeConstants.COMMA);
+ sb.append(bracketSuffix);
+ sb.append(ELNodeConstants.RIGHT_BRACKET);
+ }
+ }
+ }
+
+}
Property changes on:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstBracketSuffixTreeNode.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstChoiceTreeNode.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstChoiceTreeNode.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstChoiceTreeNode.java 2009-08-21
18:21:48 UTC (rev 15266)
@@ -0,0 +1,61 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.cdk.parser.el.node;
+
+import java.util.Map;
+
+import org.jboss.el.parser.Node;
+import org.richfaces.cdk.parser.el.ELVisitor;
+import org.richfaces.cdk.parser.el.ParsingException;
+/**
+ * This class extend AbstractTreeNode and wrap AstChoice node.
+ *
+ * @author amarkhel
+ *
+ */
+public class AstChoiceTreeNode extends AbstractTreeNode{
+
+ public AstChoiceTreeNode(Node node) {
+ super(node);
+ }
+
+ @Override
+ public void visit(StringBuilder sb, Map<String, Class<?>> context, ELVisitor
visitor) throws ParsingException{
+ StringBuilder sb1 = new StringBuilder();
+ StringBuilder sb2 = new StringBuilder();
+ StringBuilder sb3 = new StringBuilder();
+
+ ITreeNode node1 = getChild(0);
+ node1.visit(sb1, context, visitor);
+ ITreeNode node2 = getChild(1);
+ node2.visit(sb2, context, visitor);
+ ITreeNode node3 = getChild(2);
+ node3.visit(sb3, context, visitor);
+ sb.append(ELNodeConstants.LEFT_BRACKET);
+ sb.append(sb1);
+ sb.append(ELNodeConstants.QUESTION_SIGN);
+ sb.append(sb2);
+ sb.append(ELNodeConstants.COLON);
+ sb.append(sb3);
+ sb.append(ELNodeConstants.RIGHT_BRACKET);
+ }
+
+}
Property changes on:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstChoiceTreeNode.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstDeferredExpressionTreeNode.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstDeferredExpressionTreeNode.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstDeferredExpressionTreeNode.java 2009-08-21
18:21:48 UTC (rev 15266)
@@ -0,0 +1,56 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.cdk.parser.el.node;
+
+import java.util.Map;
+
+import org.jboss.el.parser.Node;
+import org.richfaces.cdk.parser.el.ELVisitor;
+import org.richfaces.cdk.parser.el.ParsingException;
+/**
+ * This class extend AbstractTreeNode and wrap AstDeferredExpression node.
+ *
+ * @author amarkhel
+ *
+ */
+public class AstDeferredExpressionTreeNode extends AbstractTreeNode {
+
+ public AstDeferredExpressionTreeNode(Node node) {
+ super(node);
+ }
+
+ @Override
+ public void visit(StringBuilder sb, Map<String, Class<?>> context, ELVisitor
visitor) throws ParsingException {
+ int numChildren = getNode().jjtGetNumChildren();
+ for (int i = 0; i < numChildren; i++) {
+ if(visitor.isNeedConversion()){
+ sb.append(ELNodeConstants.CONVERT_TO_STRING_FUNCTION);
+ sb.append(ELNodeConstants.LEFT_BRACKET);
+ }
+ ITreeNode treeNode = getChild(i);
+ treeNode.visit(sb, context, visitor);
+ if(visitor.isNeedConversion()){
+ sb.append(ELNodeConstants.RIGHT_BRACKET);
+ }
+ }
+ }
+
+}
Property changes on:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstDeferredExpressionTreeNode.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstDivTreeNode.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstDivTreeNode.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstDivTreeNode.java 2009-08-21
18:21:48 UTC (rev 15266)
@@ -0,0 +1,41 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.cdk.parser.el.node;
+
+import org.jboss.el.parser.Node;
+/**
+ * This class extend AbstractTreeNode and wrap AstDiv node.
+ *
+ * @author amarkhel
+ *
+ */
+public class AstDivTreeNode extends AbstractArithmeticTreeNode {
+
+ public AstDivTreeNode(Node node) {
+ super(node);
+ }
+
+ @Override
+ public String getOperator() {
+ return ELNodeConstants.DIV_OPERATOR;
+ }
+
+}
Property changes on:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstDivTreeNode.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstEmptyTreeNode.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstEmptyTreeNode.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstEmptyTreeNode.java 2009-08-21
18:21:48 UTC (rev 15266)
@@ -0,0 +1,52 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.cdk.parser.el.node;
+
+import java.util.Map;
+
+import org.jboss.el.parser.Node;
+import org.richfaces.cdk.parser.el.ELVisitor;
+import org.richfaces.cdk.parser.el.ParsingException;
+/**
+ * This class extend AbstractTreeNode and wrap AstEmpty node.
+ *
+ * @author amarkhel
+ *
+ */
+public class AstEmptyTreeNode extends AbstractTreeNode{
+
+ public AstEmptyTreeNode(Node node) {
+ super(node);
+ }
+
+ @Override
+ public void visit(StringBuilder sb, Map<String, Class<?>> context, ELVisitor
visitor) throws ParsingException {
+
+ StringBuilder sb1 = new StringBuilder();
+ ITreeNode treeNode = getChild(0);
+ treeNode.visit(sb1 , context, visitor);
+ sb.append(ELNodeConstants.THIS_GET_UTILS_IS_EMPTY_FUNCTION);
+ sb.append(ELNodeConstants.LEFT_BRACKET);
+ sb.append(sb1);
+ sb.append(ELNodeConstants.RIGHT_BRACKET);
+ }
+
+}
Property changes on:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstEmptyTreeNode.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstEqualTreeNode.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstEqualTreeNode.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstEqualTreeNode.java 2009-08-21
18:21:48 UTC (rev 15266)
@@ -0,0 +1,41 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.cdk.parser.el.node;
+
+import org.jboss.el.parser.Node;
+/**
+ * This class extend AbstractTreeNode and wrap AstEqual node.
+ *
+ * @author amarkhel
+ *
+ */
+public class AstEqualTreeNode extends AbstractBooleanTreeNode{
+
+ public AstEqualTreeNode(Node node) {
+ super(node);
+ }
+
+ @Override
+ public String getDelimiter() {
+ return ELNodeConstants.EQUAL;
+ }
+
+}
Property changes on:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstEqualTreeNode.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstFalseTreeNode.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstFalseTreeNode.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstFalseTreeNode.java 2009-08-21
18:21:48 UTC (rev 15266)
@@ -0,0 +1,46 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.cdk.parser.el.node;
+
+import java.util.Map;
+
+import org.jboss.el.parser.Node;
+import org.richfaces.cdk.parser.el.ELVisitor;
+import org.richfaces.cdk.parser.el.ParsingException;
+/**
+ * This class extend AbstractTreeNode and wrap AstFalse node.
+ *
+ * @author amarkhel
+ *
+ */
+public class AstFalseTreeNode extends AbstractTreeNode {
+
+ public AstFalseTreeNode(Node node) {
+ super(node);
+ }
+
+ @Override
+ public void visit(StringBuilder sb, Map<String, Class<?>> context, ELVisitor
visitor)
+ throws ParsingException {
+ sb.append(ELNodeConstants.FALSE);
+ }
+
+}
Property changes on:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstFalseTreeNode.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstFloatingPointTreeNode.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstFloatingPointTreeNode.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstFloatingPointTreeNode.java 2009-08-21
18:21:48 UTC (rev 15266)
@@ -0,0 +1,49 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.cdk.parser.el.node;
+
+import java.util.Map;
+
+import org.jboss.el.parser.Node;
+import org.richfaces.cdk.parser.el.ELVisitor;
+import org.richfaces.cdk.parser.el.ParsingException;
+/**
+ * This class extend AbstractTreeNode and wrap AstFloatingPoint node.
+ *
+ * @author amarkhel
+ *
+ */
+public class AstFloatingPointTreeNode extends AbstractTreeNode {
+
+ public AstFloatingPointTreeNode(Node node) {
+ super(node);
+ }
+
+ @Override
+ public void visit(StringBuilder sb, Map<String, Class<?>> context, ELVisitor
visitor)
+ throws ParsingException {
+ sb.append(ELNodeConstants.DOUBLE_VALUE_OF_FUNCTION);
+ sb.append(ELNodeConstants.LEFT_BRACKET);
+ sb.append(getNode().getImage());
+ sb.append(ELNodeConstants.RIGHT_BRACKET);
+ }
+
+}
Property changes on:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstFloatingPointTreeNode.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstFunctionTreeNode.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstFunctionTreeNode.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstFunctionTreeNode.java 2009-08-21
18:21:48 UTC (rev 15266)
@@ -0,0 +1,60 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.cdk.parser.el.node;
+
+import java.util.Map;
+
+import org.jboss.el.parser.AstFunction;
+import org.jboss.el.parser.Node;
+import org.richfaces.cdk.parser.el.ELVisitor;
+import org.richfaces.cdk.parser.el.ParsingException;
+/**
+ * This class extend AbstractTreeNode and wrap AstFunction node.
+ *
+ * @author amarkhel
+ *
+ */
+public class AstFunctionTreeNode extends AbstractTreeNode {
+
+ public AstFunctionTreeNode(Node node) {
+ super(node);
+ }
+
+ @Override
+ public void visit(StringBuilder sb, Map<String, Class<?>> context, ELVisitor
visitor) throws ParsingException {
+ String functionName = ((AstFunction) getNode()).getOutputName();
+ sb.append(ELNodeConstants.THIS_PREFIX);
+ sb.append(ELNodeConstants.DOT);
+ sb.append(functionName.substring(1));
+ sb.append(ELNodeConstants.LEFT_BRACKET);
+ int numChildren = getNode().jjtGetNumChildren();
+ for (int i = 0; i < numChildren; i++) {
+ ITreeNode childNode = getChild(i);
+ StringBuilder sb1 = new StringBuilder();
+ childNode.visit(sb1, context, visitor);
+ if (i != 0) {
+ sb.append(ELNodeConstants.COMMA);
+ }
+ sb.append(sb1);
+ }
+ sb.append(ELNodeConstants.RIGHT_BRACKET);
+ }
+}
Property changes on:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstFunctionTreeNode.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstGreaterThanEqualTreeNode.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstGreaterThanEqualTreeNode.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstGreaterThanEqualTreeNode.java 2009-08-21
18:21:48 UTC (rev 15266)
@@ -0,0 +1,41 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.cdk.parser.el.node;
+
+import org.jboss.el.parser.Node;
+/**
+ * This class extend AbstractTreeNode and wrap AstGreaterThanEqual node.
+ *
+ * @author amarkhel
+ *
+ */
+public class AstGreaterThanEqualTreeNode extends AbstractBooleanTreeNode{
+
+ public AstGreaterThanEqualTreeNode(Node node) {
+ super(node);
+ }
+
+ @Override
+ public String getDelimiter() {
+ return ELNodeConstants.GREAT_THEN_EQUAL;
+ }
+
+}
Property changes on:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstGreaterThanEqualTreeNode.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstGreaterThanTreeNode.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstGreaterThanTreeNode.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstGreaterThanTreeNode.java 2009-08-21
18:21:48 UTC (rev 15266)
@@ -0,0 +1,41 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.cdk.parser.el.node;
+
+import org.jboss.el.parser.Node;
+/**
+ * This class extend AbstractTreeNode and wrap AstGreaterThan node.
+ *
+ * @author amarkhel
+ *
+ */
+public class AstGreaterThanTreeNode extends AbstractBooleanTreeNode{
+
+ public AstGreaterThanTreeNode(Node node) {
+ super(node);
+ }
+
+ @Override
+ public String getDelimiter() {
+ return ELNodeConstants.GREAT_THEN;
+ }
+
+}
Property changes on:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstGreaterThanTreeNode.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstIdentifierTreeNode.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstIdentifierTreeNode.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstIdentifierTreeNode.java 2009-08-21
18:21:48 UTC (rev 15266)
@@ -0,0 +1,69 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.cdk.parser.el.node;
+
+import java.util.Map;
+
+import org.jboss.el.parser.Node;
+import org.richfaces.cdk.parser.el.ELVisitor;
+import org.richfaces.cdk.parser.el.ParsingException;
+/**
+ * This class extend AbstractTreeNode and wrap AstIdentifier node.
+ *
+ * @author amarkhel
+ *
+ */
+public class AstIdentifierTreeNode extends AbstractTreeNode {
+
+ public AstIdentifierTreeNode(Node node) {
+ super(node);
+ }
+
+ @Override
+ public void visit(StringBuilder sb, Map<String, Class<?>> context, ELVisitor
visitor) throws ParsingException {
+ String variableName = getNode().getImage();
+ if (visitor.isValueHandled()){
+ if(context.containsKey(variableName)){
+ visitor.setLastVariableType(context.get(variableName));
+ sb.append(variableName);
+ } else {
+ if(variableName.equals(ELNodeConstants.THIS_PREFIX)){
+ sb.append(variableName);
+ }else if(variableName.equals(ELNodeConstants.UTILS_PREFIX)){
+ sb.append(ELNodeConstants.THIS_PREFIX);
+ sb.append(ELNodeConstants.DOT);
+ sb.append(ELNodeConstants.GET_UTILS_FUNCTION);
+ sb.append(ELNodeConstants.LEFT_BRACKET);
+ sb.append(ELNodeConstants.RIGHT_BRACKET);
+ }else{
+ throw new ParsingException("No instance found in context for identifier "
+ variableName);
+ }
+ }
+ } else{
+ sb.append(ELNodeConstants.VARIABLES_GET_VARIABLE_FUNCTION);
+ sb.append(ELNodeConstants.LEFT_BRACKET);
+ sb.append(ELNodeConstants.QUOTE);
+ sb.append(variableName);
+ sb.append(ELNodeConstants.QUOTE);
+ sb.append(ELNodeConstants.RIGHT_BRACKET);
+ }
+ }
+}
Property changes on:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstIdentifierTreeNode.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstIntegerTreeNode.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstIntegerTreeNode.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstIntegerTreeNode.java 2009-08-21
18:21:48 UTC (rev 15266)
@@ -0,0 +1,45 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.cdk.parser.el.node;
+
+import java.util.Map;
+
+import org.jboss.el.parser.Node;
+import org.richfaces.cdk.parser.el.ELVisitor;
+import org.richfaces.cdk.parser.el.ParsingException;
+/**
+ * This class extend AbstractTreeNode and wrap AstInteger node.
+ *
+ * @author amarkhel
+ *
+ */
+public class AstIntegerTreeNode extends AbstractTreeNode {
+
+ public AstIntegerTreeNode(Node node) {
+ super(node);
+ }
+
+ @Override
+ public void visit(StringBuilder sb, Map<String, Class<?>> context, ELVisitor
visitor) throws ParsingException{
+ sb.append(getNode().getImage());
+ }
+
+}
Property changes on:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstIntegerTreeNode.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstLessThanEqualTreeNode.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstLessThanEqualTreeNode.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstLessThanEqualTreeNode.java 2009-08-21
18:21:48 UTC (rev 15266)
@@ -0,0 +1,41 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.cdk.parser.el.node;
+
+import org.jboss.el.parser.Node;
+/**
+ * This class extend AbstractTreeNode and wrap AstLessThanEqual node.
+ *
+ * @author amarkhel
+ *
+ */
+public class AstLessThanEqualTreeNode extends AbstractBooleanTreeNode{
+
+ public AstLessThanEqualTreeNode(Node node) {
+ super(node);
+ }
+
+ @Override
+ public String getDelimiter() {
+ return ELNodeConstants.LESS_THEN_EQUAL;
+ }
+
+}
Property changes on:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstLessThanEqualTreeNode.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstLessThanTreeNode.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstLessThanTreeNode.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstLessThanTreeNode.java 2009-08-21
18:21:48 UTC (rev 15266)
@@ -0,0 +1,41 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.cdk.parser.el.node;
+
+import org.jboss.el.parser.Node;
+/**
+ * This class extend AbstractTreeNode and wrap AstLessThan node.
+ *
+ * @author amarkhel
+ *
+ */
+public class AstLessThanTreeNode extends AbstractBooleanTreeNode{
+
+ public AstLessThanTreeNode(Node node) {
+ super(node);
+ }
+
+ @Override
+ public String getDelimiter() {
+ return ELNodeConstants.LESS_THEN;
+ }
+
+}
Property changes on:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstLessThanTreeNode.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstLiteralTreeNode.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstLiteralTreeNode.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstLiteralTreeNode.java 2009-08-21
18:21:48 UTC (rev 15266)
@@ -0,0 +1,50 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.cdk.parser.el.node;
+
+import java.util.Map;
+
+import org.jboss.el.parser.Node;
+import org.richfaces.cdk.parser.el.ELVisitor;
+import org.richfaces.cdk.parser.el.ParsingException;
+import org.richfaces.cdk.parser.el.StringUtils;
+/**
+ * This class extend AbstractTreeNode and wrap AstLiteral node.
+ *
+ * @author amarkhel
+ *
+ */
+public class AstLiteralTreeNode extends AbstractTreeNode{
+
+ public AstLiteralTreeNode(Node node) {
+ super(node);
+ }
+
+ @Override
+ public void visit(StringBuilder sb, Map<String, Class<?>> context, ELVisitor
visitor) throws ParsingException {
+ if (getNode().getImage() != null) {
+ sb.append(ELNodeConstants.QUOTE);
+ sb.append(StringUtils.getEscapedString(getNode().getImage()));
+ sb.append(ELNodeConstants.QUOTE);
+ }
+ }
+
+}
Property changes on:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstLiteralTreeNode.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstMethodSuffixTreeNode.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstMethodSuffixTreeNode.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstMethodSuffixTreeNode.java 2009-08-21
18:21:48 UTC (rev 15266)
@@ -0,0 +1,61 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.cdk.parser.el.node;
+
+import java.util.Map;
+
+import org.jboss.el.parser.Node;
+import org.richfaces.cdk.parser.el.ELVisitor;
+import org.richfaces.cdk.parser.el.ParsingException;
+/**
+ * This class extend AbstractTreeNode and wrap AstMethodSuffix node.
+ *
+ * @author amarkhel
+ *
+ */
+public class AstMethodSuffixTreeNode extends AbstractTreeNode{
+
+ public AstMethodSuffixTreeNode(Node node) {
+ super(node);
+ }
+
+ @Override
+ public void visit(StringBuilder sb, Map<String, Class<?>> context, ELVisitor
visitor) throws ParsingException {
+ StringBuilder sb1 = new StringBuilder();
+ sb1.append(getNode().getImage());
+ sb1.append(ELNodeConstants.LEFT_BRACKET);
+ int numChildren = getNode().jjtGetNumChildren();
+ for (int k = 0; k < numChildren; k++) {
+ StringBuilder sb2 = new StringBuilder();
+ ITreeNode treeNode = getChild(k);
+ treeNode.visit(sb2, context, visitor);
+ sb1.append(sb2);
+ if (k == numChildren - 1) {
+ //Do nothing. Last argument.
+ } else {
+ sb1.append(ELNodeConstants.COMMA);
+ }
+ }
+ sb1.append(ELNodeConstants.RIGHT_BRACKET);
+ sb.append(sb1);
+ }
+
+}
Property changes on:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstMethodSuffixTreeNode.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstMinusTreeNode.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstMinusTreeNode.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstMinusTreeNode.java 2009-08-21
18:21:48 UTC (rev 15266)
@@ -0,0 +1,41 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.cdk.parser.el.node;
+
+import org.jboss.el.parser.Node;
+/**
+ * This class extend AbstractTreeNode and wrap AstMinus node.
+ *
+ * @author amarkhel
+ *
+ */
+public class AstMinusTreeNode extends AbstractArithmeticTreeNode {
+
+ public AstMinusTreeNode(Node node) {
+ super(node);
+ }
+
+ @Override
+ public String getOperator() {
+ return ELNodeConstants.MINUS_SIGN;
+ }
+
+}
Property changes on:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstMinusTreeNode.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstModTreeNode.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstModTreeNode.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstModTreeNode.java 2009-08-21
18:21:48 UTC (rev 15266)
@@ -0,0 +1,41 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.cdk.parser.el.node;
+
+import org.jboss.el.parser.Node;
+/**
+ * This class extend AbstractTreeNode and wrap AstMod node.
+ *
+ * @author amarkhel
+ *
+ */
+public class AstModTreeNode extends AbstractArithmeticTreeNode {
+
+ public AstModTreeNode(Node node) {
+ super(node);
+ }
+
+ @Override
+ public String getOperator() {
+ return ELNodeConstants.MOD_SIGN;
+ }
+
+}
Property changes on:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstModTreeNode.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstMultTreeNode.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstMultTreeNode.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstMultTreeNode.java 2009-08-21
18:21:48 UTC (rev 15266)
@@ -0,0 +1,41 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.cdk.parser.el.node;
+
+import org.jboss.el.parser.Node;
+/**
+ * This class extend AbstractTreeNode and wrap AstMult node.
+ *
+ * @author amarkhel
+ *
+ */
+public class AstMultTreeNode extends AbstractArithmeticTreeNode{
+
+ public AstMultTreeNode(Node node) {
+ super(node);
+ }
+
+ @Override
+ public String getOperator() {
+ return ELNodeConstants.MULT_SIGN;
+ }
+
+}
Property changes on:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstMultTreeNode.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstNegativeTreeNode.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstNegativeTreeNode.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstNegativeTreeNode.java 2009-08-21
18:21:48 UTC (rev 15266)
@@ -0,0 +1,50 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.cdk.parser.el.node;
+
+import java.util.Map;
+
+import org.jboss.el.parser.Node;
+import org.richfaces.cdk.parser.el.ELVisitor;
+import org.richfaces.cdk.parser.el.ParsingException;
+/**
+ * This class extend AbstractTreeNode and wrap AstNegative node.
+ *
+ * @author amarkhel
+ *
+ */
+public class AstNegativeTreeNode extends AbstractTreeNode {
+
+ public AstNegativeTreeNode(Node node) {
+ super(node);
+ }
+
+ @Override
+ public void visit(StringBuilder sb, Map<String, Class<?>> context, ELVisitor
visitor)
+ throws ParsingException {
+ ITreeNode node = getChild(0);
+ StringBuilder sb1 = new StringBuilder();
+ sb.append(ELNodeConstants.NEGATIVE);
+ node.visit(sb1, context, visitor);
+ sb.append(sb1);
+ }
+
+}
Property changes on:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstNegativeTreeNode.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstNotEqualTreeNode.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstNotEqualTreeNode.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstNotEqualTreeNode.java 2009-08-21
18:21:48 UTC (rev 15266)
@@ -0,0 +1,41 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.cdk.parser.el.node;
+
+import org.jboss.el.parser.Node;
+/**
+ * This class extend AbstractTreeNode and wrap AstNotEqual node.
+ *
+ * @author amarkhel
+ *
+ */
+public class AstNotEqualTreeNode extends AbstractBooleanTreeNode{
+
+ public AstNotEqualTreeNode(Node node) {
+ super(node);
+ }
+
+ @Override
+ public String getDelimiter() {
+ return ELNodeConstants.NOT_EQUAL;
+ }
+
+}
Property changes on:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstNotEqualTreeNode.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstNotTreeNode.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstNotTreeNode.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstNotTreeNode.java 2009-08-21
18:21:48 UTC (rev 15266)
@@ -0,0 +1,51 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.cdk.parser.el.node;
+
+import java.util.Map;
+
+import org.jboss.el.parser.Node;
+import org.richfaces.cdk.parser.el.ELVisitor;
+import org.richfaces.cdk.parser.el.ParsingException;
+/**
+ * This class extend AbstractTreeNode and wrap AstNot node.
+ *
+ * @author amarkhel
+ *
+ */
+public class AstNotTreeNode extends AbstractTreeNode{
+
+ public AstNotTreeNode(Node node) {
+ super(node);
+ }
+
+ @Override
+ public void visit(StringBuilder sb, Map<String, Class<?>> context, ELVisitor
visitor) throws ParsingException {
+ StringBuilder sb1 = new StringBuilder();
+ ITreeNode node1 = getChild(0);
+ node1.visit(sb1, context, visitor);
+ sb.append(ELNodeConstants.LEFT_BRACKET);
+ sb.append(ELNodeConstants.EXCLAMATION_MARK);
+ sb.append(sb1);
+ sb.append(ELNodeConstants.RIGHT_BRACKET);
+ }
+
+}
Property changes on:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstNotTreeNode.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstNullTreeNode.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstNullTreeNode.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstNullTreeNode.java 2009-08-21
18:21:48 UTC (rev 15266)
@@ -0,0 +1,46 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.cdk.parser.el.node;
+
+import java.util.Map;
+
+import org.jboss.el.parser.Node;
+import org.richfaces.cdk.parser.el.ELVisitor;
+import org.richfaces.cdk.parser.el.ParsingException;
+/**
+ * This class extend AbstractTreeNode and wrap AstNull node.
+ *
+ * @author amarkhel
+ *
+ */
+public class AstNullTreeNode extends AbstractTreeNode {
+
+ public AstNullTreeNode(Node node) {
+ super(node);
+ }
+
+ @Override
+ public void visit(StringBuilder sb, Map<String, Class<?>> context, ELVisitor
visitor)
+ throws ParsingException {
+ sb.append(ELNodeConstants.NULL);
+ }
+
+}
Property changes on:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstNullTreeNode.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstOrTreeNode.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstOrTreeNode.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstOrTreeNode.java 2009-08-21
18:21:48 UTC (rev 15266)
@@ -0,0 +1,41 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.cdk.parser.el.node;
+
+import org.jboss.el.parser.Node;
+/**
+ * This class extend AbstractTreeNode and wrap AstOr node.
+ *
+ * @author amarkhel
+ *
+ */
+public class AstOrTreeNode extends AbstractBooleanTreeNode{
+
+ public AstOrTreeNode(Node node) {
+ super(node);
+ }
+
+ @Override
+ public String getDelimiter() {
+ return ELNodeConstants.OR;
+ }
+
+}
Property changes on:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstOrTreeNode.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstPlusTreeNode.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstPlusTreeNode.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstPlusTreeNode.java 2009-08-21
18:21:48 UTC (rev 15266)
@@ -0,0 +1,41 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.cdk.parser.el.node;
+
+import org.jboss.el.parser.Node;
+/**
+ * This class extend AbstractTreeNode and wrap AstPlus node.
+ *
+ * @author amarkhel
+ *
+ */
+public class AstPlusTreeNode extends AbstractArithmeticTreeNode {
+
+ public AstPlusTreeNode(Node node) {
+ super(node);
+ }
+
+ @Override
+ public String getOperator() {
+ return ELNodeConstants.PLUS_SIGN;
+ }
+
+}
Property changes on:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstPlusTreeNode.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstPropertySuffixTreeNode.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstPropertySuffixTreeNode.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstPropertySuffixTreeNode.java 2009-08-21
18:21:48 UTC (rev 15266)
@@ -0,0 +1,54 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.cdk.parser.el.node;
+
+import java.util.Map;
+
+import org.jboss.el.parser.Node;
+import org.richfaces.cdk.parser.el.ELReflectionUtils;
+import org.richfaces.cdk.parser.el.ELVisitor;
+import org.richfaces.cdk.parser.el.ParsingException;
+/**
+ * This class extend AbstractTreeNode and wrap AstPropertySuffix node.
+ *
+ * @author amarkhel
+ *
+ */
+public class AstPropertySuffixTreeNode extends AbstractTreeNode {
+
+ public AstPropertySuffixTreeNode(Node node) {
+ super(node);
+ }
+
+ @Override
+ public void visit(StringBuilder sb, Map<String, Class<?>> context, ELVisitor
visitor) throws ParsingException {
+ String propertyName = getNode().getImage();
+ if (visitor.getLastVariableType() != null) {
+ StringBuilder sb1 = new StringBuilder();
+ sb1.append(ELReflectionUtils.getReadMethodName(propertyName, visitor));
+ sb1.append(ELNodeConstants.LEFT_BRACKET);
+ sb1.append(ELNodeConstants.RIGHT_BRACKET);
+ sb.append(sb1);
+ } else{
+ throw new ParsingException("Property not found: " + propertyName);
+ }
+ }
+}
\ No newline at end of file
Property changes on:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstPropertySuffixTreeNode.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstStringTreeNode.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstStringTreeNode.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstStringTreeNode.java 2009-08-21
18:21:48 UTC (rev 15266)
@@ -0,0 +1,48 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.cdk.parser.el.node;
+
+import java.util.Map;
+
+import org.jboss.el.parser.AstString;
+import org.jboss.el.parser.Node;
+import org.richfaces.cdk.parser.el.ELVisitor;
+import org.richfaces.cdk.parser.el.ParsingException;
+/**
+ * This class extend AbstractTreeNode and wrap AstString node.
+ *
+ * @author amarkhel
+ *
+ */
+public class AstStringTreeNode extends AbstractTreeNode {
+
+ public AstStringTreeNode(Node node) {
+ super(node);
+ }
+
+ @Override
+ public void visit(StringBuilder sb, Map<String, Class<?>> context, ELVisitor
visitor) throws ParsingException {
+ sb.append(ELNodeConstants.QUOTE);
+ sb.append(((AstString)getNode()).getString());
+ sb.append(ELNodeConstants.QUOTE);
+ }
+
+}
Property changes on:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstStringTreeNode.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstTrueTreeNode.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstTrueTreeNode.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstTrueTreeNode.java 2009-08-21
18:21:48 UTC (rev 15266)
@@ -0,0 +1,46 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.cdk.parser.el.node;
+
+import java.util.Map;
+
+import org.jboss.el.parser.Node;
+import org.richfaces.cdk.parser.el.ELVisitor;
+import org.richfaces.cdk.parser.el.ParsingException;
+/**
+ * This class extend AbstractTreeNode and wrap AstTrue node.
+ *
+ * @author amarkhel
+ *
+ */
+public class AstTrueTreeNode extends AbstractTreeNode{
+
+ public AstTrueTreeNode(Node node) {
+ super(node);
+ }
+
+ @Override
+ public void visit(StringBuilder sb, Map<String, Class<?>> context, ELVisitor
visitor)
+ throws ParsingException {
+ sb.append(ELNodeConstants.TRUE);
+ }
+
+}
Property changes on:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstTrueTreeNode.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstValueTreeNode.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstValueTreeNode.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstValueTreeNode.java 2009-08-21
18:21:48 UTC (rev 15266)
@@ -0,0 +1,67 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.cdk.parser.el.node;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.jboss.el.parser.Node;
+import org.richfaces.cdk.parser.el.ELVisitor;
+import org.richfaces.cdk.parser.el.ParsingException;
+/**
+ * This class extend AbstractTreeNode and wrap AstValue node.
+ *
+ * @author amarkhel
+ *
+ */
+public class AstValueTreeNode extends AbstractTreeNode {
+
+ public AstValueTreeNode(Node node) {
+ super(node);
+ }
+
+ @Override
+ public void visit(StringBuilder sb, Map<String, Class<?>> context, ELVisitor
visitor) throws ParsingException {
+ List<String> tokens = new ArrayList<String>();
+ visitor.setValueHandled();
+ for (int i = 0; i < getNode().jjtGetNumChildren(); i++) {
+ StringBuilder sb1 = new StringBuilder();
+ ITreeNode subChild = getChild(i);
+ subChild.visit(sb1, context, visitor);
+ tokens.add(sb1.toString());
+ }
+ if (tokens.size() != 0) {
+ StringBuilder sb2 = new StringBuilder();
+ for (String element : tokens) {
+ if (sb2.length() != 0 &&
!element.startsWith(ELNodeConstants.LEFT_SQUARE_BRACKET)) {
+ sb2.append(ELNodeConstants.DOT);
+ }
+ sb2.append(element);
+ }
+ sb.append(sb2);
+ } else {
+ sb.append(visitor.getLastIndexValue());
+ }
+ visitor.unSetValueHandled();
+ visitor.reset();
+ }
+}
Property changes on:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstValueTreeNode.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/ELNodeConstants.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/ELNodeConstants.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/ELNodeConstants.java 2009-08-21
18:21:48 UTC (rev 15266)
@@ -0,0 +1,68 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.cdk.parser.el.node;
+
+public class ELNodeConstants {
+
+ public static final String RIGHT_BRACKET = ")";
+ public static final String LEFT_BRACKET = "(";
+ public static final String LEFT_SQUARE_BRACKET = "[";
+ public static final String DOT = ".";
+ public static final String TRUE = "true";
+ public static final String QUOTE = "\"";
+ public static final String RIGHT_SQUARE_BRACKET = "]";
+ public static final String ARRAY_INDICATOR = "[L";
+ public static final String GET_FUNCTION = "get";
+ public static final String COMMA = ",";
+ public static final String GET_ELELMENT_BY_INDEX_FUNCTION =
"getElelmentByIndex";
+ public static final String JAVA_UTIL_MAP = "java.util.Map";
+ public static final String JAVA_UTIL_LIST = "java.util.List";
+ public static final String PLUS_SIGN = " + ";
+ public static final String OR = " || ";
+ public static final String NULL = "null";
+ public static final String EXCLAMATION_MARK = "!";
+ public static final String NOT_EQUAL = " != ";
+ public static final String NEGATIVE = "-";
+ public static final String MULT_SIGN = " * ";
+ public static final String MOD_SIGN = " % ";
+ public static final String MINUS_SIGN = " - ";
+ public static final String LESS_THEN = " < ";
+ public static final String LESS_THEN_EQUAL = " <= ";
+ public static final String VARIABLES_GET_VARIABLE_FUNCTION =
"variables.getVariable";
+ public static final String GREAT_THEN = " > ";
+ public static final String GREAT_THEN_EQUAL = " >= ";
+ public static final String THIS_PREFIX = "this";
+ public static final String DOUBLE_VALUE_OF_FUNCTION = "Double.valueOf";
+ public static final String FALSE = "false";
+ public static final String EQUAL = " == ";
+ public static final String THIS_GET_UTILS_IS_EMPTY_FUNCTION =
"this.getUtils().isEmpty";
+ public static final String DIV_OPERATOR = " / ";
+ public static final String CONVERT_TO_STRING_FUNCTION = "convertToString";
+ public static final String COLON = " : ";
+ public static final String QUESTION_SIGN = " ? ";
+ public static final String AND_DELIMITER = " && ";
+ public static final String UTILS_PREFIX = "utils";
+ public static final String GET_UTILS_FUNCTION = "getUtils";
+
+ private ELNodeConstants(){
+
+ }
+}
Property changes on:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/ELNodeConstants.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/ITreeNode.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/ITreeNode.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/ITreeNode.java 2009-08-21
18:21:48 UTC (rev 15266)
@@ -0,0 +1,63 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.cdk.parser.el.node;
+
+import java.util.Map;
+
+import org.jboss.el.parser.Node;
+import org.richfaces.cdk.parser.el.ELVisitor;
+import org.richfaces.cdk.parser.el.ParsingException;
+
+/**
+ * Interface for all wrappers of org.jboss.el.parser.Node class.
+ * @author amarkhel
+ *
+ */
+
+public interface ITreeNode {
+
+ /**
+ * Return node of current wrapper.
+ * @return instance of org.jboss.el.parser.Node
+ *
+ */
+ Node getNode();
+
+ /**
+ * Visit current node. Generate Java code, that represent current node.
+ * @param stringBuilder instance to collect information.
+ * @param context - context to resolve beans
+ * @param visitor - ELVisitor
+ * @throws ParsingException - if error occurred during parsing process.
+ * @return instance of org.jboss.el.parser.Node
+ *
+ */
+ void visit(StringBuilder sb, Map<String, Class<?>> context, ELVisitor
visitor) throws ParsingException;
+
+ /**
+ * Return child of wrapped node by specified index
+ * @param index - index of child.
+ * @throws ParsingException - if error occurred(child not found).
+ * @return wrapper for child
+ *
+ */
+ ITreeNode getChild(int index) throws ParsingException;
+}
Property changes on:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/ITreeNode.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/parser/el/test/Bean.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/parser/el/test/Bean.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/parser/el/test/Bean.java 2009-08-21
18:21:48 UTC (rev 15266)
@@ -0,0 +1,93 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.cdk.parser.el.test;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class Bean {
+
+ public Bean(){
+ facets = new HashMap<String, UIComponent>();
+ UIComponent value = new UIComponent();
+ facets.put("header", value);
+ components = new ArrayList<UIComponent>();
+ components.add(value);
+ }
+
+ private boolean readOnly;
+
+ private Map<String, UIComponent> facets;
+
+ private List<UIComponent> components;
+
+ private Bean2 testBean2;
+
+ private UIComponent[] array = new UIComponent[]{
+ new UIComponent()
+ };
+
+ public Bean2 getTestBean2() {
+ return testBean2;
+ }
+
+ public void setTestBean2(Bean2 testBean2) {
+ this.testBean2 = testBean2;
+ }
+
+ public void test(UIComponent comp, boolean test){
+
+ }
+
+ public UIComponent[] getArray() {
+ return array;
+ }
+
+ public void setArray(UIComponent[] array) {
+ this.array = array;
+ }
+
+ public List<UIComponent> getComponents() {
+ return components;
+ }
+
+ public void setComponents(List<UIComponent> components) {
+ this.components = components;
+ }
+
+ public Map<String, UIComponent> getFacets() {
+ return facets;
+ }
+
+ public void setFacets(Map<String, UIComponent> facets) {
+ this.facets = facets;
+ }
+
+ public boolean isReadOnly() {
+ return readOnly;
+ }
+
+ public void setReadOnly(boolean readOnly) {
+ this.readOnly = readOnly;
+ }
+}
Property changes on:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/parser/el/test/Bean.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/parser/el/test/Bean2.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/parser/el/test/Bean2.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/parser/el/test/Bean2.java 2009-08-21
18:21:48 UTC (rev 15266)
@@ -0,0 +1,34 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.cdk.parser.el.test;
+
+public class Bean2 {
+
+ private String string;
+
+ public String getString() {
+ return string;
+ }
+
+ public void setString(String string) {
+ this.string = string;
+ }
+}
Property changes on:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/parser/el/test/Bean2.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/parser/el/test/ELParserTest.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/parser/el/test/ELParserTest.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/parser/el/test/ELParserTest.java 2009-08-21
18:21:48 UTC (rev 15266)
@@ -0,0 +1,286 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.cdk.parser.el.test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.Test;
+import org.richfaces.cdk.parser.el.ELVisitor;
+import org.richfaces.cdk.parser.el.ParsingException;
+
+public class ELParserTest {
+
+ @Test
+ public void testNull() throws Exception {
+ assertEquals(resolveExpression("#{null}"), "null");
+ }
+
+ @Test
+ public void testTrue() throws Exception {
+ assertEquals(resolveExpression("#{true}"), "true");
+ }
+
+ @Test
+ public void testFalse() throws Exception {
+ assertEquals(resolveExpression("#{false}"), "false");
+ }
+
+ @Test
+ public void testFloat() throws Exception {
+ assertEquals(resolveExpression("#{5.0}"), "Double.valueOf(5.0)");
+ }
+
+ @Test
+ public void testNegative() throws Exception {
+ assertEquals(resolveExpression("#{-5}"), "-5");
+ }
+
+ @Test
+ public void testNegativeFloat() throws Exception {
+ assertEquals(resolveExpression("#{-5.0}"),
"-Double.valueOf(5.0)");
+ }
+
+ @Test
+ public void testNotEqual() throws Exception {
+ assertEquals(resolveExpression("#{1 ne 3}"), "(1 != 3)");
+ assertEquals(resolveExpression("#{1 != 3}"), "(1 != 3)");
+ }
+
+ @Test
+ public void testNot() throws Exception {
+ assertEquals(resolveExpression("#{not 1}"), "(!1)");
+ assertEquals(resolveExpression("#{!1}"), "(!1)");
+ }
+
+ @Test
+ public void testPlus() throws Exception {
+ assertEquals(resolveExpression("#{1+2}"), "(1 + 2)");
+ }
+
+ @Test
+ public void testMinus() throws Exception {
+ assertEquals(resolveExpression("#{1-2}"), "(1 - 2)");
+ }
+
+ @Test
+ public void testDiv() throws Exception {
+ assertEquals(resolveExpression("#{1/2}"), "(1 / 2)");
+ }
+
+ @Test
+ public void testMult() throws Exception {
+ assertEquals(resolveExpression("#{1*2}"), "(1 * 2)");
+ }
+
+ @Test
+ public void testMod() throws Exception {
+ assertEquals(resolveExpression("#{1%2}"), "(1 % 2)");
+ }
+
+ @Test
+ public void testAnd() throws Exception {
+ assertEquals(resolveExpression("#{1 and 2}"), "(1 && 2)");
+ assertEquals(resolveExpression("#{1 && 2}"), "(1 &&
2)");
+ }
+
+ @Test
+ public void testOr() throws Exception {
+ assertEquals(resolveExpression("#{1 or 2}"), "(1 || 2)");
+ assertEquals(resolveExpression("#{1 || 2}"), "(1 || 2)");
+ }
+
+ @Test
+ public void testEquals() throws Exception {
+ assertEquals(resolveExpression("#{1 eq 2}"), "(1 == 2)");
+ assertEquals(resolveExpression("#{1 == 2}"), "(1 == 2)");
+ }
+
+ @Test
+ public void testGreatThen() throws Exception {
+ assertEquals(resolveExpression("#{1 gt 2}"), "(1 > 2)");
+ assertEquals(resolveExpression("#{1 > 2}"), "(1 > 2)");
+ }
+
+ @Test
+ public void testLessThen() throws Exception {
+ assertEquals(resolveExpression("#{1 lt 2}"), "(1 < 2)");
+ assertEquals(resolveExpression("#{1 < 2}"), "(1 < 2)");
+ }
+
+ @Test
+ public void testLessThenEquals() throws Exception {
+ assertEquals(resolveExpression("#{1 le 2}"), "(1 <= 2)");
+ assertEquals(resolveExpression("#{1 <= 2}"), "(1 <= 2)");
+ }
+
+ @Test
+ public void testGreatThenEquals() throws Exception {
+ assertEquals(resolveExpression("#{1 ge 2}"), "(1 >= 2)");
+ assertEquals(resolveExpression("#{1 >= 2}"), "(1 >= 2)");
+ }
+
+ @Test
+ public void testChoice() throws Exception {
+ assertEquals(resolveExpression("#{1 ? 2 : 3}"), "(1 ? 2 : 3)");
+ }
+
+ @Test
+ public void testInteger() throws Exception {
+ assertEquals(resolveExpression("#{152}"), "152");
+ }
+
+ @Test
+ public void testString() throws Exception {
+ assertEquals(resolveExpression("#{'nabc'}"),
"\"nabc\"");
+ assertEquals(resolveExpression("#{'\tabc'}"),
"\" abc\"");
+ assertEquals(resolveExpression("#{'/nabc'}"),
"\"/nabc\"");
+ }
+
+ @Test
+ public void testIdentifier() throws Exception {
+ assertEquals(resolveExpression("#{clientId}"),
"variables.getVariable(\"clientId\")");
+ }
+
+ @Test
+ public void testLiteral() throws Exception {
+ assertEquals(resolveExpression("clientId"),
"\"clientId\"");
+ }
+
+ @Test
+ public void testMethodReturnMap() throws Exception {
+ assertEquals(resolveExpression("#{action.facets}"),
"action.getFacets()");
+ }
+
+ @Test
+ public void testMethodReturnMapElement() throws Exception {
+ assertEquals(resolveExpression("#{action.facets['header']}"),
"action.getFacets().get(\"header\")");
+ }
+
+ @Test
+ public void testMethodReturnMapElement2() throws Exception {
+ assertEquals(resolveExpression("#{action.facets['header'].rendered}"),
"action.getFacets().get(\"header\").isRendered()");
+ }
+
+ @Test
+ public void testMethod() throws Exception {
+ assertEquals(resolveExpression("#{action.readOnly}"),
"action.isReadOnly()");
+ }
+
+ @Test
+ public void testNestedMethod() throws Exception {
+ assertEquals(resolveExpression("#{action.testBean2.string}"),
"action.getTestBean2().getString()");
+ }
+
+ @Test
+ public void testMethodReturnList() throws Exception {
+ assertEquals(resolveExpression("#{action.components}"),
"action.getComponents()");
+ }
+
+ @Test
+ public void testMethodReturnListElement() throws Exception {
+ assertEquals(resolveExpression("#{action.components[0]}"),
"action.getComponents().get(0)");
+ }
+
+ @Test
+ public void testMethodReturnListElement2() throws Exception {
+ assertEquals(resolveExpression("#{action.components[0].rendered}"),
"action.getComponents().get(0).isRendered()");
+ }
+
+ @Test
+ public void testMethodReturnArray() throws Exception {
+ assertEquals(resolveExpression("#{action.array}"),
"action.getArray()");
+ }
+
+ @Test
+ public void testMethodReturnArrayElement() throws Exception {
+ assertEquals(resolveExpression("#{action.array[0]}"),
"action.getArray()[0]");
+ }
+
+ @Test
+ public void testMethodWithParam() throws Exception {
+ assertEquals(resolveExpression("#{getType(action.array[0].rendered,
action.readOnly, true)}"),
"this.getType(action.getArray()[0].isRendered(),action.isReadOnly(),true)");
+ }
+
+ @Test
+ public void testEmpty() throws Exception {
+ assertEquals(resolveExpression("#{empty action.array}"),
"this.getUtils().isEmpty(action.getArray())");
+ }
+
+ @Test
+ public void testFunction() throws Exception {
+ assertEquals(resolveExpression("#{getType()}"), "this.getType()");
+ }
+
+ @Test
+ public void testLiteralWithDeferred() throws Exception {
+ assertEquals(resolveExpression("abs #{getType()}"), "\"abs \"
+ convertToString(this.getType())");
+ }
+
+ @Test
+ public void testLiteralWithDeferred2() throws Exception {
+ assertEquals(resolveExpression("#{getType()} abs "), "this.getType() +
\" abs \"");
+ }
+
+ @Test
+ public void testThisFunction() throws Exception {
+ assertEquals(resolveExpression("#{this.getType()}"),
"this.getType()");
+ }
+
+ @Test
+ public void testUtilsFunction() throws Exception {
+ assertEquals(resolveExpression("#{utils.getType()}"),
"this.getUtils().getType()");
+ }
+
+ @Test
+ public void testWrongExpression() throws Exception {
+ try{
+ resolveExpression("#{bean.property}");
+ fail("Parsing Exception is not thrown");
+ }catch(ParsingException pe){
+ assertEquals(pe.getMessage(), "No instance found in context for identifier
bean");
+ }
+
+ }
+
+ @Test
+ public void testWrongExpression2() throws Exception {
+ try{
+ resolveExpression("#{action.property}");
+ fail("Parsing Exception is not thrown");
+ }catch(ParsingException pe){
+ assertEquals(pe.getMessage(), "property: property not found in class: class
org.richfaces.cdk.parser.el.test.Bean");
+ }
+
+ }
+
+ private static String resolveExpression(String expression) throws ParsingException{
+
+ Map<String, Class<?>> contextMap = new HashMap<String,
Class<?>>();
+ contextMap.put("action", org.richfaces.cdk.parser.el.test.Bean.class);
+ String code = ELVisitor.getInstance().parse(expression, contextMap);
+ return code;
+ }
+
+}
Property changes on:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/parser/el/test/ELParserTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/parser/el/test/UIComponent.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/parser/el/test/UIComponent.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/parser/el/test/UIComponent.java 2009-08-21
18:21:48 UTC (rev 15266)
@@ -0,0 +1,35 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.cdk.parser.el.test;
+
+public class UIComponent {
+
+ private boolean rendered;
+
+ public boolean isRendered() {
+ return rendered;
+ }
+
+ public void setRendered(boolean rendered) {
+ this.rendered = rendered;
+ }
+
+}
Property changes on:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/parser/el/test/UIComponent.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native