JBoss Rich Faces SVN: r15794 - in root/cdk/trunk/plugins/maven-resource-dependency-plugin/src/main/java/org/richfaces/cdk/rd: generator and 3 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: Alex.Kolonitsky
Date: 2009-11-01 11:31:55 -0500 (Sun, 01 Nov 2009)
New Revision: 15794
Modified:
root/cdk/trunk/plugins/maven-resource-dependency-plugin/src/main/java/org/richfaces/cdk/rd/Component.java
root/cdk/trunk/plugins/maven-resource-dependency-plugin/src/main/java/org/richfaces/cdk/rd/Components.java
root/cdk/trunk/plugins/maven-resource-dependency-plugin/src/main/java/org/richfaces/cdk/rd/JarResourceScanner.java
root/cdk/trunk/plugins/maven-resource-dependency-plugin/src/main/java/org/richfaces/cdk/rd/generator/ResourceAssembler.java
root/cdk/trunk/plugins/maven-resource-dependency-plugin/src/main/java/org/richfaces/cdk/rd/generator/ResourcesGenerator.java
root/cdk/trunk/plugins/maven-resource-dependency-plugin/src/main/java/org/richfaces/cdk/rd/generator/ScriptAssembler.java
root/cdk/trunk/plugins/maven-resource-dependency-plugin/src/main/java/org/richfaces/cdk/rd/generator/StyleAssembler.java
root/cdk/trunk/plugins/maven-resource-dependency-plugin/src/main/java/org/richfaces/cdk/rd/handler/ComponentsHandler.java
root/cdk/trunk/plugins/maven-resource-dependency-plugin/src/main/java/org/richfaces/cdk/rd/mojo/ResourceDependencyMojo.java
root/cdk/trunk/plugins/maven-resource-dependency-plugin/src/main/java/org/richfaces/cdk/rd/utils/PluginUtils.java
Log:
Code style policy
https://jira.jboss.org/jira/browse/RFPL-195
Modified: root/cdk/trunk/plugins/maven-resource-dependency-plugin/src/main/java/org/richfaces/cdk/rd/Component.java
===================================================================
--- root/cdk/trunk/plugins/maven-resource-dependency-plugin/src/main/java/org/richfaces/cdk/rd/Component.java 2009-11-01 16:30:05 UTC (rev 15793)
+++ root/cdk/trunk/plugins/maven-resource-dependency-plugin/src/main/java/org/richfaces/cdk/rd/Component.java 2009-11-01 16:31:55 UTC (rev 15794)
@@ -18,6 +18,9 @@
* 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.rd;
import java.util.ArrayList;
@@ -27,82 +30,96 @@
* @author Anton Belevich
*
*/
-public class Component implements Comparable<Component>{
-
- private String componentName;
-
- private List <String> scripts = new ArrayList<String>();
-
- private List <String> styles = new ArrayList<String>();
-
-
- public String getComponentName() {
- return componentName;
- }
+public class Component implements Comparable<Component> {
+ private List<String> scripts = new ArrayList<String>();
+ private List<String> styles = new ArrayList<String>();
+ private String componentName;
- public void setComponentName(String componentName) {
- this.componentName = componentName;
- }
-
- public void addScript(String script){
- scripts.add(script);
- }
-
- public void addStyle(String style){
- styles.add(style);
- }
-
- public List <String> getStyles() {
- return this.styles;
- }
-
- public List <String> getScripts() {
- return this.scripts;
- }
+ public String getComponentName() {
+ return componentName;
+ }
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((componentName == null) ? 0 : componentName.hashCode());
- result = prime * result + ((scripts == null) ? 0 : scripts.hashCode());
- result = prime * result + ((styles == null) ? 0 : styles.hashCode());
- return result;
- }
+ public void setComponentName(String componentName) {
+ this.componentName = componentName;
+ }
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- final Component other = (Component) obj;
- if (componentName == null) {
- if (other.componentName != null)
- return false;
- } else if (!componentName.equals(other.componentName))
- return false;
- if (scripts == null) {
- if (other.scripts != null)
- return false;
- } else if (!scripts.equals(other.scripts))
- return false;
- if (styles == null) {
- if (other.styles != null)
- return false;
- } else if (!styles.equals(other.styles))
- return false;
- return true;
- }
+ public void addScript(String script) {
+ scripts.add(script);
+ }
- public int compareTo(Component o) {
- return componentName.compareToIgnoreCase(o.getComponentName());
- }
+ public void addStyle(String style) {
+ styles.add(style);
+ }
- @Override
- public String toString() {
- return "Component: " + componentName;
- }
+ public List<String> getStyles() {
+ return this.styles;
+ }
+
+ public List<String> getScripts() {
+ return this.scripts;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+
+ result = prime * result + ((componentName == null) ? 0 : componentName.hashCode());
+ result = prime * result + ((scripts == null) ? 0 : scripts.hashCode());
+ result = prime * result + ((styles == null) ? 0 : styles.hashCode());
+
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+
+ if (obj == null) {
+ return false;
+ }
+
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+
+ final Component other = (Component) obj;
+
+ if (componentName == null) {
+ if (other.componentName != null) {
+ return false;
+ }
+ } else if (!componentName.equals(other.componentName)) {
+ return false;
+ }
+
+ if (scripts == null) {
+ if (other.scripts != null) {
+ return false;
+ }
+ } else if (!scripts.equals(other.scripts)) {
+ return false;
+ }
+
+ if (styles == null) {
+ if (other.styles != null) {
+ return false;
+ }
+ } else if (!styles.equals(other.styles)) {
+ return false;
+ }
+
+ return true;
+ }
+
+ public int compareTo(Component o) {
+ return componentName.compareToIgnoreCase(o.getComponentName());
+ }
+
+ @Override
+ public String toString() {
+ return "Component: " + componentName;
+ }
}
Modified: root/cdk/trunk/plugins/maven-resource-dependency-plugin/src/main/java/org/richfaces/cdk/rd/Components.java
===================================================================
--- root/cdk/trunk/plugins/maven-resource-dependency-plugin/src/main/java/org/richfaces/cdk/rd/Components.java 2009-11-01 16:30:05 UTC (rev 15793)
+++ root/cdk/trunk/plugins/maven-resource-dependency-plugin/src/main/java/org/richfaces/cdk/rd/Components.java 2009-11-01 16:31:55 UTC (rev 15794)
@@ -18,6 +18,9 @@
* 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.rd;
import java.util.ArrayList;
@@ -28,60 +31,73 @@
*
*/
public class Components {
-
- private String namespace;
-
- private List <Component> components = new ArrayList<Component> ();
+ private List<Component> components = new ArrayList<Component>();
+ private String namespace;
- public String getNamespace() {
- return namespace;
- }
+ public String getNamespace() {
+ return namespace;
+ }
- public void setNamespace(String namespace) {
- this.namespace = namespace;
- }
+ public void setNamespace(String namespace) {
+ this.namespace = namespace;
+ }
- public void addComponent(Component component) {
- components.add(component);
- }
-
- public List <Component> getComponents() {
- return this.components;
- }
+ public void addComponent(Component component) {
+ components.add(component);
+ }
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((components == null) ? 0 : components.hashCode());
- result = prime * result + ((namespace == null) ? 0 : namespace.hashCode());
- return result;
- }
+ public List<Component> getComponents() {
+ return this.components;
+ }
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- final Components other = (Components) obj;
- if (components == null) {
- if (other.components != null)
- return false;
- } else if (!components.equals(other.components))
- return false;
- if (namespace == null) {
- if (other.namespace != null)
- return false;
- } else if (!namespace.equals(other.namespace))
- return false;
- return true;
- }
-
- @Override
- public String toString() {
- return "Components set: " + namespace;
- }
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+
+ result = prime * result + ((components == null) ? 0 : components.hashCode());
+ result = prime * result + ((namespace == null) ? 0 : namespace.hashCode());
+
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+
+ if (obj == null) {
+ return false;
+ }
+
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+
+ final Components other = (Components) obj;
+
+ if (components == null) {
+ if (other.components != null) {
+ return false;
+ }
+ } else if (!components.equals(other.components)) {
+ return false;
+ }
+
+ if (namespace == null) {
+ if (other.namespace != null) {
+ return false;
+ }
+ } else if (!namespace.equals(other.namespace)) {
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ return "Components set: " + namespace;
+ }
}
Modified: root/cdk/trunk/plugins/maven-resource-dependency-plugin/src/main/java/org/richfaces/cdk/rd/JarResourceScanner.java
===================================================================
--- root/cdk/trunk/plugins/maven-resource-dependency-plugin/src/main/java/org/richfaces/cdk/rd/JarResourceScanner.java 2009-11-01 16:30:05 UTC (rev 15793)
+++ root/cdk/trunk/plugins/maven-resource-dependency-plugin/src/main/java/org/richfaces/cdk/rd/JarResourceScanner.java 2009-11-01 16:31:55 UTC (rev 15794)
@@ -18,80 +18,79 @@
* 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.rd;
import java.io.IOException;
+
import java.util.HashSet;
import java.util.Set;
import org.apache.commons.vfs.FileObject;
import org.apache.commons.vfs.FileType;
+
import org.codehaus.plexus.util.SelectorUtils;
-
+
/**
* @author Anton Belevich
*
*/
public class JarResourceScanner {
-
- private FileObject baseFile;
-
- private Set <FileObject> result = new HashSet <FileObject>();
-
- private String [] patterns = new String[] {"**"};
-
-
- public String[] getPatterns() {
- return patterns;
- }
+ private String[] patterns = new String[] {"**"};
+ private Set<FileObject> result = new HashSet<FileObject>();
+ private FileObject baseFile;
- public void setPatterns(String[] patterns) {
- this.patterns = patterns;
- }
+ public String[] getPatterns() {
+ return patterns;
+ }
- public FileObject getBaseFile() {
- return baseFile;
- }
+ public void setPatterns(String[] patterns) {
+ this.patterns = patterns;
+ }
- public void setBaseFile(FileObject baseFile) {
- this.baseFile = baseFile;
- }
-
- protected boolean isAcceptable(FileObject fileObject) {
-
- for (int i = 0; i < patterns.length; i++) {
- if(SelectorUtils.matchPath(patterns[i], fileObject.getName().getURI())) {
- return true;
- }
- }
-
- return false;
- }
+ public FileObject getBaseFile() {
+ return baseFile;
+ }
- protected void walk(FileObject file) throws IOException{
- FileObject [] children = file.getChildren();
- for(FileObject child : children) {
-
- if(child.getType() != FileType.FILE) {
- walk(child);
- } else if(isAcceptable(child)) {
- result.add(child);
- }
-
- }
- }
-
- public void doScan() throws IOException{
- if(baseFile != null && baseFile.exists()) {
- walk(baseFile);
- }
- }
+ public void setBaseFile(FileObject baseFile) {
+ this.baseFile = baseFile;
+ }
- public Set <FileObject> getResult() {
- return result;
- }
+ protected boolean isAcceptable(FileObject fileObject) {
+ for (int i = 0; i < patterns.length; i++) {
+ if (SelectorUtils.matchPath(patterns[i], fileObject.getName().getURI())) {
+ return true;
+ }
+ }
- public void setResult(Set <FileObject> result) {
- this.result = result;
- }
+ return false;
+ }
+
+ protected void walk(FileObject file) throws IOException {
+ FileObject[] children = file.getChildren();
+
+ for (FileObject child : children) {
+ if (child.getType() != FileType.FILE) {
+ walk(child);
+ } else if (isAcceptable(child)) {
+ result.add(child);
+ }
+ }
+ }
+
+ public void doScan() throws IOException {
+ if (baseFile != null && baseFile.exists()) {
+ walk(baseFile);
+ }
+ }
+
+ public Set<FileObject> getResult() {
+ return result;
+ }
+
+ public void setResult(Set<FileObject> result) {
+ this.result = result;
+ }
}
Modified: root/cdk/trunk/plugins/maven-resource-dependency-plugin/src/main/java/org/richfaces/cdk/rd/generator/ResourceAssembler.java
===================================================================
--- root/cdk/trunk/plugins/maven-resource-dependency-plugin/src/main/java/org/richfaces/cdk/rd/generator/ResourceAssembler.java 2009-11-01 16:30:05 UTC (rev 15793)
+++ root/cdk/trunk/plugins/maven-resource-dependency-plugin/src/main/java/org/richfaces/cdk/rd/generator/ResourceAssembler.java 2009-11-01 16:31:55 UTC (rev 15794)
@@ -18,9 +18,13 @@
* 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.rd.generator;
import java.io.File;
+
import java.net.URL;
/**
@@ -28,9 +32,7 @@
*
*/
public interface ResourceAssembler {
-
- public void assembly(URL resource);
-
- public void writeToFile(File file);
-
+ public void assembly(URL resource);
+
+ public void writeToFile(File file);
}
Modified: root/cdk/trunk/plugins/maven-resource-dependency-plugin/src/main/java/org/richfaces/cdk/rd/generator/ResourcesGenerator.java
===================================================================
--- root/cdk/trunk/plugins/maven-resource-dependency-plugin/src/main/java/org/richfaces/cdk/rd/generator/ResourcesGenerator.java 2009-11-01 16:30:05 UTC (rev 15793)
+++ root/cdk/trunk/plugins/maven-resource-dependency-plugin/src/main/java/org/richfaces/cdk/rd/generator/ResourcesGenerator.java 2009-11-01 16:31:55 UTC (rev 15794)
@@ -18,12 +18,18 @@
* 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.rd.generator;
import java.io.File;
import java.io.IOException;
+
import java.lang.reflect.Method;
+
import java.net.URL;
+
import java.util.Collection;
import java.util.List;
@@ -34,129 +40,122 @@
*
*/
public class ResourcesGenerator {
-
- private File assemblyFile;
-
- private Log log;
-
- private Collection<String> resources;
-
- private List <String> includesBefore;
-
- private List <String> includesAfter;
-
- private ResourceAssembler assembler;
-
- public ResourcesGenerator(Log log) {
- this.log = log;
- }
+ private ResourceAssembler assembler;
+ private File assemblyFile;
+ private List<String> includesAfter;
+ private List<String> includesBefore;
+ private Log log;
+ private Collection<String> resources;
- public void doAssembly() {
- if(resources != null) {
- if(includesBefore != null && !includesBefore.isEmpty()) {
- iterate(includesBefore);
- }
-
- if(resources != null && !resources.isEmpty()) {
- iterate(resources);
- }
-
- if(includesAfter != null && !includesAfter.isEmpty()) {
- iterate(includesAfter);
- }
- }
- }
-
- private void iterate(Collection<String> resources) {
- for (String resourceName: resources) {
-
- URL resource = getResourceURL(resourceName);
- log.info("concatenate resource: " + resource);
- if(resource != null) {
- if (assembler != null) {
- assembler.assembly(resource);
- }
- }
-
- }
- }
-
- private URL getResourceURL(String resourceName) {
- ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
- URL resource = classLoader.getResource(resourceName);
-
- try {
- if(resource == null) {
- //resolve framework script path
- Class clazz = classLoader.loadClass(resourceName);
- Object obj = clazz.newInstance();
- Method method = clazz.getMethod("getPath", new Class [0]);
-
- String path = (String) method.invoke(obj, new Object[0]);
- resource = classLoader.getResource(path);
- }
- } catch (Exception e) {
- log.error("Error process: " + resourceName + "\n" + e.getMessage(), e);
- }
-
- return resource;
- }
-
- public void writeToFile() {
- if(assemblyFile != null) {
-
- if(assemblyFile.exists()) {
- assemblyFile.delete();
- }
-
- try {
- assemblyFile.createNewFile();
-
- } catch (IOException e) {
- log.error("Error create assembly File: " + assemblyFile.getPath(),e);
- }
-
- assembler.writeToFile(assemblyFile);
- }
- }
+ public ResourcesGenerator(Log log) {
+ this.log = log;
+ }
- public File getAssemblyFile() {
- return assemblyFile;
- }
+ public void doAssembly() {
+ if (resources != null) {
+ if (includesBefore != null && !includesBefore.isEmpty()) {
+ iterate(includesBefore);
+ }
- public void setAssemblyFile(File assemblyFile) {
- this.assemblyFile = assemblyFile;
- }
+ if (resources != null && !resources.isEmpty()) {
+ iterate(resources);
+ }
- public Collection<String> getResources() {
- return resources;
- }
+ if (includesAfter != null && !includesAfter.isEmpty()) {
+ iterate(includesAfter);
+ }
+ }
+ }
- public void setResources(Collection<String> resources) {
- this.resources = resources;
- }
+ private void iterate(Collection<String> resources) {
+ for (String resourceName : resources) {
+ URL resource = getResourceURL(resourceName);
- public List<String> getIncludesBefore() {
- return includesBefore;
- }
+ log.info("concatenate resource: " + resource);
- public void setIncludesBefore(List<String> includesBefore) {
- this.includesBefore = includesBefore;
- }
+ if (resource != null) {
+ if (assembler != null) {
+ assembler.assembly(resource);
+ }
+ }
+ }
+ }
- public List<String> getIncludesAfter() {
- return includesAfter;
- }
+ private URL getResourceURL(String resourceName) {
+ ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+ URL resource = classLoader.getResource(resourceName);
- public void setIncludesAfter(List<String> includesAfter) {
- this.includesAfter = includesAfter;
- }
+ try {
+ if (resource == null) {
- public ResourceAssembler getAssembler() {
- return assembler;
- }
+ // resolve framework script path
+ Class clazz = classLoader.loadClass(resourceName);
+ Object obj = clazz.newInstance();
+ Method method = clazz.getMethod("getPath", new Class[0]);
+ String path = (String) method.invoke(obj, new Object[0]);
- public void setAssembler(ResourceAssembler assembler) {
- this.assembler = assembler;
- }
+ resource = classLoader.getResource(path);
+ }
+ } catch (Exception e) {
+ log.error("Error process: " + resourceName + "\n" + e.getMessage(), e);
+ }
+
+ return resource;
+ }
+
+ public void writeToFile() {
+ if (assemblyFile != null) {
+ if (assemblyFile.exists()) {
+ assemblyFile.delete();
+ }
+
+ try {
+ assemblyFile.createNewFile();
+ } catch (IOException e) {
+ log.error("Error create assembly File: " + assemblyFile.getPath(), e);
+ }
+
+ assembler.writeToFile(assemblyFile);
+ }
+ }
+
+ public File getAssemblyFile() {
+ return assemblyFile;
+ }
+
+ public void setAssemblyFile(File assemblyFile) {
+ this.assemblyFile = assemblyFile;
+ }
+
+ public Collection<String> getResources() {
+ return resources;
+ }
+
+ public void setResources(Collection<String> resources) {
+ this.resources = resources;
+ }
+
+ public List<String> getIncludesBefore() {
+ return includesBefore;
+ }
+
+ public void setIncludesBefore(List<String> includesBefore) {
+ this.includesBefore = includesBefore;
+ }
+
+ public List<String> getIncludesAfter() {
+ return includesAfter;
+ }
+
+ public void setIncludesAfter(List<String> includesAfter) {
+ this.includesAfter = includesAfter;
+ }
+
+ public ResourceAssembler getAssembler() {
+ return assembler;
+ }
+
+ public void setAssembler(ResourceAssembler assembler) {
+ this.assembler = assembler;
+ }
}
Modified: root/cdk/trunk/plugins/maven-resource-dependency-plugin/src/main/java/org/richfaces/cdk/rd/generator/ScriptAssembler.java
===================================================================
--- root/cdk/trunk/plugins/maven-resource-dependency-plugin/src/main/java/org/richfaces/cdk/rd/generator/ScriptAssembler.java 2009-11-01 16:30:05 UTC (rev 15793)
+++ root/cdk/trunk/plugins/maven-resource-dependency-plugin/src/main/java/org/richfaces/cdk/rd/generator/ScriptAssembler.java 2009-11-01 16:31:55 UTC (rev 15794)
@@ -19,68 +19,67 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.rd.generator;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
+
import java.net.URL;
import org.apache.maven.plugin.logging.Log;
+
import org.codehaus.plexus.util.IOUtil;
/**
* @author Anton Belevich
- *
+ *
*/
public class ScriptAssembler implements ResourceAssembler {
+ private StringBuilder builder = new StringBuilder();
+ protected Log log;
- protected Log log;
-
- private StringBuilder builder = new StringBuilder();
-
- public ScriptAssembler(Log log) {
- this.log = log;
- }
-
- public void assembly(URL resource) {
- InputStream inputStream = null;
- try {
- inputStream = resource.openStream();
- builder.append(IOUtil.toString(inputStream));
- builder.append("\n");
- } catch (IOException e) {
- log.error("Error read resource: " + resource.getFile());
- } finally {
- if (inputStream != null) {
- try {
- inputStream.close();
- } catch (IOException e) {
- log.error(e.getLocalizedMessage(), e);
- }
- }
- }
-
- }
+ public ScriptAssembler(Log log) {
+ this.log = log;
+ }
- public void writeToFile(File file) {
- if(builder.length() > 0) {
-
- try {
- FileWriter fileWriter = new FileWriter(file);
-
- try {
- log.info("write result to the: " + file.getPath());
- IOUtil.copy(builder.toString(), fileWriter);
- } finally {
- fileWriter.close();
- }
-
- } catch (IOException e) {
- log.error("Error write file: " + file.getAbsolutePath(),e);
- }
-
- }
- }
+ public void assembly(URL resource) {
+ InputStream inputStream = null;
+
+ try {
+ inputStream = resource.openStream();
+ builder.append(IOUtil.toString(inputStream));
+ builder.append("\n");
+ } catch (IOException e) {
+ log.error("Error read resource: " + resource.getFile());
+ } finally {
+ if (inputStream != null) {
+ try {
+ inputStream.close();
+ } catch (IOException e) {
+ log.error(e.getLocalizedMessage(), e);
+ }
+ }
+ }
+ }
+
+ public void writeToFile(File file) {
+ if (builder.length() > 0) {
+ try {
+ FileWriter fileWriter = new FileWriter(file);
+
+ try {
+ log.info("write result to the: " + file.getPath());
+ IOUtil.copy(builder.toString(), fileWriter);
+ } finally {
+ fileWriter.close();
+ }
+ } catch (IOException e) {
+ log.error("Error write file: " + file.getAbsolutePath(), e);
+ }
+ }
+ }
}
Modified: root/cdk/trunk/plugins/maven-resource-dependency-plugin/src/main/java/org/richfaces/cdk/rd/generator/StyleAssembler.java
===================================================================
--- root/cdk/trunk/plugins/maven-resource-dependency-plugin/src/main/java/org/richfaces/cdk/rd/generator/StyleAssembler.java 2009-11-01 16:30:05 UTC (rev 15793)
+++ root/cdk/trunk/plugins/maven-resource-dependency-plugin/src/main/java/org/richfaces/cdk/rd/generator/StyleAssembler.java 2009-11-01 16:31:55 UTC (rev 15794)
@@ -18,12 +18,16 @@
* 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.rd.generator;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
+
import java.net.URL;
import org.apache.maven.plugin.logging.Log;
@@ -31,96 +35,88 @@
import org.apache.velocity.Template;
import org.apache.velocity.VelocityContext;
import org.apache.velocity.app.VelocityEngine;
+
import org.codehaus.plexus.util.IOUtil;
import org.codehaus.plexus.velocity.VelocityComponent;
+
import org.richfaces.builder.config.ParsingException;
import org.richfaces.builder.xml.XMLBody;
-
/**
* @author Anton Belevich
*
*/
-
public class StyleAssembler implements ResourceAssembler {
-
- protected Log log = new SystemStreamLog();
-
- private VelocityComponent velocityComponent;
-
- private StringBuilder builder = new StringBuilder();
-
- public StyleAssembler(Log log) {
- this.log = log;
- }
-
- public void assembly(URL resource) {
-
- String file = resource.getFile();
-
- if(log.isDebugEnabled()) {
- log.debug("process resource: " + file);
- }
-
- try {
- InputStream resourceInputStream = resource.openStream();
-
- try {
-
- if(file.endsWith(".xcss")) {
- XMLBody xmlBody = new XMLBody();
-
- try {
- xmlBody.loadXML(resourceInputStream,true);
- builder.append(xmlBody.getContent());
- } catch (ParsingException e) {
- log.error("Error process xcss: " + e.getMessage(), e);
- }
-
- } else {
- builder.append(IOUtil.toString(resourceInputStream));
- }
-
- } finally {
- resourceInputStream.close();
- }
-
- } catch (IOException e) {
- log.error("Error process css file " + file + " : " + e.getMessage(), e);
- }
- }
-
- public VelocityComponent getVelocityComponent() {
- return velocityComponent;
- }
+ protected Log log = new SystemStreamLog();
+ private StringBuilder builder = new StringBuilder();
+ private VelocityComponent velocityComponent;
- public void setVelocityComponent(VelocityComponent velocityComponent) {
- this.velocityComponent = velocityComponent;
- }
+ public StyleAssembler(Log log) {
+ this.log = log;
+ }
- public void writeToFile(File file) {
- try {
-
- if(builder.length() > 0 && velocityComponent != null) {
-
- VelocityContext context = new VelocityContext();
- context.put("content", builder);
- VelocityEngine engine = velocityComponent.getEngine();
- FileWriter fileWriter = new FileWriter(file);
- log.info("write result to the: " + file.getPath());
- try {
- Template velocityTemplate = engine.getTemplate("templates12/xcss.vm");
- velocityTemplate.merge(context, fileWriter);
- fileWriter.flush();
- } finally {
- fileWriter.close();
- }
-
- }
-
- } catch (Exception e) {
- log.error("Error write file: " + file.getAbsolutePath(),e);
- }
- }
-
+ public void assembly(URL resource) {
+ String file = resource.getFile();
+
+ if (log.isDebugEnabled()) {
+ log.debug("process resource: " + file);
+ }
+
+ try {
+ InputStream resourceInputStream = resource.openStream();
+
+ try {
+ if (file.endsWith(".xcss")) {
+ XMLBody xmlBody = new XMLBody();
+
+ try {
+ xmlBody.loadXML(resourceInputStream, true);
+ builder.append(xmlBody.getContent());
+ } catch (ParsingException e) {
+ log.error("Error process xcss: " + e.getMessage(), e);
+ }
+ } else {
+ builder.append(IOUtil.toString(resourceInputStream));
+ }
+ } finally {
+ resourceInputStream.close();
+ }
+ } catch (IOException e) {
+ log.error("Error process css file " + file + " : " + e.getMessage(), e);
+ }
+ }
+
+ public VelocityComponent getVelocityComponent() {
+ return velocityComponent;
+ }
+
+ public void setVelocityComponent(VelocityComponent velocityComponent) {
+ this.velocityComponent = velocityComponent;
+ }
+
+ public void writeToFile(File file) {
+ try {
+ if (builder.length() > 0 && velocityComponent != null) {
+ VelocityContext context = new VelocityContext();
+
+ context.put("content", builder);
+
+ VelocityEngine engine = velocityComponent.getEngine();
+ FileWriter fileWriter = new FileWriter(file);
+
+ log.info("write result to the: " + file.getPath());
+
+ try {
+ Template velocityTemplate = engine.getTemplate("templates12/xcss.vm");
+
+ velocityTemplate.merge(context, fileWriter);
+ fileWriter.flush();
+ } finally {
+ fileWriter.close();
+ }
+ }
+ } catch (Exception e) {
+ log.error("Error write file: " + file.getAbsolutePath(), e);
+ }
+ }
}
Modified: root/cdk/trunk/plugins/maven-resource-dependency-plugin/src/main/java/org/richfaces/cdk/rd/handler/ComponentsHandler.java
===================================================================
--- root/cdk/trunk/plugins/maven-resource-dependency-plugin/src/main/java/org/richfaces/cdk/rd/handler/ComponentsHandler.java 2009-11-01 16:30:05 UTC (rev 15793)
+++ root/cdk/trunk/plugins/maven-resource-dependency-plugin/src/main/java/org/richfaces/cdk/rd/handler/ComponentsHandler.java 2009-11-01 16:31:55 UTC (rev 15794)
@@ -18,13 +18,18 @@
* 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.rd.handler;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
import java.io.StringReader;
+
import java.net.URL;
+
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashSet;
@@ -33,9 +38,12 @@
import java.util.Set;
import org.apache.maven.plugin.logging.Log;
+
import org.codehaus.plexus.util.SelectorUtils;
+
import org.richfaces.cdk.rd.Component;
import org.richfaces.cdk.rd.Components;
+
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;
@@ -44,315 +52,295 @@
* @author Anton Belevich
*
*/
-public class ComponentsHandler extends DefaultHandler{
+public class ComponentsHandler extends DefaultHandler {
+ private static final String DEFAULT_DTD_PATH = "org/richfaces/default.dtd";
+ private String[] INCLUDE_ALL_PATTERN = {"**"};
+ private Map<String, Set<String>> processedComponents = new HashMap<String, Set<String>>();
+ private Set<String> scripts = new LinkedHashSet<String>();
+ private Set<String> styles = new LinkedHashSet<String>();
+ private String[] componentExcludes;
+ private String[] componentIncludes;
+ private Map<String, Components> components;
+ private String defaultDtdContent;
+ protected Log log;
+ private String[] namespaceExcludes;
+ private String[] namespaceIncludes;
+ private String[] scriptExcludes;
+ private String[] scriptIncludes;
+ private String[] styleExcludes;
+ private String[] styleIncludes;
- private String [] INCLUDE_ALL_PATTERN = {"**"};
+ public ComponentsHandler(Log log) {
+ this.log = log;
+ }
- protected Log log;
+ private Set<String> getProcessedComponentsSet(String uri) {
+ Set<String> result = processedComponents.get(uri);
- private Map <String, Components> components;
+ if (result == null) {
+ result = new HashSet<String>();
+ processedComponents.put(uri, result);
+ }
- private Map <String, Set<String>> processedComponents = new HashMap<String, Set<String>>();
-
- private Set <String> scripts = new LinkedHashSet<String>();
+ return result;
+ }
- private Set <String> styles = new LinkedHashSet<String>();
+ @Override
+ public void endElement(String uri, String localName, String name) throws SAXException {
+ if (components != null) {
+ Components library = components.get(uri);
- private String [] scriptIncludes;
+ if (library != null) {
+ Set<String> processedComponentsSet = getProcessedComponentsSet(uri);
- private String [] scriptExcludes;
+ if (processedComponentsSet.add(localName)) {
+ if (namespaceIncludes == null) {
+ namespaceIncludes = INCLUDE_ALL_PATTERN;
- private String [] styleIncludes;
+ if (log.isDebugEnabled()) {
+ log.debug("use default include patterns for namespaces");
+ }
+ }
- private String [] styleExcludes;
+ if (doMatch(namespaceIncludes, uri, true)) {
+ if (!doMatch(namespaceExcludes, uri, true)) {
+ List<Component> components = library.getComponents();
- private String [] namespaceIncludes;
+ if (componentIncludes == null) {
+ componentIncludes = INCLUDE_ALL_PATTERN;
- private String [] namespaceExcludes;
+ if (log.isDebugEnabled()) {
+ log.debug("use default include patterns for components");
+ }
+ }
- private String [] componentIncludes;
+ if (doMatch(componentIncludes, localName, false)) {
+ if (!doMatch(componentExcludes, localName, false)) {
+ for (Component component : components) {
+ String componentName = component.getComponentName();
- private String [] componentExcludes;
+ if (localName.equals(componentName)) {
+ log.info("process component: " + componentName);
+ collectScripts(component);
+ collectStyles(component);
- public ComponentsHandler(Log log) {
- this.log = log;
- }
-
- private Set<String> getProcessedComponentsSet(String uri) {
- Set<String> result = processedComponents.get(uri);
- if (result == null) {
- result = new HashSet<String>();
- processedComponents.put(uri, result);
- }
-
- return result;
- }
-
- @Override
- public void endElement(String uri, String localName, String name) throws SAXException {
- if (components != null) {
+ break;
+ }
+ }
+ }
+ }
+ } else if (log.isDebugEnabled()) {
+ log.debug("components from namespace " + uri + " are in excluded list");
+ }
+ } else if (log.isDebugEnabled()) {
+ log.debug("components from namespace " + uri + " aren't in include list");
+ }
+ }
+ }
+ }
+ }
- Components library = components.get(uri);
- if (library != null) {
-
- Set<String> processedComponentsSet = getProcessedComponentsSet(uri);
- if (processedComponentsSet.add(localName)) {
- if (namespaceIncludes == null) {
- namespaceIncludes = INCLUDE_ALL_PATTERN;
+ private void collectStyles(Component component) {
+ if (styleIncludes == null) {
+ styleIncludes = INCLUDE_ALL_PATTERN;
+ }
- if (log.isDebugEnabled()) {
- log.debug("use default include patterns for namespaces");
- }
- }
+ if (log.isDebugEnabled()) {
+ log.debug("start collect styles from component: " + component.getComponentName());
+ }
- if (doMatch(namespaceIncludes, uri, true)){
- if (!doMatch(namespaceExcludes, uri, true)) {
- List <Component> components = library.getComponents();
+ for (String style : component.getStyles()) {
+ if (doMatch(styleIncludes, style, true)) {
+ if (!doMatch(styleExcludes, style, true)) {
+ this.styles.add(style);
+ log.info("style " + style + " is collected");
+ } else {
+ log.info("style files are in excluded list");
- if (componentIncludes == null) {
- componentIncludes = INCLUDE_ALL_PATTERN;
+ for (String styleExclude : styleExcludes) {
+ log.info(styleExclude);
+ }
+ }
+ } else {
+ log.info("style files are not in included list");
- if(log.isDebugEnabled()) {
- log.debug("use default include patterns for components");
- }
- }
+ for (String styleInclude : styleIncludes) {
+ log.info(styleInclude);
+ }
+ }
+ }
+ }
- if (doMatch(componentIncludes, localName, false)) {
- if (!doMatch(componentExcludes, localName, false)) {
- for (Component component : components) {
+ private boolean doMatch(String[] patterns, String str, boolean matchPath) {
+ boolean allow = false;
- String componentName = component.getComponentName();
- if(localName.equals(componentName)) {
- log.info("process component: " + componentName);
+ if (patterns != null) {
+ for (String excludePattern : patterns) {
+ if (matchPath) {
+ allow = SelectorUtils.matchPath(excludePattern, str);
+ } else {
+ allow = SelectorUtils.match(excludePattern, str);
+ }
- collectScripts(component);
- collectStyles(component);
- break;
- }
- }
- }
- }
- } else if(log.isDebugEnabled()) {
- log.debug("components from namespace " + uri + " are in excluded list");
- }
- } else if(log.isDebugEnabled()) {
- log.debug("components from namespace " + uri + " aren't in include list");
- }
- }
- }
- }
- }
+ if (allow) {
+ break;
+ }
+ }
+ }
- private void collectStyles(Component component) {
+ return allow;
+ }
- if(styleIncludes == null) {
- styleIncludes = INCLUDE_ALL_PATTERN;
- }
+ private void collectScripts(Component component) {
+ if (scriptIncludes == null) {
+ scriptIncludes = INCLUDE_ALL_PATTERN;
+ }
- if(log.isDebugEnabled()) {
- log.debug("start collect styles from component: " + component.getComponentName() );
- }
+ if (log.isDebugEnabled()) {
+ log.debug("start collect scripts from component: " + component.getComponentName());
+ }
- for(String style : component.getStyles()) {
- if(doMatch(styleIncludes, style, true)) {
+ for (String script : component.getScripts()) {
+ if (doMatch(scriptIncludes, script, true)) {
+ if (!doMatch(scriptExcludes, script, true)) {
+ this.scripts.add(script);
+ log.info("script " + script + " is collected");
+ } else {
+ log.info("script files are in excluded list");
- if(!doMatch(styleExcludes, style, true)) {
- this.styles.add(style);
- log.info("style " + style + " is collected");
- } else {
- log.info("style files are in excluded list");
- for(String styleExclude: styleExcludes) {
- log.info(styleExclude);
- }
- }
+ for (String styleExclude : scriptExcludes) {
+ log.info(styleExclude);
+ }
+ }
+ } else {
+ log.info("script files are not in included list");
- } else {
- log.info("style files are not in included list");
- for(String styleInclude: styleIncludes) {
- log.info(styleInclude);
- }
- }
+ for (String styleInclude : scriptIncludes) {
+ log.info(styleInclude);
+ }
+ }
+ }
+ }
- }
- }
+ public Set<String> getStyles() {
+ return this.styles;
+ }
- private boolean doMatch(String [] patterns, String str, boolean matchPath) {
- boolean allow = false;
+ public Set<String> getScripts() {
+ return this.scripts;
+ }
- if(patterns != null) {
+ public Map<String, Components> getComponents() {
+ return components;
+ }
- for(String excludePattern: patterns) {
+ public void setComponents(Map<String, Components> components) {
+ this.components = components;
+ }
- if(matchPath) {
- allow = SelectorUtils.matchPath(excludePattern, str);
- } else {
- allow = SelectorUtils.match(excludePattern, str);
- }
+ public String[] getNamespaceExcludes() {
+ return namespaceExcludes;
+ }
- if(allow) break;
- }
+ public void setNamespaceExcludes(String[] namespaceExcludes) {
+ this.namespaceExcludes = namespaceExcludes;
+ }
- }
+ public String[] getComponentExcludes() {
+ return componentExcludes;
+ }
- return allow;
- }
+ public void setComponentExcludes(String[] componentExcludes) {
+ this.componentExcludes = componentExcludes;
+ }
- private void collectScripts(Component component) {
+ public String[] getScriptExcludes() {
+ return scriptExcludes;
+ }
- if (scriptIncludes == null) {
- scriptIncludes = INCLUDE_ALL_PATTERN;
- }
+ public void setScriptExcludes(String[] scriptExcludes) {
+ this.scriptExcludes = scriptExcludes;
+ }
- if (log.isDebugEnabled()) {
- log.debug("start collect scripts from component: " + component.getComponentName() );
- }
+ public String[] getStyleExcludes() {
+ return styleExcludes;
+ }
- for (String script : component.getScripts()) {
+ public void setStyleExcludes(String[] styleExcludes) {
+ this.styleExcludes = styleExcludes;
+ }
- if (doMatch(scriptIncludes, script, true)) {
- if (!doMatch(scriptExcludes, script, true)) {
- this.scripts.add(script);
- log.info("script " + script + " is collected");
- } else {
- log.info("script files are in excluded list");
- for(String styleExclude: scriptExcludes) {
- log.info(styleExclude);
- }
- }
+ public String[] getScriptIncludes() {
+ return scriptIncludes;
+ }
- } else {
- log.info("script files are not in included list");
- for(String styleInclude: scriptIncludes) {
- log.info(styleInclude);
- }
- }
- }
- }
+ public void setScriptIncludes(String[] scriptIncludes) {
+ this.scriptIncludes = scriptIncludes;
+ }
- public Set <String> getStyles() {
- return this.styles;
- }
+ public String[] getStyleIncludes() {
+ return styleIncludes;
+ }
- public Set <String> getScripts() {
- return this.scripts;
- }
+ public void setStyleIncludes(String[] styleIncludes) {
+ this.styleIncludes = styleIncludes;
+ }
- public Map <String, Components> getComponents() {
- return components;
- }
+ public String[] getNamespaceIncludes() {
+ return namespaceIncludes;
+ }
- public void setComponents(Map <String, Components> components) {
- this.components = components;
- }
+ public void setNamespaceIncludes(String[] namespaceIncludes) {
+ this.namespaceIncludes = namespaceIncludes;
+ }
- public String[] getNamespaceExcludes() {
- return namespaceExcludes;
- }
+ public String[] getComponentIncludes() {
+ return componentIncludes;
+ }
- public void setNamespaceExcludes(String[] namespaceExcludes) {
- this.namespaceExcludes = namespaceExcludes;
- }
+ public void setComponentIncludes(String[] componentIncludes) {
+ this.componentIncludes = componentIncludes;
+ }
- public String[] getComponentExcludes() {
- return componentExcludes;
- }
+ private String readDtdContent(String path) throws IOException {
+ URL url = Thread.currentThread().getContextClassLoader().getResource(path);
- public void setComponentExcludes(String[] componentExcludes) {
- this.componentExcludes = componentExcludes;
- }
+ if (url == null) {
+ url = getClass().getClassLoader().getResource(path);
+ }
- public String [] getScriptExcludes() {
- return scriptExcludes;
- }
+ Reader reader = new InputStreamReader(url.openStream());
+ String dtdContent;
- public void setScriptExcludes(String [] scriptExcludes) {
- this.scriptExcludes = scriptExcludes;
- }
+ try {
+ StringBuilder builder = new StringBuilder(32);
+ char[] cs = new char[512];
+ int read;
- public String [] getStyleExcludes() {
- return styleExcludes;
- }
+ while ((read = reader.read(cs)) != -1) {
+ builder.append(cs, 0, read);
+ }
- public void setStyleExcludes(String [] styleExcludes) {
- this.styleExcludes = styleExcludes;
- }
+ dtdContent = builder.toString();
+ } finally {
+ if (reader != null) {
+ try {
+ reader.close();
+ } catch (IOException e) {
+ log.error(e.getLocalizedMessage(), e);
+ }
+ }
+ }
- public String[] getScriptIncludes() {
- return scriptIncludes;
- }
+ return dtdContent;
+ }
- public void setScriptIncludes(String[] scriptIncludes) {
- this.scriptIncludes = scriptIncludes;
- }
+ @Override
+ public InputSource resolveEntity(String publicId, String systemId) throws IOException, SAXException {
+ if (defaultDtdContent == null) {
+ defaultDtdContent = readDtdContent(DEFAULT_DTD_PATH);
+ }
- public String[] getStyleIncludes() {
- return styleIncludes;
- }
-
- public void setStyleIncludes(String[] styleIncludes) {
- this.styleIncludes = styleIncludes;
- }
-
- public String[] getNamespaceIncludes() {
- return namespaceIncludes;
- }
-
- public void setNamespaceIncludes(String[] namespaceIncludes) {
- this.namespaceIncludes = namespaceIncludes;
- }
-
- public String[] getComponentIncludes() {
- return componentIncludes;
- }
-
- public void setComponentIncludes(String[] componentIncludes) {
- this.componentIncludes = componentIncludes;
- }
-
- private static final String DEFAULT_DTD_PATH = "org/richfaces/default.dtd";
-
- private String defaultDtdContent;
-
- private String readDtdContent(String path) throws IOException {
- URL url = Thread.currentThread().getContextClassLoader().getResource(path);
- if (url == null) {
- url = getClass().getClassLoader().getResource(path);
- }
-
- Reader reader = new InputStreamReader(url.openStream());
- String dtdContent;
-
- try {
- StringBuilder builder = new StringBuilder(32);
- char[] cs = new char[512];
- int read;
-
- while ((read = reader.read(cs)) != -1) {
- builder.append(cs, 0, read);
- }
-
- dtdContent = builder.toString();
- } finally {
- if (reader != null) {
- try {
- reader.close();
- } catch (IOException e) {
- log.error(e.getLocalizedMessage(), e);
- }
- }
- }
-
- return dtdContent;
- }
-
- @Override
- public InputSource resolveEntity(String publicId, String systemId)
- throws IOException, SAXException {
-
- if (defaultDtdContent == null) {
- defaultDtdContent = readDtdContent(DEFAULT_DTD_PATH);
- }
-
- return new InputSource(new StringReader(defaultDtdContent));
- }
+ return new InputSource(new StringReader(defaultDtdContent));
+ }
}
Modified: root/cdk/trunk/plugins/maven-resource-dependency-plugin/src/main/java/org/richfaces/cdk/rd/mojo/ResourceDependencyMojo.java
===================================================================
--- root/cdk/trunk/plugins/maven-resource-dependency-plugin/src/main/java/org/richfaces/cdk/rd/mojo/ResourceDependencyMojo.java 2009-11-01 16:30:05 UTC (rev 15793)
+++ root/cdk/trunk/plugins/maven-resource-dependency-plugin/src/main/java/org/richfaces/cdk/rd/mojo/ResourceDependencyMojo.java 2009-11-01 16:31:55 UTC (rev 15794)
@@ -18,11 +18,16 @@
* 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.rd.mojo;
import java.io.File;
+
import java.net.MalformedURLException;
import java.net.URL;
+
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
@@ -54,10 +59,12 @@
import org.apache.maven.plugin.logging.Log;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.artifact.MavenMetadataSource;
+
import org.codehaus.classworlds.ClassRealm;
import org.codehaus.classworlds.ClassWorld;
import org.codehaus.plexus.util.DirectoryScanner;
import org.codehaus.plexus.velocity.VelocityComponent;
+
import org.richfaces.cdk.rd.Components;
import org.richfaces.cdk.rd.generator.ResourceAssembler;
import org.richfaces.cdk.rd.generator.ResourcesGenerator;
@@ -70,451 +77,457 @@
* @author Anton Belevich
* @goal assembly-resources
* @phase generate-resources
- *
+ *
*/
-public class ResourceDependencyMojo extends AbstractMojo {
+public class ResourceDependencyMojo extends AbstractMojo {
- /**
- * Top maven project.
- *
- * @parameter expression="${project}"
- * @readonly
- */
- MavenProject project;
-
- /**
- * Used to look up Artifacts in the remote repository.
- *
- * @component
- */
- private ArtifactFactory factory;
-
- /**
- * Used to look up Artifacts in the remote repository.
- *
- * @component
- */
- private ArtifactResolver resolver;
-
- /**
- *
- * @component
- */
- private ArtifactMetadataSource metadataSource;
-
- /**
- * @component
- */
- protected VelocityComponent velocity;
-
- /**
- * The local repository.
- *
- * @parameter expression="${localRepository}"
- */
- private ArtifactRepository localRepository;
-
- /**
- * webSourceDirectory
- *
- * @parameter expression="${basedir}/src/main/webapp"
- */
- private File webSourceDirectory;
-
- /**
- * scriptFilePath
- * @parameter expression="custom-dependencies"
- */
- private String scriptFilePath;
-
-
- /**
- * outputResourceDirectory
- * @parameter expression="${project.build.directory}/generated-resources
- *
- */
- private File outputResourceDirectory;
- /**
- * styleFilePath
- * @parameter expression="custom-dependencies"
- */
- private String styleFilePath;
-
- /**
- * beforeScriptIncludes
- * @parameter
- */
- private List <String> beforeScriptIncludes;
-
- /**
- * afterScriptIncludes
- * @parameter
- */
- private List <String> afterScriptIncludes;
-
- /**
- * beforeStyleIncludes
- * @parameter
- */
- private List <String> beforeStyleIncludes;
-
- /**
- * afterStyleIncludes
- * @parameter
- */
- private List <String> afterStyleIncludes;
-
- /**
- * scriptIncludes
- * @parameter
- */
- private String [] scriptIncludes;
-
- /**
- * scriptExcludes
- * @parameter
- */
- private String [] scriptExcludes;
-
- /**
- * styleIncludes
- * @parameter
- */
- private String [] styleIncludes;
-
- /**
- * styleExcludes
- * @parameter
- */
- private String [] styleExcludes;
-
- /**
- * namespaceIncludes
- * @parameter
- */
- private String [] namespaceIncludes;
-
- /**
- * namespaceExcludes
- * @parameter
- */
- private String [] namespaceExcludes;
-
- /**
- * componentIncludes
- * @parameter
- */
- private String [] componentIncludes;
-
- /**
- * componentExcludes
- * @parameter
- */
- private String [] componentExcludes;
-
- /**
- * xmlConfigPatterns
- * @parameter
- */
- private String [] xmlConfigPatterns;
-
- /**
- * xhtmlIncludes
- * @parameter
- */
- private String [] xhtmlIncludes;
-
- /**
- * xhtmlExcludes
- * @parameter
- */
- private String [] xhtmlExcludes;
-
-
- public void execute() throws MojoExecutionException, MojoFailureException {
-
- try {
- Set <Artifact> artifacts = resolveDependenciesArtifacts();
-
- Digester defaultDigester = createDigester();
-
- Map <String, Components> components = new HashMap<String, Components>();
-
- if(xmlConfigPatterns == null) {
- xmlConfigPatterns = PluginUtils.DEFAULT_CONFIG_PATTERNS;
- }
-
- for (Artifact artifact : artifacts) {
- FileObject jar = resolveArtifact(artifact);
- getLog().info("Process jar: " + jar.getName().getFriendlyURI());
- FileObject [] configs = PluginUtils.resolveConfigsFromJar(jar, xmlConfigPatterns);
-
- if(configs.length == 0) {
- getLog().info("no dependecy files found");
- } else {
- getLog().info("next dependency files found");
- for (FileObject config: configs) {
- getLog().info(config.getName().getBaseName());
- }
- }
-
- components.putAll(PluginUtils.processConfigs(configs, defaultDigester));
- }
-
- if(!webSourceDirectory.exists()) {
- webSourceDirectory.mkdirs();
- }
-
- ComponentsHandler handler = findComponents(webSourceDirectory, components, xhtmlIncludes, xhtmlExcludes);
-
- ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
- ClassLoader contextClassLoader = createClassLoader();
- Thread.currentThread().setContextClassLoader(contextClassLoader);
-
- if(contextClassLoader != null) {
-
- Set <String> scripts = handler.getScripts();
-
- scriptFilePath = scriptFilePath.endsWith(".js") ? scriptFilePath : scriptFilePath + ".js";
- File scriptFile = new File(outputResourceDirectory, scriptFilePath);
- if(!scriptFile.exists()) {
- File parent = scriptFile.getParentFile();
- if(parent != null && !parent.exists()) {
- parent.mkdirs();
- }
- }
-
- ScriptAssembler scriptAssembler = new ScriptAssembler(getLog());
-
- if(!scripts.isEmpty()) {
- getLog().info("Start merge scripts to the: " + scriptFile.getPath());
- mergeResources(scriptFile,scriptAssembler, beforeScriptIncludes, afterScriptIncludes, scripts);
- }
-
- Set <String> styles = handler.getStyles();
-
- styleFilePath = styleFilePath.endsWith(".xcss") ? styleFilePath : styleFilePath + ".xcss";
-
- File styleFile = new File(outputResourceDirectory, styleFilePath);
- File parent = styleFile.getParentFile();
- if(parent != null && !parent.exists()) {
- parent.mkdirs();
- }
+ /**
+ * afterScriptIncludes
+ * @parameter
+ */
+ private List<String> afterScriptIncludes;
- StyleAssembler styleAssembler = new StyleAssembler(getLog());
- styleAssembler.setVelocityComponent(velocity);
-
- if(!styles.isEmpty()) {
- getLog().info("Start merge styles to the: " + styleFile.getPath());
- mergeResources(styleFile,styleAssembler, beforeStyleIncludes, afterStyleIncludes, styles);
- }
-
- Resource resource = new Resource();
- resource.setDirectory(outputResourceDirectory.getPath());
- project.addResource(resource);
- }
-
- Thread.currentThread().setContextClassLoader(oldClassLoader);
+ /**
+ * afterStyleIncludes
+ * @parameter
+ */
+ private List<String> afterStyleIncludes;
- } catch (Exception e) {
- getLog().error("Error generate resource", e);
- throw new MojoExecutionException(e.getMessage(),e);
- }
-
- }
-
- public void mergeResources(File assembly, ResourceAssembler assembler, List <String> beforeIncludes, List <String> afterIncludes, Collection<String> resources) {
- ResourcesGenerator styleGenerator = new ResourcesGenerator(getLog());
- styleGenerator.setAssembler(assembler);
- styleGenerator.setIncludesAfter(afterIncludes);
- styleGenerator.setIncludesBefore(beforeIncludes);
- styleGenerator.setResources(resources);
- styleGenerator.setAssemblyFile(assembly);
- styleGenerator.doAssembly();
- styleGenerator.writeToFile();
- }
-
- protected Set <Artifact> resolveDependenciesArtifacts() throws Exception {
-
- ArtifactResolutionResult result = null;
+ /**
+ * beforeScriptIncludes
+ * @parameter
+ */
+ private List<String> beforeScriptIncludes;
- List <Dependency> dependencies = project.getDependencies();
-
- Set <Artifact> artifacts = MavenMetadataSource.createArtifacts(factory, dependencies, null, null, project);
- artifacts.add(project.getArtifact());
-
- result = resolver.resolveTransitively(artifacts, project.getArtifact(), Collections.EMPTY_LIST, localRepository, metadataSource);
- return result.getArtifacts();
- }
-
-
- public ComponentsHandler findComponents (File webSourceDir, Map <String, Components> components, String [] includes, String [] excludes) throws Exception {
-
- if(includes == null) {
- includes = PluginUtils.DEFAULT_PROCESS_INCLUDES;
- }
-
- if(excludes == null) {
- excludes = new String[0];
- }
-
- DirectoryScanner scanner = new DirectoryScanner();
- scanner.setBasedir(webSourceDir);
- scanner.setIncludes(includes);
- scanner.setExcludes(excludes);
- scanner.addDefaultExcludes();
- getLog().info("search *.xhtml files");
- scanner.scan();
-
- String [] collectedFiles = scanner.getIncludedFiles();
-
- for(String collectedFile: collectedFiles) {
- getLog().info(collectedFile + " found");
- }
+ /**
+ * beforeStyleIncludes
+ * @parameter
+ */
+ private List<String> beforeStyleIncludes;
- ComponentsHandler handler = new ComponentsHandler(getLog());
- handler.setComponents(components);
- handler.setScriptIncludes(scriptIncludes);
- handler.setScriptExcludes(scriptExcludes);
- handler.setStyleIncludes(styleIncludes);
- handler.setStyleExcludes(styleExcludes);
- handler.setComponentIncludes(componentIncludes);
- handler.setComponentExcludes(componentExcludes);
- handler.setNamespaceIncludes(namespaceIncludes);
- handler.setNamespaceExcludes(namespaceExcludes);
+ /**
+ * componentExcludes
+ * @parameter
+ */
+ private String[] componentExcludes;
- SAXParserFactory saxParserFactory = SAXParserFactory.newInstance();
- saxParserFactory.setNamespaceAware(true);
-
- Log log = getLog();
- for (String processFile : collectedFiles) {
- SAXParser saxParser = saxParserFactory.newSAXParser();
- File file = new File(webSourceDir,processFile);
- if (file.exists()) {
-
- if (log.isDebugEnabled()) {
- log.debug("start process file: " + file.getPath());
- }
-
- try {
- saxParser.parse(file, handler);
- } catch (Exception e) {
- if (log.isDebugEnabled()) {
- log.error("Error process file: " + file.getPath() + "\n" + e.getMessage(), e);
- } else {
- log.error("Error process file: " + file.getPath() + "\n" + e.getMessage());
- }
- }
- }
- }
-
- return handler;
- }
-
- protected FileObject resolveArtifact(Artifact artifact) {
- FileObject jarFileObjects = null;
-
- if(artifact != null) {
-
- try {
- resolver.resolve(artifact, Collections.EMPTY_LIST, localRepository);
- if(getLog().isDebugEnabled()) {
- getLog().debug("artifact " + artifact.getFile().toURI() + " is resolved");
- }
- } catch (ArtifactResolutionException e) {
- getLog().error("Error with resolve artifact " + artifact.getFile().getPath() + "\n" + e.getMessage(), e);
- } catch (ArtifactNotFoundException e) {
- getLog().error("Not found artifact " + artifact.getFile().toURI() + "\n" + e.getMessage(), e);
- }
-
- File file = artifact.getFile();
-
- try {
- FileSystemManager manager = VFS.getManager();
- jarFileObjects = manager.resolveFile("jar:" + file.toURI());
- } catch (FileSystemException e) {
- getLog().error("Error during processing file: " + file.toURI()+ "\n" + e.getMessage(), e);
- }
-
- }
-
- return jarFileObjects;
- }
-
- public Digester createDigester() {
- // default digester for *.component-dependencies.xml
- return PluginUtils.createDefaultDigester();
- }
-
- protected ClassLoader createClassLoader() throws Exception {
-
- ClassLoader classLoader = null;
-
- Set <Artifact> artifacts = resolveDependenciesArtifacts();
-
- //create a new classloading space
- ClassWorld world = new ClassWorld();
-
- //use the existing ContextClassLoader in a realm of the classloading space
- ClassRealm realm = world.newRealm("org.richfaces.cdk", Thread.currentThread().getContextClassLoader());
-
- //create another realm for the app jars
- ClassRealm childRealm = realm.createChildRealm("jar");
-
- for(Artifact jar : artifacts ) {
- try {
- childRealm.addConstituent(jar.getFile().toURL());
- } catch (MalformedURLException e) {
- getLog().error("Artifact url " + jar.getFile() + " is invalid");
- }
- }
-
- // add project classes, scripts, styles etc ...
- List<Resource> compileClasspathElements = project.getCompileClasspathElements();
- addResources(childRealm, compileClasspathElements);
-
- List<Resource> scripts = project.getScriptSourceRoots();
- addResources(childRealm, scripts);
-
- List<Resource> resources = project.getResources();
- addResources(childRealm, resources);
-
- childRealm.addConstituent(webSourceDirectory.toURI().toURL());
-
- //make the child realm the ContextClassLoader
- classLoader = childRealm.getClassLoader();
- return classLoader;
- }
-
- private void addResources(ClassRealm realm, List resources) {
-
- if(realm != null && resources != null) {
-
- for(Object path: resources) {
- URL url = null;
- String formatted = null;
-
- if (path instanceof String) {
- formatted = (String)path;
- } else if(path instanceof Resource) {
- formatted = ((Resource)path).getDirectory();
- }
-
- if (formatted != null) {
- File file = new File(formatted);
-
- try {
- url = file.toURI().toURL();
- } catch (MalformedURLException e) {
- getLog().error("Resource url " + file.getPath() + " is invalid");
- }
-
- realm.addConstituent(url);
- }
- }
-
- }
-
- }
-
-}
+ /**
+ * componentIncludes
+ * @parameter
+ */
+ private String[] componentIncludes;
+
+ /**
+ * Used to look up Artifacts in the remote repository.
+ *
+ * @component
+ */
+ private ArtifactFactory factory;
+
+ /**
+ * The local repository.
+ *
+ * @parameter expression="${localRepository}"
+ */
+ private ArtifactRepository localRepository;
+
+ /**
+ *
+ * @component
+ */
+ private ArtifactMetadataSource metadataSource;
+
+ /**
+ * namespaceExcludes
+ * @parameter
+ */
+ private String[] namespaceExcludes;
+
+ /**
+ * namespaceIncludes
+ * @parameter
+ */
+ private String[] namespaceIncludes;
+
+ /**
+ * outputResourceDirectory
+ * @parameter expression="${project.build.directory}/generated-resources
+ *
+ */
+ private File outputResourceDirectory;
+
+ /**
+ * Top maven project.
+ *
+ * @parameter expression="${project}"
+ * @readonly
+ */
+ MavenProject project;
+
+ /**
+ * Used to look up Artifacts in the remote repository.
+ *
+ * @component
+ */
+ private ArtifactResolver resolver;
+
+ /**
+ * scriptExcludes
+ * @parameter
+ */
+ private String[] scriptExcludes;
+
+ /**
+ * scriptFilePath
+ * @parameter expression="custom-dependencies"
+ */
+ private String scriptFilePath;
+
+ /**
+ * scriptIncludes
+ * @parameter
+ */
+ private String[] scriptIncludes;
+
+ /**
+ * styleExcludes
+ * @parameter
+ */
+ private String[] styleExcludes;
+
+ /**
+ * styleFilePath
+ * @parameter expression="custom-dependencies"
+ */
+ private String styleFilePath;
+
+ /**
+ * styleIncludes
+ * @parameter
+ */
+ private String[] styleIncludes;
+
+ /**
+ * @component
+ */
+ protected VelocityComponent velocity;
+
+ /**
+ * webSourceDirectory
+ *
+ * @parameter expression="${basedir}/src/main/webapp"
+ */
+ private File webSourceDirectory;
+
+ /**
+ * xhtmlExcludes
+ * @parameter
+ */
+ private String[] xhtmlExcludes;
+
+ /**
+ * xhtmlIncludes
+ * @parameter
+ */
+ private String[] xhtmlIncludes;
+
+ /**
+ * xmlConfigPatterns
+ * @parameter
+ */
+ private String[] xmlConfigPatterns;
+
+ public void execute() throws MojoExecutionException, MojoFailureException {
+ try {
+ Set<Artifact> artifacts = resolveDependenciesArtifacts();
+ Digester defaultDigester = createDigester();
+ Map<String, Components> components = new HashMap<String, Components>();
+
+ if (xmlConfigPatterns == null) {
+ xmlConfigPatterns = PluginUtils.DEFAULT_CONFIG_PATTERNS;
+ }
+
+ for (Artifact artifact : artifacts) {
+ FileObject jar = resolveArtifact(artifact);
+
+ getLog().info("Process jar: " + jar.getName().getFriendlyURI());
+
+ FileObject[] configs = PluginUtils.resolveConfigsFromJar(jar, xmlConfigPatterns);
+
+ if (configs.length == 0) {
+ getLog().info("no dependecy files found");
+ } else {
+ getLog().info("next dependency files found");
+
+ for (FileObject config : configs) {
+ getLog().info(config.getName().getBaseName());
+ }
+ }
+
+ components.putAll(PluginUtils.processConfigs(configs, defaultDigester));
+ }
+
+ if (!webSourceDirectory.exists()) {
+ webSourceDirectory.mkdirs();
+ }
+
+ ComponentsHandler handler = findComponents(webSourceDirectory, components, xhtmlIncludes, xhtmlExcludes);
+ ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
+ ClassLoader contextClassLoader = createClassLoader();
+
+ Thread.currentThread().setContextClassLoader(contextClassLoader);
+
+ if (contextClassLoader != null) {
+ Set<String> scripts = handler.getScripts();
+
+ scriptFilePath = scriptFilePath.endsWith(".js") ? scriptFilePath : scriptFilePath + ".js";
+
+ File scriptFile = new File(outputResourceDirectory, scriptFilePath);
+
+ if (!scriptFile.exists()) {
+ File parent = scriptFile.getParentFile();
+
+ if (parent != null && !parent.exists()) {
+ parent.mkdirs();
+ }
+ }
+
+ ScriptAssembler scriptAssembler = new ScriptAssembler(getLog());
+
+ if (!scripts.isEmpty()) {
+ getLog().info("Start merge scripts to the: " + scriptFile.getPath());
+ mergeResources(scriptFile, scriptAssembler, beforeScriptIncludes, afterScriptIncludes, scripts);
+ }
+
+ Set<String> styles = handler.getStyles();
+
+ styleFilePath = styleFilePath.endsWith(".xcss") ? styleFilePath : styleFilePath + ".xcss";
+
+ File styleFile = new File(outputResourceDirectory, styleFilePath);
+ File parent = styleFile.getParentFile();
+
+ if (parent != null && !parent.exists()) {
+ parent.mkdirs();
+ }
+
+ StyleAssembler styleAssembler = new StyleAssembler(getLog());
+
+ styleAssembler.setVelocityComponent(velocity);
+
+ if (!styles.isEmpty()) {
+ getLog().info("Start merge styles to the: " + styleFile.getPath());
+ mergeResources(styleFile, styleAssembler, beforeStyleIncludes, afterStyleIncludes, styles);
+ }
+
+ Resource resource = new Resource();
+
+ resource.setDirectory(outputResourceDirectory.getPath());
+ project.addResource(resource);
+ }
+
+ Thread.currentThread().setContextClassLoader(oldClassLoader);
+ } catch (Exception e) {
+ getLog().error("Error generate resource", e);
+
+ throw new MojoExecutionException(e.getMessage(), e);
+ }
+ }
+
+ public void mergeResources(File assembly, ResourceAssembler assembler, List<String> beforeIncludes,
+ List<String> afterIncludes, Collection<String> resources) {
+ ResourcesGenerator styleGenerator = new ResourcesGenerator(getLog());
+
+ styleGenerator.setAssembler(assembler);
+ styleGenerator.setIncludesAfter(afterIncludes);
+ styleGenerator.setIncludesBefore(beforeIncludes);
+ styleGenerator.setResources(resources);
+ styleGenerator.setAssemblyFile(assembly);
+ styleGenerator.doAssembly();
+ styleGenerator.writeToFile();
+ }
+
+ protected Set<Artifact> resolveDependenciesArtifacts() throws Exception {
+ ArtifactResolutionResult result = null;
+ List<Dependency> dependencies = project.getDependencies();
+ Set<Artifact> artifacts = MavenMetadataSource.createArtifacts(factory, dependencies, null, null, project);
+
+ artifacts.add(project.getArtifact());
+ result = resolver.resolveTransitively(artifacts, project.getArtifact(), Collections.EMPTY_LIST,
+ localRepository, metadataSource);
+
+ return result.getArtifacts();
+ }
+
+ public ComponentsHandler findComponents(File webSourceDir, Map<String, Components> components, String[] includes,
+ String[] excludes)
+ throws Exception {
+ if (includes == null) {
+ includes = PluginUtils.DEFAULT_PROCESS_INCLUDES;
+ }
+
+ if (excludes == null) {
+ excludes = new String[0];
+ }
+
+ DirectoryScanner scanner = new DirectoryScanner();
+
+ scanner.setBasedir(webSourceDir);
+ scanner.setIncludes(includes);
+ scanner.setExcludes(excludes);
+ scanner.addDefaultExcludes();
+ getLog().info("search *.xhtml files");
+ scanner.scan();
+
+ String[] collectedFiles = scanner.getIncludedFiles();
+
+ for (String collectedFile : collectedFiles) {
+ getLog().info(collectedFile + " found");
+ }
+
+ ComponentsHandler handler = new ComponentsHandler(getLog());
+
+ handler.setComponents(components);
+ handler.setScriptIncludes(scriptIncludes);
+ handler.setScriptExcludes(scriptExcludes);
+ handler.setStyleIncludes(styleIncludes);
+ handler.setStyleExcludes(styleExcludes);
+ handler.setComponentIncludes(componentIncludes);
+ handler.setComponentExcludes(componentExcludes);
+ handler.setNamespaceIncludes(namespaceIncludes);
+ handler.setNamespaceExcludes(namespaceExcludes);
+
+ SAXParserFactory saxParserFactory = SAXParserFactory.newInstance();
+
+ saxParserFactory.setNamespaceAware(true);
+
+ Log log = getLog();
+
+ for (String processFile : collectedFiles) {
+ SAXParser saxParser = saxParserFactory.newSAXParser();
+ File file = new File(webSourceDir, processFile);
+
+ if (file.exists()) {
+ if (log.isDebugEnabled()) {
+ log.debug("start process file: " + file.getPath());
+ }
+
+ try {
+ saxParser.parse(file, handler);
+ } catch (Exception e) {
+ if (log.isDebugEnabled()) {
+ log.error("Error process file: " + file.getPath() + "\n" + e.getMessage(), e);
+ } else {
+ log.error("Error process file: " + file.getPath() + "\n" + e.getMessage());
+ }
+ }
+ }
+ }
+
+ return handler;
+ }
+
+ protected FileObject resolveArtifact(Artifact artifact) {
+ FileObject jarFileObjects = null;
+
+ if (artifact != null) {
+ try {
+ resolver.resolve(artifact, Collections.EMPTY_LIST, localRepository);
+
+ if (getLog().isDebugEnabled()) {
+ getLog().debug("artifact " + artifact.getFile().toURI() + " is resolved");
+ }
+ } catch (ArtifactResolutionException e) {
+ getLog().error("Error with resolve artifact " + artifact.getFile().getPath() + "\n" + e.getMessage(),
+ e);
+ } catch (ArtifactNotFoundException e) {
+ getLog().error("Not found artifact " + artifact.getFile().toURI() + "\n" + e.getMessage(), e);
+ }
+
+ File file = artifact.getFile();
+
+ try {
+ FileSystemManager manager = VFS.getManager();
+
+ jarFileObjects = manager.resolveFile("jar:" + file.toURI());
+ } catch (FileSystemException e) {
+ getLog().error("Error during processing file: " + file.toURI() + "\n" + e.getMessage(), e);
+ }
+ }
+
+ return jarFileObjects;
+ }
+
+ public Digester createDigester() {
+
+ // default digester for *.component-dependencies.xml
+ return PluginUtils.createDefaultDigester();
+ }
+
+ protected ClassLoader createClassLoader() throws Exception {
+ ClassLoader classLoader = null;
+ Set<Artifact> artifacts = resolveDependenciesArtifacts();
+
+ // create a new classloading space
+ ClassWorld world = new ClassWorld();
+
+ // use the existing ContextClassLoader in a realm of the classloading space
+ ClassRealm realm = world.newRealm("org.richfaces.cdk", Thread.currentThread().getContextClassLoader());
+
+ // create another realm for the app jars
+ ClassRealm childRealm = realm.createChildRealm("jar");
+
+ for (Artifact jar : artifacts) {
+ try {
+ childRealm.addConstituent(jar.getFile().toURL());
+ } catch (MalformedURLException e) {
+ getLog().error("Artifact url " + jar.getFile() + " is invalid");
+ }
+ }
+
+ // add project classes, scripts, styles etc ...
+ List<Resource> compileClasspathElements = project.getCompileClasspathElements();
+
+ addResources(childRealm, compileClasspathElements);
+
+ List<Resource> scripts = project.getScriptSourceRoots();
+
+ addResources(childRealm, scripts);
+
+ List<Resource> resources = project.getResources();
+
+ addResources(childRealm, resources);
+ childRealm.addConstituent(webSourceDirectory.toURI().toURL());
+
+ // make the child realm the ContextClassLoader
+ classLoader = childRealm.getClassLoader();
+
+ return classLoader;
+ }
+
+ private void addResources(ClassRealm realm, List resources) {
+ if (realm != null && resources != null) {
+ for (Object path : resources) {
+ URL url = null;
+ String formatted = null;
+
+ if (path instanceof String) {
+ formatted = (String) path;
+ } else if (path instanceof Resource) {
+ formatted = ((Resource) path).getDirectory();
+ }
+
+ if (formatted != null) {
+ File file = new File(formatted);
+
+ try {
+ url = file.toURI().toURL();
+ } catch (MalformedURLException e) {
+ getLog().error("Resource url " + file.getPath() + " is invalid");
+ }
+
+ realm.addConstituent(url);
+ }
+ }
+ }
+ }
+}
Modified: root/cdk/trunk/plugins/maven-resource-dependency-plugin/src/main/java/org/richfaces/cdk/rd/utils/PluginUtils.java
===================================================================
--- root/cdk/trunk/plugins/maven-resource-dependency-plugin/src/main/java/org/richfaces/cdk/rd/utils/PluginUtils.java 2009-11-01 16:30:05 UTC (rev 15793)
+++ root/cdk/trunk/plugins/maven-resource-dependency-plugin/src/main/java/org/richfaces/cdk/rd/utils/PluginUtils.java 2009-11-01 16:31:55 UTC (rev 15794)
@@ -18,68 +18,72 @@
* 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.rd.utils;
import java.io.IOException;
import java.io.InputStream;
+
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.digester.Digester;
import org.apache.commons.vfs.FileObject;
+
import org.richfaces.cdk.rd.Component;
import org.richfaces.cdk.rd.Components;
import org.richfaces.cdk.rd.JarResourceScanner;
+
import org.xml.sax.SAXException;
public class PluginUtils {
+ public static String[] DEFAULT_CONFIG_PATTERNS = new String[] {"**/*.component-dependencies.xml"};
+ public static String[] DEFAULT_PROCESS_INCLUDES = new String[] {"**/*.xhtml"};
- public static String [] DEFAULT_CONFIG_PATTERNS = new String [] {"**/*.component-dependencies.xml"};
-
- public static String [] DEFAULT_PROCESS_INCLUDES = new String [] {"**/*.xhtml"};
+ public static FileObject[] resolveConfigsFromJar(FileObject jarFileObject, String[] patterns) throws IOException {
+ FileObject[] result = new FileObject[0];
+ JarResourceScanner jarScanner = new JarResourceScanner();
-
- public static FileObject [] resolveConfigsFromJar(FileObject jarFileObject, String [] patterns) throws IOException{
- FileObject [] result = new FileObject[0];
-
- JarResourceScanner jarScanner = new JarResourceScanner();
- jarScanner.setBaseFile(jarFileObject);
- jarScanner.setPatterns(patterns);
- jarScanner.doScan();
-
- result = (FileObject [])jarScanner.getResult().toArray(new FileObject[jarScanner.getResult().size()]);
- return result;
- }
-
- public static Map <String,Components> processConfigs(FileObject [] configs, Digester digester) throws SAXException, IOException {
- Map <String, Components>collector = new HashMap <String, Components>();
-
- for (FileObject config: configs) {
- InputStream configInputStream = config.getContent().getInputStream();
-
- try {
- Components components = (Components)digester.parse(configInputStream);
- collector.put(components.getNamespace(), components);
- } finally {
- configInputStream.close();
- }
-
- }
-
- return collector;
- }
-
- public static Digester createDefaultDigester() {
- Digester digester = new Digester();
- digester.addObjectCreate("components", Components.class);
- digester.addCallMethod("components/namespace", "setNamespace", 0);
- digester.addObjectCreate("components/component", Component.class);
- digester.addCallMethod("components/component/name", "setComponentName",0);
- digester.addCallMethod("components/component/scripts/script", "addScript",0);
- digester.addCallMethod("components/component/styles/style", "addStyle",0);
- digester.addSetNext("components/component", "addComponent");
-
- return digester;
- }
+ jarScanner.setBaseFile(jarFileObject);
+ jarScanner.setPatterns(patterns);
+ jarScanner.doScan();
+ result = (FileObject[]) jarScanner.getResult().toArray(new FileObject[jarScanner.getResult().size()]);
+
+ return result;
+ }
+
+ public static Map<String, Components> processConfigs(FileObject[] configs, Digester digester)
+ throws SAXException, IOException {
+ Map<String, Components> collector = new HashMap<String, Components>();
+
+ for (FileObject config : configs) {
+ InputStream configInputStream = config.getContent().getInputStream();
+
+ try {
+ Components components = (Components) digester.parse(configInputStream);
+
+ collector.put(components.getNamespace(), components);
+ } finally {
+ configInputStream.close();
+ }
+ }
+
+ return collector;
+ }
+
+ public static Digester createDefaultDigester() {
+ Digester digester = new Digester();
+
+ digester.addObjectCreate("components", Components.class);
+ digester.addCallMethod("components/namespace", "setNamespace", 0);
+ digester.addObjectCreate("components/component", Component.class);
+ digester.addCallMethod("components/component/name", "setComponentName", 0);
+ digester.addCallMethod("components/component/scripts/script", "addScript", 0);
+ digester.addCallMethod("components/component/styles/style", "addStyle", 0);
+ digester.addSetNext("components/component", "addComponent");
+
+ return digester;
+ }
}
-
15 years, 1 month
JBoss Rich Faces SVN: r15793 - in root/cdk/trunk/plugins/maven-javascript-plugin/src: main/java/net/sf/alchim/mojo/yuicompressor and 2 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: Alex.Kolonitsky
Date: 2009-11-01 11:30:05 -0500 (Sun, 01 Nov 2009)
New Revision: 15793
Modified:
root/cdk/trunk/plugins/maven-javascript-plugin/src/main/java/com/yahoo/platform/yui/compressor/CssCompressor.java
root/cdk/trunk/plugins/maven-javascript-plugin/src/main/java/com/yahoo/platform/yui/compressor/JavaScriptCompressor.java
root/cdk/trunk/plugins/maven-javascript-plugin/src/main/java/com/yahoo/platform/yui/compressor/JavaScriptErrorReporter.java
root/cdk/trunk/plugins/maven-javascript-plugin/src/main/java/com/yahoo/platform/yui/compressor/JavaScriptIdentifier.java
root/cdk/trunk/plugins/maven-javascript-plugin/src/main/java/com/yahoo/platform/yui/compressor/JavaScriptToken.java
root/cdk/trunk/plugins/maven-javascript-plugin/src/main/java/com/yahoo/platform/yui/compressor/ScriptOrFnScope.java
root/cdk/trunk/plugins/maven-javascript-plugin/src/main/java/net/sf/alchim/mojo/yuicompressor/Aggregation.java
root/cdk/trunk/plugins/maven-javascript-plugin/src/main/java/net/sf/alchim/mojo/yuicompressor/BasicRhinoShell.java
root/cdk/trunk/plugins/maven-javascript-plugin/src/main/java/net/sf/alchim/mojo/yuicompressor/ErrorReporter4Mojo.java
root/cdk/trunk/plugins/maven-javascript-plugin/src/main/java/net/sf/alchim/mojo/yuicompressor/JSLintChecker.java
root/cdk/trunk/plugins/maven-javascript-plugin/src/main/java/net/sf/alchim/mojo/yuicompressor/JSLintMojo.java
root/cdk/trunk/plugins/maven-javascript-plugin/src/main/java/net/sf/alchim/mojo/yuicompressor/MojoSupport.java
root/cdk/trunk/plugins/maven-javascript-plugin/src/main/java/net/sf/alchim/mojo/yuicompressor/SourceFile.java
root/cdk/trunk/plugins/maven-javascript-plugin/src/main/java/net/sf/alchim/mojo/yuicompressor/YuiCompressorMojo.java
root/cdk/trunk/plugins/maven-javascript-plugin/src/main/java/org/mozilla/javascript/Decompiler.java
root/cdk/trunk/plugins/maven-javascript-plugin/src/main/java/org/mozilla/javascript/Parser.java
root/cdk/trunk/plugins/maven-javascript-plugin/src/main/java/org/mozilla/javascript/Token.java
root/cdk/trunk/plugins/maven-javascript-plugin/src/main/java/org/mozilla/javascript/TokenStream.java
root/cdk/trunk/plugins/maven-javascript-plugin/src/test/java/net/sf/alchim/mojo/yuicompressor/AggregationTestCase.java
Log:
Code style policy
https://jira.jboss.org/jira/browse/RFPL-195
Modified: root/cdk/trunk/plugins/maven-javascript-plugin/src/main/java/com/yahoo/platform/yui/compressor/CssCompressor.java
===================================================================
--- root/cdk/trunk/plugins/maven-javascript-plugin/src/main/java/com/yahoo/platform/yui/compressor/CssCompressor.java 2009-11-01 16:28:50 UTC (rev 15792)
+++ root/cdk/trunk/plugins/maven-javascript-plugin/src/main/java/com/yahoo/platform/yui/compressor/CssCompressor.java 2009-11-01 16:30:05 UTC (rev 15793)
@@ -8,29 +8,31 @@
* This code is a port of Isaac Schlueter's cssmin utility.
*/
+
+
package com.yahoo.platform.yui.compressor;
import java.io.IOException;
import java.io.Reader;
import java.io.Writer;
+
import java.util.regex.Pattern;
import java.util.regex.Matcher;
public class CssCompressor {
-
private StringBuffer srcsb = new StringBuffer();
public CssCompressor(Reader in) throws IOException {
+
// Read the stream...
int c;
+
while ((c = in.read()) != -1) {
srcsb.append((char) c);
}
}
- public void compress(Writer out, int linebreakpos)
- throws IOException {
-
+ public void compress(Writer out, int linebreakpos) throws IOException {
Pattern p;
Matcher m;
String css;
@@ -39,10 +41,13 @@
// Remove all comment blocks...
sb = new StringBuffer(srcsb.toString());
+
while ((startIndex = sb.indexOf("/*")) >= 0) {
endIndex = sb.indexOf("*/", startIndex + 2);
- if (endIndex >= startIndex + 2)
+
+ if (endIndex >= startIndex + 2) {
sb.delete(startIndex, endIndex + 2);
+ }
}
css = sb.toString();
@@ -56,11 +61,14 @@
sb = new StringBuffer();
p = Pattern.compile("(^|\\})(([^\\{:])+:)+([^\\{]*\\{)");
m = p.matcher(css);
+
while (m.find()) {
String s = m.group();
+
s = s.replaceAll(":", "___PSEUDOCLASSCOLON___");
m.appendReplacement(sb, s);
}
+
m.appendTail(sb);
css = sb.toString();
css = css.replaceAll("\\s+([!{};:>+\\(\\)\\],])", "$1");
@@ -79,6 +87,7 @@
css = css.replaceAll(":0 0 0 0;", ":0;");
css = css.replaceAll(":0 0 0;", ":0;");
css = css.replaceAll(":0 0;", ":0;");
+
// Replace background-position:0; with background-position:0 0;
css = css.replaceAll("background-position:0;", "background-position:0 0;");
@@ -90,40 +99,49 @@
p = Pattern.compile("rgb\\s*\\(\\s*([0-9,\\s]+)\\s*\\)");
m = p.matcher(css);
sb = new StringBuffer();
+
while (m.find()) {
String[] rgbcolors = m.group(1).split(",");
StringBuffer hexcolor = new StringBuffer("#");
+
for (int i = 0; i < rgbcolors.length; i++) {
int val = Integer.parseInt(rgbcolors[i]);
+
if (val < 16) {
hexcolor.append("0");
}
+
hexcolor.append(Integer.toHexString(val));
}
+
m.appendReplacement(sb, hexcolor.toString());
}
+
m.appendTail(sb);
css = sb.toString();
// Shorten colors from #AABBCC to #ABC. Note that we want to make sure
// the color is not preceded by either ", " or =. Indeed, the property
- // filter: chroma(color="#FFFFFF");
+ // filter: chroma(color="#FFFFFF");
// would become
- // filter: chroma(color="#FFF");
+ // filter: chroma(color="#FFF");
// which makes the filter break in IE.
- p = Pattern.compile("([^\"'=\\s])(\\s*)#([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])");
+ p = Pattern.compile(
+ "([^\"'=\\s])(\\s*)#([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])");
m = p.matcher(css);
sb = new StringBuffer();
+
while (m.find()) {
+
// Test for AABBCC pattern
- if (m.group(3).equalsIgnoreCase(m.group(4)) &&
- m.group(5).equalsIgnoreCase(m.group(6)) &&
- m.group(7).equalsIgnoreCase(m.group(8))) {
+ if (m.group(3).equalsIgnoreCase(m.group(4)) && m.group(5).equalsIgnoreCase(m.group(6))
+ && m.group(7).equalsIgnoreCase(m.group(8))) {
m.appendReplacement(sb, m.group(1) + m.group(2) + "#" + m.group(3) + m.group(5) + m.group(7));
} else {
m.appendReplacement(sb, m.group());
}
}
+
m.appendTail(sb);
css = sb.toString();
@@ -131,14 +149,18 @@
css = css.replaceAll("[^\\}]+\\{;\\}", "");
if (linebreakpos >= 0) {
+
// Some source control tools don't like it when files containing lines longer
// than, say 8000 characters, are checked in. The linebreak option is used in
// that case to split long lines after a specific column.
int i = 0;
int linestartpos = 0;
+
sb = new StringBuffer(css);
+
while (i < sb.length()) {
char c = sb.charAt(i++);
+
if (c == '}' && i - linestartpos > linebreakpos) {
sb.insert(i, '\n');
linestartpos = i;
Modified: root/cdk/trunk/plugins/maven-javascript-plugin/src/main/java/com/yahoo/platform/yui/compressor/JavaScriptCompressor.java
===================================================================
--- root/cdk/trunk/plugins/maven-javascript-plugin/src/main/java/com/yahoo/platform/yui/compressor/JavaScriptCompressor.java 2009-11-01 16:28:50 UTC (rev 15792)
+++ root/cdk/trunk/plugins/maven-javascript-plugin/src/main/java/com/yahoo/platform/yui/compressor/JavaScriptCompressor.java 2009-11-01 16:30:05 UTC (rev 15793)
@@ -6,6 +6,8 @@
* http://developer.yahoo.net/yui/license.txt
*/
+
+
package com.yahoo.platform.yui.compressor;
import org.mozilla.javascript.*;
@@ -13,17 +15,18 @@
import java.io.IOException;
import java.io.Reader;
import java.io.Writer;
+
import java.util.*;
public class JavaScriptCompressor {
-
+ private static final int BUILDING_SYMBOL_TREE = 1;
+ private static final int CHECKING_SYMBOL_TREE = 2;
+ static final Set builtin = new HashSet();
+ static final Map literals = new Hashtable();
static final ArrayList ones;
+ static final ArrayList threes;
static final ArrayList twos;
- static final ArrayList threes;
- static final Set builtin = new HashSet();
- static final Map literals = new Hashtable();
-
static {
// This list contains all the 3 characters or less built-in global
@@ -31,22 +34,32 @@
// see anything missing.
builtin.add("NaN");
builtin.add("top");
+ ones = new ArrayList();
- ones = new ArrayList();
- for (char c = 'A'; c <= 'Z'; c++)
+ for (char c = 'A'; c <= 'Z'; c++) {
ones.add(Character.toString(c));
- for (char c = 'a'; c <= 'z'; c++)
+ }
+
+ for (char c = 'a'; c <= 'z'; c++) {
ones.add(Character.toString(c));
+ }
twos = new ArrayList();
+
for (int i = 0; i < ones.size(); i++) {
String one = (String) ones.get(i);
- for (char c = 'A'; c <= 'Z'; c++)
+
+ for (char c = 'A'; c <= 'Z'; c++) {
twos.add(one + Character.toString(c));
- for (char c = 'a'; c <= 'z'; c++)
+ }
+
+ for (char c = 'a'; c <= 'z'; c++) {
twos.add(one + Character.toString(c));
- for (char c = '0'; c <= '9'; c++)
+ }
+
+ for (char c = '0'; c <= '9'; c++) {
twos.add(one + Character.toString(c));
+ }
}
// Remove two-letter JavaScript reserved words and built-in globals...
@@ -56,16 +69,22 @@
twos.remove("if");
twos.remove("in");
twos.removeAll(builtin);
+ threes = new ArrayList();
- threes = new ArrayList();
for (int i = 0; i < twos.size(); i++) {
String two = (String) twos.get(i);
- for (char c = 'A'; c <= 'Z'; c++)
+
+ for (char c = 'A'; c <= 'Z'; c++) {
threes.add(two + Character.toString(c));
- for (char c = 'a'; c <= 'z'; c++)
+ }
+
+ for (char c = 'a'; c <= 'z'; c++) {
threes.add(two + Character.toString(c));
- for (char c = '0'; c <= '9'; c++)
+ }
+
+ for (char c = '0'; c <= '9'; c++) {
threes.add(two + Character.toString(c));
+ }
}
// Remove three-letter JavaScript reserved words and built-in globals...
@@ -79,7 +98,6 @@
// That's up to ((26+26)*(1+(26+26+10)))*(1+(26+26+10))-8
// (206,380 symbols per scope)
-
// The following list comes from org/mozilla/javascript/Decompiler.java...
literals.put(new Integer(Token.GET), "get ");
literals.put(new Integer(Token.SET), "set ");
@@ -169,75 +187,106 @@
literals.put(new Integer(Token.XMLATTR), "@");
}
+ private Stack scopes = new Stack();
+ private Hashtable indexedScopes = new Hashtable();
+ private ScriptOrFnScope globalScope = new ScriptOrFnScope(-1, null);
+ private int braceNesting;
+ private ErrorReporter logger;
+ private int mode;
+ private boolean munge;
+ private int offset;
+ private ArrayList srctokens, tokens;
+ private boolean warn;
+
+ public JavaScriptCompressor(Reader in, ErrorReporter reporter) throws IOException, EvaluatorException {
+ this.logger = reporter;
+ this.srctokens = parse(in, reporter);
+ }
+
private static int countChar(String haystack, char needle) {
int idx = 0;
int count = 0;
int length = haystack.length();
+
while (idx < length) {
char c = haystack.charAt(idx++);
+
if (c == needle) {
count++;
}
}
+
return count;
}
private static int printSourceString(String source, int offset, StringBuffer sb) {
int length = source.charAt(offset);
+
++offset;
+
if ((0x8000 & length) != 0) {
length = ((0x7FFF & length) << 16) | source.charAt(offset);
++offset;
}
+
if (sb != null) {
String str = source.substring(offset, offset + length);
+
sb.append(str);
}
+
return offset + length;
}
- private static int printSourceNumber(String source,
- int offset, StringBuffer sb) {
+ private static int printSourceNumber(String source, int offset, StringBuffer sb) {
double number = 0.0;
char type = source.charAt(offset);
+
++offset;
+
if (type == 'S') {
if (sb != null) {
number = source.charAt(offset);
}
+
++offset;
} else if (type == 'J' || type == 'D') {
if (sb != null) {
long lbits;
+
lbits = (long) source.charAt(offset) << 48;
lbits |= (long) source.charAt(offset + 1) << 32;
lbits |= (long) source.charAt(offset + 2) << 16;
lbits |= (long) source.charAt(offset + 3);
+
if (type == 'J') {
number = lbits;
} else {
number = Double.longBitsToDouble(lbits);
}
}
+
offset += 4;
} else {
+
// Bad source
throw new RuntimeException();
}
+
if (sb != null) {
sb.append(ScriptRuntime.numberToString(number, 10));
}
+
return offset;
}
- private static ArrayList parse(Reader in, ErrorReporter reporter)
- throws IOException, EvaluatorException {
-
+ private static ArrayList parse(Reader in, ErrorReporter reporter) throws IOException, EvaluatorException {
CompilerEnvirons env = new CompilerEnvirons();
Parser parser = new Parser(env, reporter);
+
parser.parse(in, null, 1);
+
String source = parser.getEncodedSource();
-
int offset = 0;
int length = source.length();
ArrayList tokens = new ArrayList();
@@ -245,28 +294,32 @@
while (offset < length) {
int tt = source.charAt(offset++);
+
switch (tt) {
-
- case Token.IECC:
- case Token.NAME:
- case Token.REGEXP:
- case Token.STRING:
+ case Token.IECC :
+ case Token.NAME :
+ case Token.REGEXP :
+ case Token.STRING :
sb.setLength(0);
offset = printSourceString(source, offset, sb);
tokens.add(new JavaScriptToken(tt, sb.toString()));
+
break;
- case Token.NUMBER:
+ case Token.NUMBER :
sb.setLength(0);
offset = printSourceNumber(source, offset, sb);
tokens.add(new JavaScriptToken(tt, sb.toString()));
+
break;
- default:
+ default :
String literal = (String) literals.get(new Integer(tt));
+
if (literal != null) {
tokens.add(new JavaScriptToken(tt, literal));
}
+
break;
}
}
@@ -275,7 +328,6 @@
}
private static ArrayList processStringLiterals(ArrayList tokens, boolean merge) {
-
String tv;
int i, length;
ArrayList result = new ArrayList();
@@ -283,49 +335,52 @@
// Concatenate string literals that are being appended wherever
// it is safe to do so. Note that we take care of the case:
- // "a" + "b".toUpperCase()
-
+ // "a" + "b".toUpperCase()
for (i = 0, length = tokens.size(); i < length; i++) {
token = (JavaScriptToken) tokens.get(i);
+
switch (token.getType()) {
-
- case Token.ADD:
+ case Token.ADD :
if (merge) {
if (i > 0 && i < length) {
prevToken = (JavaScriptToken) result.get(result.size() - 1);
nextToken = (JavaScriptToken) tokens.get(i + 1);
- if (prevToken.getType() == Token.STRING && nextToken.getType() == Token.STRING &&
- (i == length - 1 || ((JavaScriptToken) tokens.get(i + 2)).getType() != Token.DOT)) {
- result.set(result.size() - 1, new JavaScriptToken(Token.STRING,
- prevToken.getValue() + nextToken.getValue()));
+
+ if (prevToken.getType() == Token.STRING && nextToken.getType() == Token.STRING
+ && (i == length - 1
+ || ((JavaScriptToken) tokens.get(i + 2)).getType() != Token.DOT)) {
+ result.set(result.size() - 1,
+ new JavaScriptToken(Token.STRING,
+ prevToken.getValue() + nextToken.getValue()));
i++; // not a good practice, but oh well...
+
break;
}
}
}
- /* FALLSTHROUGH */
+ /* FALLSTHROUGH */
+ default :
+ result.add(token);
- default:
- result.add(token);
break;
}
}
// Second pass...
-
for (i = 0, length = result.size(); i < length; i++) {
token = (JavaScriptToken) result.get(i);
+
if (token.getType() == Token.STRING) {
tv = token.getValue();
// Finally, add the quoting characters and escape the string. We use
// the quoting character that minimizes the amount of escaping to save
// a few additional bytes.
-
char quotechar;
int singleQuoteCount = countChar(tv, '\'');
int doubleQuoteCount = countChar(tv, '"');
+
if (doubleQuoteCount <= singleQuoteCount) {
quotechar = '"';
} else {
@@ -335,13 +390,12 @@
tv = quotechar + escapeString(tv, quotechar) + quotechar;
// String concatenation transforms the old script scheme:
- // '<scr'+'ipt ...><'+'/script>'
+ // '<scr'+'ipt ...><'+'/script>'
// into the following:
- // '<script ...></script>'
+ // '<script ...></script>'
// which breaks if this code is embedded inside an HTML document.
// Since this is not the right way to do this, let's fix the code by
// transforming all "</script" into "<\/script"
-
if (tv.indexOf("</script") >= 0) {
tv = tv.replaceAll("<\\/script", "<\\\\/script");
}
@@ -355,7 +409,6 @@
// Add necessary escaping that was removed in Rhino's tokenizer.
private static String escapeString(String s, char quotechar) {
-
assert quotechar == '"' || quotechar == '\'';
if (s == null) {
@@ -363,51 +416,29 @@
}
StringBuffer sb = new StringBuffer();
+
for (int i = 0, L = s.length(); i < L; i++) {
int c = s.charAt(i);
+
if (c == quotechar) {
sb.append("\\");
}
+
sb.append((char) c);
}
return sb.toString();
}
- private ErrorReporter logger;
-
- private boolean munge;
- private boolean warn;
-
- private static final int BUILDING_SYMBOL_TREE = 1;
- private static final int CHECKING_SYMBOL_TREE = 2;
-
- private int mode;
- private int offset;
- private int braceNesting;
- private ArrayList srctokens, tokens;
- private Stack scopes = new Stack();
- private ScriptOrFnScope globalScope = new ScriptOrFnScope(-1, null);
- private Hashtable indexedScopes = new Hashtable();
-
- public JavaScriptCompressor(Reader in, ErrorReporter reporter)
- throws IOException, EvaluatorException {
-
- this.logger = reporter;
- this.srctokens = parse(in, reporter);
- }
-
- public void compress(Writer out, int linebreak, boolean munge, boolean warn,
- boolean preserveAllSemiColons, boolean preserveStringLiterals)
+ public void compress(Writer out, int linebreak, boolean munge, boolean warn, boolean preserveAllSemiColons,
+ boolean preserveStringLiterals)
throws IOException {
-
this.munge = munge;
this.warn = warn;
-
this.tokens = processStringLiterals(this.srctokens, !preserveStringLiterals);
-
buildSymbolTree();
mungeSymboltree();
+
StringBuffer sb = printSymbolTree(linebreak, preserveAllSemiColons);
out.write(sb.toString());
@@ -440,13 +471,17 @@
*/
private JavaScriptIdentifier getIdentifier(String symbol, ScriptOrFnScope scope) {
JavaScriptIdentifier identifier;
+
while (scope != null) {
identifier = scope.getIdentifier(symbol);
+
if (identifier != null) {
return identifier;
}
+
scope = scope.getParentScope();
}
+
return null;
}
@@ -459,6 +494,7 @@
assert scope != null;
if (scope == globalScope) {
+
// The global scope does not get obfuscated,
// so we don't need to worry about it...
return;
@@ -475,17 +511,25 @@
private String getDebugString(int max) {
assert max > 0;
+
StringBuffer result = new StringBuffer();
int start = Math.max(offset - max, 0);
int end = Math.min(offset + max, tokens.size());
+
for (int i = start; i < end; i++) {
JavaScriptToken token = (JavaScriptToken) tokens.get(i);
- if (i == offset)
+
+ if (i == offset) {
result.append(" ---> ");
+ }
+
result.append(token.getValue());
- if (i == offset)
+
+ if (i == offset) {
result.append(" <--- ");
+ }
}
+
return result.toString();
}
@@ -494,33 +538,38 @@
if (showDebugString) {
message = message + "\n" + getDebugString(10);
}
+
logger.warning(message, null, -1, null, -1);
}
}
private void parseFunctionDeclaration() {
-
String symbol;
JavaScriptToken token;
ScriptOrFnScope currentScope, fnScope;
JavaScriptIdentifier identifier;
currentScope = getCurrentScope();
+ token = consumeToken();
- token = consumeToken();
if (token.getType() == Token.NAME) {
if (mode == BUILDING_SYMBOL_TREE) {
+
// Get the name of the function and declare it in the current scope.
symbol = token.getValue();
+
if (currentScope.getIdentifier(symbol) != null) {
warn("[WARNING] The function " + symbol + " has already been declared in the same scope...", true);
}
+
currentScope.declareIdentifier(symbol);
}
+
token = consumeToken();
}
assert token.getType() == Token.LP;
+
if (mode == BUILDING_SYMBOL_TREE) {
fnScope = new ScriptOrFnScope(braceNesting, currentScope);
indexedScopes.put(new Integer(offset), fnScope);
@@ -530,16 +579,20 @@
// Parse function arguments.
int argpos = 0;
+
while ((token = consumeToken()).getType() != Token.RP) {
- assert token.getType() == Token.NAME ||
- token.getType() == Token.COMMA;
+ assert token.getType() == Token.NAME || token.getType() == Token.COMMA;
+
if (token.getType() == Token.NAME && mode == BUILDING_SYMBOL_TREE) {
symbol = token.getValue();
identifier = fnScope.declareIdentifier(symbol);
+
if (symbol.equals("$super") && argpos == 0) {
+
// Exception for Prototype 1.6...
identifier.preventMunging();
}
+
argpos++;
}
}
@@ -547,10 +600,10 @@
token = consumeToken();
assert token.getType() == Token.LC;
braceNesting++;
+ token = getToken(0);
- token = getToken(0);
- if (token.getType() == Token.STRING &&
- getToken(1).getType() == Token.SEMI) {
+ if (token.getType() == Token.STRING && getToken(1).getType() == Token.SEMI) {
+
// This is a hint. Hints are empty statements that look like
// "localvar1:nomunge, localvar2:nomunge"; They allow developers
// to prevent specific symbols from getting obfuscated (some heretic
@@ -560,26 +613,36 @@
// of a hint. However, in the future, the right hand side may contain
// other values.
consumeToken();
+
String hints = token.getValue();
+
// Remove the leading and trailing quotes...
hints = hints.substring(1, hints.length() - 1).trim();
+
StringTokenizer st1 = new StringTokenizer(hints, ",");
+
while (st1.hasMoreTokens()) {
String hint = st1.nextToken();
int idx = hint.indexOf(':');
+
if (idx <= 0 || idx >= hint.length() - 1) {
if (mode == BUILDING_SYMBOL_TREE) {
+
// No need to report the error twice, hence the test...
warn("[WARNING] Invalid hint syntax: " + hint, true);
}
+
break;
}
+
String variableName = hint.substring(0, idx).trim();
String variableType = hint.substring(idx + 1).trim();
+
if (mode == BUILDING_SYMBOL_TREE) {
fnScope.addHint(variableName, variableType);
} else if (mode == CHECKING_SYMBOL_TREE) {
identifier = fnScope.getIdentifier(variableName);
+
if (identifier != null) {
if (variableType.equals("nomunge")) {
identifier.preventMunging();
@@ -597,7 +660,6 @@
}
private void parseCatch() {
-
String symbol;
JavaScriptToken token;
ScriptOrFnScope currentScope;
@@ -609,11 +671,11 @@
assert token.getType() == Token.LP;
token = consumeToken();
assert token.getType() == Token.NAME;
-
symbol = token.getValue();
currentScope = getCurrentScope();
if (mode == BUILDING_SYMBOL_TREE) {
+
// We must declare the exception identifier in the containing function
// scope to avoid errors related to the obfuscation process. No need to
// display a warning if the symbol was already declared here...
@@ -632,95 +694,93 @@
// Parse the expression until we encounter a comma or a semi-colon
// in the same brace nesting, bracket nesting and paren nesting.
// Parse functions if any...
-
String symbol;
JavaScriptToken token;
ScriptOrFnScope currentScope;
JavaScriptIdentifier identifier;
-
int expressionBraceNesting = braceNesting;
int bracketNesting = 0;
int parensNesting = 0;
-
int length = tokens.size();
while (offset < length) {
-
token = consumeToken();
currentScope = getCurrentScope();
switch (token.getType()) {
-
- case Token.SEMI:
- case Token.COMMA:
- if (braceNesting == expressionBraceNesting &&
- bracketNesting == 0 &&
- parensNesting == 0) {
+ case Token.SEMI :
+ case Token.COMMA :
+ if (braceNesting == expressionBraceNesting && bracketNesting == 0 && parensNesting == 0) {
return;
}
+
break;
- case Token.FUNCTION:
+ case Token.FUNCTION :
parseFunctionDeclaration();
+
break;
- case Token.LC:
+ case Token.LC :
braceNesting++;
+
break;
- case Token.RC:
+ case Token.RC :
braceNesting--;
assert braceNesting >= expressionBraceNesting;
+
break;
- case Token.LB:
+ case Token.LB :
bracketNesting++;
+
break;
- case Token.RB:
+ case Token.RB :
bracketNesting--;
+
break;
- case Token.LP:
+ case Token.LP :
parensNesting++;
+
break;
- case Token.RP:
+ case Token.RP :
parensNesting--;
+
break;
- case Token.IECC:
+ case Token.IECC :
if (mode == BUILDING_SYMBOL_TREE) {
protectScopeFromObfuscation(currentScope);
- warn("[WARNING] Using JScript conditional comments is not recommended..." + (munge ? "\n[INFO] Using JSCript conditional comments reduces the level of compression!" : ""), true);
+ warn("[WARNING] Using JScript conditional comments is not recommended..."
+ + (munge
+ ? "\n[INFO] Using JSCript conditional comments reduces the level of compression!"
+ : ""), true);
}
+
break;
- case Token.NAME:
+ case Token.NAME :
symbol = token.getValue();
if (mode == BUILDING_SYMBOL_TREE) {
-
if (symbol.equals("eval")) {
-
protectScopeFromObfuscation(currentScope);
- warn("[WARNING] Using 'eval' is not recommended..." + (munge ? "\n[INFO] Using 'eval' reduces the level of compression!" : ""), true);
-
+ warn("[WARNING] Using 'eval' is not recommended..."
+ + (munge ? "\n[INFO] Using 'eval' reduces the level of compression!" : ""), true);
}
-
} else if (mode == CHECKING_SYMBOL_TREE) {
-
- if ((offset < 2 ||
- (getToken(-2).getType() != Token.DOT &&
- getToken(-2).getType() != Token.GET &&
- getToken(-2).getType() != Token.SET)) &&
- getToken(0).getType() != Token.OBJECTLIT) {
-
+ if ((offset < 2 || (getToken(-2).getType() != Token.DOT && getToken(
+ -2).getType() != Token.GET && getToken(-2).getType() != Token.SET)) && getToken(
+ 0).getType() != Token.OBJECTLIT) {
identifier = getIdentifier(symbol, currentScope);
if (identifier == null) {
+ if (symbol.length() <= 3 && !builtin.contains(symbol)) {
- if (symbol.length() <= 3 && !builtin.contains(symbol)) {
// Here, we found an undeclared and un-namespaced symbol that is
// 3 characters or less in length. Declare it in the global scope.
// We don't need to declare longer symbols since they won't cause
@@ -728,134 +788,137 @@
globalScope.declareIdentifier(symbol);
warn("[WARNING] Found an undeclared symbol: " + symbol, true);
}
-
} else {
-
identifier.incrementRefcount();
}
}
}
+
break;
}
}
}
private void parseScope(ScriptOrFnScope scope) {
-
String symbol;
JavaScriptToken token;
JavaScriptIdentifier identifier;
-
int length = tokens.size();
enterScope(scope);
while (offset < length) {
-
token = consumeToken();
switch (token.getType()) {
+ case Token.VAR :
+ case Token.CONST :
- case Token.VAR:
- case Token.CONST:
-
// The var keyword is followed by at least one symbol name.
// If several symbols follow, they are comma separated.
- for (; ;) {
+ for (;;) {
token = consumeToken();
-
assert token.getType() == Token.NAME;
if (mode == BUILDING_SYMBOL_TREE) {
symbol = token.getValue();
+
if (scope.getIdentifier(symbol) == null) {
scope.declareIdentifier(symbol);
} else {
- warn("[WARNING] The variable " + symbol + " has already been declared in the same scope...", true);
+ warn("[WARNING] The variable " + symbol
+ + " has already been declared in the same scope...", true);
}
}
token = getToken(0);
+ assert token.getType() == Token.SEMI || token.getType() == Token.ASSIGN
+ || token.getType() == Token.COMMA || token.getType() == Token.IN;
- assert token.getType() == Token.SEMI ||
- token.getType() == Token.ASSIGN ||
- token.getType() == Token.COMMA ||
- token.getType() == Token.IN;
-
if (token.getType() == Token.IN) {
break;
} else {
parseExpression();
token = getToken(-1);
+
if (token.getType() == Token.SEMI) {
break;
}
}
}
+
break;
- case Token.FUNCTION:
+ case Token.FUNCTION :
parseFunctionDeclaration();
+
break;
- case Token.LC:
+ case Token.LC :
braceNesting++;
+
break;
- case Token.RC:
+ case Token.RC :
braceNesting--;
assert braceNesting >= scope.getBraceNesting();
+
if (braceNesting == scope.getBraceNesting()) {
leaveCurrentScope();
+
return;
}
+
break;
- case Token.WITH:
+ case Token.WITH :
if (mode == BUILDING_SYMBOL_TREE) {
+
// Inside a 'with' block, it is impossible to figure out
// statically whether a symbol is a local variable or an
// object member. As a consequence, the only thing we can
// do is turn the obfuscation off for the highest scope
// containing the 'with' block.
protectScopeFromObfuscation(scope);
- warn("[WARNING] Using 'with' is not recommended" + (munge ? "(and it reduces the level of compression)" : ""), true);
+ warn("[WARNING] Using 'with' is not recommended"
+ + (munge ? "(and it reduces the level of compression)" : ""), true);
}
+
break;
- case Token.CATCH:
+ case Token.CATCH :
parseCatch();
+
break;
- case Token.IECC:
+ case Token.IECC :
if (mode == BUILDING_SYMBOL_TREE) {
protectScopeFromObfuscation(scope);
- warn("[WARNING] Using JScript conditional comments is not recommended..." + (munge ? "\n[INFO] Using JSCript conditional comments reduces the level of compression!" : ""), true);
+ warn("[WARNING] Using JScript conditional comments is not recommended..."
+ + (munge
+ ? "\n[INFO] Using JSCript conditional comments reduces the level of compression!"
+ : ""), true);
}
+
break;
- case Token.NAME:
+ case Token.NAME :
symbol = token.getValue();
if (mode == BUILDING_SYMBOL_TREE) {
-
if (symbol.equals("eval")) {
-
protectScopeFromObfuscation(scope);
- warn("[WARNING] Using 'eval' is not recommended..." + (munge ? "\n[INFO] Using 'eval' reduces the level of compression!" : ""), true);
-
+ warn("[WARNING] Using 'eval' is not recommended..."
+ + (munge ? "\n[INFO] Using 'eval' reduces the level of compression!" : ""), true);
}
-
} else if (mode == CHECKING_SYMBOL_TREE) {
-
- if ((offset < 2 || getToken(-2).getType() != Token.DOT) &&
- getToken(0).getType() != Token.OBJECTLIT) {
-
+ if ((offset < 2 || getToken(-2).getType() != Token.DOT)
+ && getToken(0).getType() != Token.OBJECTLIT) {
identifier = getIdentifier(symbol, scope);
if (identifier == null) {
+ if (symbol.length() <= 3 && !builtin.contains(symbol)) {
- if (symbol.length() <= 3 && !builtin.contains(symbol)) {
// Here, we found an undeclared and un-namespaced symbol that is
// 3 characters or less in length. Declare it in the global scope.
// We don't need to declare longer symbols since they won't cause
@@ -863,13 +926,12 @@
globalScope.declareIdentifier(symbol);
warn("[WARNING] Found an undeclared symbol: " + symbol, true);
}
-
} else {
-
identifier.incrementRefcount();
}
}
}
+
break;
}
}
@@ -886,7 +948,6 @@
}
private void mungeSymboltree() {
-
if (!munge) {
return;
}
@@ -895,12 +956,12 @@
// and un-namespaced global symbols that are 3 characters or less
// in length. Here is an example:
//
- // var declaredGlobalVar;
+ // var declaredGlobalVar;
//
- // function declaredGlobalFn() {
- // var localvar;
- // localvar = abc; // abc is an undeclared global symbol
- // }
+ // function declaredGlobalFn() {
+ // var localvar;
+ // localvar = abc; // abc is an undeclared global symbol
+ // }
//
// In the example above, there is a slim chance that localvar may be
// munged to 'abc', conflicting with the undeclared global symbol
@@ -911,7 +972,6 @@
//
// Note: Since we go through all the tokens to do this, we also use
// the opportunity to count how many times each identifier is used.
-
offset = 0;
braceNesting = 0;
scopes.clear();
@@ -920,9 +980,7 @@
globalScope.munge();
}
- private StringBuffer printSymbolTree(int linebreakpos, boolean preserveAllSemiColons)
- throws IOException {
-
+ private StringBuffer printSymbolTree(int linebreakpos, boolean preserveAllSemiColons) throws IOException {
offset = 0;
braceNesting = 0;
scopes.clear();
@@ -931,103 +989,112 @@
JavaScriptToken token;
ScriptOrFnScope currentScope;
JavaScriptIdentifier identifier;
-
int length = tokens.size();
StringBuffer result = new StringBuffer();
-
int linestartpos = 0;
enterScope(globalScope);
while (offset < length) {
-
token = consumeToken();
symbol = token.getValue();
currentScope = getCurrentScope();
switch (token.getType()) {
-
- case Token.NAME:
-
- if (offset >= 2 && getToken(-2).getType() == Token.DOT ||
- getToken(0).getType() == Token.OBJECTLIT) {
-
+ case Token.NAME :
+ if (offset >= 2 && getToken(-2).getType() == Token.DOT
+ || getToken(0).getType() == Token.OBJECTLIT) {
result.append(symbol);
-
} else {
+ identifier = getIdentifier(symbol, currentScope);
- identifier = getIdentifier(symbol, currentScope);
if (identifier != null) {
if (identifier.getMungedValue() != null) {
result.append(identifier.getMungedValue());
} else {
result.append(symbol);
}
+
if (currentScope != globalScope && identifier.getRefcount() == 0) {
- warn("[WARNING] The symbol " + symbol + " is declared but is apparently never used.\nThis code can probably be written in a more efficient way.", true);
+ warn("[WARNING] The symbol " + symbol
+ + " is declared but is apparently never used.\nThis code can probably be written in a more efficient way.", true);
}
} else {
result.append(symbol);
}
}
+
break;
- case Token.REGEXP:
- case Token.NUMBER:
- case Token.STRING:
+ case Token.REGEXP :
+ case Token.NUMBER :
+ case Token.STRING :
result.append(symbol);
+
break;
- case Token.ADD:
- case Token.SUB:
+ case Token.ADD :
+ case Token.SUB :
result.append((String) literals.get(new Integer(token.getType())));
+
if (offset < length) {
token = getToken(0);
- if (token.getType() == Token.INC ||
- token.getType() == Token.DEC ||
- token.getType() == Token.ADD ||
- token.getType() == Token.DEC) {
+
+ if (token.getType() == Token.INC || token.getType() == Token.DEC
+ || token.getType() == Token.ADD || token.getType() == Token.DEC) {
+
// Handle the case x +/- ++/-- y
// We must keep a white space here. Otherwise, x +++ y would be
// interpreted as x ++ + y by the compiler, which is a bug (due
// to the implicit assignment being done on the wrong variable)
result.append(" ");
- } else if (token.getType() == Token.POS && getToken(-1).getType() == Token.ADD ||
- token.getType() == Token.NEG && getToken(-1).getType() == Token.SUB) {
+ } else if (token.getType() == Token.POS && getToken(-1).getType() == Token.ADD
+ || token.getType() == Token.NEG && getToken(-1).getType() == Token.SUB) {
+
// Handle the case x + + y and x - - y
result.append(" ");
}
}
+
break;
- case Token.FUNCTION:
+ case Token.FUNCTION :
result.append("function");
token = consumeToken();
+
if (token.getType() == Token.NAME) {
result.append(" ");
symbol = token.getValue();
identifier = getIdentifier(symbol, currentScope);
assert identifier != null;
+
if (identifier.getMungedValue() != null) {
result.append(identifier.getMungedValue());
} else {
result.append(symbol);
}
+
if (currentScope != globalScope && identifier.getRefcount() == 0) {
- warn("[WARNING] The symbol " + symbol + " is declared but is apparently never used.\nThis code can probably be written in a more efficient way.", true);
+ warn("[WARNING] The symbol " + symbol
+ + " is declared but is apparently never used.\nThis code can probably be written in a more efficient way.", true);
}
+
token = consumeToken();
}
+
assert token.getType() == Token.LP;
result.append("(");
currentScope = (ScriptOrFnScope) indexedScopes.get(new Integer(offset));
enterScope(currentScope);
+
while ((token = consumeToken()).getType() != Token.RP) {
assert token.getType() == Token.NAME || token.getType() == Token.COMMA;
+
if (token.getType() == Token.NAME) {
symbol = token.getValue();
identifier = getIdentifier(symbol, currentScope);
assert identifier != null;
+
if (identifier.getMungedValue() != null) {
result.append(identifier.getMungedValue());
} else {
@@ -1037,111 +1104,137 @@
result.append(",");
}
}
+
result.append(")");
token = consumeToken();
assert token.getType() == Token.LC;
result.append("{");
braceNesting++;
token = getToken(0);
+
if (token.getType() == Token.STRING) {
+
// This is a hint. Skip it!
consumeToken();
token = getToken(0);
assert token.getType() == Token.SEMI;
consumeToken();
}
+
break;
- case Token.RETURN:
+ case Token.RETURN :
result.append("return");
+
// No space needed after 'return' when followed
// by '(', '[', '{', a string or a regexp.
if (offset < length) {
token = getToken(0);
- if (token.getType() != Token.LP &&
- token.getType() != Token.LB &&
- token.getType() != Token.LC &&
- token.getType() != Token.STRING &&
- token.getType() != Token.REGEXP) {
+
+ if (token.getType() != Token.LP && token.getType() != Token.LB && token.getType() != Token.LC
+ && token.getType() != Token.STRING && token.getType() != Token.REGEXP) {
result.append(" ");
}
}
+
break;
- case Token.CASE:
+ case Token.CASE :
result.append("case");
+
// White-space needed after 'case' when not followed by a string.
if (offset < length && getToken(0).getType() != Token.STRING) {
result.append(" ");
}
+
break;
- case Token.THROW:
+ case Token.THROW :
+
// White-space needed after 'throw' when not followed by a string.
result.append("throw");
+
if (offset < length && getToken(0).getType() != Token.STRING) {
result.append(" ");
}
+
break;
- case Token.BREAK:
+ case Token.BREAK :
result.append("break");
+
if (offset < length && getToken(0).getType() != Token.SEMI) {
+
// If 'break' is not followed by a semi-colon, it must be
// followed by a label, hence the need for a white space.
result.append(" ");
}
+
break;
- case Token.CONTINUE:
+ case Token.CONTINUE :
result.append("continue");
+
if (offset < length && getToken(0).getType() != Token.SEMI) {
+
// If 'continue' is not followed by a semi-colon, it must be
// followed by a label, hence the need for a white space.
result.append(" ");
}
+
break;
- case Token.LC:
+ case Token.LC :
result.append("{");
braceNesting++;
+
break;
- case Token.RC:
+ case Token.RC :
result.append("}");
braceNesting--;
assert braceNesting >= currentScope.getBraceNesting();
+
if (braceNesting == currentScope.getBraceNesting()) {
leaveCurrentScope();
}
+
break;
- case Token.SEMI:
+ case Token.SEMI :
+
// No need to output a semi-colon if the next character is a right-curly...
- if (preserveAllSemiColons || offset < length && getToken(0).getType() != Token.RC)
+ if (preserveAllSemiColons || offset < length && getToken(0).getType() != Token.RC) {
result.append(";");
+ }
+
if (linebreakpos >= 0 && result.length() - linestartpos > linebreakpos) {
+
// Some source control tools don't like it when files containing lines longer
// than, say 8000 characters, are checked in. The linebreak option is used in
// that case to split long lines after a specific column.
result.append("\n");
linestartpos = result.length();
}
+
break;
- case Token.IECC:
+ case Token.IECC :
result.append("/*");
result.append(symbol);
result.append("*/");
+
break;
- default:
+ default :
String literal = (String) literals.get(new Integer(token.getType()));
+
if (literal != null) {
result.append(literal);
} else {
warn("[WARNING] This symbol cannot be printed: " + symbol, true);
}
+
break;
}
}
Modified: root/cdk/trunk/plugins/maven-javascript-plugin/src/main/java/com/yahoo/platform/yui/compressor/JavaScriptErrorReporter.java
===================================================================
--- root/cdk/trunk/plugins/maven-javascript-plugin/src/main/java/com/yahoo/platform/yui/compressor/JavaScriptErrorReporter.java 2009-11-01 16:28:50 UTC (rev 15792)
+++ root/cdk/trunk/plugins/maven-javascript-plugin/src/main/java/com/yahoo/platform/yui/compressor/JavaScriptErrorReporter.java 2009-11-01 16:30:05 UTC (rev 15793)
@@ -6,6 +6,8 @@
* http://developer.yahoo.net/yui/license.txt
*/
+
+
package com.yahoo.platform.yui.compressor;
import org.mozilla.javascript.ErrorReporter;
@@ -14,35 +16,32 @@
import java.io.PrintStream;
class JavaScriptErrorReporter implements ErrorReporter {
-
- private boolean reportWarnings;
private PrintStream err;
+ private boolean reportWarnings;
JavaScriptErrorReporter(PrintStream err, boolean reportWarnings) {
this.err = err;
this.reportWarnings = reportWarnings;
}
- public void warning(String message, String sourceName,
- int line, String lineSource, int lineOffset) {
+ public void warning(String message, String sourceName, int line, String lineSource, int lineOffset) {
if (reportWarnings) {
reportMessage(message, sourceName, line, lineSource, lineOffset);
}
}
- public EvaluatorException runtimeError(String message, String sourceName,
- int line, String lineSource, int lineOffset) {
+ public EvaluatorException runtimeError(String message, String sourceName, int line, String lineSource,
+ int lineOffset) {
error(message, sourceName, line, lineSource, lineOffset);
+
return new EvaluatorException(message);
}
- public void error(String message, String sourceName,
- int line, String lineSource, int lineOffset) {
+ public void error(String message, String sourceName, int line, String lineSource, int lineOffset) {
reportMessage(message, sourceName, line, lineSource, lineOffset);
}
- private void reportMessage(String message, String sourceName,
- int line, String lineSource, int lineOffset) {
+ private void reportMessage(String message, String sourceName, int line, String lineSource, int lineOffset) {
if (line < 0) {
if (message.length() == 0) {
err.println("An unknown error occurred...");
Modified: root/cdk/trunk/plugins/maven-javascript-plugin/src/main/java/com/yahoo/platform/yui/compressor/JavaScriptIdentifier.java
===================================================================
--- root/cdk/trunk/plugins/maven-javascript-plugin/src/main/java/com/yahoo/platform/yui/compressor/JavaScriptIdentifier.java 2009-11-01 16:28:50 UTC (rev 15792)
+++ root/cdk/trunk/plugins/maven-javascript-plugin/src/main/java/com/yahoo/platform/yui/compressor/JavaScriptIdentifier.java 2009-11-01 16:30:05 UTC (rev 15793)
@@ -6,6 +6,8 @@
* http://developer.yahoo.net/yui/license.txt
*/
+
+
package com.yahoo.platform.yui.compressor;
import org.mozilla.javascript.Token;
@@ -14,11 +16,10 @@
* JavaScriptIdentifier represents a variable/function identifier.
*/
class JavaScriptIdentifier extends JavaScriptToken {
-
private int refcount = 0;
+ private boolean markedForMunging = true;
+ private ScriptOrFnScope declaredScope;
private String mungedValue;
- private ScriptOrFnScope declaredScope;
- private boolean markedForMunging = true;
JavaScriptIdentifier(String value, ScriptOrFnScope declaredScope) {
super(Token.NAME, value);
Modified: root/cdk/trunk/plugins/maven-javascript-plugin/src/main/java/com/yahoo/platform/yui/compressor/JavaScriptToken.java
===================================================================
--- root/cdk/trunk/plugins/maven-javascript-plugin/src/main/java/com/yahoo/platform/yui/compressor/JavaScriptToken.java 2009-11-01 16:28:50 UTC (rev 15792)
+++ root/cdk/trunk/plugins/maven-javascript-plugin/src/main/java/com/yahoo/platform/yui/compressor/JavaScriptToken.java 2009-11-01 16:30:05 UTC (rev 15793)
@@ -6,10 +6,11 @@
* http://developer.yahoo.net/yui/license.txt
*/
+
+
package com.yahoo.platform.yui.compressor;
public class JavaScriptToken {
-
private int type;
private String value;
Modified: root/cdk/trunk/plugins/maven-javascript-plugin/src/main/java/com/yahoo/platform/yui/compressor/ScriptOrFnScope.java
===================================================================
--- root/cdk/trunk/plugins/maven-javascript-plugin/src/main/java/com/yahoo/platform/yui/compressor/ScriptOrFnScope.java 2009-11-01 16:28:50 UTC (rev 15792)
+++ root/cdk/trunk/plugins/maven-javascript-plugin/src/main/java/com/yahoo/platform/yui/compressor/ScriptOrFnScope.java 2009-11-01 16:30:05 UTC (rev 15793)
@@ -6,6 +6,8 @@
* http://developer.yahoo.net/yui/license.txt
*/
+
+
package com.yahoo.platform.yui.compressor;
import java.util.ArrayList;
@@ -13,18 +15,18 @@
import java.util.Hashtable;
class ScriptOrFnScope {
-
+ private Hashtable identifiers = new Hashtable();
+ private Hashtable hints = new Hashtable();
+ private boolean markedForMunging = true;
private int braceNesting;
private ScriptOrFnScope parentScope;
private ArrayList subScopes;
- private Hashtable identifiers = new Hashtable();
- private Hashtable hints = new Hashtable();
- private boolean markedForMunging = true;
ScriptOrFnScope(int braceNesting, ScriptOrFnScope parentScope) {
this.braceNesting = braceNesting;
this.parentScope = parentScope;
this.subScopes = new ArrayList();
+
if (parentScope != null) {
parentScope.subScopes.add(this);
}
@@ -40,10 +42,12 @@
JavaScriptIdentifier declareIdentifier(String symbol) {
JavaScriptIdentifier identifier = (JavaScriptIdentifier) identifiers.get(symbol);
+
if (identifier == null) {
identifier = new JavaScriptIdentifier(symbol, this);
identifiers.put(symbol, identifier);
}
+
return identifier;
}
@@ -57,6 +61,7 @@
void preventMunging() {
if (parentScope != null) {
+
// The symbols in the global scope don't get munged,
// but the sub-scopes it contains do get munged.
markedForMunging = false;
@@ -66,30 +71,36 @@
private ArrayList getUsedSymbols() {
ArrayList result = new ArrayList();
Enumeration elements = identifiers.elements();
+
while (elements.hasMoreElements()) {
JavaScriptIdentifier identifier = (JavaScriptIdentifier) elements.nextElement();
String mungedValue = identifier.getMungedValue();
+
if (mungedValue == null) {
mungedValue = identifier.getValue();
}
+
result.add(mungedValue);
}
+
return result;
}
private ArrayList getAllUsedSymbols() {
ArrayList result = new ArrayList();
ScriptOrFnScope scope = this;
+
while (scope != null) {
result.addAll(scope.getUsedSymbols());
scope = scope.parentScope;
}
+
return result;
}
void munge() {
+ if (!markedForMunging) {
- if (!markedForMunging) {
// Stop right here if this scope was flagged as unsafe for munging.
return;
}
@@ -98,30 +109,34 @@
// Do not munge symbols in the global scope!
if (parentScope != null) {
-
ArrayList freeSymbols = new ArrayList();
freeSymbols.addAll(JavaScriptCompressor.ones);
freeSymbols.removeAll(getAllUsedSymbols());
+
if (freeSymbols.size() == 0) {
pickFromSet = 2;
freeSymbols.addAll(JavaScriptCompressor.twos);
freeSymbols.removeAll(getAllUsedSymbols());
}
+
if (freeSymbols.size() == 0) {
pickFromSet = 3;
freeSymbols.addAll(JavaScriptCompressor.threes);
freeSymbols.removeAll(getAllUsedSymbols());
}
+
if (freeSymbols.size() == 0) {
System.err.println("The YUI Compressor ran out of symbols. Aborting...");
System.exit(1);
}
Enumeration elements = identifiers.elements();
+
while (elements.hasMoreElements()) {
if (freeSymbols.size() == 0) {
pickFromSet++;
+
if (pickFromSet == 2) {
freeSymbols.addAll(JavaScriptCompressor.twos);
} else if (pickFromSet == 3) {
@@ -130,6 +145,7 @@
System.err.println("The YUI Compressor ran out of symbols. Aborting...");
System.exit(1);
}
+
// It is essential to remove the symbols already used in
// the containing scopes, or some of the variables declared
// in the containing scopes will be redeclared, which can
@@ -139,17 +155,20 @@
String mungedValue;
JavaScriptIdentifier identifier = (JavaScriptIdentifier) elements.nextElement();
+
if (identifier.isMarkedForMunging()) {
mungedValue = (String) freeSymbols.remove(0);
} else {
mungedValue = identifier.getValue();
}
+
identifier.setMungedValue(mungedValue);
}
}
for (int i = 0; i < subScopes.size(); i++) {
ScriptOrFnScope scope = (ScriptOrFnScope) subScopes.get(i);
+
scope.munge();
}
}
Modified: root/cdk/trunk/plugins/maven-javascript-plugin/src/main/java/net/sf/alchim/mojo/yuicompressor/Aggregation.java
===================================================================
--- root/cdk/trunk/plugins/maven-javascript-plugin/src/main/java/net/sf/alchim/mojo/yuicompressor/Aggregation.java 2009-11-01 16:28:50 UTC (rev 15792)
+++ root/cdk/trunk/plugins/maven-javascript-plugin/src/main/java/net/sf/alchim/mojo/yuicompressor/Aggregation.java 2009-11-01 16:30:05 UTC (rev 15793)
@@ -18,12 +18,15 @@
* 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 net.sf.alchim.mojo.yuicompressor;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
+
import java.util.ArrayList;
import java.util.List;
@@ -31,32 +34,39 @@
import org.codehaus.plexus.util.IOUtil;
public class Aggregation {
+ public boolean removeIncluded = false;
+ public boolean insertSemicolon = false;
+ public boolean insertNewLine = false;
+ public String[] excludes;
+ public String[] includes;
public File output;
public File sourceDirectory;
- public String[] includes;
- public String[] excludes;
- public boolean removeIncluded = false;
- public boolean insertNewLine = false;
- public boolean insertSemicolon = false;
-
+
public void run(File outputDirectory) throws Exception {
- if(null == sourceDirectory){
- sourceDirectory = outputDirectory;
- }
+ if (null == sourceDirectory) {
+ sourceDirectory = outputDirectory;
+ }
+
List<File> files = getIncludedFiles();
+
if (files.size() != 0) {
FileOutputStream out = new FileOutputStream(output);
+
try {
for (File file : files) {
FileInputStream in = new FileInputStream(file);
+
try {
IOUtil.copy(in, out);
+
if (insertSemicolon) {
- out.write(';');
+ out.write(';');
}
+
if (insertNewLine) {
out.write('\n');
}
+
if (removeIncluded) {
file.delete();
}
@@ -74,31 +84,39 @@
protected List<File> getIncludedFiles() throws Exception {
ArrayList<File> back = new ArrayList<File>();
+
if (includes != null) {
for (String include : includes) {
addInto(include, back);
}
}
+
return back;
}
private void addInto(String include, List<File> includedFiles) throws Exception {
if (include.indexOf('*') > -1) {
DirectoryScanner scanner = newScanner();
- scanner.setIncludes(new String[] { include });
+
+ scanner.setIncludes(new String[] {include});
scanner.scan();
+
String[] rpaths = scanner.getIncludedFiles();
+
for (String rpath : rpaths) {
File file = new File(scanner.getBasedir(), rpath);
+
if (!includedFiles.contains(file)) {
includedFiles.add(file);
}
}
} else {
File file = new File(include);
+
if (!file.isAbsolute()) {
file = new File(output.getParentFile(), include);
}
+
if (!includedFiles.contains(file)) {
includedFiles.add(file);
}
@@ -107,11 +125,15 @@
private DirectoryScanner newScanner() throws Exception {
DirectoryScanner scanner = new DirectoryScanner();
+
scanner.setBasedir(sourceDirectory);
+
if ((excludes != null) && (excludes.length != 0)) {
scanner.setExcludes(excludes);
}
+
scanner.addDefaultExcludes();
+
return scanner;
}
}
Modified: root/cdk/trunk/plugins/maven-javascript-plugin/src/main/java/net/sf/alchim/mojo/yuicompressor/BasicRhinoShell.java
===================================================================
--- root/cdk/trunk/plugins/maven-javascript-plugin/src/main/java/net/sf/alchim/mojo/yuicompressor/BasicRhinoShell.java 2009-11-01 16:28:50 UTC (rev 15792)
+++ root/cdk/trunk/plugins/maven-javascript-plugin/src/main/java/net/sf/alchim/mojo/yuicompressor/BasicRhinoShell.java 2009-11-01 16:30:05 UTC (rev 15793)
@@ -33,6 +33,8 @@
*
* ***** END LICENSE BLOCK ***** */
+
+
package net.sf.alchim.mojo.yuicompressor;
import java.io.BufferedReader;
@@ -43,6 +45,7 @@
import java.io.InputStreamReader;
import org.codehaus.plexus.util.IOUtil;
+
import org.mozilla.javascript.Context;
import org.mozilla.javascript.ErrorReporter;
import org.mozilla.javascript.EvaluatorException;
@@ -64,6 +67,7 @@
*/
@SuppressWarnings("serial")
public class BasicRhinoShell extends ScriptableObject {
+ private boolean quitting;
@Override
public String getClassName() {
@@ -78,36 +82,46 @@
* execution environment and begin to execute scripts.
*/
public static void exec(String args[], ErrorReporter reporter) {
+
// Associate a new Context with this thread
Context cx = Context.enter();
+
cx.setErrorReporter(reporter);
+
try {
+
// Initialize the standard objects (Object, Function, etc.)
// This must be done before scripts can be executed.
BasicRhinoShell BasicRhinoShell = new BasicRhinoShell();
+
cx.initStandardObjects(BasicRhinoShell);
// Define some global functions particular to the BasicRhinoShell.
// Note
// that these functions are not part of ECMA.
- String[] names = { "print", "quit", "version", "load", "help", "readFile" };
+ String[] names = {
+ "print", "quit", "version", "load", "help", "readFile"
+ };
+
BasicRhinoShell.defineFunctionProperties(names, BasicRhinoShell.class, ScriptableObject.DONTENUM);
-
args = processOptions(cx, args);
// Set up "arguments" in the global scope to contain the command
// line arguments after the name of the script to execute
Object[] array;
+
if (args.length == 0) {
array = new Object[0];
} else {
int length = args.length - 1;
+
array = new Object[length];
System.arraycopy(args, 1, array, 0, length);
}
+
Scriptable argsObj = cx.newArray(BasicRhinoShell, array);
+
BasicRhinoShell.defineProperty("arguments", argsObj, ScriptableObject.DONTENUM);
-
BasicRhinoShell.processSource(cx, args.length == 0 ? null : args[0]);
} finally {
Context.exit();
@@ -120,26 +134,36 @@
public static String[] processOptions(Context cx, String args[]) {
for (int i = 0; i < args.length; i++) {
String arg = args[i];
+
if (!arg.startsWith("-")) {
String[] result = new String[args.length - i];
+
for (int j = i; j < args.length; j++) {
result[j - i] = args[j];
}
+
return result;
}
+
if (arg.equals("-version")) {
if (++i == args.length) {
usage(arg);
}
+
double d = Context.toNumber(args[i]);
+
if (d != d) {
usage(arg);
}
+
cx.setLanguageVersion((int) d);
+
continue;
}
+
usage(arg);
}
+
return new String[0];
}
@@ -196,6 +220,7 @@
System.out.print(s);
}
+
System.out.println();
}
@@ -230,10 +255,13 @@
*/
public static double version(Context cx, Scriptable thisObj, Object[] args, Function funObj) {
double result = cx.getLanguageVersion();
+
if (args.length > 0) {
double d = Context.toNumber(args[0]);
+
cx.setLanguageVersion((int) d);
}
+
return result;
}
@@ -245,6 +273,7 @@
*/
public static void load(Context cx, Scriptable thisObj, Object[] args, Function funObj) {
BasicRhinoShell BasicRhinoShell = (BasicRhinoShell) getTopLevelScope(thisObj);
+
for (Object element : args) {
BasicRhinoShell.processSource(cx, Context.toString(element));
}
@@ -263,22 +292,31 @@
String sourceName = "<stdin>";
int lineno = 1;
boolean hitEOF = false;
+
do {
int startline = lineno;
+
System.err.print("js> ");
System.err.flush();
+
try {
String source = "";
+
// Collect lines of source to compile.
while (true) {
String newline;
+
newline = in.readLine();
+
if (newline == null) {
hitEOF = true;
+
break;
}
+
source = source + newline + "\n";
lineno++;
+
// Continue collecting as long as more lines
// are needed to complete the current
// statement. stringIsCompilableUnit is also
@@ -289,40 +327,51 @@
break;
}
}
+
Object result = cx.evaluateString(this, source, sourceName, startline, null);
+
if (result != Context.getUndefinedValue()) {
System.err.println(Context.toString(result));
}
} catch (WrappedException we) {
+
// Some form of exception was caught by JavaScript and
// propagated up.
System.err.println(we.getWrappedException().toString());
we.printStackTrace();
} catch (EvaluatorException ee) {
+
// Some form of JavaScript error.
System.err.println("js: " + ee.getMessage());
} catch (JavaScriptException jse) {
+
// Some form of JavaScript error.
System.err.println("js: " + jse.getMessage());
} catch (IOException ioe) {
System.err.println(ioe.toString());
}
+
if (quitting) {
+
// The user executed the quit() function.
break;
}
} while (!hitEOF);
+
System.err.println();
} else {
FileReader in = null;
+
try {
in = new FileReader(filename);
} catch (FileNotFoundException ex) {
Context.reportError("Couldn't open file \"" + filename + "\".");
+
return;
}
try {
+
// Here we evalute the entire contents of the file as
// a script. Text is printed only if the print() function
// is called.
@@ -349,6 +398,4 @@
private static void p(String s) {
System.out.println(s);
}
-
- private boolean quitting;
}
Modified: root/cdk/trunk/plugins/maven-javascript-plugin/src/main/java/net/sf/alchim/mojo/yuicompressor/ErrorReporter4Mojo.java
===================================================================
--- root/cdk/trunk/plugins/maven-javascript-plugin/src/main/java/net/sf/alchim/mojo/yuicompressor/ErrorReporter4Mojo.java 2009-11-01 16:28:50 UTC (rev 15792)
+++ root/cdk/trunk/plugins/maven-javascript-plugin/src/main/java/net/sf/alchim/mojo/yuicompressor/ErrorReporter4Mojo.java 2009-11-01 16:30:05 UTC (rev 15793)
@@ -18,20 +18,22 @@
* 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 net.sf.alchim.mojo.yuicompressor;
import org.apache.maven.plugin.logging.Log;
+
import org.mozilla.javascript.ErrorReporter;
import org.mozilla.javascript.EvaluatorException;
public class ErrorReporter4Mojo implements ErrorReporter {
-
+ private boolean acceptWarn_;
private String defaultFilename_;
- private boolean acceptWarn_;
+ private int errorCnt_;
private Log log_;
private int warningCnt_;
- private int errorCnt_;
public ErrorReporter4Mojo(Log log, boolean jswarn) {
log_ = log;
@@ -42,6 +44,7 @@
if (v.length() == 0) {
v = null;
}
+
defaultFilename_ = v;
}
@@ -55,18 +58,22 @@
public void error(String message, String sourceName, int line, String lineSource, int lineOffset) {
String fullMessage = newMessage(message, sourceName, line, lineSource, lineOffset);
+
log_.error(fullMessage);
errorCnt_++;
}
- public EvaluatorException runtimeError(String message, String sourceName, int line, String lineSource, int lineOffset) {
+ public EvaluatorException runtimeError(String message, String sourceName, int line, String lineSource,
+ int lineOffset) {
error(message, sourceName, line, lineSource, lineOffset);
+
throw new EvaluatorException(message, sourceName, line, lineSource, lineOffset);
}
public void warning(String message, String sourceName, int line, String lineSource, int lineOffset) {
if (acceptWarn_) {
String fullMessage = newMessage(message, sourceName, line, lineSource, lineOffset);
+
log_.warn(fullMessage);
warningCnt_++;
}
@@ -74,29 +81,27 @@
private String newMessage(String message, String sourceName, int line, String lineSource, int lineOffset) {
StringBuilder back = new StringBuilder();
+
if ((sourceName == null) || (sourceName.length() == 0)) {
sourceName = defaultFilename_;
}
+
if (sourceName != null) {
- back.append(sourceName)
- .append(":line ")
- .append(line)
- .append(":column ")
- .append(lineOffset)
- .append(':')
- ;
+ back.append(sourceName).append(":line ").append(line).append(":column ").append(lineOffset).append(':')
+ ;
}
+
if ((message != null) && (message.length() != 0)) {
back.append(message);
} else {
back.append("unknown error");
}
+
if ((lineSource != null) && (lineSource.length() != 0)) {
- back.append("\n\t")
- .append(lineSource)
- ;
+ back.append("\n\t").append(lineSource)
+ ;
}
+
return back.toString();
}
-
}
Modified: root/cdk/trunk/plugins/maven-javascript-plugin/src/main/java/net/sf/alchim/mojo/yuicompressor/JSLintChecker.java
===================================================================
--- root/cdk/trunk/plugins/maven-javascript-plugin/src/main/java/net/sf/alchim/mojo/yuicompressor/JSLintChecker.java 2009-11-01 16:28:50 UTC (rev 15792)
+++ root/cdk/trunk/plugins/maven-javascript-plugin/src/main/java/net/sf/alchim/mojo/yuicompressor/JSLintChecker.java 2009-11-01 16:30:05 UTC (rev 15793)
@@ -18,7 +18,9 @@
* 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 net.sf.alchim.mojo.yuicompressor;
import java.io.File;
@@ -26,6 +28,7 @@
import java.io.InputStream;
import org.codehaus.plexus.util.IOUtil;
+
import org.mozilla.javascript.ErrorReporter;
//TODO: use MojoErrorReporter
@@ -35,8 +38,10 @@
public JSLintChecker() throws Exception {
FileOutputStream out = null;
InputStream in = null;
+
try {
File jslint = File.createTempFile("jslint", ".js");
+
in = getClass().getResourceAsStream("/jslint.js");
out = new FileOutputStream(jslint);
IOUtil.copy(in, out);
@@ -49,11 +54,13 @@
public void check(File jsFile, ErrorReporter reporter) {
String[] args = new String[2];
+
args[0] = jslintPath_;
args[1] = jsFile.getAbsolutePath();
BasicRhinoShell.exec(args, reporter);
- //if (Main.exec(args) != 0) {
- // reporter.warning("warnings during checking of :" + jsFile.getAbsolutePath(), null, -1, null, -1);
- //}
+
+ // if (Main.exec(args) != 0) {
+ // reporter.warning("warnings during checking of :" + jsFile.getAbsolutePath(), null, -1, null, -1);
+ // }
}
}
Modified: root/cdk/trunk/plugins/maven-javascript-plugin/src/main/java/net/sf/alchim/mojo/yuicompressor/JSLintMojo.java
===================================================================
--- root/cdk/trunk/plugins/maven-javascript-plugin/src/main/java/net/sf/alchim/mojo/yuicompressor/JSLintMojo.java 2009-11-01 16:28:50 UTC (rev 15792)
+++ root/cdk/trunk/plugins/maven-javascript-plugin/src/main/java/net/sf/alchim/mojo/yuicompressor/JSLintMojo.java 2009-11-01 16:30:05 UTC (rev 15793)
@@ -18,10 +18,11 @@
* 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 net.sf.alchim.mojo.yuicompressor;
-
/**
* Check JS files with jslint.
*
@@ -31,13 +32,14 @@
* @author David Bernard
* @created 2007-08-29
*/
-// @SuppressWarnings("unchecked")
+
+//@SuppressWarnings("unchecked")
public class JSLintMojo extends MojoSupport {
private JSLintChecker jslint_;
@Override
protected String[] getDefaultIncludes() throws Exception {
- return new String[] { "**/**.js" };
+ return new String[] {"**/**.js"};
}
@Override
@@ -46,8 +48,7 @@
}
@Override
- public void afterProcess() throws Exception {
- }
+ public void afterProcess() throws Exception {}
@Override
protected void processFile(SourceFile src) throws Exception {
Modified: root/cdk/trunk/plugins/maven-javascript-plugin/src/main/java/net/sf/alchim/mojo/yuicompressor/MojoSupport.java
===================================================================
--- root/cdk/trunk/plugins/maven-javascript-plugin/src/main/java/net/sf/alchim/mojo/yuicompressor/MojoSupport.java 2009-11-01 16:28:50 UTC (rev 15792)
+++ root/cdk/trunk/plugins/maven-javascript-plugin/src/main/java/net/sf/alchim/mojo/yuicompressor/MojoSupport.java 2009-11-01 16:30:05 UTC (rev 15793)
@@ -18,10 +18,13 @@
* 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 net.sf.alchim.mojo.yuicompressor;
import java.io.File;
+
import java.util.List;
import org.apache.maven.model.Resource;
@@ -29,177 +32,186 @@
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.project.MavenProject;
+
import org.codehaus.plexus.util.DirectoryScanner;
/**
* Common class for mojos.
- *
+ *
* @author David Bernard
* @created 2007-08-29
*/
-// @SuppressWarnings("unchecked")
+
+//@SuppressWarnings("unchecked")
public abstract class MojoSupport extends AbstractMojo {
- private static final String[] EMPTY_STRING_ARRAY = {};
+ private static final String[] EMPTY_STRING_ARRAY = {};
- /**
- * Javascript source directory. (result will be put to outputDirectory).
- * This allow project with "src/main/js" structure.
- *
- * @parameter default-value="${project.build.sourceDirectory}/../js"
- */
- private File sourceDirectory;
+ /**
+ * list of additionnal excludes
+ *
+ * @parameter
+ */
+ private List<String> excludes;
- /**
- * Single directory for extra files to include in the WAR.
- *
- * @parameter default-value="${basedir}/src/main/webapp"
- */
- private File warSourceDirectory;
+ /**
+ * define if plugin must stop/fail on warnings.
+ *
+ * @parameter expression="${maven.yuicompressor.failOnWarning}"
+ * default-value="false"
+ */
+ protected boolean failOnWarning;
- /**
- * The directory where the webapp is built.
- *
- * @parameter default-value="${project.build.directory}/${project.build.finalName}"
- */
- protected File webappDirectory;
+ /**
+ * list of additionnal includes
+ *
+ * @parameter
+ */
+ private List<String> includes;
+ protected ErrorReporter4Mojo jsErrorReporter_;
- /**
- * The output directory into which to copy the resources.
- *
- * @parameter default-value="${project.build.outputDirectory}"
- */
- protected File outputDirectory;
+ /**
+ * [js only] Display possible errors in the code
+ *
+ * @parameter expression="${maven.yuicompressor.jswarm}"
+ * default-value="true"
+ */
+ protected boolean jswarn;
- /**
- * The list of resources we want to transfer.
- *
- * @parameter default-value="${project.resources}"
- */
- private List<Resource> resources;
+ /**
+ * The output directory into which to copy the resources.
+ *
+ * @parameter default-value="${project.build.outputDirectory}"
+ */
+ protected File outputDirectory;
- /**
- * list of additionnal excludes
- *
- * @parameter
- */
- private List<String> excludes;
+ /**
+ * @parameter expression="${project}"
+ * @readonly
+ * @required
+ */
+ protected MavenProject project;
- /**
- * list of additionnal includes
- *
- * @parameter
- */
- private List<String> includes;
+ /**
+ * The list of resources we want to transfer.
+ *
+ * @parameter default-value="${project.resources}"
+ */
+ private List<Resource> resources;
- /**
- * @parameter expression="${project}"
- * @readonly
- * @required
- */
- protected MavenProject project;
+ /**
+ * Javascript source directory. (result will be put to outputDirectory).
+ * This allow project with "src/main/js" structure.
+ *
+ * @parameter default-value="${project.build.sourceDirectory}/../js"
+ */
+ private File sourceDirectory;
- /**
- * [js only] Display possible errors in the code
- *
- * @parameter expression="${maven.yuicompressor.jswarm}"
- * default-value="true"
- */
- protected boolean jswarn;
+ /**
+ * Single directory for extra files to include in the WAR.
+ *
+ * @parameter default-value="${basedir}/src/main/webapp"
+ */
+ private File warSourceDirectory;
- /**
- * define if plugin must stop/fail on warnings.
- *
- * @parameter expression="${maven.yuicompressor.failOnWarning}"
- * default-value="false"
- */
- protected boolean failOnWarning;
- protected ErrorReporter4Mojo jsErrorReporter_;
+ /**
+ * The directory where the webapp is built.
+ *
+ * @parameter default-value="${project.build.directory}/${project.build.finalName}"
+ */
+ protected File webappDirectory;
- @SuppressWarnings("unchecked")
- public void execute() throws MojoExecutionException, MojoFailureException {
- try {
- if (failOnWarning) {
- jswarn = true;
- }
- jsErrorReporter_ = new ErrorReporter4Mojo(getLog(), jswarn);
- beforeProcess();
- processDir(sourceDirectory, outputDirectory, null, null,
- true);
- for (Resource resource : resources) {
- File destRoot = outputDirectory;
- if (resource.getTargetPath() != null) {
- destRoot = new File(outputDirectory, resource
- .getTargetPath());
- }
- processDir(new File(resource.getDirectory()), destRoot,
- resource.getIncludes(), resource.getExcludes(), true);
- }
- processDir(warSourceDirectory, webappDirectory, null, null,
- false);
- afterProcess();
- getLog().info(
- String.format("nb warnings: %d, nb errors: %d",
- jsErrorReporter_.getWarningCnt(), jsErrorReporter_
- .getErrorCnt()));
- if (failOnWarning && (jsErrorReporter_.getWarningCnt() > 0)) {
- throw new MojoFailureException("warnings on "
- + this.getClass().getSimpleName()
- + "=> failure ! (see log)");
- }
- } catch (RuntimeException exc) {
- throw exc;
- } catch (MojoFailureException exc) {
- throw exc;
- } catch (MojoExecutionException exc) {
- throw exc;
- } catch (Exception exc) {
- throw new MojoExecutionException("wrap: " + exc.getMessage(), exc);
- }
- }
+ @SuppressWarnings("unchecked")
+ public void execute() throws MojoExecutionException, MojoFailureException {
+ try {
+ if (failOnWarning) {
+ jswarn = true;
+ }
- protected abstract String[] getDefaultIncludes() throws Exception;
+ jsErrorReporter_ = new ErrorReporter4Mojo(getLog(), jswarn);
+ beforeProcess();
+ processDir(sourceDirectory, outputDirectory, null, null, true);
- protected abstract void beforeProcess() throws Exception;
+ for (Resource resource : resources) {
+ File destRoot = outputDirectory;
- protected abstract void afterProcess() throws Exception;
+ if (resource.getTargetPath() != null) {
+ destRoot = new File(outputDirectory, resource.getTargetPath());
+ }
- protected void processDir(File srcRoot, File destRoot,
- List<String> srcIncludes, List<String> srcExcludes,
- boolean destAsSource) throws Exception {
- if ((srcRoot == null) || (!srcRoot.exists())) {
- return;
- }
- if (destRoot == null) {
- throw new MojoFailureException("destination directory for "
- + srcRoot + " is null");
- }
- DirectoryScanner scanner = new DirectoryScanner();
- scanner.setBasedir(srcRoot);
- if ((srcIncludes != null) && !srcIncludes.isEmpty()) {
- scanner.setIncludes(srcIncludes.toArray(EMPTY_STRING_ARRAY));
- }
- if ((includes != null) && !includes.isEmpty()) {
- scanner.setIncludes(includes.toArray(EMPTY_STRING_ARRAY));
- } else {
- scanner.setIncludes(getDefaultIncludes());
- }
- if ((srcExcludes != null) && !srcExcludes.isEmpty()) {
- scanner.setExcludes(srcExcludes.toArray(EMPTY_STRING_ARRAY));
- }
- if ((excludes != null) && !excludes.isEmpty()) {
- scanner.setExcludes(excludes.toArray(EMPTY_STRING_ARRAY));
- }
- scanner.addDefaultExcludes();
- scanner.scan();
- for (String name : scanner.getIncludedFiles()) {
- SourceFile src = new SourceFile(srcRoot, destRoot, name,
- destAsSource);
- jsErrorReporter_.setDefaultFileName("..."
- + src.toFile().getAbsolutePath().substring(
- project.getBasedir().getAbsolutePath().length()));
- processFile(src);
- }
- }
+ processDir(new File(resource.getDirectory()), destRoot, resource.getIncludes(), resource.getExcludes(),
+ true);
+ }
- protected abstract void processFile(SourceFile src) throws Exception;
+ processDir(warSourceDirectory, webappDirectory, null, null, false);
+ afterProcess();
+ getLog().info(String.format("nb warnings: %d, nb errors: %d", jsErrorReporter_.getWarningCnt(),
+ jsErrorReporter_.getErrorCnt()));
+
+ if (failOnWarning && (jsErrorReporter_.getWarningCnt() > 0)) {
+ throw new MojoFailureException("warnings on " + this.getClass().getSimpleName()
+ + "=> failure ! (see log)");
+ }
+ } catch (RuntimeException exc) {
+ throw exc;
+ } catch (MojoFailureException exc) {
+ throw exc;
+ } catch (MojoExecutionException exc) {
+ throw exc;
+ } catch (Exception exc) {
+ throw new MojoExecutionException("wrap: " + exc.getMessage(), exc);
+ }
+ }
+
+ protected abstract String[] getDefaultIncludes() throws Exception;
+
+ protected abstract void beforeProcess() throws Exception;
+
+ protected abstract void afterProcess() throws Exception;
+
+ protected void processDir(File srcRoot, File destRoot, List<String> srcIncludes, List<String> srcExcludes,
+ boolean destAsSource)
+ throws Exception {
+ if ((srcRoot == null) || (!srcRoot.exists())) {
+ return;
+ }
+
+ if (destRoot == null) {
+ throw new MojoFailureException("destination directory for " + srcRoot + " is null");
+ }
+
+ DirectoryScanner scanner = new DirectoryScanner();
+
+ scanner.setBasedir(srcRoot);
+
+ if ((srcIncludes != null) && !srcIncludes.isEmpty()) {
+ scanner.setIncludes(srcIncludes.toArray(EMPTY_STRING_ARRAY));
+ }
+
+ if ((includes != null) && !includes.isEmpty()) {
+ scanner.setIncludes(includes.toArray(EMPTY_STRING_ARRAY));
+ } else {
+ scanner.setIncludes(getDefaultIncludes());
+ }
+
+ if ((srcExcludes != null) && !srcExcludes.isEmpty()) {
+ scanner.setExcludes(srcExcludes.toArray(EMPTY_STRING_ARRAY));
+ }
+
+ if ((excludes != null) && !excludes.isEmpty()) {
+ scanner.setExcludes(excludes.toArray(EMPTY_STRING_ARRAY));
+ }
+
+ scanner.addDefaultExcludes();
+ scanner.scan();
+
+ for (String name : scanner.getIncludedFiles()) {
+ SourceFile src = new SourceFile(srcRoot, destRoot, name, destAsSource);
+
+ jsErrorReporter_.setDefaultFileName("..."
+ + src.toFile().getAbsolutePath().substring(project.getBasedir().getAbsolutePath().length()));
+ processFile(src);
+ }
+ }
+
+ protected abstract void processFile(SourceFile src) throws Exception;
}
Modified: root/cdk/trunk/plugins/maven-javascript-plugin/src/main/java/net/sf/alchim/mojo/yuicompressor/SourceFile.java
===================================================================
--- root/cdk/trunk/plugins/maven-javascript-plugin/src/main/java/net/sf/alchim/mojo/yuicompressor/SourceFile.java 2009-11-01 16:28:50 UTC (rev 15792)
+++ root/cdk/trunk/plugins/maven-javascript-plugin/src/main/java/net/sf/alchim/mojo/yuicompressor/SourceFile.java 2009-11-01 16:30:05 UTC (rev 15793)
@@ -18,26 +18,29 @@
* 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 net.sf.alchim.mojo.yuicompressor;
import java.io.File;
public class SourceFile {
-
- private File srcRoot_;
+ private boolean destAsSource_;
private File destRoot_;
- private boolean destAsSource_;
+ private String extension_;
private String rpath_;
- private String extension_;
+ private File srcRoot_;
public SourceFile(File srcRoot, File destRoot, String name, boolean destAsSource) throws Exception {
srcRoot_ = srcRoot;
destRoot_ = destRoot;
destAsSource_ = destAsSource;
rpath_ = name;
+
int sep = rpath_.lastIndexOf('.');
- if (sep>0) {
+
+ if (sep > 0) {
extension_ = rpath_.substring(sep);
rpath_ = rpath_.substring(0, sep);
} else {
@@ -47,12 +50,15 @@
public File toFile() {
String frpath = rpath_ + extension_;
+
if (destAsSource_) {
File defaultDest = new File(destRoot_, frpath);
+
if (defaultDest.exists() && defaultDest.canRead()) {
return defaultDest;
}
}
+
return new File(srcRoot_, frpath);
}
Modified: root/cdk/trunk/plugins/maven-javascript-plugin/src/main/java/net/sf/alchim/mojo/yuicompressor/YuiCompressorMojo.java
===================================================================
--- root/cdk/trunk/plugins/maven-javascript-plugin/src/main/java/net/sf/alchim/mojo/yuicompressor/YuiCompressorMojo.java 2009-11-01 16:28:50 UTC (rev 15792)
+++ root/cdk/trunk/plugins/maven-javascript-plugin/src/main/java/net/sf/alchim/mojo/yuicompressor/YuiCompressorMojo.java 2009-11-01 16:30:05 UTC (rev 15793)
@@ -18,7 +18,9 @@
* 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 net.sf.alchim.mojo.yuicompressor;
import java.io.File;
@@ -26,9 +28,11 @@
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
+
import java.util.zip.GZIPOutputStream;
import org.apache.maven.plugin.MojoExecutionException;
+
import org.codehaus.plexus.util.FileUtils;
import org.codehaus.plexus.util.IOUtil;
@@ -44,10 +48,20 @@
* @author David Bernard
* @created 2007-08-28
*/
-// @SuppressWarnings("unchecked")
+
+//@SuppressWarnings("unchecked")
public class YuiCompressorMojo extends MojoSupport {
/**
+ * a list of aggregation/concatenation to do after processing,
+ * for example to create big js files that contain several small js files.
+ * Aggregation could be done on any type of file (js, css, ...).
+ *
+ * @parameter
+ */
+ private Aggregation[] aggregations;
+
+ /**
* Read the input file using "encoding".
*
* @parameter expression="${file.encoding}" default-value="UTF-8"
@@ -55,18 +69,20 @@
private String encoding;
/**
- * The output filename suffix.
+ * force the compression of every files,
+ * else if compressed file already exists and is younger than source file, nothing is done.
*
- * @parameter expression="${maven.yuicompressor.suffix}" default-value="-min"
+ * @parameter expression="${maven.yuicompressor.force}" default-value="false"
*/
- private String suffix;
+ private boolean force;
/**
- * If no "suffix" must be add to output filename (maven's configuration manage empty suffix like default).
+ * request to create a gzipped version of the yuicompressed/aggregation files.
*
- * @parameter expression="${maven.yuicompressor.nosuffix}" default-value="false"
+ * @parameter expression="${maven.yuicompressor.gzip}" default-value="false"
*/
- private boolean nosuffix;
+ private boolean gzip;
+ private long inSizeTotal_;
/**
* Insert line breaks in output after the specified column number.
@@ -83,6 +99,14 @@
private boolean nomunge;
/**
+ * If no "suffix" must be add to output filename (maven's configuration manage empty suffix like default).
+ *
+ * @parameter expression="${maven.yuicompressor.nosuffix}" default-value="false"
+ */
+ private boolean nosuffix;
+ private long outSizeTotal_;
+
+ /**
* [js only] Preserve unnecessary semicolons.
*
* @parameter expression="${maven.yuicompressor.preserveAllSemiColons}" default-value="false"
@@ -97,42 +121,22 @@
private boolean preserveStringLiterals;
/**
- * force the compression of every files,
- * else if compressed file already exists and is younger than source file, nothing is done.
+ * show statistics (compression ratio).
*
- * @parameter expression="${maven.yuicompressor.force}" default-value="false"
+ * @parameter expression="${maven.yuicompressor.statistics}" default-value="true"
*/
- private boolean force;
+ private boolean statistics;
/**
- * a list of aggregation/concatenation to do after processing,
- * for example to create big js files that contain several small js files.
- * Aggregation could be done on any type of file (js, css, ...).
+ * The output filename suffix.
*
- * @parameter
+ * @parameter expression="${maven.yuicompressor.suffix}" default-value="-min"
*/
- private Aggregation[] aggregations;
+ private String suffix;
- /**
- * request to create a gzipped version of the yuicompressed/aggregation files.
- *
- * @parameter expression="${maven.yuicompressor.gzip}" default-value="false"
- */
- private boolean gzip;
-
- /**
- * show statistics (compression ratio).
- *
- * @parameter expression="${maven.yuicompressor.statistics}" default-value="true"
- */
- private boolean statistics;
-
- private long inSizeTotal_;
- private long outSizeTotal_;
-
@Override
protected String[] getDefaultIncludes() throws Exception {
- return new String[]{"**/*.css", "**/*.js"};
+ return new String[] {"**/*.css", "**/*.js"};
}
@Override
@@ -145,18 +149,25 @@
@Override
protected void afterProcess() throws Exception {
if (statistics && (inSizeTotal_ > 0)) {
- getLog().info(String.format("total input (%db) -> output (%db)[%d%%]", inSizeTotal_, outSizeTotal_, ((outSizeTotal_ * 100)/inSizeTotal_)));
+ getLog().info(String.format("total input (%db) -> output (%db)[%d%%]", inSizeTotal_, outSizeTotal_,
+ ((outSizeTotal_ * 100) / inSizeTotal_)));
}
+
if (aggregations != null) {
- for(Aggregation aggregation : aggregations) {
+ for (Aggregation aggregation : aggregations) {
getLog().info("generate aggregation : " + aggregation.output);
aggregation.run(outputDirectory);
+
File gzipped = gzipIfRequested(aggregation.output);
+
if (statistics) {
if (gzipped != null) {
- getLog().info(String.format("%s (%db) -> %s (%db)[%d%%]", aggregation.output.getName(), aggregation.output.length(), gzipped.getName(), gzipped.length(), ratioOfSize(aggregation.output, gzipped)));
- } else if (aggregation.output.exists()){
- getLog().info(String.format("%s (%db)", aggregation.output.getName(), aggregation.output.length()));
+ getLog().info(String.format("%s (%db) -> %s (%db)[%d%%]", aggregation.output.getName(),
+ aggregation.output.length(), gzipped.getName(), gzipped.length(),
+ ratioOfSize(aggregation.output, gzipped)));
+ } else if (aggregation.output.exists()) {
+ getLog().info(String.format("%s (%db)", aggregation.output.getName(),
+ aggregation.output.length()));
} else {
getLog().warn(String.format("%s not created", aggregation.output.getName()));
}
@@ -165,59 +176,77 @@
}
}
-
@Override
protected void processFile(SourceFile src) throws Exception {
if (getLog().isDebugEnabled()) {
- getLog().debug("compress file :" + src.toFile()+ " to " + src.toDestFile(suffix));
+ getLog().debug("compress file :" + src.toFile() + " to " + src.toDestFile(suffix));
}
+
File inFile = src.toFile();
File outFile = src.toDestFile(suffix);
getLog().debug("only compress if input file is youger than existing output file");
+
if (!force && outFile.exists() && (outFile.lastModified() > inFile.lastModified())) {
if (getLog().isInfoEnabled()) {
- getLog().info("nothing to do, " + outFile + " is younger than original, use 'force' option or clean your target");
+ getLog().info("nothing to do, " + outFile
+ + " is younger than original, use 'force' option or clean your target");
}
+
return;
}
InputStreamReader in = null;
OutputStreamWriter out = null;
+
try {
in = new InputStreamReader(new FileInputStream(inFile), encoding);
+
if (!outFile.getParentFile().exists() && !outFile.getParentFile().mkdirs()) {
- throw new MojoExecutionException( "Cannot create resource output directory: " + outFile.getParentFile() );
+ throw new MojoExecutionException("Cannot create resource output directory: " + outFile.getParentFile());
}
+
getLog().debug("use a temporary outputfile (in case in == out)");
+
File outFileTmp = new File(outFile.getAbsolutePath() + ".tmp");
+
FileUtils.forceDelete(outFileTmp);
-
getLog().debug("start compression");
out = new OutputStreamWriter(new FileOutputStream(outFileTmp), encoding);
+
if (".js".equalsIgnoreCase(src.getExtension())) {
JavaScriptCompressor compressor = new JavaScriptCompressor(in, jsErrorReporter_);
+
compressor.compress(out, linebreakpos, !nomunge, jswarn, preserveAllSemiColons, preserveStringLiterals);
} else if (".css".equalsIgnoreCase(src.getExtension())) {
CssCompressor compressor = new CssCompressor(in);
+
compressor.compress(out, linebreakpos);
}
+
getLog().debug("end compression");
+
// Close output file before rename.
- IOUtil.close(out);out=null;
+ IOUtil.close(out);
+ out = null;
FileUtils.forceDelete(outFile);
FileUtils.rename(outFileTmp, outFile);
} finally {
IOUtil.close(in);
IOUtil.close(out);
}
+
File gzipped = gzipIfRequested(outFile);
+
if (statistics) {
inSizeTotal_ += inFile.length();
outSizeTotal_ += outFile.length();
- getLog().info(String.format("%s (%db) -> %s (%db)[%d%%]", inFile.getName(), inFile.length(), outFile.getName(), outFile.length(), ratioOfSize(inFile, outFile)));
+ getLog().info(String.format("%s (%db) -> %s (%db)[%d%%]", inFile.getName(), inFile.length(),
+ outFile.getName(), outFile.length(), ratioOfSize(inFile, outFile)));
+
if (gzipped != null) {
- getLog().info(String.format("%s (%db) -> %s (%db)[%d%%]", inFile.getName(), inFile.length(), gzipped.getName(), gzipped.length(), ratioOfSize(inFile, gzipped)));
+ getLog().info(String.format("%s (%db) -> %s (%db)[%d%%]", inFile.getName(), inFile.length(),
+ gzipped.getName(), gzipped.length(), ratioOfSize(inFile, gzipped)));
}
}
}
@@ -226,13 +255,18 @@
if (!gzip || (file == null) || (!file.exists())) {
return null;
}
+
if (".gz".equalsIgnoreCase(FileUtils.getExtension(file.getName()))) {
return null;
}
- File gzipped = new File(file.getAbsolutePath()+".gz");
+
+ File gzipped = new File(file.getAbsolutePath() + ".gz");
+
getLog().debug(String.format("create gzip version : %s", gzipped.getName()));
+
GZIPOutputStream out = null;
FileInputStream in = null;
+
try {
out = new GZIPOutputStream(new FileOutputStream(gzipped));
in = new FileInputStream(file);
@@ -241,12 +275,14 @@
IOUtil.close(in);
IOUtil.close(out);
}
+
return gzipped;
}
protected long ratioOfSize(File file100, File fileX) throws Exception {
long v100 = Math.max(file100.length(), 1);
long vX = Math.max(fileX.length(), 1);
- return (vX * 100)/v100;
+
+ return (vX * 100) / v100;
}
}
Modified: root/cdk/trunk/plugins/maven-javascript-plugin/src/main/java/org/mozilla/javascript/Decompiler.java
===================================================================
--- root/cdk/trunk/plugins/maven-javascript-plugin/src/main/java/org/mozilla/javascript/Decompiler.java 2009-11-01 16:28:50 UTC (rev 15792)
+++ root/cdk/trunk/plugins/maven-javascript-plugin/src/main/java/org/mozilla/javascript/Decompiler.java 2009-11-01 16:30:05 UTC (rev 15793)
@@ -39,6 +39,8 @@
*
* ***** END LICENSE BLOCK ***** */
+
+
package org.mozilla.javascript;
/**
@@ -47,7 +49,7 @@
* associated with function nodes and with the toplevel script. When
* saved in the constant pool of a class, this string will be UTF-8
* encoded, and token values will occupy a single byte.
-
+ *
* Source is saved (mostly) as token numbers. The tokens saved pretty
* much correspond to the token stream of a 'canonical' representation
* of the input program, as directed by the parser. (There were a few
@@ -74,18 +76,17 @@
* the final constant pool entry from information available at parse
* time.
*/
-public class Decompiler
-{
+public class Decompiler {
+
/**
- * Flag to indicate that the decompilation should omit the
- * function header and trailing brace.
+ * Decompilation property to specify identation offset for case labels.
*/
- public static final int ONLY_BODY_FLAG = 1 << 0;
+ public static final int CASE_GAP_PROP = 3;
/**
- * Flag to indicate that the decompilation generates toSource result.
+ * Decompilation property to specify default identation offset.
*/
- public static final int TO_SOURCE_FLAG = 1 << 1;
+ public static final int INDENT_GAP_PROP = 2;
/**
* Decompilation property to specify initial ident value.
@@ -93,186 +94,206 @@
public static final int INITIAL_INDENT_PROP = 1;
/**
- * Decompilation property to specify default identation offset.
+ * Flag to indicate that the decompilation should omit the
+ * function header and trailing brace.
*/
- public static final int INDENT_GAP_PROP = 2;
+ public static final int ONLY_BODY_FLAG = 1 << 0;
/**
- * Decompilation property to specify identation offset for case labels.
+ * Flag to indicate that the decompilation generates toSource result.
*/
- public static final int CASE_GAP_PROP = 3;
+ public static final int TO_SOURCE_FLAG = 1 << 1;
// Marker to denote the last RC of function so it can be distinguished from
// the last RC of object literals in case of function expressions
private static final int FUNCTION_END = Token.LAST_TOKEN + 1;
- String getEncodedSource()
- {
+// whether to do a debug print of the source information, when decompiling.
+ private static final boolean printSource = false;
+ private char[] sourceBuffer = new char[128];
+
+// Per script/function source buffer top: parent source does not include a
+// nested functions source and uses function index as a reference instead.
+ private int sourceTop;
+
+ String getEncodedSource() {
return sourceToString(0);
}
- int getCurrentOffset()
- {
+ int getCurrentOffset() {
return sourceTop;
}
- int markFunctionStart(int functionType)
- {
+ int markFunctionStart(int functionType) {
int savedOffset = getCurrentOffset();
+
addToken(Token.FUNCTION);
- append((char)functionType);
+ append((char) functionType);
+
return savedOffset;
}
- int markFunctionEnd(int functionStart)
- {
+ int markFunctionEnd(int functionStart) {
int offset = getCurrentOffset();
- append((char)FUNCTION_END);
+
+ append((char) FUNCTION_END);
+
return offset;
}
- void addToken(int token)
- {
- if (!(0 <= token && token <= Token.LAST_TOKEN))
+ void addToken(int token) {
+ if (!(0 <= token && token <= Token.LAST_TOKEN)) {
throw new IllegalArgumentException();
+ }
- append((char)token);
+ append((char) token);
}
- void addEOL(int token)
- {
- if (!(0 <= token && token <= Token.LAST_TOKEN))
+ void addEOL(int token) {
+ if (!(0 <= token && token <= Token.LAST_TOKEN)) {
throw new IllegalArgumentException();
+ }
- append((char)token);
- append((char)Token.EOL);
+ append((char) token);
+ append((char) Token.EOL);
}
- void addName(String str)
- {
+ void addName(String str) {
addToken(Token.NAME);
appendString(str);
}
- void addString(String str)
- {
+ void addString(String str) {
addToken(Token.STRING);
appendString(str);
}
- void addRegexp(String regexp, String flags)
- {
+ void addRegexp(String regexp, String flags) {
addToken(Token.REGEXP);
appendString('/' + regexp + '/' + flags);
}
- void addJScriptConditionalComment(String str)
- {
+ void addJScriptConditionalComment(String str) {
addToken(Token.IECC);
appendString(str);
}
- void addNumber(double n)
- {
+ void addNumber(double n) {
addToken(Token.NUMBER);
- /* encode the number in the source stream.
+ /*
+ * encode the number in the source stream.
* Save as NUMBER type (char | char char char char)
* where type is
* 'D' - double, 'S' - short, 'J' - long.
-
+ *
* We need to retain float vs. integer type info to keep the
* behavior of liveconnect type-guessing the same after
* decompilation. (Liveconnect tries to present 1.0 to Java
* as a float/double)
* OPT: This is no longer true. We could compress the format.
-
+ *
* This may not be the most space-efficient encoding;
* the chars created below may take up to 3 bytes in
* constant pool UTF-8 encoding, so a Double could take
* up to 12 bytes.
*/
+ long lbits = (long) n;
- long lbits = (long)n;
if (lbits != n) {
+
// if it's floating point, save as a Double bit pattern.
// (12/15/97 our scanner only returns Double for f.p.)
lbits = Double.doubleToLongBits(n);
append('D');
- append((char)(lbits >> 48));
- append((char)(lbits >> 32));
- append((char)(lbits >> 16));
- append((char)lbits);
- }
- else {
+ append((char) (lbits >> 48));
+ append((char) (lbits >> 32));
+ append((char) (lbits >> 16));
+ append((char) lbits);
+ } else {
+
// we can ignore negative values, bc they're already prefixed
// by NEG
- if (lbits < 0) Kit.codeBug();
+ if (lbits < 0) {
+ Kit.codeBug();
+ }
// will it fit in a char?
// this gives a short encoding for integer values up to 2^16.
if (lbits <= Character.MAX_VALUE) {
append('S');
- append((char)lbits);
- }
- else { // Integral, but won't fit in a char. Store as a long.
+ append((char) lbits);
+ } else { // Integral, but won't fit in a char. Store as a long.
append('J');
- append((char)(lbits >> 48));
- append((char)(lbits >> 32));
- append((char)(lbits >> 16));
- append((char)lbits);
+ append((char) (lbits >> 48));
+ append((char) (lbits >> 32));
+ append((char) (lbits >> 16));
+ append((char) lbits);
}
}
}
- private void appendString(String str)
- {
+ private void appendString(String str) {
int L = str.length();
int lengthEncodingSize = 1;
+
if (L >= 0x8000) {
lengthEncodingSize = 2;
}
+
int nextTop = sourceTop + lengthEncodingSize + L;
+
if (nextTop > sourceBuffer.length) {
increaseSourceCapacity(nextTop);
}
+
if (L >= 0x8000) {
+
// Use 2 chars to encode strings exceeding 32K, were the highest
// bit in the first char indicates presence of the next byte
- sourceBuffer[sourceTop] = (char)(0x8000 | (L >>> 16));
+ sourceBuffer[sourceTop] = (char) (0x8000 | (L >>> 16));
++sourceTop;
}
- sourceBuffer[sourceTop] = (char)L;
+
+ sourceBuffer[sourceTop] = (char) L;
++sourceTop;
str.getChars(0, L, sourceBuffer, sourceTop);
sourceTop = nextTop;
}
- private void append(char c)
- {
+ private void append(char c) {
if (sourceTop == sourceBuffer.length) {
increaseSourceCapacity(sourceTop + 1);
}
+
sourceBuffer[sourceTop] = c;
++sourceTop;
}
- private void increaseSourceCapacity(int minimalCapacity)
- {
+ private void increaseSourceCapacity(int minimalCapacity) {
+
// Call this only when capacity increase is must
- if (minimalCapacity <= sourceBuffer.length) Kit.codeBug();
+ if (minimalCapacity <= sourceBuffer.length) {
+ Kit.codeBug();
+ }
+
int newCapacity = sourceBuffer.length * 2;
+
if (newCapacity < minimalCapacity) {
newCapacity = minimalCapacity;
}
+
char[] tmp = new char[newCapacity];
+
System.arraycopy(sourceBuffer, 0, tmp, 0, sourceTop);
sourceBuffer = tmp;
}
- private String sourceToString(int offset)
- {
- if (offset < 0 || sourceTop < offset) Kit.codeBug();
+ private String sourceToString(int offset) {
+ if (offset < 0 || sourceTop < offset) {
+ Kit.codeBug();
+ }
+
return new String(sourceBuffer, offset, sourceTop - offset);
}
@@ -292,19 +313,31 @@
* @param properties indentation properties
*
*/
- public static String decompile(String source, int flags,
- UintMap properties)
- {
+ public static String decompile(String source, int flags, UintMap properties) {
int length = source.length();
- if (length == 0) { return ""; }
+ if (length == 0) {
+ return "";
+ }
+
int indent = properties.getInt(INITIAL_INDENT_PROP, 0);
- if (indent < 0) throw new IllegalArgumentException();
+
+ if (indent < 0) {
+ throw new IllegalArgumentException();
+ }
+
int indentGap = properties.getInt(INDENT_GAP_PROP, 4);
- if (indentGap < 0) throw new IllegalArgumentException();
+
+ if (indentGap < 0) {
+ throw new IllegalArgumentException();
+ }
+
int caseGap = properties.getInt(CASE_GAP_PROP, 2);
- if (caseGap < 0) throw new IllegalArgumentException();
+ if (caseGap < 0) {
+ throw new IllegalArgumentException();
+ }
+
StringBuffer result = new StringBuffer();
boolean justFunctionBody = (0 != (flags & Decompiler.ONLY_BODY_FLAG));
boolean toSource = (0 != (flags & Decompiler.TO_SOURCE_FLAG));
@@ -313,26 +346,27 @@
// as TYPE number char
if (printSource) {
System.err.println("length:" + length);
+
for (int i = 0; i < length; ++i) {
+
// Note that tokenToName will fail unless Context.printTrees
// is true.
String tokenname = null;
+
if (Token.printNames) {
tokenname = Token.name(source.charAt(i));
}
+
if (tokenname == null) {
tokenname = "---";
}
- String pad = tokenname.length() > 7
- ? "\t"
- : "\t\t";
- System.err.println
- (tokenname
- + pad + (int)source.charAt(i)
- + "\t'" + ScriptRuntime.escapeString
- (source.substring(i, i+1))
- + "'");
+
+ String pad = tokenname.length() > 7 ? "\t" : "\t\t";
+
+ System.err.println(tokenname + pad + (int) source.charAt(i) + "\t'"
+ + ScriptRuntime.escapeString(source.substring(i, i + 1)) + "'");
}
+
System.err.println();
}
@@ -340,6 +374,7 @@
boolean afterFirstEOL = false;
int i = 0;
int topFunctionType;
+
if (source.charAt(i) == Token.SCRIPT) {
++i;
topFunctionType = -1;
@@ -348,10 +383,13 @@
}
if (!toSource) {
+
// add an initial newline to exactly match js.
result.append('\n');
- for (int j = 0; j < indent; j++)
+
+ for (int j = 0; j < indent; j++) {
result.append(' ');
+ }
} else {
if (topFunctionType == FunctionNode.FUNCTION_EXPRESSION) {
result.append('(');
@@ -359,473 +397,602 @@
}
while (i < length) {
- switch(source.charAt(i)) {
- case Token.GET:
- case Token.SET:
- result.append(source.charAt(i) == Token.GET ? "get " : "set ");
- ++i;
- i = printSourceString(source, i + 1, false, result);
- // Now increment one more to get past the FUNCTION token
- ++i;
- break;
+ switch (source.charAt(i)) {
+ case Token.GET :
+ case Token.SET :
+ result.append(source.charAt(i) == Token.GET ? "get " : "set ");
+ ++i;
+ i = printSourceString(source, i + 1, false, result);
- case Token.NAME:
- case Token.REGEXP: // re-wrapped in '/'s in parser...
- i = printSourceString(source, i + 1, false, result);
- continue;
+ // Now increment one more to get past the FUNCTION token
+ ++i;
- case Token.STRING:
- i = printSourceString(source, i + 1, true, result);
- continue;
+ break;
- case Token.NUMBER:
- i = printSourceNumber(source, i + 1, result);
- continue;
+ case Token.NAME :
+ case Token.REGEXP : // re-wrapped in '/'s in parser...
+ i = printSourceString(source, i + 1, false, result);
- case Token.TRUE:
- result.append("true");
- break;
+ continue;
+ case Token.STRING :
+ i = printSourceString(source, i + 1, true, result);
- case Token.FALSE:
- result.append("false");
- break;
+ continue;
+ case Token.NUMBER :
+ i = printSourceNumber(source, i + 1, result);
- case Token.NULL:
- result.append("null");
- break;
+ continue;
+ case Token.TRUE :
+ result.append("true");
- case Token.THIS:
- result.append("this");
- break;
+ break;
- case Token.FUNCTION:
- ++i; // skip function type
- result.append("function ");
- break;
+ case Token.FALSE :
+ result.append("false");
- case FUNCTION_END:
- // Do nothing
- break;
+ break;
- case Token.COMMA:
- result.append(", ");
- break;
+ case Token.NULL :
+ result.append("null");
- case Token.LC:
- ++braceNesting;
- if (Token.EOL == getNext(source, length, i))
- indent += indentGap;
- result.append('{');
- break;
+ break;
- case Token.RC: {
- --braceNesting;
- /* don't print the closing RC if it closes the
- * toplevel function and we're called from
- * decompileFunctionBody.
- */
- if (justFunctionBody && braceNesting == 0)
+ case Token.THIS :
+ result.append("this");
+
break;
- result.append('}');
- switch (getNext(source, length, i)) {
- case Token.EOL:
- case FUNCTION_END:
- indent -= indentGap;
+ case Token.FUNCTION :
+ ++i; // skip function type
+ result.append("function ");
+
+ break;
+
+ case FUNCTION_END :
+
+ // Do nothing
+ break;
+
+ case Token.COMMA :
+ result.append(", ");
+
+ break;
+
+ case Token.LC :
+ ++braceNesting;
+
+ if (Token.EOL == getNext(source, length, i)) {
+ indent += indentGap;
+ }
+
+ result.append('{');
+
+ break;
+
+ case Token.RC : {
+ --braceNesting;
+
+ /*
+ * don't print the closing RC if it closes the
+ * toplevel function and we're called from
+ * decompileFunctionBody.
+ */
+ if (justFunctionBody && braceNesting == 0) {
break;
- case Token.WHILE:
- case Token.ELSE:
- indent -= indentGap;
+ }
+
+ result.append('}');
+
+ switch (getNext(source, length, i)) {
+ case Token.EOL :
+ case FUNCTION_END :
+ indent -= indentGap;
+
+ break;
+
+ case Token.WHILE :
+ case Token.ELSE :
+ indent -= indentGap;
+ result.append(' ');
+
+ break;
+ }
+
+ break;
+ }
+
+ case Token.LP :
+ result.append('(');
+
+ break;
+
+ case Token.RP :
+ result.append(')');
+
+ if (Token.LC == getNext(source, length, i)) {
result.append(' ');
+ }
+
+ break;
+
+ case Token.LB :
+ result.append('[');
+
+ break;
+
+ case Token.RB :
+ result.append(']');
+
+ break;
+
+ case Token.EOL : {
+ if (toSource) {
break;
- }
- break;
- }
- case Token.LP:
- result.append('(');
- break;
+ }
- case Token.RP:
- result.append(')');
- if (Token.LC == getNext(source, length, i))
- result.append(' ');
- break;
+ boolean newLine = true;
- case Token.LB:
- result.append('[');
- break;
+ if (!afterFirstEOL) {
+ afterFirstEOL = true;
- case Token.RB:
- result.append(']');
- break;
+ if (justFunctionBody) {
- case Token.EOL: {
- if (toSource) break;
- boolean newLine = true;
- if (!afterFirstEOL) {
- afterFirstEOL = true;
- if (justFunctionBody) {
- /* throw away just added 'function name(...) {'
- * and restore the original indent
- */
- result.setLength(0);
- indent -= indentGap;
- newLine = false;
+ /*
+ * throw away just added 'function name(...) {'
+ * and restore the original indent
+ */
+ result.setLength(0);
+ indent -= indentGap;
+ newLine = false;
+ }
}
- }
- if (newLine) {
- result.append('\n');
- }
- /* add indent if any tokens remain,
- * less setback if next token is
- * a label, case or default.
- */
- if (i + 1 < length) {
- int less = 0;
- int nextToken = source.charAt(i + 1);
- if (nextToken == Token.CASE
- || nextToken == Token.DEFAULT)
- {
- less = indentGap - caseGap;
- } else if (nextToken == Token.RC) {
- less = indentGap;
+ if (newLine) {
+ result.append('\n');
}
- /* elaborate check against label... skip past a
- * following inlined NAME and look for a COLON.
+ /*
+ * add indent if any tokens remain,
+ * less setback if next token is
+ * a label, case or default.
*/
- else if (nextToken == Token.NAME) {
- int afterName = getSourceStringEnd(source, i + 2);
- if (source.charAt(afterName) == Token.COLON)
+ if (i + 1 < length) {
+ int less = 0;
+ int nextToken = source.charAt(i + 1);
+
+ if (nextToken == Token.CASE || nextToken == Token.DEFAULT) {
+ less = indentGap - caseGap;
+ } else if (nextToken == Token.RC) {
less = indentGap;
+ }
+
+ /*
+ * elaborate check against label... skip past a
+ * following inlined NAME and look for a COLON.
+ */
+ else if (nextToken == Token.NAME) {
+ int afterName = getSourceStringEnd(source, i + 2);
+
+ if (source.charAt(afterName) == Token.COLON) {
+ less = indentGap;
+ }
+ }
+
+ for (; less < indent; less++) {
+ result.append(' ');
+ }
}
- for (; less < indent; less++)
- result.append(' ');
+ break;
}
- break;
- }
- case Token.DOT:
- result.append('.');
- break;
- case Token.NEW:
- result.append("new ");
- break;
+ case Token.DOT :
+ result.append('.');
- case Token.DELPROP:
- result.append("delete ");
- break;
+ break;
- case Token.IF:
- result.append("if ");
- break;
+ case Token.NEW :
+ result.append("new ");
- case Token.ELSE:
- result.append("else ");
- break;
+ break;
- case Token.FOR:
- result.append("for ");
- break;
+ case Token.DELPROP :
+ result.append("delete ");
- case Token.IN:
- result.append(" in ");
- break;
+ break;
- case Token.WITH:
- result.append("with ");
- break;
+ case Token.IF :
+ result.append("if ");
- case Token.WHILE:
- result.append("while ");
- break;
+ break;
- case Token.DO:
- result.append("do ");
- break;
+ case Token.ELSE :
+ result.append("else ");
- case Token.TRY:
- result.append("try ");
- break;
+ break;
- case Token.CATCH:
- result.append("catch ");
- break;
+ case Token.FOR :
+ result.append("for ");
- case Token.FINALLY:
- result.append("finally ");
- break;
+ break;
- case Token.THROW:
- result.append("throw ");
- break;
+ case Token.IN :
+ result.append(" in ");
- case Token.SWITCH:
- result.append("switch ");
- break;
+ break;
- case Token.BREAK:
- result.append("break");
- if (Token.NAME == getNext(source, length, i))
- result.append(' ');
- break;
+ case Token.WITH :
+ result.append("with ");
- case Token.CONTINUE:
- result.append("continue");
- if (Token.NAME == getNext(source, length, i))
- result.append(' ');
- break;
+ break;
- case Token.CASE:
- result.append("case ");
- break;
+ case Token.WHILE :
+ result.append("while ");
- case Token.DEFAULT:
- result.append("default");
- break;
+ break;
- case Token.RETURN:
- result.append("return");
- if (Token.SEMI != getNext(source, length, i))
- result.append(' ');
- break;
+ case Token.DO :
+ result.append("do ");
- case Token.VAR:
- result.append("var ");
- break;
+ break;
- case Token.SEMI:
- result.append(';');
- if (Token.EOL != getNext(source, length, i)) {
- // separators in FOR
- result.append(' ');
- }
- break;
+ case Token.TRY :
+ result.append("try ");
- case Token.ASSIGN:
- result.append(" = ");
- break;
+ break;
- case Token.ASSIGN_ADD:
- result.append(" += ");
- break;
+ case Token.CATCH :
+ result.append("catch ");
- case Token.ASSIGN_SUB:
- result.append(" -= ");
- break;
+ break;
- case Token.ASSIGN_MUL:
- result.append(" *= ");
- break;
+ case Token.FINALLY :
+ result.append("finally ");
- case Token.ASSIGN_DIV:
- result.append(" /= ");
- break;
+ break;
- case Token.ASSIGN_MOD:
- result.append(" %= ");
- break;
+ case Token.THROW :
+ result.append("throw ");
- case Token.ASSIGN_BITOR:
- result.append(" |= ");
- break;
+ break;
- case Token.ASSIGN_BITXOR:
- result.append(" ^= ");
- break;
+ case Token.SWITCH :
+ result.append("switch ");
- case Token.ASSIGN_BITAND:
- result.append(" &= ");
- break;
+ break;
- case Token.ASSIGN_LSH:
- result.append(" <<= ");
- break;
+ case Token.BREAK :
+ result.append("break");
- case Token.ASSIGN_RSH:
- result.append(" >>= ");
- break;
+ if (Token.NAME == getNext(source, length, i)) {
+ result.append(' ');
+ }
- case Token.ASSIGN_URSH:
- result.append(" >>>= ");
- break;
+ break;
- case Token.HOOK:
- result.append(" ? ");
- break;
+ case Token.CONTINUE :
+ result.append("continue");
- case Token.OBJECTLIT:
- // pun OBJECTLIT to mean colon in objlit property
- // initialization.
- // This needs to be distinct from COLON in the general case
- // to distinguish from the colon in a ternary... which needs
- // different spacing.
- result.append(':');
- break;
+ if (Token.NAME == getNext(source, length, i)) {
+ result.append(' ');
+ }
- case Token.COLON:
- if (Token.EOL == getNext(source, length, i))
- // it's the end of a label
+ break;
+
+ case Token.CASE :
+ result.append("case ");
+
+ break;
+
+ case Token.DEFAULT :
+ result.append("default");
+
+ break;
+
+ case Token.RETURN :
+ result.append("return");
+
+ if (Token.SEMI != getNext(source, length, i)) {
+ result.append(' ');
+ }
+
+ break;
+
+ case Token.VAR :
+ result.append("var ");
+
+ break;
+
+ case Token.SEMI :
+ result.append(';');
+
+ if (Token.EOL != getNext(source, length, i)) {
+
+ // separators in FOR
+ result.append(' ');
+ }
+
+ break;
+
+ case Token.ASSIGN :
+ result.append(" = ");
+
+ break;
+
+ case Token.ASSIGN_ADD :
+ result.append(" += ");
+
+ break;
+
+ case Token.ASSIGN_SUB :
+ result.append(" -= ");
+
+ break;
+
+ case Token.ASSIGN_MUL :
+ result.append(" *= ");
+
+ break;
+
+ case Token.ASSIGN_DIV :
+ result.append(" /= ");
+
+ break;
+
+ case Token.ASSIGN_MOD :
+ result.append(" %= ");
+
+ break;
+
+ case Token.ASSIGN_BITOR :
+ result.append(" |= ");
+
+ break;
+
+ case Token.ASSIGN_BITXOR :
+ result.append(" ^= ");
+
+ break;
+
+ case Token.ASSIGN_BITAND :
+ result.append(" &= ");
+
+ break;
+
+ case Token.ASSIGN_LSH :
+ result.append(" <<= ");
+
+ break;
+
+ case Token.ASSIGN_RSH :
+ result.append(" >>= ");
+
+ break;
+
+ case Token.ASSIGN_URSH :
+ result.append(" >>>= ");
+
+ break;
+
+ case Token.HOOK :
+ result.append(" ? ");
+
+ break;
+
+ case Token.OBJECTLIT :
+
+ // pun OBJECTLIT to mean colon in objlit property
+ // initialization.
+ // This needs to be distinct from COLON in the general case
+ // to distinguish from the colon in a ternary... which needs
+ // different spacing.
result.append(':');
- else
- // it's the middle part of a ternary
- result.append(" : ");
- break;
- case Token.OR:
- result.append(" || ");
- break;
+ break;
- case Token.AND:
- result.append(" && ");
- break;
+ case Token.COLON :
+ if (Token.EOL == getNext(source, length, i)) {
- case Token.BITOR:
- result.append(" | ");
- break;
+ // it's the end of a label
+ result.append(':');
+ } else {
- case Token.BITXOR:
- result.append(" ^ ");
- break;
+ // it's the middle part of a ternary
+ result.append(" : ");
+ }
- case Token.BITAND:
- result.append(" & ");
- break;
+ break;
- case Token.SHEQ:
- result.append(" === ");
- break;
+ case Token.OR :
+ result.append(" || ");
- case Token.SHNE:
- result.append(" !== ");
- break;
+ break;
- case Token.EQ:
- result.append(" == ");
- break;
+ case Token.AND :
+ result.append(" && ");
- case Token.NE:
- result.append(" != ");
- break;
+ break;
- case Token.LE:
- result.append(" <= ");
- break;
+ case Token.BITOR :
+ result.append(" | ");
- case Token.LT:
- result.append(" < ");
- break;
+ break;
- case Token.GE:
- result.append(" >= ");
- break;
+ case Token.BITXOR :
+ result.append(" ^ ");
- case Token.GT:
- result.append(" > ");
- break;
+ break;
- case Token.INSTANCEOF:
- result.append(" instanceof ");
- break;
+ case Token.BITAND :
+ result.append(" & ");
- case Token.LSH:
- result.append(" << ");
- break;
+ break;
- case Token.RSH:
- result.append(" >> ");
- break;
+ case Token.SHEQ :
+ result.append(" === ");
- case Token.URSH:
- result.append(" >>> ");
- break;
+ break;
- case Token.TYPEOF:
- result.append("typeof ");
- break;
+ case Token.SHNE :
+ result.append(" !== ");
- case Token.VOID:
- result.append("void ");
- break;
+ break;
- case Token.CONST:
- result.append("const ");
- break;
+ case Token.EQ :
+ result.append(" == ");
- case Token.NOT:
- result.append('!');
- break;
+ break;
- case Token.BITNOT:
- result.append('~');
- break;
+ case Token.NE :
+ result.append(" != ");
- case Token.POS:
- result.append('+');
- break;
+ break;
- case Token.NEG:
- result.append('-');
- break;
+ case Token.LE :
+ result.append(" <= ");
- case Token.INC:
- result.append("++");
- break;
+ break;
- case Token.DEC:
- result.append("--");
- break;
+ case Token.LT :
+ result.append(" < ");
- case Token.ADD:
- result.append(" + ");
- break;
+ break;
- case Token.SUB:
- result.append(" - ");
- break;
+ case Token.GE :
+ result.append(" >= ");
- case Token.MUL:
- result.append(" * ");
- break;
+ break;
- case Token.DIV:
- result.append(" / ");
- break;
+ case Token.GT :
+ result.append(" > ");
- case Token.MOD:
- result.append(" % ");
- break;
+ break;
- case Token.COLONCOLON:
- result.append("::");
- break;
+ case Token.INSTANCEOF :
+ result.append(" instanceof ");
- case Token.DOTDOT:
- result.append("..");
- break;
+ break;
- case Token.DOTQUERY:
- result.append(".(");
- break;
+ case Token.LSH :
+ result.append(" << ");
- case Token.XMLATTR:
- result.append('@');
- break;
+ break;
- default:
- // If we don't know how to decompile it, raise an exception.
- throw new RuntimeException("Token: " +
- Token.name(source.charAt(i)));
+ case Token.RSH :
+ result.append(" >> ");
+
+ break;
+
+ case Token.URSH :
+ result.append(" >>> ");
+
+ break;
+
+ case Token.TYPEOF :
+ result.append("typeof ");
+
+ break;
+
+ case Token.VOID :
+ result.append("void ");
+
+ break;
+
+ case Token.CONST :
+ result.append("const ");
+
+ break;
+
+ case Token.NOT :
+ result.append('!');
+
+ break;
+
+ case Token.BITNOT :
+ result.append('~');
+
+ break;
+
+ case Token.POS :
+ result.append('+');
+
+ break;
+
+ case Token.NEG :
+ result.append('-');
+
+ break;
+
+ case Token.INC :
+ result.append("++");
+
+ break;
+
+ case Token.DEC :
+ result.append("--");
+
+ break;
+
+ case Token.ADD :
+ result.append(" + ");
+
+ break;
+
+ case Token.SUB :
+ result.append(" - ");
+
+ break;
+
+ case Token.MUL :
+ result.append(" * ");
+
+ break;
+
+ case Token.DIV :
+ result.append(" / ");
+
+ break;
+
+ case Token.MOD :
+ result.append(" % ");
+
+ break;
+
+ case Token.COLONCOLON :
+ result.append("::");
+
+ break;
+
+ case Token.DOTDOT :
+ result.append("..");
+
+ break;
+
+ case Token.DOTQUERY :
+ result.append(".(");
+
+ break;
+
+ case Token.XMLATTR :
+ result.append('@');
+
+ break;
+
+ default :
+
+ // If we don't know how to decompile it, raise an exception.
+ throw new RuntimeException("Token: " + Token.name(source.charAt(i)));
}
+
++i;
}
if (!toSource) {
+
// add that trailing newline if it's an outermost function.
- if (!justFunctionBody)
+ if (!justFunctionBody) {
result.append('\n');
+ }
} else {
if (topFunctionType == FunctionNode.FUNCTION_EXPRESSION) {
result.append(')');
@@ -835,28 +1002,27 @@
return result.toString();
}
- private static int getNext(String source, int length, int i)
- {
+ private static int getNext(String source, int length, int i) {
return (i + 1 < length) ? source.charAt(i + 1) : Token.EOF;
}
- private static int getSourceStringEnd(String source, int offset)
- {
+ private static int getSourceStringEnd(String source, int offset) {
return printSourceString(source, offset, false, null);
}
- private static int printSourceString(String source, int offset,
- boolean asQuotedString,
- StringBuffer sb)
- {
+ private static int printSourceString(String source, int offset, boolean asQuotedString, StringBuffer sb) {
int length = source.charAt(offset);
+
++offset;
+
if ((0x8000 & length) != 0) {
length = ((0x7FFF & length) << 16) | source.charAt(offset);
++offset;
}
+
if (sb != null) {
String str = source.substring(offset, offset + length);
+
if (!asQuotedString) {
sb.append(str);
} else {
@@ -865,52 +1031,51 @@
sb.append('"');
}
}
+
return offset + length;
}
- private static int printSourceNumber(String source, int offset,
- StringBuffer sb)
- {
+ private static int printSourceNumber(String source, int offset, StringBuffer sb) {
double number = 0.0;
char type = source.charAt(offset);
+
++offset;
+
if (type == 'S') {
if (sb != null) {
int ival = source.charAt(offset);
+
number = ival;
}
+
++offset;
} else if (type == 'J' || type == 'D') {
if (sb != null) {
long lbits;
- lbits = (long)source.charAt(offset) << 48;
- lbits |= (long)source.charAt(offset + 1) << 32;
- lbits |= (long)source.charAt(offset + 2) << 16;
+
+ lbits = (long) source.charAt(offset) << 48;
+ lbits |= (long) source.charAt(offset + 1) << 32;
+ lbits |= (long) source.charAt(offset + 2) << 16;
lbits |= source.charAt(offset + 3);
+
if (type == 'J') {
number = lbits;
} else {
number = Double.longBitsToDouble(lbits);
}
}
+
offset += 4;
} else {
+
// Bad source
throw new RuntimeException();
}
+
if (sb != null) {
sb.append(ScriptRuntime.numberToString(number, 10));
}
+
return offset;
}
-
- private char[] sourceBuffer = new char[128];
-
-// Per script/function source buffer top: parent source does not include a
-// nested functions source and uses function index as a reference instead.
- private int sourceTop;
-
-// whether to do a debug print of the source information, when decompiling.
- private static final boolean printSource = false;
-
}
Modified: root/cdk/trunk/plugins/maven-javascript-plugin/src/main/java/org/mozilla/javascript/Parser.java
===================================================================
--- root/cdk/trunk/plugins/maven-javascript-plugin/src/main/java/org/mozilla/javascript/Parser.java 2009-11-01 16:28:50 UTC (rev 15792)
+++ root/cdk/trunk/plugins/maven-javascript-plugin/src/main/java/org/mozilla/javascript/Parser.java 2009-11-01 16:30:05 UTC (rev 15793)
@@ -43,10 +43,13 @@
*
* ***** END LICENSE BLOCK ***** */
+
+
package org.mozilla.javascript;
import java.io.Reader;
import java.io.IOException;
+
import java.util.Hashtable;
/**
@@ -60,97 +63,81 @@
* @author Mike McCabe
* @author Brendan Eich
*/
+public class Parser {
-public class Parser
-{
// TokenInformation flags : currentFlaggedToken stores them together
// with token type
- final static int
- CLEAR_TI_MASK = 0xFFFF, // mask to clear token information bits
- TI_AFTER_EOL = 1 << 16, // first token of the source line
- TI_CHECK_LABEL = 1 << 17; // indicates to check for label
-
+ final static int CLEAR_TI_MASK = 0xFFFF, // mask to clear token information bits
+ TI_AFTER_EOL = 1 << 16, // first token of the source line
+ TI_CHECK_LABEL = 1 << 17; // indicates to check for label
+ boolean calledByCompileFunction;
CompilerEnvirons compilerEnv;
- private ErrorReporter errorReporter;
- private String sourceURI;
- boolean calledByCompileFunction;
-
- private TokenStream ts;
private int currentFlaggedToken;
- private int syntaxErrorCount;
- private IRFactory nf;
-
- private int nestingOfFunction;
-
+// The following are per function variables and should be saved/restored
+// during function parsing.
+// XXX Move to separated class?
+ ScriptOrFnNode currentScriptOrFn;
private Decompiler decompiler;
private String encodedSource;
+ private ErrorReporter errorReporter;
+ private int functionEndFlags;
-// The following are per function variables and should be saved/restored
-// during function parsing.
-// XXX Move to separated class?
- ScriptOrFnNode currentScriptOrFn;
- private int nestingOfWith;
+// end of per function variables
+ private boolean hasReturnValue;
private Hashtable labelSet; // map of label names into nodes
+ private ObjArray loopAndSwitchSet;
private ObjArray loopSet;
- private ObjArray loopAndSwitchSet;
- private boolean hasReturnValue;
- private int functionEndFlags;
-// end of per function variables
+ private int nestingOfFunction;
+ private int nestingOfWith;
+ private IRFactory nf;
+ private String sourceURI;
+ private int syntaxErrorCount;
+ private TokenStream ts;
- // Exception to unwind
- private static class ParserException extends RuntimeException
- {
- static final long serialVersionUID = 5882582646773765630L;
- }
-
- public Parser(CompilerEnvirons compilerEnv, ErrorReporter errorReporter)
- {
+ public Parser(CompilerEnvirons compilerEnv, ErrorReporter errorReporter) {
this.compilerEnv = compilerEnv;
this.errorReporter = errorReporter;
}
- protected Decompiler createDecompiler(CompilerEnvirons compilerEnv)
- {
+ protected Decompiler createDecompiler(CompilerEnvirons compilerEnv) {
return new Decompiler();
}
- void addStrictWarning(String messageId, String messageArg)
- {
- if (compilerEnv.isStrictMode())
+ void addStrictWarning(String messageId, String messageArg) {
+ if (compilerEnv.isStrictMode()) {
addWarning(messageId, messageArg);
+ }
}
- void addWarning(String messageId, String messageArg)
- {
+ void addWarning(String messageId, String messageArg) {
String message = ScriptRuntime.getMessage1(messageId, messageArg);
+
if (compilerEnv.reportWarningAsError()) {
++syntaxErrorCount;
- errorReporter.error(message, sourceURI, ts.getLineno(),
- ts.getLine(), ts.getOffset());
- } else
- errorReporter.warning(message, sourceURI, ts.getLineno(),
- ts.getLine(), ts.getOffset());
+ errorReporter.error(message, sourceURI, ts.getLineno(), ts.getLine(), ts.getOffset());
+ } else {
+ errorReporter.warning(message, sourceURI, ts.getLineno(), ts.getLine(), ts.getOffset());
+ }
}
- void addError(String messageId)
- {
+ void addError(String messageId) {
++syntaxErrorCount;
+
String message = ScriptRuntime.getMessage0(messageId);
- errorReporter.error(message, sourceURI, ts.getLineno(),
- ts.getLine(), ts.getOffset());
+
+ errorReporter.error(message, sourceURI, ts.getLineno(), ts.getLine(), ts.getOffset());
}
- void addError(String messageId, String messageArg)
- {
+ void addError(String messageId, String messageArg) {
++syntaxErrorCount;
+
String message = ScriptRuntime.getMessage1(messageId, messageArg);
- errorReporter.error(message, sourceURI, ts.getLineno(),
- ts.getLine(), ts.getOffset());
+
+ errorReporter.error(message, sourceURI, ts.getLineno(), ts.getLine(), ts.getOffset());
}
- RuntimeException reportError(String messageId)
- {
+ RuntimeException reportError(String messageId) {
addError(messageId);
// Throw a ParserException exception to unwind the recursive descent
@@ -158,13 +145,12 @@
throw new ParserException();
}
- private int peekToken()
- throws IOException
- {
+ private int peekToken() throws IOException {
int tt = currentFlaggedToken;
+
if (tt == Token.EOF) {
+ while ((tt = ts.getToken()) == Token.IECC) {
- while ((tt = ts.getToken()) == Token.IECC) {
/* Support for JScript conditional comments */
decompiler.addJScriptConditionalComment(ts.getString());
}
@@ -174,138 +160,139 @@
tt = ts.getToken();
if (tt == Token.IECC) {
+
/* Support for JScript conditional comments */
decompiler.addJScriptConditionalComment(ts.getString());
}
+ } while (tt == Token.EOL || tt == Token.IECC);
- } while (tt == Token.EOL || tt == Token.IECC);
tt |= TI_AFTER_EOL;
}
+
currentFlaggedToken = tt;
}
+
return tt & CLEAR_TI_MASK;
}
- private int peekFlaggedToken()
- throws IOException
- {
+ private int peekFlaggedToken() throws IOException {
peekToken();
+
return currentFlaggedToken;
}
- private void consumeToken()
- {
+ private void consumeToken() {
currentFlaggedToken = Token.EOF;
}
- private int nextToken()
- throws IOException
- {
+ private int nextToken() throws IOException {
int tt = peekToken();
+
consumeToken();
+
return tt;
}
- private int nextFlaggedToken()
- throws IOException
- {
+ private int nextFlaggedToken() throws IOException {
peekToken();
+
int ttFlagged = currentFlaggedToken;
+
consumeToken();
+
return ttFlagged;
}
- private boolean matchToken(int toMatch)
- throws IOException
- {
+ private boolean matchToken(int toMatch) throws IOException {
int tt = peekToken();
+
if (tt != toMatch) {
return false;
}
+
consumeToken();
+
return true;
}
- private int peekTokenOrEOL()
- throws IOException
- {
+ private int peekTokenOrEOL() throws IOException {
int tt = peekToken();
+
// Check for last peeked token flags
if ((currentFlaggedToken & TI_AFTER_EOL) != 0) {
tt = Token.EOL;
}
+
return tt;
}
- private void setCheckForLabel()
- {
- if ((currentFlaggedToken & CLEAR_TI_MASK) != Token.NAME)
+ private void setCheckForLabel() {
+ if ((currentFlaggedToken & CLEAR_TI_MASK) != Token.NAME) {
throw Kit.codeBug();
+ }
+
currentFlaggedToken |= TI_CHECK_LABEL;
}
- private void mustMatchToken(int toMatch, String messageId)
- throws IOException, ParserException
- {
+ private void mustMatchToken(int toMatch, String messageId) throws IOException, ParserException {
if (!matchToken(toMatch)) {
reportError(messageId);
}
}
- private void mustHaveXML()
- {
+ private void mustHaveXML() {
if (!compilerEnv.isXmlAvailable()) {
reportError("msg.XML.not.available");
}
}
- public String getEncodedSource()
- {
+ public String getEncodedSource() {
return encodedSource;
}
- public boolean eof()
- {
+ public boolean eof() {
return ts.eof();
}
- boolean insideFunction()
- {
+ boolean insideFunction() {
return nestingOfFunction != 0;
}
- private Node enterLoop(Node loopLabel)
- {
+ private Node enterLoop(Node loopLabel) {
Node loop = nf.createLoopNode(loopLabel, ts.getLineno());
+
if (loopSet == null) {
loopSet = new ObjArray();
+
if (loopAndSwitchSet == null) {
loopAndSwitchSet = new ObjArray();
}
}
+
loopSet.push(loop);
loopAndSwitchSet.push(loop);
+
return loop;
}
- private void exitLoop()
- {
+ private void exitLoop() {
loopSet.pop();
loopAndSwitchSet.pop();
}
- private Node enterSwitch(Node switchSelector, int lineno)
- {
+ private Node enterSwitch(Node switchSelector, int lineno) {
Node switchNode = nf.createSwitch(switchSelector, lineno);
+
if (loopAndSwitchSet == null) {
loopAndSwitchSet = new ObjArray();
}
+
loopAndSwitchSet.push(switchNode);
+
return switchNode;
}
- private void exitSwitch()
- {
+ private void exitSwitch() {
loopAndSwitchSet.pop();
}
@@ -317,14 +304,14 @@
* parse failure will result in a call to the ErrorReporter from
* CompilerEnvirons.)
*/
- public ScriptOrFnNode parse(String sourceString,
- String sourceURI, int lineno)
- {
+ public ScriptOrFnNode parse(String sourceString, String sourceURI, int lineno) {
this.sourceURI = sourceURI;
this.ts = new TokenStream(this, null, sourceString, lineno);
+
try {
return parse();
} catch (IOException ex) {
+
// Should never happen
throw new IllegalStateException();
}
@@ -338,32 +325,31 @@
* parse failure will result in a call to the ErrorReporter from
* CompilerEnvirons.)
*/
- public ScriptOrFnNode parse(Reader sourceReader,
- String sourceURI, int lineno)
- throws IOException
- {
+ public ScriptOrFnNode parse(Reader sourceReader, String sourceURI, int lineno) throws IOException {
this.sourceURI = sourceURI;
this.ts = new TokenStream(this, sourceReader, null, lineno);
+
return parse();
}
- private ScriptOrFnNode parse()
- throws IOException
- {
+ private ScriptOrFnNode parse() throws IOException {
this.decompiler = createDecompiler(compilerEnv);
this.nf = new IRFactory(this);
currentScriptOrFn = nf.createScript();
+
int sourceStartOffset = decompiler.getCurrentOffset();
+
this.encodedSource = null;
decompiler.addToken(Token.SCRIPT);
-
this.currentFlaggedToken = Token.EOF;
this.syntaxErrorCount = 0;
- int baseLineno = ts.getLineno(); // line number where source starts
+ int baseLineno = ts.getLineno(); // line number where source starts
- /* so we have something to add nodes to until
- * we've collected all the source */
+ /*
+ * so we have something to add nodes to until
+ * we've collected all the source
+ */
Node pn = nf.createLeaf(Token.BLOCK);
try {
@@ -375,32 +361,34 @@
}
Node n;
+
if (tt == Token.FUNCTION) {
consumeToken();
+
try {
n = function(calledByCompileFunction
- ? FunctionNode.FUNCTION_EXPRESSION
- : FunctionNode.FUNCTION_STATEMENT);
+ ? FunctionNode.FUNCTION_EXPRESSION : FunctionNode.FUNCTION_STATEMENT);
} catch (ParserException e) {
break;
}
} else {
n = statement();
}
+
nf.addChildToBack(pn, n);
}
} catch (StackOverflowError ex) {
- String msg = ScriptRuntime.getMessage0(
- "msg.too.deep.parser.recursion");
- throw Context.reportRuntimeError(msg, sourceURI,
- ts.getLineno(), null, 0);
+ String msg = ScriptRuntime.getMessage0("msg.too.deep.parser.recursion");
+
+ throw Context.reportRuntimeError(msg, sourceURI, ts.getLineno(), null, 0);
}
if (this.syntaxErrorCount != 0) {
String msg = String.valueOf(this.syntaxErrorCount);
+
msg = ScriptRuntime.getMessage1("msg.got.syntax.errors", msg);
- throw errorReporter.runtimeError(msg, sourceURI, baseLineno,
- null, 0);
+
+ throw errorReporter.runtimeError(msg, sourceURI, baseLineno, null, 0);
}
currentScriptOrFn.setSourceName(sourceURI);
@@ -408,14 +396,14 @@
currentScriptOrFn.setEndLineno(ts.getLineno());
int sourceEndOffset = decompiler.getCurrentOffset();
- currentScriptOrFn.setEncodedSourceBounds(sourceStartOffset,
- sourceEndOffset);
+ currentScriptOrFn.setEncodedSourceBounds(sourceStartOffset, sourceEndOffset);
nf.initScript(currentScriptOrFn, pn);
if (compilerEnv.isGeneratingSource()) {
encodedSource = decompiler.getEncodedSource();
}
+
this.decompiler = null; // It helps GC
return currentScriptOrFn;
@@ -427,32 +415,38 @@
* it'd only be useful for checking argument hiding, which
* I'm not doing anyway...
*/
- private Node parseFunctionBody()
- throws IOException
- {
+ private Node parseFunctionBody() throws IOException {
++nestingOfFunction;
+
Node pn = nf.createBlock(ts.getLineno());
+
try {
- bodyLoop: for (;;) {
+ bodyLoop:for (;;) {
Node n;
int tt = peekToken();
+
switch (tt) {
- case Token.ERROR:
- case Token.EOF:
- case Token.RC:
- break bodyLoop;
+ case Token.ERROR :
+ case Token.EOF :
+ case Token.RC :
+ break bodyLoop;
- case Token.FUNCTION:
- consumeToken();
- n = function(FunctionNode.FUNCTION_STATEMENT);
- break;
- default:
- n = statement();
- break;
+ case Token.FUNCTION :
+ consumeToken();
+ n = function(FunctionNode.FUNCTION_STATEMENT);
+
+ break;
+
+ default :
+ n = statement();
+
+ break;
}
+
nf.addChildToBack(pn, n);
}
} catch (ParserException e) {
+
// Ignore it
} finally {
--nestingOfFunction;
@@ -461,39 +455,45 @@
return pn;
}
- private Node function(int functionType)
- throws IOException, ParserException
- {
+ private Node function(int functionType) throws IOException, ParserException {
int syntheticType = functionType;
- int baseLineno = ts.getLineno(); // line number where source starts
-
+ int baseLineno = ts.getLineno(); // line number where source starts
int functionSourceStart = decompiler.markFunctionStart(functionType);
String name;
Node memberExprNode = null;
+
if (matchToken(Token.NAME)) {
name = ts.getString();
decompiler.addName(name);
+
if (!matchToken(Token.LP)) {
if (compilerEnv.isAllowMemberExprAsFunctionName()) {
+
// Extension to ECMA: if 'function <name>' does not follow
// by '(', assume <name> starts memberExpr
Node memberExprHead = nf.createName(name);
+
name = "";
memberExprNode = memberExprTail(false, memberExprHead);
}
+
mustMatchToken(Token.LP, "msg.no.paren.parms");
}
} else if (matchToken(Token.LP)) {
+
// Anonymous function
name = "";
} else {
name = "";
+
if (compilerEnv.isAllowMemberExprAsFunctionName()) {
+
// Note that memberExpr can not start with '(' like
// in function (1+2).toString(), because 'function (' already
// processed as anonymous function
memberExprNode = memberExpr(false);
}
+
mustMatchToken(Token.LP, "msg.no.paren.parms");
}
@@ -502,9 +502,10 @@
}
boolean nested = insideFunction();
+ FunctionNode fnNode = nf.createFunction(name);
- FunctionNode fnNode = nf.createFunction(name);
if (nested || nestingOfWith > 0) {
+
// 1. Nested functions are not affected by the dynamic scope flag
// as dynamic scope is already a parent of their scope.
// 2. Functions defined under the with statement also immune to
@@ -514,65 +515,80 @@
}
int functionIndex = currentScriptOrFn.addFunction(fnNode);
-
int functionSourceEnd;
+ ScriptOrFnNode savedScriptOrFn = currentScriptOrFn;
- ScriptOrFnNode savedScriptOrFn = currentScriptOrFn;
currentScriptOrFn = fnNode;
+
int savedNestingOfWith = nestingOfWith;
+
nestingOfWith = 0;
+
Hashtable savedLabelSet = labelSet;
+
labelSet = null;
+
ObjArray savedLoopSet = loopSet;
+
loopSet = null;
+
ObjArray savedLoopAndSwitchSet = loopAndSwitchSet;
+
loopAndSwitchSet = null;
+
boolean savedHasReturnValue = hasReturnValue;
int savedFunctionEndFlags = functionEndFlags;
+ Node body;
- Node body;
try {
decompiler.addToken(Token.LP);
+
if (!matchToken(Token.RP)) {
boolean first = true;
+
do {
- if (!first)
+ if (!first) {
decompiler.addToken(Token.COMMA);
+ }
+
first = false;
mustMatchToken(Token.NAME, "msg.no.parm");
+
String s = ts.getString();
+
if (fnNode.hasParamOrVar(s)) {
addWarning("msg.dup.parms", s);
}
+
fnNode.addParam(s);
decompiler.addName(s);
} while (matchToken(Token.COMMA));
mustMatchToken(Token.RP, "msg.no.paren.after.parms");
}
+
decompiler.addToken(Token.RP);
-
mustMatchToken(Token.LC, "msg.no.brace.body");
decompiler.addEOL(Token.LC);
body = parseFunctionBody();
mustMatchToken(Token.RC, "msg.no.brace.after.body");
- if (compilerEnv.isStrictMode() && !body.hasConsistentReturnUsage())
- {
- String msg = name.length() > 0 ? "msg.no.return.value"
- : "msg.anon.no.return.value";
- addStrictWarning(msg, name);
+ if (compilerEnv.isStrictMode() && !body.hasConsistentReturnUsage()) {
+ String msg = name.length() > 0 ? "msg.no.return.value" : "msg.anon.no.return.value";
+
+ addStrictWarning(msg, name);
}
decompiler.addToken(Token.RC);
functionSourceEnd = decompiler.markFunctionEnd(functionSourceStart);
+
if (functionType != FunctionNode.FUNCTION_EXPRESSION) {
+
// Add EOL only if function is not part of expression
// since it gets SEMI + EOL from Statement in that case
decompiler.addToken(Token.EOL);
}
- }
- finally {
+ } finally {
hasReturnValue = savedHasReturnValue;
functionEndFlags = savedFunctionEndFlags;
loopAndSwitchSet = savedLoopAndSwitchSet;
@@ -588,69 +604,74 @@
fnNode.setEndLineno(ts.getLineno());
if (name != null) {
- int index = currentScriptOrFn.getParamOrVarIndex(name);
- if (index >= 0 && index < currentScriptOrFn.getParamCount())
- addStrictWarning("msg.var.hides.arg", name);
+ int index = currentScriptOrFn.getParamOrVarIndex(name);
+
+ if (index >= 0 && index < currentScriptOrFn.getParamCount()) {
+ addStrictWarning("msg.var.hides.arg", name);
+ }
}
Node pn = nf.initFunction(fnNode, functionIndex, body, syntheticType);
+
if (memberExprNode != null) {
pn = nf.createAssignment(Token.ASSIGN, memberExprNode, pn);
+
if (functionType != FunctionNode.FUNCTION_EXPRESSION) {
+
// XXX check JScript behavior: should it be createExprStatement?
pn = nf.createExprStatementNoReturn(pn, baseLineno);
}
}
+
return pn;
}
- private Node statements()
- throws IOException
- {
+ private Node statements() throws IOException {
Node pn = nf.createBlock(ts.getLineno());
+ int tt;
- int tt;
- while((tt = peekToken()) > Token.EOF && tt != Token.RC) {
+ while ((tt = peekToken()) > Token.EOF && tt != Token.RC) {
nf.addChildToBack(pn, statement());
}
return pn;
}
- private Node condition()
- throws IOException, ParserException
- {
+ private Node condition() throws IOException, ParserException {
mustMatchToken(Token.LP, "msg.no.paren.cond");
decompiler.addToken(Token.LP);
+
Node pn = expr(false);
+
mustMatchToken(Token.RP, "msg.no.paren.after.cond");
decompiler.addToken(Token.RP);
// Report strict warning on code like "if (a = 7) ...". Suppress the
// warning if the condition is parenthesized, like "if ((a = 7)) ...".
- if (pn.getProp(Node.PARENTHESIZED_PROP) == null &&
- (pn.getType() == Token.SETNAME || pn.getType() == Token.SETPROP ||
- pn.getType() == Token.SETELEM))
- {
+ if (pn.getProp(Node.PARENTHESIZED_PROP) == null
+ && (pn.getType() == Token.SETNAME || pn.getType() == Token.SETPROP || pn.getType() == Token.SETELEM)) {
addStrictWarning("msg.equal.as.assign", "");
}
+
return pn;
}
// match a NAME; return null if no match.
- private Node matchJumpLabelName()
- throws IOException, ParserException
- {
+ private Node matchJumpLabelName() throws IOException, ParserException {
Node label = null;
+ int tt = peekTokenOrEOL();
- int tt = peekTokenOrEOL();
if (tt == Token.NAME) {
consumeToken();
+
String name = ts.getString();
+
decompiler.addName(name);
+
if (labelSet != null) {
- label = (Node)labelSet.get(name);
+ label = (Node) labelSet.get(name);
}
+
if (label == null) {
reportError("msg.undef.label");
}
@@ -659,31 +680,36 @@
return label;
}
- private Node statement()
- throws IOException
- {
+ private Node statement() throws IOException {
try {
Node pn = statementHelper(null);
+
if (pn != null) {
- if (compilerEnv.isStrictMode() && !pn.hasSideEffects())
+ if (compilerEnv.isStrictMode() && !pn.hasSideEffects()) {
addStrictWarning("msg.no.side.effects", "");
+ }
+
return pn;
}
- } catch (ParserException e) { }
+ } catch (ParserException e) {}
// skip to end of statement
int lineno = ts.getLineno();
- guessingStatementEnd: for (;;) {
+
+ guessingStatementEnd:for (;;) {
int tt = peekTokenOrEOL();
+
consumeToken();
+
switch (tt) {
- case Token.ERROR:
- case Token.EOF:
- case Token.EOL:
- case Token.SEMI:
- break guessingStatementEnd;
+ case Token.ERROR :
+ case Token.EOF :
+ case Token.EOL :
+ case Token.SEMI :
+ break guessingStatementEnd;
}
}
+
return nf.createExprStatement(nf.createName("error"), lineno);
}
@@ -691,552 +717,646 @@
* Whether the "catch (e: e instanceof Exception) { ... }" syntax
* is implemented.
*/
-
- private Node statementHelper(Node statementLabel)
- throws IOException, ParserException
- {
+ private Node statementHelper(Node statementLabel) throws IOException, ParserException {
Node pn = null;
-
int tt;
tt = peekToken();
- switch(tt) {
- case Token.IF: {
- consumeToken();
+ switch (tt) {
+ case Token.IF : {
+ consumeToken();
+ decompiler.addToken(Token.IF);
- decompiler.addToken(Token.IF);
- int lineno = ts.getLineno();
- Node cond = condition();
- decompiler.addEOL(Token.LC);
- Node ifTrue = statement();
- Node ifFalse = null;
- if (matchToken(Token.ELSE)) {
- decompiler.addToken(Token.RC);
- decompiler.addToken(Token.ELSE);
+ int lineno = ts.getLineno();
+ Node cond = condition();
+
decompiler.addEOL(Token.LC);
- ifFalse = statement();
+
+ Node ifTrue = statement();
+ Node ifFalse = null;
+
+ if (matchToken(Token.ELSE)) {
+ decompiler.addToken(Token.RC);
+ decompiler.addToken(Token.ELSE);
+ decompiler.addEOL(Token.LC);
+ ifFalse = statement();
+ }
+
+ decompiler.addEOL(Token.RC);
+ pn = nf.createIf(cond, ifTrue, ifFalse, lineno);
+
+ return pn;
}
- decompiler.addEOL(Token.RC);
- pn = nf.createIf(cond, ifTrue, ifFalse, lineno);
- return pn;
- }
- case Token.SWITCH: {
- consumeToken();
+ case Token.SWITCH : {
+ consumeToken();
+ decompiler.addToken(Token.SWITCH);
- decompiler.addToken(Token.SWITCH);
- int lineno = ts.getLineno();
- mustMatchToken(Token.LP, "msg.no.paren.switch");
- decompiler.addToken(Token.LP);
- pn = enterSwitch(expr(false), lineno);
- try {
- mustMatchToken(Token.RP, "msg.no.paren.after.switch");
- decompiler.addToken(Token.RP);
- mustMatchToken(Token.LC, "msg.no.brace.switch");
- decompiler.addEOL(Token.LC);
+ int lineno = ts.getLineno();
- boolean hasDefault = false;
- switchLoop: for (;;) {
- tt = nextToken();
- Node caseExpression;
- switch (tt) {
- case Token.RC:
- break switchLoop;
+ mustMatchToken(Token.LP, "msg.no.paren.switch");
+ decompiler.addToken(Token.LP);
+ pn = enterSwitch(expr(false), lineno);
- case Token.CASE:
- decompiler.addToken(Token.CASE);
- caseExpression = expr(false);
- mustMatchToken(Token.COLON, "msg.no.colon.case");
- decompiler.addEOL(Token.COLON);
- break;
+ try {
+ mustMatchToken(Token.RP, "msg.no.paren.after.switch");
+ decompiler.addToken(Token.RP);
+ mustMatchToken(Token.LC, "msg.no.brace.switch");
+ decompiler.addEOL(Token.LC);
- case Token.DEFAULT:
- if (hasDefault) {
- reportError("msg.double.switch.default");
+ boolean hasDefault = false;
+
+ switchLoop:for (;;) {
+ tt = nextToken();
+
+ Node caseExpression;
+
+ switch (tt) {
+ case Token.RC :
+ break switchLoop;
+
+ case Token.CASE :
+ decompiler.addToken(Token.CASE);
+ caseExpression = expr(false);
+ mustMatchToken(Token.COLON, "msg.no.colon.case");
+ decompiler.addEOL(Token.COLON);
+
+ break;
+
+ case Token.DEFAULT :
+ if (hasDefault) {
+ reportError("msg.double.switch.default");
+ }
+
+ decompiler.addToken(Token.DEFAULT);
+ hasDefault = true;
+ caseExpression = null;
+ mustMatchToken(Token.COLON, "msg.no.colon.case");
+ decompiler.addEOL(Token.COLON);
+
+ break;
+
+ default :
+ reportError("msg.bad.switch");
+
+ break switchLoop;
}
- decompiler.addToken(Token.DEFAULT);
- hasDefault = true;
- caseExpression = null;
- mustMatchToken(Token.COLON, "msg.no.colon.case");
- decompiler.addEOL(Token.COLON);
- break;
- default:
- reportError("msg.bad.switch");
- break switchLoop;
- }
+ Node block = nf.createLeaf(Token.BLOCK);
- Node block = nf.createLeaf(Token.BLOCK);
- while ((tt = peekToken()) != Token.RC
- && tt != Token.CASE
- && tt != Token.DEFAULT
- && tt != Token.EOF)
- {
- nf.addChildToBack(block, statement());
+ while ((tt = peekToken()) != Token.RC && tt != Token.CASE && tt != Token.DEFAULT
+ && tt != Token.EOF) {
+ nf.addChildToBack(block, statement());
+ }
+
+ // caseExpression == null => add default lable
+ nf.addSwitchCase(pn, caseExpression, block);
}
- // caseExpression == null => add default lable
- nf.addSwitchCase(pn, caseExpression, block);
+ decompiler.addEOL(Token.RC);
+ nf.closeSwitch(pn);
+ } finally {
+ exitSwitch();
}
- decompiler.addEOL(Token.RC);
- nf.closeSwitch(pn);
- } finally {
- exitSwitch();
+
+ return pn;
}
- return pn;
- }
- case Token.WHILE: {
- consumeToken();
- decompiler.addToken(Token.WHILE);
+ case Token.WHILE : {
+ consumeToken();
+ decompiler.addToken(Token.WHILE);
- Node loop = enterLoop(statementLabel);
- try {
- Node cond = condition();
- decompiler.addEOL(Token.LC);
- Node body = statement();
- decompiler.addEOL(Token.RC);
- pn = nf.createWhile(loop, cond, body);
- } finally {
- exitLoop();
+ Node loop = enterLoop(statementLabel);
+
+ try {
+ Node cond = condition();
+
+ decompiler.addEOL(Token.LC);
+
+ Node body = statement();
+
+ decompiler.addEOL(Token.RC);
+ pn = nf.createWhile(loop, cond, body);
+ } finally {
+ exitLoop();
+ }
+
+ return pn;
}
- return pn;
- }
- case Token.DO: {
- consumeToken();
- decompiler.addToken(Token.DO);
- decompiler.addEOL(Token.LC);
+ case Token.DO : {
+ consumeToken();
+ decompiler.addToken(Token.DO);
+ decompiler.addEOL(Token.LC);
- Node loop = enterLoop(statementLabel);
- try {
- Node body = statement();
- decompiler.addToken(Token.RC);
- mustMatchToken(Token.WHILE, "msg.no.while.do");
- decompiler.addToken(Token.WHILE);
- Node cond = condition();
- pn = nf.createDoWhile(loop, body, cond);
- } finally {
- exitLoop();
+ Node loop = enterLoop(statementLabel);
+
+ try {
+ Node body = statement();
+
+ decompiler.addToken(Token.RC);
+ mustMatchToken(Token.WHILE, "msg.no.while.do");
+ decompiler.addToken(Token.WHILE);
+
+ Node cond = condition();
+
+ pn = nf.createDoWhile(loop, body, cond);
+ } finally {
+ exitLoop();
+ }
+
+ // Always auto-insert semicon to follow SpiderMonkey:
+ // It is required by EMAScript but is ignored by the rest of
+ // world, see bug 238945
+ matchToken(Token.SEMI);
+ decompiler.addEOL(Token.SEMI);
+
+ return pn;
}
- // Always auto-insert semicon to follow SpiderMonkey:
- // It is required by EMAScript but is ignored by the rest of
- // world, see bug 238945
- matchToken(Token.SEMI);
- decompiler.addEOL(Token.SEMI);
- return pn;
- }
- case Token.FOR: {
- consumeToken();
- boolean isForEach = false;
- decompiler.addToken(Token.FOR);
+ case Token.FOR : {
+ consumeToken();
- Node loop = enterLoop(statementLabel);
- try {
+ boolean isForEach = false;
- Node init; // Node init is also foo in 'foo in Object'
- Node cond; // Node cond is also object in 'foo in Object'
- Node incr = null; // to kill warning
- Node body;
+ decompiler.addToken(Token.FOR);
- // See if this is a for each () instead of just a for ()
- if (matchToken(Token.NAME)) {
- decompiler.addName(ts.getString());
- if (ts.getString().equals("each")) {
- isForEach = true;
- } else {
- reportError("msg.no.paren.for");
+ Node loop = enterLoop(statementLabel);
+
+ try {
+ Node init; // Node init is also foo in 'foo in Object'
+ Node cond; // Node cond is also object in 'foo in Object'
+ Node incr = null; // to kill warning
+ Node body;
+
+ // See if this is a for each () instead of just a for ()
+ if (matchToken(Token.NAME)) {
+ decompiler.addName(ts.getString());
+
+ if (ts.getString().equals("each")) {
+ isForEach = true;
+ } else {
+ reportError("msg.no.paren.for");
+ }
}
- }
- mustMatchToken(Token.LP, "msg.no.paren.for");
- decompiler.addToken(Token.LP);
- tt = peekToken();
- if (tt == Token.SEMI) {
- init = nf.createLeaf(Token.EMPTY);
- } else {
- if (tt == Token.VAR) {
- // set init to a var list or initial
- consumeToken(); // consume the 'var' token
- init = variables(Token.FOR);
+ mustMatchToken(Token.LP, "msg.no.paren.for");
+ decompiler.addToken(Token.LP);
+ tt = peekToken();
+
+ if (tt == Token.SEMI) {
+ init = nf.createLeaf(Token.EMPTY);
+ } else {
+ if (tt == Token.VAR) {
+
+ // set init to a var list or initial
+ consumeToken(); // consume the 'var' token
+ init = variables(Token.FOR);
+ } else {
+ init = expr(true);
+ }
}
- else {
- init = expr(true);
- }
- }
- if (matchToken(Token.IN)) {
- decompiler.addToken(Token.IN);
- // 'cond' is the object over which we're iterating
- cond = expr(false);
- } else { // ordinary for loop
- mustMatchToken(Token.SEMI, "msg.no.semi.for");
- decompiler.addToken(Token.SEMI);
- if (peekToken() == Token.SEMI) {
- // no loop condition
- cond = nf.createLeaf(Token.EMPTY);
- } else {
+ if (matchToken(Token.IN)) {
+ decompiler.addToken(Token.IN);
+
+ // 'cond' is the object over which we're iterating
cond = expr(false);
+ } else { // ordinary for loop
+ mustMatchToken(Token.SEMI, "msg.no.semi.for");
+ decompiler.addToken(Token.SEMI);
+
+ if (peekToken() == Token.SEMI) {
+
+ // no loop condition
+ cond = nf.createLeaf(Token.EMPTY);
+ } else {
+ cond = expr(false);
+ }
+
+ mustMatchToken(Token.SEMI, "msg.no.semi.for.cond");
+ decompiler.addToken(Token.SEMI);
+
+ if (peekToken() == Token.RP) {
+ incr = nf.createLeaf(Token.EMPTY);
+ } else {
+ incr = expr(false);
+ }
}
- mustMatchToken(Token.SEMI, "msg.no.semi.for.cond");
- decompiler.addToken(Token.SEMI);
- if (peekToken() == Token.RP) {
- incr = nf.createLeaf(Token.EMPTY);
+ mustMatchToken(Token.RP, "msg.no.paren.for.ctrl");
+ decompiler.addToken(Token.RP);
+ decompiler.addEOL(Token.LC);
+ body = statement();
+ decompiler.addEOL(Token.RC);
+
+ if (incr == null) {
+
+ // cond could be null if 'in obj' got eaten
+ // by the init node.
+ pn = nf.createForIn(loop, init, cond, body, isForEach);
} else {
- incr = expr(false);
+ pn = nf.createFor(loop, init, cond, incr, body);
}
+ } finally {
+ exitLoop();
}
- mustMatchToken(Token.RP, "msg.no.paren.for.ctrl");
- decompiler.addToken(Token.RP);
+ return pn;
+ }
+
+ case Token.TRY : {
+ consumeToken();
+
+ int lineno = ts.getLineno();
+ Node tryblock;
+ Node catchblocks = null;
+ Node finallyblock = null;
+
+ decompiler.addToken(Token.TRY);
decompiler.addEOL(Token.LC);
- body = statement();
+ tryblock = statement();
decompiler.addEOL(Token.RC);
+ catchblocks = nf.createLeaf(Token.BLOCK);
- if (incr == null) {
- // cond could be null if 'in obj' got eaten
- // by the init node.
- pn = nf.createForIn(loop, init, cond, body, isForEach);
- } else {
- pn = nf.createFor(loop, init, cond, incr, body);
- }
- } finally {
- exitLoop();
- }
- return pn;
- }
+ boolean sawDefaultCatch = false;
+ int peek = peekToken();
- case Token.TRY: {
- consumeToken();
- int lineno = ts.getLineno();
+ if (peek == Token.CATCH) {
+ while (matchToken(Token.CATCH)) {
+ if (sawDefaultCatch) {
+ reportError("msg.catch.unreachable");
+ }
- Node tryblock;
- Node catchblocks = null;
- Node finallyblock = null;
+ decompiler.addToken(Token.CATCH);
+ mustMatchToken(Token.LP, "msg.no.paren.catch");
+ decompiler.addToken(Token.LP);
+ mustMatchToken(Token.NAME, "msg.bad.catchcond");
- decompiler.addToken(Token.TRY);
- decompiler.addEOL(Token.LC);
- tryblock = statement();
- decompiler.addEOL(Token.RC);
+ String varName = ts.getString();
- catchblocks = nf.createLeaf(Token.BLOCK);
+ decompiler.addName(varName);
- boolean sawDefaultCatch = false;
- int peek = peekToken();
- if (peek == Token.CATCH) {
- while (matchToken(Token.CATCH)) {
- if (sawDefaultCatch) {
- reportError("msg.catch.unreachable");
- }
- decompiler.addToken(Token.CATCH);
- mustMatchToken(Token.LP, "msg.no.paren.catch");
- decompiler.addToken(Token.LP);
+ Node catchCond = null;
- mustMatchToken(Token.NAME, "msg.bad.catchcond");
- String varName = ts.getString();
- decompiler.addName(varName);
+ if (matchToken(Token.IF)) {
+ decompiler.addToken(Token.IF);
+ catchCond = expr(false);
+ } else {
+ sawDefaultCatch = true;
+ }
- Node catchCond = null;
- if (matchToken(Token.IF)) {
- decompiler.addToken(Token.IF);
- catchCond = expr(false);
- } else {
- sawDefaultCatch = true;
+ mustMatchToken(Token.RP, "msg.bad.catchcond");
+ decompiler.addToken(Token.RP);
+ mustMatchToken(Token.LC, "msg.no.brace.catchblock");
+ decompiler.addEOL(Token.LC);
+ nf.addChildToBack(catchblocks,
+ nf.createCatch(varName, catchCond, statements(), ts.getLineno()));
+ mustMatchToken(Token.RC, "msg.no.brace.after.body");
+ decompiler.addEOL(Token.RC);
}
+ } else if (peek != Token.FINALLY) {
+ mustMatchToken(Token.FINALLY, "msg.try.no.catchfinally");
+ }
- mustMatchToken(Token.RP, "msg.bad.catchcond");
- decompiler.addToken(Token.RP);
- mustMatchToken(Token.LC, "msg.no.brace.catchblock");
+ if (matchToken(Token.FINALLY)) {
+ decompiler.addToken(Token.FINALLY);
decompiler.addEOL(Token.LC);
-
- nf.addChildToBack(catchblocks,
- nf.createCatch(varName, catchCond,
- statements(),
- ts.getLineno()));
-
- mustMatchToken(Token.RC, "msg.no.brace.after.body");
+ finallyblock = statement();
decompiler.addEOL(Token.RC);
}
- } else if (peek != Token.FINALLY) {
- mustMatchToken(Token.FINALLY, "msg.try.no.catchfinally");
- }
- if (matchToken(Token.FINALLY)) {
- decompiler.addToken(Token.FINALLY);
- decompiler.addEOL(Token.LC);
- finallyblock = statement();
- decompiler.addEOL(Token.RC);
+ pn = nf.createTryCatchFinally(tryblock, catchblocks, finallyblock, lineno);
+
+ return pn;
}
- pn = nf.createTryCatchFinally(tryblock, catchblocks,
- finallyblock, lineno);
+ case Token.THROW : {
+ consumeToken();
- return pn;
- }
+ if (peekTokenOrEOL() == Token.EOL) {
- case Token.THROW: {
- consumeToken();
- if (peekTokenOrEOL() == Token.EOL) {
- // ECMAScript does not allow new lines before throw expression,
- // see bug 256617
- reportError("msg.bad.throw.eol");
+ // ECMAScript does not allow new lines before throw expression,
+ // see bug 256617
+ reportError("msg.bad.throw.eol");
+ }
+
+ int lineno = ts.getLineno();
+
+ decompiler.addToken(Token.THROW);
+ pn = nf.createThrow(expr(false), lineno);
+
+ break;
}
- int lineno = ts.getLineno();
- decompiler.addToken(Token.THROW);
- pn = nf.createThrow(expr(false), lineno);
- break;
- }
+ case Token.BREAK : {
+ consumeToken();
- case Token.BREAK: {
- consumeToken();
- int lineno = ts.getLineno();
+ int lineno = ts.getLineno();
- decompiler.addToken(Token.BREAK);
+ decompiler.addToken(Token.BREAK);
- // matchJumpLabelName only matches if there is one
- Node breakStatement = matchJumpLabelName();
- if (breakStatement == null) {
- if (loopAndSwitchSet == null || loopAndSwitchSet.size() == 0) {
- reportError("msg.bad.break");
- return null;
+ // matchJumpLabelName only matches if there is one
+ Node breakStatement = matchJumpLabelName();
+
+ if (breakStatement == null) {
+ if (loopAndSwitchSet == null || loopAndSwitchSet.size() == 0) {
+ reportError("msg.bad.break");
+
+ return null;
+ }
+
+ breakStatement = (Node) loopAndSwitchSet.peek();
}
- breakStatement = (Node)loopAndSwitchSet.peek();
+
+ pn = nf.createBreak(breakStatement, lineno);
+
+ break;
}
- pn = nf.createBreak(breakStatement, lineno);
- break;
- }
- case Token.CONTINUE: {
- consumeToken();
- int lineno = ts.getLineno();
+ case Token.CONTINUE : {
+ consumeToken();
- decompiler.addToken(Token.CONTINUE);
+ int lineno = ts.getLineno();
- Node loop;
- // matchJumpLabelName only matches if there is one
- Node label = matchJumpLabelName();
- if (label == null) {
- if (loopSet == null || loopSet.size() == 0) {
- reportError("msg.continue.outside");
- return null;
+ decompiler.addToken(Token.CONTINUE);
+
+ Node loop;
+
+ // matchJumpLabelName only matches if there is one
+ Node label = matchJumpLabelName();
+
+ if (label == null) {
+ if (loopSet == null || loopSet.size() == 0) {
+ reportError("msg.continue.outside");
+
+ return null;
+ }
+
+ loop = (Node) loopSet.peek();
+ } else {
+ loop = nf.getLabelLoop(label);
+
+ if (loop == null) {
+ reportError("msg.continue.nonloop");
+
+ return null;
+ }
}
- loop = (Node)loopSet.peek();
- } else {
- loop = nf.getLabelLoop(label);
- if (loop == null) {
- reportError("msg.continue.nonloop");
- return null;
- }
+
+ pn = nf.createContinue(loop, lineno);
+
+ break;
}
- pn = nf.createContinue(loop, lineno);
- break;
- }
- case Token.WITH: {
- consumeToken();
+ case Token.WITH : {
+ consumeToken();
+ decompiler.addToken(Token.WITH);
- decompiler.addToken(Token.WITH);
- int lineno = ts.getLineno();
- mustMatchToken(Token.LP, "msg.no.paren.with");
- decompiler.addToken(Token.LP);
- Node obj = expr(false);
- mustMatchToken(Token.RP, "msg.no.paren.after.with");
- decompiler.addToken(Token.RP);
- decompiler.addEOL(Token.LC);
+ int lineno = ts.getLineno();
- ++nestingOfWith;
- Node body;
- try {
- body = statement();
- } finally {
- --nestingOfWith;
- }
+ mustMatchToken(Token.LP, "msg.no.paren.with");
+ decompiler.addToken(Token.LP);
- decompiler.addEOL(Token.RC);
+ Node obj = expr(false);
- pn = nf.createWith(obj, body, lineno);
- return pn;
- }
+ mustMatchToken(Token.RP, "msg.no.paren.after.with");
+ decompiler.addToken(Token.RP);
+ decompiler.addEOL(Token.LC);
+ ++nestingOfWith;
- case Token.CONST:
- case Token.VAR: {
- consumeToken();
- pn = variables(tt);
- break;
- }
+ Node body;
- case Token.RETURN: {
- if (!insideFunction()) {
- reportError("msg.bad.return");
+ try {
+ body = statement();
+ } finally {
+ --nestingOfWith;
+ }
+
+ decompiler.addEOL(Token.RC);
+ pn = nf.createWith(obj, body, lineno);
+
+ return pn;
}
- consumeToken();
- decompiler.addToken(Token.RETURN);
- int lineno = ts.getLineno();
- Node retExpr;
- /* This is ugly, but we don't want to require a semicolon. */
- tt = peekTokenOrEOL();
- switch (tt) {
- case Token.SEMI:
- case Token.RC:
- case Token.EOF:
- case Token.EOL:
- case Token.ERROR:
- retExpr = null;
+ case Token.CONST :
+ case Token.VAR : {
+ consumeToken();
+ pn = variables(tt);
+
break;
- default:
- retExpr = expr(false);
- hasReturnValue = true;
}
- pn = nf.createReturn(retExpr, lineno);
- // see if we need a strict mode warning
- if (retExpr == null) {
- if (functionEndFlags == Node.END_RETURNS_VALUE)
- addStrictWarning("msg.return.inconsistent", "");
+ case Token.RETURN : {
+ if (!insideFunction()) {
+ reportError("msg.bad.return");
+ }
- functionEndFlags |= Node.END_RETURNS;
- } else {
- if (functionEndFlags == Node.END_RETURNS)
- addStrictWarning("msg.return.inconsistent", "");
+ consumeToken();
+ decompiler.addToken(Token.RETURN);
- functionEndFlags |= Node.END_RETURNS_VALUE;
- }
+ int lineno = ts.getLineno();
+ Node retExpr;
- break;
- }
+ /* This is ugly, but we don't want to require a semicolon. */
+ tt = peekTokenOrEOL();
- case Token.LC:
- consumeToken();
- if (statementLabel != null) {
- decompiler.addToken(Token.LC);
- }
- pn = statements();
- mustMatchToken(Token.RC, "msg.no.brace.block");
- if (statementLabel != null) {
- decompiler.addEOL(Token.RC);
- }
- return pn;
+ switch (tt) {
+ case Token.SEMI :
+ case Token.RC :
+ case Token.EOF :
+ case Token.EOL :
+ case Token.ERROR :
+ retExpr = null;
- case Token.ERROR:
- // Fall thru, to have a node for error recovery to work on
- case Token.SEMI:
- consumeToken();
- pn = nf.createLeaf(Token.EMPTY);
- return pn;
+ break;
- case Token.FUNCTION: {
- consumeToken();
- pn = function(FunctionNode.FUNCTION_EXPRESSION_STATEMENT);
- return pn;
- }
+ default :
+ retExpr = expr(false);
+ hasReturnValue = true;
+ }
- case Token.DEFAULT :
- consumeToken();
- mustHaveXML();
+ pn = nf.createReturn(retExpr, lineno);
- decompiler.addToken(Token.DEFAULT);
- int nsLine = ts.getLineno();
+ // see if we need a strict mode warning
+ if (retExpr == null) {
+ if (functionEndFlags == Node.END_RETURNS_VALUE) {
+ addStrictWarning("msg.return.inconsistent", "");
+ }
- if (!(matchToken(Token.NAME)
- && ts.getString().equals("xml")))
- {
- reportError("msg.bad.namespace");
- }
- decompiler.addName(" xml");
+ functionEndFlags |= Node.END_RETURNS;
+ } else {
+ if (functionEndFlags == Node.END_RETURNS) {
+ addStrictWarning("msg.return.inconsistent", "");
+ }
- if (!(matchToken(Token.NAME)
- && ts.getString().equals("namespace")))
- {
- reportError("msg.bad.namespace");
- }
- decompiler.addName(" namespace");
+ functionEndFlags |= Node.END_RETURNS_VALUE;
+ }
- if (!matchToken(Token.ASSIGN)) {
- reportError("msg.bad.namespace");
+ break;
}
- decompiler.addToken(Token.ASSIGN);
- Node expr = expr(false);
- pn = nf.createDefaultNamespace(expr, nsLine);
- break;
+ case Token.LC :
+ consumeToken();
- case Token.NAME: {
- int lineno = ts.getLineno();
- String name = ts.getString();
- setCheckForLabel();
- pn = expr(false);
- if (pn.getType() != Token.LABEL) {
- pn = nf.createExprStatement(pn, lineno);
- } else {
- // Parsed the label: push back token should be
- // colon that primaryExpr left untouched.
- if (peekToken() != Token.COLON) Kit.codeBug();
+ if (statementLabel != null) {
+ decompiler.addToken(Token.LC);
+ }
+
+ pn = statements();
+ mustMatchToken(Token.RC, "msg.no.brace.block");
+
+ if (statementLabel != null) {
+ decompiler.addEOL(Token.RC);
+ }
+
+ return pn;
+
+ case Token.ERROR :
+
+ // Fall thru, to have a node for error recovery to work on
+ case Token.SEMI :
consumeToken();
- // depend on decompiling lookahead to guess that that
- // last name was a label.
- decompiler.addName(name);
- decompiler.addEOL(Token.COLON);
+ pn = nf.createLeaf(Token.EMPTY);
- if (labelSet == null) {
- labelSet = new Hashtable();
- } else if (labelSet.containsKey(name)) {
- reportError("msg.dup.label");
+ return pn;
+
+ case Token.FUNCTION : {
+ consumeToken();
+ pn = function(FunctionNode.FUNCTION_EXPRESSION_STATEMENT);
+
+ return pn;
+ }
+
+ case Token.DEFAULT :
+ consumeToken();
+ mustHaveXML();
+ decompiler.addToken(Token.DEFAULT);
+
+ int nsLine = ts.getLineno();
+
+ if (!(matchToken(Token.NAME) && ts.getString().equals("xml"))) {
+ reportError("msg.bad.namespace");
}
- boolean firstLabel;
- if (statementLabel == null) {
- firstLabel = true;
- statementLabel = pn;
- } else {
- // Discard multiple label nodes and use only
- // the first: it allows to simplify IRFactory
- firstLabel = false;
+ decompiler.addName(" xml");
+
+ if (!(matchToken(Token.NAME) && ts.getString().equals("namespace"))) {
+ reportError("msg.bad.namespace");
}
- labelSet.put(name, statementLabel);
- try {
- pn = statementHelper(statementLabel);
- } finally {
- labelSet.remove(name);
+
+ decompiler.addName(" namespace");
+
+ if (!matchToken(Token.ASSIGN)) {
+ reportError("msg.bad.namespace");
}
- if (firstLabel) {
- pn = nf.createLabeledStatement(statementLabel, pn);
+
+ decompiler.addToken(Token.ASSIGN);
+
+ Node expr = expr(false);
+
+ pn = nf.createDefaultNamespace(expr, nsLine);
+
+ break;
+
+ case Token.NAME : {
+ int lineno = ts.getLineno();
+ String name = ts.getString();
+
+ setCheckForLabel();
+ pn = expr(false);
+
+ if (pn.getType() != Token.LABEL) {
+ pn = nf.createExprStatement(pn, lineno);
+ } else {
+
+ // Parsed the label: push back token should be
+ // colon that primaryExpr left untouched.
+ if (peekToken() != Token.COLON) {
+ Kit.codeBug();
+ }
+
+ consumeToken();
+
+ // depend on decompiling lookahead to guess that that
+ // last name was a label.
+ decompiler.addName(name);
+ decompiler.addEOL(Token.COLON);
+
+ if (labelSet == null) {
+ labelSet = new Hashtable();
+ } else if (labelSet.containsKey(name)) {
+ reportError("msg.dup.label");
+ }
+
+ boolean firstLabel;
+
+ if (statementLabel == null) {
+ firstLabel = true;
+ statementLabel = pn;
+ } else {
+
+ // Discard multiple label nodes and use only
+ // the first: it allows to simplify IRFactory
+ firstLabel = false;
+ }
+
+ labelSet.put(name, statementLabel);
+
+ try {
+ pn = statementHelper(statementLabel);
+ } finally {
+ labelSet.remove(name);
+ }
+
+ if (firstLabel) {
+ pn = nf.createLabeledStatement(statementLabel, pn);
+ }
+
+ return pn;
}
- return pn;
+
+ break;
}
- break;
- }
- default: {
- int lineno = ts.getLineno();
- pn = expr(false);
- pn = nf.createExprStatement(pn, lineno);
- break;
- }
+ default : {
+ int lineno = ts.getLineno();
+
+ pn = expr(false);
+ pn = nf.createExprStatement(pn, lineno);
+
+ break;
+ }
}
int ttFlagged = peekFlaggedToken();
+
switch (ttFlagged & CLEAR_TI_MASK) {
- case Token.SEMI:
- // Consume ';' as a part of expression
- consumeToken();
- break;
- case Token.ERROR:
- case Token.EOF:
- case Token.RC:
- // Autoinsert ;
- break;
- default:
- if ((ttFlagged & TI_AFTER_EOL) == 0) {
- // Report error if no EOL or autoinsert ; otherwise
- reportError("msg.no.semi.stmt");
- }
- break;
+ case Token.SEMI :
+
+ // Consume ';' as a part of expression
+ consumeToken();
+
+ break;
+
+ case Token.ERROR :
+ case Token.EOF :
+ case Token.RC :
+
+ // Autoinsert ;
+ break;
+
+ default :
+ if ((ttFlagged & TI_AFTER_EOL) == 0) {
+
+ // Report error if no EOL or autoinsert ; otherwise
+ reportError("msg.no.semi.stmt");
+ }
+
+ break;
}
+
decompiler.addEOL(Token.SEMI);
return pn;
@@ -1251,13 +1371,11 @@
* @throws IOException
* @throws ParserException
*/
- private Node variables(int context)
- throws IOException, ParserException
- {
+ private Node variables(int context) throws IOException, ParserException {
Node pn;
boolean first = true;
- if (context == Token.CONST){
+ if (context == Token.CONST) {
pn = nf.createVariables(Token.CONST, ts.getLineno());
decompiler.addToken(Token.CONST);
} else {
@@ -1268,70 +1386,81 @@
for (;;) {
Node name;
Node init;
+
mustMatchToken(Token.NAME, "msg.bad.var");
+
String s = ts.getString();
- if (!first)
+ if (!first) {
decompiler.addToken(Token.COMMA);
+ }
+
first = false;
-
decompiler.addName(s);
if (context == Token.CONST) {
if (!currentScriptOrFn.addConst(s)) {
+
// We know it's already defined, since addConst passes if
// it's not defined at all. The addVar call just confirms
// what it is.
- if (currentScriptOrFn.addVar(s) != ScriptOrFnNode.DUPLICATE_CONST)
+ if (currentScriptOrFn.addVar(s) != ScriptOrFnNode.DUPLICATE_CONST) {
addError("msg.var.redecl", s);
- else
+ } else {
addError("msg.const.redecl", s);
+ }
}
} else {
int dupState = currentScriptOrFn.addVar(s);
- if (dupState == ScriptOrFnNode.DUPLICATE_CONST)
+
+ if (dupState == ScriptOrFnNode.DUPLICATE_CONST) {
addError("msg.const.redecl", s);
- else if (dupState == ScriptOrFnNode.DUPLICATE_PARAMETER)
+ } else if (dupState == ScriptOrFnNode.DUPLICATE_PARAMETER) {
addStrictWarning("msg.var.hides.arg", s);
- else if (dupState == ScriptOrFnNode.DUPLICATE_VAR)
+ } else if (dupState == ScriptOrFnNode.DUPLICATE_VAR) {
addStrictWarning("msg.var.redecl", s);
+ }
}
+
name = nf.createName(s);
// omitted check for argument hiding
-
if (matchToken(Token.ASSIGN)) {
decompiler.addToken(Token.ASSIGN);
-
init = assignExpr(context == Token.FOR);
nf.addChildToBack(name, init);
}
+
nf.addChildToBack(pn, name);
- if (!matchToken(Token.COMMA))
+
+ if (!matchToken(Token.COMMA)) {
break;
+ }
}
+
return pn;
}
- private Node expr(boolean inForInit)
- throws IOException, ParserException
- {
+ private Node expr(boolean inForInit) throws IOException, ParserException {
Node pn = assignExpr(inForInit);
+
while (matchToken(Token.COMMA)) {
decompiler.addToken(Token.COMMA);
- if (compilerEnv.isStrictMode() && !pn.hasSideEffects())
+
+ if (compilerEnv.isStrictMode() && !pn.hasSideEffects()) {
addStrictWarning("msg.no.side.effects", "");
+ }
+
pn = nf.createBinary(Token.COMMA, pn, assignExpr(inForInit));
}
+
return pn;
}
- private Node assignExpr(boolean inForInit)
- throws IOException, ParserException
- {
+ private Node assignExpr(boolean inForInit) throws IOException, ParserException {
Node pn = condExpr(inForInit);
+ int tt = peekToken();
- int tt = peekToken();
if (Token.FIRST_ASSIGN <= tt && tt <= Token.LAST_ASSIGN) {
consumeToken();
decompiler.addToken(tt);
@@ -1341,27 +1470,28 @@
return pn;
}
- private Node condExpr(boolean inForInit)
- throws IOException, ParserException
- {
+ private Node condExpr(boolean inForInit) throws IOException, ParserException {
Node pn = orExpr(inForInit);
if (matchToken(Token.HOOK)) {
decompiler.addToken(Token.HOOK);
+
Node ifTrue = assignExpr(false);
+
mustMatchToken(Token.COLON, "msg.no.colon.cond");
decompiler.addToken(Token.COLON);
+
Node ifFalse = assignExpr(inForInit);
+
return nf.createCondExpr(pn, ifTrue, ifFalse);
}
return pn;
}
- private Node orExpr(boolean inForInit)
- throws IOException, ParserException
- {
+ private Node orExpr(boolean inForInit) throws IOException, ParserException {
Node pn = andExpr(inForInit);
+
if (matchToken(Token.OR)) {
decompiler.addToken(Token.OR);
pn = nf.createBinary(Token.OR, pn, orExpr(inForInit));
@@ -1370,10 +1500,9 @@
return pn;
}
- private Node andExpr(boolean inForInit)
- throws IOException, ParserException
- {
+ private Node andExpr(boolean inForInit) throws IOException, ParserException {
Node pn = bitOrExpr(inForInit);
+
if (matchToken(Token.AND)) {
decompiler.addToken(Token.AND);
pn = nf.createBinary(Token.AND, pn, andExpr(inForInit));
@@ -1382,334 +1511,382 @@
return pn;
}
- private Node bitOrExpr(boolean inForInit)
- throws IOException, ParserException
- {
+ private Node bitOrExpr(boolean inForInit) throws IOException, ParserException {
Node pn = bitXorExpr(inForInit);
+
while (matchToken(Token.BITOR)) {
decompiler.addToken(Token.BITOR);
pn = nf.createBinary(Token.BITOR, pn, bitXorExpr(inForInit));
}
+
return pn;
}
- private Node bitXorExpr(boolean inForInit)
- throws IOException, ParserException
- {
+ private Node bitXorExpr(boolean inForInit) throws IOException, ParserException {
Node pn = bitAndExpr(inForInit);
+
while (matchToken(Token.BITXOR)) {
decompiler.addToken(Token.BITXOR);
pn = nf.createBinary(Token.BITXOR, pn, bitAndExpr(inForInit));
}
+
return pn;
}
- private Node bitAndExpr(boolean inForInit)
- throws IOException, ParserException
- {
+ private Node bitAndExpr(boolean inForInit) throws IOException, ParserException {
Node pn = eqExpr(inForInit);
+
while (matchToken(Token.BITAND)) {
decompiler.addToken(Token.BITAND);
pn = nf.createBinary(Token.BITAND, pn, eqExpr(inForInit));
}
+
return pn;
}
- private Node eqExpr(boolean inForInit)
- throws IOException, ParserException
- {
+ private Node eqExpr(boolean inForInit) throws IOException, ParserException {
Node pn = relExpr(inForInit);
+
for (;;) {
int tt = peekToken();
+
switch (tt) {
- case Token.EQ:
- case Token.NE:
- case Token.SHEQ:
- case Token.SHNE:
- consumeToken();
- int decompilerToken = tt;
- int parseToken = tt;
- if (compilerEnv.getLanguageVersion() == Context.VERSION_1_2) {
- // JavaScript 1.2 uses shallow equality for == and != .
- // In addition, convert === and !== for decompiler into
- // == and != since the decompiler is supposed to show
- // canonical source and in 1.2 ===, !== are allowed
- // only as an alias to ==, !=.
- switch (tt) {
- case Token.EQ:
- parseToken = Token.SHEQ;
- break;
- case Token.NE:
- parseToken = Token.SHNE;
- break;
- case Token.SHEQ:
- decompilerToken = Token.EQ;
- break;
- case Token.SHNE:
- decompilerToken = Token.NE;
- break;
+ case Token.EQ :
+ case Token.NE :
+ case Token.SHEQ :
+ case Token.SHNE :
+ consumeToken();
+
+ int decompilerToken = tt;
+ int parseToken = tt;
+
+ if (compilerEnv.getLanguageVersion() == Context.VERSION_1_2) {
+
+ // JavaScript 1.2 uses shallow equality for == and != .
+ // In addition, convert === and !== for decompiler into
+ // == and != since the decompiler is supposed to show
+ // canonical source and in 1.2 ===, !== are allowed
+ // only as an alias to ==, !=.
+ switch (tt) {
+ case Token.EQ :
+ parseToken = Token.SHEQ;
+
+ break;
+
+ case Token.NE :
+ parseToken = Token.SHNE;
+
+ break;
+
+ case Token.SHEQ :
+ decompilerToken = Token.EQ;
+
+ break;
+
+ case Token.SHNE :
+ decompilerToken = Token.NE;
+
+ break;
+ }
}
- }
- decompiler.addToken(decompilerToken);
- pn = nf.createBinary(parseToken, pn, relExpr(inForInit));
- continue;
+
+ decompiler.addToken(decompilerToken);
+ pn = nf.createBinary(parseToken, pn, relExpr(inForInit));
+
+ continue;
}
+
break;
}
+
return pn;
}
- private Node relExpr(boolean inForInit)
- throws IOException, ParserException
- {
+ private Node relExpr(boolean inForInit) throws IOException, ParserException {
Node pn = shiftExpr();
+
for (;;) {
int tt = peekToken();
+
switch (tt) {
- case Token.IN:
- if (inForInit)
- break;
+ case Token.IN :
+ if (inForInit) {
+ break;
+ }
+
// fall through
- case Token.INSTANCEOF:
- case Token.LE:
- case Token.LT:
- case Token.GE:
- case Token.GT:
- consumeToken();
- decompiler.addToken(tt);
- pn = nf.createBinary(tt, pn, shiftExpr());
- continue;
+ case Token.INSTANCEOF :
+ case Token.LE :
+ case Token.LT :
+ case Token.GE :
+ case Token.GT :
+ consumeToken();
+ decompiler.addToken(tt);
+ pn = nf.createBinary(tt, pn, shiftExpr());
+
+ continue;
}
+
break;
}
+
return pn;
}
- private Node shiftExpr()
- throws IOException, ParserException
- {
+ private Node shiftExpr() throws IOException, ParserException {
Node pn = addExpr();
+
for (;;) {
int tt = peekToken();
+
switch (tt) {
- case Token.LSH:
- case Token.URSH:
- case Token.RSH:
- consumeToken();
- decompiler.addToken(tt);
- pn = nf.createBinary(tt, pn, addExpr());
- continue;
+ case Token.LSH :
+ case Token.URSH :
+ case Token.RSH :
+ consumeToken();
+ decompiler.addToken(tt);
+ pn = nf.createBinary(tt, pn, addExpr());
+
+ continue;
}
+
break;
}
+
return pn;
}
- private Node addExpr()
- throws IOException, ParserException
- {
+ private Node addExpr() throws IOException, ParserException {
Node pn = mulExpr();
+
for (;;) {
int tt = peekToken();
+
if (tt == Token.ADD || tt == Token.SUB) {
consumeToken();
decompiler.addToken(tt);
+
// flushNewLines
pn = nf.createBinary(tt, pn, mulExpr());
+
continue;
}
+
break;
}
return pn;
}
- private Node mulExpr()
- throws IOException, ParserException
- {
+ private Node mulExpr() throws IOException, ParserException {
Node pn = unaryExpr();
+
for (;;) {
int tt = peekToken();
+
switch (tt) {
- case Token.MUL:
- case Token.DIV:
- case Token.MOD:
- consumeToken();
- decompiler.addToken(tt);
- pn = nf.createBinary(tt, pn, unaryExpr());
- continue;
+ case Token.MUL :
+ case Token.DIV :
+ case Token.MOD :
+ consumeToken();
+ decompiler.addToken(tt);
+ pn = nf.createBinary(tt, pn, unaryExpr());
+
+ continue;
}
+
break;
}
return pn;
}
- private Node unaryExpr()
- throws IOException, ParserException
- {
+ private Node unaryExpr() throws IOException, ParserException {
int tt;
tt = peekToken();
- switch(tt) {
- case Token.VOID:
- case Token.NOT:
- case Token.BITNOT:
- case Token.TYPEOF:
- consumeToken();
- decompiler.addToken(tt);
- return nf.createUnary(tt, unaryExpr());
+ switch (tt) {
+ case Token.VOID :
+ case Token.NOT :
+ case Token.BITNOT :
+ case Token.TYPEOF :
+ consumeToken();
+ decompiler.addToken(tt);
- case Token.ADD:
- consumeToken();
- // Convert to special POS token in decompiler and parse tree
- decompiler.addToken(Token.POS);
- return nf.createUnary(Token.POS, unaryExpr());
+ return nf.createUnary(tt, unaryExpr());
- case Token.SUB:
- consumeToken();
- // Convert to special NEG token in decompiler and parse tree
- decompiler.addToken(Token.NEG);
- return nf.createUnary(Token.NEG, unaryExpr());
+ case Token.ADD :
+ consumeToken();
- case Token.INC:
- case Token.DEC:
- consumeToken();
- decompiler.addToken(tt);
- return nf.createIncDec(tt, false, memberExpr(true));
+ // Convert to special POS token in decompiler and parse tree
+ decompiler.addToken(Token.POS);
- case Token.DELPROP:
- consumeToken();
- decompiler.addToken(Token.DELPROP);
- return nf.createUnary(Token.DELPROP, unaryExpr());
+ return nf.createUnary(Token.POS, unaryExpr());
- case Token.ERROR:
- consumeToken();
- break;
+ case Token.SUB :
+ consumeToken();
- // XML stream encountered in expression.
- case Token.LT:
- if (compilerEnv.isXmlAvailable()) {
+ // Convert to special NEG token in decompiler and parse tree
+ decompiler.addToken(Token.NEG);
+
+ return nf.createUnary(Token.NEG, unaryExpr());
+
+ case Token.INC :
+ case Token.DEC :
consumeToken();
- Node pn = xmlInitializer();
- return memberExprTail(true, pn);
- }
+ decompiler.addToken(tt);
+
+ return nf.createIncDec(tt, false, memberExpr(true));
+
+ case Token.DELPROP :
+ consumeToken();
+ decompiler.addToken(Token.DELPROP);
+
+ return nf.createUnary(Token.DELPROP, unaryExpr());
+
+ case Token.ERROR :
+ consumeToken();
+
+ break;
+
+ // XML stream encountered in expression.
+ case Token.LT :
+ if (compilerEnv.isXmlAvailable()) {
+ consumeToken();
+
+ Node pn = xmlInitializer();
+
+ return memberExprTail(true, pn);
+ }
+
// Fall thru to the default handling of RELOP
+ default :
+ Node pn = memberExpr(true);
- default:
- Node pn = memberExpr(true);
+ // Don't look across a newline boundary for a postfix incop.
+ tt = peekTokenOrEOL();
- // Don't look across a newline boundary for a postfix incop.
- tt = peekTokenOrEOL();
- if (tt == Token.INC || tt == Token.DEC) {
- consumeToken();
- decompiler.addToken(tt);
- return nf.createIncDec(tt, true, pn);
- }
- return pn;
+ if (tt == Token.INC || tt == Token.DEC) {
+ consumeToken();
+ decompiler.addToken(tt);
+
+ return nf.createIncDec(tt, true, pn);
+ }
+
+ return pn;
}
+
return nf.createName("err"); // Only reached on error. Try to continue.
-
}
- private Node xmlInitializer() throws IOException
- {
+ private Node xmlInitializer() throws IOException {
int tt = ts.getFirstXMLToken();
+
if (tt != Token.XML && tt != Token.XMLEND) {
reportError("msg.syntax");
+
return null;
}
/* Make a NEW node to append to. */
Node pnXML = nf.createLeaf(Token.NEW);
-
String xml = ts.getString();
boolean fAnonymous = xml.trim().startsWith("<>");
+ Node pn = nf.createName(fAnonymous ? "XMLList" : "XML");
- Node pn = nf.createName(fAnonymous ? "XMLList" : "XML");
nf.addChildToBack(pnXML, pn);
+ pn = null;
- pn = null;
Node expr;
- for (;;tt = ts.getNextXMLToken()) {
+
+ for (; ; tt = ts.getNextXMLToken()) {
switch (tt) {
- case Token.XML:
- xml = ts.getString();
- decompiler.addName(xml);
- mustMatchToken(Token.LC, "msg.syntax");
- decompiler.addToken(Token.LC);
- expr = (peekToken() == Token.RC)
- ? nf.createString("")
- : expr(false);
- mustMatchToken(Token.RC, "msg.syntax");
- decompiler.addToken(Token.RC);
- if (pn == null) {
- pn = nf.createString(xml);
- } else {
- pn = nf.createBinary(Token.ADD, pn, nf.createString(xml));
- }
- if (ts.isXMLAttribute()) {
- /* Need to put the result in double quotes */
- expr = nf.createUnary(Token.ESCXMLATTR, expr);
- Node prepend = nf.createBinary(Token.ADD,
- nf.createString("\""),
- expr);
- expr = nf.createBinary(Token.ADD,
- prepend,
- nf.createString("\""));
- } else {
- expr = nf.createUnary(Token.ESCXMLTEXT, expr);
- }
- pn = nf.createBinary(Token.ADD, pn, expr);
- break;
- case Token.XMLEND:
- xml = ts.getString();
- decompiler.addName(xml);
- if (pn == null) {
- pn = nf.createString(xml);
- } else {
- pn = nf.createBinary(Token.ADD, pn, nf.createString(xml));
- }
+ case Token.XML :
+ xml = ts.getString();
+ decompiler.addName(xml);
+ mustMatchToken(Token.LC, "msg.syntax");
+ decompiler.addToken(Token.LC);
+ expr = (peekToken() == Token.RC) ? nf.createString("") : expr(false);
+ mustMatchToken(Token.RC, "msg.syntax");
+ decompiler.addToken(Token.RC);
- nf.addChildToBack(pnXML, pn);
- return pnXML;
- default:
- reportError("msg.syntax");
- return null;
+ if (pn == null) {
+ pn = nf.createString(xml);
+ } else {
+ pn = nf.createBinary(Token.ADD, pn, nf.createString(xml));
+ }
+
+ if (ts.isXMLAttribute()) {
+
+ /* Need to put the result in double quotes */
+ expr = nf.createUnary(Token.ESCXMLATTR, expr);
+
+ Node prepend = nf.createBinary(Token.ADD, nf.createString("\""), expr);
+
+ expr = nf.createBinary(Token.ADD, prepend, nf.createString("\""));
+ } else {
+ expr = nf.createUnary(Token.ESCXMLTEXT, expr);
+ }
+
+ pn = nf.createBinary(Token.ADD, pn, expr);
+
+ break;
+
+ case Token.XMLEND :
+ xml = ts.getString();
+ decompiler.addName(xml);
+
+ if (pn == null) {
+ pn = nf.createString(xml);
+ } else {
+ pn = nf.createBinary(Token.ADD, pn, nf.createString(xml));
+ }
+
+ nf.addChildToBack(pnXML, pn);
+
+ return pnXML;
+
+ default :
+ reportError("msg.syntax");
+
+ return null;
}
}
}
- private void argumentList(Node listNode)
- throws IOException, ParserException
- {
+ private void argumentList(Node listNode) throws IOException, ParserException {
boolean matched;
+
matched = matchToken(Token.RP);
+
if (!matched) {
boolean first = true;
+
do {
- if (!first)
+ if (!first) {
decompiler.addToken(Token.COMMA);
+ }
+
first = false;
nf.addChildToBack(listNode, assignExpr(false));
} while (matchToken(Token.COMMA));
mustMatchToken(Token.RP, "msg.no.paren.arg");
}
+
decompiler.addToken(Token.RP);
}
- private Node memberExpr(boolean allowCallSyntax)
- throws IOException, ParserException
- {
+ private Node memberExpr(boolean allowCallSyntax) throws IOException, ParserException {
int tt;
-
Node pn;
/* Check for new expressions. */
tt = peekToken();
+
if (tt == Token.NEW) {
+
/* Eat the NEW token. */
consumeToken();
decompiler.addToken(Token.NEW);
@@ -1719,20 +1896,24 @@
if (matchToken(Token.LP)) {
decompiler.addToken(Token.LP);
+
/* Add the arguments to pn, if any are supplied. */
argumentList(pn);
}
- /* XXX there's a check in the C source against
+ /*
+ * XXX there's a check in the C source against
* "too many constructor arguments" - how many
* do we claim to support?
*/
- /* Experimental syntax: allow an object literal to follow a new expression,
+ /*
+ * Experimental syntax: allow an object literal to follow a new expression,
* which will mean a kind of anonymous class built with the JavaAdapter.
* the object literal will be passed as an additional argument to the constructor.
*/
tt = peekToken();
+
if (tt == Token.LC) {
nf.addChildToBack(pn, primaryExpr());
}
@@ -1743,95 +1924,106 @@
return memberExprTail(allowCallSyntax, pn);
}
- private Node memberExprTail(boolean allowCallSyntax, Node pn)
- throws IOException, ParserException
- {
- tailLoop:
- for (;;) {
+ private Node memberExprTail(boolean allowCallSyntax, Node pn) throws IOException, ParserException {
+ tailLoop:for (;;) {
int tt = peekToken();
+
switch (tt) {
-
- case Token.DOT:
- case Token.DOTDOT:
- {
+ case Token.DOT :
+ case Token.DOTDOT : {
int memberTypeFlags;
String s;
consumeToken();
decompiler.addToken(tt);
memberTypeFlags = 0;
+
if (tt == Token.DOTDOT) {
mustHaveXML();
memberTypeFlags = Node.DESCENDANTS_FLAG;
}
+
if (!compilerEnv.isXmlAvailable()) {
mustMatchToken(Token.NAME, "msg.no.name.after.dot");
s = ts.getString();
decompiler.addName(s);
pn = nf.createPropertyGet(pn, null, s, memberTypeFlags);
+
break;
}
tt = nextToken();
+
switch (tt) {
- // handles: name, ns::name, ns::*, ns::[expr]
- case Token.NAME:
- s = ts.getString();
- decompiler.addName(s);
- pn = propertyName(pn, s, memberTypeFlags);
- break;
- // handles: *, *::name, *::*, *::[expr]
- case Token.MUL:
- decompiler.addName("*");
- pn = propertyName(pn, "*", memberTypeFlags);
- break;
+ // handles: name, ns::name, ns::*, ns::[expr]
+ case Token.NAME :
+ s = ts.getString();
+ decompiler.addName(s);
+ pn = propertyName(pn, s, memberTypeFlags);
- // handles: '@attr', '@ns::attr', '@ns::*', '@ns::*',
- // '@::attr', '@::*', '@*', '@*::attr', '@*::*'
- case Token.XMLATTR:
- decompiler.addToken(Token.XMLATTR);
- pn = attributeAccess(pn, memberTypeFlags);
- break;
+ break;
- default:
- reportError("msg.no.name.after.dot");
+ // handles: *, *::name, *::*, *::[expr]
+ case Token.MUL :
+ decompiler.addName("*");
+ pn = propertyName(pn, "*", memberTypeFlags);
+
+ break;
+
+ // handles: '@attr', '@ns::attr', '@ns::*', '@ns::*',
+ // '@::attr', '@::*', '@*', '@*::attr', '@*::*'
+ case Token.XMLATTR :
+ decompiler.addToken(Token.XMLATTR);
+ pn = attributeAccess(pn, memberTypeFlags);
+
+ break;
+
+ default :
+ reportError("msg.no.name.after.dot");
}
}
- break;
- case Token.DOTQUERY:
- consumeToken();
- mustHaveXML();
- decompiler.addToken(Token.DOTQUERY);
- pn = nf.createDotQuery(pn, expr(false), ts.getLineno());
- mustMatchToken(Token.RP, "msg.no.paren");
- decompiler.addToken(Token.RP);
break;
- case Token.LB:
- consumeToken();
- decompiler.addToken(Token.LB);
- pn = nf.createElementGet(pn, null, expr(false), 0);
- mustMatchToken(Token.RB, "msg.no.bracket.index");
- decompiler.addToken(Token.RB);
- break;
+ case Token.DOTQUERY :
+ consumeToken();
+ mustHaveXML();
+ decompiler.addToken(Token.DOTQUERY);
+ pn = nf.createDotQuery(pn, expr(false), ts.getLineno());
+ mustMatchToken(Token.RP, "msg.no.paren");
+ decompiler.addToken(Token.RP);
- case Token.LP:
- if (!allowCallSyntax) {
+ break;
+
+ case Token.LB :
+ consumeToken();
+ decompiler.addToken(Token.LB);
+ pn = nf.createElementGet(pn, null, expr(false), 0);
+ mustMatchToken(Token.RB, "msg.no.bracket.index");
+ decompiler.addToken(Token.RB);
+
+ break;
+
+ case Token.LP :
+ if (!allowCallSyntax) {
+ break tailLoop;
+ }
+
+ consumeToken();
+ decompiler.addToken(Token.LP);
+ pn = nf.createCallOrNew(Token.CALL, pn);
+
+ /* Add the arguments to pn, if any are supplied. */
+ argumentList(pn);
+
+ break;
+
+ default :
break tailLoop;
- }
- consumeToken();
- decompiler.addToken(Token.LP);
- pn = nf.createCallOrNew(Token.CALL, pn);
- /* Add the arguments to pn, if any are supplied. */
- argumentList(pn);
- break;
-
- default:
- break tailLoop;
}
}
+
return pn;
}
@@ -1839,40 +2031,44 @@
* Xml attribute expression:
* '@attr', '@ns::attr', '@ns::*', '@ns::*', '@*', '@*::attr', '@*::*'
*/
- private Node attributeAccess(Node pn, int memberTypeFlags)
- throws IOException
- {
+ private Node attributeAccess(Node pn, int memberTypeFlags) throws IOException {
memberTypeFlags |= Node.ATTRIBUTE_FLAG;
+
int tt = nextToken();
switch (tt) {
- // handles: @name, @ns::name, @ns::*, @ns::[expr]
- case Token.NAME:
- {
+
+ // handles: @name, @ns::name, @ns::*, @ns::[expr]
+ case Token.NAME : {
String s = ts.getString();
+
decompiler.addName(s);
pn = propertyName(pn, s, memberTypeFlags);
}
- break;
- // handles: @*, @*::name, @*::*, @*::[expr]
- case Token.MUL:
- decompiler.addName("*");
- pn = propertyName(pn, "*", memberTypeFlags);
break;
- // handles @[expr]
- case Token.LB:
- decompiler.addToken(Token.LB);
- pn = nf.createElementGet(pn, null, expr(false), memberTypeFlags);
- mustMatchToken(Token.RB, "msg.no.bracket.index");
- decompiler.addToken(Token.RB);
- break;
+ // handles: @*, @*::name, @*::*, @*::[expr]
+ case Token.MUL :
+ decompiler.addName("*");
+ pn = propertyName(pn, "*", memberTypeFlags);
- default:
- reportError("msg.no.name.after.xmlAttr");
- pn = nf.createPropertyGet(pn, null, "?", memberTypeFlags);
- break;
+ break;
+
+ // handles @[expr]
+ case Token.LB :
+ decompiler.addToken(Token.LB);
+ pn = nf.createElementGet(pn, null, expr(false), memberTypeFlags);
+ mustMatchToken(Token.RB, "msg.no.bracket.index");
+ decompiler.addToken(Token.RB);
+
+ break;
+
+ default :
+ reportError("msg.no.name.after.xmlAttr");
+ pn = nf.createPropertyGet(pn, null, "?", memberTypeFlags);
+
+ break;
}
return pn;
@@ -1881,262 +2077,311 @@
/**
* Check if :: follows name in which case it becomes qualified name
*/
- private Node propertyName(Node pn, String name, int memberTypeFlags)
- throws IOException, ParserException
- {
+ private Node propertyName(Node pn, String name, int memberTypeFlags) throws IOException, ParserException {
String namespace = null;
+
if (matchToken(Token.COLONCOLON)) {
decompiler.addToken(Token.COLONCOLON);
namespace = name;
int tt = nextToken();
+
switch (tt) {
- // handles name::name
- case Token.NAME:
- name = ts.getString();
- decompiler.addName(name);
- break;
- // handles name::*
- case Token.MUL:
- decompiler.addName("*");
- name = "*";
- break;
+ // handles name::name
+ case Token.NAME :
+ name = ts.getString();
+ decompiler.addName(name);
- // handles name::[expr]
- case Token.LB:
- decompiler.addToken(Token.LB);
- pn = nf.createElementGet(pn, namespace, expr(false),
- memberTypeFlags);
- mustMatchToken(Token.RB, "msg.no.bracket.index");
- decompiler.addToken(Token.RB);
- return pn;
+ break;
- default:
- reportError("msg.no.name.after.coloncolon");
- name = "?";
+ // handles name::*
+ case Token.MUL :
+ decompiler.addName("*");
+ name = "*";
+
+ break;
+
+ // handles name::[expr]
+ case Token.LB :
+ decompiler.addToken(Token.LB);
+ pn = nf.createElementGet(pn, namespace, expr(false), memberTypeFlags);
+ mustMatchToken(Token.RB, "msg.no.bracket.index");
+ decompiler.addToken(Token.RB);
+
+ return pn;
+
+ default :
+ reportError("msg.no.name.after.coloncolon");
+ name = "?";
}
}
pn = nf.createPropertyGet(pn, namespace, name, memberTypeFlags);
+
return pn;
}
- private Node primaryExpr()
- throws IOException, ParserException
- {
+ private Node primaryExpr() throws IOException, ParserException {
Node pn;
-
int ttFlagged = nextFlaggedToken();
int tt = ttFlagged & CLEAR_TI_MASK;
- switch(tt) {
+ switch (tt) {
+ case Token.FUNCTION :
+ return function(FunctionNode.FUNCTION_EXPRESSION);
- case Token.FUNCTION:
- return function(FunctionNode.FUNCTION_EXPRESSION);
+ case Token.LB : {
+ ObjArray elems = new ObjArray();
+ int skipCount = 0;
- case Token.LB: {
- ObjArray elems = new ObjArray();
- int skipCount = 0;
- decompiler.addToken(Token.LB);
- boolean after_lb_or_comma = true;
- for (;;) {
- tt = peekToken();
+ decompiler.addToken(Token.LB);
- if (tt == Token.COMMA) {
- consumeToken();
- decompiler.addToken(Token.COMMA);
- if (!after_lb_or_comma) {
- after_lb_or_comma = true;
+ boolean after_lb_or_comma = true;
+
+ for (;;) {
+ tt = peekToken();
+
+ if (tt == Token.COMMA) {
+ consumeToken();
+ decompiler.addToken(Token.COMMA);
+
+ if (!after_lb_or_comma) {
+ after_lb_or_comma = true;
+ } else {
+ elems.add(null);
+ ++skipCount;
+ }
+ } else if (tt == Token.RB) {
+ consumeToken();
+ decompiler.addToken(Token.RB);
+
+ break;
} else {
- elems.add(null);
- ++skipCount;
+ if (!after_lb_or_comma) {
+ reportError("msg.no.bracket.arg");
+ }
+
+ elems.add(assignExpr(false));
+ after_lb_or_comma = false;
}
- } else if (tt == Token.RB) {
- consumeToken();
- decompiler.addToken(Token.RB);
- break;
- } else {
- if (!after_lb_or_comma) {
- reportError("msg.no.bracket.arg");
- }
- elems.add(assignExpr(false));
- after_lb_or_comma = false;
}
+
+ return nf.createArrayLiteral(elems, skipCount);
}
- return nf.createArrayLiteral(elems, skipCount);
- }
- case Token.LC: {
- ObjArray elems = new ObjArray();
- decompiler.addToken(Token.LC);
- if (!matchToken(Token.RC)) {
+ case Token.LC : {
+ ObjArray elems = new ObjArray();
- boolean first = true;
- commaloop:
- do {
- Object property;
+ decompiler.addToken(Token.LC);
- if (!first)
- decompiler.addToken(Token.COMMA);
- else
- first = false;
+ if (!matchToken(Token.RC)) {
+ boolean first = true;
- tt = peekToken();
- switch(tt) {
- case Token.NAME:
- case Token.STRING:
- consumeToken();
- // map NAMEs to STRINGs in object literal context
- // but tell the decompiler the proper type
- String s = ts.getString();
- if (tt == Token.NAME) {
- if (s.equals("get") &&
- peekToken() == Token.NAME) {
- decompiler.addToken(Token.GET);
+ commaloop:do {
+ Object property;
+
+ if (!first) {
+ decompiler.addToken(Token.COMMA);
+ } else {
+ first = false;
+ }
+
+ tt = peekToken();
+
+ switch (tt) {
+ case Token.NAME :
+ case Token.STRING :
consumeToken();
- s = ts.getString();
- decompiler.addName(s);
+
+ // map NAMEs to STRINGs in object literal context
+ // but tell the decompiler the proper type
+ String s = ts.getString();
+
+ if (tt == Token.NAME) {
+ if (s.equals("get") && peekToken() == Token.NAME) {
+ decompiler.addToken(Token.GET);
+ consumeToken();
+ s = ts.getString();
+ decompiler.addName(s);
+ property = ScriptRuntime.getIndexObject(s);
+
+ if (!getterSetterProperty(elems, property, true)) {
+ break commaloop;
+ }
+
+ break;
+ } else if (s.equals("set") && peekToken() == Token.NAME) {
+ decompiler.addToken(Token.SET);
+ consumeToken();
+ s = ts.getString();
+ decompiler.addName(s);
+ property = ScriptRuntime.getIndexObject(s);
+
+ if (!getterSetterProperty(elems, property, false)) {
+ break commaloop;
+ }
+
+ break;
+ }
+
+ decompiler.addName(s);
+ } else {
+ decompiler.addString(s);
+ }
+
property = ScriptRuntime.getIndexObject(s);
- if (!getterSetterProperty(elems, property,
- true))
- break commaloop;
+ plainProperty(elems, property);
+
break;
- } else if (s.equals("set") &&
- peekToken() == Token.NAME) {
- decompiler.addToken(Token.SET);
+
+ case Token.NUMBER :
consumeToken();
- s = ts.getString();
- decompiler.addName(s);
- property = ScriptRuntime.getIndexObject(s);
- if (!getterSetterProperty(elems, property,
- false))
- break commaloop;
+
+ double n = ts.getNumber();
+
+ decompiler.addNumber(n);
+ property = ScriptRuntime.getIndexObject(n);
+ plainProperty(elems, property);
+
break;
- }
- decompiler.addName(s);
- } else {
- decompiler.addString(s);
+
+ case Token.RC :
+
+ // trailing comma is OK.
+ break commaloop;
+
+ default :
+ reportError("msg.bad.prop");
+
+ break commaloop;
}
- property = ScriptRuntime.getIndexObject(s);
- plainProperty(elems, property);
- break;
+ } while (matchToken(Token.COMMA));
- case Token.NUMBER:
- consumeToken();
- double n = ts.getNumber();
- decompiler.addNumber(n);
- property = ScriptRuntime.getIndexObject(n);
- plainProperty(elems, property);
- break;
+ mustMatchToken(Token.RC, "msg.no.brace.prop");
+ }
- case Token.RC:
- // trailing comma is OK.
- break commaloop;
- default:
- reportError("msg.bad.prop");
- break commaloop;
- }
- } while (matchToken(Token.COMMA));
+ decompiler.addToken(Token.RC);
- mustMatchToken(Token.RC, "msg.no.brace.prop");
+ return nf.createObjectLiteral(elems);
}
- decompiler.addToken(Token.RC);
- return nf.createObjectLiteral(elems);
- }
- case Token.LP:
+ case Token.LP :
- /* Brendan's IR-jsparse.c makes a new node tagged with
- * TOK_LP here... I'm not sure I understand why. Isn't
- * the grouping already implicit in the structure of the
- * parse tree? also TOK_LP is already overloaded (I
- * think) in the C IR as 'function call.' */
- decompiler.addToken(Token.LP);
- pn = expr(false);
- pn.putProp(Node.PARENTHESIZED_PROP, Boolean.TRUE);
- decompiler.addToken(Token.RP);
- mustMatchToken(Token.RP, "msg.no.paren");
- return pn;
+ /*
+ * Brendan's IR-jsparse.c makes a new node tagged with
+ * TOK_LP here... I'm not sure I understand why. Isn't
+ * the grouping already implicit in the structure of the
+ * parse tree? also TOK_LP is already overloaded (I
+ * think) in the C IR as 'function call.'
+ */
+ decompiler.addToken(Token.LP);
+ pn = expr(false);
+ pn.putProp(Node.PARENTHESIZED_PROP, Boolean.TRUE);
+ decompiler.addToken(Token.RP);
+ mustMatchToken(Token.RP, "msg.no.paren");
- case Token.XMLATTR:
- mustHaveXML();
- decompiler.addToken(Token.XMLATTR);
- pn = attributeAccess(null, 0);
- return pn;
+ return pn;
- case Token.NAME: {
- String name = ts.getString();
- if ((ttFlagged & TI_CHECK_LABEL) != 0) {
- if (peekToken() == Token.COLON) {
- // Do not consume colon, it is used as unwind indicator
- // to return to statementHelper.
- // XXX Better way?
- return nf.createLabel(ts.getLineno());
+ case Token.XMLATTR :
+ mustHaveXML();
+ decompiler.addToken(Token.XMLATTR);
+ pn = attributeAccess(null, 0);
+
+ return pn;
+
+ case Token.NAME : {
+ String name = ts.getString();
+
+ if ((ttFlagged & TI_CHECK_LABEL) != 0) {
+ if (peekToken() == Token.COLON) {
+
+ // Do not consume colon, it is used as unwind indicator
+ // to return to statementHelper.
+ // XXX Better way?
+ return nf.createLabel(ts.getLineno());
+ }
}
+
+ decompiler.addName(name);
+
+ if (compilerEnv.isXmlAvailable()) {
+ pn = propertyName(null, name, 0);
+ } else {
+ pn = nf.createName(name);
+ }
+
+ return pn;
}
- decompiler.addName(name);
- if (compilerEnv.isXmlAvailable()) {
- pn = propertyName(null, name, 0);
- } else {
- pn = nf.createName(name);
+ case Token.NUMBER : {
+ double n = ts.getNumber();
+
+ decompiler.addNumber(n);
+
+ return nf.createNumber(n);
}
- return pn;
- }
- case Token.NUMBER: {
- double n = ts.getNumber();
- decompiler.addNumber(n);
- return nf.createNumber(n);
- }
+ case Token.STRING : {
+ String s = ts.getString();
- case Token.STRING: {
- String s = ts.getString();
- decompiler.addString(s);
- return nf.createString(s);
- }
+ decompiler.addString(s);
- case Token.DIV:
- case Token.ASSIGN_DIV: {
- // Got / or /= which should be treated as regexp in fact
- ts.readRegExp(tt);
- String flags = ts.regExpFlags;
- ts.regExpFlags = null;
- String re = ts.getString();
- decompiler.addRegexp(re, flags);
- int index = currentScriptOrFn.addRegexp(re, flags);
- return nf.createRegExp(index);
- }
+ return nf.createString(s);
+ }
- case Token.NULL:
- case Token.THIS:
- case Token.FALSE:
- case Token.TRUE:
- decompiler.addToken(tt);
- return nf.createLeaf(tt);
+ case Token.DIV :
+ case Token.ASSIGN_DIV : {
- case Token.RESERVED:
- reportError("msg.reserved.id");
- break;
+ // Got / or /= which should be treated as regexp in fact
+ ts.readRegExp(tt);
- case Token.ERROR:
- /* the scanner or one of its subroutines reported the error. */
- break;
+ String flags = ts.regExpFlags;
- case Token.EOF:
- reportError("msg.unexpected.eof");
- break;
+ ts.regExpFlags = null;
- default:
- reportError("msg.syntax");
- break;
+ String re = ts.getString();
+
+ decompiler.addRegexp(re, flags);
+
+ int index = currentScriptOrFn.addRegexp(re, flags);
+
+ return nf.createRegExp(index);
+ }
+
+ case Token.NULL :
+ case Token.THIS :
+ case Token.FALSE :
+ case Token.TRUE :
+ decompiler.addToken(tt);
+
+ return nf.createLeaf(tt);
+
+ case Token.RESERVED :
+ reportError("msg.reserved.id");
+
+ break;
+
+ case Token.ERROR :
+
+ /* the scanner or one of its subroutines reported the error. */
+ break;
+
+ case Token.EOF :
+ reportError("msg.unexpected.eof");
+
+ break;
+
+ default :
+ reportError("msg.syntax");
+
+ break;
}
- return null; // should never reach here
+
+ return null; // should never reach here
}
- private void plainProperty(ObjArray elems, Object property)
- throws IOException {
+ private void plainProperty(ObjArray elems, Object property) throws IOException {
mustMatchToken(Token.COLON, "msg.no.colon.prop");
// OBJLIT is used as ':' in object literal for
@@ -2146,25 +2391,37 @@
elems.add(assignExpr(false));
}
- private boolean getterSetterProperty(ObjArray elems, Object property,
- boolean isGetter) throws IOException {
+ private boolean getterSetterProperty(ObjArray elems, Object property, boolean isGetter) throws IOException {
Node f = function(FunctionNode.FUNCTION_EXPRESSION);
+
if (f.getType() != Token.FUNCTION) {
reportError("msg.bad.prop");
+
return false;
}
+
int fnIndex = f.getExistingIntProp(Node.FUNCTION_PROP);
FunctionNode fn = currentScriptOrFn.getFunctionNode(fnIndex);
+
if (fn.getFunctionName().length() != 0) {
reportError("msg.bad.prop");
+
return false;
}
+
elems.add(property);
+
if (isGetter) {
elems.add(nf.createUnary(Token.GET, f));
} else {
elems.add(nf.createUnary(Token.SET, f));
}
+
return true;
}
+
+ // Exception to unwind
+ private static class ParserException extends RuntimeException {
+ static final long serialVersionUID = 5882582646773765630L;
+ }
}
Modified: root/cdk/trunk/plugins/maven-javascript-plugin/src/main/java/org/mozilla/javascript/Token.java
===================================================================
--- root/cdk/trunk/plugins/maven-javascript-plugin/src/main/java/org/mozilla/javascript/Token.java 2009-11-01 16:28:50 UTC (rev 15792)
+++ root/cdk/trunk/plugins/maven-javascript-plugin/src/main/java/org/mozilla/javascript/Token.java 2009-11-01 16:30:05 UTC (rev 15793)
@@ -40,6 +40,8 @@
*
* ***** END LICENSE BLOCK ***** */
+
+
package org.mozilla.javascript;
/**
@@ -53,366 +55,582 @@
* @author Mike McCabe
* @author Brendan Eich
*/
+public class Token {
-public class Token
-{
-
// debug flags
public static final boolean printTrees = false;
+ static final boolean printNames = printTrees || printICode;
static final boolean printICode = false;
- static final boolean printNames = printTrees || printICode;
+ // End of interpreter bytecodes
+ public final static int
+ LAST_BYTECODE_TOKEN = REF_NS_NAME, TRY = 77, SEMI = 78, // semicolon
+ LB = 79, // left and right brackets
+ RB = 80, LC = 81, // left and right curlies (braces)
+ RC = 82, LP = 83, // left and right parentheses
+ RP = 84, COMMA = 85, // comma operator
+ ASSIGN = 86, // simple assignment (=)
+ ASSIGN_BITOR = 87, // |=
+ ASSIGN_BITXOR = 88, // ^=
+ ASSIGN_BITAND = 89, // |=
+ ASSIGN_LSH = 90, // <<=
+ ASSIGN_RSH = 91, // >>=
+ ASSIGN_URSH = 92, // >>>=
+ ASSIGN_ADD = 93, // +=
+ ASSIGN_SUB = 94, // -=
+ ASSIGN_MUL = 95, // *=
+ ASSIGN_DIV = 96, // /=
+ ASSIGN_MOD = 97; // %=
+ public final static int
+ FIRST_ASSIGN = ASSIGN, LAST_ASSIGN = ASSIGN_MOD, HOOK = 98, // conditional (?:)
+ COLON = 99, OR = 100, // logical or (||)
+ AND = 101, // logical and (&&)
+ INC = 102, // increment/decrement (++ --)
+ DEC = 103, DOT = 104, // member operator (.)
+ FUNCTION = 105, // function keyword
+ EXPORT = 106, // export keyword
+ IMPORT = 107, // import keyword
+ IF = 108, // if keyword
+ ELSE = 109, // else keyword
+ SWITCH = 110, // switch keyword
+ CASE = 111, // case keyword
+ DEFAULT = 112, // default keyword
+ WHILE = 113, // while keyword
+ DO = 114, // do keyword
+ FOR = 115, // for keyword
+ BREAK = 116, // break keyword
+ CONTINUE = 117, // continue keyword
+ VAR = 118, // var keyword
+ WITH = 119, // with keyword
+ CATCH = 120, // catch keyword
+ FINALLY = 121, // finally keyword
+ VOID = 122, // void keyword
+ RESERVED = 123, // reserved keywords
+ EMPTY = 124,
+
+ /*
+ * types used for the parse tree - these never get returned
+ * by the scanner.
+ */
+ BLOCK = 125, // statement block
+ LABEL = 126, // label
+ TARGET = 127, LOOP = 128, EXPR_VOID = 129, // expression statement in functions
+ EXPR_RESULT = 130, // expression statement in scripts
+ JSR = 131, SCRIPT = 132, // top-level node for entire script
+ TYPEOFNAME = 133, // for typeof(simple-name)
+ USE_STACK = 134, SETPROP_OP = 135, // x.y op= something
+ SETELEM_OP = 136, // x[y] op= something
+ LOCAL_BLOCK = 137, SET_REF_OP = 138, // *reference op= something
+
+ // For XML support:
+ DOTDOT = 139, // member operator (..)
+ COLONCOLON = 140, // namespace::name
+ XML = 141, // XML type
+ DOTQUERY = 142, // .() -- e.g., x.emps.emp.(name == "terry")
+ XMLATTR = 143, // @
+ XMLEND = 144,
+
+ // Optimizer-only-tokens
+ TO_OBJECT = 145, TO_DOUBLE = 146, GET = 147, // JS 1.5 get pseudo keyword
+ SET = 148, // JS 1.5 set pseudo keyword
+ CONST = 149, SETCONST = 150, SETCONSTVAR = 151, IECC = 152, // Internet Explorer conditional comment
+ LAST_TOKEN = 153;
+
/**
* Token types. These values correspond to JSTokenType values in
* jsscan.c.
*/
-
public final static int
- // start enum
- ERROR = -1, // well-known as the only code < EOF
- EOF = 0, // end of file token - (not EOF_CHAR)
- EOL = 1, // end of line
+ // start enum
+ ERROR = -1, // well-known as the only code < EOF
+ EOF = 0, // end of file token - (not EOF_CHAR)
+ EOL = 1, // end of line
+
// Interpreter reuses the following as bytecodes
- FIRST_BYTECODE_TOKEN = 2,
+ FIRST_BYTECODE_TOKEN = 2, ENTERWITH = 2, LEAVEWITH = 3, RETURN = 4, GOTO = 5, IFEQ = 6, IFNE = 7, SETNAME = 8,
+ BITOR = 9, BITXOR = 10, BITAND = 11, EQ = 12, NE = 13, LT = 14, LE = 15, GT = 16, GE = 17, LSH = 18, RSH = 19,
+ URSH = 20, ADD = 21, SUB = 22, MUL = 23, DIV = 24, MOD = 25, NOT = 26, BITNOT = 27, POS = 28, NEG = 29,
+ NEW = 30, DELPROP = 31, TYPEOF = 32, GETPROP = 33, SETPROP = 34, GETELEM = 35, SETELEM = 36, CALL = 37,
+ NAME = 38, NUMBER = 39, STRING = 40, NULL = 41, THIS = 42, FALSE = 43, TRUE = 44, SHEQ = 45, // shallow equality (===)
+ SHNE = 46, // shallow inequality (!==)
+ REGEXP = 47, BINDNAME = 48, THROW = 49, RETHROW = 50, // rethrow caught execetion: catch (e if ) use it
+ IN = 51, INSTANCEOF = 52, LOCAL_LOAD = 53, GETVAR = 54, SETVAR = 55, CATCH_SCOPE = 56, ENUM_INIT_KEYS = 57,
+ ENUM_INIT_VALUES = 58, ENUM_NEXT = 59, ENUM_ID = 60, THISFN = 61, RETURN_RESULT = 62, // to return prevoisly stored return result
+ ARRAYLIT = 63, // array literal
+ OBJECTLIT = 64, // object literal
+ GET_REF = 65, // *reference
+ SET_REF = 66, // *reference = something
+ DEL_REF = 67, // delete reference
+ REF_CALL = 68, // f(args) = something or f(args)++
+ REF_SPECIAL = 69, // reference for special properties like __proto
- ENTERWITH = 2,
- LEAVEWITH = 3,
- RETURN = 4,
- GOTO = 5,
- IFEQ = 6,
- IFNE = 7,
- SETNAME = 8,
- BITOR = 9,
- BITXOR = 10,
- BITAND = 11,
- EQ = 12,
- NE = 13,
- LT = 14,
- LE = 15,
- GT = 16,
- GE = 17,
- LSH = 18,
- RSH = 19,
- URSH = 20,
- ADD = 21,
- SUB = 22,
- MUL = 23,
- DIV = 24,
- MOD = 25,
- NOT = 26,
- BITNOT = 27,
- POS = 28,
- NEG = 29,
- NEW = 30,
- DELPROP = 31,
- TYPEOF = 32,
- GETPROP = 33,
- SETPROP = 34,
- GETELEM = 35,
- SETELEM = 36,
- CALL = 37,
- NAME = 38,
- NUMBER = 39,
- STRING = 40,
- NULL = 41,
- THIS = 42,
- FALSE = 43,
- TRUE = 44,
- SHEQ = 45, // shallow equality (===)
- SHNE = 46, // shallow inequality (!==)
- REGEXP = 47,
- BINDNAME = 48,
- THROW = 49,
- RETHROW = 50, // rethrow caught execetion: catch (e if ) use it
- IN = 51,
- INSTANCEOF = 52,
- LOCAL_LOAD = 53,
- GETVAR = 54,
- SETVAR = 55,
- CATCH_SCOPE = 56,
- ENUM_INIT_KEYS = 57,
- ENUM_INIT_VALUES = 58,
- ENUM_NEXT = 59,
- ENUM_ID = 60,
- THISFN = 61,
- RETURN_RESULT = 62, // to return prevoisly stored return result
- ARRAYLIT = 63, // array literal
- OBJECTLIT = 64, // object literal
- GET_REF = 65, // *reference
- SET_REF = 66, // *reference = something
- DEL_REF = 67, // delete reference
- REF_CALL = 68, // f(args) = something or f(args)++
- REF_SPECIAL = 69, // reference for special properties like __proto
-
// For XML support:
DEFAULTNAMESPACE = 70, // default xml namespace =
- ESCXMLATTR = 71,
- ESCXMLTEXT = 72,
- REF_MEMBER = 73, // Reference for x.@y, x..y etc.
- REF_NS_MEMBER = 74, // Reference for x.ns::y, x..ns::y etc.
- REF_NAME = 75, // Reference for @y, @[y] etc.
- REF_NS_NAME = 76; // Reference for ns::y, @ns::y@[y] etc.
+ ESCXMLATTR = 71, ESCXMLTEXT = 72, REF_MEMBER = 73, // Reference for x.@y, x..y etc.
+ REF_NS_MEMBER = 74, // Reference for x.ns::y, x..ns::y etc.
+ REF_NAME = 75, // Reference for @y, @[y] etc.
+ REF_NS_NAME = 76; // Reference for ns::y, @ns::y@[y] etc.
- // End of interpreter bytecodes
- public final static int
- LAST_BYTECODE_TOKEN = REF_NS_NAME,
+ public static String name(int token) {
+ if (!printNames) {
+ return String.valueOf(token);
+ }
- TRY = 77,
- SEMI = 78, // semicolon
- LB = 79, // left and right brackets
- RB = 80,
- LC = 81, // left and right curlies (braces)
- RC = 82,
- LP = 83, // left and right parentheses
- RP = 84,
- COMMA = 85, // comma operator
+ switch (token) {
+ case ERROR :
+ return "ERROR";
- ASSIGN = 86, // simple assignment (=)
- ASSIGN_BITOR = 87, // |=
- ASSIGN_BITXOR = 88, // ^=
- ASSIGN_BITAND = 89, // |=
- ASSIGN_LSH = 90, // <<=
- ASSIGN_RSH = 91, // >>=
- ASSIGN_URSH = 92, // >>>=
- ASSIGN_ADD = 93, // +=
- ASSIGN_SUB = 94, // -=
- ASSIGN_MUL = 95, // *=
- ASSIGN_DIV = 96, // /=
- ASSIGN_MOD = 97; // %=
+ case EOF :
+ return "EOF";
- public final static int
- FIRST_ASSIGN = ASSIGN,
- LAST_ASSIGN = ASSIGN_MOD,
+ case EOL :
+ return "EOL";
- HOOK = 98, // conditional (?:)
- COLON = 99,
- OR = 100, // logical or (||)
- AND = 101, // logical and (&&)
- INC = 102, // increment/decrement (++ --)
- DEC = 103,
- DOT = 104, // member operator (.)
- FUNCTION = 105, // function keyword
- EXPORT = 106, // export keyword
- IMPORT = 107, // import keyword
- IF = 108, // if keyword
- ELSE = 109, // else keyword
- SWITCH = 110, // switch keyword
- CASE = 111, // case keyword
- DEFAULT = 112, // default keyword
- WHILE = 113, // while keyword
- DO = 114, // do keyword
- FOR = 115, // for keyword
- BREAK = 116, // break keyword
- CONTINUE = 117, // continue keyword
- VAR = 118, // var keyword
- WITH = 119, // with keyword
- CATCH = 120, // catch keyword
- FINALLY = 121, // finally keyword
- VOID = 122, // void keyword
- RESERVED = 123, // reserved keywords
+ case ENTERWITH :
+ return "ENTERWITH";
- EMPTY = 124,
+ case LEAVEWITH :
+ return "LEAVEWITH";
- /* types used for the parse tree - these never get returned
- * by the scanner.
- */
+ case RETURN :
+ return "RETURN";
- BLOCK = 125, // statement block
- LABEL = 126, // label
- TARGET = 127,
- LOOP = 128,
- EXPR_VOID = 129, // expression statement in functions
- EXPR_RESULT = 130, // expression statement in scripts
- JSR = 131,
- SCRIPT = 132, // top-level node for entire script
- TYPEOFNAME = 133, // for typeof(simple-name)
- USE_STACK = 134,
- SETPROP_OP = 135, // x.y op= something
- SETELEM_OP = 136, // x[y] op= something
- LOCAL_BLOCK = 137,
- SET_REF_OP = 138, // *reference op= something
+ case GOTO :
+ return "GOTO";
- // For XML support:
- DOTDOT = 139, // member operator (..)
- COLONCOLON = 140, // namespace::name
- XML = 141, // XML type
- DOTQUERY = 142, // .() -- e.g., x.emps.emp.(name == "terry")
- XMLATTR = 143, // @
- XMLEND = 144,
+ case IFEQ :
+ return "IFEQ";
- // Optimizer-only-tokens
- TO_OBJECT = 145,
- TO_DOUBLE = 146,
+ case IFNE :
+ return "IFNE";
- GET = 147, // JS 1.5 get pseudo keyword
- SET = 148, // JS 1.5 set pseudo keyword
- CONST = 149,
- SETCONST = 150,
- SETCONSTVAR = 151,
+ case SETNAME :
+ return "SETNAME";
- IECC = 152, // Internet Explorer conditional comment
+ case BITOR :
+ return "BITOR";
- LAST_TOKEN = 153;
+ case BITXOR :
+ return "BITXOR";
- public static String name(int token)
- {
- if (!printNames) {
- return String.valueOf(token);
+ case BITAND :
+ return "BITAND";
+
+ case EQ :
+ return "EQ";
+
+ case NE :
+ return "NE";
+
+ case LT :
+ return "LT";
+
+ case LE :
+ return "LE";
+
+ case GT :
+ return "GT";
+
+ case GE :
+ return "GE";
+
+ case LSH :
+ return "LSH";
+
+ case RSH :
+ return "RSH";
+
+ case URSH :
+ return "URSH";
+
+ case ADD :
+ return "ADD";
+
+ case SUB :
+ return "SUB";
+
+ case MUL :
+ return "MUL";
+
+ case DIV :
+ return "DIV";
+
+ case MOD :
+ return "MOD";
+
+ case NOT :
+ return "NOT";
+
+ case BITNOT :
+ return "BITNOT";
+
+ case POS :
+ return "POS";
+
+ case NEG :
+ return "NEG";
+
+ case NEW :
+ return "NEW";
+
+ case DELPROP :
+ return "DELPROP";
+
+ case TYPEOF :
+ return "TYPEOF";
+
+ case GETPROP :
+ return "GETPROP";
+
+ case SETPROP :
+ return "SETPROP";
+
+ case GETELEM :
+ return "GETELEM";
+
+ case SETELEM :
+ return "SETELEM";
+
+ case CALL :
+ return "CALL";
+
+ case NAME :
+ return "NAME";
+
+ case NUMBER :
+ return "NUMBER";
+
+ case STRING :
+ return "STRING";
+
+ case NULL :
+ return "NULL";
+
+ case THIS :
+ return "THIS";
+
+ case FALSE :
+ return "FALSE";
+
+ case TRUE :
+ return "TRUE";
+
+ case SHEQ :
+ return "SHEQ";
+
+ case SHNE :
+ return "SHNE";
+
+ case REGEXP :
+ return "OBJECT";
+
+ case BINDNAME :
+ return "BINDNAME";
+
+ case THROW :
+ return "THROW";
+
+ case RETHROW :
+ return "RETHROW";
+
+ case IN :
+ return "IN";
+
+ case INSTANCEOF :
+ return "INSTANCEOF";
+
+ case LOCAL_LOAD :
+ return "LOCAL_LOAD";
+
+ case GETVAR :
+ return "GETVAR";
+
+ case SETVAR :
+ return "SETVAR";
+
+ case CATCH_SCOPE :
+ return "CATCH_SCOPE";
+
+ case ENUM_INIT_KEYS :
+ return "ENUM_INIT_KEYS";
+
+ case ENUM_INIT_VALUES :
+ return "ENUM_INIT_VALUES";
+
+ case ENUM_NEXT :
+ return "ENUM_NEXT";
+
+ case ENUM_ID :
+ return "ENUM_ID";
+
+ case THISFN :
+ return "THISFN";
+
+ case RETURN_RESULT :
+ return "RETURN_RESULT";
+
+ case ARRAYLIT :
+ return "ARRAYLIT";
+
+ case OBJECTLIT :
+ return "OBJECTLIT";
+
+ case GET_REF :
+ return "GET_REF";
+
+ case SET_REF :
+ return "SET_REF";
+
+ case DEL_REF :
+ return "DEL_REF";
+
+ case REF_CALL :
+ return "REF_CALL";
+
+ case REF_SPECIAL :
+ return "REF_SPECIAL";
+
+ case DEFAULTNAMESPACE :
+ return "DEFAULTNAMESPACE";
+
+ case ESCXMLTEXT :
+ return "ESCXMLTEXT";
+
+ case ESCXMLATTR :
+ return "ESCXMLATTR";
+
+ case REF_MEMBER :
+ return "REF_MEMBER";
+
+ case REF_NS_MEMBER :
+ return "REF_NS_MEMBER";
+
+ case REF_NAME :
+ return "REF_NAME";
+
+ case REF_NS_NAME :
+ return "REF_NS_NAME";
+
+ case TRY :
+ return "TRY";
+
+ case SEMI :
+ return "SEMI";
+
+ case LB :
+ return "LB";
+
+ case RB :
+ return "RB";
+
+ case LC :
+ return "LC";
+
+ case RC :
+ return "RC";
+
+ case LP :
+ return "LP";
+
+ case RP :
+ return "RP";
+
+ case COMMA :
+ return "COMMA";
+
+ case ASSIGN :
+ return "ASSIGN";
+
+ case ASSIGN_BITOR :
+ return "ASSIGN_BITOR";
+
+ case ASSIGN_BITXOR :
+ return "ASSIGN_BITXOR";
+
+ case ASSIGN_BITAND :
+ return "ASSIGN_BITAND";
+
+ case ASSIGN_LSH :
+ return "ASSIGN_LSH";
+
+ case ASSIGN_RSH :
+ return "ASSIGN_RSH";
+
+ case ASSIGN_URSH :
+ return "ASSIGN_URSH";
+
+ case ASSIGN_ADD :
+ return "ASSIGN_ADD";
+
+ case ASSIGN_SUB :
+ return "ASSIGN_SUB";
+
+ case ASSIGN_MUL :
+ return "ASSIGN_MUL";
+
+ case ASSIGN_DIV :
+ return "ASSIGN_DIV";
+
+ case ASSIGN_MOD :
+ return "ASSIGN_MOD";
+
+ case HOOK :
+ return "HOOK";
+
+ case COLON :
+ return "COLON";
+
+ case OR :
+ return "OR";
+
+ case AND :
+ return "AND";
+
+ case INC :
+ return "INC";
+
+ case DEC :
+ return "DEC";
+
+ case DOT :
+ return "DOT";
+
+ case FUNCTION :
+ return "FUNCTION";
+
+ case EXPORT :
+ return "EXPORT";
+
+ case IMPORT :
+ return "IMPORT";
+
+ case IF :
+ return "IF";
+
+ case ELSE :
+ return "ELSE";
+
+ case SWITCH :
+ return "SWITCH";
+
+ case CASE :
+ return "CASE";
+
+ case DEFAULT :
+ return "DEFAULT";
+
+ case WHILE :
+ return "WHILE";
+
+ case DO :
+ return "DO";
+
+ case FOR :
+ return "FOR";
+
+ case BREAK :
+ return "BREAK";
+
+ case CONTINUE :
+ return "CONTINUE";
+
+ case VAR :
+ return "VAR";
+
+ case WITH :
+ return "WITH";
+
+ case CATCH :
+ return "CATCH";
+
+ case FINALLY :
+ return "FINALLY";
+
+ case RESERVED :
+ return "RESERVED";
+
+ case EMPTY :
+ return "EMPTY";
+
+ case BLOCK :
+ return "BLOCK";
+
+ case LABEL :
+ return "LABEL";
+
+ case TARGET :
+ return "TARGET";
+
+ case LOOP :
+ return "LOOP";
+
+ case EXPR_VOID :
+ return "EXPR_VOID";
+
+ case EXPR_RESULT :
+ return "EXPR_RESULT";
+
+ case JSR :
+ return "JSR";
+
+ case SCRIPT :
+ return "SCRIPT";
+
+ case TYPEOFNAME :
+ return "TYPEOFNAME";
+
+ case USE_STACK :
+ return "USE_STACK";
+
+ case SETPROP_OP :
+ return "SETPROP_OP";
+
+ case SETELEM_OP :
+ return "SETELEM_OP";
+
+ case LOCAL_BLOCK :
+ return "LOCAL_BLOCK";
+
+ case SET_REF_OP :
+ return "SET_REF_OP";
+
+ case DOTDOT :
+ return "DOTDOT";
+
+ case COLONCOLON :
+ return "COLONCOLON";
+
+ case XML :
+ return "XML";
+
+ case DOTQUERY :
+ return "DOTQUERY";
+
+ case XMLATTR :
+ return "XMLATTR";
+
+ case XMLEND :
+ return "XMLEND";
+
+ case TO_OBJECT :
+ return "TO_OBJECT";
+
+ case TO_DOUBLE :
+ return "TO_DOUBLE";
+
+ case GET :
+ return "GET";
+
+ case SET :
+ return "SET";
+
+ case CONST :
+ return "CONST";
+
+ case SETCONST :
+ return "SETCONST";
}
- switch (token) {
- case ERROR: return "ERROR";
- case EOF: return "EOF";
- case EOL: return "EOL";
- case ENTERWITH: return "ENTERWITH";
- case LEAVEWITH: return "LEAVEWITH";
- case RETURN: return "RETURN";
- case GOTO: return "GOTO";
- case IFEQ: return "IFEQ";
- case IFNE: return "IFNE";
- case SETNAME: return "SETNAME";
- case BITOR: return "BITOR";
- case BITXOR: return "BITXOR";
- case BITAND: return "BITAND";
- case EQ: return "EQ";
- case NE: return "NE";
- case LT: return "LT";
- case LE: return "LE";
- case GT: return "GT";
- case GE: return "GE";
- case LSH: return "LSH";
- case RSH: return "RSH";
- case URSH: return "URSH";
- case ADD: return "ADD";
- case SUB: return "SUB";
- case MUL: return "MUL";
- case DIV: return "DIV";
- case MOD: return "MOD";
- case NOT: return "NOT";
- case BITNOT: return "BITNOT";
- case POS: return "POS";
- case NEG: return "NEG";
- case NEW: return "NEW";
- case DELPROP: return "DELPROP";
- case TYPEOF: return "TYPEOF";
- case GETPROP: return "GETPROP";
- case SETPROP: return "SETPROP";
- case GETELEM: return "GETELEM";
- case SETELEM: return "SETELEM";
- case CALL: return "CALL";
- case NAME: return "NAME";
- case NUMBER: return "NUMBER";
- case STRING: return "STRING";
- case NULL: return "NULL";
- case THIS: return "THIS";
- case FALSE: return "FALSE";
- case TRUE: return "TRUE";
- case SHEQ: return "SHEQ";
- case SHNE: return "SHNE";
- case REGEXP: return "OBJECT";
- case BINDNAME: return "BINDNAME";
- case THROW: return "THROW";
- case RETHROW: return "RETHROW";
- case IN: return "IN";
- case INSTANCEOF: return "INSTANCEOF";
- case LOCAL_LOAD: return "LOCAL_LOAD";
- case GETVAR: return "GETVAR";
- case SETVAR: return "SETVAR";
- case CATCH_SCOPE: return "CATCH_SCOPE";
- case ENUM_INIT_KEYS: return "ENUM_INIT_KEYS";
- case ENUM_INIT_VALUES: return "ENUM_INIT_VALUES";
- case ENUM_NEXT: return "ENUM_NEXT";
- case ENUM_ID: return "ENUM_ID";
- case THISFN: return "THISFN";
- case RETURN_RESULT: return "RETURN_RESULT";
- case ARRAYLIT: return "ARRAYLIT";
- case OBJECTLIT: return "OBJECTLIT";
- case GET_REF: return "GET_REF";
- case SET_REF: return "SET_REF";
- case DEL_REF: return "DEL_REF";
- case REF_CALL: return "REF_CALL";
- case REF_SPECIAL: return "REF_SPECIAL";
- case DEFAULTNAMESPACE:return "DEFAULTNAMESPACE";
- case ESCXMLTEXT: return "ESCXMLTEXT";
- case ESCXMLATTR: return "ESCXMLATTR";
- case REF_MEMBER: return "REF_MEMBER";
- case REF_NS_MEMBER: return "REF_NS_MEMBER";
- case REF_NAME: return "REF_NAME";
- case REF_NS_NAME: return "REF_NS_NAME";
- case TRY: return "TRY";
- case SEMI: return "SEMI";
- case LB: return "LB";
- case RB: return "RB";
- case LC: return "LC";
- case RC: return "RC";
- case LP: return "LP";
- case RP: return "RP";
- case COMMA: return "COMMA";
- case ASSIGN: return "ASSIGN";
- case ASSIGN_BITOR: return "ASSIGN_BITOR";
- case ASSIGN_BITXOR: return "ASSIGN_BITXOR";
- case ASSIGN_BITAND: return "ASSIGN_BITAND";
- case ASSIGN_LSH: return "ASSIGN_LSH";
- case ASSIGN_RSH: return "ASSIGN_RSH";
- case ASSIGN_URSH: return "ASSIGN_URSH";
- case ASSIGN_ADD: return "ASSIGN_ADD";
- case ASSIGN_SUB: return "ASSIGN_SUB";
- case ASSIGN_MUL: return "ASSIGN_MUL";
- case ASSIGN_DIV: return "ASSIGN_DIV";
- case ASSIGN_MOD: return "ASSIGN_MOD";
- case HOOK: return "HOOK";
- case COLON: return "COLON";
- case OR: return "OR";
- case AND: return "AND";
- case INC: return "INC";
- case DEC: return "DEC";
- case DOT: return "DOT";
- case FUNCTION: return "FUNCTION";
- case EXPORT: return "EXPORT";
- case IMPORT: return "IMPORT";
- case IF: return "IF";
- case ELSE: return "ELSE";
- case SWITCH: return "SWITCH";
- case CASE: return "CASE";
- case DEFAULT: return "DEFAULT";
- case WHILE: return "WHILE";
- case DO: return "DO";
- case FOR: return "FOR";
- case BREAK: return "BREAK";
- case CONTINUE: return "CONTINUE";
- case VAR: return "VAR";
- case WITH: return "WITH";
- case CATCH: return "CATCH";
- case FINALLY: return "FINALLY";
- case RESERVED: return "RESERVED";
- case EMPTY: return "EMPTY";
- case BLOCK: return "BLOCK";
- case LABEL: return "LABEL";
- case TARGET: return "TARGET";
- case LOOP: return "LOOP";
- case EXPR_VOID: return "EXPR_VOID";
- case EXPR_RESULT: return "EXPR_RESULT";
- case JSR: return "JSR";
- case SCRIPT: return "SCRIPT";
- case TYPEOFNAME: return "TYPEOFNAME";
- case USE_STACK: return "USE_STACK";
- case SETPROP_OP: return "SETPROP_OP";
- case SETELEM_OP: return "SETELEM_OP";
- case LOCAL_BLOCK: return "LOCAL_BLOCK";
- case SET_REF_OP: return "SET_REF_OP";
- case DOTDOT: return "DOTDOT";
- case COLONCOLON: return "COLONCOLON";
- case XML: return "XML";
- case DOTQUERY: return "DOTQUERY";
- case XMLATTR: return "XMLATTR";
- case XMLEND: return "XMLEND";
- case TO_OBJECT: return "TO_OBJECT";
- case TO_DOUBLE: return "TO_DOUBLE";
- case GET: return "GET";
- case SET: return "SET";
- case CONST: return "CONST";
- case SETCONST: return "SETCONST";
- }
// Token without name
throw new IllegalStateException(String.valueOf(token));
Modified: root/cdk/trunk/plugins/maven-javascript-plugin/src/main/java/org/mozilla/javascript/TokenStream.java
===================================================================
--- root/cdk/trunk/plugins/maven-javascript-plugin/src/main/java/org/mozilla/javascript/TokenStream.java 2009-11-01 16:28:50 UTC (rev 15792)
+++ root/cdk/trunk/plugins/maven-javascript-plugin/src/main/java/org/mozilla/javascript/TokenStream.java 2009-11-01 16:30:05 UTC (rev 15793)
@@ -42,6 +42,8 @@
*
* ***** END LICENSE BLOCK ***** */
+
+
package org.mozilla.javascript;
import java.io.*;
@@ -57,272 +59,633 @@
* @author Mike McCabe
* @author Brendan Eich
*/
+class TokenStream {
-class TokenStream
-{
/*
* For chars - because we need something out-of-range
* to check. (And checking EOF by exception is annoying.)
* Note distinction from EOF token type!
*/
- private final static int
- EOF_CHAR = -1;
+ private final static int EOF_CHAR = -1;
+ private int lineEndChar = -1;
+ private int lineStart = 0;
- TokenStream(Parser parser, Reader sourceReader, String sourceString,
- int lineno)
- {
+ // Set this to an inital non-null value so that the Parser has
+ // something to retrieve even if an error has occured and no
+ // string is found. Fosters one class of error, but saves lots of
+ // code.
+ private String string = "";
+ private char[] stringBuffer = new char[128];
+ private ObjToIntMap allStrings = new ObjToIntMap(50);
+
+ // Room to backtrace from to < on failed match of the last - in <!--
+ private final int[] ungetBuffer = new int[3];
+ private boolean hitEOF = false;
+
+ // stuff other than whitespace since start of line
+ private boolean dirtyLine;
+ private int lineno;
+ private double number;
+ private Parser parser;
+ String regExpFlags;
+ private char[] sourceBuffer;
+ private int sourceCursor;
+ private int sourceEnd;
+ private Reader sourceReader;
+ private String sourceString;
+ private int stringBufferTop;
+ private int ungetCursor;
+
+ // for xml tokenizer
+ private boolean xmlIsAttribute;
+ private boolean xmlIsTagContent;
+ private int xmlOpenTagsCount;
+
+ TokenStream(Parser parser, Reader sourceReader, String sourceString, int lineno) {
this.parser = parser;
this.lineno = lineno;
+
if (sourceReader != null) {
- if (sourceString != null) Kit.codeBug();
+ if (sourceString != null) {
+ Kit.codeBug();
+ }
+
this.sourceReader = sourceReader;
this.sourceBuffer = new char[512];
this.sourceEnd = 0;
} else {
- if (sourceString == null) Kit.codeBug();
+ if (sourceString == null) {
+ Kit.codeBug();
+ }
+
this.sourceString = sourceString;
this.sourceEnd = sourceString.length();
}
+
this.sourceCursor = 0;
}
- /* This function uses the cached op, string and number fields in
+ /*
+ * This function uses the cached op, string and number fields in
* TokenStream; if getToken has been called since the passed token
* was scanned, the op or string printed may be incorrect.
*/
- String tokenToString(int token)
- {
+ String tokenToString(int token) {
if (Token.printTrees) {
String name = Token.name(token);
switch (token) {
- case Token.STRING:
- case Token.REGEXP:
- case Token.NAME:
- return name + " `" + this.string + "'";
+ case Token.STRING :
+ case Token.REGEXP :
+ case Token.NAME :
+ return name + " `" + this.string + "'";
- case Token.NUMBER:
- return "NUMBER " + this.number;
+ case Token.NUMBER :
+ return "NUMBER " + this.number;
}
return name;
}
+
return "";
}
- static boolean isKeyword(String s)
- {
+ static boolean isKeyword(String s) {
return Token.EOF != stringToKeyword(s);
}
- private static int stringToKeyword(String name)
- {
-// #string_id_map#
-// The following assumes that Token.EOF == 0
- final int
- Id_break = Token.BREAK,
- Id_case = Token.CASE,
- Id_continue = Token.CONTINUE,
- Id_default = Token.DEFAULT,
- Id_delete = Token.DELPROP,
- Id_do = Token.DO,
- Id_else = Token.ELSE,
- Id_export = Token.EXPORT,
- Id_false = Token.FALSE,
- Id_for = Token.FOR,
- Id_function = Token.FUNCTION,
- Id_if = Token.IF,
- Id_in = Token.IN,
- Id_new = Token.NEW,
- Id_null = Token.NULL,
- Id_return = Token.RETURN,
- Id_switch = Token.SWITCH,
- Id_this = Token.THIS,
- Id_true = Token.TRUE,
- Id_typeof = Token.TYPEOF,
- Id_var = Token.VAR,
- Id_void = Token.VOID,
- Id_while = Token.WHILE,
- Id_with = Token.WITH,
+ private static int stringToKeyword(String name) {
- // the following are #ifdef RESERVE_JAVA_KEYWORDS in jsscan.c
- Id_abstract = Token.RESERVED,
- Id_boolean = Token.RESERVED,
- Id_byte = Token.RESERVED,
- Id_catch = Token.CATCH,
- Id_char = Token.RESERVED,
- Id_class = Token.RESERVED,
- Id_const = Token.CONST,
- Id_debugger = Token.RESERVED,
- Id_double = Token.RESERVED,
- Id_enum = Token.RESERVED,
- Id_extends = Token.RESERVED,
- Id_final = Token.RESERVED,
- Id_finally = Token.FINALLY,
- Id_float = Token.RESERVED,
- Id_goto = Token.RESERVED,
- Id_implements = Token.RESERVED,
- Id_import = Token.IMPORT,
- Id_instanceof = Token.INSTANCEOF,
- Id_int = Token.RESERVED,
- Id_interface = Token.RESERVED,
- Id_long = Token.RESERVED,
- Id_native = Token.RESERVED,
- Id_package = Token.RESERVED,
- Id_private = Token.RESERVED,
- Id_protected = Token.RESERVED,
- Id_public = Token.RESERVED,
- Id_short = Token.RESERVED,
- Id_static = Token.RESERVED,
- Id_super = Token.RESERVED,
- Id_synchronized = Token.RESERVED,
- Id_throw = Token.THROW,
- Id_throws = Token.RESERVED,
- Id_transient = Token.RESERVED,
- Id_try = Token.TRY,
- Id_volatile = Token.RESERVED;
+// #string_id_map#
+// The following assumes that Token.EOF == 0
+ final int Id_break = Token.BREAK, Id_case = Token.CASE, Id_continue = Token.CONTINUE,
+ Id_default = Token.DEFAULT, Id_delete = Token.DELPROP, Id_do = Token.DO, Id_else = Token.ELSE,
+ Id_export = Token.EXPORT, Id_false = Token.FALSE, Id_for = Token.FOR, Id_function = Token.FUNCTION,
+ Id_if = Token.IF, Id_in = Token.IN, Id_new = Token.NEW, Id_null = Token.NULL,
+ Id_return = Token.RETURN, Id_switch = Token.SWITCH, Id_this = Token.THIS, Id_true = Token.TRUE,
+ Id_typeof = Token.TYPEOF, Id_var = Token.VAR, Id_void = Token.VOID, Id_while = Token.WHILE,
+ Id_with = Token.WITH,
+ // the following are #ifdef RESERVE_JAVA_KEYWORDS in jsscan.c
+ Id_abstract = Token.RESERVED, Id_boolean = Token.RESERVED, Id_byte = Token.RESERVED, Id_catch = Token.CATCH,
+ Id_char = Token.RESERVED, Id_class = Token.RESERVED, Id_const = Token.CONST,
+ Id_debugger = Token.RESERVED, Id_double = Token.RESERVED, Id_enum = Token.RESERVED,
+ Id_extends = Token.RESERVED, Id_final = Token.RESERVED, Id_finally = Token.FINALLY,
+ Id_float = Token.RESERVED, Id_goto = Token.RESERVED, Id_implements = Token.RESERVED,
+ Id_import = Token.IMPORT, Id_instanceof = Token.INSTANCEOF, Id_int = Token.RESERVED,
+ Id_interface = Token.RESERVED, Id_long = Token.RESERVED, Id_native = Token.RESERVED,
+ Id_package = Token.RESERVED, Id_private = Token.RESERVED, Id_protected = Token.RESERVED,
+ Id_public = Token.RESERVED, Id_short = Token.RESERVED, Id_static = Token.RESERVED,
+ Id_super = Token.RESERVED, Id_synchronized = Token.RESERVED, Id_throw = Token.THROW,
+ Id_throws = Token.RESERVED, Id_transient = Token.RESERVED, Id_try = Token.TRY,
+ Id_volatile = Token.RESERVED;
int id;
String s = name;
-// #generated# Last update: 2001-06-01 17:45:01 CEST
- L0: { id = 0; String X = null; int c;
- L: switch (s.length()) {
- case 2: c=s.charAt(1);
- if (c=='f') { if (s.charAt(0)=='i') {id=Id_if; break L0;} }
- else if (c=='n') { if (s.charAt(0)=='i') {id=Id_in; break L0;} }
- else if (c=='o') { if (s.charAt(0)=='d') {id=Id_do; break L0;} }
- break L;
- case 3: switch (s.charAt(0)) {
- case 'f': if (s.charAt(2)=='r' && s.charAt(1)=='o') {id=Id_for; break L0;} break L;
- case 'i': if (s.charAt(2)=='t' && s.charAt(1)=='n') {id=Id_int; break L0;} break L;
- case 'n': if (s.charAt(2)=='w' && s.charAt(1)=='e') {id=Id_new; break L0;} break L;
- case 't': if (s.charAt(2)=='y' && s.charAt(1)=='r') {id=Id_try; break L0;} break L;
- case 'v': if (s.charAt(2)=='r' && s.charAt(1)=='a') {id=Id_var; break L0;} break L;
- } break L;
- case 4: switch (s.charAt(0)) {
- case 'b': X="byte";id=Id_byte; break L;
- case 'c': c=s.charAt(3);
- if (c=='e') { if (s.charAt(2)=='s' && s.charAt(1)=='a') {id=Id_case; break L0;} }
- else if (c=='r') { if (s.charAt(2)=='a' && s.charAt(1)=='h') {id=Id_char; break L0;} }
+
+// #generated# Last update: 2001-06-01 17:45:01 CEST
+ L0:{
+ id = 0;
+
+ String X = null;
+ int c;
+
+ L:switch (s.length()) {
+ case 2 :
+ c = s.charAt(1);
+
+ if (c == 'f') {
+ if (s.charAt(0) == 'i') {
+ id = Id_if;
+
+ break L0;
+ }
+ } else if (c == 'n') {
+ if (s.charAt(0) == 'i') {
+ id = Id_in;
+
+ break L0;
+ }
+ } else if (c == 'o') {
+ if (s.charAt(0) == 'd') {
+ id = Id_do;
+
+ break L0;
+ }
+ }
+
break L;
- case 'e': c=s.charAt(3);
- if (c=='e') { if (s.charAt(2)=='s' && s.charAt(1)=='l') {id=Id_else; break L0;} }
- else if (c=='m') { if (s.charAt(2)=='u' && s.charAt(1)=='n') {id=Id_enum; break L0;} }
+
+ case 3 :
+ switch (s.charAt(0)) {
+ case 'f' :
+ if (s.charAt(2) == 'r' && s.charAt(1) == 'o') {
+ id = Id_for;
+
+ break L0;
+ }
+
+ break L;
+
+ case 'i' :
+ if (s.charAt(2) == 't' && s.charAt(1) == 'n') {
+ id = Id_int;
+
+ break L0;
+ }
+
+ break L;
+
+ case 'n' :
+ if (s.charAt(2) == 'w' && s.charAt(1) == 'e') {
+ id = Id_new;
+
+ break L0;
+ }
+
+ break L;
+
+ case 't' :
+ if (s.charAt(2) == 'y' && s.charAt(1) == 'r') {
+ id = Id_try;
+
+ break L0;
+ }
+
+ break L;
+
+ case 'v' :
+ if (s.charAt(2) == 'r' && s.charAt(1) == 'a') {
+ id = Id_var;
+
+ break L0;
+ }
+
+ break L;
+ }
+
break L;
- case 'g': X="goto";id=Id_goto; break L;
- case 'l': X="long";id=Id_long; break L;
- case 'n': X="null";id=Id_null; break L;
- case 't': c=s.charAt(3);
- if (c=='e') { if (s.charAt(2)=='u' && s.charAt(1)=='r') {id=Id_true; break L0;} }
- else if (c=='s') { if (s.charAt(2)=='i' && s.charAt(1)=='h') {id=Id_this; break L0;} }
+
+ case 4 :
+ switch (s.charAt(0)) {
+ case 'b' :
+ X = "byte";
+ id = Id_byte;
+
+ break L;
+
+ case 'c' :
+ c = s.charAt(3);
+
+ if (c == 'e') {
+ if (s.charAt(2) == 's' && s.charAt(1) == 'a') {
+ id = Id_case;
+
+ break L0;
+ }
+ } else if (c == 'r') {
+ if (s.charAt(2) == 'a' && s.charAt(1) == 'h') {
+ id = Id_char;
+
+ break L0;
+ }
+ }
+
+ break L;
+
+ case 'e' :
+ c = s.charAt(3);
+
+ if (c == 'e') {
+ if (s.charAt(2) == 's' && s.charAt(1) == 'l') {
+ id = Id_else;
+
+ break L0;
+ }
+ } else if (c == 'm') {
+ if (s.charAt(2) == 'u' && s.charAt(1) == 'n') {
+ id = Id_enum;
+
+ break L0;
+ }
+ }
+
+ break L;
+
+ case 'g' :
+ X = "goto";
+ id = Id_goto;
+
+ break L;
+
+ case 'l' :
+ X = "long";
+ id = Id_long;
+
+ break L;
+
+ case 'n' :
+ X = "null";
+ id = Id_null;
+
+ break L;
+
+ case 't' :
+ c = s.charAt(3);
+
+ if (c == 'e') {
+ if (s.charAt(2) == 'u' && s.charAt(1) == 'r') {
+ id = Id_true;
+
+ break L0;
+ }
+ } else if (c == 's') {
+ if (s.charAt(2) == 'i' && s.charAt(1) == 'h') {
+ id = Id_this;
+
+ break L0;
+ }
+ }
+
+ break L;
+
+ case 'v' :
+ X = "void";
+ id = Id_void;
+
+ break L;
+
+ case 'w' :
+ X = "with";
+ id = Id_with;
+
+ break L;
+ }
+
break L;
- case 'v': X="void";id=Id_void; break L;
- case 'w': X="with";id=Id_with; break L;
- } break L;
- case 5: switch (s.charAt(2)) {
- case 'a': X="class";id=Id_class; break L;
- case 'e': X="break";id=Id_break; break L;
- case 'i': X="while";id=Id_while; break L;
- case 'l': X="false";id=Id_false; break L;
- case 'n': c=s.charAt(0);
- if (c=='c') { X="const";id=Id_const; }
- else if (c=='f') { X="final";id=Id_final; }
+
+ case 5 :
+ switch (s.charAt(2)) {
+ case 'a' :
+ X = "class";
+ id = Id_class;
+
+ break L;
+
+ case 'e' :
+ X = "break";
+ id = Id_break;
+
+ break L;
+
+ case 'i' :
+ X = "while";
+ id = Id_while;
+
+ break L;
+
+ case 'l' :
+ X = "false";
+ id = Id_false;
+
+ break L;
+
+ case 'n' :
+ c = s.charAt(0);
+
+ if (c == 'c') {
+ X = "const";
+ id = Id_const;
+ } else if (c == 'f') {
+ X = "final";
+ id = Id_final;
+ }
+
+ break L;
+
+ case 'o' :
+ c = s.charAt(0);
+
+ if (c == 'f') {
+ X = "float";
+ id = Id_float;
+ } else if (c == 's') {
+ X = "short";
+ id = Id_short;
+ }
+
+ break L;
+
+ case 'p' :
+ X = "super";
+ id = Id_super;
+
+ break L;
+
+ case 'r' :
+ X = "throw";
+ id = Id_throw;
+
+ break L;
+
+ case 't' :
+ X = "catch";
+ id = Id_catch;
+
+ break L;
+ }
+
break L;
- case 'o': c=s.charAt(0);
- if (c=='f') { X="float";id=Id_float; }
- else if (c=='s') { X="short";id=Id_short; }
+
+ case 6 :
+ switch (s.charAt(1)) {
+ case 'a' :
+ X = "native";
+ id = Id_native;
+
+ break L;
+
+ case 'e' :
+ c = s.charAt(0);
+
+ if (c == 'd') {
+ X = "delete";
+ id = Id_delete;
+ } else if (c == 'r') {
+ X = "return";
+ id = Id_return;
+ }
+
+ break L;
+
+ case 'h' :
+ X = "throws";
+ id = Id_throws;
+
+ break L;
+
+ case 'm' :
+ X = "import";
+ id = Id_import;
+
+ break L;
+
+ case 'o' :
+ X = "double";
+ id = Id_double;
+
+ break L;
+
+ case 't' :
+ X = "static";
+ id = Id_static;
+
+ break L;
+
+ case 'u' :
+ X = "public";
+ id = Id_public;
+
+ break L;
+
+ case 'w' :
+ X = "switch";
+ id = Id_switch;
+
+ break L;
+
+ case 'x' :
+ X = "export";
+ id = Id_export;
+
+ break L;
+
+ case 'y' :
+ X = "typeof";
+ id = Id_typeof;
+
+ break L;
+ }
+
break L;
- case 'p': X="super";id=Id_super; break L;
- case 'r': X="throw";id=Id_throw; break L;
- case 't': X="catch";id=Id_catch; break L;
- } break L;
- case 6: switch (s.charAt(1)) {
- case 'a': X="native";id=Id_native; break L;
- case 'e': c=s.charAt(0);
- if (c=='d') { X="delete";id=Id_delete; }
- else if (c=='r') { X="return";id=Id_return; }
+
+ case 7 :
+ switch (s.charAt(1)) {
+ case 'a' :
+ X = "package";
+ id = Id_package;
+
+ break L;
+
+ case 'e' :
+ X = "default";
+ id = Id_default;
+
+ break L;
+
+ case 'i' :
+ X = "finally";
+ id = Id_finally;
+
+ break L;
+
+ case 'o' :
+ X = "boolean";
+ id = Id_boolean;
+
+ break L;
+
+ case 'r' :
+ X = "private";
+ id = Id_private;
+
+ break L;
+
+ case 'x' :
+ X = "extends";
+ id = Id_extends;
+
+ break L;
+ }
+
break L;
- case 'h': X="throws";id=Id_throws; break L;
- case 'm': X="import";id=Id_import; break L;
- case 'o': X="double";id=Id_double; break L;
- case 't': X="static";id=Id_static; break L;
- case 'u': X="public";id=Id_public; break L;
- case 'w': X="switch";id=Id_switch; break L;
- case 'x': X="export";id=Id_export; break L;
- case 'y': X="typeof";id=Id_typeof; break L;
- } break L;
- case 7: switch (s.charAt(1)) {
- case 'a': X="package";id=Id_package; break L;
- case 'e': X="default";id=Id_default; break L;
- case 'i': X="finally";id=Id_finally; break L;
- case 'o': X="boolean";id=Id_boolean; break L;
- case 'r': X="private";id=Id_private; break L;
- case 'x': X="extends";id=Id_extends; break L;
- } break L;
- case 8: switch (s.charAt(0)) {
- case 'a': X="abstract";id=Id_abstract; break L;
- case 'c': X="continue";id=Id_continue; break L;
- case 'd': X="debugger";id=Id_debugger; break L;
- case 'f': X="function";id=Id_function; break L;
- case 'v': X="volatile";id=Id_volatile; break L;
- } break L;
- case 9: c=s.charAt(0);
- if (c=='i') { X="interface";id=Id_interface; }
- else if (c=='p') { X="protected";id=Id_protected; }
- else if (c=='t') { X="transient";id=Id_transient; }
- break L;
- case 10: c=s.charAt(1);
- if (c=='m') { X="implements";id=Id_implements; }
- else if (c=='n') { X="instanceof";id=Id_instanceof; }
- break L;
- case 12: X="synchronized";id=Id_synchronized; break L;
+
+ case 8 :
+ switch (s.charAt(0)) {
+ case 'a' :
+ X = "abstract";
+ id = Id_abstract;
+
+ break L;
+
+ case 'c' :
+ X = "continue";
+ id = Id_continue;
+
+ break L;
+
+ case 'd' :
+ X = "debugger";
+ id = Id_debugger;
+
+ break L;
+
+ case 'f' :
+ X = "function";
+ id = Id_function;
+
+ break L;
+
+ case 'v' :
+ X = "volatile";
+ id = Id_volatile;
+
+ break L;
+ }
+
+ break L;
+
+ case 9 :
+ c = s.charAt(0);
+
+ if (c == 'i') {
+ X = "interface";
+ id = Id_interface;
+ } else if (c == 'p') {
+ X = "protected";
+ id = Id_protected;
+ } else if (c == 't') {
+ X = "transient";
+ id = Id_transient;
+ }
+
+ break L;
+
+ case 10 :
+ c = s.charAt(1);
+
+ if (c == 'm') {
+ X = "implements";
+ id = Id_implements;
+ } else if (c == 'n') {
+ X = "instanceof";
+ id = Id_instanceof;
+ }
+
+ break L;
+
+ case 12 :
+ X = "synchronized";
+ id = Id_synchronized;
+
+ break L;
}
- if (X!=null && X!=s && !X.equals(s)) id = 0;
+
+ if (X != null && X != s && !X.equals(s)) {
+ id = 0;
+ }
}
-// #/generated#
-// #/string_id_map#
- if (id == 0) { return Token.EOF; }
+
+// #/generated#
+// #/string_id_map#
+ if (id == 0) {
+ return Token.EOF;
+ }
+
return id & 0xff;
}
- final int getLineno() { return lineno; }
+ final int getLineno() {
+ return lineno;
+ }
- final String getString() { return string; }
+ final String getString() {
+ return string;
+ }
- final double getNumber() { return number; }
+ final double getNumber() {
+ return number;
+ }
- final boolean eof() { return hitEOF; }
+ final boolean eof() {
+ return hitEOF;
+ }
- final int getToken() throws IOException
- {
+ final int getToken() throws IOException {
int c;
- retry:
- for (;;) {
+ retry:for (;;) {
+
// Eat whitespace, possibly sensitive to newlines.
for (;;) {
c = getChar();
+
if (c == EOF_CHAR) {
return Token.EOF;
} else if (c == '\n') {
dirtyLine = false;
+
return Token.EOL;
} else if (!isJSSpace(c)) {
if (c != '-') {
dirtyLine = true;
}
+
break;
}
}
- if (c == '@') return Token.XMLATTR;
+ if (c == '@') {
+ return Token.XMLATTR;
+ }
// identifier/keyword/instanceof?
// watch out for starting with a <backslash>
boolean identifierStart;
boolean isUnicodeEscapeStart = false;
+
if (c == '\\') {
c = getChar();
+
if (c == 'u') {
identifierStart = true;
isUnicodeEscapeStart = true;
@@ -333,7 +696,8 @@
c = '\\';
}
} else {
- identifierStart = Character.isJavaIdentifierStart((char)c);
+ identifierStart = Character.isJavaIdentifierStart((char) c);
+
if (identifierStart) {
stringBufferTop = 0;
addToString(c);
@@ -342,8 +706,10 @@
if (identifierStart) {
boolean containsEscape = isUnicodeEscapeStart;
+
for (;;) {
if (isUnicodeEscapeStart) {
+
// strictly speaking we should probably push-back
// all the bad characters if the <backslash>uXXXX
// sequence is malformed. But since there isn't a
@@ -351,56 +717,67 @@
// escape sequence in an identifier, we can report
// an error here.
int escapeVal = 0;
+
for (int i = 0; i != 4; ++i) {
c = getChar();
escapeVal = Kit.xDigitToInt(c, escapeVal);
+
// Next check takes care about c < 0 and bad escape
- if (escapeVal < 0) { break; }
+ if (escapeVal < 0) {
+ break;
+ }
}
+
if (escapeVal < 0) {
parser.addError("msg.invalid.escape");
+
return Token.ERROR;
}
+
addToString(escapeVal);
isUnicodeEscapeStart = false;
} else {
c = getChar();
+
if (c == '\\') {
c = getChar();
+
if (c == 'u') {
isUnicodeEscapeStart = true;
containsEscape = true;
} else {
parser.addError("msg.illegal.character");
+
return Token.ERROR;
}
} else {
- if (c == EOF_CHAR
- || !Character.isJavaIdentifierPart((char)c))
- {
+ if (c == EOF_CHAR || !Character.isJavaIdentifierPart((char) c)) {
break;
}
+
addToString(c);
}
}
}
+
ungetChar(c);
String str = getStringFromBuffer();
+
if (!containsEscape) {
+
// OPT we shouldn't have to make a string (object!) to
// check if it's a keyword.
-
// Return the corresponding token if it's a keyword
int result = stringToKeyword(str);
+
if (result != Token.EOF) {
if (result != Token.RESERVED) {
return result;
- } else if (!parser.compilerEnv.
- isReservedKeywordAsIdentifier())
- {
+ } else if (!parser.compilerEnv.isReservedKeywordAsIdentifier()) {
return result;
} else {
+
// If implementation permits to use future reserved
// keywords in violation with the EcmaScript,
// treat it as name but issue warning
@@ -408,18 +785,21 @@
}
}
}
- this.string = (String)allStrings.intern(str);
+
+ this.string = (String) allStrings.intern(str);
+
return Token.NAME;
}
// is it a number?
if (isDigit(c) || (c == '.' && isDigit(peekChar()))) {
+ stringBufferTop = 0;
- stringBufferTop = 0;
int base = 10;
if (c == '0') {
c = getChar();
+
if (c == 'x' || c == 'X') {
base = 16;
c = getChar();
@@ -437,6 +817,7 @@
}
} else {
while ('0' <= c && c <= '9') {
+
/*
* We permit 08 and 09 as decimal numbers, which
* makes our behavior a superset of the ECMA
@@ -444,10 +825,10 @@
* permissive, so we warn about it.
*/
if (base == 8 && c >= '8') {
- parser.addWarning("msg.bad.octal.literal",
- c == '8' ? "8" : "9");
+ parser.addWarning("msg.bad.octal.literal", c == '8' ? "8" : "9");
base = 10;
}
+
addToString(c);
c = getChar();
}
@@ -457,40 +838,49 @@
if (base == 10 && (c == '.' || c == 'e' || c == 'E')) {
isInteger = false;
+
if (c == '.') {
do {
addToString(c);
c = getChar();
} while (isDigit(c));
}
+
if (c == 'e' || c == 'E') {
addToString(c);
c = getChar();
+
if (c == '+' || c == '-') {
addToString(c);
c = getChar();
}
+
if (!isDigit(c)) {
parser.addError("msg.missing.exponent");
+
return Token.ERROR;
}
+
do {
addToString(c);
c = getChar();
} while (isDigit(c));
}
}
+
ungetChar(c);
+
String numString = getStringFromBuffer();
+ double dval;
- double dval;
if (base == 10 && !isInteger) {
try {
+
// Use Java conversion to number from string...
dval = Double.valueOf(numString).doubleValue();
- }
- catch (NumberFormatException ex) {
+ } catch (NumberFormatException ex) {
parser.addError("msg.caught.nfe");
+
return Token.ERROR;
}
} else {
@@ -498,54 +888,59 @@
}
this.number = dval;
+
return Token.NUMBER;
}
// is it a string?
if (c == '"' || c == '\'') {
+
// We attempt to accumulate a string the fast way, by
// building it directly out of the reader. But if there
// are any escaped characters in the string, we revert to
// building it out of a StringBuffer.
+ int quoteChar = c;
- int quoteChar = c;
stringBufferTop = 0;
+ c = getChar();
- c = getChar();
while (c != quoteChar) {
if (c == '\n' || c == EOF_CHAR) {
ungetChar(c);
parser.addError("msg.unterminated.string.lit");
+
return Token.ERROR;
}
if (c == '\\') {
+
// We've hit an escaped character
-
c = getChar();
switch (c) {
+ case '\\' : // backslash
+ case 'b' : // backspace
+ case 'f' : // form feed
+ case 'n' : // line feed
+ case 'r' : // carriage return
+ case 't' : // horizontal tab
+ case 'v' : // vertical tab
+ case 'd' : // octal sequence
+ case 'u' : // unicode sequence
+ case 'x' : // hexadecimal sequence
- case '\\': // backslash
- case 'b': // backspace
- case 'f': // form feed
- case 'n': // line feed
- case 'r': // carriage return
- case 't': // horizontal tab
- case 'v': // vertical tab
- case 'd': // octal sequence
- case 'u': // unicode sequence
- case 'x': // hexadecimal sequence
-
// Only keep the '\' character for those
// characters that need to be escaped...
// Don't escape quoting characters...
addToString('\\');
+
break;
- case '\n':
+ case '\n' :
+
// Remove line terminator after escape
c = getChar();
+
break;
}
}
@@ -555,228 +950,257 @@
}
String str = getStringFromBuffer();
- this.string = (String)allStrings.intern(str);
+
+ this.string = (String) allStrings.intern(str);
+
return Token.STRING;
}
switch (c) {
- case ';': return Token.SEMI;
- case '[': return Token.LB;
- case ']': return Token.RB;
- case '{': return Token.LC;
- case '}': return Token.RC;
- case '(': return Token.LP;
- case ')': return Token.RP;
- case ',': return Token.COMMA;
- case '?': return Token.HOOK;
- case ':':
- if (matchChar(':')) {
- return Token.COLONCOLON;
- } else {
- return Token.COLON;
- }
- case '.':
- if (matchChar('.')) {
- return Token.DOTDOT;
- } else if (matchChar('(')) {
- return Token.DOTQUERY;
- } else {
- return Token.DOT;
- }
+ case ';' :
+ return Token.SEMI;
- case '|':
- if (matchChar('|')) {
- return Token.OR;
- } else if (matchChar('=')) {
- return Token.ASSIGN_BITOR;
- } else {
- return Token.BITOR;
- }
+ case '[' :
+ return Token.LB;
- case '^':
- if (matchChar('=')) {
- return Token.ASSIGN_BITXOR;
- } else {
- return Token.BITXOR;
- }
+ case ']' :
+ return Token.RB;
- case '&':
- if (matchChar('&')) {
- return Token.AND;
- } else if (matchChar('=')) {
- return Token.ASSIGN_BITAND;
- } else {
- return Token.BITAND;
- }
+ case '{' :
+ return Token.LC;
- case '=':
- if (matchChar('=')) {
- if (matchChar('='))
- return Token.SHEQ;
- else
- return Token.EQ;
- } else {
- return Token.ASSIGN;
- }
+ case '}' :
+ return Token.RC;
- case '!':
- if (matchChar('=')) {
- if (matchChar('='))
- return Token.SHNE;
- else
- return Token.NE;
- } else {
- return Token.NOT;
- }
+ case '(' :
+ return Token.LP;
- case '<':
- /* NB:treat HTML begin-comment as comment-till-eol */
- if (matchChar('!')) {
- if (matchChar('-')) {
- if (matchChar('-')) {
- skipLine();
- continue retry;
- }
- ungetChar('-');
+ case ')' :
+ return Token.RP;
+
+ case ',' :
+ return Token.COMMA;
+
+ case '?' :
+ return Token.HOOK;
+
+ case ':' :
+ if (matchChar(':')) {
+ return Token.COLONCOLON;
+ } else {
+ return Token.COLON;
}
- ungetChar('!');
- }
- if (matchChar('<')) {
+ case '.' :
+ if (matchChar('.')) {
+ return Token.DOTDOT;
+ } else if (matchChar('(')) {
+ return Token.DOTQUERY;
+ } else {
+ return Token.DOT;
+ }
+ case '|' :
+ if (matchChar('|')) {
+ return Token.OR;
+ } else if (matchChar('=')) {
+ return Token.ASSIGN_BITOR;
+ } else {
+ return Token.BITOR;
+ }
+ case '^' :
if (matchChar('=')) {
- return Token.ASSIGN_LSH;
+ return Token.ASSIGN_BITXOR;
} else {
- return Token.LSH;
+ return Token.BITXOR;
}
- } else {
+ case '&' :
+ if (matchChar('&')) {
+ return Token.AND;
+ } else if (matchChar('=')) {
+ return Token.ASSIGN_BITAND;
+ } else {
+ return Token.BITAND;
+ }
+ case '=' :
if (matchChar('=')) {
- return Token.LE;
+ if (matchChar('=')) {
+ return Token.SHEQ;
+ } else {
+ return Token.EQ;
+ }
} else {
- return Token.LT;
+ return Token.ASSIGN;
}
- }
+ case '!' :
+ if (matchChar('=')) {
+ if (matchChar('=')) {
+ return Token.SHNE;
+ } else {
+ return Token.NE;
+ }
+ } else {
+ return Token.NOT;
+ }
+ case '<' :
- case '>':
- if (matchChar('>')) {
- if (matchChar('>')) {
+ /* NB:treat HTML begin-comment as comment-till-eol */
+ if (matchChar('!')) {
+ if (matchChar('-')) {
+ if (matchChar('-')) {
+ skipLine();
+
+ continue retry;
+ }
+
+ ungetChar('-');
+ }
+
+ ungetChar('!');
+ }
+
+ if (matchChar('<')) {
if (matchChar('=')) {
- return Token.ASSIGN_URSH;
+ return Token.ASSIGN_LSH;
} else {
- return Token.URSH;
+ return Token.LSH;
}
} else {
if (matchChar('=')) {
- return Token.ASSIGN_RSH;
+ return Token.LE;
} else {
- return Token.RSH;
+ return Token.LT;
}
}
- } else {
+ case '>' :
+ if (matchChar('>')) {
+ if (matchChar('>')) {
+ if (matchChar('=')) {
+ return Token.ASSIGN_URSH;
+ } else {
+ return Token.URSH;
+ }
+ } else {
+ if (matchChar('=')) {
+ return Token.ASSIGN_RSH;
+ } else {
+ return Token.RSH;
+ }
+ }
+ } else {
+ if (matchChar('=')) {
+ return Token.GE;
+ } else {
+ return Token.GT;
+ }
+ }
+ case '*' :
if (matchChar('=')) {
- return Token.GE;
+ return Token.ASSIGN_MUL;
} else {
- return Token.GT;
+ return Token.MUL;
}
- }
+ case '/' :
- case '*':
- if (matchChar('=')) {
- return Token.ASSIGN_MUL;
- } else {
- return Token.MUL;
- }
+ // is it a // comment?
+ if (matchChar('/')) {
+ skipLine();
- case '/':
- // is it a // comment?
- if (matchChar('/')) {
- skipLine();
- continue retry;
- }
- if (matchChar('*')) {
- boolean lookForSlash = false;
- StringBuffer sb = new StringBuffer();
- for (;;) {
- c = getChar();
- if (c == EOF_CHAR) {
- parser.addError("msg.unterminated.comment");
- return Token.ERROR;
- }
- sb.append((char) c);
- if (c == '*') {
- lookForSlash = true;
- } else if (c == '/') {
- if (lookForSlash) {
- sb.delete(sb.length()-2, sb.length());
- String s = sb.toString();
- if (s.startsWith("@cc_on") ||
- s.startsWith("@if") ||
- s.startsWith("@elif") ||
- s.startsWith("@else") ||
- s.startsWith("@end")) {
- this.string = s;
- return Token.IECC;
- } else {
- continue retry;
+ continue retry;
+ }
+
+ if (matchChar('*')) {
+ boolean lookForSlash = false;
+ StringBuffer sb = new StringBuffer();
+
+ for (;;) {
+ c = getChar();
+
+ if (c == EOF_CHAR) {
+ parser.addError("msg.unterminated.comment");
+
+ return Token.ERROR;
+ }
+
+ sb.append((char) c);
+
+ if (c == '*') {
+ lookForSlash = true;
+ } else if (c == '/') {
+ if (lookForSlash) {
+ sb.delete(sb.length() - 2, sb.length());
+
+ String s = sb.toString();
+
+ if (s.startsWith("@cc_on") || s.startsWith("@if") || s.startsWith("@elif")
+ || s.startsWith("@else") || s.startsWith("@end")) {
+ this.string = s;
+
+ return Token.IECC;
+ } else {
+ continue retry;
+ }
}
+ } else {
+ lookForSlash = false;
}
- } else {
- lookForSlash = false;
}
}
- }
- if (matchChar('=')) {
- return Token.ASSIGN_DIV;
- } else {
- return Token.DIV;
- }
+ if (matchChar('=')) {
+ return Token.ASSIGN_DIV;
+ } else {
+ return Token.DIV;
+ }
+ case '%' :
+ if (matchChar('=')) {
+ return Token.ASSIGN_MOD;
+ } else {
+ return Token.MOD;
+ }
+ case '~' :
+ return Token.BITNOT;
- case '%':
- if (matchChar('=')) {
- return Token.ASSIGN_MOD;
- } else {
- return Token.MOD;
- }
+ case '+' :
+ if (matchChar('=')) {
+ return Token.ASSIGN_ADD;
+ } else if (matchChar('+')) {
+ return Token.INC;
+ } else {
+ return Token.ADD;
+ }
+ case '-' :
+ if (matchChar('=')) {
+ c = Token.ASSIGN_SUB;
+ } else if (matchChar('-')) {
+ if (!dirtyLine) {
- case '~':
- return Token.BITNOT;
+ // treat HTML end-comment after possible whitespace
+ // after line start as comment-utill-eol
+ if (matchChar('>')) {
+ skipLine();
- case '+':
- if (matchChar('=')) {
- return Token.ASSIGN_ADD;
- } else if (matchChar('+')) {
- return Token.INC;
- } else {
- return Token.ADD;
- }
+ continue retry;
+ }
+ }
- case '-':
- if (matchChar('=')) {
- c = Token.ASSIGN_SUB;
- } else if (matchChar('-')) {
- if (!dirtyLine) {
- // treat HTML end-comment after possible whitespace
- // after line start as comment-utill-eol
- if (matchChar('>')) {
- skipLine();
- continue retry;
- }
+ c = Token.DEC;
+ } else {
+ c = Token.SUB;
}
- c = Token.DEC;
- } else {
- c = Token.SUB;
- }
- dirtyLine = true;
- return c;
- default:
- parser.addError("msg.illegal.character");
- return Token.ERROR;
+ dirtyLine = true;
+
+ return c;
+
+ default :
+ parser.addError("msg.illegal.character");
+
+ return Token.ERROR;
}
}
}
- private static boolean isAlpha(int c)
- {
+ private static boolean isAlpha(int c) {
+
// Use 'Z' < 'a'
if (c <= 'Z') {
return 'A' <= c;
@@ -785,50 +1209,52 @@
}
}
- static boolean isDigit(int c)
- {
+ static boolean isDigit(int c) {
return '0' <= c && c <= '9';
}
- /* As defined in ECMA. jsscan.c uses C isspace() (which allows
+ /*
+ * As defined in ECMA. jsscan.c uses C isspace() (which allows
* \v, I think.) note that code in getChar() implicitly accepts
* '\r' == \u000D as well.
*/
- static boolean isJSSpace(int c)
- {
+ static boolean isJSSpace(int c) {
if (c <= 127) {
return c == 0x20 || c == 0x9 || c == 0xC || c == 0xB;
} else {
- return c == 0xA0
- || Character.getType((char)c) == Character.SPACE_SEPARATOR;
+ return c == 0xA0 || Character.getType((char) c) == Character.SPACE_SEPARATOR;
}
}
- private static boolean isJSFormatChar(int c)
- {
- return c > 127 && Character.getType((char)c) == Character.FORMAT;
+ private static boolean isJSFormatChar(int c) {
+ return c > 127 && Character.getType((char) c) == Character.FORMAT;
}
/**
* Parser calls the method when it gets / or /= in literal context.
*/
- void readRegExp(int startToken)
- throws IOException
- {
+ void readRegExp(int startToken) throws IOException {
stringBufferTop = 0;
+
if (startToken == Token.ASSIGN_DIV) {
+
// Miss-scanned /=
addToString('=');
} else {
- if (startToken != Token.DIV) Kit.codeBug();
+ if (startToken != Token.DIV) {
+ Kit.codeBug();
+ }
}
int c;
+
while ((c = getChar()) != '/') {
if (c == '\n' || c == EOF_CHAR) {
ungetChar(c);
+
throw parser.reportError("msg.unterminated.re.lit");
}
+
if (c == '\\') {
addToString(c);
c = getChar();
@@ -836,17 +1262,19 @@
addToString(c);
}
+
int reEnd = stringBufferTop;
while (true) {
- if (matchChar('g'))
+ if (matchChar('g')) {
addToString('g');
- else if (matchChar('i'))
+ } else if (matchChar('i')) {
addToString('i');
- else if (matchChar('m'))
+ } else if (matchChar('m')) {
addToString('m');
- else
+ } else {
break;
+ }
}
if (isAlpha(peekChar())) {
@@ -854,164 +1282,215 @@
}
this.string = new String(stringBuffer, 0, reEnd);
- this.regExpFlags = new String(stringBuffer, reEnd,
- stringBufferTop - reEnd);
+ this.regExpFlags = new String(stringBuffer, reEnd, stringBufferTop - reEnd);
}
- boolean isXMLAttribute()
- {
+ boolean isXMLAttribute() {
return xmlIsAttribute;
}
- int getFirstXMLToken() throws IOException
- {
+ int getFirstXMLToken() throws IOException {
xmlOpenTagsCount = 0;
xmlIsAttribute = false;
xmlIsTagContent = false;
ungetChar('<');
+
return getNextXMLToken();
}
- int getNextXMLToken() throws IOException
- {
+ int getNextXMLToken() throws IOException {
stringBufferTop = 0; // remember the XML
for (int c = getChar(); c != EOF_CHAR; c = getChar()) {
if (xmlIsTagContent) {
switch (c) {
- case '>':
- addToString(c);
- xmlIsTagContent = false;
- xmlIsAttribute = false;
- break;
- case '/':
- addToString(c);
- if (peekChar() == '>') {
- c = getChar();
+ case '>' :
addToString(c);
xmlIsTagContent = false;
- xmlOpenTagsCount--;
- }
- break;
- case '{':
- ungetChar(c);
- this.string = getStringFromBuffer();
- return Token.XML;
- case '\'':
- case '"':
- addToString(c);
- if (!readQuotedString(c)) return Token.ERROR;
- break;
- case '=':
- addToString(c);
- xmlIsAttribute = true;
- break;
- case ' ':
- case '\t':
- case '\r':
- case '\n':
- addToString(c);
- break;
- default:
- addToString(c);
- xmlIsAttribute = false;
- break;
+ xmlIsAttribute = false;
+
+ break;
+
+ case '/' :
+ addToString(c);
+
+ if (peekChar() == '>') {
+ c = getChar();
+ addToString(c);
+ xmlIsTagContent = false;
+ xmlOpenTagsCount--;
+ }
+
+ break;
+
+ case '{' :
+ ungetChar(c);
+ this.string = getStringFromBuffer();
+
+ return Token.XML;
+
+ case '\'' :
+ case '"' :
+ addToString(c);
+
+ if (!readQuotedString(c)) {
+ return Token.ERROR;
+ }
+
+ break;
+
+ case '=' :
+ addToString(c);
+ xmlIsAttribute = true;
+
+ break;
+
+ case ' ' :
+ case '\t' :
+ case '\r' :
+ case '\n' :
+ addToString(c);
+
+ break;
+
+ default :
+ addToString(c);
+ xmlIsAttribute = false;
+
+ break;
}
if (!xmlIsTagContent && xmlOpenTagsCount == 0) {
this.string = getStringFromBuffer();
+
return Token.XMLEND;
}
} else {
switch (c) {
- case '<':
- addToString(c);
- c = peekChar();
- switch (c) {
- case '!':
- c = getChar(); // Skip !
+ case '<' :
addToString(c);
c = peekChar();
+
switch (c) {
- case '-':
- c = getChar(); // Skip -
- addToString(c);
- c = getChar();
- if (c == '-') {
+ case '!' :
+ c = getChar(); // Skip !
addToString(c);
- if(!readXmlComment()) return Token.ERROR;
- } else {
- // throw away the string in progress
- stringBufferTop = 0;
- this.string = null;
- parser.addError("msg.XML.bad.form");
- return Token.ERROR;
- }
- break;
- case '[':
- c = getChar(); // Skip [
- addToString(c);
- if (getChar() == 'C' &&
- getChar() == 'D' &&
- getChar() == 'A' &&
- getChar() == 'T' &&
- getChar() == 'A' &&
- getChar() == '[')
- {
- addToString('C');
- addToString('D');
- addToString('A');
- addToString('T');
- addToString('A');
- addToString('[');
- if (!readCDATA()) return Token.ERROR;
+ c = peekChar();
- } else {
- // throw away the string in progress
- stringBufferTop = 0;
- this.string = null;
- parser.addError("msg.XML.bad.form");
- return Token.ERROR;
- }
- break;
- default:
- if(!readEntity()) return Token.ERROR;
- break;
+ switch (c) {
+ case '-' :
+ c = getChar(); // Skip -
+ addToString(c);
+ c = getChar();
+
+ if (c == '-') {
+ addToString(c);
+
+ if (!readXmlComment()) {
+ return Token.ERROR;
+ }
+ } else {
+
+ // throw away the string in progress
+ stringBufferTop = 0;
+ this.string = null;
+ parser.addError("msg.XML.bad.form");
+
+ return Token.ERROR;
+ }
+
+ break;
+
+ case '[' :
+ c = getChar(); // Skip [
+ addToString(c);
+
+ if (getChar() == 'C' && getChar() == 'D' && getChar() == 'A'
+ && getChar() == 'T' && getChar() == 'A' && getChar() == '[') {
+ addToString('C');
+ addToString('D');
+ addToString('A');
+ addToString('T');
+ addToString('A');
+ addToString('[');
+
+ if (!readCDATA()) {
+ return Token.ERROR;
+ }
+ } else {
+
+ // throw away the string in progress
+ stringBufferTop = 0;
+ this.string = null;
+ parser.addError("msg.XML.bad.form");
+
+ return Token.ERROR;
+ }
+
+ break;
+
+ default :
+ if (!readEntity()) {
+ return Token.ERROR;
+ }
+
+ break;
+ }
+
+ break;
+
+ case '?' :
+ c = getChar(); // Skip ?
+ addToString(c);
+
+ if (!readPI()) {
+ return Token.ERROR;
+ }
+
+ break;
+
+ case '/' :
+
+ // End tag
+ c = getChar(); // Skip /
+ addToString(c);
+
+ if (xmlOpenTagsCount == 0) {
+
+ // throw away the string in progress
+ stringBufferTop = 0;
+ this.string = null;
+ parser.addError("msg.XML.bad.form");
+
+ return Token.ERROR;
+ }
+
+ xmlIsTagContent = true;
+ xmlOpenTagsCount--;
+
+ break;
+
+ default :
+
+ // Start tag
+ xmlIsTagContent = true;
+ xmlOpenTagsCount++;
+
+ break;
}
+
break;
- case '?':
- c = getChar(); // Skip ?
+
+ case '{' :
+ ungetChar(c);
+ this.string = getStringFromBuffer();
+
+ return Token.XML;
+
+ default :
addToString(c);
- if (!readPI()) return Token.ERROR;
+
break;
- case '/':
- // End tag
- c = getChar(); // Skip /
- addToString(c);
- if (xmlOpenTagsCount == 0) {
- // throw away the string in progress
- stringBufferTop = 0;
- this.string = null;
- parser.addError("msg.XML.bad.form");
- return Token.ERROR;
- }
- xmlIsTagContent = true;
- xmlOpenTagsCount--;
- break;
- default:
- // Start tag
- xmlIsTagContent = true;
- xmlOpenTagsCount++;
- break;
- }
- break;
- case '{':
- ungetChar(c);
- this.string = getStringFromBuffer();
- return Token.XML;
- default:
- addToString(c);
- break;
}
}
}
@@ -1019,114 +1498,135 @@
stringBufferTop = 0; // throw away the string in progress
this.string = null;
parser.addError("msg.XML.bad.form");
+
return Token.ERROR;
}
/**
*
*/
- private boolean readQuotedString(int quote) throws IOException
- {
+ private boolean readQuotedString(int quote) throws IOException {
for (int c = getChar(); c != EOF_CHAR; c = getChar()) {
addToString(c);
- if (c == quote) return true;
+
+ if (c == quote) {
+ return true;
+ }
}
stringBufferTop = 0; // throw away the string in progress
this.string = null;
parser.addError("msg.XML.bad.form");
+
return false;
}
/**
*
*/
- private boolean readXmlComment() throws IOException
- {
- for (int c = getChar(); c != EOF_CHAR;) {
+ private boolean readXmlComment() throws IOException {
+ for (int c = getChar(); c != EOF_CHAR; ) {
addToString(c);
+
if (c == '-' && peekChar() == '-') {
c = getChar();
addToString(c);
+
if (peekChar() == '>') {
c = getChar(); // Skip >
addToString(c);
+
return true;
} else {
continue;
}
}
+
c = getChar();
}
stringBufferTop = 0; // throw away the string in progress
this.string = null;
parser.addError("msg.XML.bad.form");
+
return false;
}
/**
*
*/
- private boolean readCDATA() throws IOException
- {
- for (int c = getChar(); c != EOF_CHAR;) {
+ private boolean readCDATA() throws IOException {
+ for (int c = getChar(); c != EOF_CHAR; ) {
addToString(c);
+
if (c == ']' && peekChar() == ']') {
c = getChar();
addToString(c);
+
if (peekChar() == '>') {
c = getChar(); // Skip >
addToString(c);
+
return true;
} else {
continue;
}
}
+
c = getChar();
}
stringBufferTop = 0; // throw away the string in progress
this.string = null;
parser.addError("msg.XML.bad.form");
+
return false;
}
/**
*
*/
- private boolean readEntity() throws IOException
- {
+ private boolean readEntity() throws IOException {
int declTags = 1;
+
for (int c = getChar(); c != EOF_CHAR; c = getChar()) {
addToString(c);
+
switch (c) {
- case '<':
- declTags++;
- break;
- case '>':
- declTags--;
- if (declTags == 0) return true;
- break;
+ case '<' :
+ declTags++;
+
+ break;
+
+ case '>' :
+ declTags--;
+
+ if (declTags == 0) {
+ return true;
+ }
+
+ break;
}
}
stringBufferTop = 0; // throw away the string in progress
this.string = null;
parser.addError("msg.XML.bad.form");
+
return false;
}
/**
*
*/
- private boolean readPI() throws IOException
- {
+ private boolean readPI() throws IOException {
for (int c = getChar(); c != EOF_CHAR; c = getChar()) {
addToString(c);
+
if (c == '?' && peekChar() == '>') {
c = getChar(); // Skip >
addToString(c);
+
return true;
}
}
@@ -1134,81 +1634,93 @@
stringBufferTop = 0; // throw away the string in progress
this.string = null;
parser.addError("msg.XML.bad.form");
+
return false;
}
- private String getStringFromBuffer()
- {
+ private String getStringFromBuffer() {
return new String(stringBuffer, 0, stringBufferTop);
}
- private void addToString(int c)
- {
+ private void addToString(int c) {
int N = stringBufferTop;
+
if (N == stringBuffer.length) {
char[] tmp = new char[stringBuffer.length * 2];
+
System.arraycopy(stringBuffer, 0, tmp, 0, N);
stringBuffer = tmp;
}
- stringBuffer[N] = (char)c;
+
+ stringBuffer[N] = (char) c;
stringBufferTop = N + 1;
}
- private void ungetChar(int c)
- {
+ private void ungetChar(int c) {
+
// can not unread past across line boundary
- if (ungetCursor != 0 && ungetBuffer[ungetCursor - 1] == '\n')
+ if (ungetCursor != 0 && ungetBuffer[ungetCursor - 1] == '\n') {
Kit.codeBug();
+ }
+
ungetBuffer[ungetCursor++] = c;
}
- private boolean matchChar(int test) throws IOException
- {
+ private boolean matchChar(int test) throws IOException {
int c = getChar();
+
if (c == test) {
return true;
} else {
ungetChar(c);
+
return false;
}
}
- private int peekChar() throws IOException
- {
+ private int peekChar() throws IOException {
int c = getChar();
+
ungetChar(c);
+
return c;
}
- private int getChar() throws IOException
- {
+ private int getChar() throws IOException {
if (ungetCursor != 0) {
return ungetBuffer[--ungetCursor];
}
- for(;;) {
+ for (;;) {
int c;
+
if (sourceString != null) {
if (sourceCursor == sourceEnd) {
hitEOF = true;
+
return EOF_CHAR;
}
+
c = sourceString.charAt(sourceCursor++);
} else {
if (sourceCursor == sourceEnd) {
if (!fillSourceBuffer()) {
hitEOF = true;
+
return EOF_CHAR;
}
}
+
c = sourceBuffer[sourceCursor++];
}
if (lineEndChar >= 0) {
if (lineEndChar == '\r' && c == '\n') {
lineEndChar = '\n';
+
continue;
}
+
lineEndChar = -1;
lineStart = sourceCursor - 1;
lineno++;
@@ -1223,137 +1735,124 @@
if (isJSFormatChar(c)) {
continue;
}
+
if (ScriptRuntime.isJSLineTerminator(c)) {
lineEndChar = c;
c = '\n';
}
}
+
return c;
}
}
- private void skipLine() throws IOException
- {
+ private void skipLine() throws IOException {
+
// skip to end of line
int c;
- while ((c = getChar()) != EOF_CHAR && c != '\n') { }
+
+ while ((c = getChar()) != EOF_CHAR && c != '\n') {}
+
ungetChar(c);
}
- final int getOffset()
- {
+ final int getOffset() {
int n = sourceCursor - lineStart;
- if (lineEndChar >= 0) { --n; }
+
+ if (lineEndChar >= 0) {
+ --n;
+ }
+
return n;
}
- final String getLine()
- {
+ final String getLine() {
if (sourceString != null) {
+
// String case
int lineEnd = sourceCursor;
+
if (lineEndChar >= 0) {
--lineEnd;
} else {
for (; lineEnd != sourceEnd; ++lineEnd) {
int c = sourceString.charAt(lineEnd);
+
if (ScriptRuntime.isJSLineTerminator(c)) {
break;
}
}
}
+
return sourceString.substring(lineStart, lineEnd);
} else {
+
// Reader case
int lineLength = sourceCursor - lineStart;
+
if (lineEndChar >= 0) {
--lineLength;
} else {
+
// Read until the end of line
- for (;; ++lineLength) {
+ for (; ; ++lineLength) {
int i = lineStart + lineLength;
+
if (i == sourceEnd) {
try {
- if (!fillSourceBuffer()) { break; }
+ if (!fillSourceBuffer()) {
+ break;
+ }
} catch (IOException ioe) {
+
// ignore it, we're already displaying an error...
break;
}
+
// i recalculuation as fillSourceBuffer can move saved
// line buffer and change lineStart
i = lineStart + lineLength;
}
+
int c = sourceBuffer[i];
+
if (ScriptRuntime.isJSLineTerminator(c)) {
break;
}
}
}
+
return new String(sourceBuffer, lineStart, lineLength);
}
}
- private boolean fillSourceBuffer() throws IOException
- {
- if (sourceString != null) Kit.codeBug();
+ private boolean fillSourceBuffer() throws IOException {
+ if (sourceString != null) {
+ Kit.codeBug();
+ }
+
if (sourceEnd == sourceBuffer.length) {
if (lineStart != 0) {
- System.arraycopy(sourceBuffer, lineStart, sourceBuffer, 0,
- sourceEnd - lineStart);
+ System.arraycopy(sourceBuffer, lineStart, sourceBuffer, 0, sourceEnd - lineStart);
sourceEnd -= lineStart;
sourceCursor -= lineStart;
lineStart = 0;
} else {
char[] tmp = new char[sourceBuffer.length * 2];
+
System.arraycopy(sourceBuffer, 0, tmp, 0, sourceEnd);
sourceBuffer = tmp;
}
}
- int n = sourceReader.read(sourceBuffer, sourceEnd,
- sourceBuffer.length - sourceEnd);
+
+ int n = sourceReader.read(sourceBuffer, sourceEnd, sourceBuffer.length - sourceEnd);
+
if (n < 0) {
return false;
}
+
sourceEnd += n;
+
return true;
}
-
- // stuff other than whitespace since start of line
- private boolean dirtyLine;
-
- String regExpFlags;
-
- // Set this to an inital non-null value so that the Parser has
- // something to retrieve even if an error has occured and no
- // string is found. Fosters one class of error, but saves lots of
- // code.
- private String string = "";
- private double number;
-
- private char[] stringBuffer = new char[128];
- private int stringBufferTop;
- private ObjToIntMap allStrings = new ObjToIntMap(50);
-
- // Room to backtrace from to < on failed match of the last - in <!--
- private final int[] ungetBuffer = new int[3];
- private int ungetCursor;
-
- private boolean hitEOF = false;
-
- private int lineStart = 0;
- private int lineno;
- private int lineEndChar = -1;
-
- private String sourceString;
- private Reader sourceReader;
- private char[] sourceBuffer;
- private int sourceEnd;
- private int sourceCursor;
-
- // for xml tokenizer
- private boolean xmlIsAttribute;
- private boolean xmlIsTagContent;
- private int xmlOpenTagsCount;
-
- private Parser parser;
}
Modified: root/cdk/trunk/plugins/maven-javascript-plugin/src/test/java/net/sf/alchim/mojo/yuicompressor/AggregationTestCase.java
===================================================================
--- root/cdk/trunk/plugins/maven-javascript-plugin/src/test/java/net/sf/alchim/mojo/yuicompressor/AggregationTestCase.java 2009-11-01 16:28:50 UTC (rev 15792)
+++ root/cdk/trunk/plugins/maven-javascript-plugin/src/test/java/net/sf/alchim/mojo/yuicompressor/AggregationTestCase.java 2009-11-01 16:30:05 UTC (rev 15793)
@@ -18,7 +18,9 @@
* 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 net.sf.alchim.mojo.yuicompressor;
import java.io.File;
@@ -44,31 +46,30 @@
public void test0to1() throws Exception {
Aggregation target = new Aggregation();
+
target.output = new File(dir_, "output.js");
-
assertFalse(target.output.exists());
target.run(dir_);
assertFalse(target.output.exists());
-
- target.includes = new String[]{};
+ target.includes = new String[] {};
assertFalse(target.output.exists());
target.run(dir_);
assertFalse(target.output.exists());
-
- target.includes = new String[]{"**/*.js"};
+ target.includes = new String[] {"**/*.js"};
assertFalse(target.output.exists());
target.run(dir_);
assertFalse(target.output.exists());
}
-
public void test1to1() throws Exception {
File f1 = new File(dir_, "01.js");
+
FileUtils.fileWrite(f1.getAbsolutePath(), "1");
+
Aggregation target = new Aggregation();
+
target.output = new File(dir_, "output.js");
- target.includes = new String[]{f1.getName()};
-
+ target.includes = new String[] {f1.getName()};
assertFalse(target.output.exists());
target.run(dir_);
assertTrue(target.output.exists());
@@ -77,46 +78,49 @@
public void test2to1() throws Exception {
File f1 = new File(dir_, "01.js");
+
FileUtils.fileWrite(f1.getAbsolutePath(), "1");
File f2 = new File(dir_, "02.js");
+
FileUtils.fileWrite(f2.getAbsolutePath(), "22\n22");
Aggregation target = new Aggregation();
+
target.output = new File(dir_, "output.js");
-
- target.includes = new String[]{f1.getName(), f2.getName()};
+ target.includes = new String[] {f1.getName(), f2.getName()};
assertFalse(target.output.exists());
target.run(dir_);
assertTrue(target.output.exists());
assertEquals(FileUtils.fileRead(f1) + FileUtils.fileRead(f2), FileUtils.fileRead(target.output));
-
target.output.delete();
- target.includes = new String[]{"*.js"};
+ target.includes = new String[] {"*.js"};
assertFalse(target.output.exists());
target.run(dir_);
assertTrue(target.output.exists());
-// assertEquals(FileUtils.fileRead(f1) + FileUtils.fileRead(f2), FileUtils.fileRead(target.output));
+
+// assertEquals(FileUtils.fileRead(f1) + FileUtils.fileRead(f2), FileUtils.fileRead(target.output));
}
public void testNoDuplicateAggregation() throws Exception {
File f1 = new File(dir_, "01.js");
+
FileUtils.fileWrite(f1.getAbsolutePath(), "1");
File f2 = new File(dir_, "02.js");
+
FileUtils.fileWrite(f2.getAbsolutePath(), "22\n22");
Aggregation target = new Aggregation();
+
target.output = new File(dir_, "output.js");
-
- target.includes = new String[]{f1.getName(), f1.getName(), f2.getName()};
+ target.includes = new String[] {f1.getName(), f1.getName(), f2.getName()};
assertFalse(target.output.exists());
target.run(dir_);
assertTrue(target.output.exists());
assertEquals(FileUtils.fileRead(f1) + FileUtils.fileRead(f2), FileUtils.fileRead(target.output));
-
target.output.delete();
- target.includes = new String[]{f1.getName(), "*.js"};
+ target.includes = new String[] {f1.getName(), "*.js"};
assertFalse(target.output.exists());
target.run(dir_);
assertTrue(target.output.exists());
@@ -125,15 +129,17 @@
public void test2to1Order() throws Exception {
File f1 = new File(dir_, "01.js");
+
FileUtils.fileWrite(f1.getAbsolutePath(), "1");
File f2 = new File(dir_, "02.js");
+
FileUtils.fileWrite(f2.getAbsolutePath(), "2");
Aggregation target = new Aggregation();
+
target.output = new File(dir_, "output.js");
-
- target.includes = new String[]{f2.getName(), f1.getName()};
+ target.includes = new String[] {f2.getName(), f1.getName()};
assertFalse(target.output.exists());
target.run(dir_);
assertTrue(target.output.exists());
@@ -142,16 +148,18 @@
public void test2to1WithNewLine() throws Exception {
File f1 = new File(dir_, "01.js");
+
FileUtils.fileWrite(f1.getAbsolutePath(), "1");
File f2 = new File(dir_, "02.js");
+
FileUtils.fileWrite(f2.getAbsolutePath(), "22\n22");
Aggregation target = new Aggregation();
+
target.output = new File(dir_, "output.js");
target.insertNewLine = true;
- target.includes = new String[]{f1.getName(), f2.getName()};
-
+ target.includes = new String[] {f1.getName(), f2.getName()};
assertFalse(target.output.exists());
target.run(dir_);
assertTrue(target.output.exists());
@@ -160,15 +168,17 @@
public void testAbsolutePathFromInside() throws Exception {
File f1 = new File(dir_, "01.js");
+
FileUtils.fileWrite(f1.getAbsolutePath(), "1");
File f2 = new File(dir_, "02.js");
+
FileUtils.fileWrite(f2.getAbsolutePath(), "22\n22");
Aggregation target = new Aggregation();
+
target.output = new File(dir_, "output.js");
-
- target.includes = new String[]{f1.getAbsolutePath(), f2.getName()};
+ target.includes = new String[] {f1.getAbsolutePath(), f2.getName()};
assertFalse(target.output.exists());
target.run(dir_);
assertTrue(target.output.exists());
@@ -177,16 +187,18 @@
public void testAbsolutePathFromOutside() throws Exception {
File f1 = File.createTempFile("test-01", ".js");
+
try {
FileUtils.fileWrite(f1.getAbsolutePath(), "1");
File f2 = new File(dir_, "02.js");
+
FileUtils.fileWrite(f2.getAbsolutePath(), "22\n22");
Aggregation target = new Aggregation();
+
target.output = new File(dir_, "output.js");
-
- target.includes = new String[]{f1.getAbsolutePath(), f2.getName()};
+ target.includes = new String[] {f1.getAbsolutePath(), f2.getName()};
assertFalse(target.output.exists());
target.run(dir_);
assertTrue(target.output.exists());
15 years, 1 month
JBoss Rich Faces SVN: r15792 - in root/cdk/trunk/plugins/maven-cdk-plugin/src: main/java/org/richfaces/builder/maven and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: Alex.Kolonitsky
Date: 2009-11-01 11:28:50 -0500 (Sun, 01 Nov 2009)
New Revision: 15792
Modified:
root/cdk/trunk/plugins/maven-cdk-plugin/src/it/annotated-component/src/main/java/org/richfaces/cdk/test/component/AbstractTestComponent.java
root/cdk/trunk/plugins/maven-cdk-plugin/src/it/annotated-component/src/main/java/org/richfaces/cdk/test/component/UITestCommand.java
root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/maven/MavenLogger.java
root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/AbstractCDKMojo.java
root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/AbstractGenerateMojo.java
root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/CompileMojo.java
root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/CompileTemplatesMojo.java
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/Library.java
root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/Renderkit.java
root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/SkinInfo.java
root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/Taglib.java
Log:
Code style policy
https://jira.jboss.org/jira/browse/RFPL-195
Modified: root/cdk/trunk/plugins/maven-cdk-plugin/src/it/annotated-component/src/main/java/org/richfaces/cdk/test/component/AbstractTestComponent.java
===================================================================
--- root/cdk/trunk/plugins/maven-cdk-plugin/src/it/annotated-component/src/main/java/org/richfaces/cdk/test/component/AbstractTestComponent.java 2009-11-01 16:27:54 UTC (rev 15791)
+++ root/cdk/trunk/plugins/maven-cdk-plugin/src/it/annotated-component/src/main/java/org/richfaces/cdk/test/component/AbstractTestComponent.java 2009-11-01 16:28:50 UTC (rev 15792)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.test.component;
import org.richfaces.cdk.annotations.Attribute;
@@ -29,6 +31,7 @@
import org.richfaces.cdk.annotations.Generate;
import java.util.List;
+
import javax.faces.component.UIComponentBase;
import javax.faces.component.ValueHolder;
@@ -40,20 +43,19 @@
@Component("org.richfaces.cdk.test.TestComponent")
@Generate("org.richfaces.cdk.test.UITestComponent")
@Family("org.richfaces.cdk.test.Test")
-public abstract class AbstractTestComponent extends UIComponentBase {
-
- @Attribute
- private int foo;
-
- /**
- * Test Attribute
- */
- @Attribute
- public abstract List<String> getTestValue();
+public abstract class AbstractTestComponent extends UIComponentBase {
+ @Attribute
+ private int foo;
- /**
- * Bar Attribute
- */
- @Attribute
- public abstract void setBarValue(List<Object> bar);
+ /**
+ * Test Attribute
+ */
+ @Attribute
+ public abstract List<String> getTestValue();
+
+ /**
+ * Bar Attribute
+ */
+ @Attribute
+ public abstract void setBarValue(List<Object> bar);
}
Modified: root/cdk/trunk/plugins/maven-cdk-plugin/src/it/annotated-component/src/main/java/org/richfaces/cdk/test/component/UITestCommand.java
===================================================================
--- root/cdk/trunk/plugins/maven-cdk-plugin/src/it/annotated-component/src/main/java/org/richfaces/cdk/test/component/UITestCommand.java 2009-11-01 16:27:54 UTC (rev 15791)
+++ root/cdk/trunk/plugins/maven-cdk-plugin/src/it/annotated-component/src/main/java/org/richfaces/cdk/test/component/UITestCommand.java 2009-11-01 16:28:50 UTC (rev 15792)
@@ -21,9 +21,12 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.test.component;
import javax.el.MethodExpression;
+
import javax.faces.component.ActionSource2;
import javax.faces.component.FacesComponent;
import javax.faces.component.UIComponentBase;
@@ -37,96 +40,110 @@
*/
@FacesComponent("cdk.TestCommand")
public class UITestCommand extends UIComponentBase implements ActionSource2 {
-
- private static final String COMPONENT_FAMILY="cdk.TestFamily";
+ private static final String COMPONENT_FAMILY = "cdk.TestFamily";
- /* (non-Javadoc)
- * @see javax.faces.component.UIComponent#getFamily()
- */
- @Override
- public String getFamily() {
- return COMPONENT_FAMILY;
- }
+ /*
+ * (non-Javadoc)
+ * @see javax.faces.component.UIComponent#getFamily()
+ */
+ @Override
+ public String getFamily() {
+ return COMPONENT_FAMILY;
+ }
- /* (non-Javadoc)
- * @see javax.faces.component.ActionSource#addActionListener(javax.faces.event.ActionListener)
- */
- public void addActionListener(ActionListener listener) {
- // TODO Auto-generated method stub
+ /*
+ * (non-Javadoc)
+ * @see javax.faces.component.ActionSource#addActionListener(javax.faces.event.ActionListener)
+ */
+ public void addActionListener(ActionListener listener) {
- }
+ // TODO Auto-generated method stub
+ }
- /* (non-Javadoc)
- * @see javax.faces.component.ActionSource#getAction()
- */
- public MethodBinding getAction() {
- // TODO Auto-generated method stub
- return null;
- }
+ /*
+ * (non-Javadoc)
+ * @see javax.faces.component.ActionSource#getAction()
+ */
+ public MethodBinding getAction() {
- /* (non-Javadoc)
- * @see javax.faces.component.ActionSource#getActionListener()
- */
- public MethodBinding getActionListener() {
- // TODO Auto-generated method stub
- return null;
- }
+ // TODO Auto-generated method stub
+ return null;
+ }
- /* (non-Javadoc)
- * @see javax.faces.component.ActionSource#getActionListeners()
- */
- public ActionListener[] getActionListeners() {
- // TODO Auto-generated method stub
- return null;
- }
+ /*
+ * (non-Javadoc)
+ * @see javax.faces.component.ActionSource#getActionListener()
+ */
+ public MethodBinding getActionListener() {
- /* (non-Javadoc)
- * @see javax.faces.component.ActionSource#isImmediate()
- */
- public boolean isImmediate() {
- // TODO Auto-generated method stub
- return false;
- }
+ // TODO Auto-generated method stub
+ return null;
+ }
- /* (non-Javadoc)
- * @see javax.faces.component.ActionSource#removeActionListener(javax.faces.event.ActionListener)
- */
- public void removeActionListener(ActionListener listener) {
- // TODO Auto-generated method stub
+ /*
+ * (non-Javadoc)
+ * @see javax.faces.component.ActionSource#getActionListeners()
+ */
+ public ActionListener[] getActionListeners() {
- }
+ // TODO Auto-generated method stub
+ return null;
+ }
- /* (non-Javadoc)
- * @see javax.faces.component.ActionSource#setAction(javax.faces.el.MethodBinding)
- */
- public void setAction(MethodBinding action) {
- // TODO Auto-generated method stub
+ /*
+ * (non-Javadoc)
+ * @see javax.faces.component.ActionSource#isImmediate()
+ */
+ public boolean isImmediate() {
- }
+ // TODO Auto-generated method stub
+ return false;
+ }
- /* (non-Javadoc)
- * @see javax.faces.component.ActionSource#setActionListener(javax.faces.el.MethodBinding)
- */
- public void setActionListener(MethodBinding actionListener) {
- // TODO Auto-generated method stub
+ /*
+ * (non-Javadoc)
+ * @see javax.faces.component.ActionSource#removeActionListener(javax.faces.event.ActionListener)
+ */
+ public void removeActionListener(ActionListener listener) {
- }
+ // TODO Auto-generated method stub
+ }
- public void setActionExpression(MethodExpression action) {
- // TODO Auto-generated method stub
-
- }
- /* (non-Javadoc)
- * @see javax.faces.component.ActionSource#setImmediate(boolean)
- */
- public void setImmediate(boolean immediate) {
- // TODO Auto-generated method stub
+ /*
+ * (non-Javadoc)
+ * @see javax.faces.component.ActionSource#setAction(javax.faces.el.MethodBinding)
+ */
+ public void setAction(MethodBinding action) {
- }
+ // TODO Auto-generated method stub
+ }
- public MethodExpression getActionExpression() {
- // TODO Auto-generated method stub
- return null;
- }
+ /*
+ * (non-Javadoc)
+ * @see javax.faces.component.ActionSource#setActionListener(javax.faces.el.MethodBinding)
+ */
+ public void setActionListener(MethodBinding actionListener) {
+ // TODO Auto-generated method stub
+ }
+
+ public void setActionExpression(MethodExpression action) {
+
+ // TODO Auto-generated method stub
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see javax.faces.component.ActionSource#setImmediate(boolean)
+ */
+ public void setImmediate(boolean immediate) {
+
+ // TODO Auto-generated method stub
+ }
+
+ public MethodExpression getActionExpression() {
+
+ // TODO Auto-generated method stub
+ return null;
+ }
}
Modified: root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/maven/MavenLogger.java
===================================================================
--- root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/maven/MavenLogger.java 2009-11-01 16:27:54 UTC (rev 15791)
+++ root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/maven/MavenLogger.java 2009-11-01 16:28:50 UTC (rev 15792)
@@ -19,9 +19,12 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.builder.maven;
import org.apache.maven.plugin.logging.Log;
+
import org.richfaces.cdk.Logger;
/**
@@ -29,147 +32,145 @@
*
*/
public class MavenLogger implements Logger {
-
- private Log _log;
+ private Log log;
- /**
- * @param _log
- */
- public MavenLogger(Log _log) {
- super();
- this._log = _log;
- }
+ /**
+ * @param log
+ */
+ public MavenLogger(Log log) {
+ super();
+ this.log = log;
+ }
- /**
- * @param content
- * @param error
- * @see org.apache.maven.plugin.logging.Log#debug(java.lang.CharSequence, java.lang.Throwable)
- */
- public void debug(CharSequence content, Throwable error) {
- _log.debug(content, error);
- }
+ /**
+ * @param content
+ * @param error
+ * @see org.apache.maven.plugin.logging.Log#debug(java.lang.CharSequence, java.lang.Throwable)
+ */
+ public void debug(CharSequence content, Throwable error) {
+ log.debug(content, error);
+ }
- /**
- * @param content
- * @see org.apache.maven.plugin.logging.Log#debug(java.lang.CharSequence)
- */
- public void debug(CharSequence content) {
- _log.debug(content);
- }
+ /**
+ * @param content
+ * @see org.apache.maven.plugin.logging.Log#debug(java.lang.CharSequence)
+ */
+ public void debug(CharSequence content) {
+ log.debug(content);
+ }
- /**
- * @param error
- * @see org.apache.maven.plugin.logging.Log#debug(java.lang.Throwable)
- */
- public void debug(Throwable error) {
- _log.debug(error);
- }
+ /**
+ * @param error
+ * @see org.apache.maven.plugin.logging.Log#debug(java.lang.Throwable)
+ */
+ public void debug(Throwable error) {
+ log.debug(error);
+ }
- /**
- * @param content
- * @param error
- * @see org.apache.maven.plugin.logging.Log#error(java.lang.CharSequence, java.lang.Throwable)
- */
- public void error(CharSequence content, Throwable error) {
- _log.error(content, error);
- }
+ /**
+ * @param content
+ * @param error
+ * @see org.apache.maven.plugin.logging.Log#error(java.lang.CharSequence, java.lang.Throwable)
+ */
+ public void error(CharSequence content, Throwable error) {
+ log.error(content, error);
+ }
- /**
- * @param content
- * @see org.apache.maven.plugin.logging.Log#error(java.lang.CharSequence)
- */
- public void error(CharSequence content) {
- _log.error(content);
- }
+ /**
+ * @param content
+ * @see org.apache.maven.plugin.logging.Log#error(java.lang.CharSequence)
+ */
+ public void error(CharSequence content) {
+ log.error(content);
+ }
- /**
- * @param error
- * @see org.apache.maven.plugin.logging.Log#error(java.lang.Throwable)
- */
- public void error(Throwable error) {
- _log.error(error);
- }
+ /**
+ * @param error
+ * @see org.apache.maven.plugin.logging.Log#error(java.lang.Throwable)
+ */
+ public void error(Throwable error) {
+ log.error(error);
+ }
- /**
- * @param content
- * @param error
- * @see org.apache.maven.plugin.logging.Log#info(java.lang.CharSequence, java.lang.Throwable)
- */
- public void info(CharSequence content, Throwable error) {
- _log.info(content, error);
- }
+ /**
+ * @param content
+ * @param error
+ * @see org.apache.maven.plugin.logging.Log#info(java.lang.CharSequence, java.lang.Throwable)
+ */
+ public void info(CharSequence content, Throwable error) {
+ log.info(content, error);
+ }
- /**
- * @param content
- * @see org.apache.maven.plugin.logging.Log#info(java.lang.CharSequence)
- */
- public void info(CharSequence content) {
- _log.info(content);
- }
+ /**
+ * @param content
+ * @see org.apache.maven.plugin.logging.Log#info(java.lang.CharSequence)
+ */
+ public void info(CharSequence content) {
+ log.info(content);
+ }
- /**
- * @param error
- * @see org.apache.maven.plugin.logging.Log#info(java.lang.Throwable)
- */
- public void info(Throwable error) {
- _log.info(error);
- }
+ /**
+ * @param error
+ * @see org.apache.maven.plugin.logging.Log#info(java.lang.Throwable)
+ */
+ public void info(Throwable error) {
+ log.info(error);
+ }
- /**
- * @return
- * @see org.apache.maven.plugin.logging.Log#isDebugEnabled()
- */
- public boolean isDebugEnabled() {
- return _log.isDebugEnabled();
- }
+ /**
+ * @return
+ * @see org.apache.maven.plugin.logging.Log#isDebugEnabled()
+ */
+ public boolean isDebugEnabled() {
+ return log.isDebugEnabled();
+ }
- /**
- * @return
- * @see org.apache.maven.plugin.logging.Log#isErrorEnabled()
- */
- public boolean isErrorEnabled() {
- return _log.isErrorEnabled();
- }
+ /**
+ * @return
+ * @see org.apache.maven.plugin.logging.Log#isErrorEnabled()
+ */
+ public boolean isErrorEnabled() {
+ return log.isErrorEnabled();
+ }
- /**
- * @return
- * @see org.apache.maven.plugin.logging.Log#isInfoEnabled()
- */
- public boolean isInfoEnabled() {
- return _log.isInfoEnabled();
- }
+ /**
+ * @return
+ * @see org.apache.maven.plugin.logging.Log#isInfoEnabled()
+ */
+ public boolean isInfoEnabled() {
+ return log.isInfoEnabled();
+ }
- /**
- * @return
- * @see org.apache.maven.plugin.logging.Log#isWarnEnabled()
- */
- public boolean isWarnEnabled() {
- return _log.isWarnEnabled();
- }
+ /**
+ * @return
+ * @see org.apache.maven.plugin.logging.Log#isWarnEnabled()
+ */
+ public boolean isWarnEnabled() {
+ return log.isWarnEnabled();
+ }
- /**
- * @param content
- * @param error
- * @see org.apache.maven.plugin.logging.Log#warn(java.lang.CharSequence, java.lang.Throwable)
- */
- public void warn(CharSequence content, Throwable error) {
- _log.warn(content, error);
- }
+ /**
+ * @param content
+ * @param error
+ * @see org.apache.maven.plugin.logging.Log#warn(java.lang.CharSequence, java.lang.Throwable)
+ */
+ public void warn(CharSequence content, Throwable error) {
+ log.warn(content, error);
+ }
- /**
- * @param content
- * @see org.apache.maven.plugin.logging.Log#warn(java.lang.CharSequence)
- */
- public void warn(CharSequence content) {
- _log.warn(content);
- }
+ /**
+ * @param content
+ * @see org.apache.maven.plugin.logging.Log#warn(java.lang.CharSequence)
+ */
+ public void warn(CharSequence content) {
+ log.warn(content);
+ }
- /**
- * @param error
- * @see org.apache.maven.plugin.logging.Log#warn(java.lang.Throwable)
- */
- public void warn(Throwable error) {
- _log.warn(error);
- }
-
+ /**
+ * @param error
+ * @see org.apache.maven.plugin.logging.Log#warn(java.lang.Throwable)
+ */
+ public void warn(Throwable error) {
+ log.warn(error);
+ }
}
Modified: root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/AbstractCDKMojo.java
===================================================================
--- root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/AbstractCDKMojo.java 2009-11-01 16:27:54 UTC (rev 15791)
+++ root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/AbstractCDKMojo.java 2009-11-01 16:28:50 UTC (rev 15792)
@@ -19,347 +19,390 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.builder.mojo;
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.DependencyResolutionRequiredException;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.project.MavenProject;
+
+import org.codehaus.plexus.util.DirectoryScanner;
+
import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
+
import java.lang.reflect.Method;
+
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
+
import java.util.Iterator;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.DependencyResolutionRequiredException;
-import org.apache.maven.plugin.AbstractMojo;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.project.MavenProject;
-import org.apache.velocity.Template;
-import org.apache.velocity.VelocityContext;
-import org.apache.velocity.app.VelocityEngine;
-import org.apache.velocity.exception.MethodInvocationException;
-import org.apache.velocity.exception.ParseErrorException;
-import org.apache.velocity.exception.ResourceNotFoundException;
-import org.codehaus.plexus.util.DirectoryScanner;
-import org.codehaus.plexus.velocity.VelocityComponent;
-
/**
* @author shura
*
*/
public abstract class AbstractCDKMojo extends AbstractMojo {
- /**
- * Top maven project.
- *
- * @parameter expression="${project}"
- * @readonly
- */
- protected MavenProject project;
- /**
- *
- * @parameter
- */
- protected String key;
- /**
- * Place for component configuration XML files. All '*.xml' files wil be
- * parsed as components config. All '*.ent' files will be processed as
- * include configurations.
- *
- * @parameter expression="src/main/config/component"
- */
- protected File componentConfigDirectory;
- /**
- * Place for validator configuration XML files. All '*.xml' files wil be
- * parsed as component config. All '*.ent' files will be processed as
- * include configurations.
- *
- * @parameter expression="src/main/config/validator"
- */
- protected File validatorConfigDirectory;
+ /**
+ * Project classpath.
+ *
+ * @parameter expression="${project.compileClasspathElements}"
+ * @required
+ * @readonly
+ */
+ protected List classpathElements;
- /**
- * Place for converter configuration XML files. All '*.xml' files wil be
- * parsed as components config. All '*.ent' files will be processed as
- * include configurations.
- *
- * @parameter expression="src/main/config/converter"
- */
- protected File converterConfigDirectory;
+ /**
+ * The source directories containing the sources to be compiled.
+ *
+ * @parameter expression="${project.compileSourceRoots}"
+ * @required
+ * @readonly
+ */
+ protected List<String> compileSourceRoots;
- /**
- * Place for faces configuration XML files
- *
- * @parameter expression="src/main/config/faces"
- */
- protected File facesConfigInclude;
- /**
- * Place for component configuration XML files
- *
- * @parameter expression="src/main/config/taglib"
- */
- protected File taglibInclude;
- /**
- * Place for component configuration XML files
- *
- * @parameter expression="src/main/config/resources"
- */
- protected File resourcesInclude;
- /**
- *
- * @parameter expression="src/main/templates"
- */
- protected File templatesDirectory;
- /**
- * Directory where the output Java Files will be located.
- *
- * @parameter expression="${project.build.directory}/generated-component/java"
- */
- protected File outputJavaDirectory;
+ /**
+ * Place for component configuration XML files. All '*.xml' files wil be
+ * parsed as components config. All '*.ent' files will be processed as
+ * include configurations.
+ *
+ * @parameter expression="src/main/config/component"
+ */
+ protected File componentConfigDirectory;
- /**
- * @parameter expression="${project.build.directory}/generated-component/test"
- */
- protected File outputTestsDirectory;
+ /**
+ * Place for converter configuration XML files. All '*.xml' files wil be
+ * parsed as components config. All '*.ent' files will be processed as
+ * include configurations.
+ *
+ * @parameter expression="src/main/config/converter"
+ */
+ protected File converterConfigDirectory;
- /**
- * Directory where the output Java Files will be located.
- *
- * @parameter expression="${project.build.directory}/generated-component/resources"
- */
- protected File outputResourcesDirectory;
- /**
- * @parameter
- */
- protected Library library;
- /**
- * The source directories containing the sources to be compiled.
- *
- * @parameter expression="${project.compileSourceRoots}"
- * @required
- * @readonly
- */
- protected List<String> compileSourceRoots;
- /**
- * Project classpath.
- *
- * @parameter expression="${project.compileClasspathElements}"
- * @required
- * @readonly
- */
- protected List classpathElements;
- /**
- * The directory for compiled classes.
- *
- * @parameter expression="${project.build.outputDirectory}"
- * @required
- * @readonly
- */
- protected File outputDirectory;
- /**
- * Check library configuration, and fill all empty values to default.
- *
- * @return
- */
- protected Taglib checkLibraryConfig() {
- if (null != library) {
- getLog().debug("Library prefix is " + library.getPrefix());
- } else {
- library = new Library();
- }
- if (null == library.getPrefix()) {
- library.setPrefix(project.getGroupId());
+ /**
+ * Place for faces configuration XML files
+ *
+ * @parameter expression="src/main/config/faces"
+ */
+ protected File facesConfigInclude;
- }
- getLog().debug("Default prefix for a generated packages: "+library.getPrefix());
- if (null == library.getDescription()) {
- library.setDescription(project.getDescription());
- }
- getLog().debug("Library description: "+library.getDescription());
- if( null == library.getJsfVersion()){
- String version = Library.JSF11;
- // Check version-specific methods in UIComponent class
- try {
- Class<?> componentClass = createProjectClassLoader(project, false).loadClass("javax.faces.component.UIComponent");
- Method[] methods = componentClass.getDeclaredMethods();
- for (int i = 0; i < methods.length; i++) {
- if("encodeAll".equals(methods[i].getName())){
- version = Library.JSF12;
- break;
- }
- }
- } catch (ClassNotFoundException e) {
- // Ignore - by defaule, generate codes for JSF 1.1
- }
- library.setJsfVersion(version);
- }
-
- //velocity = new DefaultVelocityComponent();
-
- getLog().debug("Generate files for a JSF "+library.getJsfVersion());
- Renderkit[] renderkits = library.getRenderkits();
- if (null != renderkits) {
- for (int i = 0; i < renderkits.length; i++) {
- Renderkit renderkit = renderkits[i];
- getLog().debug("Renderkit name is " + renderkit.getName());
- if(null == renderkit.getPackage()){
- renderkit.setPackage(library.getPrefix()+".renderkit."+renderkit.getName().toLowerCase());
- }
- }
- } else {
- renderkits = new Renderkit[1];
- Renderkit renderkit = new Renderkit();
- renderkit.setMarkup("html");
- renderkit.setName("HTML_BASIC");
- renderkit.setPackage(library.getPrefix()+".renderkit."+renderkit.getName().toLowerCase());
- renderkits[0] = renderkit;
- library.setRenderkits(renderkits);
- }
- Taglib taglib = library.getTaglib();
- if (null != taglib) {
- getLog().debug("Taglib uri is " + taglib.getUri());
- getLog().debug("Taglib shortname is " + taglib.getShortName());
- } else {
- taglib = new Taglib();
- library.setTaglib(taglib);
- }
- if (null == taglib.getDisplayName()) {
- taglib.setDisplayName(project.getDescription());
+ /**
+ *
+ * @parameter
+ */
+ protected String key;
- }
- if( null == taglib.getJspVersion()){
- // Jsf 1.2 can use JSP 2.1 only, other - 2.0
- taglib.setJspVersion(library.getJsfVersion().equals(Library.JSF12)?"2.1":"1.2");
- }
- if (null == taglib.getUri()) {
- String url = project.getUrl();
- if (null == url) {
- url = "http://";
- String[] parts = project.getGroupId().split(".");
- for (int i = parts.length - 1; i >= 0; i--) {
- url = url + parts[i];
- if (i > 0) {
- url = url + ".";
- }
- }
- url = url + "/" + project.getArtifactId();
- }
- taglib.setUri(url);
+ /**
+ * @parameter
+ */
+ protected Library library;
- }
- if (null == taglib.getShortName()) {
- taglib.setShortName(project.getArtifactId());
+ /**
+ * The directory for compiled classes.
+ *
+ * @parameter expression="${project.build.outputDirectory}"
+ * @required
+ * @readonly
+ */
+ protected File outputDirectory;
- }
- if(null == taglib.getTaglib()){
- taglib.setTaglib(taglib.getShortName());
- }
-
- if (null == taglib.getTlibVersion()) {
- taglib.setTlibVersion(createTaglibVersionFromProjectVersion());
- }
- getLog().debug("Taglib uri is " + taglib.getUri());
- getLog().debug("Taglib shortname is " + taglib.getShortName());
- if (null != library.getTaglibs() && library.getTaglibs().length > 0) {
- for (int i = 0; i < library.getTaglibs().length; i++) {
- Taglib t = library.getTaglibs()[i];
- checkTaglib(t);
- }
- }
- return taglib;
- }
+ /**
+ * Directory where the output Java Files will be located.
+ *
+ * @parameter expression="${project.build.directory}/generated-component/java"
+ */
+ protected File outputJavaDirectory;
- private String createTaglibVersionFromProjectVersion() {
- Artifact artifact = project.getArtifact();
- String version = artifact.getVersion();
- Matcher matcher = Pattern.compile("^(\\d+(?:\\.\\d+)*)").matcher(version);
- if (matcher.find()) {
- return matcher.group(1);
- }
+ /**
+ * Directory where the output Java Files will be located.
+ *
+ * @parameter expression="${project.build.directory}/generated-component/resources"
+ */
+ protected File outputResourcesDirectory;
- return "1.2";
- }
+ /**
+ * @parameter expression="${project.build.directory}/generated-component/test"
+ */
+ protected File outputTestsDirectory;
- protected ClassLoader createProjectClassLoader(MavenProject project, boolean useCCL) {
- ClassLoader classLoader = Thread.currentThread()
- .getContextClassLoader();
- try {
- List<?> compileClasspathElements = project
- .getCompileClasspathElements();
- String outputDirectory = project.getBuild().getOutputDirectory();
- URL[] urls = new URL[compileClasspathElements.size() + 1];
- int i = 0;
- urls[i++] = new File(outputDirectory).toURI().toURL();
- for (Iterator<?> iter = compileClasspathElements.iterator(); iter
- .hasNext();) {
- String element = (String) iter.next();
- urls[i++] = new File(element).toURI().toURL();
- }
+ /**
+ * Top maven project.
+ *
+ * @parameter expression="${project}"
+ * @readonly
+ */
+ protected MavenProject project;
- if (useCCL) {
- classLoader = new URLClassLoader(urls, classLoader);
- } else {
- classLoader = new URLClassLoader(urls);
- }
- } catch (MalformedURLException e) {
- getLog().error("Bad URL in classpath", e);
- } catch (DependencyResolutionRequiredException e) {
- getLog().error("Dependencies not resolved ", e);
- }
+ /**
+ * Place for component configuration XML files
+ *
+ * @parameter expression="src/main/config/resources"
+ */
+ protected File resourcesInclude;
- return classLoader;
- }
+ /**
+ * Place for component configuration XML files
+ *
+ * @parameter expression="src/main/config/taglib"
+ */
+ protected File taglibInclude;
- protected ClassLoader createProjectClassLoader(MavenProject project) {
- return createProjectClassLoader(project, true);
- }
+ /**
+ *
+ * @parameter expression="src/main/templates"
+ */
+ protected File templatesDirectory;
- protected void checkTaglib(Taglib taglib) {
- if (null == taglib.getDisplayName()) {
- taglib.setDisplayName(library.getTaglib().getDisplayName());
- }
- if (null == taglib.getShortName()) {
- taglib.setShortName(library.getTaglib().getShortName());
- }
- if (null == taglib.getJspVersion()) {
- taglib.setJspVersion(library.getTaglib().getJspVersion());
- }
- if (null == taglib.getUri()) {
- taglib.setUri(library.getTaglib().getUri() + "/"
- + taglib.getShortName());
- }
- if(null == taglib.getTaglib()){
- taglib.setTaglib(taglib.getShortName());
- }
- if (null == taglib.getTlibVersion()) {
- taglib.setTlibVersion(createTaglibVersionFromProjectVersion());
- }
- getLog().debug("Taglib uri is " + taglib.getUri());
- getLog().debug("Taglib shortname is " + taglib.getShortName());
- getLog().debug("Taglib version is " + taglib.getTlibVersion());
- }
+ /**
+ * Place for validator configuration XML files. All '*.xml' files wil be
+ * parsed as component config. All '*.ent' files will be processed as
+ * include configurations.
+ *
+ * @parameter expression="src/main/config/validator"
+ */
+ protected File validatorConfigDirectory;
- protected String[] doScan(String[] includes, String[] excludes, File rootFolder)
- throws MojoExecutionException {
- try {
- DirectoryScanner directoryScanner = new DirectoryScanner();
- directoryScanner.setFollowSymlinks(true);
- directoryScanner.setBasedir(rootFolder);
- directoryScanner.setExcludes(excludes);
- directoryScanner.setIncludes(includes);
- directoryScanner.addDefaultExcludes();
+ /**
+ * Check library configuration, and fill all empty values to default.
+ *
+ * @return
+ */
+ protected Taglib checkLibraryConfig() {
+ if (null != library) {
+ getLog().debug("Library prefix is " + library.getPrefix());
+ } else {
+ library = new Library();
+ }
- directoryScanner.scan();
+ if (null == library.getPrefix()) {
+ library.setPrefix(project.getGroupId());
+ }
- return directoryScanner.getIncludedFiles();
- } catch (IllegalStateException e) {
- throw new MojoExecutionException(
- "Error scanning source root: \'" + rootFolder + "\'", e );
- }
- }
+ getLog().debug("Default prefix for a generated packages: " + library.getPrefix());
+ if (null == library.getDescription()) {
+ library.setDescription(project.getDescription());
+ }
+
+ getLog().debug("Library description: " + library.getDescription());
+
+ if (null == library.getJsfVersion()) {
+ String version = Library.JSF11;
+
+ // Check version-specific methods in UIComponent class
+ try {
+ Class<?> componentClass = createProjectClassLoader(project,
+ false).loadClass("javax.faces.component.UIComponent");
+ Method[] methods = componentClass.getDeclaredMethods();
+
+ for (int i = 0; i < methods.length; i++) {
+ if ("encodeAll".equals(methods[i].getName())) {
+ version = Library.JSF12;
+
+ break;
+ }
+ }
+ } catch (ClassNotFoundException e) {
+
+ // Ignore - by defaule, generate codes for JSF 1.1
+ }
+
+ library.setJsfVersion(version);
+ }
+
+ // velocity = new DefaultVelocityComponent();
+ getLog().debug("Generate files for a JSF " + library.getJsfVersion());
+
+ Renderkit[] renderkits = library.getRenderkits();
+
+ if (null != renderkits) {
+ for (int i = 0; i < renderkits.length; i++) {
+ Renderkit renderkit = renderkits[i];
+
+ getLog().debug("Renderkit name is " + renderkit.getName());
+
+ if (null == renderkit.getPackage()) {
+ renderkit.setPackage(library.getPrefix() + ".renderkit." + renderkit.getName().toLowerCase());
+ }
+ }
+ } else {
+ renderkits = new Renderkit[1];
+
+ Renderkit renderkit = new Renderkit();
+
+ renderkit.setMarkup("html");
+ renderkit.setName("HTML_BASIC");
+ renderkit.setPackage(library.getPrefix() + ".renderkit." + renderkit.getName().toLowerCase());
+ renderkits[0] = renderkit;
+ library.setRenderkits(renderkits);
+ }
+
+ Taglib taglib = library.getTaglib();
+
+ if (null != taglib) {
+ getLog().debug("Taglib uri is " + taglib.getUri());
+ getLog().debug("Taglib shortname is " + taglib.getShortName());
+ } else {
+ taglib = new Taglib();
+ library.setTaglib(taglib);
+ }
+
+ if (null == taglib.getDisplayName()) {
+ taglib.setDisplayName(project.getDescription());
+ }
+
+ if (null == taglib.getJspVersion()) {
+
+ // Jsf 1.2 can use JSP 2.1 only, other - 2.0
+ taglib.setJspVersion(library.getJsfVersion().equals(Library.JSF12) ? "2.1" : "1.2");
+ }
+
+ if (null == taglib.getUri()) {
+ String url = project.getUrl();
+
+ if (null == url) {
+ url = "http://";
+
+ String[] parts = project.getGroupId().split(".");
+
+ for (int i = parts.length - 1; i >= 0; i--) {
+ url = url + parts[i];
+
+ if (i > 0) {
+ url = url + ".";
+ }
+ }
+
+ url = url + "/" + project.getArtifactId();
+ }
+
+ taglib.setUri(url);
+ }
+
+ if (null == taglib.getShortName()) {
+ taglib.setShortName(project.getArtifactId());
+ }
+
+ if (null == taglib.getTaglib()) {
+ taglib.setTaglib(taglib.getShortName());
+ }
+
+ if (null == taglib.getTlibVersion()) {
+ taglib.setTlibVersion(createTaglibVersionFromProjectVersion());
+ }
+
+ getLog().debug("Taglib uri is " + taglib.getUri());
+ getLog().debug("Taglib shortname is " + taglib.getShortName());
+
+ if (null != library.getTaglibs() && library.getTaglibs().length > 0) {
+ for (int i = 0; i < library.getTaglibs().length; i++) {
+ Taglib t = library.getTaglibs()[i];
+
+ checkTaglib(t);
+ }
+ }
+
+ return taglib;
+ }
+
+ private String createTaglibVersionFromProjectVersion() {
+ Artifact artifact = project.getArtifact();
+ String version = artifact.getVersion();
+ Matcher matcher = Pattern.compile("^(\\d+(?:\\.\\d+)*)").matcher(version);
+
+ if (matcher.find()) {
+ return matcher.group(1);
+ }
+
+ return "1.2";
+ }
+
+ protected ClassLoader createProjectClassLoader(MavenProject project, boolean useCCL) {
+ ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+
+ try {
+ List<?> compileClasspathElements = project.getCompileClasspathElements();
+ String outputDirectory = project.getBuild().getOutputDirectory();
+ URL[] urls = new URL[compileClasspathElements.size() + 1];
+ int i = 0;
+
+ urls[i++] = new File(outputDirectory).toURI().toURL();
+
+ for (Iterator<?> iter = compileClasspathElements.iterator(); iter.hasNext(); ) {
+ String element = (String) iter.next();
+
+ urls[i++] = new File(element).toURI().toURL();
+ }
+
+ if (useCCL) {
+ classLoader = new URLClassLoader(urls, classLoader);
+ } else {
+ classLoader = new URLClassLoader(urls);
+ }
+ } catch (MalformedURLException e) {
+ getLog().error("Bad URL in classpath", e);
+ } catch (DependencyResolutionRequiredException e) {
+ getLog().error("Dependencies not resolved ", e);
+ }
+
+ return classLoader;
+ }
+
+ protected ClassLoader createProjectClassLoader(MavenProject project) {
+ return createProjectClassLoader(project, true);
+ }
+
+ protected void checkTaglib(Taglib taglib) {
+ if (null == taglib.getDisplayName()) {
+ taglib.setDisplayName(library.getTaglib().getDisplayName());
+ }
+
+ if (null == taglib.getShortName()) {
+ taglib.setShortName(library.getTaglib().getShortName());
+ }
+
+ if (null == taglib.getJspVersion()) {
+ taglib.setJspVersion(library.getTaglib().getJspVersion());
+ }
+
+ if (null == taglib.getUri()) {
+ taglib.setUri(library.getTaglib().getUri() + "/" + taglib.getShortName());
+ }
+
+ if (null == taglib.getTaglib()) {
+ taglib.setTaglib(taglib.getShortName());
+ }
+
+ if (null == taglib.getTlibVersion()) {
+ taglib.setTlibVersion(createTaglibVersionFromProjectVersion());
+ }
+
+ getLog().debug("Taglib uri is " + taglib.getUri());
+ getLog().debug("Taglib shortname is " + taglib.getShortName());
+ getLog().debug("Taglib version is " + taglib.getTlibVersion());
+ }
+
+ protected String[] doScan(String[] includes, String[] excludes, File rootFolder) throws MojoExecutionException {
+ try {
+ DirectoryScanner directoryScanner = new DirectoryScanner();
+
+ directoryScanner.setFollowSymlinks(true);
+ directoryScanner.setBasedir(rootFolder);
+ directoryScanner.setExcludes(excludes);
+ directoryScanner.setIncludes(includes);
+ directoryScanner.addDefaultExcludes();
+ directoryScanner.scan();
+
+ return directoryScanner.getIncludedFiles();
+ } catch (IllegalStateException e) {
+ throw new MojoExecutionException("Error scanning source root: \'" + rootFolder + "\'", e);
+ }
+ }
}
Modified: root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/AbstractGenerateMojo.java
===================================================================
--- root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/AbstractGenerateMojo.java 2009-11-01 16:27:54 UTC (rev 15791)
+++ root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/AbstractGenerateMojo.java 2009-11-01 16:28:50 UTC (rev 15792)
@@ -19,202 +19,200 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.builder.mojo;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.project.MavenProject;
+
+import org.codehaus.plexus.util.DirectoryScanner;
+
import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.lang.reflect.Method;
+
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
+
import java.util.Iterator;
import java.util.List;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.DependencyResolutionRequiredException;
-import org.apache.maven.plugin.AbstractMojo;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.project.MavenProject;
-import org.apache.velocity.Template;
-import org.apache.velocity.VelocityContext;
-import org.apache.velocity.app.VelocityEngine;
-import org.apache.velocity.exception.MethodInvocationException;
-import org.apache.velocity.exception.ParseErrorException;
-import org.apache.velocity.exception.ResourceNotFoundException;
-import org.codehaus.plexus.util.DirectoryScanner;
-import org.codehaus.plexus.velocity.VelocityComponent;
-
/**
* @author shura
*
*/
public abstract class AbstractGenerateMojo extends AbstractMojo {
- /**
- * Top maven project.
- *
- * @parameter expression="${project}"
- * @readonly
- */
- protected MavenProject project;
- /**
- *
- * @parameter
- */
- protected String key;
- /**
- * Place for component configuration XML files. All '*.xml' files wil be
- * parsed as components config. All '*.ent' files will be processed as
- * include configurations.
- *
- * @parameter expression="src/main/config/component"
- */
- protected File componentConfigDirectory;
- /**
- * Place for validator configuration XML files. All '*.xml' files wil be
- * parsed as component config. All '*.ent' files will be processed as
- * include configurations.
- *
- * @parameter expression="src/main/config/validator"
- */
- protected File validatorConfigDirectory;
+ /**
+ * Project classpath.
+ *
+ * @parameter expression="${project.compileClasspathElements}"
+ * @required
+ * @readonly
+ */
+ protected List<String> classpathElements;
- /**
- * Place for converter configuration XML files. All '*.xml' files wil be
- * parsed as components config. All '*.ent' files will be processed as
- * include configurations.
- *
- * @parameter expression="src/main/config/converter"
- */
- protected File converterConfigDirectory;
+ /**
+ * The source directories containing the sources to be compiled.
+ *
+ * @parameter expression="${project.compileSourceRoots}"
+ * @required
+ * @readonly
+ */
+ protected List<String> compileSourceRoots;
- /**
- * Place for faces configuration XML files
- *
- * @parameter expression="src/main/config/faces"
- */
- protected File facesConfigInclude;
- /**
- * Place for component configuration XML files
- *
- * @parameter expression="src/main/config/taglib"
- */
- protected File taglibInclude;
- /**
- * Place for component configuration XML files
- *
- * @parameter expression="src/main/config/resources"
- */
- protected File resourcesInclude;
- /**
- *
- * @parameter expression="src/main/templates"
- */
- protected File templatesDirectory;
- /**
- * Directory where the output Java Files will be located.
- *
- * @parameter expression="${project.build.directory}/generated-component/java"
- */
- protected File outputJavaDirectory;
+ /**
+ * Place for component configuration XML files. All '*.xml' files wil be
+ * parsed as components config. All '*.ent' files will be processed as
+ * include configurations.
+ *
+ * @parameter expression="src/main/config/component"
+ */
+ protected File componentConfigDirectory;
- /**
- * @parameter expression="${project.build.directory}/generated-component/test"
- */
- protected File outputTestsDirectory;
+ /**
+ * Place for converter configuration XML files. All '*.xml' files wil be
+ * parsed as components config. All '*.ent' files will be processed as
+ * include configurations.
+ *
+ * @parameter expression="src/main/config/converter"
+ */
+ protected File converterConfigDirectory;
- /**
- * Directory where the output Java Files will be located.
- *
- * @parameter expression="${project.build.directory}/generated-component/resources"
- */
- protected File outputResourcesDirectory;
+ /**
+ * Place for faces configuration XML files
+ *
+ * @parameter expression="src/main/config/faces"
+ */
+ protected File facesConfigInclude;
- /**
- * @parameter expression="${project.build.directory}/generated-component/test-resources"
- */
- protected File outputTestsResourcesDirectory;
-
-
- /**
- * @parameter
- */
- protected Library library;
- /**
- * The source directories containing the sources to be compiled.
- *
- * @parameter expression="${project.compileSourceRoots}"
- * @required
- * @readonly
- */
- protected List<String> compileSourceRoots;
- /**
- * Project classpath.
- *
- * @parameter expression="${project.compileClasspathElements}"
- * @required
- * @readonly
- */
- protected List<String> classpathElements;
- /**
- * The directory for compiled classes.
- *
- * @parameter expression="${project.build.outputDirectory}"
- * @required
- * @readonly
- */
- protected File outputDirectory;
-
-
- protected ClassLoader createProjectClassLoader(MavenProject project, boolean useCCL) {
- ClassLoader classLoader = Thread.currentThread()
- .getContextClassLoader();
- try {
- URL[] urls = new URL[classpathElements.size() + 1];
- int i = 0;
- urls[i++] = outputDirectory.toURI().toURL();
- for (Iterator<?> iter = classpathElements.iterator(); iter
- .hasNext();) {
- String element = (String) iter.next();
- urls[i++] = new File(element).toURI().toURL();
- }
+ /**
+ *
+ * @parameter
+ */
+ protected String key;
- if (useCCL) {
- classLoader = new URLClassLoader(urls, classLoader);
- } else {
- classLoader = new URLClassLoader(urls);
- }
- } catch (MalformedURLException e) {
- getLog().error("Bad URL in classpath", e);
- }
+ /**
+ * @parameter
+ */
+ protected Library library;
- return classLoader;
- }
+ /**
+ * The directory for compiled classes.
+ *
+ * @parameter expression="${project.build.outputDirectory}"
+ * @required
+ * @readonly
+ */
+ protected File outputDirectory;
- protected ClassLoader createProjectClassLoader(MavenProject project) {
- return createProjectClassLoader(project, true);
- }
+ /**
+ * Directory where the output Java Files will be located.
+ *
+ * @parameter expression="${project.build.directory}/generated-component/java"
+ */
+ protected File outputJavaDirectory;
- protected String[] doScan(String[] includes, String[] excludes, File rootFolder)
- throws MojoExecutionException {
- try {
- DirectoryScanner directoryScanner = new DirectoryScanner();
- directoryScanner.setFollowSymlinks(true);
- directoryScanner.setBasedir(rootFolder);
- directoryScanner.setExcludes(excludes);
- directoryScanner.setIncludes(includes);
- directoryScanner.addDefaultExcludes();
+ /**
+ * Directory where the output Java Files will be located.
+ *
+ * @parameter expression="${project.build.directory}/generated-component/resources"
+ */
+ protected File outputResourcesDirectory;
- directoryScanner.scan();
+ /**
+ * @parameter expression="${project.build.directory}/generated-component/test"
+ */
+ protected File outputTestsDirectory;
- return directoryScanner.getIncludedFiles();
- } catch (IllegalStateException e) {
- throw new MojoExecutionException(
- "Error scanning source root: \'" + rootFolder + "\'", e );
- }
- }
+ /**
+ * @parameter expression="${project.build.directory}/generated-component/test-resources"
+ */
+ protected File outputTestsResourcesDirectory;
+ /**
+ * Top maven project.
+ *
+ * @parameter expression="${project}"
+ * @readonly
+ */
+ protected MavenProject project;
+
+ /**
+ * Place for component configuration XML files
+ *
+ * @parameter expression="src/main/config/resources"
+ */
+ protected File resourcesInclude;
+
+ /**
+ * Place for component configuration XML files
+ *
+ * @parameter expression="src/main/config/taglib"
+ */
+ protected File taglibInclude;
+
+ /**
+ *
+ * @parameter expression="src/main/templates"
+ */
+ protected File templatesDirectory;
+
+ /**
+ * Place for validator configuration XML files. All '*.xml' files wil be
+ * parsed as component config. All '*.ent' files will be processed as
+ * include configurations.
+ *
+ * @parameter expression="src/main/config/validator"
+ */
+ protected File validatorConfigDirectory;
+
+ protected ClassLoader createProjectClassLoader(MavenProject project, boolean useCCL) {
+ ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+
+ try {
+ URL[] urls = new URL[classpathElements.size() + 1];
+ int i = 0;
+
+ urls[i++] = outputDirectory.toURI().toURL();
+
+ for (Iterator<?> iter = classpathElements.iterator(); iter.hasNext(); ) {
+ String element = (String) iter.next();
+
+ urls[i++] = new File(element).toURI().toURL();
+ }
+
+ if (useCCL) {
+ classLoader = new URLClassLoader(urls, classLoader);
+ } else {
+ classLoader = new URLClassLoader(urls);
+ }
+ } catch (MalformedURLException e) {
+ getLog().error("Bad URL in classpath", e);
+ }
+
+ return classLoader;
+ }
+
+ protected ClassLoader createProjectClassLoader(MavenProject project) {
+ return createProjectClassLoader(project, true);
+ }
+
+ protected String[] doScan(String[] includes, String[] excludes, File rootFolder) throws MojoExecutionException {
+ try {
+ DirectoryScanner directoryScanner = new DirectoryScanner();
+
+ directoryScanner.setFollowSymlinks(true);
+ directoryScanner.setBasedir(rootFolder);
+ directoryScanner.setExcludes(excludes);
+ directoryScanner.setIncludes(includes);
+ directoryScanner.addDefaultExcludes();
+ directoryScanner.scan();
+
+ return directoryScanner.getIncludedFiles();
+ } catch (IllegalStateException e) {
+ throw new MojoExecutionException("Error scanning source root: \'" + rootFolder + "\'", e);
+ }
+ }
}
Modified: root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/CompileMojo.java
===================================================================
--- root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/CompileMojo.java 2009-11-01 16:27:54 UTC (rev 15791)
+++ root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/CompileMojo.java 2009-11-01 16:28:50 UTC (rev 15792)
@@ -19,13 +19,18 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.builder.mojo;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
+
import java.io.File;
+
import java.lang.reflect.Array;
import java.lang.reflect.InvocationTargetException;
+
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
@@ -38,6 +43,7 @@
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.MavenProjectBuilder;
import org.apache.maven.project.ProjectBuildingException;
+
import org.codehaus.plexus.PlexusConstants;
import org.codehaus.plexus.PlexusContainer;
import org.codehaus.plexus.archiver.manager.ArchiverManager;
@@ -49,246 +55,268 @@
/**
* Compile all xml templates, matched given pattern to Java classes. Sources
* will be created in {@link AbstractCDKMojo#outputJavaDirectory}
- *
+ *
* @goal compile
* @requiresDependencyResolution compile
* @phase generate-sources
* @author shura
- *
+ *
*/
public class CompileMojo extends AbstractCDKMojo implements Contextualizable {
- /**
- * Project executed by first compile lifecycle.
- *
- * @parameter expression="${executedProject}"
- * @readonly
- */
- private MavenProject executedProject;
+ /**
+ * To look up Archiver/UnArchiver implementations
+ *
+ * @component
+ */
+ private ArchiverManager archiverManager;
+ private PlexusContainer container;
- /**
- * The reactor projects.
- *
- * @parameter expression="${project.parent}"
- * @readonly
- */
- private MavenProject parentProject;
- /**
- * @parameter default-value=${project.groupId}
- */
- private String defaultPackage;
+ /**
+ * @parameter default-value=${project.groupId}
+ */
+ private String defaultPackage;
- /**
- * A list of inclusion filters for the compiler. By default, include all
- * files in templates directory.
- *
- * @parameter
- */
- private String[] includes;
+ /**
+ * A list of exclusion filters for the compiler. None by default.
+ *
+ * @parameter
+ */
+ private String[] excludes;
- /**
- * A list of exclusion filters for the compiler. None by default.
- *
- * @parameter
- */
- private String[] excludes;
+ /**
+ * Project executed by first compile lifecycle.
+ *
+ * @parameter expression="${executedProject}"
+ * @readonly
+ */
+ private MavenProject executedProject;
- /**
- * The local repository.
- *
- * @parameter expression="${localRepository}"
- */
- private ArtifactRepository localRepository;
+ /**
+ * A list of inclusion filters for the compiler. By default, include all
+ * files in templates directory.
+ *
+ * @parameter
+ */
+ private String[] includes;
- /**
- * To look up Archiver/UnArchiver implementations
- *
- * @component
- */
- private ArchiverManager archiverManager;
+ /**
+ * The local repository.
+ *
+ * @parameter expression="${localRepository}"
+ */
+ private ArtifactRepository localRepository;
- /**
- * Project builder
- *
- * @component
- */
- private MavenProjectBuilder mavenProjectBuilder;
- private PlexusContainer container;
+ /**
+ * Project builder
+ *
+ * @component
+ */
+ private MavenProjectBuilder mavenProjectBuilder;
- /*
- * (non-Javadoc)
- *
- * @see org.apache.maven.plugin.Mojo#execute()
- */
- public void execute() throws MojoExecutionException, MojoFailureException {
+ /**
+ * The reactor projects.
+ *
+ * @parameter expression="${project.parent}"
+ * @readonly
+ */
+ private MavenProject parentProject;
- // VelocityTemplates.init();
- try {
- List components = container
- .lookupList("org.richfaces.templatecompiler.elements.ElementsFactory");
- for (Iterator iter = components.iterator(); iter.hasNext();) {
- Object element = iter.next();
- System.out.println(element.getClass().getName());
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.maven.plugin.Mojo#execute()
+ */
+ public void execute() throws MojoExecutionException, MojoFailureException {
- }
- System.out.println("Components Map");
- Map componentsMap = container
- .lookupMap("org.richfaces.templatecompiler.elements.ElementsFactory");
- for (Iterator iter = componentsMap.entrySet().iterator(); iter
- .hasNext();) {
- Map.Entry element = (Map.Entry) iter.next();
- System.out.println(element.getKey() + ":"
- + element.getValue().getClass().getName());
- }
- } catch (ComponentLookupException e) {
- throw new MojoExecutionException(
- "Error lookup ElementFactory components");
- }
- Parent parentModel = project.getModel().getParent();
- if (null != parentModel) {
- String relativePath = parentModel.getRelativePath();
- File parentPom = new File(project.getFile().getParentFile(), relativePath);
- if (parentPom.isDirectory()) {
- parentPom = new File(parentPom, "pom.xml");
- }
- if (parentPom.exists()) {
- try {
- parentProject = mavenProjectBuilder.build(parentPom,
- localRepository, null);
- } catch (ProjectBuildingException e) {
- throw new MojoExecutionException("Error get parent project for a components library",e);
- }
- } else {
- throw new MojoFailureException("Parent project pom file "+parentPom.getAbsolutePath()+" is not found for a components library");
- }
- }else {
- throw new MojoFailureException("Components library project must have parent pom with components modules");
- }
- getLog().info("Parent Project object :\n" + toLog(parentProject) + "\n");
- getLog().info("Project object :\n" + toLog(project) + "\n");
- getLog().info("Project object Model :\n" + toLog(project.getModel()) + "\n");
- getLog().info("Project object Parent Model :\n" + toLog(project.getModel().getParent()) + "\n");
-
- getLog().info(
- "Executed Project object :\n" + toLog(executedProject) + "\n");
- }
+ // VelocityTemplates.init();
+ try {
+ List components = container.lookupList("org.richfaces.templatecompiler.elements.ElementsFactory");
- /*
- * (non-Javadoc)
- *
- * @see org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable#contextualize(org.codehaus.plexus.context.Context)
- */
- public void contextualize(Context context) throws ContextException {
- this.container = (PlexusContainer) context
- .get(PlexusConstants.PLEXUS_KEY);
+ for (Iterator iter = components.iterator(); iter.hasNext(); ) {
+ Object element = iter.next();
- }
+ System.out.println(element.getClass().getName());
+ }
- private void logBean(Object bean) {
- StringBuffer content = new StringBuffer();
- }
+ System.out.println("Components Map");
- /**
- * Convert any Java Object to JavaScript representation ( as possible ).
- *
- * @param obj
- * @return
- * @throws MojoExecutionException
- */
- public String toLog(Object obj) throws MojoExecutionException {
- if (null == obj) {
- return "null";
- } else if (obj.getClass().isArray()) {
- StringBuffer ret = new StringBuffer("[");
- boolean first = true;
- for (int i = 0; i < Array.getLength(obj); i++) {
- Object element = Array.get(obj, i);
- if (!first) {
- ret.append(',');
- }
- ret.append(toLog(element));
- first = false;
- }
- return ret.append("]\n").toString();
- } else if (obj instanceof Collection) {
- // Collections put as JavaScript array.
- Collection collection = (Collection) obj;
- StringBuffer ret = new StringBuffer("[");
- boolean first = true;
- for (Iterator iter = collection.iterator(); iter.hasNext();) {
- Object element = iter.next();
- if (!first) {
- ret.append(',');
- }
- ret.append(toLog(element));
- first = false;
- }
- return ret.append("]\n").toString();
- } else if (obj instanceof Map) {
- // Maps put as JavaScript hash.
- Map map = (Map) obj;
+ Map componentsMap = container.lookupMap("org.richfaces.templatecompiler.elements.ElementsFactory");
- StringBuffer ret = new StringBuffer("{");
- boolean first = true;
- for (Iterator iter = map.keySet().iterator(); iter.hasNext();) {
- Object key = (Object) iter.next();
- if (!first) {
- ret.append(',');
- }
- ret.append(key);
- ret.append(":");
- ret.append(toLog(map.get(key)));
- first = false;
- }
- return ret.append("}\n").toString();
- } else if (obj instanceof Number || obj instanceof Boolean) {
- // numbers and boolean put as-is, without conversion
- return obj.toString();
- } else if (obj instanceof String) {
- // all other put as encoded strings.
- StringBuffer ret = new StringBuffer();
- addEncodedString(ret, obj);
- return ret.append("\n").toString();
- }
- // All other objects threaded as Java Beans.
- try {
- StringBuffer ret = new StringBuffer("{");
- PropertyDescriptor[] propertyDescriptors = Introspector
- .getBeanInfo(obj.getClass()).getPropertyDescriptors();
- boolean first = true;
- for (int i = 0; i < propertyDescriptors.length; i++) {
- PropertyDescriptor propertyDescriptor = propertyDescriptors[i];
- String key = propertyDescriptor.getName();
- if (!"class".equals(key)
- && propertyDescriptor.getReadMethod() != null) {
- if (!first) {
- ret.append(",\n\t");
- }
- addEncodedString(ret, key);
- ret.append(":");
- try {
- Object value = propertyDescriptor.getReadMethod()
- .invoke(obj, new Object[] {});
- propertyDescriptor.getReadMethod();
- ret.append(String.valueOf(value));
- } catch (InvocationTargetException e) {
- ret.append("null");
- }// ret.append(toLog(PropertyUtils.getProperty(obj, key)));
- first = false;
- }
- }
- return ret.append("}\n").toString();
- } catch (Exception e) {
- throw new MojoExecutionException(
- "Error in conversion Java Object to String", e);
- }
- }
+ for (Iterator iter = componentsMap.entrySet().iterator(); iter.hasNext(); ) {
+ Map.Entry element = (Map.Entry) iter.next();
- public void addEncodedString(StringBuffer buff, Object obj) {
- buff.append("'");
- buff.append(obj);
- buff.append("'");
+ System.out.println(element.getKey() + ":" + element.getValue().getClass().getName());
+ }
+ } catch (ComponentLookupException e) {
+ throw new MojoExecutionException("Error lookup ElementFactory components");
+ }
- }
+ Parent parentModel = project.getModel().getParent();
+ if (null != parentModel) {
+ String relativePath = parentModel.getRelativePath();
+ File parentPom = new File(project.getFile().getParentFile(), relativePath);
+
+ if (parentPom.isDirectory()) {
+ parentPom = new File(parentPom, "pom.xml");
+ }
+
+ if (parentPom.exists()) {
+ try {
+ parentProject = mavenProjectBuilder.build(parentPom, localRepository, null);
+ } catch (ProjectBuildingException e) {
+ throw new MojoExecutionException("Error get parent project for a components library", e);
+ }
+ } else {
+ throw new MojoFailureException("Parent project pom file " + parentPom.getAbsolutePath()
+ + " is not found for a components library");
+ }
+ } else {
+ throw new MojoFailureException("Components library project must have parent pom with components modules");
+ }
+
+ getLog().info("Parent Project object :\n" + toLog(parentProject) + "\n");
+ getLog().info("Project object :\n" + toLog(project) + "\n");
+ getLog().info("Project object Model :\n" + toLog(project.getModel()) + "\n");
+ getLog().info("Project object Parent Model :\n" + toLog(project.getModel().getParent()) + "\n");
+ getLog().info("Executed Project object :\n" + toLog(executedProject) + "\n");
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable#contextualize(org.codehaus.plexus.context.Context)
+ */
+ public void contextualize(Context context) throws ContextException {
+ this.container = (PlexusContainer) context.get(PlexusConstants.PLEXUS_KEY);
+ }
+
+ private void logBean(Object bean) {
+ StringBuffer content = new StringBuffer();
+ }
+
+ /**
+ * Convert any Java Object to JavaScript representation ( as possible ).
+ *
+ * @param obj
+ * @return
+ * @throws MojoExecutionException
+ */
+ public String toLog(Object obj) throws MojoExecutionException {
+ if (null == obj) {
+ return "null";
+ } else if (obj.getClass().isArray()) {
+ StringBuffer ret = new StringBuffer("[");
+ boolean first = true;
+
+ for (int i = 0; i < Array.getLength(obj); i++) {
+ Object element = Array.get(obj, i);
+
+ if (!first) {
+ ret.append(',');
+ }
+
+ ret.append(toLog(element));
+ first = false;
+ }
+
+ return ret.append("]\n").toString();
+ } else if (obj instanceof Collection) {
+
+ // Collections put as JavaScript array.
+ Collection collection = (Collection) obj;
+ StringBuffer ret = new StringBuffer("[");
+ boolean first = true;
+
+ for (Iterator iter = collection.iterator(); iter.hasNext(); ) {
+ Object element = iter.next();
+
+ if (!first) {
+ ret.append(',');
+ }
+
+ ret.append(toLog(element));
+ first = false;
+ }
+
+ return ret.append("]\n").toString();
+ } else if (obj instanceof Map) {
+
+ // Maps put as JavaScript hash.
+ Map map = (Map) obj;
+ StringBuffer ret = new StringBuffer("{");
+ boolean first = true;
+
+ for (Iterator iter = map.keySet().iterator(); iter.hasNext(); ) {
+ Object key = (Object) iter.next();
+
+ if (!first) {
+ ret.append(',');
+ }
+
+ ret.append(key);
+ ret.append(":");
+ ret.append(toLog(map.get(key)));
+ first = false;
+ }
+
+ return ret.append("}\n").toString();
+ } else if (obj instanceof Number || obj instanceof Boolean) {
+
+ // numbers and boolean put as-is, without conversion
+ return obj.toString();
+ } else if (obj instanceof String) {
+
+ // all other put as encoded strings.
+ StringBuffer ret = new StringBuffer();
+
+ addEncodedString(ret, obj);
+
+ return ret.append("\n").toString();
+ }
+
+ // All other objects threaded as Java Beans.
+ try {
+ StringBuffer ret = new StringBuffer("{");
+ PropertyDescriptor[] propertyDescriptors =
+ Introspector.getBeanInfo(obj.getClass()).getPropertyDescriptors();
+ boolean first = true;
+
+ for (int i = 0; i < propertyDescriptors.length; i++) {
+ PropertyDescriptor propertyDescriptor = propertyDescriptors[i];
+ String key = propertyDescriptor.getName();
+
+ if (!"class".equals(key) && propertyDescriptor.getReadMethod() != null) {
+ if (!first) {
+ ret.append(",\n\t");
+ }
+
+ addEncodedString(ret, key);
+ ret.append(":");
+
+ try {
+ Object value = propertyDescriptor.getReadMethod().invoke(obj, new Object[] {});
+
+ propertyDescriptor.getReadMethod();
+ ret.append(String.valueOf(value));
+ } catch (InvocationTargetException e) {
+ ret.append("null");
+ } // ret.append(toLog(PropertyUtils.getProperty(obj, key)));
+
+ first = false;
+ }
+ }
+
+ return ret.append("}\n").toString();
+ } catch (Exception e) {
+ throw new MojoExecutionException("Error in conversion Java Object to String", e);
+ }
+ }
+
+ public void addEncodedString(StringBuffer buff, Object obj) {
+ buff.append("'");
+ buff.append(obj);
+ buff.append("'");
+ }
}
Modified: root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/CompileTemplatesMojo.java
===================================================================
--- root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/CompileTemplatesMojo.java 2009-11-01 16:27:54 UTC (rev 15791)
+++ root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/CompileTemplatesMojo.java 2009-11-01 16:28:50 UTC (rev 15792)
@@ -19,16 +19,20 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.builder.mojo;
import java.io.File;
import java.io.FileInputStream;
import java.io.PrintWriter;
+
import java.util.HashSet;
import java.util.Set;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
+
import org.richfaces.builder.model.JavaClass;
import org.richfaces.builder.render.JavaClassRenderer;
import org.richfaces.builder.templates.TemplateReader;
@@ -39,86 +43,80 @@
*/
public class CompileTemplatesMojo extends AbstractCDKMojo {
-
- /**
- * sourceFileIncludes
- * @parameter
- */
- protected String[] templateFileIncludes = {"**/*.template.xml"};
-
- /**
- * sourceFileExcludes
- * @parameter
- */
- protected String[] templatesFileExcludes = null;
-
- /**
- * @param templatesDirectory the templatesDirectory to set
- */
- protected void setTemplatesDirectory(File templatesDirectory) {
- this.templatesDirectory = templatesDirectory;
- }
-
- /**
- * @param templateFileIncludes the templateFileIncludes to set
- */
- public void setTemplateFileIncludes(String[] templateFileIncludes) {
- this.templateFileIncludes = templateFileIncludes;
- }
-
- /**
- * @param templatesFileExcludes the templatesFileExcludes to set
- */
- public void setTemplatesFileExcludes(String[] templatesFileExcludes) {
- this.templatesFileExcludes = templatesFileExcludes;
- }
-
- protected Iterable<File> findTemplateFiles() throws MojoExecutionException {
- Set<File> sourceFiles = new HashSet<File>();
- if (templatesDirectory.exists() && templatesDirectory.isDirectory()) {
- for (String fileName : doScan(templateFileIncludes, templatesFileExcludes, templatesDirectory)) {
- sourceFiles.add(new File(templatesDirectory, fileName));
- }
- }
-
- return sourceFiles;
- }
-
- protected void compileTemplates() throws MojoExecutionException, MojoFailureException {
- try {
- Iterable<File> templates = findTemplateFiles();
- for (File file : templates) {
- JavaClass javaClass = TemplateReader.parse(new FileInputStream(file));
-
- String fullName = javaClass.getFullName();
-
- File outFile = new File(outputJavaDirectory,
- fullName.replace('.', '/') + ".java");
-
- if (outFile.exists()) {
- outFile.delete();
- }
+ /**
+ * sourceFileIncludes
+ * @parameter
+ */
+ protected String[] templateFileIncludes = {"**/*.template.xml"};
- outFile.getParentFile().mkdirs();
-
- new JavaClassRenderer().render(javaClass, new PrintWriter(outFile));
- }
- } catch (Exception e) {
- throw new MojoExecutionException(e.getMessage(), e);
- }
- }
-
- @Override
- public void execute() throws MojoExecutionException, MojoFailureException {
- outputJavaDirectory.mkdirs();
- outputResourcesDirectory.mkdirs();
- outputTestsDirectory.mkdirs();
-
- project.addCompileSourceRoot(outputJavaDirectory.getAbsolutePath());
- project.addCompileSourceRoot(outputResourcesDirectory.getAbsolutePath());
- project.addTestCompileSourceRoot(outputTestsDirectory.getAbsolutePath());
-
- compileTemplates();
- }
+ /**
+ * sourceFileExcludes
+ * @parameter
+ */
+ protected String[] templatesFileExcludes = null;
+ /**
+ * @param templatesDirectory the templatesDirectory to set
+ */
+ protected void setTemplatesDirectory(File templatesDirectory) {
+ this.templatesDirectory = templatesDirectory;
+ }
+
+ /**
+ * @param templateFileIncludes the templateFileIncludes to set
+ */
+ public void setTemplateFileIncludes(String[] templateFileIncludes) {
+ this.templateFileIncludes = templateFileIncludes;
+ }
+
+ /**
+ * @param templatesFileExcludes the templatesFileExcludes to set
+ */
+ public void setTemplatesFileExcludes(String[] templatesFileExcludes) {
+ this.templatesFileExcludes = templatesFileExcludes;
+ }
+
+ protected Iterable<File> findTemplateFiles() throws MojoExecutionException {
+ Set<File> sourceFiles = new HashSet<File>();
+
+ if (templatesDirectory.exists() && templatesDirectory.isDirectory()) {
+ for (String fileName : doScan(templateFileIncludes, templatesFileExcludes, templatesDirectory)) {
+ sourceFiles.add(new File(templatesDirectory, fileName));
+ }
+ }
+
+ return sourceFiles;
+ }
+
+ protected void compileTemplates() throws MojoExecutionException, MojoFailureException {
+ try {
+ Iterable<File> templates = findTemplateFiles();
+
+ for (File file : templates) {
+ JavaClass javaClass = TemplateReader.parse(new FileInputStream(file));
+ String fullName = javaClass.getFullName();
+ File outFile = new File(outputJavaDirectory, fullName.replace('.', '/') + ".java");
+
+ if (outFile.exists()) {
+ outFile.delete();
+ }
+
+ outFile.getParentFile().mkdirs();
+ new JavaClassRenderer().render(javaClass, new PrintWriter(outFile));
+ }
+ } catch (Exception e) {
+ throw new MojoExecutionException(e.getMessage(), e);
+ }
+ }
+
+ @Override
+ public void execute() throws MojoExecutionException, MojoFailureException {
+ outputJavaDirectory.mkdirs();
+ outputResourcesDirectory.mkdirs();
+ outputTestsDirectory.mkdirs();
+ project.addCompileSourceRoot(outputJavaDirectory.getAbsolutePath());
+ project.addCompileSourceRoot(outputResourcesDirectory.getAbsolutePath());
+ project.addTestCompileSourceRoot(outputTestsDirectory.getAbsolutePath());
+ compileTemplates();
+ }
}
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-11-01 16:27:54 UTC (rev 15791)
+++ root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/GenerateMojo.java 2009-11-01 16:28:50 UTC (rev 15792)
@@ -21,408 +21,416 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.builder.mojo;
-import java.io.File;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.Map.Entry;
-
-import org.apache.maven.artifact.DependencyResolutionRequiredException;
import org.apache.maven.model.FileSet;
import org.apache.maven.model.Resource;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.project.MavenProject;
+
import org.codehaus.plexus.util.DirectoryScanner;
+
import org.richfaces.builder.maven.MavenLogger;
-import org.richfaces.cdk.CdkContextBase;
-import org.richfaces.cdk.CdkException;
-import org.richfaces.cdk.CdkWorker;
-import org.richfaces.cdk.LibraryBuilder;
-import org.richfaces.cdk.LoggerFactory;
-import org.richfaces.cdk.ModelValidator;
-import org.richfaces.cdk.NamingConventions;
-import org.richfaces.cdk.RichFacesConventions;
-import org.richfaces.cdk.StandardOutputFolders;
-import org.richfaces.cdk.StandardOutputs;
-import org.richfaces.cdk.StandardSources;
-import org.richfaces.cdk.ValidatorImpl;
+import org.richfaces.cdk.*;
import org.richfaces.cdk.model.ComponentLibrary;
+import java.io.File;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+
+import java.util.*;
+import java.util.Map.Entry;
+
/**
* <p class="changed_added_4_0">
* </p>
- *
+ *
* @author asmirnov(a)exadel.com
- *
+ *
* @goal generate
* @phase generate-sources
*/
public class GenerateMojo extends AbstractMojo {
+ private static final String[] JAVA_INCLUDES = new String[] {"**/*.java"};
+ private static final String MAIN_CONFIG = "src/main/config";
+ private static final String MAIN_TEMPLATES = "src/main/templates";
+ private static final String[] STRINGS_ARRAY = new String[0];
+ private static final String XML_INCLUDES = "**/*.xml";
- private static final String MAIN_CONFIG = "src/main/config";
+ /**
+ * Project classpath.
+ *
+ * @parameter expression="${project.compileClasspathElements}"
+ * @required
+ * @readonly
+ */
+ protected List<String> classpathElements;
- private static final String XML_INCLUDES = "**/*.xml";
+ /**
+ * The source directories containing the sources to be compiled.
+ *
+ * @parameter expression="${project.compileSourceRoots}"
+ * @required
+ * @readonly
+ */
+ protected List<String> compileSourceRoots;
- private static final String[] JAVA_INCLUDES = new String[] { "**/*.java" };
+ /**
+ * The list of JSF configuration files that will be processed by CDK.
+ * By default, CDK looks for all files in the <code>src/main/config</code> folder
+ * with "xml" extension.
+ * @parameter
+ */
+ protected FileSet[] facesConfigs;
- private static final String[] STRINGS_ARRAY = new String[0];
+ /**
+ * @parameter
+ */
+ protected Map<String, String> options;
- private static final String MAIN_TEMPLATES = "src/main/templates";
+ /**
+ * The directory for compiled classes.
+ *
+ * @parameter expression="${project.build.outputDirectory}"
+ * @required
+ * @readonly
+ */
+ protected File outputDirectory;
- /**
- * Top maven project.
- *
- * @parameter expression="${project}"
- * @readonly
- */
- protected MavenProject project;
+ /**
+ * Directory where the output Java Files will be located.
+ *
+ * @parameter expression="${project.build.directory}/cdk-generated/main/java"
+ */
+ protected File outputJavaDirectory;
- /**
- * List of filename patterns that will be included to process by annotations processor.
- * By default, all *.java files will be processed.
- * @parameter
- */
- protected String[] sourceIncludes;
+ /**
+ * Directory where the output Java Files will be located.
+ *
+ * @parameter
+ * expression="${project.build.directory}/cdk-generated/main/resources"
+ */
+ protected File outputResourcesDirectory;
- /**
- * List of filename patterns that will be excluded from process by annotations processor.
- * By default, all *.java files will be processed.
- * @parameter
- */
- protected String[] sourceExcludes;
+ /**
+ * @parameter expression="${project.build.directory}/cdk-generated/test/java"
+ */
+ protected File outputTestDirectory;
- /**
- * The list of JSF configuration files that will be processed by CDK.
- * By default, CDK looks for all files in the <code>src/main/config</code> folder
- * with "xml" extension.
- * @parameter
- */
- protected FileSet[] facesConfigs;
+ /**
+ * Directory where the output Java Files will be located.
+ *
+ * @parameter
+ * expression="${project.build.directory}/cdk-generated/test/resources"
+ */
+ protected File outputTestResourcesDirectory;
- /**
- * The list of Renderer template files that will be processed by CDK.
- * By default, CDK looks for all files in the <code>src/main/templates</code> folder
- * with "xml" extension.
- * @parameter
- */
- protected FileSet[] templates;
+ /**
+ * Top maven project.
+ *
+ * @parameter expression="${project}"
+ * @readonly
+ */
+ protected MavenProject project;
- /**
- * Directory where the output Java Files will be located.
- *
- * @parameter expression="${project.build.directory}/cdk-generated/main/java"
- */
- protected File outputJavaDirectory;
+ /**
+ * List of filename patterns that will be excluded from process by annotations processor.
+ * By default, all *.java files will be processed.
+ * @parameter
+ */
+ protected String[] sourceExcludes;
- /**
- * @parameter expression="${project.build.directory}/cdk-generated/test/java"
- */
- protected File outputTestDirectory;
+ /**
+ * List of filename patterns that will be included to process by annotations processor.
+ * By default, all *.java files will be processed.
+ * @parameter
+ */
+ protected String[] sourceIncludes;
- /**
- * Directory where the output Java Files will be located.
- *
- * @parameter
- * expression="${project.build.directory}/cdk-generated/main/resources"
- */
- protected File outputResourcesDirectory;
+ /**
+ * The list of Renderer template files that will be processed by CDK.
+ * By default, CDK looks for all files in the <code>src/main/templates</code> folder
+ * with "xml" extension.
+ * @parameter
+ */
+ protected FileSet[] templates;
- /**
- * Directory where the output Java Files will be located.
- *
- * @parameter
- * expression="${project.build.directory}/cdk-generated/test/resources"
- */
- protected File outputTestResourcesDirectory;
- /**
- * The source directories containing the sources to be compiled.
- *
- * @parameter expression="${project.compileSourceRoots}"
- * @required
- * @readonly
- */
- protected List<String> compileSourceRoots;
- /**
- * Project classpath.
- *
- * @parameter expression="${project.compileClasspathElements}"
- * @required
- * @readonly
- */
- protected List<String> classpathElements;
- /**
- * The directory for compiled classes.
- *
- * @parameter expression="${project.build.outputDirectory}"
- * @required
- * @readonly
- */
- protected File outputDirectory;
+ /**
+ * @parameter
+ */
+ protected Map<String, String> workers;
- /**
- * @parameter
- */
- protected Map<String, String> workers;
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.maven.plugin.Mojo#execute()
+ */
+ @Override
+ public void execute() throws MojoExecutionException, MojoFailureException {
- /**
- * @parameter
- */
- protected Map<String, String> options;
+ // Setup logger.
+ LoggerFactory.setLogger(new MavenLogger(getLog()));
- /*
- * (non-Javadoc)
- *
- * @see org.apache.maven.plugin.Mojo#execute()
- */
- @Override
- public void execute() throws MojoExecutionException, MojoFailureException {
- // Setup logger.
- LoggerFactory.setLogger(new MavenLogger(getLog()));
- CdkContextBase context = new CdkContextBase(this
- .createProjectClassLoader(project));
- // Set source folders.
- 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);
- // Non-java sources.
- context.addSources(StandardSources.JAVA_SOURCES, findJavaFiles());
- context.addSources(StandardSources.RENDERER_TEMPLATES,
- findTemplateFiles());
- context.addSources(StandardSources.FACES_CONFIGS,
- findFacesConfigFiles());
- // Setup output folders.
- setOutput(context, outputJavaDirectory, StandardOutputFolders.JAVA_CLASSES);
- setOutput(context, outputResourcesDirectory, StandardOutputFolders.RESOURCES);
- setOutput(context, outputTestDirectory, StandardOutputFolders.TEST_JAVA_CLASSES);
- setOutput(context, outputTestResourcesDirectory, StandardOutputFolders.TEST_RESOURCES);
- // configure CDK workers.
- boolean namingConventionsConfigured = false;
- boolean validatorConfigured = false;
- if (null != workers) {
- for (Entry<String, String> workerEntry : workers.entrySet()) {
- try {
- Class<? extends CdkWorker> workerClass = Class.forName(
- workerEntry.getKey()).asSubclass(CdkWorker.class);
- Class<? extends CdkWorker> workerImplementationClass = Class
- .forName(workerEntry.getValue()).asSubclass(
- CdkWorker.class);
- CdkWorker workerInstance = workerImplementationClass
- .newInstance();
- workerInstance.init(context);
- context.addWorker(workerClass, workerInstance);
- if (NamingConventions.class.equals(workerClass)) {
- namingConventionsConfigured = true;
- }
- if (ModelValidator.class.equals(workerClass)) {
- validatorConfigured = true;
- }
- } catch (ClassNotFoundException e) {
- throw new MojoFailureException("Worker class not found", e);
- } catch (InstantiationException e) {
- throw new MojoFailureException(
- "Worker instance can't be created", e);
- } catch (IllegalAccessException e) {
- throw new MojoFailureException(
- "Worker instance can't be created", e);
- } catch (CdkException e) {
- throw new MojoFailureException(
- "Worker initialization error", e);
- }
- }
+ CdkContextBase context = new CdkContextBase(this.createProjectClassLoader(project));
- }
- // Set default naming conventions if it was not configured.
- if (namingConventionsConfigured) {
- RichFacesConventions facesConventions = new RichFacesConventions();
- try {
- facesConventions.init(context);
- } catch (CdkException e) {
- throw new MojoFailureException(
- "Naming conventions initialization error", e);
- }
- context.addWorker(NamingConventions.class, facesConventions);
- }
- // Set default model validator if it was not configured.
- if (validatorConfigured) {
- ValidatorImpl validatorImpl = new ValidatorImpl();
- try {
- validatorImpl.init(context);
- } catch (CdkException e) {
- throw new MojoFailureException(
- "RichFaces Validator initialization error", e);
- }
- context.addWorker(ModelValidator.class, validatorImpl);
- }
- if (null != options) {
- // TODO make it type safe.
- context.setOptions(options);
- }
- try {
- // Build JSF library.
- LibraryBuilder builder = LibraryBuilder.createInstance(context);
- ComponentLibrary model = builder.buildModel();
- builder.generate(model);
- // Tell project about generated files.
- project.addCompileSourceRoot(outputJavaDirectory.getAbsolutePath());
- Resource resource = new Resource();
- resource.setDirectory(outputResourcesDirectory.getAbsolutePath());
- project.addResource(resource);
- project.addTestCompileSourceRoot(outputTestDirectory
- .getAbsolutePath());
- Resource testResource = new Resource();
- testResource.setDirectory(outputTestResourcesDirectory
- .getAbsolutePath());
- project.addTestResource(testResource);
- } catch (CdkException e) {
- throw new MojoExecutionException("CDK build error", e);
- }
- }
+ // Set source folders.
+ ArrayList<File> folders = new ArrayList<File>(compileSourceRoots.size());
- /**
- * <p class="changed_added_4_0">This utility method sets output directory for particular type.
- * I such directory does not exist, it is created.</p>
- * @param context
- * @param directory
- * @param type
- */
- private static void setOutput(CdkContextBase context, File directory,
- StandardOutputFolders type) {
- if (!directory.exists()) {
- directory.mkdirs();
- }
- context.setOutputFolder(type,
- directory);
- }
+ for (String sourceFolder : compileSourceRoots) {
+ File folder = new File(sourceFolder);
- /**
- * <p class="changed_added_4_0">This method checks library configuration and sets default values if necessary.</p>
- */
- protected void checkLibraryConfig() {
- // TODO Auto-generated method stub
+ if (folder.exists() && folder.isDirectory()) {
+ folders.add(folder);
+ }
+ }
- }
+ context.setSourceFolders(StandardSources.JAVA_SOURCES, folders);
- private Iterable<File> findTemplateFiles() throws MojoExecutionException {
- if (null == templates) {
- File defaultDirectory = new File(MAIN_TEMPLATES);
- if (defaultDirectory.exists() && defaultDirectory.isDirectory()) {
- FileSet fileSet = new FileSet();
- fileSet.setDirectory(MAIN_TEMPLATES);
- fileSet.addInclude(XML_INCLUDES);
- templates = new FileSet[] { fileSet };
- }
- }
- return doScan(templates);
+ // Non-java sources.
+ context.addSources(StandardSources.JAVA_SOURCES, findJavaFiles());
+ context.addSources(StandardSources.RENDERER_TEMPLATES, findTemplateFiles());
+ context.addSources(StandardSources.FACES_CONFIGS, findFacesConfigFiles());
- }
+ // Setup output folders.
+ setOutput(context, outputJavaDirectory, StandardOutputFolders.JAVA_CLASSES);
+ setOutput(context, outputResourcesDirectory, StandardOutputFolders.RESOURCES);
+ setOutput(context, outputTestDirectory, StandardOutputFolders.TEST_JAVA_CLASSES);
+ setOutput(context, outputTestResourcesDirectory, StandardOutputFolders.TEST_RESOURCES);
- private Iterable<File> findJavaFiles() throws MojoExecutionException {
- Set<File> javaSources = new HashSet<File>();
- String[] includes = null == sourceIncludes ? JAVA_INCLUDES
- : sourceIncludes;
- for (String compileRoot : compileSourceRoots) {
- File rootFolder = new File(compileRoot);
- String[] sources = doScan(includes, sourceExcludes, rootFolder);
- for (String src : sources) {
- javaSources.add(new File(rootFolder, src));
- }
- }
- return javaSources;
- }
+ // configure CDK workers.
+ boolean namingConventionsConfigured = false;
+ boolean validatorConfigured = false;
- private Iterable<File> findFacesConfigFiles() throws MojoExecutionException {
- if (null == facesConfigs) {
- File defaultDirectory = new File(MAIN_CONFIG);
- if (defaultDirectory.exists() && defaultDirectory.isDirectory()) {
- FileSet fileSet = new FileSet();
- fileSet.setDirectory(MAIN_CONFIG);
- fileSet.addInclude(XML_INCLUDES);
- facesConfigs = new FileSet[] { fileSet };
- }
- }
- return doScan(facesConfigs);
- }
+ if (null != workers) {
+ for (Entry<String, String> workerEntry : workers.entrySet()) {
+ try {
+ Class<? extends CdkWorker> workerClass =
+ Class.forName(workerEntry.getKey()).asSubclass(CdkWorker.class);
+ Class<? extends CdkWorker> workerImplementationClass =
+ Class.forName(workerEntry.getValue()).asSubclass(CdkWorker.class);
+ CdkWorker workerInstance = workerImplementationClass.newInstance();
- protected ClassLoader createProjectClassLoader(MavenProject project) {
- ClassLoader classLoader = null;
- try {
- String outputDirectory = project.getBuild().getOutputDirectory();
- URL[] urls = new URL[classpathElements.size() + 1];
- int i = 0;
- urls[i++] = new File(outputDirectory).toURI().toURL();
- for (Iterator<String> iter = classpathElements.iterator(); iter
- .hasNext();) {
- String element = iter.next();
- urls[i++] = new File(element).toURI().toURL();
- }
- classLoader = new URLClassLoader(urls);
- } catch (MalformedURLException e) {
- getLog().error("Bad URL in classpath", e);
- }
+ workerInstance.init(context);
+ context.addWorker(workerClass, workerInstance);
- return classLoader;
- }
+ if (NamingConventions.class.equals(workerClass)) {
+ namingConventionsConfigured = true;
+ }
- protected String[] doScan(String[] includes, String[] excludes,
- File rootFolder) throws MojoExecutionException {
- try {
- DirectoryScanner directoryScanner = new DirectoryScanner();
- directoryScanner.setFollowSymlinks(true);
- directoryScanner.setBasedir(rootFolder);
- directoryScanner.setExcludes(excludes);
- directoryScanner.setIncludes(includes);
- directoryScanner.addDefaultExcludes();
+ if (ModelValidator.class.equals(workerClass)) {
+ validatorConfigured = true;
+ }
+ } catch (ClassNotFoundException e) {
+ throw new MojoFailureException("Worker class not found", e);
+ } catch (InstantiationException e) {
+ throw new MojoFailureException("Worker instance can't be created", e);
+ } catch (IllegalAccessException e) {
+ throw new MojoFailureException("Worker instance can't be created", e);
+ } catch (CdkException e) {
+ throw new MojoFailureException("Worker initialization error", e);
+ }
+ }
+ }
- directoryScanner.scan();
+ // Set default naming conventions if it was not configured.
+ if (namingConventionsConfigured) {
+ RichFacesConventions facesConventions = new RichFacesConventions();
- return directoryScanner.getIncludedFiles();
- } catch (IllegalStateException e) {
- throw new MojoExecutionException("Error scanning source root: \'"
- + rootFolder + "\'", e);
- }
- }
+ try {
+ facesConventions.init(context);
+ } catch (CdkException e) {
+ throw new MojoFailureException("Naming conventions initialization error", e);
+ }
- /**
- * Skan Array of filesets for selected resources.
- *
- * @param fileset
- * @return
- * @throws MojoExecutionException
- */
- @SuppressWarnings("unchecked")
- protected Collection<File> doScan(FileSet[] filesets)
- throws MojoExecutionException {
- List<File> files = new ArrayList<File>();
- if (null != filesets) {
- for (FileSet fileSet : filesets) {
- String[] includes = (String[]) fileSet.getIncludes().toArray(
- STRINGS_ARRAY);
- String[] excludes = (String[]) fileSet.getExcludes().toArray(
- STRINGS_ARRAY);
- String[] scan = doScan(includes, excludes, new File(fileSet
- .getDirectory()));
- for (String filename : scan) {
- files.add(new File(filename));
- }
- }
+ context.addWorker(NamingConventions.class, facesConventions);
+ }
- }
- return files;
- }
+ // Set default model validator if it was not configured.
+ if (validatorConfigured) {
+ ValidatorImpl validatorImpl = new ValidatorImpl();
+
+ try {
+ validatorImpl.init(context);
+ } catch (CdkException e) {
+ throw new MojoFailureException("RichFaces Validator initialization error", e);
+ }
+
+ context.addWorker(ModelValidator.class, validatorImpl);
+ }
+
+ if (null != options) {
+
+ // TODO make it type safe.
+ context.setOptions(options);
+ }
+
+ try {
+
+ // Build JSF library.
+ LibraryBuilder builder = LibraryBuilder.createInstance(context);
+ ComponentLibrary model = builder.buildModel();
+
+ builder.generate(model);
+
+ // Tell project about generated files.
+ project.addCompileSourceRoot(outputJavaDirectory.getAbsolutePath());
+
+ Resource resource = new Resource();
+
+ resource.setDirectory(outputResourcesDirectory.getAbsolutePath());
+ project.addResource(resource);
+ project.addTestCompileSourceRoot(outputTestDirectory.getAbsolutePath());
+
+ Resource testResource = new Resource();
+
+ testResource.setDirectory(outputTestResourcesDirectory.getAbsolutePath());
+ project.addTestResource(testResource);
+ } catch (CdkException e) {
+ throw new MojoExecutionException("CDK build error", e);
+ }
+ }
+
+ /**
+ * <p class="changed_added_4_0">This utility method sets output directory for particular type.
+ * I such directory does not exist, it is created.</p>
+ * @param context
+ * @param directory
+ * @param type
+ */
+ private static void setOutput(CdkContextBase context, File directory, StandardOutputFolders type) {
+ if (!directory.exists()) {
+ directory.mkdirs();
+ }
+
+ context.setOutputFolder(type, directory);
+ }
+
+ /**
+ * <p class="changed_added_4_0">This method checks library configuration and sets default values if necessary.</p>
+ */
+ protected void checkLibraryConfig() {
+
+ // TODO Auto-generated method stub
+ }
+
+ private Iterable<File> findTemplateFiles() throws MojoExecutionException {
+ if (null == templates) {
+ File defaultDirectory = new File(MAIN_TEMPLATES);
+
+ if (defaultDirectory.exists() && defaultDirectory.isDirectory()) {
+ FileSet fileSet = new FileSet();
+
+ fileSet.setDirectory(MAIN_TEMPLATES);
+ fileSet.addInclude(XML_INCLUDES);
+ templates = new FileSet[] {fileSet};
+ }
+ }
+
+ return doScan(templates);
+ }
+
+ private Iterable<File> findJavaFiles() throws MojoExecutionException {
+ Set<File> javaSources = new HashSet<File>();
+ String[] includes = null == sourceIncludes ? JAVA_INCLUDES : sourceIncludes;
+
+ for (String compileRoot : compileSourceRoots) {
+ File rootFolder = new File(compileRoot);
+ String[] sources = doScan(includes, sourceExcludes, rootFolder);
+
+ for (String src : sources) {
+ javaSources.add(new File(rootFolder, src));
+ }
+ }
+
+ return javaSources;
+ }
+
+ private Iterable<File> findFacesConfigFiles() throws MojoExecutionException {
+ if (null == facesConfigs) {
+ File defaultDirectory = new File(MAIN_CONFIG);
+
+ if (defaultDirectory.exists() && defaultDirectory.isDirectory()) {
+ FileSet fileSet = new FileSet();
+
+ fileSet.setDirectory(MAIN_CONFIG);
+ fileSet.addInclude(XML_INCLUDES);
+ facesConfigs = new FileSet[] {fileSet};
+ }
+ }
+
+ return doScan(facesConfigs);
+ }
+
+ protected ClassLoader createProjectClassLoader(MavenProject project) {
+ ClassLoader classLoader = null;
+
+ try {
+ String outputDirectory = project.getBuild().getOutputDirectory();
+ URL[] urls = new URL[classpathElements.size() + 1];
+ int i = 0;
+
+ urls[i++] = new File(outputDirectory).toURI().toURL();
+
+ for (Iterator<String> iter = classpathElements.iterator(); iter.hasNext(); ) {
+ String element = iter.next();
+
+ urls[i++] = new File(element).toURI().toURL();
+ }
+
+ classLoader = new URLClassLoader(urls);
+ } catch (MalformedURLException e) {
+ getLog().error("Bad URL in classpath", e);
+ }
+
+ return classLoader;
+ }
+
+ protected String[] doScan(String[] includes, String[] excludes, File rootFolder) throws MojoExecutionException {
+ try {
+ DirectoryScanner directoryScanner = new DirectoryScanner();
+
+ directoryScanner.setFollowSymlinks(true);
+ directoryScanner.setBasedir(rootFolder);
+ directoryScanner.setExcludes(excludes);
+ directoryScanner.setIncludes(includes);
+ directoryScanner.addDefaultExcludes();
+ directoryScanner.scan();
+
+ return directoryScanner.getIncludedFiles();
+ } catch (IllegalStateException e) {
+ throw new MojoExecutionException("Error scanning source root: \'" + rootFolder + "\'", e);
+ }
+ }
+
+ /**
+ * Skan Array of filesets for selected resources.
+ *
+ * @param fileset
+ * @return
+ * @throws MojoExecutionException
+ */
+ @SuppressWarnings("unchecked")
+ protected Collection<File> doScan(FileSet[] filesets) throws MojoExecutionException {
+ List<File> files = new ArrayList<File>();
+
+ if (null != filesets) {
+ for (FileSet fileSet : filesets) {
+ String[] includes = (String[]) fileSet.getIncludes().toArray(STRINGS_ARRAY);
+ String[] excludes = (String[]) fileSet.getExcludes().toArray(STRINGS_ARRAY);
+ String[] scan = doScan(includes, excludes, new File(fileSet.getDirectory()));
+
+ for (String filename : scan) {
+ files.add(new File(filename));
+ }
+ }
+ }
+
+ return files;
+ }
}
Modified: root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/Library.java
===================================================================
--- root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/Library.java 2009-11-01 16:27:54 UTC (rev 15791)
+++ root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/Library.java 2009-11-01 16:28:50 UTC (rev 15792)
@@ -19,133 +19,125 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.builder.mojo;
/**
* @author shura
- *
+ *
*/
public class Library {
+ public static final String JSF10 = "1.0";
+ public static final String JSF11 = "1.1";
+ public static final String JSF12 = "1.2";
+ private String description;
+ private String jsfVersion;
+ private String prefix;
+ private Renderkit[] renderkits;
+ private Taglib taglib;
- public static final String JSF10 = "1.0";
+ /**
+ * @parameter
+ */
+ private Taglib[] taglibs;
- public static final String JSF11 = "1.1";
+ /**
+ * @return the prefix
+ */
+ public String getPrefix() {
+ return this.prefix;
+ }
- public static final String JSF12 = "1.2";
+ /**
+ * @param prefix
+ * the prefix to set
+ */
+ public void setPrefix(String prefix) {
+ this.prefix = prefix;
+ }
- private String _prefix;
+ /**
+ * @return the renderkits
+ */
+ public Renderkit[] getRenderkits() {
+ return this.renderkits;
+ }
- private String _description;
+ /**
+ * @param renderkits
+ * the renderkits to set
+ */
+ public void setRenderkits(Renderkit[] renderkits) {
+ this.renderkits = renderkits;
+ }
- private String _jsfVersion;
+ /**
+ * @return the taglib
+ */
+ public Taglib getTaglib() {
+ return this.taglib;
+ }
- private Taglib _taglib;
+ /**
+ * @param taglib
+ * the taglib to set
+ */
+ public void setTaglib(Taglib taglib) {
+ this.taglib = taglib;
+ }
- private Renderkit[] _renderkits;
+ /**
+ * @return the description
+ */
+ public String getDescription() {
+ return this.description;
+ }
- /**
- * @parameter
- */
- private Taglib[] taglibs;
+ /**
+ * @param description
+ * the description to set
+ */
+ public void setDescription(String description) {
+ this.description = description;
+ }
- /**
- * @return the prefix
- */
- public String getPrefix() {
- return this._prefix;
- }
+ /**
+ * @return the jsfVersion
+ */
+ public String getJsfVersion() {
+ return this.jsfVersion;
+ }
- /**
- * @param prefix
- * the prefix to set
- */
- public void setPrefix(String prefix) {
- this._prefix = prefix;
- }
+ /**
+ * @param jsfVersion
+ * the jsfVersion to set
+ */
+ public void setJsfVersion(String jsfVersion) {
+ if (JSF10.equals(jsfVersion) || JSF11.equals(jsfVersion) || JSF12.equals(jsfVersion)) {
+ this.jsfVersion = jsfVersion;
+ } else {
+ throw new IllegalArgumentException("Supported JSF versions is 1.0,1.1 and 1.2 only. ");
+ }
+ }
- /**
- * @return the renderkits
- */
- public Renderkit[] getRenderkits() {
- return this._renderkits;
- }
+ /**
+ * @return the taglibs
+ */
+ public Taglib[] getTaglibs() {
+ return taglibs;
+ }
- /**
- * @param renderkits
- * the renderkits to set
- */
- public void setRenderkits(Renderkit[] renderkits) {
- this._renderkits = renderkits;
- }
+ /**
+ * @param taglibs the taglibs to set
+ */
+ public void setTaglibs(Taglib[] taglibs) {
+ this.taglibs = taglibs;
+ }
- /**
- * @return the taglib
- */
- public Taglib getTaglib() {
- return this._taglib;
- }
-
- /**
- * @param taglib
- * the taglib to set
- */
- public void setTaglib(Taglib taglib) {
- this._taglib = taglib;
- }
-
- /**
- * @return the description
- */
- public String getDescription() {
- return this._description;
- }
-
- /**
- * @param description
- * the description to set
- */
- public void setDescription(String description) {
- this._description = description;
- }
-
- /**
- * @return the jsfVersion
- */
- public String getJsfVersion() {
- return this._jsfVersion;
- }
-
- /**
- * @param jsfVersion
- * the jsfVersion to set
- */
- public void setJsfVersion(String jsfVersion) {
- if (JSF10.equals(jsfVersion) || JSF11.equals(jsfVersion)
- || JSF12.equals(jsfVersion)) {
- this._jsfVersion = jsfVersion;
-
- } else {
- throw new IllegalArgumentException(
- "Supported JSF versions is 1.0,1.1 and 1.2 only. ");
- }
- }
-
- /**
- * @return the taglibs
- */
- public Taglib[] getTaglibs() {
- return taglibs;
- }
-
- /**
- * @param taglibs the taglibs to set
- */
- public void setTaglibs(Taglib[] taglibs) {
- this.taglibs = taglibs;
- }
-
- @Override
- public String toString() {
- return "JSF library "+getPrefix()+", desc: "+getDescription()+(null!=getTaglibs()?", libs: "+getTaglibs():"");
- }
+ @Override
+ public String toString() {
+ return "JSF library " + getPrefix() + ", desc: " + getDescription()
+ + (null != getTaglibs() ? ", libs: " + getTaglibs() : "");
+ }
}
Modified: root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/Renderkit.java
===================================================================
--- root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/Renderkit.java 2009-11-01 16:27:54 UTC (rev 15791)
+++ root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/Renderkit.java 2009-11-01 16:28:50 UTC (rev 15792)
@@ -19,6 +19,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.builder.mojo;
/**
@@ -26,98 +28,96 @@
*
*/
public class Renderkit {
-
- private String _name = "HTML_BASIC";
-
- private String _markup = "html";
-
- private String _classname;
-
- private String _package;
-
- private StringBuffer _content;
+ private String markup = "html";
+ private String name = "HTML_BASIC";
+ private String classPackage;
+ private String classname;
+ private StringBuffer content;
- /**
- * @return the classname
- */
- public String getClassname() {
- return this._classname;
- }
+ /**
+ * @return the classname
+ */
+ public String getClassname() {
+ return this.classname;
+ }
- /**
- * @param classname the classname to set
- */
- public void setClassname(String classname) {
- this._classname = classname;
- }
+ /**
+ * @param classname the classname to set
+ */
+ public void setClassname(String classname) {
+ this.classname = classname;
+ }
- /**
- * @return the markup
- */
- public String getMarkup() {
- return this._markup;
- }
+ /**
+ * @return the markup
+ */
+ public String getMarkup() {
+ return this.markup;
+ }
- /**
- * @param markup the markup to set
- */
- public void setMarkup(String markup) {
- this._markup = markup;
- }
+ /**
+ * @param markup the markup to set
+ */
+ public void setMarkup(String markup) {
+ this.markup = markup;
+ }
- /**
- * @return the name
- */
- public String getName() {
- return this._name;
- }
+ /**
+ * @return the name
+ */
+ public String getName() {
+ return this.name;
+ }
- /**
- * @param name the name to set
- */
- public void setName(String name) {
- this._name = name;
- }
+ /**
+ * @param name the name to set
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
- /**
- * @return the package
- */
- public String getPackage() {
- return this._package;
- }
+ /**
+ * @return the package
+ */
+ public String getPackage() {
+ return this.classPackage;
+ }
- /**
- * @param package1 the package to set
- */
- public void setPackage(String package1) {
- this._package = package1;
- }
+ /**
+ * @param package1 the package to set
+ */
+ public void setPackage(String package1) {
+ this.classPackage = package1;
+ }
- /**
- * @return the content
- */
- StringBuffer getContent() {
- return this._content;
- }
+ /**
+ * @return the content
+ */
+ StringBuffer getContent() {
+ return this.content;
+ }
- /**
- * @param content the content to set
- */
- void setContent(StringBuffer content) {
- this._content = content;
- }
-
- public String getFacesConfig(){
- if(null != _content){
- return _content.toString();
- }
- return "";
- }
- /* (non-Javadoc)
- * @see java.lang.Object#toString()
- */
- public String toString() {
- return "render-kit id ["+_name+"], class ["+_classname+"], content :"+_content;
- }
+ /**
+ * @param content the content to set
+ */
+ void setContent(StringBuffer content) {
+ this.content = content;
+ }
+ public String getFacesConfig() {
+ if (null != content) {
+ return content.toString();
+ }
+
+ return "";
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ return "render-kit id [" + name + "], class [" + classname + "], content :" + content;
+ }
}
Modified: root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/SkinInfo.java
===================================================================
--- root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/SkinInfo.java 2009-11-01 16:27:54 UTC (rev 15791)
+++ root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/SkinInfo.java 2009-11-01 16:28:50 UTC (rev 15792)
@@ -19,6 +19,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.builder.mojo;
import java.util.ArrayList;
@@ -30,76 +32,91 @@
* @author Maksim Kaszynski
*
*/
-public class SkinInfo implements Cloneable{
- private String shortName;
- private String packageName;
-
- private String baseSkin;
- private List<Resource> baseClassResources = new ArrayList<Resource>();
- private List<Resource> extClassResources = new ArrayList<Resource>();
- private Resource masterXcss;
- private Resource extendedXcss;
- private Resource propertyFile;
- private boolean useExt;
-
- public boolean isUseExt() {
- return useExt;
- }
- public void setUseExt(boolean useExt) {
- this.useExt = useExt;
- }
- public String getShortName() {
- return shortName;
- }
- public void setShortName(String shortName) {
- this.shortName = shortName;
- }
- public String getPackageName() {
- return packageName;
- }
- public void setPackageName(String packageName) {
- this.packageName = packageName;
- }
- public List<Resource> getBaseClassResources() {
- return baseClassResources;
- }
- public void setBaseClassResources(List<Resource> baseClassResources) {
- this.baseClassResources = baseClassResources;
- }
- public List<Resource> getExtClassResources() {
- return extClassResources;
- }
- public void setExtClassResources(List<Resource> extClassResources) {
- this.extClassResources = extClassResources;
- }
- public Resource getMasterXcss() {
- return masterXcss;
- }
- public void setMasterXcss(Resource masterXcss) {
- this.masterXcss = masterXcss;
- }
- public Resource getExtendedXcss() {
- return extendedXcss;
- }
- public void setExtendedXcss(Resource extendedXcss) {
- this.extendedXcss = extendedXcss;
- }
- public Resource getPropertyFile() {
- return propertyFile;
- }
- public void setPropertyFile(Resource propertyFile) {
- this.propertyFile = propertyFile;
- }
- @Override
- public Object clone() throws CloneNotSupportedException {
- return super.clone();
- }
- public String getBaseSkin() {
- return baseSkin;
- }
- public void setBaseSkin(String baseSkin) {
- this.baseSkin = baseSkin;
- }
+public class SkinInfo implements Cloneable {
+ private List<Resource> baseClassResources = new ArrayList<Resource>();
+ private List<Resource> extClassResources = new ArrayList<Resource>();
+ private String baseSkin;
+ private Resource extendedXcss;
+ private Resource masterXcss;
+ private String packageName;
+ private Resource propertyFile;
+ private String shortName;
+ private boolean useExt;
+ public boolean isUseExt() {
+ return useExt;
+ }
+ public void setUseExt(boolean useExt) {
+ this.useExt = useExt;
+ }
+
+ public String getShortName() {
+ return shortName;
+ }
+
+ public void setShortName(String shortName) {
+ this.shortName = shortName;
+ }
+
+ public String getPackageName() {
+ return packageName;
+ }
+
+ public void setPackageName(String packageName) {
+ this.packageName = packageName;
+ }
+
+ public List<Resource> getBaseClassResources() {
+ return baseClassResources;
+ }
+
+ public void setBaseClassResources(List<Resource> baseClassResources) {
+ this.baseClassResources = baseClassResources;
+ }
+
+ public List<Resource> getExtClassResources() {
+ return extClassResources;
+ }
+
+ public void setExtClassResources(List<Resource> extClassResources) {
+ this.extClassResources = extClassResources;
+ }
+
+ public Resource getMasterXcss() {
+ return masterXcss;
+ }
+
+ public void setMasterXcss(Resource masterXcss) {
+ this.masterXcss = masterXcss;
+ }
+
+ public Resource getExtendedXcss() {
+ return extendedXcss;
+ }
+
+ public void setExtendedXcss(Resource extendedXcss) {
+ this.extendedXcss = extendedXcss;
+ }
+
+ public Resource getPropertyFile() {
+ return propertyFile;
+ }
+
+ public void setPropertyFile(Resource propertyFile) {
+ this.propertyFile = propertyFile;
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ return super.clone();
+ }
+
+ public String getBaseSkin() {
+ return baseSkin;
+ }
+
+ public void setBaseSkin(String baseSkin) {
+ this.baseSkin = baseSkin;
+ }
}
Modified: root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/Taglib.java
===================================================================
--- root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/Taglib.java 2009-11-01 16:27:54 UTC (rev 15791)
+++ root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/Taglib.java 2009-11-01 16:28:50 UTC (rev 15792)
@@ -19,208 +19,198 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.richfaces.builder.mojo;
+package org.richfaces.builder.mojo;
+
/**
* @author shura
*
*/
public class Taglib {
-
- private String _taglib;
-
- private String _uri;
-
- private String _shortName;
-
- private String _listenerClass;
-
- private String _displayName;
+ private String excludeModules = null;
+ private String excludeTags = null;
+ private String includeModules = null;
+ private String includeTags = null;
+ private String tlibVersion = null;
+ private String validatorClass = null;
+ private String displayName;
+ private String jspVersion;
+ private String listenerClass;
+ private String shortName;
+ private String taglib;
+ private String uri;
- private String _tlibVersion = null;
-
- private String _jspVersion ;
-
- private String _validatorClass = null;
-
- private String _includeModules = null;
-
- private String _excludeModules = null;
-
- private String _includeTags = null;
-
- private String _excludeTags = null;
- /**
- * @return the displayName
- */
- public String getDisplayName() {
- return this._displayName;
- }
+ /**
+ * @return the displayName
+ */
+ public String getDisplayName() {
+ return this.displayName;
+ }
- /**
- * @param displayName the displayName to set
- */
- public void setDisplayName(String displayName) {
- this._displayName = displayName;
- }
+ /**
+ * @param displayName the displayName to set
+ */
+ public void setDisplayName(String displayName) {
+ this.displayName = displayName;
+ }
- /**
- * @return the listenerClass
- */
- public String getListenerClass() {
- return this._listenerClass;
- }
+ /**
+ * @return the listenerClass
+ */
+ public String getListenerClass() {
+ return this.listenerClass;
+ }
- /**
- * @param listenerClass the listenerClass to set
- */
- public void setListenerClass(String listenerClass) {
- this._listenerClass = listenerClass;
- }
+ /**
+ * @param listenerClass the listenerClass to set
+ */
+ public void setListenerClass(String listenerClass) {
+ this.listenerClass = listenerClass;
+ }
- /**
- * @return the shortName
- */
- public String getShortName() {
- return this._shortName;
- }
+ /**
+ * @return the shortName
+ */
+ public String getShortName() {
+ return this.shortName;
+ }
- /**
- * @param shortName the shortName to set
- */
- public void setShortName(String shortName) {
- this._shortName = shortName;
- }
+ /**
+ * @param shortName the shortName to set
+ */
+ public void setShortName(String shortName) {
+ this.shortName = shortName;
+ }
- /**
- * @return the taglib
- */
- public String getTaglib() {
- return this._taglib;
- }
+ /**
+ * @return the taglib
+ */
+ public String getTaglib() {
+ return this.taglib;
+ }
- /**
- * @param taglib the taglib to set
- */
- public void setTaglib(String taglib) {
- this._taglib = taglib;
- }
+ /**
+ * @param taglib the taglib to set
+ */
+ public void setTaglib(String taglib) {
+ this.taglib = taglib;
+ }
- /**
- * @return the uri
- */
- public String getUri() {
- return this._uri;
- }
+ /**
+ * @return the uri
+ */
+ public String getUri() {
+ return this.uri;
+ }
- /**
- * @param uri the uri to set
- */
- public void setUri(String uri) {
- this._uri = uri;
- }
+ /**
+ * @param uri the uri to set
+ */
+ public void setUri(String uri) {
+ this.uri = uri;
+ }
- /**
- * @return the jspVersion
- */
- public String getJspVersion() {
- return this._jspVersion;
- }
+ /**
+ * @return the jspVersion
+ */
+ public String getJspVersion() {
+ return this.jspVersion;
+ }
- /**
- * @param jspVersion the jspVersion to set
- */
- public void setJspVersion(String jspVersion) {
- this._jspVersion = jspVersion;
- }
+ /**
+ * @param jspVersion the jspVersion to set
+ */
+ public void setJspVersion(String jspVersion) {
+ this.jspVersion = jspVersion;
+ }
- /**
- * @return the tlibVersion
- */
- public String getTlibVersion() {
- return this._tlibVersion;
- }
+ /**
+ * @return the tlibVersion
+ */
+ public String getTlibVersion() {
+ return this.tlibVersion;
+ }
- /**
- * @param tlibVersion the tlibVersion to set
- */
- public void setTlibVersion(String tlibVersion) {
- this._tlibVersion = tlibVersion;
- }
+ /**
+ * @param tlibVersion the tlibVersion to set
+ */
+ public void setTlibVersion(String tlibVersion) {
+ this.tlibVersion = tlibVersion;
+ }
- /**
- * @return the validatorClass
- */
- public String getValidatorClass() {
- return this._validatorClass;
- }
+ /**
+ * @return the validatorClass
+ */
+ public String getValidatorClass() {
+ return this.validatorClass;
+ }
- /**
- * @param validatorClass the validatorClass to set
- */
- public void setValidatorClass(String validatorClass) {
- this._validatorClass = validatorClass;
- }
+ /**
+ * @param validatorClass the validatorClass to set
+ */
+ public void setValidatorClass(String validatorClass) {
+ this.validatorClass = validatorClass;
+ }
- /**
- * @return the includeModules
- */
- public String getIncludeModules() {
- return _includeModules;
- }
+ /**
+ * @return the includeModules
+ */
+ public String getIncludeModules() {
+ return includeModules;
+ }
- /**
- * @param includeModules the includeModules to set
- */
- public void setIncludeModules(String includeModules) {
- _includeModules = includeModules;
- }
+ /**
+ * @param includeModules the includeModules to set
+ */
+ public void setIncludeModules(String includeModules) {
+ this.includeModules = includeModules;
+ }
- /**
- * @return the excludeModules
- */
- public String getExcludeModules() {
- return _excludeModules;
- }
+ /**
+ * @return the excludeModules
+ */
+ public String getExcludeModules() {
+ return excludeModules;
+ }
- /**
- * @param excludeModules the excludeModules to set
- */
- public void setExcludeModules(String excludeModules) {
- _excludeModules = excludeModules;
- }
+ /**
+ * @param excludeModules the excludeModules to set
+ */
+ public void setExcludeModules(String excludeModules) {
+ this.excludeModules = excludeModules;
+ }
- /**
- * @return the includeTags
- */
- public String getIncludeTags() {
- return _includeTags;
- }
+ /**
+ * @return the includeTags
+ */
+ public String getIncludeTags() {
+ return includeTags;
+ }
- /**
- * @param includeTags the includeTags to set
- */
- public void setIncludeTags(String includeTags) {
- _includeTags = includeTags;
- }
+ /**
+ * @param includeTags the includeTags to set
+ */
+ public void setIncludeTags(String includeTags) {
+ this.includeTags = includeTags;
+ }
- /**
- * @return the excludeTags
- */
- public String getExcludeTags() {
- return _excludeTags;
- }
+ /**
+ * @return the excludeTags
+ */
+ public String getExcludeTags() {
+ return excludeTags;
+ }
- /**
- * @param excludeTags the excludeTags to set
- */
- public void setExcludeTags(String excludeTags) {
- _excludeTags = excludeTags;
- }
+ /**
+ * @param excludeTags the excludeTags to set
+ */
+ public void setExcludeTags(String excludeTags) {
+ this.excludeTags = excludeTags;
+ }
- @Override
- public String toString() {
- return "Lib: "+getShortName()+", URL: "+getUri();
- }
+ @Override
+ public String toString() {
+ return "Lib: " + getShortName() + ", URL: " + getUri();
+ }
}
15 years, 1 month
JBoss Rich Faces SVN: r15791 - in root/cdk/trunk/plugins/generator/src/test: java/org/richfaces/builder and 13 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: Alex.Kolonitsky
Date: 2009-11-01 11:27:54 -0500 (Sun, 01 Nov 2009)
New Revision: 15791
Added:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/builder/
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/builder/render/
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/builder/render/JavaClassRendererTest.java
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/LibraryBuilderTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/NamingConventionsTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/TemplateReaderTest.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/apt/TestAnnotation.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/TestAnnotation2.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/TestInterfaceAnnotation.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/TestMethodAnnotation.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/VirtualFileManagerTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/VirtualFileTest.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/generate/java/ComponentClassGeneratorTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/model/ClassDescriptionTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/model/ComponentLibraryTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/model/ModelBean.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/model/NameTest.java
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
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/FacesConfigTest.java
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/JAXBCopyTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/JaxbMarshalTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/JaxbTestBase.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/JaxbUnmarshalTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/Child.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/Id.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/Root.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlutils/XMLBodyMergeTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlutils/XMLBodySerializerTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlutils/XMLBodyTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlutils/XPathComparatorTest.java
root/cdk/trunk/plugins/generator/src/test/java/test/TestComponent.java
root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/apt/TestClass.java
root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/apt/TestInterface.java
root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/apt/TestSubClass.java
root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/test/component/AbstractTestComponent.java
root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/test/component/UITestCommand.java
Log:
Code style policy
https://jira.jboss.org/jira/browse/RFPL-195
Added: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/builder/render/JavaClassRendererTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/builder/render/JavaClassRendererTest.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/builder/render/JavaClassRendererTest.java 2009-11-01 16:27:54 UTC (rev 15791)
@@ -0,0 +1,86 @@
+/**
+ * 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.builder.render;
+
+import junit.framework.TestCase;
+
+import org.richfaces.builder.model.*;
+
+import javax.faces.component.UIComponentBase;
+
+import java.io.PrintWriter;
+
+/**
+ * @author akolonitsky
+ * @since Oct 30, 2009
+ */
+public class JavaClassRendererTest extends TestCase {
+ public void testMain() {
+ JavaClass javaClass = new JavaClass("MyClass", new JavaPackage("mypackage"));
+ JavaField javaField = new JavaField(int.class, "count");
+
+ javaField.setValue(0);
+ javaField.getModifiers().add(JavaModifier.PRIVATE);
+ javaClass.addField(javaField);
+
+ JavaField field = new JavaField(UIComponentBase.class, "component", "null");
+
+ field.addModifier(JavaModifier.PUBLIC);
+ field.addAnnotation(Deprecated.class);
+ javaClass.addField(field);
+ javaClass.addAnnotation(Deprecated.class);
+
+ JavaMethod accessor = new JavaMethod("getCount", int.class);
+
+ accessor.setMethodBody(new MethodBody(accessor) {
+ @Override
+ public String toCode() {
+ return "return count;";
+ }
+ });
+ accessor.getModifiers().add(JavaModifier.PUBLIC);
+ accessor.getModifiers().add(JavaModifier.FINAL);
+ javaClass.addMethod(accessor);
+
+ JavaMethod mutator = new JavaMethod("setCount", new Argument("i", int.class));
+
+ mutator.setMethodBody(new MethodBody(mutator) {
+ @Override
+ public String toCode() {
+ return "count = i;";
+ }
+ });
+ mutator.addAnnotation(Tezt.class);
+ mutator.addModifier(JavaModifier.PUBLIC);
+ mutator.addModifier(JavaModifier.FINAL);
+ javaClass.addMethod(mutator);
+
+ PrintWriter printWriter = new PrintWriter(System.out);
+
+ new JavaClassRenderer().render(javaClass, printWriter);
+ printWriter.flush();
+ }
+
+ private @interface Tezt {}
+}
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-11-01 16:21:55 UTC (rev 15790)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/CdkTestBase.java 2009-11-01 16:27:54 UTC (rev 15791)
@@ -21,14 +21,18 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
+
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
+
import java.util.Collections;
import java.util.logging.LogManager;
@@ -41,41 +45,42 @@
*
*/
public class CdkTestBase {
+ protected Iterable<File> testSourceDirectory;
- protected Iterable<File> testSourceDirectory;
+ @Before
+ public void setUpSourceDirectory() throws Exception {
+ testSourceDirectory = Collections.singleton(getJavaFile("test.source.properties").getParentFile());
- @Before
- public void setUpSourceDirectory() throws Exception {
- testSourceDirectory = Collections.singleton(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.
- }
- }
- }
- }
+ InputStream stream = this.getClass().getResourceAsStream("logging.properties");
- @After
- public void tearDownSourceDirectory() {
- testSourceDirectory = null;
- }
+ if (null != stream) {
+ try {
+ LogManager.getLogManager().readConfiguration(stream);
+ } catch (Exception e) {
- protected 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;
- }
+ // Ignore it.
+ } finally {
+ try {
+ stream.close();
+ } catch (IOException e) {
+ // Ignore it.
+ }
+ }
+ }
+ }
+
+ @After
+ public void tearDownSourceDirectory() {
+ testSourceDirectory = null;
+ }
+
+ protected 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/LibraryBuilderTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/LibraryBuilderTest.java 2009-11-01 16:21:55 UTC (rev 15790)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/LibraryBuilderTest.java 2009-11-01 16:27:54 UTC (rev 15791)
@@ -1,5 +1,6 @@
+
/**
- *
+ *
*/
package org.richfaces.cdk;
@@ -17,6 +18,7 @@
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
+
import org.richfaces.cdk.xmlutils.XMLBodyMergeTest;
import org.richfaces.cdk.xmlutils.XMLBodySerializerTest;
import org.richfaces.cdk.xmlutils.XMLBodyTest;
@@ -28,42 +30,35 @@
*/
@RunWith(Parameterized.class)
public class LibraryBuilderTest {
-
- private String param;
-
+ private String param;
- public LibraryBuilderTest(String param) {
- this.param=param;
- }
+ public LibraryBuilderTest(String param) {
+ this.param = param;
+ }
-
- /**
- * @throws java.lang.Exception
- */
- @Before
- public void setUp() throws Exception {
- }
+ /**
+ * @throws java.lang.Exception
+ */
+ @Before
+ public void setUp() throws Exception {}
- /**
- * @throws java.lang.Exception
- */
- @After
- public void tearDown() throws Exception {
- }
+ /**
+ * @throws java.lang.Exception
+ */
+ @After
+ public void tearDown() throws Exception {}
- /**
- * Test method for {@link org.richfaces.cdk.LibraryBuilder#createInstance()}.
- */
- @Test
- public void createInstance() {
-// assertEquals("Parameter match","Two", param);
- }
+ /**
+ * Test method for {@link org.richfaces.cdk.LibraryBuilder#createInstance()}.
+ */
+ @Test
+ public void createInstance() {
-
- @Parameters
- public static Collection<String[]> values(){
- return Arrays.asList(new String[]{"One"},new String[]{"Two"},new String[]{"Tree"});
- }
+// assertEquals("Parameter match","Two", param);
+ }
-
+ @Parameters
+ public static Collection<String[]> values() {
+ return Arrays.asList(new String[] {"One"}, new String[] {"Two"}, new String[] {"Tree"});
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/NamingConventionsTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/NamingConventionsTest.java 2009-11-01 16:21:55 UTC (rev 15790)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/NamingConventionsTest.java 2009-11-01 16:27:54 UTC (rev 15791)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk;
import static org.junit.Assert.*;
@@ -28,6 +30,7 @@
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+
import org.richfaces.cdk.model.InvalidNameException;
/**
@@ -36,79 +39,80 @@
*
*/
public class NamingConventionsTest {
-
- private static final String BASE="foo.bar";
- private RichFacesConventions conventions;
-
- @Before
- public void createConventions() {
- conventions = new RichFacesConventions();
- }
-
- @After
- public void destroyConventions(){
- conventions = null;
- }
+ private static final String BASE = "foo.bar";
+ private RichFacesConventions conventions;
- /**
- * Test method for {@link org.richfaces.cdk.RichFacesConventions#inferComponentType(java.lang.String, java.lang.String)}.
- * @throws Exception
- */
- @Test
- public void testInferComponentTypeExplicit() throws Exception {
- assertEquals("foo.bar.Test", conventions.inferComponentType("foo.bar.Test","foo.baz.UITest"));
- }
+ @Before
+ public void createConventions() {
+ conventions = new RichFacesConventions();
+ }
- /**
- * Test method for {@link org.richfaces.cdk.RichFacesConventions#inferComponentType(java.lang.String, java.lang.String)}.
- * @throws Exception
- */
- @Test
- public void testInferComponentTypeFromUIClass() throws Exception {
- assertEquals("foo.baz.Test", conventions.inferComponentType("","foo.baz.component.UITest"));
- }
+ @After
+ public void destroyConventions() {
+ conventions = null;
+ }
- /**
- * Test method for {@link org.richfaces.cdk.RichFacesConventions#inferComponentType(java.lang.String, java.lang.String)}.
- * @throws Exception
- */
- @Test
- public void testInferComponentTypeFromAbstractClass() throws Exception {
- assertEquals("foo.baz.Test", conventions.inferComponentType("","foo.baz.component.AbstractTest"));
- }
+ /**
+ * Test method for {@link org.richfaces.cdk.RichFacesConventions#inferComponentType(java.lang.String, java.lang.String)}.
+ * @throws Exception
+ */
+ @Test
+ public void testInferComponentTypeExplicit() throws Exception {
+ assertEquals("foo.bar.Test", conventions.inferComponentType("foo.bar.Test", "foo.baz.UITest"));
+ }
- /**
- * Test method for {@link org.richfaces.cdk.RichFacesConventions#inferComponentType(java.lang.String, java.lang.String)}.
- * @throws Exception
- */
- @Test
- public void testInferComponentTypeFromBaseClass() throws Exception {
- assertEquals("foo.baz.Test", conventions.inferComponentType("","foo.baz.component.TestBase"));
- }
+ /**
+ * Test method for {@link org.richfaces.cdk.RichFacesConventions#inferComponentType(java.lang.String, java.lang.String)}.
+ * @throws Exception
+ */
+ @Test
+ public void testInferComponentTypeFromUIClass() throws Exception {
+ assertEquals("foo.baz.Test", conventions.inferComponentType("", "foo.baz.component.UITest"));
+ }
- /**
- * Test method for {@link org.richfaces.cdk.RichFacesConventions#inferComponentType(java.lang.String, java.lang.String)}.
- * @throws Exception
- */
- @Test
- public void testInferComponentTypeFromMarkupClass() throws Exception {
- assertEquals("foo.baz.HtmlTest", conventions.inferComponentType("","foo.baz.component.html.HtmlTest"));
- }
+ /**
+ * Test method for {@link org.richfaces.cdk.RichFacesConventions#inferComponentType(java.lang.String, java.lang.String)}.
+ * @throws Exception
+ */
+ @Test
+ public void testInferComponentTypeFromAbstractClass() throws Exception {
+ assertEquals("foo.baz.Test", conventions.inferComponentType("", "foo.baz.component.AbstractTest"));
+ }
- /**
- * Test method for {@link org.richfaces.cdk.RichFacesConventions#inferUIComponentClass(java.lang.String, java.lang.String, java.lang.String, boolean)}.
- */
- @Test
- public void testInferUIComponentClassFromExplicit() throws Exception {
- assertEquals("foo.bar.UITest", conventions.inferUIComponentClass("foo.bar.Test", "foo.bar.UITest", "foo.bar.AbstractClass", true));
- }
+ /**
+ * Test method for {@link org.richfaces.cdk.RichFacesConventions#inferComponentType(java.lang.String, java.lang.String)}.
+ * @throws Exception
+ */
+ @Test
+ public void testInferComponentTypeFromBaseClass() throws Exception {
+ assertEquals("foo.baz.Test", conventions.inferComponentType("", "foo.baz.component.TestBase"));
+ }
- /**
- * Test method for {@link org.richfaces.cdk.RichFacesConventions#inferUIComponentClass(java.lang.String, java.lang.String, java.lang.String, boolean)}.
- */
- @Test
- public void testInferUIComponentClassFromType() throws Exception {
- assertEquals("foo.bar.component.UITest", conventions.inferUIComponentClass("foo.bar.Test", "", "foo.bar.AbstractClass", true));
- }
+ /**
+ * Test method for {@link org.richfaces.cdk.RichFacesConventions#inferComponentType(java.lang.String, java.lang.String)}.
+ * @throws Exception
+ */
+ @Test
+ public void testInferComponentTypeFromMarkupClass() throws Exception {
+ assertEquals("foo.baz.HtmlTest", conventions.inferComponentType("", "foo.baz.component.html.HtmlTest"));
+ }
+ /**
+ * Test method for {@link org.richfaces.cdk.RichFacesConventions#inferUIComponentClass(java.lang.String, java.lang.String, java.lang.String, boolean)}.
+ */
+ @Test
+ public void testInferUIComponentClassFromExplicit() throws Exception {
+ assertEquals("foo.bar.UITest",
+ conventions.inferUIComponentClass("foo.bar.Test", "foo.bar.UITest", "foo.bar.AbstractClass",
+ true));
+ }
+
+ /**
+ * Test method for {@link org.richfaces.cdk.RichFacesConventions#inferUIComponentClass(java.lang.String, java.lang.String, java.lang.String, boolean)}.
+ */
+ @Test
+ public void testInferUIComponentClassFromType() throws Exception {
+ assertEquals("foo.bar.component.UITest",
+ conventions.inferUIComponentClass("foo.bar.Test", "", "foo.bar.AbstractClass", true));
+ }
}
Modified: 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 2009-11-01 16:21:55 UTC (rev 15790)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/TemplateReaderTest.java 2009-11-01 16:27:54 UTC (rev 15791)
@@ -1,6 +1,5 @@
package org.richfaces.cdk;
-
import static org.junit.Assert.*;
import java.io.IOException;
@@ -9,100 +8,114 @@
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 ENCODE_BEGIN_METHOD = "encodeBegin";
+ private static final String ENCODE_CHILDREN_METHOD = "encodeChildren";
+ private static final String ENCODE_END_METHOD = "encodeEnd";
+ private static final String END_DIV_FRAGMENT = "responseWriter.endElement(\"div\");";
+ private static final String END_TABLE_FRAGMENT = "responseWriter.endElement(\"table\");";
+ private static final String FULL_NAME = "org.richfaces.renderkit.html.TabPanelRenderer";
+ private static final String IF_FRAGMENT = "if (";
+ private static final String PACKAGE = "org.richfaces.renderkit.html";
+ 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 SUPERCLASS = "javax.faces.render.Renderer";
+ private static final String TAB_PANEL_RENDERER = "TabPanelRenderer";
+ private static final String TEMPLATE_SIMPLE_XML = "template-simple.xml";
+ private static final String TEMPLATE_XML = "template.xml";
+ private static final String WRITE_ATTRIBBUTE_FRAGMENT =
+ "responseWriter.writeAttribute(\"id\", component.getClientId(context), \"id\");";
+ InputStream stream = null;
- 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();
- }
- }
+ @Before
+ public void create() {}
- @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;
- }
+ @After
+ public void destroy() {
+ try {
+ stream.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
- private boolean containMethod(JavaClass clazz, String name){
- for(JavaMethod method : clazz.getMethods()){
- if(method.getName().equals(name)){
- return true;
- }
- }
- return false;
- }
+ @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;
+ }
}
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-11-01 16:21:55 UTC (rev 15790)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/CdkProcessorTest.java 2009-11-01 16:27:54 UTC (rev 15791)
@@ -21,14 +21,20 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.apt;
import static org.easymock.EasyMock.*;
+
import static org.junit.Assert.*;
+
import static javax.lang.model.util.ElementFilter.*;
import java.io.File;
+
import java.net.URISyntaxException;
+
import java.util.Set;
import javax.annotation.processing.ProcessingEnvironment;
@@ -36,14 +42,18 @@
import javax.annotation.processing.RoundEnvironment;
import javax.annotation.processing.SupportedAnnotationTypes;
import javax.annotation.processing.SupportedSourceVersion;
+
import javax.lang.model.SourceVersion;
import javax.lang.model.element.TypeElement;
+
import javax.tools.JavaFileObject;
import javax.tools.SimpleJavaFileObject;
import org.easymock.Capture;
import org.easymock.CaptureType;
+
import org.junit.Test;
+
import org.richfaces.cdk.CdkContext;
import org.richfaces.cdk.CdkTestBase;
import org.richfaces.cdk.StandardOutputs;
@@ -61,229 +71,227 @@
/**
* <p class="changed_added_4_0">
* </p>
- *
+ *
* @author asmirnov(a)exadel.com
- *
+ *
*/
public class CdkProcessorTest extends CdkTestBase {
+ private static final String ANNOTATION2 = TestAnnotation2.class.getName();
+ private static final String CLASS_JAVA = "org/richfaces/cdk/apt/TestClass.java";
+ private static final String COMPONENT_CLASS_JAVA = "org/richfaces/cdk/test/component/AbstractTestComponent.java";
+ private static final String INTERFACE_JAVA = "org/richfaces/cdk/apt/TestInterface.java";
+ private static final String SUB_CLASS_JAVA = "org/richfaces/cdk/apt/TestSubClass.java";
+ private static final ImmutableSet<String> PROCESS_ANNOTATIONS = ImmutableSet.of(TestAnnotation.class.getName());
+ private ClassLoader testLoader;
- private static final String ANNOTATION2 = TestAnnotation2.class.getName();
+ /**
+ * Test method for
+ * {@link org.richfaces.cdk.apt.CdkProcessor#process(java.util.Set, javax.annotation.processing.RoundEnvironment)}
+ * .
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testProcess() throws Exception {
- private static abstract class TestProcessor extends CdkProcessor {
+ // Prepare Mock compilation context.
+ CdkContext cdkContext = createMock(CdkContext.class);
- protected ComponentLibrary library;
+ expect(cdkContext.getSourceFolders(StandardSources.JAVA_SOURCES)).andStubReturn(testSourceDirectory);
+ expect(cdkContext.getOutputFolder((OutputType) anyObject())).andStubReturn(null);
+ expect(cdkContext.getLoader()).andStubReturn(TestAnnotation.class.getClassLoader());
+ replay(cdkContext);
- protected int numOfComponents;
+ Processor processor = createMock(Processor.class);
- public TestProcessor(CdkContext context) {
- super(context);
- }
+ processor.init((ProcessingEnvironment) anyObject());
+ expect(processor.getSupportedOptions()).andReturn(ImmutableSet.<String>of());
- @Override
- public synchronized void init(ProcessingEnvironment processingEnv) {
- super.init(processingEnv);
- }
+ // processor.process(null,null);
+ Capture<Set<? extends TypeElement>> capturedTypes = new Capture<Set<? extends TypeElement>>();
- @Override
- public synchronized boolean isInitialized() {
- return super.isInitialized();
- }
+ expect(processor.process(capture(capturedTypes),
+ capture(new Capture<RoundEnvironment>()))).andReturn(true).times(2);
+ expect(processor.getSupportedAnnotationTypes()).andReturn(ImmutableSet.of(TestAnnotation.class.getName()));
+ expect(processor.getSupportedSourceVersion()).andReturn(SourceVersion.RELEASE_6);
+ replay(processor);
- @Override
- public Set<String> getSupportedAnnotationTypes() {
- // Process all annotations
- return ImmutableSet.of("*");
- }
+ AptBuilder compiler = new AptBuilder();
- }
+ compiler.init(cdkContext);
+ compiler.process(ImmutableList.of(getJavaFile(CLASS_JAVA)), processor);
+ verify(cdkContext, processor);
+ }
- private static final String INTERFACE_JAVA = "org/richfaces/cdk/apt/TestInterface.java";
- private static final String SUB_CLASS_JAVA = "org/richfaces/cdk/apt/TestSubClass.java";
- private static final String CLASS_JAVA = "org/richfaces/cdk/apt/TestClass.java";
- private static final ImmutableSet<String> PROCESS_ANNOTATIONS = ImmutableSet
- .of(TestAnnotation.class.getName());
- private static final String COMPONENT_CLASS_JAVA = "org/richfaces/cdk/test/component/AbstractTestComponent.java";
+ /**
+ * Test method for
+ * {@link org.richfaces.cdk.apt.CdkProcessor#process(java.util.Set, javax.annotation.processing.RoundEnvironment)}
+ * .
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testProcessSubClass() throws Exception {
- private ClassLoader testLoader;
+ // Prepare Mock compilation context.
+ CdkContext cdkContext = createMock(CdkContext.class);
- /**
- * Test method for
- * {@link org.richfaces.cdk.apt.CdkProcessor#process(java.util.Set, javax.annotation.processing.RoundEnvironment)}
- * .
- *
- * @throws Exception
- */
- @Test
- public void testProcess() throws Exception {
- // Prepare Mock compilation context.
- CdkContext cdkContext = createMock(CdkContext.class);
- expect(cdkContext.getSourceFolders(StandardSources.JAVA_SOURCES)).andStubReturn(testSourceDirectory);
- expect(cdkContext.getOutputFolder((OutputType) anyObject())).andStubReturn(null);
- expect(cdkContext.getLoader()).andStubReturn(
- TestAnnotation.class.getClassLoader());
- replay(cdkContext);
+ expect(cdkContext.getSourceFolders(StandardSources.JAVA_SOURCES)).andStubReturn(testSourceDirectory);
+ expect(cdkContext.getOutputFolder((OutputType) anyObject())).andStubReturn(null);
+ expect(cdkContext.getLoader()).andStubReturn(TestAnnotation2.class.getClassLoader());
+ replay(cdkContext);
- Processor processor = createMock(Processor.class);
- processor.init((ProcessingEnvironment) anyObject());
- expect(processor.getSupportedOptions()).andReturn(
- ImmutableSet.<String> of());
- // processor.process(null,null);
- Capture<Set<? extends TypeElement>> capturedTypes = new Capture<Set<? extends TypeElement>>();
- expect(
- processor.process(capture(capturedTypes),
- capture(new Capture<RoundEnvironment>()))).andReturn(
- true).times(2);
- expect(processor.getSupportedAnnotationTypes()).andReturn(
- ImmutableSet.of(TestAnnotation.class.getName()));
- expect(processor.getSupportedSourceVersion()).andReturn(
- SourceVersion.RELEASE_6);
- replay(processor);
- AptBuilder compiler = new AptBuilder();
- compiler.init(cdkContext);
- compiler.process(ImmutableList.of(getJavaFile(CLASS_JAVA)), processor);
- verify(cdkContext, processor);
- }
+ Processor processor = createMock(Processor.class);
- /**
- * Test method for
- * {@link org.richfaces.cdk.apt.CdkProcessor#process(java.util.Set, javax.annotation.processing.RoundEnvironment)}
- * .
- *
- * @throws Exception
- */
- @Test
- public void testProcessSubClass() throws Exception {
- // Prepare Mock compilation context.
- CdkContext cdkContext = createMock(CdkContext.class);
- expect(cdkContext.getSourceFolders(StandardSources.JAVA_SOURCES)).andStubReturn(testSourceDirectory);
- expect(cdkContext.getOutputFolder((OutputType) anyObject())).andStubReturn(null);
- expect(cdkContext.getLoader()).andStubReturn(
- TestAnnotation2.class.getClassLoader());
- replay(cdkContext);
+ processor.init((ProcessingEnvironment) anyObject());
+ expect(processor.getSupportedOptions()).andReturn(ImmutableSet.<String>of());
- Processor processor = createMock(Processor.class);
- processor.init((ProcessingEnvironment) anyObject());
- expect(processor.getSupportedOptions()).andReturn(
- ImmutableSet.<String> of());
- // processor.process(null,null);
- Capture<Set<? extends TypeElement>> capturedTypes = new Capture<Set<? extends TypeElement>>(
- CaptureType.FIRST);
- expect(
- processor.process(capture(capturedTypes),
- capture(new Capture<RoundEnvironment>()))).andReturn(
- true).times(2);
- expect(processor.getSupportedAnnotationTypes()).andReturn(
- ImmutableSet.of(TestAnnotation2.class.getName()));
- expect(processor.getSupportedSourceVersion()).andReturn(
- SourceVersion.RELEASE_6);
- replay(processor);
- AptBuilder compiler = new AptBuilder();
- compiler.init(cdkContext);
- compiler.process(ImmutableList.of(getJavaFile(SUB_CLASS_JAVA),
- getJavaFile(CLASS_JAVA)), processor);
- verify(cdkContext, processor);
- Set<? extends TypeElement> elements = capturedTypes.getValue();
- assertFalse(elements.isEmpty());
- assertEquals("TestAnnotation2", elements.iterator().next()
- .getSimpleName().toString());
- }
+ // processor.process(null,null);
+ Capture<Set<? extends TypeElement>> capturedTypes = new Capture<Set<? extends TypeElement>>(CaptureType.FIRST);
- /**
- * Test method for
- * {@link org.richfaces.cdk.apt.CdkProcessor#getClassesAnnotatedWith(RoundEnvironment, Class)}
- * .
- *
- * @throws Exception
- */
- @Test
- public void testGetClassesAnnotatedWith() throws Exception {
- // Prepare Mock compilation context.
- CdkContext cdkContext = createMock(CdkContext.class);
- expect(cdkContext.getSourceFolders(StandardSources.JAVA_SOURCES)).andStubReturn(testSourceDirectory);
- expect(cdkContext.getOutputFolder((OutputType) anyObject())).andStubReturn(null);
- expect(cdkContext.getLoader()).andStubReturn(
- TestAnnotation2.class.getClassLoader());
- replay(cdkContext);
- TestProcessor processor = new TestProcessor(cdkContext) {
- @Override
- public boolean process(Set<? extends TypeElement> annotations,
- RoundEnvironment roundEnv) {
- if (!roundEnv.processingOver()) {
- this.numOfComponents = getClassesAnnotatedWith(
- roundEnv, Component.class).size();
+ expect(processor.process(capture(capturedTypes),
+ capture(new Capture<RoundEnvironment>()))).andReturn(true).times(2);
+ expect(processor.getSupportedAnnotationTypes()).andReturn(ImmutableSet.of(TestAnnotation2.class.getName()));
+ expect(processor.getSupportedSourceVersion()).andReturn(SourceVersion.RELEASE_6);
+ replay(processor);
- }
- return true;
- }
- };
- // ComponentLibrary library = new
- // ComponentLibrary("org.richfaces.cdk.test");
- // processor.library = library;
- AptBuilder compiler = new AptBuilder();
- compiler.init(cdkContext);
- compiler.process(ImmutableList.of(getJavaFile(COMPONENT_CLASS_JAVA)),
- processor);
- verify(cdkContext);
- assertTrue(processor.isInitialized());
- assertEquals(1, processor.numOfComponents);
- }
+ AptBuilder compiler = new AptBuilder();
- /**
- * Test method for
- * {@link org.richfaces.cdk.apt.CdkProcessor#getClassesAnnotatedWith(RoundEnvironment, Class)}
- * .
- *
- * @throws Exception
- */
- @Test
- public void testGetPropertiesAnnotatedWith() throws Exception {
- // Prepare Mock compilation context.
- CdkContext cdkContext = createMock(CdkContext.class);
- expect(cdkContext.getSourceFolders(StandardSources.JAVA_SOURCES)).andStubReturn(testSourceDirectory);
- expect(cdkContext.getOutputFolder((OutputType) anyObject())).andStubReturn(null);
- expect(cdkContext.getLoader()).andStubReturn(
- TestAnnotation2.class.getClassLoader());
- replay(cdkContext);
- TestProcessor processor = new TestProcessor(cdkContext) {
- @Override
- public boolean process(Set<? extends TypeElement> annotations,
- RoundEnvironment roundEnv) {
- if (!roundEnv.processingOver()) {
- TypeElement typeElement = getClassesAnnotatedWith(
- roundEnv, Component.class).iterator().next();
- Set<BeanProperty> beanProperties = getBeanPropertiesAnnotatedWith(Attribute.class, typeElement);
- assertEquals(3, beanProperties.size());
- BeanProperty property = Iterables.get(beanProperties,2);
- assertEquals("foo", property.getName());
- assertEquals("int", property.getType().toString());
- assertNull(property.getDocComment());
-
- property = Iterables.get(beanProperties,1);
- assertEquals("testValue", property.getName());
- assertEquals("java.util.List<java.lang.String>", property.getType().toString());
- assertEquals(" Test Attribute\n", property.getDocComment());
-
- property = Iterables.get(beanProperties,0);
- assertEquals("barValue", property.getName());
- assertEquals("java.util.List<M>", property.getType().toString());
- assertEquals(" Bar Attribute\n", property.getDocComment());
-// assertEquals("<M>" ,property.getTypeParameters());
-
- numOfComponents++;
- }
- return true;
- }
- };
- // ComponentLibrary library = new
- // ComponentLibrary("org.richfaces.cdk.test");
- // processor.library = library;
- AptBuilder compiler = new AptBuilder();
- compiler.init(cdkContext);
- compiler.process(ImmutableList.of(getJavaFile(COMPONENT_CLASS_JAVA)),
- processor);
- verify(cdkContext);
- assertTrue(processor.isInitialized());
- assertEquals(1, processor.numOfComponents);
- }
+ compiler.init(cdkContext);
+ compiler.process(ImmutableList.of(getJavaFile(SUB_CLASS_JAVA), getJavaFile(CLASS_JAVA)), processor);
+ verify(cdkContext, processor);
+ Set<? extends TypeElement> elements = capturedTypes.getValue();
+
+ assertFalse(elements.isEmpty());
+ assertEquals("TestAnnotation2", elements.iterator().next().getSimpleName().toString());
+ }
+
+ /**
+ * Test method for
+ * {@link org.richfaces.cdk.apt.CdkProcessor#getClassesAnnotatedWith(RoundEnvironment, Class)}
+ * .
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testGetClassesAnnotatedWith() throws Exception {
+
+ // Prepare Mock compilation context.
+ CdkContext cdkContext = createMock(CdkContext.class);
+
+ expect(cdkContext.getSourceFolders(StandardSources.JAVA_SOURCES)).andStubReturn(testSourceDirectory);
+ expect(cdkContext.getOutputFolder((OutputType) anyObject())).andStubReturn(null);
+ expect(cdkContext.getLoader()).andStubReturn(TestAnnotation2.class.getClassLoader());
+ replay(cdkContext);
+
+ TestProcessor processor = new TestProcessor(cdkContext) {
+ @Override
+ public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
+ if (!roundEnv.processingOver()) {
+ this.numOfComponents = getClassesAnnotatedWith(roundEnv, Component.class).size();
+ }
+
+ return true;
+ }
+ };
+
+ // ComponentLibrary library = new
+ // ComponentLibrary("org.richfaces.cdk.test");
+ // processor.library = library;
+ AptBuilder compiler = new AptBuilder();
+
+ compiler.init(cdkContext);
+ compiler.process(ImmutableList.of(getJavaFile(COMPONENT_CLASS_JAVA)), processor);
+ verify(cdkContext);
+ assertTrue(processor.isInitialized());
+ assertEquals(1, processor.numOfComponents);
+ }
+
+ /**
+ * Test method for
+ * {@link org.richfaces.cdk.apt.CdkProcessor#getClassesAnnotatedWith(RoundEnvironment, Class)}
+ * .
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testGetPropertiesAnnotatedWith() throws Exception {
+
+ // Prepare Mock compilation context.
+ CdkContext cdkContext = createMock(CdkContext.class);
+
+ expect(cdkContext.getSourceFolders(StandardSources.JAVA_SOURCES)).andStubReturn(testSourceDirectory);
+ expect(cdkContext.getOutputFolder((OutputType) anyObject())).andStubReturn(null);
+ expect(cdkContext.getLoader()).andStubReturn(TestAnnotation2.class.getClassLoader());
+ replay(cdkContext);
+
+ TestProcessor processor = new TestProcessor(cdkContext) {
+ @Override
+ public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
+ if (!roundEnv.processingOver()) {
+ TypeElement typeElement = getClassesAnnotatedWith(roundEnv, Component.class).iterator().next();
+ Set<BeanProperty> beanProperties = getBeanPropertiesAnnotatedWith(Attribute.class, typeElement);
+
+ assertEquals(3, beanProperties.size());
+
+ BeanProperty property = Iterables.get(beanProperties, 2);
+
+ assertEquals("foo", property.getName());
+ assertEquals("int", property.getType().toString());
+ assertNull(property.getDocComment());
+ property = Iterables.get(beanProperties, 1);
+ assertEquals("testValue", property.getName());
+ assertEquals("java.util.List<java.lang.String>", property.getType().toString());
+ assertEquals(" Test Attribute\n", property.getDocComment());
+ property = Iterables.get(beanProperties, 0);
+ assertEquals("barValue", property.getName());
+ assertEquals("java.util.List<M>", property.getType().toString());
+ assertEquals(" Bar Attribute\n", property.getDocComment());
+
+// assertEquals("<M>" ,property.getTypeParameters());
+ numOfComponents++;
+ }
+
+ return true;
+ }
+ };
+
+ // ComponentLibrary library = new
+ // ComponentLibrary("org.richfaces.cdk.test");
+ // processor.library = library;
+ AptBuilder compiler = new AptBuilder();
+
+ compiler.init(cdkContext);
+ compiler.process(ImmutableList.of(getJavaFile(COMPONENT_CLASS_JAVA)), processor);
+ verify(cdkContext);
+ assertTrue(processor.isInitialized());
+ assertEquals(1, processor.numOfComponents);
+ }
+
+ private static abstract class TestProcessor extends CdkProcessor {
+ protected ComponentLibrary library;
+ protected int numOfComponents;
+
+ public TestProcessor(CdkContext context) {
+ super(context);
+ }
+
+ @Override
+ public synchronized void init(ProcessingEnvironment processingEnv) {
+ super.init(processingEnv);
+ }
+
+ @Override
+ public synchronized boolean isInitialized() {
+ return super.isInitialized();
+ }
+
+ @Override
+ public Set<String> getSupportedAnnotationTypes() {
+
+ // Process all annotations
+ return ImmutableSet.of("*");
+ }
+ }
}
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-11-01 16:21:55 UTC (rev 15790)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/ComponentProcessorTest.java 2009-11-01 16:27:54 UTC (rev 15791)
@@ -21,26 +21,32 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.apt;
import static org.easymock.EasyMock.*;
+
import static org.junit.Assert.*;
+
import static javax.lang.model.util.ElementFilter.*;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
+
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
+
import java.util.Collection;
import java.util.Set;
import java.util.logging.LogManager;
-
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+
import org.richfaces.cdk.CdkContext;
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.CdkTestBase;
@@ -61,83 +67,97 @@
/**
* <p class="changed_added_4_0">
* </p>
- *
+ *
* @author asmirnov(a)exadel.com
- *
+ *
*/
public class ComponentProcessorTest extends CdkTestBase {
+ private static final String COMPONENT_CLASS_JAVA = "org/richfaces/cdk/test/component/AbstractTestComponent.java";
+ private static final String FACES_COMPONENT_CLASS_JAVA = "org/richfaces/cdk/test/component/UITestCommand.java";
+ /**
+ * Test method for
+ * {@link org.richfaces.cdk.apt.CdkProcessor#process(java.util.Set, javax.annotation.processing.RoundEnvironment)}
+ * .
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testProcess() throws Exception {
- private static final String COMPONENT_CLASS_JAVA = "org/richfaces/cdk/test/component/AbstractTestComponent.java";
- private static final String FACES_COMPONENT_CLASS_JAVA = "org/richfaces/cdk/test/component/UITestCommand.java";
+ // Prepare Mock compilation context.
+ CdkContext cdkContext = createMockContext();
+ ComponentLibrary library = new ComponentLibrary();
+ ComponentProcessor processor = new ComponentProcessor(cdkContext, library);
+ AptBuilder compiler = new AptBuilder();
+ compiler.init(cdkContext);
+ compiler.process(ImmutableList.of(getJavaFile(COMPONENT_CLASS_JAVA)), processor);
+ verify(cdkContext);
- /**
- * Test method for
- * {@link org.richfaces.cdk.apt.CdkProcessor#process(java.util.Set, javax.annotation.processing.RoundEnvironment)}
- * .
- *
- * @throws Exception
- */
- @Test
- public void testProcess() throws Exception {
- // Prepare Mock compilation context.
- CdkContext cdkContext = createMockContext();
- ComponentLibrary library = new ComponentLibrary();
- ComponentProcessor processor = new ComponentProcessor(cdkContext,library);
- AptBuilder compiler = new AptBuilder();
- compiler.init(cdkContext);
- compiler.process(ImmutableList.of(getJavaFile(COMPONENT_CLASS_JAVA)), processor);
- verify(cdkContext);
- Collection<Component> components = library.getComponents();
- assertEquals(1, components.size());
- Component component = Iterables.get(components, 0);
- Collection<Property> attributes = component.getAttributes();
- assertEquals(5, attributes.size());
- }
+ Collection<Component> components = library.getComponents();
- /**
- * Test method for
- * {@link org.richfaces.cdk.apt.CdkProcessor#process(java.util.Set, javax.annotation.processing.RoundEnvironment)}
- * .
- *
- * @throws Exception
- */
- @Test
- public void testProcessFacesComponent() throws Exception {
- // Prepare Mock compilation context.
- CdkContext cdkContext = createMockContext();
- ComponentLibrary library = new ComponentLibrary();
- ComponentProcessor processor = new ComponentProcessor(cdkContext,library);
- AptBuilder compiler = new AptBuilder();
- compiler.init(cdkContext);
- compiler.process(ImmutableList.of(getJavaFile(FACES_COMPONENT_CLASS_JAVA)), processor);
- verify(cdkContext);
- Collection<Component> components = library.getComponents();
- assertEquals(1, components.size());
- Component component = Iterables.get(components, 0);
- Collection<Property> attributes = component.getAttributes();
- assertEquals(2, attributes.size());
- }
+ assertEquals(1, components.size());
- private CdkContext createMockContext() throws Exception {
- CdkContext cdkContext = createMock(CdkContext.class);
- expect(cdkContext.getSourceFolders(StandardSources.JAVA_SOURCES)).andStubReturn(testSourceDirectory);
- expect(cdkContext.getOutputFolder((OutputType) anyObject())).andStubReturn(null);
- expect(cdkContext.getLoader()).andStubReturn(
- TestAnnotation.class.getClassLoader());
- RichFacesConventions richFacesConventions = new RichFacesConventions();
- expect(cdkContext.getWorkerInstance(NamingConventions.class)).andStubReturn(richFacesConventions);
- FragmentParser fragmentParser = new FragmentParser();
- expect(cdkContext.getWorkerInstance(FragmentParser.class)).andStubReturn(fragmentParser);
- JAXBBinding jaxbBinding = new JAXBBinding();
- expect(cdkContext.getWorkerInstance(JAXBBinding.class)).andStubReturn(jaxbBinding);
- replay(cdkContext);
- richFacesConventions.init(cdkContext);
- jaxbBinding.init(cdkContext);
- fragmentParser.init(cdkContext);
- return cdkContext;
- }
+ Component component = Iterables.get(components, 0);
+ Collection<Property> attributes = component.getAttributes();
+ assertEquals(5, attributes.size());
+ }
+ /**
+ * Test method for
+ * {@link org.richfaces.cdk.apt.CdkProcessor#process(java.util.Set, javax.annotation.processing.RoundEnvironment)}
+ * .
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testProcessFacesComponent() throws Exception {
+
+ // Prepare Mock compilation context.
+ CdkContext cdkContext = createMockContext();
+ ComponentLibrary library = new ComponentLibrary();
+ ComponentProcessor processor = new ComponentProcessor(cdkContext, library);
+ AptBuilder compiler = new AptBuilder();
+
+ compiler.init(cdkContext);
+ compiler.process(ImmutableList.of(getJavaFile(FACES_COMPONENT_CLASS_JAVA)), processor);
+ verify(cdkContext);
+
+ Collection<Component> components = library.getComponents();
+
+ assertEquals(1, components.size());
+
+ Component component = Iterables.get(components, 0);
+ Collection<Property> attributes = component.getAttributes();
+
+ assertEquals(2, attributes.size());
+ }
+
+ private CdkContext createMockContext() throws Exception {
+ CdkContext cdkContext = createMock(CdkContext.class);
+
+ expect(cdkContext.getSourceFolders(StandardSources.JAVA_SOURCES)).andStubReturn(testSourceDirectory);
+ expect(cdkContext.getOutputFolder((OutputType) anyObject())).andStubReturn(null);
+ expect(cdkContext.getLoader()).andStubReturn(TestAnnotation.class.getClassLoader());
+
+ RichFacesConventions richFacesConventions = new RichFacesConventions();
+
+ expect(cdkContext.getWorkerInstance(NamingConventions.class)).andStubReturn(richFacesConventions);
+
+ FragmentParser fragmentParser = new FragmentParser();
+
+ expect(cdkContext.getWorkerInstance(FragmentParser.class)).andStubReturn(fragmentParser);
+
+ JAXBBinding jaxbBinding = new JAXBBinding();
+
+ expect(cdkContext.getWorkerInstance(JAXBBinding.class)).andStubReturn(jaxbBinding);
+ replay(cdkContext);
+ richFacesConventions.init(cdkContext);
+ jaxbBinding.init(cdkContext);
+ fragmentParser.init(cdkContext);
+
+ return cdkContext;
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/TestAnnotation.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/TestAnnotation.java 2009-11-01 16:21:55 UTC (rev 15790)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/TestAnnotation.java 2009-11-01 16:27:54 UTC (rev 15791)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.apt;
import java.lang.annotation.Documented;
@@ -37,5 +39,5 @@
@Documented
@Target(ElementType.TYPE)
public @interface TestAnnotation {
- public String value();
+ public String value();
}
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/TestAnnotation2.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/TestAnnotation2.java 2009-11-01 16:21:55 UTC (rev 15790)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/TestAnnotation2.java 2009-11-01 16:27:54 UTC (rev 15791)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.apt;
import java.lang.annotation.Documented;
@@ -37,5 +39,5 @@
@Documented
@Target(ElementType.TYPE)
public @interface TestAnnotation2 {
- public String value();
+ public String value();
}
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/TestInterfaceAnnotation.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/TestInterfaceAnnotation.java 2009-11-01 16:21:55 UTC (rev 15790)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/TestInterfaceAnnotation.java 2009-11-01 16:27:54 UTC (rev 15791)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.apt;
import java.lang.annotation.Documented;
@@ -36,6 +38,4 @@
@Inherited
@Documented
@Target(ElementType.TYPE)
-public @interface TestInterfaceAnnotation {
-
-}
+public @interface TestInterfaceAnnotation {}
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/TestMethodAnnotation.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/TestMethodAnnotation.java 2009-11-01 16:21:55 UTC (rev 15790)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/TestMethodAnnotation.java 2009-11-01 16:27:54 UTC (rev 15791)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.apt;
import java.lang.annotation.Documented;
@@ -37,5 +39,5 @@
@Documented
@Target(ElementType.METHOD)
public @interface TestMethodAnnotation {
- public String value();
+ public String value();
}
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/VirtualFileManagerTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/VirtualFileManagerTest.java 2009-11-01 16:21:55 UTC (rev 15790)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/VirtualFileManagerTest.java 2009-11-01 16:27:54 UTC (rev 15791)
@@ -1,16 +1,19 @@
package org.richfaces.cdk.apt;
import static org.junit.Assert.*;
+
import static org.easymock.EasyMock.*;
+
import static org.hamcrest.CoreMatchers.*;
import java.io.File;
import java.io.IOException;
+
import java.net.URI;
import java.net.URL;
+
import java.util.ArrayList;
-
import javax.tools.FileObject;
import javax.tools.JavaFileManager;
import javax.tools.JavaFileObject;
@@ -25,91 +28,122 @@
import com.google.common.collect.Lists;
public class VirtualFileManagerTest {
-
- private static final String TEST_PACKAGE = "org.richfaces.cdk.apt";
- private static final String TEST_CLASS = "TestClass";
- private static final String TEST_CLASS_NAME = TEST_PACKAGE + "." + TEST_CLASS;
- private JavaFileManager mockFileManager;
- private File javaSourceDirectory;
+ private static final String TEST_CLASS = "TestClass";
+ private static final String TEST_PACKAGE = "org.richfaces.cdk.apt";
+ private static final String TEST_CLASS_NAME = TEST_PACKAGE + "." + TEST_CLASS;
+ private File javaSourceDirectory;
+ private JavaFileManager mockFileManager;
- @Before
- public void setUp() throws Exception{
- mockFileManager = createMock(JavaFileManager.class);
- URL url = this.getClass().getResource(TEST_CLASS+".java");
- final File classFile = new File(url.toURI());
- javaSourceDirectory = classFile.getParentFile().getParentFile();
- }
+ @Before
+ public void setUp() throws Exception {
+ mockFileManager = createMock(JavaFileManager.class);
- @After
- public void tearDown() {
- mockFileManager = null;
- }
-
+ URL url = this.getClass().getResource(TEST_CLASS + ".java");
+ final File classFile = new File(url.toURI());
- @Test
- public void testGetJavaFileForInputSource() throws Exception {
- VirtualFileManager fileManager = new VirtualFileManager(mockFileManager,this.getClass().getClassLoader());
- fileManager.setJavaSourceDirectory(javaSourceDirectory);
- replay(mockFileManager);
- JavaFileObject fileObject = fileManager.getJavaFileForInput(StandardLocation.SOURCE_PATH, "apt."+TEST_CLASS, Kind.SOURCE);
- assertNotNull(fileObject);
- assertThat(fileObject,instanceOf(VirtualJavaFileObject.class) );
- JavaFileObject fileObject1 = fileManager.getJavaFileForInput(StandardLocation.SOURCE_PATH, "apt."+TEST_CLASS, Kind.SOURCE);
- assertSame(fileObject,fileObject1);
- }
+ javaSourceDirectory = classFile.getParentFile().getParentFile();
+ }
- @Test
- public void testHasLocationLocation() {
- VirtualFileManager fileManager = new VirtualFileManager(mockFileManager,this.getClass().getClassLoader());
- fileManager.setJavaSourceDirectory(javaSourceDirectory);
- replay(mockFileManager);
- assertTrue(fileManager.hasLocation(StandardLocation.SOURCE_PATH));
- }
+ @After
+ public void tearDown() {
+ mockFileManager = null;
+ }
- @Test
- public void testListLocationStringSetOfKindBoolean() throws Exception {
- VirtualFileManager fileManager = new VirtualFileManager(mockFileManager,this.getClass().getClassLoader());
- fileManager.setJavaSourceDirectory(javaSourceDirectory);
- replay(mockFileManager);
- ArrayList<JavaFileObject> list = Lists.newArrayList(fileManager.list(StandardLocation.SOURCE_PATH, "apt", ImmutableSet.of(Kind.HTML), false));
- assertEquals(1, list.size());
- }
+ @Test
+ public void testGetJavaFileForInputSource() throws Exception {
+ VirtualFileManager fileManager = new VirtualFileManager(mockFileManager, this.getClass().getClassLoader());
- @Test
- public void testListRecursive() throws Exception {
- VirtualFileManager fileManager = new VirtualFileManager(mockFileManager,this.getClass().getClassLoader());
- fileManager.setJavaSourceDirectory(javaSourceDirectory);
- replay(mockFileManager);
- ArrayList<JavaFileObject> list = Lists.newArrayList(fileManager.list(StandardLocation.SOURCE_PATH, "", ImmutableSet.of(Kind.HTML), true));
- assertEquals(1, list.size());
- }
+ fileManager.setJavaSourceDirectory(javaSourceDirectory);
+ replay(mockFileManager);
- @Test
- public void testListRecursiveJava() throws Exception {
- VirtualFileManager fileManager = new VirtualFileManager(mockFileManager,this.getClass().getClassLoader());
- fileManager.setJavaSourceDirectory(javaSourceDirectory);
- replay(mockFileManager);
- ArrayList<JavaFileObject> list = Lists.newArrayList(fileManager.list(StandardLocation.SOURCE_PATH, "", ImmutableSet.of(Kind.HTML,Kind.SOURCE), true));
- assertEquals(6, list.size());
- }
- @Test
- public void testGetFileForInputLocationStringString() throws Exception {
- VirtualFileManager fileManager = new VirtualFileManager(mockFileManager,this.getClass().getClassLoader());
- expect(mockFileManager.getFileForInput(StandardLocation.CLASS_PATH, TestAnnotation.class.getPackage().getName(), TestAnnotation.class.getSimpleName()+".class")).andReturn(new VirtualJavaFileObject(new URI("file:/TestAnnotation.class"),Kind.CLASS));
- replay(mockFileManager);
- FileObject fileObject = fileManager.getFileForInput(StandardLocation.CLASS_PATH, TestAnnotation.class.getPackage().getName(), TestAnnotation.class.getSimpleName()+".class");
- assertNotNull(fileObject);
- assertThat(fileObject,instanceOf(VirtualJavaFileObject.class) );
- }
+ JavaFileObject fileObject = fileManager.getJavaFileForInput(StandardLocation.SOURCE_PATH, "apt." + TEST_CLASS,
+ Kind.SOURCE);
- @Test
- public void testGetFileForInputLocationFromSource() throws Exception {
- VirtualFileManager fileManager = new VirtualFileManager(mockFileManager,this.getClass().getClassLoader());
- fileManager.setJavaSourceDirectory(javaSourceDirectory);
- replay(mockFileManager);
- FileObject fileObject = fileManager.getFileForInput(StandardLocation.SOURCE_PATH, "apt", TEST_CLASS+".java");
- assertNotNull(fileObject);
- assertThat(fileObject,instanceOf(VirtualJavaFileObject.class) );
- }
+ assertNotNull(fileObject);
+ assertThat(fileObject, instanceOf(VirtualJavaFileObject.class));
+ JavaFileObject fileObject1 = fileManager.getJavaFileForInput(StandardLocation.SOURCE_PATH, "apt." + TEST_CLASS,
+ Kind.SOURCE);
+
+ assertSame(fileObject, fileObject1);
+ }
+
+ @Test
+ public void testHasLocationLocation() {
+ VirtualFileManager fileManager = new VirtualFileManager(mockFileManager, this.getClass().getClassLoader());
+
+ fileManager.setJavaSourceDirectory(javaSourceDirectory);
+ replay(mockFileManager);
+ assertTrue(fileManager.hasLocation(StandardLocation.SOURCE_PATH));
+ }
+
+ @Test
+ public void testListLocationStringSetOfKindBoolean() throws Exception {
+ VirtualFileManager fileManager = new VirtualFileManager(mockFileManager, this.getClass().getClassLoader());
+
+ fileManager.setJavaSourceDirectory(javaSourceDirectory);
+ replay(mockFileManager);
+
+ ArrayList<JavaFileObject> list = Lists.newArrayList(fileManager.list(StandardLocation.SOURCE_PATH, "apt",
+ ImmutableSet.of(Kind.HTML), false));
+
+ assertEquals(1, list.size());
+ }
+
+ @Test
+ public void testListRecursive() throws Exception {
+ VirtualFileManager fileManager = new VirtualFileManager(mockFileManager, this.getClass().getClassLoader());
+
+ fileManager.setJavaSourceDirectory(javaSourceDirectory);
+ replay(mockFileManager);
+
+ ArrayList<JavaFileObject> list = Lists.newArrayList(fileManager.list(StandardLocation.SOURCE_PATH, "",
+ ImmutableSet.of(Kind.HTML), true));
+
+ assertEquals(1, list.size());
+ }
+
+ @Test
+ public void testListRecursiveJava() throws Exception {
+ VirtualFileManager fileManager = new VirtualFileManager(mockFileManager, this.getClass().getClassLoader());
+
+ fileManager.setJavaSourceDirectory(javaSourceDirectory);
+ replay(mockFileManager);
+
+ ArrayList<JavaFileObject> list = Lists.newArrayList(fileManager.list(StandardLocation.SOURCE_PATH, "",
+ ImmutableSet.of(Kind.HTML, Kind.SOURCE), true));
+
+ assertEquals(6, list.size());
+ }
+
+ @Test
+ public void testGetFileForInputLocationStringString() throws Exception {
+ VirtualFileManager fileManager = new VirtualFileManager(mockFileManager, this.getClass().getClassLoader());
+
+ expect(mockFileManager.getFileForInput(StandardLocation.CLASS_PATH,
+ TestAnnotation.class.getPackage().getName(),
+ TestAnnotation.class.getSimpleName()
+ + ".class")).andReturn(new VirtualJavaFileObject(new URI("file:/TestAnnotation.class"), Kind.CLASS));
+ replay(mockFileManager);
+
+ FileObject fileObject = fileManager.getFileForInput(StandardLocation.CLASS_PATH,
+ TestAnnotation.class.getPackage().getName(),
+ TestAnnotation.class.getSimpleName() + ".class");
+
+ assertNotNull(fileObject);
+ assertThat(fileObject, instanceOf(VirtualJavaFileObject.class));
+ }
+
+ @Test
+ public void testGetFileForInputLocationFromSource() throws Exception {
+ VirtualFileManager fileManager = new VirtualFileManager(mockFileManager, this.getClass().getClassLoader());
+
+ fileManager.setJavaSourceDirectory(javaSourceDirectory);
+ replay(mockFileManager);
+
+ FileObject fileObject = fileManager.getFileForInput(StandardLocation.SOURCE_PATH, "apt", TEST_CLASS + ".java");
+
+ assertNotNull(fileObject);
+ assertThat(fileObject, instanceOf(VirtualJavaFileObject.class));
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/VirtualFileTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/VirtualFileTest.java 2009-11-01 16:21:55 UTC (rev 15790)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/VirtualFileTest.java 2009-11-01 16:27:54 UTC (rev 15791)
@@ -21,18 +21,21 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.apt;
import java.io.File;
import java.io.InputStream;
import java.io.Reader;
+
import java.net.URISyntaxException;
import java.net.URL;
+
import java.nio.charset.Charset;
import javax.tools.JavaFileObject.Kind;
-
import junit.framework.TestCase;
/**
@@ -41,84 +44,90 @@
*
*/
public class VirtualFileTest extends TestCase {
-
- private static final String CONTENT="<html><body>test</body></html>\n";
+ private static final String CONTENT = "<html><body>test</body></html>\n";
- /**
- * Test method for {@link org.richfaces.cdk.apt.VirtualJavaFileObject#getLastModified()}.
- * @throws Exception
- */
- public void testGetLastModified() throws Exception {
- URL resource = getTestResource();
- File testFile = new File(resource.toURI());
- long lastModified = testFile.lastModified();
- assertEquals(lastModified, new VirtualJavaClassPathObject(resource,Kind.HTML).getLastModified());
- assertEquals(lastModified, new VirtualJavaFileSystemObject(testFile,Kind.HTML).getLastModified());
- }
+ /**
+ * Test method for {@link org.richfaces.cdk.apt.VirtualJavaFileObject#getLastModified()}.
+ * @throws Exception
+ */
+ public void testGetLastModified() throws Exception {
+ URL resource = getTestResource();
+ File testFile = new File(resource.toURI());
+ long lastModified = testFile.lastModified();
- /**
- * <p class="changed_added_4_0"></p>
- * @return
- */
- protected URL getTestResource() {
- return this.getClass().getResource("test.html");
- }
+ assertEquals(lastModified, new VirtualJavaClassPathObject(resource, Kind.HTML).getLastModified());
+ assertEquals(lastModified, new VirtualJavaFileSystemObject(testFile, Kind.HTML).getLastModified());
+ }
- /**
- * Test method for {@link org.richfaces.cdk.apt.VirtualJavaFileObject#openInputStream()}.
- * @throws Exception
- */
- public void testOpenInputStream() throws Exception {
- VirtualJavaFileObject fileObject = createFileObject();
- InputStream inputStream = fileObject.openInputStream();
- byte buff[] = new byte[CONTENT.getBytes().length+10];
- int read = inputStream.read(buff,0,CONTENT.getBytes().length);
- inputStream.close();
- String result = new String(buff,0,read);
- assertEquals(CONTENT, result);
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return
+ */
+ protected URL getTestResource() {
+ return this.getClass().getResource("test.html");
+ }
- /**
- * Test method for {@link org.richfaces.cdk.apt.VirtualJavaFileObject#getCharContent(boolean)}.
- * @throws Exception
- */
- public void testGetCharContentBoolean() throws Exception {
- VirtualJavaFileObject fileObject = createFileObject();
- CharSequence charContent = fileObject.getCharContent(true);
- assertEquals(CONTENT, charContent.toString());
- }
+ /**
+ * Test method for {@link org.richfaces.cdk.apt.VirtualJavaFileObject#openInputStream()}.
+ * @throws Exception
+ */
+ public void testOpenInputStream() throws Exception {
+ VirtualJavaFileObject fileObject = createFileObject();
+ InputStream inputStream = fileObject.openInputStream();
+ byte buff[] = new byte[CONTENT.getBytes().length + 10];
+ int read = inputStream.read(buff, 0, CONTENT.getBytes().length);
- /**
- * Test method for {@link org.richfaces.cdk.apt.VirtualJavaFileObject#openReader(boolean)}.
- * @throws Exception
- */
- public void testOpenReaderBoolean() throws Exception {
- VirtualJavaFileObject fileObject = createFileObject();
- Reader reader = fileObject.openReader(true);
- char buff[] = new char[CONTENT.length()+10];
- int read = reader.read(buff);
- reader.close();
- String result = new String(buff,0,read);
- assertEquals(CONTENT, result);
- }
+ inputStream.close();
- /**
- * <p class="changed_added_4_0"></p>
- * @return
- * @throws URISyntaxException
- */
- protected VirtualJavaFileObject createFileObject()
- throws URISyntaxException {
- return new VirtualJavaClassPathObject(getTestResource(),Kind.HTML);
- }
+ String result = new String(buff, 0, read);
- /**
- * Test method for {@link org.richfaces.cdk.apt.VirtualJavaFileObject#setCharset(java.nio.charset.Charset)}.
- * @throws Exception
- */
- public void testSetCharset() throws Exception {
- VirtualJavaFileObject javaFileObject = createFileObject();
- javaFileObject.setCharset(Charset.forName("UTF-8"));
- }
+ assertEquals(CONTENT, result);
+ }
+ /**
+ * Test method for {@link org.richfaces.cdk.apt.VirtualJavaFileObject#getCharContent(boolean)}.
+ * @throws Exception
+ */
+ public void testGetCharContentBoolean() throws Exception {
+ VirtualJavaFileObject fileObject = createFileObject();
+ CharSequence charContent = fileObject.getCharContent(true);
+
+ assertEquals(CONTENT, charContent.toString());
+ }
+
+ /**
+ * Test method for {@link org.richfaces.cdk.apt.VirtualJavaFileObject#openReader(boolean)}.
+ * @throws Exception
+ */
+ public void testOpenReaderBoolean() throws Exception {
+ VirtualJavaFileObject fileObject = createFileObject();
+ Reader reader = fileObject.openReader(true);
+ char buff[] = new char[CONTENT.length() + 10];
+ int read = reader.read(buff);
+
+ reader.close();
+
+ String result = new String(buff, 0, read);
+
+ assertEquals(CONTENT, result);
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return
+ * @throws URISyntaxException
+ */
+ protected VirtualJavaFileObject createFileObject() throws URISyntaxException {
+ return new VirtualJavaClassPathObject(getTestResource(), Kind.HTML);
+ }
+
+ /**
+ * Test method for {@link org.richfaces.cdk.apt.VirtualJavaFileObject#setCharset(java.nio.charset.Charset)}.
+ * @throws Exception
+ */
+ public void testSetCharset() throws Exception {
+ VirtualJavaFileObject javaFileObject = createFileObject();
+
+ javaFileObject.setCharset(Charset.forName("UTF-8"));
+ }
}
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-11-01 16:21:55 UTC (rev 15790)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/freemarker/FreeMarkerRendererTest.java 2009-11-01 16:27:54 UTC (rev 15791)
@@ -1,6 +1,7 @@
package org.richfaces.cdk.freemarker;
import static org.easymock.EasyMock.*;
+
import static org.junit.Assert.*;
import java.io.File;
@@ -8,14 +9,17 @@
import java.io.InputStream;
import java.io.StringWriter;
import java.io.Writer;
+
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
+
import java.util.logging.LogManager;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+
import org.richfaces.cdk.CdkContext;
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.CdkTestBase;
@@ -27,58 +31,53 @@
import org.richfaces.cdk.model.Visitable;
public class FreeMarkerRendererTest extends CdkTestBase {
+ @Test
+ public void testRender() {
- @Test
- public void testRender() {
-// fail("Not yet implemented");
- }
+// fail("Not yet implemented");
+ }
- @Test
- public void testProcessComponent() throws Exception {
- final StringWriter output = new StringWriter();
- Component component = new Component(new Component.Type("foo.Bar"));
- FreeMarkerRenderer<Component, Boolean> renderer = new FreeMarkerRenderer<Component, Boolean>(){
+ @Test
+ public void testProcessComponent() throws Exception {
+ final StringWriter output = new StringWriter();
+ Component component = new Component(new Component.Type("foo.Bar"));
+ FreeMarkerRenderer<Component, Boolean> renderer = new FreeMarkerRenderer<Component, Boolean>() {
+ @Override
+ protected String getOutputFile(Component c) {
+ return null;
+ }
+ @Override
+ protected Writer getOutput(Component c) throws CdkException {
+ return output;
+ }
+ @Override
+ protected String getTemplateName() {
+ return "testComponent.ftl";
+ }
+ @Override
+ protected boolean isMyComponent(Visitable c) {
+ return true;
+ }
+ @Override
+ protected OutputType getOutputType() {
+ return null;
+ }
+ };
+ CdkContext cdkContext = createMockContext();
- @Override
- protected String getOutputFile(Component c) {
- return null;
- }
+ renderer.init(cdkContext);
+ renderer.processComponent(component, Boolean.TRUE);
+ assertEquals("foo.Bar", output.toString());
+ }
- @Override
- protected Writer getOutput(Component c) throws CdkException {
- return output;
- }
- @Override
- protected String getTemplateName() {
-
- return "testComponent.ftl";
- }
+ private CdkContext createMockContext() {
+ CdkContext cdkContext = createMock(CdkContext.class);
- @Override
- protected boolean isMyComponent(Visitable c) {
- return true;
- }
+ expect(cdkContext.getSourceFolders(StandardSources.JAVA_SOURCES)).andStubReturn(testSourceDirectory);
+ expect(cdkContext.getOutputFolder((OutputType) anyObject())).andStubReturn(null);
+ expect(cdkContext.getLoader()).andStubReturn(FreeMarkerRendererTest.class.getClassLoader());
+ replay(cdkContext);
- @Override
- protected OutputType getOutputType() {
- return null;
- }
- };
- CdkContext cdkContext = createMockContext();
- renderer.init(cdkContext);
- renderer.processComponent(component, Boolean.TRUE);
- assertEquals("foo.Bar", output.toString());
- }
-
- private CdkContext createMockContext() {
- CdkContext cdkContext = createMock(CdkContext.class);
- expect(cdkContext.getSourceFolders(StandardSources.JAVA_SOURCES)).andStubReturn(testSourceDirectory);
- expect(cdkContext.getOutputFolder((OutputType) anyObject())).andStubReturn(null);
- expect(cdkContext.getLoader()).andStubReturn(
- FreeMarkerRendererTest.class.getClassLoader());
- replay(cdkContext);
- return cdkContext;
- }
-
-
+ return cdkContext;
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ComponentClassGeneratorTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ComponentClassGeneratorTest.java 2009-11-01 16:21:55 UTC (rev 15790)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ComponentClassGeneratorTest.java 2009-11-01 16:27:54 UTC (rev 15791)
@@ -21,18 +21,23 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.generate.java;
import static org.easymock.EasyMock.*;
+
import static org.junit.Assert.*;
import java.io.StringWriter;
import java.io.Writer;
+
import java.util.Set;
import javax.faces.component.UIOutput;
import org.junit.Test;
+
import org.richfaces.cdk.CdkContext;
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.CdkTestBase;
@@ -52,57 +57,65 @@
*/
public class ComponentClassGeneratorTest extends CdkTestBase {
+ /**
+ * Test method for {@link org.richfaces.cdk.generate.java.ComponentClassGenerator#getOutputFile(org.richfaces.cdk.model.Component)}.
+ * @throws Exception
+ */
+ @Test
+ public void testGetOutputFileComponent() throws Exception {
+ final StringWriter output = new StringWriter();
+ ComponentClassGenerator generator = new ComponentClassGenerator() {
+ @Override
+ protected Writer getOutput(Component c) throws CdkException {
+ return output;
+ }
+ };
+ CdkContext mockContext = createMockContext();
- /**
- * Test method for {@link org.richfaces.cdk.generate.java.ComponentClassGenerator#getOutputFile(org.richfaces.cdk.model.Component)}.
- * @throws Exception
- */
- @Test
- public void testGetOutputFileComponent() throws Exception {
- final StringWriter output = new StringWriter();
- ComponentClassGenerator generator = new ComponentClassGenerator(){
- @Override
- protected Writer getOutput(Component c) throws CdkException {
- return output;
- }
- };
- CdkContext mockContext = createMockContext();
- generator.init(mockContext);
- ComponentLibrary library = new ComponentLibrary();
- Component component = library.findOrCreateComponent("foo.bar");
- component.setGenerate(true);
- component.setBaseClass(new ClassDescription(UIOutput.class));
- component.setComponentClass(new ClassDescription("foo.bar.UIBar"));
- Property attribute = component.findOrCreateAttribute("testValue");
- attribute.setType(new ClassDescription(Object.class));
- attribute.setGenerate(true);
- attribute = component.findOrCreateAttribute("testFlag");
- attribute.setType(new ClassDescription(boolean.class));
- attribute.setGenerate(true);
- attribute = component.findOrCreateAttribute("id");
- attribute.setType(new ClassDescription(String.class));
- Set<EventName> eventNames = attribute.getEventNames();
- EventName event = new EventName();
- event.setName("id");
- eventNames.add(event);
- event = new EventName();
- event.setName("action");
- event.setDefaultEvent(true);
- eventNames.add(event);
- attribute.setGenerate(false);
- generator.visit(component, library);
- System.out.println(output);
- verify(mockContext);
- // TODO - check generated file.
- }
+ generator.init(mockContext);
- private CdkContext createMockContext() {
- CdkContext cdkContext = createMock(CdkContext.class);
- expect(cdkContext.getSourceFolders(StandardSources.JAVA_SOURCES)).andStubReturn(testSourceDirectory);
- expect(cdkContext.getOutputFolder((OutputType) anyObject())).andStubReturn(null);
- expect(cdkContext.getLoader()).andStubReturn(
- FreeMarkerRendererTest.class.getClassLoader());
- replay(cdkContext);
- return cdkContext;
- }
+ ComponentLibrary library = new ComponentLibrary();
+ Component component = library.findOrCreateComponent("foo.bar");
+
+ component.setGenerate(true);
+ component.setBaseClass(new ClassDescription(UIOutput.class));
+ component.setComponentClass(new ClassDescription("foo.bar.UIBar"));
+
+ Property attribute = component.findOrCreateAttribute("testValue");
+
+ attribute.setType(new ClassDescription(Object.class));
+ attribute.setGenerate(true);
+ attribute = component.findOrCreateAttribute("testFlag");
+ attribute.setType(new ClassDescription(boolean.class));
+ attribute.setGenerate(true);
+ attribute = component.findOrCreateAttribute("id");
+ attribute.setType(new ClassDescription(String.class));
+
+ Set<EventName> eventNames = attribute.getEventNames();
+ EventName event = new EventName();
+
+ event.setName("id");
+ eventNames.add(event);
+ event = new EventName();
+ event.setName("action");
+ event.setDefaultEvent(true);
+ eventNames.add(event);
+ attribute.setGenerate(false);
+ generator.visit(component, library);
+ System.out.println(output);
+ verify(mockContext);
+
+ // TODO - check generated file.
+ }
+
+ private CdkContext createMockContext() {
+ CdkContext cdkContext = createMock(CdkContext.class);
+
+ expect(cdkContext.getSourceFolders(StandardSources.JAVA_SOURCES)).andStubReturn(testSourceDirectory);
+ expect(cdkContext.getOutputFolder((OutputType) anyObject())).andStubReturn(null);
+ expect(cdkContext.getLoader()).andStubReturn(FreeMarkerRendererTest.class.getClassLoader());
+ replay(cdkContext);
+
+ return cdkContext;
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/model/ClassDescriptionTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/model/ClassDescriptionTest.java 2009-11-01 16:21:55 UTC (rev 15790)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/model/ClassDescriptionTest.java 2009-11-01 16:27:54 UTC (rev 15791)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.model;
import static org.junit.Assert.*;
@@ -40,43 +42,46 @@
*/
@RunWith(Parameterized.class)
public class ClassDescriptionTest {
+ private final String className;
+ private final String expectedBoxedName;
+ private final String expectedCanonicalName;
+ private final String expectedTypeParameter;
+ private final String packageName;
+ private final String simpleName;
- private final String className;
- private final String expectedCanonicalName;
- private final String expectedBoxedName;
- private final String expectedTypeParameter;
- private final String packageName;
- private final String simpleName;
+ public ClassDescriptionTest(String className, String expectedCanonicalName, String expectedBoxedName,
+ String expectedTypeParameter, String packageName, String simpleName) {
+ this.className = className;
+ this.expectedCanonicalName = expectedCanonicalName;
+ this.expectedBoxedName = expectedBoxedName;
+ this.expectedTypeParameter = expectedTypeParameter;
+ this.packageName = packageName;
+ this.simpleName = simpleName;
+ }
- public ClassDescriptionTest(String className,String expectedCanonicalName,String expectedBoxedName,String expectedTypeParameter, String packageName, String simpleName) {
- this.className = className;
- this.expectedCanonicalName = expectedCanonicalName;
- this.expectedBoxedName = expectedBoxedName;
- this.expectedTypeParameter = expectedTypeParameter;
- this.packageName = packageName;
- this.simpleName = simpleName;
+ /**
+ * Test method for {@link org.richfaces.cdk.model.ClassDescription#ClassDescription(java.lang.String)}.
+ */
+ @Test
+ public void testClassDescription() {
+ ClassDescription description = new ClassDescription(className);
- }
- /**
- * Test method for {@link org.richfaces.cdk.model.ClassDescription#ClassDescription(java.lang.String)}.
- */
- @Test
- public void testClassDescription() {
- ClassDescription description = new ClassDescription(className);
- assertEquals(className, description.toString());
- assertEquals(expectedCanonicalName, description.getName());
- assertEquals(expectedBoxedName, description.getBoxingName());
- assertEquals(expectedTypeParameter, description.getTypeParameters());
- assertEquals(packageName, description.getPackage());
- assertEquals(simpleName, description.getSimpleName());
-
- }
+ assertEquals(className, description.toString());
+ assertEquals(expectedCanonicalName, description.getName());
+ assertEquals(expectedBoxedName, description.getBoxingName());
+ assertEquals(expectedTypeParameter, description.getTypeParameters());
+ assertEquals(packageName, description.getPackage());
+ assertEquals(simpleName, description.getSimpleName());
+ }
- @Parameters
- public static Collection<String[]> values(){
- return Arrays.asList(new String[]{int.class.getName(),"int","java.lang.Integer",null,null,"int"},
- new String[]{"java.util.List<String>","java.util.List","java.util.List<String>","<String>","java.util","List"},
- new String[]{double.class.getName(),"double","java.lang.Double",null,null,"double"});
- }
-
+ @Parameters
+ public static Collection<String[]> values() {
+ return Arrays.asList(new String[] {
+ int.class.getName(), "int", "java.lang.Integer", null, null, "int"
+ }, new String[] {
+ "java.util.List<String>", "java.util.List", "java.util.List<String>", "<String>", "java.util", "List"
+ }, new String[] {
+ double.class.getName(), "double", "java.lang.Double", null, null, "double"
+ });
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/model/ComponentLibraryTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/model/ComponentLibraryTest.java 2009-11-01 16:21:55 UTC (rev 15790)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/model/ComponentLibraryTest.java 2009-11-01 16:27:54 UTC (rev 15791)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.model;
import static org.junit.Assert.*;
@@ -31,6 +33,7 @@
import javax.faces.render.RenderKitFactory;
import org.junit.Test;
+
import org.richfaces.cdk.CdkException;
/**
@@ -40,114 +43,126 @@
*/
public class ComponentLibraryTest {
- /**
- * Test method for {@link org.richfaces.cdk.model.ComponentLibrary#merge(org.richfaces.cdk.model.ComponentLibrary)}.
- */
- @Test
- public void testMergeComponentLibrary() {
- ComponentLibrary lib = new ComponentLibrary();
- ComponentLibrary otherLib = new ComponentLibrary();
- Component component = lib.findOrCreateComponent("foo.Bar");
- Component component2 = otherLib.findOrCreateComponent("foo.Bar");
- otherLib.findOrCreateComponent("foo.baz");
- otherLib.findOrCreateRenderKit("foo.kit");
- lib.merge(otherLib);
- assertEquals(2, lib.getComponents().size());
- assertEquals(1, lib.getRenderKits().size());
- }
+ /**
+ * Test method for {@link org.richfaces.cdk.model.ComponentLibrary#merge(org.richfaces.cdk.model.ComponentLibrary)}.
+ */
+ @Test
+ public void testMergeComponentLibrary() {
+ ComponentLibrary lib = new ComponentLibrary();
+ ComponentLibrary otherLib = new ComponentLibrary();
+ Component component = lib.findOrCreateComponent("foo.Bar");
+ Component component2 = otherLib.findOrCreateComponent("foo.Bar");
- /**
- * Test method for {@link org.richfaces.cdk.model.ComponentLibrary#accept(org.richfaces.cdk.model.LibraryVisitor, java.lang.Object)}.
- * @throws Exception
- */
- @Test
- public void testAcceptLibraryVisitorOfRPP() throws Exception {
- ComponentLibrary lib = new ComponentLibrary();
- final Component component = lib.findOrCreateComponent("foo.Bar");
- LibraryVisitor<Boolean, Boolean> visitor = new LibraryVisitor<Boolean, Boolean>() {
-
- @Override
- public Boolean visit(Visitable c, Boolean param) {
- return component == c?Boolean.TRUE:null;
- }
- };
- assertTrue(lib.accept(visitor, null));
- }
+ otherLib.findOrCreateComponent("foo.baz");
+ otherLib.findOrCreateRenderKit("foo.kit");
+ lib.merge(otherLib);
+ assertEquals(2, lib.getComponents().size());
+ assertEquals(1, lib.getRenderKits().size());
+ }
- /**
- * Test method for {@link org.richfaces.cdk.model.ComponentLibrary#findOrCreateComponent(java.lang.String)}.
- */
- @Test
- public void testFindOrCreateComponent() {
- ComponentLibrary lib = new ComponentLibrary();
- Component component = lib.findOrCreateComponent("foo.Bar");
- assertNotNull(component);
- assertEquals(new Component.Type("foo.Bar"), component.getKey());
- assertSame(component, lib.findOrCreateComponent("foo.Bar"));
- }
+ /**
+ * Test method for {@link org.richfaces.cdk.model.ComponentLibrary#accept(org.richfaces.cdk.model.LibraryVisitor, java.lang.Object)}.
+ * @throws Exception
+ */
+ @Test
+ public void testAcceptLibraryVisitorOfRPP() throws Exception {
+ ComponentLibrary lib = new ComponentLibrary();
+ final Component component = lib.findOrCreateComponent("foo.Bar");
+ LibraryVisitor<Boolean, Boolean> visitor = new LibraryVisitor<Boolean, Boolean>() {
+ @Override
+ public Boolean visit(Visitable c, Boolean param) {
+ return component == c ? Boolean.TRUE : null;
+ }
+ };
- /**
- * Test method for {@link org.richfaces.cdk.model.ComponentLibrary#findOrCreateRenderer(java.lang.String, java.lang.String)}.
- */
- @Test
- public void testFindOrCreateRenderKit() {
- ComponentLibrary lib = new ComponentLibrary();
- RenderKit renderKit = lib.findOrCreateRenderKit(RenderKitFactory.HTML_BASIC_RENDER_KIT);
- assertNotNull(renderKit);
- assertSame(renderKit, lib.findOrCreateRenderKit(RenderKitFactory.HTML_BASIC_RENDER_KIT));
- }
+ assertTrue(lib.accept(visitor, null));
+ }
+ /**
+ * Test method for {@link org.richfaces.cdk.model.ComponentLibrary#findOrCreateComponent(java.lang.String)}.
+ */
+ @Test
+ public void testFindOrCreateComponent() {
+ ComponentLibrary lib = new ComponentLibrary();
+ Component component = lib.findOrCreateComponent("foo.Bar");
- /**
- * Test method for {@link org.richfaces.cdk.model.ComponentLibrary#merge(org.richfaces.cdk.model.Mergeable, org.richfaces.cdk.model.Mergeable)}.
- */
- @Test
- public void testMergeTT() {
- ModelBean foo = new ModelBean("foo");
- foo.setResult("Result");
- foo.setDoNotReplace("Important");
- ModelBean bar = new ModelBean("bar");
- bar.setVizited(true);
- Object result = new Object();
- bar.setResult(result);
- bar.readOnly = "readOnly";
- bar.writeOnly = "writeOnly";
- bar.setDoNotReplace("Replaced");
- ComponentLibrary.merge(foo, bar);
- assertSame(result, foo.getResult());
- assertEquals(new ModelBean.Type("foo"), foo.getKey());
- assertTrue(foo.isVizited());
- assertEquals("Important", foo.getDoNotReplace());
- assertNull(foo.readOnly);
- assertNull(foo.writeOnly);
- }
+ assertNotNull(component);
+ assertEquals(new Component.Type("foo.Bar"), component.getKey());
+ assertSame(component, lib.findOrCreateComponent("foo.Bar"));
+ }
- /**
- * Test method for {@link org.richfaces.cdk.model.ComponentLibrary#accept(java.lang.Iterable, org.richfaces.cdk.model.LibraryVisitor, java.lang.Object, java.lang.Object)}.
- * @throws Exception
- */
- @Test
- public void testAcceptIterableOfTLibraryVisitorOfRPPR() throws Exception {
- List<ModelBean> beans = new ArrayList<ModelBean>();
- ModelBean foo = new ModelBean("foo");
- foo.setResult("foo");
- beans.add(foo);
- ModelBean bar = new ModelBean("bar");
- beans.add(bar);
- LibraryVisitor<Object, String> visitor = new LibraryVisitor<Object, String>() {
-
- @Override
- public Object visit(Visitable c, String param) {
- ModelBean bean = (ModelBean) c;
- bean.setDoNotReplace(param);
- return bean.getResult();
- }
- };
- Object result = ComponentLibrary.accept(beans, visitor, "visited", null);
- assertTrue(foo.isVizited()||bar.isVizited());
- assertFalse(foo.isVizited()&&bar.isVizited());
- assertEquals("foo", result);
- assertEquals("visited", foo.getDoNotReplace());
- }
+ /**
+ * Test method for {@link org.richfaces.cdk.model.ComponentLibrary#findOrCreateRenderer(java.lang.String, java.lang.String)}.
+ */
+ @Test
+ public void testFindOrCreateRenderKit() {
+ ComponentLibrary lib = new ComponentLibrary();
+ RenderKit renderKit = lib.findOrCreateRenderKit(RenderKitFactory.HTML_BASIC_RENDER_KIT);
+ assertNotNull(renderKit);
+ assertSame(renderKit, lib.findOrCreateRenderKit(RenderKitFactory.HTML_BASIC_RENDER_KIT));
+ }
+
+ /**
+ * Test method for {@link org.richfaces.cdk.model.ComponentLibrary#merge(org.richfaces.cdk.model.Mergeable, org.richfaces.cdk.model.Mergeable)}.
+ */
+ @Test
+ public void testMergeTT() {
+ ModelBean foo = new ModelBean("foo");
+
+ foo.setResult("Result");
+ foo.setDoNotReplace("Important");
+
+ ModelBean bar = new ModelBean("bar");
+
+ bar.setVizited(true);
+
+ Object result = new Object();
+
+ bar.setResult(result);
+ bar.readOnly = "readOnly";
+ bar.writeOnly = "writeOnly";
+ bar.setDoNotReplace("Replaced");
+ ComponentLibrary.merge(foo, bar);
+ assertSame(result, foo.getResult());
+ assertEquals(new ModelBean.Type("foo"), foo.getKey());
+ assertTrue(foo.isVizited());
+ assertEquals("Important", foo.getDoNotReplace());
+ assertNull(foo.readOnly);
+ assertNull(foo.writeOnly);
+ }
+
+ /**
+ * Test method for {@link org.richfaces.cdk.model.ComponentLibrary#accept(java.lang.Iterable, org.richfaces.cdk.model.LibraryVisitor, java.lang.Object, java.lang.Object)}.
+ * @throws Exception
+ */
+ @Test
+ public void testAcceptIterableOfTLibraryVisitorOfRPPR() throws Exception {
+ List<ModelBean> beans = new ArrayList<ModelBean>();
+ ModelBean foo = new ModelBean("foo");
+
+ foo.setResult("foo");
+ beans.add(foo);
+
+ ModelBean bar = new ModelBean("bar");
+
+ beans.add(bar);
+
+ LibraryVisitor<Object, String> visitor = new LibraryVisitor<Object, String>() {
+ @Override
+ public Object visit(Visitable c, String param) {
+ ModelBean bean = (ModelBean) c;
+
+ bean.setDoNotReplace(param);
+
+ return bean.getResult();
+ }
+ };
+ Object result = ComponentLibrary.accept(beans, visitor, "visited", null);
+
+ assertTrue(foo.isVizited() || bar.isVizited());
+ assertFalse(foo.isVizited() && bar.isVizited());
+ assertEquals("foo", result);
+ assertEquals("visited", foo.getDoNotReplace());
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/model/ModelBean.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/model/ModelBean.java 2009-11-01 16:21:55 UTC (rev 15790)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/model/ModelBean.java 2009-11-01 16:27:54 UTC (rev 15791)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.model;
import org.richfaces.cdk.CdkException;
@@ -31,132 +33,114 @@
*
*/
@SuppressWarnings("serial")
-public class ModelBean implements ModelElement<ModelBean,ModelBean.Type> {
-
- /**
- * <p class="changed_added_4_0"></p>
- */
- private static final long serialVersionUID = -4853397197172488116L;
+public class ModelBean implements ModelElement<ModelBean, ModelBean.Type> {
- @SuppressWarnings("serial")
- public static final class Type extends Key {
+ /**
+ * <p class="changed_added_4_0"></p>
+ */
+ private static final long serialVersionUID = -4853397197172488116L;
+ private boolean vizited = false;
+ private String doNotReplace;
+ String readOnly;
+ private Object result;
+ private Type type;
+ String writeOnly;
- public Type(String type) {
- super(type);
- }
-
- }
-
- private boolean vizited = false;
-
- private Type type;
-
- String readOnly;
-
- String writeOnly;
-
- private Object result;
-
- private String doNotReplace;
-
- public ModelBean() {
-
- }
-
- public ModelBean(String name) {
- this.type = new Type(name);
- }
+ public ModelBean() {}
- /**
- * <p class="changed_added_4_0"></p>
- * @return the vizited
- */
- @Merge
- public boolean isVizited() {
- return vizited;
- }
+ public ModelBean(String name) {
+ this.type = new Type(name);
+ }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the vizited
+ */
+ @Merge
+ public boolean isVizited() {
+ return vizited;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param vizited the vizited to set
- */
- public void setVizited(boolean vizited) {
- this.vizited = vizited;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param vizited the vizited to set
+ */
+ public void setVizited(boolean vizited) {
+ this.vizited = vizited;
+ }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the result
+ */
+ @Merge
+ public Object getResult() {
+ return result;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the result
- */
- @Merge
- public Object getResult() {
- return result;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param result the result to set
+ */
+ public void setResult(Object result) {
+ this.result = result;
+ }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the readOnly
+ */
+ @Merge
+ public String getReadOnly() {
+ return readOnly;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param result the result to set
- */
- public void setResult(Object result) {
- this.result = result;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param writeOnly the writeOnly to set
+ */
+ public void setWriteOnly(String writeOnly) {
+ this.writeOnly = writeOnly;
+ }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the doNotReplace
+ */
+ @Merge(false)
+ public String getDoNotReplace() {
+ return doNotReplace;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the readOnly
- */
- @Merge
- public String getReadOnly() {
- return readOnly;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param doNotReplace the doNotReplace to set
+ */
+ public void setDoNotReplace(String doNotReplace) {
+ this.doNotReplace = doNotReplace;
+ }
+ @Override
+ public void merge(ModelBean other) {
+ ComponentLibrary.merge(this, other);
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param writeOnly the writeOnly to set
- */
- public void setWriteOnly(String writeOnly) {
- this.writeOnly = writeOnly;
- }
+ @Override
+ public Type getKey() {
+ return type;
+ }
+ @Override
+ public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) throws CdkException {
+ vizited = true;
- /**
- * <p class="changed_added_4_0"></p>
- * @return the doNotReplace
- */
- @Merge(false)
- public String getDoNotReplace() {
- return doNotReplace;
- }
+ return (R) visitor.visit(this, param);
+ }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @param doNotReplace the doNotReplace to set
- */
- public void setDoNotReplace(String doNotReplace) {
- this.doNotReplace = doNotReplace;
- }
-
-
- @Override
- public void merge(ModelBean other) {
- ComponentLibrary.merge(this, other);
- }
-
- @Override
- public Type getKey() {
- return type;
- }
-
- @Override
- public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) throws CdkException {
- vizited = true;
- return (R) visitor.visit(this, param);
- }
-
+ @SuppressWarnings("serial")
+ public static final class Type extends Key {
+ public Type(String type) {
+ super(type);
+ }
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/model/NameTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/model/NameTest.java 2009-11-01 16:21:55 UTC (rev 15790)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/model/NameTest.java 2009-11-01 16:27:54 UTC (rev 15791)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.model;
import static org.junit.Assert.*;
@@ -36,127 +38,133 @@
*/
public class NameTest {
- /**
- * <p class="changed_added_4_0"></p>
- * @throws java.lang.Exception
- */
- @Before
- public void setUp() throws Exception {
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @throws java.lang.Exception
+ */
+ @Before
+ public void setUp() throws Exception {}
- /**
- * <p class="changed_added_4_0"></p>
- * @throws java.lang.Exception
- */
- @After
- public void tearDown() throws Exception {
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @throws java.lang.Exception
+ */
+ @After
+ public void tearDown() throws Exception {}
- /**
- * Test method for {@link org.richfaces.cdk.model.Name#create(java.lang.String)}.
- * @throws Exception
- */
- @Test
- public void testCreateString() throws Exception {
- Name name = Name.create("foo.bar.component.wml.WmlFoo");
- assertEquals("foo.bar", name.getPrefix());
- assertEquals(Name.Classifier.component, name.getClassifier());
- assertEquals("wml", name.getMarkup());
- assertEquals("WmlFoo", name.getSimpleName());
- }
+ /**
+ * Test method for {@link org.richfaces.cdk.model.Name#create(java.lang.String)}.
+ * @throws Exception
+ */
+ @Test
+ public void testCreateString() throws Exception {
+ Name name = Name.create("foo.bar.component.wml.WmlFoo");
- /**
- * Test method for {@link org.richfaces.cdk.model.Name#create(java.lang.String)}.
- * @throws Exception
- */
- @Test
- public void testCreateString1() throws Exception {
- Name name = Name.create("foo.bar.wml.WmlFoo");
- assertEquals("foo.bar.wml", name.getPrefix());
- assertNull(name.getClassifier());
- assertNull(name.getMarkup());
- assertEquals("WmlFoo", name.getSimpleName());
- }
+ assertEquals("foo.bar", name.getPrefix());
+ assertEquals(Name.Classifier.component, name.getClassifier());
+ assertEquals("wml", name.getMarkup());
+ assertEquals("WmlFoo", name.getSimpleName());
+ }
- /**
- * Test method for {@link org.richfaces.cdk.model.Name#create(java.lang.String)}.
- * @throws Exception
- */
- @Test
- public void testCreateString2() throws Exception {
- Name name = Name.create("foo.bar.component.Foo");
- assertEquals("foo.bar", name.getPrefix());
- assertEquals(Name.Classifier.component, name.getClassifier());
- assertNull( name.getMarkup());
- assertEquals("Foo", name.getSimpleName());
- }
+ /**
+ * Test method for {@link org.richfaces.cdk.model.Name#create(java.lang.String)}.
+ * @throws Exception
+ */
+ @Test
+ public void testCreateString1() throws Exception {
+ Name name = Name.create("foo.bar.wml.WmlFoo");
- /**
- * Test method for {@link org.richfaces.cdk.model.Name#create(java.lang.String)}.
- * @throws Exception
- */
- @Test
- public void testCreateString3() throws Exception {
- Name name = Name.create("Foo");
- assertNull(name.getPrefix());
- assertNull(name.getClassifier());
- assertNull( name.getMarkup());
- assertEquals("Foo", name.getSimpleName());
- }
+ assertEquals("foo.bar.wml", name.getPrefix());
+ assertNull(name.getClassifier());
+ assertNull(name.getMarkup());
+ assertEquals("WmlFoo", name.getSimpleName());
+ }
- /**
- * Test method for {@link org.richfaces.cdk.model.Name#create(java.lang.String)}.
- * @throws Exception
- */
- @Test
- public void testCreateString4() throws Exception {
- Name name = Name.create("component.Foo");
- assertNull(name.getPrefix());
- assertEquals(Name.Classifier.component, name.getClassifier());
- assertNull( name.getMarkup());
- assertEquals("Foo", name.getSimpleName());
- }
- /**
- * Test method for {@link org.richfaces.cdk.model.Name#create(java.lang.String)}.
- * @throws Exception
- */
- @Test
- public void testCreateString5() throws Exception {
- Name name = Name.create("component.wml.Foo");
- assertNull(name.getPrefix());
- assertEquals(Name.Classifier.component, name.getClassifier());
- assertEquals("wml", name.getMarkup());
- assertEquals("Foo", name.getSimpleName());
- }
+ /**
+ * Test method for {@link org.richfaces.cdk.model.Name#create(java.lang.String)}.
+ * @throws Exception
+ */
+ @Test
+ public void testCreateString2() throws Exception {
+ Name name = Name.create("foo.bar.component.Foo");
-
- /**
- * Test method for {@link org.richfaces.cdk.model.Name#create(java.lang.String)}.
- * @throws Exception
- */
- @Test
- public void testCreateString6() throws Exception {
- Name name = Name.create("bar.component.wml.Foo");
- assertEquals("bar",name.getPrefix());
- assertEquals(Name.Classifier.component, name.getClassifier());
- assertEquals("wml", name.getMarkup());
- assertEquals("Foo", name.getSimpleName());
- }
+ assertEquals("foo.bar", name.getPrefix());
+ assertEquals(Name.Classifier.component, name.getClassifier());
+ assertNull(name.getMarkup());
+ assertEquals("Foo", name.getSimpleName());
+ }
- /**
- * Test method for {@link org.richfaces.cdk.model.Name#create(java.lang.String, java.lang.String)}.
- */
- @Test
- public void testCreateStringString() {
-// fail("Not yet implemented");
- }
+ /**
+ * Test method for {@link org.richfaces.cdk.model.Name#create(java.lang.String)}.
+ * @throws Exception
+ */
+ @Test
+ public void testCreateString3() throws Exception {
+ Name name = Name.create("Foo");
- /**
- * Test method for {@link org.richfaces.cdk.model.Name#create(java.lang.String, org.richfaces.cdk.model.Name.Classifier, java.lang.String)}.
- */
- @Test
- public void testCreateStringClassifierString() {
-// fail("Not yet implemented");
- }
+ assertNull(name.getPrefix());
+ assertNull(name.getClassifier());
+ assertNull(name.getMarkup());
+ assertEquals("Foo", name.getSimpleName());
+ }
+ /**
+ * Test method for {@link org.richfaces.cdk.model.Name#create(java.lang.String)}.
+ * @throws Exception
+ */
+ @Test
+ public void testCreateString4() throws Exception {
+ Name name = Name.create("component.Foo");
+
+ assertNull(name.getPrefix());
+ assertEquals(Name.Classifier.component, name.getClassifier());
+ assertNull(name.getMarkup());
+ assertEquals("Foo", name.getSimpleName());
+ }
+
+ /**
+ * Test method for {@link org.richfaces.cdk.model.Name#create(java.lang.String)}.
+ * @throws Exception
+ */
+ @Test
+ public void testCreateString5() throws Exception {
+ Name name = Name.create("component.wml.Foo");
+
+ assertNull(name.getPrefix());
+ assertEquals(Name.Classifier.component, name.getClassifier());
+ assertEquals("wml", name.getMarkup());
+ assertEquals("Foo", name.getSimpleName());
+ }
+
+ /**
+ * Test method for {@link org.richfaces.cdk.model.Name#create(java.lang.String)}.
+ * @throws Exception
+ */
+ @Test
+ public void testCreateString6() throws Exception {
+ Name name = Name.create("bar.component.wml.Foo");
+
+ assertEquals("bar", name.getPrefix());
+ assertEquals(Name.Classifier.component, name.getClassifier());
+ assertEquals("wml", name.getMarkup());
+ assertEquals("Foo", name.getSimpleName());
+ }
+
+ /**
+ * Test method for {@link org.richfaces.cdk.model.Name#create(java.lang.String, java.lang.String)}.
+ */
+ @Test
+ public void testCreateStringString() {
+
+// fail("Not yet implemented");
+ }
+
+ /**
+ * Test method for {@link org.richfaces.cdk.model.Name#create(java.lang.String, org.richfaces.cdk.model.Name.Classifier, java.lang.String)}.
+ */
+ @Test
+ public void testCreateStringClassifierString() {
+
+// fail("Not yet implemented");
+ }
}
Modified: 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 2009-11-01 16:21:55 UTC (rev 15790)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/parser/el/test/Bean.java 2009-11-01 16:27:54 UTC (rev 15791)
@@ -18,6 +18,9 @@
* 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;
@@ -26,68 +29,61 @@
import java.util.Map;
public class Bean {
+ private UIComponent[] array = new UIComponent[] {new UIComponent()};
+ private List<UIComponent> components;
+ private Map<String, UIComponent> facets;
+ private boolean readOnly;
+ private Bean2 testBean2;
- 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 Bean() {
+ facets = new HashMap<String, UIComponent>();
- public void setTestBean2(Bean2 testBean2) {
- this.testBean2 = testBean2;
- }
+ UIComponent value = new UIComponent();
- public void test(UIComponent comp, boolean test){
-
- }
-
- public UIComponent[] getArray() {
- return array;
- }
+ facets.put("header", value);
+ components = new ArrayList<UIComponent>();
+ components.add(value);
+ }
- public void setArray(UIComponent[] array) {
- this.array = array;
- }
+ public Bean2 getTestBean2() {
+ return testBean2;
+ }
- public List<UIComponent> getComponents() {
- return components;
- }
+ public void setTestBean2(Bean2 testBean2) {
+ this.testBean2 = testBean2;
+ }
- public void setComponents(List<UIComponent> components) {
- this.components = components;
- }
-
- public Map<String, UIComponent> getFacets() {
- return facets;
- }
+ public void test(UIComponent comp, boolean test) {}
- public void setFacets(Map<String, UIComponent> facets) {
- this.facets = facets;
- }
+ public UIComponent[] getArray() {
+ return array;
+ }
- public boolean isReadOnly() {
- return readOnly;
- }
+ public void setArray(UIComponent[] array) {
+ this.array = array;
+ }
- public void setReadOnly(boolean readOnly) {
- this.readOnly = readOnly;
- }
+ 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;
+ }
}
Modified: 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 2009-11-01 16:21:55 UTC (rev 15790)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/parser/el/test/Bean2.java 2009-11-01 16:27:54 UTC (rev 15791)
@@ -18,17 +18,19 @@
* 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;
- private String string;
+ public String getString() {
+ return string;
+ }
- public String getString() {
- return string;
- }
-
- public void setString(String string) {
- this.string = string;
- }
+ public void setString(String string) {
+ this.string = string;
+ }
}
Modified: 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 2009-11-01 16:21:55 UTC (rev 15790)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/parser/el/test/ELParserTest.java 2009-11-01 16:27:54 UTC (rev 15791)
@@ -18,6 +18,9 @@
* 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;
@@ -27,260 +30,263 @@
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;
- }
+ @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;
+ }
}
Modified: 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 2009-11-01 16:21:55 UTC (rev 15790)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/parser/el/test/UIComponent.java 2009-11-01 16:27:54 UTC (rev 15791)
@@ -18,18 +18,19 @@
* 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;
- private boolean rendered;
+ public boolean isRendered() {
+ return rendered;
+ }
- public boolean isRendered() {
- return rendered;
- }
-
- public void setRendered(boolean rendered) {
- this.rendered = rendered;
- }
-
+ public void setRendered(boolean rendered) {
+ this.rendered = rendered;
+ }
}
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-11-01 16:21:55 UTC (rev 15790)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/CdkResolverTest.java 2009-11-01 16:27:54 UTC (rev 15791)
@@ -1,6 +1,7 @@
package org.richfaces.cdk.xmlconfig;
import static org.easymock.EasyMock.*;
+
import static org.junit.Assert.*;
import java.io.ByteArrayInputStream;
@@ -8,84 +9,99 @@
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
+
import java.util.logging.LogManager;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+
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;
public class CdkResolverTest extends CdkTestBase {
+ @Test
+ public void testResolveSystemIdSystem() throws Exception {
+ // Prepare Mock compilation context.
+ CdkContext cdkContext = createMockContext();
- @Test
- public void testResolveSystemIdSystem() throws Exception {
- // Prepare Mock compilation context.
- CdkContext cdkContext = createMockContext();
- expect(cdkContext.getLoader()).andStubReturn(
- CdkEntityResolver.class.getClassLoader());
- replay(cdkContext);
- CdkEntityResolver entityResolver = new CdkEntityResolver(cdkContext);
- InputSource input = entityResolver.resolveSystemId("http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd");
- assertNotNull(input);
- }
+ expect(cdkContext.getLoader()).andStubReturn(CdkEntityResolver.class.getClassLoader());
+ replay(cdkContext);
- @Test
- public void testResolveSystemIdResource() throws Exception {
- // Prepare Mock compilation context.
- CdkContext cdkContext = createMockContext();
- ClassLoader loader = new ClassLoader(CdkEntityResolver.class.getClassLoader()){
- @Override
- public InputStream getResourceAsStream(String name) {
- if("foo/bar.xml".equals(name)){
- return new ByteArrayInputStream("baz".getBytes());
- } else {
- return super.getResourceAsStream(name);
- }
- }
- };
- expect(cdkContext.getLoader()).andStubReturn(
- loader);
- replay(cdkContext);
- CdkEntityResolver entityResolver = new CdkEntityResolver(cdkContext);
- InputSource input = entityResolver.resolveSystemId("urn:resource:foo/bar.xml");
- assertNotNull(input);
- }
+ CdkEntityResolver entityResolver = new CdkEntityResolver(cdkContext);
+ InputSource input = entityResolver.resolveSystemId("http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd");
- @Test
- public void testResolveSystemIdAttributes() throws Exception {
- // Prepare Mock compilation context.
- CdkContext cdkContext = createMockContext();
- ClassLoader loader = CdkEntityResolver.class.getClassLoader();
- expect(cdkContext.getLoader()).andStubReturn(
- loader);
- replay(cdkContext);
- CdkEntityResolver entityResolver = new CdkEntityResolver(cdkContext);
- InputSource input = entityResolver.resolveSystemId("urn:attributes:javax.faces.component.UIComponent.xml");
- assertNotNull(input);
- }
+ assertNotNull(input);
+ }
- private CdkContext createMockContext() {
- CdkContext cdkContext = createMock(CdkContext.class);
- expect(cdkContext.getSourceFolders(StandardSources.JAVA_SOURCES)).andStubReturn(testSourceDirectory);
- expect(cdkContext.getOutputFolder((OutputType) anyObject())).andStubReturn(null);
- return cdkContext;
- }
+ @Test
+ public void testResolveSystemIdResource() throws Exception {
- @Test
- public void testGetProjectInputSource() throws Exception {
- CdkContext cdkContext = createMockContext();
- 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");
- assertNotNull(input);
- verify(cdkContext);
- }
+ // Prepare Mock compilation context.
+ CdkContext cdkContext = createMockContext();
+ ClassLoader loader = new ClassLoader(CdkEntityResolver.class.getClassLoader()) {
+ @Override
+ public InputStream getResourceAsStream(String name) {
+ if ("foo/bar.xml".equals(name)) {
+ return new ByteArrayInputStream("baz".getBytes());
+ } else {
+ return super.getResourceAsStream(name);
+ }
+ }
+ };
+ expect(cdkContext.getLoader()).andStubReturn(loader);
+ replay(cdkContext);
+
+ CdkEntityResolver entityResolver = new CdkEntityResolver(cdkContext);
+ InputSource input = entityResolver.resolveSystemId("urn:resource:foo/bar.xml");
+
+ assertNotNull(input);
+ }
+
+ @Test
+ public void testResolveSystemIdAttributes() throws Exception {
+
+ // Prepare Mock compilation context.
+ CdkContext cdkContext = createMockContext();
+ ClassLoader loader = CdkEntityResolver.class.getClassLoader();
+
+ expect(cdkContext.getLoader()).andStubReturn(loader);
+ replay(cdkContext);
+
+ CdkEntityResolver entityResolver = new CdkEntityResolver(cdkContext);
+ InputSource input = entityResolver.resolveSystemId("urn:attributes:javax.faces.component.UIComponent.xml");
+
+ assertNotNull(input);
+ }
+
+ private CdkContext createMockContext() {
+ CdkContext cdkContext = createMock(CdkContext.class);
+
+ 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.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");
+
+ assertNotNull(input);
+ verify(cdkContext);
+ }
}
Modified: 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 2009-11-01 16:21:55 UTC (rev 15790)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/FacesConfigTest.java 2009-11-01 16:27:54 UTC (rev 15791)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.xmlconfig;
import static org.junit.Assert.*;
@@ -28,6 +30,7 @@
import java.util.Collection;
import org.junit.Test;
+
import org.richfaces.cdk.CdkContextBase;
import org.richfaces.cdk.CdkTestBase;
import org.richfaces.cdk.model.Component;
@@ -38,36 +41,43 @@
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 {
+ CdkContextBase contextBase = new CdkContextBase(this.getClass().getClassLoader());
+ JAXBBinding jaxbBinding = new JAXBBinding();
+ jaxbBinding.init(contextBase);
- @Test
- public void testComponentUnmarshal() throws Exception {
- CdkContextBase contextBase = new CdkContextBase(this.getClass().getClassLoader());
- JAXBBinding jaxbBinding = new JAXBBinding();
- jaxbBinding.init(contextBase);
- 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());
- assertEquals("panel.gif", component.getIcon().getSmallIcon());
- assertEquals("panel-large.gif", component.getIcon().getLargeIcon());
- assertEquals("Panel component", component.getDescription());
- assertEquals("Panel", component.getDisplayname());
- assertTrue(component.isGenerate());
- Facet facet = Iterables.getOnlyElement(component.getFacets());
- assertEquals("header", facet.getName().toString());
- assertEquals("Header facet", facet.getDescription());
- assertTrue(facet.isGenerate());
- Collection<Property> attributes = component.getAttributes();
- assertEquals(3, attributes.size());
- }
+ 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());
+ assertEquals("panel.gif", component.getIcon().getSmallIcon());
+ assertEquals("panel-large.gif", component.getIcon().getLargeIcon());
+ assertEquals("Panel component", component.getDescription());
+ assertEquals("Panel", component.getDisplayname());
+ assertTrue(component.isGenerate());
+
+ Facet facet = Iterables.getOnlyElement(component.getFacets());
+
+ assertEquals("header", facet.getName().toString());
+ assertEquals("Header facet", facet.getDescription());
+ assertTrue(facet.isGenerate());
+
+ Collection<Property> attributes = component.getAttributes();
+
+ assertEquals(3, attributes.size());
+ }
}
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-11-01 16:21:55 UTC (rev 15790)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/FragmentParserTest.java 2009-11-01 16:27:54 UTC (rev 15791)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.xmlconfig;
import static org.junit.Assert.*;
@@ -30,71 +32,92 @@
import java.util.Set;
import org.junit.Test;
+
import org.richfaces.cdk.CdkContextBase;
import org.richfaces.cdk.model.ClassDescription;
import org.richfaces.cdk.model.Property;
import com.google.common.collect.Iterables;
-
/**
* <p class="changed_added_4_0"></p>
* @author asmirnov(a)exadel.com
*
*/
public class FragmentParserTest {
-
- @Test
- public void parserTest() throws Exception {
- FragmentParser parser = new FragmentParser();
- CdkContextBase contextBase = new CdkContextBase(this.getClass().getClassLoader());
- parser.init(contextBase);
- Collection<Property> properties = parser.parseProperties("urn:resource:org/richfaces/cdk/xmlconfig/fragment.xml");
- assertEquals(3,properties.size());
- }
+ @Test
+ public void parserTest() throws Exception {
+ FragmentParser parser = new FragmentParser();
+ CdkContextBase contextBase = new CdkContextBase(this.getClass().getClassLoader());
- @Test
- public void xincludeTest() throws Exception {
- FragmentParser parser = new FragmentParser();
- CdkContextBase contextBase = new CdkContextBase(this.getClass().getClassLoader());
- parser.init(contextBase);
- Collection<Property> properties = parser.parseProperties("urn:resource:org/richfaces/cdk/xmlconfig/parent.xml");
- assertEquals(2,properties.size());
- }
+ parser.init(contextBase);
- @Test
- public void nestedXincludeTest() throws Exception {
- FragmentParser parser = new FragmentParser();
- CdkContextBase contextBase = new CdkContextBase(this.getClass().getClassLoader());
- parser.init(contextBase);
- Collection<Property> properties = parser.parseProperties("urn:resource:org/richfaces/cdk/xmlconfig/parent2.xml");
- assertEquals(2,properties.size());
- }
+ Collection<Property> properties =
+ parser.parseProperties("urn:resource:org/richfaces/cdk/xmlconfig/fragment.xml");
- @Test
- public void propertyTest() throws Exception {
- FragmentParser parser = new FragmentParser();
- CdkContextBase contextBase = new CdkContextBase(this.getClass().getClassLoader());
- parser.init(contextBase);
- Collection<Property> properties = parser.parseProperties("urn:resource:org/richfaces/cdk/xmlconfig/properties.xml");
- assertEquals(1,properties.size());
- Property property = Iterables.getOnlyElement(properties);
- assertEquals("ontest2",property.getName().toString());
- assertEquals("int",property.getType().getName());
- assertEquals("test2 property",property.getDescription());
- assertEquals("ontest2.png",property.getIcon().getSmallIcon());
- assertEquals("test2 event property",property.getDisplayname());
- assertEquals("3",property.getDefaultValue());
- assertEquals("15",property.getSuggestedValue());
- // CDK extensions.
- assertTrue(property.isGenerate());
- assertTrue(property.isHidden());
- assertTrue(property.isLiteral());
- assertTrue(property.isPassThrough());
- assertTrue(property.isRequired());
- List<ClassDescription> signature = property.getSignature();
- assertEquals(2, signature.size());
- Set<String> aliases = property.getAliases();
- assertEquals(2, aliases.size());
- }
+ assertEquals(3, properties.size());
+ }
+
+ @Test
+ public void xincludeTest() throws Exception {
+ FragmentParser parser = new FragmentParser();
+ CdkContextBase contextBase = new CdkContextBase(this.getClass().getClassLoader());
+
+ parser.init(contextBase);
+
+ Collection<Property> properties = parser.parseProperties("urn:resource:org/richfaces/cdk/xmlconfig/parent.xml");
+
+ assertEquals(2, properties.size());
+ }
+
+ @Test
+ public void nestedXincludeTest() throws Exception {
+ FragmentParser parser = new FragmentParser();
+ CdkContextBase contextBase = new CdkContextBase(this.getClass().getClassLoader());
+
+ parser.init(contextBase);
+
+ Collection<Property> properties =
+ parser.parseProperties("urn:resource:org/richfaces/cdk/xmlconfig/parent2.xml");
+
+ assertEquals(2, properties.size());
+ }
+
+ @Test
+ public void propertyTest() throws Exception {
+ FragmentParser parser = new FragmentParser();
+ CdkContextBase contextBase = new CdkContextBase(this.getClass().getClassLoader());
+
+ parser.init(contextBase);
+
+ Collection<Property> properties =
+ parser.parseProperties("urn:resource:org/richfaces/cdk/xmlconfig/properties.xml");
+
+ assertEquals(1, properties.size());
+
+ Property property = Iterables.getOnlyElement(properties);
+
+ assertEquals("ontest2", property.getName().toString());
+ assertEquals("int", property.getType().getName());
+ assertEquals("test2 property", property.getDescription());
+ assertEquals("ontest2.png", property.getIcon().getSmallIcon());
+ assertEquals("test2 event property", property.getDisplayname());
+ assertEquals("3", property.getDefaultValue());
+ assertEquals("15", property.getSuggestedValue());
+
+ // CDK extensions.
+ assertTrue(property.isGenerate());
+ assertTrue(property.isHidden());
+ assertTrue(property.isLiteral());
+ assertTrue(property.isPassThrough());
+ assertTrue(property.isRequired());
+
+ List<ClassDescription> signature = property.getSignature();
+
+ assertEquals(2, signature.size());
+
+ Set<String> aliases = property.getAliases();
+
+ assertEquals(2, aliases.size());
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/JAXBCopyTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/JAXBCopyTest.java 2009-11-01 16:21:55 UTC (rev 15790)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/JAXBCopyTest.java 2009-11-01 16:27:54 UTC (rev 15791)
@@ -5,6 +5,7 @@
import java.util.List;
import org.junit.Test;
+
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.model.ClassDescription;
import org.richfaces.cdk.model.Component;
@@ -13,38 +14,45 @@
import org.richfaces.cdk.xmlconfig.model.ComponentBean.ComponentExtension;
public class JAXBCopyTest {
+ private static final String BAZ = "baz";
+ private static final String FOO_BAR = "foo.Bar";
+ private static final String FOO_DESCTIPTION = "foo.Desctiption";
+ private static final String FOO_FAMILY = "foo.Family";
+ private static final String FOO_UI_BAR = "foo.UIBar";
- private static final String FOO_FAMILY = "foo.Family";
- private static final String BAZ = "baz";
- private static final String FOO_DESCTIPTION = "foo.Desctiption";
- private static final String FOO_UI_BAR = "foo.UIBar";
- private static final String FOO_BAR = "foo.Bar";
+ @Test
+ public void testCreateAdapter() throws Exception {
+ Component component = new Component(new Component.Type(FOO_BAR));
- @Test
- public void testCreateAdapter() throws Exception {
- Component component = new Component(new Component.Type(FOO_BAR));
- component.setDescription(FOO_DESCTIPTION);
- component.setComponentClass(new ClassDescription(FOO_UI_BAR));
- component.findOrCreateAttribute(BAZ);
- component.setFamily(FOO_FAMILY);
- ComponentBean componentBean = JAXBBinding.createAdapter(ComponentBean.class, component);
- assertEquals(FOO_BAR,componentBean.getType());
- List<Property> attributes = componentBean.getAttributes();
- assertEquals(1,attributes.size());
- assertEquals(BAZ,attributes.get(0).getName().toString());
- ComponentExtension extension = componentBean.getExtension();
- assertNotNull(extension);
- assertEquals(FOO_FAMILY, extension.getFamily());
- }
+ component.setDescription(FOO_DESCTIPTION);
+ component.setComponentClass(new ClassDescription(FOO_UI_BAR));
+ component.findOrCreateAttribute(BAZ);
+ component.setFamily(FOO_FAMILY);
- @Test
- public void testCopyExtensions() {
-// fail("Not yet implemented");
- }
+ ComponentBean componentBean = JAXBBinding.createAdapter(ComponentBean.class, component);
- @Test
- public void testCopyProperties() {
-// fail("Not yet implemented");
- }
+ assertEquals(FOO_BAR, componentBean.getType());
+ List<Property> attributes = componentBean.getAttributes();
+
+ assertEquals(1, attributes.size());
+ assertEquals(BAZ, attributes.get(0).getName().toString());
+
+ ComponentExtension extension = componentBean.getExtension();
+
+ assertNotNull(extension);
+ assertEquals(FOO_FAMILY, extension.getFamily());
+ }
+
+ @Test
+ public void testCopyExtensions() {
+
+// fail("Not yet implemented");
+ }
+
+ @Test
+ public void testCopyProperties() {
+
+// fail("Not yet implemented");
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/JaxbMarshalTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/JaxbMarshalTest.java 2009-11-01 16:21:55 UTC (rev 15790)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/JaxbMarshalTest.java 2009-11-01 16:27:54 UTC (rev 15791)
@@ -7,6 +7,7 @@
import javax.xml.transform.stream.StreamResult;
import org.junit.Test;
+
import org.richfaces.cdk.CdkContextBase;
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.model.Component;
@@ -15,21 +16,24 @@
import org.richfaces.cdk.xmlconfig.model.FacesConfigAdapter;
public class JaxbMarshalTest extends JaxbTestBase {
+ @Test
+ public void testMarshalResultStringT() throws Exception {
+ CdkContextBase contextBase = new CdkContextBase(this.getClass().getClassLoader());
+ JAXBBinding jaxbBinding = new JAXBBinding();
- @Test
- public void testMarshalResultStringT() throws Exception {
- CdkContextBase contextBase = new CdkContextBase(this.getClass().getClassLoader());
- JAXBBinding jaxbBinding = new JAXBBinding();
- jaxbBinding.init(contextBase);
- ComponentLibrary library = new ComponentLibrary();
- Component component = library.findOrCreateComponent("foo.bar");
- RenderKit renderKit = library.findOrCreateRenderKit("HTML");
- renderKit.findOrCreateRenderer("foo.Renderer");
- StringWriter writer = new StringWriter();
- StreamResult result = new StreamResult(writer);
- FacesConfigAdapter adapter = new FacesConfigAdapter();
- jaxbBinding.marshal(result, FacesConfigGenerator.FACES_SCHEMA_LOCATION, adapter.marshal(library));
- System.out.println(writer.toString());
- }
+ jaxbBinding.init(contextBase);
+ ComponentLibrary library = new ComponentLibrary();
+ Component component = library.findOrCreateComponent("foo.bar");
+ RenderKit renderKit = library.findOrCreateRenderKit("HTML");
+
+ renderKit.findOrCreateRenderer("foo.Renderer");
+
+ StringWriter writer = new StringWriter();
+ StreamResult result = new StreamResult(writer);
+ FacesConfigAdapter adapter = new FacesConfigAdapter();
+
+ jaxbBinding.marshal(result, FacesConfigGenerator.FACES_SCHEMA_LOCATION, adapter.marshal(library));
+ System.out.println(writer.toString());
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/JaxbTestBase.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/JaxbTestBase.java 2009-11-01 16:21:55 UTC (rev 15790)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/JaxbTestBase.java 2009-11-01 16:27:54 UTC (rev 15791)
@@ -9,40 +9,42 @@
import org.junit.Before;
public class JaxbTestBase {
+ protected static final String XML_PROLOG = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
- protected static final String XML_PROLOG = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
+ public JaxbTestBase() {
+ super();
+ }
- public JaxbTestBase() {
- super();
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @throws java.lang.Exception
+ */
+ @Before
+ public void setUp() throws Exception {}
- /**
- * <p class="changed_added_4_0"></p>
- * @throws java.lang.Exception
- */
- @Before
- public void setUp() throws Exception {
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @throws java.lang.Exception
+ */
+ @After
+ public void tearDown() throws Exception {}
- /**
- * <p class="changed_added_4_0"></p>
- * @throws java.lang.Exception
- */
- @After
- public void tearDown() throws Exception {
- }
+ protected <T> T unmarshal(Class<T> type, String src) {
+ StringBuilder xml = new StringBuilder(XML_PROLOG);
- protected <T> T unmarshal(Class<T> type, String src) {
- StringBuilder xml = new StringBuilder(XML_PROLOG);
- xml.append(src);
- StringReader reader = new StringReader(xml.toString());
- T result = JAXB.unmarshal(reader, type);
- return result;
- }
+ xml.append(src);
- protected <T> String marshal(T root){
- ByteArrayOutputStream xml = new ByteArrayOutputStream();
- JAXB.marshal(root, xml);
- return new String(xml.toByteArray());
- }
-}
\ No newline at end of file
+ StringReader reader = new StringReader(xml.toString());
+ T result = JAXB.unmarshal(reader, type);
+
+ return result;
+ }
+
+ protected <T> String marshal(T root) {
+ ByteArrayOutputStream xml = new ByteArrayOutputStream();
+
+ JAXB.marshal(root, xml);
+
+ return new String(xml.toByteArray());
+ }
+}
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/JaxbUnmarshalTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/JaxbUnmarshalTest.java 2009-11-01 16:21:55 UTC (rev 15790)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/JaxbUnmarshalTest.java 2009-11-01 16:27:54 UTC (rev 15791)
@@ -21,61 +21,78 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.xmlconfig;
import static org.easymock.EasyMock.*;
+
import static org.junit.Assert.*;
+
import static javax.lang.model.util.ElementFilter.*;
import java.io.StringReader;
+
import java.util.Set;
import javax.xml.bind.JAXB;
import org.junit.Test;
+
import org.richfaces.cdk.xmlconfig.testmodel.Child;
import org.richfaces.cdk.xmlconfig.testmodel.Root;
/**
* <p class="changed_added_4_0">
* </p>
- *
+ *
* @author asmirnov(a)exadel.com
- *
+ *
*/
public class JaxbUnmarshalTest extends JaxbTestBase {
+ @Test
+ public void testRootElement() throws Exception {
+ Root root =
+ unmarshal(
+ Root.class,
+ "<root-config xmlns='http://foo.bar/schema' ><name>foo</name><children><id>xxx</id><value>bar</value></children></root-config>");
- @Test
- public void testRootElement() throws Exception {
- Root root = unmarshal(
- Root.class,
- "<root-config xmlns='http://foo.bar/schema' ><name>foo</name><children><id>xxx</id><value>bar</value></children></root-config>");
- assertEquals("foo", root.getName());
- Set<Child> children = root.getChildren();
- assertEquals(1, children.size());
- assertEquals("xxx", children.iterator().next().getId());
- }
+ assertEquals("foo", root.getName());
- @Test
- public void testUniqueElement() throws Exception {
- Root root = unmarshal(
- Root.class,
- "<root-config xmlns='http://foo.bar/schema' ><name>foo</name><children><id>xxx</id><value>bar</value></children><children><id>xxx</id><value>baz</value></children></root-config>");
- assertEquals("foo", root.getName());
- Set<Child> children = root.getChildren();
- assertEquals(1, children.size());
- assertEquals("xxx", children.iterator().next().getId());
- }
-
- @Test
- public void testExtensions() throws Exception {
- Root root = unmarshal(
- Root.class,
- "<root-config xmlns='http://foo.bar/schema' ><name>foo</name><children><id>xxx</id><value>bar</value><extension><e:myExtension xmlns:e=\"http://foo.bar/extensions\">eee</e:myExtension><s:foo xmlns:s=\"urn:foo\">foo</s:foo></extension></children></root-config>");
- Set<Child> children = root.getChildren();
- assertEquals(1, children.size());
- Child child = children.iterator().next();
- assertEquals(1, child.getExtension().getExtensions().size());
- assertEquals("eee", child.getWrapped());
- }
+ Set<Child> children = root.getChildren();
+
+ assertEquals(1, children.size());
+ assertEquals("xxx", children.iterator().next().getId());
+ }
+
+ @Test
+ public void testUniqueElement() throws Exception {
+ Root root =
+ unmarshal(
+ Root.class,
+ "<root-config xmlns='http://foo.bar/schema' ><name>foo</name><children><id>xxx</id><value>bar</value></children><children><id>xxx</id><value>baz</value></children></root-config>");
+
+ assertEquals("foo", root.getName());
+
+ Set<Child> children = root.getChildren();
+
+ assertEquals(1, children.size());
+ assertEquals("xxx", children.iterator().next().getId());
+ }
+
+ @Test
+ public void testExtensions() throws Exception {
+ Root root =
+ unmarshal(
+ Root.class,
+ "<root-config xmlns='http://foo.bar/schema' ><name>foo</name><children><id>xxx</id><value>bar</value><extension><e:myExtension xmlns:e=\"http://foo.bar/extensions\">eee</e:myExtension><s:foo xmlns:s=\"urn:foo\">foo</s:foo></extension></children></root-config>");
+ Set<Child> children = root.getChildren();
+
+ assertEquals(1, children.size());
+
+ Child child = children.iterator().next();
+
+ assertEquals(1, child.getExtension().getExtensions().size());
+ assertEquals("eee", child.getWrapped());
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/Child.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/Child.java 2009-11-01 16:21:55 UTC (rev 15790)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/Child.java 2009-11-01 16:27:54 UTC (rev 15791)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.xmlconfig.testmodel;
import java.util.ArrayList;
@@ -39,172 +41,173 @@
* @author asmirnov(a)exadel.com
*
*/
-@XmlType(name="ChildType",namespace=Root.HTTP_FOO_BAR_SCHEMA)
+@XmlType(name = "ChildType", namespace = Root.HTTP_FOO_BAR_SCHEMA)
public class Child implements Id {
-
- /**
- * <p class="changed_added_4_0"></p>
- * @author asmirnov(a)exadel.com
- *
- */
- public static class Extension {
- private List<Element> extensions = new ArrayList<Element>();
-
- private Child parent;
+ private Extension extension;
+ private String id;
+ private String value;
+ private String wrapped;
- /**
- * <p class="changed_added_4_0"></p>
- * @return the myExtension
- */
- @XmlElement(namespace = Root.EXTENSIONS_NAMESPACE)
- public String getMyExtension() {
- return parent.getWrapped();
- }
+ /*
+ * (non-Javadoc)
+ * @see org.richfaces.cdk.xmlconfig.testmodel.Id#getId()
+ */
+ @Override
+ @XmlElement(namespace = Root.HTTP_FOO_BAR_SCHEMA)
+ public String getId() {
+ return id;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param myExtension the myExtension to set
- */
- public void setMyExtension(String myExtension) {
- parent.setWrapped(myExtension);
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param id the id to set
+ */
+ public void setId(String id) {
+ this.id = id;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the extensions
- */
- @XmlAnyElement
- public List<Element> getExtensions() {
- return extensions;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the value
+ */
+ @XmlElement(namespace = Root.HTTP_FOO_BAR_SCHEMA)
+ public String getValue() {
+ return value;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param extensions the extensions to set
- */
- public void setExtensions(List<Element> extensions) {
- this.extensions = extensions;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param value the value to set
+ */
+ public void setValue(String value) {
+ this.value = value;
+ }
- // This method is called immediately after the object is created and before the unmarshalling of this
- // object begins. The callback provides an opportunity to initialize JavaBean properties prior to unmarshalling.
- void beforeUnmarshal(Unmarshaller u, Object parent){
- this.parent = (Child) parent;
- }
-
- //This method is called after all the properties (except IDREF) are unmarshalled for this object,
- //but before this object is set to the parent object.
- void afterUnmarshal(Unmarshaller u, Object parent){
-
- }
- }
+ @XmlElement(namespace = Root.HTTP_FOO_BAR_SCHEMA)
+ public Extension getExtension() {
+ if (extension == null) {
+ extension = new Extension();
+ }
- private String id;
-
- private String value;
-
- private Extension extension;
-
- private String wrapped;
+ return extension;
+ }
+ public void setExtension(Extension extension) {
+ this.extension = extension;
+ }
- /* (non-Javadoc)
- * @see org.richfaces.cdk.xmlconfig.testmodel.Id#getId()
- */
- @Override
- @XmlElement(namespace = Root.HTTP_FOO_BAR_SCHEMA)
- public String getId() {
- return id;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the wrapped
+ */
+ public String getWrapped() {
+ return wrapped;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param id the id to set
- */
- public void setId(String id) {
- this.id = id;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param wrapped the wrapped to set
+ */
+ public void setWrapped(String wrapped) {
+ this.wrapped = wrapped;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the value
- */
- @XmlElement(namespace=Root.HTTP_FOO_BAR_SCHEMA)
- public String getValue() {
- return value;
- }
+ /*
+ * (non-Javadoc)
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
- /**
- * <p class="changed_added_4_0"></p>
- * @param value the value to set
- */
- public void setValue(String value) {
- this.value = value;
- }
+ result = prime * result + ((id == null) ? 0 : id.hashCode());
-
- @XmlElement(namespace=Root.HTTP_FOO_BAR_SCHEMA)
- public Extension getExtension(){
- if (extension == null) {
- extension = new Extension();
- }
- return extension;
- }
-
- public void setExtension(Extension extension) {
- this.extension = extension;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @return the wrapped
- */
- public String getWrapped() {
- return wrapped;
- }
+ return result;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param wrapped the wrapped to set
- */
- public void setWrapped(String wrapped) {
- this.wrapped = wrapped;
- }
+ /*
+ * (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
- /* (non-Javadoc)
- * @see java.lang.Object#hashCode()
- */
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((id == null) ? 0 : id.hashCode());
- return result;
- }
+ if (obj == null) {
+ return false;
+ }
- /* (non-Javadoc)
- * @see java.lang.Object#equals(java.lang.Object)
- */
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (!(obj instanceof Child)) {
- return false;
- }
- Child other = (Child) obj;
- if (id == null) {
- if (other.id != null) {
- return false;
- }
- } else if (!id.equals(other.id)) {
- return false;
- }
- return true;
- }
+ if (!(obj instanceof Child)) {
+ return false;
+ }
+ Child other = (Child) obj;
+
+ if (id == null) {
+ if (other.id != null) {
+ return false;
+ }
+ } else if (!id.equals(other.id)) {
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+ public static class Extension {
+ private List<Element> extensions = new ArrayList<Element>();
+ private Child parent;
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the myExtension
+ */
+ @XmlElement(namespace = Root.EXTENSIONS_NAMESPACE)
+ public String getMyExtension() {
+ return parent.getWrapped();
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param myExtension the myExtension to set
+ */
+ public void setMyExtension(String myExtension) {
+ parent.setWrapped(myExtension);
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the extensions
+ */
+ @XmlAnyElement
+ public List<Element> getExtensions() {
+ return extensions;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param extensions the extensions to set
+ */
+ public void setExtensions(List<Element> extensions) {
+ this.extensions = extensions;
+ }
+
+ // This method is called immediately after the object is created and before the unmarshalling of this
+ // object begins. The callback provides an opportunity to initialize JavaBean properties prior to unmarshalling.
+ void beforeUnmarshal(Unmarshaller u, Object parent) {
+ this.parent = (Child) parent;
+ }
+
+ // This method is called after all the properties (except IDREF) are unmarshalled for this object,
+ // but before this object is set to the parent object.
+ void afterUnmarshal(Unmarshaller u, Object parent) {}
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/Id.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/Id.java 2009-11-01 16:21:55 UTC (rev 15790)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/Id.java 2009-11-01 16:27:54 UTC (rev 15791)
@@ -4,11 +4,10 @@
public interface Id {
- /**
- * <p class="changed_added_4_0"></p>
- * @return the id
- */
- @XmlElement(namespace = Root.HTTP_FOO_BAR_SCHEMA)
- public String getId();
-
-}
\ No newline at end of file
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the id
+ */
+ @XmlElement(namespace = Root.HTTP_FOO_BAR_SCHEMA)
+ public String getId();
+}
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/Root.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/Root.java 2009-11-01 16:21:55 UTC (rev 15790)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/Root.java 2009-11-01 16:27:54 UTC (rev 15791)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.xmlconfig.testmodel;
import java.util.Set;
@@ -35,48 +37,44 @@
* @author asmirnov(a)exadel.com
*
*/
-@XmlRootElement(name="root-config",namespace=Root.HTTP_FOO_BAR_SCHEMA)
+@XmlRootElement(name = "root-config", namespace = Root.HTTP_FOO_BAR_SCHEMA)
public class Root {
+ public static final String EXTENSIONS_NAMESPACE = "http://foo.bar/extensions";
+ public static final String HTTP_FOO_BAR_SCHEMA = "http://foo.bar/schema";
+ private Set<Child> children = Sets.newHashSet();
+ private String name;
- public static final String HTTP_FOO_BAR_SCHEMA = "http://foo.bar/schema";
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the name
+ */
+ @XmlElement(namespace = HTTP_FOO_BAR_SCHEMA)
+ public String getName() {
+ return name;
+ }
- public static final String EXTENSIONS_NAMESPACE = "http://foo.bar/extensions";
-
- private String name;
-
- private Set<Child> children = Sets.newHashSet();
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param name the name to set
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the name
- */
- @XmlElement(namespace=HTTP_FOO_BAR_SCHEMA)
- public String getName() {
- return name;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the children
+ */
+ @XmlElement(namespace = HTTP_FOO_BAR_SCHEMA)
+ public Set<Child> getChildren() {
+ return children;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param name the name to set
- */
- public void setName(String name) {
- this.name = name;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @return the children
- */
- @XmlElement(namespace=HTTP_FOO_BAR_SCHEMA)
- public Set<Child> getChildren() {
- return children;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @param children the children to set
- */
- public void setChildren(Set<Child> children) {
- this.children = children;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param children the children to set
+ */
+ public void setChildren(Set<Child> children) {
+ this.children = children;
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlutils/XMLBodyMergeTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlutils/XMLBodyMergeTest.java 2009-11-01 16:21:55 UTC (rev 15790)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlutils/XMLBodyMergeTest.java 2009-11-01 16:27:54 UTC (rev 15791)
@@ -19,6 +19,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.xmlutils;
import junit.framework.TestCase;
@@ -29,54 +31,58 @@
*/
public class XMLBodyMergeTest extends TestCase {
- /* (non-Javadoc)
- * @see junit.framework.TestCase#setUp()
- */
- protected void setUp() throws Exception {
- super.setUp();
- }
+ /*
+ * (non-Javadoc)
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
- /* (non-Javadoc)
- * @see junit.framework.TestCase#tearDown()
- */
- protected void tearDown() throws Exception {
- super.tearDown();
- }
+ /*
+ * (non-Javadoc)
+ * @see junit.framework.TestCase#tearDown()
+ */
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
- /**
- * Test method for {@link org.richfaces.cdk.xmlutils.XMLBodyMerge#add(org.w3c.dom.Node)}.
- */
- public void testAddNode() {
- XMLBodyMerge merge = new XMLBodyMerge("//node()");
-
- }
+ /**
+ * Test method for {@link org.richfaces.cdk.xmlutils.XMLBodyMerge#add(org.w3c.dom.Node)}.
+ */
+ public void testAddNode() {
+ XMLBodyMerge merge = new XMLBodyMerge("//node()");
+ }
- /**
- * Test method for {@link org.richfaces.cdk.xmlutils.XMLBodyMerge#add(org.richfaces.cdk.xmlutils.XMLBody)}.
- */
- public void testAddXMLBody() {
- //fail("Not yet implemented");
- }
+ /**
+ * Test method for {@link org.richfaces.cdk.xmlutils.XMLBodyMerge#add(org.richfaces.cdk.xmlutils.XMLBody)}.
+ */
+ public void testAddXMLBody() {
- /**
- * Test method for {@link org.richfaces.cdk.xmlutils.XMLBodyMerge#getLength()}.
- */
- public void testGetLength() {
- //fail("Not yet implemented");
- }
+ // fail("Not yet implemented");
+ }
- /**
- * Test method for {@link org.richfaces.cdk.xmlutils.XMLBodyMerge#item(int)}.
- */
- public void testItem() {
- //fail("Not yet implemented");
- }
+ /**
+ * Test method for {@link org.richfaces.cdk.xmlutils.XMLBodyMerge#getLength()}.
+ */
+ public void testGetLength() {
- /**
- * Test method for {@link org.richfaces.cdk.xmlutils.XMLBodyMerge#getContent()}.
- */
- public void testGetContent() {
- //fail("Not yet implemented");
- }
+ // fail("Not yet implemented");
+ }
+ /**
+ * Test method for {@link org.richfaces.cdk.xmlutils.XMLBodyMerge#item(int)}.
+ */
+ public void testItem() {
+
+ // fail("Not yet implemented");
+ }
+
+ /**
+ * Test method for {@link org.richfaces.cdk.xmlutils.XMLBodyMerge#getContent()}.
+ */
+ public void testGetContent() {
+
+ // fail("Not yet implemented");
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlutils/XMLBodySerializerTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlutils/XMLBodySerializerTest.java 2009-11-01 16:21:55 UTC (rev 15790)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlutils/XMLBodySerializerTest.java 2009-11-01 16:27:54 UTC (rev 15791)
@@ -19,6 +19,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.xmlutils;
import java.io.ByteArrayInputStream;
@@ -34,53 +36,62 @@
*
*/
public class XMLBodySerializerTest extends TestCase {
+ private XMLBodySerializer serializer;
- private XMLBodySerializer serializer;
-
- /* (non-Javadoc)
- * @see junit.framework.TestCase#setUp()
- */
- protected void setUp() throws Exception {
- super.setUp();
- serializer = new XMLBodySerializer();
- }
+ /*
+ * (non-Javadoc)
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ serializer = new XMLBodySerializer();
+ }
- /* (non-Javadoc)
- * @see junit.framework.TestCase#tearDown()
- */
- protected void tearDown() throws Exception {
- serializer = null;
- super.tearDown();
- }
+ /*
+ * (non-Javadoc)
+ * @see junit.framework.TestCase#tearDown()
+ */
+ protected void tearDown() throws Exception {
+ serializer = null;
+ super.tearDown();
+ }
- /**
- * Test method for {@link org.richfaces.cdk.xmlutils.XMLBodySerializer#serialize(org.w3c.dom.NodeList, org.w3c.dom.Document)}.
- */
- public void testSerialize() throws ParsingException{
- String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
- + "<!DOCTYPE faces-config PUBLIC \"-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN\"\n"
- + " \"http://java.sun.com/dtd/web-facesconfig_1_1.dtd\">\n"
- + "<faces-config>\n" + " <component><test>blabla</test></component><component><test>blabla</test></component><component><test>blabla2</test></component>\n"
- + "</faces-config>";
- InputStream in = new ByteArrayInputStream(xml.getBytes());
- XMLBody body = new XMLBody();
- body.loadXML(in);
+ /**
+ * Test method for {@link org.richfaces.cdk.xmlutils.XMLBodySerializer#serialize(org.w3c.dom.NodeList, org.w3c.dom.Document)}.
+ */
+ public void testSerialize() throws ParsingException {
+ String xml =
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+ + "<!DOCTYPE faces-config PUBLIC \"-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN\"\n"
+ + " \"http://java.sun.com/dtd/web-facesconfig_1_1.dtd\">\n"
+ + "<faces-config>\n"
+ + " <component><test>blabla</test></component><component><test>blabla</test></component><component><test>blabla2</test></component>\n"
+ + "</faces-config>";
+ InputStream in = new ByteArrayInputStream(xml.getBytes());
+ XMLBody body = new XMLBody();
- NodeList singleElementList = body.getByXpath("/faces-config");
- assertEquals(1, singleElementList.getLength());
- Node node = singleElementList.item(0);
- assertNotNull(node);
- assertEquals("faces-config", node.getNodeName());
- String actual = serializer.serialize(singleElementList, node.getOwnerDocument()).replaceAll("\\s", "");
- String expected = "<faces-config><component><test>blabla</test></component><component><test>blabla</test></component><component><test>blabla2</test></component></faces-config>";
- assertEquals(expected, actual);
-
- NodeList children = node.getChildNodes();
- actual = serializer.serialize(children, node.getOwnerDocument()).replaceAll("\\s", "");
- expected = "<component><test>blabla</test></component><component><test>blabla</test></component><component><test>blabla2</test></component>";
- assertEquals(expected, actual);
-
-
- }
+ body.loadXML(in);
+ NodeList singleElementList = body.getByXpath("/faces-config");
+
+ assertEquals(1, singleElementList.getLength());
+
+ Node node = singleElementList.item(0);
+
+ assertNotNull(node);
+ assertEquals("faces-config", node.getNodeName());
+
+ String actual = serializer.serialize(singleElementList, node.getOwnerDocument()).replaceAll("\\s", "");
+ String expected =
+ "<faces-config><component><test>blabla</test></component><component><test>blabla</test></component><component><test>blabla2</test></component></faces-config>";
+
+ assertEquals(expected, actual);
+
+ NodeList children = node.getChildNodes();
+
+ actual = serializer.serialize(children, node.getOwnerDocument()).replaceAll("\\s", "");
+ expected =
+ "<component><test>blabla</test></component><component><test>blabla</test></component><component><test>blabla2</test></component>";
+ assertEquals(expected, actual);
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlutils/XMLBodyTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlutils/XMLBodyTest.java 2009-11-01 16:21:55 UTC (rev 15790)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlutils/XMLBodyTest.java 2009-11-01 16:27:54 UTC (rev 15791)
@@ -19,188 +19,196 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.xmlutils;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
+
import java.util.HashSet;
import junit.framework.TestCase;
/**
* @author shura
- *
+ *
*/
public class XMLBodyTest extends TestCase {
- /*
- * (non-Javadoc)
- *
- * @see junit.framework.TestCase#setUp()
- */
- protected void setUp() throws Exception {
- super.setUp();
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
- /*
- * (non-Javadoc)
- *
- * @see junit.framework.TestCase#tearDown()
- */
- protected void tearDown() throws Exception {
- super.tearDown();
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see junit.framework.TestCase#tearDown()
+ */
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
- /**
- * Test method for
- * {@link org.richfaces.cdk.xmlutils.XMLBody#loadXML(java.io.InputStream)}.
- *
- * @throws ParsingException
- */
- public void testLoadXML() throws ParsingException {
- String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
- + "<!DOCTYPE faces-config PUBLIC \"-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN\"\n"
- + " \"http://java.sun.com/dtd/web-facesconfig_1_1.dtd\">\n"
- + "<faces-config>\n"
- + " <component>\n"
- + " <component-type>org.richfaces.ajax.Test</component-type>\n"
- + " <component-class>org.richfaces.ajax.html.Test</component-class>\n"
- + "\n" + " <component-extension>\n"
- + " <component-family>org.richfaces.Test</component-family>\n"
- + " <renderer-type>org.richfaces.Test</renderer-type>\n"
- + " </component-extension>\n" + " </component>\n"
- + "</faces-config>";
- InputStream in = new ByteArrayInputStream(xml.getBytes());
- XMLBody body = new XMLBody();
- body.loadXML(in);
- }
+ /**
+ * Test method for
+ * {@link org.richfaces.cdk.xmlutils.XMLBody#loadXML(java.io.InputStream)}.
+ *
+ * @throws ParsingException
+ */
+ public void testLoadXML() throws ParsingException {
+ String xml =
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+ + "<!DOCTYPE faces-config PUBLIC \"-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN\"\n"
+ + " \"http://java.sun.com/dtd/web-facesconfig_1_1.dtd\">\n"
+ + "<faces-config>\n" + " <component>\n" + " <component-type>org.richfaces.ajax.Test</component-type>\n"
+ + " <component-class>org.richfaces.ajax.html.Test</component-class>\n" + "\n"
+ + " <component-extension>\n" + " <component-family>org.richfaces.Test</component-family>\n"
+ + " <renderer-type>org.richfaces.Test</renderer-type>\n" + " </component-extension>\n"
+ + " </component>\n" + "</faces-config>";
+ InputStream in = new ByteArrayInputStream(xml.getBytes());
+ XMLBody body = new XMLBody();
- /**
- * Test method for
- * {@link org.richfaces.cdk.xmlutils.XMLBody#isRootName(java.lang.String)}.
- *
- * @throws ParsingException
- */
- public void testIsRootName() throws ParsingException {
- String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
- + "<!DOCTYPE faces-config PUBLIC \"-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN\"\n"
- + " \"http://java.sun.com/dtd/web-facesconfig_1_1.dtd\">\n"
- + "<faces-config>\n" + " <component>\n" + " </component>\n"
- + "</faces-config>";
- InputStream in = new ByteArrayInputStream(xml.getBytes());
- XMLBody body = new XMLBody();
- body.loadXML(in);
- assertTrue(body.isRootName("faces-config"));
- assertEquals("faces-config", body.getDoctype());
- }
+ body.loadXML(in);
+ }
- /**
- * Test method for {@link org.richfaces.cdk.xmlutils.XMLBody#getDoctype()}.
- *
- * @throws ParsingException
- */
- public void testGetDoctype() throws ParsingException {
- String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
- + "<!DOCTYPE faces-config PUBLIC \"-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN\"\n"
- + " \"http://java.sun.com/dtd/web-facesconfig_1_1.dtd\">\n"
- + "<faces-config>\n" + " <component>\n" + " </component>\n"
- + "</faces-config>";
- InputStream in = new ByteArrayInputStream(xml.getBytes());
- XMLBody body = new XMLBody();
- body.loadXML(in);
- assertEquals(
- "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN",
- body.getPiblicId());
- }
+ /**
+ * Test method for
+ * {@link org.richfaces.cdk.xmlutils.XMLBody#isRootName(java.lang.String)}.
+ *
+ * @throws ParsingException
+ */
+ public void testIsRootName() throws ParsingException {
+ String xml =
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+ + "<!DOCTYPE faces-config PUBLIC \"-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN\"\n"
+ + " \"http://java.sun.com/dtd/web-facesconfig_1_1.dtd\">\n"
+ + "<faces-config>\n" + " <component>\n" + " </component>\n" + "</faces-config>";
+ InputStream in = new ByteArrayInputStream(xml.getBytes());
+ XMLBody body = new XMLBody();
- /**
- * Test method for
- * {@link org.richfaces.cdk.xmlutils.XMLBody#getRootNameSpace()}.
- *
- * @throws ParsingException
- */
- public void testGetRootNameSpace() throws ParsingException {
- String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
- + "<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd\">\n"
- + " <modelVersion>4.0.0</modelVersion>\n" + "</project>";
- InputStream in = new ByteArrayInputStream(xml.getBytes());
- XMLBody body = new XMLBody();
- body.loadXML(in);
- assertNull( body.getRootTypeName());
- }
+ body.loadXML(in);
+ assertTrue(body.isRootName("faces-config"));
+ assertEquals("faces-config", body.getDoctype());
+ }
- /**
- * Test method for {@link org.richfaces.cdk.xmlutils.XMLBody#getContent()}.
- *
- * @throws ParsingException
- */
- public void testGetContent() throws ParsingException {
- String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
- + "<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd\">"
- + "<modelVersion>4.0.0</modelVersion></project>";
- InputStream in = new ByteArrayInputStream(xml.getBytes());
- XMLBody body = new XMLBody();
- body.loadXML(in);
- assertEquals("<modelVersion>4.0.0</modelVersion>", body.getContent().trim());
- }
+ /**
+ * Test method for {@link org.richfaces.cdk.xmlutils.XMLBody#getDoctype()}.
+ *
+ * @throws ParsingException
+ */
+ public void testGetDoctype() throws ParsingException {
+ String xml =
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+ + "<!DOCTYPE faces-config PUBLIC \"-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN\"\n"
+ + " \"http://java.sun.com/dtd/web-facesconfig_1_1.dtd\">\n"
+ + "<faces-config>\n" + " <component>\n" + " </component>\n" + "</faces-config>";
+ InputStream in = new ByteArrayInputStream(xml.getBytes());
+ XMLBody body = new XMLBody();
- public void testGetContentXpath() throws ParsingException {
- String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
- + "<!DOCTYPE faces-config PUBLIC \"-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN\"\n"
- + " \"http://java.sun.com/dtd/web-facesconfig_1_1.dtd\">\n"
- + "<faces-config>\n" + " <component>blabla</component>\n"
- + "</faces-config>";
- InputStream in = new ByteArrayInputStream(xml.getBytes());
- XMLBody body = new XMLBody();
- body.loadXML(in);
- try {
- assertEquals(
- "<component>blabla</component>",
- body.getContent("/faces-config/component").trim());
- } catch (ParsingException e) {
- e.printStackTrace();
- assertTrue(e.getMessage(),false);
- }
- }
+ body.loadXML(in);
+ assertEquals("-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN", body.getPiblicId());
+ }
- public void testGetContentUnique() throws ParsingException {
- String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
- + "<!DOCTYPE faces-config PUBLIC \"-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN\"\n"
- + " \"http://java.sun.com/dtd/web-facesconfig_1_1.dtd\">\n"
- + "<faces-config>\n" + " <component><test>blabla</test></component><component><test>blabla</test></component><component><test>blabla2</test></component>\n"
- + "</faces-config>";
- InputStream in = new ByteArrayInputStream(xml.getBytes());
- XMLBody body = new XMLBody();
- body.loadXML(in);
- try {
- String expected = "<component><test>blabla</test></component><component><test>blabla2</test></component>";
- String actual = body.getContentUnique("/faces-config/component", "test/text()", new HashSet<String>()).replaceAll("\\s", "");
-
- assertEquals(
- expected,
- actual);
- } catch (ParsingException e) {
- e.printStackTrace();
- assertTrue(e.getMessage(),false);
- }
- }
-
- public void testGetContentWithNS() throws Exception {
- String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
- + "<f:faces-config xmlns=\"http://foo.bar\" xmlns:f=\"http://foo.baz\">"
- + "<f:component><test f:foo=\"xxx\">blabla</test></f:component>"
- + "</f:faces-config>";
- InputStream in = new ByteArrayInputStream(xml.getBytes());
- XMLBody body = new XMLBody();
- body.loadXML(in,true);
- try {
- assertEquals(
- "<f:component xmlns:f=\"http://foo.baz\"><test f:foo=\"xxx\" xmlns=\"http://foo.bar\">blabla</test></f:component>",
- body.getContent().replace("\r", "\n").replace("\n", ""));
- } catch (ParsingException e) {
- e.printStackTrace();
- assertTrue(e.getMessage(),false);
- }
-
- }
+ /**
+ * Test method for
+ * {@link org.richfaces.cdk.xmlutils.XMLBody#getRootNameSpace()}.
+ *
+ * @throws ParsingException
+ */
+ public void testGetRootNameSpace() throws ParsingException {
+ String xml =
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+ + "<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd\">\n"
+ + " <modelVersion>4.0.0</modelVersion>\n" + "</project>";
+ InputStream in = new ByteArrayInputStream(xml.getBytes());
+ XMLBody body = new XMLBody();
+
+ body.loadXML(in);
+ assertNull(body.getRootTypeName());
+ }
+
+ /**
+ * Test method for {@link org.richfaces.cdk.xmlutils.XMLBody#getContent()}.
+ *
+ * @throws ParsingException
+ */
+ public void testGetContent() throws ParsingException {
+ String xml =
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+ + "<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd\">"
+ + "<modelVersion>4.0.0</modelVersion></project>";
+ InputStream in = new ByteArrayInputStream(xml.getBytes());
+ XMLBody body = new XMLBody();
+
+ body.loadXML(in);
+ assertEquals("<modelVersion>4.0.0</modelVersion>", body.getContent().trim());
+ }
+
+ public void testGetContentXpath() throws ParsingException {
+ String xml =
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+ + "<!DOCTYPE faces-config PUBLIC \"-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN\"\n"
+ + " \"http://java.sun.com/dtd/web-facesconfig_1_1.dtd\">\n"
+ + "<faces-config>\n" + " <component>blabla</component>\n" + "</faces-config>";
+ InputStream in = new ByteArrayInputStream(xml.getBytes());
+ XMLBody body = new XMLBody();
+
+ body.loadXML(in);
+
+ try {
+ assertEquals("<component>blabla</component>", body.getContent("/faces-config/component").trim());
+ } catch (ParsingException e) {
+ e.printStackTrace();
+ assertTrue(e.getMessage(), false);
+ }
+ }
+
+ public void testGetContentUnique() throws ParsingException {
+ String xml =
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+ + "<!DOCTYPE faces-config PUBLIC \"-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN\"\n"
+ + " \"http://java.sun.com/dtd/web-facesconfig_1_1.dtd\">\n"
+ + "<faces-config>\n"
+ + " <component><test>blabla</test></component><component><test>blabla</test></component><component><test>blabla2</test></component>\n"
+ + "</faces-config>";
+ InputStream in = new ByteArrayInputStream(xml.getBytes());
+ XMLBody body = new XMLBody();
+
+ body.loadXML(in);
+
+ try {
+ String expected = "<component><test>blabla</test></component><component><test>blabla2</test></component>";
+ String actual = body.getContentUnique("/faces-config/component", "test/text()",
+ new HashSet<String>()).replaceAll("\\s", "");
+
+ assertEquals(expected, actual);
+ } catch (ParsingException e) {
+ e.printStackTrace();
+ assertTrue(e.getMessage(), false);
+ }
+ }
+
+ public void testGetContentWithNS() throws Exception {
+ String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+ + "<f:faces-config xmlns=\"http://foo.bar\" xmlns:f=\"http://foo.baz\">"
+ + "<f:component><test f:foo=\"xxx\">blabla</test></f:component>" + "</f:faces-config>";
+ InputStream in = new ByteArrayInputStream(xml.getBytes());
+ XMLBody body = new XMLBody();
+
+ body.loadXML(in, true);
+
+ try {
+ assertEquals(
+ "<f:component xmlns:f=\"http://foo.baz\"><test f:foo=\"xxx\" xmlns=\"http://foo.bar\">blabla</test></f:component>",
+ body.getContent().replace("\r", "\n").replace("\n", ""));
+ } catch (ParsingException e) {
+ e.printStackTrace();
+ assertTrue(e.getMessage(), false);
+ }
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlutils/XPathComparatorTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlutils/XPathComparatorTest.java 2009-11-01 16:21:55 UTC (rev 15790)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlutils/XPathComparatorTest.java 2009-11-01 16:27:54 UTC (rev 15791)
@@ -19,6 +19,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.xmlutils;
import java.io.ByteArrayInputStream;
@@ -35,59 +37,62 @@
*/
public class XPathComparatorTest extends TestCase {
- /* (non-Javadoc)
- * @see junit.framework.TestCase#setUp()
- */
- protected void setUp() throws Exception {
- super.setUp();
- }
+ /*
+ * (non-Javadoc)
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
- /* (non-Javadoc)
- * @see junit.framework.TestCase#tearDown()
- */
- protected void tearDown() throws Exception {
- super.tearDown();
- }
+ /*
+ * (non-Javadoc)
+ * @see junit.framework.TestCase#tearDown()
+ */
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
- public void testCompare() throws Exception{
- String xml = "<faces-config>" +
- "<component><test>blabla1</test></component>" +
- "<component><test>blabla</test></component>" +
- "<renderer><foo>blabla2</foo></renderer>" +
- "<component><test>blabla2</test></component>"
- + "</faces-config>";
- InputStream in = new ByteArrayInputStream(xml.getBytes());
- XMLBody body = new XMLBody();
- body.loadXML(in);
- NodeList list = body.getByXpath("//component|//renderer");
- assertEquals(4, list.getLength());
- Node node0 = list.item(0);
- Node node1 = list.item(1);
- Node node2 = list.item(2);
- Node node3 = list.item(3);
-
- XPathComparator dummyComparator = new XPathComparator();
- assertEquals(0, dummyComparator.compare(node0, node1));
- assertEquals(0, dummyComparator.compare(node1, node2));
- assertEquals(0, dummyComparator.compare(node0, node2));
- assertEquals(0, dummyComparator.compare(node0, node3));
- assertEquals(0, dummyComparator.compare(node2, node3));
- assertEquals(0, dummyComparator.compare(node1, node0));
- assertEquals(0, dummyComparator.compare(node2, node1));
- assertEquals(0, dummyComparator.compare(node2, node0));
-
- XPathComparator simpleComparator = new XPathComparator("local-name()");
- assertEquals(0, simpleComparator.compare(node0, node1));
- assertEquals(0, simpleComparator.compare(node0, node3));
- assertTrue(simpleComparator.compare(node0, node2) < 0);
- assertTrue(simpleComparator.compare(node2, node1) > 0);
-
- XPathComparator advancedComparator = new XPathComparator("local-name()", "test/text()", "foo/text()");
- assertTrue(advancedComparator.compare(node0, node2) < 0);
- assertTrue(advancedComparator.compare(node2, node1) > 0);
- assertTrue(advancedComparator.compare(node0, node1) > 0);
- assertTrue(advancedComparator.compare(node1, node0) < 0);
-
-
- }
+ public void testCompare() throws Exception {
+ String xml = "<faces-config>" + "<component><test>blabla1</test></component>"
+ + "<component><test>blabla</test></component>" + "<renderer><foo>blabla2</foo></renderer>"
+ + "<component><test>blabla2</test></component>" + "</faces-config>";
+ InputStream in = new ByteArrayInputStream(xml.getBytes());
+ XMLBody body = new XMLBody();
+
+ body.loadXML(in);
+
+ NodeList list = body.getByXpath("//component|//renderer");
+
+ assertEquals(4, list.getLength());
+
+ Node node0 = list.item(0);
+ Node node1 = list.item(1);
+ Node node2 = list.item(2);
+ Node node3 = list.item(3);
+ XPathComparator dummyComparator = new XPathComparator();
+
+ assertEquals(0, dummyComparator.compare(node0, node1));
+ assertEquals(0, dummyComparator.compare(node1, node2));
+ assertEquals(0, dummyComparator.compare(node0, node2));
+ assertEquals(0, dummyComparator.compare(node0, node3));
+ assertEquals(0, dummyComparator.compare(node2, node3));
+ assertEquals(0, dummyComparator.compare(node1, node0));
+ assertEquals(0, dummyComparator.compare(node2, node1));
+ assertEquals(0, dummyComparator.compare(node2, node0));
+
+ XPathComparator simpleComparator = new XPathComparator("local-name()");
+
+ assertEquals(0, simpleComparator.compare(node0, node1));
+ assertEquals(0, simpleComparator.compare(node0, node3));
+ assertTrue(simpleComparator.compare(node0, node2) < 0);
+ assertTrue(simpleComparator.compare(node2, node1) > 0);
+
+ XPathComparator advancedComparator = new XPathComparator("local-name()", "test/text()", "foo/text()");
+
+ assertTrue(advancedComparator.compare(node0, node2) < 0);
+ assertTrue(advancedComparator.compare(node2, node1) > 0);
+ assertTrue(advancedComparator.compare(node0, node1) > 0);
+ assertTrue(advancedComparator.compare(node1, node0) < 0);
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/test/java/test/TestComponent.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/test/TestComponent.java 2009-11-01 16:21:55 UTC (rev 15790)
+++ root/cdk/trunk/plugins/generator/src/test/java/test/TestComponent.java 2009-11-01 16:27:54 UTC (rev 15791)
@@ -19,33 +19,23 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package test;
-
-import javax.faces.component.UIInput;
+package test;
-
+import javax.faces.component.UIInput;
-/**
+/**
+ *
+ * @author shura (latest modification by $Author$)
+ *
+ * @version $Revision$ $Date$
+ *
+ *
+ *
+ */
+public abstract class TestComponent extends UIInput {
+ public abstract String getMyProperty();
- * @author shura (latest modification by $Author$)
-
- * @version $Revision$ $Date$
-
- *
-
- */
-
-public abstract class TestComponent extends UIInput {
-
-
-
- public abstract String getMyProperty();
-
-
-
- public abstract void setMyProperty(String myProperty);
-
-}
-
+ public abstract void setMyProperty(String myProperty);
+}
Modified: root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/apt/TestClass.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/apt/TestClass.java 2009-11-01 16:21:55 UTC (rev 15790)
+++ root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/apt/TestClass.java 2009-11-01 16:27:54 UTC (rev 15791)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.apt;
/**
@@ -29,6 +31,4 @@
*
*/
@TestAnnotation("foo")
-public class TestClass {
-
-}
+public class TestClass {}
Modified: root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/apt/TestInterface.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/apt/TestInterface.java 2009-11-01 16:21:55 UTC (rev 15790)
+++ root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/apt/TestInterface.java 2009-11-01 16:27:54 UTC (rev 15791)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.apt;
/**
@@ -30,10 +32,8 @@
*/
@TestInterfaceAnnotation
public interface TestInterface {
-
- @TestMethodAnnotation("baz")
- public String getValue();
-
- public void setValue(String value);
+ @TestMethodAnnotation("baz")
+ public String getValue();
+ public void setValue(String value);
}
Modified: root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/apt/TestSubClass.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/apt/TestSubClass.java 2009-11-01 16:21:55 UTC (rev 15790)
+++ root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/apt/TestSubClass.java 2009-11-01 16:27:54 UTC (rev 15791)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.apt;
/**
@@ -30,23 +32,22 @@
*/
@TestAnnotation2("subclass")
public class TestSubClass extends TestClass implements TestInterface {
+ private String value;
- private String value;
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param value the value to set
+ */
+ @TestMethodAnnotation("setter")
+ public void setValue(String value) {
+ this.value = value;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param value the value to set
- */
- @TestMethodAnnotation("setter")
- public void setValue(String value) {
- this.value = value;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @return the value
- */
- public String getValue() {
- return value;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the value
+ */
+ public String getValue() {
+ return value;
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/test/component/AbstractTestComponent.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/test/component/AbstractTestComponent.java 2009-11-01 16:21:55 UTC (rev 15790)
+++ root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/test/component/AbstractTestComponent.java 2009-11-01 16:27:54 UTC (rev 15791)
@@ -21,12 +21,15 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.test.component;
import org.richfaces.cdk.annotations.Attribute;
import org.richfaces.cdk.annotations.Component;
import java.util.List;
+
import javax.faces.component.UIComponent;
import javax.faces.component.ValueHolder;
@@ -36,24 +39,20 @@
*
*/
@Component("org.richfaces.cdk.test.TestComponent")
-public abstract class AbstractTestComponent extends UIComponent implements
- ValueHolder {
-
-
- private static final String COMPONENT_FAMILY="org.richfaces.Test";
-
- @Attribute
- private int foo;
-
- /**
- * Test Attribute
- */
- @Attribute
- public abstract List<String> getTestValue();
+public abstract class AbstractTestComponent extends UIComponent implements ValueHolder {
+ private static final String COMPONENT_FAMILY = "org.richfaces.Test";
+ @Attribute
+ private int foo;
- /**
- * Bar Attribute
- */
- @Attribute
- public abstract <M> void setBarValue(List<M> bar);
+ /**
+ * Test Attribute
+ */
+ @Attribute
+ public abstract List<String> getTestValue();
+
+ /**
+ * Bar Attribute
+ */
+ @Attribute
+ public abstract <M> void setBarValue(List<M> bar);
}
Modified: root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/test/component/UITestCommand.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/test/component/UITestCommand.java 2009-11-01 16:21:55 UTC (rev 15790)
+++ root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/test/component/UITestCommand.java 2009-11-01 16:27:54 UTC (rev 15791)
@@ -21,9 +21,12 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.test.component;
import javax.el.MethodExpression;
+
import javax.faces.component.ActionSource2;
import javax.faces.component.FacesComponent;
import javax.faces.component.UIComponentBase;
@@ -37,96 +40,110 @@
*/
@FacesComponent("cdk.TestCommand")
public class UITestCommand extends UIComponentBase implements ActionSource2 {
-
- private static final String COMPONENT_FAMILY="cdk.TestFamily";
+ private static final String COMPONENT_FAMILY = "cdk.TestFamily";
- /* (non-Javadoc)
- * @see javax.faces.component.UIComponent#getFamily()
- */
- @Override
- public String getFamily() {
- return COMPONENT_FAMILY;
- }
+ /*
+ * (non-Javadoc)
+ * @see javax.faces.component.UIComponent#getFamily()
+ */
+ @Override
+ public String getFamily() {
+ return COMPONENT_FAMILY;
+ }
- /* (non-Javadoc)
- * @see javax.faces.component.ActionSource#addActionListener(javax.faces.event.ActionListener)
- */
- public void addActionListener(ActionListener listener) {
- // TODO Auto-generated method stub
+ /*
+ * (non-Javadoc)
+ * @see javax.faces.component.ActionSource#addActionListener(javax.faces.event.ActionListener)
+ */
+ public void addActionListener(ActionListener listener) {
- }
+ // TODO Auto-generated method stub
+ }
- /* (non-Javadoc)
- * @see javax.faces.component.ActionSource#getAction()
- */
- public MethodBinding getAction() {
- // TODO Auto-generated method stub
- return null;
- }
+ /*
+ * (non-Javadoc)
+ * @see javax.faces.component.ActionSource#getAction()
+ */
+ public MethodBinding getAction() {
- /* (non-Javadoc)
- * @see javax.faces.component.ActionSource#getActionListener()
- */
- public MethodBinding getActionListener() {
- // TODO Auto-generated method stub
- return null;
- }
+ // TODO Auto-generated method stub
+ return null;
+ }
- /* (non-Javadoc)
- * @see javax.faces.component.ActionSource#getActionListeners()
- */
- public ActionListener[] getActionListeners() {
- // TODO Auto-generated method stub
- return null;
- }
+ /*
+ * (non-Javadoc)
+ * @see javax.faces.component.ActionSource#getActionListener()
+ */
+ public MethodBinding getActionListener() {
- /* (non-Javadoc)
- * @see javax.faces.component.ActionSource#isImmediate()
- */
- public boolean isImmediate() {
- // TODO Auto-generated method stub
- return false;
- }
+ // TODO Auto-generated method stub
+ return null;
+ }
- /* (non-Javadoc)
- * @see javax.faces.component.ActionSource#removeActionListener(javax.faces.event.ActionListener)
- */
- public void removeActionListener(ActionListener listener) {
- // TODO Auto-generated method stub
+ /*
+ * (non-Javadoc)
+ * @see javax.faces.component.ActionSource#getActionListeners()
+ */
+ public ActionListener[] getActionListeners() {
- }
+ // TODO Auto-generated method stub
+ return null;
+ }
- /* (non-Javadoc)
- * @see javax.faces.component.ActionSource#setAction(javax.faces.el.MethodBinding)
- */
- public void setAction(MethodBinding action) {
- // TODO Auto-generated method stub
+ /*
+ * (non-Javadoc)
+ * @see javax.faces.component.ActionSource#isImmediate()
+ */
+ public boolean isImmediate() {
- }
+ // TODO Auto-generated method stub
+ return false;
+ }
- /* (non-Javadoc)
- * @see javax.faces.component.ActionSource#setActionListener(javax.faces.el.MethodBinding)
- */
- public void setActionListener(MethodBinding actionListener) {
- // TODO Auto-generated method stub
+ /*
+ * (non-Javadoc)
+ * @see javax.faces.component.ActionSource#removeActionListener(javax.faces.event.ActionListener)
+ */
+ public void removeActionListener(ActionListener listener) {
- }
+ // TODO Auto-generated method stub
+ }
- public void setActionExpression(MethodExpression action) {
- // TODO Auto-generated method stub
-
- }
- /* (non-Javadoc)
- * @see javax.faces.component.ActionSource#setImmediate(boolean)
- */
- public void setImmediate(boolean immediate) {
- // TODO Auto-generated method stub
+ /*
+ * (non-Javadoc)
+ * @see javax.faces.component.ActionSource#setAction(javax.faces.el.MethodBinding)
+ */
+ public void setAction(MethodBinding action) {
- }
+ // TODO Auto-generated method stub
+ }
- public MethodExpression getActionExpression() {
- // TODO Auto-generated method stub
- return null;
- }
+ /*
+ * (non-Javadoc)
+ * @see javax.faces.component.ActionSource#setActionListener(javax.faces.el.MethodBinding)
+ */
+ public void setActionListener(MethodBinding actionListener) {
+ // TODO Auto-generated method stub
+ }
+
+ public void setActionExpression(MethodExpression action) {
+
+ // TODO Auto-generated method stub
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see javax.faces.component.ActionSource#setImmediate(boolean)
+ */
+ public void setImmediate(boolean immediate) {
+
+ // TODO Auto-generated method stub
+ }
+
+ public MethodExpression getActionExpression() {
+
+ // TODO Auto-generated method stub
+ return null;
+ }
}
15 years, 1 month
JBoss Rich Faces SVN: r15790 - in root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk: apt and 12 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: Alex.Kolonitsky
Date: 2009-11-01 11:21:55 -0500 (Sun, 01 Nov 2009)
New Revision: 15790
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/CdkContextBase.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkError.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkException.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkProcessingError.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkWorker.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkWriter.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/DummyBuilder.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/DummyGenerator.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/JavaLogger.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/Logger.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/LoggerFactory.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/StandardOutputFolders.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/StandardOutputs.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/StandardSources.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/AptException.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/apt/VirtualFileManager.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/VirtualJavaClassPathObject.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/VirtualJavaFileObject.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/VirtualJavaFileSystemObject.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/CdkConfiguration.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/ComponentTemplateModel.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/FreeMarkerRenderer.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/LibraryModelWrapper.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/PropertyModel.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/model/Attribute.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Behavior.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/BehaviorRenderer.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ClassDescription.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Component.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ComponentLibrary.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ConfigExtension.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Converter.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/DescriptionGroup.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Event.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/EventName.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Extensible.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Facet.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/InvalidNameException.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Key.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/LibraryVisitor.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Listener.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Merge.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Mergeable.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ModelCollection.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ModelElement.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ModelElementBase.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Name.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Properties.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Property.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/RenderKit.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Renderer.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Searchable.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/SearchableCollection.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Tag.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/TagLibrary.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Trackable.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Validator.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Visitable.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/package-info.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/package-info.java
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/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/main/java/org/richfaces/cdk/util/PropertyUtils.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/util/Strings.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/FacesConfigGenerator.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FacesConfigNamespacePreffixMapper.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/JAXBBinding.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/AttributeAdapter.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/AttributeBean.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/BehaviorRendererAdapter.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/BehaviorRendererBean.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ClassAdapter.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ClassBean.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/DescriptionGroupBean.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/EventAdapter.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/EventBean.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ExtensibleBean.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/main/java/org/richfaces/cdk/xmlconfig/model/FacetAdapter.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/FacetBean.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/PropertyAdapter.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/PropertyBean.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/RenderKitAdapter.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/RenderKitBean.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/RendererAdapter.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/RendererBean.java
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/xmlutils/NamesListComparator.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/ParsingException.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/XMLBody.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/XMLBodyMerge.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/XMLBodySerializer.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/XPathComparator.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/dtd/Attribute.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/dtd/DocumentDefinition.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/dtd/DocumentDefinitionFactory.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/dtd/Element.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/dtd/Node.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/dtd/wutka/WutkaDefinitionFactory.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/dtd/xerces/XercesDefinitionFactory.java
Log:
Code style policy
https://jira.jboss.org/jira/browse/RFPL-195
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-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkContext.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -4,90 +4,87 @@
import org.richfaces.cdk.CdkWriter.OutputType;
-
-
/**
* <p class="changed_added_4_0">
* That interface defines context for all CDK operations
* </p>
- *
+ *
* @author asmirnov(a)exadel.com
- *
+ *
*/
public interface CdkContext {
-
- /**
- * <p class="changed_added_4_0">Id of source files e.g. Java classes, faces-configs, renderer templates</p>
- * @author asmirnov(a)exadel.com
- *
- */
- public interface SourceType {
- String getName();
- }
- /**
- * <p class="changed_added_4_0">
- * Tools classloader.
- * </p>
- *
- * @return the loader
- */
- public ClassLoader getLoader();
+ /**
+ * <p class="changed_added_4_0">
+ * Tools classloader.
+ * </p>
+ *
+ * @return the loader
+ */
+ public ClassLoader getLoader();
- /**
- * <p class="changed_added_4_0">Get all sources for given type.</p>
- * @param type
- * @return
- */
- public Iterable<File> getSources(SourceType type);
-
- /**
- * <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">This method creates output file in the appropriate output folder. If target file exists and its modification time is late than model modification time from {@code lastModified} parameter, no new file will be created.</p>
- * @param output target output folder.
- * @param relativePath path to file in the output folder.
- * @param lastModified model modification time. If that parameter is less then 0, no checks for existing file will be performed.
- * @return new created file or null if the target file exists and its modification time is late then model.
- */
- public File createOutputFile(OutputType output,String relativePath,long lastModified) throws CdkException;
- /**
- * <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);
+ /**
+ * <p class="changed_added_4_0">Get all sources for given type.</p>
+ * @param type
+ * @return
+ */
+ public Iterable<File> getSources(SourceType type);
- public abstract Iterable<CdkError> getErrors();
+ /**
+ * <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"></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;
-
- /**
- * <p class="changed_added_4_0">Get value of configuration option.</p>
- * TODO make it type safe.
- * @param name option name.
- * @return option value or null.
- */
- public String getOption(String name);
+ /**
+ * <p class="changed_added_4_0">This method creates output file in the appropriate output folder. If target file exists and its modification time is late than model modification time from {@code lastModified} parameter, no new file will be created.</p>
+ * @param output target output folder.
+ * @param relativePath path to file in the output folder.
+ * @param lastModified model modification time. If that parameter is less then 0, no checks for existing file will be performed.
+ * @return new created file or null if the target file exists and its modification time is late then model.
+ */
+ public File createOutputFile(OutputType output, String relativePath, long lastModified) throws CdkException;
-}
\ No newline at end of file
+ /**
+ * <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 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;
+
+ /**
+ * <p class="changed_added_4_0">Get value of configuration option.</p>
+ * TODO make it type safe.
+ * @param name option name.
+ * @return option value or null.
+ */
+ public String getOption(String name);
+
+ /**
+ * <p class="changed_added_4_0">Id of source files e.g. Java classes, faces-configs, renderer templates</p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+ public interface SourceType {
+ String getName();
+ }
+}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkContextBase.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkContextBase.java 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkContextBase.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -21,20 +21,22 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+
+import org.richfaces.cdk.CdkWriter.OutputType;
+
import java.io.File;
import java.io.IOException;
+
import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import org.richfaces.cdk.CdkWriter.OutputType;
-import org.richfaces.cdk.model.ComponentLibrary;
-
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-
/**
* <p class="changed_added_4_0">Base CDK context class. Particular build tool ( Ant, Maven ) should extend that class with
* tool-specific methods.</p>
@@ -42,156 +44,161 @@
*
*/
public class CdkContextBase implements CdkContext {
+ private Map<String, String> options = Maps.newHashMap();
+ private Map<SourceType, Iterable<File>> sources = Maps.newHashMap();
+ private Map<OutputType, File> outputs = 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();
+ private final ClassLoader loader;
- private final ClassLoader loader;
-
- private Map<String, String> options = Maps.newHashMap();
+ public CdkContextBase(ClassLoader loader) {
+ this.loader = loader;
+ }
- private Map<SourceType, Iterable<File>> sources = Maps.newHashMap();
-
- private Map<OutputType,File> outputs = Maps.newHashMap();
-
- private Map<SourceType,Iterable<File>> inputFolders = Maps.newHashMap();
+ /*
+ * (non-Javadoc)
+ * @see org.richfaces.cdk.CdkContext#getLoader()
+ */
+ public ClassLoader getLoader() {
+ return loader;
+ }
- private Map<Class<? extends CdkWorker>,CdkWorker> workers = Maps.newHashMap();
+ public void addSources(SourceType type, Iterable<File> files) {
+ sources.put(type, files);
+ }
- private List<CdkError> errors = Lists.newArrayList();
+ @Override
+ public Iterable<File> getSources(SourceType type) {
+ return sources.get(type);
+ }
- public CdkContextBase(ClassLoader loader) {
- this.loader = loader;
- }
+ @Override
+ public File getOutputFolder(OutputType type) {
+ File outputFolder = outputs.get(type);
+ OutputType folderType = type.getFolderType();
- /* (non-Javadoc)
- * @see org.richfaces.cdk.CdkContext#getLoader()
- */
- public ClassLoader getLoader() {
- return loader;
- }
+ if (null == outputFolder && null != folderType) {
- public void addSources(SourceType type,Iterable<File> files) {
- sources.put(type, files);
- }
-
- @Override
- public Iterable<File> getSources(SourceType type) {
- return sources.get(type);
- }
+ // Lookup for standard folder type.
+ outputFolder = outputs.get(folderType);
- @Override
- public File getOutputFolder(OutputType type) {
- File outputFolder = outputs.get(type);
- OutputType folderType = type.getFolderType();
- if(null == outputFolder && null != folderType){
- // Lookup for standard folder type.
- outputFolder = outputs.get(folderType);
- // Lookup for output with same folder type.
- Iterator<OutputType> keysIterator = outputs.keySet().iterator();
- while (null == outputFolder && keysIterator.hasNext()) {
- CdkWriter.OutputType outputType = (CdkWriter.OutputType) keysIterator
- .next();
- if(folderType.equals(outputType.getFolderType())){
- outputFolder = outputs.get(outputType);
- }
- }
- }
- return outputFolder;
- }
+ // Lookup for output with same folder type.
+ Iterator<OutputType> keysIterator = outputs.keySet().iterator();
-
- 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;
- }
-
+ while (null == outputFolder && keysIterator.hasNext()) {
+ CdkWriter.OutputType outputType = (CdkWriter.OutputType) keysIterator.next();
- @Override
- public Iterable<File> getSourceFolders(SourceType type) {
- return inputFolders.get(type);
- }
-
-
- public void setSourceFolders(SourceType type, Iterable<File> folders){
- inputFolders.put(type, folders);
- }
+ if (folderType.equals(outputType.getFolderType())) {
+ outputFolder = outputs.get(outputType);
+ }
+ }
+ }
- @Override
- public <W extends CdkWorker> W getWorkerInstance(Class<W> workerClass)
- throws CdkException {
- CdkWorker worker = workers.get(workerClass);
- if(null == worker){
- // 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;
- }
-
+ return outputFolder;
+ }
- public void addWorker(Class<? extends CdkWorker> workerClass, CdkWorker workerInstance) {
- workers.put(workerClass, workerInstance);
- }
+ public void setOutputFolder(OutputType type, File folder) {
+ outputs.put(type, folder);
+ }
- @Override
- public File createOutputFile(OutputType output, String relativePath,
- long lastModified) throws CdkException {
- if(null == relativePath){
- throw new NullPointerException();
- }
- File outputFolder = getOutputFolder(output);
- if(null == outputFolder){
- throw new CdkException("No output folder for type "+output.getName());
- }
- if(outputFolder.exists() && !outputFolder.isDirectory()){
- throw new CdkException("Output folder "+outputFolder+" not is directory.");
- }
- // Strip leading '/'
- if(relativePath.startsWith(File.separator)){
- relativePath = relativePath.substring(1);
- }
- File outputFile = new File(outputFolder,relativePath);
- if(outputFile.exists()){
- if(lastModified > 0 && outputFile.lastModified() > lastModified){
- return null;
- } else {
- outputFile.delete();
- }
- }
- // Create file folder.
- outputFile.getParentFile().mkdirs();
- try {
- outputFile.createNewFile();
- } catch (IOException e) {
- throw new CdkException("Error create output file", e);
- }
- return outputFile;
- }
+ @Override
+ public void sendError(CdkError error) {
+ errors.add(error);
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param options the options to set
- */
- public void setOptions(Map<String, String> options) {
- this.options.putAll(options);
- }
-
- @Override
- public String getOption(String name) {
- return options.get(name);
- }
+ @Override
+ public Iterable<CdkError> getErrors() {
+ return errors;
+ }
+
+ @Override
+ 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) {
+
+ // 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 void addWorker(Class<? extends CdkWorker> workerClass, CdkWorker workerInstance) {
+ workers.put(workerClass, workerInstance);
+ }
+
+ @Override
+ public File createOutputFile(OutputType output, String relativePath, long lastModified) throws CdkException {
+ if (null == relativePath) {
+ throw new NullPointerException();
+ }
+
+ File outputFolder = getOutputFolder(output);
+
+ if (null == outputFolder) {
+ throw new CdkException("No output folder for type " + output.getName());
+ }
+
+ if (outputFolder.exists() && !outputFolder.isDirectory()) {
+ throw new CdkException("Output folder " + outputFolder + " not is directory.");
+ }
+
+ // Strip leading '/'
+ if (relativePath.startsWith(File.separator)) {
+ relativePath = relativePath.substring(1);
+ }
+
+ File outputFile = new File(outputFolder, relativePath);
+
+ if (outputFile.exists()) {
+ if (lastModified > 0 && outputFile.lastModified() > lastModified) {
+ return null;
+ } else {
+ outputFile.delete();
+ }
+ }
+
+ // Create file folder.
+ outputFile.getParentFile().mkdirs();
+
+ try {
+ outputFile.createNewFile();
+ } catch (IOException e) {
+ throw new CdkException("Error create output file", e);
+ }
+
+ return outputFile;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param options the options to set
+ */
+ public void setOptions(Map<String, String> options) {
+ this.options.putAll(options);
+ }
+
+ @Override
+ public String getOption(String name) {
+ return options.get(name);
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkError.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkError.java 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkError.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk;
/**
@@ -29,29 +31,49 @@
*
*/
public class CdkError {
-
- private String message;
-
- private String description;
-
- private Throwable cause;
+ private Throwable cause;
+ private String description;
+ private String message;
- /**
- * <p class="changed_added_4_0"></p>
- * @param message
- */
- public CdkError(String message) {
- this.message = message;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param message
+ */
+ public CdkError(String message) {
+ this.message = message;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param message
- * @param cause
- */
- public CdkError(String message, Throwable cause) {
- this.message = message;
- this.cause = cause;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param message
+ * @param cause
+ */
+ public CdkError(String message, Throwable cause) {
+ this.message = message;
+ this.cause = cause;
+ }
+ public Throwable getCause() {
+ return cause;
+ }
+
+ public void setCause(Throwable cause) {
+ this.cause = cause;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkException.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkException.java 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkException.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk;
/**
@@ -30,35 +32,33 @@
*/
public class CdkException extends Exception {
- /**
- * <p class="changed_added_4_0"></p>
- */
- public CdkException() {
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ */
+ public CdkException() {}
- /**
- * <p class="changed_added_4_0"></p>
- * @param message
- */
- public CdkException(String message) {
- super(message);
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param message
+ */
+ public CdkException(String message) {
+ super(message);
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param cause
- */
- public CdkException(Throwable cause) {
- super(cause);
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param cause
+ */
+ public CdkException(Throwable cause) {
+ super(cause);
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param message
- * @param cause
- */
- public CdkException(String message, Throwable cause) {
- super(message, cause);
- }
-
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param message
+ * @param cause
+ */
+ public CdkException(String message, Throwable cause) {
+ super(message, cause);
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkProcessingError.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkProcessingError.java 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkProcessingError.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -21,52 +21,53 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk;
/**
* <p class="changed_added_4_0">That exception indicates recoverable CDK error, that it is, means
- * errors in source code or configuration files that makes project build failed, so no result shulde be generated, but does not
- * stop further processing of other classes or files. CDK should collect such errors but do not
- * stop processing that let developer to know about all errors in the project.</p>
+ * errors in source code or configuration files that makes project build failed, so no result shulde be generated,
+ * but does not stop further processing of other classes or files. CDK should collect such errors but do not stop
+ * processing that let developer to know about all errors in the project.</p>
+ *
* @author asmirnov(a)exadel.com
*
*/
public class CdkProcessingError extends CdkException {
- /**
- * <p class="changed_added_4_0"></p>
- */
- private static final long serialVersionUID = -3696046213271071968L;
+ /**
+ * <p class="changed_added_4_0"></p>
+ */
+ private static final long serialVersionUID = -3696046213271071968L;
- /**
- * <p class="changed_added_4_0"></p>
- */
- public CdkProcessingError() {
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ */
+ public CdkProcessingError() {}
- /**
- * <p class="changed_added_4_0"></p>
- * @param message
- */
- public CdkProcessingError(String message) {
- super(message);
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param message
+ */
+ public CdkProcessingError(String message) {
+ super(message);
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param cause
- */
- public CdkProcessingError(Throwable cause) {
- super(cause);
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param cause
+ */
+ public CdkProcessingError(Throwable cause) {
+ super(cause);
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param message
- * @param cause
- */
- public CdkProcessingError(String message, Throwable cause) {
- super(message, cause);
- }
-
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param message
+ * @param cause
+ */
+ public CdkProcessingError(String message, Throwable cause) {
+ super(message, cause);
+ }
}
Modified: 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 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkWorker.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk;
/**
@@ -30,7 +32,5 @@
*
*/
public interface CdkWorker {
-
- public void init(CdkContext context) throws CdkException;
-
+ public void init(CdkContext context) throws CdkException;
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkWriter.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkWriter.java 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkWriter.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk;
import org.richfaces.cdk.model.ComponentLibrary;
@@ -31,13 +33,11 @@
*
*/
public interface CdkWriter extends CdkWorker {
-
- interface OutputType {
- String getName();
- OutputType getFolderType();
- }
-
-
- public void render(ComponentLibrary library) throws CdkException;
+ public void render(ComponentLibrary library) throws CdkException;
+ interface OutputType {
+ String getName();
+
+ OutputType getFolderType();
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/DummyBuilder.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/DummyBuilder.java 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/DummyBuilder.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk;
import org.richfaces.cdk.model.ComponentLibrary;
@@ -31,26 +33,27 @@
*
*/
public class DummyBuilder implements ModelBuilder {
+ private CdkContext context;
- private CdkContext context;
+ /*
+ * (non-Javadoc)
+ * @see org.richfaces.cdk.ModelBuilder#build()
+ */
+ @Override
+ public ComponentLibrary build() throws CdkException {
+ return new ComponentLibrary();
+ }
- /* (non-Javadoc)
- * @see org.richfaces.cdk.ModelBuilder#build()
- */
- @Override
- public ComponentLibrary build() throws CdkException {
- return new ComponentLibrary();
- }
+ /*
+ * (non-Javadoc)
+ * @see org.richfaces.cdk.ModelBuilder#init(org.richfaces.cdk.CdkContext)
+ */
+ @Override
+ public void init(CdkContext context) {
+ this.context = context;
+ }
- /* (non-Javadoc)
- * @see org.richfaces.cdk.ModelBuilder#init(org.richfaces.cdk.CdkContext)
- */
- @Override
- public void init(CdkContext context) {
- this.context = context;
- }
-
- protected CdkContext getContext() {
- return context;
- }
+ protected CdkContext getContext() {
+ return context;
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/DummyGenerator.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/DummyGenerator.java 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/DummyGenerator.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk;
import org.richfaces.cdk.model.ComponentLibrary;
@@ -31,27 +33,28 @@
*
*/
public class DummyGenerator implements CdkWriter {
+ private CdkContext context;
- private CdkContext context;
+ /*
+ * (non-Javadoc)
+ * @see org.richfaces.cdk.CdkWriter#init(org.richfaces.cdk.CdkContext)
+ */
+ @Override
+ public void init(CdkContext context) throws CdkException {
+ this.context = context;
+ }
- /* (non-Javadoc)
- * @see org.richfaces.cdk.CdkWriter#init(org.richfaces.cdk.CdkContext)
- */
- @Override
- public void init(CdkContext context) throws CdkException {
- this.context = context;
- }
+ /*
+ * (non-Javadoc)
+ * @see org.richfaces.cdk.CdkWriter#render(org.richfaces.cdk.model.ComponentLibrary)
+ */
+ @Override
+ public void render(ComponentLibrary library) throws CdkException {
- /* (non-Javadoc)
- * @see org.richfaces.cdk.CdkWriter#render(org.richfaces.cdk.model.ComponentLibrary)
- */
- @Override
- public void render(ComponentLibrary library) throws CdkException {
- // Do nothing
- }
-
- protected CdkContext getContext() {
- return context;
- }
+ // Do nothing
+ }
+ protected CdkContext getContext() {
+ return context;
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/JavaLogger.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/JavaLogger.java 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/JavaLogger.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk;
import java.util.logging.Level;
@@ -31,138 +33,149 @@
*
*/
class JavaLogger implements Logger {
-
- java.util.logging.Logger jdkLogger = java.util.logging.Logger.getLogger(LoggerFactory.CDK_LOG);
+ java.util.logging.Logger jdkLogger = java.util.logging.Logger.getLogger(LoggerFactory.CDK_LOG);
- /* (non-Javadoc)
- * @see org.richfaces.cdk.Logger#debug(java.lang.CharSequence)
- */
- @Override
- public void debug(CharSequence content) {
- jdkLogger.fine(String.valueOf(content));
- }
+ /*
+ * (non-Javadoc)
+ * @see org.richfaces.cdk.Logger#debug(java.lang.CharSequence)
+ */
+ @Override
+ public void debug(CharSequence content) {
+ jdkLogger.fine(String.valueOf(content));
+ }
- /* (non-Javadoc)
- * @see org.richfaces.cdk.Logger#debug(java.lang.CharSequence, java.lang.Throwable)
- */
- @Override
- public void debug(CharSequence content, Throwable error) {
- jdkLogger.log(Level.FINE, String.valueOf(content), error);
- }
+ /*
+ * (non-Javadoc)
+ * @see org.richfaces.cdk.Logger#debug(java.lang.CharSequence, java.lang.Throwable)
+ */
+ @Override
+ public void debug(CharSequence content, Throwable error) {
+ jdkLogger.log(Level.FINE, String.valueOf(content), error);
+ }
- /* (non-Javadoc)
- * @see org.richfaces.cdk.Logger#debug(java.lang.Throwable)
- */
- @Override
- public void debug(Throwable error) {
- jdkLogger.log(Level.FINE, "", error);
- }
+ /*
+ * (non-Javadoc)
+ * @see org.richfaces.cdk.Logger#debug(java.lang.Throwable)
+ */
+ @Override
+ public void debug(Throwable error) {
+ jdkLogger.log(Level.FINE, "", error);
+ }
- /* (non-Javadoc)
- * @see org.richfaces.cdk.Logger#error(java.lang.CharSequence)
- */
- @Override
- public void error(CharSequence content) {
- jdkLogger.severe(String.valueOf(content));
+ /*
+ * (non-Javadoc)
+ * @see org.richfaces.cdk.Logger#error(java.lang.CharSequence)
+ */
+ @Override
+ public void error(CharSequence content) {
+ jdkLogger.severe(String.valueOf(content));
+ }
- }
+ /*
+ * (non-Javadoc)
+ * @see org.richfaces.cdk.Logger#error(java.lang.CharSequence, java.lang.Throwable)
+ */
+ @Override
+ public void error(CharSequence content, Throwable error) {
+ jdkLogger.log(Level.SEVERE, String.valueOf(content), error);
+ }
- /* (non-Javadoc)
- * @see org.richfaces.cdk.Logger#error(java.lang.CharSequence, java.lang.Throwable)
- */
- @Override
- public void error(CharSequence content, Throwable error) {
- jdkLogger.log(Level.SEVERE, String.valueOf(content), error);
- }
+ /*
+ * (non-Javadoc)
+ * @see org.richfaces.cdk.Logger#error(java.lang.Throwable)
+ */
+ @Override
+ public void error(Throwable error) {
+ jdkLogger.log(Level.SEVERE, "", error);
+ }
- /* (non-Javadoc)
- * @see org.richfaces.cdk.Logger#error(java.lang.Throwable)
- */
- @Override
- public void error(Throwable error) {
- jdkLogger.log(Level.SEVERE, "", error);
- }
+ /*
+ * (non-Javadoc)
+ * @see org.richfaces.cdk.Logger#info(java.lang.CharSequence)
+ */
+ @Override
+ public void info(CharSequence content) {
+ jdkLogger.info(String.valueOf(content));
+ }
- /* (non-Javadoc)
- * @see org.richfaces.cdk.Logger#info(java.lang.CharSequence)
- */
- @Override
- public void info(CharSequence content) {
- jdkLogger.info(String.valueOf(content));
- }
+ /*
+ * (non-Javadoc)
+ * @see org.richfaces.cdk.Logger#info(java.lang.CharSequence, java.lang.Throwable)
+ */
+ @Override
+ public void info(CharSequence content, Throwable error) {
+ jdkLogger.log(Level.INFO, String.valueOf(content), error);
+ }
- /* (non-Javadoc)
- * @see org.richfaces.cdk.Logger#info(java.lang.CharSequence, java.lang.Throwable)
- */
- @Override
- public void info(CharSequence content, Throwable error) {
- jdkLogger.log(Level.INFO, String.valueOf(content), error);
+ /*
+ * (non-Javadoc)
+ * @see org.richfaces.cdk.Logger#info(java.lang.Throwable)
+ */
+ @Override
+ public void info(Throwable error) {
+ jdkLogger.log(Level.INFO, "", error);
+ }
- }
+ /*
+ * (non-Javadoc)
+ * @see org.richfaces.cdk.Logger#isDebugEnabled()
+ */
+ @Override
+ public boolean isDebugEnabled() {
+ return jdkLogger.isLoggable(Level.FINE);
+ }
- /* (non-Javadoc)
- * @see org.richfaces.cdk.Logger#info(java.lang.Throwable)
- */
- @Override
- public void info(Throwable error) {
- jdkLogger.log(Level.INFO, "", error);
- }
+ /*
+ * (non-Javadoc)
+ * @see org.richfaces.cdk.Logger#isErrorEnabled()
+ */
+ @Override
+ public boolean isErrorEnabled() {
+ return jdkLogger.isLoggable(Level.SEVERE);
+ }
- /* (non-Javadoc)
- * @see org.richfaces.cdk.Logger#isDebugEnabled()
- */
- @Override
- public boolean isDebugEnabled() {
- return jdkLogger.isLoggable(Level.FINE);
- }
+ /*
+ * (non-Javadoc)
+ * @see org.richfaces.cdk.Logger#isInfoEnabled()
+ */
+ @Override
+ public boolean isInfoEnabled() {
+ return jdkLogger.isLoggable(Level.INFO);
+ }
- /* (non-Javadoc)
- * @see org.richfaces.cdk.Logger#isErrorEnabled()
- */
- @Override
- public boolean isErrorEnabled() {
- return jdkLogger.isLoggable(Level.SEVERE);
- }
+ /*
+ * (non-Javadoc)
+ * @see org.richfaces.cdk.Logger#isWarnEnabled()
+ */
+ @Override
+ public boolean isWarnEnabled() {
+ return jdkLogger.isLoggable(Level.WARNING);
+ }
- /* (non-Javadoc)
- * @see org.richfaces.cdk.Logger#isInfoEnabled()
- */
- @Override
- public boolean isInfoEnabled() {
- return jdkLogger.isLoggable(Level.INFO);
- }
+ /*
+ * (non-Javadoc)
+ * @see org.richfaces.cdk.Logger#warn(java.lang.CharSequence)
+ */
+ @Override
+ public void warn(CharSequence content) {
+ jdkLogger.warning(String.valueOf(content));
+ }
- /* (non-Javadoc)
- * @see org.richfaces.cdk.Logger#isWarnEnabled()
- */
- @Override
- public boolean isWarnEnabled() {
- return jdkLogger.isLoggable(Level.WARNING);
- }
+ /*
+ * (non-Javadoc)
+ * @see org.richfaces.cdk.Logger#warn(java.lang.CharSequence, java.lang.Throwable)
+ */
+ @Override
+ public void warn(CharSequence content, Throwable error) {
+ jdkLogger.log(Level.WARNING, String.valueOf(content), error);
+ }
- /* (non-Javadoc)
- * @see org.richfaces.cdk.Logger#warn(java.lang.CharSequence)
- */
- @Override
- public void warn(CharSequence content) {
- jdkLogger.warning(String.valueOf(content));
- }
-
- /* (non-Javadoc)
- * @see org.richfaces.cdk.Logger#warn(java.lang.CharSequence, java.lang.Throwable)
- */
- @Override
- public void warn(CharSequence content, Throwable error) {
- jdkLogger.log(Level.WARNING, String.valueOf(content), error);
-
- }
-
- /* (non-Javadoc)
- * @see org.richfaces.cdk.Logger#warn(java.lang.Throwable)
- */
- @Override
- public void warn(Throwable error) {
- jdkLogger.log(Level.WARNING, "", error);
- }
-
+ /*
+ * (non-Javadoc)
+ * @see org.richfaces.cdk.Logger#warn(java.lang.Throwable)
+ */
+ @Override
+ public void warn(Throwable error) {
+ jdkLogger.log(Level.WARNING, "", error);
+ }
}
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-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/LibraryBuilder.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -21,228 +21,230 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk;
-import java.io.File;
+import com.google.common.collect.ImmutableMap;
import org.richfaces.builder.templates.RendererClassGenerator;
import org.richfaces.builder.templates.RendererTemplateParser;
import org.richfaces.cdk.CdkContext.SourceType;
import org.richfaces.cdk.CdkWriter.OutputType;
import org.richfaces.cdk.apt.AptBuilder;
-import org.richfaces.cdk.apt.CdkProcessor;
-import org.richfaces.cdk.apt.ComponentProcessor;
import org.richfaces.cdk.generate.java.ComponentClassGenerator;
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.xmlconfig.FacesConfigGenerator;
import org.richfaces.cdk.xmlconfig.FacesConfigParser;
-import com.google.common.collect.ImmutableMap;
-
/**
* <p class="changed_added_4_0">
* That class builds JSF library model from different sources. It acts as
* "controller" for whole CDK generation process.
* </p>
- *
+ *
* @author asmirnov(a)exadel.com
- *
+ *
*/
public final class LibraryBuilder implements CdkWorker {
- /**
- * <p class="changed_added_4_0">
- * Current CDK context
- * </p>
- */
- private CdkContext context;
+ /**
+ * Map contains writer classes for standard outputs.
+ */
+ private static final ImmutableMap<OutputType, Class<? extends CdkWriter>> WRITERS =
+ ImmutableMap.<OutputType, Class<? extends CdkWriter>>builder().put(StandardOutputs.COMPONENT_CLASSES,
+ ComponentClassGenerator.class).put(StandardOutputs.RENDERER_CLASSES,
+ RendererClassGenerator.class).put(StandardOutputs.FACES_CONFIG,
+ FacesConfigGenerator.class).build();
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @param context
- */
- public LibraryBuilder() {
-
- }
+ /**
+ * map contain library model builder classes for each source type.
+ */
+ private static final ImmutableMap<SourceType, Class<? extends ModelBuilder>> BUILDERS =
+ ImmutableMap.<SourceType, Class<? extends ModelBuilder>>builder().put(StandardSources.FACES_CONFIGS,
+ FacesConfigParser.class).put(StandardSources.JAVA_SOURCES,
+ AptBuilder.class).put(StandardSources.RENDERER_TEMPLATES,
+ RendererTemplateParser.class).build();
- @Override
- public void init(CdkContext context) throws CdkException {
- this.context = context;
- // default workers.
- }
+ /**
+ * <p class="changed_added_4_0">
+ * Current CDK context
+ * </p>
+ */
+ private CdkContext context;
- /**
- * <p class="changed_added_4_0">
- * Static factory method
- * </p>
- *
- * @return
- * @throws CdkException
- */
- public static LibraryBuilder createInstance(CdkContext context) throws CdkException {
- return context.getWorkerInstance(LibraryBuilder.class);
- }
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param context
+ */
+ public LibraryBuilder() {}
- /**
- * <p class="changed_added_4_0">
- * Parse source files for annotations and populate CDK-related information
- * into model.
- * </p>
- *
- * @param sources
- * Java Source files.
- * @return generated library model.
- * @throws CdkException
- */
- public ComponentLibrary buildModel(SourceType type) throws CdkException {
- ModelBuilder modelBuilder = getBuilderFor(type);
- ComponentLibrary library = modelBuilder.build();
- getVerifier().verify(library);
- return library;
- }
+ @Override
+ public void init(CdkContext context) throws CdkException {
+ this.context = context;
- /**
- * <p class="changed_added_4_0">
- * Build library model from all available sources.
- * </p>
- *
- * @param templates
- * @throws CdkException
- */
- public ComponentLibrary buildModel() throws CdkException {
- ComponentLibrary library = null;
- for (SourceType type : StandardSources.values()) {
- ComponentLibrary model = buildModel(type);
- if (null != model) {
- if (null != library) {
- library.merge(model);
- } else {
- library = model;
- }
- }
- }
- getVerifier().verify(library);
- return library;
- }
+ // default workers.
+ }
- /**
- * Generate all types of files from library model.
- * @param library
- * @throws CdkException
- */
- public void generate(ComponentLibrary library) throws CdkException {
- for (OutputType type : StandardOutputs.values()) {
- generate(library, type);
- }
- }
+ /**
+ * <p class="changed_added_4_0">
+ * Static factory method
+ * </p>
+ *
+ * @return
+ * @throws CdkException
+ */
+ public static LibraryBuilder createInstance(CdkContext context) throws CdkException {
+ return context.getWorkerInstance(LibraryBuilder.class);
+ }
- /**
- * <p class="changed_added_4_0">
- * Cenerate files from library model for given type ( eg. component classes, faces-config ).
- * </p>
- *
- * @param library model
- * @param type of generated files.
- * @throws CdkException
- */
- public void generate(ComponentLibrary library, OutputType type)
- throws CdkException {
- CdkWriter generator = getGeneratorFor(type);
- generator.render(library);
- }
-
- /**
- * Map contains writer classes for standard outputs.
- */
- private static final ImmutableMap<OutputType, Class<? extends CdkWriter>> writers = ImmutableMap
- .<OutputType, Class<? extends CdkWriter>> builder().put(
- StandardOutputs.COMPONENT_CLASSES,
- ComponentClassGenerator.class).put(
- StandardOutputs.RENDERER_CLASSES,
- RendererClassGenerator.class).put(
- StandardOutputs.FACES_CONFIG, FacesConfigGenerator.class)
- .build();
+ /**
+ * <p class="changed_added_4_0">
+ * Parse source files for annotations and populate CDK-related information
+ * into model.
+ * </p>
+ *
+ * @param sources
+ * Java Source files.
+ * @return generated library model.
+ * @throws CdkException
+ */
+ public ComponentLibrary buildModel(SourceType type) throws CdkException {
+ ModelBuilder modelBuilder = getBuilderFor(type);
+ ComponentLibrary library = modelBuilder.build();
- /**
- * This method returns instance of {@link CdkWriter} for given output type.
- * @param type
- * @return
- * @throws CdkException
- */
- protected CdkWriter getGeneratorFor(OutputType type) throws CdkException {
- CdkWriter generator = null;
- Class<? extends CdkWriter> writerClass = writers.get(type);
- if (null != writerClass) {
- generator = context.getWorkerInstance(writerClass);
- } else {
- generator = new DummyGenerator();
- generator.init(getContext());
- // TODO - make service method for new source types.
- // throw new CdkException("No generator for type " +
- // type.getName());
- }
- return generator;
- }
+ getVerifier().verify(library);
- /**
- * <p class="changed_added_4_0">
- * Builder method that creates new library instance.
- * </p>
- *
- * @return
- */
- public ComponentLibrary createLibrary() {
- return new ComponentLibrary();
- }
+ return library;
+ }
- /**
- * <p class="changed_added_4_0">
- * Getter for the current CDK context
- * </p>
- *
- * @return the context
- */
- protected CdkContext getContext() {
- return context;
- }
+ /**
+ * <p class="changed_added_4_0">
+ * Build library model from all available sources.
+ * </p>
+ *
+ * @param templates
+ * @throws CdkException
+ */
+ public ComponentLibrary buildModel() throws CdkException {
+ ComponentLibrary library = null;
+ for (SourceType type : StandardSources.values()) {
+ ComponentLibrary model = buildModel(type);
- /**
- * map contain library model builder classes for each source type.
- */
- private static final ImmutableMap<SourceType, Class<? extends ModelBuilder>> builders = ImmutableMap
- .<SourceType, Class<? extends ModelBuilder>> builder().put(
- StandardSources.FACES_CONFIGS,
- FacesConfigParser.class).put(
- StandardSources.JAVA_SOURCES,
- AptBuilder.class).put(
- StandardSources.RENDERER_TEMPLATES, RendererTemplateParser.class)
- .build();
-
- /**
- * This method returns initialized instance of the {@link ModelBuilder} for given source type.
- * @param type
- * @return
- * @throws CdkException
- */
- protected ModelBuilder getBuilderFor(SourceType type) throws CdkException {
- ModelBuilder builder;
- Class<? extends ModelBuilder> builderClass = builders.get(type);
- if (null != builderClass) {
- builder = context.getWorkerInstance(builderClass);
- } else {
- builder = new DummyBuilder();
- builder.init(getContext());
- // TODO - make service method for new source types.
- // throw new CdkException("No model builder for source type " +
- // type.getName());
- }
- return builder;
- }
+ if (null != model) {
+ if (null != library) {
+ library.merge(model);
+ } else {
+ library = model;
+ }
+ }
+ }
- protected ModelValidator getVerifier() throws CdkException {
- return getContext().getWorkerInstance(ModelValidator.class);
- }
+ getVerifier().verify(library);
+
+ return library;
+ }
+
+ /**
+ * Generate all types of files from library model.
+ * @param library
+ * @throws CdkException
+ */
+ public void generate(ComponentLibrary library) throws CdkException {
+ for (OutputType type : StandardOutputs.values()) {
+ generate(library, type);
+ }
+ }
+
+ /**
+ * <p class="changed_added_4_0">
+ * Cenerate files from library model for given type ( eg. component classes, faces-config ).
+ * </p>
+ *
+ * @param library model
+ * @param type of generated files.
+ * @throws CdkException
+ */
+ public void generate(ComponentLibrary library, OutputType type) throws CdkException {
+ CdkWriter generator = getGeneratorFor(type);
+
+ generator.render(library);
+ }
+
+ /**
+ * This method returns instance of {@link CdkWriter} for given output type.
+ * @param type
+ * @return
+ * @throws CdkException
+ */
+ protected CdkWriter getGeneratorFor(OutputType type) throws CdkException {
+ CdkWriter generator = null;
+ Class<? extends CdkWriter> writerClass = WRITERS.get(type);
+
+ if (null != writerClass) {
+ generator = context.getWorkerInstance(writerClass);
+ } else {
+ generator = new DummyGenerator();
+ generator.init(getContext());
+
+ // TODO - make service method for new source types.
+ // throw new CdkException("No generator for type " +
+ // type.getName());
+ }
+
+ return generator;
+ }
+
+ /**
+ * <p class="changed_added_4_0">
+ * Builder method that creates new library instance.
+ * </p>
+ *
+ * @return
+ */
+ public ComponentLibrary createLibrary() {
+ return new ComponentLibrary();
+ }
+
+ /**
+ * <p class="changed_added_4_0">
+ * Getter for the current CDK context
+ * </p>
+ *
+ * @return the context
+ */
+ protected CdkContext getContext() {
+ return context;
+ }
+
+ /**
+ * This method returns initialized instance of the {@link ModelBuilder} for given source type.
+ * @param type
+ * @return
+ * @throws CdkException
+ */
+ protected ModelBuilder getBuilderFor(SourceType type) throws CdkException {
+ ModelBuilder builder;
+ Class<? extends ModelBuilder> builderClass = BUILDERS.get(type);
+
+ if (null != builderClass) {
+ builder = context.getWorkerInstance(builderClass);
+ } else {
+ builder = new DummyBuilder();
+ builder.init(getContext());
+
+ // TODO - make service method for new source types.
+ // throw new CdkException("No model builder for source type " +
+ // type.getName());
+ }
+
+ return builder;
+ }
+
+ protected ModelValidator getVerifier() throws CdkException {
+ return getContext().getWorkerInstance(ModelValidator.class);
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/Logger.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/Logger.java 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/Logger.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -19,6 +19,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk;
/**
@@ -29,38 +31,35 @@
*
*/
public interface Logger {
-
boolean isDebugEnabled();
-
- void debug( CharSequence content );
- void debug( CharSequence content, Throwable error );
+ void debug(CharSequence content);
- void debug( Throwable error );
+ void debug(CharSequence content, Throwable error);
+ void debug(Throwable error);
+
boolean isInfoEnabled();
-
- void info( CharSequence content );
- void info( CharSequence content, Throwable error );
+ void info(CharSequence content);
- void info( Throwable error );
+ void info(CharSequence content, Throwable error);
+ void info(Throwable error);
+
boolean isWarnEnabled();
-
- void warn( CharSequence content );
- void warn( CharSequence content, Throwable error );
+ void warn(CharSequence content);
- void warn( Throwable error );
+ void warn(CharSequence content, Throwable error);
+ void warn(Throwable error);
+
boolean isErrorEnabled();
-
- void error( CharSequence content );
- void error( CharSequence content, Throwable error );
+ void error(CharSequence content);
- void error( Throwable error );
+ void error(CharSequence content, Throwable error);
-
+ void error(Throwable error);
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/LoggerFactory.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/LoggerFactory.java 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/LoggerFactory.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk;
/**
@@ -29,115 +31,115 @@
*
*/
public final class LoggerFactory {
-
- private static final class LoggerWrapper implements Logger {
- @Override
- public void debug(CharSequence content) {
- logger.debug(content);
- }
+ public static final String CDK_LOG = "org.richfaces.cdk";
- @Override
- public void debug(CharSequence content, Throwable error) {
- logger.debug(content, error);
- }
+ /**
+ * <p class="changed_added_4_0">Current logger. By default all calls will be sent to system
+ * {@link java.util.logging.Logger}</p>
+ */
+ private static Logger logger = new JavaLogger();
- @Override
- public void debug(Throwable error) {
- logger.debug(error);
- }
+ /**
+ * <p class="changed_added_4_0">
+ * That constant wraps current logger object to allow access to logger at
+ * the class instantiation time.
+ * </p>
+ */
+ private static final Logger WRAPPER = new LoggerWrapper();
- @Override
- public void error(CharSequence content) {
- logger.error(content);
- }
+ private LoggerFactory() {
- @Override
- public void error(CharSequence content, Throwable error) {
- logger.error(content, error);
- }
+ // That class has static methods only.
+ }
- @Override
- public void error(Throwable error) {
- logger.error(error);
- }
+ public static Logger getLogger() {
+ return WRAPPER;
+ }
- @Override
- public void info(CharSequence content) {
- logger.info(content);
- }
+ public static void setLogger(Logger newLogger) {
+ assert null != newLogger;
+ logger = newLogger;
+ }
- @Override
- public void info(CharSequence content, Throwable error) {
- logger.info(content, error);
- }
+ private static final class LoggerWrapper implements Logger {
+ @Override
+ public void debug(CharSequence content) {
+ logger.debug(content);
+ }
- @Override
- public void info(Throwable error) {
- logger.info(error);
- }
+ @Override
+ public void debug(CharSequence content, Throwable error) {
+ logger.debug(content, error);
+ }
- @Override
- public boolean isDebugEnabled() {
- return logger.isDebugEnabled();
- }
+ @Override
+ public void debug(Throwable error) {
+ logger.debug(error);
+ }
- @Override
- public boolean isErrorEnabled() {
- return logger.isErrorEnabled();
- }
+ @Override
+ public void error(CharSequence content) {
+ logger.error(content);
+ }
- @Override
- public boolean isInfoEnabled() {
- return logger.isInfoEnabled();
- }
+ @Override
+ public void error(CharSequence content, Throwable error) {
+ logger.error(content, error);
+ }
- @Override
- public boolean isWarnEnabled() {
- return logger.isWarnEnabled();
- }
+ @Override
+ public void error(Throwable error) {
+ logger.error(error);
+ }
- @Override
- public void warn(CharSequence content) {
- logger.warn(content);
- }
+ @Override
+ public void info(CharSequence content) {
+ logger.info(content);
+ }
- @Override
- public void warn(CharSequence content, Throwable error) {
- logger.warn(content, error);
-
- }
+ @Override
+ public void info(CharSequence content, Throwable error) {
+ logger.info(content, error);
+ }
- @Override
- public void warn(Throwable error) {
- logger.warn(error);
- }
- }
+ @Override
+ public void info(Throwable error) {
+ logger.info(error);
+ }
- /**
- * <p class="changed_added_4_0">Current logger. By default all calls will be sent to system {@link java.util.logging.Logger}</p>
- */
- private static Logger logger = new JavaLogger();
+ @Override
+ public boolean isDebugEnabled() {
+ return logger.isDebugEnabled();
+ }
- /**
- * <p class="changed_added_4_0">
- * That constant wraps current logger object to allow access to logger at
- * the class instantiation time.
- * </p>
- */
- private static final Logger wrapper = new LoggerWrapper();
+ @Override
+ public boolean isErrorEnabled() {
+ return logger.isErrorEnabled();
+ }
- public static final String CDK_LOG = "org.richfaces.cdk";
-
- private LoggerFactory() {
- // That class has static methods only.
- }
+ @Override
+ public boolean isInfoEnabled() {
+ return logger.isInfoEnabled();
+ }
- public static Logger getLogger(){
- return wrapper;
- }
-
- public static void setLogger(Logger newLogger){
- assert(null != newLogger);
- logger = newLogger;
- }
+ @Override
+ public boolean isWarnEnabled() {
+ return logger.isWarnEnabled();
+ }
+
+ @Override
+ public void warn(CharSequence content) {
+ logger.warn(content);
+ }
+
+ @Override
+ public void warn(CharSequence content, Throwable error) {
+ logger.warn(content, error);
+ }
+
+ @Override
+ public void warn(Throwable error) {
+ logger.warn(error);
+ }
+ }
}
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-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/ModelBuilder.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk;
import org.richfaces.cdk.model.ComponentLibrary;
@@ -31,19 +33,18 @@
*
*/
public interface ModelBuilder extends CdkWorker {
-
- /**
- * <p class="changed_added_4_0">Initialize builder.</p>
- * @param context
- * @throws CdkException
- */
- public void init(CdkContext context) throws CdkException;
-
- /**
- * <p class="changed_added_4_0">Build library model.</p>
- * @return
- * @throws CdkException
- */
- public ComponentLibrary build() throws CdkException;
+ /**
+ * <p class="changed_added_4_0">Initialize builder.</p>
+ * @param context
+ * @throws CdkException
+ */
+ public void init(CdkContext context) throws CdkException;
+
+ /**
+ * <p class="changed_added_4_0">Build library model.</p>
+ * @return
+ * @throws CdkException
+ */
+ public ComponentLibrary build() throws CdkException;
}
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-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/ModelValidator.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk;
import org.richfaces.cdk.model.ComponentLibrary;
@@ -31,12 +33,11 @@
*
*/
public interface ModelValidator extends CdkWorker {
-
- /**
- * <p class="changed_added_4_0">Perform verify procedure on the library model.</p>
- * @param library
- * @throws CdkException
- */
- public void verify(ComponentLibrary library) throws CdkException;
+ /**
+ * <p class="changed_added_4_0">Perform verify procedure on the library model.</p>
+ * @param library
+ * @throws CdkException
+ */
+ public void verify(ComponentLibrary library) throws CdkException;
}
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-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/NamingConventions.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -21,12 +21,11 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk;
-import org.richfaces.cdk.model.ClassDescription;
-import org.richfaces.cdk.model.Component;
import org.richfaces.cdk.model.InvalidNameException;
-import org.richfaces.cdk.model.Component.Type;
/**
* <p class="changed_added_4_0">
@@ -34,41 +33,42 @@
* href="http://www.jboss.org/community/docs/DOC-13693">CDK naming
* conventions</>
* </p>
- *
+ *
* @author asmirnov(a)exadel.com
- *
+ *
*/
public interface NamingConventions extends CdkWorker {
-
- /**
- * <p class="changed_added_4_0">Calculates component type from explicit value or base class name.</p>
- * <ul>
- * <li><code><prefix>.component.Abstract<Name></code> => <code><prefix>.<Name></code> </li>
- * <li><code><prefix>.component.<Name>Base</code> => <code><prefix>.<Name></code> </li>
- * <li><code><prefix>.component.UI<Name></code> => <code><prefix>.<Name></code> </li>
- * </ul>
- * @param explicitType
- * @param className
- * @return
- * @throws InvalidNameException if className does not match naming conventions.
- */
- public String inferComponentType(String explicitType, String className) throws InvalidNameException;
- /**
- * <p class="changed_added_4_0">Calculates concrete component class from explicit value or type.</p>
- * <ul>
- * <li>Use explicit class name if it was provided by developer.</li>
- * <li>Calculate name from type as <code><prefix>.<Name></code> => <code><prefix>.component.UI<Name></code> for an abstract class.</li>
- * <li>Use base class name if concrete class should not be generated.
- * </ul>
- * @param explicitClass
- * @param className
- * @return
- */
- public String inferUIComponentClass(String componentType, String explicitClass, String baseClass, boolean baseClassIsAbstract) throws InvalidNameException;
+ /**
+ * <p class="changed_added_4_0">Calculates component type from explicit value or base class name.</p>
+ * <ul>
+ * <li><code><prefix>.component.Abstract<Name></code> =><code><prefix>.<Name></code></li>
+ * <li><code><prefix>.component.<Name>Base</code> => <code><prefix>.<Name></code> </li>
+ * <li><code><prefix>.component.UI<Name></code> => <code><prefix>.<Name></code> </li>
+ * </ul>
+ * @param explicitType
+ * @param className
+ * @return
+ * @throws InvalidNameException if className does not match naming conventions.
+ */
+ public String inferComponentType(String explicitType, String className) throws InvalidNameException;
- public String inferUIComponentBaseClass(String componentType,String baseClassName, boolean baseClassIsAbstract);
+ /**
+ * <p class="changed_added_4_0">Calculates concrete component class from explicit value or type.</p>
+ * <ul>
+ * <li>Use explicit class name if it was provided by developer.</li>
+ * <li>Calculate name from type as <code><prefix>.<Name></code> =>
+ * <code><prefix>.component.UI<Name></code> for an abstract class.</li>
+ * <li>Use base class name if concrete class should not be generated.
+ * </ul>
+ * @param explicitClass
+ * @param className
+ * @return
+ */
+ public String inferUIComponentClass(String componentType, String explicitClass, String baseClass,
+ boolean baseClassIsAbstract) throws InvalidNameException;
- public String inferUIComponentFamily(String componentType, String explicitFamily);
+ public String inferUIComponentBaseClass(String componentType, String baseClassName, boolean baseClassIsAbstract);
+ public String inferUIComponentFamily(String componentType, String explicitFamily);
}
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-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/RichFacesConventions.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -1,138 +1,133 @@
package org.richfaces.cdk;
-import org.richfaces.cdk.model.ClassDescription;
-import org.richfaces.cdk.model.Component;
import org.richfaces.cdk.model.InvalidNameException;
import org.richfaces.cdk.model.Name;
-import org.richfaces.cdk.model.Component.Type;
import org.richfaces.cdk.model.Name.Classifier;
import org.richfaces.cdk.util.Strings;
/**
* <p class="changed_added_4_0">
* </p>
- *
+ *
* @author asmirnov(a)exadel.com
- *
+ *
*/
public final class RichFacesConventions implements NamingConventions {
+ private static final String ABSTRACT = "Abstract";
+ private static final String BASE = "Base";
+ private static final String UI = "UI";
+ private static final String[] COMPONENT_SUFFIXES = {BASE};
+ private static final String[] COMPONENT_PREFIXES = {UI, ABSTRACT};
- private static final String ABSTRACT = "Abstract";
- private static final String UI = "UI";
- private static final String BASE = "Base";
- /**
- * <p class="changed_added_4_0">
- * </p>
- */
- private String baseName;
- private CdkContext context;
+ private String baseName;
+ private CdkContext context;
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @param componentLibrary
- */
- public RichFacesConventions() {
- }
+ public RichFacesConventions() {}
- @Override
- public void init(CdkContext context) throws CdkException {
- this.context = context;
- }
+ @Override
+ public void init(CdkContext context) throws CdkException {
+ this.context = context;
+ }
- private final String[] COMPONENT_SUFFIXES = { BASE };
- private final String[] COMPONENT_PREFIXES = { UI, ABSTRACT };
+ @Override
+ public String inferComponentType(String explicitType, String className) throws InvalidNameException {
- @Override
- public String inferComponentType(String explicitType, String className)
- throws InvalidNameException {
- // check parameters.
- if (Strings.isEmpty(explicitType)) {
- if (Strings.isEmpty(className)) {
- throw new IllegalArgumentException();
- }
- Name name = Name.create(className);
- // Use base library prefix.
- String baseName = this.getBaseName();
- if (null != baseName) {
- name.setPrefix(baseName);
- }
- // Component type does not contain class or markup parts.
- name.setClassifier(null);
- name.setMarkup(null);
- String simpleName = name.getSimpleName();
- // Remove common prefixes.
- for (int i = 0; i < COMPONENT_PREFIXES.length; i++) {
- if (simpleName.startsWith(COMPONENT_PREFIXES[i])) {
- simpleName = simpleName.substring(COMPONENT_PREFIXES[i]
- .length());
- break;
- }
- }
- // Remove common suffixes.
- for (int i = 0; i < COMPONENT_SUFFIXES.length; i++) {
- if (simpleName.endsWith(COMPONENT_SUFFIXES[i])) {
- simpleName = simpleName.substring(0, simpleName.length()
- - COMPONENT_SUFFIXES[i].length());
- break;
- }
- }
- name.setSimpleName(simpleName);
- return name.toString();
- } else {
- return explicitType;
- }
- }
+ // check parameters.
+ if (Strings.isEmpty(explicitType)) {
+ if (Strings.isEmpty(className)) {
+ throw new IllegalArgumentException();
+ }
- @Override
- public String inferUIComponentClass(String componentType,
- String explicitClass, String baseClass, boolean baseClassIsAbstract)
- throws InvalidNameException {
- String className;
- if (!Strings.isEmpty(explicitClass)) {
- // Class name provided by developer.
- className = explicitClass;
- } else if (isAbstract(baseClass, baseClassIsAbstract)) {
- // Infer UI class name from component type.
- Name name = Name.create(componentType);
- name.setClassifier(Classifier.component);
- name.setMarkup(null);
- name.setSimpleName(UI + name.getSimpleName());
- className = name.toString();
- } else {
- // Do not generate class, use base name.
- className = baseClass;
- }
- return className;
- }
+ Name name = Name.create(className);
- private boolean isAbstract(String baseClass, boolean baseClassIsAbstract) {
- return baseClassIsAbstract || baseClass.startsWith(ABSTRACT)
- || baseClass.endsWith(BASE);
- }
+ // Use base library prefix.
+ String baseName = this.getBaseName();
- @Override
- public String inferUIComponentBaseClass(String componentType,
- String baseClassName, boolean baseClassIsAbstract) {
- return isAbstract(baseClassName, baseClassIsAbstract) ? baseClassName
- : null;
- }
+ if (null != baseName) {
+ name.setPrefix(baseName);
+ }
- @Override
- public String inferUIComponentFamily(String componentType,
- String explicitFamily) {
- return Strings.isEmpty(explicitFamily) ? componentType : explicitFamily;
- }
+ // Component type does not contain class or markup parts.
+ name.setClassifier(null);
+ name.setMarkup(null);
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @return the baseName
- */
- protected String getBaseName() {
- return baseName;
- }
+ String simpleName = name.getSimpleName();
-}
\ No newline at end of file
+ // Remove common prefixes.
+ for (int i = 0; i < COMPONENT_PREFIXES.length; i++) {
+ if (simpleName.startsWith(COMPONENT_PREFIXES[i])) {
+ simpleName = simpleName.substring(COMPONENT_PREFIXES[i].length());
+
+ break;
+ }
+ }
+
+ // Remove common suffixes.
+ for (int i = 0; i < COMPONENT_SUFFIXES.length; i++) {
+ if (simpleName.endsWith(COMPONENT_SUFFIXES[i])) {
+ simpleName = simpleName.substring(0, simpleName.length() - COMPONENT_SUFFIXES[i].length());
+
+ break;
+ }
+ }
+
+ name.setSimpleName(simpleName);
+
+ return name.toString();
+ } else {
+ return explicitType;
+ }
+ }
+
+ @Override
+ public String inferUIComponentClass(String componentType, String explicitClass, String baseClass,
+ boolean baseClassIsAbstract) throws InvalidNameException {
+
+ String className;
+
+ if (!Strings.isEmpty(explicitClass)) {
+
+ // Class name provided by developer.
+ className = explicitClass;
+ } else if (isAbstract(baseClass, baseClassIsAbstract)) {
+
+ // Infer UI class name from component type.
+ Name name = Name.create(componentType);
+
+ name.setClassifier(Classifier.component);
+ name.setMarkup(null);
+ name.setSimpleName(UI + name.getSimpleName());
+ className = name.toString();
+ } else {
+
+ // Do not generate class, use base name.
+ className = baseClass;
+ }
+
+ return className;
+ }
+
+ private boolean isAbstract(String baseClass, boolean baseClassIsAbstract) {
+ return baseClassIsAbstract || baseClass.startsWith(ABSTRACT) || baseClass.endsWith(BASE);
+ }
+
+ @Override
+ public String inferUIComponentBaseClass(String componentType, String baseClassName, boolean baseClassIsAbstract) {
+ return isAbstract(baseClassName, baseClassIsAbstract) ? baseClassName : null;
+ }
+
+ @Override
+ public String inferUIComponentFamily(String componentType, String explicitFamily) {
+ return Strings.isEmpty(explicitFamily) ? componentType : explicitFamily;
+ }
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @return the baseName
+ */
+ protected String getBaseName() {
+ return baseName;
+ }
+}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/StandardOutputFolders.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/StandardOutputFolders.java 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/StandardOutputFolders.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk;
import org.richfaces.cdk.CdkWriter.OutputType;
@@ -31,20 +33,15 @@
*
*/
public enum StandardOutputFolders implements OutputType {
- JAVA_CLASSES,
- RESOURCES,
- TEST_JAVA_CLASSES,
- TEST_RESOURCES,
- DOCUMENTATION;
+ JAVA_CLASSES, RESOURCES, TEST_JAVA_CLASSES, TEST_RESOURCES, DOCUMENTATION;
- @Override
- public OutputType getFolderType() {
- return null;
- }
+ @Override
+ public OutputType getFolderType() {
+ return null;
+ }
- @Override
- public String getName() {
- return name();
- }
-
+ @Override
+ public String getName() {
+ return name();
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/StandardOutputs.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/StandardOutputs.java 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/StandardOutputs.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk;
import org.richfaces.cdk.CdkWriter.OutputType;
@@ -31,34 +33,30 @@
*
*/
public enum StandardOutputs implements OutputType {
- COMPONENT_CLASSES(StandardOutputFolders.JAVA_CLASSES),
- RENDERER_CLASSES(StandardOutputFolders.JAVA_CLASSES),
- EVENT_LISTENER_CLASSES(StandardOutputFolders.JAVA_CLASSES),
- EVENT_SOURCE_CLASSES(StandardOutputFolders.JAVA_CLASSES),
- TAG_HANDLER_CLASSES(StandardOutputFolders.JAVA_CLASSES),
- FACES_CONFIG(StandardOutputFolders.RESOURCES),
- TAG_LIBRARY(StandardOutputFolders.RESOURCES),
- JBDS_RENDERERS(StandardOutputFolders.JAVA_CLASSES),
- XML_SCHEMA(StandardOutputFolders.RESOURCES),
- COMPONENT_TEST(StandardOutputFolders.TEST_JAVA_CLASSES);
+ COMPONENT_CLASSES(StandardOutputFolders.JAVA_CLASSES), RENDERER_CLASSES(StandardOutputFolders.JAVA_CLASSES),
+ EVENT_LISTENER_CLASSES(StandardOutputFolders.JAVA_CLASSES),
+ EVENT_SOURCE_CLASSES(StandardOutputFolders.JAVA_CLASSES),
+ TAG_HANDLER_CLASSES(StandardOutputFolders.JAVA_CLASSES), FACES_CONFIG(StandardOutputFolders.RESOURCES),
+ TAG_LIBRARY(StandardOutputFolders.RESOURCES), JBDS_RENDERERS(StandardOutputFolders.JAVA_CLASSES),
+ XML_SCHEMA(StandardOutputFolders.RESOURCES), COMPONENT_TEST(StandardOutputFolders.TEST_JAVA_CLASSES);
- private final OutputType folderType;
- /**
- * <p class="changed_added_4_0"></p>
- * @param folderType
- */
- private StandardOutputs(OutputType folderType) {
- this.folderType = folderType;
- }
+ private final OutputType folderType;
- @Override
- public String getName() {
- return name();
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param folderType
+ */
+ private StandardOutputs(OutputType folderType) {
+ this.folderType = folderType;
+ }
- @Override
- public OutputType getFolderType() {
- return folderType;
- }
+ @Override
+ public String getName() {
+ return name();
+ }
+ @Override
+ public OutputType getFolderType() {
+ return folderType;
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/StandardSources.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/StandardSources.java 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/StandardSources.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk;
import org.richfaces.cdk.CdkContext.SourceType;
@@ -31,14 +33,10 @@
*
*/
public enum StandardSources implements SourceType {
-
- JAVA_SOURCES,
- FACES_CONFIGS,
- RENDERER_TEMPLATES;
+ JAVA_SOURCES, FACES_CONFIGS, RENDERER_TEMPLATES;
- @Override
- public String getName() {
- return name();
- }
-
+ @Override
+ public String getName() {
+ return name();
+ }
}
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-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/ValidatorImpl.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -21,85 +21,91 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.richfaces.cdk;
-import java.util.Collection;
+package org.richfaces.cdk;
import org.richfaces.cdk.model.Component;
import org.richfaces.cdk.model.ComponentLibrary;
-import org.richfaces.cdk.model.ModelCollection;
import org.richfaces.cdk.model.RenderKit;
import org.richfaces.cdk.model.Renderer;
+import java.util.Collection;
+
/**
* <p class="changed_added_4_0"></p>
* @author asmirnov(a)exadel.com
*
*/
public class ValidatorImpl implements ModelValidator {
+ private CdkContext context;
+ private NamingConventions namingConventions;
- private CdkContext context;
-
- private NamingConventions namingConventions;
+ public void init(CdkContext context) throws CdkException {
+ this.context = context;
+ this.namingConventions = context.getWorkerInstance(NamingConventions.class);
+ }
- public void init(CdkContext context) throws CdkException {
- this.context = context;
- this.namingConventions = context.getWorkerInstance(NamingConventions.class);
- }
+ /*
+ * (non-Javadoc)
+ * @see org.richfaces.cdk.ModelValidator#verify(org.richfaces.cdk.model.ComponentLibrary)
+ */
+ @Override
+ public void verify(ComponentLibrary library) throws CdkException {
+ verifyRenderers(library);
+ verifyComponents(library);
- /* (non-Javadoc)
- * @see org.richfaces.cdk.ModelValidator#verify(org.richfaces.cdk.model.ComponentLibrary)
- */
- @Override
- public void verify(ComponentLibrary library) throws CdkException {
- verifyRenderers(library);
- verifyComponents(library);
- // After all, merge all similar elements.
- compact(library.getComponents());
- compact(library.getRenderKits());
- compact(library.getRenderKits());
- }
+ // After all, merge all similar elements.
+ compact(library.getComponents());
+ compact(library.getRenderKits());
+ compact(library.getRenderKits());
+ }
- protected void verifyRenderers(ComponentLibrary library) {
- for (RenderKit renderKit : library.getRenderKits()) {
- // Check render kit name and class.
- for (Renderer renderer : renderKit.getRenderers()) {
- // Check type.
- // Check family.
- // Check generated class.
- // Check superclass.
- // Check component type.
- }
- compact(renderKit.getRenderers());
- }
-
- }
+ protected void verifyRenderers(ComponentLibrary library) {
+ for (RenderKit renderKit : library.getRenderKits()) {
- protected void verifyComponents(ComponentLibrary library) {
- NamingConventions namingConventions = getNamingConventions();
- for (Component component : library.getComponents()) {
- // Check classes.
- // Check Component type.
- if(null == component.getType()){
-// component.setType(new Component.Type(namingConventions.inferComponentType(explicitType, className)));
- }
- // Check family.
- // Check attributes.
- // Check renderers.
- compact(component.getAttributes());
- }
-
- }
+ // Check render kit name and class.
+ for (Renderer renderer : renderKit.getRenderers()) {
- private NamingConventions getNamingConventions() {
- return namingConventions;
- }
+ // Check type.
+ // Check family.
+ // Check generated class.
+ // Check superclass.
+ // Check component type.
+ }
- protected void compact(Collection<?> collection) {
-// if (collection instanceof ModelCollection) {
-// ModelCollection model = (ModelCollection) collection;
-// model.mergeKeys();
-// }
- }
+ compact(renderKit.getRenderers());
+ }
+ }
+
+ protected void verifyComponents(ComponentLibrary library) {
+ NamingConventions namingConventions = getNamingConventions();
+
+ for (Component component : library.getComponents()) {
+
+ // Check classes.
+ // Check Component type.
+ if (null == component.getType()) {
+
+// component.setType(new Component.Type(namingConventions.inferComponentType(explicitType, className)));
+ }
+
+ // Check family.
+ // Check attributes.
+ // Check renderers.
+ compact(component.getAttributes());
+ }
+ }
+
+ private NamingConventions getNamingConventions() {
+ return namingConventions;
+ }
+
+ protected void compact(Collection<?> collection) {
+
+// if (collection instanceof ModelCollection) {
+// ModelCollection model = (ModelCollection) collection;
+// model.mergeKeys();
+// }
+ }
}
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-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptBuilder.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -21,18 +21,22 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.apt;
import java.io.File;
+
import java.net.URL;
import java.net.URLClassLoader;
+
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Collection;
import java.util.List;
import java.util.Locale;
import javax.annotation.processing.Processor;
+
import javax.tools.Diagnostic;
import javax.tools.DiagnosticListener;
import javax.tools.JavaCompiler;
@@ -57,201 +61,216 @@
* <p class="changed_added_4_0">
* That class compiles files from sources and process annotations
* </p>
- *
+ *
* @author asmirnov(a)exadel.com
- *
+ *
*/
public class AptBuilder implements ModelBuilder {
-
- private static final Logger log = LoggerFactory.getLogger();
+ private static final Logger LOG = LoggerFactory.getLogger();
+ private boolean initialized = false;
+ private CdkContext context;
+ private VirtualFileManager fileManager;
+ private JavaCompiler javaCompiler;
+ private Locale locale;
+ private Iterable<String> options;
- private VirtualFileManager fileManager;
+ /**
+ * <p class="changed_added_4_0">Builder method that creates and initializes compiler instance.
+ * That instance can be reused for consecuence processing.</p>
+ * @param context
+ * @return
+ */
+ @Override
+ public void init(CdkContext context) {
+ this.context = context;
- private Iterable<String> options;
+ JavaCompiler javaCompiler = ToolProvider.getSystemJavaCompiler();
- private JavaCompiler javaCompiler;
-
- private Locale locale;
+ setJavaCompiler(javaCompiler);
- private CdkContext context;
-
- private boolean initialized = false;
+ ArrayList<String> options = new ArrayList<String>();
- /**
- * <p class="changed_added_4_0">Builder method that creates and initializes compiler instance.
- * That instance can be reused for consecuence processing.</p>
- * @param context
- * @return
- */
- @Override
- public void init(CdkContext context) {
- this.context = context;
- JavaCompiler javaCompiler = ToolProvider.getSystemJavaCompiler();
- setJavaCompiler(javaCompiler);
- ArrayList<String> options = new ArrayList<String>();
- options.add("-proc:only");
- options.add("-implicit:class");
- options.add("-verbose");
- ClassLoader classPathLoader = context.getLoader();
- StringBuilder classPathOption = new StringBuilder();
- boolean hasClassPathElement=false;
- while (null != classPathLoader && classPathLoader instanceof URLClassLoader) {
- URLClassLoader urlLoader = (URLClassLoader) classPathLoader;
+ options.add("-proc:only");
+ options.add("-implicit:class");
+ options.add("-verbose");
+
+ ClassLoader classPathLoader = context.getLoader();
+ StringBuilder classPathOption = new StringBuilder();
+ boolean hasClassPathElement = false;
+
+ while (null != classPathLoader && classPathLoader instanceof URLClassLoader) {
+ URLClassLoader urlLoader = (URLClassLoader) classPathLoader;
+
for (URL cpElement : urlLoader.getURLs()) {
- if(hasClassPathElement){
- classPathOption.append(File.pathSeparatorChar);
- } else {
+ if (hasClassPathElement) {
+ classPathOption.append(File.pathSeparatorChar);
+ } else {
options.add("-classpath");
- hasClassPathElement = true;
- }
- classPathOption.append(cpElement.getFile());
- }
+ hasClassPathElement = true;
+ }
+
+ classPathOption.append(cpElement.getFile());
+ }
+
classPathLoader = classPathLoader.getParent();
- }
- if (hasClassPathElement) {
- options.add(classPathOption.toString());
- log.info("Compiler classpath:" + classPathOption);
+ }
- }
- Iterable<File> sourceFolders = context.getSourceFolders(StandardSources.JAVA_SOURCES);
- File javaSource;
- if(null != sourceFolders && sourceFolders.iterator().hasNext()){
- options.add("-sourcepath");
- javaSource = sourceFolders.iterator().next();
- options.add(javaSource.getAbsolutePath());
- } else {
- javaSource = null;
- }
- if(null != context.getOutputFolder(StandardOutputs.COMPONENT_CLASSES)){
- options.add("-s");
- options.add(context.getOutputFolder(StandardOutputs.COMPONENT_CLASSES).getAbsolutePath());
- }
- setOptions(options);
- // TODO - provide source files locale.
- setLocale(Locale.getDefault());
- // TODO -set locale and charset for platform-independent processing. Provide own diagnostics listener.
- StandardJavaFileManager stdFileManager = javaCompiler
- .getStandardFileManager(null, null, null);
- // TODO - use standard file manager for all tasks.
- VirtualFileManager fileManager = new VirtualFileManager(stdFileManager,
- context.getLoader());
- fileManager.setJavaSourceDirectory(javaSource);
- setFileManager(fileManager);
- initialized = true;
- }
+ if (hasClassPathElement) {
+ options.add(classPathOption.toString());
+ LOG.info("Compiler classpath:" + classPathOption);
+ }
- @Override
- public ComponentLibrary build() throws CdkException {
- if(!initialized){
- throw new CdkException("Annotation processor is not initialized");
- }
- ComponentLibrary library = new ComponentLibrary();
- ComponentProcessor processor = new ComponentProcessor(context,library);
- process(context.getSources(StandardSources.JAVA_SOURCES),processor);
- return library;
- }
- /**
- * <p class="changed_added_4_0">That method process source files and call appropriate annotation processors</p>
- * @param sources
- * @param processors
- * @throws AptException
- */
- protected void process(Iterable<File> sources, Processor...processors) throws AptException {
- final List<String> messages = Lists.newArrayList();
- DiagnosticListener<JavaFileObject> listener = new DiagnosticListener<JavaFileObject>() {
+ Iterable<File> sourceFolders = context.getSourceFolders(StandardSources.JAVA_SOURCES);
+ File javaSource;
- @Override
- public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
- log.debug("LOG: " + diagnostic.getMessage(null));
- if(Kind.ERROR.equals(diagnostic.getKind())){
- messages.add(diagnostic.getMessage(null));
- }
- }
+ if (null != sourceFolders && sourceFolders.iterator().hasNext()) {
+ options.add("-sourcepath");
+ javaSource = sourceFolders.iterator().next();
+ options.add(javaSource.getAbsolutePath());
+ } else {
+ javaSource = null;
+ }
- };
- ArrayList<VirtualJavaFileObject> sourceObjects = new ArrayList<VirtualJavaFileObject>();
- for (File file : sources) {
- VirtualJavaFileObject sourceObject = new VirtualJavaFileSystemObject(file);
- sourceObjects.add(sourceObject);
- }
- CompilationTask task = getJavaCompiler().getTask(null, getFileManager(), listener, getOptions(), null, sourceObjects);
- task.setProcessors(Arrays.asList(processors));
- task.setLocale(locale);
- if(!task.call()){
- throw new AptException("Compilation error: "+messages);
- }
- }
+ if (null != context.getOutputFolder(StandardOutputs.COMPONENT_CLASSES)) {
+ options.add("-s");
+ options.add(context.getOutputFolder(StandardOutputs.COMPONENT_CLASSES).getAbsolutePath());
+ }
+ setOptions(options);
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @return the options
- */
- protected Iterable<String> getOptions() {
- return options;
- }
+ // TODO - provide source files locale.
+ setLocale(Locale.getDefault());
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @param options
- * the options to set
- */
- protected void setOptions(Iterable<String> options) {
- this.options = options;
- }
+ // TODO -set locale and charset for platform-independent processing. Provide own diagnostics listener.
+ StandardJavaFileManager stdFileManager = javaCompiler.getStandardFileManager(null, null, null);
- /**
- * <p class="changed_added_4_0"></p>
- * @return the fileManager
- */
- protected VirtualFileManager getFileManager() {
- return fileManager;
- }
+ // TODO - use standard file manager for all tasks.
+ VirtualFileManager fileManager = new VirtualFileManager(stdFileManager, context.getLoader());
- /**
- * <p class="changed_added_4_0"></p>
- * @param fileManager the fileManager to set
- */
- protected void setFileManager(VirtualFileManager fileManager) {
- this.fileManager = fileManager;
- }
+ fileManager.setJavaSourceDirectory(javaSource);
+ setFileManager(fileManager);
+ initialized = true;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param javaCompiler the javaCompiler to set
- */
- protected void setJavaCompiler(JavaCompiler javaCompiler) {
- this.javaCompiler = javaCompiler;
- }
+ @Override
+ public ComponentLibrary build() throws CdkException {
+ if (!initialized) {
+ throw new CdkException("Annotation processor is not initialized");
+ }
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @return the javaCompiler
- */
- protected JavaCompiler getJavaCompiler() {
- return javaCompiler;
- }
+ ComponentLibrary library = new ComponentLibrary();
+ ComponentProcessor processor = new ComponentProcessor(context, library);
- /**
- * <p class="changed_added_4_0"></p>
- * @return the locale
- */
- public Locale getLocale() {
- return locale;
- }
+ process(context.getSources(StandardSources.JAVA_SOURCES), processor);
- /**
- * <p class="changed_added_4_0"></p>
- * @param locale the locale to set
- */
- public void setLocale(Locale locale) {
- this.locale = locale;
- }
+ return library;
+ }
+ /**
+ * <p class="changed_added_4_0">That method process source files and call appropriate annotation processors</p>
+ * @param sources
+ * @param processors
+ * @throws AptException
+ */
+ protected void process(Iterable<File> sources, Processor... processors) throws AptException {
+ final List<String> messages = Lists.newArrayList();
+ DiagnosticListener<JavaFileObject> listener = new DiagnosticListener<JavaFileObject>() {
+ @Override
+ public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
+ LOG.debug("LOG: " + diagnostic.getMessage(null));
+
+ if (Kind.ERROR.equals(diagnostic.getKind())) {
+ messages.add(diagnostic.getMessage(null));
+ }
+ }
+ };
+ ArrayList<VirtualJavaFileObject> sourceObjects = new ArrayList<VirtualJavaFileObject>();
+
+ for (File file : sources) {
+ VirtualJavaFileObject sourceObject = new VirtualJavaFileSystemObject(file);
+
+ sourceObjects.add(sourceObject);
+ }
+
+ CompilationTask task = getJavaCompiler().getTask(null, getFileManager(), listener, getOptions(), null,
+ sourceObjects);
+
+ task.setProcessors(Arrays.asList(processors));
+ task.setLocale(locale);
+
+ if (!task.call()) {
+ throw new AptException("Compilation error: " + messages);
+ }
+ }
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @return the options
+ */
+ protected Iterable<String> getOptions() {
+ return options;
+ }
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param options
+ * the options to set
+ */
+ protected void setOptions(Iterable<String> options) {
+ this.options = options;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the fileManager
+ */
+ protected VirtualFileManager getFileManager() {
+ return fileManager;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param fileManager the fileManager to set
+ */
+ protected void setFileManager(VirtualFileManager fileManager) {
+ this.fileManager = fileManager;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param javaCompiler the javaCompiler to set
+ */
+ protected void setJavaCompiler(JavaCompiler javaCompiler) {
+ this.javaCompiler = javaCompiler;
+ }
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @return the javaCompiler
+ */
+ protected JavaCompiler getJavaCompiler() {
+ return javaCompiler;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the locale
+ */
+ public Locale getLocale() {
+ return locale;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param locale the locale to set
+ */
+ public void setLocale(Locale locale) {
+ this.locale = locale;
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptException.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptException.java 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptException.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.apt;
import org.richfaces.cdk.CdkException;
@@ -32,40 +34,38 @@
*/
public class AptException extends CdkException {
- /**
- * <p class="changed_added_4_0"></p>
- */
- private static final long serialVersionUID = 8023042422371321042L;
+ /**
+ * <p class="changed_added_4_0"></p>
+ */
+ private static final long serialVersionUID = 8023042422371321042L;
- /**
- * <p class="changed_added_4_0"></p>
- */
- public AptException() {
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ */
+ public AptException() {}
- /**
- * <p class="changed_added_4_0"></p>
- * @param message
- */
- public AptException(String message) {
- super(message);
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param message
+ */
+ public AptException(String message) {
+ super(message);
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param cause
- */
- public AptException(Throwable cause) {
- super(cause);
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param cause
+ */
+ public AptException(Throwable cause) {
+ super(cause);
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param message
- * @param cause
- */
- public AptException(String message, Throwable cause) {
- super(message, cause);
- }
-
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param message
+ * @param cause
+ */
+ public AptException(String message, Throwable cause) {
+ super(message, cause);
+ }
}
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-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/CdkProcessor.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -21,278 +21,290 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.apt;
-import java.lang.annotation.Annotation;
-import java.util.List;
-import java.util.Set;
+import com.google.common.collect.Sets;
+import org.richfaces.cdk.CdkContext;
+import org.richfaces.cdk.CdkException;
+import org.richfaces.cdk.NamingConventions;
+import org.richfaces.cdk.model.InvalidNameException;
+import org.richfaces.cdk.util.PropertyUtils;
+
import javax.annotation.processing.AbstractProcessor;
import javax.annotation.processing.RoundEnvironment;
-import javax.annotation.processing.SupportedSourceVersion;
+
import javax.lang.model.SourceVersion;
-import javax.lang.model.element.Element;
-import javax.lang.model.element.ElementKind;
-import javax.lang.model.element.ExecutableElement;
-import javax.lang.model.element.Modifier;
-import javax.lang.model.element.TypeElement;
-import javax.lang.model.element.TypeParameterElement;
-import javax.lang.model.element.VariableElement;
-import javax.lang.model.type.DeclaredType;
+import javax.lang.model.element.*;
import javax.lang.model.type.TypeKind;
import javax.lang.model.type.TypeMirror;
-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.annotations.Icon;
-import org.richfaces.cdk.model.ClassDescription;
-import org.richfaces.cdk.model.InvalidNameException;
-import org.richfaces.cdk.util.PropertyUtils;
+import java.lang.annotation.Annotation;
-import com.google.common.collect.Sets;
+import java.util.List;
+import java.util.Set;
/**
* <p class="changed_added_4_0">
* Base class for all CDK Annotation processors. That class provides access to
* current CDK context and utility methods for Java source models.
* </p>
- *
+ *
* @author asmirnov(a)exadel.com
- *
+ *
*/
public abstract class CdkProcessor extends AbstractProcessor {
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @author asmirnov(a)exadel.com
- *
- */
- protected final class BeanProperty {
+ /**
+ * <p class="changed_added_4_0">
+ * CDK context.
+ * </p>
+ */
+ protected final CdkContext context;
- private TypeMirror type;
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param context
+ * current CDK context
+ */
+ protected CdkProcessor(CdkContext context) {
+ super();
+ this.context = context;
+ }
- private Element element;
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @return the context
+ */
+ protected CdkContext getContext() {
+ return context;
+ }
- private final String name;
+ @Override
+ public SourceVersion getSupportedSourceVersion() {
- private boolean exists;
+ // CDK supports Java 5 or 6 source code.
+ return SourceVersion.RELEASE_6;
+ }
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#hashCode()
- */
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((name == null) ? 0 : name.hashCode());
- return result;
- }
+ /**
+ * <p class="changed_added_4_0">
+ * Get all classes annotated with particular annotation.
+ * </p>
+ * @param round
+ * current round environment.
+ * @param annotation
+ * annotation class.
+ *
+ * @return {@link Set} of all classes annotated with {@code annotation}
+ * type.
+ */
+ protected Set<? extends TypeElement> getClassesAnnotatedWith(RoundEnvironment round,
+ Class<? extends Annotation> annotation) {
+ Set<TypeElement> classes = Sets.newHashSet();
+ Set<? extends Element> annotatedWith = round.getElementsAnnotatedWith(annotation);
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#equals(java.lang.Object)
- */
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- BeanProperty other = (BeanProperty) obj;
- if (name == null) {
- if (other.name != null)
- return false;
- } else if (!name.equals(other.name))
- return false;
- return true;
- }
+ for (Element element : annotatedWith) {
+ if (ElementKind.CLASS.equals(element.getKind())) {
+ TypeElement classElement = (TypeElement) element;
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @param name
- */
- public BeanProperty(String name) {
- this.name = name;
- }
+ classes.add(classElement);
+ }
+ }
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @return the name
- */
- public String getName() {
- return name;
- }
+ return classes;
+ }
- /**
- * <p class="changed_added_4_0">Get JavaDoc comment of appropriate bean property element.</p>
- * @return
- */
- public String getDocComment() {
- return processingEnv.getElementUtils().getDocComment(element);
- }
+ /**
+ * <p class="changed_added_4_0">
+ * Get all fields and bean properties that are annotated with given
+ * annotation.
+ * </p>
+ *
+ * @param annotation
+ * @param type
+ * @return
+ */
+ protected Set<BeanProperty> getBeanPropertiesAnnotatedWith(Class<? extends Annotation> annotation,
+ TypeElement type) {
+ Set<BeanProperty> properties = Sets.newHashSet();
+ List<? extends Element> members = this.processingEnv.getElementUtils().getAllMembers(type);
- public TypeMirror getType() {
- return type;
- }
+ // Get all methods and fields annotated by annotation.
+ for (Element childElement : members) {
+ if (null != childElement.getAnnotation(annotation)) {
+ // Have an annotation, infer property name.
+ String name;
+ TypeMirror propertyType;
+ boolean exists = false;
- /**
- * <p class="changed_added_4_0"></p>
- * @return the exists
- */
- public boolean isExists() {
- return exists;
- }
+ if (ElementKind.METHOD.equals(childElement.getKind())) {
+ ExecutableElement method = (ExecutableElement) childElement;
- public <T extends Annotation> T getAnnotation(Class<T> annotationType) {
- return element.getAnnotation(annotationType);
- }
+ propertyType = method.getReturnType();
- }
+ List<? extends VariableElement> parameters = method.getParameters();
- /**
- * <p class="changed_added_4_0">
- * CDK context.
- * </p>
- */
- protected final CdkContext context;
+ if (TypeKind.VOID.equals(propertyType.getKind()) && 1 == parameters.size()) {
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @param context
- * current CDK context
- */
- protected CdkProcessor(CdkContext context) {
- super();
- this.context = context;
- }
+ // That is setter method, get type from parameter.
+ propertyType = parameters.get(0).asType();
+ } else if (!parameters.isEmpty()) {
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @return the context
- */
- protected CdkContext getContext() {
- return context;
- }
+ // TODO Invalid method signature for a bean property,
+ // throw exception ?
+ continue;
+ }
- @Override
- public SourceVersion getSupportedSourceVersion() {
- // CDK supports Java 5 or 6 source code.
- return SourceVersion.RELEASE_6;
- }
+ try {
+ name = PropertyUtils.methodToName(childElement.getSimpleName().toString());
+ } catch (InvalidNameException e) {
- /**
- * <p class="changed_added_4_0">
- * Get all classes annotated with particular annotation.
- * </p>
- * @param round
- * current round environment.
- * @param annotation
- * annotation class.
- *
- * @return {@link Set} of all classes annotated with {@code annotation}
- * type.
- */
- protected Set<? extends TypeElement> getClassesAnnotatedWith(
- RoundEnvironment round, Class<? extends Annotation> annotation) {
- Set<TypeElement> classes = Sets.newHashSet();
- Set<? extends Element> annotatedWith = round
- .getElementsAnnotatedWith(annotation);
- for (Element element : annotatedWith) {
- if (ElementKind.CLASS.equals(element.getKind())) {
- TypeElement classElement = (TypeElement) element;
- classes.add(classElement);
- }
- }
- return classes;
- }
+ // TODO Invalid method name for a bean property, throw
+ // exception ?
+ continue;
+ }
- /**
- * <p class="changed_added_4_0">
- * Get all fields and bean properties that are annotated with given
- * annotation.
- * </p>
- *
- * @param annotation
- * @param type
- * @return
- */
- protected Set<BeanProperty> getBeanPropertiesAnnotatedWith(
- Class<? extends Annotation> annotation, TypeElement type) {
- Set<BeanProperty> properties = Sets.newHashSet();
- List<? extends Element> members = this.processingEnv.getElementUtils().getAllMembers(
- type);
- // Get all methods and fields annotated by annotation.
- for (Element childElement : members) {
- if (null != childElement.getAnnotation(annotation)) {
- // Have an annotation, infer property name.
- String name;
- TypeMirror propertyType;
- boolean exists = false;
- if (ElementKind.METHOD.equals(childElement.getKind())) {
- ExecutableElement method = (ExecutableElement) childElement;
- propertyType = method.getReturnType();
- List<? extends VariableElement> parameters = method
- .getParameters();
- if (TypeKind.VOID.equals(propertyType.getKind())
- && 1 == parameters.size()) {
- // That is setter method, get type from parameter.
- propertyType = parameters.get(0).asType();
- } else if (!parameters.isEmpty()) {
- // TODO Invalid method signature for a bean property,
- // throw exception ?
- continue;
- }
- try {
- name = PropertyUtils
- .methodToName(childElement.getSimpleName()
- .toString());
- } catch (InvalidNameException e) {
- // TODO Invalid method name for a bean property, throw
- // exception ?
- continue;
- }
- exists = !method.getModifiers().contains(Modifier.ABSTRACT);
- // List<? extends TypeParameterElement> typeParameters = method.getTypeParameters();
- } else if (ElementKind.FIELD
- .equals(childElement.getKind())) {
- name = childElement.getSimpleName().toString();
- propertyType = childElement.asType();
- // TODO - find getter/setter, check them for abstract.
- exists = true;
- } else {
- continue;
- }
- BeanProperty property = new BeanProperty(name);
- property.type = propertyType;
- property.element = childElement;
- property.exists = exists;
- // TODO - merge properties with same name ?
- properties.add(property);
- }
- }
- return properties;
- }
+ exists = !method.getModifiers().contains(Modifier.ABSTRACT);
- protected NamingConventions getNamingConventions() throws CdkException {
- return getContext().getWorkerInstance(NamingConventions.class);
- }
-
+ // List<? extends TypeParameterElement> typeParameters = method.getTypeParameters();
+ } else if (ElementKind.FIELD.equals(childElement.getKind())) {
+ name = childElement.getSimpleName().toString();
+ propertyType = childElement.asType();
+
+ // TODO - find getter/setter, check them for abstract.
+ exists = true;
+ } else {
+ continue;
+ }
+
+ BeanProperty property = new BeanProperty(name);
+
+ property.type = propertyType;
+ property.element = childElement;
+ property.exists = exists;
+
+ // TODO - merge properties with same name ?
+ properties.add(property);
+ }
+ }
+
+ return properties;
+ }
+
+ protected NamingConventions getNamingConventions() throws CdkException {
+ return getContext().getWorkerInstance(NamingConventions.class);
+ }
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @author asmirnov(a)exadel.com
+ *
+ */
+ protected final class BeanProperty {
+ private Element element;
+ private boolean exists;
+ private final String name;
+ private TypeMirror type;
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param name
+ */
+ public BeanProperty(String name) {
+ this.name = name;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+
+ result = prime * result + ((name == null) ? 0 : name.hashCode());
+
+ return result;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+
+ if (obj == null) {
+ return false;
+ }
+
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+
+ BeanProperty other = (BeanProperty) obj;
+
+ if (name == null) {
+ if (other.name != null) {
+ return false;
+ }
+ } else if (!name.equals(other.name)) {
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @return the name
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * <p class="changed_added_4_0">Get JavaDoc comment of appropriate bean property element.</p>
+ * @return
+ */
+ public String getDocComment() {
+ return processingEnv.getElementUtils().getDocComment(element);
+ }
+
+ public TypeMirror getType() {
+ return type;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the exists
+ */
+ public boolean isExists() {
+ return exists;
+ }
+
+ public <T extends Annotation> T getAnnotation(Class<T> annotationType) {
+ return element.getAnnotation(annotationType);
+ }
+ }
}
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-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ComponentProcessor.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -21,47 +21,15 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.apt;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.Map.Entry;
+import com.google.common.collect.Lists;
-import javax.annotation.processing.RoundEnvironment;
-import javax.annotation.processing.SupportedAnnotationTypes;
-import javax.faces.component.FacesComponent;
-import javax.faces.event.FacesEvent;
-import javax.lang.model.element.AnnotationMirror;
-import javax.lang.model.element.AnnotationValue;
-import javax.lang.model.element.Element;
-import javax.lang.model.element.ExecutableElement;
-import javax.lang.model.element.Modifier;
-import javax.lang.model.element.Name;
-import javax.lang.model.element.TypeElement;
-import javax.lang.model.element.VariableElement;
-import javax.lang.model.type.MirroredTypesException;
-import javax.lang.model.type.TypeMirror;
-import javax.lang.model.util.ElementFilter;
-
import org.richfaces.cdk.CdkContext;
import org.richfaces.cdk.CdkException;
-import org.richfaces.cdk.annotations.Attribute;
-import org.richfaces.cdk.annotations.Attributes;
-import org.richfaces.cdk.annotations.Component;
-import org.richfaces.cdk.annotations.DefaultValue;
-import org.richfaces.cdk.annotations.DisplayName;
-import org.richfaces.cdk.annotations.EventName;
-import org.richfaces.cdk.annotations.EventNames;
-import org.richfaces.cdk.annotations.Facet;
-import org.richfaces.cdk.annotations.Facets;
-import org.richfaces.cdk.annotations.Family;
-import org.richfaces.cdk.annotations.Fires;
-import org.richfaces.cdk.annotations.Generate;
-import org.richfaces.cdk.annotations.Icon;
-import org.richfaces.cdk.annotations.Signature;
-import org.richfaces.cdk.annotations.SuggestedValue;
+import org.richfaces.cdk.annotations.*;
import org.richfaces.cdk.model.ClassDescription;
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.DescriptionGroup;
@@ -70,367 +38,449 @@
import org.richfaces.cdk.xmlconfig.CdkEntityResolver;
import org.richfaces.cdk.xmlconfig.FragmentParser;
-import com.google.common.collect.Lists;
+import javax.annotation.processing.RoundEnvironment;
+import javax.annotation.processing.SupportedAnnotationTypes;
+import javax.faces.event.FacesEvent;
+
+import javax.lang.model.element.*;
+import javax.lang.model.type.MirroredTypesException;
+import javax.lang.model.type.TypeMirror;
+import javax.lang.model.util.ElementFilter;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+
/**
- * <p class="changed_added_4_0">That class process component-related annotations such as {@link Component} or {@link FacesComponent} and stores information in model.
+ * <p class="changed_added_4_0">That class process component-related annotations such as {@link Component} or
+ * {@link javax.faces.component.FacesComponent} and stores information in model.
* </p>
- *
+ *
* @author asmirnov(a)exadel.com
- *
+ *
*/
-@SupportedAnnotationTypes({"javax.faces.component.FacesComponent",Component.NAME})
+@SupportedAnnotationTypes({"javax.faces.component.FacesComponent", Component.NAME})
public class ComponentProcessor extends CdkProcessor {
+ private static final String FACES_COMPONENT = "javax.faces.component.FacesComponent";
+ private FragmentParser fragmentParser;
+ private final ComponentLibrary library;
- private static final String FACES_COMPONENT = "javax.faces.component.FacesComponent";
- private final ComponentLibrary library;
- private FragmentParser fragmentParser;
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param context
+ * @throws CdkException
+ */
+ public ComponentProcessor(CdkContext context, ComponentLibrary library) throws CdkException {
+ super(context);
+ this.library = library;
+ fragmentParser = context.getWorkerInstance(FragmentParser.class);
+ }
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @param context
- * @throws CdkException
- */
- public ComponentProcessor(CdkContext context, ComponentLibrary library) throws CdkException {
- super(context);
- this.library = library;
- fragmentParser = context.getWorkerInstance(FragmentParser.class);
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.annotation.processing.AbstractProcessor#process(java.util.Set,
+ * javax.annotation.processing.RoundEnvironment)
+ */
+ @Override
+ public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
+ if (null != annotations && !annotations.isEmpty()) {
+ ComponentLibrary library = getLibrary();
- /*
- * (non-Javadoc)
- *
- * @see javax.annotation.processing.AbstractProcessor#process(java.util.Set,
- * javax.annotation.processing.RoundEnvironment)
- */
- @Override
- public boolean process(Set<? extends TypeElement> annotations,
- RoundEnvironment roundEnv) {
- if (null != annotations && !annotations.isEmpty()) {
- ComponentLibrary library = getLibrary();
- // Process all component classes annotated with CDK @Component.
- Set<? extends TypeElement> componentClasses = getClassesAnnotatedWith(
- roundEnv, Component.class);
- for (TypeElement componentElement : componentClasses) {
- try {
- // Process class-level annotations.
- // Calculate type for base UI component class.
- 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 = getNamingConventions().inferComponentType(componentAnnotation.value(),componentElement.getQualifiedName().toString());
- org.richfaces.cdk.model.Component component = library.findOrCreateComponent(type);
- // Should that component be generated ?
- setClassNames(componentElement, component);
- setComponentProperties(componentElement, component);
- } catch (Exception e) {
- // rise error and continue.
- processingEnv.getMessager().printMessage(
- javax.tools.Diagnostic.Kind.ERROR, e.getMessage(),
- componentElement);
- continue;
- }
- }
- // process classes annotated as "FacesComponent".
- TypeElement facesComponentAnnotation = this.processingEnv.getElementUtils().getTypeElement(FACES_COMPONENT);
- // TODO - extrach AnnotationMirror processing into separate methods.
- Set<? extends TypeElement> annotatedWith = ElementFilter.typesIn(roundEnv.getElementsAnnotatedWith(facesComponentAnnotation));
- for (TypeElement element : annotatedWith) {
- List<? extends AnnotationMirror> mirrors = element.getAnnotationMirrors();
- for (AnnotationMirror mirror : mirrors) {
- if(FACES_COMPONENT.equals(mirror.getAnnotationType().toString())){
- Map<? extends ExecutableElement, ? extends AnnotationValue> valuesWithDefaults = processingEnv.getElementUtils().getElementValuesWithDefaults(mirror);
- for (Entry<? extends ExecutableElement, ? extends AnnotationValue> valueEntry : valuesWithDefaults.entrySet()) {
- Name name = valueEntry.getKey().getSimpleName();
- if("value".equals(name.toString())){
- try {
- Object value = valueEntry.getValue().getValue();
- if(null!=value && value instanceof String){
- org.richfaces.cdk.model.Component component = library.findOrCreateComponent(value.toString());
- ClassDescription componentClass = new ClassDescription(element
- .getQualifiedName().toString());
- component.setComponentClass(componentClass);
- component.setGenerate(false);
- setComponentProperties(element, component);
- }
- } catch (Exception e) {
- // rise error and continue.
- processingEnv.getMessager().printMessage(
- javax.tools.Diagnostic.Kind.ERROR, e.getMessage(),
- element);
- continue;
- }
- }
- }
- }
- }
- }
- return true;
- }
- return false;
- }
+ // Process all component classes annotated with CDK @Component.
+ Set<? extends TypeElement> componentClasses = getClassesAnnotatedWith(roundEnv, Component.class);
- private void setComponentProperties(TypeElement componentElement,
- org.richfaces.cdk.model.Component component) throws CdkException {
- // Component family
- setComponeneFamily(componentElement, component);
- setComponentDescription(componentElement, component);
- processFacets(componentElement,component);
- // TODO - process Events attribute.
- // TODO - process renderers ( @Renderer and @RendererTemplate attribute.
- // TODO - process @Test annotations.
- // Process attributes.
- processAttributes(componentElement, component);
- }
+ for (TypeElement componentElement : componentClasses) {
+ try {
- private void processFacets(TypeElement componentElement,
- org.richfaces.cdk.model.Component component) throws CdkException {
- Set<BeanProperty> properties = getBeanPropertiesAnnotatedWith(
- Facet.class, componentElement);
- // TODO - encapsulate attribute builder into utility class.
- for (BeanProperty beanProperty : properties) {
- org.richfaces.cdk.model.Facet facet = component.findOrCreateFacet(beanProperty
- .getName());
- // Documentation
- facet.setDescription(beanProperty.getDocComment());
- Icon icon = beanProperty.getAnnotation(Icon.class);
- if (null != icon) {
- setIcon(facet, icon);
- }
- DisplayName displayName = beanProperty
- .getAnnotation(DisplayName.class);
- if (null != displayName) {
- facet.setDisplayname(displayName.value());
- }
- // Flags.
- facet.setGenerate(beanProperty.isExists());
- }
- // @Facets annotation.
- Facets facetsAnnotation = componentElement
- .getAnnotation(Facets.class);
- if (null != facetsAnnotation) {
- Facet[] facets = facetsAnnotation.value();
- for (Facet facet : facets) {
- if (!Strings.isEmpty(facet.value())) {
- component.findOrCreateFacet(facet.value());
- } else {
- // TODO - record error.
- }
- }
- }
-
- }
+ // Process class-level annotations.
+ // Calculate type for base UI component class.
+ Component componentAnnotation = componentElement.getAnnotation(Component.class);
- private void setComponentDescription(TypeElement componentElement,
- org.richfaces.cdk.model.Component component) {
- // JavaDoc comments
- component.setDescription(this.processingEnv.getElementUtils()
- .getDocComment(componentElement));
- Icon icon = componentElement.getAnnotation(Icon.class);
- if (null != icon) {
- setIcon(component, icon);
- }
- DisplayName displayName = componentElement
- .getAnnotation(DisplayName.class);
- if (null != displayName) {
- component.setDisplayname(displayName.value());
- }
- }
+ // Because component type is a primary key for components collection, we have to infer explicit
+ // value here.
+ String type = getNamingConventions().inferComponentType(componentAnnotation.value(),
+ componentElement.getQualifiedName().toString());
+ org.richfaces.cdk.model.Component component = library.findOrCreateComponent(type);
- /**
- * <p class="changed_added_4_0"></p>
- * @param component
- * @param icon
- */
- private void setIcon(DescriptionGroup component, Icon icon) {
- DescriptionGroup.Icon iconValue = new DescriptionGroup.Icon();
- if (icon.small().length() > 0) {
- iconValue.setSmallIcon(icon.small());
- }
- if (icon.large().length() > 0) {
- iconValue.setLargeIcon(icon.large());
- }
- component.setIcon(iconValue);
- }
+ // Should that component be generated ?
+ setClassNames(componentElement, component);
+ setComponentProperties(componentElement, component);
+ } catch (Exception e) {
- private void setComponeneFamily(TypeElement componentElement,
- org.richfaces.cdk.model.Component component) {
- Family family = componentElement.getAnnotation(Family.class);
- if (null != family) {
- // @Family annotation
- component.setFamily(family.value());
- } else {
- // static final COMPONENT_FAMILY string constant.
- List<VariableElement> fieldsIn = ElementFilter.fieldsIn(this.processingEnv.getElementUtils().getAllMembers(componentElement));
- for (VariableElement field : fieldsIn) {
- Set<Modifier> modifiers = field.getModifiers();
- if(modifiers.contains(Modifier.FINAL)&&modifiers.contains(Modifier.STATIC)&&field.getSimpleName().equals("COMPONENT_FAMILY")){
- Object value = field.getConstantValue();
- if(null != value){
- component.setFamily(value.toString());
- }
- }
- }
- }
- }
+ // rise error and continue.
+ processingEnv.getMessager().printMessage(javax.tools.Diagnostic.Kind.ERROR, e.getMessage(),
+ componentElement);
- private void setEvents(TypeElement componentElement,
- org.richfaces.cdk.model.Component component) {
- Fires fires = componentElement.getAnnotation(Fires.class);
- if(null != fires){
- try {
- for (Class<? extends FacesEvent> eventClass : fires.value()) {
- component.addEvent(eventClass.getName());
- }
- } catch (MirroredTypesException mirror) {
- for(TypeMirror eventType :mirror.getTypeMirrors()){
- component.addEvent(eventType.toString());
- // TODO - check does component already implement eventSource interface
- }
- }
- }
- }
+ continue;
+ }
+ }
-
- private void setClassNames(TypeElement componentElement,
- org.richfaces.cdk.model.Component component) {
- Generate generate = componentElement.getAnnotation(Generate.class);
- // Set generated and base class names.
- ClassDescription baseClass = new ClassDescription(componentElement
- .getQualifiedName().toString());
- if (null != generate) {
- component.setComponentClass(new ClassDescription(generate.value()));
- component.setBaseClass(baseClass);
- component.setGenerate(true);
- } else if (componentElement.getModifiers().contains(Modifier.ABSTRACT)) {
- // Final component class will be set by validator.
- component.setBaseClass(baseClass);
- component.setGenerate(true);
- } else {
- component.setComponentClass(baseClass);
- component.setGenerate(false);
- }
- }
+ // process classes annotated as "FacesComponent".
+ TypeElement facesComponentAnnotation = this.processingEnv.getElementUtils().getTypeElement(FACES_COMPONENT);
- protected void processAttributes(TypeElement componentElement,
- org.richfaces.cdk.model.Component component) throws CdkException {
- Set<BeanProperty> properties = getBeanPropertiesAnnotatedWith(
- Attribute.class, componentElement);
- // TODO - encapsulate attribute builder into utility class.
- for (BeanProperty beanProperty : properties) {
- Property attribute = component.findOrCreateAttribute(beanProperty
- .getName());
- // Flags
- Attribute attributeAnnotarion = beanProperty.getAnnotation(Attribute.class);
- attribute.setHidden(attributeAnnotarion.hidden());
- attribute.setLiteral(attributeAnnotarion.literal());
- attribute.setPassThrough(attributeAnnotarion.passThough());
- attribute.setRequired(attributeAnnotarion.required());
- attribute.setReadOnly(attributeAnnotarion.readOnly());
- // Documentation
- attribute.setDescription(beanProperty.getDocComment());
- Icon icon = beanProperty.getAnnotation(Icon.class);
- if (null != icon) {
- setIcon(attribute,icon);
- }
- DisplayName displayName = beanProperty
- .getAnnotation(DisplayName.class);
- if (null != displayName) {
- attribute.setDisplayname(displayName.value());
- }
- // type.
- attribute.setType(new ClassDescription(beanProperty.getType()
- .toString()));
- // MethodExpression call signature.
- Signature signature = beanProperty.getAnnotation(Signature.class);
- if(null != signature){
- List<ClassDescription> parameters = Lists.newArrayList();
- try {
- for (Class<?> parameterType : signature.parameters()) {
- parameters.add(new ClassDescription(parameterType.getName()));
- }
- } catch (MirroredTypesException e) {
- for(TypeMirror parameterType :e.getTypeMirrors()){
- parameters.add(new ClassDescription(parameterType.toString()));
- }
- }
- // signature parameters always should be replaced.
- attribute.setSignature(parameters);
- // TODO - set method return type.
- }
- // Behavior events.
- EventName eventName = beanProperty.getAnnotation(EventName.class);
- setBehaviorEvent(attribute, eventName);
- EventNames eventNames = beanProperty.getAnnotation(EventNames.class);
- if(null != eventNames){
- for (EventName eventNameInstance : eventNames.value()) {
- setBehaviorEvent(attribute, eventNameInstance);
- }
- }
- // DefaultValues
- DefaultValue defaultValue = beanProperty.getAnnotation(DefaultValue.class);
- if(null != defaultValue){
- attribute.setDefaultValue(defaultValue.value());
- }
- SuggestedValue suggestedValue = beanProperty.getAnnotation(SuggestedValue.class);
- if(null != suggestedValue){
- attribute.setSuggestedValue(suggestedValue.value());
- }
- // Flags.
- attribute.setGenerate(!beanProperty.isExists()||null != beanProperty.getAnnotation(Generate.class));
- }
- // Process XML files with standard attributes definitions.
- Attributes attributes = componentElement
- .getAnnotation(Attributes.class);
- if (null != attributes) {
- String[] includes = attributes.value();
- for (String attributesConfig : includes) {
- // process additional properties.
- component.getAttributes().addAll(fragmentParser.parseProperties(attributesConfig));
- }
- }
- // Process standard information for parent classes
- processTypeProperties(component,componentElement.getSuperclass());
- // and interfaces.
- List<? extends TypeMirror> interfaces = componentElement.getInterfaces();
- for (TypeMirror interfaceMirror : interfaces) {
- processTypeProperties(component,interfaceMirror);
- }
- }
+ // TODO - extrach AnnotationMirror processing into separate methods.
+ Set<? extends TypeElement> annotatedWith =
+ ElementFilter.typesIn(roundEnv.getElementsAnnotatedWith(facesComponentAnnotation));
- private void setBehaviorEvent(Property attribute, EventName eventName) {
- if(null != eventName){
- org.richfaces.cdk.model.EventName event = new org.richfaces.cdk.model.EventName();
- event.setName(eventName.value());
- event.setDefaultEvent(eventName.defaultEvent());
- attribute.getEventNames().add(event);
- }
- }
+ for (TypeElement element : annotatedWith) {
+ List<? extends AnnotationMirror> mirrors = element.getAnnotationMirrors();
- /**
- * <p class="changed_added_4_0">Reccursive method to find and process standard class or interface attributes.</p>
- * @param component
- * @param interfaceMirror
- */
- private void processTypeProperties(
- org.richfaces.cdk.model.Component component,
- TypeMirror interfaceMirror) {
- String name = interfaceMirror.toString();
- try{
- component.getAttributes().addAll(fragmentParser.parseProperties(CdkEntityResolver.URN_ATTRIBUTES+name+".xml"));
- } catch(CdkException e){
- // TODO - log errors ?
- }
- List<? extends TypeMirror> supertypes = processingEnv.getTypeUtils().directSupertypes(interfaceMirror);
- for (TypeMirror supertype : supertypes) {
- processTypeProperties(component, supertype);
- }
- }
+ for (AnnotationMirror mirror : mirrors) {
+ if (FACES_COMPONENT.equals(mirror.getAnnotationType().toString())) {
+ Map<? extends ExecutableElement, ? extends AnnotationValue> valuesWithDefaults =
+ processingEnv.getElementUtils().getElementValuesWithDefaults(mirror);
- public ComponentLibrary getLibrary() {
- return library;
- }
+ for (Entry<? extends ExecutableElement, ? extends AnnotationValue> valueEntry
+ : valuesWithDefaults.entrySet()) {
+ Name name = valueEntry.getKey().getSimpleName();
+ if ("value".equals(name.toString())) {
+ try {
+ Object value = valueEntry.getValue().getValue();
+
+ if (null != value && value instanceof String) {
+ org.richfaces.cdk.model.Component component =
+ library.findOrCreateComponent(value.toString());
+ ClassDescription componentClass =
+ new ClassDescription(element.getQualifiedName().toString());
+
+ component.setComponentClass(componentClass);
+ component.setGenerate(false);
+ setComponentProperties(element, component);
+ }
+ } catch (Exception e) {
+
+ // rise error and continue.
+ processingEnv.getMessager().printMessage(javax.tools.Diagnostic.Kind.ERROR,
+ e.getMessage(), element);
+
+ continue;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return true;
+ }
+
+ return false;
+ }
+
+ private void setComponentProperties(TypeElement componentElement, org.richfaces.cdk.model.Component component)
+ throws CdkException {
+
+ // Component family
+ setComponeneFamily(componentElement, component);
+ setComponentDescription(componentElement, component);
+ processFacets(componentElement, component);
+
+ // TODO - process Events attribute.
+ // TODO - process renderers ( @Renderer and @RendererTemplate attribute.
+ // TODO - process @Test annotations.
+ // Process attributes.
+ processAttributes(componentElement, component);
+ }
+
+ private void processFacets(TypeElement componentElement, org.richfaces.cdk.model.Component component) {
+ Set<BeanProperty> properties = getBeanPropertiesAnnotatedWith(Facet.class, componentElement);
+
+ // TODO - encapsulate attribute builder into utility class.
+ for (BeanProperty beanProperty : properties) {
+ org.richfaces.cdk.model.Facet facet = component.findOrCreateFacet(beanProperty.getName());
+
+ // Documentation
+ facet.setDescription(beanProperty.getDocComment());
+
+ Icon icon = beanProperty.getAnnotation(Icon.class);
+
+ if (null != icon) {
+ setIcon(facet, icon);
+ }
+
+ DisplayName displayName = beanProperty.getAnnotation(DisplayName.class);
+
+ if (null != displayName) {
+ facet.setDisplayname(displayName.value());
+ }
+
+ // Flags.
+ facet.setGenerate(beanProperty.isExists());
+ }
+
+ // @Facets annotation.
+ Facets facetsAnnotation = componentElement.getAnnotation(Facets.class);
+
+ if (null != facetsAnnotation) {
+ Facet[] facets = facetsAnnotation.value();
+
+ for (Facet facet : facets) {
+ if (!Strings.isEmpty(facet.value())) {
+ component.findOrCreateFacet(facet.value());
+ } else {
+
+ // TODO - record error.
+ }
+ }
+ }
+ }
+
+ private void setComponentDescription(TypeElement componentElement, org.richfaces.cdk.model.Component component) {
+
+ // JavaDoc comments
+ component.setDescription(this.processingEnv.getElementUtils().getDocComment(componentElement));
+
+ Icon icon = componentElement.getAnnotation(Icon.class);
+
+ if (null != icon) {
+ setIcon(component, icon);
+ }
+
+ DisplayName displayName = componentElement.getAnnotation(DisplayName.class);
+
+ if (null != displayName) {
+ component.setDisplayname(displayName.value());
+ }
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param component
+ * @param icon
+ */
+ private void setIcon(DescriptionGroup component, Icon icon) {
+ DescriptionGroup.Icon iconValue = new DescriptionGroup.Icon();
+
+ if (icon.small().length() > 0) {
+ iconValue.setSmallIcon(icon.small());
+ }
+
+ if (icon.large().length() > 0) {
+ iconValue.setLargeIcon(icon.large());
+ }
+
+ component.setIcon(iconValue);
+ }
+
+ private void setComponeneFamily(TypeElement componentElement, org.richfaces.cdk.model.Component component) {
+ Family family = componentElement.getAnnotation(Family.class);
+
+ if (null != family) {
+
+ // @Family annotation
+ component.setFamily(family.value());
+ } else {
+
+ // static final COMPONENT_FAMILY string constant.
+ List<VariableElement> fieldsIn =
+ ElementFilter.fieldsIn(this.processingEnv.getElementUtils().getAllMembers(componentElement));
+
+ for (VariableElement field : fieldsIn) {
+ Set<Modifier> modifiers = field.getModifiers();
+
+ if (modifiers.contains(Modifier.FINAL) && modifiers.contains(Modifier.STATIC)
+ && field.getSimpleName().equals("COMPONENT_FAMILY")) {
+ Object value = field.getConstantValue();
+
+ if (null != value) {
+ component.setFamily(value.toString());
+ }
+ }
+ }
+ }
+ }
+
+ private void setEvents(TypeElement componentElement, org.richfaces.cdk.model.Component component) {
+ Fires fires = componentElement.getAnnotation(Fires.class);
+
+ if (null != fires) {
+ try {
+ for (Class<? extends FacesEvent> eventClass : fires.value()) {
+ component.addEvent(eventClass.getName());
+ }
+ } catch (MirroredTypesException mirror) {
+ for (TypeMirror eventType : mirror.getTypeMirrors()) {
+ component.addEvent(eventType.toString());
+
+ // TODO - check does component already implement eventSource interface
+ }
+ }
+ }
+ }
+
+ private void setClassNames(TypeElement componentElement, org.richfaces.cdk.model.Component component) {
+ Generate generate = componentElement.getAnnotation(Generate.class);
+
+ // Set generated and base class names.
+ ClassDescription baseClass = new ClassDescription(componentElement.getQualifiedName().toString());
+
+ if (null != generate) {
+ component.setComponentClass(new ClassDescription(generate.value()));
+ component.setBaseClass(baseClass);
+ component.setGenerate(true);
+ } else if (componentElement.getModifiers().contains(Modifier.ABSTRACT)) {
+
+ // Final component class will be set by validator.
+ component.setBaseClass(baseClass);
+ component.setGenerate(true);
+ } else {
+ component.setComponentClass(baseClass);
+ component.setGenerate(false);
+ }
+ }
+
+ protected void processAttributes(TypeElement componentElement, org.richfaces.cdk.model.Component component)
+ throws CdkException {
+
+ Set<BeanProperty> properties = getBeanPropertiesAnnotatedWith(Attribute.class, componentElement);
+
+ // TODO - encapsulate attribute builder into utility class.
+ for (BeanProperty beanProperty : properties) {
+ Property attribute = component.findOrCreateAttribute(beanProperty.getName());
+
+ // Flags
+ Attribute attributeAnnotarion = beanProperty.getAnnotation(Attribute.class);
+
+ attribute.setHidden(attributeAnnotarion.hidden());
+ attribute.setLiteral(attributeAnnotarion.literal());
+ attribute.setPassThrough(attributeAnnotarion.passThough());
+ attribute.setRequired(attributeAnnotarion.required());
+ attribute.setReadOnly(attributeAnnotarion.readOnly());
+
+ // Documentation
+ attribute.setDescription(beanProperty.getDocComment());
+
+ Icon icon = beanProperty.getAnnotation(Icon.class);
+
+ if (null != icon) {
+ setIcon(attribute, icon);
+ }
+
+ DisplayName displayName = beanProperty.getAnnotation(DisplayName.class);
+
+ if (null != displayName) {
+ attribute.setDisplayname(displayName.value());
+ }
+
+ // type.
+ attribute.setType(new ClassDescription(beanProperty.getType().toString()));
+
+ // MethodExpression call signature.
+ Signature signature = beanProperty.getAnnotation(Signature.class);
+
+ if (null != signature) {
+ List<ClassDescription> parameters = Lists.newArrayList();
+
+ try {
+ for (Class<?> parameterType : signature.parameters()) {
+ parameters.add(new ClassDescription(parameterType.getName()));
+ }
+ } catch (MirroredTypesException e) {
+ for (TypeMirror parameterType : e.getTypeMirrors()) {
+ parameters.add(new ClassDescription(parameterType.toString()));
+ }
+ }
+
+ // signature parameters always should be replaced.
+ attribute.setSignature(parameters);
+
+ // TODO - set method return type.
+ }
+
+ // Behavior events.
+ EventName eventName = beanProperty.getAnnotation(EventName.class);
+
+ setBehaviorEvent(attribute, eventName);
+
+ EventNames eventNames = beanProperty.getAnnotation(EventNames.class);
+
+ if (null != eventNames) {
+ for (EventName eventNameInstance : eventNames.value()) {
+ setBehaviorEvent(attribute, eventNameInstance);
+ }
+ }
+
+ // DefaultValues
+ DefaultValue defaultValue = beanProperty.getAnnotation(DefaultValue.class);
+
+ if (null != defaultValue) {
+ attribute.setDefaultValue(defaultValue.value());
+ }
+
+ SuggestedValue suggestedValue = beanProperty.getAnnotation(SuggestedValue.class);
+
+ if (null != suggestedValue) {
+ attribute.setSuggestedValue(suggestedValue.value());
+ }
+
+ // Flags.
+ attribute.setGenerate(!beanProperty.isExists() || null != beanProperty.getAnnotation(Generate.class));
+ }
+
+ // Process XML files with standard attributes definitions.
+ Attributes attributes = componentElement.getAnnotation(Attributes.class);
+
+ if (null != attributes) {
+ String[] includes = attributes.value();
+
+ for (String attributesConfig : includes) {
+
+ // process additional properties.
+ component.getAttributes().addAll(fragmentParser.parseProperties(attributesConfig));
+ }
+ }
+
+ // Process standard information for parent classes
+ processTypeProperties(component, componentElement.getSuperclass());
+
+ // and interfaces.
+ List<? extends TypeMirror> interfaces = componentElement.getInterfaces();
+
+ for (TypeMirror interfaceMirror : interfaces) {
+ processTypeProperties(component, interfaceMirror);
+ }
+ }
+
+ private void setBehaviorEvent(Property attribute, EventName eventName) {
+ if (null != eventName) {
+ org.richfaces.cdk.model.EventName event = new org.richfaces.cdk.model.EventName();
+
+ event.setName(eventName.value());
+ event.setDefaultEvent(eventName.defaultEvent());
+ attribute.getEventNames().add(event);
+ }
+ }
+
+ /**
+ * <p class="changed_added_4_0">Reccursive method to find and process standard class or interface attributes.</p>
+ * @param component
+ * @param interfaceMirror
+ */
+ private void processTypeProperties(org.richfaces.cdk.model.Component component, TypeMirror interfaceMirror) {
+ String name = interfaceMirror.toString();
+
+ try {
+ component.getAttributes().addAll(fragmentParser.parseProperties(CdkEntityResolver.URN_ATTRIBUTES + name
+ + ".xml"));
+ } catch (CdkException e) {
+
+ // TODO - log errors ?
+ }
+
+ List<? extends TypeMirror> supertypes = processingEnv.getTypeUtils().directSupertypes(interfaceMirror);
+
+ for (TypeMirror supertype : supertypes) {
+ processTypeProperties(component, supertype);
+ }
+ }
+
+ public ComponentLibrary getLibrary() {
+ return library;
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/VirtualFileManager.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/VirtualFileManager.java 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/VirtualFileManager.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -21,543 +21,559 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.apt;
+import com.google.common.collect.BiMap;
+import com.google.common.collect.HashBiMap;
+import com.google.common.collect.Lists;
+
+import org.richfaces.cdk.Logger;
+import org.richfaces.cdk.LoggerFactory;
+
+import javax.tools.*;
+import javax.tools.JavaFileObject.Kind;
+
import java.io.File;
import java.io.FilenameFilter;
import java.io.IOException;
-import java.io.InputStream;
import java.io.Serializable;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.util.ArrayList;
+
import java.util.Collections;
-import java.util.Enumeration;
import java.util.Iterator;
import java.util.List;
-import java.util.Map;
import java.util.Set;
-import javax.tools.FileObject;
-import javax.tools.ForwardingJavaFileManager;
-import javax.tools.JavaFileManager;
-import javax.tools.JavaFileObject;
-import javax.tools.StandardJavaFileManager;
-import javax.tools.StandardLocation;
-import javax.tools.JavaFileObject.Kind;
-
-import org.richfaces.cdk.Logger;
-import org.richfaces.cdk.LoggerFactory;
-
-import com.google.common.collect.BiMap;
-import com.google.common.collect.HashBiMap;
-import com.google.common.collect.Lists;
-
/**
* <p class="changed_added_4_0">
* That class wraps {@link StandardJavaFileManager}
* </p>
- *
+ *
* @author asmirnov(a)exadel.com
- *
+ *
*/
-final class VirtualFileManager extends
- ForwardingJavaFileManager<JavaFileManager> {
+final class VirtualFileManager extends ForwardingJavaFileManager<JavaFileManager> {
+ private static final Logger LOG = LoggerFactory.getLogger();
- private static final Logger log = LoggerFactory.getLogger();
+// private final BiMap<FileObjectKey, FileObject> classPathFiles;
+// private final BiMap<FileObject, FileObjectKey> inversedClassPathFiles;
+ private final ClassLoader classPathLoader;
+ private final BiMap<FileObject, FileObjectKey> inversedSources;
+ private final BiMap<FileObjectKey, FileObject> sources;
- private final BiMap<FileObjectKey, FileObject> sources;
- private final BiMap<FileObject, FileObjectKey> inversedSources;
+ private File javaSourceDirectory;
+ private File outputDirectory;
-// private final BiMap<FileObjectKey, FileObject> classPathFiles;
-// private final BiMap<FileObject, FileObjectKey> inversedClassPathFiles;
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param fileManager
+ */
+ public VirtualFileManager(JavaFileManager fileManager, ClassLoader classPathLoader) {
+ super(fileManager);
+ this.classPathLoader = classPathLoader;
+ this.sources = HashBiMap.create(128);
+ inversedSources = this.sources.inverse();
- private final ClassLoader classPathLoader;
+// this.classPathFiles = HashBiMap.create(128);
+// inversedClassPathFiles = this.classPathFiles.inverse();
+ }
- private File outputDirectory;
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * javax.tools.ForwardingJavaFileManager#getJavaFileForInput(javax.tools
+ * .JavaFileManager.Location, java.lang.String,
+ * javax.tools.JavaFileObject.Kind)
+ */
+ @Override
+ public JavaFileObject getJavaFileForInput(Location location, String className, Kind kind) throws IOException {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("VirtualFileManager.getJavaFileForInput(" + String.valueOf(location) + "," + className + ","
+ + String.valueOf(kind) + ")");
+ }
- private File javaSourceDirectory;
+ FileObjectKey key = new FileObjectKey(className, kind);
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @param fileManager
- */
- public VirtualFileManager(JavaFileManager fileManager,
- ClassLoader classPathLoader) {
- super(fileManager);
- this.classPathLoader = classPathLoader;
- this.sources = HashBiMap.create(128);
- inversedSources = this.sources.inverse();
-// this.classPathFiles = HashBiMap.create(128);
-// inversedClassPathFiles = this.classPathFiles.inverse();
- }
+ if (StandardLocation.SOURCE_PATH.equals(location)) {
+ JavaFileObject fileObject = null;
- /*
- * (non-Javadoc)
- *
- * @see
- * javax.tools.ForwardingJavaFileManager#getJavaFileForInput(javax.tools
- * .JavaFileManager.Location, java.lang.String,
- * javax.tools.JavaFileObject.Kind)
- */
- @Override
- public JavaFileObject getJavaFileForInput(Location location,
- String className, Kind kind) throws IOException {
- if (log.isDebugEnabled()) {
- log.debug("VirtualFileManager.getJavaFileForInput("
- + String.valueOf(location) + "," + className + ","
- + String.valueOf(kind) + ")");
- }
- FileObjectKey key = new FileObjectKey(className, kind);
- if (StandardLocation.SOURCE_PATH.equals(location)) {
- JavaFileObject fileObject = null;
- fileObject = (JavaFileObject) sources.get(key);
- if (null == fileObject && null != javaSourceDirectory) {
- String fileName = className.replace('.', File.separatorChar)
- + kind.extension;
- File resource = new File(javaSourceDirectory, fileName);
- if (resource.exists()) {
- fileObject = new VirtualJavaFileSystemObject(resource, kind);
- sources.put(key, fileObject);
- }
- }
- return fileObject;
- }
- return super.getJavaFileForInput(location, className, kind);
- }
+ fileObject = (JavaFileObject) sources.get(key);
- @Override
- public ClassLoader getClassLoader(Location location) {
- if (log.isDebugEnabled()) {
- log.debug("VirtualFileManager.getClassLoader("
- + String.valueOf(location) + ")");
- }
- if (StandardLocation.CLASS_OUTPUT.equals(location)
- || StandardLocation.SOURCE_PATH.equals(location)
- || StandardLocation.SOURCE_OUTPUT.equals(location)) {
- return getClassPathLoader();
- } else {
- return super.getClassLoader(location);
- }
- }
+ if (null == fileObject && null != javaSourceDirectory) {
+ String fileName = className.replace('.', File.separatorChar) + kind.extension;
+ File resource = new File(javaSourceDirectory, fileName);
- /*
- * (non-Javadoc)
- *
- * @see
- * javax.tools.ForwardingJavaFileManager#getJavaFileForOutput(javax.tools
- * .JavaFileManager.Location, java.lang.String,
- * javax.tools.JavaFileObject.Kind, javax.tools.FileObject)
- */
- @Override
- public JavaFileObject getJavaFileForOutput(Location location,
- String className, Kind kind, FileObject sibling) throws IOException {
- if (log.isDebugEnabled()) {
- log.debug("VirtualFileManager.getJavaFileForOutput("
- + String.valueOf(location) + "," + className + ","
- + String.valueOf(kind) + "," + String.valueOf(sibling)
- + ")");
- }
- JavaFileObject fileForOutput = null;
- if (StandardLocation.CLASS_OUTPUT.equals(location)
- && null != getOutputDirectory()) {
- String fileName = className.replace('.', '/') + kind.extension;
- File outputFile = new File(getOutputDirectory(), fileName);
- fileForOutput = new VirtualJavaFileSystemObject(outputFile, kind);
- }
- return fileForOutput;
- }
+ if (resource.exists()) {
+ fileObject = new VirtualJavaFileSystemObject(resource, kind);
+ sources.put(key, fileObject);
+ }
+ }
- /*
- * (non-Javadoc)
- *
- * @see
- * javax.tools.ForwardingJavaFileManager#hasLocation(javax.tools.JavaFileManager
- * .Location)
- */
- @Override
- public boolean hasLocation(Location location) {
- boolean hasLocation;
- if (log.isDebugEnabled()) {
- log.debug("VirtualFileManager.hasLocation("
- + String.valueOf(location) + ")");
- }
- if (StandardLocation.SOURCE_PATH.equals(location)) {
- hasLocation = null != getJavaSourceDirectory()
- || !sources.isEmpty();
- } else if (StandardLocation.CLASS_OUTPUT.equals(location)) {
- hasLocation = null != getOutputDirectory();
- } else {
- hasLocation = super.hasLocation(location);
- }
- return hasLocation;
- }
+ return fileObject;
+ }
-
- @Override
- public Iterable<JavaFileObject> list(final Location location,
- final String packageName, final Set<Kind> kinds,
- final boolean recurse) throws IOException {
- if (log.isDebugEnabled()) {
- log.debug("VirtualFileManager.list(" + String.valueOf(location)
- + "," + packageName + "," + String.valueOf(kinds) + ","
- + String.valueOf(recurse) + ")");
- }
- Iterable<JavaFileObject> list;
- if (StandardLocation.SOURCE_PATH.equals(location)) {
- if (null != getJavaSourceDirectory()) {
- String fileName = packageName.replace('.', File.separatorChar);
- File packageDirectory = new File(getJavaSourceDirectory(),
- fileName);
- if (packageDirectory.exists()) {
- final List<JavaFileObject> fileslist = Lists.newArrayList();
- File[] files = packageDirectory
- .listFiles(new FilenameFilter() {
+ return super.getJavaFileForInput(location, className, kind);
+ }
- @Override
- public boolean accept(File dir, String name) {
- File child = new File(dir, name);
- if (child.isDirectory() && recurse) {
- // Recursive add directory content.
- try {
- Iterable<JavaFileObject> childList = list(
- location, packageName + '.'
- + name, kinds,
- recurse);
- for (JavaFileObject javaFileObject : childList) {
- fileslist.add(javaFileObject);
- }
- } catch (IOException e) {
- return false;
- }
- } else {
- for (Kind kind : kinds) {
- if (name.endsWith(kind.extension)) {
- return true;
- }
- }
- }
- return false;
- }
- });
- for (File file : files) {
- String name = file.getName();
- Kind kind = Kind.SOURCE;
- int indexOfPeriod = name.lastIndexOf('.');
- if (indexOfPeriod > 0) {
- name = name.substring(0, indexOfPeriod);
- String ext = name.substring(indexOfPeriod);
- for (Kind requestedKind : kinds) {
- if (ext.equals(requestedKind.extension)) {
- kind = requestedKind;
- }
- }
- }
- String className = packageName + '.' + name;
- FileObjectKey key = new FileObjectKey(className, kind);
- JavaFileObject javaFileObject = (JavaFileObject) sources
- .get(key);
- if (null == javaFileObject) {
- javaFileObject = new VirtualJavaFileSystemObject(
- file, kind);
- sources.put(key, javaFileObject);
- }
- fileslist.add(javaFileObject);
- }
- list = fileslist;
+ @Override
+ public ClassLoader getClassLoader(Location location) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("VirtualFileManager.getClassLoader(" + String.valueOf(location) + ")");
+ }
- } else {
- list = Collections.emptyList();
- }
- } else {
- list = Collections.emptyList();
- }
- } else {
- list = super.list(location, packageName, kinds, recurse);
- }
- return list;
- }
+ if (StandardLocation.CLASS_OUTPUT.equals(location) || StandardLocation.SOURCE_PATH.equals(location)
+ || StandardLocation.SOURCE_OUTPUT.equals(location)) {
+ return getClassPathLoader();
+ } else {
+ return super.getClassLoader(location);
+ }
+ }
- /*
- * (non-Javadoc)
- *
- * @see javax.tools.ForwardingJavaFileManager#close()
- */
- @Override
- public void close() throws IOException {
- if (log.isDebugEnabled()) {
- log.debug("VirtualFileManager.close()");
- }
- super.close();
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * javax.tools.ForwardingJavaFileManager#getJavaFileForOutput(javax.tools
+ * .JavaFileManager.Location, java.lang.String,
+ * javax.tools.JavaFileObject.Kind, javax.tools.FileObject)
+ */
+ @Override
+ public JavaFileObject getJavaFileForOutput(Location location, String className, Kind kind, FileObject sibling) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("VirtualFileManager.getJavaFileForOutput(" + String.valueOf(location) + "," + className + ","
+ + String.valueOf(kind) + "," + String.valueOf(sibling) + ")");
+ }
- /*
- * (non-Javadoc)
- *
- * @see javax.tools.ForwardingJavaFileManager#flush()
- */
- @Override
- public void flush() throws IOException {
- if (log.isDebugEnabled()) {
- log.debug("VirtualFileManager.flush()");
- }
- super.flush();
- }
+ JavaFileObject fileForOutput = null;
- /*
- * (non-Javadoc)
- *
- * @seejavax.tools.ForwardingJavaFileManager#getFileForInput(javax.tools.
- * JavaFileManager.Location, java.lang.String, java.lang.String)
- */
- @Override
- public FileObject getFileForInput(Location location, String packageName,
- String relativeName) throws IOException {
- if (log.isDebugEnabled()) {
- log.debug("VirtualFileManager.getFileForInput("
- + String.valueOf(location) + "," + packageName + ","
- + relativeName + ")");
- }
- if (StandardLocation.SOURCE_PATH.equals(location)) {
- String fileName = packageName.replace('.', File.separatorChar)
- + File.separator + relativeName;
- if (null != javaSourceDirectory) {
- File resource = new File(javaSourceDirectory, fileName);
- if (resource.exists()) {
- return new VirtualJavaFileSystemObject(resource, Kind.OTHER);
- }
- }
- return null;
- }
- return super.getFileForInput(location, packageName, relativeName);
- }
+ if (StandardLocation.CLASS_OUTPUT.equals(location) && null != getOutputDirectory()) {
+ String fileName = className.replace('.', '/') + kind.extension;
+ File outputFile = new File(getOutputDirectory(), fileName);
- /*
- * (non-Javadoc)
- *
- * @seejavax.tools.ForwardingJavaFileManager#getFileForOutput(javax.tools.
- * JavaFileManager.Location, java.lang.String, java.lang.String,
- * javax.tools.FileObject)
- */
- @Override
- public FileObject getFileForOutput(Location location, String packageName,
- String relativeName, FileObject sibling) throws IOException {
- if (log.isDebugEnabled()) {
- log.debug("VirtualFileManager.getFileForOutput("
- + String.valueOf(location) + "," + packageName + ","
- + relativeName + "," + String.valueOf(sibling) + ")");
- }
- return super.getFileForOutput(location, packageName, relativeName,
- sibling);
- }
+ fileForOutput = new VirtualJavaFileSystemObject(outputFile, kind);
+ }
- /*
- * (non-Javadoc)
- *
- * @see javax.tools.ForwardingJavaFileManager#handleOption(java.lang.String,
- * java.util.Iterator)
- */
- @Override
- public boolean handleOption(String current, Iterator<String> remaining) {
- if (log.isDebugEnabled()) {
- log.debug("VirtualFileManager.handleOption(" + current
- + ",remaining)");
- }
- return super.handleOption(current, remaining);
- }
+ return fileForOutput;
+ }
- /*
- * (non-Javadoc)
- *
- * @seejavax.tools.ForwardingJavaFileManager#inferBinaryName(javax.tools.
- * JavaFileManager.Location, javax.tools.JavaFileObject)
- */
- @Override
- public String inferBinaryName(Location location, JavaFileObject file) {
- if (log.isDebugEnabled()) {
- log.debug("VirtualFileManager.inferBinaryName("
- + String.valueOf(location) + "," + String.valueOf(file)
- + ")");
- }
- if (StandardLocation.SOURCE_PATH.equals(location)) {
- FileObjectKey fileObjectKey = inversedSources.get(file);
- if (null != fileObjectKey) {
- return fileObjectKey.getBinaryName();
- } else {
- return null;
- }
- } else {
- return super.inferBinaryName(location, file);
- }
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * javax.tools.ForwardingJavaFileManager#hasLocation(javax.tools.JavaFileManager
+ * .Location)
+ */
+ @Override
+ public boolean hasLocation(Location location) {
+ boolean hasLocation;
- /*
- * (non-Javadoc)
- *
- * @see
- * javax.tools.ForwardingJavaFileManager#isSameFile(javax.tools.FileObject,
- * javax.tools.FileObject)
- */
- @Override
- public boolean isSameFile(FileObject a, FileObject b) {
- if (log.isDebugEnabled()) {
- log.debug("VirtualFileManager.isSameFile(" + String.valueOf(a)
- + "," + String.valueOf(b) + ")");
- }
- if (a instanceof VirtualJavaFileObject) {
- return a.equals(b);
- }
- return super.isSameFile(a, b);
- }
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("VirtualFileManager.hasLocation(" + String.valueOf(location) + ")");
+ }
- /*
- * (non-Javadoc)
- *
- * @see
- * javax.tools.ForwardingJavaFileManager#isSupportedOption(java.lang.String)
- */
- @Override
- public int isSupportedOption(String option) {
- if (log.isDebugEnabled()) {
- log.debug("VirtualFileManager.isSupportedOption(" + option + ")");
- }
- return super.isSupportedOption(option);
- }
+ if (StandardLocation.SOURCE_PATH.equals(location)) {
+ hasLocation = null != getJavaSourceDirectory() || !sources.isEmpty();
+ } else if (StandardLocation.CLASS_OUTPUT.equals(location)) {
+ hasLocation = null != getOutputDirectory();
+ } else {
+ hasLocation = super.hasLocation(location);
+ }
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @return the classPathLoader
- */
- private ClassLoader getClassPathLoader() {
- return classPathLoader;
- }
+ return hasLocation;
+ }
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @return the outputDirectory
- */
- public File getOutputDirectory() {
- return outputDirectory;
- }
+ @Override
+ public Iterable<JavaFileObject> list(final Location location, final String packageName, final Set<Kind> kinds,
+ final boolean recurse) throws IOException {
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @param outputDirectory
- * the outputDirectory to set
- */
- public void setOutputDirectory(File outputDirectory) {
- this.outputDirectory = outputDirectory;
- }
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("VirtualFileManager.list(" + String.valueOf(location) + "," + packageName + ","
+ + String.valueOf(kinds) + "," + String.valueOf(recurse) + ")");
+ }
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @return the javaSourceDirectory
- */
- public File getJavaSourceDirectory() {
- return javaSourceDirectory;
- }
+ Iterable<JavaFileObject> list;
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @param javaSourceDirectory
- * the javaSourceDirectory to set
- */
- public void setJavaSourceDirectory(File javaSourceDirectory) {
- this.javaSourceDirectory = javaSourceDirectory;
- }
+ if (StandardLocation.SOURCE_PATH.equals(location)) {
+ if (null != getJavaSourceDirectory()) {
+ String fileName = packageName.replace('.', File.separatorChar);
+ File packageDirectory = new File(getJavaSourceDirectory(), fileName);
- @SuppressWarnings("serial")
- private static class FileObjectKey implements Serializable {
- private final String binaryName;
- private final Kind kind;
+ if (packageDirectory.exists()) {
+ final List<JavaFileObject> fileslist = Lists.newArrayList();
+ File[] files = packageDirectory.listFiles(new FilenameFilter() {
+ @Override
+ public boolean accept(File dir, String name) {
+ File child = new File(dir, name);
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @param binaryName
- * @param kind
- */
- public FileObjectKey(String binaryName, Kind kind) {
- super();
- this.binaryName = binaryName;
- this.kind = kind;
- }
+ if (child.isDirectory() && recurse) {
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @return the binaryName
- */
- public String getBinaryName() {
- return binaryName;
- }
+ // Recursive add directory content.
+ try {
+ Iterable<JavaFileObject> childList = list(location, packageName + '.' + name,
+ kinds, recurse);
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @return the kind
- */
- public Kind getKind() {
- return kind;
- }
+ for (JavaFileObject javaFileObject : childList) {
+ fileslist.add(javaFileObject);
+ }
+ } catch (IOException e) {
+ return false;
+ }
+ } else {
+ for (Kind kind : kinds) {
+ if (name.endsWith(kind.extension)) {
+ return true;
+ }
+ }
+ }
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#hashCode()
- */
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result
- + ((binaryName == null) ? 0 : binaryName.hashCode());
- result = prime * result + ((kind == null) ? 0 : kind.hashCode());
- return result;
- }
+ return false;
+ }
+ });
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#equals(java.lang.Object)
- */
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- FileObjectKey other = (FileObjectKey) obj;
- if (binaryName == null) {
- if (other.binaryName != null)
- return false;
- } else if (!binaryName.equals(other.binaryName))
- return false;
- if (kind == null) {
- if (other.kind != null)
- return false;
- } else if (!kind.equals(other.kind))
- return false;
- return true;
- }
- }
+ for (File file : files) {
+ String name = file.getName();
+ Kind kind = Kind.SOURCE;
+ int indexOfPeriod = name.lastIndexOf('.');
-}
\ No newline at end of file
+ if (indexOfPeriod > 0) {
+ name = name.substring(0, indexOfPeriod);
+
+ String ext = name.substring(indexOfPeriod);
+
+ for (Kind requestedKind : kinds) {
+ if (ext.equals(requestedKind.extension)) {
+ kind = requestedKind;
+ }
+ }
+ }
+
+ String className = packageName + '.' + name;
+ FileObjectKey key = new FileObjectKey(className, kind);
+ JavaFileObject javaFileObject = (JavaFileObject) sources.get(key);
+
+ if (null == javaFileObject) {
+ javaFileObject = new VirtualJavaFileSystemObject(file, kind);
+ sources.put(key, javaFileObject);
+ }
+
+ fileslist.add(javaFileObject);
+ }
+
+ list = fileslist;
+ } else {
+ list = Collections.emptyList();
+ }
+ } else {
+ list = Collections.emptyList();
+ }
+ } else {
+ list = super.list(location, packageName, kinds, recurse);
+ }
+
+ return list;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.tools.ForwardingJavaFileManager#close()
+ */
+ @Override
+ public void close() throws IOException {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("VirtualFileManager.close()");
+ }
+
+ super.close();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.tools.ForwardingJavaFileManager#flush()
+ */
+ @Override
+ public void flush() throws IOException {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("VirtualFileManager.flush()");
+ }
+
+ super.flush();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @seejavax.tools.ForwardingJavaFileManager#getFileForInput(javax.tools.
+ * JavaFileManager.Location, java.lang.String, java.lang.String)
+ */
+ @Override
+ public FileObject getFileForInput(Location location, String packageName, String relativeName) throws IOException {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("VirtualFileManager.getFileForInput(" + String.valueOf(location) + "," + packageName + ","
+ + relativeName + ")");
+ }
+
+ if (StandardLocation.SOURCE_PATH.equals(location)) {
+ String fileName = packageName.replace('.', File.separatorChar) + File.separator + relativeName;
+
+ if (null != javaSourceDirectory) {
+ File resource = new File(javaSourceDirectory, fileName);
+
+ if (resource.exists()) {
+ return new VirtualJavaFileSystemObject(resource, Kind.OTHER);
+ }
+ }
+
+ return null;
+ }
+
+ return super.getFileForInput(location, packageName, relativeName);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @seejavax.tools.ForwardingJavaFileManager#getFileForOutput(javax.tools.
+ * JavaFileManager.Location, java.lang.String, java.lang.String,
+ * javax.tools.FileObject)
+ */
+ @Override
+ public FileObject getFileForOutput(Location location, String packageName, String relativeName, FileObject sibling)
+ throws IOException {
+
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("VirtualFileManager.getFileForOutput(" + String.valueOf(location) + "," + packageName + ","
+ + relativeName + "," + String.valueOf(sibling) + ")");
+ }
+
+ return super.getFileForOutput(location, packageName, relativeName, sibling);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.tools.ForwardingJavaFileManager#handleOption(java.lang.String,
+ * java.util.Iterator)
+ */
+ @Override
+ public boolean handleOption(String current, Iterator<String> remaining) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("VirtualFileManager.handleOption(" + current + ",remaining)");
+ }
+
+ return super.handleOption(current, remaining);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @seejavax.tools.ForwardingJavaFileManager#inferBinaryName(javax.tools.
+ * JavaFileManager.Location, javax.tools.JavaFileObject)
+ */
+ @Override
+ public String inferBinaryName(Location location, JavaFileObject file) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("VirtualFileManager.inferBinaryName(" + String.valueOf(location) + "," + String.valueOf(file)
+ + ")");
+ }
+
+ if (StandardLocation.SOURCE_PATH.equals(location)) {
+ FileObjectKey fileObjectKey = inversedSources.get(file);
+
+ if (null != fileObjectKey) {
+ return fileObjectKey.getBinaryName();
+ } else {
+ return null;
+ }
+ } else {
+ return super.inferBinaryName(location, file);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * javax.tools.ForwardingJavaFileManager#isSameFile(javax.tools.FileObject,
+ * javax.tools.FileObject)
+ */
+ @Override
+ public boolean isSameFile(FileObject a, FileObject b) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("VirtualFileManager.isSameFile(" + String.valueOf(a) + "," + String.valueOf(b) + ")");
+ }
+
+ if (a instanceof VirtualJavaFileObject) {
+ return a.equals(b);
+ }
+
+ return super.isSameFile(a, b);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * javax.tools.ForwardingJavaFileManager#isSupportedOption(java.lang.String)
+ */
+ @Override
+ public int isSupportedOption(String option) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("VirtualFileManager.isSupportedOption(" + option + ")");
+ }
+
+ return super.isSupportedOption(option);
+ }
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @return the classPathLoader
+ */
+ private ClassLoader getClassPathLoader() {
+ return classPathLoader;
+ }
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @return the outputDirectory
+ */
+ public File getOutputDirectory() {
+ return outputDirectory;
+ }
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param outputDirectory
+ * the outputDirectory to set
+ */
+ public void setOutputDirectory(File outputDirectory) {
+ this.outputDirectory = outputDirectory;
+ }
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @return the javaSourceDirectory
+ */
+ public File getJavaSourceDirectory() {
+ return javaSourceDirectory;
+ }
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param javaSourceDirectory
+ * the javaSourceDirectory to set
+ */
+ public void setJavaSourceDirectory(File javaSourceDirectory) {
+ this.javaSourceDirectory = javaSourceDirectory;
+ }
+
+ @SuppressWarnings("serial")
+ private static class FileObjectKey implements Serializable {
+ private final String binaryName;
+ private final Kind kind;
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param binaryName
+ * @param kind
+ */
+ public FileObjectKey(String binaryName, Kind kind) {
+ super();
+ this.binaryName = binaryName;
+ this.kind = kind;
+ }
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @return the binaryName
+ */
+ public String getBinaryName() {
+ return binaryName;
+ }
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @return the kind
+ */
+ public Kind getKind() {
+ return kind;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+
+ result = prime * result + ((binaryName == null) ? 0 : binaryName.hashCode());
+ result = prime * result + ((kind == null) ? 0 : kind.hashCode());
+
+ return result;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+
+ if (obj == null) {
+ return false;
+ }
+
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+
+ FileObjectKey other = (FileObjectKey) obj;
+
+ if (binaryName == null) {
+ if (other.binaryName != null) {
+ return false;
+ }
+ } else if (!binaryName.equals(other.binaryName)) {
+ return false;
+ }
+
+ if (kind == null) {
+ if (other.kind != null) {
+ return false;
+ }
+ } else if (!kind.equals(other.kind)) {
+ return false;
+ }
+
+ return true;
+ }
+ }
+}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/VirtualJavaClassPathObject.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/VirtualJavaClassPathObject.java 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/VirtualJavaClassPathObject.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -21,114 +21,113 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.apt;
-import java.io.File;
-import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
+
import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLConnection;
-import java.nio.ByteBuffer;
-import java.nio.channels.Channels;
-import java.nio.channels.ReadableByteChannel;
-import java.nio.charset.Charset;
-import javax.tools.JavaFileObject;
-import javax.tools.SimpleJavaFileObject;
-
/**
- * <p class="changed_added_4_0">This class represents read-only {@link JavaFileObject} created from {@link File} or {@link URL}</p>
+ * <p class="changed_added_4_0">This class represents read-only {@link javax.tools.JavaFileObject} created
+ * from {@link java.io.File} or {@link URL}</p>
+ *
* @author asmirnov(a)exadel.com
*
*/
public class VirtualJavaClassPathObject extends VirtualJavaFileObject {
+ private final URL url;
+ /**
+ * <p class="changed_added_4_0">Create file object from URL</p>
+ * @param url
+ * @param kind
+ * @throws URISyntaxException
+ */
+ public VirtualJavaClassPathObject(URL url, Kind kind) throws URISyntaxException {
+ super(url.toURI(), kind);
+ this.url = url;
+ }
- private final URL url;
+ /*
+ * (non-Javadoc)
+ * @see javax.tools.SimpleJavaFileObject#openInputStream()
+ */
+ @Override
+ public InputStream openInputStream() throws IOException {
+ return url.openStream();
+ }
+ /*
+ * (non-Javadoc)
+ * @see javax.tools.SimpleJavaFileObject#getLastModified()
+ */
+ @Override
+ public long getLastModified() {
+ try {
+ URLConnection connection = url.openConnection();
- /**
- * <p class="changed_added_4_0">Create file object from URL</p>
- * @param url
- * @param kind
- * @throws URISyntaxException
- */
- public VirtualJavaClassPathObject(URL url, Kind kind) throws URISyntaxException {
- super(url.toURI(),kind);
- this.url = url;
- }
-
- /* (non-Javadoc)
- * @see javax.tools.SimpleJavaFileObject#openInputStream()
- */
- @Override
- public InputStream openInputStream() throws IOException {
- return url.openStream();
- }
+ return connection.getLastModified();
+ } catch (IOException e) {
+ return super.getLastModified();
+ }
+ }
+ /*
+ * (non-Javadoc)
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
- /* (non-Javadoc)
- * @see javax.tools.SimpleJavaFileObject#getLastModified()
- */
- @Override
- public long getLastModified() {
- try {
- URLConnection connection = url.openConnection();
- return connection.getLastModified();
- } catch (IOException e) {
- return super.getLastModified();
- }
- }
-
-
+ result = prime * result + ((url == null) ? 0 : url.hashCode());
+ result = prime * result + ((getKind() == null) ? 0 : getKind().hashCode());
- /* (non-Javadoc)
- * @see java.lang.Object#hashCode()
- */
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((url == null) ? 0 : url.hashCode());
- result = prime * result + ((getKind() == null) ? 0 : getKind().hashCode());
- return result;
- }
+ return result;
+ }
- /* (non-Javadoc)
- * @see java.lang.Object#equals(java.lang.Object)
- */
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (!(obj instanceof VirtualJavaClassPathObject)) {
- return false;
- }
- VirtualJavaClassPathObject other = (VirtualJavaClassPathObject) obj;
- if (url == null) {
- if (other.uri != null) {
- return false;
- }
- } else if (!url.equals(other.uri)) {
- return false;
- }
- if(getKind() == null){
- if(other.getKind()!=null){
- return false;
- }
- } else if (!getKind().equals(other.getKind())) {
- return false;
- }
- return true;
- }
-
-
-}
\ No newline at end of file
+ /*
+ * (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+
+ if (obj == null) {
+ return false;
+ }
+
+ if (!(obj instanceof VirtualJavaClassPathObject)) {
+ return false;
+ }
+
+ VirtualJavaClassPathObject other = (VirtualJavaClassPathObject) obj;
+
+ if (url == null) {
+ if (other.uri != null) {
+ return false;
+ }
+ } else if (!url.equals(other.uri)) {
+ return false;
+ }
+
+ if (getKind() == null) {
+ if (other.getKind() != null) {
+ return false;
+ }
+ } else if (!getKind().equals(other.getKind())) {
+ return false;
+ }
+
+ return true;
+ }
+}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/VirtualJavaFileObject.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/VirtualJavaFileObject.java 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/VirtualJavaFileObject.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -21,100 +21,93 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.apt;
-import java.io.File;
-import java.io.FileInputStream;
+import javax.tools.SimpleJavaFileObject;
+
import java.io.IOException;
import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
+
import java.net.URI;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.net.URLConnection;
+
import java.nio.ByteBuffer;
import java.nio.channels.Channels;
import java.nio.channels.ReadableByteChannel;
import java.nio.charset.Charset;
-import javax.tools.JavaFileObject;
-import javax.tools.SimpleJavaFileObject;
-
/**
- * <p class="changed_added_4_0">This class represents read-only {@link JavaFileObject} created from {@link File} or {@link URL}</p>
+ * <p class="changed_added_4_0">This class represents read-only {@link javax.tools.JavaFileObject} created
+ * from {@link java.io.File} or {@link java.net.URL}</p>
+ *
* @author asmirnov(a)exadel.com
*
*/
public class VirtualJavaFileObject extends SimpleJavaFileObject {
- /**
- * <p class="changed_added_4_0">base file object. One of {@link file} or {@link url} fields should be set</p>
- */
+ /**
+ * <p class="changed_added_4_0">base file object. One of {@link file} or {@link url} fields should be set</p>
+ */
+ private Charset charset = Charset.defaultCharset();
- private Charset charset = Charset.defaultCharset();
-
- /**
- * <p class="changed_added_4_0">Cached content</p>
- */
- private CharSequence content;
+ /**
+ * <p class="changed_added_4_0">Cached content</p>
+ */
+ private CharSequence content;
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param classFile
+ * @param kind
+ */
+ protected VirtualJavaFileObject(URI classFile, Kind kind) {
+ super(classFile, kind);
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param classFile
- * @param kind
- */
- protected VirtualJavaFileObject(URI classFile, Kind kind) {
- super(classFile, kind);
- }
+ /*
+ * (non-Javadoc)
+ * @see javax.tools.SimpleJavaFileObject#getCharContent(boolean)
+ */
+ @Override
+ public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException {
+ if (null == content) {
+ StringBuilder builder = new StringBuilder((int) (4096f * getCharset().newDecoder().averageCharsPerByte()));
+ InputStream inputStream = openInputStream();
+ if (null != inputStream) {
+ ReadableByteChannel channel = Channels.newChannel(inputStream);
-
+ for (ByteBuffer buff = ByteBuffer.allocate(4096); channel.read(buff) >= 0; buff.clear()) {
+ buff.flip();
+ builder.append(getCharset().decode(buff));
+ }
- /* (non-Javadoc)
- * @see javax.tools.SimpleJavaFileObject#getCharContent(boolean)
- */
- @Override
- public CharSequence getCharContent(boolean ignoreEncodingErrors)
- throws IOException {
- if (null == content) {
- StringBuilder builder = new StringBuilder((int) (4096f * getCharset().newDecoder()
- .averageCharsPerByte()));
- InputStream inputStream = openInputStream();
- if (null != inputStream) {
- ReadableByteChannel channel = Channels.newChannel(inputStream);
- for (ByteBuffer buff = ByteBuffer.allocate(4096); channel
- .read(buff) >= 0; buff.clear()) {
- buff.flip();
- builder.append(getCharset().decode(buff));
- }
- channel.close();
- inputStream.close();
- content = builder.toString();
- }
- }
- return content;
- }
+ channel.close();
+ inputStream.close();
+ content = builder.toString();
+ }
+ }
+ return content;
+ }
-
-
- /**
- * <p class="changed_added_4_0">Set {@link Charset} for read operations</p>
- * @param charset the charset to set
- */
- public void setCharset(Charset charset) {
- this.charset = charset;
- // Reset cached content
- this.content = null;
- }
+ /**
+ * <p class="changed_added_4_0">Set {@link Charset} for read operations</p>
+ * @param charset the charset to set
+ */
+ public void setCharset(Charset charset) {
+ this.charset = charset;
- /**
- * <p class="changed_added_4_0"></p>
- * @return the charset
- */
- public Charset getCharset() {
- return charset;
- }
-}
\ No newline at end of file
+ // Reset cached content
+ this.content = null;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the charset
+ */
+ public Charset getCharset() {
+ return charset;
+ }
+}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/VirtualJavaFileSystemObject.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/VirtualJavaFileSystemObject.java 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/VirtualJavaFileSystemObject.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -21,117 +21,111 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.apt;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.net.URLConnection;
-import java.nio.ByteBuffer;
-import java.nio.channels.Channels;
-import java.nio.channels.ReadableByteChannel;
-import java.nio.charset.Charset;
-import javax.tools.JavaFileObject;
-import javax.tools.SimpleJavaFileObject;
-
/**
- * <p class="changed_added_4_0">This class represents read-only {@link JavaFileObject} created from {@link File} or {@link URL}</p>
+ * <p class="changed_added_4_0">This class represents read-only {@link javax.tools.JavaFileObject} created from
+ * {@link File} or {@link java.net.URL}</p>
+ *
* @author asmirnov(a)exadel.com
*
*/
public class VirtualJavaFileSystemObject extends VirtualJavaFileObject {
- /**
- * <p class="changed_added_4_0">base file object. One of {@link file} or {@link url} fields should be set</p>
- */
- private final File classFile;
+ /**
+ * <p class="changed_added_4_0">base file object. One of {@link file} or {@link url} fields should be set</p>
+ */
+ private final File classFile;
-
+ /**
+ * <p class="changed_added_4_0">Create source from {@link File}</p>
+ * @param classFile
+ */
+ public VirtualJavaFileSystemObject(File classFile) {
+ this(classFile, Kind.SOURCE);
+ }
- /**
- * <p class="changed_added_4_0">Create source from {@link File}</p>
- * @param classFile
- */
- public VirtualJavaFileSystemObject(File classFile) {
- this(classFile, Kind.SOURCE);
- }
+ public VirtualJavaFileSystemObject(File classFile, Kind kind) {
+ super(classFile.toURI(), kind);
+ this.classFile = classFile;
+ }
- public VirtualJavaFileSystemObject(File classFile, Kind kind) {
- super(classFile.toURI(), kind);
- this.classFile = classFile;
- }
+ /*
+ * (non-Javadoc)
+ * @see javax.tools.SimpleJavaFileObject#openInputStream()
+ */
+ @Override
+ public InputStream openInputStream() throws IOException {
+ return new FileInputStream(classFile);
+ }
+ /*
+ * (non-Javadoc)
+ * @see javax.tools.SimpleJavaFileObject#getLastModified()
+ */
+ @Override
+ public long getLastModified() {
+ return classFile.lastModified();
+ }
-
- /* (non-Javadoc)
- * @see javax.tools.SimpleJavaFileObject#openInputStream()
- */
- @Override
- public InputStream openInputStream() throws IOException {
- return new FileInputStream(classFile);
- }
+ /*
+ * (non-Javadoc)
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((classFile == null) ? 0 : classFile.hashCode());
+ result = prime * result + ((getKind() == null) ? 0 : getKind().hashCode());
- /* (non-Javadoc)
- * @see javax.tools.SimpleJavaFileObject#getLastModified()
- */
- @Override
- public long getLastModified() {
- return classFile.lastModified();
- }
-
-
+ return result;
+ }
- /* (non-Javadoc)
- * @see java.lang.Object#hashCode()
- */
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result
- + ((classFile == null) ? 0 : classFile.hashCode());
- result = prime * result + ((getKind() == null) ? 0 : getKind().hashCode());
- return result;
- }
+ /*
+ * (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
- /* (non-Javadoc)
- * @see java.lang.Object#equals(java.lang.Object)
- */
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (!(obj instanceof VirtualJavaFileSystemObject)) {
- return false;
- }
- VirtualJavaFileSystemObject other = (VirtualJavaFileSystemObject) obj;
- if (classFile == null) {
- if (other.classFile != null) {
- return false;
- }
- } else if (!classFile.equals(other.classFile)) {
- return false;
- }
- if(getKind() == null){
- if(other.getKind()!=null){
- return false;
- }
- } else if (!getKind().equals(other.getKind())) {
- return false;
- }
- return true;
- }
-
-
-}
\ No newline at end of file
+ if (obj == null) {
+ return false;
+ }
+
+ if (!(obj instanceof VirtualJavaFileSystemObject)) {
+ return false;
+ }
+
+ VirtualJavaFileSystemObject other = (VirtualJavaFileSystemObject) obj;
+
+ if (classFile == null) {
+ if (other.classFile != null) {
+ return false;
+ }
+ } else if (!classFile.equals(other.classFile)) {
+ return false;
+ }
+
+ if (getKind() == null) {
+ if (other.getKind() != null) {
+ return false;
+ }
+ } else if (!getKind().equals(other.getKind())) {
+ return false;
+ }
+
+ return true;
+ }
+}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/CdkConfiguration.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/CdkConfiguration.java 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/CdkConfiguration.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.freemarker;
import org.richfaces.cdk.CdkContext;
@@ -36,39 +38,39 @@
*
*/
public class CdkConfiguration extends Configuration {
-
- private static final String TEMPLATES = "/META-INF/templates";
- private final CdkContext context;
+ private static final String TEMPLATES = "/META-INF/templates";
+ private final CdkContext context;
- /**
- * <p class="changed_added_4_0"></p>
- * @return the context
- */
- protected CdkContext getContext() {
- return context;
- }
+ public CdkConfiguration(CdkContext context) {
+ super();
+ this.context = context;
- public CdkConfiguration(CdkContext context) {
- super();
- this.context = context;
- // TODO set proper template loader.
- setClassForTemplateLoading(context.getClass(), TEMPLATES);
- // TODO create an object wrapper for library model.
- setObjectWrapper(new LibraryModelWrapper());
- // Add context variables
- this.setSharedVariable("context", new TemplateHashModel() {
+ // TODO set proper template loader.
+ setClassForTemplateLoading(context.getClass(), TEMPLATES);
- @Override
- public TemplateModel get(String key) throws TemplateModelException {
- // TODO - define context parameters that could be exposed to template.
- return null;
- }
+ // TODO create an object wrapper for library model.
+ setObjectWrapper(new LibraryModelWrapper());
- @Override
- public boolean isEmpty() throws TemplateModelException {
- return false;
- }
- });
- }
+ // Add context variables
+ this.setSharedVariable("context", new TemplateHashModel() {
+ @Override
+ public TemplateModel get(String key) throws TemplateModelException {
+ // TODO - define context parameters that could be exposed to template.
+ return null;
+ }
+ @Override
+ public boolean isEmpty() throws TemplateModelException {
+ return false;
+ }
+ });
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the context
+ */
+ protected CdkContext getContext() {
+ return context;
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/ComponentTemplateModel.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/ComponentTemplateModel.java 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/ComponentTemplateModel.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.freemarker;
import java.util.NoSuchElementException;
@@ -37,83 +39,87 @@
import freemarker.ext.beans.BeanModel;
import freemarker.ext.beans.BeansWrapper;
+
import freemarker.template.TemplateModel;
import freemarker.template.TemplateModelException;
/**
* <p class="changed_added_4_0">
* </p>
- *
+ *
* @author asmirnov(a)exadel.com
- *
+ *
*/
public class ComponentTemplateModel extends BeanModel implements TemplateModel {
+ private final Component component;
+ private Set<EventName> eventNames;
- private final Component component;
- private Set<EventName> eventNames;
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param object
+ * @param wrapper
+ */
+ public ComponentTemplateModel(Component object, BeansWrapper wrapper) {
+ super(object, wrapper);
+ component = object;
+ }
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @param object
- * @param wrapper
- */
- public ComponentTemplateModel(Component object, BeansWrapper wrapper) {
- super(object, wrapper);
- component = object;
- }
+ @Override
+ public TemplateModel get(String key) throws TemplateModelException {
+ if ("generatedAttributes".equals(key)) {
+ return generatedAttributes();
+ } else if ("eventNames".equals(key)) {
+ return eventNames();
+ } else if ("defaultEvent".equals(key)) {
+ return defaultEvent();
+ }
- @Override
- public TemplateModel get(String key) throws TemplateModelException {
- if ("generatedAttributes".equals(key)) {
- return generatedAttributes();
- } else if ("eventNames".equals(key)) {
- return eventNames();
- } else if ("defaultEvent".equals(key)) {
- return defaultEvent();
- }
- return super.get(key);
- }
+ return super.get(key);
+ }
- private TemplateModel eventNames() throws TemplateModelException {
- Set<EventName> eventNames = getEventNames();
- return wrapper.wrap(eventNames);
- }
+ private TemplateModel eventNames() throws TemplateModelException {
+ Set<EventName> eventNames = getEventNames();
- private TemplateModel defaultEvent() throws TemplateModelException {
- Set<EventName> names = getEventNames();
- try{
- EventName defaultEvent = Iterables.find(names, new Predicate<EventName>() {
+ return wrapper.wrap(eventNames);
+ }
- @Override
- public boolean apply(EventName event) {
- return event.isDefaultEvent();
- }
- });
- return wrapper.wrap(defaultEvent);
- } catch(NoSuchElementException e){
- return wrapper.wrap(null);
- }
- }
- private Set<EventName> getEventNames() {
- if (null == eventNames) {
- eventNames = Sets.newHashSet();
- for (Property property : component.getAttributes()) {
- eventNames.addAll(property.getEventNames());
- }
- }
- return eventNames;
- }
+ private TemplateModel defaultEvent() throws TemplateModelException {
+ Set<EventName> names = getEventNames();
- private TemplateModel generatedAttributes() throws TemplateModelException {
- return wrapper.wrap(Collections2.filter(component.getAttributes(),
- new Predicate<Property>() {
+ try {
+ EventName defaultEvent = Iterables.find(names, new Predicate<EventName>() {
+ @Override
+ public boolean apply(EventName event) {
+ return event.isDefaultEvent();
+ }
+ });
- @Override
- public boolean apply(Property input) {
- return input.isGenerate();
- }
- }));
- }
+ return wrapper.wrap(defaultEvent);
+ } catch (NoSuchElementException e) {
+ return wrapper.wrap(null);
+ }
+ }
+
+ private Set<EventName> getEventNames() {
+ if (null == eventNames) {
+ eventNames = Sets.newHashSet();
+
+ for (Property property : component.getAttributes()) {
+ eventNames.addAll(property.getEventNames());
+ }
+ }
+
+ return eventNames;
+ }
+
+ private TemplateModel generatedAttributes() throws TemplateModelException {
+ return wrapper.wrap(Collections2.filter(component.getAttributes(), new Predicate<Property>() {
+ @Override
+ public boolean apply(Property input) {
+ return input.isGenerate();
+ }
+ }));
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/FreeMarkerRenderer.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/FreeMarkerRenderer.java 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/FreeMarkerRenderer.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.freemarker;
import java.io.File;
@@ -33,7 +35,6 @@
import org.richfaces.cdk.CdkWriter;
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.LibraryVisitor;
-import org.richfaces.cdk.model.Searchable;
import org.richfaces.cdk.model.Trackable;
import org.richfaces.cdk.model.Visitable;
@@ -46,83 +47,91 @@
* @author asmirnov(a)exadel.com
*
*/
-public abstract class FreeMarkerRenderer<C extends Visitable,P> implements CdkWriter,LibraryVisitor<Boolean, P> {
+public abstract class FreeMarkerRenderer<C extends Visitable, P> implements CdkWriter, LibraryVisitor<Boolean, P> {
+ private Configuration configuration;
+ private CdkContext context;
+ private Template template;
- private CdkContext context;
- private Configuration configuration;
- private Template template;
+ @Override
+ public void init(CdkContext context) throws CdkException {
+ this.context = context;
+ this.configuration = new CdkConfiguration(context);
- @Override
- public void init(CdkContext context) throws CdkException {
- this.context = context;
- this.configuration = new CdkConfiguration(context);
- try {
- template = configuration.getTemplate(getTemplateName());
- } catch (IOException e) {
- throw new CdkException(e);
- }
- }
+ try {
+ template = configuration.getTemplate(getTemplateName());
+ } catch (IOException e) {
+ throw new CdkException(e);
+ }
+ }
- @Override
- public void render(ComponentLibrary library) throws CdkException {
- library.accept(this, getVisitorParameter());
- }
+ @Override
+ public void render(ComponentLibrary library) throws CdkException {
+ library.accept(this, getVisitorParameter());
+ }
- private P getVisitorParameter() {
- return null;
- }
+ private P getVisitorParameter() {
+ return null;
+ }
- @Override
- public Boolean visit(Visitable c, P param) throws CdkException {
- if(isMyComponent(c)){
- return processComponent((C)c, param);
- }
- return null;
- }
+ @Override
+ public Boolean visit(Visitable c, P param) throws CdkException {
+ if (isMyComponent(c)) {
+ return processComponent((C) c, param);
+ }
- protected boolean processComponent(C c, P param) throws CdkException {
- try {
- Writer out = getOutput(c);
- template.process(c, out);
- out.close();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (TemplateException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } finally {
- }
- return false;
- }
+ return null;
+ }
- protected Writer getOutput(C c) throws CdkException {
- long lastModified = Long.MIN_VALUE;
- if (c instanceof Trackable) {
- Trackable trackuble = (Trackable) c;
- lastModified = trackuble.lastModified();
- }
- File sourceOutput = getContext().createOutputFile(getOutputType(), getOutputFile(c), lastModified);
- try {
- return new FileWriter(sourceOutput);
- } catch (IOException e) {
- throw new CdkException(e);
- }
- }
+ protected boolean processComponent(C c, P param) throws CdkException {
+ try {
+ Writer out = getOutput(c);
- protected abstract String getOutputFile(C c) throws CdkException;
+ template.process(c, out);
+ out.close();
+ } catch (IOException e) {
- protected abstract boolean isMyComponent(Visitable c);
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (TemplateException e) {
- protected abstract String getTemplateName();
-
- protected abstract OutputType getOutputType();
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the context
- */
- protected CdkContext getContext() {
- return context;
- }
+ return false;
+ }
+
+ protected Writer getOutput(C c) throws CdkException {
+ long lastModified = Long.MIN_VALUE;
+
+ if (c instanceof Trackable) {
+ Trackable trackuble = (Trackable) c;
+
+ lastModified = trackuble.lastModified();
+ }
+
+ File sourceOutput = getContext().createOutputFile(getOutputType(), getOutputFile(c), lastModified);
+
+ try {
+ return new FileWriter(sourceOutput);
+ } catch (IOException e) {
+ throw new CdkException(e);
+ }
+ }
+
+ protected abstract String getOutputFile(C c) throws CdkException;
+
+ protected abstract boolean isMyComponent(Visitable c);
+
+ protected abstract String getTemplateName();
+
+ protected abstract OutputType getOutputType();
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the context
+ */
+ protected CdkContext getContext() {
+ return context;
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/LibraryModelWrapper.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/LibraryModelWrapper.java 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/LibraryModelWrapper.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -21,45 +21,48 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.freemarker;
-import org.richfaces.cdk.model.Component;
-import org.richfaces.cdk.model.Property;
+import freemarker.ext.beans.BeansWrapper;
-import freemarker.ext.beans.BeansWrapper;
-import freemarker.template.DefaultObjectWrapper;
import freemarker.template.ObjectWrapper;
import freemarker.template.TemplateModel;
import freemarker.template.TemplateModelException;
-import freemarker.template.TemplateScalarModel;
+import org.richfaces.cdk.model.Component;
+import org.richfaces.cdk.model.Property;
+
/**
* <p class="changed_added_4_0"></p>
* @author asmirnov(a)exadel.com
*
*/
-public class LibraryModelWrapper extends BeansWrapper implements
- ObjectWrapper {
+public class LibraryModelWrapper extends BeansWrapper implements ObjectWrapper {
+ public LibraryModelWrapper() {
+ super();
+ setStrict(true);
+ setSimpleMapWrapper(true);
- public LibraryModelWrapper() {
- super();
- setStrict(true);
- setSimpleMapWrapper(true);
-// setNullModel(TemplateScalarModel.EMPTY_STRING);
- setUseCache(true);
- }
+// setNullModel(TemplateScalarModel.EMPTY_STRING);
+ setUseCache(true);
+ }
- @Override
- public TemplateModel wrap(Object obj) throws TemplateModelException {
- // TODO wrap specified model classes.
- TemplateModel templateModel;
- if (obj instanceof Component) {
- templateModel = new ComponentTemplateModel((Component)obj,this);
- } else if (obj instanceof Property) {
- templateModel = new PropertyModel((Property)obj,this);
- }else {
- templateModel = super.wrap(obj);
- }
- return templateModel;
- }
+ @Override
+ public TemplateModel wrap(Object obj) throws TemplateModelException {
+
+ // TODO wrap specified model classes.
+ TemplateModel templateModel;
+
+ if (obj instanceof Component) {
+ templateModel = new ComponentTemplateModel((Component) obj, this);
+ } else if (obj instanceof Property) {
+ templateModel = new PropertyModel((Property) obj, this);
+ } else {
+ templateModel = super.wrap(obj);
+ }
+
+ return templateModel;
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/PropertyModel.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/PropertyModel.java 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/PropertyModel.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.freemarker;
import org.richfaces.cdk.model.Property;
@@ -28,6 +30,7 @@
import freemarker.ext.beans.BeanModel;
import freemarker.ext.beans.BeansWrapper;
+
import freemarker.template.TemplateModel;
import freemarker.template.TemplateModelException;
@@ -37,39 +40,39 @@
*
*/
public class PropertyModel extends BeanModel implements TemplateModel {
+ private final Property property;
- private final Property property;
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param object
+ * @param wrapper
+ */
+ public PropertyModel(Property object, BeansWrapper wrapper) {
+ super(object, wrapper);
+ property = object;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param object
- * @param wrapper
- */
- public PropertyModel(Property object, BeansWrapper wrapper) {
- super(object, wrapper);
- property = object;
- }
-
- @Override
- public TemplateModel get(String key) throws TemplateModelException {
- Object value;
- if("getterName".equals(key)){
- value = getGetterName();
- } else if("setterName".equals(key)){
- value = getSetterName();
- } else {
- return super.get(key);
- }
- return wrapper.wrap(value);
- }
- // Model utility methods.
-
- public String getGetterName(){
- return property.getType().getGetterPrefix()+Strings.firstToUpperCase(property.getName().toString());
- }
+ @Override
+ public TemplateModel get(String key) throws TemplateModelException {
+ Object value;
- public String getSetterName(){
- return "set"+Strings.firstToUpperCase(property.getName().toString());
- }
+ if ("getterName".equals(key)) {
+ value = getGetterName();
+ } else if ("setterName".equals(key)) {
+ value = getSetterName();
+ } else {
+ return super.get(key);
+ }
+ return wrapper.wrap(value);
+ }
+
+ // Model utility methods.
+ public String getGetterName() {
+ return property.getType().getGetterPrefix() + Strings.firstToUpperCase(property.getName().toString());
+ }
+
+ public String getSetterName() {
+ return "set" + Strings.firstToUpperCase(property.getName().toString());
+ }
}
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-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ComponentClassGenerator.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -21,11 +21,10 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.richfaces.cdk.generate.java;
-import java.io.File;
-import java.io.IOException;
+package org.richfaces.cdk.generate.java;
+
import org.richfaces.cdk.CdkContext;
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.CdkWriter;
@@ -33,9 +32,10 @@
import org.richfaces.cdk.freemarker.FreeMarkerRenderer;
import org.richfaces.cdk.model.Component;
import org.richfaces.cdk.model.ComponentLibrary;
-import org.richfaces.cdk.model.Searchable;
import org.richfaces.cdk.model.Visitable;
+import java.io.File;
+
/**
* <p class="changed_added_4_0"></p>
* @author asmirnov(a)exadel.com
@@ -43,40 +43,38 @@
*/
public class ComponentClassGenerator extends FreeMarkerRenderer<Component, ComponentLibrary> implements CdkWriter {
- /* (non-Javadoc)
- * @see org.richfaces.cdk.CdkWriter#init(org.richfaces.cdk.CdkContext)
- */
- @Override
- public void init(CdkContext context) throws CdkException {
- super.init(context);
+ /*
+ * (non-Javadoc)
+ * @see org.richfaces.cdk.CdkWriter#init(org.richfaces.cdk.CdkContext)
+ */
+ @Override
+ public void init(CdkContext context) throws CdkException {
+ super.init(context);
+ }
- }
+ @Override
+ protected boolean isMyComponent(Visitable c) {
+ if (c instanceof Component) {
+ Component component = (Component) c;
+ return component.isGenerate();
+ }
- @Override
- protected boolean isMyComponent(Visitable c) {
- if (c instanceof Component) {
- Component component = (Component) c;
- return component.isGenerate();
- }
- return false;
- }
+ return false;
+ }
+ @Override
+ protected String getOutputFile(Component c) throws CdkException {
+ return c.getComponentClass().getName().replace('.', File.separatorChar) + ".java";
+ }
- @Override
- protected String getOutputFile(Component c) throws CdkException {
- return c.getComponentClass().getName().replace('.', File.separatorChar)+".java";
- }
+ @Override
+ protected String getTemplateName() {
+ return "component.ftl";
+ }
-
- @Override
- protected String getTemplateName() {
- return "component.ftl";
- }
-
-
- @Override
- protected OutputType getOutputType() {
- return StandardOutputs.COMPONENT_CLASSES;
- }
+ @Override
+ protected OutputType getOutputType() {
+ return StandardOutputs.COMPONENT_CLASSES;
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Attribute.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Attribute.java 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Attribute.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.model;
/**
@@ -31,12 +33,11 @@
@SuppressWarnings("serial")
public class Attribute extends Property {
- /**
- * <p class="changed_added_4_0"></p>
- * @param name
- */
- public Attribute(Property.Name name) {
- super(name);
- }
-
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param name
+ */
+ public Attribute(Property.Name name) {
+ super(name);
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Behavior.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Behavior.java 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Behavior.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.model;
import org.richfaces.cdk.CdkException;
@@ -31,37 +33,36 @@
*
*/
@SuppressWarnings("serial")
-public class Behavior implements ModelElement<Behavior,Behavior.Type> {
+public class Behavior implements ModelElement<Behavior, Behavior.Type> {
+ private final Type type;
- public static final class Type extends Key {
-
- public Type(String name) {
- super(name);
- }
- }
- private final Type type;
+ public Behavior(Type type) {
+ this.type = type;
+ }
- public Behavior(Type type) {
- this.type = type;
- }
- /* (non-Javadoc)
- * @see org.richfaces.cdk.model.ModelElement#getType()
- */
- @Override
- public Type getKey() {
- return type;
- }
+ /*
+ * (non-Javadoc)
+ * @see org.richfaces.cdk.model.ModelElement#getType()
+ */
+ @Override
+ public Type getKey() {
+ return type;
+ }
+ @Override
+ public void merge(Behavior other) {
- @Override
- public void merge(Behavior other) {
- // TODO Auto-generated method stub
-
- }
+ // TODO Auto-generated method stub
+ }
- @Override
- public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) throws CdkException {
- return visitor.visit(this, param);
- }
+ @Override
+ public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) throws CdkException {
+ return visitor.visit(this, param);
+ }
+ public static final class Type extends Key {
+ public Type(String name) {
+ super(name);
+ }
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/BehaviorRenderer.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/BehaviorRenderer.java 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/BehaviorRenderer.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.model;
import org.richfaces.cdk.CdkException;
@@ -31,71 +33,67 @@
*
*/
@SuppressWarnings("serial")
-public class BehaviorRenderer implements ModelElement<BehaviorRenderer, BehaviorRenderer.Type>{
+public class BehaviorRenderer implements ModelElement<BehaviorRenderer, BehaviorRenderer.Type> {
+ private ClassDescription rendererClass;
+ private final Type type;
- /**
- * <p class="changed_added_4_0"></p>
- * @author asmirnov(a)exadel.com
- *
- */
- @SuppressWarnings("serial")
- public static final class Type extends Key {
+ public BehaviorRenderer(Type type) {
+ this.type = type;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param type
- */
- public Type(String type) {
- super(type);
- }
+ @Override
+ public Type getKey() {
+ return type;
+ }
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the type
+ */
+ public Type getType() {
+ return type;
+ }
- private final Type type;
-
- private ClassDescription rendererClass;
-
- public BehaviorRenderer(Type type) {
- this.type = type;
- }
-
- @Override
- public Type getKey() {
- return type;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the rendererClass
+ */
+ public ClassDescription getRendererClass() {
+ return rendererClass;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the type
- */
- public Type getType() {
- return type;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param rendererClass the rendererClass to set
+ */
+ public void setRendererClass(ClassDescription rendererClass) {
+ this.rendererClass = rendererClass;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the rendererClass
- */
- public ClassDescription getRendererClass() {
- return rendererClass;
- }
+ @Override
+ public void merge(BehaviorRenderer other) {
+ ComponentLibrary.merge(this, other);
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param rendererClass the rendererClass to set
- */
- public void setRendererClass(ClassDescription rendererClass) {
- this.rendererClass = rendererClass;
- }
+ @Override
+ public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) throws CdkException {
+ return visitor.visit(this, param);
+ }
- @Override
- public void merge(BehaviorRenderer other) {
- ComponentLibrary.merge(this, other);
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+ @SuppressWarnings("serial")
+ public static final class Type extends Key {
- @Override
- public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) throws CdkException {
- return visitor.visit(this, param);
- }
-
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param type
+ */
+ public Type(String type) {
+ super(type);
+ }
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ClassDescription.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ClassDescription.java 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ClassDescription.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -21,206 +21,214 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.model;
-import javax.annotation.Generated;
-
import com.google.common.collect.ImmutableMap;
/**
* <p class="changed_added_4_0">
* Tthat class represents information about Jsf object class.
* </p>
- *
+ *
* @author asmirnov(a)exadel.com
- *
+ *
*/
-public class ClassDescription {
+public class ClassDescription {
- /**
- * <p class="changed_added_4_0"></p>
- */
- private static final long serialVersionUID = -846623207703750456L;
+ /**
+ * <p class="changed_added_4_0"></p>
+ */
+ private static final long serialVersionUID = -846623207703750456L;
+ private static final ImmutableMap<String, String> PRIMITIVE_TYPES =
+ ImmutableMap.<String, String>builder().put(boolean.class.getName(),
+ Boolean.class.getName()).put(byte.class.getName(),
+ Byte.class.getName()).put(char.class.getName(),
+ Character.class.getName()).put(short.class.getName(),
+ Short.class.getName()).put(int.class.getName(),
+ Integer.class.getName()).put(long.class.getName(),
+ Long.class.getName()).put(float.class.getName(),
+ Float.class.getName()).put(double.class.getName(),
+ Double.class.getName()).build();
+ private final String boxingClassName;
+ private final String fullName;
- private static final ImmutableMap<String, String> primitiveTypes = ImmutableMap
- .<String, String> builder().put(boolean.class.getName(),
- Boolean.class.getName()).put(byte.class.getName(),
- Byte.class.getName()).put(char.class.getName(),
- Character.class.getName()).put(short.class.getName(),
- Short.class.getName()).put(int.class.getName(),
- Integer.class.getName()).put(long.class.getName(),
- Long.class.getName()).put(float.class.getName(),
- Float.class.getName()).put(double.class.getName(),
- Double.class.getName()).build();
+ /**
+ * <p class="changed_added_4_0"></p>
+ */
+ private final String name;
+ private final boolean primitive;
- /**
- * <p class="changed_added_4_0"></p>
- */
- private final String name;
+ /**
+ * <p class="changed_added_4_0">Id parameters for that class</p>
+ * TODO append type parameters to key.
+ */
+ private String typeParameters;
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param cl
+ */
+ public ClassDescription(Class<?> cl) {
- private final boolean primitive;
+ // TODO get information directly from class.
+ this(cl.getName());
+ }
- private final String boxingClassName;
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param name
+ */
+ public ClassDescription(String name) {
+ fullName = name;
- /**
- * <p class="changed_added_4_0">Id parameters for that class</p>
- * TODO append type parameters to key.
- */
- private String typeParameters;
+ if (PRIMITIVE_TYPES.containsKey(name)) {
+ this.name = name;
+ boxingClassName = PRIMITIVE_TYPES.get(name);
+ primitive = true;
+ } else {
+ int i = name.indexOf('<');
- private final String fullName;
+ if (i > 0) {
+ this.name = name.substring(0, i);
+ this.typeParameters = name.substring(i);
+ } else {
+ this.name = name;
+ }
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @param name
- */
- public ClassDescription(String name) {
- fullName = name;
- if (primitiveTypes.containsKey(name)) {
- this.name = name;
- boxingClassName = primitiveTypes.get(name);
- primitive = true;
- } else {
- int i = name.indexOf('<');
- if(i>0){
- this.name = name.substring(0,i);
- this.typeParameters=name.substring(i);
- } else {
- this.name = name;
- }
- boxingClassName = name;
- primitive = false;
- }
- }
+ boxingClassName = name;
+ primitive = false;
+ }
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param cl
- */
- public ClassDescription(Class<?>cl) {
- // TODO get information directly from class.
- this(cl.getName());
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the typeParameters
+ */
+ public String getTypeParameters() {
+ return typeParameters;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the typeParameters
- */
- public String getTypeParameters() {
- return typeParameters;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param typeParameters the typeParameters to set
+ */
+ public void setTypeParameters(String typeParameters) {
+ this.typeParameters = typeParameters;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param typeParameters the typeParameters to set
- */
- public void setTypeParameters(String typeParameters) {
- this.typeParameters = typeParameters;
- }
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @return the name
+ */
+ public String getName() {
+ return name;
+ }
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @return the name
- */
- public String getName() {
- return name;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return package name.
+ */
+ public String getPackage() {
+ int indexOfPeriod = name.lastIndexOf('.');
- /**
- * <p class="changed_added_4_0"></p>
- * @return package name.
- */
- public String getPackage() {
- int indexOfPeriod = name.lastIndexOf('.');
- if(indexOfPeriod>0){
- return name.substring(0,indexOfPeriod);
- } else {
- return null;
- }
- }
+ if (indexOfPeriod > 0) {
+ return name.substring(0, indexOfPeriod);
+ } else {
+ return null;
+ }
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return package name.
- */
- public String getSimpleName() {
- int indexOfPeriod = name.lastIndexOf('.');
- if(indexOfPeriod>0){
- return name.substring(indexOfPeriod+1);
- } else {
- return name;
- }
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return package name.
+ */
+ public String getSimpleName() {
+ int indexOfPeriod = name.lastIndexOf('.');
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @return the primitive
- */
- public boolean isPrimitive() {
- return primitive;
- }
+ if (indexOfPeriod > 0) {
+ return name.substring(indexOfPeriod + 1);
+ } else {
+ return name;
+ }
+ }
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @return the boxingClassName
- */
- public String getBoxingName() {
- return boxingClassName;
- }
-
- public String getGetterPrefix(){
- return Boolean.class.getName().equals(boxingClassName)?"is":"get";
- }
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @return the primitive
+ */
+ public boolean isPrimitive() {
+ return primitive;
+ }
- @Override
- public String toString() {
- return fullName;
- }
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @return the boxingClassName
+ */
+ public String getBoxingName() {
+ return boxingClassName;
+ }
- /* (non-Javadoc)
- * @see java.lang.Object#hashCode()
- */
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((name == null) ? 0 : name.hashCode());
- return result;
- }
+ public String getGetterPrefix() {
+ return Boolean.class.getName().equals(boxingClassName) ? "is" : "get";
+ }
- /* (non-Javadoc)
- * @see java.lang.Object#equals(java.lang.Object)
- */
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (!(obj instanceof ClassDescription)) {
- return false;
- }
- ClassDescription other = (ClassDescription) obj;
- if (fullName == null) {
- if (other.fullName != null) {
- return false;
- }
- } else if (!fullName.equals(other.fullName)) {
- return false;
- }
- return true;
- }
+ @Override
+ public String toString() {
+ return fullName;
+ }
+ /*
+ * (non-Javadoc)
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((name == null) ? 0 : name.hashCode());
+
+ return result;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+
+ if (obj == null) {
+ return false;
+ }
+
+ if (!(obj instanceof ClassDescription)) {
+ return false;
+ }
+
+ ClassDescription other = (ClassDescription) obj;
+
+ if (fullName == null) {
+ if (other.fullName != null) {
+ return false;
+ }
+ } else if (!fullName.equals(other.fullName)) {
+ return false;
+ }
+
+ return true;
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Component.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Component.java 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Component.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -18,269 +18,266 @@
* That class represents JSF component in the CDK.
* That is mapped to faces-config "component" element.
* @author asmirnov(a)exadel.com
- *
+ *
*/
@SuppressWarnings("serial")
-@XmlType(name="faces-config-componentType")
-@XmlAccessorType( XmlAccessType.NONE )
-public final class Component extends ModelElementBase implements ModelElement<Component,Component.Type> {
+@XmlType(name = "faces-config-componentType")
+(a)XmlAccessorType(XmlAccessType.NONE)
+public final class Component extends ModelElementBase implements ModelElement<Component, Component.Type> {
+ /**
+ * <p class="changed_added_4_0">Is that component c</p>
+ */
+ private boolean generate = true;
- /**
- * <p class="changed_added_4_0">
- * Component type
- * </p>
- */
- private final Type type;
+ /**
+ * <p class="changed_added_4_0">
+ * Facets recognised by the component
+ * </p>
+ */
+ private final SearchableCollection<Facet, Facet.Name> facets = new ModelCollection<Facet, Facet.Name>() {
+ @Override
+ public Facet create(Name key) {
+ return new Facet(key);
+ }
+ };
- /**
- * <p class="changed_added_4_0">
- * Cenerated component class
- * </p>
- */
- private ClassDescription componentClass;
+ /**
+ * <p class="changed_added_4_0">
+ * Application level events fired by the component
+ * </p>
+ */
+ private final SearchableCollection<Event, Event.Type> events = new ModelCollection<Event, Event.Type>() {
+ @Override
+ public Event create(Event.Type key) {
+ return new Event(key);
+ }
+ };
- /**
- * <p class="changed_added_4_0">
- * Cenerated component class
- * </p>
- */
- private ClassDescription baseClass;
+ /**
+ * <p class="changed_added_4_0">
+ * Component attributes
+ * </p>
+ */
+ private final SearchableCollection<Property, Property.Name> attributes = new ModelCollection<Property,
+ Property.Name>() {
+ @Override
+ public Property create(Property.Name key) {
+ return new Property(key);
+ }
+ };
- private String family;
- /**
- * <p class="changed_added_4_0">Is that component c</p>
- */
- private boolean generate = true;
+ /**
+ * <p class="changed_added_4_0">
+ * Renderer for the final component. This is bidirectional many to many
+ * relation.
+ * </p>
+ */
+ private final Set<Renderer> renderers = Sets.newHashSet();
- /**
- * <p class="changed_added_4_0">
- * Component attributes
- * </p>
- */
- private final SearchableCollection<Property, Property.Name> attributes = new ModelCollection<Property, Property.Name>() {
+ /**
+ * <p class="changed_added_4_0">
+ * Cenerated component class
+ * </p>
+ */
+ private ClassDescription baseClass;
- @Override
- public Property create(Property.Name key) {
- return new Property(key);
- }
- };
+ /**
+ * <p class="changed_added_4_0">
+ * Cenerated component class
+ * </p>
+ */
+ private ClassDescription componentClass;
+ private String family;
- /**
- * <p class="changed_added_4_0">
- * Facets recognised by the component
- * </p>
- */
- private final SearchableCollection<Facet,Facet.Name> facets = new ModelCollection<Facet, Facet.Name>() {
+ /**
+ * <p class="changed_added_4_0">
+ * Component type
+ * </p>
+ */
+ private final Type type;
- @Override
- public Facet create(Name key) {
- return new Facet(key);
- }
- };
+ public Component(Type key) {
+ this.type = key;
+ }
- /**
- * <p class="changed_added_4_0">
- * Application level events fired by the component
- * </p>
- */
- private final SearchableCollection<Event,Event.Type> events = new ModelCollection<Event, Event.Type>() {
+ @Override
+ public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) throws CdkException {
+ return visitor.visit(this, param);
+ }
- @Override
- public Event create(Event.Type key) {
- return new Event(key);
- }
- };
+ @Override
+ public void merge(Component otherComponent) {
+ ComponentLibrary.merge(renderers, otherComponent.getRenderers());
- /**
- * <p class="changed_added_4_0">
- * Renderer for the final component. This is bidirectional many to many
- * relation.
- * </p>
- */
- private final Set<Renderer> renderers = Sets.newHashSet();
-
- public Component(Type key) {
- this.type = key;
- }
+// TODO - merge facets, renderers, events ...
+ ComponentLibrary.merge(attributes, otherComponent.getAttributes());
+ ComponentLibrary.merge(facets, otherComponent.getFacets());
+// ComponentLibrary.merge(events, otherComponent.getEvents());
+ ComponentLibrary.merge(this, otherComponent);
+ }
- @Override
- public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) throws CdkException {
- return visitor.visit(this, param);
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.richfaces.cdk.model.ModelElement#getType()
+ */
+ @Override
+ public Type getKey() {
+ return type;
+ }
- @Override
- public void merge(Component otherComponent) {
- ComponentLibrary.merge(renderers, otherComponent.getRenderers());
-// TODO - merge facets, renderers, events ...
- ComponentLibrary.merge(attributes, otherComponent.getAttributes());
- ComponentLibrary.merge(facets, otherComponent.getFacets());
-// ComponentLibrary.merge(events, otherComponent.getEvents());
- ComponentLibrary.merge(this,otherComponent);
- }
+ @XmlElement(name = "component-type", required = true)
+ public Type getType() {
+ return type;
+ }
- /*
- * (non-Javadoc)
- *
- * @see org.richfaces.cdk.model.ModelElement#getType()
- */
- @Override
- public Type getKey() {
- return type;
- }
+ /**
+ * <p class="changed_added_4_0">
+ * Reepresent a component family. In the faces-config element that property encoded as
+ * <component><component-extension><cdk:component-family>....
+ * </p>
+ *
+ * @return the family
+ */
+ @Merge
+ public String getFamily() {
+ return family;
+ }
-
-
- @XmlElement(name="component-type",required=true)
- public Type getType() {
- return type;
- }
+ /**
+ * <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">
- * Reepresent a component family. In the faces-config element that property encoded as
- * <component><component-extension><cdk:component-family>....
- * </p>
- *
- * @return the family
- */
- @Merge
- public String getFamily() {
- return family;
- }
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @return the componentClass
+ */
+ @Merge
+ public ClassDescription getComponentClass() {
+ return componentClass;
+ }
- /**
- * <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">Represents class of that component.
+ * </p>
+ *
+ * @param componentClass
+ * the componentClass to set
+ */
+ @XmlElement(name = "component-class")
+ public void setComponentClass(ClassDescription componentClass) {
+ this.componentClass = componentClass;
+ }
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @return the componentClass
- */
- @Merge
- public ClassDescription getComponentClass() {
- return componentClass;
- }
+ /**
+ * <p class="changed_added_4_0">Base class for generated components.
+ * </p>
+ *
+ * @return the baseClass
+ */
+ @Merge
+ public ClassDescription getBaseClass() {
+ return baseClass;
+ }
- /**
- * <p class="changed_added_4_0">Represents class of that component.
- * </p>
- *
- * @param componentClass
- * the componentClass to set
- */
- @XmlElement(name="component-class")
- public void setComponentClass(ClassDescription componentClass) {
- this.componentClass = componentClass;
- }
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param baseClass
+ * the baseClass to set
+ */
+ public void setBaseClass(ClassDescription baseClass) {
+ this.baseClass = baseClass;
+ }
- /**
- * <p class="changed_added_4_0">Base class for generated components.
- * </p>
- *
- * @return the baseClass
- */
- @Merge
- public ClassDescription getBaseClass() {
- return baseClass;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the generate
+ */
+ @Merge
+ public boolean isGenerate() {
+ return generate;
+ }
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @param baseClass
- * the baseClass to set
- */
- public void setBaseClass(ClassDescription baseClass) {
- this.baseClass = baseClass;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param generate the generate to set
+ */
+ public void setGenerate(boolean exists) {
+ this.generate = exists;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the generate
- */
- @Merge
- public boolean isGenerate() {
- return generate;
- }
+ /**
+ * <p class="changed_added_4_0">
+ * Represents JSF component attributes and properties.
+ * </p>
+ *
+ * @return the attributes
+ */
+ @XmlElements({@XmlElement(name = "property", type = Property.class) ,
+ @XmlElement(name = "attribute", type = Attribute.class) })
+ public Collection<Property> getAttributes() {
+ return attributes;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param generate the generate to set
- */
- public void setGenerate(boolean exists) {
- this.generate = exists;
- }
+ public Property findOrCreateAttribute(String attributeName) {
+ Property attribute;
- /**
- * <p class="changed_added_4_0">
- * Represents JSF component attributes and properties.
- * </p>
- *
- * @return the attributes
- */
- @XmlElements({@XmlElement(name="property",type=Property.class),@XmlElement(name="attribute",type=Attribute.class)})
- public Collection<Property> getAttributes() {
- return attributes;
- }
+ attribute = attributes.findOrCreate(new Property.Name(attributeName));
- public Property findOrCreateAttribute(String attributeName) {
- Property attribute;
- attribute = attributes.findOrCreate(new Property.Name(attributeName));
- return attribute;
- }
+ return attribute;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the facets
- */
- public Collection<Facet> getFacets() {
- return facets;
- }
-
- public Facet findOrCreateFacet(String name){
- return facets.findOrCreate(new Facet.Name(name));
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the facets
+ */
+ public Collection<Facet> getFacets() {
+ return facets;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the events
- */
- public Collection<Event> getEvents() {
- return events;
- }
-
- public Event addEvent(String className){
- // TODO - use a single events collection from library.
- return events.findOrCreate(new Event.Type(className));
- }
+ public Facet findOrCreateFacet(String name) {
+ return facets.findOrCreate(new Facet.Name(name));
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * TODO - synchronize renderers collection with library ?
- * @return the renderers
- */
- public Set<Renderer> getRenderers() {
- return renderers;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the events
+ */
+ public Collection<Event> getEvents() {
+ return events;
+ }
- public static class Type extends Key {
+ public Event addEvent(String className) {
- public Type(String type) {
- super(type);
- }
+ // TODO - use a single events collection from library.
+ return events.findOrCreate(new Event.Type(className));
+ }
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * TODO - synchronize renderers collection with library ?
+ * @return the renderers
+ */
+ public Set<Renderer> getRenderers() {
+ return renderers;
+ }
+ public static class Type extends Key {
+ public Type(String type) {
+ super(type);
+ }
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ComponentLibrary.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ComponentLibrary.java 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ComponentLibrary.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -21,14 +21,19 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.model;
import java.beans.IntrospectionException;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
+
import java.io.Serializable;
+
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
+
import java.util.Collection;
import java.util.NoSuchElementException;
@@ -49,362 +54,362 @@
* To keep consistence of library references, only library methods are allowed
* to components manipulations.
* </p>
- *
+ *
* @author asmirnov(a)exadel.com
- *
+ *
*/
@XmlRootElement(name = "faces-config", namespace = ComponentLibrary.FACES_CONFIG_NAMESPACE)
@XmlType(namespace = ComponentLibrary.FACES_CONFIG_NAMESPACE, name = "faces-configType")
-public class ComponentLibrary implements Serializable,Extensible<ConfigExtension>,Trackable {
+public class ComponentLibrary implements Serializable, Extensible<ConfigExtension>, Trackable {
+ public static final String CDK_EXTENSIONS_NAMESPACE = "http://richfaces.org/cdk/extensions";
+ public static final String FACES_CONFIG_NAMESPACE = "http://java.sun.com/xml/ns/javaee";
+ public static final String FACES_CONFIG_SCHEMA_LOCATION =
+ "http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd";
- public static final String FACES_CONFIG_NAMESPACE = "http://java.sun.com/xml/ns/javaee";
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ */
+ private static final long serialVersionUID = -6055670836731899832L;
+ private final SearchableCollection<Component, Component.Type> components = new ModelCollection<Component,
+ Component.Type>() {
+ @Override
+ public Component create(Component.Type key) {
+ return new Component(key);
+ }
+ };
- public static final String FACES_CONFIG_SCHEMA_LOCATION = "http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd";
+ /**
+ * <p class="changed_added_4_0">
+ * JSF renderer associated with that library
+ * </p>
+ */
+ private final SearchableCollection<RenderKit, RenderKit.Id> renderKits = new ModelCollection<RenderKit,
+ RenderKit.Id>() {
+ @Override
+ public RenderKit create(RenderKit.Id key) {
+ RenderKit rendererKit = new RenderKit(key);
- public static final String CDK_EXTENSIONS_NAMESPACE = "http://richfaces.org/cdk/extensions";
+ return rendererKit;
+ }
+ };
+ private final SearchableCollection<Converter, Key> converters = new ModelCollection<Converter, Key>() {
+ @Override
+ public Converter create(Key key) {
+ Converter converter = new Converter(key);
- /**
- * <p class="changed_added_4_0">
- * </p>
- */
- private static final long serialVersionUID = -6055670836731899832L;
+ return converter;
+ }
+ };
+ private final SearchableCollection<Validator, Key> validators = new ModelCollection<Validator, Key>() {
+ @Override
+ public Validator create(Key key) {
+ Validator validator = new Validator(key);
- private final SearchableCollection<Component, Component.Type> components = new ModelCollection<Component, Component.Type>() {
+ return validator;
+ }
+ };
+ private final SearchableCollection<Listener, Key> listeners = new ModelCollection<Listener, Key>() {
+ @Override
+ public Listener create(Key key) {
+ Listener listener = new Listener(key);
- @Override
- public Component create(Component.Type key) {
- return new Component(key);
- }
- };
+ return listener;
+ }
+ };
+ private long lastModified = Long.MIN_VALUE;
- /**
- * <p class="changed_added_4_0">
- * JSF renderer associated with that library
- * </p>
- */
- private final SearchableCollection<RenderKit, RenderKit.Id> renderKits = new ModelCollection<RenderKit, RenderKit.Id>() {
+ /**
+ * <p class="changed_added_4_0">
+ * Application level events fired by the component
+ * </p>
+ */
+ private final SearchableCollection<Event, Event.Type> events = new ModelCollection<Event, Event.Type>() {
+ @Override
+ public Event create(Event.Type key) {
+ return new Event(key);
+ }
+ };
+ private final SearchableCollection<Behavior, Behavior.Type> behaviors = new ModelCollection<Behavior,
+ Behavior.Type>() {
+ @Override
+ public Behavior create(Behavior.Type key) {
+ Behavior behavior = new Behavior(key);
- @Override
- public RenderKit create(RenderKit.Id key) {
- RenderKit rendererKit = new RenderKit(key);
- return rendererKit;
- }
- };
+ return behavior;
+ }
+ };
+ private ConfigExtension extension;
- private final SearchableCollection<Converter, Key> converters = new ModelCollection<Converter, Key>() {
+ /**
+ * <p class="changed_added_4_0">
+ * Tag library with references of all used tags
+ * </p>
+ */
+ private final TagLibrary tagLibrary;
- @Override
- public Converter create(Key key) {
- Converter converter = new Converter(key);
- return converter;
- }
- };
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param baseName
+ */
+ public ComponentLibrary() {
+ this.tagLibrary = new TagLibrary();
+ }
- private final SearchableCollection<Validator, Key> validators = new ModelCollection<Validator, Key>() {
+ /**
+ * <p class="changed_added_4_0">
+ * Merge component library model with other.
+ * </p>
+ *
+ * @param otherLibrary
+ */
+ public void merge(ComponentLibrary otherLibrary) {
+ components.merge(otherLibrary.components);
+ renderKits.merge(otherLibrary.renderKits);
+ converters.merge(otherLibrary.converters);
+ validators.merge(otherLibrary.validators);
+ listeners.merge(otherLibrary.listeners);
+ events.merge(otherLibrary.events);
+ behaviors.merge(otherLibrary.behaviors);
+ }
- @Override
- public Validator create(Key key) {
- Validator validator = new Validator(key);
- return validator;
- }
- };
+ public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) throws CdkException {
+ R result = accept(components, visitor, param, null);
- private final SearchableCollection<Behavior, Behavior.Type> behaviors = new ModelCollection<Behavior, Behavior.Type>() {
+ result = accept(renderKits, visitor, param, result);
+ result = accept(converters, visitor, param, result);
+ result = accept(validators, visitor, param, result);
+ result = accept(listeners, visitor, param, result);
+ result = accept(events, visitor, param, result);
+ result = accept(behaviors, visitor, param, result);
- @Override
- public Behavior create(Behavior.Type key) {
- Behavior behavior = new Behavior(key);
- return behavior;
- }
- };
+ return result;
+ }
- /**
- * <p class="changed_added_4_0">
- * Application level events fired by the component
- * </p>
- */
- private final SearchableCollection<Event,Event.Type> events = new ModelCollection<Event, Event.Type>() {
+ /**
+ * <p class="changed_added_4_0">
+ * Create a new component description.
+ * </p>
+ *
+ * @param type
+ * component type.
+ * @param className
+ * final component class name.
+ * @param superClassName
+ * name of the component superclass. May be empty or null for
+ * already existed components.
+ * @return
+ */
+ public Component findOrCreateComponent(String type) {
+ Component component = components.findOrCreate(new Component.Type(type));
- @Override
- public Event create(Event.Type key) {
- return new Event(key);
- }
- };
-
- private final SearchableCollection<Listener, Key> listeners = new ModelCollection<Listener, Key>() {
+ return component;
+ }
- @Override
- public Listener create(Key key) {
- Listener listener = new Listener(key);
- return listener;
- }
- };
-
- private ConfigExtension extension;
- /**
- * <p class="changed_added_4_0">
- * Tag library with references of all used tags
- * </p>
- */
- private final TagLibrary tagLibrary;
-
- private long lastModified = Long.MIN_VALUE;
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param renderKitId
+ * @param rendererType
+ * @return
+ */
+ public RenderKit findOrCreateRenderKit(String renderKitId) {
+ RenderKit.Id renderKitType = new RenderKit.Id(renderKitId);
+ RenderKit renderKit = renderKits.findOrCreate(renderKitType);
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @param baseName
- */
- public ComponentLibrary() {
- this.tagLibrary = new TagLibrary();
- }
+ return renderKit;
+ }
- /**
- * <p class="changed_added_4_0">
- * Merge component library model with other.
- * </p>
- *
- * @param otherLibrary
- */
- public void merge(ComponentLibrary otherLibrary) {
- components.merge(otherLibrary.components);
- renderKits.merge(otherLibrary.renderKits);
- converters.merge(otherLibrary.converters);
- validators.merge(otherLibrary.validators);
- listeners.merge(otherLibrary.listeners);
- events.merge(otherLibrary.events);
- behaviors.merge(otherLibrary.behaviors);
- }
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @return the components
+ */
+ @XmlElement
+ public Collection<Component> getComponents() {
+ return components;
+ }
- public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) throws CdkException {
- R result = accept(components, visitor, param, null);
- result = accept(renderKits, visitor, param, result);
- result = accept(converters, visitor, param, result);
- result = accept(validators, visitor, param, result);
- result = accept(listeners, visitor, param, result);
- result = accept(events, visitor, param, result);
- result = accept(behaviors, visitor, param, result);
- return result;
- }
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @return the renderKits
+ */
+ public Collection<RenderKit> getRenderKits() {
+ return renderKits;
+ }
- /**
- * <p class="changed_added_4_0">
- * Create a new component description.
- * </p>
- *
- * @param type
- * component type.
- * @param className
- * final component class name.
- * @param superClassName
- * name of the component superclass. May be empty or null for
- * already existed components.
- * @return
- */
- public Component findOrCreateComponent(String type) {
- Component component = components.findOrCreate(new Component.Type(type));
- return component;
- }
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @return the converters
+ */
+ public Collection<Converter> getConverters() {
+ return converters;
+ }
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @param renderKitId
- * @param rendererType
- * @return
- */
- public RenderKit findOrCreateRenderKit(String renderKitId) {
- RenderKit.Id renderKitType = new RenderKit.Id(renderKitId);
- RenderKit renderKit = renderKits.findOrCreate(renderKitType);
- return renderKit;
- }
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @return the validators
+ */
+ public Collection<Validator> getValidators() {
+ return validators;
+ }
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @return the components
- */
- @XmlElement
- public Collection<Component> getComponents() {
- return components;
- }
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @return the behaviors
+ */
+ public Collection<Behavior> getBehaviors() {
+ return behaviors;
+ }
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @return the renderKits
- */
- public Collection<RenderKit> getRenderKits() {
- return renderKits;
- }
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @return the listeners
+ */
+ public Collection<Listener> getListeners() {
+ return listeners;
+ }
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @return the converters
- */
- public Collection<Converter> getConverters() {
- return converters;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the events
+ */
+ public SearchableCollection<Event, Event.Type> getEvents() {
+ return events;
+ }
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @return the validators
- */
- public Collection<Validator> getValidators() {
- return validators;
- }
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @return the tagLibrary
+ */
+ public TagLibrary getTagLibrary() {
+ return tagLibrary;
+ }
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @return the behaviors
- */
- public Collection<Behavior> getBehaviors() {
- return behaviors;
- }
+ // Utility methods.
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @return the listeners
- */
- public Collection<Listener> getListeners() {
- return listeners;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the extension
+ */
+ public ConfigExtension getExtension() {
+ return extension;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the events
- */
- public SearchableCollection<Event, Event.Type> getEvents() {
- return events;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param extension the extension to set
+ */
+ public void setExtension(ConfigExtension extension) {
+ this.extension = extension;
+ }
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @return the tagLibrary
- */
- public TagLibrary getTagLibrary() {
- return tagLibrary;
- }
+ @Override
+ public long lastModified() {
+ return lastModified;
+ }
- // Utility methods.
+ static <K extends Key, T extends ModelElement<T, K>> void merge(Collection<T> target, Collection<T> source) {
+ for (T element : source) {
+ T targetElement = find(target, element.getKey());
- /**
- * <p class="changed_added_4_0"></p>
- * @return the extension
- */
- public ConfigExtension getExtension() {
- return extension;
- }
+ if (null == targetElement) {
+ target.add(element);
+ } else {
+ targetElement.merge(element);
+ }
+ }
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param extension the extension to set
- */
- public void setExtension(ConfigExtension extension) {
- this.extension = extension;
- }
-
- @Override
- public long lastModified() {
- return lastModified;
- }
+ static <T extends Mergeable<T>> void merge(T target, T source) {
+ try {
+ PropertyDescriptor[] properties = Introspector.getBeanInfo(target.getClass()).getPropertyDescriptors();
- static <K extends Key,T extends ModelElement<T,K>> void merge(Collection<T> target,
- Collection<T> source) {
- for (T element : source) {
- T targetElement = find(target, element.getKey());
- if (null == targetElement) {
- target.add(element);
- } else {
- targetElement.merge(element);
- }
- }
- }
+ for (PropertyDescriptor propertyDescriptor : properties) {
+ Method readMethod = propertyDescriptor.getReadMethod();
+ Method writeMethod = propertyDescriptor.getWriteMethod();
- static <T extends Mergeable<T>> void merge(T target, T source) {
- try {
- PropertyDescriptor[] properties = Introspector.getBeanInfo(
- target.getClass()).getPropertyDescriptors();
- for (PropertyDescriptor propertyDescriptor : properties) {
- Method readMethod = propertyDescriptor.getReadMethod();
- Method writeMethod = propertyDescriptor.getWriteMethod();
- if (null != readMethod && null != writeMethod
- && readMethod.isAnnotationPresent(Merge.class)) {
- boolean overwrite = readMethod.getAnnotation(Merge.class)
- .value();
- Object oldValue = readMethod.invoke(target);
- Object newValue = readMethod.invoke(source);
- if (null != newValue && (overwrite || null == oldValue)) {
- writeMethod.invoke(target, newValue);
- }
- }
- }
- } catch (IntrospectionException e) {
- // TODO Auto-generated catch block
- } catch (IllegalArgumentException e) {
- // TODO Auto-generated catch block
- } catch (IllegalAccessException e) {
- // TODO Auto-generated catch block
- } catch (InvocationTargetException e) {
- // TODO Auto-generated catch block
- }
- }
+ if (null != readMethod && null != writeMethod && readMethod.isAnnotationPresent(Merge.class)) {
+ boolean overwrite = readMethod.getAnnotation(Merge.class).value();
+ Object oldValue = readMethod.invoke(target);
+ Object newValue = readMethod.invoke(source);
- static <R, P, T extends ModelElement<T,?>> R accept(Iterable<T> components,
- LibraryVisitor<R, P> visitor, P param, R result) throws CdkException {
- if (null == result) {
- for (T t : components) {
- R accept = t.accept(visitor, param);
- if (null != accept) {
- result = accept;
- break;
- }
- }
+ if (null != newValue && (overwrite || null == oldValue)) {
+ writeMethod.invoke(target, newValue);
+ }
+ }
+ }
+ } catch (IntrospectionException e) {
- }
- return result;
- }
+ // TODO Auto-generated catch block
+ } catch (IllegalArgumentException e) {
- /**
- * <p class="changed_added_4_0">
- * Find element in the model collection.
- * </p>
- *
- * @param <T>
- * type of element to find.
- * @param collection
- * of elements.
- * @param key
- * for search.
- * @return existing element in the collection.
- * @throws NoSuchElementException
- * if there was no such element in collection.
- */
- static <K extends Key,T extends Searchable<K>> T find(Iterable<T> collection, final K key)
- throws NoSuchElementException {
- return Iterables.find(collection, new Predicate<T>() {
+ // TODO Auto-generated catch block
+ } catch (IllegalAccessException e) {
- @Override
- public boolean apply(T input) {
+ // TODO Auto-generated catch block
+ } catch (InvocationTargetException e) {
- return key.equals(input.getKey());
- }
+ // TODO Auto-generated catch block
+ }
+ }
- });
- }
+ static <R, P, T extends ModelElement<T, ?>> R accept(Iterable<T> components, LibraryVisitor<R, P> visitor, P param,
+ R result) throws CdkException {
+ if (null == result) {
+ for (T t : components) {
+ R accept = t.accept(visitor, param);
+ if (null != accept) {
+ result = accept;
+
+ break;
+ }
+ }
+ }
+
+ return result;
+ }
+
+ /**
+ * <p class="changed_added_4_0">
+ * Find element in the model collection.
+ * </p>
+ *
+ * @param <T>
+ * type of element to find.
+ * @param collection
+ * of elements.
+ * @param key
+ * for search.
+ * @return existing element in the collection.
+ * @throws NoSuchElementException
+ * if there was no such element in collection.
+ */
+ static <K extends Key, T extends Searchable<K>> T find(Iterable<T> collection, final K key)
+ throws NoSuchElementException {
+
+ return Iterables.find(collection, new Predicate<T>() {
+ @Override
+ public boolean apply(T input) {
+ return key.equals(input.getKey());
+ }
+ });
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ConfigExtension.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ConfigExtension.java 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ConfigExtension.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.model;
import java.util.List;
@@ -35,24 +37,22 @@
*
*/
public class ConfigExtension {
-
- private List<Element> extensions;
+ private List<Element> extensions;
- /**
- * <p class="changed_added_4_0"></p>
- * @return the extensions
- */
- @XmlAnyElement
- public List<Element> getExtensions() {
- return extensions;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the extensions
+ */
+ @XmlAnyElement
+ public List<Element> getExtensions() {
+ return extensions;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param extensions the extensions to set
- */
- public void setExtensions(List<Element> extensions) {
- this.extensions = extensions;
- }
-
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param extensions the extensions to set
+ */
+ public void setExtensions(List<Element> extensions) {
+ this.extensions = extensions;
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Converter.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Converter.java 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Converter.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.model;
import org.richfaces.cdk.CdkException;
@@ -31,34 +33,33 @@
*
*/
@SuppressWarnings("serial")
-public class Converter implements ModelElement <Converter,Key>{
+public class Converter implements ModelElement<Converter, Key> {
+ private final Key type;
- private final Key type;
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param type the type to set
+ */
+ public Converter(Key type) {
+ this.type = type;
+ }
- @Override
- public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) throws CdkException {
- return visitor.visit(this, param);
- }
+ @Override
+ public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) throws CdkException {
+ return visitor.visit(this, param);
+ }
- /* (non-Javadoc)
- * @see org.richfaces.cdk.model.ModelElement#getType()
- */
- public Key getKey() {
- return type;
- }
+ /*
+ * (non-Javadoc)
+ * @see org.richfaces.cdk.model.ModelElement#getType()
+ */
+ public Key getKey() {
+ return type;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param type the type to set
- */
- public Converter(Key type) {
- this.type = type;
- }
+ @Override
+ public void merge(Converter other) {
- @Override
- public void merge(Converter other) {
- // TODO Auto-generated method stub
-
- }
-
+ // TODO Auto-generated method stub
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/DescriptionGroup.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/DescriptionGroup.java 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/DescriptionGroup.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -10,102 +10,105 @@
*/
public interface DescriptionGroup {
- /**
- * <p class="changed_added_4_0"></p>
- * @author asmirnov(a)exadel.com
- *
- */
- @XmlType(name="icon-type",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
- public static final class Icon {
- private String smallIcon;
- /**
- * <p class="changed_added_4_0"></p>
- * @return the smallIcon
- */
- @XmlElement(name = "small-icon", namespace = ComponentLibrary.FACES_CONFIG_NAMESPACE)
- public String getSmallIcon() {
- return smallIcon;
- }
- /**
- * <p class="changed_added_4_0"></p>
- * @param smallIcon the smallIcon to set
- */
- public void setSmallIcon(String smallIcon) {
- this.smallIcon = smallIcon;
- }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the largeIcon
- */
- @XmlElement(name = "large-icon", namespace = ComponentLibrary.FACES_CONFIG_NAMESPACE)
- public String getLargeIcon() {
- return largeIcon;
- }
- /**
- * <p class="changed_added_4_0"></p>
- * @param largeIcon the largeIcon to set
- */
- public void setLargeIcon(String largeIcon) {
- this.largeIcon = largeIcon;
- }
- private String largeIcon;
- }
+ /**
+ * <p class="changed_added_4_0">Documentation description of that element.
+ * </p>
+ *
+ * @return the description
+ */
+ @XmlElement
+ @Merge
+ public String getDescription();
- /**
- * <p class="changed_added_4_0">Documentation description of that element.
- * </p>
- *
- * @return the description
- */
- @XmlElement
- @Merge
- public String getDescription();
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param description
+ * the description to set
+ */
+ public void setDescription(String description);
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @param description
- * the description to set
- */
- public void setDescription(String description);
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @return the displayname
+ */
+ @XmlElement(name = "display-name")
+ @Merge
+ public String getDisplayname();
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @return the displayname
- */
- @XmlElement(name = "display-name")
- @Merge
- public String getDisplayname();
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param displayname
+ * the displayname to set
+ */
+ public void setDisplayname(String displayname);
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @param displayname
- * the displayname to set
- */
- public void setDisplayname(String displayname);
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @return the icon
+ */
+ @XmlElement
+ @Merge
+ public Icon getIcon();
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @return the icon
- */
- @XmlElement
- @Merge
- public Icon getIcon();
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param icon
+ * the icon to set
+ */
+ public void setIcon(Icon icon);
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @param icon
- * the icon to set
- */
- public void setIcon(Icon icon);
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+ @XmlType(name = "icon-type", namespace = ComponentLibrary.FACES_CONFIG_NAMESPACE)
+ public static final class Icon {
+ private String largeIcon;
+ private String smallIcon;
-}
\ No newline at end of file
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the smallIcon
+ */
+ @XmlElement(name = "small-icon", namespace = ComponentLibrary.FACES_CONFIG_NAMESPACE)
+ public String getSmallIcon() {
+ return smallIcon;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param smallIcon the smallIcon to set
+ */
+ public void setSmallIcon(String smallIcon) {
+ this.smallIcon = smallIcon;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the largeIcon
+ */
+ @XmlElement(name = "large-icon", namespace = ComponentLibrary.FACES_CONFIG_NAMESPACE)
+ public String getLargeIcon() {
+ return largeIcon;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param largeIcon the largeIcon to set
+ */
+ public void setLargeIcon(String largeIcon) {
+ this.largeIcon = largeIcon;
+ }
+ }
+}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Event.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Event.java 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Event.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -21,146 +21,139 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.richfaces.cdk.model;
-import javax.faces.event.FacesEvent;
+package org.richfaces.cdk.model;
+
import org.richfaces.cdk.CdkException;
/**
- * <p class="changed_added_4_0">That bean represent {@link FacesEvent} subclass that can be fired by component.</p>
+ * <p class="changed_added_4_0">That bean represent {@link javax.faces.event.FacesEvent} subclass that can be fired by
+ * component.</p>
+ *
* @author asmirnov(a)exadel.com
*
*/
@SuppressWarnings("serial")
-public class Event implements ModelElement<Event,Event.Type>{
+public class Event implements ModelElement<Event, Event.Type> {
+ private String description;
+ private ClassDescription listenerInterface;
+ private ClassDescription sourceInterface;
+ private ClassDescription tagHandler;
- /**
- * <p class="changed_added_4_0"></p>
- * @author asmirnov(a)exadel.com
- *
- */
- public static final class Type extends Key {
+ /**
+ * <p class="changed_added_4_0"></p>
+ */
+ private final Type type;
- /**
- * <p class="changed_added_4_0"></p>
- * @param type
- */
- public Type(String type) {
- super(type);
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param type the type to set
+ */
+ public Event(Type name) {
+ this.type = name;
+ }
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the type
+ */
+ public Key getType() {
+ return type;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- */
- private final Type type;
+ @Override
+ public Type getKey() {
+ return type;
+ }
- private String description;
-
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the description
+ */
+ public String getDescription() {
+ return description;
+ }
- private ClassDescription listenerInterface;
-
- private ClassDescription sourceInterface;
-
- private ClassDescription tagHandler;
-
-
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param description the description to set
+ */
+ public void setDescription(String description) {
+ this.description = description;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param type the type to set
- */
- public Event(Type name) {
- this.type = name;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the listenerInterface
+ */
+ public ClassDescription getListenerInterface() {
+ return listenerInterface;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the type
- */
- public Key getType() {
- return type;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param listenerInterface the listenerInterface to set
+ */
+ public void setListenerInterface(ClassDescription listenerInterface) {
+ this.listenerInterface = listenerInterface;
+ }
- @Override
- public Type getKey() {
- return type;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the sourceInterface
+ */
+ public ClassDescription getSourceInterface() {
+ return sourceInterface;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the description
- */
- public String getDescription() {
- return description;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param sourceInterface the sourceInterface to set
+ */
+ public void setSourceInterface(ClassDescription sourceInterface) {
+ this.sourceInterface = sourceInterface;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param description the description to set
- */
- public void setDescription(String description) {
- this.description = description;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the tagHandler
+ */
+ public ClassDescription getTagHandler() {
+ return tagHandler;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the listenerInterface
- */
- public ClassDescription getListenerInterface() {
- return listenerInterface;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param tagHandler the tagHandler to set
+ */
+ public void setTagHandler(ClassDescription tagHandler) {
+ this.tagHandler = tagHandler;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param listenerInterface the listenerInterface to set
- */
- public void setListenerInterface(ClassDescription listenerInterface) {
- this.listenerInterface = listenerInterface;
- }
+ @Override
+ public void merge(Event other) {
+ ComponentLibrary.merge(this, other);
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the sourceInterface
- */
- public ClassDescription getSourceInterface() {
- return sourceInterface;
- }
+ @Override
+ public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) throws CdkException {
+ return visitor.visit(this, param);
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param sourceInterface the sourceInterface to set
- */
- public void setSourceInterface(ClassDescription sourceInterface) {
- this.sourceInterface = sourceInterface;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+ public static final class Type extends Key {
- /**
- * <p class="changed_added_4_0"></p>
- * @return the tagHandler
- */
- public ClassDescription getTagHandler() {
- return tagHandler;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @param tagHandler the tagHandler to set
- */
- public void setTagHandler(ClassDescription tagHandler) {
- this.tagHandler = tagHandler;
- }
-
- @Override
- public void merge(Event other) {
- ComponentLibrary.merge(this, other);
- }
-
- @Override
- public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) throws CdkException {
- return visitor.visit(this, param);
- }
-
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param type
+ */
+ public Type(String type) {
+ super(type);
+ }
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/EventName.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/EventName.java 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/EventName.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.model;
import java.io.Serializable;
@@ -35,83 +37,90 @@
*/
@SuppressWarnings("serial")
public class EventName implements Serializable {
-
- private String name;
-
- private boolean defaultEvent = false;
+ private boolean defaultEvent = false;
+ private String name;
- /**
- * <p class="changed_added_4_0"></p>
- * @return the name
- */
- @XmlValue
- public String getName() {
- return name;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the name
+ */
+ @XmlValue
+ public String getName() {
+ return name;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param name the name to set
- */
- public void setName(String name) {
- this.name = name;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param name the name to set
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the defaultEvent
- */
- @XmlAttribute(name="default")
- public boolean isDefaultEvent() {
- return defaultEvent;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the defaultEvent
+ */
+ @XmlAttribute(name = "default")
+ public boolean isDefaultEvent() {
+ return defaultEvent;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param defaultEvent the defaultEvent to set
- */
- public void setDefaultEvent(boolean defaultEvent) {
- this.defaultEvent = defaultEvent;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param defaultEvent the defaultEvent to set
+ */
+ public void setDefaultEvent(boolean defaultEvent) {
+ this.defaultEvent = defaultEvent;
+ }
- @Override
- public String toString() {
- return name;
- }
- /* (non-Javadoc)
- * @see java.lang.Object#hashCode()
- */
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((name == null) ? 0 : name.hashCode());
- return result;
- }
+ @Override
+ public String toString() {
+ return name;
+ }
- /* (non-Javadoc)
- * @see java.lang.Object#equals(java.lang.Object)
- */
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- EventName other = (EventName) obj;
- if (name == null) {
- if (other.name != null) {
- return false;
- }
- } else if (!name.equals(other.name)) {
- return false;
- }
- return true;
- }
+ /*
+ * (non-Javadoc)
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((name == null) ? 0 : name.hashCode());
+
+ return result;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+
+ if (obj == null) {
+ return false;
+ }
+
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+
+ EventName other = (EventName) obj;
+
+ if (name == null) {
+ if (other.name != null) {
+ return false;
+ }
+ } else if (!name.equals(other.name)) {
+ return false;
+ }
+
+ return true;
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Extensible.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Extensible.java 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Extensible.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.model;
/**
@@ -30,12 +32,11 @@
*/
public interface Extensible<E extends ConfigExtension> {
- /**
- * <p class="changed_added_4_0">Return extension object that holds CDK-related tags and any other content as well.</p>
- * @return
- */
- public E getExtension();
-
- public void setExtension(E ext);
-
+ /**
+ * <p class="changed_added_4_0">Return extension object that holds CDK-related tags and any other content as well.</p>
+ * @return
+ */
+ public E getExtension();
+
+ public void setExtension(E ext);
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Facet.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Facet.java 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Facet.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.model;
import org.richfaces.cdk.CdkException;
@@ -31,62 +33,60 @@
*
*/
@SuppressWarnings("serial")
-public class Facet extends ModelElementBase implements ModelElement<Facet,Facet.Name> {
-
- public static final class Name extends Key {
-
- public Name(String name) {
- super(name);
- }
- }
+public class Facet extends ModelElementBase implements ModelElement<Facet, Facet.Name> {
+ private boolean generate;
+ private final Name name;
- private final Name name;
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param name
+ */
+ public Facet(Name name) {
+ this.name = name;
+ }
- private boolean generate;
- /**
- * <p class="changed_added_4_0"></p>
- * @param name
- */
- public Facet(Name name) {
- this.name = name;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the name
+ */
+ public Name getName() {
+ return name;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the name
- */
- public Name getName() {
- return name;
- }
+ @Override
+ public Name getKey() {
+ return name;
+ }
- @Override
- public Name getKey() {
- return name;
- }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the generate
- */
- public boolean isGenerate() {
- return generate;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the generate
+ */
+ public boolean isGenerate() {
+ return generate;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param generate the generate to set
- */
- public void setGenerate(boolean generate) {
- this.generate = generate;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param generate the generate to set
+ */
+ public void setGenerate(boolean generate) {
+ this.generate = generate;
+ }
- @Override
- public void merge(Facet other) {
- ComponentLibrary.merge(this, other);
- }
+ @Override
+ public void merge(Facet other) {
+ ComponentLibrary.merge(this, other);
+ }
- @Override
- public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) throws CdkException {
- return visitor.visit(this, param);
- }
+ @Override
+ public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) throws CdkException {
+ return visitor.visit(this, param);
+ }
+ public static final class Name extends Key {
+ public Name(String name) {
+ super(name);
+ }
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/InvalidNameException.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/InvalidNameException.java 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/InvalidNameException.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.model;
import org.richfaces.cdk.CdkException;
@@ -33,36 +35,35 @@
@SuppressWarnings("serial")
public class InvalidNameException extends CdkException {
- /**
- * <p class="changed_added_4_0"></p>
- */
- public InvalidNameException() {
- super();
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ */
+ public InvalidNameException() {
+ super();
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param message
- */
- public InvalidNameException(String message) {
- super(message);
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param message
+ */
+ public InvalidNameException(String message) {
+ super(message);
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param cause
- */
- public InvalidNameException(Throwable cause) {
- super(cause);
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param cause
+ */
+ public InvalidNameException(Throwable cause) {
+ super(cause);
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param message
- * @param cause
- */
- public InvalidNameException(String message, Throwable cause) {
- super(message, cause);
- }
-
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param message
+ * @param cause
+ */
+ public InvalidNameException(String message, Throwable cause) {
+ super(message, cause);
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Key.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Key.java 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Key.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.model;
import java.io.Serializable;
@@ -32,59 +34,71 @@
*/
@SuppressWarnings("serial")
public class Key implements Serializable {
-
- private final String type;
+ private final String type;
- /**
- * <p class="changed_added_4_0"></p>
- * @param type
- */
- public Key(String type) {
- this.type = type;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param type
+ */
+ public Key(String type) {
+ this.type = type;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the type
- */
- public String getType() {
- return type;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the type
+ */
+ public String getType() {
+ return type;
+ }
- @Override
- public String toString() {
- return type;
- }
- /* (non-Javadoc)
- * @see java.lang.Object#hashCode()
- */
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((type == null) ? 0 : type.hashCode());
- return result;
- }
+ @Override
+ public String toString() {
+ return type;
+ }
- /* (non-Javadoc)
- * @see java.lang.Object#equals(java.lang.Object)
- */
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- Key other = (Key) obj;
- if (type == null) {
- if (other.type != null)
- return false;
- } else if (!type.equals(other.type))
- return false;
- return true;
- }
+ /*
+ * (non-Javadoc)
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((type == null) ? 0 : type.hashCode());
+ return result;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+
+ if (obj == null) {
+ return false;
+ }
+
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+
+ Key other = (Key) obj;
+
+ if (type == null) {
+ if (other.type != null) {
+ return false;
+ }
+ } else if (!type.equals(other.type)) {
+ return false;
+ }
+
+ return true;
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/LibraryVisitor.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/LibraryVisitor.java 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/LibraryVisitor.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.model;
import org.richfaces.cdk.CdkException;
@@ -32,15 +34,14 @@
* @param <R> return type
* @param <P> optional parameter type.
*/
-public interface LibraryVisitor<R,P> {
-
- /**
- * <p class="changed_added_4_0"></p>
- * @param c
- * @param param
- * @return
- * @throws CdkException
- */
- public R visit(Visitable c, P param) throws CdkException;
+public interface LibraryVisitor<R, P> {
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param c
+ * @param param
+ * @return
+ * @throws CdkException
+ */
+ public R visit(Visitable c, P param) throws CdkException;
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Listener.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Listener.java 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Listener.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.model;
import org.richfaces.cdk.CdkException;
@@ -31,33 +33,33 @@
*
*/
@SuppressWarnings("serial")
-public class Listener implements ModelElement<Listener,Key> {
-
- /**
- * <p class="changed_added_4_0"></p>
- */
- private final Key type;
+public class Listener implements ModelElement<Listener, Key> {
- @Override
- public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) throws CdkException {
- return visitor.visit(this, param);
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ */
+ private final Key type;
- public Listener(Key type) {
- this.type = type;
- }
- /* (non-Javadoc)
- * @see org.richfaces.cdk.model.ModelElement#getType()
- */
- public Key getKey() {
- return type;
- }
+ public Listener(Key type) {
+ this.type = type;
+ }
+ @Override
+ public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) throws CdkException {
+ return visitor.visit(this, param);
+ }
- @Override
- public void merge(Listener other) {
- // TODO Auto-generated method stub
-
- }
+ /*
+ * (non-Javadoc)
+ * @see org.richfaces.cdk.model.ModelElement#getType()
+ */
+ public Key getKey() {
+ return type;
+ }
+ @Override
+ public void merge(Listener other) {
+
+ // TODO Auto-generated method stub
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Merge.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Merge.java 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Merge.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.model;
import java.lang.annotation.ElementType;
@@ -38,11 +40,10 @@
@Target({ElementType.METHOD})
@Inherited
public @interface Merge {
-
- /**
- * <p class="changed_added_4_0">If true, target value should be overwritten, otherwise only null values will bw replaced.</p>
- * @return
- */
- boolean value() default true;
+ /**
+ * <p class="changed_added_4_0">If true, target value should be overwritten, otherwise only null values will bw replaced.</p>
+ * @return
+ */
+ boolean value() default true;
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Mergeable.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Mergeable.java 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Mergeable.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -1,7 +1,5 @@
package org.richfaces.cdk.model;
public interface Mergeable<T> {
-
- public void merge(T other);
-
-}
\ No newline at end of file
+ public void merge(T other);
+}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ModelCollection.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ModelCollection.java 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ModelCollection.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.model;
import java.util.Collection;
@@ -36,163 +38,172 @@
* <p class="changed_added_4_0">
* Base class for all model collections.
* </p>
- *
+ *
* @author asmirnov(a)exadel.com
- *
+ *
*/
-public abstract class ModelCollection<E extends ModelElement<E,K>, K extends Key>
- implements SearchableCollection<E, K>, Visitable,
- Mergeable<SearchableCollection<E, K>> {
+public abstract class ModelCollection<E extends ModelElement<E, K>, K extends Key>
+ implements SearchableCollection<E, K>, Visitable, Mergeable<SearchableCollection<E, K>> {
+ private final BiMap<K, E> elementsMap = HashBiMap.create();
+ private final BiMap<E, K> reverseMap = elementsMap.inverse();
- @SuppressWarnings("unused")
- private final class SearchPredicate implements Predicate<E> {
+ // TODO -provide factory methods.
+ // private final Method factoryMethod;
+ @Override
+ public E find(final K key) {
+ if (null != key) {
+ return elementsMap.get(key);
+ } else {
+ return null;
+ }
+ }
- private final K key;
+ @Override
+ public E findOrCreate(K key) {
+ E element = find(key);
- private SearchPredicate(K key) {
- this.key = key;
- }
+ if (null == element) {
+ element = create(key);
+ elementsMap.put(key, element);
+ }
- @Override
- public boolean apply(E input) {
- return key.equals(input.getKey());
- }
- }
+ return element;
+ }
- private final BiMap<K, E> elementsMap = HashBiMap.create();
-
- private final BiMap<E, K> reverseMap = elementsMap.inverse();
+ @Override
+ public Iterable<K> keys() {
+ return elementsMap.keySet();
+ }
- // TODO -provide factory methods.
- // private final Method factoryMethod;
+ @Override
+ public boolean add(E e) {
+ E old = elementsMap.put(e.getKey(), e);
- @Override
- public E find(final K key) {
- if (null != key) {
- return elementsMap.get(key);
- } else {
- return null;
- }
- }
+ if (null != old) {
- @Override
- public E findOrCreate(K key) {
- E element = find(key);
- if (null == element) {
- element = create(key);
- elementsMap.put(key,element);
- }
- return element;
- }
+ // TODO - merge values ?
+ }
- @Override
- public Iterable<K> keys() {
- return elementsMap.keySet();
- }
+ return null != old;
+ }
- @Override
- public boolean add(E e) {
- E old = elementsMap.put(e.getKey(),e);
- if(null != old){
- // TODO - merge values ?
- }
- return null != old;
- }
+ @Override
+ public boolean addAll(Collection<? extends E> c) {
+ boolean changed = false;
- @Override
- public boolean addAll(Collection<? extends E> c) {
- boolean changed = false;
- for (E e : c) {
- changed |= add(e);
- }
- return changed;
- }
+ for (E e : c) {
+ changed |= add(e);
+ }
- @Override
- public void clear() {
- elementsMap.clear();
- }
+ return changed;
+ }
- @SuppressWarnings("unchecked")
- @Override
- public boolean contains(Object o) {
- if (o instanceof ModelElement<?,?>) {
- K key = ((ModelElement<E,K>) o).getKey();
- return elementsMap.containsKey(key);
- }
- return false;
- }
+ @Override
+ public void clear() {
+ elementsMap.clear();
+ }
- @Override
- public boolean containsAll(Collection<?> c) {
- return elementsMap.values().containsAll(c);
- }
+ @SuppressWarnings("unchecked")
+ @Override
+ public boolean contains(Object o) {
+ if (o instanceof ModelElement<?, ?>) {
+ K key = ((ModelElement<E, K>) o).getKey();
- @Override
- public boolean isEmpty() {
- return elementsMap.isEmpty();
- }
+ return elementsMap.containsKey(key);
+ }
- @Override
- public Iterator<E> iterator() {
- return elementsMap.values().iterator();
- }
+ return false;
+ }
- @Override
- public boolean remove(Object o) {
- return null != reverseMap.remove(o);
- }
+ @Override
+ public boolean containsAll(Collection<?> c) {
+ return elementsMap.values().containsAll(c);
+ }
- @Override
- public boolean removeAll(Collection<?> c) {
- boolean changed = false;
- for (Object e : c) {
- changed |= remove(e);
- }
- return changed;
- }
+ @Override
+ public boolean isEmpty() {
+ return elementsMap.isEmpty();
+ }
- @Override
- public boolean retainAll(Collection<?> c) {
-// return elements.retainAll(c);
- return false;
- }
+ @Override
+ public Iterator<E> iterator() {
+ return elementsMap.values().iterator();
+ }
- @Override
- public int size() {
- return elementsMap.size();
- }
+ @Override
+ public boolean remove(Object o) {
+ return null != reverseMap.remove(o);
+ }
- @Override
- public Object[] toArray() {
- return elementsMap.values().toArray();
- }
+ @Override
+ public boolean removeAll(Collection<?> c) {
+ boolean changed = false;
- @Override
- public <T> T[] toArray(T[] a) {
- return elementsMap.values().toArray(a);
- }
+ for (Object e : c) {
+ changed |= remove(e);
+ }
- public <R, P> R accept(
- org.richfaces.cdk.model.LibraryVisitor<R, P> visitor, P param) throws CdkException {
- R result = null;
- Iterator<E> iterator = iterator();
- while (null == result && iterator.hasNext()) {
- result = iterator.next().accept(visitor, param);
- }
- return result;
- };
+ return changed;
+ }
- @Override
- public void merge(SearchableCollection<E, K> other) {
- for (E element : other) {
- K key = element.getKey();
- E old = find(key);
- if (null == old) {
- elementsMap.put(key,element);
- } else {
- old.merge(element);
- }
- }
- }
+ @Override
+ public boolean retainAll(Collection<?> c) {
+
+// return elements.retainAll(c);
+ return false;
+ }
+
+ @Override
+ public int size() {
+ return elementsMap.size();
+ }
+
+ @Override
+ public Object[] toArray() {
+ return elementsMap.values().toArray();
+ }
+
+ @Override
+ public <T> T[] toArray(T[] a) {
+ return elementsMap.values().toArray(a);
+ }
+
+ public <R, P> R accept(org.richfaces.cdk.model.LibraryVisitor<R, P> visitor, P param) throws CdkException {
+ R result = null;
+ Iterator<E> iterator = iterator();
+
+ while (null == result && iterator.hasNext()) {
+ result = iterator.next().accept(visitor, param);
+ }
+
+ return result;
+ }
+
+ @Override
+ public void merge(SearchableCollection<E, K> other) {
+ for (E element : other) {
+ K key = element.getKey();
+ E old = find(key);
+
+ if (null == old) {
+ elementsMap.put(key, element);
+ } else {
+ old.merge(element);
+ }
+ }
+ }
+
+ @SuppressWarnings("unused")
+ private final class SearchPredicate implements Predicate<E> {
+ private final K key;
+
+ private SearchPredicate(K key) {
+ this.key = key;
+ }
+
+ @Override
+ public boolean apply(E input) {
+ return key.equals(input.getKey());
+ }
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ModelElement.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ModelElement.java 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ModelElement.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -2,6 +2,5 @@
import java.io.Serializable;
-public interface ModelElement<T extends ModelElement<T, K>,K extends Key> extends Serializable, Mergeable<T>, Searchable<K>, Visitable {
-
-}
\ No newline at end of file
+public interface ModelElement<T extends ModelElement<T, K>, K extends Key>
+ extends Serializable, Mergeable<T>, Searchable<K>, Visitable {}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ModelElementBase.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ModelElementBase.java 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ModelElementBase.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -2,72 +2,71 @@
import javax.xml.bind.annotation.XmlElement;
-import org.richfaces.cdk.model.Component.Type;
+public class ModelElementBase implements DescriptionGroup, Extensible<ConfigExtension> {
-public class ModelElementBase implements DescriptionGroup,Extensible<ConfigExtension> {
+ /**
+ * <p class="changed_added_4_0">
+ * Long description for documentation
+ * </p>
+ */
+ private String description;
- /**
- * <p class="changed_added_4_0">
- * Long description for documentation
- * </p>
- */
- private String description;
- /**
- * <p class="changed_added_4_0">
- * Short name for IDE tools
- * </p>
- */
- private String displayname;
- /**
- * <p class="changed_added_4_0">
- * Icon name for IDE tools
- * </p>
- */
- private Icon icon;
- private ConfigExtension extension;
+ /**
+ * <p class="changed_added_4_0">
+ * Short name for IDE tools
+ * </p>
+ */
+ private String displayname;
+ private ConfigExtension extension;
- public ModelElementBase() {
- super();
- }
+ /**
+ * <p class="changed_added_4_0">
+ * Icon name for IDE tools
+ * </p>
+ */
+ private Icon icon;
- @XmlElement
- public final String getDescription() {
- return description;
- }
+ public ModelElementBase() {
+ super();
+ }
- public final void setDescription(String description) {
- this.description = description;
- }
+ @XmlElement
+ public final String getDescription() {
+ return description;
+ }
- @XmlElement(name = "display-name")
- public final String getDisplayname() {
- return displayname;
- }
+ public final void setDescription(String description) {
+ this.description = description;
+ }
- public final void setDisplayname(String displayname) {
- this.displayname = displayname;
- }
+ @XmlElement(name = "display-name")
+ public final String getDisplayname() {
+ return displayname;
+ }
- @XmlElement
- public final Icon getIcon() {
- return icon;
- }
+ public final void setDisplayname(String displayname) {
+ this.displayname = displayname;
+ }
- public final void setIcon(Icon icon) {
- this.icon = icon;
- }
+ @XmlElement
+ public final Icon getIcon() {
+ return icon;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the extension
- */
- @XmlElement(name = "component-extensions")
- public final ConfigExtension getExtension() {
- return extension;
- }
+ public final void setIcon(Icon icon) {
+ this.icon = icon;
+ }
- public final void setExtension(ConfigExtension extension) {
- this.extension = extension;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the extension
+ */
+ @XmlElement(name = "component-extensions")
+ public final ConfigExtension getExtension() {
+ return extension;
+ }
-}
\ No newline at end of file
+ public final void setExtension(ConfigExtension extension) {
+ this.extension = extension;
+ }
+}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Name.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Name.java 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Name.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.model;
import java.util.regex.Pattern;
@@ -30,243 +32,248 @@
* Represents parts of component type/family/classname according to CDK naming
* conventions.
* </p>
- *
+ *
* @author asmirnov(a)exadel.com
- *
+ *
*/
public class Name {
+ private static final Pattern NAME_PATTERN = Pattern.compile("^(?:(.+)\\.)?(?:(" + Classifier.component + "|"
+ + Classifier.renderkit + "|" + Classifier.event + "|"
+ + Classifier.taglib + ")\\.(?:([^\\.]+)\\.)?)?([^\\.]+)$");
- /**
- * <p class="changed_added_4_0">
- * Standard package names for components, renderers, event listeners and taglib.
- * </p>
- *
- * @author asmirnov(a)exadel.com
- *
- */
- public enum Classifier {
- /**
- * <p class="changed_added_4_0"></p>
- */
- component,
- /**
- * <p class="changed_added_4_0"></p>
- */
- renderkit,
- /**
- * <p class="changed_added_4_0"></p>
- */
- event,
- /**
- * <p class="changed_added_4_0"></p>
- */
- taglib;
- }
+ /**
+ * <p class="changed_added_4_0">
+ * Element type classifier - "component","event","renderkit","taglib"
+ * </p>
+ */
+ private Classifier classifier;
- private static final Pattern namePattern = Pattern
- .compile("^(?:(.+)\\.)?(?:(" + Classifier.component + "|"
- + Classifier.renderkit + "|" + Classifier.event + "|"
- + Classifier.taglib + ")\\.(?:([^\\.]+)\\.)?)?([^\\.]+)$");
+ /**
+ * <p class="changed_added_4_0">
+ * Markup-specific part of name ( "html","xhtml","wml" ... )
+ * </p>
+ */
+ private String markup;
- /**
- * <p class="changed_added_4_0">
- * represents library part prefix of name.
- * </p>
- */
- private String prefix;
+ /**
+ * <p class="changed_added_4_0">
+ * represents library part prefix of name.
+ * </p>
+ */
+ private String prefix;
- /**
- * <p class="changed_added_4_0">
- * Element type classifier - "component","event","renderkit","taglib"
- * </p>
- */
- private Classifier classifier;
+ /**
+ * <p class="changed_added_4_0">
+ * Simple name ( last word after a period ).
+ * </p>
+ */
+ private String simpleName;
- /**
- * <p class="changed_added_4_0">
- * Markup-specific part of name ( "html","xhtml","wml" ... )
- * </p>
- */
- private String markup;
+ /**
+ * <p class="changed_added_4_0">
+ * Standard package names for components, renderers, event listeners and taglib.
+ * </p>
+ *
+ * @author asmirnov(a)exadel.com
+ *
+ */
+ public enum Classifier {
- /**
- * <p class="changed_added_4_0">
- * Simple name ( last word after a period ).
- * </p>
- */
- private String simpleName;
+ /**
+ * <p class="changed_added_4_0"></p>
+ */
+ component,
- /**
- * <p class="changed_added_4_0">
- * Creates RichFaces name representation from string.
- * </p>
- *
- * @param name
- * @return
- * @throws InvalidNameException
- */
- public static Name create(String name) throws InvalidNameException {
- Name cdkName = new Name();
- StringBuilder prefix = new StringBuilder(name.length());
- String[] parts = name.split("\\.");
- cdkName.setSimpleName(parts[parts.length - 1]);
- if (parts.length > 1) {
- try {
- cdkName.setClassifier(Classifier
- .valueOf(parts[parts.length - 2]));
- fillPrefix(prefix, parts, parts.length - 2);
- } catch (IllegalArgumentException e) {
- if (parts.length > 2) {
- try {
- cdkName.setClassifier(Classifier
- .valueOf(parts[parts.length - 3]));
- fillPrefix(prefix, parts, parts.length - 3);
- cdkName.setMarkup(parts[parts.length - 2]);
- } catch (IllegalArgumentException e1) {
- fillPrefix(prefix, parts, parts.length - 1);
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ */
+ renderkit,
- } else {
- prefix.append(parts[0]);
- }
- }
- if (prefix.length() > 0) {
- cdkName.setPrefix(prefix.toString());
- }
- }
- return cdkName;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ */
+ event,
- /**
- * <p class="changed_added_4_0">Utility method that composes library prefix from first elements of array</p>
- * @param prefix buffer that collects prefix.
- * @param parts package name parts
- * @param size size of prefix part of array.
- */
- private static void fillPrefix(StringBuilder prefix, String[] parts,
- int size) {
- for (int i = 0; i < size; i++) {
- if (i != 0) {
- prefix.append('.');
- }
- prefix.append(parts[i]);
- }
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ */
+ taglib;
+ }
- public static Name create(String prefix, String name)
- throws InvalidNameException {
- Name cdkName = create(name);
- if (prefix.equals(cdkName.getPrefix())) {
- return new Name();
- } else {
- throw new InvalidNameException("Nape " + name
- + " does not start with prefix " + prefix);
- }
- }
+ /**
+ * <p class="changed_added_4_0">
+ * Creates RichFaces name representation from string.
+ * </p>
+ *
+ * @param name
+ * @return
+ * @throws InvalidNameException
+ */
+ public static Name create(String name) throws InvalidNameException {
+ Name cdkName = new Name();
+ StringBuilder prefix = new StringBuilder(name.length());
+ String[] parts = name.split("\\.");
- public static Name create(String prefix, Classifier classifier, String name)
- throws InvalidNameException {
- return new Name();
- }
+ cdkName.setSimpleName(parts[parts.length - 1]);
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @return the prefix
- */
- public String getPrefix() {
- return prefix;
- }
+ if (parts.length > 1) {
+ try {
+ cdkName.setClassifier(Classifier.valueOf(parts[parts.length - 2]));
+ fillPrefix(prefix, parts, parts.length - 2);
+ } catch (IllegalArgumentException e) {
+ if (parts.length > 2) {
+ try {
+ cdkName.setClassifier(Classifier.valueOf(parts[parts.length - 3]));
+ fillPrefix(prefix, parts, parts.length - 3);
+ cdkName.setMarkup(parts[parts.length - 2]);
+ } catch (IllegalArgumentException e1) {
+ fillPrefix(prefix, parts, parts.length - 1);
+ }
+ } else {
+ prefix.append(parts[0]);
+ }
+ }
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @param prefix
- * the prefix to set
- */
- public void setPrefix(String prefix) {
- this.prefix = prefix;
- }
+ if (prefix.length() > 0) {
+ cdkName.setPrefix(prefix.toString());
+ }
+ }
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @return the classifier
- */
- public Classifier getClassifier() {
- return classifier;
- }
+ return cdkName;
+ }
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @param classifier
- * the classifier to set
- */
- public void setClassifier(Classifier classifier) {
- this.classifier = classifier;
- }
+ /**
+ * <p class="changed_added_4_0">Utility method that composes library prefix from first elements of array</p>
+ * @param prefix buffer that collects prefix.
+ * @param parts package name parts
+ * @param size size of prefix part of array.
+ */
+ private static void fillPrefix(StringBuilder prefix, String[] parts, int size) {
+ for (int i = 0; i < size; i++) {
+ if (i != 0) {
+ prefix.append('.');
+ }
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @return the markup
- */
- public String getMarkup() {
- return markup;
- }
+ prefix.append(parts[i]);
+ }
+ }
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @param markup
- * the markup to set
- */
- public void setMarkup(String markup) {
- this.markup = markup;
- }
+ public static Name create(String prefix, String name) throws InvalidNameException {
+ Name cdkName = create(name);
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @return the simpleName
- */
- public String getSimpleName() {
- return simpleName;
- }
+ if (prefix.equals(cdkName.getPrefix())) {
+ return new Name();
+ } else {
+ throw new InvalidNameException("Nape " + name + " does not start with prefix " + prefix);
+ }
+ }
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @param simpleName
- * the simpleName to set
- */
- public void setSimpleName(String simpleName) {
- this.simpleName = simpleName;
- }
-
- @Override
- public String toString() {
- StringBuilder result = new StringBuilder();
- if(null != prefix){
- result.append(prefix).append('.');
- }
- if(null != classifier){
- result.append(classifier).append('.');
- }
- if(null != markup){
- result.append(markup).append('.');
- }
- result.append(simpleName);
- return result.toString();
- }
+ public static Name create(String prefix, Classifier classifier, String name) throws InvalidNameException {
+ return new Name();
+ }
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @return the prefix
+ */
+ public String getPrefix() {
+ return prefix;
+ }
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param prefix
+ * the prefix to set
+ */
+ public void setPrefix(String prefix) {
+ this.prefix = prefix;
+ }
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @return the classifier
+ */
+ public Classifier getClassifier() {
+ return classifier;
+ }
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param classifier
+ * the classifier to set
+ */
+ public void setClassifier(Classifier classifier) {
+ this.classifier = classifier;
+ }
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @return the markup
+ */
+ public String getMarkup() {
+ return markup;
+ }
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param markup
+ * the markup to set
+ */
+ public void setMarkup(String markup) {
+ this.markup = markup;
+ }
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @return the simpleName
+ */
+ public String getSimpleName() {
+ return simpleName;
+ }
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param simpleName
+ * the simpleName to set
+ */
+ public void setSimpleName(String simpleName) {
+ this.simpleName = simpleName;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder result = new StringBuilder();
+
+ if (null != prefix) {
+ result.append(prefix).append('.');
+ }
+
+ if (null != classifier) {
+ result.append(classifier).append('.');
+ }
+
+ if (null != markup) {
+ result.append(markup).append('.');
+ }
+
+ result.append(simpleName);
+
+ return result.toString();
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Properties.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Properties.java 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Properties.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.model;
import java.util.List;
@@ -33,23 +35,21 @@
*
*/
public class Properties {
-
- private List<? extends Property> properties = Lists.newArrayList();
+ private List<? extends Property> properties = Lists.newArrayList();
- /**
- * <p class="changed_added_4_0"></p>
- * @return the properties
- */
- public List<? extends Property> getProperties() {
- return properties;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the properties
+ */
+ public List<? extends Property> getProperties() {
+ return properties;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param properties the properties to set
- */
- public void setProperties(List<? extends Property> properties) {
- this.properties = properties;
- }
-
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param properties the properties to set
+ */
+ public void setProperties(List<? extends Property> properties) {
+ this.properties = properties;
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Property.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Property.java 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Property.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -19,313 +19,283 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.richfaces.cdk.model;
-import java.util.List;
-import java.util.Set;
-import org.richfaces.cdk.CdkException;
-import org.richfaces.cdk.util.Strings;
+package org.richfaces.cdk.model;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
+import org.richfaces.cdk.CdkException;
+
+import java.util.List;
+import java.util.Set;
+
/**
* That class represents JSF component property.
* @author asmirnov(a)exadel.com
*
*/
@SuppressWarnings("serial")
-public class Property extends ModelElementBase implements ModelElement<Property,Property.Name> {
-
- public static final class Name extends Key {
-
- public Name(String name) {
- super(name);
- }
- }
- /**
- * <p class="changed_added_4_0">Bean property name of component attribute</p>
- */
- private final Name name;
-
-
- private ClassDescription type;
-
- /**
- * <p class="changed_added_4_0">Is that bean property generate in the class or should be generated ?</p>
- */
- private boolean generate=false;
-
- private boolean hidden=false;
-
- private boolean literal=false;
-
- private boolean required=false;
-
- private boolean readOnly = false;
+public class Property extends ModelElementBase implements ModelElement<Property, Property.Name> {
- private String defaultValue;
-
- private String suggestedValue;
-
- private boolean passThrough=false;
+ /**
+ * <p class="changed_added_4_0">Is that bean property generate in the class or should be generated ?</p>
+ */
+ private boolean generate = false;
+ private boolean hidden = false;
+ private boolean literal = false;
+ private boolean required = false;
+ private boolean readOnly = false;
+ private boolean passThrough = false;
+ private Set<EventName> eventNames = Sets.newHashSet();
+ private List<ClassDescription> signature = Lists.newArrayList();
+ private Set<String> aliases = Sets.newHashSet();
+ private String defaultValue;
- private Set<EventName> eventNames = Sets.newHashSet();
-
- private List<ClassDescription> signature = Lists.newArrayList();
-
- private Set<String> aliases = Sets.newHashSet();
-
- /**
- * <p class="changed_added_4_0"></p>
- * @param name
- */
- public Property(Name name) {
- if(null==name){
- throw new NullPointerException();
- }
- this.name = name;
- }
+ /**
+ * <p class="changed_added_4_0">Bean property name of component attribute</p>
+ */
+ private final Name name;
+ private String suggestedValue;
+ private ClassDescription type;
-
- @Override
- public Name getKey() {
- return name;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param name
+ */
+ public Property(Name name) {
+ if (null == name) {
+ throw new NullPointerException();
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the name
- */
- public Name getName() {
- return name;
- }
+ this.name = name;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the type
- */
- @Merge
- public ClassDescription getType() {
- return type;
- }
+ @Override
+ public Name getKey() {
+ return name;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param type the type to set
- */
- public void setType(ClassDescription type) {
- this.type = type;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the name
+ */
+ public Name getName() {
+ return name;
+ }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the type
+ */
+ @Merge
+ public ClassDescription getType() {
+ return type;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the defaultValue
- */
- @Merge
- public String getDefaultValue() {
- return defaultValue;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param type the type to set
+ */
+ public void setType(ClassDescription type) {
+ this.type = type;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param defaultValue the defaultValue to set
- */
- public void setDefaultValue(String dafaultValue) {
- this.defaultValue = dafaultValue;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the defaultValue
+ */
+ @Merge
+ public String getDefaultValue() {
+ return defaultValue;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the suggestedValue
- */
- @Merge
- public String getSuggestedValue() {
- return suggestedValue;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param defaultValue the defaultValue to set
+ */
+ public void setDefaultValue(String dafaultValue) {
+ this.defaultValue = dafaultValue;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param suggestedValue the suggestedValue to set
- */
- public void setSuggestedValue(String suggestedValue) {
- this.suggestedValue = suggestedValue;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the suggestedValue
+ */
+ @Merge
+ public String getSuggestedValue() {
+ return suggestedValue;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the generate
- */
- @Merge
- public boolean isGenerate() {
- return generate;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param suggestedValue the suggestedValue to set
+ */
+ public void setSuggestedValue(String suggestedValue) {
+ this.suggestedValue = suggestedValue;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param generate the generate to set
- */
- public void setGenerate(boolean exists) {
- this.generate = exists;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the generate
+ */
+ @Merge
+ public boolean isGenerate() {
+ return generate;
+ }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param generate the generate to set
+ */
+ public void setGenerate(boolean exists) {
+ this.generate = exists;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the eventNames
- */
- @Merge
- public Set<EventName> getEventNames() {
- return eventNames;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the eventNames
+ */
+ @Merge
+ public Set<EventName> getEventNames() {
+ return eventNames;
+ }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param eventNames the eventNames to set
+ */
+ public void setEventNames(Set<EventName> eventNames) {
+ this.eventNames = eventNames;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param eventNames the eventNames to set
- */
- public void setEventNames(Set<EventName> eventNames) {
- this.eventNames = eventNames;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the hidden
+ */
+ public boolean isHidden() {
+ return hidden;
+ }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param hidden the hidden to set
+ */
+ public void setHidden(boolean hidden) {
+ this.hidden = hidden;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the hidden
- */
- public boolean isHidden() {
- return hidden;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the literal
+ */
+ public boolean isLiteral() {
+ return literal;
+ }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param literal the literal to set
+ */
+ public void setLiteral(boolean literal) {
+ this.literal = literal;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param hidden the hidden to set
- */
- public void setHidden(boolean hidden) {
- this.hidden = hidden;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the required
+ */
+ public boolean isRequired() {
+ return required;
+ }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param required the required to set
+ */
+ public void setRequired(boolean required) {
+ this.required = required;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the literal
- */
- public boolean isLiteral() {
- return literal;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param readOnly the readOnly to set
+ */
+ public void setReadOnly(boolean readOnly) {
+ this.readOnly = readOnly;
+ }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the readOnly
+ */
+ public boolean isReadOnly() {
+ return readOnly;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param literal the literal to set
- */
- public void setLiteral(boolean literal) {
- this.literal = literal;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the passThrough
+ */
+ public boolean isPassThrough() {
+ return passThrough;
+ }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param passThrough the passThrough to set
+ */
+ public void setPassThrough(boolean passThrough) {
+ this.passThrough = passThrough;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the required
- */
- public boolean isRequired() {
- return required;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the signature
+ */
+ @Merge(true)
+ public List<ClassDescription> getSignature() {
+ return signature;
+ }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param signature the signature to set
+ */
+ public void setSignature(List<ClassDescription> signature) {
+ this.signature = signature;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param required the required to set
- */
- public void setRequired(boolean required) {
- this.required = required;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the aliases
+ */
+ public Set<String> getAliases() {
+ return aliases;
+ }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param aliases the aliases to set
+ */
+ public void setAliases(Set<String> aliases) {
+ this.aliases = aliases;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param readOnly the readOnly to set
- */
- public void setReadOnly(boolean readOnly) {
- this.readOnly = readOnly;
- }
+ @Override
+ public void merge(Property other) {
+ ComponentLibrary.merge(this, other);
+ }
+ @Override
+ public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) throws CdkException {
+ return visitor.visit(this, param);
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the readOnly
- */
- public boolean isReadOnly() {
- return readOnly;
- }
-
-
- /**
- * <p class="changed_added_4_0"></p>
- * @return the passThrough
- */
- public boolean isPassThrough() {
- return passThrough;
- }
-
-
- /**
- * <p class="changed_added_4_0"></p>
- * @param passThrough the passThrough to set
- */
- public void setPassThrough(boolean passThrough) {
- this.passThrough = passThrough;
- }
-
-
- /**
- * <p class="changed_added_4_0"></p>
- * @return the signature
- */
- @Merge(true)
- public List<ClassDescription> getSignature() {
- return signature;
- }
-
-
- /**
- * <p class="changed_added_4_0"></p>
- * @param signature the signature to set
- */
- public void setSignature(List<ClassDescription> signature) {
- this.signature = signature;
- }
-
-
- /**
- * <p class="changed_added_4_0"></p>
- * @return the aliases
- */
- public Set<String> getAliases() {
- return aliases;
- }
-
-
- /**
- * <p class="changed_added_4_0"></p>
- * @param aliases the aliases to set
- */
- public void setAliases(Set<String> aliases) {
- this.aliases = aliases;
- }
-
-
- @Override
- public void merge(Property other) {
- ComponentLibrary.merge(this, other);
- }
-
- @Override
- public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) throws CdkException {
- return visitor.visit(this, param);
- }
-
+ public static final class Name extends Key {
+ public Name(String name) {
+ super(name);
+ }
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/RenderKit.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/RenderKit.java 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/RenderKit.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.model;
import java.util.Collection;
@@ -35,138 +37,142 @@
*
*/
@SuppressWarnings("serial")
-public class RenderKit extends ModelElementBase implements ModelElement<RenderKit,RenderKit.Id> {
+public class RenderKit extends ModelElementBase implements ModelElement<RenderKit, RenderKit.Id> {
+ private final SearchableCollection<Renderer, Renderer.Type> renderers = new ModelCollection<Renderer,
+ Renderer.Type>() {
+ @Override
+ public Renderer create(Renderer.Type key) {
+ Renderer renderer = new Renderer(key);
- /**
- * <p class="changed_added_4_0"></p>
- * @author asmirnov(a)exadel.com
- *
- */
- @SuppressWarnings("serial")
- public static final class Id extends Key {
+ return renderer;
+ }
+ };
+ private final SearchableCollection<BehaviorRenderer, BehaviorRenderer.Type> behaviorRenderers =
+ new ModelCollection<BehaviorRenderer, BehaviorRenderer.Type>() {
+ @Override
+ public BehaviorRenderer create(BehaviorRenderer.Type key) {
+ return new BehaviorRenderer(key);
+ }
+ };
- /**
- * <p class="changed_added_4_0"></p>
- * @param id
- */
- public Id(String type) {
- // Null value means default render kit.
- super(null==type?RenderKitFactory.HTML_BASIC_RENDER_KIT:type);
- }
+ private final Id id;
+ private ClassDescription renderKitClass;
- public String getId(){
- return super.getType();
- }
- }
+ public RenderKit(Id id) {
+ this.id = id;
+ }
- private final Id id;
-
- private ClassDescription renderKitClass;
-
- private final SearchableCollection<Renderer,Renderer.Type> renderers = new ModelCollection<Renderer, Renderer.Type>() {
+ /*
+ * (non-Javadoc)
+ * @see org.richfaces.cdk.model.ModelElement#getType()
+ */
+ @Override
+ public Id getKey() {
+ return getId();
+ }
- @Override
- public Renderer create(Renderer.Type key) {
- Renderer renderer = new Renderer(key);
- return renderer;
- }
- };
-
- private final SearchableCollection<BehaviorRenderer,BehaviorRenderer.Type> behaviorRenderers = new ModelCollection<BehaviorRenderer, BehaviorRenderer.Type>() {
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the id
+ */
+ public Id getId() {
+ return id;
+ }
- @Override
- public BehaviorRenderer create(BehaviorRenderer.Type key) {
- BehaviorRenderer renderer = new BehaviorRenderer(key);
- return renderer;
- }
- };
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the renderKitClass
+ */
+ @Merge
+ public ClassDescription getRenderKitClass() {
+ return renderKitClass;
+ }
- public RenderKit(Id id) {
- this.id = id;
- }
-
- /* (non-Javadoc)
- * @see org.richfaces.cdk.model.ModelElement#getType()
- */
- @Override
- public Id getKey() {
- return getId();
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param renderKitClass the renderKitClass to set
+ */
+ public void setRenderKitClass(ClassDescription renderKitClass) {
+ this.renderKitClass = renderKitClass;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the id
- */
- public Id getId() {
- return id;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the renderers
+ */
+ public Collection<Renderer> getRenderers() {
+ return renderers;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the renderKitClass
- */
- @Merge
- public ClassDescription getRenderKitClass() {
- return renderKitClass;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the behaviorRenderers
+ */
+ public SearchableCollection<BehaviorRenderer, BehaviorRenderer.Type> getBehaviorRenderers() {
+ return behaviorRenderers;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param renderKitClass the renderKitClass to set
- */
- public void setRenderKitClass(ClassDescription renderKitClass) {
- this.renderKitClass = renderKitClass;
- }
+ /*
+ * (non-Javadoc)
+ * @see org.richfaces.cdk.model.ModelElement#accept(org.richfaces.cdk.model.LibraryVisitor, java.lang.Object)
+ */
+ @Override
+ public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) throws CdkException {
+ R result = visitor.visit(this, param);
- /**
- * <p class="changed_added_4_0"></p>
- * @return the renderers
- */
- public Collection<Renderer> getRenderers() {
- return renderers;
- }
+ return ComponentLibrary.accept(renderers, visitor, param, result);
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the behaviorRenderers
- */
- public SearchableCollection<BehaviorRenderer, BehaviorRenderer.Type> getBehaviorRenderers() {
- return behaviorRenderers;
- }
+ @Override
+ public void merge(RenderKit other) {
+ renderers.merge(other.renderers);
+ ComponentLibrary.merge(this, other);
+ }
- /* (non-Javadoc)
- * @see org.richfaces.cdk.model.ModelElement#accept(org.richfaces.cdk.model.LibraryVisitor, java.lang.Object)
- */
- @Override
- public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) throws CdkException {
- R result = visitor.visit(this, param);
- return ComponentLibrary.accept(renderers, visitor, param, result);
- }
+ public Renderer getOrCreateRenderer(String rendererType) {
+ Renderer.Type type = new Renderer.Type(rendererType);
- @Override
- public void merge(RenderKit other) {
- renderers.merge(other.renderers);
- ComponentLibrary.merge(this, other);
- }
+ return renderers.find(type);
+ }
- public Renderer getOrCreateRenderer(String rendererType) {
- Renderer.Type type = new Renderer.Type(rendererType);
- return renderers.find(type);
- }
+ public Renderer findOrCreateRenderer(String rendererType) {
+ Renderer.Type type = new Renderer.Type(rendererType);
- public Renderer findOrCreateRenderer(String rendererType) {
- Renderer.Type type = new Renderer.Type(rendererType);
- return renderers.findOrCreate(type);
- }
-
- public BehaviorRenderer getOrCreateBehaviorRenderer(String rendererType) {
- BehaviorRenderer.Type type = new BehaviorRenderer.Type(rendererType);
- return behaviorRenderers.find(type);
- }
+ return renderers.findOrCreate(type);
+ }
- public BehaviorRenderer findOrCreateBehaviorRenderer(String rendererType) {
- BehaviorRenderer.Type type = new BehaviorRenderer.Type(rendererType);
- return behaviorRenderers.findOrCreate(type);
- }
-
+ public BehaviorRenderer getOrCreateBehaviorRenderer(String rendererType) {
+ BehaviorRenderer.Type type = new BehaviorRenderer.Type(rendererType);
+
+ return behaviorRenderers.find(type);
+ }
+
+ public BehaviorRenderer findOrCreateBehaviorRenderer(String rendererType) {
+ BehaviorRenderer.Type type = new BehaviorRenderer.Type(rendererType);
+
+ return behaviorRenderers.findOrCreate(type);
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+ @SuppressWarnings("serial")
+ public static final class Id extends Key {
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param id
+ */
+ public Id(String type) {
+
+ // Null value means default render kit.
+ super(null == type ? RenderKitFactory.HTML_BASIC_RENDER_KIT : type);
+ }
+
+ public String getId() {
+ return super.getType();
+ }
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Renderer.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Renderer.java 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Renderer.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.model;
import org.richfaces.builder.model.JavaClass;
@@ -32,118 +34,113 @@
*
*/
@SuppressWarnings("serial")
-public class Renderer extends ModelElementBase implements ModelElement<Renderer,Renderer.Type> {
+public class Renderer extends ModelElementBase implements ModelElement<Renderer, Renderer.Type> {
+ private String family;
+ private ClassDescription rendererClass;
+ private JavaClass template;
+ private Type type;
- private Type type;
-
- private JavaClass template;
-
- private String family;
-
- private ClassDescription rendererClass;
+ public Renderer() {}
-
- public Renderer() {
- }
+ public Renderer(Type type) {
+ this.type = type;
+ }
- public Renderer(Type type) {
- this.type=type;
- }
-
- /* (non-Javadoc)
- * @see org.richfaces.cdk.model.ModelElement#getType()
- */
- public Type getKey() {
- return type;
- }
+ /*
+ * (non-Javadoc)
+ * @see org.richfaces.cdk.model.ModelElement#getType()
+ */
+ public Type getKey() {
+ return type;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param type the type to set
- */
- public void setType(Type type) {
- this.type = type;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param type the type to set
+ */
+ public void setType(Type type) {
+ this.type = type;
+ }
- public Type getType() {
- return type;
- }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the template
- */
- @Merge
- public JavaClass getTemplate() {
- return template;
- }
- /**
- * <p class="changed_added_4_0"></p>
- * @param template the template to set
- */
- public void setTemplate(JavaClass template) {
- this.template = template;
- }
+ public Type getType() {
+ return type;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the family
- */
- @Merge
- public String getFamily() {
- return 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 template
+ */
+ @Merge
+ public JavaClass getTemplate() {
+ return template;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the rendererClass
- */
- public ClassDescription getRendererClass() {
- return rendererClass;
- }
- /**
- * <p class="changed_added_4_0"></p>
- * @param rendererClass the rendererClass to set
- */
- public void setRendererClass(ClassDescription rendererClass) {
- this.rendererClass = rendererClass;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param template the template to set
+ */
+ public void setTemplate(JavaClass template) {
+ this.template = template;
+ }
- @Override
- public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) throws CdkException {
- return visitor.visit(this, param);
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the family
+ */
+ @Merge
+ public String getFamily() {
+ return family;
+ }
- @Override
- public void merge(Renderer other) {
- ComponentLibrary.merge(this, other);
- }
+ /**
+ * <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">Key for lookup renderer in the model.</p>
- * @author asmirnov(a)exadel.com
- *
- */
- @SuppressWarnings("serial")
- public static class Type extends Key {
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the rendererClass
+ */
+ public ClassDescription getRendererClass() {
+ return rendererClass;
+ }
-
- /**
- * <p class="changed_added_4_0"></p>
- * TODO - use family as part of key ?
- * @param type
- */
- public Type(String type) {
- super(type);
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param rendererClass the rendererClass to set
+ */
+ public void setRendererClass(ClassDescription rendererClass) {
+ this.rendererClass = rendererClass;
+ }
+ @Override
+ public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) throws CdkException {
+ return visitor.visit(this, param);
+ }
- }
+ @Override
+ public void merge(Renderer other) {
+ ComponentLibrary.merge(this, other);
+ }
+ /**
+ * <p class="changed_added_4_0">Key for lookup renderer in the model.</p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+ @SuppressWarnings("serial")
+ public static class Type extends Key {
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * TODO - use family as part of key ?
+ * @param type
+ */
+ public Type(String type) {
+ super(type);
+ }
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Searchable.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Searchable.java 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Searchable.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -2,13 +2,12 @@
public interface Searchable<K extends Key> {
- /**
- * <p class="changed_added_4_0">Marker interface for all JSF objects:
- * {@code Validator}, {@code Converter}, {@code Behavior}, {@code
- * FacesListener}</p>
- *
- * @return the type of JSF object.
- */
- public K getKey();
-
-}
\ No newline at end of file
+ /**
+ * <p class="changed_added_4_0">Marker interface for all JSF objects:
+ * {@code Validator}, {@code Converter}, {@code Behavior}, {@code
+ * FacesListener}</p>
+ *
+ * @return the type of JSF object.
+ */
+ public K getKey();
+}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/SearchableCollection.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/SearchableCollection.java 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/SearchableCollection.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.model;
import java.util.Collection;
@@ -30,34 +32,33 @@
* @author asmirnov(a)exadel.com
*
*/
-public interface SearchableCollection<E extends Searchable,K extends Key> extends Collection<E>, Visitable,
-Mergeable<SearchableCollection<E, K>> {
-
- /**
- * <p class="changed_added_4_0">Find element in collection by Key</p>
- * @param key
- * @return element from collection for that key, null if no such element.
- */
- public E find(K key);
-
- /**
- * <p class="changed_added_4_0">Look for ilement in collection by key. If such element exists in collection, return that, otherwise create a new one.</p>
- * @param key
- * @return
- */
- public E findOrCreate(K key);
-
- /**
- * <p class="changed_added_4_0">Factory method used to create a component instance.</p>
- * @param key
- * @return
- */
- E create(K key);
-
- /**
- * <p class="changed_added_4_0">Return collection of all components keys.</p>
- * @return
- */
- public Iterable<K> keys();
+public interface SearchableCollection<E extends Searchable, K extends Key>
+ extends Collection<E>, Visitable, Mergeable<SearchableCollection<E, K>> {
+ /**
+ * <p class="changed_added_4_0">Find element in collection by Key</p>
+ * @param key
+ * @return element from collection for that key, null if no such element.
+ */
+ public E find(K key);
+
+ /**
+ * <p class="changed_added_4_0">Look for ilement in collection by key. If such element exists in collection, return that, otherwise create a new one.</p>
+ * @param key
+ * @return
+ */
+ public E findOrCreate(K key);
+
+ /**
+ * <p class="changed_added_4_0">Factory method used to create a component instance.</p>
+ * @param key
+ * @return
+ */
+ E create(K key);
+
+ /**
+ * <p class="changed_added_4_0">Return collection of all components keys.</p>
+ * @return
+ */
+ public Iterable<K> keys();
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Tag.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Tag.java 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Tag.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.model;
/**
@@ -30,36 +32,83 @@
*/
public class Tag {
- /**
- * <p class="changed_added_4_0">Tag name</p>
- */
- private String name;
+ /**
+ * <p class="changed_added_4_0">Component that the tag creates. This in bidirectional one to one relation.</p>
+ * TODO - tag should also works with {@code Validator}, {@code Converter}, {@code Behavior}, {@code FacesListener}
+ */
+ private Searchable component;
- /**
- * <p class="changed_added_4_0">Tag library for which that tag is belong.
- * This is bidirectional many to one relation.</p>
- */
- private TagLibrary library;
+ /**
+ * <p class="changed_added_4_0">Jsp tag class</p>
+ */
+ private String jspClass;
- /**
- * <p class="changed_added_4_0">Facelets VDL tag handler class.</p>
- */
- private String tagHandlerClass;
+ /**
+ * <p class="changed_added_4_0">Tag library for which that tag is belong.
+ * This is bidirectional many to one relation.</p>
+ */
+ private TagLibrary library;
- /**
- * <p class="changed_added_4_0">Facelets VDL tag handler base class for generation.</p>
- */
- private String tagHandlerSuperClass;
+ /**
+ * <p class="changed_added_4_0">Tag name</p>
+ */
+ private String name;
- /**
- * <p class="changed_added_4_0">Jsp tag class</p>
- */
- private String jspClass;
-
- /**
- * <p class="changed_added_4_0">Component that the tag creates. This in bidirectional one to one relation.</p>
- * TODO - tag should also works with {@code Validator}, {@code Converter}, {@code Behavior}, {@code FacesListener}
- */
- private Searchable component;
+ /**
+ * <p class="changed_added_4_0">Facelets VDL tag handler class.</p>
+ */
+ private String tagHandlerClass;
+ /**
+ * <p class="changed_added_4_0">Facelets VDL tag handler base class for generation.</p>
+ */
+ private String tagHandlerSuperClass;
+
+ public Searchable getComponent() {
+ return component;
+ }
+
+ public void setComponent(Searchable component) {
+ this.component = component;
+ }
+
+ public String getJspClass() {
+ return jspClass;
+ }
+
+ public void setJspClass(String jspClass) {
+ this.jspClass = jspClass;
+ }
+
+ public TagLibrary getLibrary() {
+ return library;
+ }
+
+ public void setLibrary(TagLibrary library) {
+ this.library = library;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getTagHandlerClass() {
+ return tagHandlerClass;
+ }
+
+ public void setTagHandlerClass(String tagHandlerClass) {
+ this.tagHandlerClass = tagHandlerClass;
+ }
+
+ public String getTagHandlerSuperClass() {
+ return tagHandlerSuperClass;
+ }
+
+ public void setTagHandlerSuperClass(String tagHandlerSuperClass) {
+ this.tagHandlerSuperClass = tagHandlerSuperClass;
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/TagLibrary.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/TagLibrary.java 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/TagLibrary.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.model;
import java.util.ArrayList;
@@ -32,19 +34,17 @@
*
*/
public class TagLibrary {
-
- /**
- * <p class="changed_added_4_0">Collection of tags associated with that library</p>
- */
- private final List<Tag> tags = new ArrayList<Tag>();
-
- /**
- * <p class="changed_added_4_0"></p>
- * @return the tags
- */
- public List<Tag> getTags() {
- return tags;
- }
+ /**
+ * <p class="changed_added_4_0">Collection of tags associated with that library</p>
+ */
+ private final List<Tag> tags = new ArrayList<Tag>();
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the tags
+ */
+ public List<Tag> getTags() {
+ return tags;
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Trackable.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Trackable.java 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Trackable.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -7,10 +7,9 @@
*/
public interface Trackable {
- /**
- * <p class="changed_added_4_0">Last modification time for model information.</p>
- * @return
- */
- public long lastModified();
-
+ /**
+ * <p class="changed_added_4_0">Last modification time for model information.</p>
+ * @return
+ */
+ public long lastModified();
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Validator.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Validator.java 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Validator.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.model;
import org.richfaces.cdk.CdkException;
@@ -31,34 +33,33 @@
*
*/
@SuppressWarnings("serial")
-public class Validator implements ModelElement<Validator,Key> {
+public class Validator implements ModelElement<Validator, Key> {
+ private final Key type;
- private final Key type;
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param type the type to set
+ */
+ public Validator(Key type) {
+ this.type = type;
+ }
- @Override
- public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) throws CdkException {
- return visitor.visit(this, param);
- }
+ @Override
+ public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) throws CdkException {
+ return visitor.visit(this, param);
+ }
- /* (non-Javadoc)
- * @see org.richfaces.cdk.model.ModelElement#getType()
- */
- public Key getKey() {
- return type;
- }
+ /*
+ * (non-Javadoc)
+ * @see org.richfaces.cdk.model.ModelElement#getType()
+ */
+ public Key getKey() {
+ return type;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param type the type to set
- */
- public Validator(Key type) {
- this.type = type;
- }
+ @Override
+ public void merge(Validator other) {
- @Override
- public void merge(Validator other) {
- // TODO Auto-generated method stub
-
- }
-
+ // TODO Auto-generated method stub
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Visitable.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Visitable.java 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Visitable.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -4,14 +4,13 @@
public interface Visitable {
- /**
- * <p class="changed_added_4_0"></p>
- * @param <R>
- * @param <P>
- * @param visitor
- * @param param
- * @return
- */
- public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) throws CdkException;
-
-}
\ No newline at end of file
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param <R>
+ * @param <P>
+ * @param visitor
+ * @param param
+ * @return
+ */
+ public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) throws CdkException;
+}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/package-info.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/package-info.java 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/package-info.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -1,22 +1,25 @@
/**
* <h2>CDK library model classes used by all generation tasks.</h2>
- * <p>CDK architecture seems like MVC-pattern implementation. The controller {@link org.richfaces.cdk.LibraryBuilder} class
- * generates model from different sources ( Java Annotations, XML files and so on ). That model will be used to generate all necessary
- * classes by the appropriate "renderers" that act as 'View' part of pattern.</p>
+ * <p>CDK architecture seems like MVC-pattern implementation. The controller {@link org.richfaces.cdk.LibraryBuilder}
+ * class generates model from different sources ( Java Annotations, XML files and so on ). That model will be used to
+ * generate all necessary classes by the appropriate "renderers" that act as 'View' part of pattern.</p>
* <p>That model:</p>
* <ul>
* <li>Contains all information about JSF library components and their properties</li>
- * <li>Encapsulates restrictions and references for model components, therefore it should be modified by model metods only.</li>
+ * <li>Encapsulates restrictions and references for model components, therefore it should be modified by model metods
+ * only.</li>
* <li>Encapsulates <a href="http://www.jboss.org/community/docs/DOC-13693">CDK naming conventions</a></li>
* <li>Provides 'Visitor' pattern methods. see {@link LibraryVisitor} for reference.</li>
* </ul>
- *
+ *
*/
@XmlAccessorType(XmlAccessType.NONE)
-(a)javax.xml.bind.annotation.XmlSchema(namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE,
- xmlns = { @javax.xml.bind.annotation.XmlNs( prefix = "cdk",
- namespaceURI = ComponentLibrary.CDK_EXTENSIONS_NAMESPACE ) })
+(a)javax.xml.bind.annotation.XmlSchema(
+ namespace = ComponentLibrary.FACES_CONFIG_NAMESPACE,
+ xmlns = {(a)javax.xml.bind.annotation.XmlNs(prefix = "cdk", namespaceURI = ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)}
+)
package org.richfaces.cdk.model;
+
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAccessType;
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/package-info.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/package-info.java 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/package-info.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -1,7 +1,6 @@
+
/**
* <h2>Public CDK API classes.</h2>
- *
+ *
*/
package org.richfaces.cdk;
-
-
Modified: 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 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/ELReflectionUtils.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -18,6 +18,9 @@
* 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;
@@ -25,10 +28,12 @@
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;
@@ -64,6 +69,7 @@
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;
@@ -97,180 +103,192 @@
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...
+ * Class, that encapsulate all functionality, related to Reflection calls, such as loading classes, get property
+ * descriptors etc...
* @author amarkhel
- *
+ *
*/
-public class ELReflectionUtils {
+public final class ELReflectionUtils {
+ private static final Class<?>[] EMPTY_CLASS_PARAMETERS = new Class<?>[0];
+ private static Map<String, Map<String, PropertyDescriptor>> resolvedProperties =
+ new HashMap<String, Map<String, PropertyDescriptor>>();
- 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.
- */
+ private ELReflectionUtils() { }
+
+ /**
+ * 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;
- }
+ 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.
+ * 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);
- }
+ */
+ 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.
+ * 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;
- }
+ */
+ private static Map<String, PropertyDescriptor> resolveProperties(Class<?> clazz) throws ParsingException {
+ final Map<String, PropertyDescriptor> descriptors = new HashMap<String, PropertyDescriptor>();
- 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;
- }
+ new ClassWalkingLogic(clazz).walk(new ClassVisitor() {
+ public void visit(Class<?> clazz) throws ParsingException {
+ PropertyDescriptor[] pds = getPropertyDescriptors(clazz);
- if (null == clazz) {
- throw new ClassNotFoundException(className);
- }
- return clazz;
- }
-
- private static Map<String, Map<String, PropertyDescriptor>> resolvedProperties =
- new HashMap<String, Map<String,PropertyDescriptor>>();
-
+ 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;
+ }
+
+ /**
* <p>Retrieve the property descriptors for the specified class,
* introspecting and caching them the first time a particular bean class
* is encountered.</p>
@@ -283,8 +301,7 @@
*
* @exception IllegalArgumentException if <code>beanClass</code> is null
*/
- private static PropertyDescriptor[] getPropertyDescriptors(Class<?> beanClass) throws ParsingException {
-
+ private static PropertyDescriptor[] getPropertyDescriptors(Class<?> beanClass) throws ParsingException {
if (beanClass == null) {
throw new IllegalArgumentException("No bean class specified");
}
@@ -294,53 +311,57 @@
// Introspect the bean and cache the generated descriptors
BeanInfo beanInfo = null;
+
try {
beanInfo = Introspector.getBeanInfo(beanClass);
} catch (IntrospectionException e) {
- return (new PropertyDescriptor[0]);
+ 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);
+ 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);
+ ? descriptor.getIndexedReadMethod().getName() : "get" + propName;
+ Method readMethod = getMatchingAccessibleMethod(beanClass, methodName, EMPTY_CLASS_PARAMETERS);
+
if (readMethod != null) {
try {
descriptor.setReadMethod(readMethod);
- } catch(Exception e) {
- }
+ } catch (Exception e) {
+
+ // TODO Refactoring
+ }
}
}
}
}
- return (descriptors);
+ 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
+ * Compatible parameters mean that every method parameter is assignable from
* the given parameters.
- * In other words, it finds a method with the given name
+ * 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
+ * <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
+ *
+ * <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.
@@ -349,64 +370,74 @@
*
* @param clazz find method in this class
* @param methodName find method with this name
- * @param parameterTypes find method with compatible parameters
+ * @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 {
+ 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);
- Method method = clazz.getMethod(methodName, parameterTypes);
-
setMethodAccessible(method); // Default access superclass workaround
return method;
-
- } catch (NoSuchMethodException e) { /* SWALLOW */ }
-
- // search through all methods
+ } 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)) {
-
+ int size = methods.length;
+
+ for (int i = 0; i < size; i++) {
+ if (methods[i].getName().equals(methodName)) {
+
// compare parameters
- Class<?>[] methodsParams = methods[i].getParameterTypes();
+ Class<?>[] methodsParams = methods[i].getParameterTypes();
int methodParamSize = methodsParams.length;
- if (methodParamSize == paramSize) {
+
+ if (methodParamSize == paramSize) {
boolean match = true;
- for (int n = 0 ; n < methodParamSize; n++) {
- if (!isAssignmentCompatible(methodsParams[n], parameterTypes[n])) {
+
+ 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;
+ myCost = getTotalTransformationCost(parameterTypes, method.getParameterTypes());
+
+ if (myCost < bestMatchCost) {
+ bestMatch = method;
+ bestMatchCost = myCost;
}
}
-
}
}
}
}
-
- return bestMatch;
+
+ 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
@@ -417,26 +448,28 @@
* @return The accessible method
* @throws ParsingException if error occured.
*/
- private static Method getAccessibleMethod(Class<?> clazz, Method method) throws ParsingException {
+ private static Method getAccessibleMethod(Class<?> clazz, Method method) throws ParsingException {
// Make sure we have a method to check
if (method == null) {
- return (null);
+ return null;
}
// If the requested method is not public we cannot call it
if (!Modifier.isPublic(method.getModifiers())) {
- return (null);
+ 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());
+ throw new IllegalArgumentException(clazz.getName() + " is not assignable from "
+ + method.getDeclaringClass().getName());
}
}
@@ -445,24 +478,24 @@
if (!sameClass && !Modifier.isPublic(method.getDeclaringClass().getModifiers())) {
setMethodAccessible(method); // Default access superclass workaround
}
- return (method);
+
+ return method;
}
- String methodName = method.getName();
+ String methodName = method.getName();
Class<?>[] parameterTypes = method.getParameterTypes();
// Check the implemented interfaces and subinterfaces
- method = getAccessibleMethodFromInterfaceNest(clazz, methodName, parameterTypes);
+ method = getAccessibleMethodFromInterfaceNest(clazz, methodName, parameterTypes);
// Check the superclass chain
if (method == null) {
method = getAccessibleMethodFromSuperclass(clazz, methodName, parameterTypes);
}
- return (method);
+ 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
@@ -472,9 +505,10 @@
* @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) {
+ private static Method getAccessibleMethodFromSuperclass(Class<?> clazz, String methodName,
+ Class<?>[] parameterTypes) {
+ Class<?> parentClazz = clazz.getSuperclass();
- Class<?> parentClazz = clazz.getSuperclass();
while (parentClazz != null) {
if (Modifier.isPublic(parentClazz.getModifiers())) {
try {
@@ -483,8 +517,10 @@
return null;
}
}
+
parentClazz = parentClazz.getSuperclass();
}
+
return null;
}
@@ -502,15 +538,16 @@
* @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) {
-
+ 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();
+ Class<?>[] interfaces = clazz.getInterfaces();
+
for (int i = 0; i < interfaces.length; i++) {
// Is this interface public?
@@ -522,34 +559,35 @@
try {
method = interfaces[i].getDeclaredMethod(methodName, parameterTypes);
} catch (NoSuchMethodException e) {
- /* Swallow, if no method is found after the loop then this
+
+ /*
+ * 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);
+ return method;
}
// We did not find anything
- return (null);
+ return null;
+ }
- }
-
/**
* Returns the sum of the object transformation cost for each class in the source
* argument list.
@@ -557,44 +595,48 @@
* @param destArgs The destination arguments
* @return The total transformation cost
*/
- private static float getTotalTransformationCost(Class<?>[] srcArgs, Class<?>[] destArgs) {
+ private static float getTotalTransformationCost(Class<?>[] srcArgs, Class<?>[] destArgs) {
+ float totalCost = 0.0f;
- float totalCost = 0.0f;
for (int i = 0; i < srcArgs.length; i++) {
- Class<?> srcClass, destClass;
- srcClass = srcArgs[i];
- destClass = destArgs[i];
+ Class<?> srcClass = srcArgs[i];
+ Class<?> 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
+ * 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) {
+ 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
+ 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
+ * 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) {
@@ -603,7 +645,7 @@
return cost;
}
-
+
/**
* <p>Determine whether a type can be used as a parameter in a method invocation.
* This method handles primitive conversions correctly.</p>
@@ -617,36 +659,40 @@
* 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
+ * @param parameterization the type of parameter being tested
*
* @return true if the assignement is compatible.
*/
- private static final boolean isAssignmentCompatible(Class<?> parameterType, Class<?> parameterization) {
+ private static 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);
+ 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
+ * @return the wrapper type associated with the given primitive
* or null if no match is found
*/
- private static Class<?> getPrimitiveWrapper(Class<?> primitiveType) {
+ private static Class<?> getPrimitiveWrapper(Class<?> primitiveType) {
+
// does anyone know a better strategy than comparing names?
if (boolean.class.equals(primitiveType)) {
return Boolean.class;
@@ -665,11 +711,10 @@
} else if (char.class.equals(primitiveType)) {
return Character.class;
} else {
-
return null;
}
}
-
+
/**
* Try to make the method accessible
* @param method The source arguments
@@ -677,6 +722,7 @@
*/
private static void setMethodAccessible(Method method) throws ParsingException {
try {
+
//
// XXX Default access superclass workaround
//
@@ -689,17 +735,17 @@
// modifer is public.
//
// The following workaround solves the problem but will only
- // work from sufficiently privilages code.
+ // 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);
+ 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
@@ -707,74 +753,91 @@
* @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());
- }
+ 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;
- }
+ interface ClassVisitor {
+ public void visit(Class<?> clazz) throws ParsingException;
+ }
+
+
+ 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);
+ }
+ }
}
Modified: 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 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/ELVisitor.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -18,6 +18,9 @@
* 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;
@@ -27,137 +30,141 @@
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 {
+public final class ELVisitor {
+ private static ELVisitor elVisitor;
+ Class<?> collectionVariableType = null;
+ String lastIndexValue = "null";
+ Class<?> lastVariableType = null;
+ List<Object> propertyResolved = new ArrayList<Object>();
+ boolean needConversion;
- private 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 static ELVisitor getInstance() {
+ if (elVisitor == null) {
+ elVisitor = new ELVisitor();
+ }
- public void setNeedConversion(boolean needConversion) {
- this.needConversion = needConversion;
- }
+ elVisitor.refresh();
- public String getLastIndexValue() {
- return lastIndexValue;
- }
+ return elVisitor;
+ }
- public void setLastIndexValue(String lastIndexValue) {
- this.lastIndexValue = lastIndexValue;
- }
+ public boolean isNeedConversion() {
+ return needConversion;
+ }
- public Class<?> getLastVariableType() {
- return lastVariableType;
- }
+ public void setNeedConversion(boolean needConversion) {
+ this.needConversion = needConversion;
+ }
- public void setLastVariableType(Class<?> lastVariableType) {
- this.lastVariableType = lastVariableType;
- }
+ public String getLastIndexValue() {
+ return lastIndexValue;
+ }
- public Class<?> getCollectionVariableType() {
- return collectionVariableType;
- }
+ public void setLastIndexValue(String lastIndexValue) {
+ this.lastIndexValue = lastIndexValue;
+ }
- public void setCollectionVariableType(Class<?> collectionVariableType) {
- this.collectionVariableType = collectionVariableType;
- }
+ public Class<?> getLastVariableType() {
+ return lastVariableType;
+ }
- /**
- * 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();
- }
+ public void setLastVariableType(Class<?> lastVariableType) {
+ this.lastVariableType = lastVariableType;
+ }
- /**
- * 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>();
- }
+ public Class<?> getCollectionVariableType() {
+ return collectionVariableType;
+ }
- /**
- * This method called after parse process handle AstValue node, to include special logic in that case.
- */
- public void setValueHandled() {
- propertyResolved.add(new Object());
- }
+ public void setCollectionVariableType(Class<?> collectionVariableType) {
+ this.collectionVariableType = collectionVariableType;
+ }
- /**
- * 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;
- }
+ /**
+ * 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;
+ }
}
Modified: 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 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/ParsingException.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -19,40 +19,39 @@
* 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;
- private static final long serialVersionUID = 6045782920008419804L;
+ public ParsingException() {}
- public ParsingException() {
- }
+ /**
+ * @param message
+ */
+ public ParsingException(String message) {
+ super(message);
+ }
- /**
- * @param message
- */
- public ParsingException(String message) {
- super(message);
- }
+ /**
+ * @param cause
+ */
+ public ParsingException(Throwable cause) {
+ super(cause);
+ }
- /**
- * @param cause
- */
- public ParsingException(Throwable cause) {
- super(cause);
- }
-
- /**
- * @param message
- * @param cause
- */
- public ParsingException(String message, Throwable cause) {
- super(message, cause);
- }
-
+ /**
+ * @param message
+ * @param cause
+ */
+ public ParsingException(String message, Throwable cause) {
+ super(message, cause);
+ }
}
Modified: 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 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/StringUtils.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -19,69 +19,79 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.parser.el;
-public class StringUtils {
+public final class StringUtils {
+ private StringUtils() {}
- static public String getEscapedString(final String text) {
- StringBuffer buf = new StringBuffer();
+ public static String getEscapedString(final String text) {
+ StringBuffer buf = new StringBuffer();
+ int i = 0;
- 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();
- }
+ while (i < text.length()) {
+ char c = text.charAt(i);
- /**
- * Returns true if the char isalpha() or isdigit().
- */
- public static boolean isalnum(char c) {
- return (isalpha(c) || isdigit(c));
- }
+ if (isalnum(c)) {
+ buf.append(c);
+ } else {
+ switch (c) {
+ case '"' :
+ buf.append("\\\"");
- /**
- * Returns true if the char isupper() or islower().
- */
- public static boolean isalpha(char c) {
- return (isupper(c) || islower(c));
- }
+ break;
- /**
- * Returns true if the char is from 'A' to 'Z' inclusive.
- */
- public static boolean isupper(char c) {
- return ((c >= 'A') && (c <= 'Z'));
- }
+ case '\n' :
+ buf.append("\\n");
- /**
- * Returns true if the char is from 'a' to 'z' inclusive.
- */
- public static boolean islower(char c) {
- return ((c >= 'a') && (c <= 'z'));
- }
+ break;
- /**
- * Returns true if the char is from '0' to '9' inclusive.
- */
- public static boolean isdigit(char c) {
- return ((c >= '0') && (c <= '9'));
- }
+ 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');
+ }
}
Modified: 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 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AbstractArithmeticTreeNode.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -18,49 +18,53 @@
* 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);
+ }
- 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);
- @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);
- }
+ node1.visit(sb1, context, visitor);
- /**
- * This abstract method return string representation of arithmetic operation.
- *
- * @return string representation of arithmetic operation of current node.
- *
- */
- public abstract String getOperator();
+ 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();
}
Modified: 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 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AbstractBooleanTreeNode.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -18,48 +18,53 @@
* 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);
- }
+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);
- }
+ @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);
- /**
- * This abstract method return string representation of comparison operation.
- *
- * @return string representation of comparison operation of current node.
- *
- */
- public abstract String getDelimiter();
+ 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();
}
Modified: 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 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AbstractTreeNode.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -18,63 +18,69 @@
* 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 {
+ private Node node;
- 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;
+ public AbstractTreeNode(Node node) {
+ this.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;
}
Modified: 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 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstAndTreeNode.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -18,24 +18,26 @@
* 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 class AstAndTreeNode extends AbstractBooleanTreeNode {
+ public AstAndTreeNode(Node node) {
+ super(node);
+ }
- public AstAndTreeNode(Node node) {
- super(node);
- }
-
- @Override
- public String getDelimiter() {
- return ELNodeConstants.AND_DELIMITER;
- }
-
+ @Override
+ public String getDelimiter() {
+ return ELNodeConstants.AND_DELIMITER;
+ }
}
Modified: 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 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstBracketSuffixTreeNode.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -18,56 +18,64 @@
* 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);
+ }
- public AstBracketSuffixTreeNode(Node node) {
- super(node);
- }
+ @Override
+ public void visit(StringBuilder sb, Map<String, Class<?>> context, ELVisitor visitor) throws ParsingException {
+ ITreeNode node = getChild(0);
- @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);
- }
- }
- }
+ 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);
+ }
+ }
+ }
}
Modified: 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 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstChoiceTreeNode.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -18,44 +18,51 @@
* 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 class AstChoiceTreeNode extends AbstractTreeNode {
+ public AstChoiceTreeNode(Node node) {
+ super(node);
+ }
- 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);
- @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);
- }
+ 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);
+ }
}
Modified: 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 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstDeferredExpressionTreeNode.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -18,39 +18,46 @@
* 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);
+ }
- public AstDeferredExpressionTreeNode(Node node) {
- super(node);
- }
+ @Override
+ public void visit(StringBuilder sb, Map<String, Class<?>> context, ELVisitor visitor) throws ParsingException {
+ int numChildren = getNode().jjtGetNumChildren();
- @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);
- }
- }
- }
+ 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);
+ }
+ }
+ }
}
Modified: 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 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstDivTreeNode.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -18,24 +18,26 @@
* 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);
+ }
- public AstDivTreeNode(Node node) {
- super(node);
- }
-
- @Override
- public String getOperator() {
- return ELNodeConstants.DIV_OPERATOR;
- }
-
+ @Override
+ public String getOperator() {
+ return ELNodeConstants.DIV_OPERATOR;
+ }
}
Modified: 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 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstEmptyTreeNode.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -18,35 +18,38 @@
* 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 class AstEmptyTreeNode extends AbstractTreeNode {
+ public AstEmptyTreeNode(Node node) {
+ super(node);
+ }
- 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);
- @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);
- }
-
+ 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);
+ }
}
Modified: 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 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstEqualTreeNode.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -18,24 +18,26 @@
* 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 class AstEqualTreeNode extends AbstractBooleanTreeNode {
+ public AstEqualTreeNode(Node node) {
+ super(node);
+ }
- public AstEqualTreeNode(Node node) {
- super(node);
- }
-
- @Override
- public String getDelimiter() {
- return ELNodeConstants.EQUAL;
- }
-
+ @Override
+ public String getDelimiter() {
+ return ELNodeConstants.EQUAL;
+ }
}
Modified: 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 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstFalseTreeNode.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -18,29 +18,31 @@
* 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);
+ }
- public AstFalseTreeNode(Node node) {
- super(node);
- }
-
- @Override
- public void visit(StringBuilder sb, Map<String, Class<?>> context, ELVisitor visitor)
- throws ParsingException {
- sb.append(ELNodeConstants.FALSE);
- }
-
+ @Override
+ public void visit(StringBuilder sb, Map<String, Class<?>> context, ELVisitor visitor) throws ParsingException {
+ sb.append(ELNodeConstants.FALSE);
+ }
}
Modified: 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 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstFloatingPointTreeNode.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -18,32 +18,34 @@
* 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);
+ }
- 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);
- }
-
+ @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);
+ }
}
Modified: 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 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstFunctionTreeNode.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -18,43 +18,54 @@
* 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);
+ }
- 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();
- @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);
- }
+ 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);
+ }
}
Modified: 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 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstGreaterThanEqualTreeNode.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -18,24 +18,26 @@
* 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 class AstGreaterThanEqualTreeNode extends AbstractBooleanTreeNode {
+ public AstGreaterThanEqualTreeNode(Node node) {
+ super(node);
+ }
- public AstGreaterThanEqualTreeNode(Node node) {
- super(node);
- }
-
- @Override
- public String getDelimiter() {
- return ELNodeConstants.GREAT_THEN_EQUAL;
- }
-
+ @Override
+ public String getDelimiter() {
+ return ELNodeConstants.GREAT_THEN_EQUAL;
+ }
}
Modified: 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 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstGreaterThanTreeNode.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -18,24 +18,26 @@
* 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 class AstGreaterThanTreeNode extends AbstractBooleanTreeNode {
+ public AstGreaterThanTreeNode(Node node) {
+ super(node);
+ }
- public AstGreaterThanTreeNode(Node node) {
- super(node);
- }
-
- @Override
- public String getDelimiter() {
- return ELNodeConstants.GREAT_THEN;
- }
-
+ @Override
+ public String getDelimiter() {
+ return ELNodeConstants.GREAT_THEN;
+ }
}
Modified: 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 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstIdentifierTreeNode.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -18,52 +18,57 @@
* 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);
+ }
- public AstIdentifierTreeNode(Node node) {
- super(node);
- }
+ @Override
+ public void visit(StringBuilder sb, Map<String, Class<?>> context, ELVisitor visitor) throws ParsingException {
+ String variableName = getNode().getImage();
- @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);
- }
- }
+ 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);
+ }
+ }
}
Modified: 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 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstIntegerTreeNode.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -18,28 +18,31 @@
* 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);
+ }
- public AstIntegerTreeNode(Node node) {
- super(node);
- }
-
- @Override
- public void visit(StringBuilder sb, Map<String, Class<?>> context, ELVisitor visitor) throws ParsingException{
- sb.append(getNode().getImage());
- }
-
+ @Override
+ public void visit(StringBuilder sb, Map<String, Class<?>> context, ELVisitor visitor) throws ParsingException {
+ sb.append(getNode().getImage());
+ }
}
Modified: 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 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstLessThanEqualTreeNode.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -18,24 +18,26 @@
* 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 class AstLessThanEqualTreeNode extends AbstractBooleanTreeNode {
+ public AstLessThanEqualTreeNode(Node node) {
+ super(node);
+ }
- public AstLessThanEqualTreeNode(Node node) {
- super(node);
- }
-
- @Override
- public String getDelimiter() {
- return ELNodeConstants.LESS_THEN_EQUAL;
- }
-
+ @Override
+ public String getDelimiter() {
+ return ELNodeConstants.LESS_THEN_EQUAL;
+ }
}
Modified: 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 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstLessThanTreeNode.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -18,24 +18,26 @@
* 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 class AstLessThanTreeNode extends AbstractBooleanTreeNode {
+ public AstLessThanTreeNode(Node node) {
+ super(node);
+ }
- public AstLessThanTreeNode(Node node) {
- super(node);
- }
-
- @Override
- public String getDelimiter() {
- return ELNodeConstants.LESS_THEN;
- }
-
+ @Override
+ public String getDelimiter() {
+ return ELNodeConstants.LESS_THEN;
+ }
}
Modified: 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 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstLiteralTreeNode.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -18,33 +18,36 @@
* 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 class AstLiteralTreeNode extends AbstractTreeNode {
+ public AstLiteralTreeNode(Node node) {
+ super(node);
+ }
- 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);
- }
- }
-
+ @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);
+ }
+ }
}
Modified: 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 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstMethodSuffixTreeNode.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -18,44 +18,54 @@
* 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 class AstMethodSuffixTreeNode extends AbstractTreeNode {
+ public AstMethodSuffixTreeNode(Node node) {
+ super(node);
+ }
- public AstMethodSuffixTreeNode(Node node) {
- super(node);
- }
+ @Override
+ public void visit(StringBuilder sb, Map<String, Class<?>> context, ELVisitor visitor) throws ParsingException {
+ StringBuilder sb1 = new StringBuilder();
- @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);
- }
+ 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);
+ }
}
Modified: 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 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstMinusTreeNode.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -18,24 +18,26 @@
* 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);
+ }
- public AstMinusTreeNode(Node node) {
- super(node);
- }
-
- @Override
- public String getOperator() {
- return ELNodeConstants.MINUS_SIGN;
- }
-
+ @Override
+ public String getOperator() {
+ return ELNodeConstants.MINUS_SIGN;
+ }
}
Modified: 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 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstModTreeNode.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -18,24 +18,26 @@
* 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);
+ }
- public AstModTreeNode(Node node) {
- super(node);
- }
-
- @Override
- public String getOperator() {
- return ELNodeConstants.MOD_SIGN;
- }
-
+ @Override
+ public String getOperator() {
+ return ELNodeConstants.MOD_SIGN;
+ }
}
Modified: 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 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstMultTreeNode.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -18,24 +18,26 @@
* 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 class AstMultTreeNode extends AbstractArithmeticTreeNode {
+ public AstMultTreeNode(Node node) {
+ super(node);
+ }
- public AstMultTreeNode(Node node) {
- super(node);
- }
-
- @Override
- public String getOperator() {
- return ELNodeConstants.MULT_SIGN;
- }
-
+ @Override
+ public String getOperator() {
+ return ELNodeConstants.MULT_SIGN;
+ }
}
Modified: 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 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstNegativeTreeNode.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -18,33 +18,36 @@
* 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);
+ }
- 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();
- @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);
- }
-
+ sb.append(ELNodeConstants.NEGATIVE);
+ node.visit(sb1, context, visitor);
+ sb.append(sb1);
+ }
}
Modified: 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 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstNotEqualTreeNode.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -18,24 +18,26 @@
* 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 class AstNotEqualTreeNode extends AbstractBooleanTreeNode {
+ public AstNotEqualTreeNode(Node node) {
+ super(node);
+ }
- public AstNotEqualTreeNode(Node node) {
- super(node);
- }
-
- @Override
- public String getDelimiter() {
- return ELNodeConstants.NOT_EQUAL;
- }
-
+ @Override
+ public String getDelimiter() {
+ return ELNodeConstants.NOT_EQUAL;
+ }
}
Modified: 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 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstNotTreeNode.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -18,34 +18,38 @@
* 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 class AstNotTreeNode extends AbstractTreeNode {
+ public AstNotTreeNode(Node node) {
+ super(node);
+ }
- 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);
- @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);
- }
-
+ node1.visit(sb1, context, visitor);
+ sb.append(ELNodeConstants.LEFT_BRACKET);
+ sb.append(ELNodeConstants.EXCLAMATION_MARK);
+ sb.append(sb1);
+ sb.append(ELNodeConstants.RIGHT_BRACKET);
+ }
}
Modified: 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 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstNullTreeNode.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -18,29 +18,31 @@
* 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);
+ }
- public AstNullTreeNode(Node node) {
- super(node);
- }
-
- @Override
- public void visit(StringBuilder sb, Map<String, Class<?>> context, ELVisitor visitor)
- throws ParsingException {
- sb.append(ELNodeConstants.NULL);
- }
-
+ @Override
+ public void visit(StringBuilder sb, Map<String, Class<?>> context, ELVisitor visitor) throws ParsingException {
+ sb.append(ELNodeConstants.NULL);
+ }
}
Modified: 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 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstOrTreeNode.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -18,24 +18,26 @@
* 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 class AstOrTreeNode extends AbstractBooleanTreeNode {
+ public AstOrTreeNode(Node node) {
+ super(node);
+ }
- public AstOrTreeNode(Node node) {
- super(node);
- }
-
- @Override
- public String getDelimiter() {
- return ELNodeConstants.OR;
- }
-
+ @Override
+ public String getDelimiter() {
+ return ELNodeConstants.OR;
+ }
}
Modified: 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 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstPlusTreeNode.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -18,24 +18,26 @@
* 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);
+ }
- public AstPlusTreeNode(Node node) {
- super(node);
- }
-
- @Override
- public String getOperator() {
- return ELNodeConstants.PLUS_SIGN;
- }
-
+ @Override
+ public String getOperator() {
+ return ELNodeConstants.PLUS_SIGN;
+ }
}
Modified: 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 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstPropertySuffixTreeNode.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -18,37 +18,43 @@
* 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);
+ }
- public AstPropertySuffixTreeNode(Node node) {
- super(node);
- }
+ @Override
+ public void visit(StringBuilder sb, Map<String, Class<?>> context, ELVisitor visitor) throws ParsingException {
+ String propertyName = getNode().getImage();
- @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
+ 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);
+ }
+ }
+}
Modified: 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 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstStringTreeNode.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -18,31 +18,34 @@
* 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);
+ }
- 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);
- }
-
+ @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);
+ }
}
Modified: 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 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstTrueTreeNode.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -18,29 +18,31 @@
* 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 class AstTrueTreeNode extends AbstractTreeNode {
+ public AstTrueTreeNode(Node node) {
+ super(node);
+ }
- public AstTrueTreeNode(Node node) {
- super(node);
- }
-
- @Override
- public void visit(StringBuilder sb, Map<String, Class<?>> context, ELVisitor visitor)
- throws ParsingException {
- sb.append(ELNodeConstants.TRUE);
- }
-
+ @Override
+ public void visit(StringBuilder sb, Map<String, Class<?>> context, ELVisitor visitor) throws ParsingException {
+ sb.append(ELNodeConstants.TRUE);
+ }
}
Modified: 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 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstValueTreeNode.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -18,6 +18,9 @@
* 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;
@@ -25,43 +28,52 @@
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);
+ }
- 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>();
- @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();
- }
+ 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();
+ }
}
Modified: 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 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/ELNodeConstants.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -18,51 +18,51 @@
* 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 final class ELNodeConstants {
+ public static final String AND_DELIMITER = " && ";
+ public static final String ARRAY_INDICATOR = "[L";
+ public static final String COLON = " : ";
+ public static final String COMMA = ",";
+ public static final String CONVERT_TO_STRING_FUNCTION = "convertToString";
+ public static final String DIV_OPERATOR = " / ";
+ public static final String DOT = ".";
+ public static final String DOUBLE_VALUE_OF_FUNCTION = "Double.valueOf";
+ public static final String EQUAL = " == ";
+ public static final String EXCLAMATION_MARK = "!";
+ public static final String FALSE = "false";
+ public static final String GET_ELELMENT_BY_INDEX_FUNCTION = "getElelmentByIndex";
+ public static final String GET_FUNCTION = "get";
+ public static final String GET_UTILS_FUNCTION = "getUtils";
+ public static final String GREAT_THEN = " > ";
+ public static final String GREAT_THEN_EQUAL = " >= ";
+ public static final String JAVA_UTIL_LIST = "java.util.List";
+ public static final String JAVA_UTIL_MAP = "java.util.Map";
+ public static final String LEFT_BRACKET = "(";
+ public static final String LEFT_SQUARE_BRACKET = "[";
+ public static final String LESS_THEN = " < ";
+ public static final String LESS_THEN_EQUAL = " <= ";
+ public static final String MINUS_SIGN = " - ";
+ public static final String MOD_SIGN = " % ";
+ public static final String MULT_SIGN = " * ";
+ public static final String NEGATIVE = "-";
+ public static final String NOT_EQUAL = " != ";
+ public static final String NULL = "null";
+ public static final String OR = " || ";
+ public static final String PLUS_SIGN = " + ";
+ public static final String QUESTION_SIGN = " ? ";
+ public static final String QUOTE = "\"";
+ public static final String RIGHT_BRACKET = ")";
+ public static final String RIGHT_SQUARE_BRACKET = "]";
+ public static final String THIS_GET_UTILS_IS_EMPTY_FUNCTION = "this.getUtils().isEmpty";
+ public static final String THIS_PREFIX = "this";
+ public static final String TRUE = "true";
+ public static final String UTILS_PREFIX = "utils";
+ public static final String VARIABLES_GET_VARIABLE_FUNCTION = "variables.getVariable";
- 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(){
-
- }
+ private ELNodeConstants() {}
}
Modified: 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 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/ITreeNode.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -18,46 +18,49 @@
* 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();
+ /**
+ * 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;
+ /**
+ * 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;
+ /**
+ * 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;
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/util/PropertyUtils.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/util/PropertyUtils.java 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/util/PropertyUtils.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.util;
import org.richfaces.cdk.model.InvalidNameException;
@@ -30,17 +32,20 @@
* @author asmirnov(a)exadel.com
*
*/
-public class PropertyUtils {
-
- public static String methodToName(String methodName) throws InvalidNameException {
- if(null != methodName ){
- if(methodName.length()>3 && Character.isUpperCase(methodName.charAt(3)) &&(methodName.startsWith("set")||methodName.startsWith("get"))){
- return Strings.firstToLowerCase(methodName.substring(3));
- } else if(methodName.length()>2 && Character.isUpperCase(methodName.charAt(2)) && methodName.startsWith("is")) {
- return Strings.firstToLowerCase(methodName.substring(2));
- }
- }
- throw new InvalidNameException("Method name "+methodName+" is not valid bean property getter or setter");
- }
+public final class PropertyUtils {
+ private PropertyUtils() {}
+ public static String methodToName(String methodName) throws InvalidNameException {
+ if (null != methodName) {
+ if (methodName.length() > 3 && Character.isUpperCase(methodName.charAt(3))
+ && (methodName.startsWith("set") || methodName.startsWith("get"))) {
+ return Strings.firstToLowerCase(methodName.substring(3));
+ } else if (methodName.length() > 2 && Character.isUpperCase(methodName.charAt(2))
+ && methodName.startsWith("is")) {
+ return Strings.firstToLowerCase(methodName.substring(2));
+ }
+ }
+
+ throw new InvalidNameException("Method name " + methodName + " is not valid bean property getter or setter");
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/util/Strings.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/util/Strings.java 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/util/Strings.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.util;
/**
@@ -29,57 +31,59 @@
*
*/
public final class Strings {
+ private Strings() {
- private Strings() {
- // this is utility class with static methods only.
- }
-
- /**
- * <p class="changed_added_4_0">Remove characters from string end</p>
- * @param in input string
- * @param size number of characters to remove.
- * @return
- */
- public static String cut(String in, int size) {
- if(size >0){
- return in.substring(0, in.length()-size);
- }
- return in;
- }
-
- /**
- * <p class="changed_added_4_0">Change case of the first character to lower, as it required by the Java Beans property and setter/getter method name conventions:</p>
- * <p>"PropertyFoo" will be changed to "propertyFoo"</p>
- * @param in
- * @return {@code in} with first character changed to lower case.
- */
- public static String firstToLowerCase(String in) {
- if(!isEmpty(in)){
- in = in.substring(0,1).toLowerCase()+in.substring(1);
- }
- return in;
- }
-
- /**
- * <p class="changed_added_4_0">Change case of the first character to upper, as it required by the Java Beans property and setter/getter method name conventions:</p>
- * <p>"propertyFoo" will be changed to "PropertyFoo"</p>
- * @param in
- * @return {@code in} with first character changed to lower case.
- */
- public static String firstToUpperCase(String in) {
- if(!isEmpty(in)){
- in = in.substring(0,1).toUpperCase()+in.substring(1);
- }
- return in;
- }
-
- /**
- * <p class="changed_added_4_0">Check string for null or empty value</p>
- * @param type
- * @return true if {@code type} is null or zero-length string.
- */
- public static boolean isEmpty(String type) {
- return type == null || type.length()==0;
- }
+ // this is utility class with static methods only.
+ }
+ /**
+ * <p class="changed_added_4_0">Remove characters from string end</p>
+ * @param in input string
+ * @param size number of characters to remove.
+ * @return
+ */
+ public static String cut(String in, int size) {
+ if (size > 0) {
+ return in.substring(0, in.length() - size);
+ }
+
+ return in;
+ }
+
+ /**
+ * <p class="changed_added_4_0">Change case of the first character to lower, as it required by the Java Beans property and setter/getter method name conventions:</p>
+ * <p>"PropertyFoo" will be changed to "propertyFoo"</p>
+ * @param in
+ * @return {@code in} with first character changed to lower case.
+ */
+ public static String firstToLowerCase(String in) {
+ if (!isEmpty(in)) {
+ in = in.substring(0, 1).toLowerCase() + in.substring(1);
+ }
+
+ return in;
+ }
+
+ /**
+ * <p class="changed_added_4_0">Change case of the first character to upper, as it required by the Java Beans property and setter/getter method name conventions:</p>
+ * <p>"propertyFoo" will be changed to "PropertyFoo"</p>
+ * @param in
+ * @return {@code in} with first character changed to lower case.
+ */
+ public static String firstToUpperCase(String in) {
+ if (!isEmpty(in)) {
+ in = in.substring(0, 1).toUpperCase() + in.substring(1);
+ }
+
+ return in;
+ }
+
+ /**
+ * <p class="changed_added_4_0">Check string for null or empty value</p>
+ * @param type
+ * @return true if {@code type} is null or zero-length string.
+ */
+ public static boolean isEmpty(String type) {
+ return type == null || type.length() == 0;
+ }
}
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-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/CdkEntityResolver.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.xmlconfig;
import java.io.File;
@@ -28,11 +30,13 @@
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
+
import java.net.URI;
import org.richfaces.cdk.CdkContext;
import org.richfaces.cdk.StandardSources;
import org.richfaces.cdk.CdkContext.SourceType;
+
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.ext.EntityResolver2;
@@ -44,186 +48,190 @@
* That class resolves entities used by CDK ( standard JSF schemas, extensions,
* configuration fragments.)
* </p>
- *
+ *
* @author asmirnov(a)exadel.com
- *
+ *
*/
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 URN_ATTRIBUTES = "urn:attributes:";
+ public static final String URN_CONFIG = "urn:config:";
+ public static final String URN_RESOURCE = "urn:resource:";
+ public static final String URN_TEMPLATES = "urn:templates:";
+ 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 RESOURCE_PREFIX = "";
+ private static final String ATTRIBUTES_PREFIX = "META-INF/cdk/attributes/";
+ private static final String SYSTEM_PREFIX = "/META-INF/schema";
+ private static final String URN_SYSTEM = "urn:system:";
+ private static final ImmutableMap<String, String> SYSTEM_ENTITIES =
+ ImmutableMap.<String, String>builder().put(
+ "http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd", URN_SYSTEM + "/web-facesconfig_2_0.xsd").put(
+ "http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd", URN_SYSTEM + "/web-facesconfig_1_2.xsd").put(
+ "http://java.sun.com/xml/ns/javaee/javaee_5.xsd", URN_SYSTEM + "/javaee_5.xsd").put(
+ "http://java.sun.com/xml/ns/javaee/javaee_web_services_1_2.xsd",
+ URN_SYSTEM + "/javaee_web_services_1_2.xsd").put(
+ "http://java.sun.com/xml/ns/javaee/javaee_web_services_client_1_2.xsd",
+ URN_SYSTEM + "/javaee_web_services_client_1_2.xsd").put(
+ "http://www.w3.org/2001/03/xml.xsd", URN_SYSTEM + "/xml.xsd").build();
+
+ private final CdkContext context;
- private static final String URN_SYSTEM = "urn:system:";
+ public CdkEntityResolver(CdkContext context) {
+ this.context = context;
+ }
- private static final ImmutableMap<String, String> systemEntities = ImmutableMap
- .<String, String> builder()
- .put("http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd",
- URN_SYSTEM + "/web-facesconfig_2_0.xsd")
- .put("http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd",
- URN_SYSTEM + "/web-facesconfig_1_2.xsd")
- .put("http://java.sun.com/xml/ns/javaee/javaee_5.xsd",
- URN_SYSTEM + "/javaee_5.xsd")
- .put(
- "http://java.sun.com/xml/ns/javaee/javaee_web_services_1_2.xsd",
- URN_SYSTEM + "/javaee_web_services_1_2.xsd")
- .put(
- "http://java.sun.com/xml/ns/javaee/javaee_web_services_client_1_2.xsd",
- URN_SYSTEM + "/javaee_web_services_client_1_2.xsd")
- .put("http://www.w3.org/2001/03/xml.xsd", URN_SYSTEM + "/xml.xsd")
- .build();
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.xml.sax.ext.EntityResolver2#getExternalSubset(java.lang.String,
+ * java.lang.String)
+ */
+ @Override
+ public InputSource getExternalSubset(String name, String baseURI) throws SAXException, IOException {
- private static final String SYSTEM_PREFIX = "/META-INF/schema";
+ // do nothing because we use XML schema only.
+ return null;
+ }
- public static final String URN_RESOURCE = "urn:resource:";
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.xml.sax.ext.EntityResolver2#resolveEntity(java.lang.String,
+ * java.lang.String, java.lang.String, java.lang.String)
+ */
+ @Override
+ public InputSource resolveEntity(String name, String publicId, String baseURI, String systemId)
+ throws SAXException, IOException {
+
+ String temSystemId = systemId;
- private static final String RESOURCE_PREFIX = "";
+ // perform conversions with baseURI
+ if (null != temSystemId) {
+ try {
+ URI sourceURI = URI.create(temSystemId);
- public static final String URN_CONFIG = "urn:config:";
+ if (!sourceURI.isAbsolute() && null != baseURI) {
+ temSystemId = URI.create(baseURI).resolve(sourceURI).toString();
+ }
+ } catch (IllegalArgumentException e) {
- public static final String URN_TEMPLATES = "urn:templates:";
+ // Ignore ?
+ }
+ }
- public static final String URN_ATTRIBUTES = "urn:attributes:";
+ return resolveSystemId(temSystemId);
+ }
- private static final String ATTRIBUTES_PREFIX = "META-INF/cdk/attributes/";
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.xml.sax.EntityResolver#resolveEntity(java.lang.String,
+ * java.lang.String)
+ */
+ @Override
+ public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {
+ InputSource entity = null;
- private final CdkContext context;
+ if (null != systemId) {
+ entity = resolveSystemId(systemId);
+ }
- public CdkEntityResolver(CdkContext context) {
- this.context = context;
+ return entity;
+ }
- }
+ protected InputSource resolveSystemId(String systemId) throws FileNotFoundException {
+ InputSource entity = null;
- /*
- * (non-Javadoc)
- *
- * @see org.xml.sax.ext.EntityResolver2#getExternalSubset(java.lang.String,
- * java.lang.String)
- */
- @Override
- public InputSource getExternalSubset(String name, String baseURI)
- throws SAXException, IOException {
- // do nothing because we use XML schema only.
- return null;
- }
+ // first step - convert known system url's:
+ String systemIdInternal;
- /*
- * (non-Javadoc)
- *
- * @see org.xml.sax.ext.EntityResolver2#resolveEntity(java.lang.String,
- * java.lang.String, java.lang.String, java.lang.String)
- */
- @Override
- public InputSource resolveEntity(String name, String publicId,
- String baseURI, String systemId) throws SAXException, IOException {
- // perform conversions with baseURI
- if (null != systemId) {
- try {
- URI sourceURI = URI.create(systemId);
- if (!sourceURI.isAbsolute() && null != baseURI) {
- systemId = URI.create(baseURI).resolve(sourceURI).toString();
- }
- } catch (IllegalArgumentException e){
- // Ignore ?
- }
- }
- return resolveSystemId(systemId);
- }
+ if (SYSTEM_ENTITIES.containsKey(systemId)) {
+ systemIdInternal = SYSTEM_ENTITIES.get(systemId);
+ } else {
+ systemIdInternal = systemId;
+ }
- /*
- * (non-Javadoc)
- *
- * @see org.xml.sax.EntityResolver#resolveEntity(java.lang.String,
- * java.lang.String)
- */
- @Override
- public InputSource resolveEntity(String publicId, String systemId)
- throws SAXException, IOException {
- InputSource entity = null;
- if (null != systemId) {
- entity = resolveSystemId(systemId);
- }
- return entity;
- }
+ // Check registered urn's:
+ if (systemIdInternal.startsWith(URN_SYSTEM)) {
- protected InputSource resolveSystemId(String systemId)
- throws FileNotFoundException {
- InputSource entity = null;
- // first step - convert known system url's:
- String systemIdInternal;
- if (systemEntities.containsKey(systemId)) {
- systemIdInternal = systemEntities.get(systemId);
- } else {
- systemIdInternal = systemId;
- }
- // Check registered urn's:
- if (systemIdInternal.startsWith(URN_SYSTEM)) {
- // Cdk resources
- String path = systemIdInternal.substring(URN_SYSTEM.length());
- InputStream inputStream = CdkEntityResolver.class
- .getResourceAsStream(SYSTEM_PREFIX + path);
- if (null != inputStream) {
- entity = new InputSource(inputStream);
- }
- } else if (systemIdInternal.startsWith(URN_RESOURCE)) {
- // Project resources
- String path = systemIdInternal.substring(URN_RESOURCE.length());
- InputStream inputStream = getContext().getLoader()
- .getResourceAsStream(RESOURCE_PREFIX + path);
- if (null != inputStream) {
- entity = new InputSource(inputStream);
- }
- } else if (systemIdInternal.startsWith(URN_ATTRIBUTES)) {
- // Standard attributes. Look for them in the satndard place via
- // project classloader.
- String path = systemIdInternal.substring(URN_ATTRIBUTES.length());
- InputStream inputStream = getContext().getLoader()
- .getResourceAsStream(ATTRIBUTES_PREFIX + path);
- if (null != inputStream) {
- entity = new InputSource(inputStream);
- }
- } else if (systemIdInternal.startsWith(URN_CONFIG)) {
- // Config folder.
- String path = systemIdInternal.substring(URN_CONFIG.length());
- entity = getProjectInputSource(StandardSources.FACES_CONFIGS, path);
- } else if (systemIdInternal.startsWith(URN_TEMPLATES)) {
- // Templates folder.
- String path = systemIdInternal.substring(URN_TEMPLATES.length());
- entity = getProjectInputSource(StandardSources.RENDERER_TEMPLATES,
- path);
- }
- if(null != entity){
- entity.setSystemId(systemId);
- }
- return entity;
- }
+ // Cdk resources
+ String path = systemIdInternal.substring(URN_SYSTEM.length());
+ InputStream inputStream = CdkEntityResolver.class.getResourceAsStream(SYSTEM_PREFIX + path);
- protected InputSource getProjectInputSource(SourceType type, String path)
- throws FileNotFoundException {
- Iterable<File> folders = getContext().getSourceFolders(type);
- InputSource entity = null;
- 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;
- }
+ if (null != inputStream) {
+ entity = new InputSource(inputStream);
+ }
+ } else if (systemIdInternal.startsWith(URN_RESOURCE)) {
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @return the context
- */
- public CdkContext getContext() {
- return context;
- }
+ // Project resources
+ String path = systemIdInternal.substring(URN_RESOURCE.length());
+ InputStream inputStream = getContext().getLoader().getResourceAsStream(RESOURCE_PREFIX + path);
+ if (null != inputStream) {
+ entity = new InputSource(inputStream);
+ }
+ } else if (systemIdInternal.startsWith(URN_ATTRIBUTES)) {
+
+ // Standard attributes. Look for them in the satndard place via
+ // project classloader.
+ String path = systemIdInternal.substring(URN_ATTRIBUTES.length());
+ InputStream inputStream = getContext().getLoader().getResourceAsStream(ATTRIBUTES_PREFIX + path);
+
+ if (null != inputStream) {
+ entity = new InputSource(inputStream);
+ }
+ } else if (systemIdInternal.startsWith(URN_CONFIG)) {
+
+ // Config folder.
+ String path = systemIdInternal.substring(URN_CONFIG.length());
+
+ entity = getProjectInputSource(StandardSources.FACES_CONFIGS, path);
+ } else if (systemIdInternal.startsWith(URN_TEMPLATES)) {
+
+ // Templates folder.
+ String path = systemIdInternal.substring(URN_TEMPLATES.length());
+
+ entity = getProjectInputSource(StandardSources.RENDERER_TEMPLATES, path);
+ }
+
+ if (null != entity) {
+ entity.setSystemId(systemId);
+ }
+
+ return entity;
+ }
+
+ protected InputSource getProjectInputSource(SourceType type, String path) throws FileNotFoundException {
+ Iterable<File> folders = getContext().getSourceFolders(type);
+ InputSource entity = null;
+
+ 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;
+ }
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @return the context
+ */
+ public CdkContext getContext() {
+ return context;
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FacesConfigGenerator.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FacesConfigGenerator.java 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FacesConfigGenerator.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -21,11 +21,10 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.xmlconfig;
-import java.io.File;
-import java.io.IOException;
-
import org.richfaces.cdk.CdkContext;
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.CdkWriter;
@@ -33,61 +32,62 @@
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.xmlconfig.model.FacesConfigAdapter;
+import java.io.File;
+
/**
* <p class="changed_added_4_0">
* </p>
- *
+ *
* @author asmirnov(a)exadel.com
- *
+ *
*/
public class FacesConfigGenerator implements CdkWriter {
+ private static final String FACES_CONFIG_XML = "META-INF/faces-config.xml";
+ public static final String FACES_SCHEMA_LOCATION = ComponentLibrary.FACES_CONFIG_NAMESPACE + " "
+ + ComponentLibrary.FACES_CONFIG_SCHEMA_LOCATION;
+ private CdkContext context;
+ private JAXBBinding jaxbBinding;
+ private FacesConfigAdapter libraryAdapter;
- private static final String FACES_CONFIG_XML = "META-INF/faces-config.xml";
- private CdkContext context;
- private JAXBBinding jaxbBinding;
- private FacesConfigAdapter libraryAdapter;
- public static final String FACES_SCHEMA_LOCATION = ComponentLibrary.FACES_CONFIG_NAMESPACE
- + " " + ComponentLibrary.FACES_CONFIG_SCHEMA_LOCATION;
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.richfaces.cdk.CdkWriter#init(org.richfaces.cdk.CdkContext)
+ */
+ @Override
+ public void init(CdkContext context) throws CdkException {
+ this.context = context;
+ jaxbBinding = context.getWorkerInstance(JAXBBinding.class);
+ libraryAdapter = new FacesConfigAdapter();
+ }
- /*
- * (non-Javadoc)
- *
- * @see org.richfaces.cdk.CdkWriter#init(org.richfaces.cdk.CdkContext)
- */
- @Override
- public void init(CdkContext context) throws CdkException {
- this.context = context;
- jaxbBinding = context.getWorkerInstance(JAXBBinding.class);
- libraryAdapter = new FacesConfigAdapter();
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.richfaces.cdk.CdkWriter#render(org.richfaces.cdk.model.ComponentLibrary
+ * )
+ */
+ @Override
+ public void render(ComponentLibrary library) throws CdkException {
- /*
- * (non-Javadoc)
- *
- * @see
- * org.richfaces.cdk.CdkWriter#render(org.richfaces.cdk.model.ComponentLibrary
- * )
- */
- @Override
- public void render(ComponentLibrary library) throws CdkException {
- // TODO - check modification time.
- File facesConfigXml = context.createOutputFile(
- StandardOutputs.FACES_CONFIG, FACES_CONFIG_XML, library.lastModified());
- if (null != facesConfigXml) {
- try {
- // TODO - transform output to strip prefixes from faces-config
- // namespace.
- jaxbBinding.marshal(facesConfigXml, FACES_SCHEMA_LOCATION,
- libraryAdapter.marshal(library));
- } catch (Exception e) {
- if (e instanceof CdkException) {
- throw (CdkException) e;
- } else {
- throw new CdkException(e);
- }
- }
+ // TODO - check modification time.
+ File facesConfigXml = context.createOutputFile(StandardOutputs.FACES_CONFIG, FACES_CONFIG_XML,
+ library.lastModified());
- }
- }
+ if (null != facesConfigXml) {
+ try {
+ // TODO - transform output to strip prefixes from faces-config
+ // namespace.
+ jaxbBinding.marshal(facesConfigXml, FACES_SCHEMA_LOCATION, libraryAdapter.marshal(library));
+ } catch (Exception e) {
+ if (e instanceof CdkException) {
+ throw(CdkException) e;
+ } else {
+ throw new CdkException(e);
+ }
+ }
+ }
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FacesConfigNamespacePreffixMapper.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FacesConfigNamespacePreffixMapper.java 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FacesConfigNamespacePreffixMapper.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.xmlconfig;
import org.richfaces.cdk.model.ComponentLibrary;
@@ -32,18 +34,19 @@
* @author asmirnov(a)exadel.com
*
*/
-public class FacesConfigNamespacePreffixMapper /*extends NamespacePrefixMapper*/ {
+public class FacesConfigNamespacePreffixMapper /* extends NamespacePrefixMapper */ {
- /* (non-Javadoc)
- * @see com.sun.xml.internal.bind.marshaller.NamespacePrefixMapper#getPreferredPrefix(java.lang.String, java.lang.String, boolean)
- */
- public String getPreferredPrefix(String namespaceUri, String suggestion, boolean required) {
- if(ComponentLibrary.FACES_CONFIG_NAMESPACE.equals(namespaceUri)){
- return "";
- } else if (ComponentLibrary.CDK_EXTENSIONS_NAMESPACE.equals(namespaceUri)) {
- return "cdk";
- }
- return suggestion;
- }
+ /*
+ * (non-Javadoc)
+ * @see com.sun.xml.internal.bind.marshaller.NamespacePrefixMapper#getPreferredPrefix(java.lang.String, java.lang.String, boolean)
+ */
+ public String getPreferredPrefix(String namespaceUri, String suggestion, boolean required) {
+ if (ComponentLibrary.FACES_CONFIG_NAMESPACE.equals(namespaceUri)) {
+ return "";
+ } else if (ComponentLibrary.CDK_EXTENSIONS_NAMESPACE.equals(namespaceUri)) {
+ return "cdk";
+ }
+ return suggestion;
+ }
}
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-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FacesConfigParser.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -21,11 +21,9 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.richfaces.cdk.xmlconfig;
-import java.io.File;
-import javax.xml.bind.JAXB;
+package org.richfaces.cdk.xmlconfig;
import org.richfaces.cdk.CdkContext;
import org.richfaces.cdk.CdkException;
@@ -34,54 +32,60 @@
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.xmlconfig.model.FacesConfigBean;
+import java.io.File;
+
/**
* <p class="changed_added_4_0"></p>
* @author asmirnov(a)exadel.com
*
*/
public class FacesConfigParser implements ModelBuilder {
+ private CdkContext context;
+ private JAXBBinding jaxbBinding;
- private CdkContext context;
- private JAXBBinding jaxbBinding;
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the context
+ */
+ public CdkContext getContext() {
+ return context;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the context
- */
- public CdkContext getContext() {
- return context;
- }
+ /*
+ * (non-Javadoc)
+ * @see org.richfaces.cdk.ModelBuilder#build()
+ */
+ @Override
+ public ComponentLibrary build() throws CdkException {
+ ComponentLibrary library = new ComponentLibrary();
- /* (non-Javadoc)
- * @see org.richfaces.cdk.ModelBuilder#build()
- */
- @Override
- public ComponentLibrary build() throws CdkException {
- ComponentLibrary library = new ComponentLibrary();
- for(File file :context.getSources(StandardSources.FACES_CONFIGS)){
- 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;
- }
+ for (File file : context.getSources(StandardSources.FACES_CONFIGS)) {
+ FacesConfigBean unmarshal = unmarshalFacesConfig(file);
- protected FacesConfigBean unmarshalFacesConfig(File file) throws CdkException {
- return jaxbBinding.unmarshal(file, ComponentLibrary.FACES_CONFIG_SCHEMA_LOCATION,FacesConfigBean.class);
- }
+ library.getComponents().addAll(unmarshal.getComponents());
- /* (non-Javadoc)
- * @see org.richfaces.cdk.ModelBuilder#init(org.richfaces.cdk.CdkContext)
- */
- @Override
- public void init(CdkContext context) throws CdkException {
- this.context = context;
- jaxbBinding = context.getWorkerInstance(JAXBBinding.class);
- }
+ // 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) throws CdkException {
+ this.context = context;
+ jaxbBinding = context.getWorkerInstance(JAXBBinding.class);
+ }
}
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-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FragmentParser.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.xmlconfig;
import java.util.Collection;
@@ -38,44 +40,41 @@
* That class parses xml document with fragment of faces-config ( eg, standard
* component attributes )
* </p>
- *
+ *
* @author asmirnov(a)exadel.com
- *
+ *
*/
public class FragmentParser implements CdkWorker {
+ private JAXBBinding binding;
+ private CdkContext context;
- private CdkContext context;
- private JAXBBinding binding;
+ public FragmentParser() {}
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param context
+ * @throws CdkException
+ */
+ public void init(CdkContext context) throws CdkException {
+ this.context = context;
+ binding = context.getWorkerInstance(JAXBBinding.class);
+ }
-
- public FragmentParser() {
- }
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @param context
- * @throws CdkException
- */
- public void init(CdkContext context) throws CdkException {
- this.context = context;
- binding = context.getWorkerInstance(JAXBBinding.class);
- }
+ /**
+ * <p class="changed_added_4_0">
+ * Parses faces-config.xml fragment with component/renderer properties.
+ * </p>
+ *
+ * @param url
+ * @return
+ */
+ public Collection<Property> parseProperties(String url) throws CdkException {
+ String schemaLocation = ComponentLibrary.FACES_CONFIG_SCHEMA_LOCATION;
+ Class<Properties> bindClass = Properties.class;
+ Properties unmarshal = binding.unmarshal(url, schemaLocation, bindClass);
- /**
- * <p class="changed_added_4_0">
- * Parses faces-config.xml fragment with component/renderer properties.
- * </p>
- *
- * @param url
- * @return
- */
- public Collection<Property> parseProperties(String url) throws CdkException {
- 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();
- }
-
+ return null == unmarshal ? Collections.<Property>emptySet() : unmarshal.getProperty();
+ }
}
Modified: 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 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/JAXBBinding.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -21,10 +21,13 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.xmlconfig;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
+
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
@@ -32,10 +35,13 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
+
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
+
import java.net.URI;
import java.net.URISyntaxException;
+
import java.util.Collection;
import javax.xml.bind.JAXBContext;
@@ -50,6 +56,7 @@
import javax.xml.transform.stream.StreamResult;
import org.apache.cocoon.pipeline.component.sax.XIncludeTransformer;
+
import org.richfaces.cdk.CdkContext;
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.CdkWorker;
@@ -57,6 +64,7 @@
import org.richfaces.cdk.model.Extensible;
import org.richfaces.cdk.model.Key;
import org.richfaces.cdk.model.ModelElement;
+
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
@@ -67,344 +75,362 @@
/**
* <p class="changed_added_4_0">
* </p>
- *
+ *
* @author asmirnov(a)exadel.com
- *
+ *
*/
public class JAXBBinding implements CdkWorker {
+ private static final FacesConfigNamespacePreffixMapper PREFFIX_MAPPER = new FacesConfigNamespacePreffixMapper();
+ private static final ImmutableSet<String> IGNORE_PROPERTIES = ImmutableSet.of("class", "extension");
- private static final FacesConfigNamespacePreffixMapper PREFFIX_MAPPER = new FacesConfigNamespacePreffixMapper();
+ private CdkContext context;
+ private CdkEntityResolver resolver;
- private CdkContext context;
+ public JAXBBinding() { }
- private CdkEntityResolver resolver;
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param context
+ */
+ public void init(CdkContext context) throws CdkException {
+ this.context = context;
+ this.resolver = new CdkEntityResolver(context);
+ }
- public JAXBBinding() {
+ public <T> T unmarshal(File file, String schemaLocation, Class<T> bindClass) throws CdkException {
+ try {
+ InputSource input = new InputSource(new FileInputStream(file));
- }
+ input.setSystemId(file.toURI().toString());
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @param context
- */
- public void init(CdkContext context) throws CdkException {
- this.context = context;
- this.resolver = new CdkEntityResolver(context);
- }
+ T unmarshal = unmarshal(schemaLocation, bindClass, input);
- public <T> T unmarshal(File file, String schemaLocation, Class<T> bindClass)
- throws CdkException {
- try {
- InputSource input = new InputSource(new FileInputStream(file));
- input.setSystemId(file.toURI().toString());
- T unmarshal = unmarshal(schemaLocation, bindClass, input);
- return unmarshal;
- } catch (FileNotFoundException e) {
- throw new CdkException("XML file not found", e);
- }
- }
+ 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);
- }
- }
+ public <T> T unmarshal(String url, String schemaLocation, Class<T> bindClass) throws CdkException {
+ try {
+ InputSource inputSource = resolver.resolveSystemId(url);
- @SuppressWarnings("unchecked")
- public <T> T unmarshal(String schemaLocation, Class<T> bindClass,
- InputSource inputSource) throws CdkException {
- T unmarshal = null;
- try {
+ 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")
+ public <T> T unmarshal(String schemaLocation, Class<T> bindClass, InputSource inputSource) throws CdkException {
+ T unmarshal = null;
+
+ try {
XMLReader xmlReader = XMLReaderFactory.createXMLReader();
+
xmlReader.setEntityResolver(resolver);
xmlReader.setFeature("http://xml.org/sax/features/validation", true);
xmlReader.setFeature("http://apache.org/xml/features/validation/schema", true);
xmlReader.setFeature("http://apache.org/xml/features/validation/dynamic", true);
- // Setup JAXB to unmarshal
- // TODO - create xinclude content handler that process xinclude directives
- // and send SAX event to the unmarshaller handler.
- JAXBContext jc = JAXBContext.newInstance(bindClass);
- Unmarshaller u = jc.createUnmarshaller();
- ValidationEventCollector vec = new ValidationEventCollector();
- u.setEventHandler(vec);
+
+ // Setup JAXB to unmarshal
+ // TODO - create xinclude content handler that process xinclude directives
+ // and send SAX event to the unmarshaller handler.
+ JAXBContext jc = JAXBContext.newInstance(bindClass);
+ Unmarshaller u = jc.createUnmarshaller();
+ ValidationEventCollector vec = new ValidationEventCollector();
+
+ u.setEventHandler(vec);
+
XIncludeTransformer xIncludeTransformer = new XIncludeTransformer();
- if(null != inputSource.getSystemId()){
- xIncludeTransformer.setBaseUri(new URI(inputSource.getSystemId()));
+
+ if (null != inputSource.getSystemId()) {
+ xIncludeTransformer.setBaseUri(new URI(inputSource.getSystemId()));
}
+
UnmarshallerHandler unmarshallerHandler = u.getUnmarshallerHandler();
- xIncludeTransformer.setContentHandler(unmarshallerHandler);
- xIncludeTransformer.setResolver(resolver);
- xmlReader.setContentHandler(xIncludeTransformer);
+
+ xIncludeTransformer.setContentHandler(unmarshallerHandler);
+ xIncludeTransformer.setResolver(resolver);
+ xmlReader.setContentHandler(xIncludeTransformer);
xmlReader.setProperty("http://xml.org/sax/properties/lexical-handler", xIncludeTransformer);
- xmlReader.parse(inputSource);
- // turn off the JAXB provider's default validation mechanism to
- // avoid duplicate validation
- // u.setValidating(false);
- unmarshal = (T) unmarshallerHandler.getResult();
- } catch (JAXBException e) {
- throw new CdkException("JAXB Unmarshaller error", e);
- } catch (URISyntaxException e) {
- throw new CdkException("Invalid XML source URI", e);
- } catch (IOException e) {
- throw new CdkException("JAXB Unmarshaller input error", e);
- } catch (SAXException e) {
- throw new CdkException("XML error", e);
- } finally {
- }
- return unmarshal;
- }
-
- public <T> void marshal(File output,String schemaLocation,T model) throws CdkException {
- try {
- FileOutputStream outputStream = new FileOutputStream(output);
- StreamResult result = new StreamResult(outputStream);
- marshal(result, schemaLocation, model);
- outputStream.flush();
- outputStream.close();
- } catch (FileNotFoundException e) {
- throw new CdkException("File not found", e);
- } catch (IOException e) {
- throw new CdkException("XML file writting error", e);
- }
-
- }
+ xmlReader.parse(inputSource);
+ // turn off the JAXB provider's default validation mechanism to
+ // avoid duplicate validation
+ // u.setValidating(false);
+ unmarshal = (T) unmarshallerHandler.getResult();
+ } catch (JAXBException e) {
+ throw new CdkException("JAXB Unmarshaller error", e);
+ } catch (URISyntaxException e) {
+ throw new CdkException("Invalid XML source URI", e);
+ } catch (IOException e) {
+ throw new CdkException("JAXB Unmarshaller input error", e);
+ } catch (SAXException e) {
+ throw new CdkException("XML error", e);
+ } finally {
- public <T> void marshal(Result output,String schemaLocation,T model) throws CdkException {
- try {
- JAXBContext jc = JAXBContext.newInstance(model.getClass());
- Marshaller marshaller = jc.createMarshaller();
- marshaller.setProperty("jaxb.formatted.output", Boolean.TRUE);
- // TODO - let writer to define additional schemes.
-// marshaller.setProperty("jaxb.schemaLocation", Boolean.TRUE);
- marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT,
- true);
- if (null != schemaLocation) {
- marshaller.setProperty(Marshaller.JAXB_SCHEMA_LOCATION,
- schemaLocation);
-// marshaller.setProperty("com.sun.xml.bind.namespacePrefixMapper", PREFFIX_MAPPER);
- }
- marshaller.marshal(model, output);
- } catch (JAXBException e) {
- throw new CdkException("JAXB Marshaller error", e);
- } finally {
-
- }
- }
- /**
- * <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.
- }
- }
- }
+ // TODO Refactoring
+ }
- private static final ImmutableSet<String> ignoreProperties = ImmutableSet.of("class","extension");
- /**
- * <p class="changed_added_4_0">
- * This method creates adapter object and copies properties from model
- * object to adapter.
- * </p>
- *
- * @param <A>
- * type of adapter object
- * @param <T>
- * type of model object.
- * @param adapterClass
- * adapter class.
- * @param modelObject
- * model object class.
- * @return initialized instance of adapter object.
- */
- public static <A, T> A createAdapter(Class<A> adapterClass, T modelObject)
- throws CdkException {
- try {
- A adapter = adapterClass.newInstance();
- // Copy properties from model to adapter.
- copyProperties(modelObject, adapter);
- copyExtensions(modelObject, adapter, true);
- return adapter;
- } catch (InstantiationException e) {
- throw new CdkException("JAXB adapter class instantiation error", e);
- } catch (IllegalAccessException e) {
- throw new CdkException("JAXB adapter class instantiation error", e);
- }
- }
+ return unmarshal;
+ }
- public static <A, T extends ModelElement<? super T, K>, K extends Key> T createModelElement(
- Class<T> modelClass, A adapter, K key) throws CdkException {
- try {
- Constructor<T> constructor = modelClass.getConstructor(key
- .getClass());
- T modelBean = constructor.newInstance(key);
- copyProperties(adapter, modelBean);
- copyExtensions(adapter, modelBean, false);
- return modelBean;
- } catch (Exception e) {
- throw new CdkException("CDK model class instantiation error", e);
- }
- }
+ public <T> void marshal(File output, String schemaLocation, T model) throws CdkException {
+ try {
+ FileOutputStream outputStream = new FileOutputStream(output);
+ StreamResult result = new StreamResult(outputStream);
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @param <S>
- * @param <D>
- * @param source
- * @param destination
- * @param fromModel
- * @throws CdkException
- */
- public static <S, D> void copyExtensions(S source, D destination,
- boolean fromModel) throws CdkException {
- try {
- if (source instanceof Extensible
- && destination instanceof Extensible) {
- Extensible extensibleSource = (Extensible) source;
- Extensible<ConfigExtension> extensibleDestination = (Extensible<ConfigExtension>) destination;
- ConfigExtension sourceExtension = extensibleSource
- .getExtension();
- if (null != sourceExtension) {
- ConfigExtension destinationExtension = createExtension(destination);
- destinationExtension.setExtensions(sourceExtension
- .getExtensions());
- if (fromModel) {
- copyProperties(source, destinationExtension);
- } else {
- copyProperties(sourceExtension, destination);
- }
- extensibleDestination.setExtension(destinationExtension);
- } else if (fromModel) {
- ConfigExtension destinationExtension = createExtension(destination);
- copyProperties(source, destinationExtension);
- extensibleDestination.setExtension(destinationExtension);
- }
- }
- } catch (Exception e) {
- throw new CdkException("Properties copiing error", e);
- }
- }
+ marshal(result, schemaLocation, model);
+ outputStream.flush();
+ outputStream.close();
+ } catch (FileNotFoundException e) {
+ throw new CdkException("File not found", e);
+ } catch (IOException e) {
+ throw new CdkException("XML file writting error", e);
+ }
+ }
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @param <D>
- * @param destination
- * @return
- * @throws NoSuchMethodException
- * @throws InstantiationException
- * @throws IllegalAccessException
- */
- private static <D> ConfigExtension createExtension(D destination)
- throws NoSuchMethodException, InstantiationException,
- IllegalAccessException {
- Method method = destination.getClass().getMethod("getExtension");
- Class<? extends ConfigExtension> destinationExtensionType = (Class<? extends ConfigExtension>) method
- .getReturnType();
- ConfigExtension destinationExtension = destinationExtensionType
- .newInstance();
- return destinationExtension;
- }
+ public <T> void marshal(Result output, String schemaLocation, T model) throws CdkException {
+ try {
+ JAXBContext jc = JAXBContext.newInstance(model.getClass());
+ Marshaller marshaller = jc.createMarshaller();
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @param <S>
- * @param <D>
- * @param source
- * @param destination
- * @throws CdkException
- */
- public static <S, D> void copyProperties(S source, D destination)
- throws CdkException {
- try {
- PropertyDescriptor[] targetProperties = Introspector.getBeanInfo(
- destination.getClass()).getPropertyDescriptors();
- PropertyDescriptor[] sourceProperties = Introspector.getBeanInfo(
- source.getClass()).getPropertyDescriptors();
- for (PropertyDescriptor targetProperty : targetProperties) {
- Method writeMethod = targetProperty.getWriteMethod();
- String name = targetProperty.getName();
- for (PropertyDescriptor sourceProperty : sourceProperties) {
- Method readMethod = sourceProperty.getReadMethod();
- if (!ignoreProperties.contains(name) && name.equals(sourceProperty.getName())
- && null != readMethod) {
- Class<?> targetType = targetProperty.getPropertyType();
- Class<?> sourceType = sourceProperty.getPropertyType();
- Object propertyValue = readMethod.invoke(source);
- if (null != propertyValue) {
- if (null != writeMethod) {
- if (targetType.equals(sourceType)) {
- writeMethod.invoke(destination,
- propertyValue);
- } else if (targetType.equals(String.class)) {
- writeMethod.invoke(destination,
- propertyValue.toString());
- } else if (isCollections(targetType, propertyValue)) {
- Collection targetCollection = (Collection) targetProperty
- .getReadMethod()
- .invoke(destination);
- if (null != targetCollection) {
- targetCollection
- .addAll((Collection) propertyValue);
- } else {
- writeMethod.invoke(destination,
- propertyValue);
- }
- }
- } else if (isCollections(targetType, propertyValue)) {
- Collection targetCollection = (Collection) targetProperty
- .getReadMethod().invoke(destination);
- if (null != targetCollection) {
- targetCollection
- .addAll((Collection) propertyValue);
- }
- }
- }
- }
- }
- }
- } catch (Exception e) {
- throw new CdkException("Properties copiing error", e);
- }
- }
+ marshaller.setProperty("jaxb.formatted.output", Boolean.TRUE);
- private static boolean isCollections(Class<?> targetType, Object propertyValue) {
- return Collection.class
- .isAssignableFrom(targetType)
- && propertyValue instanceof Collection;
- }
+ // TODO - let writer to define additional schemes.
+// marshaller.setProperty("jaxb.schemaLocation", Boolean.TRUE);
+ marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
+ if (null != schemaLocation) {
+ marshaller.setProperty(Marshaller.JAXB_SCHEMA_LOCATION, schemaLocation);
+
+// marshaller.setProperty("com.sun.xml.bind.namespacePrefixMapper", PREFFIX_MAPPER);
+ }
+
+ marshaller.marshal(model, output);
+ } catch (JAXBException e) {
+ throw new CdkException("JAXB Marshaller error", e);
+ } finally {
+
+ // TODO Refactoring
+ }
+ }
+
+ /**
+ * <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.
+ }
+ }
+ }
+
+ /**
+ * <p class="changed_added_4_0">
+ * This method creates adapter object and copies properties from model
+ * object to adapter.
+ * </p>
+ *
+ * @param <A>
+ * type of adapter object
+ * @param <T>
+ * type of model object.
+ * @param adapterClass
+ * adapter class.
+ * @param modelObject
+ * model object class.
+ * @return initialized instance of adapter object.
+ */
+ public static <A, T> A createAdapter(Class<A> adapterClass, T modelObject) throws CdkException {
+ try {
+ A adapter = adapterClass.newInstance();
+
+ // Copy properties from model to adapter.
+ copyProperties(modelObject, adapter);
+ copyExtensions(modelObject, adapter, true);
+
+ return adapter;
+ } catch (InstantiationException e) {
+ throw new CdkException("JAXB adapter class instantiation error", e);
+ } catch (IllegalAccessException e) {
+ throw new CdkException("JAXB adapter class instantiation error", e);
+ }
+ }
+
+ public static <A, T extends ModelElement<? super T, K>, K extends Key> T createModelElement(Class<T> modelClass,
+ A adapter, K key) throws CdkException {
+
+ try {
+ Constructor<T> constructor = modelClass.getConstructor(key.getClass());
+ T modelBean = constructor.newInstance(key);
+
+ copyProperties(adapter, modelBean);
+ copyExtensions(adapter, modelBean, false);
+
+ return modelBean;
+ } catch (Exception e) {
+ throw new CdkException("CDK model class instantiation error", e);
+ }
+ }
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param <S>
+ * @param <D>
+ * @param source
+ * @param destination
+ * @param fromModel
+ * @throws CdkException
+ */
+ public static <S, D> void copyExtensions(S source, D destination, boolean fromModel) throws CdkException {
+ try {
+ if (source instanceof Extensible && destination instanceof Extensible) {
+ Extensible extensibleSource = (Extensible) source;
+ Extensible<ConfigExtension> extensibleDestination = (Extensible<ConfigExtension>) destination;
+ ConfigExtension sourceExtension = extensibleSource.getExtension();
+
+ if (null != sourceExtension) {
+ ConfigExtension destinationExtension = createExtension(destination);
+
+ destinationExtension.setExtensions(sourceExtension.getExtensions());
+
+ if (fromModel) {
+ copyProperties(source, destinationExtension);
+ } else {
+ copyProperties(sourceExtension, destination);
+ }
+
+ extensibleDestination.setExtension(destinationExtension);
+ } else if (fromModel) {
+ ConfigExtension destinationExtension = createExtension(destination);
+
+ copyProperties(source, destinationExtension);
+ extensibleDestination.setExtension(destinationExtension);
+ }
+ }
+ } catch (Exception e) {
+ throw new CdkException("Properties copiing error", e);
+ }
+ }
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param <D>
+ * @param destination
+ * @return
+ * @throws NoSuchMethodException
+ * @throws InstantiationException
+ * @throws IllegalAccessException
+ */
+ private static <D> ConfigExtension createExtension(D destination)
+ throws NoSuchMethodException, InstantiationException, IllegalAccessException {
+
+ Method method = destination.getClass().getMethod("getExtension");
+ Class<? extends ConfigExtension> destinationExtensionType =
+ (Class<? extends ConfigExtension>) method.getReturnType();
+
+ return destinationExtensionType.newInstance();
+ }
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param <S>
+ * @param <D>
+ * @param source
+ * @param destination
+ * @throws CdkException
+ */
+ public static <S, D> void copyProperties(S source, D destination) throws CdkException {
+ try {
+ PropertyDescriptor[] targetProperties =
+ Introspector.getBeanInfo(destination.getClass()).getPropertyDescriptors();
+ PropertyDescriptor[] sourceProperties =
+ Introspector.getBeanInfo(source.getClass()).getPropertyDescriptors();
+
+ for (PropertyDescriptor targetProperty : targetProperties) {
+ Method writeMethod = targetProperty.getWriteMethod();
+ String name = targetProperty.getName();
+
+ for (PropertyDescriptor sourceProperty : sourceProperties) {
+ Method readMethod = sourceProperty.getReadMethod();
+
+ if (!IGNORE_PROPERTIES.contains(name) && name.equals(sourceProperty.getName())
+ && null != readMethod) {
+ Class<?> targetType = targetProperty.getPropertyType();
+ Class<?> sourceType = sourceProperty.getPropertyType();
+ Object propertyValue = readMethod.invoke(source);
+
+ if (null != propertyValue) {
+ if (null != writeMethod) {
+ if (targetType.equals(sourceType)) {
+ writeMethod.invoke(destination, propertyValue);
+ } else if (targetType.equals(String.class)) {
+ writeMethod.invoke(destination, propertyValue.toString());
+ } else if (isCollections(targetType, propertyValue)) {
+ Collection targetCollection =
+ (Collection) targetProperty.getReadMethod().invoke(destination);
+
+ if (null != targetCollection) {
+ targetCollection.addAll((Collection) propertyValue);
+ } else {
+ writeMethod.invoke(destination, propertyValue);
+ }
+ }
+ } else if (isCollections(targetType, propertyValue)) {
+ Collection targetCollection =
+ (Collection) targetProperty.getReadMethod().invoke(destination);
+
+ if (null != targetCollection) {
+ targetCollection.addAll((Collection) propertyValue);
+ }
+ }
+ }
+ }
+ }
+ }
+ } catch (Exception e) {
+ throw new CdkException("Properties copiing error", e);
+ }
+ }
+
+ private static boolean isCollections(Class<?> targetType, Object propertyValue) {
+ return Collection.class.isAssignableFrom(targetType) && propertyValue instanceof Collection;
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/AttributeAdapter.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/AttributeAdapter.java 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/AttributeAdapter.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* 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;
@@ -35,15 +37,13 @@
*
*/
public class AttributeAdapter extends XmlAdapter<AttributeBean, Attribute> {
+ @Override
+ public AttributeBean marshal(Attribute v) throws Exception {
+ return JAXBBinding.createAdapter(AttributeBean.class, v);
+ }
- @Override
- public AttributeBean marshal(Attribute v) throws Exception {
- return JAXBBinding.createAdapter(AttributeBean.class, v);
- }
-
- @Override
- public Attribute unmarshal(AttributeBean v) throws Exception {
- return JAXBBinding.createModelElement(Attribute.class, v, new Property.Name(v.getName()));
- }
-
+ @Override
+ public Attribute unmarshal(AttributeBean v) throws Exception {
+ return JAXBBinding.createModelElement(Attribute.class, v, new Property.Name(v.getName()));
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/AttributeBean.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/AttributeBean.java 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/AttributeBean.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.xmlconfig.model;
import javax.xml.bind.annotation.XmlElement;
@@ -36,99 +38,94 @@
* @author asmirnov(a)exadel.com
*
*/
-public class AttributeBean extends DescriptionGroupBean implements Extensible<PropertyBean.PropertyExtension>{
- private String name;
+public class AttributeBean extends DescriptionGroupBean implements Extensible<PropertyBean.PropertyExtension> {
+ private String defaultValue;
+ private PropertyExtension extension;
+ private String name;
+ private String suggestedValue;
+ private ClassDescription type;
- private ClassDescription type;
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the name
+ */
+ @XmlElement(name = "attribute-name", namespace = ComponentLibrary.FACES_CONFIG_NAMESPACE)
+ public String getName() {
+ return name;
+ }
- private String defaultValue;
-
- private String suggestedValue;
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param name the name to set
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
- private PropertyExtension extension;
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the type
+ */
+ @XmlElement(name = "attribute-class", namespace = ComponentLibrary.FACES_CONFIG_NAMESPACE)
+ @XmlJavaTypeAdapter(ClassAdapter.class)
+ public ClassDescription getType() {
+ return type;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the name
- */
- @XmlElement(name="attribute-name",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
- public String getName() {
- return name;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param type the type to set
+ */
+ public void setType(ClassDescription type) {
+ this.type = type;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param name the name to set
- */
- public void setName(String name) {
- this.name = name;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the defaultValue
+ */
+ @XmlElement(name = "default-value", namespace = ComponentLibrary.FACES_CONFIG_NAMESPACE)
+ public String getDefaultValue() {
+ return defaultValue;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the type
- */
- @XmlElement(name="attribute-class",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
- @XmlJavaTypeAdapter(ClassAdapter.class)
- public ClassDescription getType() {
- return type;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param defaultValue the defaultValue to set
+ */
+ public void setDefaultValue(String defaultValue) {
+ this.defaultValue = defaultValue;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param type the type to set
- */
- public void setType(ClassDescription type) {
- this.type = type;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the suggestedValue
+ */
+ @XmlElement(name = "suggested-value", namespace = ComponentLibrary.FACES_CONFIG_NAMESPACE)
+ public String getSuggestedValue() {
+ return suggestedValue;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the defaultValue
- */
- @XmlElement(name="default-value",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
- public String getDefaultValue() {
- return defaultValue;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param suggestedValue the suggestedValue to set
+ */
+ public void setSuggestedValue(String suggestedValue) {
+ this.suggestedValue = suggestedValue;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param defaultValue the defaultValue to set
- */
- public void setDefaultValue(String defaultValue) {
- this.defaultValue = defaultValue;
- }
+ @Override
+ @XmlElement(name = "attribute-extension", namespace = ComponentLibrary.FACES_CONFIG_NAMESPACE)
+ public PropertyExtension getExtension() {
+ return extension;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the suggestedValue
- */
- @XmlElement(name="suggested-value",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
- public String getSuggestedValue() {
- return suggestedValue;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @param suggestedValue the suggestedValue to set
- */
- public void setSuggestedValue(String suggestedValue) {
- this.suggestedValue = suggestedValue;
- }
-
- @Override
- @XmlElement(name="attribute-extension",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
- public PropertyExtension getExtension() {
- return extension;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @param extension the extension to set
- */
- @Override
- public void setExtension(PropertyExtension extension) {
- this.extension = extension;
- }
-
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param extension the extension to set
+ */
+ @Override
+ public void setExtension(PropertyExtension extension) {
+ this.extension = extension;
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/BehaviorRendererAdapter.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/BehaviorRendererAdapter.java 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/BehaviorRendererAdapter.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* 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;
@@ -34,15 +36,13 @@
*
*/
public class BehaviorRendererAdapter extends XmlAdapter<BehaviorRendererBean, BehaviorRenderer> {
+ @Override
+ public BehaviorRendererBean marshal(BehaviorRenderer v) throws Exception {
+ return JAXBBinding.createAdapter(BehaviorRendererBean.class, v);
+ }
- @Override
- public BehaviorRendererBean marshal(BehaviorRenderer v) throws Exception {
- return JAXBBinding.createAdapter(BehaviorRendererBean.class, v);
- }
-
- @Override
- public BehaviorRenderer unmarshal(BehaviorRendererBean v) throws Exception {
- return JAXBBinding.createModelElement(BehaviorRenderer.class, v, new BehaviorRenderer.Type(v.getType()));
- }
-
+ @Override
+ public BehaviorRenderer unmarshal(BehaviorRendererBean v) throws Exception {
+ return JAXBBinding.createModelElement(BehaviorRenderer.class, v, new BehaviorRenderer.Type(v.getType()));
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/BehaviorRendererBean.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/BehaviorRendererBean.java 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/BehaviorRendererBean.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.xmlconfig.model;
import javax.xml.bind.annotation.XmlElement;
@@ -36,65 +38,60 @@
* @author asmirnov(a)exadel.com
*
*/
-@XmlType(name="faces-config-client-behavior-rendererType",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
+@XmlType(name = "faces-config-client-behavior-rendererType", namespace = ComponentLibrary.FACES_CONFIG_NAMESPACE)
public class BehaviorRendererBean {
+ private ClassDescription rendererClass;
+ private String type;
- /**
- * <p class="changed_added_4_0"></p>
- * @author asmirnov(a)exadel.com
- *
- */
- public static class BehaviorRendererExtension extends ConfigExtension {
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the type
+ */
+ @XmlElement(name = "client-behavior-renderer-type", namespace = ComponentLibrary.FACES_CONFIG_NAMESPACE)
+ public String getType() {
+ return type;
+ }
- }
-
- private String type;
-
-
- private ClassDescription rendererClass;
+ /**
+ * <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 type
- */
- @XmlElement(name="client-behavior-renderer-type",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
- public String getType() {
- return type;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the rendererClass
+ */
+ @XmlElement(name = "client-behavior-renderer-class", namespace = ComponentLibrary.FACES_CONFIG_NAMESPACE)
+ @XmlJavaTypeAdapter(ClassAdapter.class)
+ public ClassDescription getRendererClass() {
+ return rendererClass;
+ }
- /**
- * <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>
+ * @param rendererClass the rendererClass to set
+ */
+ public void setRendererClass(ClassDescription rendererClass) {
+ this.rendererClass = rendererClass;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the rendererClass
- */
- @XmlElement(name="client-behavior-renderer-class",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
- @XmlJavaTypeAdapter(ClassAdapter.class)
- public ClassDescription getRendererClass() {
- return rendererClass;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+ public static class BehaviorRendererExtension extends ConfigExtension {}
- /**
- * <p class="changed_added_4_0"></p>
- * @param rendererClass the rendererClass to set
- */
- public void setRendererClass(ClassDescription rendererClass) {
- this.rendererClass = rendererClass;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the extension
+ */
- /**
- * <p class="changed_added_4_0"></p>
- * @return the extension
- */
-// @XmlElement(name="client-behavior-renderer-extension",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
-// public BehaviorRendererExtension getExtension() {
-// return super.getExtension();
-// }
-
+// @XmlElement(name="client-behavior-renderer-extension",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
+// public BehaviorRendererExtension getExtension() {
+// return super.getExtension();
+// }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ClassAdapter.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ClassAdapter.java 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ClassAdapter.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* 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;
@@ -33,17 +35,17 @@
*
*/
public class ClassAdapter extends XmlAdapter<ClassBean, ClassDescription> {
+ @Override
+ public ClassBean marshal(ClassDescription v) throws Exception {
+ ClassBean bean = new ClassBean();
- @Override
- public ClassBean marshal(ClassDescription v) throws Exception {
- ClassBean bean = new ClassBean();
- bean.setName(v.getName());
- return bean;
- }
+ bean.setName(v.getName());
- @Override
- public ClassDescription unmarshal(ClassBean v) throws Exception {
- return new ClassDescription(v.getName());
- }
+ return bean;
+ }
+ @Override
+ public ClassDescription unmarshal(ClassBean v) throws Exception {
+ return new ClassDescription(v.getName());
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ClassBean.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ClassBean.java 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ClassBean.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.xmlconfig.model;
import javax.xml.bind.annotation.XmlType;
@@ -33,26 +35,24 @@
* @author asmirnov(a)exadel.com
*
*/
-@XmlType(name="fully-qualified-classType",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
+@XmlType(name = "fully-qualified-classType", namespace = ComponentLibrary.FACES_CONFIG_NAMESPACE)
public class ClassBean {
-
- private String name;
+ private String name;
- /**
- * <p class="changed_added_4_0"></p>
- * @return the name
- */
- @XmlValue
- public String getName() {
- return name;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the name
+ */
+ @XmlValue
+ public String getName() {
+ return name;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param name the name to set
- */
- public void setName(String name) {
- this.name = name;
- }
-
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param name the name to set
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
}
Modified: 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 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ComponentAdapter.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* 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;
@@ -34,19 +36,19 @@
*
*/
public class ComponentAdapter extends XmlAdapter<ComponentBean, Component> {
+ @Override
+ public ComponentBean marshal(Component v) throws Exception {
+ ComponentBean bean = JAXBBinding.createAdapter(ComponentBean.class, v);
- @Override
- public ComponentBean marshal(Component v) throws Exception {
- ComponentBean bean = JAXBBinding.createAdapter(ComponentBean.class, v);
- // TODO - copy renderer types.
- return bean;
- }
+ // TODO - copy renderer types.
+ return bean;
+ }
- @Override
- public Component unmarshal(ComponentBean v) throws Exception {
- Component component = JAXBBinding.createModelElement(Component.class, v, new Component.Type(v.getType()));
- // TODO - copy renderer types.
- return component;
- }
+ @Override
+ public Component unmarshal(ComponentBean v) throws Exception {
+ Component component = JAXBBinding.createModelElement(Component.class, v, new Component.Type(v.getType()));
+ // TODO - copy renderer types.
+ return component;
+ }
}
Modified: 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 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ComponentBean.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.xmlconfig.model;
import java.util.List;
@@ -44,199 +46,200 @@
* @author asmirnov(a)exadel.com
*
*/
-@XmlType(name="faces-config-componentType",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
+@XmlType(name = "faces-config-componentType", namespace = ComponentLibrary.FACES_CONFIG_NAMESPACE)
public class ComponentBean extends ExtensibleBean<ComponentBean.ComponentExtension> {
+ private List<Property> attributes = Lists.newArrayList();
+ private List<Facet> facets = Lists.newArrayList();
+ private ClassDescription componentClass;
+ private String type;
- private String type;
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the type
+ */
+ @XmlElement(name = "component-type", namespace = ComponentLibrary.FACES_CONFIG_NAMESPACE)
+ public String getType() {
+ return type;
+ }
- private ClassDescription componentClass;
+ /**
+ * <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 componentClass
+ */
+ @XmlElement(name = "component-class", namespace = ComponentLibrary.FACES_CONFIG_NAMESPACE)
+ @XmlJavaTypeAdapter(ClassAdapter.class)
+ public ClassDescription getComponentClass() {
+ return componentClass;
+ }
- private List<Property> attributes = Lists.newArrayList();
-
- private List<Facet> facets = Lists.newArrayList();
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param componentClass the componentClass to set
+ */
+ public void setComponentClass(ClassDescription className) {
+ this.componentClass = className;
+ }
- /**
- * <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>
+ * @return the attributes
+ */
+ @XmlElements({@XmlElement(
+ name = "property",
+ namespace = ComponentLibrary.FACES_CONFIG_NAMESPACE,
+ type = PropertyBean.class
+ ) , @XmlElement(
+ name = "attribute",
+ namespace = ComponentLibrary.FACES_CONFIG_NAMESPACE,
+ type = AttributeBean.class
+ ) })
- /**
- * <p class="changed_added_4_0"></p>
- * @param type the type to set
- */
- public void setType(String type) {
- this.type = type;
- }
+// @XmlElement(name="attributes",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
+ public List<Property> getAttributes() {
+ return attributes;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the componentClass
- */
- @XmlElement(name="component-class",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
- @XmlJavaTypeAdapter(ClassAdapter.class)
- public ClassDescription getComponentClass() {
- return componentClass;
- }
+ /**
+ * <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>
- * @param componentClass the componentClass to set
- */
- public void setComponentClass(ClassDescription className) {
- this.componentClass = 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",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE,type=AttributeBean.class)})
-// @XmlElement(name="attributes",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
- public List<Property> getAttributes() {
- return attributes;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the facets
+ */
+ @XmlElement(name = "facet", namespace = ComponentLibrary.FACES_CONFIG_NAMESPACE)
+ @XmlJavaTypeAdapter(FacetAdapter.class)
+ public List<Facet> getFacets() {
+ return facets;
+ }
- /**
- * <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 facets
- */
- @XmlElement(name="facet",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
- @XmlJavaTypeAdapter(FacetAdapter.class)
- public List<Facet> getFacets() {
- return facets;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param facets the facets to set
+ */
+ public void setFacets(List<Facet> facets) {
+ this.facets = facets;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param facets the facets to set
- */
- public void setFacets(List<Facet> facets) {
- this.facets = facets;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the extension
+ */
+ @XmlElement(name = "component-extension", namespace = ComponentLibrary.FACES_CONFIG_NAMESPACE)
+ @Override
+ public ComponentExtension getExtension() {
+ return super.getExtension();
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the extension
- */
- @XmlElement(name="component-extension",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
- @Override
- public ComponentExtension getExtension() {
- return super.getExtension();
- }
-
- @Override
- public void setExtension(ComponentExtension extension) {
- super.setExtension(extension);
- }
+ @Override
+ public void setExtension(ComponentExtension extension) {
+ super.setExtension(extension);
+ }
- public static class ComponentExtension extends ConfigExtension {
-
- private String family;
+ public static class ComponentExtension extends ConfigExtension {
+ private List<String> rendererTypes = Lists.newArrayList();
+ private List<Event> events = Lists.newArrayList();
+ private ClassDescription baseClass;
+ private String family;
+ private boolean generate;
- private ClassDescription baseClass;
-
- private boolean generate;
-
- private List<String> rendererTypes = Lists.newArrayList();
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param family the family to set
+ */
+ public void setFamily(String family) {
+ this.family = family;
+ }
- private List<Event> events = Lists.newArrayList();
- /**
- * <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;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the family
- */
- @XmlElement(name="component-family",namespace=ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
- public String getFamily() {
- return family;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the baseClass
+ */
+ @XmlElement(name = "base-class", namespace = ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
+ @XmlJavaTypeAdapter(ClassAdapter.class)
+ public ClassDescription getBaseClass() {
+ return baseClass;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the baseClass
- */
- @XmlElement(name="base-class",namespace=ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
- @XmlJavaTypeAdapter(ClassAdapter.class)
- public ClassDescription getBaseClass() {
- return baseClass;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param baseClass the baseClass to set
+ */
+ public void setBaseClass(ClassDescription baseClass) {
+ this.baseClass = baseClass;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param baseClass the baseClass to set
- */
- public void setBaseClass(ClassDescription baseClass) {
- this.baseClass = baseClass;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the generate
+ */
+ @XmlElement(name = "generate", namespace = ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
+ public boolean isGenerate() {
+ return generate;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the generate
- */
- @XmlElement(name="generate",namespace=ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
- public boolean isGenerate() {
- return generate;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param generate the generate to set
+ */
+ public void setGenerate(boolean generate) {
+ this.generate = generate;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param generate the generate to set
- */
- public void setGenerate(boolean generate) {
- this.generate = generate;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param rendererTypes the rendererTypes to set
+ */
+ @XmlElement(name = "renderer-type", namespace = ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
+ public void setRendererTypes(List<String> rendererTypes) {
+ this.rendererTypes = rendererTypes;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param rendererTypes the rendererTypes to set
- */
- @XmlElement(name="renderer-type",namespace=ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
- public void setRendererTypes(List<String> rendererTypes) {
- this.rendererTypes = rendererTypes;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the rendererTypes
+ */
+ public List<String> getRendererTypes() {
+ return rendererTypes;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the rendererTypes
- */
- public List<String> getRendererTypes() {
- return rendererTypes;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the events
+ */
+ @XmlElement(name = "fires", namespace = ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
+ @XmlJavaTypeAdapter(EventAdapter.class)
+ public List<Event> getEvents() {
+ return events;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the events
- */
- @XmlElement(name="fires",namespace=ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
- @XmlJavaTypeAdapter(EventAdapter.class)
- public List<Event> getEvents() {
- return events;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @param events the events to set
- */
- public void setEvents(List<Event> events) {
- this.events = events;
- }
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param events the events to set
+ */
+ public void setEvents(List<Event> events) {
+ this.events = events;
+ }
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/DescriptionGroupBean.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/DescriptionGroupBean.java 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/DescriptionGroupBean.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -6,64 +6,62 @@
import org.richfaces.cdk.model.DescriptionGroup;
public class DescriptionGroupBean implements DescriptionGroup {
+ private String description;
+ private String displayname;
+ private Icon icon;
- private Icon icon;
- private String description;
- private String displayname;
+ public DescriptionGroupBean() {
+ super();
+ }
- public DescriptionGroupBean() {
- super();
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the icon
+ */
+ @XmlElement(name = "icon", namespace = ComponentLibrary.FACES_CONFIG_NAMESPACE)
+ public final Icon getIcon() {
+ return icon;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the icon
- */
- @XmlElement(name = "icon", namespace = ComponentLibrary.FACES_CONFIG_NAMESPACE)
- public final Icon getIcon() {
- return icon;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param icon the icon to set
+ */
+ public final void setIcon(Icon icon) {
+ this.icon = icon;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param icon the icon to set
- */
- public final void setIcon(Icon icon) {
- this.icon = icon;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the description
+ */
+ @XmlElement(name = "description", namespace = ComponentLibrary.FACES_CONFIG_NAMESPACE)
+ public final String getDescription() {
+ return description;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the description
- */
- @XmlElement(name = "description", namespace = ComponentLibrary.FACES_CONFIG_NAMESPACE)
- public final String getDescription() {
- return description;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param description the description to set
+ */
+ public final void setDescription(String description) {
+ this.description = description;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param description the description to set
- */
- public final void setDescription(String description) {
- this.description = description;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the displayname
+ */
+ @XmlElement(name = "display-name", namespace = ComponentLibrary.FACES_CONFIG_NAMESPACE)
+ public final String getDisplayname() {
+ return displayname;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the displayname
- */
- @XmlElement(name = "display-name", namespace = ComponentLibrary.FACES_CONFIG_NAMESPACE)
- public final String getDisplayname() {
- return displayname;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @param displayname the displayname to set
- */
- public final void setDisplayname(String displayname) {
- this.displayname = displayname;
- }
-
-}
\ No newline at end of file
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param displayname the displayname to set
+ */
+ public final void setDisplayname(String displayname) {
+ this.displayname = displayname;
+ }
+}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/EventAdapter.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/EventAdapter.java 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/EventAdapter.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* 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;
@@ -34,15 +36,13 @@
*
*/
public class EventAdapter extends XmlAdapter<EventBean, Event> {
+ @Override
+ public EventBean marshal(Event v) throws Exception {
+ return JAXBBinding.createAdapter(EventBean.class, v);
+ }
- @Override
- public EventBean marshal(Event v) throws Exception {
- return JAXBBinding.createAdapter(EventBean.class, v);
- }
-
- @Override
- public Event unmarshal(EventBean v) throws Exception {
- return JAXBBinding.createModelElement(Event.class, v, new Event.Type(v.getType()));
- }
-
+ @Override
+ public Event unmarshal(EventBean v) throws Exception {
+ return JAXBBinding.createModelElement(Event.class, v, new Event.Type(v.getType()));
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/EventBean.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/EventBean.java 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/EventBean.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.xmlconfig.model;
import javax.xml.bind.annotation.XmlElement;
@@ -35,105 +37,99 @@
* @author asmirnov(a)exadel.com
*
*/
-@XmlType(name="faces-eventType",namespace=ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
+@XmlType(name = "faces-eventType", namespace = ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
public class EventBean {
+ private String description;
+ private ClassDescription listenerInterface;
+ private ClassDescription sourceInterface;
+ private ClassDescription tagHandler;
+ private String type;
- private String type;
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the type
+ */
+ @XmlElement(name = "event-class", namespace = ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
+ public String getType() {
+ return type;
+ }
- private String description;
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param type the type to set
+ */
+ public void setType(String type) {
+ this.type = type;
+ }
- private ClassDescription listenerInterface;
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the description
+ */
+ @XmlElement(name = "description", namespace = ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
+ public String getDescription() {
+ return description;
+ }
- private ClassDescription sourceInterface;
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param description the description to set
+ */
+ public void setDescription(String description) {
+ this.description = description;
+ }
- private ClassDescription tagHandler;
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the listenerInterface
+ */
+ @XmlElement(name = "listener-class", namespace = ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
+ @XmlJavaTypeAdapter(ClassAdapter.class)
+ public ClassDescription getListenerInterface() {
+ return listenerInterface;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the type
- */
- @XmlElement(name="event-class",namespace=ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
- public String getType() {
- return type;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param listenerInterface the listenerInterface to set
+ */
+ public void setListenerInterface(ClassDescription listenerInterface) {
+ this.listenerInterface = listenerInterface;
+ }
- /**
- * <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 sourceInterface
+ */
+ @XmlElement(name = "source-class", namespace = ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
+ @XmlJavaTypeAdapter(ClassAdapter.class)
+ public ClassDescription getSourceInterface() {
+ return sourceInterface;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the description
- */
- @XmlElement(name="description",namespace=ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
- public String getDescription() {
- return description;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param sourceInterface the sourceInterface to set
+ */
+ public void setSourceInterface(ClassDescription sourceInterface) {
+ this.sourceInterface = sourceInterface;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param description the description to set
- */
- public void setDescription(String description) {
- this.description = description;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the tagHandler
+ */
+ @XmlElement(name = "tag-handler-class", namespace = ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
+ @XmlJavaTypeAdapter(ClassAdapter.class)
+ public ClassDescription getTagHandler() {
+ return tagHandler;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the listenerInterface
- */
- @XmlElement(name="listener-class",namespace=ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
- @XmlJavaTypeAdapter(ClassAdapter.class)
- public ClassDescription getListenerInterface() {
- return listenerInterface;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @param listenerInterface the listenerInterface to set
- */
- public void setListenerInterface(ClassDescription listenerInterface) {
- this.listenerInterface = listenerInterface;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @return the sourceInterface
- */
- @XmlElement(name="source-class",namespace=ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
- @XmlJavaTypeAdapter(ClassAdapter.class)
- public ClassDescription getSourceInterface() {
- return sourceInterface;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @param sourceInterface the sourceInterface to set
- */
- public void setSourceInterface(ClassDescription sourceInterface) {
- this.sourceInterface = sourceInterface;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @return the tagHandler
- */
- @XmlElement(name="tag-handler-class",namespace=ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
- @XmlJavaTypeAdapter(ClassAdapter.class)
- public ClassDescription getTagHandler() {
- return tagHandler;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @param tagHandler the tagHandler to set
- */
- public void setTagHandler(ClassDescription tagHandler) {
- this.tagHandler = tagHandler;
- }
-
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param tagHandler the tagHandler to set
+ */
+ public void setTagHandler(ClassDescription tagHandler) {
+ this.tagHandler = tagHandler;
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ExtensibleBean.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ExtensibleBean.java 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ExtensibleBean.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.xmlconfig.model;
import org.richfaces.cdk.model.ConfigExtension;
@@ -31,25 +33,22 @@
* @author asmirnov(a)exadel.com
*
*/
-public class ExtensibleBean<E extends ConfigExtension> extends DescriptionGroupBean implements
- Extensible<E> {
-
- private E extension;
+public class ExtensibleBean<E extends ConfigExtension> extends DescriptionGroupBean implements Extensible<E> {
+ private E extension;
- /**
- * <p class="changed_added_4_0"></p>
- * @return the extension
- */
- public E getExtension() {
- return extension;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the extension
+ */
+ public E getExtension() {
+ return extension;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param extension the extension to set
- */
- public void setExtension(E extension) {
- this.extension = extension;
- }
-
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param extension the extension to set
+ */
+ public void setExtension(E extension) {
+ this.extension = extension;
+ }
}
Modified: 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 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/FacesConfigAdapter.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* 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;
@@ -34,19 +36,20 @@
*
*/
public class FacesConfigAdapter extends XmlAdapter<FacesConfigBean, ComponentLibrary> {
+ @Override
+ public FacesConfigBean marshal(ComponentLibrary v) throws Exception {
+ FacesConfigBean facesConfigBean = JAXBBinding.createAdapter(FacesConfigBean.class, v);
- @Override
- public FacesConfigBean marshal(ComponentLibrary v) throws Exception {
- FacesConfigBean facesConfigBean = JAXBBinding.createAdapter(FacesConfigBean.class, v);
- return facesConfigBean;
- }
+ return facesConfigBean;
+ }
- @Override
- public ComponentLibrary unmarshal(FacesConfigBean v) throws Exception {
- ComponentLibrary library = new ComponentLibrary();
- JAXBBinding.copyProperties(v, library);
- JAXBBinding.copyExtensions(v, library, false);
- return library;
- }
+ @Override
+ public ComponentLibrary unmarshal(FacesConfigBean v) throws Exception {
+ ComponentLibrary library = new ComponentLibrary();
+ JAXBBinding.copyProperties(v, library);
+ JAXBBinding.copyExtensions(v, library, false);
+
+ return library;
+ }
}
Modified: 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 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/FacesConfigBean.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.xmlconfig.model;
import java.util.List;
@@ -44,101 +46,98 @@
* @author asmirnov(a)exadel.com
*
*/
-@XmlRootElement(name="faces-config",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
+@XmlRootElement(name = "faces-config", namespace = ComponentLibrary.FACES_CONFIG_NAMESPACE)
public class FacesConfigBean implements Extensible<FacesConfigBean.FacesConfigExtension> {
+ @XmlElement(name = "component", namespace = ComponentLibrary.FACES_CONFIG_NAMESPACE)
+ @XmlJavaTypeAdapter(ComponentAdapter.class)
+ private List<Component> components = Lists.newArrayList();
+ @XmlElement(name = "render-kit", namespace = ComponentLibrary.FACES_CONFIG_NAMESPACE)
+ @XmlJavaTypeAdapter(RenderKitAdapter.class)
+ private List<RenderKit> renderKits = Lists.newArrayList();
+ private String version = "2.0";
+ private FacesConfigExtension extension;
- public static final class FacesConfigExtension extends ConfigExtension {
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the version
+ */
+ @XmlAttribute
+ public String getVersion() {
+ return version;
+ }
- private List<Event> events = Lists.newArrayList();
- @XmlElement(name="faces-event",namespace=ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
- @XmlJavaTypeAdapter(EventAdapter.class)
- public List<Event> getEvents() {
- return events;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param version the version to set
+ */
+ public void setVersion(String version) {
+ this.version = version;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param events the events to set
- */
- public void setEvents(List<Event> events) {
- this.events = events;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the components
+ */
+ public List<Component> getComponents() {
+ return components;
+ }
- }
- @XmlElement(name="component",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
- @XmlJavaTypeAdapter(ComponentAdapter.class)
- private List<Component> components = Lists.newArrayList();
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param components the components to set
+ */
+ public void setComponents(List<Component> components) {
+ this.components = components;
+ }
- @XmlElement(name="render-kit",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
- @XmlJavaTypeAdapter(RenderKitAdapter.class)
- private List<RenderKit> renderKits = Lists.newArrayList();
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the renderKits
+ */
+ public List<RenderKit> getRenderKits() {
+ return renderKits;
+ }
- private FacesConfigExtension extension;
-
- private String version="2.0";
- /**
- * <p class="changed_added_4_0"></p>
- * @return the version
- */
- @XmlAttribute
- public String getVersion() {
- return version;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param renderKits the renderKits to set
+ */
+ public void setRenderKits(List<RenderKit> renderKits) {
+ this.renderKits = renderKits;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param version the version to set
- */
- public void setVersion(String version) {
- this.version = version;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the extension
+ */
+ @XmlElement(name = "faces-config-extension", namespace = ComponentLibrary.FACES_CONFIG_NAMESPACE)
+ public FacesConfigExtension getExtension() {
+ return extension;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the components
- */
- public List<Component> getComponents() {
- return components;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param extension the extension to set
+ */
+ public void setExtension(FacesConfigExtension extension) {
+ this.extension = extension;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param components the components to set
- */
- public void setComponents(List<Component> components) {
- this.components = components;
- }
+ public static final class FacesConfigExtension extends ConfigExtension {
+ private List<Event> events = Lists.newArrayList();
- /**
- * <p class="changed_added_4_0"></p>
- * @return the renderKits
- */
- public List<RenderKit> getRenderKits() {
- return renderKits;
- }
+ @XmlElement(name = "faces-event", namespace = ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
+ @XmlJavaTypeAdapter(EventAdapter.class)
+ public List<Event> getEvents() {
+ return events;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param renderKits the renderKits to set
- */
- public void setRenderKits(List<RenderKit> renderKits) {
- this.renderKits = renderKits;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @return the extension
- */
- @XmlElement(name="faces-config-extension",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
- public FacesConfigExtension getExtension() {
- return extension;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @param extension the extension to set
- */
- public void setExtension(FacesConfigExtension extension) {
- this.extension = extension;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param events the events to set
+ */
+ public void setEvents(List<Event> events) {
+ this.events = events;
+ }
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/FacetAdapter.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/FacetAdapter.java 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/FacetAdapter.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* 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;
@@ -34,15 +36,13 @@
*
*/
public class FacetAdapter extends XmlAdapter<FacetBean, Facet> {
+ @Override
+ public FacetBean marshal(Facet v) throws Exception {
+ return JAXBBinding.createAdapter(FacetBean.class, v);
+ }
- @Override
- public FacetBean marshal(Facet v) throws Exception {
- return JAXBBinding.createAdapter(FacetBean.class, v);
- }
-
- @Override
- public Facet unmarshal(FacetBean v) throws Exception {
- return JAXBBinding.createModelElement(Facet.class, v, new Facet.Name(v.getName()));
- }
-
+ @Override
+ public Facet unmarshal(FacetBean v) throws Exception {
+ return JAXBBinding.createModelElement(Facet.class, v, new Facet.Name(v.getName()));
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/FacetBean.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/FacetBean.java 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/FacetBean.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.xmlconfig.model;
import javax.xml.bind.annotation.XmlElement;
@@ -33,67 +35,63 @@
* @author asmirnov(a)exadel.com
*
*/
-public class FacetBean extends ExtensibleBean<FacetBean.FacetExtension>{
+public class FacetBean extends ExtensibleBean<FacetBean.FacetExtension> {
+ private String name;
- /**
- * <p class="changed_added_4_0"></p>
- * @author asmirnov(a)exadel.com
- *
- */
- public static final class FacetExtension extends ConfigExtension {
-
- private boolean generate;
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the name
+ */
+ @XmlElement(name = "facet-name", namespace = ComponentLibrary.FACES_CONFIG_NAMESPACE)
+ public String getName() {
+ return name;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the generate
- */
- @XmlElement(name="generate",namespace=ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
- public boolean isGenerate() {
- return generate;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param name the name to set
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param generate the generate to set
- */
- public void setGenerate(boolean generate) {
- this.generate = generate;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the extension
+ */
+ @XmlElement(name = "facet-extension", namespace = ComponentLibrary.FACES_CONFIG_NAMESPACE)
+ public FacetExtension getExtension() {
+ return super.getExtension();
+ }
- }
-
- private String name;
+ @Override
+ public void setExtension(FacetExtension extension) {
+ super.setExtension(extension);
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the name
- */
- @XmlElement(name="facet-name",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
- public String getName() {
- return name;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+ public static final class FacetExtension extends ConfigExtension {
+ private boolean generate;
- /**
- * <p class="changed_added_4_0"></p>
- * @param name the name to set
- */
- public void setName(String name) {
- this.name = name;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the generate
+ */
+ @XmlElement(name = "generate", namespace = ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
+ public boolean isGenerate() {
+ return generate;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the extension
- */
- @XmlElement(name="facet-extension",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
- public FacetExtension getExtension() {
- return super.getExtension();
- }
-
- @Override
- public void setExtension(FacetExtension extension) {
- super.setExtension(extension);
- }
-
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param generate the generate to set
+ */
+ public void setGenerate(boolean generate) {
+ this.generate = generate;
+ }
+ }
}
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-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/Properties.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.xmlconfig.model;
import java.util.List;
@@ -39,25 +41,30 @@
* @author asmirnov(a)exadel.com
*
*/
-@XmlRootElement(name="properties",namespace=ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
+@XmlRootElement(name = "properties", namespace = ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
public class Properties {
- private List<Property> property = Lists.newArrayList();
+ private List<Property> property = Lists.newArrayList();
- /**
- * <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=PropertyBean.class)})
-// @XmlElement(name="property",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
- public List<Property> getProperty() {
- return property;
- }
+ /**
+ * <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 = PropertyBean.class) })
- /**
- * <p class="changed_added_4_0"></p>
- * @param property the property to set
- */
- public void setProperty(List<Property> property) {
- this.property = property;
- }
+// @XmlElement(name="property",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
+ public List<Property> getProperty() {
+ return property;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param property the property to set
+ */
+ public void setProperty(List<Property> property) {
+ this.property = property;
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/PropertyAdapter.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/PropertyAdapter.java 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/PropertyAdapter.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* 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;
@@ -34,15 +36,13 @@
*
*/
public class PropertyAdapter extends XmlAdapter<PropertyBean, Property> {
+ @Override
+ public PropertyBean marshal(Property v) throws Exception {
+ return JAXBBinding.createAdapter(PropertyBean.class, v);
+ }
- @Override
- public PropertyBean marshal(Property v) throws Exception {
- return JAXBBinding.createAdapter(PropertyBean.class, v);
- }
-
- @Override
- public Property unmarshal(PropertyBean v) throws Exception {
- return JAXBBinding.createModelElement(Property.class, v, new Property.Name(v.getName()));
- }
-
+ @Override
+ public Property unmarshal(PropertyBean v) throws Exception {
+ return JAXBBinding.createModelElement(Property.class, v, new Property.Name(v.getName()));
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/PropertyBean.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/PropertyBean.java 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/PropertyBean.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.xmlconfig.model;
import java.util.List;
@@ -44,273 +46,259 @@
*
*/
public class PropertyBean extends ExtensibleBean<PropertyBean.PropertyExtension> {
+ private String defaultValue;
+ private String name;
+ private String suggestedValue;
+ private ClassDescription type;
- /**
- * <p class="changed_added_4_0"></p>
- * @author asmirnov(a)exadel.com
- *
- */
- public static class PropertyExtension extends ConfigExtension {
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the name
+ */
+ @XmlElement(name = "property-name", namespace = ComponentLibrary.FACES_CONFIG_NAMESPACE)
+ public String getName() {
+ return name;
+ }
- private boolean generate;
-
- private boolean hidden;
-
- private boolean literal;
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param name the name to set
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
- private boolean required;
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the type
+ */
+ @XmlElement(name = "property-class", namespace = ComponentLibrary.FACES_CONFIG_NAMESPACE)
+ @XmlJavaTypeAdapter(ClassAdapter.class)
+ public ClassDescription getType() {
+ return type;
+ }
- private boolean readOnly;
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param type the type to set
+ */
+ public void setType(ClassDescription type) {
+ this.type = type;
+ }
- private boolean passThrough=false;
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the defaultValue
+ */
+ @XmlElement(name = "default-value", namespace = ComponentLibrary.FACES_CONFIG_NAMESPACE)
+ public String getDefaultValue() {
+ return defaultValue;
+ }
- private Set<EventName> eventNames = Sets.newHashSet();
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param defaultValue the defaultValue to set
+ */
+ public void setDefaultValue(String defaultValue) {
+ this.defaultValue = defaultValue;
+ }
- private List<ClassDescription> signature = Lists.newArrayList();
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the suggestedValue
+ */
+ @XmlElement(name = "suggested-value", namespace = ComponentLibrary.FACES_CONFIG_NAMESPACE)
+ public String getSuggestedValue() {
+ return suggestedValue;
+ }
- private Set<String> aliases = Sets.newHashSet();
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param suggestedValue the suggestedValue to set
+ */
+ public void setSuggestedValue(String suggestedValue) {
+ this.suggestedValue = suggestedValue;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the generate
- */
- @XmlElement(name="generate",namespace=ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
- public boolean isGenerate() {
- return generate;
- }
+ @Override
+ @XmlElement(name = "property-extension", namespace = ComponentLibrary.FACES_CONFIG_NAMESPACE)
+ public PropertyExtension getExtension() {
+ return super.getExtension();
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param generate the generate to set
- */
- public void setGenerate(boolean generate) {
- this.generate = generate;
- }
+ @Override
+ public void setExtension(PropertyExtension extension) {
+ super.setExtension(extension);
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the hidden
- */
- @XmlElement(name="hidden",namespace=ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
- public boolean isHidden() {
- return hidden;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+ public static class PropertyExtension extends ConfigExtension {
+ private boolean passThrough = false;
+ private Set<EventName> eventNames = Sets.newHashSet();
+ private List<ClassDescription> signature = Lists.newArrayList();
+ private Set<String> aliases = Sets.newHashSet();
+ private boolean generate;
+ private boolean hidden;
+ private boolean literal;
+ private boolean readOnly;
+ private boolean required;
- /**
- * <p class="changed_added_4_0"></p>
- * @param hidden the hidden to set
- */
- public void setHidden(boolean hidden) {
- this.hidden = hidden;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the generate
+ */
+ @XmlElement(name = "generate", namespace = ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
+ public boolean isGenerate() {
+ return generate;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the literal
- */
- @XmlElement(name="literal",namespace=ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
- public boolean isLiteral() {
- return literal;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param generate the generate to set
+ */
+ public void setGenerate(boolean generate) {
+ this.generate = generate;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param literal the literal to set
- */
- public void setLiteral(boolean literal) {
- this.literal = literal;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the hidden
+ */
+ @XmlElement(name = "hidden", namespace = ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
+ public boolean isHidden() {
+ return hidden;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the required
- */
- @XmlElement(name="required",namespace=ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
- public boolean isRequired() {
- return required;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param hidden the hidden to set
+ */
+ public void setHidden(boolean hidden) {
+ this.hidden = hidden;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param required the required to set
- */
- public void setRequired(boolean required) {
- this.required = required;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the literal
+ */
+ @XmlElement(name = "literal", namespace = ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
+ public boolean isLiteral() {
+ return literal;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the readOnly
- */
- public boolean isReadOnly() {
- return readOnly;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param literal the literal to set
+ */
+ public void setLiteral(boolean literal) {
+ this.literal = literal;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param readOnly the readOnly to set
- */
- public void setReadOnly(boolean readOnly) {
- this.readOnly = readOnly;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the required
+ */
+ @XmlElement(name = "required", namespace = ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
+ public boolean isRequired() {
+ return required;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the passThrough
- */
- @XmlElement(name="pass-through",namespace=ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
- public boolean isPassThrough() {
- return passThrough;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param required the required to set
+ */
+ public void setRequired(boolean required) {
+ this.required = required;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param passThrough the passThrough to set
- */
- public void setPassThrough(boolean passThrough) {
- this.passThrough = passThrough;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the readOnly
+ */
+ public boolean isReadOnly() {
+ return readOnly;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the eventNames
- */
- @XmlElement(name="event-name",namespace=ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
- public Set<EventName> getEventNames() {
- return eventNames;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param readOnly the readOnly to set
+ */
+ public void setReadOnly(boolean readOnly) {
+ this.readOnly = readOnly;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param eventNames the eventNames to set
- */
- public void setEventNames(Set<EventName> eventNames) {
- this.eventNames = eventNames;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the passThrough
+ */
+ @XmlElement(name = "pass-through", namespace = ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
+ public boolean isPassThrough() {
+ return passThrough;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the signature
- */
- @XmlElementWrapper(name="signature",namespace=ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
- @XmlElement(name="param",namespace=ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
- @XmlJavaTypeAdapter(ClassAdapter.class)
- public List<ClassDescription> getSignature() {
- return signature;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param passThrough the passThrough to set
+ */
+ public void setPassThrough(boolean passThrough) {
+ this.passThrough = passThrough;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param signature the signature to set
- */
- public void setSignature(List<ClassDescription> signature) {
- this.signature = signature;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the eventNames
+ */
+ @XmlElement(name = "event-name", namespace = ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
+ public Set<EventName> getEventNames() {
+ return eventNames;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the aliases
- */
- @XmlElement(name="alias",namespace=ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
- public Set<String> getAliases() {
- return aliases;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param eventNames the eventNames to set
+ */
+ public void setEventNames(Set<EventName> eventNames) {
+ this.eventNames = eventNames;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param aliases the aliases to set
- */
- public void setAliases(Set<String> aliases) {
- this.aliases = aliases;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the signature
+ */
+ @XmlElementWrapper(name = "signature", namespace = ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
+ @XmlElement(name = "param", namespace = ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
+ @XmlJavaTypeAdapter(ClassAdapter.class)
+ public List<ClassDescription> getSignature() {
+ return signature;
+ }
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param signature the signature to set
+ */
+ public void setSignature(List<ClassDescription> signature) {
+ this.signature = signature;
+ }
- private String name;
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the aliases
+ */
+ @XmlElement(name = "alias", namespace = ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
+ public Set<String> getAliases() {
+ return aliases;
+ }
- private ClassDescription type;
-
- private String defaultValue;
-
- private String suggestedValue;
-
- /**
- * <p class="changed_added_4_0"></p>
- * @return the name
- */
- @XmlElement(name="property-name",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
- public String getName() {
- return name;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @param name the name to set
- */
- public void setName(String name) {
- this.name = name;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @return the type
- */
- @XmlElement(name="property-class",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
- @XmlJavaTypeAdapter(ClassAdapter.class)
- public ClassDescription getType() {
- return type;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @param type the type to set
- */
- public void setType(ClassDescription type) {
- this.type = type;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @return the defaultValue
- */
- @XmlElement(name="default-value",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
- public String getDefaultValue() {
- return defaultValue;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @param defaultValue the defaultValue to set
- */
- public void setDefaultValue(String defaultValue) {
- this.defaultValue = defaultValue;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @return the suggestedValue
- */
- @XmlElement(name="suggested-value",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
- public String getSuggestedValue() {
- return suggestedValue;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @param suggestedValue the suggestedValue to set
- */
- public void setSuggestedValue(String suggestedValue) {
- this.suggestedValue = suggestedValue;
- }
-
- @Override
- @XmlElement(name="property-extension",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
- public PropertyExtension getExtension() {
- return super.getExtension();
- }
-
- @Override
- public void setExtension(PropertyExtension extension) {
- super.setExtension(extension);
- }
-}
\ No newline at end of file
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param aliases the aliases to set
+ */
+ public void setAliases(Set<String> aliases) {
+ this.aliases = aliases;
+ }
+ }
+}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/RenderKitAdapter.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/RenderKitAdapter.java 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/RenderKitAdapter.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* 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;
@@ -34,15 +36,13 @@
*
*/
public class RenderKitAdapter extends XmlAdapter<RenderKitBean, RenderKit> {
+ @Override
+ public RenderKitBean marshal(RenderKit v) throws Exception {
+ return JAXBBinding.createAdapter(RenderKitBean.class, v);
+ }
- @Override
- public RenderKitBean marshal(RenderKit v) throws Exception {
- return JAXBBinding.createAdapter(RenderKitBean.class, v);
- }
-
- @Override
- public RenderKit unmarshal(RenderKitBean v) throws Exception {
- return JAXBBinding.createModelElement(RenderKit.class, v, new RenderKit.Id(v.getId()));
- }
-
+ @Override
+ public RenderKit unmarshal(RenderKitBean v) throws Exception {
+ return JAXBBinding.createModelElement(RenderKit.class, v, new RenderKit.Id(v.getId()));
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/RenderKitBean.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/RenderKitBean.java 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/RenderKitBean.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -21,12 +21,14 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.richfaces.cdk.xmlconfig.model;
+package org.richfaces.cdk.xmlconfig.model;
+
import java.util.List;
import javax.faces.render.RenderKitFactory;
+
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
@@ -43,95 +45,88 @@
* @author asmirnov(a)exadel.com
*
*/
-public class RenderKitBean extends ExtensibleBean<RenderKitBean.RenderKitExtension>{
+public class RenderKitBean extends ExtensibleBean<RenderKitBean.RenderKitExtension> {
+ @XmlElement(name = "render-kit-id", namespace = ComponentLibrary.FACES_CONFIG_NAMESPACE)
+ private String id = RenderKitFactory.HTML_BASIC_RENDER_KIT;
+ @XmlElement(name = "renderer", namespace = ComponentLibrary.FACES_CONFIG_NAMESPACE)
+ @XmlJavaTypeAdapter(RendererAdapter.class)
+ private List<Renderer> renderers = Lists.newArrayList();
+ @XmlElement(name = "client-behavior-renderer", namespace = ComponentLibrary.FACES_CONFIG_NAMESPACE)
+ @XmlJavaTypeAdapter(BehaviorRendererAdapter.class)
+ private List<BehaviorRenderer> behaviorRenderers = Lists.newArrayList();
+ @XmlElement(name = "render-kit-class", namespace = ComponentLibrary.FACES_CONFIG_NAMESPACE)
+ @XmlJavaTypeAdapter(ClassAdapter.class)
+ private ClassDescription renderkitClass;
- /**
- * <p class="changed_added_4_0"></p>
- * @author asmirnov(a)exadel.com
- *
- */
- public static class RenderKitExtension extends ConfigExtension {
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the renderkitClass
+ */
+ public ClassDescription getRenderkitClass() {
+ return renderkitClass;
+ }
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param renderkitClass the renderkitClass to set
+ */
+ public void setRenderkitClass(ClassDescription renderkitClass) {
+ this.renderkitClass = renderkitClass;
+ }
-
- @XmlElement(name="render-kit-id",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
- private String id = RenderKitFactory.HTML_BASIC_RENDER_KIT;
-
- @XmlElement(name="render-kit-class",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
- @XmlJavaTypeAdapter(ClassAdapter.class)
- private ClassDescription renderkitClass;
-
- @XmlElement(name="renderer",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
- @XmlJavaTypeAdapter(RendererAdapter.class)
- private List<Renderer> renderers = Lists.newArrayList();
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the id
+ */
+ public String getId() {
+ return id;
+ }
- @XmlElement(name="client-behavior-renderer",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
- @XmlJavaTypeAdapter(BehaviorRendererAdapter.class)
- private List<BehaviorRenderer> behaviorRenderers = Lists.newArrayList();
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param id the id to set
+ */
+ public void setId(String id) {
+ this.id = id;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the renderkitClass
- */
- public ClassDescription getRenderkitClass() {
- return renderkitClass;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the renderers
+ */
+ public List<Renderer> getRenderers() {
+ return renderers;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param renderkitClass the renderkitClass to set
- */
- public void setRenderkitClass(ClassDescription renderkitClass) {
- this.renderkitClass = renderkitClass;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param renderers the renderers to set
+ */
+ public void setRenderers(List<Renderer> renderers) {
+ this.renderers = renderers;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the id
- */
- public String getId() {
- return id;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the extension
+ */
+ @XmlElement(name = "render-kit-extension", namespace = ComponentLibrary.FACES_CONFIG_NAMESPACE)
+ public RenderKitExtension getExtension() {
+ return super.getExtension();
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param id the id to set
- */
- public void setId(String id) {
- this.id = id;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param extension the extension to set
+ */
+ public void setExtension(RenderKitExtension extension) {
+ super.setExtension(extension);
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the renderers
- */
- public List<Renderer> getRenderers() {
- return renderers;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @param renderers the renderers to set
- */
- public void setRenderers(List<Renderer> renderers) {
- this.renderers = renderers;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @return the extension
- */
- @XmlElement(name="render-kit-extension",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
- public RenderKitExtension getExtension() {
- return super.getExtension();
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @param extension the extension to set
- */
- public void setExtension(RenderKitExtension extension) {
- super.setExtension(extension);
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+ public static class RenderKitExtension extends ConfigExtension {}
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/RendererAdapter.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/RendererAdapter.java 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/RendererAdapter.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* 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;
@@ -34,15 +36,13 @@
*
*/
public class RendererAdapter extends XmlAdapter<RendererBean, Renderer> {
+ @Override
+ public RendererBean marshal(Renderer v) throws Exception {
+ return JAXBBinding.createAdapter(RendererBean.class, v);
+ }
- @Override
- public RendererBean marshal(Renderer v) throws Exception {
- return JAXBBinding.createAdapter(RendererBean.class, v);
- }
-
- @Override
- public Renderer unmarshal(RendererBean v) throws Exception {
- return JAXBBinding.createModelElement(Renderer.class, v, new Renderer.Type(v.getType()));
- }
-
+ @Override
+ public Renderer unmarshal(RendererBean v) throws Exception {
+ return JAXBBinding.createModelElement(Renderer.class, v, new Renderer.Type(v.getType()));
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/RendererBean.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/RendererBean.java 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/RendererBean.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.xmlconfig.model;
import javax.xml.bind.annotation.XmlElement;
@@ -36,87 +38,82 @@
* @author asmirnov(a)exadel.com
*
*/
-@XmlType(name="faces-config-rendererType",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
-public class RendererBean extends ExtensibleBean<RendererBean.RendererExtension>{
+@XmlType(name = "faces-config-rendererType", namespace = ComponentLibrary.FACES_CONFIG_NAMESPACE)
+public class RendererBean extends ExtensibleBean<RendererBean.RendererExtension> {
+ private String family;
+ private ClassDescription rendererClass;
+ private String type;
- /**
- * <p class="changed_added_4_0"></p>
- * @author asmirnov(a)exadel.com
- *
- */
- public static class RendererExtension extends ConfigExtension {
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the type
+ */
+ @XmlElement(name = "renderer-type", namespace = ComponentLibrary.FACES_CONFIG_NAMESPACE)
+ public String getType() {
+ return type;
+ }
- }
-
- private String type;
-
- private String family;
-
- private ClassDescription rendererClass;
+ /**
+ * <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 type
- */
- @XmlElement(name="renderer-type",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
- public String getType() {
- return type;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the family
+ */
+ @XmlElement(name = "component-family", namespace = ComponentLibrary.FACES_CONFIG_NAMESPACE)
+ public String getFamily() {
+ return family;
+ }
- /**
- * <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>
+ * @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.FACES_CONFIG_NAMESPACE)
- public String getFamily() {
- return family;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the rendererClass
+ */
+ @XmlElement(name = "renderer-class", namespace = ComponentLibrary.FACES_CONFIG_NAMESPACE)
+ @XmlJavaTypeAdapter(ClassAdapter.class)
+ public ClassDescription getRendererClass() {
+ return rendererClass;
+ }
- /**
- * <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>
+ * @param rendererClass the rendererClass to set
+ */
+ public void setRendererClass(ClassDescription rendererClass) {
+ this.rendererClass = rendererClass;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the rendererClass
- */
- @XmlElement(name="renderer-class",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
- @XmlJavaTypeAdapter(ClassAdapter.class)
- public ClassDescription getRendererClass() {
- return rendererClass;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the extension
+ */
+ @XmlElement(name = "renderer-extension", namespace = ComponentLibrary.FACES_CONFIG_NAMESPACE)
+ public RendererExtension getExtension() {
+ return super.getExtension();
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param rendererClass the rendererClass to set
- */
- public void setRendererClass(ClassDescription rendererClass) {
- this.rendererClass = rendererClass;
- }
+ @Override
+ public void setExtension(RendererExtension extension) {
+ super.setExtension(extension);
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the extension
- */
- @XmlElement(name="renderer-extension",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
- public RendererExtension getExtension() {
- return super.getExtension();
- }
-
- @Override
- public void setExtension(RendererExtension extension) {
- super.setExtension(extension);
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+ public static class RendererExtension extends ConfigExtension {}
}
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-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/package-info.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -1,21 +1,22 @@
/**
* <h2>JAXB classes that wraps real model classes.</h2>
- * <p>Some model requirements do not match JAXB plain bean model. The most important case is requirements for unique Id's like component and renderer type.
- * the other important difference is model properties which do not map to faces-config schema but moved into <<....-extension> elements.</p>
- *
+ * <p>Some model requirements do not match JAXB plain bean model. The most important case is requirements for unique
+ * Id's like component and renderer type. the other important difference is model properties which do not map to
+ * faces-config schema but moved into <<....-extension> elements.</p>
+ *
*/
@XmlAccessorType(XmlAccessType.NONE)
-(a)javax.xml.bind.annotation.XmlSchema(namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE,
- location=ComponentLibrary.FACES_CONFIG_SCHEMA_LOCATION,
- xmlns = { @javax.xml.bind.annotation.XmlNs( prefix = "cdk",
- namespaceURI = ComponentLibrary.CDK_EXTENSIONS_NAMESPACE ) })
-@XmlJavaTypeAdapters({(a)XmlJavaTypeAdapter(type=Property.class,value=PropertyAdapter.class),
- @XmlJavaTypeAdapter(type=Attribute.class,value=AttributeAdapter.class),
- @XmlJavaTypeAdapter(type=ClassDescription.class,value=ClassAdapter.class),
- @XmlJavaTypeAdapter(type=ComponentLibrary.class,value=FacesConfigAdapter.class)
- })
+(a)javax.xml.bind.annotation.XmlSchema(namespace = ComponentLibrary.FACES_CONFIG_NAMESPACE,
+ location = ComponentLibrary.FACES_CONFIG_SCHEMA_LOCATION,
+ xmlns = {(a)javax.xml.bind.annotation.XmlNs(prefix = "cdk",
+ namespaceURI = ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)})
+@XmlJavaTypeAdapters({@XmlJavaTypeAdapter(type = Property.class, value = PropertyAdapter.class),
+ @XmlJavaTypeAdapter(type = Attribute.class, value = AttributeAdapter.class),
+ @XmlJavaTypeAdapter(type = ClassDescription.class, value = ClassAdapter.class),
+ @XmlJavaTypeAdapter(type = ComponentLibrary.class, value = FacesConfigAdapter.class)
+})
+package org.richfaces.cdk.xmlconfig.model;
-package org.richfaces.cdk.xmlconfig.model;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/NamesListComparator.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/NamesListComparator.java 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/NamesListComparator.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -19,6 +19,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.xmlutils;
import java.util.Comparator;
@@ -29,60 +31,60 @@
* @author Nick Belaevski
* @since 3.2.2
*/
-
public class NamesListComparator implements Comparator<Node> {
+ private Comparator<Node> comparator;
+ private String[] names;
- private Comparator<Node> comparator;
- private String[] names;
-
- public NamesListComparator(Comparator<Node> comparator, String[] names) {
- super();
- this.comparator = comparator;
- this.names = names;
- }
+ public NamesListComparator(Comparator<Node> comparator, String[] names) {
+ super();
+ this.comparator = comparator;
+ this.names = names;
+ }
- private final int getOrder(String s) {
- for (int i = 0; i < names.length; i++) {
- if (names[i].equals(s)) {
- return i;
- }
- }
-
- return -1;
- }
+ private final int getOrder(String s) {
+ for (int i = 0; i < names.length; i++) {
+ if (names[i].equals(s)) {
+ return i;
+ }
+ }
- private String getNodeName(Node node) {
- String name = node.getLocalName();
- if (name == null) {
- name = node.getNodeName();
- }
-
- return name;
- }
-
- public int compare(Node o1, Node o2) {
- String name1 = getNodeName(o1);
- String name2 = getNodeName(o2);
-
- if (name1 != null && name2 != null && !name1.equals(name2)) {
- int order1 = getOrder(name1);
- if (order1 < 0) {
- System.out.println("Tag: " + name1 + " is unknown!");
- }
-
- int order2 = getOrder(name2);
- if (order2 < 0) {
- System.out.println("Tag: " + name2 + " is unknown!");
- }
+ return -1;
+ }
- if (order1 < order2) {
- return -1;
- } else if (order1 > order2) {
- return 1;
- }
- }
-
- return comparator.compare(o1, o2);
- }
+ private String getNodeName(Node node) {
+ String name = node.getLocalName();
+ if (name == null) {
+ name = node.getNodeName();
+ }
+
+ return name;
+ }
+
+ public int compare(Node o1, Node o2) {
+ String name1 = getNodeName(o1);
+ String name2 = getNodeName(o2);
+
+ if (name1 != null && name2 != null && !name1.equals(name2)) {
+ int order1 = getOrder(name1);
+
+ if (order1 < 0) {
+ System.out.println("Tag: " + name1 + " is unknown!");
+ }
+
+ int order2 = getOrder(name2);
+
+ if (order2 < 0) {
+ System.out.println("Tag: " + name2 + " is unknown!");
+ }
+
+ if (order1 < order2) {
+ return -1;
+ } else if (order1 > order2) {
+ return 1;
+ }
+ }
+
+ return comparator.compare(o1, o2);
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/ParsingException.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/ParsingException.java 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/ParsingException.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -4,41 +4,40 @@
public class ParsingException extends CdkException {
- /**
- * <p class="changed_added_4_0"></p>
- */
- private static final long serialVersionUID = 1629210103196620913L;
+ /**
+ * <p class="changed_added_4_0"></p>
+ */
+ private static final long serialVersionUID = 1629210103196620913L;
- /**
- * <p class="changed_added_4_0"></p>
- */
- public ParsingException() {
- super();
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ */
+ public ParsingException() {
+ super();
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param message
- * @param cause
- */
- public ParsingException(String message, Throwable cause) {
- super(message, cause);
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param message
+ */
+ public ParsingException(String message) {
+ super(message);
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param message
- */
- public ParsingException(String message) {
- super(message);
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param cause
+ */
+ public ParsingException(Throwable cause) {
+ super(cause);
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param cause
- */
- public ParsingException(Throwable cause) {
- super(cause);
- }
-
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param message
+ * @param cause
+ */
+ public ParsingException(String message, Throwable cause) {
+ super(message, cause);
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/XMLBody.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/XMLBody.java 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/XMLBody.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -19,11 +19,14 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.xmlutils;
import java.io.IOException;
import java.io.InputStream;
import java.io.StringReader;
+
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
@@ -40,180 +43,189 @@
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
+
import org.xml.sax.EntityResolver;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
+class ArrayNodeList implements NodeList {
+ private Node[] nodes;
+
+ public ArrayNodeList(Node[] nodes) {
+ super();
+ this.nodes = nodes;
+ }
+
+ public int getLength() {
+ return nodes.length;
+ }
+
+ public Node item(int index) {
+ if (index < nodes.length) {
+ return this.nodes[index];
+ }
+
+ return null;
+ }
+}
+
+
/**
* This class must read XML file from input stream and can extract body of root
* element for include into target in generation.
- *
+ *
* @author shura
- *
+ *
*/
public class XMLBody {
- private Document xmlDocument;
+ private Element rootElement;
+ private Document xmlDocument;
- private Element rootElement;
+ /**
+ * Load XML document and parse it into DOM.
+ *
+ * @param input
+ * @throws ParsingException
+ */
+ public void loadXML(InputStream input) throws ParsingException {
+ loadXML(input, false);
+ }
- /**
- * Load XML document and parse it into DOM.
- *
- * @param input
- * @throws ParsingException
- */
- public void loadXML(InputStream input) throws ParsingException {
- loadXML(input,false);
- }
+ /**
+ * Load XML document and parse it into DOM.
+ *
+ * @param input
+ * @throws ParsingException
+ */
+ public void loadXML(InputStream input, boolean namespaceAware) throws ParsingException {
+ try {
-
- /**
- * Load XML document and parse it into DOM.
- *
- * @param input
- * @throws ParsingException
- */
- public void loadXML(InputStream input, boolean namespaceAware) throws ParsingException {
- try {
- // Create Document Builder Factory
- DocumentBuilderFactory docFactory = DocumentBuilderFactory
- .newInstance();
- docFactory.setIgnoringElementContentWhitespace(true);
- docFactory.setValidating(false);
- docFactory.setNamespaceAware(namespaceAware);
- // Create Document Builder
- DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
- //docBuilder.
- //docBuilder.isValidating();
-
- // Disable loading of external Entityes
- docBuilder.setEntityResolver(new EntityResolver() {
- // Dummi resolver - alvays do nothing
- public InputSource resolveEntity(String publicId, String systemId)
- throws SAXException, IOException {
- return new InputSource(new StringReader(""));
- }
+ // Create Document Builder Factory
+ DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
- });
+ docFactory.setIgnoringElementContentWhitespace(true);
+ docFactory.setValidating(false);
+ docFactory.setNamespaceAware(namespaceAware);
- // open and parse XML-file
- xmlDocument = docBuilder.parse(input);
+ // Create Document Builder
+ DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
- // Get Root xmlElement
- rootElement = xmlDocument.getDocumentElement();
- } catch (Exception e) {
- throw new ParsingException("Error load XML ", e);
- }
+ // docBuilder.
+ // docBuilder.isValidating();
+ // Disable loading of external Entityes
+ docBuilder.setEntityResolver(new EntityResolver() {
- }
+ // Dummi resolver - alvays do nothing
+ public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {
+ return new InputSource(new StringReader(""));
+ }
+ });
- /**
- * Check name of root element is as expected.
- *
- * @param name
- * @return
- */
- public boolean isRootName(String name) {
- return rootElement.getNodeName().equals(name);
- }
+ // open and parse XML-file
+ xmlDocument = docBuilder.parse(input);
- public String getDoctype() {
- DocumentType doctype = xmlDocument.getDoctype();
- if (null != doctype) {
- return doctype.getName();
- }
- return null;
- }
+ // Get Root xmlElement
+ rootElement = xmlDocument.getDocumentElement();
+ } catch (Exception e) {
+ throw new ParsingException("Error load XML ", e);
+ }
+ }
- public String getPiblicId() {
- DocumentType doctype = xmlDocument.getDoctype();
- if (null != doctype) {
- return doctype.getPublicId();
- }
- return null;
- }
+ /**
+ * Check name of root element is as expected.
+ *
+ * @param name
+ * @return
+ */
+ public boolean isRootName(String name) {
+ return rootElement.getNodeName().equals(name);
+ }
- public String getRootTypeName() {
- return rootElement.getSchemaTypeInfo().getTypeName();
- }
+ public String getDoctype() {
+ DocumentType doctype = xmlDocument.getDoctype();
- public String getContent() throws ParsingException {
- NodeList childNodes = rootElement.getChildNodes();
- return serializeNodes(childNodes);
- }
+ if (null != doctype) {
+ return doctype.getName();
+ }
- private String serializeNodes(NodeList childNodes) throws ParsingException {
- try {
- return new XMLBodySerializer().serialize(childNodes, xmlDocument);
- } catch (Exception e) {
- throw new ParsingException(e);
- }
- }
-
- public String getContent(String xpath) throws ParsingException{
- return serializeNodes(getByXpath(xpath));
- }
+ return null;
+ }
- public NodeList getByXpath(String xpath) throws ParsingException {
- XPath path = XPathFactory.newInstance().newXPath();
- NodeList childNodes;
- try {
- childNodes = (NodeList) path.evaluate(xpath, xmlDocument, XPathConstants.NODESET);
- } catch (XPathExpressionException e) {
- throw new ParsingException("Error evaluate xpath",e);
- }
- return childNodes;
- }
-
- public NodeList getByXpathUnique(String xpath, String keyXPath, Set<String> keySet) throws ParsingException {
- if (keyXPath == null) {
- return getByXpath(xpath);
- } else {
- XPath path = XPathFactory.newInstance().newXPath();
- NodeList childNodes;
- try {
- childNodes = getByXpath(xpath);
-
- List<Node> nodeSet = new ArrayList<Node>();
-
- for (int i = 0; i < childNodes.getLength(); i++) {
- Node node = childNodes.item(i).cloneNode(true);
-
- String key = serializeNodes((NodeList) path.evaluate(keyXPath, node, XPathConstants.NODESET));
- if (!keySet.contains(key)) {
- keySet.add(key);
- nodeSet.add(node);
- }
- }
- return new ArrayNodeList(nodeSet.toArray(new Node[nodeSet.size()]));
- } catch (XPathExpressionException e) {
- throw new ParsingException("Error evaluate xpath",e);
- }
+ public String getPiblicId() {
+ DocumentType doctype = xmlDocument.getDoctype();
- }
- }
- public String getContentUnique(String xpath, String keyXPath, Set<String> keySet) throws ParsingException{
- return serializeNodes(getByXpathUnique(xpath, keyXPath, keySet));
- }
-}
+ if (null != doctype) {
+ return doctype.getPublicId();
+ }
-class ArrayNodeList implements NodeList {
- private Node[] nodes;
+ return null;
+ }
- public ArrayNodeList(Node[] nodes) {
- super();
- this.nodes = nodes;
- }
+ public String getRootTypeName() {
+ return rootElement.getSchemaTypeInfo().getTypeName();
+ }
- public int getLength() {
- return nodes.length;
- }
+ public String getContent() throws ParsingException {
+ NodeList childNodes = rootElement.getChildNodes();
- public Node item(int index) {
- if (index < nodes.length) {
- return this.nodes[index];
- }
-
- return null;
- }
+ return serializeNodes(childNodes);
+ }
+
+ private String serializeNodes(NodeList childNodes) throws ParsingException {
+ try {
+ return new XMLBodySerializer().serialize(childNodes, xmlDocument);
+ } catch (Exception e) {
+ throw new ParsingException(e);
+ }
+ }
+
+ public String getContent(String xpath) throws ParsingException {
+ return serializeNodes(getByXpath(xpath));
+ }
+
+ public NodeList getByXpath(String xpath) throws ParsingException {
+ XPath path = XPathFactory.newInstance().newXPath();
+ NodeList childNodes;
+
+ try {
+ childNodes = (NodeList) path.evaluate(xpath, xmlDocument, XPathConstants.NODESET);
+ } catch (XPathExpressionException e) {
+ throw new ParsingException("Error evaluate xpath", e);
+ }
+
+ return childNodes;
+ }
+
+ public NodeList getByXpathUnique(String xpath, String keyXPath, Set<String> keySet) throws ParsingException {
+ if (keyXPath == null) {
+ return getByXpath(xpath);
+ } else {
+ XPath path = XPathFactory.newInstance().newXPath();
+ NodeList childNodes;
+
+ try {
+ childNodes = getByXpath(xpath);
+
+ List<Node> nodeSet = new ArrayList<Node>();
+
+ for (int i = 0; i < childNodes.getLength(); i++) {
+ Node node = childNodes.item(i).cloneNode(true);
+ String key = serializeNodes((NodeList) path.evaluate(keyXPath, node, XPathConstants.NODESET));
+
+ if (!keySet.contains(key)) {
+ keySet.add(key);
+ nodeSet.add(node);
+ }
+ }
+
+ return new ArrayNodeList(nodeSet.toArray(new Node[nodeSet.size()]));
+ } catch (XPathExpressionException e) {
+ throw new ParsingException("Error evaluate xpath", e);
+ }
+ }
+ }
+
+ public String getContentUnique(String xpath, String keyXPath, Set<String> keySet) throws ParsingException {
+ return serializeNodes(getByXpathUnique(xpath, keyXPath, keySet));
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/XMLBodyMerge.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/XMLBodyMerge.java 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/XMLBodyMerge.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -19,6 +19,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.xmlutils;
import java.util.ArrayList;
@@ -38,110 +40,109 @@
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
-
/**
* @author Maksim Kaszynski
*
*/
-public class XMLBodyMerge implements NodeList{
-
- private String xpath;
-
- private List<Node> nodes = new ArrayList<Node>();
-
- private Document document = null;
-
- private XPathExpression keyXpath = null;
-
- private StringBuffer content = new StringBuffer();
-
- private Set<String> keys = new HashSet<String>();
-
-
-
- public XMLBodyMerge(String xpath) {
- super();
- this.xpath = xpath;
- }
-
- public XMLBodyMerge(String xpath, String keyXpath) {
- this(xpath);
- if (keyXpath != null) {
- try {
- XPath newXPath = XPathFactory.newInstance().newXPath();
- this.keyXpath = newXPath.compile(keyXpath);
- } catch (XPathExpressionException e) {
- e.printStackTrace();
- }
- }
- }
-
- public void add(Node node) {
-
- if (keyXpath != null) {
- String key = getKey(node);
- if (key == null || keys.contains(key)) {
- return;
- }
- }
-
- if (document == null) {
- document = node.getOwnerDocument();
- } else {
- node = document.importNode(node, true);
- }
- nodes.add(node);
- }
-
- public void add(XMLBody xmlBody) throws ParsingException {
-
- if (xpath != null) {
- NodeList nodeList = xmlBody.getByXpath(xpath);
- if (nodeList != null) {
- for(int i = 0; i < nodeList.getLength(); i++) {
- add(nodeList.item(i));
- }
- }
- } else {
- content.append(xmlBody.getContent());
- }
-
- }
-
- public int getLength() {
- return nodes.size();
- }
-
- public Node item(int index) {
- if (index < nodes.size()) {
- return nodes.get(index);
- }
- return null;
- }
-
-
- public void sort(Comparator<Node> comparator) {
- Collections.sort(nodes, comparator);
- }
-
- public String getContent() throws Exception{
- StringBuilder buf = new StringBuilder();
- if (content != null) {
- buf.append(content);
- }
- if (document != null) {
- buf.append(new XMLBodySerializer().serialize(this, document));
- }
-
- return buf.toString();
- }
-
- private String getKey(Node node) {
- try {
- NodeList list = (NodeList) keyXpath.evaluate(node, XPathConstants.NODESET);
- return new XMLBodySerializer().serialize(list, node.getOwnerDocument());
- } catch (Exception e) {
- }
- return null;
- }
+public class XMLBodyMerge implements NodeList {
+ private Document document = null;
+ private XPathExpression keyXpath = null;
+ private List<Node> nodes = new ArrayList<Node>();
+ private Set<String> keys = new HashSet<String>();
+ private StringBuffer content = new StringBuffer();
+ private String xpath;
+
+ public XMLBodyMerge(String xpath) {
+ super();
+ this.xpath = xpath;
+ }
+
+ public XMLBodyMerge(String xpath, String keyXpath) {
+ this(xpath);
+
+ if (keyXpath != null) {
+ try {
+ XPath newXPath = XPathFactory.newInstance().newXPath();
+
+ this.keyXpath = newXPath.compile(keyXpath);
+ } catch (XPathExpressionException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ public void add(Node node) {
+ if (keyXpath != null) {
+ String key = getKey(node);
+
+ if (key == null || keys.contains(key)) {
+ return;
+ }
+ }
+
+ if (document == null) {
+ document = node.getOwnerDocument();
+ } else {
+ node = document.importNode(node, true);
+ }
+
+ nodes.add(node);
+ }
+
+ public void add(XMLBody xmlBody) throws ParsingException {
+ if (xpath != null) {
+ NodeList nodeList = xmlBody.getByXpath(xpath);
+
+ if (nodeList != null) {
+ for (int i = 0; i < nodeList.getLength(); i++) {
+ add(nodeList.item(i));
+ }
+ }
+ } else {
+ content.append(xmlBody.getContent());
+ }
+ }
+
+ public int getLength() {
+ return nodes.size();
+ }
+
+ public Node item(int index) {
+ if (index < nodes.size()) {
+ return nodes.get(index);
+ }
+
+ return null;
+ }
+
+ public void sort(Comparator<Node> comparator) {
+ Collections.sort(nodes, comparator);
+ }
+
+ public String getContent() throws Exception {
+ StringBuilder buf = new StringBuilder();
+
+ if (content != null) {
+ buf.append(content);
+ }
+
+ if (document != null) {
+ buf.append(new XMLBodySerializer().serialize(this, document));
+ }
+
+ return buf.toString();
+ }
+
+ private String getKey(Node node) {
+ try {
+ NodeList list = (NodeList) keyXpath.evaluate(node, XPathConstants.NODESET);
+
+ return new XMLBodySerializer().serialize(list, node.getOwnerDocument());
+ } catch (Exception e) {
+
+ // TODO Refactoring
+ }
+
+ return null;
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/XMLBodySerializer.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/XMLBodySerializer.java 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/XMLBodySerializer.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -19,6 +19,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.xmlutils;
import java.io.StringWriter;
@@ -34,44 +36,39 @@
import org.w3c.dom.DocumentFragment;
import org.w3c.dom.NodeList;
-
/**
* @author Maksim Kaszynski
*
*/
public class XMLBodySerializer {
- public String serialize(NodeList childNodes, Document xmlDocument) throws ParsingException {
- try {
- StringWriter out;
- DocumentFragment fragment = xmlDocument.createDocumentFragment();
- for (int i = 0; i < childNodes.getLength(); i++) {
- fragment.appendChild(childNodes.item(i).cloneNode(true));
- }
- TransformerFactory transformerFactory = TransformerFactory.newInstance();
- Transformer transformer = transformerFactory.newTransformer();
- transformer.setErrorListener(new ErrorListener(){
+ public String serialize(NodeList childNodes, Document xmlDocument) throws ParsingException {
+ try {
+ StringWriter out;
+ DocumentFragment fragment = xmlDocument.createDocumentFragment();
- public void error(TransformerException exception)
- throws TransformerException {
- }
+ for (int i = 0; i < childNodes.getLength(); i++) {
+ fragment.appendChild(childNodes.item(i).cloneNode(true));
+ }
- public void fatalError(TransformerException exception)
- throws TransformerException {
- }
+ TransformerFactory transformerFactory = TransformerFactory.newInstance();
+ Transformer transformer = transformerFactory.newTransformer();
- public void warning(TransformerException exception)
- throws TransformerException {
- }
-
- });
- transformer.setOutputProperty("indent", "yes");
- transformer.setOutputProperty("omit-xml-declaration", "yes");
- out = new StringWriter();
- StreamResult result = new StreamResult(out);
- transformer.transform(new DOMSource(fragment), result);
- return out.toString();
- } catch (Exception e) {
- throw new ParsingException(e);
- }
- }
+ transformer.setErrorListener(new ErrorListener() {
+ public void error(TransformerException exception) throws TransformerException {}
+ public void fatalError(TransformerException exception) throws TransformerException {}
+ public void warning(TransformerException exception) throws TransformerException {}
+ });
+ transformer.setOutputProperty("indent", "yes");
+ transformer.setOutputProperty("omit-xml-declaration", "yes");
+ out = new StringWriter();
+
+ StreamResult result = new StreamResult(out);
+
+ transformer.transform(new DOMSource(fragment), result);
+
+ return out.toString();
+ } catch (Exception e) {
+ throw new ParsingException(e);
+ }
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/XPathComparator.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/XPathComparator.java 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/XPathComparator.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -19,6 +19,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.xmlutils;
import java.util.Comparator;
@@ -34,64 +36,68 @@
*
*/
public class XPathComparator implements Comparator<Node> {
+ private XPathCompatorCriterion[] criteria;
- class XPathCompatorCriterion {
- private XPathExpression expression = null;
-
- public XPathCompatorCriterion(String xPath){
- try {
- expression = XPathFactory.newInstance().newXPath().compile(xPath);
- } catch (XPathExpressionException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-
- public String getValue(Object node) throws XPathExpressionException {
- return expression == null ? null : expression.evaluate(node);
- }
- }
+ public XPathComparator(String... criteria) {
+ this.criteria = new XPathCompatorCriterion[criteria.length];
- private XPathCompatorCriterion [] criteria;
-
- public XPathComparator(String ... criteria) {
- this.criteria = new XPathCompatorCriterion[criteria.length];
- for(int i = 0; i < criteria.length; i++) {
- this.criteria[i] = new XPathCompatorCriterion(criteria[i]);
- }
- }
-
- public int compare(Node o1, Node o2) {
- int result = 0;
-
- for(int i = 0; i < criteria.length && result == 0; i++) {
- String s1 = null;
- String s2 = null;
- try {
- s1 = this.criteria[i].getValue(o1);
- } catch (XPathExpressionException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- try {
- s2 = this.criteria[i].getValue(o2);
- } catch (XPathExpressionException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- if (s1 != null) {
- if (s2 != null) {
- result = s1.compareTo(s2);
- } else {
- result = 1;
- }
- } else if (s2 != null) {
- result = -1;
- }
- }
-
- return result;
- }
+ for (int i = 0; i < criteria.length; i++) {
+ this.criteria[i] = new XPathCompatorCriterion(criteria[i]);
+ }
+ }
+ public int compare(Node o1, Node o2) {
+ int result = 0;
+
+ for (int i = 0; i < criteria.length && result == 0; i++) {
+ String s1 = null;
+ String s2 = null;
+
+ try {
+ s1 = this.criteria[i].getValue(o1);
+ } catch (XPathExpressionException e) {
+
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ try {
+ s2 = this.criteria[i].getValue(o2);
+ } catch (XPathExpressionException e) {
+
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ if (s1 != null) {
+ if (s2 != null) {
+ result = s1.compareTo(s2);
+ } else {
+ result = 1;
+ }
+ } else if (s2 != null) {
+ result = -1;
+ }
+ }
+
+ return result;
+ }
+
+ class XPathCompatorCriterion {
+ private XPathExpression expression = null;
+
+ public XPathCompatorCriterion(String xPath) {
+ try {
+ expression = XPathFactory.newInstance().newXPath().compile(xPath);
+ } catch (XPathExpressionException e) {
+
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ public String getValue(Object node) throws XPathExpressionException {
+ return expression == null ? null : expression.evaluate(node);
+ }
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/dtd/Attribute.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/dtd/Attribute.java 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/dtd/Attribute.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -19,17 +19,16 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.xmlutils.dtd;
/**
* @author Maksim Kaszynski
*
*/
-public class Attribute extends Node{
-
- public Attribute(String name) {
- super(name);
- }
-
-
+public class Attribute extends Node {
+ public Attribute(String name) {
+ super(name);
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/dtd/DocumentDefinition.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/dtd/DocumentDefinition.java 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/dtd/DocumentDefinition.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -19,9 +19,12 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.xmlutils.dtd;
import java.net.URL;
+
import java.util.HashMap;
import java.util.Map;
@@ -30,33 +33,29 @@
*
*/
public class DocumentDefinition {
- private Map<String, Element> elements = new HashMap<String, Element>();
-
- private URL url;
-
- private Element rootElement;
-
- public DocumentDefinition(URL url, Element rootElement) {
- super();
- this.url = url;
- this.rootElement = rootElement;
- }
+ private Map<String, Element> elements = new HashMap<String, Element>();
+ private Element rootElement;
+ private URL url;
- public void addElement(Element e) {
- elements.put(e.getName(), e);
- }
-
- public Element getElement(String name) {
- return elements.get(name);
- }
+ public DocumentDefinition(URL url, Element rootElement) {
+ super();
+ this.url = url;
+ this.rootElement = rootElement;
+ }
- public URL getUrl() {
- return url;
- }
+ public void addElement(Element e) {
+ elements.put(e.getName(), e);
+ }
- public Element getRootElement() {
- return rootElement;
- }
+ public Element getElement(String name) {
+ return elements.get(name);
+ }
-
+ public URL getUrl() {
+ return url;
+ }
+
+ public Element getRootElement() {
+ return rootElement;
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/dtd/DocumentDefinitionFactory.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/dtd/DocumentDefinitionFactory.java 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/dtd/DocumentDefinitionFactory.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -19,6 +19,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.xmlutils.dtd;
import java.net.URL;
@@ -30,13 +32,11 @@
*
*/
public abstract class DocumentDefinitionFactory {
+ private static DocumentDefinitionFactory instance = new WutkaDefinitionFactory();
- private static DocumentDefinitionFactory instance =
- new WutkaDefinitionFactory();
-
- public static DocumentDefinitionFactory instance() {
- return instance;
- }
-
- public abstract DocumentDefinition getDocumentDefinition(URL resource);
+ public static DocumentDefinitionFactory instance() {
+ return instance;
+ }
+
+ public abstract DocumentDefinition getDocumentDefinition(URL resource);
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/dtd/Element.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/dtd/Element.java 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/dtd/Element.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -19,6 +19,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.xmlutils.dtd;
import java.util.HashMap;
@@ -28,21 +30,18 @@
* @author Maksim Kaszynski
*
*/
-public class Element extends Node{
+public class Element extends Node {
+ private Map<String, Attribute> attributes = new HashMap<String, Attribute>();
- private Map<String, Attribute> attributes = new HashMap<String, Attribute>();
+ public Element(String name) {
+ super(name);
+ }
- public Element(String name) {
- super(name);
- }
-
- public void addAttribute(Attribute attribute) {
- attributes.put(attribute.getName(), attribute);
- }
-
- public Map<String, Attribute> getAttributes() {
- return attributes;
- }
+ public void addAttribute(Attribute attribute) {
+ attributes.put(attribute.getName(), attribute);
+ }
-
+ public Map<String, Attribute> getAttributes() {
+ return attributes;
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/dtd/Node.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/dtd/Node.java 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/dtd/Node.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -19,6 +19,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.xmlutils.dtd;
/**
@@ -27,16 +29,14 @@
*
*/
public class Node {
-
- private String name;
+ private String name;
- public String getName() {
- return name;
- }
+ public Node(String name) {
+ super();
+ this.name = name;
+ }
- public Node(String name) {
- super();
- this.name = name;
- }
-
+ public String getName() {
+ return name;
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/dtd/wutka/WutkaDefinitionFactory.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/dtd/wutka/WutkaDefinitionFactory.java 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/dtd/wutka/WutkaDefinitionFactory.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -19,9 +19,12 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.xmlutils.dtd.wutka;
import java.net.URL;
+
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
@@ -42,74 +45,62 @@
* @author Maksim Kaszynski
*
*/
-public class WutkaDefinitionFactory extends DocumentDefinitionFactory{
-
- private final Logger log = LoggerFactory.getLogger();
-
- private Map<URL, DocumentDefinition> definitions
- = new HashMap<URL, DocumentDefinition>();
-
- @Override
- public synchronized DocumentDefinition getDocumentDefinition(URL resource) {
- DocumentDefinition def = null;
- if (definitions.containsKey(resource)) {
- def = definitions.get(resource);
- } else {
-
- try {
- def = initDefinition(resource);
- } catch(Exception e) {
- log.error("An error has occured", e);
- }
-
- if (def != null) {
- definitions.put(resource, def);
- }
- }
- return def;
- }
-
-
- private DocumentDefinition initDefinition(URL resource) throws Exception{
+public class WutkaDefinitionFactory extends DocumentDefinitionFactory {
+ private final Logger log = LoggerFactory.getLogger();
+ private Map<URL, DocumentDefinition> definitions = new HashMap<URL, DocumentDefinition>();
- DTD dtd = new DTDParser(resource).parse();
-
- Element rootElement = fromWutka(dtd.rootElement);
-
- DocumentDefinition definition = new DocumentDefinition(resource, rootElement);
-
- @SuppressWarnings("unchecked")
- Enumeration<DTDElement> elements = dtd.elements.elements();
-
- while(elements.hasMoreElements()) {
- DTDElement element = elements.nextElement();
-
- definition.addElement(fromWutka(element));
- }
-
- return definition;
- }
-
- private Attribute fromWutka(DTDAttribute attr) {
- return new Attribute(attr.name);
- }
-
- private Element fromWutka(DTDElement element) {
-
- if (element == null) {
- return null;
- }
-
- Element e = new Element(element.getName());
+ @Override
+ public synchronized DocumentDefinition getDocumentDefinition(URL resource) {
+ DocumentDefinition def = null;
- @SuppressWarnings("unchecked")
- Enumeration<DTDAttribute> attrs =
- element.attributes.elements();
-
- while(attrs.hasMoreElements()) {
- e.addAttribute(fromWutka(attrs.nextElement()));
- }
-
- return e;
- }
+ if (definitions.containsKey(resource)) {
+ def = definitions.get(resource);
+ } else {
+ try {
+ def = initDefinition(resource);
+ } catch (Exception e) {
+ log.error("An error has occured", e);
+ }
+
+ if (def != null) {
+ definitions.put(resource, def);
+ }
+ }
+
+ return def;
+ }
+
+ private DocumentDefinition initDefinition(URL resource) throws Exception {
+ DTD dtd = new DTDParser(resource).parse();
+ Element rootElement = fromWutka(dtd.rootElement);
+ DocumentDefinition definition = new DocumentDefinition(resource, rootElement);
+ @SuppressWarnings("unchecked") Enumeration<DTDElement> elements = dtd.elements.elements();
+
+ while (elements.hasMoreElements()) {
+ DTDElement element = elements.nextElement();
+
+ definition.addElement(fromWutka(element));
+ }
+
+ return definition;
+ }
+
+ private Attribute fromWutka(DTDAttribute attr) {
+ return new Attribute(attr.name);
+ }
+
+ private Element fromWutka(DTDElement element) {
+ if (element == null) {
+ return null;
+ }
+
+ Element e = new Element(element.getName());
+ @SuppressWarnings("unchecked") Enumeration<DTDAttribute> attrs = element.attributes.elements();
+
+ while (attrs.hasMoreElements()) {
+ e.addAttribute(fromWutka(attrs.nextElement()));
+ }
+
+ return e;
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/dtd/xerces/XercesDefinitionFactory.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/dtd/xerces/XercesDefinitionFactory.java 2009-11-01 16:17:29 UTC (rev 15789)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/dtd/xerces/XercesDefinitionFactory.java 2009-11-01 16:21:55 UTC (rev 15790)
@@ -21,10 +21,14 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.xmlutils.dtd.xerces;
import java.io.IOException;
+
import java.net.URL;
+
import java.util.HashMap;
import java.util.Map;
@@ -36,6 +40,7 @@
import org.apache.xerces.xni.grammars.XSGrammar;
import org.apache.xerces.xni.parser.XMLInputSource;
import org.apache.xerces.xs.XSModel;
+
import org.richfaces.cdk.Logger;
import org.richfaces.cdk.LoggerFactory;
import org.richfaces.cdk.xmlutils.dtd.DocumentDefinition;
@@ -46,98 +51,103 @@
* That class implements {@link DocumentDefinitionFactory} that parses XML
* schema using Xerces Xml Schema API
* </p>
- *
+ *
* @author asmirnov(a)exadel.com
- *
+ *
*/
public class XercesDefinitionFactory extends DocumentDefinitionFactory {
- private final Logger log = LoggerFactory.getLogger();
- /** Namespaces feature id (http://xml.org/sax/features/namespaces). */
- public static final String NAMESPACES_FEATURE_ID = "http://xml.org/sax/features/namespaces";
- /** Validation feature id (http://xml.org/sax/features/validation). */
- public static final String VALIDATION_FEATURE_ID = "http://xml.org/sax/features/validation";
- /**
- * Schema validation feature id
- * (http://apache.org/xml/features/validation/schema).
- */
- public static final String SCHEMA_VALIDATION_FEATURE_ID = "http://apache.org/xml/features/validation/schema";
- /**
- * Schema full checking feature id
- * (http://apache.org/xml/features/validation/schema-full-checking).
- */
- public static final String SCHEMA_FULL_CHECKING_FEATURE_ID = "http://apache.org/xml/features/validation/schema-full-checking";
+ /** Namespaces feature id (http://xml.org/sax/features/namespaces). */
+ public static final String NAMESPACES_FEATURE_ID = "http://xml.org/sax/features/namespaces";
- // feature: continue-after-fatal-error
- public final static String CONTINUE_AFTER_FATAL_ERROR = Constants.XERCES_FEATURE_PREFIX
- + Constants.CONTINUE_AFTER_FATAL_ERROR_FEATURE;
- /** Property identifier: symbol table. */
- public static final String SYMBOL_TABLE = Constants.XERCES_PROPERTY_PREFIX
- + Constants.SYMBOL_TABLE_PROPERTY;
- /** Property identifier: error reporter. */
- public static final String ERROR_REPORTER = Constants.XERCES_PROPERTY_PREFIX
- + Constants.ERROR_REPORTER_PROPERTY;
- /** Property identifier: error handler. */
- public static final String ERROR_HANDLER = Constants.XERCES_PROPERTY_PREFIX
- + Constants.ERROR_HANDLER_PROPERTY;
- /** Property identifier: entity resolver. */
- public static final String ENTITY_RESOLVER = Constants.XERCES_PROPERTY_PREFIX
- + Constants.ENTITY_RESOLVER_PROPERTY;
- /** Property identifier: grammar pool . */
- public static final String GRAMMAR_POOL = Constants.XERCES_PROPERTY_PREFIX
- + Constants.XMLGRAMMAR_POOL_PROPERTY;
+ /**
+ * Schema full checking feature id
+ * (http://apache.org/xml/features/validation/schema-full-checking).
+ */
+ public static final String SCHEMA_FULL_CHECKING_FEATURE_ID =
+ "http://apache.org/xml/features/validation/schema-full-checking";
- private Map<URL, DocumentDefinition> definitions = new HashMap<URL, DocumentDefinition>();
+ /**
+ * Schema validation feature id
+ * (http://apache.org/xml/features/validation/schema).
+ */
+ public static final String SCHEMA_VALIDATION_FEATURE_ID = "http://apache.org/xml/features/validation/schema";
- @Override
- public synchronized DocumentDefinition getDocumentDefinition(URL resource) {
- DocumentDefinition def = null;
- if (definitions.containsKey(resource)) {
- def = definitions.get(resource);
- } else {
+ /** Validation feature id (http://xml.org/sax/features/validation). */
+ public static final String VALIDATION_FEATURE_ID = "http://xml.org/sax/features/validation";
- try {
- def = initDefinition(resource);
- } catch (Exception e) {
- log.error("An error has occured", e);
- }
+ /** Property identifier: symbol table. */
+ public static final String SYMBOL_TABLE = Constants.XERCES_PROPERTY_PREFIX + Constants.SYMBOL_TABLE_PROPERTY;
- if (def != null) {
- definitions.put(resource, def);
- }
- }
- return def;
- }
+ /** Property identifier: grammar pool . */
+ public static final String GRAMMAR_POOL = Constants.XERCES_PROPERTY_PREFIX + Constants.XMLGRAMMAR_POOL_PROPERTY;
- public DocumentDefinition initDefinition(URL resource) {
- XMLGrammarPreparser preparser = new XMLGrammarPreparser();
- // preparser.registerPreparser(XMLGrammarDescription.XML_DTD, null);
- preparser.registerPreparser(XMLGrammarDescription.XML_SCHEMA, null);
+ /** Property identifier: error reporter. */
+ public static final String ERROR_REPORTER = Constants.XERCES_PROPERTY_PREFIX + Constants.ERROR_REPORTER_PROPERTY;
- // preparser.setProperty(GRAMMAR_POOL, grammarPool);
- preparser.setFeature(NAMESPACES_FEATURE_ID, true);
- preparser.setFeature(VALIDATION_FEATURE_ID, true);
- // note we can set schema features just in case...
- preparser.setFeature(SCHEMA_VALIDATION_FEATURE_ID, true);
- preparser.setFeature(SCHEMA_FULL_CHECKING_FEATURE_ID, true);
+ /** Property identifier: error handler. */
+ public static final String ERROR_HANDLER = Constants.XERCES_PROPERTY_PREFIX + Constants.ERROR_HANDLER_PROPERTY;
- try {
- Grammar g = preparser.preparseGrammar(
- XMLGrammarDescription.XML_SCHEMA,
- createInputSource(resource));
- XSGrammar grammar = (XSGrammar) g;
- XSModel model = grammar.toXSModel();
- // TODO - make DocumentDefinition from XML schema.
- } catch (XNIException e) {
- log.error(e);
- } catch (IOException e) {
- log.error(e);
- }
- return null;
- }
+ /** Property identifier: entity resolver. */
+ public static final String ENTITY_RESOLVER = Constants.XERCES_PROPERTY_PREFIX + Constants.ENTITY_RESOLVER_PROPERTY;
- protected XMLInputSource createInputSource(URL resource) {
- return new XMLInputSource(null, resource.toExternalForm(), null);
- }
+ // feature: continue-after-fatal-error
+ public static final String CONTINUE_AFTER_FATAL_ERROR = Constants.XERCES_FEATURE_PREFIX
+ + Constants.CONTINUE_AFTER_FATAL_ERROR_FEATURE;
+ private final Logger log = LoggerFactory.getLogger();
+ private Map<URL, DocumentDefinition> definitions = new HashMap<URL, DocumentDefinition>();
+ @Override
+ public synchronized DocumentDefinition getDocumentDefinition(URL resource) {
+ DocumentDefinition def = null;
+
+ if (definitions.containsKey(resource)) {
+ def = definitions.get(resource);
+ } else {
+ try {
+ def = initDefinition(resource);
+ } catch (Exception e) {
+ log.error("An error has occured", e);
+ }
+
+ if (def != null) {
+ definitions.put(resource, def);
+ }
+ }
+
+ return def;
+ }
+
+ public DocumentDefinition initDefinition(URL resource) {
+ XMLGrammarPreparser preparser = new XMLGrammarPreparser();
+
+ // preparser.registerPreparser(XMLGrammarDescription.XML_DTD, null);
+ preparser.registerPreparser(XMLGrammarDescription.XML_SCHEMA, null);
+
+ // preparser.setProperty(GRAMMAR_POOL, grammarPool);
+ preparser.setFeature(NAMESPACES_FEATURE_ID, true);
+ preparser.setFeature(VALIDATION_FEATURE_ID, true);
+
+ // note we can set schema features just in case...
+ preparser.setFeature(SCHEMA_VALIDATION_FEATURE_ID, true);
+ preparser.setFeature(SCHEMA_FULL_CHECKING_FEATURE_ID, true);
+
+ try {
+ Grammar g = preparser.preparseGrammar(XMLGrammarDescription.XML_SCHEMA, createInputSource(resource));
+ XSGrammar grammar = (XSGrammar) g;
+ XSModel model = grammar.toXSModel();
+
+ // TODO - make DocumentDefinition from XML schema.
+ } catch (XNIException e) {
+ log.error(e);
+ } catch (IOException e) {
+ log.error(e);
+ }
+
+ return null;
+ }
+
+ protected XMLInputSource createInputSource(URL resource) {
+ return new XMLInputSource(null, resource.toExternalForm(), null);
+ }
}
15 years, 1 month
JBoss Rich Faces SVN: r15789 - in root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder: render and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: Alex.Kolonitsky
Date: 2009-11-01 11:17:29 -0500 (Sun, 01 Nov 2009)
New Revision: 15789
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/model/Argument.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/model/ClassImport.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/model/JavaAnnotation.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/model/JavaClass.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/model/JavaComment.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/model/JavaConstructor.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/model/JavaField.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/model/JavaImport.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/model/JavaLanguageElement.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/model/JavaMethod.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/model/JavaModifier.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/model/JavaPackage.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/model/JavaPrimitive.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/model/MethodBody.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/model/MethodBodyStatement.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/model/MethodBodyStatementsContainer.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/model/RuntimeImport.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/render/JavaClassRenderer.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/render/JavaFieldRenderer.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/render/JavaLanguageElementRenderer.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/render/JavaMethodRenderer.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/templates/BaseTagBodyConsumer.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/templates/BaseTemplateConsumer.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/templates/ChooseTagBodyConsumer.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/templates/Consumer.java
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/RendererTemplateParser.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/templates/RootElementConsumer.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/templates/StructuralTagBodyConsumer.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/templates/TemplateBodyConsumer.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/templates/TemplateReader.java
Log:
Code style policy
https://jira.jboss.org/jira/browse/RFPL-195
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/model/Argument.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/model/Argument.java 2009-11-01 16:01:20 UTC (rev 15788)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/model/Argument.java 2009-11-01 16:17:29 UTC (rev 15789)
@@ -19,6 +19,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.builder.model;
/**
@@ -27,23 +29,24 @@
*
*/
public class Argument {
- private Class<?> type;
- private String name;
-
- public static Argument arg(String name, Class<?> type) {
- return new Argument(name, type);
- }
-
- public Argument(String name, Class<?> type) {
- super();
- this.name = name;
- this.type = type;
- }
- public Class<?> getType() {
- return type;
- }
- public String getName() {
- return name;
- }
-
+ private String name;
+ private Class<?> type;
+
+ public Argument(String name, Class<?> type) {
+ super();
+ this.name = name;
+ this.type = type;
+ }
+
+ public static Argument arg(String name, Class<?> type) {
+ return new Argument(name, type);
+ }
+
+ public Class<?> getType() {
+ return type;
+ }
+
+ public String getName() {
+ return name;
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/model/ClassImport.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/model/ClassImport.java 2009-11-01 16:01:20 UTC (rev 15788)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/model/ClassImport.java 2009-11-01 16:17:29 UTC (rev 15789)
@@ -19,22 +19,23 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.builder.model;
/**
* @author Maksim Kaszynski
*
*/
-public class ClassImport implements JavaImport{
- private Class<?> clazz;
+public class ClassImport implements JavaImport {
+ private Class<?> clazz;
- public ClassImport(Class<?> clazz) {
- super();
- this.clazz = clazz;
- }
-
- public String getName() {
- return clazz.getName();
- }
+ public ClassImport(Class<?> clazz) {
+ super();
+ this.clazz = clazz;
+ }
+ public String getName() {
+ return clazz.getName();
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/model/JavaAnnotation.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/model/JavaAnnotation.java 2009-11-01 16:01:20 UTC (rev 15788)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/model/JavaAnnotation.java 2009-11-01 16:17:29 UTC (rev 15789)
@@ -19,41 +19,38 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.builder.model;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-
-
/**
* Wrapper for '@annotations
* @author Maksim Kaszynski
*
*/
public class JavaAnnotation {
-
- private Class<?> type;
-
- private List <String> arguments = new ArrayList <String>();
-
- public JavaAnnotation(Class<?> type) {
- super();
- this.type = type;
- }
+ private List<String> arguments = new ArrayList<String>();
+ private Class<?> type;
- public JavaAnnotation(Class<?> type, String ... parameters) {
- this(type);
- this.arguments = Arrays.asList(parameters);
- }
-
- public Class<?> getType() {
- return type;
- }
-
- public List<String> getArguments() {
- return arguments;
- }
-
+ public JavaAnnotation(Class<?> type) {
+ super();
+ this.type = type;
+ }
+
+ public JavaAnnotation(Class<?> type, String... parameters) {
+ this(type);
+ this.arguments = Arrays.asList(parameters);
+ }
+
+ public Class<?> getType() {
+ return type;
+ }
+
+ public List<String> getArguments() {
+ return arguments;
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/model/JavaClass.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/model/JavaClass.java 2009-11-01 16:01:20 UTC (rev 15788)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/model/JavaClass.java 2009-11-01 16:17:29 UTC (rev 15789)
@@ -19,6 +19,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.builder.model;
import java.util.ArrayList;
@@ -33,164 +35,166 @@
* @author Maksim Kaszynski
*
*/
-public class JavaClass extends JavaLanguageElement{
- private List<JavaField> fields = new ArrayList<JavaField>();
- private List<JavaMethod> methods = new ArrayList<JavaMethod>();
- private Set<JavaImport> imports = new TreeSet<JavaImport>(
- new Comparator<JavaImport> () {
- public int compare(JavaImport o1, JavaImport o2) {
- return o1.getName().compareTo(o2.getName());
- }
- });
-
- private JavaPackage pakg;
-
- private static final JavaClass DEFAULT_SUPERCLASS = new JavaClass(Object.class);
-
- private JavaClass superClass = DEFAULT_SUPERCLASS;
-
- public JavaClass(String shortName, JavaPackage pakg, Class<?> superClass) {
- this(shortName, pakg);
- setSuperClass(new JavaClass(superClass));
- }
-
- public JavaClass() {
- super();
- }
+public class JavaClass extends JavaLanguageElement {
+ private static final JavaClass DEFAULT_SUPERCLASS = new JavaClass(Object.class);
+ private List<JavaField> fields = new ArrayList<JavaField>();
+ private List<JavaMethod> methods = new ArrayList<JavaMethod>();
+ private Set<JavaImport> imports = new TreeSet<JavaImport>(new Comparator<JavaImport>() {
+ public int compare(JavaImport o1, JavaImport o2) {
+ return o1.getName().compareTo(o2.getName());
+ }
+ });
+ private JavaClass superClass = DEFAULT_SUPERCLASS;
+ private JavaPackage pakg;
- public JavaClass(String shortName, JavaPackage pakg) {
- super(shortName);
- this.pakg = pakg;
- }
-
- public JavaClass(Class<?> clazz) {
- this(clazz.getSimpleName(), new JavaPackage(clazz.getPackage()));
- }
+ public JavaClass() {
+ super();
+ }
- public void addImport(String name) {
- imports.add(new RuntimeImport(name));
- }
-
- public void addImport(Class<?> claz) {
- if (shouldAddToImports(claz)) {
- imports.add(new ClassImport(claz));
- }
- }
-
- @Override
- public void addAnnotation(JavaAnnotation annotation) {
- super.addAnnotation(annotation);
- addImport(annotation.getType());
- }
-
- public void addField(JavaField field) {
- fields.add(field);
- addImport(field.getType());
+ public JavaClass(Class<?> clazz) {
+ this(clazz.getSimpleName(), new JavaPackage(clazz.getPackage()));
+ }
- List<JavaAnnotation> annotations2 = field.getAnnotations();
- if (annotations2 != null) {
- for (JavaAnnotation javaAnnotation : annotations2) {
- addImport(javaAnnotation.getType());
- }
- }
- }
-
- public void addMethod(JavaMethod method) {
- methods.add(method);
- addImport(method.getReturnType());
-
- List<Class<? extends Throwable>> exceptions = method.getExceptions();
-
- for (Class<? extends Throwable> exception : exceptions) {
- addImport(exception);
- }
-
- List<Argument> arguments =
- method.getArguments();
-
- if (arguments != null) {
- for (Argument argument : arguments) {
- addImport(argument.getType());
- }
- }
-
- List<JavaAnnotation> annotations2 = method.getAnnotations();
- if (annotations2 != null) {
- for (JavaAnnotation javaAnnotation : annotations2) {
- addImport(javaAnnotation.getType());
- }
- }
-
- MethodBody methodBody = method.getMethodBody();
- if (methodBody != null) {
- Set<Class<?>> usedClasses = methodBody.getUsedClasses();
- for (Class<?> class1 : usedClasses) {
- addImport(class1);
- }
- }
-
- }
-
- public JavaPackage getPakg() {
- return pakg;
- }
+ public JavaClass(String shortName, JavaPackage pakg) {
+ super(shortName);
+ this.pakg = pakg;
+ }
- public JavaClass getSuperClass() {
- return superClass;
- }
-
- public void setSuperClass(JavaClass superClass) {
- this.superClass = superClass;
- addImport(superClass.getFullName());
- }
-
- public void setPackage(JavaPackage s) {
- pakg = s;
- }
- public JavaPackage getPackage() {
- return pakg;
- }
-
- public List<JavaField> getFields() {
- return fields;
- }
- public List<JavaMethod> getMethods() {
- return methods;
- }
- public Set<JavaImport> getImports() {
- return imports;
- }
-
- public String getFullName() {
- StringBuilder fullName = new StringBuilder();
- fullName.append(getPackage().getName());
- if (fullName.length() != 0) {
- fullName.append('.');
- fullName.append(getName());
- }
-
- return fullName.toString();
- }
-
- //FIXME: remodel this method so that it imports set is aligned when rendering
- private boolean shouldAddToImports(Class<?> clas) {
-
- boolean result = false;
+ public JavaClass(String shortName, JavaPackage pakg, Class<?> superClass) {
+ this(shortName, pakg);
+ setSuperClass(new JavaClass(superClass));
+ }
- if (clas != null) {
- Package p = clas.getPackage();
- JavaPackage jp = getPackage();
+ public void addImport(String name) {
+ imports.add(new RuntimeImport(name));
+ }
- if (!(clas.isPrimitive() || p == null)) {
- String importPackageName = p.getName();
- if (importPackageName != null && importPackageName.length() != 0) {
+ public void addImport(Class<?> claz) {
+ if (shouldAddToImports(claz)) {
+ imports.add(new ClassImport(claz));
+ }
+ }
- result = !(importPackageName.equals("java.lang") || (jp != null && importPackageName.equals(jp.getName())));
- }
- }
- }
+ @Override
+ public void addAnnotation(JavaAnnotation annotation) {
+ super.addAnnotation(annotation);
+ addImport(annotation.getType());
+ }
- return result;
- }
+ public void addField(JavaField field) {
+ fields.add(field);
+ addImport(field.getType());
+ List<JavaAnnotation> annotations2 = field.getAnnotations();
+
+ if (annotations2 != null) {
+ for (JavaAnnotation javaAnnotation : annotations2) {
+ addImport(javaAnnotation.getType());
+ }
+ }
+ }
+
+ public void addMethod(JavaMethod method) {
+ methods.add(method);
+ addImport(method.getReturnType());
+
+ List<Class<? extends Throwable>> exceptions = method.getExceptions();
+
+ for (Class<? extends Throwable> exception : exceptions) {
+ addImport(exception);
+ }
+
+ List<Argument> arguments = method.getArguments();
+
+ if (arguments != null) {
+ for (Argument argument : arguments) {
+ addImport(argument.getType());
+ }
+ }
+
+ List<JavaAnnotation> annotations2 = method.getAnnotations();
+
+ if (annotations2 != null) {
+ for (JavaAnnotation javaAnnotation : annotations2) {
+ addImport(javaAnnotation.getType());
+ }
+ }
+
+ MethodBody methodBody = method.getMethodBody();
+
+ if (methodBody != null) {
+ Set<Class<?>> usedClasses = methodBody.getUsedClasses();
+
+ for (Class<?> class1 : usedClasses) {
+ addImport(class1);
+ }
+ }
+ }
+
+ public JavaPackage getPakg() {
+ return pakg;
+ }
+
+ public JavaClass getSuperClass() {
+ return superClass;
+ }
+
+ public void setSuperClass(JavaClass superClass) {
+ this.superClass = superClass;
+ addImport(superClass.getFullName());
+ }
+
+ public void setPackage(JavaPackage s) {
+ pakg = s;
+ }
+
+ public JavaPackage getPackage() {
+ return pakg;
+ }
+
+ public List<JavaField> getFields() {
+ return fields;
+ }
+
+ public List<JavaMethod> getMethods() {
+ return methods;
+ }
+
+ public Set<JavaImport> getImports() {
+ return imports;
+ }
+
+ public String getFullName() {
+ StringBuilder fullName = new StringBuilder();
+
+ fullName.append(getPackage().getName());
+
+ if (fullName.length() != 0) {
+ fullName.append('.');
+ fullName.append(getName());
+ }
+
+ return fullName.toString();
+ }
+
+ // FIXME: remodel this method so that it imports set is aligned when rendering
+ private boolean shouldAddToImports(Class<?> clas) {
+ boolean result = false;
+
+ if (clas != null) {
+ Package p = clas.getPackage();
+ JavaPackage jp = getPackage();
+
+ if (!(clas.isPrimitive() || p == null)) {
+ String importPackageName = p.getName();
+
+ if (importPackageName != null && importPackageName.length() != 0) {
+ result = !(importPackageName.equals("java.lang")
+ || (jp != null && importPackageName.equals(jp.getName())));
+ }
+ }
+ }
+
+ return result;
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/model/JavaComment.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/model/JavaComment.java 2009-11-01 16:01:20 UTC (rev 15788)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/model/JavaComment.java 2009-11-01 16:17:29 UTC (rev 15789)
@@ -19,6 +19,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.builder.model;
/**
@@ -27,21 +29,20 @@
*
*/
public class JavaComment {
- private String value;
+ private String value;
- public String getValue() {
- return value;
- }
+ public JavaComment() {}
- public void setValue(String value) {
- this.value = value;
- }
+ public JavaComment(String value) {
+ super();
+ this.value = value;
+ }
- public JavaComment(String value) {
- super();
- this.value = value;
- }
-
- public JavaComment() {
- }
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/model/JavaConstructor.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/model/JavaConstructor.java 2009-11-01 16:01:20 UTC (rev 15788)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/model/JavaConstructor.java 2009-11-01 16:17:29 UTC (rev 15789)
@@ -19,17 +19,17 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.builder.model;
-
/**
* Constructor method
* @author Maksim Kaszynski
*
*/
public class JavaConstructor extends JavaMethod {
-
- public JavaConstructor(JavaClass javaClass, Argument ... arguments) {
- super(javaClass.getName(), null, arguments);
- }
+ public JavaConstructor(JavaClass javaClass, Argument... arguments) {
+ super(javaClass.getName(), null, arguments);
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/model/JavaField.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/model/JavaField.java 2009-11-01 16:01:20 UTC (rev 15788)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/model/JavaField.java 2009-11-01 16:17:29 UTC (rev 15789)
@@ -19,6 +19,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.builder.model;
/**
@@ -26,38 +28,29 @@
* @author Maksim Kaszynski
*
*/
-public class JavaField extends JavaLanguageElement{
+public class JavaField extends JavaLanguageElement {
+ private Class<?> type;
+ private Object value;
- private Class <?> type;
- private Object value;
-
- public JavaField(Class<?> type, String name) {
- this(type, name, null);
- }
+ public JavaField(Class<?> type, String name) {
+ this(type, name, null);
+ }
-
-
- public JavaField(Class<?> type, String name, Object value) {
- super(name);
- this.type = type;
- this.value = value;
- }
+ public JavaField(Class<?> type, String name, Object value) {
+ super(name);
+ this.type = type;
+ this.value = value;
+ }
+ public Class<?> getType() {
+ return type;
+ }
+ public Object getValue() {
+ return value;
+ }
- public Class<?> getType() {
- return type;
- }
-
-
-
- public Object getValue() {
- return value;
- }
-
-
-
- public void setValue(Object value) {
- this.value = value;
- }
+ public void setValue(Object value) {
+ this.value = value;
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/model/JavaImport.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/model/JavaImport.java 2009-11-01 16:01:20 UTC (rev 15788)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/model/JavaImport.java 2009-11-01 16:17:29 UTC (rev 15789)
@@ -19,6 +19,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.builder.model;
/**
@@ -26,5 +28,5 @@
*
*/
public interface JavaImport {
- public String getName();
+ public String getName();
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/model/JavaLanguageElement.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/model/JavaLanguageElement.java 2009-11-01 16:01:20 UTC (rev 15788)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/model/JavaLanguageElement.java 2009-11-01 16:17:29 UTC (rev 15789)
@@ -19,65 +19,68 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.builder.model;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
+
/**
- *
+ *
* @author Maksim Kaszynski
*
*/
public class JavaLanguageElement {
+ private Set<JavaModifier> modifiers = new HashSet<JavaModifier>();
+ private List<JavaComment> comments = new ArrayList<JavaComment>();
+ private List<JavaAnnotation> annotations = new ArrayList<JavaAnnotation>();
+ private String name;
- private Set<JavaModifier> modifiers = new HashSet<JavaModifier>();
- private List<JavaAnnotation> annotations = new ArrayList<JavaAnnotation>();
- private List<JavaComment> comments = new ArrayList<JavaComment>();
- private String name;
+ public JavaLanguageElement() {
+ super();
+ }
- public JavaLanguageElement() {
- super();
- }
-
- public JavaLanguageElement(String name) {
- super();
- this.name = name;
- }
+ public JavaLanguageElement(String name) {
+ super();
+ this.name = name;
+ }
- public Set<JavaModifier> getModifiers() {
- return modifiers;
- }
+ public Set<JavaModifier> getModifiers() {
+ return modifiers;
+ }
- public List<JavaAnnotation> getAnnotations() {
- return annotations;
- }
+ public List<JavaAnnotation> getAnnotations() {
+ return annotations;
+ }
- public List<JavaComment> getComments() {
- return comments;
- }
+ public List<JavaComment> getComments() {
+ return comments;
+ }
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public void addModifier(JavaModifier modifier) {
- modifiers.add(modifier);
- }
-
- public void addAnnotation(JavaAnnotation annotation) {
- annotations.add(annotation);
- }
- public void addAnnotation(Class<?> annotation, String ... arguments) {
- annotations.add(new JavaAnnotation(annotation, arguments));
- }
- public void addAnnotation(Class<?> annotation) {
- annotations.add(new JavaAnnotation(annotation));
- }
+ public String getName() {
+ return name;
+ }
-}
\ No newline at end of file
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public void addModifier(JavaModifier modifier) {
+ modifiers.add(modifier);
+ }
+
+ public void addAnnotation(JavaAnnotation annotation) {
+ annotations.add(annotation);
+ }
+
+ public void addAnnotation(Class<?> annotation, String... arguments) {
+ annotations.add(new JavaAnnotation(annotation, arguments));
+ }
+
+ public void addAnnotation(Class<?> annotation) {
+ annotations.add(new JavaAnnotation(annotation));
+ }
+}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/model/JavaMethod.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/model/JavaMethod.java 2009-11-01 16:01:20 UTC (rev 15788)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/model/JavaMethod.java 2009-11-01 16:17:29 UTC (rev 15789)
@@ -19,6 +19,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.builder.model;
import java.util.ArrayList;
@@ -30,54 +32,52 @@
*
*/
public class JavaMethod extends JavaLanguageElement {
-
- private Class<?> returnType;
-
- private MethodBody methodBody;
-
- private List <Argument> arguments = new ArrayList<Argument>();
- private List<Class<? extends Throwable>> exceptions = new ArrayList<Class<? extends Throwable>>();
-
- public List<Class<? extends Throwable>> getExceptions() {
- return exceptions;
- }
+ private List<Argument> arguments = new ArrayList<Argument>();
+ private List<Class<? extends Throwable>> exceptions = new ArrayList<Class<? extends Throwable>>();
+ private MethodBody methodBody;
+ private Class<?> returnType;
- public void setExceptions(List<Class<? extends Throwable>> exceptions) {
- this.exceptions = exceptions;
- }
+ public JavaMethod(String name) {
+ super(name);
+ this.returnType = Void.TYPE;
+ }
- public JavaMethod(String name) {
- super(name);
- this.returnType = Void.TYPE;
- }
+ public JavaMethod(String name, Argument... arguments) {
+ this(name);
+ this.arguments = Arrays.asList(arguments);
+ }
- public JavaMethod(String name, Argument ... arguments) {
- this(name);
- this.arguments = Arrays.asList(arguments);
- }
+ public JavaMethod(String name, Class<?> returnType, Argument... arguments) {
+ this(name);
+ this.returnType = returnType;
+ this.arguments = Arrays.asList(arguments);
+ }
- public JavaMethod(String name, Class<?> returnType, Argument ... arguments) {
- this(name);
- this.returnType = returnType;
- this.arguments = Arrays.asList(arguments);
- }
- public List<Argument> getArguments() {
- return arguments;
- }
-
- public MethodBody getMethodBody() {
- return methodBody;
- }
+ public List<Class<? extends Throwable>> getExceptions() {
+ return exceptions;
+ }
+ public void setExceptions(List<Class<? extends Throwable>> exceptions) {
+ this.exceptions = exceptions;
+ }
- public Class<?> getReturnType() {
- return returnType;
- }
+ public List<Argument> getArguments() {
+ return arguments;
+ }
- public void setMethodBody(MethodBody methodBody) {
- this.methodBody = methodBody;
- if (methodBody != null) {
- methodBody.setMethod(this);
- }
- }
+ public MethodBody getMethodBody() {
+ return methodBody;
+ }
+
+ public Class<?> getReturnType() {
+ return returnType;
+ }
+
+ public void setMethodBody(MethodBody methodBody) {
+ this.methodBody = methodBody;
+
+ if (methodBody != null) {
+ methodBody.setMethod(this);
+ }
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/model/JavaModifier.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/model/JavaModifier.java 2009-11-01 16:01:20 UTC (rev 15788)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/model/JavaModifier.java 2009-11-01 16:17:29 UTC (rev 15789)
@@ -19,6 +19,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.builder.model;
/**
@@ -26,21 +28,16 @@
*
*/
public enum JavaModifier {
- PRIVATE ,
- DEFAULT {
- public String toString() {
- return "";
- }
- },
- PROTECTED,
- PUBLIC,
- STATIC,
- FINAL,
- TRANSIENT
- ;
+ PRIVATE, DEFAULT {
+ @Override
+ public String toString() {
+ return "";
+ }
+ },
+ PROTECTED, PUBLIC, STATIC, FINAL, TRANSIENT;
- public String toString() {
- return super.toString().toLowerCase();
- }
-
+ @Override
+ public String toString() {
+ return super.toString().toLowerCase();
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/model/JavaPackage.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/model/JavaPackage.java 2009-11-01 16:01:20 UTC (rev 15788)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/model/JavaPackage.java 2009-11-01 16:17:29 UTC (rev 15789)
@@ -19,6 +19,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.builder.model;
/**
@@ -26,20 +28,18 @@
*
*/
public class JavaPackage {
- private String name;
+ private String name;
- public String getName() {
- return name;
- }
+ public JavaPackage(Package pkg) {
+ this(pkg.getName());
+ }
- public JavaPackage(String name) {
- super();
- this.name = name;
- }
+ public JavaPackage(String name) {
+ super();
+ this.name = name;
+ }
- public JavaPackage(Package pkg) {
- this(pkg.getName());
- }
-
-
+ public String getName() {
+ return name;
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/model/JavaPrimitive.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/model/JavaPrimitive.java 2009-11-01 16:01:20 UTC (rev 15788)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/model/JavaPrimitive.java 2009-11-01 16:17:29 UTC (rev 15789)
@@ -19,6 +19,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.builder.model;
import java.util.HashMap;
@@ -28,52 +30,53 @@
* @author Maksim Kaszynski
*
*/
-public class JavaPrimitive {
-
- @SuppressWarnings("serial")
- private static Map<String, Class<?>> types =
- new HashMap<String, Class<?>> () {{
- put("boolean", boolean.class);
- put("byte", byte.class);
- put("short", short.class);
- put("char", char.class);
- put("int", int.class);
- put("long", long.class);
- put("float", float.class);
- put("double", double.class);
- }};
-
- @SuppressWarnings("serial")
- private static Map<String, Class<?>> wrappers =
- new HashMap<String, Class<?>>() {
- {
- put(boolean.class.getName(), Boolean.class);
- put(byte.class.getName(), Byte.class);
- put(short.class.getName(), Short.class);
- put(char.class.getName(), Character.class);
- put(int.class.getName(), Integer.class);
- put(float.class.getName(), Float.class);
- put(long.class.getName(), Long.class);
- put(double.class.getName(), Double.class);
- }};
-
- public static final Class<?> forName(String name) throws ClassNotFoundException{
- Class<?> class1 = types.get(name);
- if (class1 == null) {
- throw new ClassNotFoundException(name);
- }
- return class1;
- }
-
- public static final Class<?> wrapperType(Class<?> primitive) {
- if (!primitive.isPrimitive()) {
- throw new IllegalArgumentException("Class " + primitive + " is not primitive.");
- }
-
- return wrappers.get(primitive.getName());
- }
-
- public static final boolean isPrimitive(String typeName) {
- return types.containsKey(typeName);
- }
+public final class JavaPrimitive {
+ private static final Map<String, Class<?>> TYPES = new HashMap<String, Class<?>>() {
+ {
+ put("boolean", boolean.class);
+ put("byte", byte.class);
+ put("short", short.class);
+ put("char", char.class);
+ put("int", int.class);
+ put("long", long.class);
+ put("float", float.class);
+ put("double", double.class);
+ }
+ };
+ private static final Map<String, Class<?>> WRAPPERS = new HashMap<String, Class<?>>() {
+ {
+ put(boolean.class.getName(), Boolean.class);
+ put(byte.class.getName(), Byte.class);
+ put(short.class.getName(), Short.class);
+ put(char.class.getName(), Character.class);
+ put(int.class.getName(), Integer.class);
+ put(float.class.getName(), Float.class);
+ put(long.class.getName(), Long.class);
+ put(double.class.getName(), Double.class);
+ }
+ };
+
+ private JavaPrimitive() {}
+
+ public static Class<?> forName(String name) throws ClassNotFoundException {
+ Class<?> class1 = TYPES.get(name);
+
+ if (class1 == null) {
+ throw new ClassNotFoundException(name);
+ }
+
+ return class1;
+ }
+
+ public static Class<?> wrapperType(Class<?> primitive) {
+ if (!primitive.isPrimitive()) {
+ throw new IllegalArgumentException("Class " + primitive + " is not primitive.");
+ }
+
+ return WRAPPERS.get(primitive.getName());
+ }
+
+ public static boolean isPrimitive(String typeName) {
+ return TYPES.containsKey(typeName);
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/model/MethodBody.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/model/MethodBody.java 2009-11-01 16:01:20 UTC (rev 15788)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/model/MethodBody.java 2009-11-01 16:17:29 UTC (rev 15789)
@@ -19,6 +19,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.builder.model;
import java.util.ArrayList;
@@ -31,49 +33,46 @@
*
*/
public class MethodBody implements MethodBodyStatementsContainer {
-
- private JavaMethod method;
-
- private Set<Class<?>> usedClasses = new HashSet<Class<?>>();
-
- private List<MethodBodyStatement> body = new ArrayList<MethodBodyStatement>();
-
- public MethodBody() {
- }
- public MethodBody(JavaMethod method) {
- super();
- this.method = method;
- }
+ private Set<Class<?>> usedClasses = new HashSet<Class<?>>();
+ private List<MethodBodyStatement> body = new ArrayList<MethodBodyStatement>();
+ private JavaMethod method;
- protected JavaMethod getMethod() {
- return method;
- }
+ public MethodBody() {}
- protected void setMethod(JavaMethod method) {
- this.method = method;
- }
+ public MethodBody(JavaMethod method) {
+ super();
+ this.method = method;
+ }
- public String toCode() {
- StringBuilder builder = new StringBuilder();
-
- for (MethodBodyStatement statement : body) {
- statement.appendTo(builder);
- }
-
- return builder.toString();
- }
+ protected JavaMethod getMethod() {
+ return method;
+ }
- public void addToBody(MethodBodyStatement... argStatements) {
- for (MethodBodyStatement methodBodyStatement : argStatements) {
- body.add(methodBodyStatement);
- }
- }
-
- public void addType(Class<?> clazz) {
- usedClasses.add(clazz);
- }
-
- public Set<Class<?>> getUsedClasses() {
- return usedClasses;
- }
+ protected void setMethod(JavaMethod method) {
+ this.method = method;
+ }
+
+ public String toCode() {
+ StringBuilder builder = new StringBuilder();
+
+ for (MethodBodyStatement statement : body) {
+ statement.appendTo(builder);
+ }
+
+ return builder.toString();
+ }
+
+ public void addToBody(MethodBodyStatement... argStatements) {
+ for (MethodBodyStatement methodBodyStatement : argStatements) {
+ body.add(methodBodyStatement);
+ }
+ }
+
+ public void addType(Class<?> clazz) {
+ usedClasses.add(clazz);
+ }
+
+ public Set<Class<?>> getUsedClasses() {
+ return usedClasses;
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/model/MethodBodyStatement.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/model/MethodBodyStatement.java 2009-11-01 16:01:20 UTC (rev 15788)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/model/MethodBodyStatement.java 2009-11-01 16:17:29 UTC (rev 15789)
@@ -19,6 +19,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.builder.model;
import java.util.ArrayList;
@@ -26,53 +28,50 @@
/**
* @author Nick Belaevski
- *
+ *
*/
public class MethodBodyStatement implements MethodBodyStatementsContainer {
+ private String end = null;
+ private String start = null;
+ private List<MethodBodyStatement> statements = new ArrayList<MethodBodyStatement>();
- private List<MethodBodyStatement> statements = new ArrayList<MethodBodyStatement>();
+ public MethodBodyStatement() {
+ this(null);
+ }
- private String start = null;
-
- private String end = null;
+ public MethodBodyStatement(String expression) {
+ this(expression, null);
+ }
- public MethodBodyStatement() {
- this(null);
- }
+ public MethodBodyStatement(String start, String end) {
+ super();
+ this.start = start;
+ this.end = end;
+ }
- public MethodBodyStatement(String expression) {
- this(expression, null);
- }
-
- public MethodBodyStatement(String start, String end) {
- super();
- this.start = start;
- this.end = end;
- }
+ /**
+ * @param builder
+ */
+ public void appendTo(StringBuilder builder) {
+ if (start != null) {
+ builder.append(start);
+ builder.append('\n');
+ }
- /**
- * @param builder
- */
- public void appendTo(StringBuilder builder) {
- if (start != null) {
- builder.append(start);
- builder.append('\n');
- }
-
- for (MethodBodyStatement statement : statements) {
- statement.appendTo(builder);
- builder.append('\n');
- }
+ for (MethodBodyStatement statement : statements) {
+ statement.appendTo(builder);
+ builder.append('\n');
+ }
- if (end != null) {
- builder.append(end);
- builder.append('\n');
- }
- }
+ if (end != null) {
+ builder.append(end);
+ builder.append('\n');
+ }
+ }
- public void addToBody(MethodBodyStatement... argStatements) {
- for (MethodBodyStatement methodBodyStatement : argStatements) {
- statements.add(methodBodyStatement);
- }
- }
+ public void addToBody(MethodBodyStatement... argStatements) {
+ for (MethodBodyStatement methodBodyStatement : argStatements) {
+ statements.add(methodBodyStatement);
+ }
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/model/MethodBodyStatementsContainer.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/model/MethodBodyStatementsContainer.java 2009-11-01 16:01:20 UTC (rev 15788)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/model/MethodBodyStatementsContainer.java 2009-11-01 16:17:29 UTC (rev 15789)
@@ -19,13 +19,14 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.builder.model;
/**
* @author Nick Belaevski
- *
+ *
*/
public interface MethodBodyStatementsContainer {
-
- public void addToBody(MethodBodyStatement... s);
+ public void addToBody(MethodBodyStatement... s);
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/model/RuntimeImport.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/model/RuntimeImport.java 2009-11-01 16:01:20 UTC (rev 15788)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/model/RuntimeImport.java 2009-11-01 16:17:29 UTC (rev 15789)
@@ -19,6 +19,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.builder.model;
/**
@@ -27,17 +29,14 @@
*
*/
public class RuntimeImport implements JavaImport {
+ private String name;
- private String name;
-
- public RuntimeImport(String name) {
- super();
- this.name = name;
- }
+ public RuntimeImport(String name) {
+ super();
+ this.name = name;
+ }
-
- public String getName() {
- return name;
- }
-
+ public String getName() {
+ return name;
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/render/JavaClassRenderer.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/render/JavaClassRenderer.java 2009-11-01 16:01:20 UTC (rev 15788)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/render/JavaClassRenderer.java 2009-11-01 16:17:29 UTC (rev 15789)
@@ -19,133 +19,70 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.richfaces.builder.render;
-import java.io.PrintWriter;
-import java.util.List;
-import java.util.Set;
-import javax.faces.component.UIComponentBase;
+package org.richfaces.builder.render;
-import org.richfaces.builder.model.Argument;
import org.richfaces.builder.model.JavaClass;
import org.richfaces.builder.model.JavaField;
import org.richfaces.builder.model.JavaImport;
import org.richfaces.builder.model.JavaMethod;
-import org.richfaces.builder.model.JavaModifier;
-import org.richfaces.builder.model.JavaPackage;
-import org.richfaces.builder.model.MethodBody;
+import java.io.PrintWriter;
+
+import java.util.List;
+import java.util.Set;
+
/**
* @author Maksim Kaszynski
*
*/
public class JavaClassRenderer extends JavaLanguageElementRenderer<JavaClass> {
-
- private JavaMethodRenderer methodRenderer = new JavaMethodRenderer();
-
- private JavaFieldRenderer fieldRenderer = new JavaFieldRenderer();
-
- public void render(JavaClass javaClass, PrintWriter out){
- out.println("package " + javaClass.getPackage().getName() + ";");
- out.println();
- Set<JavaImport> imports = javaClass.getImports();
-
- for (JavaImport impord : imports) {
- out.println("import " + impord.getName() + ";");
- }
-
- out.println();
+ private JavaMethodRenderer methodRenderer = new JavaMethodRenderer();
+ private JavaFieldRenderer fieldRenderer = new JavaFieldRenderer();
- renderAnnotations(javaClass, out);
-
- renderModifiers(javaClass, out);
- out.print("class " + javaClass.getName() );
-
- JavaClass superClass =
- javaClass.getSuperClass();
-
- if (!Object.class.getName().equals(superClass.getName())) {
- out.print(" extends " + superClass.getName() + " ");
- }
-
- out.println("{");
+ public void render(JavaClass javaClass, PrintWriter out) {
+ out.println("package " + javaClass.getPackage().getName() + ";");
+ out.println();
- out.println();
+ Set<JavaImport> imports = javaClass.getImports();
- List<JavaField> fields = javaClass.getFields();
- for (JavaField javaField : fields) {
- fieldRenderer.render(javaField, out);
- out.println();
+ for (JavaImport impord : imports) {
+ out.println("import " + impord.getName() + ";");
+ }
- }
+ out.println();
+ renderAnnotations(javaClass, out);
+ renderModifiers(javaClass, out);
+ out.print("class " + javaClass.getName());
- out.println();
+ JavaClass superClass = javaClass.getSuperClass();
-
- List<JavaMethod> methods = javaClass.getMethods();
- for (JavaMethod javaMethod : methods) {
- methodRenderer.render(javaMethod, out);
- out.println();
+ if (!Object.class.getName().equals(superClass.getName())) {
+ out.print(" extends " + superClass.getName() + " ");
+ }
- }
-
-
- out.println("}");
- out.flush();
- out.close();
- }
-
- @interface Tezt {
-
- }
-
- public static void main(String[] args) {
- JavaClass javaClass = new JavaClass("MyClass", new JavaPackage("mypackage"));
-
- JavaField javaField = new JavaField(int.class, "count");
- javaField.setValue(0);
- javaField.getModifiers().add(JavaModifier.PRIVATE);
- javaClass.addField(javaField);
-
- JavaField field =
- new JavaField(UIComponentBase.class, "component", "null");
- field.addModifier(JavaModifier.PUBLIC);
- field.addAnnotation(Deprecated.class);
- javaClass.addField(field);
-
- javaClass.addAnnotation(Deprecated.class);
-
- JavaMethod accessor = new JavaMethod("getCount", int.class);
- accessor.setMethodBody(
- new MethodBody(accessor) {
- @Override
- public String toCode() {
- return "return count;";
- }
- }
- );
- accessor.getModifiers().add(JavaModifier.PUBLIC);
- accessor.getModifiers().add(JavaModifier.FINAL);
- javaClass.addMethod(accessor);
-
- JavaMethod mutator = new JavaMethod("setCount",
- new Argument("i", int.class));
- mutator.setMethodBody(
- new MethodBody(mutator) {
- @Override
- public String toCode() {
- return "count = i;";
- }
- }
- );
- mutator.addAnnotation(Tezt.class);
- mutator.addModifier(JavaModifier.PUBLIC);
- mutator.addModifier(JavaModifier.FINAL);
- javaClass.addMethod(mutator);
-
- PrintWriter printWriter = new PrintWriter(System.out);
- new JavaClassRenderer().render(javaClass, printWriter);
- printWriter.flush();
- }
+ out.println("{");
+ out.println();
+
+ List<JavaField> fields = javaClass.getFields();
+
+ for (JavaField javaField : fields) {
+ fieldRenderer.render(javaField, out);
+ out.println();
+ }
+
+ out.println();
+
+ List<JavaMethod> methods = javaClass.getMethods();
+
+ for (JavaMethod javaMethod : methods) {
+ methodRenderer.render(javaMethod, out);
+ out.println();
+ }
+
+ out.println("}");
+ out.flush();
+ out.close();
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/render/JavaFieldRenderer.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/render/JavaFieldRenderer.java 2009-11-01 16:01:20 UTC (rev 15788)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/render/JavaFieldRenderer.java 2009-11-01 16:17:29 UTC (rev 15789)
@@ -19,6 +19,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.builder.render;
import java.io.PrintWriter;
@@ -31,20 +33,22 @@
*/
public class JavaFieldRenderer extends JavaLanguageElementRenderer<JavaField> {
- /* (non-Javadoc)
- * @see org.richfaces.builder.render.JavaLanguageElementRenderer#render(org.richfaces.builder.model.JavaLanguageElement, java.io.PrintWriter)
- */
- @Override
- public void render(JavaField field, PrintWriter out) {
- renderComments(field, out);
- renderAnnotations(field, out);
- renderModifiers(field, out);
- out.print(" " + field.getType().getSimpleName());
- out.print(" " + field.getName());
- if (field.getValue() != null) {
- out.print(" = " + field.getValue());
- }
- out.println(";");
- }
+ /*
+ * (non-Javadoc)
+ * @see org.richfaces.builder.render.JavaLanguageElementRenderer#render(org.richfaces.builder.model.JavaLanguageElement, java.io.PrintWriter)
+ */
+ @Override
+ public void render(JavaField field, PrintWriter out) {
+ renderComments(field, out);
+ renderAnnotations(field, out);
+ renderModifiers(field, out);
+ out.print(" " + field.getType().getSimpleName());
+ out.print(" " + field.getName());
+ if (field.getValue() != null) {
+ out.print(" = " + field.getValue());
+ }
+
+ out.println(";");
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/render/JavaLanguageElementRenderer.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/render/JavaLanguageElementRenderer.java 2009-11-01 16:01:20 UTC (rev 15788)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/render/JavaLanguageElementRenderer.java 2009-11-01 16:17:29 UTC (rev 15789)
@@ -18,9 +18,13 @@
* 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.builder.render;
import java.io.PrintWriter;
+
import java.util.Iterator;
import java.util.List;
import java.util.Set;
@@ -29,58 +33,66 @@
import org.richfaces.builder.model.JavaComment;
import org.richfaces.builder.model.JavaLanguageElement;
import org.richfaces.builder.model.JavaModifier;
+
/**
- *
+ *
* @author Maksim Kaszynski
*
* @param <T>
*/
public abstract class JavaLanguageElementRenderer<T extends JavaLanguageElement> {
+ public JavaLanguageElementRenderer() {
+ super();
+ }
- public JavaLanguageElementRenderer() {
- super();
- }
+ public void renderModifiers(T element, PrintWriter out) {
+ Set<JavaModifier> modifiers = element.getModifiers();
- public void renderModifiers(T element, PrintWriter out) {
- Set<JavaModifier> modifiers = element.getModifiers();
- for (JavaModifier javaModifier : modifiers) {
- out.print(javaModifier);
- out.print(" ");
- }
- }
-
- public void renderAnnotations(T element, PrintWriter out) {
- List<JavaAnnotation> annotations = element.getAnnotations();
- if (annotations != null) {
- for (JavaAnnotation javaAnnotation : annotations) {
- out.print("@" + javaAnnotation.getType().getSimpleName());
- List<String> arguments = javaAnnotation.getArguments();
- if (arguments != null && !arguments.isEmpty()) {
- out.print("(");
- for (Iterator<String> iterator = arguments.iterator(); iterator
- .hasNext();) {
- String string = iterator.next();
- out.print(string);
- if (iterator.hasNext()) {
- out.print(", ");
- }
- }
- out.print(")");
- }
- out.println();
- }
- }
-
- }
+ for (JavaModifier javaModifier : modifiers) {
+ out.print(javaModifier);
+ out.print(" ");
+ }
+ }
- public void renderComments(T element, PrintWriter out) {
- List<JavaComment> comments = element.getComments();
- for (JavaComment javaComment : comments) {
- out.println("/*");
- out.println("* " + javaComment.getValue());
- out.println("*/");
- }
- }
-
- public abstract void render(T element, PrintWriter out);
-}
\ No newline at end of file
+ public void renderAnnotations(T element, PrintWriter out) {
+ List<JavaAnnotation> annotations = element.getAnnotations();
+
+ if (annotations != null) {
+ for (JavaAnnotation javaAnnotation : annotations) {
+ out.print("@" + javaAnnotation.getType().getSimpleName());
+
+ List<String> arguments = javaAnnotation.getArguments();
+
+ if (arguments != null && !arguments.isEmpty()) {
+ out.print("(");
+
+ for (Iterator<String> iterator = arguments.iterator(); iterator.hasNext(); ) {
+ String string = iterator.next();
+
+ out.print(string);
+
+ if (iterator.hasNext()) {
+ out.print(", ");
+ }
+ }
+
+ out.print(")");
+ }
+
+ out.println();
+ }
+ }
+ }
+
+ public void renderComments(T element, PrintWriter out) {
+ List<JavaComment> comments = element.getComments();
+
+ for (JavaComment javaComment : comments) {
+ out.println("/*");
+ out.println("* " + javaComment.getValue());
+ out.println("*/");
+ }
+ }
+
+ public abstract void render(T element, PrintWriter out);
+}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/render/JavaMethodRenderer.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/render/JavaMethodRenderer.java 2009-11-01 16:01:20 UTC (rev 15788)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/render/JavaMethodRenderer.java 2009-11-01 16:17:29 UTC (rev 15789)
@@ -19,9 +19,12 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.builder.render;
import java.io.PrintWriter;
+
import java.util.Iterator;
import java.util.List;
@@ -34,55 +37,63 @@
*
*/
public class JavaMethodRenderer extends JavaLanguageElementRenderer<JavaMethod> {
+ @Override
+ public void render(JavaMethod javaMethod, PrintWriter out) {
+ renderComments(javaMethod, out);
+ renderAnnotations(javaMethod, out);
+ renderModifiers(javaMethod, out);
- @Override
- public void render(JavaMethod javaMethod, PrintWriter out) {
- renderComments(javaMethod, out);
- renderAnnotations(javaMethod, out);
- renderModifiers(javaMethod, out);
-
- Class<?> returnType = javaMethod.getReturnType();
-
- if (returnType != null) {
- out.print(returnType.getSimpleName() + " ");
- }
-
- out.print(javaMethod.getName());
+ Class<?> returnType = javaMethod.getReturnType();
- out.print("(");
- List<Argument> arguments = javaMethod.getArguments();
- if (arguments != null) {
- for (Iterator<Argument> iterator = arguments.iterator(); iterator.hasNext();) {
- Argument argument = iterator.next();
- out.print(argument.getType().getSimpleName());
- out.print(" ");
- out.print(argument.getName());
- if (iterator.hasNext()) {
- out.print(", ");
- }
- }
- }
- out.print(")");
- List<Class<? extends Throwable>> exceptions = javaMethod.getExceptions();
-
- if (exceptions != null && !exceptions.isEmpty()) {
- out.print(" throws ");
- for (Iterator<Class<? extends Throwable>> iterator = exceptions.iterator(); iterator.hasNext();) {
- Class<? extends Throwable> class1 = iterator.next();
- out.print(class1.getSimpleName());
- if (iterator.hasNext()) {
- out.print(", ");
- }
-
- }
- }
-
- out.println("{");
- MethodBody methodBody = javaMethod.getMethodBody();
- if (methodBody != null){
- out.println(methodBody.toCode());
- }
- out.println("}");
+ if (returnType != null) {
+ out.print(returnType.getSimpleName() + " ");
+ }
- }
+ out.print(javaMethod.getName());
+ out.print("(");
+
+ List<Argument> arguments = javaMethod.getArguments();
+
+ if (arguments != null) {
+ for (Iterator<Argument> iterator = arguments.iterator(); iterator.hasNext(); ) {
+ Argument argument = iterator.next();
+
+ out.print(argument.getType().getSimpleName());
+ out.print(" ");
+ out.print(argument.getName());
+
+ if (iterator.hasNext()) {
+ out.print(", ");
+ }
+ }
+ }
+
+ out.print(")");
+
+ List<Class<? extends Throwable>> exceptions = javaMethod.getExceptions();
+
+ if (exceptions != null && !exceptions.isEmpty()) {
+ out.print(" throws ");
+
+ for (Iterator<Class<? extends Throwable>> iterator = exceptions.iterator(); iterator.hasNext(); ) {
+ Class<? extends Throwable> class1 = iterator.next();
+
+ out.print(class1.getSimpleName());
+
+ if (iterator.hasNext()) {
+ out.print(", ");
+ }
+ }
+ }
+
+ out.println("{");
+
+ MethodBody methodBody = javaMethod.getMethodBody();
+
+ if (methodBody != null) {
+ out.println(methodBody.toCode());
+ }
+
+ out.println("}");
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/templates/BaseTagBodyConsumer.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/templates/BaseTagBodyConsumer.java 2009-11-01 16:01:20 UTC (rev 15788)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/templates/BaseTagBodyConsumer.java 2009-11-01 16:17:29 UTC (rev 15789)
@@ -1,4 +1,5 @@
package org.richfaces.builder.templates;
+
import javax.xml.namespace.QName;
import javax.xml.stream.events.Characters;
import javax.xml.stream.events.EndElement;
@@ -29,58 +30,60 @@
/**
* @author Nick Belaevski
- *
+ *
*/
public class BaseTagBodyConsumer extends BaseTemplateConsumer {
+ protected final MethodBodyStatement statement;
- protected final MethodBodyStatement statement;
-
- public BaseTagBodyConsumer(MethodBodyStatement methodBodyStatement) {
- super();
-
- this.statement = methodBodyStatement;
- }
+ public BaseTagBodyConsumer(MethodBodyStatement methodBodyStatement) {
+ super();
+ this.statement = methodBodyStatement;
+ }
- @Override
- public void consumeEndElement(EndElement endElement) {
- QName name = endElement.getName();
-
- if (!isCdkNamespace(name)) {
- statement.addToBody(createEndElement(endElement));
- }
- }
+ @Override
+ public void consumeEndElement(EndElement endElement) {
+ QName name = endElement.getName();
- @Override
- public Consumer consumeStartElement(StartElement startElement) {
- QName name = startElement.getName();
- if (isCdkNamespace(name)) {
- if ("if".equals(name.getLocalPart())) {
- MethodBodyStatement ifStatement = createIfExpression(startElement);
-
- statement.addToBody(ifStatement);
- return new StructuralTagBodyConsumer(ifStatement);
- } else if ("choose".equals(name.getLocalPart())) {
- MethodBodyStatement whenStatement = new MethodBodyStatement();
- statement.addToBody(whenStatement);
- return new ChooseTagBodyConsumer(whenStatement);
- } else if ("call".equals(name.getLocalPart())) {
- statement.addToBody(createCallExpression(startElement));
- } else {
- throw new IllegalArgumentException();
- }
- } else {
- statement.addToBody(createStartElement(startElement));
- }
-
- return this;
- }
-
- @Override
- public void consumeCharacters(Characters characters) {
- String trimmedText = characters.getData().trim();
-
- if (trimmedText.length() != 0) {
- statement.addToBody(createWriteText(characters));
- }
- }
+ if (!isCdkNamespace(name)) {
+ statement.addToBody(createEndElement(endElement));
+ }
+ }
+
+ @Override
+ public Consumer consumeStartElement(StartElement startElement) {
+ QName name = startElement.getName();
+
+ if (isCdkNamespace(name)) {
+ if ("if".equals(name.getLocalPart())) {
+ MethodBodyStatement ifStatement = createIfExpression(startElement);
+
+ statement.addToBody(ifStatement);
+
+ return new StructuralTagBodyConsumer(ifStatement);
+ } else if ("choose".equals(name.getLocalPart())) {
+ MethodBodyStatement whenStatement = new MethodBodyStatement();
+
+ statement.addToBody(whenStatement);
+
+ return new ChooseTagBodyConsumer(whenStatement);
+ } else if ("call".equals(name.getLocalPart())) {
+ statement.addToBody(createCallExpression(startElement));
+ } else {
+ throw new IllegalArgumentException();
+ }
+ } else {
+ statement.addToBody(createStartElement(startElement));
+ }
+
+ return this;
+ }
+
+ @Override
+ public void consumeCharacters(Characters characters) {
+ String trimmedText = characters.getData().trim();
+
+ if (trimmedText.length() != 0) {
+ statement.addToBody(createWriteText(characters));
+ }
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/templates/BaseTemplateConsumer.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/templates/BaseTemplateConsumer.java 2009-11-01 16:01:20 UTC (rev 15788)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/templates/BaseTemplateConsumer.java 2009-11-01 16:17:29 UTC (rev 15789)
@@ -1,25 +1,27 @@
package org.richfaces.builder.templates;
+
+import org.richfaces.builder.model.MethodBodyStatement;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.events.Attribute;
+import javax.xml.stream.events.Characters;
+import javax.xml.stream.events.EndElement;
+import javax.xml.stream.events.StartElement;
+
import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInputStream;
+
import java.text.MessageFormat;
-import java.util.HashSet;
+
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.Set;
-import java.util.Map.Entry;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import javax.xml.namespace.QName;
-import javax.xml.stream.events.Attribute;
-import javax.xml.stream.events.Characters;
-import javax.xml.stream.events.EndElement;
-import javax.xml.stream.events.StartElement;
-
-import org.richfaces.builder.model.MethodBodyStatement;
-
/**
* License Agreement.
*
@@ -43,246 +45,277 @@
/**
* @author Nick Belaevski
- *
+ *
*/
public class BaseTemplateConsumer implements Consumer {
+ private static final String CDK_NAMESPACE = "http://richfaces.org/cdk";
+ private static final String XHTML_NAMESPACE = "http://richfaces.org/xhtml-el";
+ private static final Pattern EL_EXPRESSION = Pattern.compile("#\\{([^\\}]+)\\}");
+ private static final Pattern COMPONENT_ATTRIBUTES_EXPRESSION =
+ Pattern.compile("^component\\.attributes\\[(?:'|\")?([^'\"]+)(?:'|\")?\\]$");
+ private static final Map<String, Set<String>> ELEMENTS_ATTRIBUTES;
- private static final String XHTML_NAMESPACE = "http://richfaces.org/xhtml-el";
+ static {
+ InputStream serializedAttributesStream = BaseTemplateConsumer.class.getResourceAsStream("/attributes.ser");
- private static final String CDK_NAMESPACE = "http://richfaces.org/cdk";
+ try {
- private static final Map<String, Set<String>> elementsAttributes;
-
- private static final Pattern EL_EXPRESSION = Pattern.compile("#\\{([^\\}]+)\\}");
-
- private static final Pattern COMPONENT_ATTRIBUTES_EXPRESSION = Pattern.compile("^component\\.attributes\\[(?:'|\")?([^'\"]+)(?:'|\")?\\]$");
+ // TODO read default attributes values
+ // TODO detect URI attributes
+ ObjectInputStream ois = new ObjectInputStream(serializedAttributesStream);
- static {
- InputStream serializedAttributesStream = BaseTemplateConsumer.class.getResourceAsStream("/attributes.ser");
- try {
- //TODO read default attributes values
- //TODO detect URI attributes
- ObjectInputStream ois = new ObjectInputStream(serializedAttributesStream);
- elementsAttributes = (Map<String, Set<String>>) ois.readObject();
- } catch (Exception e) {
- throw new IllegalStateException(e.getMessage(), e);
- } finally {
- try {
- serializedAttributesStream.close();
- } catch (IOException e) {
- throw new IllegalStateException(e.getMessage(), e);
- }
- }
- }
-
- /* (non-Javadoc)
- * @see Consumer#consumeCharacters(javax.xml.stream.events.Characters)
- */
- @Override
- public void consumeCharacters(Characters characters) {
- }
+ ELEMENTS_ATTRIBUTES = (Map<String, Set<String>>) ois.readObject();
+ } catch (Exception e) {
+ throw new IllegalStateException(e.getMessage(), e);
+ } finally {
+ try {
+ serializedAttributesStream.close();
+ } catch (IOException e) {
+ throw new IllegalStateException(e.getMessage(), e);
+ }
+ }
+ }
- /* (non-Javadoc)
- * @see Consumer#consumeEndElement(javax.xml.stream.events.EndElement)
- */
- @Override
- public void consumeEndElement(EndElement endElement) {
- }
+ /*
+ * (non-Javadoc)
+ * @see Consumer#consumeCharacters(javax.xml.stream.events.Characters)
+ */
+ @Override
+ public void consumeCharacters(Characters characters) {}
- /* (non-Javadoc)
- * @see Consumer#consumeStartElement(javax.xml.stream.events.StartElement)
- */
- @Override
- public Consumer consumeStartElement(StartElement startElement) {
- return this;
- }
+ /*
+ * (non-Javadoc)
+ * @see Consumer#consumeEndElement(javax.xml.stream.events.EndElement)
+ */
+ @Override
+ public void consumeEndElement(EndElement endElement) {}
- /* (non-Javadoc)
- * @see Consumer#enter()
- */
- @Override
- public void enter() {
- }
+ /*
+ * (non-Javadoc)
+ * @see Consumer#consumeStartElement(javax.xml.stream.events.StartElement)
+ */
+ @Override
+ public Consumer consumeStartElement(StartElement startElement) {
+ return this;
+ }
- /* (non-Javadoc)
- * @see Consumer#exit()
- */
- @Override
- public void exit() {
- }
+ /*
+ * (non-Javadoc)
+ * @see Consumer#enter()
+ */
+ @Override
+ public void enter() {}
- protected boolean isDefaultNamespace(QName name) {
- return name.getNamespaceURI().length() == 0;
- }
-
- protected boolean isXhtmlNamespace(QName name) {
- return XHTML_NAMESPACE.equals(name.getNamespaceURI());
- }
+ /*
+ * (non-Javadoc)
+ * @see Consumer#exit()
+ */
+ @Override
+ public void exit() {}
- protected boolean isCdkNamespace(QName name) {
- return CDK_NAMESPACE.equals(name.getNamespaceURI());
- }
-
- private String quote(String s) {
- StringBuilder result = new StringBuilder();
- result.append('\"');
-
- char[] chars = s.toCharArray();
- for (char c : chars) {
-
- switch (c) {
- case '\n':
- result.append("\\n");
- break;
- case '\r':
- result.append("\\r");
- break;
- case '\t':
- result.append("\\t");
- break;
- case '\f':
- result.append("\\f");
- break;
- case '\b':
- result.append("\\b");
- break;
- case '\\':
- result.append("\\\\");
- break;
- case '"':
- result.append("\\\"");
- break;
- default:
- result.append(c);
- }
- }
-
- result.append('\"');
- return result.toString();
- }
-
- protected String elExpressionToJava(String elExpression) {
- if ("clientId".equalsIgnoreCase(elExpression)) {
- return "component.getClientId(context)";
- } else {
- Matcher matcher = COMPONENT_ATTRIBUTES_EXPRESSION.matcher(elExpression);
- if (matcher.matches()) {
- String componentAttributeName = matcher.group(1);
- return MessageFormat.format("component.getAttributes().get(\"{0}\")", componentAttributeName);
- }
- }
-
- return elExpression;
- }
-
- protected String compileEl(String elString) {
- Matcher matcher = EL_EXPRESSION.matcher(elString);
- StringBuffer buffer = new StringBuffer();
-
- int start = 0;
- int elStart;
- while (matcher.find(start)) {
- elStart = matcher.start();
-
- if (elStart != start) {
- if (buffer.length() != 0) {
- buffer.append(" + ");
- }
- buffer.append(quote(elString.substring(start, elStart)));
- }
-
- String elExpression = matcher.group(1);
- if (buffer.length() != 0) {
- buffer.append(" + ");
- }
- buffer.append(elExpressionToJava(elExpression));
-
-
- start = matcher.end();
- }
-
- if (start != elString.length()) {
- if (buffer.length() != 0) {
- buffer.append(" + ");
- }
- buffer.append(quote(elString.substring(start)));
- }
- return buffer.toString();
- }
-
- protected MethodBodyStatement createStartElement(StartElement startElement) {
- MethodBodyStatement rootStatement = new MethodBodyStatement();
- String elementName = startElement.getName().getLocalPart();
- rootStatement.addToBody(new MethodBodyStatement(
- MessageFormat.format("responseWriter.startElement(\"{0}\", component);",
- elementName)));
-
- Map<String, String> attributes = new LinkedHashMap<String, String>();
-
- Iterator<Attribute> attributesItr = startElement.getAttributes();
- while (attributesItr.hasNext()) {
- Attribute attribute = attributesItr.next();
- QName attributeName = attribute.getName();
- String value = attribute.getValue();
-
- if (isXhtmlNamespace(attributeName) || isDefaultNamespace(attributeName)) {
- attributes.put(attributeName.getLocalPart(), value);
- } else if (isCdkNamespace(attributeName)) {
- if ("passThroughWithExclusions".equals(attributeName.getLocalPart())) {
- if (!"#none".equals(value)) {
- rootStatement.addToBody(new MethodBodyStatement(MessageFormat
- .format("getUtils().encodePassThruWithExclusions(context, component, \"{0}\", null);", value)));
- }
- } else {
- throw new IllegalArgumentException(attributeName.toString());
- }
- } else {
- throw new IllegalArgumentException(attributeName.toString());
- }
- }
-
- for (Entry<String, String> attributeEntry : attributes.entrySet()) {
- //TODO add check for default values
- rootStatement.addToBody(new MethodBodyStatement(
- MessageFormat.format("responseWriter.writeAttribute(\"{0}\", {1}, \"{0}\");",
- attributeEntry.getKey(), compileEl(attributeEntry.getValue()))));
- }
-
- return rootStatement;
- }
+ protected boolean isDefaultNamespace(QName name) {
+ return name.getNamespaceURI().length() == 0;
+ }
- protected MethodBodyStatement createEndElement(EndElement startElement) {
- String elementName = startElement.getName().getLocalPart();
- return new MethodBodyStatement(MessageFormat.format("responseWriter.endElement(\"{0}\");", elementName));
- }
-
- protected MethodBodyStatement createWriteText(Characters characters) {
- return new MethodBodyStatement(MessageFormat.format("responseWriter.writeText(convertToString({0}), component, null);",
- compileEl(characters.getData().trim())));
- }
-
- protected MethodBodyStatement createIfExpression(StartElement element) {
- Attribute testAttribute = element.getAttributeByName(new QName("test"));
- String testExpression = compileEl(testAttribute.getValue());
- return new MethodBodyStatement(
- MessageFormat.format("if ({0}) '{'", testExpression), "}");
- }
+ protected boolean isXhtmlNamespace(QName name) {
+ return XHTML_NAMESPACE.equals(name.getNamespaceURI());
+ }
- protected MethodBodyStatement createIfElseExpression(StartElement element) {
- Attribute testAttribute = element.getAttributeByName(new QName("test"));
- String testExpression = compileEl(testAttribute.getValue());
- return new MethodBodyStatement(
- MessageFormat.format("else if ({0}) '{'", testExpression), "}");
- }
+ protected boolean isCdkNamespace(QName name) {
+ return CDK_NAMESPACE.equals(name.getNamespaceURI());
+ }
- protected MethodBodyStatement createGetComponentClassMethod(String componentClassName) {
- return new MethodBodyStatement(MessageFormat.format("return {0}.class;", componentClassName));
- }
+ private String quote(String s) {
+ StringBuilder result = new StringBuilder();
- protected MethodBodyStatement createCallExpression(StartElement startElement) {
- Attribute expressionAttribute = startElement.getAttributeByName(new QName("expression"));
- String expressionValue = expressionAttribute.getValue();
- return new MethodBodyStatement(expressionValue);
- }
+ result.append('\"');
+ char[] chars = s.toCharArray();
+
+ for (char c : chars) {
+ switch (c) {
+ case '\n' :
+ result.append("\\n");
+
+ break;
+
+ case '\r' :
+ result.append("\\r");
+
+ break;
+
+ case '\t' :
+ result.append("\\t");
+
+ break;
+
+ case '\f' :
+ result.append("\\f");
+
+ break;
+
+ case '\b' :
+ result.append("\\b");
+
+ break;
+
+ case '\\' :
+ result.append("\\\\");
+
+ break;
+
+ case '"' :
+ result.append("\\\"");
+
+ break;
+
+ default :
+ result.append(c);
+ }
+ }
+
+ result.append('\"');
+
+ return result.toString();
+ }
+
+ protected String elExpressionToJava(String elExpression) {
+ if ("clientId".equalsIgnoreCase(elExpression)) {
+ return "component.getClientId(context)";
+ } else {
+ Matcher matcher = COMPONENT_ATTRIBUTES_EXPRESSION.matcher(elExpression);
+
+ if (matcher.matches()) {
+ String componentAttributeName = matcher.group(1);
+
+ return MessageFormat.format("component.getAttributes().get(\"{0}\")", componentAttributeName);
+ }
+ }
+
+ return elExpression;
+ }
+
+ protected String compileEl(String elString) {
+ Matcher matcher = EL_EXPRESSION.matcher(elString);
+ StringBuffer buffer = new StringBuffer();
+ int start = 0;
+ int elStart;
+
+ while (matcher.find(start)) {
+ elStart = matcher.start();
+
+ if (elStart != start) {
+ if (buffer.length() != 0) {
+ buffer.append(" + ");
+ }
+
+ buffer.append(quote(elString.substring(start, elStart)));
+ }
+
+ String elExpression = matcher.group(1);
+
+ if (buffer.length() != 0) {
+ buffer.append(" + ");
+ }
+
+ buffer.append(elExpressionToJava(elExpression));
+ start = matcher.end();
+ }
+
+ if (start != elString.length()) {
+ if (buffer.length() != 0) {
+ buffer.append(" + ");
+ }
+
+ buffer.append(quote(elString.substring(start)));
+ }
+
+ return buffer.toString();
+ }
+
+ protected MethodBodyStatement createStartElement(StartElement startElement) {
+ MethodBodyStatement rootStatement = new MethodBodyStatement();
+ String elementName = startElement.getName().getLocalPart();
+
+ rootStatement.addToBody(
+ new MethodBodyStatement(
+ MessageFormat.format("responseWriter.startElement(\"{0}\", component);", elementName)));
+
+ Map<String, String> attributes = new LinkedHashMap<String, String>();
+ Iterator<Attribute> attributesItr = startElement.getAttributes();
+
+ while (attributesItr.hasNext()) {
+ Attribute attribute = attributesItr.next();
+ QName attributeName = attribute.getName();
+ String value = attribute.getValue();
+
+ if (isXhtmlNamespace(attributeName) || isDefaultNamespace(attributeName)) {
+ attributes.put(attributeName.getLocalPart(), value);
+ } else if (isCdkNamespace(attributeName)) {
+ if ("passThroughWithExclusions".equals(attributeName.getLocalPart())) {
+ if (!"#none".equals(value)) {
+ rootStatement.addToBody(
+ new MethodBodyStatement(
+ MessageFormat.format(
+ "getUtils().encodePassThruWithExclusions(context, component, \"{0}\", null);",
+ value)));
+ }
+ } else {
+ throw new IllegalArgumentException(attributeName.toString());
+ }
+ } else {
+ throw new IllegalArgumentException(attributeName.toString());
+ }
+ }
+
+ for (Entry<String, String> attributeEntry : attributes.entrySet()) {
+
+ // TODO add check for default values
+ rootStatement.addToBody(
+ new MethodBodyStatement(
+ MessageFormat.format(
+ "responseWriter.writeAttribute(\"{0}\", {1}, \"{0}\");", attributeEntry.getKey(),
+ compileEl(attributeEntry.getValue()))));
+ }
+
+ return rootStatement;
+ }
+
+ protected MethodBodyStatement createEndElement(EndElement startElement) {
+ String elementName = startElement.getName().getLocalPart();
+
+ return new MethodBodyStatement(MessageFormat.format("responseWriter.endElement(\"{0}\");", elementName));
+ }
+
+ protected MethodBodyStatement createWriteText(Characters characters) {
+ return new MethodBodyStatement(
+ MessageFormat.format(
+ "responseWriter.writeText(convertToString({0}), component, null);",
+ compileEl(characters.getData().trim())));
+ }
+
+ protected MethodBodyStatement createIfExpression(StartElement element) {
+ Attribute testAttribute = element.getAttributeByName(new QName("test"));
+ String testExpression = compileEl(testAttribute.getValue());
+
+ return new MethodBodyStatement(MessageFormat.format("if ({0}) '{'", testExpression), "}");
+ }
+
+ protected MethodBodyStatement createIfElseExpression(StartElement element) {
+ Attribute testAttribute = element.getAttributeByName(new QName("test"));
+ String testExpression = compileEl(testAttribute.getValue());
+
+ return new MethodBodyStatement(MessageFormat.format("else if ({0}) '{'", testExpression), "}");
+ }
+
+ protected MethodBodyStatement createGetComponentClassMethod(String componentClassName) {
+ return new MethodBodyStatement(MessageFormat.format("return {0}.class;", componentClassName));
+ }
+
+ protected MethodBodyStatement createCallExpression(StartElement startElement) {
+ Attribute expressionAttribute = startElement.getAttributeByName(new QName("expression"));
+ String expressionValue = expressionAttribute.getValue();
+
+ return new MethodBodyStatement(expressionValue);
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/templates/ChooseTagBodyConsumer.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/templates/ChooseTagBodyConsumer.java 2009-11-01 16:01:20 UTC (rev 15788)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/templates/ChooseTagBodyConsumer.java 2009-11-01 16:17:29 UTC (rev 15789)
@@ -1,4 +1,5 @@
package org.richfaces.builder.templates;
+
import java.util.ArrayList;
import java.util.List;
@@ -31,57 +32,59 @@
/**
* @author Nick Belaevski
- *
+ *
*/
public class ChooseTagBodyConsumer extends BaseTagBodyConsumer {
+ private List<MethodBodyStatement> statements = new ArrayList<MethodBodyStatement>();
- private List<MethodBodyStatement> statements = new ArrayList<MethodBodyStatement>();
-
- public ChooseTagBodyConsumer(MethodBodyStatement methodBodyStatement) {
- super(methodBodyStatement);
- }
+ public ChooseTagBodyConsumer(MethodBodyStatement methodBodyStatement) {
+ super(methodBodyStatement);
+ }
- /* (non-Javadoc)
- * @see BaseTagBodyConsumer#consumeStartElement(javax.xml.stream.events.StartElement)
- */
- @Override
- public Consumer consumeStartElement(StartElement startElement) {
- QName name = startElement.getName();
- if (isCdkNamespace(name)) {
- MethodBodyStatement bodyStatement;
-
- if (statements.isEmpty()) {
- if ("when".equals(name.getLocalPart())) {
- bodyStatement = createIfExpression(startElement);
- } else {
- throw new IllegalArgumentException();
- }
- } else {
- if ("when".equals(name.getLocalPart())) {
- bodyStatement = createIfElseExpression(startElement);
- } else if ("otherwise".equals(name.getLocalPart())) {
- bodyStatement = new MethodBodyStatement("else {", "}");
- } else {
- throw new IllegalArgumentException();
- }
- }
-
- statement.addToBody(bodyStatement);
-
- statements.add(bodyStatement);
- return new StructuralTagBodyConsumer(bodyStatement);
- } else {
- throw new IllegalArgumentException();
- }
- }
-
- /* (non-Javadoc)
- * @see org.richfaces.builder.templates.BaseTagBodyConsumer#consumeCharacters(javax.xml.stream.events.Characters)
- */
- @Override
- public void consumeCharacters(Characters characters) {
- if (characters.getData().trim().length() != 0) {
- throw new IllegalArgumentException();
- }
- }
+ /*
+ * (non-Javadoc)
+ * @see BaseTagBodyConsumer#consumeStartElement(javax.xml.stream.events.StartElement)
+ */
+ @Override
+ public Consumer consumeStartElement(StartElement startElement) {
+ QName name = startElement.getName();
+
+ if (isCdkNamespace(name)) {
+ MethodBodyStatement bodyStatement;
+
+ if (statements.isEmpty()) {
+ if ("when".equals(name.getLocalPart())) {
+ bodyStatement = createIfExpression(startElement);
+ } else {
+ throw new IllegalArgumentException();
+ }
+ } else {
+ if ("when".equals(name.getLocalPart())) {
+ bodyStatement = createIfElseExpression(startElement);
+ } else if ("otherwise".equals(name.getLocalPart())) {
+ bodyStatement = new MethodBodyStatement("else {", "}");
+ } else {
+ throw new IllegalArgumentException();
+ }
+ }
+
+ statement.addToBody(bodyStatement);
+ statements.add(bodyStatement);
+
+ return new StructuralTagBodyConsumer(bodyStatement);
+ } else {
+ throw new IllegalArgumentException();
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.richfaces.builder.templates.BaseTagBodyConsumer#consumeCharacters(javax.xml.stream.events.Characters)
+ */
+ @Override
+ public void consumeCharacters(Characters characters) {
+ if (characters.getData().trim().length() != 0) {
+ throw new IllegalArgumentException();
+ }
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/templates/Consumer.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/templates/Consumer.java 2009-11-01 16:01:20 UTC (rev 15788)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/templates/Consumer.java 2009-11-01 16:17:29 UTC (rev 15789)
@@ -18,6 +18,9 @@
* 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.builder.templates;
import javax.xml.stream.events.Characters;
@@ -26,18 +29,16 @@
/**
* @author Nick Belaevski
- *
+ *
*/
public interface Consumer {
+ public void enter();
- public void enter();
+ public void exit();
- public void exit();
+ public Consumer consumeStartElement(StartElement startElement);
- public Consumer consumeStartElement(StartElement startElement);
+ public void consumeEndElement(EndElement endElement);
- public void consumeEndElement(EndElement endElement);
-
- public void consumeCharacters(Characters characters);
-
+ public void consumeCharacters(Characters characters);
}
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-11-01 16:01:20 UTC (rev 15788)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/templates/RendererClassGenerator.java 2009-11-01 16:17:29 UTC (rev 15789)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.builder.templates;
import java.io.File;
@@ -40,54 +42,47 @@
/**
* <p class="changed_added_4_0">
* </p>
- *
+ *
* @author asmirnov(a)exadel.com
- *
+ *
*/
public class RendererClassGenerator implements CdkWriter {
+ private CdkContext context;
- private CdkContext context;
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.richfaces.cdk.CdkWriter#init(org.richfaces.cdk.CdkContext)
+ */
+ @Override
+ public void init(CdkContext context) throws CdkException {
+ this.context = context;
+ }
- /*
- * (non-Javadoc)
- *
- * @see org.richfaces.cdk.CdkWriter#init(org.richfaces.cdk.CdkContext)
- */
- @Override
- public void init(CdkContext context) throws CdkException {
- this.context = context;
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.richfaces.cdk.CdkWriter#render(org.richfaces.cdk.model.ComponentLibrary
+ * )
+ */
+ @Override
+ public void render(ComponentLibrary library) throws CdkException {
+ for (RenderKit renderKit : library.getRenderKits()) {
+ for (Renderer renderer : renderKit.getRenderers()) {
+ JavaClass javaClass = renderer.getTemplate();
+ String fullName = javaClass.getFullName();
+ File outFile = context.createOutputFile(StandardOutputs.RENDERER_CLASSES,
+ fullName.replace('.', '/') + ".java", library.lastModified());
- /*
- * (non-Javadoc)
- *
- * @see
- * org.richfaces.cdk.CdkWriter#render(org.richfaces.cdk.model.ComponentLibrary
- * )
- */
- @Override
- public void render(ComponentLibrary library) throws CdkException {
- for (RenderKit renderKit : library.getRenderKits()) {
- for (Renderer renderer : renderKit.getRenderers()) {
- JavaClass javaClass = renderer.getTemplate();
- String fullName = javaClass.getFullName();
-
- File outFile = context.createOutputFile(
- StandardOutputs.RENDERER_CLASSES, fullName.replace('.',
- '/')
- + ".java", library.lastModified());
- if (null != outFile) {
- try {
- new JavaClassRenderer().render(javaClass,
- new PrintWriter(outFile));
- } catch (FileNotFoundException e) {
- throw new CdkException(e);
- }
-
- }
- }
- }
-
- }
-
+ if (null != outFile) {
+ try {
+ new JavaClassRenderer().render(javaClass, new PrintWriter(outFile));
+ } catch (FileNotFoundException e) {
+ throw new CdkException(e);
+ }
+ }
+ }
+ }
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/templates/RendererTemplateParser.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/templates/RendererTemplateParser.java 2009-11-01 16:01:20 UTC (rev 15788)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/templates/RendererTemplateParser.java 2009-11-01 16:17:29 UTC (rev 15789)
@@ -21,75 +21,83 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.richfaces.builder.templates;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import javax.xml.stream.XMLStreamException;
+package org.richfaces.builder.templates;
-import org.richfaces.builder.model.JavaClass;
import org.richfaces.cdk.CdkContext;
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.ModelBuilder;
import org.richfaces.cdk.StandardSources;
-import org.richfaces.cdk.model.ClassDescription;
-import org.richfaces.cdk.model.Component;
-import org.richfaces.cdk.model.ComponentLibrary;
-import org.richfaces.cdk.model.RenderKit;
-import org.richfaces.cdk.model.Renderer;
+import org.richfaces.cdk.model.*;
+import javax.xml.stream.XMLStreamException;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+
/**
* <p class="changed_added_4_0"></p>
* @author asmirnov(a)exadel.com
*
*/
public class RendererTemplateParser implements ModelBuilder {
+ private CdkContext context;
- private CdkContext context;
+ /*
+ * (non-Javadoc)
+ * @see org.richfaces.cdk.ModelBuilder#build()
+ */
+ @Override
+ public ComponentLibrary build() throws CdkException {
+ ComponentLibrary library = new ComponentLibrary();
- /* (non-Javadoc)
- * @see org.richfaces.cdk.ModelBuilder#build()
- */
- @Override
- public ComponentLibrary build() throws CdkException {
- ComponentLibrary library = new ComponentLibrary();
- for(File file : getContext().getSources(StandardSources.RENDERER_TEMPLATES)){
- try {
- RootElementConsumer template = TemplateReader.parseTemplate(new FileInputStream(file));
- RenderKit renderKit = library.findOrCreateRenderKit(template.getRenderKitId());
- Renderer renderer = renderKit.findOrCreateRenderer(template.getRendererType());
- renderer.setTemplate(template.getJavaClass());
- String componentType = template.getComponentType();
- if(null != componentType){
- Component component = library.findOrCreateComponent(componentType);
- component.getRenderers().add(renderer);
- }
- String family = template.getFamily();
- if(null != family){
- renderer.setFamily(family);
- }
- renderer.setRendererClass(new ClassDescription(template.getJavaClass().getFullName()));
- } catch (FileNotFoundException e) {
- // TODO - log errors, marks mojo failed after whole build cycle.
- throw new CdkException(e);
- } catch (XMLStreamException e) {
- throw new CdkException(e);
- }
- }
- return library;
- }
+ for (File file : getContext().getSources(StandardSources.RENDERER_TEMPLATES)) {
+ try {
+ RootElementConsumer template = TemplateReader.parseTemplate(new FileInputStream(file));
+ RenderKit renderKit = library.findOrCreateRenderKit(template.getRenderKitId());
+ Renderer renderer = renderKit.findOrCreateRenderer(template.getRendererType());
- /* (non-Javadoc)
- * @see org.richfaces.cdk.ModelBuilder#init(org.richfaces.cdk.CdkContext)
- */
- @Override
- public void init(CdkContext context) {
- this.context = context;
- }
+ renderer.setTemplate(template.getJavaClass());
- public CdkContext getContext() {
- return context;
- }
+ String componentType = template.getComponentType();
+
+ if (null != componentType) {
+ Component component = library.findOrCreateComponent(componentType);
+
+ component.getRenderers().add(renderer);
+ }
+
+ String family = template.getFamily();
+
+ if (null != family) {
+ renderer.setFamily(family);
+ }
+
+ renderer.setRendererClass(new ClassDescription(template.getJavaClass().getFullName()));
+ } catch (FileNotFoundException e) {
+
+ // TODO - log errors, marks mojo failed after whole build cycle.
+ throw new CdkException(e);
+ } catch (XMLStreamException e) {
+ throw new CdkException(e);
+ }
+ }
+
+ return library;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.richfaces.cdk.ModelBuilder#init(org.richfaces.cdk.CdkContext)
+ */
+ @Override
+ public void init(CdkContext context) {
+ this.context = context;
+ }
+
+ public CdkContext getContext() {
+ return context;
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/templates/RootElementConsumer.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/templates/RootElementConsumer.java 2009-11-01 16:01:20 UTC (rev 15788)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/templates/RootElementConsumer.java 2009-11-01 16:17:29 UTC (rev 15789)
@@ -1,18 +1,19 @@
package org.richfaces.builder.templates;
+
+import org.richfaces.builder.model.JavaClass;
+import org.richfaces.builder.model.JavaModifier;
+import org.richfaces.builder.model.JavaPackage;
+
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
-import javax.faces.render.RenderKit;
import javax.faces.render.RenderKitFactory;
import javax.faces.render.Renderer;
+
import javax.xml.namespace.QName;
import javax.xml.stream.events.Attribute;
import javax.xml.stream.events.StartElement;
-import org.richfaces.builder.model.JavaClass;
-import org.richfaces.builder.model.JavaModifier;
-import org.richfaces.builder.model.JavaPackage;
-
/**
* License Agreement.
*
@@ -36,130 +37,128 @@
/**
* @author Nick Belaevski
- *
+ *
*/
public class RootElementConsumer extends BaseTemplateConsumer {
-
- private String renderKitId = RenderKitFactory.HTML_BASIC_RENDER_KIT;
-
- private String rendererType;
-
- private String family;
-
- private String componentType;
+ private String renderKitId = RenderKitFactory.HTML_BASIC_RENDER_KIT;
+ private String componentType;
+ private String family;
+ private JavaClass javaClass;
+ private String rendererType;
- private JavaClass javaClass;
-
- public JavaClass getJavaClass() {
- return javaClass;
- }
+ public JavaClass getJavaClass() {
+ return javaClass;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the renderKitId
- */
- public String getRenderKitId() {
- return renderKitId;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the renderKitId
+ */
+ public String getRenderKitId() {
+ return renderKitId;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the rendererType
- */
- public String getRendererType() {
- return rendererType;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the rendererType
+ */
+ public String getRendererType() {
+ return rendererType;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the family
- */
- public String getFamily() {
- return family;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the family
+ */
+ public String getFamily() {
+ return family;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the componentType
- */
- public String getComponentType() {
- return componentType;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the componentType
+ */
+ public String getComponentType() {
+ return componentType;
+ }
- private String getAttributeValue(StartElement element, String attributeName) {
- Attribute attribute = element.getAttributeByName(new QName(attributeName));
- if (attribute != null) {
- String attributeValue = attribute.getValue();
- if (attributeValue != null && attributeValue.length() != 0) {
- return attributeValue;
- }
- }
-
- return null;
- }
+ private String getAttributeValue(StartElement element, String attributeName) {
+ Attribute attribute = element.getAttributeByName(new QName(attributeName));
- private String getSimpleClassName(String fullClassName) {
- int lastDotIdx = fullClassName.lastIndexOf('.');
+ if (attribute != null) {
+ String attributeValue = attribute.getValue();
- if (lastDotIdx != -1) {
- return fullClassName.substring(lastDotIdx + 1);
- } else {
- return fullClassName;
- }
- }
-
- private JavaClass createJavaClassByName(String fullName) {
- String simpleName = null;
- String packageName = "";
+ if (attributeValue != null && attributeValue.length() != 0) {
+ return attributeValue;
+ }
+ }
- int lastDotIdx = fullName.lastIndexOf('.');
+ return null;
+ }
- if (lastDotIdx != -1) {
- simpleName = fullName.substring(lastDotIdx + 1);
- packageName = fullName.substring(0, lastDotIdx);
- } else {
- simpleName = fullName;
- }
+ private String getSimpleClassName(String fullClassName) {
+ int lastDotIdx = fullClassName.lastIndexOf('.');
- return new JavaClass(simpleName, new JavaPackage(packageName));
- }
-
- @Override
- public Consumer consumeStartElement(StartElement startElement) {
- QName name = startElement.getName();
- if (isCdkNamespace(name) && "root".equals(name.getLocalPart())) {
+ if (lastDotIdx != -1) {
+ return fullClassName.substring(lastDotIdx + 1);
+ } else {
+ return fullClassName;
+ }
+ }
- String className = getAttributeValue(startElement, "class");
- if (className != null) {
- javaClass = createJavaClassByName(className);
- } else {
- javaClass = new JavaClass();
- }
-
- String superClassName = getAttributeValue(startElement, "superclass");
- if (superClassName != null) {
- javaClass.setSuperClass(createJavaClassByName(superClassName));
- } else {
- javaClass.setSuperClass(new JavaClass(Renderer.class));
- }
-
- javaClass.getModifiers().add(JavaModifier.PUBLIC);
-
- javaClass.addImport(ResponseWriter.class);
- javaClass.addImport(FacesContext.class);
- javaClass.addImport(UIComponent.class);
- javaClass.addImport(Renderer.class);
-
- String componentClassName = getAttributeValue(startElement, "componentclass");
- javaClass.addImport(componentClassName);
- renderKitId = getAttributeValue(startElement, "renderkit");
- rendererType = getAttributeValue(startElement, "renderertype");
- family = getAttributeValue(startElement, "family");
- componentType = getAttributeValue(startElement, "componenttype");
- return new TemplateBodyConsumer(javaClass, getSimpleClassName(componentClassName));
- } else {
- throw new IllegalArgumentException();
- }
- }
+ private JavaClass createJavaClassByName(String fullName) {
+ String simpleName = null;
+ String packageName = "";
+ int lastDotIdx = fullName.lastIndexOf('.');
+ if (lastDotIdx != -1) {
+ simpleName = fullName.substring(lastDotIdx + 1);
+ packageName = fullName.substring(0, lastDotIdx);
+ } else {
+ simpleName = fullName;
+ }
+
+ return new JavaClass(simpleName, new JavaPackage(packageName));
+ }
+
+ @Override
+ public Consumer consumeStartElement(StartElement startElement) {
+ QName name = startElement.getName();
+
+ if (isCdkNamespace(name) && "root".equals(name.getLocalPart())) {
+ String className = getAttributeValue(startElement, "class");
+
+ if (className != null) {
+ javaClass = createJavaClassByName(className);
+ } else {
+ javaClass = new JavaClass();
+ }
+
+ String superClassName = getAttributeValue(startElement, "superclass");
+
+ if (superClassName != null) {
+ javaClass.setSuperClass(createJavaClassByName(superClassName));
+ } else {
+ javaClass.setSuperClass(new JavaClass(Renderer.class));
+ }
+
+ javaClass.getModifiers().add(JavaModifier.PUBLIC);
+ javaClass.addImport(ResponseWriter.class);
+ javaClass.addImport(FacesContext.class);
+ javaClass.addImport(UIComponent.class);
+ javaClass.addImport(Renderer.class);
+
+ String componentClassName = getAttributeValue(startElement, "componentclass");
+
+ javaClass.addImport(componentClassName);
+ renderKitId = getAttributeValue(startElement, "renderkit");
+ rendererType = getAttributeValue(startElement, "renderertype");
+ family = getAttributeValue(startElement, "family");
+ componentType = getAttributeValue(startElement, "componenttype");
+
+ return new TemplateBodyConsumer(javaClass, getSimpleClassName(componentClassName));
+ } else {
+ throw new IllegalArgumentException();
+ }
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/templates/StructuralTagBodyConsumer.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/templates/StructuralTagBodyConsumer.java 2009-11-01 16:01:20 UTC (rev 15788)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/templates/StructuralTagBodyConsumer.java 2009-11-01 16:17:29 UTC (rev 15789)
@@ -18,7 +18,11 @@
* 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.builder.templates;
+
import javax.xml.namespace.QName;
import javax.xml.stream.events.StartElement;
@@ -26,22 +30,21 @@
/**
* @author Nick Belaevski
- *
+ *
*/
public class StructuralTagBodyConsumer extends BaseTagBodyConsumer {
+ public StructuralTagBodyConsumer(MethodBodyStatement methodBodyStatement) {
+ super(methodBodyStatement);
+ }
- public StructuralTagBodyConsumer(MethodBodyStatement methodBodyStatement) {
- super(methodBodyStatement);
- }
+ @Override
+ public Consumer consumeStartElement(StartElement startElement) {
+ QName name = startElement.getName();
- @Override
- public Consumer consumeStartElement(StartElement startElement) {
- QName name = startElement.getName();
- if (isCdkNamespace(name)&& name.getLocalPart().equals("body")) {
- throw new IllegalArgumentException();
- } else {
- return super.consumeStartElement(startElement);
- }
- }
-
+ if (isCdkNamespace(name) && name.getLocalPart().equals("body")) {
+ throw new IllegalArgumentException();
+ } else {
+ return super.consumeStartElement(startElement);
+ }
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/templates/TemplateBodyConsumer.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/templates/TemplateBodyConsumer.java 2009-11-01 16:01:20 UTC (rev 15788)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/templates/TemplateBodyConsumer.java 2009-11-01 16:17:29 UTC (rev 15789)
@@ -1,24 +1,22 @@
package org.richfaces.builder.templates;
-import java.io.IOException;
-import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.List;
+import org.richfaces.builder.model.*;
+
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
+
import javax.xml.namespace.QName;
-import javax.xml.stream.events.Attribute;
import javax.xml.stream.events.Characters;
import javax.xml.stream.events.EndElement;
import javax.xml.stream.events.StartElement;
-import org.richfaces.builder.model.Argument;
-import org.richfaces.builder.model.JavaClass;
-import org.richfaces.builder.model.JavaMethod;
-import org.richfaces.builder.model.JavaModifier;
-import org.richfaces.builder.model.MethodBody;
-import org.richfaces.builder.model.MethodBodyStatement;
+import java.io.IOException;
+import java.text.MessageFormat;
+
+import java.util.ArrayList;
+import java.util.List;
+
/**
* License Agreement.
*
@@ -42,110 +40,116 @@
/**
* @author Nick Belaevski
- *
+ *
*/
public class TemplateBodyConsumer extends BaseTemplateConsumer {
+ private List<MethodBodyStatement> statements = new ArrayList<MethodBodyStatement>();
+ private String componentClassName;
+ private JavaClass javaClass;
- private JavaClass javaClass;
-
- private List<MethodBodyStatement> statements = new ArrayList<MethodBodyStatement>();
-
- private String componentClassName;
-
- public TemplateBodyConsumer(JavaClass javaClass, String componentClassName) {
- super();
-
- this.javaClass = javaClass;
- this.componentClassName = componentClassName;
- }
+ public TemplateBodyConsumer(JavaClass javaClass, String componentClassName) {
+ super();
+ this.javaClass = javaClass;
+ this.componentClassName = componentClassName;
+ }
- @Override
- public void consumeCharacters(Characters characters) {
- String trimmedText = characters.getData().trim();
-
- if (trimmedText.length() != 0) {
- statements.add(createWriteText(characters));
- }
- }
+ @Override
+ public void consumeCharacters(Characters characters) {
+ String trimmedText = characters.getData().trim();
- @Override
- public void consumeEndElement(EndElement endElement) {
- QName name = endElement.getName();
-
- if (isCdkNamespace(name)) {
- if (name.getLocalPart().equals("body")) {
- flushStatements("encodeChildren");
- }
- } else {
- statements.add(createEndElement(endElement));
- }
- }
+ if (trimmedText.length() != 0) {
+ statements.add(createWriteText(characters));
+ }
+ }
- private void flushStatements(String methodName) {
- JavaMethod javaMethod = new JavaMethod(methodName, new Argument("context", FacesContext.class),
- new Argument("uiComponent", UIComponent.class));
-
- javaMethod.getModifiers().add(JavaModifier.PUBLIC);
- javaMethod.getExceptions().add(IOException.class);
- MethodBody methodBody = new MethodBody(javaMethod);
- javaMethod.setMethodBody(methodBody);
+ @Override
+ public void consumeEndElement(EndElement endElement) {
+ QName name = endElement.getName();
- methodBody.addToBody(
- new MethodBodyStatement(MessageFormat.format("{0} component = ({0}) uiComponent;", componentClassName)));
- methodBody.addToBody(
- new MethodBodyStatement("ResponseWriter responseWriter = context.getResponseWriter();"));
-
- for (MethodBodyStatement methodBodyStatement : statements) {
- methodBody.addToBody(methodBodyStatement);
- }
- statements.clear();
-
- javaClass.addMethod(javaMethod);
- }
+ if (isCdkNamespace(name)) {
+ if (name.getLocalPart().equals("body")) {
+ flushStatements("encodeChildren");
+ }
+ } else {
+ statements.add(createEndElement(endElement));
+ }
+ }
- @Override
- public Consumer consumeStartElement(StartElement startElement) {
- QName name = startElement.getName();
- if (isCdkNamespace(name)) {
- if ("body".equals(name.getLocalPart())) {
- flushStatements("encodeBegin");
- } else if ("if".equals(name.getLocalPart())) {
- MethodBodyStatement ifStatement = createIfExpression(startElement);
- statements.add(ifStatement);
- return new StructuralTagBodyConsumer(ifStatement);
- } else if ("choose".equals(name.getLocalPart())) {
- MethodBodyStatement chooseStatement = new MethodBodyStatement();
- statements.add(chooseStatement);
- return new ChooseTagBodyConsumer(chooseStatement);
- } else if ("call".equals(name.getLocalPart())) {
- statements.add(createCallExpression(startElement));
- }
- } else {
- statements.add(createStartElement(startElement));
- }
-
- return this;
- }
+ private void flushStatements(String methodName) {
+ JavaMethod javaMethod = new JavaMethod(methodName, new Argument("context", FacesContext.class),
+ new Argument("uiComponent", UIComponent.class));
- @Override
- public void exit() {
- super.exit();
-
- flushStatements("encodeEnd");
+ javaMethod.getModifiers().add(JavaModifier.PUBLIC);
+ javaMethod.getExceptions().add(IOException.class);
- JavaMethod getComponentClassMethod = new JavaMethod("getComponentClass", Class.class);
- getComponentClassMethod.getModifiers().add(JavaModifier.PROTECTED);
- MethodBody methodBody = new MethodBody(getComponentClassMethod);
- methodBody.addToBody(createGetComponentClassMethod(componentClassName));
- getComponentClassMethod.setMethodBody(methodBody);
- javaClass.addMethod(getComponentClassMethod);
+ MethodBody methodBody = new MethodBody(javaMethod);
- JavaMethod convertToStringMethod = new JavaMethod("convertToString", String.class, new Argument("obj", Object.class));
- convertToStringMethod.getModifiers().add(JavaModifier.PRIVATE);
- MethodBody convertToStringBody = new MethodBody(convertToStringMethod);
- convertToStringBody.addToBody(new MethodBodyStatement("return obj == null ? \"\" : obj.toString();"));
- convertToStringMethod.setMethodBody(convertToStringBody);
- javaClass.addMethod(convertToStringMethod);
- }
+ javaMethod.setMethodBody(methodBody);
+ methodBody.addToBody(new MethodBodyStatement(MessageFormat.format("{0} component = ({0}) uiComponent;",
+ componentClassName)));
+ methodBody.addToBody(new MethodBodyStatement("ResponseWriter responseWriter = context.getResponseWriter();"));
+ for (MethodBodyStatement methodBodyStatement : statements) {
+ methodBody.addToBody(methodBodyStatement);
+ }
+
+ statements.clear();
+ javaClass.addMethod(javaMethod);
+ }
+
+ @Override
+ public Consumer consumeStartElement(StartElement startElement) {
+ QName name = startElement.getName();
+
+ if (isCdkNamespace(name)) {
+ if ("body".equals(name.getLocalPart())) {
+ flushStatements("encodeBegin");
+ } else if ("if".equals(name.getLocalPart())) {
+ MethodBodyStatement ifStatement = createIfExpression(startElement);
+
+ statements.add(ifStatement);
+
+ return new StructuralTagBodyConsumer(ifStatement);
+ } else if ("choose".equals(name.getLocalPart())) {
+ MethodBodyStatement chooseStatement = new MethodBodyStatement();
+
+ statements.add(chooseStatement);
+
+ return new ChooseTagBodyConsumer(chooseStatement);
+ } else if ("call".equals(name.getLocalPart())) {
+ statements.add(createCallExpression(startElement));
+ }
+ } else {
+ statements.add(createStartElement(startElement));
+ }
+
+ return this;
+ }
+
+ @Override
+ public void exit() {
+ super.exit();
+ flushStatements("encodeEnd");
+
+ JavaMethod getComponentClassMethod = new JavaMethod("getComponentClass", Class.class);
+
+ getComponentClassMethod.getModifiers().add(JavaModifier.PROTECTED);
+
+ MethodBody methodBody = new MethodBody(getComponentClassMethod);
+
+ methodBody.addToBody(createGetComponentClassMethod(componentClassName));
+ getComponentClassMethod.setMethodBody(methodBody);
+ javaClass.addMethod(getComponentClassMethod);
+
+ JavaMethod convertToStringMethod = new JavaMethod("convertToString", String.class,
+ new Argument("obj", Object.class));
+
+ convertToStringMethod.getModifiers().add(JavaModifier.PRIVATE);
+
+ MethodBody convertToStringBody = new MethodBody(convertToStringMethod);
+
+ convertToStringBody.addToBody(new MethodBodyStatement("return obj == null ? \"\" : obj.toString();"));
+ convertToStringMethod.setMethodBody(convertToStringBody);
+ javaClass.addMethod(convertToStringMethod);
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/templates/TemplateReader.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/templates/TemplateReader.java 2009-11-01 16:01:20 UTC (rev 15788)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/templates/TemplateReader.java 2009-11-01 16:17:29 UTC (rev 15789)
@@ -19,9 +19,13 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.builder.templates;
+
import java.io.IOException;
import java.io.InputStream;
+
import java.util.ArrayDeque;
import java.util.Deque;
@@ -39,133 +43,137 @@
/**
* @author Nick Belaevski
- *
+ *
*/
-public class TemplateReader {
+public final class TemplateReader {
+ private static final Logger LOG = LoggerFactory.getLogger();
- private static final Logger log = LoggerFactory.getLogger();
+ private TemplateReader() {}
- private static final class ConsumersTracker {
-
- private final class ConsumerEntry {
+ public static RootElementConsumer parseTemplate(InputStream stream) throws XMLStreamException {
+ XMLEventReader xmlEventReader = XMLInputFactoryHolder.FACTORY.createXMLEventReader(stream);
- public ConsumerEntry(Consumer consumer) {
- this.consumer = consumer;
- }
+ try {
+ ConsumersTracker tracker = new ConsumersTracker();
+ RootElementConsumer consumer = new RootElementConsumer();
- private Consumer consumer;
-
- private int depth = 0;
+ tracker.pushConsumer(consumer);
- public void increaseDepth() {
- depth++;
- }
-
- public void decreaseDepth() {
- depth--;
- }
-
- public boolean isZeroDepth() {
- return depth == 0;
- }
- }
-
- private Deque<ConsumerEntry> consumerEntries = new ArrayDeque<ConsumerEntry>();
-
- private ConsumerEntry consumerEntry = null;
-
- public void pushConsumer(Consumer consumer) {
- if (consumerEntry != null && consumer == consumerEntry.consumer) {
- consumerEntry.increaseDepth();
- } else {
- if (consumerEntry != null) {
- consumerEntries.push(consumerEntry);
- }
-
- consumerEntry = new ConsumerEntry(consumer);
- consumer.enter();
- }
- }
-
- public Consumer peekConsumer() {
- return consumerEntry.consumer;
- }
-
- public Consumer popConsumer() {
- if (consumerEntry.isZeroDepth()) {
- consumerEntry.consumer.exit();
- if (!consumerEntries.isEmpty()) {
- consumerEntry = consumerEntries.pop();
- } else {
- consumerEntry = null;
- }
- } else {
- consumerEntry.decreaseDepth();
- }
-
- if (consumerEntry != null) {
- return consumerEntry.consumer;
- } else {
- return null;
- }
- }
- }
-
- private static class XMLInputFactoryHolder {
- static final XMLInputFactory factory = XMLInputFactory.newInstance();
-
- static {
- factory.setProperty("javax.xml.stream.isNamespaceAware", Boolean.TRUE);
- factory.setProperty("javax.xml.stream.isCoalescing", Boolean.TRUE);
- }
- }
-
- public static RootElementConsumer parseTemplate(InputStream stream) throws XMLStreamException {
- XMLEventReader xmlEventReader = XMLInputFactoryHolder.factory.createXMLEventReader(stream);
-
- try {
- ConsumersTracker tracker = new ConsumersTracker();
- RootElementConsumer consumer = new RootElementConsumer();
- tracker.pushConsumer(consumer);
-
- while (xmlEventReader.hasNext()) {
- XMLEvent event = xmlEventReader.nextEvent();
-
- if (event.isStartElement()) {
- StartElement startElement = event.asStartElement();
- Consumer currentConsumer = tracker.peekConsumer();
- Consumer nextConsumer = currentConsumer.consumeStartElement(startElement);
-
- tracker.pushConsumer(nextConsumer);
- } else if (event.isEndElement()) {
- EndElement endElement = event.asEndElement();
- Consumer currentConsumer = tracker.popConsumer();
- currentConsumer.consumeEndElement(endElement);
- } else if (event.isCharacters()) {
- Characters characters = event.asCharacters();
- tracker.peekConsumer().consumeCharacters(characters);
- }
- }
-
- tracker.popConsumer();
-
- return consumer;
- } finally {
- try {
- stream.close();
- } catch (IOException e) {
- log.warn("Error to close XML template stream", e);
- }
- try {
- xmlEventReader.close();
- } catch (XMLStreamException e) {
- log.warn("Error to close XMLEventReader for renderer template parser", e);
- }
- }
-
- }
-
- public static JavaClass parse(InputStream input) throws XMLStreamException{
- return parseTemplate(input).getJavaClass();
- }
+ while (xmlEventReader.hasNext()) {
+ XMLEvent event = xmlEventReader.nextEvent();
+
+ if (event.isStartElement()) {
+ StartElement startElement = event.asStartElement();
+ Consumer currentConsumer = tracker.peekConsumer();
+ Consumer nextConsumer = currentConsumer.consumeStartElement(startElement);
+
+ tracker.pushConsumer(nextConsumer);
+ } else if (event.isEndElement()) {
+ EndElement endElement = event.asEndElement();
+ Consumer currentConsumer = tracker.popConsumer();
+
+ currentConsumer.consumeEndElement(endElement);
+ } else if (event.isCharacters()) {
+ Characters characters = event.asCharacters();
+
+ tracker.peekConsumer().consumeCharacters(characters);
+ }
+ }
+
+ tracker.popConsumer();
+
+ return consumer;
+ } finally {
+ try {
+ stream.close();
+ } catch (IOException e) {
+ LOG.warn("Error to close XML template stream", e);
+ }
+
+ try {
+ xmlEventReader.close();
+ } catch (XMLStreamException e) {
+ LOG.warn("Error to close XMLEventReader for renderer template parser", e);
+ }
+ }
+ }
+
+ public static JavaClass parse(InputStream input) throws XMLStreamException {
+ return parseTemplate(input).getJavaClass();
+ }
+
+ private static final class ConsumersTracker {
+ private Deque<ConsumerEntry> consumerEntries = new ArrayDeque<ConsumerEntry>();
+ private ConsumerEntry consumerEntry = null;
+
+ public void pushConsumer(Consumer consumer) {
+ if (consumerEntry != null && consumer == consumerEntry.consumer) {
+ consumerEntry.increaseDepth();
+ } else {
+ if (consumerEntry != null) {
+ consumerEntries.push(consumerEntry);
+ }
+
+ consumerEntry = new ConsumerEntry(consumer);
+ consumer.enter();
+ }
+ }
+
+ public Consumer peekConsumer() {
+ return consumerEntry.consumer;
+ }
+
+ public Consumer popConsumer() {
+ if (consumerEntry.isZeroDepth()) {
+ consumerEntry.consumer.exit();
+
+ if (!consumerEntries.isEmpty()) {
+ consumerEntry = consumerEntries.pop();
+ } else {
+ consumerEntry = null;
+ }
+ } else {
+ consumerEntry.decreaseDepth();
+ }
+
+ if (consumerEntry != null) {
+ return consumerEntry.consumer;
+ } else {
+ return null;
+ }
+ }
+
+ private final class ConsumerEntry {
+ private int depth = 0;
+ private Consumer consumer;
+
+ public ConsumerEntry(Consumer consumer) {
+ this.consumer = consumer;
+ }
+
+ public void increaseDepth() {
+ depth++;
+ }
+
+ public void decreaseDepth() {
+ depth--;
+ }
+
+ public boolean isZeroDepth() {
+ return depth == 0;
+ }
+ }
+ }
+
+
+ private static final class XMLInputFactoryHolder {
+ static final XMLInputFactory FACTORY = XMLInputFactory.newInstance();
+
+ static {
+ FACTORY.setProperty("javax.xml.stream.isNamespaceAware", Boolean.TRUE);
+ FACTORY.setProperty("javax.xml.stream.isCoalescing", Boolean.TRUE);
+ }
+
+ private XMLInputFactoryHolder() {}
+ }
}
15 years, 1 month
JBoss Rich Faces SVN: r15788 - root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations.
by richfaces-svn-commits@lists.jboss.org
Author: Alex.Kolonitsky
Date: 2009-11-01 11:01:20 -0500 (Sun, 01 Nov 2009)
New Revision: 15788
Modified:
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Alias.java
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Attribute.java
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Attributes.java
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Behavior.java
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Component.java
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Converter.java
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/DefaultValue.java
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/DisplayName.java
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Event.java
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/EventName.java
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/EventNames.java
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Facet.java
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Facets.java
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Family.java
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Fires.java
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Generate.java
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Icon.java
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Renderer.java
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/RendererTemplate.java
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/RendererTemplates.java
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Signature.java
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/SuggestedValue.java
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Tag.java
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Test.java
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/TestType.java
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/package-info.java
Log:
Code style policy
https://jira.jboss.org/jira/browse/RFPL-195
Modified: root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Alias.java
===================================================================
--- root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Alias.java 2009-10-30 23:28:08 UTC (rev 15787)
+++ root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Alias.java 2009-11-01 16:01:20 UTC (rev 15788)
@@ -30,27 +30,24 @@
import java.lang.annotation.Target;
/**
- * <p class="changed_added_4_0">Attribute aliases. CDK will generate getters/setters for these aliases which delegate calls to the original attribute methods.
- * </p>
- *
+ * <p class="changed_added_4_0">Attribute aliases. CDK will generate getters/setters for these aliases which
+ * delegate calls to the original attribute methods. </p>
+ *
* @author asmirnov(a)exadel.com
- *
*/
@Retention(RetentionPolicy.CLASS)
-(a)Target({ElementType.METHOD,ElementType.FIELD})
+(a)Target({ElementType.METHOD, ElementType.FIELD})
@Inherited
public @interface Alias {
- public static final String NAME = "org.richfaces.cdk.annotations.Alias";
+ public static final String NAME = "org.richfaces.cdk.annotations.Alias";
- /**
- * <p class="changed_added_4_0">
- * Attribute aliases. This is mandatory parameter</p>
- *
- * @return attribute aliases.
- */
- public String[] value();
+ /**
+ * <p class="changed_added_4_0">
+ * Attribute aliases. This is mandatory parameter</p>
+ *
+ * @return attribute aliases.
+ */
+ public String[] value();
-
-
}
Modified: root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Attribute.java
===================================================================
--- root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Attribute.java 2009-10-30 23:28:08 UTC (rev 15787)
+++ root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Attribute.java 2009-11-01 16:01:20 UTC (rev 15788)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.annotations;
import java.lang.annotation.ElementType;
@@ -35,7 +37,7 @@
*
*/
@Retention(RetentionPolicy.CLASS)
-(a)Target({ElementType.FIELD,ElementType.METHOD})
+(a)Target({ElementType.FIELD, ElementType.METHOD})
@Inherited
public @interface Attribute {
@@ -56,16 +58,13 @@
* @return
*/
boolean readOnly() default false;
-
-// boolean transient() default false;
+// boolean transient() default false;
+
/**
* <p class="changed_added_4_0"></p>
* @return
*/
boolean passThough() default false;
-
- boolean required() default false;
-
-
+ boolean required() default false;
}
Modified: root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Attributes.java
===================================================================
--- root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Attributes.java 2009-10-30 23:28:08 UTC (rev 15787)
+++ root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Attributes.java 2009-11-01 16:01:20 UTC (rev 15788)
@@ -32,26 +32,25 @@
/**
* <p class="changed_added_4_0">
* </p>
- *
+ *
* @author asmirnov(a)exadel.com
- *
*/
@Retention(RetentionPolicy.CLASS)
@Target(ElementType.TYPE)
@Inherited
public @interface Attributes {
- public static final String NAME = "org.richfaces.cdk.annotations.Attributes";
+ public static final String NAME = "org.richfaces.cdk.annotations.Attributes";
- /**
- * <p class="changed_added_4_0">
- * To avoid copy/paste routine for standard or other useful attributes, their definitions could be
- * stored in faces-config.xml extensions and reused from different
- * components.
- * </p>
- *
- * @return URL's of the XML files that contain attribute definitions.
- */
- public String[] value();
+ /**
+ * <p class="changed_added_4_0">
+ * To avoid copy/paste routine for standard or other useful attributes, their definitions could be
+ * stored in faces-config.xml extensions and reused from different
+ * components.
+ * </p>
+ *
+ * @return URL's of the XML files that contain attribute definitions.
+ */
+ public String[] value();
}
Modified: root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Behavior.java
===================================================================
--- root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Behavior.java 2009-10-30 23:28:08 UTC (rev 15787)
+++ root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Behavior.java 2009-11-01 16:01:20 UTC (rev 15788)
@@ -32,25 +32,24 @@
/**
* <p class="changed_added_4_0">
* </p>
- *
+ *
* @author asmirnov(a)exadel.com
- *
*/
@Retention(RetentionPolicy.CLASS)
@Target(ElementType.TYPE)
@Inherited
public @interface Behavior {
- public static final String NAME = "org.richfaces.cdk.annotations.Behavior";
+ public static final String NAME = "org.richfaces.cdk.annotations.Behavior";
- /**
- * <p class="changed_added_4_0">
- * behavior-id with which instances of implementation class can be created b JSF Application implementation. If this value an empty, behavior-id will be inferred from class name.
- * </p>
- *
- * @return converter type.
- */
- public String value() ;
+ /**
+ * <p class="changed_added_4_0">
+ * behavior-id with which instances of implementation class can be created b JSF Application implementation.
+ * If this value an empty, behavior-id will be inferred from class name. </p>
+ *
+ * @return converter type.
+ */
+ public String value();
}
Modified: root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Component.java
===================================================================
--- root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Component.java 2009-10-30 23:28:08 UTC (rev 15787)
+++ root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Component.java 2009-11-01 16:01:20 UTC (rev 15788)
@@ -29,44 +29,41 @@
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
-import javax.faces.component.FacesComponent;
-
/**
* <p class="changed_added_4_0">
* That annotation marks class as JSF component. The difference with JSF 2.0
- * @{@link FacesComponent} annotation is what this one could marks abstaract
+ * @{@link javax.faces.component.FacesComponent} annotation is what this one could marks abstaract
* class from which a real UI-component implementation will be generated. The
* value of default {@link #value()} attribute is taken to be
* <em>component type</em>. The fully qualified class name becomes a component
* class unless that class is abstract or final component class is defined by
* the {@link Generate} annotation value.
* </p>
- *
+ *
* @author asmirnov(a)exadel.com
- *
*/
@Retention(RetentionPolicy.CLASS)
@Target(ElementType.TYPE)
@Inherited
public @interface Component {
- /**
- * <p class="changed_added_4_0">Annotation class name to use as key for annotation processor class.</p>
- */
- public static final String NAME = "org.richfaces.cdk.annotations.Component";
+ /**
+ * <p class="changed_added_4_0">Annotation class name to use as key for annotation processor class.</p>
+ */
+ public static final String NAME = "org.richfaces.cdk.annotations.Component";
- /**
- * <p class="changed_added_4_0">
- * Type of the component. Currently this is mandatory parameter because CDK
- * uses <em>component-type</em> as primary key for components library model.
- * </p>
- * <p class="todo">
- * TODO if this value is an empty, component type will be inferred from
- * class name.
- * </p>
- *
- * @return component type.
- */
- public String value() default "";
+ /**
+ * <p class="changed_added_4_0">
+ * Type of the component. Currently this is mandatory parameter because CDK
+ * uses <em>component-type</em> as primary key for components library model.
+ * </p>
+ * <p class="todo">
+ * TODO if this value is an empty, component type will be inferred from
+ * class name.
+ * </p>
+ *
+ * @return component type.
+ */
+ public String value() default "";
}
Modified: root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Converter.java
===================================================================
--- root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Converter.java 2009-10-30 23:28:08 UTC (rev 15787)
+++ root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Converter.java 2009-11-01 16:01:20 UTC (rev 15788)
@@ -32,25 +32,24 @@
/**
* <p class="changed_added_4_0">
* </p>
- *
+ *
* @author asmirnov(a)exadel.com
- *
*/
@Retention(RetentionPolicy.CLASS)
@Target(ElementType.TYPE)
@Inherited
public @interface Converter {
- public static final String NAME = "org.richfaces.cdk.annotations.Converter";
+ public static final String NAME = "org.richfaces.cdk.annotations.Converter";
- /**
- * <p class="changed_added_4_0">
- * Type of the renderer. If this value an empty, component type will be inferred from class name.
- * </p>
- *
- * @return converter type.
- */
- public String id() default "";
+ /**
+ * <p class="changed_added_4_0">
+ * Type of the renderer. If this value an empty, component type will be inferred from class name.
+ * </p>
+ *
+ * @return converter type.
+ */
+ public String id() default "";
public Class<?> forClass() default Object.class;
Modified: root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/DefaultValue.java
===================================================================
--- root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/DefaultValue.java 2009-10-30 23:28:08 UTC (rev 15787)
+++ root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/DefaultValue.java 2009-11-01 16:01:20 UTC (rev 15788)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.annotations;
import java.lang.annotation.ElementType;
@@ -35,10 +37,8 @@
*
*/
@Retention(RetentionPolicy.CLASS)
-(a)Target({ElementType.METHOD,ElementType.FIELD})
+(a)Target({ElementType.METHOD, ElementType.FIELD})
@Inherited
public @interface DefaultValue {
-
- String value();
-
+ String value();
}
Modified: root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/DisplayName.java
===================================================================
--- root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/DisplayName.java 2009-10-30 23:28:08 UTC (rev 15787)
+++ root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/DisplayName.java 2009-11-01 16:01:20 UTC (rev 15788)
@@ -32,25 +32,24 @@
/**
* <p class="changed_added_4_0">Defines name that would be used in IDE to display.
* </p>
- *
+ *
* @author asmirnov(a)exadel.com
- *
*/
@Retention(RetentionPolicy.CLASS)
-(a)Target({ElementType.TYPE,ElementType.METHOD})
+(a)Target({ElementType.TYPE, ElementType.METHOD})
@Inherited
public @interface DisplayName {
- public static final String NAME = "org.richfaces.cdk.annotations.DisplayName";
+ public static final String NAME = "org.richfaces.cdk.annotations.DisplayName";
- /**
- * <p class="changed_added_4_0">
- * IDE display name.
- * </p>
- *
- * @return Icon url.
- */
- public String value();
+ /**
+ * <p class="changed_added_4_0">
+ * IDE display name.
+ * </p>
+ *
+ * @return Icon url.
+ */
+ public String value();
Modified: root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Event.java
===================================================================
--- root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Event.java 2009-10-30 23:28:08 UTC (rev 15787)
+++ root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Event.java 2009-11-01 16:01:20 UTC (rev 15788)
@@ -37,33 +37,32 @@
* <li>Event tag handler and binding wrapper.</li>
* </ul>
* </p>
- *
+ *
* @author asmirnov(a)exadel.com
- *
*/
@Retention(RetentionPolicy.CLASS)
@Target(ElementType.TYPE)
@Inherited
public @interface Event {
- public static final String NAME = "org.richfaces.cdk.annotations.Event";
+ public static final String NAME = "org.richfaces.cdk.annotations.Event";
- /**
- * <p class="changed_added_4_0">
- * Name of the listener interface class.
- * </p>
- *
- * @return name of generated listener interface..
- */
- public String listener() default "";
+ /**
+ * <p class="changed_added_4_0">
+ * Name of the listener interface class.
+ * </p>
+ *
+ * @return name of generated listener interface..
+ */
+ public String listener() default "";
- /**
- * <p class="changed_added_4_0">
- * Name of the listener interface class.
- * </p>
- *
- * @return name of generated source interface..
- */
- public String source() default "";
+ /**
+ * <p class="changed_added_4_0">
+ * Name of the listener interface class.
+ * </p>
+ *
+ * @return name of generated source interface..
+ */
+ public String source() default "";
}
Modified: root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/EventName.java
===================================================================
--- root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/EventName.java 2009-10-30 23:28:08 UTC (rev 15787)
+++ root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/EventName.java 2009-11-01 16:01:20 UTC (rev 15788)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.annotations;
import java.lang.annotation.ElementType;
@@ -35,19 +37,19 @@
*
*/
@Retention(RetentionPolicy.CLASS)
-(a)Target({ElementType.METHOD,ElementType.FIELD})
+(a)Target({ElementType.METHOD, ElementType.FIELD})
@Inherited
public @interface EventName {
-
- /**
- * <p class="changed_added_4_0"></p>
- * @return
- */
- public String value() default "";
- /**
- * <p class="changed_added_4_0"></p>
- * @return
- */
- public boolean defaultEvent() default false;
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return
+ */
+ public String value() default "";
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return
+ */
+ public boolean defaultEvent() default false;
}
Modified: root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/EventNames.java
===================================================================
--- root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/EventNames.java 2009-10-30 23:28:08 UTC (rev 15787)
+++ root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/EventNames.java 2009-11-01 16:01:20 UTC (rev 15788)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.annotations;
import java.lang.annotation.ElementType;
@@ -35,14 +37,13 @@
*
*/
@Retention(RetentionPolicy.CLASS)
-(a)Target({ElementType.METHOD,ElementType.FIELD})
+(a)Target({ElementType.METHOD, ElementType.FIELD})
@Inherited
public @interface EventNames {
-
- /**
- * <p class="changed_added_4_0"></p>
- * @return
- */
- public EventName[] value();
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return
+ */
+ public EventName[] value();
}
Modified: root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Facet.java
===================================================================
--- root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Facet.java 2009-10-30 23:28:08 UTC (rev 15787)
+++ root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Facet.java 2009-11-01 16:01:20 UTC (rev 15788)
@@ -31,20 +31,21 @@
/**
* <p class="changed_added_4_0"></p>
+ *
* @author asmirnov(a)exadel.com
- *
*/
@Retention(RetentionPolicy.CLASS)
@Target(ElementType.METHOD)
@Inherited
public @interface Facet {
- public static final String NAME = "org.richfaces.cdk.annotations.Facet";
+ public static final String NAME = "org.richfaces.cdk.annotations.Facet";
/**
* <p class="changed_added_4_0">The name of that facet.</p>
+ *
* @return
*/
String value() default "";
-
+
}
Modified: root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Facets.java
===================================================================
--- root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Facets.java 2009-10-30 23:28:08 UTC (rev 15787)
+++ root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Facets.java 2009-11-01 16:01:20 UTC (rev 15788)
@@ -32,26 +32,25 @@
/**
* <p class="changed_added_4_0">
* </p>
- *
+ *
* @author asmirnov(a)exadel.com
- *
*/
@Retention(RetentionPolicy.CLASS)
@Target(ElementType.TYPE)
@Inherited
public @interface Facets {
- public static final String NAME = "org.richfaces.cdk.annotations.Facets";
+ public static final String NAME = "org.richfaces.cdk.annotations.Facets";
- /**
- * <p class="changed_added_4_0">
- * To avoid copy/paste routine for standard or other useful attributes, their definitions could be
- * stored in faces-config.xml extensions and reused from different
- * components.
- * </p>
- *
- * @return references to XML files that contain attributes definitions.
- */
- public Facet[] value();
+ /**
+ * <p class="changed_added_4_0">
+ * To avoid copy/paste routine for standard or other useful attributes, their definitions could be
+ * stored in faces-config.xml extensions and reused from different
+ * components.
+ * </p>
+ *
+ * @return references to XML files that contain attributes definitions.
+ */
+ public Facet[] value();
}
Modified: root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Family.java
===================================================================
--- root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Family.java 2009-10-30 23:28:08 UTC (rev 15787)
+++ root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Family.java 2009-11-01 16:01:20 UTC (rev 15788)
@@ -31,26 +31,26 @@
/**
* <p class="changed_added_4_0">Defines family of the JSF component or renderer.</p>
+ *
* @author asmirnov(a)exadel.com
- *
*/
@Retention(RetentionPolicy.CLASS)
@Target(ElementType.TYPE)
@Inherited
public @interface Family {
- /**
- * <p class="changed_added_4_0">Annotation class name to use as key for annotation processor class.</p>
- */
- public static final String NAME = "org.richfaces.cdk.annotations.Family";
+ /**
+ * <p class="changed_added_4_0">Annotation class name to use as key for annotation processor class.</p>
+ */
+ public static final String NAME = "org.richfaces.cdk.annotations.Family";
- /**
- * <p class="changed_added_4_0">
- * The value of this annotation attribute is taken to be <em>component-family</em> for annotated JSF component or renderer class. If this value an empty, it will be inferred from component type or <code>COMPONENT_FAMILY</code> constant.
- * </p>
- *
- * @return component family.
- */
- public String value() default "";
+ /**
+ * <p class="changed_added_4_0">
+ * The value of this annotation attribute is taken to be <em>component-family</em> for annotated JSF component or renderer class. If this value an empty, it will be inferred from component type or <code>COMPONENT_FAMILY</code> constant.
+ * </p>
+ *
+ * @return component family.
+ */
+ public String value() default "";
}
Modified: root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Fires.java
===================================================================
--- root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Fires.java 2009-10-30 23:28:08 UTC (rev 15787)
+++ root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Fires.java 2009-11-01 16:01:20 UTC (rev 15788)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.annotations;
import java.lang.annotation.ElementType;
@@ -33,18 +35,19 @@
/**
* <p class="changed_added_4_0">This annotation defines events that are fired by component.</p>
+ *
* @author asmirnov(a)exadel.com
- *
*/
@Retention(RetentionPolicy.CLASS)
@Target(ElementType.TYPE)
@Inherited
public @interface Fires {
- /**
- * <p class="changed_added_4_0">Array of all {@link FacesEvent} inherited classes that could be fired by component.</p>
- * @return
- */
- public Class<? extends FacesEvent>[] value();
-
+ /**
+ * <p class="changed_added_4_0">Array of all {@link FacesEvent} inherited classes that could be fired
+ * by component.</p>
+ *
+ * @return
+ */
+ public Class<? extends FacesEvent>[] value();
}
Modified: root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Generate.java
===================================================================
--- root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Generate.java 2009-10-30 23:28:08 UTC (rev 15787)
+++ root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Generate.java 2009-11-01 16:01:20 UTC (rev 15788)
@@ -34,26 +34,25 @@
* The presence of this annotation tells CDK to generate class or method
* implementation even though target does not have the {@code abstract} modifier.
* </p>
- *
+ *
* @author asmirnov(a)exadel.com
- *
*/
@Retention(RetentionPolicy.CLASS)
-@Target( { ElementType.TYPE, ElementType.METHOD })
+(a)Target({ElementType.TYPE, ElementType.METHOD})
@Inherited
public @interface Generate {
- public static final String NAME = "org.richfaces.cdk.annotations.Generate";
+ public static final String NAME = "org.richfaces.cdk.annotations.Generate";
- public static final String DEFAULT = NAME + ".DEFAULT";
+ public static final String DEFAULT = NAME + ".DEFAULT";
- /**
- * <p class="changed_added_4_0">
- * Name of the generated class. If this value was an empty, name will be inferred by CDK.
- * </p>
- *
- * @return generated object type.
- */
- public String value() default "";
+ /**
+ * <p class="changed_added_4_0">
+ * Name of the generated class. If this value was an empty, name will be inferred by CDK.
+ * </p>
+ *
+ * @return generated object type.
+ */
+ public String value() default "";
}
Modified: root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Icon.java
===================================================================
--- root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Icon.java 2009-10-30 23:28:08 UTC (rev 15787)
+++ root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Icon.java 2009-11-01 16:01:20 UTC (rev 15788)
@@ -32,27 +32,26 @@
/**
* <p class="changed_added_4_0">Icon used that would be used in IDE to display.
* </p>
- *
+ *
* @author asmirnov(a)exadel.com
- *
*/
@Retention(RetentionPolicy.CLASS)
-(a)Target({ElementType.TYPE,ElementType.METHOD,ElementType.FIELD})
+(a)Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD})
@Inherited
public @interface Icon {
- public static final String NAME = "org.richfaces.cdk.annotations.Icon";
+ public static final String NAME = "org.richfaces.cdk.annotations.Icon";
- /**
- * <p class="changed_added_4_0">
- * URL that defines IDE icon.
- * </p>
- *
- * @return Icon url.
- */
- public String small() default "";
+ /**
+ * <p class="changed_added_4_0">
+ * URL that defines IDE icon.
+ * </p>
+ *
+ * @return Icon url.
+ */
+ public String small() default "";
- public String large() default "";
+ public String large() default "";
}
Modified: root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Renderer.java
===================================================================
--- root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Renderer.java 2009-10-30 23:28:08 UTC (rev 15787)
+++ root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Renderer.java 2009-11-01 16:01:20 UTC (rev 15788)
@@ -30,27 +30,27 @@
import java.lang.annotation.Target;
/**
- * <p class="changed_added_4_0">The presence of this annotation in the JSF component class associated particular renderer with component.
- * </p>
- *
+ * <p class="changed_added_4_0">The presence of this annotation in the JSF component class associated particular
+ * renderer with component. </p>
+ *
* @author asmirnov(a)exadel.com
- *
*/
@Retention(RetentionPolicy.CLASS)
@Target(ElementType.TYPE)
@Inherited
public @interface Renderer {
- public static final String NAME = "org.richfaces.cdk.annotations.Renderer";
+ public static final String NAME = "org.richfaces.cdk.annotations.Renderer";
- /**
- * <p class="changed_added_4_0">
- * The value of this annotation attribute is taken to be JSF <em>renderer-type</em>. If this value was empty, component type will be inferred from by the CDK.
- * </p>
- *
- * @return JSF <em>renderer-type</em>.
- */
- public String type() default "";
+ /**
+ * <p class="changed_added_4_0">
+ * The value of this annotation attribute is taken to be JSF <em>renderer-type</em>. If this value was empty,
+ * component type will be inferred from by the CDK.
+ * </p>
+ *
+ * @return JSF <em>renderer-type</em>.
+ */
+ public String type() default "";
}
Modified: root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/RendererTemplate.java
===================================================================
--- root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/RendererTemplate.java 2009-10-30 23:28:08 UTC (rev 15787)
+++ root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/RendererTemplate.java 2009-11-01 16:01:20 UTC (rev 15788)
@@ -32,25 +32,24 @@
/**
* <p class="changed_added_4_0">
* </p>
- *
+ *
* @author asmirnov(a)exadel.com
- *
*/
@Retention(RetentionPolicy.CLASS)
@Target(ElementType.TYPE)
@Inherited
public @interface RendererTemplate {
- public static final String NAME = "org.richfaces.cdk.annotations.RendererTemplate";
+ public static final String NAME = "org.richfaces.cdk.annotations.RendererTemplate";
- /**
- * <p class="changed_added_4_0">
- * Reference to renderer template used with that component.
- * </p>
- *
- * @return template url.
- */
- public String value();
+ /**
+ * <p class="changed_added_4_0">
+ * Reference to renderer template used with that component.
+ * </p>
+ *
+ * @return template url.
+ */
+ public String value();
}
Modified: root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/RendererTemplates.java
===================================================================
--- root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/RendererTemplates.java 2009-10-30 23:28:08 UTC (rev 15787)
+++ root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/RendererTemplates.java 2009-11-01 16:01:20 UTC (rev 15788)
@@ -32,26 +32,25 @@
/**
* <p class="changed_added_4_0">
* </p>
- *
+ *
* @author asmirnov(a)exadel.com
- *
*/
@Retention(RetentionPolicy.CLASS)
@Target(ElementType.TYPE)
@Inherited
public @interface RendererTemplates {
- public static final String NAME = "org.richfaces.cdk.annotations.RendererTemplates";
+ public static final String NAME = "org.richfaces.cdk.annotations.RendererTemplates";
- /**
- * <p class="changed_added_4_0">
- * To avoid copy/paste routine for standard or other useful attributes, their definitions could be
- * stored in faces-config.xml extensions and reused from different
- * components.
- * </p>
- *
- * @return references to XML files that contain attributes definitions.
- */
- public RendererTemplate[] value();
+ /**
+ * <p class="changed_added_4_0">
+ * To avoid copy/paste routine for standard or other useful attributes, their definitions could be
+ * stored in faces-config.xml extensions and reused from different
+ * components.
+ * </p>
+ *
+ * @return references to XML files that contain attributes definitions.
+ */
+ public RendererTemplate[] value();
}
Modified: root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Signature.java
===================================================================
--- root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Signature.java 2009-10-30 23:28:08 UTC (rev 15787)
+++ root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Signature.java 2009-11-01 16:01:20 UTC (rev 15788)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.annotations;
import java.lang.annotation.ElementType;
@@ -35,20 +37,19 @@
*
*/
@Retention(RetentionPolicy.CLASS)
-(a)Target({ElementType.METHOD,ElementType.FIELD})
+(a)Target({ElementType.METHOD, ElementType.FIELD})
@Inherited
public @interface Signature {
- /**
- * <p class="changed_added_4_0">Method return type. Default is {@code Object}</p>
- * @return
- */
- public Class<?> returnType() default Object.class;
-
- /**
- * <p class="changed_added_4_0">Method parameters. Default is no-argument method.</p>
- * @return
- */
- public Class<?>[] parameters() default {};
-
+ /**
+ * <p class="changed_added_4_0">Method return type. Default is {@code Object}</p>
+ * @return
+ */
+ public Class<?> returnType() default Object.class;
+
+ /**
+ * <p class="changed_added_4_0">Method parameters. Default is no-argument method.</p>
+ * @return
+ */
+ public Class<?>[] parameters() default {};
}
Modified: root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/SuggestedValue.java
===================================================================
--- root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/SuggestedValue.java 2009-10-30 23:28:08 UTC (rev 15787)
+++ root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/SuggestedValue.java 2009-11-01 16:01:20 UTC (rev 15788)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.annotations;
import java.lang.annotation.ElementType;
@@ -35,10 +37,8 @@
*
*/
@Retention(RetentionPolicy.CLASS)
-(a)Target({ElementType.METHOD,ElementType.FIELD})
+(a)Target({ElementType.METHOD, ElementType.FIELD})
@Inherited
public @interface SuggestedValue {
-
- String value();
-
+ String value();
}
Modified: root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Tag.java
===================================================================
--- root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Tag.java 2009-10-30 23:28:08 UTC (rev 15787)
+++ root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Tag.java 2009-11-01 16:01:20 UTC (rev 15788)
@@ -32,34 +32,37 @@
/**
* <p class="changed_added_4_0">
* </p>
- *
+ *
* @author asmirnov(a)exadel.com
- *
*/
@Retention(RetentionPolicy.CLASS)
@Target(ElementType.TYPE)
@Inherited
public @interface Tag {
- public static final String NAME = "org.richfaces.cdk.annotations.Tag";
+ public static final String NAME = "org.richfaces.cdk.annotations.Tag";
- /**
- * <p class="changed_added_4_0">
- * Name of the JSF tag that creates target component.
- * </p>
- *
- * @return tag name.
- */
- public String name();
+ /**
+ * <p class="changed_added_4_0">
+ * Name of the JSF tag that creates target component.
+ * </p>
+ *
+ * @return tag name.
+ */
+ public String name();
/**
- * <p class="changed_added_4_0">The value of this annotation attribute defines JSF renderer that will be associated with component.</p>
+ * <p class="changed_added_4_0">The value of this annotation attribute defines JSF renderer that will be
+ * associated with component.</p>
+ *
* @return
*/
public Renderer renderer();
-
+
/**
- * <p class="changed_added_4_0">Taglib url in which generated tag will be defined. By default CDK uses url defined in the built project.</p>
+ * <p class="changed_added_4_0">Taglib url in which generated tag will be defined. By default CDK uses url
+ * defined in the built project.</p>
+ *
* @return
*/
public String taglib() default "";
Modified: root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Test.java
===================================================================
--- root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Test.java 2009-10-30 23:28:08 UTC (rev 15787)
+++ root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Test.java 2009-11-01 16:01:20 UTC (rev 15788)
@@ -33,36 +33,40 @@
* <p class="changed_added_4_0">Mark component class or method for automated testing.</p>
* <p class="todo">TODO: introduce additional parameters to refine generated test.
* </p>
- *
+ *
* @author asmirnov(a)exadel.com
- *
*/
@Retention(RetentionPolicy.CLASS)
-(a)Target({ElementType.TYPE,ElementType.METHOD})
+(a)Target({ElementType.TYPE, ElementType.METHOD})
@Inherited
public @interface Test {
- public static final String NAME = "org.richfaces.cdk.annotations.Test";
+ public static final String NAME = "org.richfaces.cdk.annotations.Test";
- /**
- * <p class="changed_added_4_0">
- * Name of the generated unit test class. Currently that is mandatory</p>
- * <p class="todo">TODO: if this value is an empty, class will be inferred from the base class name.
- * </p>
- *
- * @return name of the generated test class.
- */
- public String testClass();
+ /**
+ * <p class="changed_added_4_0">
+ * Name of the generated unit test class. Currently that is mandatory</p>
+ * <p class="todo">TODO: if this value is an empty, class will be inferred from the base class name.
+ * </p>
+ *
+ * @return name of the generated test class.
+ */
+ public String testClass();
- /**
- * <p class="changed_added_4_0">The value of this annotation attribute is taken to be a name of the generated test method.</p>
- * @return
- */
- public String testMethod() default "";
- /**
- * <p class="changed_added_4_0">The value of this annotation attribute tells CDK what kind of tests should be generated.</p>
- * @return
- */
- public TestType type() default TestType.ALL;
+ /**
+ * <p class="changed_added_4_0">The value of this annotation attribute is taken to be a name of the generated
+ * test method.</p>
+ *
+ * @return
+ */
+ public String testMethod() default "";
+ /**
+ * <p class="changed_added_4_0">The value of this annotation attribute tells CDK what kind of tests should be
+ * generated.</p>
+ *
+ * @return
+ */
+ public TestType type() default TestType.ALL;
+
}
Modified: root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/TestType.java
===================================================================
--- root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/TestType.java 2009-10-30 23:28:08 UTC (rev 15787)
+++ root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/TestType.java 2009-11-01 16:01:20 UTC (rev 15788)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.annotations;
/**
@@ -29,18 +31,19 @@
*
*/
public enum TestType {
-
- /**
- * <p class="changed_added_4_0">Generate tests for JSF <b>RENDER_RESPONSE</b> phase.</p>
- */
- RENDER,
- /**
- * <p class="changed_added_4_0"></p>
- */
- DECODE,
- /**
- * <p class="changed_added_4_0">Generate all possible tests.</p>
- */
- ALL
+ /**
+ * <p class="changed_added_4_0">Generate tests for JSF <b>RENDER_RESPONSE</b> phase.</p>
+ */
+ RENDER,
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ */
+ DECODE,
+
+ /**
+ * <p class="changed_added_4_0">Generate all possible tests.</p>
+ */
+ ALL
}
Modified: root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/package-info.java
===================================================================
--- root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/package-info.java 2009-10-30 23:28:08 UTC (rev 15787)
+++ root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/package-info.java 2009-11-01 16:01:20 UTC (rev 15788)
@@ -1,3 +1,4 @@
+
/**
* <h1>Java annotations used by the CDK.</h1>
* <h2>Class-level annotations:</h2>
@@ -25,10 +26,9 @@
* <li>@{@link Icon} , @{@link DisplayName} - optional IDE-related parameters.</li>
* </ul>
* <p> </p>
- *<h3>Facet annotations.</h3>
+ * <h3>Facet annotations.</h3>
* <p>There are two methods to define component facet. At the class level, developer could use @{@link Facets annotations. It is also possible to define facet getter/setter methods for facet and mark one of them with @{@link Facet} annotation.</p>
-
- *
+ *
+ *
*/
package org.richfaces.cdk.annotations;
-
15 years, 1 month