JBoss Rich Faces SVN: r15275 - branches/community/3.3.X/test-applications/richfaces-docs.
by richfaces-svn-commits@lists.jboss.org
Author: msorokin
Date: 2009-08-24 09:37:39 -0400 (Mon, 24 Aug 2009)
New Revision: 15275
Modified:
branches/community/3.3.X/test-applications/richfaces-docs/pom.xml
Log:
added repositories
Modified: branches/community/3.3.X/test-applications/richfaces-docs/pom.xml
===================================================================
--- branches/community/3.3.X/test-applications/richfaces-docs/pom.xml 2009-08-24 12:45:22 UTC (rev 15274)
+++ branches/community/3.3.X/test-applications/richfaces-docs/pom.xml 2009-08-24 13:37:39 UTC (rev 15275)
@@ -20,6 +20,61 @@
</plugins>
</build>
+ <pluginRepositories>
+ <pluginRepository>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ <snapshots>
+ <enabled>false</enabled>
+ <updatePolicy>never</updatePolicy>
+ </snapshots>
+ <id>repository.jboss.com</id>
+ <name>Jboss Repository for Maven</name>
+ <url>http://repository.jboss.com/maven2/</url>
+ <layout>default</layout>
+ </pluginRepository>
+ <pluginRepository>
+ <releases>
+ <enabled>false</enabled>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ <id>snapshots.jboss.org</id>
+ <name>Jboss Snapshots Repository for Maven</name>
+ <url>http://snapshots.jboss.org/maven2/</url>
+ <layout>default</layout>
+ </pluginRepository>
+ </pluginRepositories>
+ <repositories>
+ <repository>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ <updatePolicy>always</updatePolicy>
+ </snapshots>
+ <id>snapshots.jboss.org</id>
+ <name>Snapshot Jboss Repository for Maven</name>
+ <url>http://snapshots.jboss.org/maven2/</url>
+ <layout>default</layout>
+ </repository>
+ <repository>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ <updatePolicy>always</updatePolicy>
+ </snapshots>
+ <id>repository.jboss.com</id>
+ <name>Jboss Repository for Maven</name>
+ <url>http://repository.jboss.com/maven2/</url>
+ <layout>default</layout>
+ </repository>
+ </repositories>
<dependencies>
<dependency>
15 years, 4 months
JBoss Rich Faces SVN: r15274 - in root: ui/trunk/components/core and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: Alex.Kolonitsky
Date: 2009-08-24 08:45:22 -0400 (Mon, 24 Aug 2009)
New Revision: 15274
Modified:
root/pom.xml
root/richfaces.xml
root/ui/trunk/components/core/pom.xml
Log:
Update 4.0 ALPHA1 assembler for new structure
https://jira.jboss.org/jira/browse/RF-7745
Modified: root/pom.xml
===================================================================
--- root/pom.xml 2009-08-24 12:28:20 UTC (rev 15273)
+++ root/pom.xml 2009-08-24 12:45:22 UTC (rev 15274)
@@ -49,7 +49,7 @@
<executions>
<execution>
<configuration>
- <finalName>richfaces-${version}.ALPHA1</finalName>
+ <finalName>richfaces-${version}</finalName>
<descriptor>richfaces.xml</descriptor>
</configuration>
<id>richfaces</id>
@@ -60,7 +60,7 @@
</execution>
<execution>
<configuration>
- <finalName>richfaces-examples-${version}.ALPHA1</finalName>
+ <finalName>richfaces-examples-${version}</finalName>
<descriptor>richfaces-examples.xml</descriptor>
</configuration>
<id>richfaces-examples</id>
Modified: root/richfaces.xml
===================================================================
--- root/richfaces.xml 2009-08-24 12:28:20 UTC (rev 15273)
+++ root/richfaces.xml 2009-08-24 12:45:22 UTC (rev 15274)
@@ -15,7 +15,7 @@
<includes>
<include>org.richfaces.framework:richfaces-api</include>
<include>org.richfaces.framework:richfaces-impl</include>
- <include>org.richfaces.ui:components</include>
+ <include>org.richfaces.ui.components:core-ui</include>
</includes>
<sources>
Modified: root/ui/trunk/components/core/pom.xml
===================================================================
--- root/ui/trunk/components/core/pom.xml 2009-08-24 12:28:20 UTC (rev 15273)
+++ root/ui/trunk/components/core/pom.xml 2009-08-24 12:45:22 UTC (rev 15274)
@@ -50,4 +50,50 @@
<scope>test</scope>
</dependency>
</dependencies>
+
+ <profiles>
+ <profile>
+ <id>release</id>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <version>2.2</version>
+ <configuration>
+ <javadocVersion>1.5</javadocVersion>
+ <aggregate>true</aggregate>
+ </configuration>
+ <executions>
+ <execution>
+ <id>generate-javadoc</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-source-plugin</artifactId>
+ <configuration>
+ <aggregate>true</aggregate>
+ </configuration>
+ <executions>
+ <execution>
+ <id>generate-source</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+
</project>
\ No newline at end of file
15 years, 4 months
JBoss Rich Faces SVN: r15273 - root/ui/trunk/components/core/src/main/java/org/ajax4jsf/facelets/tag.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2009-08-24 08:28:20 -0400 (Mon, 24 Aug 2009)
New Revision: 15273
Modified:
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/facelets/tag/AjaxHandler.java
Log:
remove un. imports
Modified: root/ui/trunk/components/core/src/main/java/org/ajax4jsf/facelets/tag/AjaxHandler.java
===================================================================
--- root/ui/trunk/components/core/src/main/java/org/ajax4jsf/facelets/tag/AjaxHandler.java 2009-08-24 11:13:26 UTC (rev 15272)
+++ root/ui/trunk/components/core/src/main/java/org/ajax4jsf/facelets/tag/AjaxHandler.java 2009-08-24 12:28:20 UTC (rev 15273)
@@ -1,10 +1,7 @@
package org.ajax4jsf.facelets.tag;
-import java.beans.BeanDescriptor;
-import java.beans.BeanInfo;
import java.io.IOException;
import java.util.Collection;
-import java.util.List;
import javax.el.ELContext;
import javax.el.MethodExpression;
@@ -15,9 +12,7 @@
import javax.faces.event.AbortProcessingException;
import javax.faces.event.AjaxBehaviorEvent;
import javax.faces.event.AjaxBehaviorListener;
-import javax.faces.view.AttachedObjectTarget;
import javax.faces.view.BehaviorHolderAttachedObjectHandler;
-import javax.faces.view.BehaviorHolderAttachedObjectTarget;
import javax.faces.view.facelets.BehaviorConfig;
import javax.faces.view.facelets.ComponentHandler;
import javax.faces.view.facelets.CompositeFaceletHandler;
@@ -121,18 +116,19 @@
}
-// private void applyWrapping(FaceletContext ctx, UIComponent parent, String eventName) throws IOException {
-// AjaxBehavior ajaxBehavior = createAjaxBehavior(ctx, eventName);
-//
-// FacesContext context = ctx.getFacesContext();
-// AjaxBehaviors ajaxBehaviors = AjaxBehaviors.getAjaxBehaviors(context, true);
-// ajaxBehaviors.pushBehavior(context, ajaxBehavior, eventName);
-//
-// nextHandler.apply(ctx, parent);
-//
-// ajaxBehaviors.popBehavior();
-// }
+/* private void applyWrapping(FaceletContext ctx, UIComponent parent, String eventName) throws IOException {
+ AjaxBehavior ajaxBehavior = createAjaxBehavior(ctx, eventName);
+
+ FacesContext context = ctx.getFacesContext();
+ AjaxBehaviors ajaxBehaviors = AjaxBehaviors.getAjaxBehaviors(context, true);
+ ajaxBehaviors.pushBehavior(context, ajaxBehavior, eventName);
+
+ nextHandler.apply(ctx, parent);
+
+ ajaxBehaviors.popBehavior();
+ } */
+
public void applyAttachedObject(FaceletContext fContext, UIComponent parent, String eventName) {
ClientBehaviorHolder bHolder = (ClientBehaviorHolder) parent;
if (null == eventName) {
15 years, 4 months
JBoss Rich Faces SVN: r15272 - root/ui/trunk/components/core/src/main/java/org/ajax4jsf/renderkit.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2009-08-24 07:13:26 -0400 (Mon, 24 Aug 2009)
New Revision: 15272
Modified:
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/AjaxBehaviorRenderer.java
Log:
add jsf scripts rendering
Modified: root/ui/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/AjaxBehaviorRenderer.java
===================================================================
--- root/ui/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/AjaxBehaviorRenderer.java 2009-08-24 10:51:33 UTC (rev 15271)
+++ root/ui/trunk/components/core/src/main/java/org/ajax4jsf/renderkit/AjaxBehaviorRenderer.java 2009-08-24 11:13:26 UTC (rev 15272)
@@ -25,6 +25,7 @@
*/
@FacesBehaviorRenderer(rendererType="org.ajax4jsf.behavior.Ajax",renderKitId=RenderKitFactory.HTML_BASIC_RENDER_KIT)
@ResourceDependencies({
+ @ResourceDependency(library = "javax.faces", name = "jsf.js"),
@ResourceDependency(name="jquery.js", target="head"),
@ResourceDependency(name="richfaces.js", target="head")
})
15 years, 4 months
JBoss Rich Faces SVN: r15271 - Reports/3.3.2 and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: tkuprevich
Date: 2009-08-24 06:51:33 -0400 (Mon, 24 Aug 2009)
New Revision: 15271
Added:
branches/community/3.3.X/test-applications/qa/Test Reports/3.3.2/RFTestReport3.3.2.CR1(08.17-21).xls
Log:
Added: branches/community/3.3.X/test-applications/qa/Test Reports/3.3.2/RFTestReport3.3.2.CR1(08.17-21).xls
===================================================================
(Binary files differ)
Property changes on: branches/community/3.3.X/test-applications/qa/Test Reports/3.3.2/RFTestReport3.3.2.CR1(08.17-21).xls
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
15 years, 4 months
JBoss Rich Faces SVN: r15270 - root/examples/trunk/richfaces-demo/src/main/webapp/images.
by richfaces-svn-commits@lists.jboss.org
Author: ilya_shaikovsky
Date: 2009-08-24 05:24:12 -0400 (Mon, 24 Aug 2009)
New Revision: 15270
Added:
root/examples/trunk/richfaces-demo/src/main/webapp/images/ai.gif
Log:
continue rf-demo
Added: root/examples/trunk/richfaces-demo/src/main/webapp/images/ai.gif
===================================================================
(Binary files differ)
Property changes on: root/examples/trunk/richfaces-demo/src/main/webapp/images/ai.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
15 years, 4 months
JBoss Rich Faces SVN: r15269 - in root/cdk/trunk/plugins: generator/src/main/java/org/richfaces/cdk and 10 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2009-08-21 20:42:50 -0400 (Fri, 21 Aug 2009)
New Revision: 15269
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkWorker.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/JAXBBinding.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ComponentAdapter.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ComponentBean.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/FacesConfigAdapter.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/FacesConfigBean.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/FacesConfigTest.java
root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/xmlconfig/component.xml
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/templates/RendererClassGenerator.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/AbstractCdkContext.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkContext.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/LibraryBuilder.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/ModelBuilder.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/ModelValidator.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/NamingConventions.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/RichFacesConventions.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/ValidatorImpl.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptBuilder.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/CdkProcessor.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ComponentProcessor.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ComponentClassGenerator.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/CdkEntityResolver.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FacesConfigParser.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FragmentParser.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/Properties.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/package-info.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/CdkTestBase.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/CdkProcessorTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/ComponentProcessorTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/freemarker/FreeMarkerRendererTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/CdkResolverTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/FragmentParserTest.java
root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/GenerateMojo.java
Log:
faces-config.xml parser implemented.
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/templates/RendererClassGenerator.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/templates/RendererClassGenerator.java 2009-08-21 18:45:20 UTC (rev 15268)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/templates/RendererClassGenerator.java 2009-08-22 00:42:50 UTC (rev 15269)
@@ -32,6 +32,7 @@
import org.richfaces.cdk.CdkContext;
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.CdkWriter;
+import org.richfaces.cdk.StandardOutputs;
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.Renderer;
import org.richfaces.cdk.model.RenderKit;
@@ -65,7 +66,7 @@
JavaClass javaClass = renderer.getTemplate();
String fullName = javaClass.getFullName();
- File outFile = new File(context.getJavaSourceOutput(),
+ File outFile = new File(context.getOutputFolder(StandardOutputs.RENDERER_CLASSES),
fullName.replace('.', '/') + ".java");
if (outFile.exists()) {
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/AbstractCdkContext.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/AbstractCdkContext.java 2009-08-21 18:45:20 UTC (rev 15268)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/AbstractCdkContext.java 2009-08-22 00:42:50 UTC (rev 15269)
@@ -43,73 +43,16 @@
private final ClassLoader loader;
- private File javaSource;
-
- private File javaSourceOutput;
-
- private File resourceOutput;
-
- private NamingConventions namingConventions;
-
private Map<SourceType, Iterable<File>> sources = Maps.newHashMap();
private Map<OutputType,File> outputs = Maps.newHashMap();
- private Map<SourceType,File> inputFolders = Maps.newHashMap();
+ private Map<SourceType,Iterable<File>> inputFolders = Maps.newHashMap();
+ private Map<Class<? extends CdkWorker>,CdkWorker> workers = Maps.newHashMap();
+
private List<CdkError> errors = Lists.newArrayList();
- /**
- * <p class="changed_added_4_0"></p>
- * @return the javaSource
- */
- @Override
- public File getJavaSource() {
- return javaSource;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @param javaSource the javaSource to set
- */
- public void setJavaSource(File javaSource) {
- this.javaSource = javaSource;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @return the javaSourceOutput
- */
- @Override
- public File getJavaSourceOutput() {
- return javaSourceOutput;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @param javaSourceOutput the javaSourceOutput to set
- */
- public void setJavaSourceOutput(File javaSourceOutput) {
- this.javaSourceOutput = javaSourceOutput;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @return the resourceOutput
- */
- @Override
- public File getResourceOutput() {
- return resourceOutput;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @param resourceOutput the resourceOutput to set
- */
- public void setResourceOutput(File resourceOutput) {
- this.resourceOutput = resourceOutput;
- }
-
public AbstractCdkContext(ClassLoader loader) {
this.loader = loader;
// TODO Auto-generated constructor stub
@@ -122,23 +65,6 @@
return loader;
}
- /**
- * <p class="changed_added_4_0"></p>
- * @return the namingConventions
- */
- @Override
- public NamingConventions getNamingConventions() {
- return namingConventions;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @param namingConventions the namingConventions to set
- */
- public void setNamingConventions(NamingConventions namingConventions) {
- this.namingConventions = namingConventions;
- }
-
public void addSources(SourceType type,Iterable<File> files) {
sources.put(type, files);
}
@@ -154,15 +80,53 @@
return outputFolder;
}
+
+ public void setOutputFolder(OutputType type, File folder) {
+ outputs.put(type, folder);
+ }
+
@Override
public void sendError(CdkError error) {
errors.add(error);
}
+
+ @Override
+ public Iterable<CdkError> getErrors() {
+ return errors;
+ }
+
@Override
- public File getSourceFolder(SourceType type) {
+ public Iterable<File> getSourceFolders(SourceType type) {
return inputFolders.get(type);
}
+
+ public void setSourceFolders(SourceType type, Iterable<File> folders){
+ inputFolders.put(type, folders);
+ }
+ @Override
+ public <W extends CdkWorker> W getWorkerInstance(Class<W> workerClass)
+ throws CdkException {
+ CdkWorker worker = workers.get(workerClass);
+ if(null == worker){
+ // TODO - instantiate worker.
+ try {
+ worker = workerClass.newInstance();
+ worker.init(this);
+ workers.put(workerClass, worker);
+ } catch (InstantiationException e) {
+ throw new CdkException("error to instantiate cdk component "+workerClass.getName(), e);
+ } catch (IllegalAccessException e) {
+ throw new CdkException("Illegal access to cdk component "+workerClass.getName(), e);
+ }
+ }
+ return (W) worker;
+ }
+
+
+ public <W extends CdkWorker> void addWorker(Class<W> workerClass, W worker) {
+ workers.put(workerClass, worker);
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkContext.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkContext.java 2009-08-21 18:45:20 UTC (rev 15268)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkContext.java 2009-08-22 00:42:50 UTC (rev 15269)
@@ -35,39 +35,6 @@
public ClassLoader getLoader();
/**
- * <p class="changed_added_4_0">
- * Output folder for generated resources.
- * </p>
- *
- * @return
- */
- public abstract File getResourceOutput();
-
- /**
- * <p class="changed_added_4_0">
- * Output folder for generated Java sources.
- * </p>
- *
- * @return
- */
- public abstract File getJavaSourceOutput();
-
- /**
- * <p class="changed_added_4_0">
- * Java source folder.
- * </p>
- *
- * @return
- */
- public abstract File getJavaSource();
-
- /**
- * <p class="changed_added_4_0"></p>
- * @return
- */
- public NamingConventions getNamingConventions();
-
- /**
* <p class="changed_added_4_0">Get all sources for given type.</p>
* @param type
* @return
@@ -76,13 +43,34 @@
/**
* <p class="changed_added_4_0">Provides default output folder for given output type.</p>
+ * TODO - define "output families" to group similar outputs ( classes, resources, tests ... ).
* @param type of output
* @return output folder for requested type.
*/
public File getOutputFolder(OutputType type);
+ /**
+ * <p class="changed_added_4_0">Record recowerable CdkError. To avoid consequence builds of the project with many errors, all non-fatal errors ( Java compilation errors, incorrect xml fales, inconsistent component descriptions ) these error are stored in the context and marks whole build failed.</p>
+ * @param error
+ */
public void sendError(CdkError error);
- public File getSourceFolder(SourceType type);
+ public abstract Iterable<CdkError> getErrors();
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param type
+ * @return
+ */
+ public Iterable<File> getSourceFolders(SourceType type);
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param <W>
+ * @param workerClass
+ * @return
+ * @throws CdkException
+ */
+ public <W extends CdkWorker> W getWorkerInstance(Class<W> workerClass) throws CdkException;
+
}
\ No newline at end of file
Added: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkWorker.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkWorker.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkWorker.java 2009-08-22 00:42:50 UTC (rev 15269)
@@ -0,0 +1,36 @@
+/*
+ * $Id$
+ *
+ * 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;
+
+/**
+ * <p class="changed_added_4_0">Interface for all CDK worker objects ( parsers, validators, renderers etc. ).
+ * Instances of these objects are stored in the {@link CdkContext}</p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public interface CdkWorker {
+
+ public void init(CdkContext context) throws CdkException;
+
+}
Property changes on: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkWorker.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/LibraryBuilder.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/LibraryBuilder.java 2009-08-21 18:45:20 UTC (rev 15268)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/LibraryBuilder.java 2009-08-22 00:42:50 UTC (rev 15269)
@@ -45,14 +45,14 @@
* @author asmirnov(a)exadel.com
*
*/
-public final class LibraryBuilder {
+public final class LibraryBuilder implements CdkWorker {
/**
* <p class="changed_added_4_0">
* Current CDK context
* </p>
*/
- private final CdkContext context;
+ private CdkContext context;
/**
* <p class="changed_added_4_0">
@@ -60,7 +60,12 @@
*
* @param context
*/
- LibraryBuilder(CdkContext context) {
+ public LibraryBuilder() {
+
+ }
+
+ @Override
+ public void init(CdkContext context) throws CdkException {
this.context = context;
}
@@ -70,9 +75,10 @@
* </p>
*
* @return
+ * @throws CdkException
*/
- public static LibraryBuilder createInstance(CdkContext context) {
- return new LibraryBuilder(context);
+ public static LibraryBuilder createInstance(CdkContext context) throws CdkException {
+ return context.getWorkerInstance(LibraryBuilder.class);
}
/**
@@ -194,8 +200,7 @@
return builder;
}
- protected ModelValidator getVerifier() {
- // TODO - put verifier implementation into context ?
- return new ValidatorImpl(getContext());
+ protected ModelValidator getVerifier() throws CdkException {
+ return getContext().getWorkerInstance(ModelValidator.class);
}
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/ModelBuilder.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/ModelBuilder.java 2009-08-21 18:45:20 UTC (rev 15268)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/ModelBuilder.java 2009-08-22 00:42:50 UTC (rev 15269)
@@ -30,13 +30,14 @@
* @author asmirnov(a)exadel.com
*
*/
-public interface ModelBuilder {
+public interface ModelBuilder extends CdkWorker {
/**
* <p class="changed_added_4_0">Initialize builder.</p>
* @param context
+ * @throws CdkException
*/
- public void init(CdkContext context);
+ public void init(CdkContext context) throws CdkException;
/**
* <p class="changed_added_4_0">Build library model.</p>
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/ModelValidator.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/ModelValidator.java 2009-08-21 18:45:20 UTC (rev 15268)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/ModelValidator.java 2009-08-22 00:42:50 UTC (rev 15269)
@@ -30,7 +30,7 @@
* @author asmirnov(a)exadel.com
*
*/
-public interface ModelValidator {
+public interface ModelValidator extends CdkWorker {
/**
* <p class="changed_added_4_0">Perform verify procedure on the library model.</p>
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/NamingConventions.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/NamingConventions.java 2009-08-21 18:45:20 UTC (rev 15268)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/NamingConventions.java 2009-08-22 00:42:50 UTC (rev 15269)
@@ -38,7 +38,7 @@
* @author asmirnov(a)exadel.com
*
*/
-public interface NamingConventions {
+public interface NamingConventions extends CdkWorker {
/**
* <p class="changed_added_4_0">Calculates component type from explicit value or base class name.</p>
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/RichFacesConventions.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/RichFacesConventions.java 2009-08-21 18:45:20 UTC (rev 15268)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/RichFacesConventions.java 2009-08-22 00:42:50 UTC (rev 15269)
@@ -25,6 +25,7 @@
* </p>
*/
private final String baseName;
+ private CdkContext context;
/**
@@ -36,6 +37,12 @@
}
+ @Override
+ public void init(CdkContext context) throws CdkException {
+ this.context = context;
+ }
+
+
private final String[] COMPONENT_SUFFIXES = { BASE };
private final String[] COMPONENT_PREFIXES = { UI, ABSTRACT };
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/ValidatorImpl.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/ValidatorImpl.java 2009-08-21 18:45:20 UTC (rev 15268)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/ValidatorImpl.java 2009-08-22 00:42:50 UTC (rev 15269)
@@ -39,10 +39,13 @@
*/
public class ValidatorImpl implements ModelValidator {
- private final CdkContext context;
+ private CdkContext context;
+
+ private NamingConventions namingConventions;
- public ValidatorImpl(CdkContext context) {
+ public void init(CdkContext context) throws CdkException {
this.context = context;
+ this.namingConventions = context.getWorkerInstance(NamingConventions.class);
}
/* (non-Javadoc)
@@ -90,7 +93,7 @@
}
private NamingConventions getNamingConventions() {
- return context.getNamingConventions();
+ return namingConventions;
}
protected void compact(Collection<?> collection) {
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptBuilder.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptBuilder.java 2009-08-21 18:45:20 UTC (rev 15268)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptBuilder.java 2009-08-22 00:42:50 UTC (rev 15269)
@@ -47,6 +47,7 @@
import org.richfaces.cdk.Logger;
import org.richfaces.cdk.LoggerFactory;
import org.richfaces.cdk.ModelBuilder;
+import org.richfaces.cdk.StandardOutputs;
import org.richfaces.cdk.StandardSources;
import org.richfaces.cdk.model.ComponentLibrary;
@@ -112,13 +113,18 @@
log.info("Compiler classpath:" + classPathOption);
}
- if(null != context.getJavaSource()){
+ Iterable<File> sourceFolders = context.getSourceFolders(StandardSources.JAVA_SOURCES);
+ File javaSource;
+ if(null != sourceFolders && sourceFolders.iterator().hasNext()){
options.add("-sourcepath");
- options.add(context.getJavaSource().getAbsolutePath());
+ javaSource = sourceFolders.iterator().next();
+ options.add(javaSource.getAbsolutePath());
+ } else {
+ javaSource = null;
}
- if(null != context.getJavaSourceOutput() ){
+ if(null != context.getOutputFolder(StandardOutputs.COMPONENT_CLASSES)){
options.add("-s");
- options.add(context.getJavaSourceOutput().getAbsolutePath());
+ options.add(context.getOutputFolder(StandardOutputs.COMPONENT_CLASSES).getAbsolutePath());
}
setOptions(options);
// TODO - provide source files locale.
@@ -129,7 +135,7 @@
// TODO - use standard file manager for all tasks.
VirtualFileManager fileManager = new VirtualFileManager(stdFileManager,
context.getLoader());
- fileManager.setJavaSourceDirectory(context.getJavaSource());
+ fileManager.setJavaSourceDirectory(javaSource);
setFileManager(fileManager);
initialized = true;
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/CdkProcessor.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/CdkProcessor.java 2009-08-21 18:45:20 UTC (rev 15268)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/CdkProcessor.java 2009-08-22 00:42:50 UTC (rev 15269)
@@ -44,6 +44,8 @@
import javax.lang.model.util.ElementFilter;
import org.richfaces.cdk.CdkContext;
+import org.richfaces.cdk.CdkException;
+import org.richfaces.cdk.NamingConventions;
import org.richfaces.cdk.model.ClassDescription;
import org.richfaces.cdk.model.InvalidNameException;
import org.richfaces.cdk.util.PropertyUtils;
@@ -283,5 +285,9 @@
}
return properties;
}
+
+ protected NamingConventions getNamingConventions() throws CdkException {
+ return getContext().getWorkerInstance(NamingConventions.class);
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ComponentProcessor.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ComponentProcessor.java 2009-08-21 18:45:20 UTC (rev 15268)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ComponentProcessor.java 2009-08-22 00:42:50 UTC (rev 15269)
@@ -58,16 +58,19 @@
public class ComponentProcessor extends CdkProcessor {
private final ComponentLibrary library;
+ private FragmentParser fragmentParser;
/**
* <p class="changed_added_4_0">
* </p>
*
* @param context
+ * @throws CdkException
*/
- public ComponentProcessor(CdkContext context, ComponentLibrary library) {
+ public ComponentProcessor(CdkContext context, ComponentLibrary library) throws CdkException {
super(context);
this.library = library;
+ fragmentParser = FragmentParser.getInstance(context);
}
/*
@@ -91,7 +94,7 @@
Component componentAnnotation = componentElement
.getAnnotation(Component.class);
// Because component type is a primary key for components collection, we have to infer explicit value here.
- String type = getContext().getNamingConventions().inferComponentType(componentAnnotation.value(),componentElement.getQualifiedName().toString());
+ String type = getNamingConventions().inferComponentType(componentAnnotation.value(),componentElement.getQualifiedName().toString());
org.richfaces.cdk.model.Component component = library.findOrCreateComponent(type);
// Should that component be generated ?
setClassNames(componentElement, component);
@@ -201,8 +204,7 @@
String[] includes = attributes.value();
for (String attributesConfig : includes) {
// process additional properties.
- FragmentParser parser = new FragmentParser(getContext());
- component.getAttributes().addAll(parser.parseProperties(attributesConfig));
+ component.getAttributes().addAll(fragmentParser.parseProperties(attributesConfig));
}
}
// TODO - Process standard information for parent classes
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ComponentClassGenerator.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ComponentClassGenerator.java 2009-08-21 18:45:20 UTC (rev 15268)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ComponentClassGenerator.java 2009-08-22 00:42:50 UTC (rev 15269)
@@ -29,6 +29,7 @@
import org.richfaces.cdk.CdkContext;
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.CdkWriter;
+import org.richfaces.cdk.StandardOutputs;
import org.richfaces.cdk.freemarker.FreeMarkerRenderer;
import org.richfaces.cdk.model.Component;
import org.richfaces.cdk.model.ComponentLibrary;
@@ -64,7 +65,7 @@
@Override
protected String getOutputFile(Component c) throws IOException {
- File sourceOutput = getContext().getJavaSourceOutput();
+ File sourceOutput = getContext().getOutputFolder(StandardOutputs.COMPONENT_CLASSES);
File outputFile = new File(sourceOutput,c.getComponentClass().getName().replace('.', File.separatorChar)+".java");
if(!outputFile.exists()){
outputFile.getParentFile().mkdirs();
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/CdkEntityResolver.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/CdkEntityResolver.java 2009-08-21 18:45:20 UTC (rev 15268)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/CdkEntityResolver.java 2009-08-22 00:42:50 UTC (rev 15269)
@@ -49,15 +49,12 @@
*/
public class CdkEntityResolver implements EntityResolver2 {
- // configure a validating SAX2.0 parser (Xerces2)
- public static final String JAXP_SCHEMA_LANGUAGE =
- "http://java.sun.com/xml/jaxp/properties/schemaLanguage";
- public static final String JAXP_SCHEMA_LOCATION =
- "http://java.sun.com/xml/jaxp/properties/schemaSource";
- public static final String W3C_XML_SCHEMA =
- "http://www.w3.org/2001/XMLSchema";
+ // configure a validating SAX2.0 parser (Xerces2)
+ public static final String JAXP_SCHEMA_LANGUAGE = "http://java.sun.com/xml/jaxp/properties/schemaLanguage";
+ public static final String JAXP_SCHEMA_LOCATION = "http://java.sun.com/xml/jaxp/properties/schemaSource";
+ public static final String W3C_XML_SCHEMA = "http://www.w3.org/2001/XMLSchema";
- private static final String URN_SYSTEM = "urn:system:";
+ private static final String URN_SYSTEM = "urn:system:";
private static final ImmutableMap<String, String> systemEntities = ImmutableMap
.<String, String> builder()
@@ -132,11 +129,11 @@
@Override
public InputSource resolveEntity(String publicId, String systemId)
throws SAXException, IOException {
- InputSource entity = null;
+ InputSource entity = null;
if (null != systemId) {
entity = resolveSystemId(systemId);
} else {
- //TODO - check publicId
+ // TODO - check publicId
}
return entity;
}
@@ -168,7 +165,8 @@
}
} else if (systemId.startsWith(URN_ATTRIBUTES)) {
- // Standard attributes. Look for them in the satndard place via project classloader.
+ // Standard attributes. Look for them in the satndard place via
+ // project classloader.
String path = systemId.substring(URN_ATTRIBUTES.length());
InputStream inputStream = getContext().getLoader()
.getResourceAsStream(ATTRIBUTES_PREFIX + path);
@@ -183,20 +181,24 @@
} else if (systemId.startsWith(URN_TEMPLATES)) {
// Templates folder.
String path = systemId.substring(URN_TEMPLATES.length());
- entity = getProjectInputSource(StandardSources.RENDERER_TEMPLATES, path);
+ entity = getProjectInputSource(StandardSources.RENDERER_TEMPLATES,
+ path);
}
return entity;
}
protected InputSource getProjectInputSource(SourceType type, String path)
throws FileNotFoundException {
- File folder = getContext().getSourceFolder(type);
+ Iterable<File> folders = getContext().getSourceFolders(type);
InputSource entity = null;
- if(null != folder && folder.exists() && folder.isDirectory()){
- File configFile = new File(folder,path);
- if(configFile.exists()){
- InputStream inputStream = new FileInputStream(configFile);
- entity = new InputSource(inputStream);
+ for (File folder : folders) {
+ if (folder.exists() && folder.isDirectory()) {
+ File configFile = new File(folder, path);
+ if (configFile.exists()) {
+ InputStream inputStream = new FileInputStream(configFile);
+ entity = new InputSource(inputStream);
+ break;
+ }
}
}
return entity;
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FacesConfigParser.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FacesConfigParser.java 2009-08-21 18:45:20 UTC (rev 15268)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FacesConfigParser.java 2009-08-22 00:42:50 UTC (rev 15269)
@@ -32,6 +32,7 @@
import org.richfaces.cdk.ModelBuilder;
import org.richfaces.cdk.StandardSources;
import org.richfaces.cdk.model.ComponentLibrary;
+import org.richfaces.cdk.xmlconfig.model.FacesConfigBean;
/**
* <p class="changed_added_4_0"></p>
@@ -41,6 +42,7 @@
public class FacesConfigParser implements ModelBuilder {
private CdkContext context;
+ private JAXBBinding jaxbBinding;
/**
* <p class="changed_added_4_0"></p>
@@ -55,24 +57,31 @@
*/
@Override
public ComponentLibrary build() throws CdkException {
- ComponentLibrary library = null;
+ ComponentLibrary library = new ComponentLibrary();
for(File file :context.getSources(StandardSources.FACES_CONFIGS)){
- ComponentLibrary unmarshal = JAXB.unmarshal(file, ComponentLibrary.class);
- if(null == library){
- library = unmarshal;
- } else {
- library.merge(unmarshal);
- }
+ FacesConfigBean unmarshal = unmarshalFacesConfig(file);
+ library.getComponents().addAll(unmarshal.getComponents());
+ // TODO - merge changes into library.
+// library.getRenderers().addAll(unmarshal.getRenderers());
+// library.getValidators().addAll(unmarshal.getValidators);
+// library.getConverters().addAll(unmarshal.getConverters());
+// library.getBehaviors().addAll(unmarshal.getBehaviors());
+// library.setExtensions(unmarshal.getExtensions());
}
return library;
}
+ protected FacesConfigBean unmarshalFacesConfig(File file) throws CdkException {
+ return jaxbBinding.unmarshal(file, ComponentLibrary.FACES_CONFIG_SCHEMA_LOCATION,FacesConfigBean.class);
+ }
+
/* (non-Javadoc)
* @see org.richfaces.cdk.ModelBuilder#init(org.richfaces.cdk.CdkContext)
*/
@Override
- public void init(CdkContext context) {
+ public void init(CdkContext context) throws CdkException {
this.context = context;
+ jaxbBinding = JAXBBinding.getInstance(context);
}
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FragmentParser.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FragmentParser.java 2009-08-21 18:45:20 UTC (rev 15268)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FragmentParser.java 2009-08-22 00:42:50 UTC (rev 15269)
@@ -23,29 +23,14 @@
package org.richfaces.cdk.xmlconfig;
-import java.io.FileNotFoundException;
import java.util.Collection;
import java.util.Collections;
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.Unmarshaller;
-import javax.xml.bind.util.ValidationEventCollector;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.parsers.SAXParser;
-import javax.xml.parsers.SAXParserFactory;
-import javax.xml.transform.sax.SAXSource;
-
import org.richfaces.cdk.CdkContext;
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.Property;
import org.richfaces.cdk.xmlconfig.model.Properties;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXNotRecognizedException;
-import org.xml.sax.SAXNotSupportedException;
-import org.xml.sax.XMLReader;
/**
* <p class="changed_added_4_0">
@@ -59,18 +44,28 @@
public class FragmentParser {
private CdkContext context;
+ private JAXBBinding binding;
- private CdkEntityResolver resolver;
+ public static FragmentParser getInstance(CdkContext context) throws CdkException{
+ FragmentParser parser = new FragmentParser();
+ parser.init(context);
+ return parser;
+ }
+
+ protected FragmentParser() {
+ // TODO Auto-generated constructor stub
+ }
/**
* <p class="changed_added_4_0">
* </p>
*
* @param context
+ * @throws CdkException
*/
- public FragmentParser(CdkContext context) {
+ public void init(CdkContext context) throws CdkException {
this.context = context;
- this.resolver = new CdkEntityResolver(context);
+ binding = JAXBBinding.getInstance(context);
}
/**
@@ -82,53 +77,10 @@
* @return
*/
public Collection<Property> parseProperties(String url) throws CdkException {
- SAXParserFactory spf = SAXParserFactory.newInstance("org.apache.xerces.jaxp.SAXParserFactoryImpl",FragmentParser.class.getClassLoader());
- spf.setNamespaceAware(true);
- spf.setValidating(true);
- try {
- spf.setFeature("http://apache.org/xml/features/validation/schema", true);
- spf.setFeature("http://apache.org/xml/features/xinclude", true);
- spf.setFeature("http://apache.org/xml/features/xinclude/fixup-base-uris", false);
- SAXParser saxParser = spf.newSAXParser();
- try {
- saxParser.setProperty(CdkEntityResolver.JAXP_SCHEMA_LANGUAGE,
- CdkEntityResolver.W3C_XML_SCHEMA);
- saxParser.setProperty(CdkEntityResolver.JAXP_SCHEMA_LOCATION,
- ComponentLibrary.FACES_CONFIG_SCHEMA_LOCATION);
-
- } catch (SAXNotRecognizedException x) {
- // exception handling omitted
- } catch (SAXNotSupportedException e) {
- throw new CdkException(e);
- }
-
- XMLReader xmlReader = saxParser.getXMLReader();
- xmlReader.setEntityResolver(resolver);
- SAXSource source = new SAXSource(xmlReader, resolver.resolveSystemId(url));
-
- // Setup JAXB to unmarshal
- JAXBContext jc = JAXBContext.newInstance(Properties.class);
- Unmarshaller u = jc.createUnmarshaller();
- ValidationEventCollector vec = new ValidationEventCollector();
- u.setEventHandler(vec);
-
- // turn off the JAXB provider's default validation mechanism to
- // avoid duplicate validation
-// u.setValidating(false);
- Properties unmarshal = (Properties) u.unmarshal(source);
- return unmarshal.getProperty();
- } catch(SAXException e){
-
- } catch (ParserConfigurationException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (JAXBException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (FileNotFoundException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- return Collections.emptySet();
+ String schemaLocation = ComponentLibrary.FACES_CONFIG_SCHEMA_LOCATION;
+ Class<Properties> bindClass = Properties.class;
+ Properties unmarshal = binding.unmarshal(url, schemaLocation, bindClass);
+ return null == unmarshal?Collections.<Property>emptySet():unmarshal.getProperty();
}
+
}
Added: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/JAXBBinding.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/JAXBBinding.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/JAXBBinding.java 2009-08-22 00:42:50 UTC (rev 15269)
@@ -0,0 +1,225 @@
+/*
+ * $Id$
+ *
+ * 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.xmlconfig;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Reader;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Unmarshaller;
+import javax.xml.bind.util.ValidationEventCollector;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+import javax.xml.transform.Source;
+import javax.xml.transform.sax.SAXSource;
+
+import org.richfaces.cdk.CdkContext;
+import org.richfaces.cdk.CdkException;
+import org.richfaces.cdk.model.ComponentLibrary;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXNotRecognizedException;
+import org.xml.sax.SAXNotSupportedException;
+import org.xml.sax.XMLReader;
+
+/**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public class JAXBBinding {
+
+ private CdkContext context;
+
+ private CdkEntityResolver resolver;
+
+ private SAXParserFactory spf;
+
+ /**
+ * <p class="changed_added_4_0">
+ * Factory method for binding instance.
+ * </p>
+ *
+ * @param context
+ * @return
+ * @throws CdkException
+ */
+ public static JAXBBinding getInstance(CdkContext context)
+ throws CdkException {
+ JAXBBinding jaxbBinding = new JAXBBinding();
+ jaxbBinding.init(context);
+ return jaxbBinding;
+ }
+
+ protected JAXBBinding() {
+
+ }
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param context
+ */
+ public void init(CdkContext context) throws CdkException {
+ this.context = context;
+ this.resolver = new CdkEntityResolver(context);
+ spf = createParserFactory(context);
+ }
+
+ private SAXParserFactory createParserFactory(CdkContext context)
+ throws CdkException {
+ SAXParserFactory spf = SAXParserFactory.newInstance(
+ "org.apache.xerces.jaxp.SAXParserFactoryImpl",
+ FragmentParser.class.getClassLoader());
+ spf.setNamespaceAware(true);
+ spf.setValidating(true);
+ try {
+ spf.setFeature("http://apache.org/xml/features/validation/schema",
+ true);
+ spf.setFeature("http://apache.org/xml/features/xinclude", true);
+ spf.setFeature(
+ "http://apache.org/xml/features/xinclude/fixup-base-uris",
+ false);
+ } catch (ParserConfigurationException e) {
+ throw new CdkException(
+ "parser does not support desired configuration", e);
+ } catch (SAXNotRecognizedException e) {
+ throw new CdkException("parser does not recofnize property", e);
+ } catch (SAXNotSupportedException e) {
+ throw new CdkException("parser feature does not supported", e);
+ }
+ return spf;
+ }
+
+ public <T> T unmarshal(File file,
+ String schemaLocation, Class<T> bindClass) throws CdkException {
+ try {
+ InputSource input = new InputSource(new FileInputStream(file));
+ T unmarshal = unmarshal(schemaLocation, bindClass, input);
+ return unmarshal;
+ } catch (FileNotFoundException e) {
+ throw new CdkException("XML file not found",e);
+ }
+ }
+
+ public <T> T unmarshal(String url, String schemaLocation,
+ Class<T> bindClass) throws CdkException {
+ try {
+ InputSource inputSource = resolver.resolveSystemId(url);
+ if(null == inputSource){
+ inputSource = new InputSource(url);
+ }
+ T unmarshal = unmarshal(schemaLocation, bindClass, inputSource);
+ return unmarshal;
+ } catch (FileNotFoundException e) {
+ throw new CdkException("XML file not found",e);
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ private <T> T unmarshal(String schemaLocation, Class<T> bindClass,
+ InputSource inputSource) throws CdkException {
+ T unmarshal = null;
+ Source source = createXmlSource(inputSource, schemaLocation);
+ try {
+ // Setup JAXB to unmarshal
+ JAXBContext jc = JAXBContext.newInstance(bindClass);
+ Unmarshaller u = jc.createUnmarshaller();
+ ValidationEventCollector vec = new ValidationEventCollector();
+ u.setEventHandler(vec);
+
+ // turn off the JAXB provider's default validation mechanism to
+ // avoid duplicate validation
+ // u.setValidating(false);
+ unmarshal = (T) u.unmarshal(source);
+ } catch (JAXBException e) {
+ throw new CdkException("JAXB Unmarshaller error", e);
+ } finally {
+ closeSource(source);
+ }
+ return unmarshal;
+ }
+
+ /**
+ * <p class="changed_added_4_0">
+ * Close input source after parsing.
+ * </p>
+ *
+ * @param source
+ */
+ private void closeSource(Source source) {
+ if (source instanceof SAXSource) {
+ SAXSource saxSource = (SAXSource) source;
+ InputSource inputSource = saxSource.getInputSource();
+ try {
+ Reader stream = inputSource.getCharacterStream();
+ if (null != stream) {
+ stream.close();
+ } else {
+ InputStream byteStream = inputSource.getByteStream();
+ if (null != byteStream) {
+ byteStream.close();
+ }
+ }
+ } catch (IOException e) {
+ // Can be ignored because source has already been read.
+ }
+ }
+ }
+
+ private Source createXmlSource(InputSource input, String schemaLocation)
+ throws CdkException {
+ try {
+ SAXParser saxParser = spf.newSAXParser();
+ if (null != schemaLocation) {
+ saxParser.setProperty(CdkEntityResolver.JAXP_SCHEMA_LANGUAGE,
+ CdkEntityResolver.W3C_XML_SCHEMA);
+ saxParser.setProperty(CdkEntityResolver.JAXP_SCHEMA_LOCATION,
+ schemaLocation);
+
+ }
+ XMLReader xmlReader = saxParser.getXMLReader();
+ xmlReader.setEntityResolver(resolver);
+ SAXSource source = new SAXSource(xmlReader, input);
+ return source;
+ } catch (SAXNotRecognizedException x) {
+ throw new CdkException(x);
+ } catch (SAXException e) {
+ throw new CdkException(e);
+ } catch (ParserConfigurationException e) {
+ throw new CdkException(e);
+ }
+
+ }
+
+}
Property changes on: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/JAXBBinding.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ComponentAdapter.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ComponentAdapter.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ComponentAdapter.java 2009-08-22 00:42:50 UTC (rev 15269)
@@ -0,0 +1,70 @@
+/*
+ * $Id$
+ *
+ * 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.xmlconfig.model;
+
+import javax.xml.bind.annotation.adapters.XmlAdapter;
+
+import org.richfaces.cdk.model.ClassDescription;
+import org.richfaces.cdk.model.Component;
+import org.richfaces.cdk.model.ConfigExtension;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public class ComponentAdapter extends XmlAdapter<ComponentBean, Component> {
+
+ @Override
+ public ComponentBean marshal(Component v) throws Exception {
+ ComponentBean bean = new ComponentBean();
+ bean.setType(v.getType().toString());
+ bean.setClassName(v.getComponentClass().getName());
+ bean.getAttributes().addAll(v.getAttributes());
+ ComponentBean.ComponentExtension extension = new ComponentBean.ComponentExtension();
+ extension.setFamily(v.getFamily());
+ ConfigExtension configExtension = v.getExtension();
+ if(null != configExtension){
+ extension.setExtensions(configExtension.getExtensions());
+ }
+ bean.setExtension(extension);
+ return bean;
+ }
+
+ @Override
+ public Component unmarshal(ComponentBean v) throws Exception {
+ Component component = new Component(new Component.Type(v.getType()));
+ component.setComponentClass(new ClassDescription(v.getClassName()));
+ component.getAttributes().addAll(v.getAttributes());
+ ConfigExtension extension = new ConfigExtension();
+ ComponentBean.ComponentExtension configExtension = v.getExtension();
+ if(null != configExtension){
+ component.setFamily(configExtension.getFamily());
+ extension.setExtensions(configExtension.getExtensions());
+ component.setExtension(extension);
+ }
+ return component;
+ }
+
+}
Property changes on: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ComponentAdapter.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ComponentBean.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ComponentBean.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ComponentBean.java 2009-08-22 00:42:50 UTC (rev 15269)
@@ -0,0 +1,141 @@
+/*
+ * $Id$
+ *
+ * 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.xmlconfig.model;
+
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElements;
+
+import org.richfaces.cdk.model.ComponentLibrary;
+import org.richfaces.cdk.model.ConfigExtension;
+import org.richfaces.cdk.model.Property;
+
+import com.google.common.collect.Lists;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public class ComponentBean {
+
+ private String type;
+
+ private String className;
+
+ private List<Property> attributes = Lists.newArrayList();
+
+ private ComponentExtension extension;
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the type
+ */
+ @XmlElement(name="component-type",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
+ public String getType() {
+ return type;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param type the type to set
+ */
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the className
+ */
+ @XmlElement(name="component-class",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
+ public String getClassName() {
+ return className;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param className the className to set
+ */
+ public void setClassName(String className) {
+ this.className = className;
+ }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the attributes
+ */
+ @XmlElements({@XmlElement(name="property",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE,type=PropertyBean.class),@XmlElement(name="attribute",type=PropertyBean.class)})
+// @XmlElement(name="attributes",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
+ public List<Property> getAttributes() {
+ return attributes;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param attributes the attributes to set
+ */
+ public void setAttributes(List<Property> property) {
+ this.attributes = property;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the extension
+ */
+ @XmlElement(name="component-extension",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
+ public ComponentExtension getExtension() {
+ return extension;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param extension the extension to set
+ */
+ public void setExtension(ComponentExtension extension) {
+ this.extension = extension;
+ }
+
+ public static class ComponentExtension extends ConfigExtension {
+
+ private String family;
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param family the family to set
+ */
+ public void setFamily(String family) {
+ this.family = family;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the family
+ */
+ @XmlElement(name="component-family",namespace=ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
+ public String getFamily() {
+ return family;
+ }
+ }
+}
Property changes on: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ComponentBean.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/FacesConfigAdapter.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/FacesConfigAdapter.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/FacesConfigAdapter.java 2009-08-22 00:42:50 UTC (rev 15269)
@@ -0,0 +1,49 @@
+/*
+ * $Id$
+ *
+ * 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.xmlconfig.model;
+
+import javax.xml.bind.annotation.adapters.XmlAdapter;
+
+import org.richfaces.cdk.model.ComponentLibrary;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public class FacesConfigAdapter extends XmlAdapter<FacesConfigBean, ComponentLibrary> {
+
+ @Override
+ public FacesConfigBean marshal(ComponentLibrary v) throws Exception {
+ FacesConfigBean facesConfigBean = new FacesConfigBean();
+ return facesConfigBean;
+ }
+
+ @Override
+ public ComponentLibrary unmarshal(FacesConfigBean v) throws Exception {
+ ComponentLibrary library = new ComponentLibrary();
+ return library;
+ }
+
+}
Property changes on: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/FacesConfigAdapter.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/FacesConfigBean.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/FacesConfigBean.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/FacesConfigBean.java 2009-08-22 00:42:50 UTC (rev 15269)
@@ -0,0 +1,64 @@
+/*
+ * $Id$
+ *
+ * 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.xmlconfig.model;
+
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+
+import org.richfaces.cdk.model.Component;
+import org.richfaces.cdk.model.ComponentLibrary;
+
+import com.google.common.collect.Lists;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+@XmlRootElement(name="faces-config",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
+public class FacesConfigBean {
+
+ @XmlElement(name="component",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
+ @XmlJavaTypeAdapter(ComponentAdapter.class)
+ private List<Component> components = Lists.newArrayList();
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the components
+ */
+ public List<Component> getComponents() {
+ return components;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param components the components to set
+ */
+ public void setComponents(List<Component> components) {
+ this.components = components;
+ }
+}
Property changes on: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/FacesConfigBean.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/Properties.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/Properties.java 2009-08-21 18:45:20 UTC (rev 15268)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/Properties.java 2009-08-22 00:42:50 UTC (rev 15269)
@@ -49,7 +49,7 @@
* <p class="changed_added_4_0"></p>
* @return the property
*/
- @XmlElements({@XmlElement(name="property",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE,type=PropertyBean.class)/*,@XmlElement(name="attribute",type=Attribute.class)*/})
+ @XmlElements({@XmlElement(name="property",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE,type=PropertyBean.class),@XmlElement(name="attribute",type=PropertyBean.class)})
// @XmlElement(name="property",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
public List<Property> getProperty() {
return property;
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/package-info.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/package-info.java 2009-08-21 18:45:20 UTC (rev 15268)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/package-info.java 2009-08-22 00:42:50 UTC (rev 15269)
@@ -9,12 +9,15 @@
location=ComponentLibrary.FACES_CONFIG_SCHEMA_LOCATION,
xmlns = { @javax.xml.bind.annotation.XmlNs( prefix = "cdk",
namespaceURI = ComponentLibrary.CDK_EXTENSIONS_NAMESPACE ) })
-(a)XmlJavaTypeAdapter(type=Property.class,value=PropertyAdapter.class)
+@XmlJavaTypeAdapters({(a)XmlJavaTypeAdapter(type=Property.class,value=PropertyAdapter.class),
+ @XmlJavaTypeAdapter(type=ComponentLibrary.class,value=FacesConfigAdapter.class)
+ })
package org.richfaces.cdk.xmlconfig.model;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapters;
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.Property;
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/CdkTestBase.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/CdkTestBase.java 2009-08-21 18:45:20 UTC (rev 15268)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/CdkTestBase.java 2009-08-22 00:42:50 UTC (rev 15269)
@@ -29,6 +29,7 @@
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
+import java.util.Collections;
import java.util.logging.LogManager;
import org.junit.After;
@@ -41,12 +42,12 @@
*/
public class CdkTestBase {
- protected File testSourceDirectory;
+ protected Iterable<File> testSourceDirectory;
@Before
public void setUpSourceDirectory() throws Exception {
- testSourceDirectory = getJavaFile("test.source.properties")
- .getParentFile();
+ testSourceDirectory = Collections.singleton(getJavaFile("test.source.properties")
+ .getParentFile());
InputStream stream = this.getClass().getResourceAsStream(
"logging.properties");
if (null != stream) {
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/CdkProcessorTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/CdkProcessorTest.java 2009-08-21 18:45:20 UTC (rev 15268)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/CdkProcessorTest.java 2009-08-22 00:42:50 UTC (rev 15269)
@@ -46,6 +46,9 @@
import org.junit.Test;
import org.richfaces.cdk.CdkContext;
import org.richfaces.cdk.CdkTestBase;
+import org.richfaces.cdk.StandardOutputs;
+import org.richfaces.cdk.StandardSources;
+import org.richfaces.cdk.CdkWriter.OutputType;
import org.richfaces.cdk.annotations.Attribute;
import org.richfaces.cdk.annotations.Component;
import org.richfaces.cdk.apt.CdkProcessor.BeanProperty;
@@ -114,9 +117,8 @@
public void testProcess() throws Exception {
// Prepare Mock compilation context.
CdkContext cdkContext = createMock(CdkContext.class);
- expect(cdkContext.getJavaSource()).andStubReturn(testSourceDirectory);
- expect(cdkContext.getJavaSourceOutput()).andStubReturn(null);
- expect(cdkContext.getResourceOutput()).andStubReturn(null);
+ expect(cdkContext.getSourceFolders(StandardSources.JAVA_SOURCES)).andStubReturn(testSourceDirectory);
+ expect(cdkContext.getOutputFolder((OutputType) anyObject())).andStubReturn(null);
expect(cdkContext.getLoader()).andStubReturn(
TestAnnotation.class.getClassLoader());
replay(cdkContext);
@@ -153,9 +155,8 @@
public void testProcessSubClass() throws Exception {
// Prepare Mock compilation context.
CdkContext cdkContext = createMock(CdkContext.class);
- expect(cdkContext.getJavaSource()).andStubReturn(testSourceDirectory);
- expect(cdkContext.getJavaSourceOutput()).andStubReturn(null);
- expect(cdkContext.getResourceOutput()).andStubReturn(null);
+ expect(cdkContext.getSourceFolders(StandardSources.JAVA_SOURCES)).andStubReturn(testSourceDirectory);
+ expect(cdkContext.getOutputFolder((OutputType) anyObject())).andStubReturn(null);
expect(cdkContext.getLoader()).andStubReturn(
TestAnnotation2.class.getClassLoader());
replay(cdkContext);
@@ -198,9 +199,8 @@
public void testGetClassesAnnotatedWith() throws Exception {
// Prepare Mock compilation context.
CdkContext cdkContext = createMock(CdkContext.class);
- expect(cdkContext.getJavaSource()).andStubReturn(testSourceDirectory);
- expect(cdkContext.getJavaSourceOutput()).andStubReturn(null);
- expect(cdkContext.getResourceOutput()).andStubReturn(null);
+ expect(cdkContext.getSourceFolders(StandardSources.JAVA_SOURCES)).andStubReturn(testSourceDirectory);
+ expect(cdkContext.getOutputFolder((OutputType) anyObject())).andStubReturn(null);
expect(cdkContext.getLoader()).andStubReturn(
TestAnnotation2.class.getClassLoader());
replay(cdkContext);
@@ -239,9 +239,8 @@
public void testGetPropertiesAnnotatedWith() throws Exception {
// Prepare Mock compilation context.
CdkContext cdkContext = createMock(CdkContext.class);
- expect(cdkContext.getJavaSource()).andStubReturn(testSourceDirectory);
- expect(cdkContext.getJavaSourceOutput()).andStubReturn(null);
- expect(cdkContext.getResourceOutput()).andStubReturn(null);
+ expect(cdkContext.getSourceFolders(StandardSources.JAVA_SOURCES)).andStubReturn(testSourceDirectory);
+ expect(cdkContext.getOutputFolder((OutputType) anyObject())).andStubReturn(null);
expect(cdkContext.getLoader()).andStubReturn(
TestAnnotation2.class.getClassLoader());
replay(cdkContext);
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/ComponentProcessorTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/ComponentProcessorTest.java 2009-08-21 18:45:20 UTC (rev 15268)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/ComponentProcessorTest.java 2009-08-22 00:42:50 UTC (rev 15269)
@@ -42,6 +42,12 @@
import org.junit.Before;
import org.junit.Test;
import org.richfaces.cdk.CdkContext;
+import org.richfaces.cdk.CdkException;
+import org.richfaces.cdk.CdkTestBase;
+import org.richfaces.cdk.NamingConventions;
+import org.richfaces.cdk.RichFacesConventions;
+import org.richfaces.cdk.StandardSources;
+import org.richfaces.cdk.CdkWriter.OutputType;
import org.richfaces.cdk.model.Component;
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.Property;
@@ -57,7 +63,7 @@
* @author asmirnov(a)exadel.com
*
*/
-public class ComponentProcessorTest {
+public class ComponentProcessorTest extends CdkTestBase {
private static final String INTERFACE_JAVA = "org/richfaces/cdk/apt/TestInterface.java";
@@ -67,35 +73,7 @@
.of(TestAnnotation.class.getName());
private static final String COMPONENT_CLASS_JAVA = "org/richfaces/cdk/test/component/AbstractTestComponent.java";
- private File testSourceDirectory;
- private ClassLoader testLoader;
- @Before
- public void setUp() throws Exception {
- testSourceDirectory = getJavaFile("test.source.properties")
- .getParentFile();
- InputStream stream = this.getClass().getResourceAsStream(
- "logging.properties");
- if (null != stream) {
- try {
- LogManager.getLogManager().readConfiguration(stream);
- } catch (Exception e) {
- // Ignore it.
- } finally {
- try {
- stream.close();
- } catch (IOException e) {
- // Ignore it.
- }
- }
- }
- }
-
- @After
- public void tearDown() {
- testSourceDirectory = null;
- }
-
/**
* Test method for
* {@link org.richfaces.cdk.apt.CdkProcessor#process(java.util.Set, javax.annotation.processing.RoundEnvironment)}
@@ -120,23 +98,16 @@
assertEquals(3, attributes.size());
}
- private CdkContext createMockContext() {
+ private CdkContext createMockContext() throws Exception {
CdkContext cdkContext = createMock(CdkContext.class);
- expect(cdkContext.getJavaSource()).andStubReturn(testSourceDirectory);
- expect(cdkContext.getJavaSourceOutput()).andStubReturn(null);
- expect(cdkContext.getResourceOutput()).andStubReturn(null);
+ expect(cdkContext.getSourceFolders(StandardSources.JAVA_SOURCES)).andStubReturn(testSourceDirectory);
+ expect(cdkContext.getOutputFolder((OutputType) anyObject())).andStubReturn(null);
expect(cdkContext.getLoader()).andStubReturn(
TestAnnotation.class.getClassLoader());
+ expect(cdkContext.getWorkerInstance(NamingConventions.class)).andStubReturn(new RichFacesConventions("foo.bar"));
replay(cdkContext);
return cdkContext;
}
- private File getJavaFile(String name) throws URISyntaxException {
- ClassLoader classLoader = this.getClass().getClassLoader();
- URL testResource = classLoader.getResource(name);
- URI testUri = testResource.toURI();
- final File classFile = new File(testUri);
- return classFile;
- }
}
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/freemarker/FreeMarkerRendererTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/freemarker/FreeMarkerRendererTest.java 2009-08-21 18:45:20 UTC (rev 15268)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/freemarker/FreeMarkerRendererTest.java 2009-08-22 00:42:50 UTC (rev 15269)
@@ -18,41 +18,16 @@
import org.junit.Test;
import org.richfaces.cdk.CdkContext;
import org.richfaces.cdk.CdkException;
+import org.richfaces.cdk.CdkTestBase;
+import org.richfaces.cdk.StandardSources;
+import org.richfaces.cdk.CdkWriter.OutputType;
import org.richfaces.cdk.apt.TestAnnotation;
import org.richfaces.cdk.model.Component;
import org.richfaces.cdk.model.Searchable;
import org.richfaces.cdk.model.Visitable;
-public class FreeMarkerRendererTest {
+public class FreeMarkerRendererTest extends CdkTestBase {
- private File testSourceDirectory;
- private ClassLoader testLoader;
-
- @Before
- public void setUp() throws Exception {
- testSourceDirectory = getJavaFile("test.source.properties")
- .getParentFile();
- InputStream stream = this.getClass().getResourceAsStream(
- "logging.properties");
- if (null != stream) {
- try {
- LogManager.getLogManager().readConfiguration(stream);
- } catch (Exception e) {
- // Ignore it.
- } finally {
- try {
- stream.close();
- } catch (IOException e) {
- // Ignore it.
- }
- }
- }
- }
-
- @After
- public void tearDown() {
- testSourceDirectory = null;
- }
@Test
public void testRender() {
// fail("Not yet implemented");
@@ -92,21 +67,13 @@
private CdkContext createMockContext() {
CdkContext cdkContext = createMock(CdkContext.class);
- expect(cdkContext.getJavaSource()).andStubReturn(testSourceDirectory);
- expect(cdkContext.getJavaSourceOutput()).andStubReturn(null);
- expect(cdkContext.getResourceOutput()).andStubReturn(null);
+ expect(cdkContext.getSourceFolders(StandardSources.JAVA_SOURCES)).andStubReturn(testSourceDirectory);
+ expect(cdkContext.getOutputFolder((OutputType) anyObject())).andStubReturn(null);
expect(cdkContext.getLoader()).andStubReturn(
- testLoader);
+ FreeMarkerRendererTest.class.getClassLoader());
replay(cdkContext);
return cdkContext;
}
- private File getJavaFile(String name) throws URISyntaxException {
- ClassLoader classLoader = this.getClass().getClassLoader();
- URL testResource = classLoader.getResource(name);
- URI testUri = testResource.toURI();
- final File classFile = new File(testUri);
- return classFile;
- }
}
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/CdkResolverTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/CdkResolverTest.java 2009-08-21 18:45:20 UTC (rev 15268)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/CdkResolverTest.java 2009-08-22 00:42:50 UTC (rev 15269)
@@ -16,6 +16,7 @@
import org.richfaces.cdk.CdkContext;
import org.richfaces.cdk.CdkTestBase;
import org.richfaces.cdk.StandardSources;
+import org.richfaces.cdk.CdkWriter.OutputType;
import org.richfaces.cdk.apt.TestAnnotation2;
import org.xml.sax.InputSource;
@@ -71,16 +72,15 @@
private CdkContext createMockContext() {
CdkContext cdkContext = createMock(CdkContext.class);
- expect(cdkContext.getJavaSource()).andStubReturn(testSourceDirectory);
- expect(cdkContext.getJavaSourceOutput()).andStubReturn(null);
- expect(cdkContext.getResourceOutput()).andStubReturn(null);
+ expect(cdkContext.getSourceFolders(StandardSources.JAVA_SOURCES)).andStubReturn(testSourceDirectory);
+ expect(cdkContext.getOutputFolder((OutputType) anyObject())).andStubReturn(null);
return cdkContext;
}
@Test
public void testGetProjectInputSource() throws Exception {
CdkContext cdkContext = createMockContext();
- expect(cdkContext.getSourceFolder(StandardSources.FACES_CONFIGS)).andReturn(this.testSourceDirectory);
+ expect(cdkContext.getSourceFolders(StandardSources.FACES_CONFIGS)).andStubReturn(testSourceDirectory);
replay(cdkContext);
CdkEntityResolver entityResolver = new CdkEntityResolver(cdkContext);
InputSource input = entityResolver.getProjectInputSource(StandardSources.FACES_CONFIGS, "org/richfaces/cdk/apt/test.html");
Added: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/FacesConfigTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/FacesConfigTest.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/FacesConfigTest.java 2009-08-22 00:42:50 UTC (rev 15269)
@@ -0,0 +1,61 @@
+/*
+ * $Id$
+ *
+ * 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.xmlconfig;
+
+import static org.junit.Assert.*;
+
+import java.util.Collection;
+
+import org.junit.Test;
+import org.richfaces.cdk.AbstractCdkContext;
+import org.richfaces.cdk.CdkTestBase;
+import org.richfaces.cdk.model.Component;
+import org.richfaces.cdk.model.ComponentLibrary;
+import org.richfaces.cdk.model.Property;
+import org.richfaces.cdk.xmlconfig.model.FacesConfigBean;
+
+import com.google.common.collect.Iterables;
+
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public class FacesConfigTest extends CdkTestBase {
+
+
+ @Test
+ public void testComponentUnmarshal() throws Exception {
+ JAXBBinding jaxbBinding = JAXBBinding.getInstance(new AbstractCdkContext(this.getClass().getClassLoader()));
+ FacesConfigBean library = jaxbBinding.unmarshal("urn:resource:org/richfaces/cdk/xmlconfig/component.xml", ComponentLibrary.FACES_CONFIG_SCHEMA_LOCATION, FacesConfigBean.class);
+ assertEquals(1,library.getComponents().size());
+ Component component = library.getComponents().get(0);
+ assertEquals("javax.faces.Panel", component.getType().toString());
+ assertEquals("javax.faces.Panel", component.getFamily());
+ assertEquals("javax.faces.component.UIPanel", component.getComponentClass().getName());
+ Collection<Property> attributes = component.getAttributes();
+ assertEquals(10, attributes.size());
+ }
+}
Property changes on: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/FacesConfigTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/FragmentParserTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/FragmentParserTest.java 2009-08-21 18:45:20 UTC (rev 15268)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/FragmentParserTest.java 2009-08-22 00:42:50 UTC (rev 15269)
@@ -41,7 +41,7 @@
@Test
public void parserTest() throws Exception {
- FragmentParser parser = new FragmentParser(new AbstractCdkContext(this.getClass().getClassLoader()));
+ FragmentParser parser = FragmentParser.getInstance(new AbstractCdkContext(this.getClass().getClassLoader()));
Collection<Property> properties = parser.parseProperties("urn:resource:org/richfaces/cdk/xmlconfig/fragment.xml");
assertEquals(3,properties.size());
}
Added: root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/xmlconfig/component.xml
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/xmlconfig/component.xml (rev 0)
+++ root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/xmlconfig/component.xml 2009-08-22 00:42:50 UTC (rev 15269)
@@ -0,0 +1,155 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<faces-config xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xi="http://www.w3.org/2001/XInclude"
+ xmlns:cdk="http://richfaces.org/cdk/extensions"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
+ version="2.0">
+
+ <component>
+ <component-type>javax.faces.Panel</component-type>
+ <component-class>javax.faces.component.UIPanel</component-class>
+
+ <property>
+ <description><![CDATA[
+ A mutable Map of the attributes associated with
+ this component, keyed by attribute name.
+ ]]></description>
+ <display-name>Attributes Map</display-name>
+ <icon />
+ <property-name>attributes</property-name>
+ <property-class>java.util.Map</property-class>
+ <property-extension>
+ <tag-attribute>false</tag-attribute>
+ <read-only>true</read-only>
+ </property-extension>
+ </property>
+ <property>
+ <description><![CDATA[
+ The number of child components associated with
+ this component.
+ ]]></description>
+ <display-name>Child Component Count</display-name>
+ <icon />
+ <property-name>childCount</property-name>
+ <property-class>int</property-class>
+ <property-extension>
+ <tag-attribute>false</tag-attribute>
+ <read-only>true</read-only>
+ </property-extension>
+ </property>
+ <property>
+ <description><![CDATA[
+ A mutable List of the child components associated with
+ this component.
+ ]]></description>
+ <display-name>Child Component List</display-name>
+ <icon />
+ <property-name>children</property-name>
+ <property-class>java.util.List</property-class>
+ <property-extension>
+ <tag-attribute>false</tag-attribute>
+ <read-only>true</read-only>
+ </property-extension>
+ </property>
+ <property>
+ <description><![CDATA[
+ A mutable Map of the facets associated with
+ this component, keyed by facet name.
+ ]]></description>
+ <display-name>Facets Map</display-name>
+ <icon />
+ <property-name>facets</property-name>
+ <property-class>java.util.Map</property-class>
+ <property-extension>
+ <tag-attribute>false</tag-attribute>
+ <read-only>true</read-only>
+ </property-extension>
+ </property>
+ <property>
+ <description><![CDATA[
+ The component family to which this component belongs. This property
+ is used to select an appropriate Renderer.
+ ]]></description>
+ <display-name>Component Family</display-name>
+ <icon />
+ <property-name>family</property-name>
+ <property-class>java.lang.String</property-class>
+ <property-extension>
+ <tag-attribute>false</tag-attribute>
+ <read-only>true</read-only>
+ </property-extension>
+ </property>
+ <property>
+ <description><![CDATA[
+ The component identifier for this component. This value must be
+ unique within the closest parent component that is a naming
+ container.
+ ]]></description>
+ <display-name>Component Identifier</display-name>
+ <icon />
+ <property-name>id</property-name>
+ <property-class>java.lang.String</property-class>
+ </property>
+ <property>
+ <description><![CDATA[
+ The parent component for this component. On the root component
+ in the component tree (which must be of type UIViewRoot), this
+ property is null.
+ ]]></description>
+ <display-name>Parent Component</display-name>
+ <icon />
+ <property-name>parent</property-name>
+ <property-class>javax.faces.component.UIComponent</property-class>
+ <property-extension>
+ <tag-attribute>false</tag-attribute>
+ <read-only>true</read-only>
+ </property-extension>
+ </property>
+ <property>
+ <description><![CDATA[
+ Flag indicating whether or not this component should be rendered
+ (during Render Response Phase), or processed on any subsequent
+ form submit. The default value for this property is true.
+ ]]></description>
+ <display-name>Rendered Flag</display-name>
+ <icon />
+ <property-name>rendered</property-name>
+ <property-class>boolean</property-class>
+ <property-extension>
+ <value-expression-enabled>true</value-expression-enabled>
+ </property-extension>
+ </property>
+ <property>
+ <description><![CDATA[
+ Identifier used (in conjunction with the "family" property) to
+ select an appropriate Renderer to encode and decode this component.
+ ]]></description>
+ <display-name>Renderer Type</display-name>
+ <icon />
+ <property-name>rendererType</property-name>
+ <property-class>java.lang.String</property-class>
+ <property-extension>
+ <tag-attribute>false</tag-attribute>
+ </property-extension>
+ </property>
+ <property>
+ <description><![CDATA[
+ Flag indicating whether or not this component takes responsibility
+ for rendering its own children. This decision is normally delegated
+ to the associated Renderer, if there is one.
+ ]]></description>
+ <display-name>Renders Children</display-name>
+ <icon />
+ <property-name>rendersChildren</property-name>
+ <property-class>boolean</property-class>
+ <property-extension>
+ <tag-attribute>false</tag-attribute>
+ <read-only>true</read-only>
+ </property-extension>
+ </property>
+
+ <component-extension>
+ <cdk:component-family>javax.faces.Panel</cdk:component-family>
+ </component-extension>
+ </component>
+</faces-config>
\ No newline at end of file
Property changes on: root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/xmlconfig/component.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/GenerateMojo.java
===================================================================
--- root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/GenerateMojo.java 2009-08-21 18:45:20 UTC (rev 15268)
+++ root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/GenerateMojo.java 2009-08-22 00:42:50 UTC (rev 15269)
@@ -24,6 +24,7 @@
package org.richfaces.builder.mojo;
import java.io.File;
+import java.util.ArrayList;
import java.util.HashSet;
import java.util.Set;
@@ -32,9 +33,12 @@
import org.richfaces.cdk.AbstractCdkContext;
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.LibraryBuilder;
+import org.richfaces.cdk.ModelValidator;
+import org.richfaces.cdk.NamingConventions;
import org.richfaces.cdk.RichFacesConventions;
import org.richfaces.cdk.StandardOutputs;
import org.richfaces.cdk.StandardSources;
+import org.richfaces.cdk.ValidatorImpl;
import org.richfaces.cdk.model.ComponentLibrary;
/**
@@ -58,24 +62,37 @@
checkLibraryConfig();
AbstractCdkContext context = new AbstractCdkContext(this
.createProjectClassLoader(project));
- context.setJavaSource(new File(compileSourceRoots.get(0)));
+ ArrayList<File> folders = new ArrayList<File>(compileSourceRoots.size());
+ for (String sourceFolder : compileSourceRoots) {
+ File folder = new File(sourceFolder);
+ if(folder.exists() && folder.isDirectory()){
+ folders.add(folder);
+ }
+ }
+ context.setSourceFolders(StandardSources.JAVA_SOURCES, folders);
if(!outputJavaDirectory.exists()){
outputJavaDirectory.mkdirs();
}
- context.setJavaSourceOutput(outputJavaDirectory);
+ context.setOutputFolder(StandardOutputs.COMPONENT_CLASSES, outputJavaDirectory);
+ context.setOutputFolder(StandardOutputs.EVENT_LISTENER_CLASSES, outputJavaDirectory);
+ context.setOutputFolder(StandardOutputs.EVENT_SOURCE_CLASSES, outputJavaDirectory);
if(!outputResourcesDirectory.exists()){
outputResourcesDirectory.mkdirs();
}
- context.setResourceOutput(outputResourcesDirectory);
- context.setNamingConventions(new RichFacesConventions(library
+ context.setOutputFolder(StandardOutputs.FACES_CONFIG, outputResourcesDirectory);
+ context.setOutputFolder(StandardOutputs.TAG_LIBRARY, outputResourcesDirectory);
+ context.setOutputFolder(StandardOutputs.XML_SCHEMA, outputResourcesDirectory);
+ // TODO - configure.
+ context.addWorker(NamingConventions.class, new RichFacesConventions(library
.getPrefix()));
+ context.addWorker(ModelValidator.class, new ValidatorImpl());
context.addSources(StandardSources.JAVA_SOURCES, findJavaFiles());
context.addSources(StandardSources.RENDERER_TEMPLATES,
findTemplateFiles());
context.addSources(StandardSources.FACES_CONFIGS,
findFacesConfigFiles());
- LibraryBuilder builder = LibraryBuilder.createInstance(context);
try {
+ LibraryBuilder builder = LibraryBuilder.createInstance(context);
ComponentLibrary model = builder.buildModel();
builder.generate(model);
} catch (CdkException e) {
15 years, 4 months
JBoss Rich Faces SVN: r15268 - in root: examples/trunk/components/core-demo/src/main/webapp and 5 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: konstantin.mishin
Date: 2009-08-21 14:45:20 -0400 (Fri, 21 Aug 2009)
New Revision: 15268
Added:
root/examples/trunk/components/core-demo/src/main/java/org/richfaces/demo/CommandBean.java
root/examples/trunk/components/core-demo/src/main/webapp/button.xhtml
root/examples/trunk/components/core-demo/src/main/webapp/link.xhtml
root/ui/trunk/components/core/src/main/java/org/richfaces/component/html/HtmlCommandButton.java
root/ui/trunk/components/core/src/main/java/org/richfaces/component/html/HtmlCommandLink.java
Modified:
root/ui/trunk/components/core/src/main/java/org/richfaces/component/html/HtmlAjaxFunction.java
root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/AjaxCommandRendererBase.java
root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/AjaxFunctionRendererBase.java
root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/html/AjaxCommandButtonRendererBase.java
root/ui/trunk/components/core/src/main/resources/META-INF/a4j.taglib.xml
root/ui/trunk/components/core/src/main/resources/META-INF/faces-config.xml
root/ui/trunk/components/core/src/main/templates/org/ajax4jsf/renderkit/html/button.template.xml
root/ui/trunk/components/core/src/main/templates/org/ajax4jsf/renderkit/html/function.template.xml
root/ui/trunk/components/core/src/main/templates/org/ajax4jsf/renderkit/html/link.template.xml
Log:
a4j:commandLink and a4j:commandButton initial integration into 4.0
Added: root/examples/trunk/components/core-demo/src/main/java/org/richfaces/demo/CommandBean.java
===================================================================
--- root/examples/trunk/components/core-demo/src/main/java/org/richfaces/demo/CommandBean.java (rev 0)
+++ root/examples/trunk/components/core-demo/src/main/java/org/richfaces/demo/CommandBean.java 2009-08-21 18:45:20 UTC (rev 15268)
@@ -0,0 +1,27 @@
+package org.richfaces.demo;
+import javax.faces.bean.ManagedBean;
+import javax.faces.bean.SessionScoped;
+
+@ManagedBean(name="commandBean")
+@SessionScoped
+public class CommandBean {
+
+ private String name;
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void submit() {
+ name = "Hello " + name;
+
+ }
+
+ public void reset() {
+ name = "";
+ }
+}
Added: root/examples/trunk/components/core-demo/src/main/webapp/button.xhtml
===================================================================
--- root/examples/trunk/components/core-demo/src/main/webapp/button.xhtml (rev 0)
+++ root/examples/trunk/components/core-demo/src/main/webapp/button.xhtml 2009-08-21 18:45:20 UTC (rev 15268)
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:a4j="http://richfaces.org/a4j">
+<f:view>
+ <h:head>
+ </h:head>
+ <h:body>
+ <h:outputText value="Name:" />
+ <h:form>
+ <h:inputText value="#{commandBean.name}" />
+ <a4j:commandButton action="#{commandBean.submit}" render="out" value="Say Hello" />
+ <a4j:commandButton action="#{commandBean.reset}" render="out" value="Reset" />
+ </h:form>
+ <br />
+ <h:panelGroup id="out">
+ <h:outputText value="#{commandBean.name}" />
+ <h:outputText value="!" rendered="#{not empty commandBean.name}" />
+ </h:panelGroup>
+ </h:body>
+</f:view>
+</html>
\ No newline at end of file
Added: root/examples/trunk/components/core-demo/src/main/webapp/link.xhtml
===================================================================
--- root/examples/trunk/components/core-demo/src/main/webapp/link.xhtml (rev 0)
+++ root/examples/trunk/components/core-demo/src/main/webapp/link.xhtml 2009-08-21 18:45:20 UTC (rev 15268)
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:a4j="http://richfaces.org/a4j">
+<f:view>
+ <h:head>
+ </h:head>
+ <h:body>
+ <h:outputText value="Name:" />
+ <h:form>
+ <h:inputText value="#{commandBean.name}" />
+ <a4j:commandLink action="#{commandBean.submit}" render="out">
+ <h:outputText value="Say Hello" />
+ </a4j:commandLink>
+ <a4j:commandLink action="#{commandBean.reset}" render="out">
+ <h:outputText value="Reset" />
+ </a4j:commandLink>
+ </h:form>
+ <br />
+ <h:panelGroup id="out">
+ <h:outputText value="#{commandBean.name}" />
+ <h:outputText value="!" rendered="#{not empty commandBean.name}" />
+ </h:panelGroup>
+ </h:body>
+</f:view>
+</html>
\ No newline at end of file
Modified: root/ui/trunk/components/core/src/main/java/org/richfaces/component/html/HtmlAjaxFunction.java
===================================================================
--- root/ui/trunk/components/core/src/main/java/org/richfaces/component/html/HtmlAjaxFunction.java 2009-08-21 18:25:38 UTC (rev 15267)
+++ root/ui/trunk/components/core/src/main/java/org/richfaces/component/html/HtmlAjaxFunction.java 2009-08-21 18:45:20 UTC (rev 15268)
@@ -3,12 +3,11 @@
import javax.el.ELException;
import javax.el.ValueExpression;
import javax.faces.FacesException;
+import javax.faces.component.UICommand;
import javax.faces.context.FacesContext;
-import org.richfaces.component.UIAjaxFunction;
+public class HtmlAjaxFunction extends UICommand {
-public class HtmlAjaxFunction extends UIAjaxFunction {
-
public final static String COMPONENT_FAMILY = "javax.faces.Command";
public final static String COMPONENT_TYPE = "org.richfaces.Function";
Added: root/ui/trunk/components/core/src/main/java/org/richfaces/component/html/HtmlCommandButton.java
===================================================================
--- root/ui/trunk/components/core/src/main/java/org/richfaces/component/html/HtmlCommandButton.java (rev 0)
+++ root/ui/trunk/components/core/src/main/java/org/richfaces/component/html/HtmlCommandButton.java 2009-08-21 18:45:20 UTC (rev 15268)
@@ -0,0 +1,38 @@
+/**
+ * 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.component.html;
+
+import javax.faces.component.UICommand;
+
+/**
+ * @author Konstantin Mishin
+ *
+ */
+
+public class HtmlCommandButton extends UICommand {
+
+ public final static String COMPONENT_TYPE = "org.richfaces.CommandButton";
+
+ public HtmlCommandButton(){
+ setRendererType("org.richfaces.CommandButtonRenderer");
+ }
+}
Added: root/ui/trunk/components/core/src/main/java/org/richfaces/component/html/HtmlCommandLink.java
===================================================================
--- root/ui/trunk/components/core/src/main/java/org/richfaces/component/html/HtmlCommandLink.java (rev 0)
+++ root/ui/trunk/components/core/src/main/java/org/richfaces/component/html/HtmlCommandLink.java 2009-08-21 18:45:20 UTC (rev 15268)
@@ -0,0 +1,59 @@
+/**
+ * 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.component.html;
+
+import javax.faces.component.UICommand;
+
+/**
+ * @author Konstantin Mishin
+ *
+ */
+
+
+public class HtmlCommandLink extends UICommand {
+
+ public final static String COMPONENT_TYPE = "org.richfaces.CommandLink";
+
+ private static enum PropertyKeys {
+ style, styleClass
+ }
+
+ public HtmlCommandLink() {
+ setRendererType("org.richfaces.CommandLinkRenderer");
+ }
+
+ public String getStyle() {
+ return (String) getStateHelper().eval(PropertyKeys.style, "");
+ }
+
+ public void setStyle(String style) {
+ getStateHelper().put(PropertyKeys.style, style);
+ }
+
+ public String getStyleClass() {
+ return (String) getStateHelper().eval(PropertyKeys.styleClass, "");
+ }
+
+ public void setStyleClass(String styleClass) {
+ getStateHelper().put(PropertyKeys.styleClass, styleClass);
+ }
+}
Modified: root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/AjaxCommandRendererBase.java
===================================================================
--- root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/AjaxCommandRendererBase.java 2009-08-21 18:25:38 UTC (rev 15267)
+++ root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/AjaxCommandRendererBase.java 2009-08-21 18:45:20 UTC (rev 15268)
@@ -21,22 +21,16 @@
package org.richfaces.renderkit;
-import java.io.IOException;
-import java.util.LinkedHashSet;
import java.util.Map;
-import java.util.Set;
+import javax.faces.application.ResourceDependencies;
+import javax.faces.application.ResourceDependency;
import javax.faces.component.UIComponent;
-import javax.faces.component.ValueHolder;
-import javax.faces.component.html.HtmlCommandButton;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
-import org.ajax4jsf.component.AjaxComponent;
-import org.ajax4jsf.context.AjaxContext;
-import org.ajax4jsf.event.AjaxEvent;
-import org.ajax4jsf.renderkit.AjaxComponentRendererBase;
import org.ajax4jsf.renderkit.AjaxRendererUtils;
+import org.ajax4jsf.renderkit.RendererBase;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -45,84 +39,24 @@
* @version $Revision: 1.1.2.3 $ $Date: 2007/02/12 17:46:53 $
*
*/
-public abstract class AjaxCommandRendererBase extends AjaxComponentRendererBase {
+@ResourceDependencies({
+ @ResourceDependency(library = "javax.faces", name = "jsf.js"),
+ @ResourceDependency(name = "jquery.js"),
+ @ResourceDependency(name = "richfaces.js")
+})
+public abstract class AjaxCommandRendererBase extends RendererBase {
private static final Log _log = LogFactory
.getLog(AjaxCommandRendererBase.class);
protected void doDecode(FacesContext facesContext, UIComponent uiComponent) {
-
- // super.decode must not be called, because value is handled here
if (isSubmitted(facesContext, uiComponent)) {
- ActionEvent event;
- event = new ActionEvent(uiComponent);
- uiComponent.queueEvent(event);
- uiComponent.queueEvent(new AjaxEvent(uiComponent));
- // Check areas for processing
- if (uiComponent instanceof AjaxComponent) {
- AjaxComponent ajaxComponent = (AjaxComponent) uiComponent;
- Set<String> toProcess = AjaxRendererUtils.asSet(ajaxComponent
- .getProcess());
- if (null != toProcess) {
- Set<String> componentIdsToProcess = new LinkedHashSet<String>();
- for (String componentId : toProcess) {
- UIComponent component = getUtils().findComponentFor(uiComponent, componentId);
- if(null != component){
- componentIdsToProcess.add(component.getClientId(facesContext));
- } else {
- componentIdsToProcess.add(componentId);
- }
- }
- AjaxContext.getCurrentInstance(facesContext).setAjaxAreasToProcess(componentIdsToProcess);
- }
- }
+ new ActionEvent(uiComponent).queue();
}
}
- public String getOnClick(FacesContext context, UIComponent component) {
- StringBuffer onClick;
- if (!getUtils().isBooleanAttribute(component, "disabled")) {
- onClick = AjaxRendererUtils.buildOnClick(component, context, true);
- if (!"reset".equals(component.getAttributes().get("type"))) {
- onClick.append(";return false;");
- }
- } else {
- onClick = new StringBuffer("return false;");
- }
- return onClick.toString();
- }
-
- public void encodeChildren(FacesContext context, UIComponent component)
- throws IOException {
- renderChildren(context, component);
- }
-
- public Object getValue(UIComponent uiComponent) {
- if (uiComponent instanceof ValueHolder) {
- return ((ValueHolder) uiComponent).getValue();
- }
- return uiComponent.getAttributes().get("value");
- }
-
- public String getType(UIComponent uiComponent) {
- String type;
- if (uiComponent instanceof HtmlCommandButton) {
- type = ((HtmlCommandButton) uiComponent).getType();
- } else {
- type = (String) uiComponent.getAttributes().get("type");
- }
- if (type == null) {
- type = "button";
- }
- return type;
- }
-
protected boolean isSubmitted(FacesContext facesContext,
UIComponent uiComponent) {
- // Componet accept only ajax requests.
- if (!AjaxContext.getCurrentInstance(facesContext).isAjaxRequest()) {
- return false;
- }
if (getUtils().isBooleanAttribute(uiComponent, "disabled")) {
return false;
}
@@ -136,5 +70,42 @@
}
return submitted;
}
-
+
+ public String getOnClick(FacesContext context, UIComponent component) {
+ StringBuffer onClick = new StringBuffer();
+ if (!getUtils().isBooleanAttribute(component, "disabled")) {
+ onClick.append(AjaxRendererUtils.createBehaviorsChain(context, component, "onclick"));
+ if (!"reset".equals(component.getAttributes().get("type"))) {
+ onClick.append(";return false;");
+ }
+ } else {
+ onClick.append("return false;");
+ }
+ return onClick.toString();
+ }
+//
+// public void encodeChildren(FacesContext context, UIComponent component)
+// throws IOException {
+// renderChildren(context, component);
+// }
+//
+// public Object getValue(UIComponent uiComponent) {
+// if (uiComponent instanceof ValueHolder) {
+// return ((ValueHolder) uiComponent).getValue();
+// }
+// return uiComponent.getAttributes().get("value");
+// }
+//
+// public String getType(UIComponent uiComponent) {
+// String type;
+// if (uiComponent instanceof HtmlCommandButton) {
+// type = ((HtmlCommandButton) uiComponent).getType();
+// } else {
+// type = (String) uiComponent.getAttributes().get("type");
+// }
+// if (type == null) {
+// type = "button";
+// }
+// return type;
+// }
}
Modified: root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/AjaxFunctionRendererBase.java
===================================================================
--- root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/AjaxFunctionRendererBase.java 2009-08-21 18:25:38 UTC (rev 15267)
+++ root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/AjaxFunctionRendererBase.java 2009-08-21 18:45:20 UTC (rev 15268)
@@ -25,12 +25,9 @@
import java.util.Map;
import javax.faces.FacesException;
-import javax.faces.application.ResourceDependencies;
-import javax.faces.application.ResourceDependency;
import javax.faces.component.UIComponent;
import javax.faces.component.UIParameter;
import javax.faces.context.FacesContext;
-import javax.faces.event.ActionEvent;
import org.ajax4jsf.javascript.JSFunction;
import org.ajax4jsf.javascript.JSFunctionDefinition;
@@ -38,30 +35,15 @@
import org.ajax4jsf.javascript.ScriptUtils;
import org.ajax4jsf.renderkit.AjaxEventOptions;
import org.ajax4jsf.renderkit.AjaxRendererUtils;
-import org.richfaces.component.UIAjaxFunction;
/**
* @author shura
*
*/
-@ResourceDependencies({
- @ResourceDependency(library = "javax.faces", name = "jsf.js"),
- @ResourceDependency(name = "jquery.js"),
- @ResourceDependency(name = "richfaces.js")
-})
-public class AjaxFunctionRendererBase extends AjaxCommandRendererBase {
+public abstract class AjaxFunctionRendererBase extends AjaxCommandRendererBase {
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.renderkit.RendererBase#getComponentClass()
- */
- protected Class<? extends UIComponent> getComponentClass() {
- return UIAjaxFunction.class;
- }
-
- public String getFunction(FacesContext context, UIAjaxFunction component) {
- String functionName = component.getName();
+ public String getFunction(FacesContext context, UIComponent component) {
+ String functionName = (String)component.getAttributes().get("name");
if (functionName == null) {
throw new FacesException("Value of 'name' attribute of a4j:jsFunction component is null!");
}
@@ -106,14 +88,4 @@
func.appendScript(script);
return script.toString();
}
-
- @Override
- protected void doDecode(FacesContext facesContext, UIComponent uiComponent) {
- Map<String, String> requestParameterMap = facesContext.getExternalContext().getRequestParameterMap();
- String clientId = uiComponent.getClientId(facesContext);
-
- if (requestParameterMap.get(clientId) != null) {
- new ActionEvent(uiComponent).queue();
- }
- }
}
Modified: root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/html/AjaxCommandButtonRendererBase.java
===================================================================
--- root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/html/AjaxCommandButtonRendererBase.java 2009-08-21 18:25:38 UTC (rev 15267)
+++ root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/html/AjaxCommandButtonRendererBase.java 2009-08-21 18:45:20 UTC (rev 15268)
@@ -28,7 +28,6 @@
import javax.faces.context.ResponseWriter;
import org.richfaces.renderkit.AjaxCommandRendererBase;
-import org.richfaces.renderkit.CommandRendererBase;
/**
* @author Nick Belaevski
Modified: root/ui/trunk/components/core/src/main/resources/META-INF/a4j.taglib.xml
===================================================================
--- root/ui/trunk/components/core/src/main/resources/META-INF/a4j.taglib.xml 2009-08-21 18:25:38 UTC (rev 15267)
+++ root/ui/trunk/components/core/src/main/resources/META-INF/a4j.taglib.xml 2009-08-21 18:45:20 UTC (rev 15268)
@@ -47,6 +47,20 @@
<renderer-type>org.richfaces.AjaxLogRenderer</renderer-type>
</component>
</tag>
+ <tag>
+ <tag-name>commandLink</tag-name>
+ <component>
+ <component-type>org.richfaces.CommandLink</component-type>
+ <renderer-type>org.richfaces.CommandLinkRenderer</renderer-type>
+ </component>
+ </tag>
+ <tag>
+ <tag-name>commandButton</tag-name>
+ <component>
+ <component-type>org.richfaces.CommandButton</component-type>
+ <renderer-type>org.richfaces.CommandButtonRenderer</renderer-type>
+ </component>
+ </tag>
<tag>
<tag-name>ajax</tag-name>
Modified: root/ui/trunk/components/core/src/main/resources/META-INF/faces-config.xml
===================================================================
--- root/ui/trunk/components/core/src/main/resources/META-INF/faces-config.xml 2009-08-21 18:25:38 UTC (rev 15267)
+++ root/ui/trunk/components/core/src/main/resources/META-INF/faces-config.xml 2009-08-21 18:45:20 UTC (rev 15268)
@@ -39,6 +39,16 @@
<component-class>org.richfaces.component.html.HtmlAjaxLog</component-class>
</component>
+ <component>
+ <component-type>org.richfaces.CommandLink</component-type>
+ <component-class>org.richfaces.component.html.HtmlCommandLink</component-class>
+ </component>
+
+ <component>
+ <component-type>org.richfaces.CommandButton</component-type>
+ <component-class>org.richfaces.component.html.HtmlCommandButton</component-class>
+ </component>
+
<render-kit>
<render-kit-id>HTML_BASIC</render-kit-id>
<renderer>
@@ -71,5 +81,15 @@
<renderer-type>org.richfaces.AjaxLogRenderer</renderer-type>
<renderer-class>org.richfaces.renderkit.html.AjaxLogRenderer</renderer-class>
</renderer>
+ <renderer>
+ <component-family>javax.faces.Command</component-family>
+ <renderer-type>org.richfaces.CommandLinkRenderer</renderer-type>
+ <renderer-class>org.richfaces.renderkit.html.CommandLinkRenderer</renderer-class>
+ </renderer>
+ <renderer>
+ <component-family>javax.faces.Command</component-family>
+ <renderer-type>org.richfaces.CommandButtonRenderer</renderer-type>
+ <renderer-class>org.richfaces.renderkit.html.CommandButtonRenderer</renderer-class>
+ </renderer>
</render-kit>
</faces-config>
\ No newline at end of file
Modified: root/ui/trunk/components/core/src/main/templates/org/ajax4jsf/renderkit/html/button.template.xml
===================================================================
--- root/ui/trunk/components/core/src/main/templates/org/ajax4jsf/renderkit/html/button.template.xml 2009-08-21 18:25:38 UTC (rev 15267)
+++ root/ui/trunk/components/core/src/main/templates/org/ajax4jsf/renderkit/html/button.template.xml 2009-08-21 18:45:20 UTC (rev 15268)
@@ -4,15 +4,14 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
class="org.richfaces.renderkit.html.CommandButtonRenderer"
superclass="org.richfaces.renderkit.html.AjaxCommandButtonRendererBase"
- componentclass="org.richfaces.component.UIAjaxCommandButton">
+ componentclass="javax.faces.component.UIComponent">
<!-- f:clientid var="clientId"/ -->
<input
id="#{clientId}"
name="#{clientId}"
- value="#{this.getValue(component)}"
- cdk:passThroughWithExclusions="value name onclick type id class"
+ cdk:passThroughWithExclusions="name onclick type id class"
onclick="#{this.getOnClick(context,component)}"
class="#{component.attributes['styleClass']}"
>
Modified: root/ui/trunk/components/core/src/main/templates/org/ajax4jsf/renderkit/html/function.template.xml
===================================================================
--- root/ui/trunk/components/core/src/main/templates/org/ajax4jsf/renderkit/html/function.template.xml 2009-08-21 18:25:38 UTC (rev 15267)
+++ root/ui/trunk/components/core/src/main/templates/org/ajax4jsf/renderkit/html/function.template.xml 2009-08-21 18:45:20 UTC (rev 15268)
@@ -3,7 +3,7 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
class="org.richfaces.renderkit.html.AjaxFunctionRenderer"
superclass="org.richfaces.renderkit.AjaxFunctionRendererBase"
- componentclass="org.richfaces.component.UIAjaxFunction">
+ componentclass="javax.faces.component.UIComponent">
<!-- f:clientid var="clientId"/ -->
<span id="#{clientId}" style="display: none;">
Modified: root/ui/trunk/components/core/src/main/templates/org/ajax4jsf/renderkit/html/link.template.xml
===================================================================
--- root/ui/trunk/components/core/src/main/templates/org/ajax4jsf/renderkit/html/link.template.xml 2009-08-21 18:25:38 UTC (rev 15267)
+++ root/ui/trunk/components/core/src/main/templates/org/ajax4jsf/renderkit/html/link.template.xml 2009-08-21 18:45:20 UTC (rev 15268)
@@ -4,19 +4,18 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
class="org.richfaces.renderkit.html.CommandLinkRenderer"
superclass="org.richfaces.renderkit.AjaxCommandRendererBase"
- componentclass="org.richfaces.component.UIAjaxCommandLink">
+ componentclass="javax.faces.component.UIComponent">
<!-- f:clientid var="clientId"/ -->
<a
id="#{clientId}"
name="#{clientId}"
- type="#{component.attributes['type']}"
- cdk:passThroughWithExclusions="value name onclick type href id"
+ cdk:passThroughWithExclusions="value name onclick href id"
onclick="#{this.getOnClick(context,component)}"
href="#"
class="#{component.attributes['styleClass']}"
>
- #{this.getValue(component)}
+ #{component.attributes['value']}
<cdk:body>
<cdk:call expression="renderChildren(context,component);" />
</cdk:body>
15 years, 4 months
JBoss Rich Faces SVN: r15267 - in root/cdk/trunk/plugins/generator/src/test: resources/org/richfaces/cdk and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: amarkhel
Date: 2009-08-21 14:25:38 -0400 (Fri, 21 Aug 2009)
New Revision: 15267
Added:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/TemplateReaderTest.java
root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/template-simple.xml
root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/template.xml
Log:
Add test to Template Renderer
Added: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/TemplateReaderTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/TemplateReaderTest.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/TemplateReaderTest.java 2009-08-21 18:25:38 UTC (rev 15267)
@@ -0,0 +1,108 @@
+package org.richfaces.cdk;
+
+
+import static org.junit.Assert.*;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.richfaces.builder.model.JavaClass;
+import org.richfaces.builder.model.JavaMethod;
+import org.richfaces.builder.templates.TemplateReader;
+
+public class TemplateReaderTest {
+
+ private static final String IF_FRAGMENT = "if (";
+ private static final String START_DIV_FRAGMENT = "responseWriter.startElement(\"div\", component);";
+ private static final String START_TABLE_FRAGMENT = "responseWriter.startElement(\"table\", component);";
+ private static final String END_DIV_FRAGMENT = "responseWriter.endElement(\"div\");";
+ private static final String END_TABLE_FRAGMENT = "responseWriter.endElement(\"table\");";
+ private static final String WRITE_ATTRIBBUTE_FRAGMENT = "responseWriter.writeAttribute(\"id\", component.getClientId(context), \"id\");";
+ private static final String TEMPLATE_XML = "template.xml";
+ private static final String TEMPLATE_SIMPLE_XML = "template-simple.xml";
+ private static final String FULL_NAME = "org.richfaces.renderkit.html.TabPanelRenderer";
+ private static final String SUPERCLASS = "javax.faces.render.Renderer";
+ private static final String PACKAGE = "org.richfaces.renderkit.html";
+ private static final String TAB_PANEL_RENDERER = "TabPanelRenderer";
+ private static final String ENCODE_CHILDREN_METHOD = "encodeChildren";
+ private static final String ENCODE_END_METHOD = "encodeEnd";
+ private static final String ENCODE_BEGIN_METHOD = "encodeBegin";
+ InputStream stream = null;
+
+ @Before
+ public void create() {
+ }
+
+ @After
+ public void destroy(){
+ try {
+ stream.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testSimpleTemplate() throws Exception {
+ stream = this.getClass().getResourceAsStream(TEMPLATE_SIMPLE_XML);
+ JavaClass claz = TemplateReader.parse(stream);
+ /*JavaClassRenderer renderer = new JavaClassRenderer();
+ renderer.render(claz, new PrintWriter(System.out));*/
+ assertEquals(claz.getFullName(), FULL_NAME);
+ assertEquals(claz.getName(), TAB_PANEL_RENDERER);
+ assertEquals(claz.getPakg().getName(), PACKAGE);
+ assertEquals(claz.getSuperClass().getFullName(), SUPERCLASS);
+ assertTrue(containMethod(claz, ENCODE_BEGIN_METHOD));
+ assertTrue(containMethod(claz, ENCODE_END_METHOD));
+ assertTrue(containMethod(claz, ENCODE_CHILDREN_METHOD));
+ }
+
+ @Test
+ public void testFullTemplate() throws Exception {
+ stream = this.getClass().getResourceAsStream(TEMPLATE_XML);
+ JavaClass claz = TemplateReader.parse(stream);
+ /*JavaClassRenderer renderer = new JavaClassRenderer();
+ renderer.render(claz, new PrintWriter(System.err));*/
+ assertEquals(claz.getFullName(), FULL_NAME);
+ assertEquals(claz.getName(), TAB_PANEL_RENDERER);
+ assertEquals(claz.getPakg().getName(), PACKAGE);
+ assertEquals(claz.getSuperClass().getFullName(), SUPERCLASS);
+ assertTrue(containMethod(claz, ENCODE_BEGIN_METHOD));
+ assertTrue(containMethod(claz, ENCODE_CHILDREN_METHOD));
+ assertTrue(containMethod(claz, ENCODE_END_METHOD));
+ JavaMethod method = getMethodByName(claz, ENCODE_CHILDREN_METHOD);
+ assertNotNull(method);
+ String code = method.getMethodBody().toCode();
+ assertTrue(code.lastIndexOf(IF_FRAGMENT) != -1);
+ assertTrue(code.lastIndexOf(START_TABLE_FRAGMENT) != -1);
+ assertTrue(code.lastIndexOf(WRITE_ATTRIBBUTE_FRAGMENT) != -1);
+ assertTrue(code.lastIndexOf(START_DIV_FRAGMENT) != -1);
+ assertTrue(code.lastIndexOf(END_TABLE_FRAGMENT) != -1);
+ assertTrue(code.lastIndexOf(END_DIV_FRAGMENT) != -1);
+ assertTrue(code.lastIndexOf(START_TABLE_FRAGMENT) < code.lastIndexOf(START_DIV_FRAGMENT));
+ assertTrue(code.lastIndexOf(WRITE_ATTRIBBUTE_FRAGMENT) < code.lastIndexOf(START_DIV_FRAGMENT));
+ assertTrue(code.lastIndexOf(WRITE_ATTRIBBUTE_FRAGMENT) < code.lastIndexOf(END_TABLE_FRAGMENT));
+ assertTrue(code.lastIndexOf(END_TABLE_FRAGMENT) > code.lastIndexOf(END_DIV_FRAGMENT));
+ }
+
+ private JavaMethod getMethodByName(JavaClass clazz, String name) {
+ for(JavaMethod method : clazz.getMethods()){
+ if(method.getName().equals(name)){
+ return method;
+ }
+ }
+ return null;
+ }
+
+ private boolean containMethod(JavaClass clazz, String name){
+ for(JavaMethod method : clazz.getMethods()){
+ if(method.getName().equals(name)){
+ return true;
+ }
+ }
+ return false;
+ }
+}
Property changes on: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/TemplateReaderTest.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/resources/org/richfaces/cdk/template-simple.xml
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/template-simple.xml (rev 0)
+++ root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/template-simple.xml 2009-08-21 18:25:38 UTC (rev 15267)
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<cdk:root xmlns:cdk="http://richfaces.org/cdk"
+ class="org.richfaces.renderkit.html.TabPanelRenderer" componentclass="org.richfaces.component.UITabPanel">
+ <cdk:body>
+ <table border="0" cellpadding="0" cellspacing="0" id="#{clientId}"
+ class="rich-tabpanel #{component.attributes['styleClass']}"/>
+</cdk:body>
+</cdk:root>
\ No newline at end of file
Property changes on: root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/template-simple.xml
___________________________________________________________________
Name: svn:mime-type
+ text/xml
Name: svn:eol-style
+ native
Added: root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/template.xml
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/template.xml (rev 0)
+++ root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/template.xml 2009-08-21 18:25:38 UTC (rev 15267)
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<cdk:root xmlns:cdk="http://richfaces.org/cdk"
+ class="org.richfaces.renderkit.html.TabPanelRenderer"
+ componentclass="org.richfaces.component.UITabPanel">
+<cdk:body>
+<cdk:clientid var="clientId" />
+<table border="0" cellpadding="0" cellspacing="0" id="#{clientId}"
+ class="rich-tabpanel #{component.attributes['styleClass']}">
+ <tbody>
+ <tr>
+ <td align="#{component.attributes['headerAlignment']}" class="rich-tab-bottom-line #{component.attributes['headerClass']}">
+ <div style="display: none;">
+ <cdk:if test="#{clientSide}">
+ <input autocomplete="off" type="hidden"
+ id="#{clientId}_input"
+ name="#{clientId}"
+ value=" " />
+ </cdk:if>
+ </div>
+ </td>
+ </tr>
+ </tbody>
+ </table>
+ </cdk:body>
+</cdk:root>
\ No newline at end of file
Property changes on: root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/template.xml
___________________________________________________________________
Name: svn:mime-type
+ text/xml
Name: svn:eol-style
+ native
15 years, 4 months
JBoss Rich Faces SVN: r15266 - in root/cdk/trunk/plugins/generator/src: main/java/org/richfaces/cdk/parser and 6 other directories.
by richfaces-svn-commits@lists.jboss.org
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
15 years, 4 months