Author: alexsmirnov
Date: 2010-06-29 20:47:26 -0400 (Tue, 29 Jun 2010)
New Revision: 17682
Added:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/AttributesStatement.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/ElementStatement.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/TemplateStatementBase.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/TemplateStatementsContainerBase.java
Removed:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/AbstractTemplateMethodBodyStatementsContainer.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/BaseTemplateMethodBodyStatement.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/ConversionToBooleanMethodBodyStatement.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/ConversionToStringMethodBodyStatement.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/EmptinessCheckingMethodBodyStatement.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/EqualsCheckingMethodBodyStatement.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/HelperMethodBodyStatement.java
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassVisitor.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/VisitorFactoryImpl.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/ELVisitor.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AbstractMethodTreeNode.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AstBracketSuffixTreeNode.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AstChoiceTreeNode.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AstEmptyTreeNode.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AstFunctionTreeNode.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AstIdentifierTreeNode.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AstMethodSuffixTreeNode.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AstPropertySuffixTreeNode.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AstValueTreeNode.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/ConstantValueTreeNode.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/EqualityTestTreeNode.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/AnyElement.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/ConstantReturnMethodBodyStatement.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/DefineObjectStatement.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/EncodeMethodPrefaceStatement.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/EndElementStatement.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/ForEachStatement.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/HelperJavaMethod.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/HelperMethod.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/HelperMethodFactoryImpl.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/IfElseStatement.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/StartElementStatement.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/StatementsContainer.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/TemplateStatement.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/TypedTemplateStatement.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/WriteAttributeStatement.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/WriteAttributesSetStatement.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/WriteTextStatement.java
root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/parser/el/test/ELParserTest.java
Log:
start template renderer refactor.
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassVisitor.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassVisitor.java 2010-06-29
22:50:34 UTC (rev 17681)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassVisitor.java 2010-06-30
00:47:26 UTC (rev 17682)
@@ -28,6 +28,7 @@
import static org.richfaces.cdk.util.JavaUtils.getEscapedStringsArray;
import java.io.IOException;
+import java.lang.reflect.Type;
import java.util.Collection;
import java.util.Collections;
import java.util.EnumMap;
@@ -51,6 +52,7 @@
import org.richfaces.cdk.model.EventName;
import org.richfaces.cdk.model.PropertyBase;
import org.richfaces.cdk.templatecompiler.builder.model.Argument;
+import org.richfaces.cdk.templatecompiler.builder.model.JavaAnnotation;
import org.richfaces.cdk.templatecompiler.builder.model.JavaClass;
import org.richfaces.cdk.templatecompiler.builder.model.JavaField;
import org.richfaces.cdk.templatecompiler.builder.model.JavaMethod;
@@ -76,6 +78,7 @@
import org.richfaces.cdk.templatecompiler.model.CompositeInterface;
import org.richfaces.cdk.templatecompiler.model.Template;
import org.richfaces.cdk.templatecompiler.model.TemplateVisitor;
+import org.richfaces.cdk.templatecompiler.statements.AttributesStatement;
import org.richfaces.cdk.templatecompiler.statements.ConstantReturnMethodBodyStatement;
import
org.richfaces.cdk.templatecompiler.statements.ConversionToBooleanMethodBodyStatement;
import
org.richfaces.cdk.templatecompiler.statements.ConversionToStringMethodBodyStatement;
@@ -85,6 +88,7 @@
import org.richfaces.cdk.templatecompiler.statements.EndElementStatement;
import org.richfaces.cdk.templatecompiler.statements.EqualsCheckingMethodBodyStatement;
import org.richfaces.cdk.templatecompiler.statements.ForEachStatement;
+import org.richfaces.cdk.templatecompiler.statements.HelperJavaMethod;
import org.richfaces.cdk.templatecompiler.statements.HelperMethod;
import org.richfaces.cdk.templatecompiler.statements.HelperMethodBodyStatement;
import org.richfaces.cdk.templatecompiler.statements.HelperMethodFactory;
@@ -149,40 +153,26 @@
private static final Set<String> DEFAULT_NAMESPACES =
ImmutableSet.of(Template.XHTML_EL_NAMESPACE,
Template.XHTML_NAMESPACE);
- private static final EnumMap<HelperMethod, HelperMethodBodyStatement>
HELPER_METHOD_BODIES =
- new EnumMap<HelperMethod, HelperMethodBodyStatement>(HelperMethod.class);
-
- static {
- HELPER_METHOD_BODIES.put(HelperMethod.EMPTINESS_CHECK, new
EmptinessCheckingMethodBodyStatement());
- HELPER_METHOD_BODIES.put(HelperMethod.EQUALS_CHECK, new
EqualsCheckingMethodBodyStatement());
- HELPER_METHOD_BODIES.put(HelperMethod.TO_BOOLEAN_CONVERSION, new
ConversionToBooleanMethodBodyStatement());
- HELPER_METHOD_BODIES.put(HelperMethod.TO_STRING_CONVERSION, new
ConversionToStringMethodBodyStatement());
- }
-
private final Logger log;
+ private final Injector injector;
+ private final TypesFactory typesFactory;
+ private final HelperMethodFactory helperMethodFactory;
+ private final CompositeInterface compositeInterface;
+ private final Collection<PropertyBase> attributes;
private StatementsContainer currentStatement;
private JavaClass generatedClass;
- private CompositeInterface compositeInterface;
-
- private final ELParser parser;
-
private Set<HelperMethod> addedHelperMethods =
EnumSet.noneOf(HelperMethod.class);
- private ELType lastCompiledExpressionType;
private int passThroughCounter;
- private final Collection<PropertyBase> attributes;
- private final Injector injector;
- private final HelperMethodFactory helperMethodFactory;
-
public RendererClassVisitor(CompositeInterface compositeInterface,
Collection<PropertyBase> attributes, Logger log,
- Injector injector, ELParser parser, HelperMethodFactory helperFactory) {
+ Injector injector, TypesFactory typesFactory, HelperMethodFactory helperFactory)
{
this.compositeInterface = compositeInterface;
this.attributes = attributes;
this.injector = injector;
- this.parser = parser;
+ this.typesFactory = typesFactory;
this.log = log;
this.helperMethodFactory = helperFactory;
}
@@ -212,26 +202,21 @@
private void addHelperMethod(HelperMethod helperMethod) {
if (addedHelperMethods.add(helperMethod)) {
JavaMethod helperJavaMethod =
helperMethodFactory.getHelperMethod(helperMethod);
- generatedClass.addMethod(helperJavaMethod);
+ if (helperJavaMethod.isHidden()) {
+ generatedClass.addImports(helperJavaMethod.getRequiredImports());
+ } else {
+ generatedClass.addMethod(helperJavaMethod);
+ }
+ addHelperMethods(helperJavaMethod.getMethodBody());
}
}
- private String compileEl(String expression, Class<?> type) {
- try {
- ELVisitor elVisitor = new ELVisitor();
- elVisitor.parse(expression, currentStatement,
TypesFactoryImpl.getType(type));
-
- lastCompiledExpressionType = elVisitor.getExpressionType();
- String parsedExpression = elVisitor.getParsedExpression();
-
- for (HelperMethod helperMethod : elVisitor.getUsedHelperMethods()) {
- addHelperMethod(helperMethod);
+ private void addHelperMethods(JavaStatement statement) {
+ if (statement instanceof TemplateStatement) {
+ TemplateStatement templateStatement = (TemplateStatement) statement;
+ for (HelperMethod helper : templateStatement.getRequiredMethods()) {
+ addHelperMethod(helper);
}
-
- return parsedExpression + "/* " + expression.trim() + "
*/";
- } catch (ParsingException e) {
- // TODO Auto-generated catch block
- throw new RuntimeException(e.getMessage(), e);
}
}
@@ -248,27 +233,8 @@
return false;
}
- private ELType createTypeOfKnownClass(JavaClass initialClass, Class<?>
knownSuperClass) {
- assert !knownSuperClass.isInterface();
-
- ELType result = null;
-
- JavaClass javaClass = initialClass;
- while (javaClass != null) {
- ELType type = TypesFactoryImpl.getType(javaClass.getName(), parser);
- if (knownSuperClass.isAssignableFrom(type.getRawType())) {
- result = type;
- break;
- }
-
- javaClass = javaClass.getSuperClass();
- }
-
- if (result == null) {
- result = TypesFactoryImpl.getType(knownSuperClass);
- }
-
- return result;
+ private ELType getType(Type type) {
+ return typesFactory.getType(type);
}
private String createPassThroughAttributeCode(String htmlAttributeName, String
componentAttributeName) {
@@ -360,47 +326,38 @@
private void createMethodContext() {
this.currentStatement = new StatementsContainer();
- currentStatement.setVariable(FACES_CONTEXT_VARIABLE,
TypesFactoryImpl.getType(FacesContext.class));
- currentStatement.setVariable(RESPONSE_WRITER_VARIABLE,
TypesFactoryImpl.getType(ResponseWriter.class));
- currentStatement.setVariable(CLIENT_ID_VARIABLE,
TypesFactoryImpl.getType(String.class));
+ currentStatement.setVariable(FACES_CONTEXT_VARIABLE,
getType(FacesContext.class));
+ currentStatement.setVariable(RESPONSE_WRITER_VARIABLE,
getType(ResponseWriter.class));
+ currentStatement.setVariable(CLIENT_ID_VARIABLE, getType(String.class));
// TODO: try load component class
- currentStatement.setVariable(COMPONENT_VARIABLE,
TypesFactoryImpl.getType(UIComponent.class));
+ currentStatement.setVariable(COMPONENT_VARIABLE, getType(UIComponent.class));
- ELType generatedClassType = createTypeOfKnownClass(generatedClass,
Renderer.class);
+ ELType generatedClassType = typesFactory.getType(generatedClass.getName());
currentStatement.setVariable(THIS_VARIABLE, generatedClassType);
- ELType generatedClassSuperType =
createTypeOfKnownClass(generatedClass.getSuperClass(), Renderer.class);
+ ELType generatedClassSuperType =
typesFactory.getType(generatedClass.getSuperClass().getName());
currentStatement.setVariable(SUPER_VARIABLE, generatedClassSuperType);
}
private void flushToEncodeMethod(String encodeMethodName) {
if (!this.currentStatement.isEmpty()) {
- Argument facesContextArgument = new Argument(FACES_CONTEXT_VARIABLE,
FacesContext.class);
- Argument componentArgument = new Argument(COMPONENT_VARIABLE,
UIComponent.class);
+ Argument facesContextArgument = new Argument(FACES_CONTEXT_VARIABLE,
getType(FacesContext.class));
+ Argument componentArgument = new Argument(COMPONENT_VARIABLE,
getType(UIComponent.class));
JavaMethod javaMethod = new JavaMethod(encodeMethodName,
facesContextArgument, componentArgument);
javaMethod.addModifier(JavaModifier.PUBLIC);
- javaMethod.addAnnotation(Override.class);
- javaMethod.getExceptions().add(IOException.class);
- currentStatement.addStatement(0, new EncodeMethodPrefaceStatement());
+ javaMethod.addAnnotation(new JavaAnnotation(getType(Override.class)));
+ javaMethod.getExceptions().add(getType(IOException.class));
+ currentStatement.addStatement(0,
createStatement(EncodeMethodPrefaceStatement.class));
javaMethod.setMethodBody(currentStatement);
- generatedClass.addMethod(javaMethod);
- Iterable<ELType> importsList = currentStatement.getRequiredImports();
- for (ELType importedClass : importsList) {
- generatedClass.addImport(importedClass.getRawType());
- for (Class<?> classToImport : importedClass.getRequiredImports())
{
- generatedClass.addImport(classToImport);
- }
- }
- for (HelperMethod helper : currentStatement.getRequiredMethods()) {
- addHelperMethod(helper);
- }
+ addHelperMethods(currentStatement);
for (JavaField field : currentStatement.getRequiredFields()) {
generatedClass.addField(field);
}
+ generatedClass.addMethod(javaMethod);
}
createMethodContext();
@@ -414,15 +371,14 @@
private void createRendersChildrenMethod() {
Boolean rendersChildren = compositeInterface.getRendersChildren();
if (rendersChildren != null) {
- JavaMethod rendersChildrenMethod = new
JavaMethod("getRendersChildren", Boolean.TYPE);
+ JavaMethod rendersChildrenMethod = new
JavaMethod("getRendersChildren", TypesFactory.BOOLEAN_TYPE);
rendersChildrenMethod.addModifier(JavaModifier.PUBLIC);
- rendersChildrenMethod.addAnnotation(Override.class);
+ rendersChildrenMethod.addAnnotation(new
JavaAnnotation(getType(Override.class)));
- rendersChildrenMethod.setMethodBody(new
ConstantReturnMethodBodyStatement(Boolean
- .toString(compositeInterface.getRendersChildren())));
-
+ ConstantReturnMethodBodyStatement statement =
createStatement(ConstantReturnMethodBodyStatement.class);
+
statement.setReturnValue(Boolean.toString(compositeInterface.getRendersChildren()));
+ rendersChildrenMethod.setMethodBody(statement);
generatedClass.addMethod(rendersChildrenMethod);
-
}
}
@@ -435,9 +391,9 @@
currentStatement = currentStatement.getParent();
}
- protected void addStatement(JavaStatement statement) {
- // TODO - add imports, fields and helper methods required by statement.
- addStatement(statement);
+ protected void addStatement(TemplateStatement statement) {
+ addHelperMethods(statement);
+ currentStatement.addStatement(statement);
}
/**
@@ -490,66 +446,65 @@
// TODO: add support
return;
}
-
- addStatement(new StartElementStatement(elementName.getLocalPart()));
-
- if (elementAttributes != null) {
- Set<String> writtenAttributes = new HashSet<String>();
- boolean shouldEncodePassThrough = false;
- String[] passThroughExclusions = null;
-
- Map<QName, Object> sortedElementAttributes = new TreeMap<QName,
Object>(QNAME_COMPARATOR);
- sortedElementAttributes.putAll(elementAttributes);
-
- for (Map.Entry<QName, Object> attribute :
sortedElementAttributes.entrySet()) {
- QName attributeName = attribute.getKey();
- Object attributeValue = attribute.getValue();
-
- if (!isDefaultNamespace(attributeName.getNamespaceURI())) {
- // TODO: add support
- if (Template.CDK_NAMESPACE.equals(attributeName.getNamespaceURI())
- &&
"passThroughWithExclusions".equals(attributeName.getLocalPart())) {
-
- shouldEncodePassThrough = true;
- if (attributeValue != null) {
- passThroughExclusions =
attributeValue.toString().split("\\s+");
- }
- }
- } else {
- String attributeLocalName = attributeName.getLocalPart();
- if (writtenAttributes.add(attributeLocalName)) {
- addRendererUtilsImport();
- addStatement(new WriteAttributeStatement(attributeLocalName,
compileEl(
- attributeValue.toString(), Object.class)));
- }
- }
- }
-
- if (shouldEncodePassThrough) {
- Element attributesElement =
attributesSchema.getElements().get(elementName.getLocalPart());
- if (attributesElement != null) {
- // make a copy of original set
- TreeMap<String, Attribute> actualAttributesMap =
- new TreeMap<String,
Attribute>(attributesElement.getAttributes());
-
- if (passThroughExclusions != null) {
- for (String passThroughExclusion : passThroughExclusions) {
- actualAttributesMap.remove(passThroughExclusion);
- }
- }
-
- for (String writtenAttribute : writtenAttributes) {
- actualAttributesMap.remove(writtenAttribute);
- }
-
- if (!actualAttributesMap.isEmpty()) {
- String passThroughFieldName =
createPassThroughField(actualAttributesMap);
- addRendererUtilsImport();
- addStatement(new
WriteAttributesSetStatement(passThroughFieldName));
- }
- }
- }
- }
+ StartElementStatement startElementStatement =
createStatement(StartElementStatement.class);
+ addStatement(startElementStatement);
+ startElementStatement.setElementName(elementName.getLocalPart());
+ AttributesStatement attributesStatement =
createStatement(AttributesStatement.class);
+ addStatement(attributesStatement);
+ attributesStatement.setAttributes(elementAttributes);
+// Set<String> writtenAttributes = new HashSet<String>();
+// boolean shouldEncodePassThrough = false;
+// String[] passThroughExclusions = null;
+//
+// Map<QName, Object> sortedElementAttributes = new TreeMap<QName,
Object>(QNAME_COMPARATOR);
+// sortedElementAttributes.putAll(elementAttributes);
+//
+// for (Map.Entry<QName, Object> attribute :
sortedElementAttributes.entrySet()) {
+// QName attributeName = attribute.getKey();
+// Object attributeValue = attribute.getValue();
+//
+// if (!isDefaultNamespace(attributeName.getNamespaceURI())) {
+// // TODO: add support
+// if (Template.CDK_NAMESPACE.equals(attributeName.getNamespaceURI())
+// &&
"passThroughWithExclusions".equals(attributeName.getLocalPart())) {
+//
+// shouldEncodePassThrough = true;
+// if (attributeValue != null) {
+// passThroughExclusions =
attributeValue.toString().split("\\s+");
+// }
+// }
+// } else {
+// String attributeLocalName = attributeName.getLocalPart();
+// if (writtenAttributes.add(attributeLocalName)) {
+// addStatement(new WriteAttributeStatement(attributeLocalName,
compileEl(
+// attributeValue.toString(), Object.class)));
+// }
+// }
+// }
+//
+// if (shouldEncodePassThrough) {
+// Element attributesElement =
attributesSchema.getElements().get(elementName.getLocalPart());
+// if (attributesElement != null) {
+// // make a copy of original set
+// TreeMap<String, Attribute> actualAttributesMap =
+// new TreeMap<String,
Attribute>(attributesElement.getAttributes());
+//
+// if (passThroughExclusions != null) {
+// for (String passThroughExclusion : passThroughExclusions) {
+// actualAttributesMap.remove(passThroughExclusion);
+// }
+// }
+//
+// for (String writtenAttribute : writtenAttributes) {
+// actualAttributesMap.remove(writtenAttribute);
+// }
+//
+// if (!actualAttributesMap.isEmpty()) {
+// String passThroughFieldName =
createPassThroughField(actualAttributesMap);
+// addStatement(new
WriteAttributesSetStatement(passThroughFieldName));
+// }
+// }
+// }
}
/*
@@ -562,7 +517,9 @@
@Override
public void endElement(AnyElement anyElement) throws CdkException {
QName elementName = anyElement.getName();
- addStatement(new EndElementStatement(elementName.getLocalPart()));
+ EndElementStatement endElementStatement =
createStatement(EndElementStatement.class);
+ endElementStatement.setElementName(elementName.getLocalPart());
+ addStatement(endElementStatement);
}
/*
@@ -725,7 +682,7 @@
ELType type = null;
if (!Strings.isEmpty(typeString)) {
- type = TypesFactoryImpl.getType(typeString, parser);
+ type = TypesFactoryImpl.getType(typeString, typesFactory);
}
if (!Strings.isEmpty(value)) {
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/VisitorFactoryImpl.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/VisitorFactoryImpl.java 2010-06-29
22:50:34 UTC (rev 17681)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/VisitorFactoryImpl.java 2010-06-30
00:47:26 UTC (rev 17682)
@@ -27,6 +27,7 @@
import org.richfaces.cdk.Logger;
import org.richfaces.cdk.model.PropertyBase;
+import org.richfaces.cdk.templatecompiler.el.types.TypesFactory;
import org.richfaces.cdk.templatecompiler.model.CompositeInterface;
import org.richfaces.cdk.templatecompiler.statements.HelperMethodFactory;
@@ -40,7 +41,7 @@
*/
public class VisitorFactoryImpl implements
TemplateVisitorFactory<RendererClassVisitor> {
- final ELParser parser;
+ final TypesFactory typesFactory;
final Logger log;
final Injector injector;
private final HelperMethodFactory helpersFactory;
@@ -52,8 +53,8 @@
* @param log
*/
@Inject
- public VisitorFactoryImpl(ELParser parser, Logger log, Injector
injector,HelperMethodFactory helpersFactory) {
- this.parser = parser;
+ public VisitorFactoryImpl(TypesFactory typesFactory, Logger log, Injector
injector,HelperMethodFactory helpersFactory) {
+ this.typesFactory = typesFactory;
this.log = log;
this.injector = injector;
this.helpersFactory = helpersFactory;
@@ -64,7 +65,7 @@
*/
@Override
public RendererClassVisitor createVisitor(CompositeInterface composite,
Collection<PropertyBase> attributes) {
- return new RendererClassVisitor(composite, attributes,
log,injector,parser,helpersFactory);
+ return new RendererClassVisitor(composite, attributes,
log,injector,typesFactory,helpersFactory);
}
}
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/ELVisitor.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/ELVisitor.java 2010-06-29
22:50:34 UTC (rev 17681)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/ELVisitor.java 2010-06-30
00:47:26 UTC (rev 17682)
@@ -116,7 +116,9 @@
private boolean mixedExpression;
+ private boolean literal = true;
+
public ELVisitor(Logger log, TypesFactory typesFactory) {
this.log = log;
this.typesFactory = typesFactory;
@@ -128,6 +130,25 @@
}
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the literal
+ */
+ @Override
+ public boolean isLiteral() {
+ return this.literal;
+ }
+
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param literal the literal to set
+ */
+ public void setLiteral(boolean literal) {
+ this.literal = literal;
+ }
+
+
public ELType getExpressionType() {
return expressionType;
}
@@ -167,6 +188,7 @@
//AstCompositeExpression with 2+ children is a mixed expression
usedHelperMethods.add(TO_STRING_CONVERSION);
this.mixedExpression = true;
+ this.literal = false;
}
if (ret != null && ret.jjtGetNumChildren() > 0) {
@@ -190,6 +212,7 @@
return conversionMethod.getName() + "(" + valueString +
")";
}
}
+ setLiteral(false);
}
return valueString;
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AbstractMethodTreeNode.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AbstractMethodTreeNode.java 2010-06-29
22:50:34 UTC (rev 17681)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AbstractMethodTreeNode.java 2010-06-30
00:47:26 UTC (rev 17682)
@@ -80,6 +80,7 @@
returnType = TypesFactory.OBJECT_TYPE;
}
+ visitor.setLiteral(false);
visitor.setExpressionType(returnType);
}
}
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AstBracketSuffixTreeNode.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AstBracketSuffixTreeNode.java 2010-06-29
22:50:34 UTC (rev 17681)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AstBracketSuffixTreeNode.java 2010-06-30
00:47:26 UTC (rev 17682)
@@ -60,6 +60,7 @@
if (containerType == null) {
containerType = TypesFactory.OBJECT_TYPE;
}
+ visitor.setLiteral(false);
visitor.setExpressionType(containerType);
}
}
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AstChoiceTreeNode.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AstChoiceTreeNode.java 2010-06-29
22:50:34 UTC (rev 17681)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AstChoiceTreeNode.java 2010-06-30
00:47:26 UTC (rev 17682)
@@ -60,6 +60,7 @@
sb.append(ELNodeConstants.RIGHT_BRACKET);
+ visitor.setLiteral(false);
if (!correctConditionBranchType.isNullType()) {
visitor.setExpressionType(correctConditionBranchType);
} else {
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AstEmptyTreeNode.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AstEmptyTreeNode.java 2010-06-29
22:50:34 UTC (rev 17681)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AstEmptyTreeNode.java 2010-06-30
00:47:26 UTC (rev 17682)
@@ -55,5 +55,6 @@
sb.append(ELNodeConstants.RIGHT_BRACKET);
visitor.setExpressionType(TypesFactory.BOOLEAN_TYPE);
+ visitor.setLiteral(false);
}
}
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AstFunctionTreeNode.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AstFunctionTreeNode.java 2010-06-29
22:50:34 UTC (rev 17681)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AstFunctionTreeNode.java 2010-06-30
00:47:26 UTC (rev 17682)
@@ -62,5 +62,6 @@
visitor.setExpressionType(identifierType);
visitMethod(sb, visitor, functionName);
+ visitor.setLiteral(false);
}
}
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AstIdentifierTreeNode.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AstIdentifierTreeNode.java 2010-06-29
22:50:34 UTC (rev 17681)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AstIdentifierTreeNode.java 2010-06-30
00:47:26 UTC (rev 17682)
@@ -47,5 +47,6 @@
//TODO: implement variable mapper like "utils" ->
"this.getUtils()"
visitor.setExpressionType(identifierType);
sb.append(identifierName);
+ visitor.setLiteral(false);
}
}
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AstMethodSuffixTreeNode.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AstMethodSuffixTreeNode.java 2010-06-29
22:50:34 UTC (rev 17681)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AstMethodSuffixTreeNode.java 2010-06-30
00:47:26 UTC (rev 17682)
@@ -42,5 +42,6 @@
String methodName = getNode().getImage();
visitMethod(sb, visitor, methodName);
+ visitor.setLiteral(false);
}
}
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AstPropertySuffixTreeNode.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AstPropertySuffixTreeNode.java 2010-06-29
22:50:34 UTC (rev 17681)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AstPropertySuffixTreeNode.java 2010-06-30
00:47:26 UTC (rev 17682)
@@ -55,5 +55,6 @@
sb.append(readMethodName);
sb.append(ELNodeConstants.LEFT_BRACKET);
sb.append(ELNodeConstants.RIGHT_BRACKET);
+ visitor.setLiteral(false);
}
}
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AstValueTreeNode.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AstValueTreeNode.java 2010-06-29
22:50:34 UTC (rev 17681)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AstValueTreeNode.java 2010-06-30
00:47:26 UTC (rev 17682)
@@ -43,6 +43,7 @@
String childOutput = getChildOutput(i, visitor);
sb.append(childOutput);
}
+ visitor.setLiteral(false);
//variable type has been already set by getChildOuput()
}
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/ConstantValueTreeNode.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/ConstantValueTreeNode.java 2010-06-29
22:50:34 UTC (rev 17681)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/ConstantValueTreeNode.java 2010-06-30
00:47:26 UTC (rev 17682)
@@ -66,6 +66,9 @@
public void visit(StringBuilder sb, ELVisitor visitor) throws ParsingException {
sb.append(value);
visitor.setExpressionType(type);
+ if(type.isNullType()){
+ visitor.setLiteral(false);
+ }
}
}
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/EqualityTestTreeNode.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/EqualityTestTreeNode.java 2010-06-29
22:50:34 UTC (rev 17681)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/EqualityTestTreeNode.java 2010-06-30
00:47:26 UTC (rev 17682)
@@ -114,6 +114,7 @@
sb.append(ELNodeConstants.RIGHT_BRACKET);
}
+ visitor.setLiteral(false);
visitor.setExpressionType(TypesFactory.BOOLEAN_TYPE);
}
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/AnyElement.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/AnyElement.java 2010-06-29
22:50:34 UTC (rev 17681)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/AnyElement.java 2010-06-30
00:47:26 UTC (rev 17682)
@@ -30,6 +30,8 @@
import org.richfaces.cdk.CdkException;
+import com.google.common.collect.Maps;
+
/**
* <p class="changed_added_4_0"></p>
*
@@ -39,7 +41,7 @@
private QName name;
- private Map<QName, Object> attributes;
+ private Map<QName, Object> attributes = Maps.newHashMap();
/**
* <p class="changed_added_4_0"></p>
Deleted:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/AbstractTemplateMethodBodyStatementsContainer.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/AbstractTemplateMethodBodyStatementsContainer.java 2010-06-29
22:50:34 UTC (rev 17681)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/AbstractTemplateMethodBodyStatementsContainer.java 2010-06-30
00:47:26 UTC (rev 17682)
@@ -1,42 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software 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 software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.richfaces.cdk.templatecompiler.statements;
-
-
-/**
- * @author Nick Belaevski
- */
-public class AbstractTemplateMethodBodyStatementsContainer extends StatementsContainer {
-
- private String templateName;
-
- protected AbstractTemplateMethodBodyStatementsContainer(String templateName) {
- super();
- this.templateName = templateName;
- }
-
- @Override
- public String getCode() {
- return renderer.renderSnippet(templateName, this);
- }
-
-}
Added:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/AttributesStatement.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/AttributesStatement.java
(rev 0)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/AttributesStatement.java 2010-06-30
00:47:26 UTC (rev 17682)
@@ -0,0 +1,35 @@
+package org.richfaces.cdk.templatecompiler.statements;
+
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+import org.richfaces.cdk.attributes.Schema;
+import org.richfaces.cdk.templatecompiler.ELParser;
+import org.richfaces.cdk.templatecompiler.model.Template;
+
+import com.google.inject.Inject;
+import com.google.inject.Provider;
+import com.google.inject.name.Named;
+
+public class AttributesStatement extends StatementsContainer {
+
+ private final Schema attributesSchema;
+ private final Provider<WriteAttributeStatement> statementProvider;
+ private final Provider<WriteAttributesSetStatement>
passThroughStatementProvider;
+ private final ELParser parser;
+
+ @Inject
+ public AttributesStatement((a)Named(Template.XHTML_EL_NAMESPACE) Schema
attributesSchema,
+ Provider<WriteAttributeStatement> attributeStatementProvider,
+ Provider<WriteAttributesSetStatement> passThroughStatementProvider,
ELParser parser) {
+ this.attributesSchema = attributesSchema;
+ this.statementProvider = attributeStatementProvider;
+ this.passThroughStatementProvider = passThroughStatementProvider;
+ this.parser = parser;
+ }
+
+ public void setAttributes(Map<QName, Object> attributes) {
+
+ }
+}
Property changes on:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/AttributesStatement.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/BaseTemplateMethodBodyStatement.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/BaseTemplateMethodBodyStatement.java 2010-06-29
22:50:34 UTC (rev 17681)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/BaseTemplateMethodBodyStatement.java 2010-06-30
00:47:26 UTC (rev 17682)
@@ -1,65 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software 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 software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.richfaces.cdk.templatecompiler.statements;
-
-import java.util.Collections;
-
-import org.richfaces.cdk.templatecompiler.FreeMarkerRenderer;
-import org.richfaces.cdk.templatecompiler.builder.model.JavaField;
-import org.richfaces.cdk.templatecompiler.builder.model.JavaImport;
-
-/**
- * @author Nick Belaevski
- *
- */
-public class BaseTemplateMethodBodyStatement implements TemplateStatement {
-
- private final String templateName;
- private final FreeMarkerRenderer renderer;
-
- protected BaseTemplateMethodBodyStatement(FreeMarkerRenderer renderer,String
templateName) {
- super();
- this.renderer = renderer;
- this.templateName = templateName;
- }
-
- @Override
- public String getCode() {
- return renderer.renderSnippet(templateName, this);
- }
-
- @Override
- public Iterable<JavaImport> getRequiredImports() {
- return Collections.emptySet();
- }
-
- @Override
- public Iterable<JavaField> getRequiredFields() {
- return Collections.emptySet();
- }
-
- @Override
- public Iterable<HelperMethod> getRequiredMethods() {
- return Collections.emptySet();
- }
-
-}
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/ConstantReturnMethodBodyStatement.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/ConstantReturnMethodBodyStatement.java 2010-06-29
22:50:34 UTC (rev 17681)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/ConstantReturnMethodBodyStatement.java 2010-06-30
00:47:26 UTC (rev 17682)
@@ -21,21 +21,33 @@
*/
package org.richfaces.cdk.templatecompiler.statements;
+import org.richfaces.cdk.templatecompiler.FreeMarkerRenderer;
+
+import com.google.inject.Inject;
+
/**
* @author Nick Belaevski
*
*/
-public class ConstantReturnMethodBodyStatement extends BaseTemplateMethodBodyStatement {
+public class ConstantReturnMethodBodyStatement extends TemplateStatementBase {
private String returnValue;
- public ConstantReturnMethodBodyStatement(String returnValue) {
- super("constant-return");
+ @Inject
+ public ConstantReturnMethodBodyStatement(FreeMarkerRenderer renderer) {
+ super(renderer,"constant-return");
- this.returnValue = returnValue;
}
public String getReturnValue() {
return returnValue;
}
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param returnValue the returnValue to set
+ */
+ public void setReturnValue(String returnValue) {
+ this.returnValue = returnValue;
+ }
}
Deleted:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/ConversionToBooleanMethodBodyStatement.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/ConversionToBooleanMethodBodyStatement.java 2010-06-29
22:50:34 UTC (rev 17681)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/ConversionToBooleanMethodBodyStatement.java 2010-06-30
00:47:26 UTC (rev 17682)
@@ -1,32 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software 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 software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.richfaces.cdk.templatecompiler.statements;
-
-/**
- * @author Nick Belaevski
- */
-public class ConversionToBooleanMethodBodyStatement extends HelperMethodBodyStatement {
-
- public ConversionToBooleanMethodBodyStatement() {
- super("conversion-to-boolean-method", new String[]
{"object"});
- }
-}
Deleted:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/ConversionToStringMethodBodyStatement.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/ConversionToStringMethodBodyStatement.java 2010-06-29
22:50:34 UTC (rev 17681)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/ConversionToStringMethodBodyStatement.java 2010-06-30
00:47:26 UTC (rev 17682)
@@ -1,32 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software 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 software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.richfaces.cdk.templatecompiler.statements;
-
-/**
- * @author Nick Belaevski
- */
-public class ConversionToStringMethodBodyStatement extends HelperMethodBodyStatement {
-
- public ConversionToStringMethodBodyStatement() {
- super("conversion-to-string-method", new String[]
{"object"});
- }
-}
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/DefineObjectStatement.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/DefineObjectStatement.java 2010-06-29
22:50:34 UTC (rev 17681)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/DefineObjectStatement.java 2010-06-30
00:47:26 UTC (rev 17682)
@@ -26,7 +26,7 @@
/**
* @author Nick Belaevski
*/
-public class DefineObjectStatement extends BaseTemplateMethodBodyStatement {
+public class DefineObjectStatement extends TemplateStatementBase {
private ELType type;
Added:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/ElementStatement.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/ElementStatement.java
(rev 0)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/ElementStatement.java 2010-06-30
00:47:26 UTC (rev 17682)
@@ -0,0 +1,54 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.richfaces.cdk.templatecompiler.statements;
+
+import org.richfaces.cdk.templatecompiler.FreeMarkerRenderer;
+
+/**
+ * @author Nick Belaevski
+ * @since 4.0
+ */
+public class ElementStatement extends TemplateStatementBase {
+
+ private String elementName;
+
+ public ElementStatement(FreeMarkerRenderer renderer,String template) {
+ super(renderer,template);
+ }
+
+
+ /**
+ * @return the elementName
+ */
+ public String getElementName() {
+ return elementName;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param elementName the elementName to set
+ */
+ public void setElementName(String elementName) {
+ this.elementName = elementName;
+ }
+
+}
Property changes on:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/ElementStatement.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/EmptinessCheckingMethodBodyStatement.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/EmptinessCheckingMethodBodyStatement.java 2010-06-29
22:50:34 UTC (rev 17681)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/EmptinessCheckingMethodBodyStatement.java 2010-06-30
00:47:26 UTC (rev 17682)
@@ -1,32 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software 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 software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.richfaces.cdk.templatecompiler.statements;
-
-/**
- * @author Nick Belaevski
- */
-public class EmptinessCheckingMethodBodyStatement extends HelperMethodBodyStatement {
-
- public EmptinessCheckingMethodBodyStatement() {
- super("emptiness-check-method", new String[] {"object"});
- }
-}
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/EncodeMethodPrefaceStatement.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/EncodeMethodPrefaceStatement.java 2010-06-29
22:50:34 UTC (rev 17681)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/EncodeMethodPrefaceStatement.java 2010-06-30
00:47:26 UTC (rev 17682)
@@ -21,16 +21,21 @@
*/
package org.richfaces.cdk.templatecompiler.statements;
+import org.richfaces.cdk.templatecompiler.FreeMarkerRenderer;
+
+import com.google.inject.Inject;
+
/**
* @author Nick Belaevski
*/
-public class EncodeMethodPrefaceStatement extends BaseTemplateMethodBodyStatement {
+public class EncodeMethodPrefaceStatement extends TemplateStatementBase {
/**
* @param templateName
*/
- public EncodeMethodPrefaceStatement() {
- super("encode-method-preface");
+ @Inject
+ public EncodeMethodPrefaceStatement(FreeMarkerRenderer renderer) {
+ super(renderer,"encode-method-preface");
}
}
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/EndElementStatement.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/EndElementStatement.java 2010-06-29
22:50:34 UTC (rev 17681)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/EndElementStatement.java 2010-06-30
00:47:26 UTC (rev 17682)
@@ -21,14 +21,19 @@
*/
package org.richfaces.cdk.templatecompiler.statements;
+import org.richfaces.cdk.templatecompiler.FreeMarkerRenderer;
+
+import com.google.inject.Inject;
+
/**
* @author Nick Belaevski
* @since 4.0
*/
-public class EndElementStatement extends StartElementStatement {
+public class EndElementStatement extends ElementStatement {
- public EndElementStatement(String elementName) {
- super("end-element", elementName);
+ @Inject
+ public EndElementStatement(FreeMarkerRenderer renderer) {
+ super(renderer,"end-element");
}
}
Deleted:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/EqualsCheckingMethodBodyStatement.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/EqualsCheckingMethodBodyStatement.java 2010-06-29
22:50:34 UTC (rev 17681)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/EqualsCheckingMethodBodyStatement.java 2010-06-30
00:47:26 UTC (rev 17682)
@@ -1,33 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software 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 software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.richfaces.cdk.templatecompiler.statements;
-
-/**
- * @author Nick Belaevski
- *
- */
-public class EqualsCheckingMethodBodyStatement extends HelperMethodBodyStatement {
-
- public EqualsCheckingMethodBodyStatement() {
- super("equals-check-method", new String[] {"o1",
"o2"});
- }
-}
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/ForEachStatement.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/ForEachStatement.java 2010-06-29
22:50:34 UTC (rev 17681)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/ForEachStatement.java 2010-06-30
00:47:26 UTC (rev 17682)
@@ -24,7 +24,7 @@
/**
* @author Nick Belaevski
*/
-public class ForEachStatement extends AbstractTemplateMethodBodyStatementsContainer {
+public class ForEachStatement extends TemplateStatementsContainerBase {
private String itemsExpression;
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/HelperJavaMethod.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/HelperJavaMethod.java 2010-06-29
22:50:34 UTC (rev 17681)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/HelperJavaMethod.java 2010-06-30
00:47:26 UTC (rev 17682)
@@ -23,7 +23,9 @@
package org.richfaces.cdk.templatecompiler.statements;
+import org.richfaces.cdk.templatecompiler.builder.model.Argument;
import org.richfaces.cdk.templatecompiler.builder.model.JavaMethod;
+import org.richfaces.cdk.templatecompiler.el.types.ELType;
/**
* <p class="changed_added_4_0"></p>
@@ -31,5 +33,15 @@
*
*/
public class HelperJavaMethod extends JavaMethod {
+
+ public HelperJavaMethod(String name, ELType returnType, Argument[] arguments) {
+ super(name, returnType, arguments);
+ }
+
+ public HelperJavaMethod(String name) {
+ super(name);
+ }
+
+
}
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/HelperMethod.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/HelperMethod.java 2010-06-29
22:50:34 UTC (rev 17681)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/HelperMethod.java 2010-06-30
00:47:26 UTC (rev 17682)
@@ -26,6 +26,8 @@
import java.util.EnumSet;
import java.util.Set;
+import javax.faces.context.FacesContext;
+
/**
* @author Nick Belaevski
*
@@ -35,7 +37,8 @@
TO_STRING_CONVERSION(CONVERT_TO_STRING_FUNCTION, String.class, Object.class),
TO_BOOLEAN_CONVERSION(CONVERT_TO_BOOLEAN_FUNCTION, Boolean.TYPE, Object.class),
EMPTINESS_CHECK(IS_EMPTY_FUNCTION, Boolean.TYPE, Object.class),
- EQUALS_CHECK(IS_EQUAL_FUNCTION, Boolean.TYPE, Object.class, Object.class);
+ EQUALS_CHECK(IS_EQUAL_FUNCTION, Boolean.TYPE, Object.class, Object.class),
+
WRITE_ATTRIBUTE("renderAttribute",Void.TYPE,FacesContext.class,String.class,Object.class);
private static final Set<HelperMethod> CONVERSION_METHODS =
EnumSet.of(TO_STRING_CONVERSION, TO_BOOLEAN_CONVERSION);
@@ -45,7 +48,6 @@
private Class<?>[] argumentTypes;
- private boolean utilsMethod = false;
private HelperMethod(String name, Class<?> returnType, Class<?>...
argumentTypes) {
this.name = name;
@@ -53,21 +55,6 @@
this.argumentTypes = argumentTypes;
}
- private HelperMethod(String name, Class<?> returnType, boolean utils,
Class<?>... argumentTypes) {
- this.name = name;
- this.returnType = returnType;
- this.argumentTypes = argumentTypes;
- this.utilsMethod=utils;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @return the utilsMethod
- */
- public boolean isUtilsMethod() {
- return this.utilsMethod;
- }
-
public String getName() {
return name;
}
Deleted:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/HelperMethodBodyStatement.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/HelperMethodBodyStatement.java 2010-06-29
22:50:34 UTC (rev 17681)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/HelperMethodBodyStatement.java 2010-06-30
00:47:26 UTC (rev 17682)
@@ -1,41 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software 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 software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.richfaces.cdk.templatecompiler.statements;
-
-/**
- * @author Nick Belaevski
- *
- */
-public class HelperMethodBodyStatement extends BaseTemplateMethodBodyStatement {
-
- private String[] argumentNames;
-
- protected HelperMethodBodyStatement(String templateName, String[] argumentNames) {
- super(templateName);
-
- this.argumentNames = argumentNames;
- }
-
- public String[] getArgumentNames() {
- return argumentNames;
- }
-}
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/HelperMethodFactoryImpl.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/HelperMethodFactoryImpl.java 2010-06-29
22:50:34 UTC (rev 17681)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/HelperMethodFactoryImpl.java 2010-06-30
00:47:26 UTC (rev 17682)
@@ -23,6 +23,8 @@
package org.richfaces.cdk.templatecompiler.statements;
+import java.util.EnumMap;
+
import org.richfaces.cdk.Generator;
import org.richfaces.cdk.templatecompiler.FreeMarkerRenderer;
import org.richfaces.cdk.templatecompiler.builder.model.Argument;
@@ -31,6 +33,7 @@
import org.richfaces.cdk.templatecompiler.el.types.ELType;
import org.richfaces.cdk.templatecompiler.el.types.TypesFactory;
+import com.google.common.collect.Maps;
import com.google.inject.Inject;
import com.google.inject.internal.Nullable;
import com.google.inject.name.Named;
@@ -47,18 +50,30 @@
private final FreeMarkerRenderer renderer;
private final TypesFactory typesFactory;
private final String rendererUtilsClass;
+ private final EnumMap<HelperMethod, JavaMethod> helperMethods =
+ Maps.newEnumMap(HelperMethod.class);
+
@Inject
public HelperMethodFactoryImpl(FreeMarkerRenderer renderer, TypesFactory
typesFactory,
@Named(Generator.RENDERER_UTILS_CLASS) @Nullable String rendererUtilsClass) {
this.renderer = renderer;
this.typesFactory = typesFactory;
this.rendererUtilsClass = rendererUtilsClass;
+ initHelperMethods();
}
- private JavaMethod buildHelperMethod(HelperMethod helperMethod, String templateName,
String... argumentNames) {
- if (helperMethod.isUtilsMethod() && null != rendererUtilsClass) {
- return new RendererUtilsMethod(helperMethod, rendererUtilsClass);
+ protected void initHelperMethods() {
+ buildHelperMethod(HelperMethod.EMPTINESS_CHECK, false,
"emptiness-check-method", "object");
+ buildHelperMethod(HelperMethod.EQUALS_CHECK, false,
"equals-check-method", "o1", "o2");
+ buildHelperMethod(HelperMethod.TO_BOOLEAN_CONVERSION,
false,"conversion-to-boolean-method", "object");
+ buildHelperMethod(HelperMethod.TO_STRING_CONVERSION, false,
"conversion-to-string-method", "object");
+ }
+
+ private JavaMethod buildHelperMethod(HelperMethod helperMethod, boolean utilsMethod,
String templateName, String... argumentNames) {
+ JavaMethod helperJavaMethod;
+ if (utilsMethod && null != rendererUtilsClass) {
+ helperJavaMethod = new RendererUtilsMethod(helperMethod,
rendererUtilsClass);
} else {
Class<?>[] argumentTypes = helperMethod.getArgumentTypes();
Argument[] arguments = new Argument[argumentTypes.length];
@@ -67,12 +82,13 @@
arguments[i] = new Argument(argumentName,
typesFactory.getType(argumentTypes[i]));
}
ELType returnType = typesFactory.getType(helperMethod.getReturnType());
- JavaMethod helperJavaMethod = new JavaMethod(helperMethod.getName(),
returnType, arguments);
+ helperJavaMethod = new JavaMethod(helperMethod.getName(), returnType,
arguments);
helperJavaMethod.addModifier(JavaModifier.PRIVATE);
helperJavaMethod.addModifier(JavaModifier.STATIC);
- helperJavaMethod.setMethodBody(new BaseTemplateMethodBodyStatement(renderer,
templateName));
- return helperJavaMethod;
+ helperJavaMethod.setMethodBody(new TemplateStatementBase(renderer,
templateName));
}
+ helperMethods.put(helperMethod, helperJavaMethod);
+ return helperJavaMethod;
}
/*
@@ -84,8 +100,7 @@
*/
@Override
public JavaMethod getHelperMethod(HelperMethod helper) {
- // TODO Auto-generated method stub
- return null;
+ return helperMethods.get(helper);
}
}
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/IfElseStatement.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/IfElseStatement.java 2010-06-29
22:50:34 UTC (rev 17681)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/IfElseStatement.java 2010-06-30
00:47:26 UTC (rev 17682)
@@ -25,7 +25,7 @@
* @author Nick Belaevski
* @since 4.0
*/
-public class IfElseStatement extends AbstractTemplateMethodBodyStatementsContainer {
+public class IfElseStatement extends TemplateStatementsContainerBase {
public IfElseStatement() {
super("if-else");
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/StartElementStatement.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/StartElementStatement.java 2010-06-29
22:50:34 UTC (rev 17681)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/StartElementStatement.java 2010-06-30
00:47:26 UTC (rev 17682)
@@ -21,28 +21,19 @@
*/
package org.richfaces.cdk.templatecompiler.statements;
+import org.richfaces.cdk.templatecompiler.FreeMarkerRenderer;
+
+import com.google.inject.Inject;
+
/**
* @author Nick Belaevski
* @since 4.0
*/
-public class StartElementStatement extends BaseTemplateMethodBodyStatement {
+public class StartElementStatement extends ElementStatement {
- private String elementName;
-
- public StartElementStatement(String elementName) {
- this("start-element", elementName);
+ @Inject
+ public StartElementStatement(FreeMarkerRenderer renderer) {
+ super(renderer,"start-element");
}
- protected StartElementStatement(String templateName, String elementName) {
- super(templateName);
- this.elementName = elementName;
- }
-
- /**
- * @return the elementName
- */
- public String getElementName() {
- return elementName;
- }
-
}
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/StatementsContainer.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/StatementsContainer.java 2010-06-29
22:50:34 UTC (rev 17681)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/StatementsContainer.java 2010-06-30
00:47:26 UTC (rev 17682)
@@ -40,30 +40,33 @@
*/
public class StatementsContainer implements TemplateStatement, Variables {
- private static final Function<TemplateStatement, Iterable<JavaImport>>
IMPORTS_TRANSFORM = new Function<TemplateStatement, Iterable<JavaImport>>() {
-
- @Override
- public Iterable<JavaImport> apply(TemplateStatement from) {
- return from.getRequiredImports();
- }
- };
+ private static final Function<TemplateStatement, Iterable<JavaImport>>
IMPORTS_TRANSFORM =
+ new Function<TemplateStatement, Iterable<JavaImport>>() {
- private static final Function<TemplateStatement, Iterable<JavaField>>
FIELDS_TRANSFORM = new Function<TemplateStatement, Iterable<JavaField>>() {
-
- @Override
- public Iterable<JavaField> apply(TemplateStatement from) {
- return from.getRequiredFields();
- }
- };
+ @Override
+ public Iterable<JavaImport> apply(TemplateStatement from) {
+ return from.getRequiredImports();
+ }
+ };
- private static final Function<TemplateStatement, Iterable<HelperMethod>>
HELPER_METHODS_TRANSFORM = new Function<TemplateStatement,
Iterable<HelperMethod>>() {
-
- @Override
- public Iterable<HelperMethod> apply(TemplateStatement from) {
- return from.getRequiredMethods();
- }
- };
+ private static final Function<TemplateStatement, Iterable<JavaField>>
FIELDS_TRANSFORM =
+ new Function<TemplateStatement, Iterable<JavaField>>() {
+ @Override
+ public Iterable<JavaField> apply(TemplateStatement from) {
+ return from.getRequiredFields();
+ }
+ };
+
+ private static final Function<TemplateStatement, Iterable<HelperMethod>>
HELPER_METHODS_TRANSFORM =
+ new Function<TemplateStatement, Iterable<HelperMethod>>() {
+
+ @Override
+ public Iterable<HelperMethod> apply(TemplateStatement from) {
+ return from.getRequiredMethods();
+ }
+ };
+
private List<TemplateStatement> statements = new
ArrayList<TemplateStatement>();
private StatementsContainer parent;
@@ -75,22 +78,15 @@
}
public void addStatement(TemplateStatement statement) {
- setParent(statement);
+ statement.setParent(this);
statements.add(statement);
}
public void addStatement(int index, TemplateStatement statement) {
- setParent(statement);
+ statement.setParent(this);
statements.add(index, statement);
}
- private void setParent(TemplateStatement statement) {
- if (statement instanceof StatementsContainer) {
- StatementsContainer container = (StatementsContainer) statement;
- container.setParent(this);
- }
- }
-
/**
* <p class="changed_added_4_0">
* </p>
@@ -176,7 +172,7 @@
public Iterable<HelperMethod> getRequiredMethods() {
return concatStatements(HELPER_METHODS_TRANSFORM);
}
-
+
@Override
public String toString() {
return getCode();
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/TemplateStatement.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/TemplateStatement.java 2010-06-29
22:50:34 UTC (rev 17681)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/TemplateStatement.java 2010-06-30
00:47:26 UTC (rev 17682)
@@ -17,5 +17,7 @@
Iterable<JavaField> getRequiredFields();
Iterable<HelperMethod> getRequiredMethods();
+
+ void setParent(StatementsContainer parent);
}
Copied:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/TemplateStatementBase.java
(from rev 17680,
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/BaseTemplateMethodBodyStatement.java)
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/TemplateStatementBase.java
(rev 0)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/TemplateStatementBase.java 2010-06-30
00:47:26 UTC (rev 17682)
@@ -0,0 +1,78 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.richfaces.cdk.templatecompiler.statements;
+
+import java.util.Collections;
+import java.util.EnumSet;
+
+import org.richfaces.cdk.templatecompiler.FreeMarkerRenderer;
+import org.richfaces.cdk.templatecompiler.builder.model.JavaField;
+import org.richfaces.cdk.templatecompiler.builder.model.JavaImport;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class TemplateStatementBase implements TemplateStatement {
+
+ protected StatementsContainer parent;
+ private final String templateName;
+ private final FreeMarkerRenderer renderer;
+ private final EnumSet<HelperMethod> requiredMethods =
EnumSet.noneOf(HelperMethod.class);
+
+ protected TemplateStatementBase(FreeMarkerRenderer renderer, String templateName) {
+ super();
+ this.renderer = renderer;
+ this.templateName = templateName;
+ }
+
+ @Override
+ public void setParent(StatementsContainer parent) {
+ this.parent = parent;
+ }
+
+ @Override
+ public String getCode() {
+ return renderer.renderSnippet(templateName, this);
+ }
+
+ @Override
+ public Iterable<JavaImport> getRequiredImports() {
+ return Collections.emptySet();
+ }
+
+ @Override
+ public Iterable<JavaField> getRequiredFields() {
+ return Collections.emptySet();
+ }
+
+ @Override
+ public Iterable<HelperMethod> getRequiredMethods() {
+ return requiredMethods;
+ }
+
+ protected void addRequiredMethods(HelperMethod... methods) {
+ for (HelperMethod helperMethod : methods) {
+ requiredMethods.add(helperMethod);
+ }
+ }
+}
\ No newline at end of file
Property changes on:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/TemplateStatementBase.java
___________________________________________________________________
Name: svn:keywords
+ LastChangedDate LastChangedRevision LastChangedBy HeadURL Id
Copied:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/TemplateStatementsContainerBase.java
(from rev 17680,
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/AbstractTemplateMethodBodyStatementsContainer.java)
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/TemplateStatementsContainerBase.java
(rev 0)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/TemplateStatementsContainerBase.java 2010-06-30
00:47:26 UTC (rev 17682)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.richfaces.cdk.templatecompiler.statements;
+
+import org.richfaces.cdk.templatecompiler.FreeMarkerRenderer;
+
+
+/**
+ * @author Nick Belaevski
+ */
+public class TemplateStatementsContainerBase extends StatementsContainer {
+
+ private final String templateName;
+ private final FreeMarkerRenderer renderer;
+
+ protected TemplateStatementsContainerBase(FreeMarkerRenderer renderer,String
templateName) {
+ super();
+ this.renderer = renderer;
+ this.templateName = templateName;
+ }
+
+ @Override
+ public String getCode() {
+ return renderer.renderSnippet(templateName, this);
+ }
+
+}
Property changes on:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/TemplateStatementsContainerBase.java
___________________________________________________________________
Name: svn:keywords
+ LastChangedDate LastChangedRevision LastChangedBy HeadURL Id
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/TypedTemplateStatement.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/TypedTemplateStatement.java 2010-06-29
22:50:34 UTC (rev 17681)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/TypedTemplateStatement.java 2010-06-30
00:47:26 UTC (rev 17682)
@@ -34,4 +34,6 @@
ELType getExpressionType();
+ boolean isLiteral();
+
}
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/WriteAttributeStatement.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/WriteAttributeStatement.java 2010-06-29
22:50:34 UTC (rev 17681)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/WriteAttributeStatement.java 2010-06-30
00:47:26 UTC (rev 17682)
@@ -21,26 +21,36 @@
*/
package org.richfaces.cdk.templatecompiler.statements;
+import org.richfaces.cdk.templatecompiler.FreeMarkerRenderer;
+
+import com.google.inject.Inject;
+
/**
* @author Nick Belaevski
*/
-public class WriteAttributeStatement extends BaseTemplateMethodBodyStatement {
+public class WriteAttributeStatement extends TemplateStatementBase {
- private String attributeName;
+ private String name;
- private String valueExpression;
+ private TypedTemplateStatement valueExpression;
- public WriteAttributeStatement(String attributeName, String valueExpression) {
- super("write-attribute");
- this.attributeName = attributeName;
- this.valueExpression = valueExpression;
+
+ @Inject
+ public WriteAttributeStatement(FreeMarkerRenderer renderer) {
+ super(renderer,"write-attribute");
}
+
+ public void setAttribute(String name,TypedTemplateStatement expression) {
+ this.name = name;
+ this.valueExpression = expression;
+ addRequiredMethods(HelperMethod.WRITE_ATTRIBUTE);
+ }
- public String getAttributeName() {
- return attributeName;
+ public String getName() {
+ return name;
}
- public String getValueExpression() {
+ public TypedTemplateStatement getValue() {
return valueExpression;
}
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/WriteAttributesSetStatement.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/WriteAttributesSetStatement.java 2010-06-29
22:50:34 UTC (rev 17681)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/WriteAttributesSetStatement.java 2010-06-30
00:47:26 UTC (rev 17682)
@@ -25,7 +25,7 @@
/**
* @author Nick Belaevski
*/
-public class WriteAttributesSetStatement extends BaseTemplateMethodBodyStatement {
+public class WriteAttributesSetStatement extends TemplateStatementBase {
private String passThroughFieldName;
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/WriteTextStatement.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/WriteTextStatement.java 2010-06-29
22:50:34 UTC (rev 17681)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/WriteTextStatement.java 2010-06-30
00:47:26 UTC (rev 17682)
@@ -24,7 +24,7 @@
/**
* @author Nick Belaevski
*/
-public class WriteTextStatement extends BaseTemplateMethodBodyStatement {
+public class WriteTextStatement extends TemplateStatementBase {
private String textExpression;
Modified:
root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/parser/el/test/ELParserTest.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/parser/el/test/ELParserTest.java 2010-06-29
22:50:34 UTC (rev 17681)
+++
root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/parser/el/test/ELParserTest.java 2010-06-30
00:47:26 UTC (rev 17682)
@@ -658,4 +658,14 @@
public void testWrongExpression2() throws Exception {
parseExpression("#{action.property}", "action.getProperty()",
Object.class);
}
+
+ @Test
+ public void testLiteralExpression() throws Exception {
+ controller.replay();
+ TypedTemplateStatement parseExpression = parseExpression("Literal",
Object.class);
+ controller.verify();
+ assertTrue(parseExpression.isLiteral());
+ assertEquals("\"Literal\"",parseExpression.getCode());
+ assertEquals(String.class.getName(),
parseExpression.getExpressionType().getRawName());
+ }
}