Author: nbelaevski
Date: 2010-07-10 06:55:46 -0400 (Sat, 10 Jul 2010)
New Revision: 17803
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassVisitor.java
Log:
Fixed NPE in CDK
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassVisitor.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassVisitor.java 2010-07-10
00:23:48 UTC (rev 17802)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassVisitor.java 2010-07-10
10:55:46 UTC (rev 17803)
@@ -90,7 +90,7 @@
/**
* <p class="changed_added_4_0">
* </p>
- *
+ *
* @author asmirnov(a)exadel.com
*/
public class RendererClassVisitor implements TemplateVisitor {
@@ -177,23 +177,25 @@
List<ResourceDependency> resourceDependencies =
compositeInterface.getResourceDependencies();
ELType dependencyType =
typesFactory.getType(javax.faces.application.ResourceDependency.class);
- if (1 == resourceDependencies.size()) {
- ResourceDependency resource = resourceDependencies.get(0);
- this.generatedClass.addAnnotation(createResourceAnnotation(dependencyType,
resource));
- } else if (resourceDependencies.size() > 1) {
- StringBuilder resources = new StringBuilder("{");
- for (ResourceDependency resource : resourceDependencies) {
- if (resources.length() > 1) {
- resources.append(',');
+ if (resourceDependencies != null) {
+ if (1 == resourceDependencies.size()) {
+ ResourceDependency resource = resourceDependencies.get(0);
+
this.generatedClass.addAnnotation(createResourceAnnotation(dependencyType, resource));
+ } else if (resourceDependencies.size() > 1) {
+ StringBuilder resources = new StringBuilder("{");
+ for (ResourceDependency resource : resourceDependencies) {
+ if (resources.length() > 1) {
+ resources.append(',');
+ }
+ resources.append("@ResourceDependency(");
+
resources.append("name=\"").append(resource.getName()).append("\",library=\"").append(
+
resource.getLibrary()).append("\",target=\"").append(resource.getTarget()).append("\"").append(")");
}
- resources.append("@ResourceDependency(");
-
resources.append("name=\"").append(resource.getName()).append("\",library=\"").append(
-
resource.getLibrary()).append("\",target=\"").append(resource.getTarget()).append("\"").append(")");
+ resources.append("}");
+ this.generatedClass.addAnnotation(new
JavaAnnotation(typesFactory.getType(ResourceDependencies.class),
+ resources.toString()));
+
this.generatedClass.addImport(javax.faces.application.ResourceDependency.class);
}
- resources.append("}");
- this.generatedClass.addAnnotation(new
JavaAnnotation(typesFactory.getType(ResourceDependencies.class),
- resources.toString()));
-
this.generatedClass.addImport(javax.faces.application.ResourceDependency.class);
}
this.createMethodContext();
}
@@ -313,7 +315,7 @@
/**
* <p class="changed_added_4_0">
* </p>
- *
+ *
* @return the rendererClass
*/
public JavaClass getGeneratedClass() {
@@ -322,7 +324,7 @@
/*
* (non-Javadoc)
- *
+ *
* @see org.richfaces.cdk.templatecompiler.model.TemplateVisitor
* #startElement(org.richfaces.cdk.templatecompiler.model.CdkBodyElement)
*/
@@ -334,7 +336,7 @@
/*
* (non-Javadoc)
- *
+ *
* @see org.richfaces.cdk.templatecompiler.model.TemplateVisitor
* #endElement(org.richfaces.cdk.templatecompiler.model.CdkBodyElement)
*/
@@ -346,7 +348,7 @@
/*
* (non-Javadoc)
- *
+ *
* @see org.richfaces.cdk.templatecompiler.model.TemplateVisitor
* #startElement(org.richfaces.cdk.templatecompiler.model.AnyElement)
*/
@@ -366,7 +368,7 @@
/*
* (non-Javadoc)
- *
+ *
* @see org.richfaces.cdk.templatecompiler.model.TemplateVisitor
* #endElement(org.richfaces.cdk.templatecompiler.model.AnyElement)
*/
@@ -380,7 +382,7 @@
/*
* (non-Javadoc)
- *
+ *
* @see
org.richfaces.cdk.templatecompiler.model.TemplateVisitor#visitElement(java.lang.String)
*/
@@ -397,7 +399,7 @@
/*
* (non-Javadoc)
- *
+ *
* @see org.richfaces.cdk.templatecompiler.model.TemplateVisitor
* #visitElement(org.richfaces.cdk.templatecompiler.model.CdkCallElement)
*/
@@ -413,7 +415,7 @@
/*
* (non-Javadoc)
- *
+ *
* @see org.richfaces.cdk.templatecompiler.model.TemplateVisitor
* #startElement(org.richfaces.cdk.templatecompiler.model.CdkIfElement)
*/
@@ -427,7 +429,7 @@
/*
* (non-Javadoc)
- *
+ *
* @see org.richfaces.cdk.templatecompiler.model.TemplateVisitor
* #endElement(org.richfaces.cdk.templatecompiler.model.CdkIfElement)
*/
@@ -440,7 +442,7 @@
/*
* (non-Javadoc)
- *
+ *
* @see org.richfaces.cdk.templatecompiler.model.TemplateVisitor
* #startElement(org.richfaces.cdk.templatecompiler.model.CdkChooseElement)
*/
@@ -452,7 +454,7 @@
/*
* (non-Javadoc)
- *
+ *
* @see org.richfaces.cdk.templatecompiler.model.TemplateVisitor
* #endElement(org.richfaces.cdk.templatecompiler.model.CdkChooseElement)
*/
@@ -464,7 +466,7 @@
/*
* (non-Javadoc)
- *
+ *
* @see org.richfaces.cdk.templatecompiler.model.TemplateVisitor
* #startElement(org.richfaces.cdk.templatecompiler.model.CdkWhenElement)
*/
@@ -477,7 +479,7 @@
/*
* (non-Javadoc)
- *
+ *
* @see org.richfaces.cdk.templatecompiler.model.TemplateVisitor
* #endElement(org.richfaces.cdk.templatecompiler.model.CdkWhenElement)
*/
@@ -489,7 +491,7 @@
/*
* (non-Javadoc)
- *
+ *
* @see org.richfaces.cdk.templatecompiler.model.TemplateVisitor
* #startElement(org.richfaces.cdk.templatecompiler.model.CdkOtherwiseElement)
*/
@@ -501,7 +503,7 @@
/*
* (non-Javadoc)
- *
+ *
* @see org.richfaces.cdk.templatecompiler.model.TemplateVisitor
* #endElement(org.richfaces.cdk.templatecompiler.model.CdkOtherwiseElement)
*/
@@ -513,7 +515,7 @@
/*
* (non-Javadoc)
- *
+ *
* @see org.richfaces.cdk.templatecompiler.model.TemplateVisitor
* #visitElement(org.richfaces.cdk.templatecompiler.model.CdkObjectElement)
*/
@@ -532,7 +534,7 @@
/*
* (non-Javadoc)
- *
+ *
* @see org.richfaces.cdk.templatecompiler.model.TemplateVisitor
* #startElement(org.richfaces.cdk.templatecompiler.model.CdkForEachElement)
*/
@@ -554,7 +556,7 @@
/*
* (non-Javadoc)
- *
+ *
* @see org.richfaces.cdk.templatecompiler.model.TemplateVisitor
* #endElement(org.richfaces.cdk.templatecompiler.model.CdkForEachElement)
*/