Author: alexsmirnov
Date: 2010-06-24 20:01:41 -0400 (Thu, 24 Jun 2010)
New Revision: 17669
Added:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/ELParser.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/XhtmlElSchemaProvider.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/JavaStatement.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/StatementImpl.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/ELParserImpl.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/ELType.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/types/TypesFactoryImpl.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/
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/ConstantReturnMethodBodyStatement.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/DefineObjectStatement.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/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/EqualsCheckingMethodBodyStatement.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/HelperMethodBodyStatement.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/IfStatement.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/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
Removed:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/AbstractTemplateMethodBodyStatementsContainer.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/BaseTemplateMethodBodyStatement.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/ConstantReturnMethodBodyStatement.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/ConversionToBooleanMethodBodyStatement.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/ConversionToStringMethodBodyStatement.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/DefineObjectStatement.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/EmptinessCheckingMethodBodyStatement.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/EncodeMethodPrefaceStatement.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/EndElementStatement.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/EqualsCheckingMethodBodyStatement.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/ForEachStatement.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/HelperMethodBodyStatement.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/IfElseStatement.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/IfStatement.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/StartElementStatement.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/WriteAttributeStatement.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/WriteAttributesSetStatement.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/WriteTextStatement.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/MethodBody.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/MethodBodyStatement.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/MethodBodyStatementImpl.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/MethodBodyStatementsContainer.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/Type.java
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/JavaClassModelWrapper.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/MethodBodyTemplateModel.java
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/TemplateModule.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/builder/model/JavaClass.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/JavaField.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/JavaMethod.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/Variables.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/ELParserUtils.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/AbstractBinaryOperationTreeNode.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/AbstractTreeNode.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/AstDeferredOrDynamicExpressionTreeNode.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/AstFloatingPointTreeNode.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/AstIntegerTreeNode.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AstLiteralTreeNode.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/AstStringTreeNode.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/BinaryArithmeticIntegerOperationTreeNode.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/BinaryArithmeticOperationTreeNode.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/BinaryBooleanOperationTreeNode.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/BinaryBooleanResultOperationTreeNode.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/el/types/ComplexType.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/types/NullType.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/types/PlainClassType.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/types/ReferencedType.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/types/TypesFactory.java
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/TypesFactoryTest.java
Log:
convert EL parser to guice
Deleted:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/AbstractTemplateMethodBodyStatementsContainer.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/AbstractTemplateMethodBodyStatementsContainer.java 2010-06-24
14:18:53 UTC (rev 17668)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/AbstractTemplateMethodBodyStatementsContainer.java 2010-06-25
00:01:41 UTC (rev 17669)
@@ -1,43 +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;
-
-import org.richfaces.cdk.templatecompiler.builder.model.MethodBodyStatementsContainer;
-
-/**
- * @author Nick Belaevski
- */
-public class AbstractTemplateMethodBodyStatementsContainer extends
MethodBodyStatementsContainer {
-
- private String templateName;
-
- protected AbstractTemplateMethodBodyStatementsContainer(String templateName) {
- super();
- this.templateName = templateName;
- }
-
- @Override
- public String getCode(FreeMarkerRenderer renderer) {
- return renderer.renderSnippet(templateName, this);
- }
-
-}
Deleted:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/BaseTemplateMethodBodyStatement.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/BaseTemplateMethodBodyStatement.java 2010-06-24
14:18:53 UTC (rev 17668)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/BaseTemplateMethodBodyStatement.java 2010-06-25
00:01:41 UTC (rev 17669)
@@ -1,43 +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;
-
-import org.richfaces.cdk.templatecompiler.builder.model.MethodBodyStatement;
-
-/**
- * @author Nick Belaevski
- */
-public class BaseTemplateMethodBodyStatement implements MethodBodyStatement {
-
- private String templateName;
-
- protected BaseTemplateMethodBodyStatement(String templateName) {
- super();
- this.templateName = templateName;
- }
-
- @Override
- public String getCode(FreeMarkerRenderer renderer) {
- return renderer.renderSnippet(templateName, this);
- }
-
-}
Deleted:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/ConstantReturnMethodBodyStatement.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/ConstantReturnMethodBodyStatement.java 2010-06-24
14:18:53 UTC (rev 17668)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/ConstantReturnMethodBodyStatement.java 2010-06-25
00:01:41 UTC (rev 17669)
@@ -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;
-
-/**
- * @author Nick Belaevski
- *
- */
-public class ConstantReturnMethodBodyStatement extends BaseTemplateMethodBodyStatement {
-
- private String returnValue;
-
- public ConstantReturnMethodBodyStatement(String returnValue) {
- super("constant-return");
-
- this.returnValue = returnValue;
- }
-
- public String getReturnValue() {
- return returnValue;
- }
-}
Deleted:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/ConversionToBooleanMethodBodyStatement.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/ConversionToBooleanMethodBodyStatement.java 2010-06-24
14:18:53 UTC (rev 17668)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/ConversionToBooleanMethodBodyStatement.java 2010-06-25
00:01:41 UTC (rev 17669)
@@ -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;
-
-/**
- * @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/ConversionToStringMethodBodyStatement.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/ConversionToStringMethodBodyStatement.java 2010-06-24
14:18:53 UTC (rev 17668)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/ConversionToStringMethodBodyStatement.java 2010-06-25
00:01:41 UTC (rev 17669)
@@ -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;
-
-/**
- * @author Nick Belaevski
- */
-public class ConversionToStringMethodBodyStatement extends HelperMethodBodyStatement {
-
- public ConversionToStringMethodBodyStatement() {
- super("conversion-to-string-method", new String[]
{"object"});
- }
-}
Deleted:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/DefineObjectStatement.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/DefineObjectStatement.java 2010-06-24
14:18:53 UTC (rev 17668)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/DefineObjectStatement.java 2010-06-25
00:01:41 UTC (rev 17669)
@@ -1,66 +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;
-
-import org.richfaces.cdk.templatecompiler.el.Type;
-
-/**
- * @author Nick Belaevski
- */
-public class DefineObjectStatement extends BaseTemplateMethodBodyStatement {
-
- private Type type;
-
- private String name;
-
- private String initializationExpression;
-
- public DefineObjectStatement(Type type, String name, String initializationExpression)
{
- super("define-object");
-
- this.type = type;
- this.name = name;
- this.initializationExpression = initializationExpression != null ?
initializationExpression : "";
- }
-
- /**
- * @return the type
- */
- public Type getType() {
- return type;
- }
-
- /**
- * @return the name
- */
- public String getName() {
- return name;
- }
-
- /**
- * @return the initializationExpression
- */
- public String getInitializationExpression() {
- return initializationExpression;
- }
-
-}
Added:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/ELParser.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/ELParser.java
(rev 0)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/ELParser.java 2010-06-25
00:01:41 UTC (rev 17669)
@@ -0,0 +1,19 @@
+package org.richfaces.cdk.templatecompiler;
+
+import org.richfaces.cdk.model.ClassName;
+import org.richfaces.cdk.templatecompiler.builder.model.Variables;
+import org.richfaces.cdk.templatecompiler.el.ELType;
+import org.richfaces.cdk.templatecompiler.el.ParsingException;
+import org.richfaces.cdk.templatecompiler.statements.TemplateStatement;
+
+public interface ELParser {
+
+ TemplateStatement parse(String expression, Variables variables, ELType expectedType)
throws ParsingException;
+
+ ELType getType(Class<?> targetClass);
+
+ ELType getType(String classExpression);
+
+ ELType getType(ClassName targetClass);
+
+}
Property changes on:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/ELParser.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Deleted:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/EmptinessCheckingMethodBodyStatement.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/EmptinessCheckingMethodBodyStatement.java 2010-06-24
14:18:53 UTC (rev 17668)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/EmptinessCheckingMethodBodyStatement.java 2010-06-25
00:01:41 UTC (rev 17669)
@@ -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;
-
-/**
- * @author Nick Belaevski
- */
-public class EmptinessCheckingMethodBodyStatement extends HelperMethodBodyStatement {
-
- public EmptinessCheckingMethodBodyStatement() {
- super("emptiness-check-method", new String[] {"object"});
- }
-}
Deleted:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/EncodeMethodPrefaceStatement.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/EncodeMethodPrefaceStatement.java 2010-06-24
14:18:53 UTC (rev 17668)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/EncodeMethodPrefaceStatement.java 2010-06-25
00:01:41 UTC (rev 17669)
@@ -1,36 +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;
-
-/**
- * @author Nick Belaevski
- */
-public class EncodeMethodPrefaceStatement extends BaseTemplateMethodBodyStatement {
-
- /**
- * @param templateName
- */
- public EncodeMethodPrefaceStatement() {
- super("encode-method-preface");
- }
-
-}
Deleted:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/EndElementStatement.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/EndElementStatement.java 2010-06-24
14:18:53 UTC (rev 17668)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/EndElementStatement.java 2010-06-25
00:01:41 UTC (rev 17669)
@@ -1,34 +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;
-
-/**
- * @author Nick Belaevski
- * @since 4.0
- */
-public class EndElementStatement extends StartElementStatement {
-
- public EndElementStatement(String elementName) {
- super("end-element", elementName);
- }
-
-}
Deleted:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/EqualsCheckingMethodBodyStatement.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/EqualsCheckingMethodBodyStatement.java 2010-06-24
14:18:53 UTC (rev 17668)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/EqualsCheckingMethodBodyStatement.java 2010-06-25
00:01:41 UTC (rev 17669)
@@ -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;
-
-/**
- * @author Nick Belaevski
- *
- */
-public class EqualsCheckingMethodBodyStatement extends HelperMethodBodyStatement {
-
- public EqualsCheckingMethodBodyStatement() {
- super("equals-check-method", new String[] {"o1",
"o2"});
- }
-}
Deleted:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/ForEachStatement.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/ForEachStatement.java 2010-06-24
14:18:53 UTC (rev 17668)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/ForEachStatement.java 2010-06-25
00:01:41 UTC (rev 17669)
@@ -1,64 +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;
-
-/**
- * @author Nick Belaevski
- */
-public class ForEachStatement extends AbstractTemplateMethodBodyStatementsContainer {
-
- private String itemsExpression;
-
- private String var;
-
- private String varType;
-
- public ForEachStatement(String itemsExpression,
- String var, String varType) {
- super("for-each");
- this.itemsExpression = itemsExpression;
- this.var = var;
- this.varType = varType;
- }
-
- /**
- * @return the itemsExpression
- */
- public String getItemsExpression() {
- return itemsExpression;
- }
-
- /**
- * @return the var
- */
- public String getVar() {
- return var;
- }
-
- /**
- * @return the varType
- */
- public String getVarType() {
- return varType;
- }
-
-}
Deleted:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/HelperMethodBodyStatement.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/HelperMethodBodyStatement.java 2010-06-24
14:18:53 UTC (rev 17668)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/HelperMethodBodyStatement.java 2010-06-25
00:01:41 UTC (rev 17669)
@@ -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;
-
-/**
- * @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;
- }
-}
Deleted:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/IfElseStatement.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/IfElseStatement.java 2010-06-24
14:18:53 UTC (rev 17668)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/IfElseStatement.java 2010-06-25
00:01:41 UTC (rev 17669)
@@ -1,34 +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;
-
-/**
- * @author Nick Belaevski
- * @since 4.0
- */
-public class IfElseStatement extends AbstractTemplateMethodBodyStatementsContainer {
-
- public IfElseStatement() {
- super("if-else");
- }
-
-}
Deleted:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/IfStatement.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/IfStatement.java 2010-06-24
14:18:53 UTC (rev 17668)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/IfStatement.java 2010-06-25
00:01:41 UTC (rev 17669)
@@ -1,38 +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;
-
-import org.richfaces.cdk.templatecompiler.builder.model.MethodBodyStatementsContainer;
-
-public final class IfStatement extends MethodBodyStatementsContainer {
-
- private String test;
-
- public IfStatement(String test) {
- super();
- this.test = test;
- }
-
- public String getTest() {
- return test;
- }
-}
\ No newline at end of file
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/JavaClassModelWrapper.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/JavaClassModelWrapper.java 2010-06-24
14:18:53 UTC (rev 17668)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/JavaClassModelWrapper.java 2010-06-25
00:01:41 UTC (rev 17669)
@@ -1,6 +1,6 @@
package org.richfaces.cdk.templatecompiler;
-import org.richfaces.cdk.templatecompiler.builder.model.MethodBodyStatement;
+import org.richfaces.cdk.templatecompiler.builder.model.JavaStatement;
import freemarker.ext.beans.BeansWrapper;
import freemarker.template.ObjectWrapper;
@@ -21,8 +21,8 @@
// TODO wrap specified model classes.
TemplateModel templateModel;
- if (obj instanceof MethodBodyStatement) {
- templateModel = new MethodBodyTemplateModel((MethodBodyStatement) obj,
this);
+ if (obj instanceof JavaStatement) {
+ templateModel = new MethodBodyTemplateModel((JavaStatement) obj, this);
} else {
templateModel = super.wrap(obj);
}
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/MethodBodyTemplateModel.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/MethodBodyTemplateModel.java 2010-06-24
14:18:53 UTC (rev 17668)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/MethodBodyTemplateModel.java 2010-06-25
00:01:41 UTC (rev 17669)
@@ -23,7 +23,7 @@
package org.richfaces.cdk.templatecompiler;
-import org.richfaces.cdk.templatecompiler.builder.model.MethodBodyStatement;
+import org.richfaces.cdk.templatecompiler.builder.model.JavaStatement;
import freemarker.ext.beans.BeanModel;
import freemarker.template.TemplateModel;
@@ -38,7 +38,7 @@
private static final String CODE_ATTRIBUTE_NAME = "code";
- private final MethodBodyStatement statement;
+ private final JavaStatement statement;
private final JavaClassModelWrapper modelWrapper;
/**
@@ -47,7 +47,7 @@
* @param statement
* @param javaClassModelWrapper
*/
- public MethodBodyTemplateModel(MethodBodyStatement statement, JavaClassModelWrapper
javaClassModelWrapper) {
+ public MethodBodyTemplateModel(JavaStatement statement, JavaClassModelWrapper
javaClassModelWrapper) {
super(statement, javaClassModelWrapper);
this.statement = statement;
this.modelWrapper = javaClassModelWrapper;
@@ -56,7 +56,7 @@
@Override
public TemplateModel get(String key) throws TemplateModelException {
if (CODE_ATTRIBUTE_NAME.equals(key)) {
- String statementCode = statement.getCode(modelWrapper.getConfiguration());
+ String statementCode = statement.getCode();
return modelWrapper.wrap(statementCode);
}
return super.get(key);
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-24
14:18:53 UTC (rev 17668)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassVisitor.java 2010-06-25
00:01:41 UTC (rev 17669)
@@ -55,16 +55,15 @@
import org.richfaces.cdk.templatecompiler.builder.model.JavaField;
import org.richfaces.cdk.templatecompiler.builder.model.JavaMethod;
import org.richfaces.cdk.templatecompiler.builder.model.JavaModifier;
-import org.richfaces.cdk.templatecompiler.builder.model.MethodBody;
-import org.richfaces.cdk.templatecompiler.builder.model.MethodBodyStatement;
-import org.richfaces.cdk.templatecompiler.builder.model.MethodBodyStatementImpl;
-import org.richfaces.cdk.templatecompiler.builder.model.MethodBodyStatementsContainer;
+import org.richfaces.cdk.templatecompiler.builder.model.JavaStatement;
+import org.richfaces.cdk.templatecompiler.builder.model.StatementImpl;
import org.richfaces.cdk.templatecompiler.el.ELParserUtils;
import org.richfaces.cdk.templatecompiler.el.ELVisitor;
import org.richfaces.cdk.templatecompiler.el.HelperMethod;
import org.richfaces.cdk.templatecompiler.el.ParsingException;
-import org.richfaces.cdk.templatecompiler.el.Type;
+import org.richfaces.cdk.templatecompiler.el.ELType;
import org.richfaces.cdk.templatecompiler.el.types.TypesFactory;
+import org.richfaces.cdk.templatecompiler.el.types.TypesFactoryImpl;
import org.richfaces.cdk.templatecompiler.model.AnyElement;
import org.richfaces.cdk.templatecompiler.model.CdkBodyElement;
import org.richfaces.cdk.templatecompiler.model.CdkCallElement;
@@ -78,11 +77,30 @@
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.ConstantReturnMethodBodyStatement;
+import
org.richfaces.cdk.templatecompiler.statements.ConversionToBooleanMethodBodyStatement;
+import
org.richfaces.cdk.templatecompiler.statements.ConversionToStringMethodBodyStatement;
+import org.richfaces.cdk.templatecompiler.statements.DefineObjectStatement;
+import
org.richfaces.cdk.templatecompiler.statements.EmptinessCheckingMethodBodyStatement;
+import org.richfaces.cdk.templatecompiler.statements.EncodeMethodPrefaceStatement;
+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.HelperMethodBodyStatement;
+import org.richfaces.cdk.templatecompiler.statements.IfElseStatement;
+import org.richfaces.cdk.templatecompiler.statements.IfStatement;
+import org.richfaces.cdk.templatecompiler.statements.StartElementStatement;
+import org.richfaces.cdk.templatecompiler.statements.StatementsContainer;
+import org.richfaces.cdk.templatecompiler.statements.TemplateStatement;
+import org.richfaces.cdk.templatecompiler.statements.WriteAttributeStatement;
+import org.richfaces.cdk.templatecompiler.statements.WriteAttributesSetStatement;
+import org.richfaces.cdk.templatecompiler.statements.WriteTextStatement;
import org.richfaces.cdk.util.Strings;
import com.google.common.base.Function;
import com.google.common.collect.Collections2;
import com.google.common.collect.ImmutableSet;
+import com.google.inject.Injector;
/**
* <p class="changed_added_4_0">
@@ -142,30 +160,28 @@
private final Logger log;
- private MethodBodyStatementsContainer currentStatement;
+ private StatementsContainer currentStatement;
- private final Schema attributesSchema;
private JavaClass generatedClass;
private CompositeInterface compositeInterface;
- private final ClassLoader classLoader;
+ private final ELParser parser;
private Set<HelperMethod> addedHelperMethods =
EnumSet.noneOf(HelperMethod.class);
- private Type lastCompiledExpressionType;
+ private ELType lastCompiledExpressionType;
private int passThroughCounter;
private final Collection<PropertyBase> attributes;
- private final VisitorFactoryImpl visitorFactoryImpl;
+ private final Injector injector;
- public RendererClassVisitor(CompositeInterface compositeInterface,
Collection<PropertyBase> attributes,
- VisitorFactoryImpl factory) {
+ public RendererClassVisitor(CompositeInterface compositeInterface,
Collection<PropertyBase> attributes, Logger log,
+ Injector injector, ELParser parser) {
this.compositeInterface = compositeInterface;
this.attributes = attributes;
- this.visitorFactoryImpl = factory;
- this.classLoader = factory.classLoader;
- this.log = factory.log;
- this.attributesSchema = factory.attributesSchema;
+ this.injector = injector;
+ this.parser = parser;
+ this.log = log;
}
private void initializeJavaClass() {
@@ -185,6 +201,10 @@
this.createMethodContext();
}
+ private <T extends TemplateStatement> T createStatement(Class<T>
statementClass) {
+ return this.injector.getInstance(statementClass);
+ }
+
private void addHelperMethod(HelperMethod helperMethod) {
if (addedHelperMethods.add(helperMethod)) {
HelperMethodBodyStatement methodBodyStatement =
HELPER_METHOD_BODIES.get(helperMethod);
@@ -206,9 +226,7 @@
helperJavaMethod.addModifier(JavaModifier.STATIC);
helperJavaMethod.addModifier(JavaModifier.FINAL);
- MethodBody helperJavaMethodBody = new MethodBody(helperJavaMethod);
- helperJavaMethod.setMethodBody(helperJavaMethodBody);
- helperJavaMethodBody.addStatement(methodBodyStatement);
+ helperJavaMethod.setMethodBody(methodBodyStatement);
generatedClass.addMethod(helperJavaMethod);
}
@@ -217,7 +235,7 @@
private String compileEl(String expression, Class<?> type) {
try {
ELVisitor elVisitor = new ELVisitor();
- elVisitor.parse(expression, currentStatement, TypesFactory.getType(type));
+ elVisitor.parse(expression, currentStatement,
TypesFactoryImpl.getType(type));
lastCompiledExpressionType = elVisitor.getExpressionType();
String parsedExpression = elVisitor.getParsedExpression();
@@ -246,14 +264,14 @@
return false;
}
- private Type createTypeOfKnownClass(JavaClass initialClass, Class<?>
knownSuperClass) {
+ private ELType createTypeOfKnownClass(JavaClass initialClass, Class<?>
knownSuperClass) {
assert !knownSuperClass.isInterface();
- Type result = null;
+ ELType result = null;
JavaClass javaClass = initialClass;
while (javaClass != null) {
- Type type = TypesFactory.getType(javaClass.getName(), classLoader);
+ ELType type = TypesFactoryImpl.getType(javaClass.getName(), parser);
if (knownSuperClass.isAssignableFrom(type.getRawType())) {
result = type;
break;
@@ -263,7 +281,7 @@
}
if (result == null) {
- result = TypesFactory.getType(knownSuperClass);
+ result = TypesFactoryImpl.getType(knownSuperClass);
}
return result;
@@ -350,31 +368,25 @@
fieldValue.append("))");
- passThroughField.setValue(fieldValue.toString());
+ passThroughField.setValue(new StatementImpl(fieldValue.toString()));
generatedClass.addField(passThroughField);
return fieldName;
}
- private void addRendererUtilsImport() {
- if (!Strings.isEmpty(this.visitorFactoryImpl.rendererUtilsClassName)) {
- generatedClass.addImport("static " +
this.visitorFactoryImpl.rendererUtilsClassName + ".*");
- }
- }
-
private void createMethodContext() {
- this.currentStatement = new MethodBody();
- currentStatement.setVariable(FACES_CONTEXT_VARIABLE,
TypesFactory.getType(FacesContext.class));
- currentStatement.setVariable(RESPONSE_WRITER_VARIABLE,
TypesFactory.getType(ResponseWriter.class));
- currentStatement.setVariable(CLIENT_ID_VARIABLE,
TypesFactory.getType(String.class));
+ 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));
// TODO: try load component class
- currentStatement.setVariable(COMPONENT_VARIABLE,
TypesFactory.getType(UIComponent.class));
+ currentStatement.setVariable(COMPONENT_VARIABLE,
TypesFactoryImpl.getType(UIComponent.class));
- Type generatedClassType = createTypeOfKnownClass(generatedClass,
Renderer.class);
+ ELType generatedClassType = createTypeOfKnownClass(generatedClass,
Renderer.class);
currentStatement.setVariable(THIS_VARIABLE, generatedClassType);
- Type generatedClassSuperType =
createTypeOfKnownClass(generatedClass.getSuperClass(), Renderer.class);
+ ELType generatedClassSuperType =
createTypeOfKnownClass(generatedClass.getSuperClass(), Renderer.class);
currentStatement.setVariable(SUPER_VARIABLE, generatedClassSuperType);
}
@@ -387,24 +399,30 @@
javaMethod.addModifier(JavaModifier.PUBLIC);
javaMethod.addAnnotation(Override.class);
javaMethod.getExceptions().add(IOException.class);
+ currentStatement.addStatement(0, new EncodeMethodPrefaceStatement());
- MethodBody methodBody = (MethodBody) currentStatement;
- javaMethod.setMethodBody(methodBody);
+ javaMethod.setMethodBody(currentStatement);
- methodBody.addStatement(0, new EncodeMethodPrefaceStatement());
generatedClass.addMethod(javaMethod);
- Collection<Class<?>> importsList =
currentStatement.getImports();
- if (importsList != null) {
- for (Class<?> importedClass : importsList) {
- generatedClass.addImport(importedClass);
+ Iterable<ELType> importsList = currentStatement.getRequiredImports();
+ for (ELType importedClass : importsList) {
+ generatedClass.addImport(importedClass.getRawType());
+ for (Class<?> classToImport : importedClass.getImportsList()) {
+ generatedClass.addImport(classToImport);
}
}
+ for (HelperMethod helper : currentStatement.getRequiredMethods()) {
+ addHelperMethod(helper);
+ }
+ for(JavaField field : currentStatement.getRequiredFields()){
+ generatedClass.addField(field);
+ }
}
createMethodContext();
}
- private void defineObject(Type type, String name, String initializationExpression) {
+ private void defineObject(ELType type, String name, String initializationExpression)
{
addStatement(new DefineObjectStatement(type, name, initializationExpression));
currentStatement.setVariable(name, type);
}
@@ -416,17 +434,15 @@
rendersChildrenMethod.addModifier(JavaModifier.PUBLIC);
rendersChildrenMethod.addAnnotation(Override.class);
- MethodBody methodBody = new MethodBody();
- rendersChildrenMethod.setMethodBody(methodBody);
+ rendersChildrenMethod.setMethodBody(new
ConstantReturnMethodBodyStatement(Boolean
+ .toString(compositeInterface.getRendersChildren())));
generatedClass.addMethod(rendersChildrenMethod);
- methodBody.addStatement(new
ConstantReturnMethodBodyStatement(Boolean.toString(compositeInterface
- .getRendersChildren())));
}
}
- protected void pushStatement(MethodBodyStatementsContainer container) {
+ protected void pushStatement(StatementsContainer container) {
addStatement(container);
currentStatement = container;
}
@@ -435,7 +451,7 @@
currentStatement = currentStatement.getParent();
}
- protected void addStatement(MethodBodyStatement statement) {
+ protected void addStatement(JavaStatement statement) {
// TODO - add imports, fields and helper methods required by statement.
addStatement(statement);
}
@@ -519,8 +535,8 @@
String attributeLocalName = attributeName.getLocalPart();
if (writtenAttributes.add(attributeLocalName)) {
addRendererUtilsImport();
- addStatement(new WriteAttributeStatement(attributeLocalName,
compileEl(attributeValue
- .toString(), Object.class)));
+ addStatement(new WriteAttributeStatement(attributeLocalName,
compileEl(
+ attributeValue.toString(), Object.class)));
}
}
}
@@ -529,8 +545,8 @@
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());
+ TreeMap<String, Attribute> actualAttributesMap = new
TreeMap<String, Attribute>(
+ attributesElement.getAttributes());
if (passThroughExclusions != null) {
for (String passThroughExclusion : passThroughExclusions) {
@@ -595,7 +611,7 @@
expression = cdkCallElement.getBodyValue();
}
- addStatement(new MethodBodyStatementImpl(expression + ";"));
+ addStatement(new StatementImpl(expression + ";"));
}
/*
@@ -723,9 +739,9 @@
typeString += "<" + typeArgumentsString + ">";
}
- Type type = null;
+ ELType type = null;
if (!Strings.isEmpty(typeString)) {
- type = TypesFactory.getType(typeString, classLoader);
+ type = TypesFactoryImpl.getType(typeString, parser);
}
if (!Strings.isEmpty(value)) {
@@ -743,7 +759,7 @@
}
if (type == null) {
- type = TypesFactory.getType(Object.class);
+ type = TypesFactory.OBJECT_TYPE;
}
defineObject(type, name, value);
@@ -767,8 +783,8 @@
collectionElementClass = Object.class;
}
- pushStatement(new ForEachStatement(itemsExpression, cdkForEachElement.getVar(),
collectionElementClass
- .getName()));
+ pushStatement(new ForEachStatement(itemsExpression, cdkForEachElement.getVar(),
+ collectionElementClass.getName()));
currentStatement.setVariable(cdkForEachElement.getVar(),
lastCompiledExpressionType.getContainerType());
}
@@ -801,7 +817,7 @@
}
public static void clearCaches() {
- TypesFactory.clearCaches();
+ TypesFactoryImpl.clearCaches();
ELParserUtils.clearCaches();
}
}
Deleted:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/StartElementStatement.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/StartElementStatement.java 2010-06-24
14:18:53 UTC (rev 17668)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/StartElementStatement.java 2010-06-25
00:01:41 UTC (rev 17669)
@@ -1,48 +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;
-
-/**
- * @author Nick Belaevski
- * @since 4.0
- */
-public class StartElementStatement extends BaseTemplateMethodBodyStatement {
-
- private String elementName;
-
- public StartElementStatement(String elementName) {
- this("start-element", elementName);
- }
-
- 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/TemplateModule.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/TemplateModule.java 2010-06-24
14:18:53 UTC (rev 17668)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/TemplateModule.java 2010-06-25
00:01:41 UTC (rev 17669)
@@ -25,11 +25,17 @@
import org.richfaces.cdk.CdkWriter;
import org.richfaces.cdk.ModelBuilder;
+import org.richfaces.cdk.attributes.Schema;
+import org.richfaces.cdk.templatecompiler.el.ELParserImpl;
+import org.richfaces.cdk.templatecompiler.el.types.TypesFactory;
+import org.richfaces.cdk.templatecompiler.el.types.TypesFactoryImpl;
+import org.richfaces.cdk.templatecompiler.model.Template;
import com.google.inject.AbstractModule;
import com.google.inject.Singleton;
import com.google.inject.TypeLiteral;
import com.google.inject.multibindings.Multibinder;
+import com.google.inject.name.Names;
/**
* <p class="changed_added_4_0"></p>
@@ -48,6 +54,9 @@
Multibinder.newSetBinder(binder(),
CdkWriter.class).addBinding().to(RendererClassGenerator.class);
bind(new
TypeLiteral<TemplateVisitorFactory<RendererClassVisitor>>(){}).to(VisitorFactoryImpl.class).in(Singleton.class);
bind(FreeMarkerRenderer.class).to(JavaClassConfiguration.class);
+ bind(TypesFactory.class).to(TypesFactoryImpl.class);
+ bind(ELParser.class).to(ELParserImpl.class);
+
bind(Schema.class).annotatedWith(Names.named(Template.XHTML_EL_NAMESPACE)).toProvider(XhtmlElSchemaProvider.class).in(Singleton.class);
}
}
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-24
14:18:53 UTC (rev 17668)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/VisitorFactoryImpl.java 2010-06-25
00:01:41 UTC (rev 17669)
@@ -25,19 +25,12 @@
import java.util.Collection;
-import org.richfaces.cdk.CdkClassLoader;
-import org.richfaces.cdk.Generator;
import org.richfaces.cdk.Logger;
-import org.richfaces.cdk.attributes.Schema;
-import org.richfaces.cdk.attributes.SchemaSet;
import org.richfaces.cdk.model.PropertyBase;
import org.richfaces.cdk.templatecompiler.model.CompositeInterface;
-import org.richfaces.cdk.templatecompiler.model.Template;
-import org.richfaces.cdk.xmlconfig.JAXB;
import com.google.inject.Inject;
-import com.google.inject.internal.Nullable;
-import com.google.inject.name.Named;
+import com.google.inject.Injector;
/**
* <p class="changed_added_4_0"></p>
@@ -46,10 +39,9 @@
*/
public class VisitorFactoryImpl implements
TemplateVisitorFactory<RendererClassVisitor> {
- final CdkClassLoader classLoader;
+ final ELParser parser;
final Logger log;
- final Schema attributesSchema;
- final String rendererUtilsClassName;
+ final Injector injector;
/**
* <p class="changed_added_4_0"></p>
@@ -58,12 +50,10 @@
* @param log
*/
@Inject
- public VisitorFactoryImpl(CdkClassLoader classLoader, JAXB jaxbBinding, Logger
log,(a)Named(Generator.RENDERER_UTILS_CLASS) @Nullable String rendererUtilsClassName) {
- this.classLoader = classLoader;
+ public VisitorFactoryImpl(ELParser parser, Logger log, Injector injector) {
+ this.parser = parser;
this.log = log;
- SchemaSet schemaSet =
jaxbBinding.unmarshal("urn:attributes:xhtml-el.xml", null, SchemaSet.class);
- this.attributesSchema = schemaSet.getSchemas().get(Template.XHTML_EL_NAMESPACE);
- this.rendererUtilsClassName = rendererUtilsClassName;
+ this.injector = injector;
}
/* (non-Javadoc)
@@ -71,7 +61,7 @@
*/
@Override
public RendererClassVisitor createVisitor(CompositeInterface composite,
Collection<PropertyBase> attributes) {
- return new RendererClassVisitor(composite, attributes, this);
+ return new RendererClassVisitor(composite, attributes, log,injector,parser);
}
}
Deleted:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/WriteAttributeStatement.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/WriteAttributeStatement.java 2010-06-24
14:18:53 UTC (rev 17668)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/WriteAttributeStatement.java 2010-06-25
00:01:41 UTC (rev 17669)
@@ -1,47 +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;
-
-/**
- * @author Nick Belaevski
- */
-public class WriteAttributeStatement extends BaseTemplateMethodBodyStatement {
-
- private String attributeName;
-
- private String valueExpression;
-
- public WriteAttributeStatement(String attributeName, String valueExpression) {
- super("write-attribute");
- this.attributeName = attributeName;
- this.valueExpression = valueExpression;
- }
-
- public String getAttributeName() {
- return attributeName;
- }
-
- public String getValueExpression() {
- return valueExpression;
- }
-
-}
Deleted:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/WriteAttributesSetStatement.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/WriteAttributesSetStatement.java 2010-06-24
14:18:53 UTC (rev 17668)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/WriteAttributesSetStatement.java 2010-06-25
00:01:41 UTC (rev 17669)
@@ -1,44 +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;
-
-
-/**
- * @author Nick Belaevski
- */
-public class WriteAttributesSetStatement extends BaseTemplateMethodBodyStatement {
-
- private String passThroughFieldName;
-
- public WriteAttributesSetStatement(String passThroughFieldName) {
- super("write-attributes-set");
- this.passThroughFieldName = passThroughFieldName;
- }
-
- /**
- * @return the passThroughFieldName
- */
- public String getPassThroughFieldName() {
- return passThroughFieldName;
- }
-
-}
Deleted:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/WriteTextStatement.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/WriteTextStatement.java 2010-06-24
14:18:53 UTC (rev 17668)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/WriteTextStatement.java 2010-06-25
00:01:41 UTC (rev 17669)
@@ -1,40 +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;
-
-/**
- * @author Nick Belaevski
- */
-public class WriteTextStatement extends BaseTemplateMethodBodyStatement {
-
- private String textExpression;
-
- public WriteTextStatement(String textExpression) {
- super("write-text");
- this.textExpression = textExpression;
- }
-
- public String getTextExpression() {
- return textExpression;
- }
-
-}
Added:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/XhtmlElSchemaProvider.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/XhtmlElSchemaProvider.java
(rev 0)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/XhtmlElSchemaProvider.java 2010-06-25
00:01:41 UTC (rev 17669)
@@ -0,0 +1,33 @@
+/**
+ *
+ */
+package org.richfaces.cdk.templatecompiler;
+
+import org.richfaces.cdk.attributes.Schema;
+import org.richfaces.cdk.attributes.SchemaSet;
+import org.richfaces.cdk.templatecompiler.model.Template;
+import org.richfaces.cdk.xmlconfig.JAXB;
+
+import com.google.inject.Inject;
+import com.google.inject.Provider;
+
+/**
+ * @author asmirnov
+ *
+ */
+public class XhtmlElSchemaProvider implements Provider<Schema> {
+
+ private final JAXB jaxbBinding;
+
+ @Inject
+ public XhtmlElSchemaProvider(JAXB jaxbBinding) {
+ this.jaxbBinding = jaxbBinding;
+ }
+
+ @Override
+ public Schema get() {
+ SchemaSet schemaSet =
jaxbBinding.unmarshal("urn:attributes:xhtml-el.xml", null, SchemaSet.class);
+ return schemaSet.getSchemas().get(Template.XHTML_EL_NAMESPACE);
+ }
+
+}
Property changes on:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/XhtmlElSchemaProvider.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/JavaClass.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/JavaClass.java 2010-06-24
14:18:53 UTC (rev 17668)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/JavaClass.java 2010-06-25
00:01:41 UTC (rev 17669)
@@ -170,15 +170,6 @@
}
}
- MethodBody methodBody = method.getMethodBody();
-
- if (methodBody != null) {
- Set<Class<?>> usedClasses = methodBody.getUsedClasses();
-
- for (Class<?> class1 : usedClasses) {
- addImport(class1);
- }
- }
}
public JavaPackage getPakg() {
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/JavaField.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/JavaField.java 2010-06-24
14:18:53 UTC (rev 17668)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/JavaField.java 2010-06-25
00:01:41 UTC (rev 17669)
@@ -30,7 +30,7 @@
public class JavaField extends JavaLanguageElement {
private JavaClass type;
- private Object value;
+ private JavaStatement value;
private JavaClass[] genericArguments;
@@ -42,11 +42,11 @@
this(type, name, null);
}
- public JavaField(Class<?> type, String name, Object value) {
+ public JavaField(Class<?> type, String name, JavaStatement value) {
this(new JavaClass(type), name, value);
}
- public JavaField(JavaClass type, String name, Object value) {
+ public JavaField(JavaClass type, String name, JavaStatement value) {
super(name);
this.type = type;
this.value = value;
@@ -56,11 +56,11 @@
return type;
}
- public Object getValue() {
+ public JavaStatement getValue() {
return value;
}
- public void setValue(Object value) {
+ public void setValue(JavaStatement value) {
this.value = value;
}
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/JavaMethod.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/JavaMethod.java 2010-06-24
14:18:53 UTC (rev 17668)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/JavaMethod.java 2010-06-25
00:01:41 UTC (rev 17669)
@@ -31,7 +31,7 @@
public class JavaMethod extends JavaLanguageElement {
private List<Argument> arguments = new ArrayList<Argument>();
private List<Class<? extends Throwable>> exceptions = new
ArrayList<Class<? extends Throwable>>();
- private MethodBody methodBody;
+ private JavaStatement methodBody;
private JavaClass returnType;
public JavaMethod(String name) {
@@ -63,7 +63,7 @@
return arguments;
}
- public MethodBody getMethodBody() {
+ public JavaStatement getMethodBody() {
return methodBody;
}
@@ -71,11 +71,7 @@
return returnType;
}
- public void setMethodBody(MethodBody methodBody) {
+ public void setMethodBody(JavaStatement methodBody) {
this.methodBody = methodBody;
-
- if (methodBody != null) {
- methodBody.setMethod(this);
- }
}
}
Copied:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/JavaStatement.java
(from rev 17668,
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/MethodBodyStatement.java)
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/JavaStatement.java
(rev 0)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/JavaStatement.java 2010-06-25
00:01:41 UTC (rev 17669)
@@ -0,0 +1,32 @@
+/*
+ * 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.builder.model;
+
+
+/**
+ * @author Nick Belaevski
+ */
+public interface JavaStatement {
+
+ public String getCode();
+
+}
Property changes on:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/JavaStatement.java
___________________________________________________________________
Name: svn:keywords
+ LastChangedDate LastChangedRevision LastChangedBy HeadURL Id
Deleted:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/MethodBody.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/MethodBody.java 2010-06-24
14:18:53 UTC (rev 17668)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/MethodBody.java 2010-06-25
00:01:41 UTC (rev 17669)
@@ -1,59 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.cdk.templatecompiler.builder.model;
-
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * @author Maksim Kaszynski
- * @author Nick Belaevski
- */
-public class MethodBody extends MethodBodyStatementsContainer {
- private Set<Class<?>> usedClasses = new HashSet<Class<?>>();
- private JavaMethod method;
-
- public MethodBody() {
- }
-
- public MethodBody(JavaMethod method) {
- super();
- this.method = method;
- }
-
- protected JavaMethod getMethod() {
- return method;
- }
-
- protected void setMethod(JavaMethod method) {
- this.method = method;
- }
-
- public void addType(Class<?> clazz) {
- usedClasses.add(clazz);
- }
-
- public Set<Class<?>> getUsedClasses() {
- return usedClasses;
- }
-
-}
Deleted:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/MethodBodyStatement.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/MethodBodyStatement.java 2010-06-24
14:18:53 UTC (rev 17668)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/MethodBodyStatement.java 2010-06-25
00:01:41 UTC (rev 17669)
@@ -1,33 +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.builder.model;
-
-import org.richfaces.cdk.templatecompiler.FreeMarkerRenderer;
-
-/**
- * @author Nick Belaevski
- */
-public interface MethodBodyStatement {
-
- public String getCode(FreeMarkerRenderer renderer);
-
-}
Deleted:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/MethodBodyStatementImpl.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/MethodBodyStatementImpl.java 2010-06-24
14:18:53 UTC (rev 17668)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/MethodBodyStatementImpl.java 2010-06-25
00:01:41 UTC (rev 17669)
@@ -1,43 +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.builder.model;
-
-import org.richfaces.cdk.templatecompiler.FreeMarkerRenderer;
-
-/**
- * @author Nick Belaevski
- */
-public class MethodBodyStatementImpl implements MethodBodyStatement {
-
- private String code;
-
- public MethodBodyStatementImpl(String code) {
- super();
- this.code = code;
- }
-
- @Override
- public String getCode(FreeMarkerRenderer renderer) {
- return code;
- }
-
-}
Deleted:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/MethodBodyStatementsContainer.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/MethodBodyStatementsContainer.java 2010-06-24
14:18:53 UTC (rev 17668)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/MethodBodyStatementsContainer.java 2010-06-25
00:01:41 UTC (rev 17669)
@@ -1,132 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.cdk.templatecompiler.builder.model;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-
-import org.richfaces.cdk.templatecompiler.FreeMarkerRenderer;
-import org.richfaces.cdk.templatecompiler.el.Type;
-
-import com.google.common.collect.Maps;
-
-/**
- * @author Nick Belaevski
- * @since 4.0
- */
-public class MethodBodyStatementsContainer implements MethodBodyStatement, Variables {
-
- private List<MethodBodyStatement> statements = new
ArrayList<MethodBodyStatement>();
-
- private MethodBodyStatementsContainer parent;
-
- private final Map<String, Type> localVariablesMap = Maps.newHashMap();
-
-
- public List<MethodBodyStatement> getStatements() {
- return statements;
- }
-
- public void addStatement(MethodBodyStatement statement) {
- setParent(statement);
- statements.add(statement);
- }
-
- public void addStatement(int index,MethodBodyStatement statement) {
- setParent(statement);
- statements.add(index,statement);
- }
-
- private void setParent(MethodBodyStatement statement) {
- if (statement instanceof MethodBodyStatementsContainer) {
- MethodBodyStatementsContainer container = (MethodBodyStatementsContainer)
statement;
- container.setParent(this);
- }
- }
-
-
- /**
- * <p class="changed_added_4_0"></p>
- * @param parent the parent to set
- */
- public void setParent(MethodBodyStatementsContainer parent) {
- this.parent = parent;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @return the parent
- */
- public MethodBodyStatementsContainer getParent() {
- return parent;
- }
-
- public boolean isEmpty() {
- return statements.isEmpty();
- }
-
- /* (non-Javadoc)
- * @see
org.richfaces.cdk.templatecompiler.builder.model.MethodBodyStatement#getCode()
- */
- @Override
- public String getCode(FreeMarkerRenderer renderer) {
- StringBuilder sb = new StringBuilder();
- for (MethodBodyStatement statement : statements) {
- sb.append(statement.getCode(renderer));
- sb.append('\n');
- }
-
- return sb.toString();
- }
-
- @Override
- public Type getVariable(String name) {
- Type type = localVariablesMap.get(name);
- if(null == type && null != parent){
- type = parent.getVariable(name);
- }
- return type;
- }
-
- @Override
- public boolean isDefined(String name) {
- boolean defined = localVariablesMap.containsKey(name);
- if(!defined && null != parent){
- defined = parent.isDefined(name);
- }
- return defined;
- }
-
- @Override
- public Type setVariable(String name, Type type) {
- Type variable = getVariable(name);
- localVariablesMap.put(name, type);
- return variable;
- }
-
- public Collection<Class<?>> getImports() {
- // TODO Auto-generated method stub
- return null;
- }
-}
Copied:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/StatementImpl.java
(from rev 17668,
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/MethodBodyStatementImpl.java)
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/StatementImpl.java
(rev 0)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/StatementImpl.java 2010-06-25
00:01:41 UTC (rev 17669)
@@ -0,0 +1,42 @@
+/*
+ * 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.builder.model;
+
+
+/**
+ * @author Nick Belaevski
+ */
+public class StatementImpl implements JavaStatement {
+
+ private String code;
+
+ public StatementImpl(String code) {
+ super();
+ this.code = code;
+ }
+
+ @Override
+ public String getCode() {
+ return code;
+ }
+
+}
Property changes on:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/StatementImpl.java
___________________________________________________________________
Name: svn:keywords
+ LastChangedDate LastChangedRevision LastChangedBy HeadURL Id
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/Variables.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/Variables.java 2010-06-24
14:18:53 UTC (rev 17668)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/Variables.java 2010-06-25
00:01:41 UTC (rev 17669)
@@ -1,14 +1,14 @@
package org.richfaces.cdk.templatecompiler.builder.model;
import org.richfaces.cdk.templatecompiler.el.ParsingException;
-import org.richfaces.cdk.templatecompiler.el.Type;
+import org.richfaces.cdk.templatecompiler.el.ELType;
public interface Variables {
- public Type getVariable(String name) throws ParsingException;
+ public ELType getVariable(String name) throws ParsingException;
public boolean isDefined(String name) throws ParsingException;
- public Type setVariable(String name, Type type) throws ParsingException;
+ public ELType setVariable(String name, ELType type) throws ParsingException;
}
Added:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/ELParserImpl.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/ELParserImpl.java
(rev 0)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/ELParserImpl.java 2010-06-25
00:01:41 UTC (rev 17669)
@@ -0,0 +1,66 @@
+/**
+ *
+ */
+package org.richfaces.cdk.templatecompiler.el;
+
+import org.richfaces.cdk.Logger;
+import org.richfaces.cdk.model.ClassName;
+import org.richfaces.cdk.templatecompiler.ELParser;
+import org.richfaces.cdk.templatecompiler.builder.model.Variables;
+import org.richfaces.cdk.templatecompiler.el.types.TypesFactory;
+import org.richfaces.cdk.templatecompiler.statements.TemplateStatement;
+
+import com.google.inject.Inject;
+
+/**
+ * @author asmirnov
+ *
+ */
+public class ELParserImpl implements ELParser {
+
+ private final TypesFactory typesFactory;
+ private final Logger log;
+ private final ELParserUtils utils;
+
+ @Inject
+ public ELParserImpl(TypesFactory typesFactory, ELParserUtils utils, Logger log) {
+ this.typesFactory = typesFactory;
+ this.utils = utils;
+ this.log = log;
+ }
+
+ /* (non-Javadoc)
+ * @see org.richfaces.cdk.templatecompiler.ELParser#parse(java.lang.String,
org.richfaces.cdk.templatecompiler.builder.model.Variables,
org.richfaces.cdk.templatecompiler.el.ELType)
+ */
+ @Override
+ public TemplateStatement parse(String expression, Variables variables, ELType
expectedType) throws ParsingException {
+ ELVisitor visitor = new ELVisitor(log,typesFactory,utils);
+ visitor.parse(expression, variables, expectedType);
+ return visitor;
+ }
+
+ /* (non-Javadoc)
+ * @see org.richfaces.cdk.templatecompiler.ELParser#getType(java.lang.Class)
+ */
+ @Override
+ public ELType getType(Class<?> targetClass) {
+ return typesFactory.getType(targetClass);
+ }
+
+ /* (non-Javadoc)
+ * @see org.richfaces.cdk.templatecompiler.ELParser#getType(java.lang.String)
+ */
+ @Override
+ public ELType getType(String classExpression) {
+ return typesFactory.getType(classExpression);
+ }
+
+ /* (non-Javadoc)
+ * @see
org.richfaces.cdk.templatecompiler.ELParser#getType(org.richfaces.cdk.model.ClassName)
+ */
+ @Override
+ public ELType getType(ClassName targetClass) {
+ return typesFactory.getType(targetClass.toString());
+ }
+
+}
Property changes on:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/ELParserImpl.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/ELParserUtils.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/ELParserUtils.java 2010-06-24
14:18:53 UTC (rev 17668)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/ELParserUtils.java 2010-06-25
00:01:41 UTC (rev 17669)
@@ -28,7 +28,6 @@
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
@@ -70,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.Logger;
import org.richfaces.cdk.templatecompiler.el.node.AstBracketSuffixTreeNode;
import org.richfaces.cdk.templatecompiler.el.node.AstChoiceTreeNode;
import
org.richfaces.cdk.templatecompiler.el.node.AstDeferredOrDynamicExpressionTreeNode;
@@ -94,6 +94,9 @@
import org.richfaces.cdk.templatecompiler.el.node.ITreeNode;
import org.richfaces.cdk.templatecompiler.el.types.TypesFactory;
+import com.google.inject.Inject;
+import com.google.inject.internal.Maps;
+
/**
* Class, that encapsulate all functionality, related to Reflection calls, such as
loading classes, get property
* descriptors etc...
@@ -149,13 +152,18 @@
}
}
- private static Map<Class<?>, ClassDataHolder> classDataCache =
Collections
- .synchronizedMap(new HashMap<Class<?>, ClassDataHolder>());
+ private final Map<Class<?>, ClassDataHolder> classDataCache =
Maps.newHashMap();
- private ELParserUtils() {
+ private final TypesFactory typesFactory;
+ private final Logger log;
+
+ @Inject
+ public ELParserUtils(Logger log, TypesFactory typesFactory) {
+ this.log = log;
+ this.typesFactory = typesFactory;
}
- private static ClassDataHolder resolveClassPropertiesAndMethods(Class<?>
initialClass) throws ParsingException {
+ private ClassDataHolder resolveClassPropertiesAndMethods(Class<?> initialClass)
throws ParsingException {
ClassDataHolder classDataHolder = classDataCache.get(initialClass);
if (classDataHolder == null) {
classDataHolder = new ClassDataHolder();
@@ -260,7 +268,7 @@
* @throws ParsingException
* if error occured.
*/
- public static PropertyDescriptor getPropertyDescriptor(Class<?> clazz, String
propertyName) throws ParsingException {
+ public PropertyDescriptor getPropertyDescriptor(Class<?> clazz, String
propertyName) throws ParsingException {
if (clazz == null) {
return null;
@@ -346,11 +354,11 @@
* @throws ParsingException
* if error occured.
*/
- public static Type getMatchingVisibleMethodReturnType(Class<?> clazz, final
String methodName, Type[] parameterTypes)
+ public ELType getMatchingVisibleMethodReturnType(Class<?> clazz, final String
methodName, ELType[] parameterTypes)
throws ParsingException {
if (clazz == null) {
- return TypesFactory.getType(Object.class);
+ return TypesFactory.OBJECT_TYPE;
}
ClassDataHolder classDataHolder = resolveClassPropertiesAndMethods(clazz);
@@ -370,7 +378,7 @@
}
// compare parameters
- Type[] methodsParams =
TypesFactory.getTypesArray(resolvedMethod.getParameterTypes());
+ ELType[] methodsParams =
typesFactory.getTypesArray(resolvedMethod.getParameterTypes());
int methodParamSize = methodsParams.length;
if (methodParamSize == paramSize) {
@@ -397,9 +405,9 @@
}
if (bestMatch != null) {
- return TypesFactory.getType(bestMatch.getGenericReturnType());
+ return typesFactory.getType(bestMatch.getGenericReturnType());
} else {
- return TypesFactory.getType(Object.class);
+ return TypesFactory.OBJECT_TYPE;
}
}
@@ -457,22 +465,5 @@
}
}
- public static void clearCaches() {
- classDataCache.clear();
- }
- public static String coerceToType(String valueString, ELVisitor visitor, Type
expectedType) {
- if (!expectedType.isAssignableFrom(visitor.getExpressionType())) {
- for (HelperMethod conversionMethod : HelperMethod.getConversionMethods()) {
- Type returnType =
TypesFactory.getType(conversionMethod.getReturnType());
- if (expectedType.isAssignableFrom(returnType)) {
- visitor.getUsedHelperMethods().add(conversionMethod);
- visitor.setExpressionType(returnType);
- return conversionMethod.getName() + "(" + valueString +
")";
- }
- }
- }
-
- return valueString;
- }
}
Copied:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/ELType.java
(from rev 17668,
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/Type.java)
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/ELType.java
(rev 0)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/ELType.java 2010-06-25
00:01:41 UTC (rev 17669)
@@ -0,0 +1,48 @@
+/*
+ * 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.el;
+
+import java.util.Collection;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+//TODO unit-test thoroughly all implementations of this interface
+public interface ELType {
+
+ public String getCode();
+
+ public Collection<Class<?>> getImportsList();
+
+ public boolean isNullType();
+
+ public boolean isArray();
+
+ public Class<?> getRawType();
+
+ public ELType getContainerType();
+
+ public ELType[] getTypeArguments();
+
+ public boolean isAssignableFrom(ELType anotherType);
+}
Property changes on:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/ELType.java
___________________________________________________________________
Name: svn:keywords
+ LastChangedDate LastChangedRevision LastChangedBy HeadURL Id
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-24
14:18:53 UTC (rev 17668)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/ELVisitor.java 2010-06-25
00:01:41 UTC (rev 17669)
@@ -21,69 +21,83 @@
package org.richfaces.cdk.templatecompiler.el;
-import static org.richfaces.cdk.templatecompiler.el.HelperMethod.*;
-import static org.richfaces.cdk.util.JavaUtils.*;
+import static org.richfaces.cdk.templatecompiler.el.HelperMethod.TO_STRING_CONVERSION;
+import static org.richfaces.cdk.util.JavaUtils.getEscapedString;
+import java.beans.PropertyDescriptor;
+import java.lang.reflect.Type;
import java.text.MessageFormat;
+import java.util.Collections;
import java.util.EnumSet;
import java.util.Set;
import org.jboss.el.parser.AstCompositeExpression;
import org.jboss.el.parser.ELParser;
import org.jboss.el.parser.Node;
+import org.richfaces.cdk.Logger;
+import org.richfaces.cdk.templatecompiler.builder.model.JavaField;
import org.richfaces.cdk.templatecompiler.builder.model.Variables;
import org.richfaces.cdk.templatecompiler.el.node.ITreeNode;
import org.richfaces.cdk.templatecompiler.el.types.TypesFactory;
+import org.richfaces.cdk.templatecompiler.statements.TemplateStatement;
/**
* Entry point for parsing EL expressions. @see parse() method.
*
* @author amarkhel
*/
-public final class ELVisitor {
+public final class ELVisitor implements TemplateStatement {
private String parsedExpression = null;
- private Type expressionType = null;
+ private ELType expressionType = null;
private Variables variables = null;
- private Set<HelperMethod> usedHelperMethods =
EnumSet.noneOf(HelperMethod.class);
+ private Set<HelperMethod> usedHelperMethods =
EnumSet.noneOf(HelperMethod.class);
- private Set<HelperMethod> usedConversionMethods =
EnumSet.noneOf(HelperMethod.class);
+ private final Logger log;
- public Type getExpressionType() {
+ private final TypesFactory typesFactory;
+
+ private final ELParserUtils utils;
+
+ private boolean mixedExpression;
+
+
+ public ELVisitor(Logger log, TypesFactory typesFactory, ELParserUtils utils) {
+ this.log = log;
+ this.typesFactory = typesFactory;
+ this.utils = utils;
+ }
+
+
+ public boolean isMixedExpression() {
+ return mixedExpression;
+ }
+
+
+ public ELType getExpressionType() {
return expressionType;
}
- public void setExpressionType(Type variableType) {
+ public void setExpressionType(ELType variableType) {
this.expressionType = variableType;
}
- public Type getVariable(String name) throws ParsingException {
- Type variableType = variables.getVariable(name);
- if (variableType == null) {
- throw new ParsingException(MessageFormat.format(
+ public ELType getVariable(String name) throws ParsingException {
+ ELType variableType;
+ if(variables.isDefined(name)){
+ variableType = variables.getVariable(name);
+ } else {
+ log.warn(MessageFormat.format(
"No type found in context for identifier ''{0}'',
handling as generic Object", name));
+ variableType = TypesFactory.OBJECT_TYPE;
}
return variableType;
}
/**
- * @return the uses
- */
- public Set<HelperMethod> getUsedHelperMethods() {
- return usedHelperMethods;
- }
-
- /**
- * @return the parsedExpression
- */
- public String getParsedExpression() {
- return parsedExpression;
- }
-
- /**
* Parse specified EL expression and return Java code, that represent this
expression
*
* @param expression - expression to resolve
@@ -91,7 +105,7 @@
* @return generated Java code.
* @throws ParsingException - if error occurred during parsing.
*/
- public void parse(String expression, Variables contextVariables, Type expectedType)
throws ParsingException {
+ public void parse(String expression, Variables contextVariables, ELType expectedType)
throws ParsingException {
reset();
Node ret = ELParser.parse(expression);
@@ -99,19 +113,36 @@
if (ret instanceof AstCompositeExpression && ret.jjtGetNumChildren()
>= 2) {
//AstCompositeExpression with 2+ children is a mixed expression
- getUsedHelperMethods().add(TO_STRING_CONVERSION);
+ usedHelperMethods.add(TO_STRING_CONVERSION);
+ this.mixedExpression = true;
}
if (ret != null && ret.jjtGetNumChildren() > 0) {
parsedExpression = this.visit(ret);
} else {
parsedExpression = getEscapedString("");
- expressionType = TypesFactory.getType(String.class);
+ expressionType = TypesFactory.STRING_TYPE;
}
- parsedExpression = ELParserUtils.coerceToType(parsedExpression, this,
expectedType);
+ parsedExpression = coerceToType(parsedExpression, expectedType);
}
+
+ public String coerceToType(String valueString, ELType expectedType) {
+ if (!expectedType.isAssignableFrom(getExpressionType())) {
+ for (HelperMethod conversionMethod : HelperMethod.getConversionMethods()) {
+ ELType returnType =
typesFactory.getType(conversionMethod.getReturnType());
+ if (expectedType.isAssignableFrom(returnType)) {
+ usedHelperMethods.add(conversionMethod);
+ setExpressionType(returnType);
+ return conversionMethod.getName() + "(" + valueString +
")";
+ }
+ }
+ }
+
+ return valueString;
+ }
+
private String visit(Node node) throws ParsingException {
int numChildren = node.jjtGetNumChildren();
StringBuilder sb = new StringBuilder();
@@ -138,4 +169,45 @@
expressionType = null;
}
+ @Override
+ public String getCode() {
+ return parsedExpression;
+ }
+
+ @Override
+ public Iterable<ELType> getRequiredImports() {
+ return Collections.singleton(getExpressionType());
+ }
+
+ @Override
+ public Iterable<JavaField> getRequiredFields() {
+ return Collections.emptySet();
+ }
+
+ @Override
+ public Iterable<HelperMethod> getRequiredMethods() {
+ return usedHelperMethods;
+ }
+
+
+ public ELType getMatchingVisibleMethodReturnType(String methodName, ELType[]
parameterTypes) throws ParsingException {
+
+ return utils.getMatchingVisibleMethodReturnType(getExpressionType().getRawType(),
methodName, parameterTypes);
+ }
+
+
+ public PropertyDescriptor getPropertyDescriptor(String propertyName) throws
ParsingException {
+ return utils.getPropertyDescriptor(getExpressionType().getRawType(),
propertyName);
+ }
+
+
+ public ELType getType(Type genericReturnType) {
+ return typesFactory.getType(genericReturnType);
+ }
+
+
+ public void addHelperMethods(HelperMethod helper) {
+ usedHelperMethods.add(helper);
+ }
+
}
Deleted:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/Type.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/Type.java 2010-06-24
14:18:53 UTC (rev 17668)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/Type.java 2010-06-25
00:01:41 UTC (rev 17669)
@@ -1,48 +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.el;
-
-import java.util.Collection;
-
-/**
- * @author Nick Belaevski
- *
- */
-//TODO unit-test thoroughly all implementations of this interface
-public interface Type {
-
- public String getCode();
-
- public Collection<Class<?>> getImportsList();
-
- public boolean isNullType();
-
- public boolean isArray();
-
- public Class<?> getRawType();
-
- public Type getContainerType();
-
- public Type[] getTypeArguments();
-
- public boolean isAssignableFrom(Type anotherType);
-}
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AbstractBinaryOperationTreeNode.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AbstractBinaryOperationTreeNode.java 2010-06-24
14:18:53 UTC (rev 17668)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AbstractBinaryOperationTreeNode.java 2010-06-25
00:01:41 UTC (rev 17669)
@@ -25,7 +25,7 @@
import org.richfaces.cdk.templatecompiler.el.ELNodeConstants;
import org.richfaces.cdk.templatecompiler.el.ELVisitor;
import org.richfaces.cdk.templatecompiler.el.ParsingException;
-import org.richfaces.cdk.templatecompiler.el.Type;
+import org.richfaces.cdk.templatecompiler.el.ELType;
/**
* <p>
@@ -47,7 +47,7 @@
this.operatorString = operatorString;
}
- protected abstract Type getOperationType(Type firstArgumentType, Type
secondArgumentType);
+ protected abstract ELType getOperationType(ELType firstArgumentType, ELType
secondArgumentType);
protected abstract String getCoercedChildOutput(int childIndex, ELVisitor visitor)
throws ParsingException;
@@ -61,9 +61,9 @@
@Override
public void visit(StringBuilder sb, ELVisitor visitor) throws ParsingException {
String firstChildOutput = getCoercedChildOutput(0, visitor);
- Type firstChildType = visitor.getExpressionType();
+ ELType firstChildType = visitor.getExpressionType();
String secondChildOutput = getCoercedChildOutput(1, visitor);
- Type secondChildType = visitor.getExpressionType();
+ ELType secondChildType = visitor.getExpressionType();
sb.append(ELNodeConstants.LEFT_BRACKET);
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-24
14:18:53 UTC (rev 17668)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AbstractMethodTreeNode.java 2010-06-25
00:01:41 UTC (rev 17669)
@@ -26,10 +26,9 @@
import org.jboss.el.parser.Node;
import org.richfaces.cdk.templatecompiler.el.ELNodeConstants;
-import org.richfaces.cdk.templatecompiler.el.ELParserUtils;
+import org.richfaces.cdk.templatecompiler.el.ELType;
import org.richfaces.cdk.templatecompiler.el.ELVisitor;
import org.richfaces.cdk.templatecompiler.el.ParsingException;
-import org.richfaces.cdk.templatecompiler.el.Type;
import org.richfaces.cdk.templatecompiler.el.types.TypesFactory;
/**
@@ -38,7 +37,7 @@
*/
public abstract class AbstractMethodTreeNode extends AbstractTreeNode {
- private static final Type[] EMPTY_TYPES_ARRAY = new Type[0];
+ private static final ELType[] EMPTY_TYPES_ARRAY = new ELType[0];
/**
* @param node
@@ -50,8 +49,7 @@
protected void visitMethod(StringBuilder sb, ELVisitor visitor, String methodName)
throws ParsingException {
- Class<?> methodHolderClass = visitor.getExpressionType().getRawType();
- List<Type> argumentTypes = new ArrayList<Type>();
+ List<ELType> argumentTypes = new ArrayList<ELType>();
sb.append(ELNodeConstants.DOT);
sb.append(methodName);
@@ -72,14 +70,14 @@
sb.append(ELNodeConstants.RIGHT_BRACKET);
- Type returnType = null;
+ ELType returnType = null;
try {
- returnType =
ELParserUtils.getMatchingVisibleMethodReturnType(methodHolderClass, methodName,
argumentTypes
+ returnType = visitor.getMatchingVisibleMethodReturnType( methodName,
argumentTypes
.toArray(EMPTY_TYPES_ARRAY));
} catch (ParsingException e) {
// TODO: handle exception
- returnType = TypesFactory.getType(Object.class);
+ returnType = TypesFactory.OBJECT_TYPE;
}
visitor.setExpressionType(returnType);
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AbstractTreeNode.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AbstractTreeNode.java 2010-06-24
14:18:53 UTC (rev 17668)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AbstractTreeNode.java 2010-06-25
00:01:41 UTC (rev 17669)
@@ -25,7 +25,6 @@
import org.richfaces.cdk.templatecompiler.el.ELParserUtils;
import org.richfaces.cdk.templatecompiler.el.ELVisitor;
import org.richfaces.cdk.templatecompiler.el.ParsingException;
-import org.richfaces.cdk.templatecompiler.el.Type;
import org.richfaces.cdk.templatecompiler.el.types.TypesFactory;
/**
@@ -61,8 +60,7 @@
}
protected String coerceToBoolean(String value, ELVisitor visitor) {
- Type booleanType = TypesFactory.getType(Boolean.TYPE);
- return ELParserUtils.coerceToType(value, visitor, booleanType);
+ return visitor.coerceToType(value, TypesFactory.BOOLEAN_TYPE);
}
/**
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-24
14:18:53 UTC (rev 17668)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AstBracketSuffixTreeNode.java 2010-06-25
00:01:41 UTC (rev 17669)
@@ -24,9 +24,9 @@
import org.jboss.el.parser.Node;
import org.richfaces.cdk.templatecompiler.el.ELNodeConstants;
+import org.richfaces.cdk.templatecompiler.el.ELType;
import org.richfaces.cdk.templatecompiler.el.ELVisitor;
import org.richfaces.cdk.templatecompiler.el.ParsingException;
-import org.richfaces.cdk.templatecompiler.el.Type;
import org.richfaces.cdk.templatecompiler.el.types.TypesFactory;
/**
@@ -41,7 +41,7 @@
@Override
public void visit(StringBuilder sb, ELVisitor visitor) throws ParsingException {
- Type variableType = visitor.getExpressionType();
+ ELType variableType = visitor.getExpressionType();
String suffixValue = getChildOutput(0, visitor);
if (variableType.isArray()) {
@@ -56,9 +56,9 @@
sb.append(ELNodeConstants.RIGHT_BRACKET);
}
- Type containerType = variableType.getContainerType();
+ ELType containerType = variableType.getContainerType();
if (containerType == null) {
- containerType = TypesFactory.getType(Object.class);
+ containerType = TypesFactory.OBJECT_TYPE;
}
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-24
14:18:53 UTC (rev 17668)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AstChoiceTreeNode.java 2010-06-25
00:01:41 UTC (rev 17669)
@@ -28,7 +28,7 @@
import org.richfaces.cdk.templatecompiler.el.ELNodeConstants;
import org.richfaces.cdk.templatecompiler.el.ELVisitor;
import org.richfaces.cdk.templatecompiler.el.ParsingException;
-import org.richfaces.cdk.templatecompiler.el.Type;
+import org.richfaces.cdk.templatecompiler.el.ELType;
/**
* This class extend AbstractTreeNode and wrap AstChoice node.
@@ -46,9 +46,9 @@
//condition ? correctConditionBranch : incorrectConditionBranch
String condition = coerceToBoolean(getChildOutput(0, visitor), visitor);
String correctConditionBranch = getChildOutput(1, visitor);
- Type correctConditionBranchType = visitor.getExpressionType();
+ ELType correctConditionBranchType = visitor.getExpressionType();
String incorrectConditionBranch = getChildOutput(2, visitor);
- Type incorrectConditionBranchType = visitor.getExpressionType();
+ ELType incorrectConditionBranchType = visitor.getExpressionType();
sb.append(ELNodeConstants.LEFT_BRACKET);
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AstDeferredOrDynamicExpressionTreeNode.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AstDeferredOrDynamicExpressionTreeNode.java 2010-06-24
14:18:53 UTC (rev 17668)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AstDeferredOrDynamicExpressionTreeNode.java 2010-06-25
00:01:41 UTC (rev 17669)
@@ -21,8 +21,6 @@
package org.richfaces.cdk.templatecompiler.el.node;
-import static org.richfaces.cdk.templatecompiler.el.HelperMethod.*;
-
import org.jboss.el.parser.Node;
import org.richfaces.cdk.templatecompiler.el.ELNodeConstants;
import org.richfaces.cdk.templatecompiler.el.ELVisitor;
@@ -45,7 +43,7 @@
int childrenCount = getChildrenCount();
for (int i = 0; i < childrenCount; i++) {
- if (visitor.getUsedHelperMethods().contains(TO_STRING_CONVERSION)) {
+ if (visitor.isMixedExpression()) {
sb.append(ELNodeConstants.CONVERT_TO_STRING_FUNCTION);
sb.append(ELNodeConstants.LEFT_BRACKET);
}
@@ -54,9 +52,9 @@
treeNode.visit(sb, visitor);
- if (visitor.getUsedHelperMethods().contains(TO_STRING_CONVERSION)) {
+ if (visitor.isMixedExpression()) {
sb.append(ELNodeConstants.RIGHT_BRACKET);
- visitor.setExpressionType(TypesFactory.getType(String.class));
+ visitor.setExpressionType(TypesFactory.STRING_TYPE);
} /* otherwise variableType will be set in child's visit invocation */
}
}
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-24
14:18:53 UTC (rev 17668)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AstEmptyTreeNode.java 2010-06-25
00:01:41 UTC (rev 17669)
@@ -23,7 +23,7 @@
package org.richfaces.cdk.templatecompiler.el.node;
-import static org.richfaces.cdk.templatecompiler.el.HelperMethod.*;
+import static org.richfaces.cdk.templatecompiler.el.HelperMethod.EMPTINESS_CHECK;
import org.jboss.el.parser.Node;
import org.richfaces.cdk.templatecompiler.el.ELNodeConstants;
@@ -44,9 +44,9 @@
@Override
public void visit(StringBuilder sb, ELVisitor visitor) throws ParsingException {
- visitor.getUsedHelperMethods().add(EMPTINESS_CHECK);
+ visitor.addHelperMethods(EMPTINESS_CHECK);
- sb.append(ELNodeConstants.IS_EMPTY_FUNCTION);
+ sb.append(EMPTINESS_CHECK.getName());
sb.append(ELNodeConstants.LEFT_BRACKET);
String childOutput = getChildOutput(0, visitor);
@@ -54,6 +54,6 @@
sb.append(ELNodeConstants.RIGHT_BRACKET);
- visitor.setExpressionType(TypesFactory.getType(Boolean.TYPE));
+ visitor.setExpressionType(TypesFactory.BOOLEAN_TYPE);
}
}
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AstFloatingPointTreeNode.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AstFloatingPointTreeNode.java 2010-06-24
14:18:53 UTC (rev 17668)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AstFloatingPointTreeNode.java 2010-06-25
00:01:41 UTC (rev 17669)
@@ -48,6 +48,6 @@
sb.append(getNode().getImage());
sb.append(ELNodeConstants.RIGHT_BRACKET);
- visitor.setExpressionType(TypesFactory.getType(Double.TYPE));
+ visitor.setExpressionType(TypesFactory.DOUBLE_TYPE);
}
}
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-24
14:18:53 UTC (rev 17668)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AstFunctionTreeNode.java 2010-06-25
00:01:41 UTC (rev 17669)
@@ -27,7 +27,7 @@
import org.richfaces.cdk.templatecompiler.el.ELNodeConstants;
import org.richfaces.cdk.templatecompiler.el.ELVisitor;
import org.richfaces.cdk.templatecompiler.el.ParsingException;
-import org.richfaces.cdk.templatecompiler.el.Type;
+import org.richfaces.cdk.templatecompiler.el.ELType;
import org.richfaces.cdk.util.Strings;
/**
@@ -58,7 +58,7 @@
sb.append(identifierName);
- Type identifierType = visitor.getVariable(identifierName);
+ ELType identifierType = visitor.getVariable(identifierName);
visitor.setExpressionType(identifierType);
visitMethod(sb, visitor, functionName);
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-24
14:18:53 UTC (rev 17668)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AstIdentifierTreeNode.java 2010-06-25
00:01:41 UTC (rev 17669)
@@ -25,7 +25,7 @@
import org.jboss.el.parser.Node;
import org.richfaces.cdk.templatecompiler.el.ELVisitor;
import org.richfaces.cdk.templatecompiler.el.ParsingException;
-import org.richfaces.cdk.templatecompiler.el.Type;
+import org.richfaces.cdk.templatecompiler.el.ELType;
/**
* This class extend AbstractTreeNode and wrap AstIdentifier node.
@@ -42,7 +42,7 @@
public void visit(StringBuilder sb, ELVisitor visitor) throws ParsingException {
String identifierName = getNode().getImage();
- Type identifierType = visitor.getVariable(identifierName);
+ ELType identifierType = visitor.getVariable(identifierName);
//TODO: implement variable mapper like "utils" ->
"this.getUtils()"
visitor.setExpressionType(identifierType);
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AstIntegerTreeNode.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AstIntegerTreeNode.java 2010-06-24
14:18:53 UTC (rev 17668)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AstIntegerTreeNode.java 2010-06-25
00:01:41 UTC (rev 17669)
@@ -43,6 +43,6 @@
@Override
public void visit(StringBuilder sb, ELVisitor visitor) throws ParsingException {
sb.append(getNode().getImage());
- visitor.setExpressionType(TypesFactory.getType(Integer.TYPE));
+ visitor.setExpressionType(TypesFactory.INT_TYPE);
}
}
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AstLiteralTreeNode.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AstLiteralTreeNode.java 2010-06-24
14:18:53 UTC (rev 17668)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AstLiteralTreeNode.java 2010-06-25
00:01:41 UTC (rev 17669)
@@ -24,7 +24,7 @@
package org.richfaces.cdk.templatecompiler.el.node;
-import static org.richfaces.cdk.util.JavaUtils.*;
+import static org.richfaces.cdk.util.JavaUtils.getEscapedString;
import org.jboss.el.parser.Node;
import org.richfaces.cdk.templatecompiler.el.ELVisitor;
@@ -47,7 +47,7 @@
if (getNode().getImage() != null) {
sb.append(getEscapedString(getNode().getImage()));
- visitor.setExpressionType(TypesFactory.getType(String.class));
+ visitor.setExpressionType(TypesFactory.STRING_TYPE);
}
}
}
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-24
14:18:53 UTC (rev 17668)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AstPropertySuffixTreeNode.java 2010-06-25
00:01:41 UTC (rev 17669)
@@ -26,10 +26,9 @@
import org.jboss.el.parser.Node;
import org.richfaces.cdk.templatecompiler.el.ELNodeConstants;
-import org.richfaces.cdk.templatecompiler.el.ELParserUtils;
+import org.richfaces.cdk.templatecompiler.el.ELType;
import org.richfaces.cdk.templatecompiler.el.ELVisitor;
import org.richfaces.cdk.templatecompiler.el.ParsingException;
-import org.richfaces.cdk.templatecompiler.el.Type;
import org.richfaces.cdk.templatecompiler.el.types.TypesFactory;
/**
@@ -49,14 +48,10 @@
return new String(chars);
}
- private Method getReadMethod(Class<?> clazz, String propertyName) {
- if (clazz == null) {
- return null;
- }
-
+ private Method getReadMethod(ELVisitor visitor, String propertyName) {
PropertyDescriptor propertyDescriptor = null;
try {
- propertyDescriptor = ELParserUtils.getPropertyDescriptor(clazz,
propertyName);
+ propertyDescriptor = visitor.getPropertyDescriptor(propertyName);
} catch (ParsingException e) {
// TODO: handle exception
}
@@ -72,19 +67,16 @@
public void visit(StringBuilder sb, ELVisitor visitor) throws ParsingException {
String propertyName = getNode().getImage();
- Type variableType = visitor.getExpressionType();
- Class<?> clazz = variableType.getRawType();
-
String readMethodName;
- Type readMethodReturnType;
+ ELType readMethodReturnType;
- Method readMethod = getReadMethod(clazz, propertyName);
+ Method readMethod = getReadMethod(visitor, propertyName);
if (readMethod != null) {
readMethodName = readMethod.getName();
- readMethodReturnType =
TypesFactory.getType(readMethod.getGenericReturnType());
+ readMethodReturnType = visitor.getType(readMethod.getGenericReturnType());
} else {
readMethodName = ELNodeConstants.GETTER_PREFIX + capitalize(propertyName);
- readMethodReturnType = TypesFactory.getType(Object.class);
+ readMethodReturnType = TypesFactory.OBJECT_TYPE;
}
visitor.setExpressionType(readMethodReturnType);
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AstStringTreeNode.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AstStringTreeNode.java 2010-06-24
14:18:53 UTC (rev 17668)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AstStringTreeNode.java 2010-06-25
00:01:41 UTC (rev 17669)
@@ -24,7 +24,7 @@
package org.richfaces.cdk.templatecompiler.el.node;
-import static org.richfaces.cdk.util.JavaUtils.*;
+import static org.richfaces.cdk.util.JavaUtils.getEscapedString;
import org.jboss.el.parser.AstString;
import org.jboss.el.parser.Node;
@@ -47,6 +47,6 @@
public void visit(StringBuilder sb, ELVisitor visitor) throws ParsingException {
sb.append(getEscapedString(((AstString) getNode()).getString()));
- visitor.setExpressionType(TypesFactory.getType(String.class));
+ visitor.setExpressionType(TypesFactory.STRING_TYPE);
}
}
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/BinaryArithmeticIntegerOperationTreeNode.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/BinaryArithmeticIntegerOperationTreeNode.java 2010-06-24
14:18:53 UTC (rev 17668)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/BinaryArithmeticIntegerOperationTreeNode.java 2010-06-25
00:01:41 UTC (rev 17669)
@@ -23,9 +23,9 @@
import org.jboss.el.parser.Node;
+import org.richfaces.cdk.templatecompiler.el.ELType;
import org.richfaces.cdk.templatecompiler.el.ELVisitor;
import org.richfaces.cdk.templatecompiler.el.ParsingException;
-import org.richfaces.cdk.templatecompiler.el.Type;
import org.richfaces.cdk.templatecompiler.el.types.TypesFactory;
/**
@@ -46,9 +46,9 @@
* @see
org.richfaces.cdk.templatecompiler.el.node.AbstractBinaryOperationTreeNode#getOperationType(java.lang.reflect.Type,
java.lang.reflect.Type)
*/
@Override
- protected Type getOperationType(Type firstArgumentType,
- Type secondArgumentType) {
- return TypesFactory.getType(Integer.TYPE);
+ protected ELType getOperationType(ELType firstArgumentType,
+ ELType secondArgumentType) {
+ return TypesFactory.INT_TYPE;
}
/* (non-Javadoc)
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/BinaryArithmeticOperationTreeNode.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/BinaryArithmeticOperationTreeNode.java 2010-06-24
14:18:53 UTC (rev 17668)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/BinaryArithmeticOperationTreeNode.java 2010-06-25
00:01:41 UTC (rev 17669)
@@ -22,9 +22,9 @@
package org.richfaces.cdk.templatecompiler.el.node;
import org.jboss.el.parser.Node;
+import org.richfaces.cdk.templatecompiler.el.ELType;
import org.richfaces.cdk.templatecompiler.el.ELVisitor;
import org.richfaces.cdk.templatecompiler.el.ParsingException;
-import org.richfaces.cdk.templatecompiler.el.Type;
import org.richfaces.cdk.templatecompiler.el.types.TypesFactory;
/**
@@ -46,18 +46,18 @@
*/
@Override
- protected Type getOperationType(Type firstArgumentType,
- Type secondArgumentType) {
+ protected ELType getOperationType(ELType firstArgumentType,
+ ELType secondArgumentType) {
- Type doubleType = TypesFactory.getType(Double.class);
+ ELType doubleType = TypesFactory.DOUBLE_TYPE;
if (doubleType.isAssignableFrom(firstArgumentType)
|| doubleType.isAssignableFrom(secondArgumentType)) {
- return TypesFactory.getType(Double.TYPE);
+ return TypesFactory.DOUBLE_TYPE;
}
- return TypesFactory.getType(Integer.TYPE);
+ return TypesFactory.INT_TYPE;
}
/* (non-Javadoc)
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/BinaryBooleanOperationTreeNode.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/BinaryBooleanOperationTreeNode.java 2010-06-24
14:18:53 UTC (rev 17668)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/BinaryBooleanOperationTreeNode.java 2010-06-25
00:01:41 UTC (rev 17669)
@@ -22,9 +22,9 @@
package org.richfaces.cdk.templatecompiler.el.node;
import org.jboss.el.parser.Node;
+import org.richfaces.cdk.templatecompiler.el.ELType;
import org.richfaces.cdk.templatecompiler.el.ELVisitor;
import org.richfaces.cdk.templatecompiler.el.ParsingException;
-import org.richfaces.cdk.templatecompiler.el.Type;
import org.richfaces.cdk.templatecompiler.el.types.TypesFactory;
/**
@@ -45,9 +45,9 @@
* @see
org.richfaces.cdk.templatecompiler.el.node.AbstractBinaryOperationTreeNode#getOperationType(java.lang.reflect.Type,
java.lang.reflect.Type)
*/
@Override
- protected Type getOperationType(Type firstArgumentType,
- Type secondArgumentType) {
- return TypesFactory.getType(Boolean.TYPE);
+ protected ELType getOperationType(ELType firstArgumentType,
+ ELType secondArgumentType) {
+ return TypesFactory.BOOLEAN_TYPE;
}
@Override
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/BinaryBooleanResultOperationTreeNode.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/BinaryBooleanResultOperationTreeNode.java 2010-06-24
14:18:53 UTC (rev 17668)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/BinaryBooleanResultOperationTreeNode.java 2010-06-25
00:01:41 UTC (rev 17669)
@@ -22,9 +22,9 @@
package org.richfaces.cdk.templatecompiler.el.node;
import org.jboss.el.parser.Node;
+import org.richfaces.cdk.templatecompiler.el.ELType;
import org.richfaces.cdk.templatecompiler.el.ELVisitor;
import org.richfaces.cdk.templatecompiler.el.ParsingException;
-import org.richfaces.cdk.templatecompiler.el.Type;
import org.richfaces.cdk.templatecompiler.el.types.TypesFactory;
/**
@@ -45,9 +45,9 @@
* @see
org.richfaces.cdk.templatecompiler.el.node.AbstractBinaryOperationTreeNode#getOperationType(java.lang.reflect.Type,
java.lang.reflect.Type)
*/
@Override
- protected Type getOperationType(Type firstArgumentType,
- Type secondArgumentType) {
- return TypesFactory.getType(Boolean.TYPE);
+ protected ELType getOperationType(ELType firstArgumentType,
+ ELType secondArgumentType) {
+ return TypesFactory.BOOLEAN_TYPE;
}
@Override
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-24
14:18:53 UTC (rev 17668)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/ConstantValueTreeNode.java 2010-06-25
00:01:41 UTC (rev 17669)
@@ -23,9 +23,10 @@
import org.richfaces.cdk.templatecompiler.el.ELNodeConstants;
+import org.richfaces.cdk.templatecompiler.el.ELType;
import org.richfaces.cdk.templatecompiler.el.ELVisitor;
import org.richfaces.cdk.templatecompiler.el.ParsingException;
-import org.richfaces.cdk.templatecompiler.el.Type;
+import org.richfaces.cdk.templatecompiler.el.types.NullType;
import org.richfaces.cdk.templatecompiler.el.types.TypesFactory;
/**
@@ -36,19 +37,19 @@
// XXX what class to use for null object: Void.class or null - special NullType be
used
public static final ConstantValueTreeNode NULL_NODE = new
ConstantValueTreeNode(ELNodeConstants.NULL_VALUE,
- TypesFactory.getNullType());
+ NullType.INSTANCE);
public static final ConstantValueTreeNode TRUE_NODE = new
ConstantValueTreeNode(ELNodeConstants.TRUE_VALUE,
- TypesFactory.getType(Boolean.TYPE));
+ TypesFactory.BOOLEAN_TYPE);
public static final ConstantValueTreeNode FALSE_NODE = new
ConstantValueTreeNode(ELNodeConstants.FALSE_VALUE,
- TypesFactory.getType(Boolean.TYPE));
+ TypesFactory.BOOLEAN_TYPE);
private final String value;
- private final Type type;
+ private final ELType type;
- private ConstantValueTreeNode(String value, Type type) {
+ private ConstantValueTreeNode(String value, ELType type) {
super(null);
this.value = value;
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-24
14:18:53 UTC (rev 17668)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/EqualityTestTreeNode.java 2010-06-25
00:01:41 UTC (rev 17669)
@@ -21,13 +21,13 @@
*/
package org.richfaces.cdk.templatecompiler.el.node;
-import static org.richfaces.cdk.templatecompiler.el.HelperMethod.*;
+import static org.richfaces.cdk.templatecompiler.el.HelperMethod.EQUALS_CHECK;
import org.jboss.el.parser.Node;
import org.richfaces.cdk.templatecompiler.el.ELNodeConstants;
+import org.richfaces.cdk.templatecompiler.el.ELType;
import org.richfaces.cdk.templatecompiler.el.ELVisitor;
import org.richfaces.cdk.templatecompiler.el.ParsingException;
-import org.richfaces.cdk.templatecompiler.el.Type;
import org.richfaces.cdk.templatecompiler.el.types.TypesFactory;
/**
@@ -51,11 +51,11 @@
this.negateValue = negateValue;
}
- private boolean isPrimitive(Type type) {
+ private boolean isPrimitive(ELType type) {
return type.getRawType().isPrimitive();
}
- private boolean useIsEqualsMethod(Type firstType, Type secondType) {
+ private boolean useIsEqualsMethod(ELType firstType, ELType secondType) {
if (firstType.isNullType() && !isPrimitive(secondType)) {
return false;
}
@@ -77,9 +77,9 @@
@Override
public void visit(StringBuilder sb, ELVisitor visitor) throws ParsingException {
String firstChildOutput = getChildOutput(0, visitor);
- Type firstChildType = visitor.getExpressionType();
+ ELType firstChildType = visitor.getExpressionType();
String secondChildOutput = getChildOutput(1, visitor);
- Type secondChildType = visitor.getExpressionType();
+ ELType secondChildType = visitor.getExpressionType();
if (useIsEqualsMethod(firstChildType, secondChildType)) {
@@ -89,7 +89,7 @@
//do nothing
}
- sb.append(ELNodeConstants.IS_EQUAL_FUNCTION);
+ sb.append(EQUALS_CHECK.getName());
sb.append(ELNodeConstants.LEFT_BRACKET);
sb.append(firstChildOutput);
@@ -97,7 +97,7 @@
sb.append(secondChildOutput);
sb.append(ELNodeConstants.RIGHT_BRACKET);
- visitor.getUsedHelperMethods().add(EQUALS_CHECK);
+ visitor.addHelperMethods(EQUALS_CHECK);
} else {
sb.append(ELNodeConstants.LEFT_BRACKET);
@@ -114,7 +114,7 @@
sb.append(ELNodeConstants.RIGHT_BRACKET);
}
- visitor.setExpressionType(TypesFactory.getType(Boolean.TYPE));
+ visitor.setExpressionType(TypesFactory.BOOLEAN_TYPE);
}
}
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/types/ComplexType.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/types/ComplexType.java 2010-06-24
14:18:53 UTC (rev 17668)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/types/ComplexType.java 2010-06-25
00:01:41 UTC (rev 17669)
@@ -27,24 +27,24 @@
import java.util.LinkedHashSet;
import java.util.Set;
-import org.richfaces.cdk.templatecompiler.el.Type;
+import org.richfaces.cdk.templatecompiler.el.ELType;
import org.richfaces.cdk.util.ArrayUtils;
/**
* @author Nick Belaevski
*
*/
-public class ComplexType implements Type {
+public class ComplexType implements ELType {
- private Type clearComponentType;
+ private ELType clearComponentType;
- private Type[] typeArguments;
+ private ELType[] typeArguments;
private Class<?> cachedRawType;
private int arrayDepth;
- public ComplexType(Type clearComponentType, Type[] typeArguments, int arrayDepth) {
+ public ComplexType(ELType clearComponentType, ELType[] typeArguments, int arrayDepth)
{
super();
this.clearComponentType = clearComponentType;
this.typeArguments = typeArguments;
@@ -54,14 +54,14 @@
/*
* (non-Javadoc)
*
- * @see org.richfaces.cdk.templatecompiler.el.Type#getImportsList()
+ * @see org.richfaces.cdk.templatecompiler.el.ELType#getImportsList()
*/
@Override
public Collection<Class<?>> getImportsList() {
Set<Class<?>> result = new LinkedHashSet<Class<?>>();
result.addAll(clearComponentType.getImportsList());
- for (Type typeArgument : typeArguments) {
+ for (ELType typeArgument : typeArguments) {
result.addAll(typeArgument.getImportsList());
}
@@ -71,7 +71,7 @@
/*
* (non-Javadoc)
*
- * @see org.richfaces.cdk.templatecompiler.el.Type#isNullType()
+ * @see org.richfaces.cdk.templatecompiler.el.ELType#isNullType()
*/
@Override
public boolean isNullType() {
@@ -81,22 +81,22 @@
/*
* (non-Javadoc)
*
- * @see org.richfaces.cdk.templatecompiler.el.Type#getTypeArguments()
+ * @see org.richfaces.cdk.templatecompiler.el.ELType#getTypeArguments()
*/
@Override
- public Type[] getTypeArguments() {
+ public ELType[] getTypeArguments() {
return typeArguments;
}
@Override
- public Type getContainerType() {
+ public ELType getContainerType() {
if (arrayDepth != 0) {
return new ComplexType(clearComponentType, typeArguments, arrayDepth - 1);
} else {
if (!ArrayUtils.isEmpty(typeArguments)) {
return typeArguments[typeArguments.length - 1];
} else {
- return TypesFactory.getType(Object.class);
+ return TypesFactory.OBJECT_TYPE;
}
}
}
@@ -104,7 +104,7 @@
/*
* (non-Javadoc)
*
- * @see org.richfaces.cdk.templatecompiler.el.Type#getCode()
+ * @see org.richfaces.cdk.templatecompiler.el.ELType#getCode()
*/
@Override
public String getCode() {
@@ -114,7 +114,7 @@
if (!ArrayUtils.isEmpty(typeArguments)) {
sb.append("<");
for (int i = 0; i < typeArguments.length; i++) {
- Type typeArgument = typeArguments[i];
+ ELType typeArgument = typeArguments[i];
if (i != 0) {
sb.append(", ");
@@ -178,7 +178,7 @@
}
/* (non-Javadoc)
- * @see org.richfaces.cdk.templatecompiler.el.Type#getRawType()
+ * @see org.richfaces.cdk.templatecompiler.el.ELType#getRawType()
*/
@Override
public Class<?> getRawType() {
@@ -199,7 +199,7 @@
}
/* (non-Javadoc)
- * @see org.richfaces.cdk.templatecompiler.el.Type#isArray()
+ * @see org.richfaces.cdk.templatecompiler.el.ELType#isArray()
*/
@Override
public boolean isArray() {
@@ -207,20 +207,20 @@
}
/* (non-Javadoc)
- * @see
org.richfaces.cdk.templatecompiler.el.Type#isAssignableFrom(org.richfaces.cdk.templatecompiler.el.Type)
+ * @see
org.richfaces.cdk.templatecompiler.el.ELType#isAssignableFrom(org.richfaces.cdk.templatecompiler.el.ELType)
*/
@Override
- public boolean isAssignableFrom(Type anotherType) {
- Class<?> thisWrapperClass = TypesFactory.getWrapperClass(getRawType());
- Class<?> anotherWrapperClass =
TypesFactory.getWrapperClass(anotherType.getRawType());
+ public boolean isAssignableFrom(ELType anotherType) {
+ Class<?> thisWrapperClass =
TypesFactoryImpl.getWrapperClass(getRawType());
+ Class<?> anotherWrapperClass =
TypesFactoryImpl.getWrapperClass(anotherType.getRawType());
if (thisWrapperClass.isAssignableFrom(anotherWrapperClass)) {
- Type[] thisTypeArguments = getTypeArguments();
+ ELType[] thisTypeArguments = getTypeArguments();
if (ArrayUtils.isEmpty(thisTypeArguments)) {
return true;
}
- Type[] anotherTypeArguments = anotherType.getTypeArguments();
+ ELType[] anotherTypeArguments = anotherType.getTypeArguments();
if (ArrayUtils.isEmpty(anotherTypeArguments)) {
return true;
}
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/types/NullType.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/types/NullType.java 2010-06-24
14:18:53 UTC (rev 17668)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/types/NullType.java 2010-06-25
00:01:41 UTC (rev 17669)
@@ -24,25 +24,25 @@
import java.util.Collection;
import java.util.Collections;
-import org.richfaces.cdk.templatecompiler.el.Type;
+import org.richfaces.cdk.templatecompiler.el.ELType;
/**
* @author Nick Belaevski
*
*/
-public final class NullType implements Type {
+public final class NullType implements ELType {
/**
* Singleton instance of {@link NullType}
*/
- public static final Type INSTANCE = new NullType();
+ public static final ELType INSTANCE = new NullType();
private NullType() {
//this class is a singleton, thus has private ctor
}
/* (non-Javadoc)
- * @see org.richfaces.cdk.templatecompiler.el.Type#getCode()
+ * @see org.richfaces.cdk.templatecompiler.el.ELType#getCode()
*/
@Override
public String getCode() {
@@ -50,7 +50,7 @@
}
/* (non-Javadoc)
- * @see org.richfaces.cdk.templatecompiler.el.Type#getImportsIterator()
+ * @see org.richfaces.cdk.templatecompiler.el.ELType#getImportsIterator()
*/
@Override
public Collection<Class<?>> getImportsList() {
@@ -58,7 +58,7 @@
}
/* (non-Javadoc)
- * @see org.richfaces.cdk.templatecompiler.el.Type#isNullType()
+ * @see org.richfaces.cdk.templatecompiler.el.ELType#isNullType()
*/
@Override
public boolean isNullType() {
@@ -66,7 +66,7 @@
}
/* (non-Javadoc)
- * @see org.richfaces.cdk.templatecompiler.el.Type#getRawType()
+ * @see org.richfaces.cdk.templatecompiler.el.ELType#getRawType()
*/
@Override
public Class<?> getRawType() {
@@ -74,10 +74,10 @@
}
/* (non-Javadoc)
- * @see org.richfaces.cdk.templatecompiler.el.Type#getTypeArguments()
+ * @see org.richfaces.cdk.templatecompiler.el.ELType#getTypeArguments()
*/
@Override
- public Type[] getTypeArguments() {
+ public ELType[] getTypeArguments() {
return null;
}
@@ -90,15 +90,15 @@
}
/* (non-Javadoc)
- * @see org.richfaces.cdk.templatecompiler.el.Type#getContainerType()
+ * @see org.richfaces.cdk.templatecompiler.el.ELType#getContainerType()
*/
@Override
- public Type getContainerType() {
+ public ELType getContainerType() {
return null;
}
/* (non-Javadoc)
- * @see org.richfaces.cdk.templatecompiler.el.Type#isArray()
+ * @see org.richfaces.cdk.templatecompiler.el.ELType#isArray()
*/
@Override
public boolean isArray() {
@@ -106,10 +106,10 @@
}
/* (non-Javadoc)
- * @see
org.richfaces.cdk.templatecompiler.el.Type#isAssignableFrom(org.richfaces.cdk.templatecompiler.el.Type)
+ * @see
org.richfaces.cdk.templatecompiler.el.ELType#isAssignableFrom(org.richfaces.cdk.templatecompiler.el.ELType)
*/
@Override
- public boolean isAssignableFrom(Type anotherType) {
+ public boolean isAssignableFrom(ELType anotherType) {
return true;
}
}
\ No newline at end of file
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/types/PlainClassType.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/types/PlainClassType.java 2010-06-24
14:18:53 UTC (rev 17668)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/types/PlainClassType.java 2010-06-25
00:01:41 UTC (rev 17669)
@@ -25,15 +25,15 @@
import java.util.Arrays;
import java.util.Collection;
-import org.richfaces.cdk.templatecompiler.el.Type;
+import org.richfaces.cdk.templatecompiler.el.ELType;
/**
* @author Nick Belaevski
*
*/
-public class PlainClassType implements Type {
+public final class PlainClassType implements ELType {
- private Class<?> clazz;
+ private final Class<?> clazz;
public PlainClassType(Class<?> clazz) {
super();
@@ -46,7 +46,7 @@
}
/* (non-Javadoc)
- * @see org.richfaces.cdk.templatecompiler.el.Type#getCode()
+ * @see org.richfaces.cdk.templatecompiler.el.ELType#getCode()
*/
@Override
public String getCode() {
@@ -54,7 +54,7 @@
}
/* (non-Javadoc)
- * @see org.richfaces.cdk.templatecompiler.el.Type#getImportsIterator()
+ * @see org.richfaces.cdk.templatecompiler.el.ELType#getImportsIterator()
*/
@Override
public Collection<Class<?>> getImportsList() {
@@ -62,7 +62,7 @@
}
/* (non-Javadoc)
- * @see org.richfaces.cdk.templatecompiler.el.Type#isNullType()
+ * @see org.richfaces.cdk.templatecompiler.el.ELType#isNullType()
*/
@Override
public boolean isNullType() {
@@ -70,7 +70,7 @@
}
/* (non-Javadoc)
- * @see org.richfaces.cdk.templatecompiler.el.Type#getRawType()
+ * @see org.richfaces.cdk.templatecompiler.el.ELType#getRawType()
*/
@Override
public Class<?> getRawType() {
@@ -78,10 +78,10 @@
}
/* (non-Javadoc)
- * @see org.richfaces.cdk.templatecompiler.el.Type#getTypeArguments()
+ * @see org.richfaces.cdk.templatecompiler.el.ELType#getTypeArguments()
*/
@Override
- public Type[] getTypeArguments() {
+ public ELType[] getTypeArguments() {
return null;
}
@@ -130,15 +130,15 @@
}
/* (non-Javadoc)
- * @see org.richfaces.cdk.templatecompiler.el.Type#getCompositeType()
+ * @see org.richfaces.cdk.templatecompiler.el.ELType#getCompositeType()
*/
@Override
- public Type getContainerType() {
+ public ELType getContainerType() {
return null;
}
/* (non-Javadoc)
- * @see org.richfaces.cdk.templatecompiler.el.Type#isArray()
+ * @see org.richfaces.cdk.templatecompiler.el.ELType#isArray()
*/
@Override
public boolean isArray() {
@@ -146,15 +146,15 @@
}
/* (non-Javadoc)
- * @see
org.richfaces.cdk.templatecompiler.el.Type#isAssignableFrom(org.richfaces.cdk.templatecompiler.el.Type)
+ * @see
org.richfaces.cdk.templatecompiler.el.ELType#isAssignableFrom(org.richfaces.cdk.templatecompiler.el.ELType)
*/
@Override
- public boolean isAssignableFrom(Type anotherType) {
+ public boolean isAssignableFrom(ELType anotherType) {
if (anotherType.isNullType()) {
return !clazz.isPrimitive();
} else {
- Class<?> thisWrapperClass = TypesFactory.getWrapperClass(clazz);
- Class<?> anotherWrapperClass =
TypesFactory.getWrapperClass(anotherType.getRawType());
+ Class<?> thisWrapperClass = TypesFactoryImpl.getWrapperClass(clazz);
+ Class<?> anotherWrapperClass =
TypesFactoryImpl.getWrapperClass(anotherType.getRawType());
return thisWrapperClass.isAssignableFrom(anotherWrapperClass);
}
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/types/ReferencedType.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/types/ReferencedType.java 2010-06-24
14:18:53 UTC (rev 17668)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/types/ReferencedType.java 2010-06-25
00:01:41 UTC (rev 17669)
@@ -25,13 +25,13 @@
import java.util.Collection;
import java.util.Collections;
-import org.richfaces.cdk.templatecompiler.el.Type;
+import org.richfaces.cdk.templatecompiler.el.ELType;
/**
* @author Nick Belaevski
*
*/
-public class ReferencedType implements Type {
+public class ReferencedType implements ELType {
private String classCodeString;
@@ -46,7 +46,7 @@
}
/* (non-Javadoc)
- * @see org.richfaces.cdk.templatecompiler.el.Type#getCode()
+ * @see org.richfaces.cdk.templatecompiler.el.ELType#getCode()
*/
@Override
public String getCode() {
@@ -54,7 +54,7 @@
}
/* (non-Javadoc)
- * @see org.richfaces.cdk.templatecompiler.el.Type#getImportsList()
+ * @see org.richfaces.cdk.templatecompiler.el.ELType#getImportsList()
*/
@Override
public Collection<Class<?>> getImportsList() {
@@ -62,7 +62,7 @@
}
/* (non-Javadoc)
- * @see org.richfaces.cdk.templatecompiler.el.Type#getRawType()
+ * @see org.richfaces.cdk.templatecompiler.el.ELType#getRawType()
*/
@Override
public Class<?> getRawType() {
@@ -70,7 +70,7 @@
}
/* (non-Javadoc)
- * @see org.richfaces.cdk.templatecompiler.el.Type#isNullType()
+ * @see org.richfaces.cdk.templatecompiler.el.ELType#isNullType()
*/
@Override
public boolean isNullType() {
@@ -78,10 +78,10 @@
}
/* (non-Javadoc)
- * @see org.richfaces.cdk.templatecompiler.el.Type#getTypeArguments()
+ * @see org.richfaces.cdk.templatecompiler.el.ELType#getTypeArguments()
*/
@Override
- public Type[] getTypeArguments() {
+ public ELType[] getTypeArguments() {
return null;
}
@@ -130,15 +130,15 @@
}
/* (non-Javadoc)
- * @see org.richfaces.cdk.templatecompiler.el.Type#getCompositeType()
+ * @see org.richfaces.cdk.templatecompiler.el.ELType#getCompositeType()
*/
@Override
- public Type getContainerType() {
+ public ELType getContainerType() {
return null;
}
/* (non-Javadoc)
- * @see org.richfaces.cdk.templatecompiler.el.Type#isArray()
+ * @see org.richfaces.cdk.templatecompiler.el.ELType#isArray()
*/
@Override
public boolean isArray() {
@@ -146,10 +146,10 @@
}
/* (non-Javadoc)
- * @see
org.richfaces.cdk.templatecompiler.el.Type#isAssignableFrom(org.richfaces.cdk.templatecompiler.el.Type)
+ * @see
org.richfaces.cdk.templatecompiler.el.ELType#isAssignableFrom(org.richfaces.cdk.templatecompiler.el.ELType)
*/
@Override
- public boolean isAssignableFrom(Type anotherType) {
+ public boolean isAssignableFrom(ELType anotherType) {
if (anotherType instanceof ReferencedType) {
ReferencedType anotherReferencedType = (ReferencedType) anotherType;
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/types/TypesFactory.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/types/TypesFactory.java 2010-06-24
14:18:53 UTC (rev 17668)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/types/TypesFactory.java 2010-06-25
00:01:41 UTC (rev 17669)
@@ -21,298 +21,26 @@
*/
package org.richfaces.cdk.templatecompiler.el.types;
-import java.lang.reflect.GenericArrayType;
-import java.lang.reflect.ParameterizedType;
-import java.text.MessageFormat;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
+import org.richfaces.cdk.templatecompiler.el.ELType;
-import javax.faces.application.Application;
-import javax.faces.component.UIComponent;
-import javax.faces.component.behavior.Behavior;
-import javax.faces.context.FacesContext;
-import javax.faces.convert.Converter;
-import javax.faces.event.FacesEvent;
-import javax.faces.model.DataModel;
-import javax.faces.render.Renderer;
-import javax.faces.validator.Validator;
-
-import org.richfaces.cdk.JavaLogger;
-import org.richfaces.cdk.Logger;
-import org.richfaces.cdk.templatecompiler.el.Type;
-import org.richfaces.cdk.util.ArrayUtils;
-
/**
* @author Nick Belaevski
*
*/
-public final class TypesFactory {
+public interface TypesFactory {
- private static Logger log = new JavaLogger();
- private static final Map<java.lang.reflect.Type, Type> REFLECTION_TYPES_CACHE =
Collections
- .synchronizedMap(new HashMap<java.lang.reflect.Type, Type>());
-
- private static final Map<String, Type> REFERENCED_TYPES_CACHE = Collections
- .synchronizedMap(new HashMap<String, Type>());
-
- private static final Map<Class<?>, Class<?>>
PRIMITIVE_TO_WRAPPER_CLASSES_MAP;
- private static final Map<String, Class<?>> PRIMITIVE_CLASSES_MAP;
-
- static {
- Map<Class<?>, Class<?>> primitiveToWrapperClassesMap = new
HashMap<Class<?>, Class<?>>();
- primitiveToWrapperClassesMap.put(Boolean.TYPE, Boolean.class);
- primitiveToWrapperClassesMap.put(Float.TYPE, Float.class);
- primitiveToWrapperClassesMap.put(Long.TYPE, Long.class);
- primitiveToWrapperClassesMap.put(Integer.TYPE, Integer.class);
- primitiveToWrapperClassesMap.put(Short.TYPE, Short.class);
- primitiveToWrapperClassesMap.put(Byte.TYPE, Byte.class);
- primitiveToWrapperClassesMap.put(Double.TYPE, Double.class);
- primitiveToWrapperClassesMap.put(Character.TYPE, Character.class);
-
- PRIMITIVE_TO_WRAPPER_CLASSES_MAP =
Collections.unmodifiableMap(primitiveToWrapperClassesMap);
-
- Map<String, Class<?>> primitiveClassesMap = new HashMap<String,
Class<?>>();
- for (Class<?> primitiveClass : PRIMITIVE_TO_WRAPPER_CLASSES_MAP.keySet())
{
- primitiveClassesMap.put(primitiveClass.getName(), primitiveClass);
- }
-
- PRIMITIVE_CLASSES_MAP = Collections.unmodifiableMap(primitiveClassesMap);
- }
-
- private static final Pattern CLASS_SIGNATURE_PATTERN = Pattern.compile("^"
+ "\\s*([^\\[<]+)\\s*" + // class name
- "(?:<\\s*(.*)\\s*>)?\\s*" + // generic signature
- "((?:\\[\\s*\\]\\s*)+)?\\s*" + // array signature
- "$");
-
- private static final int CLASS_NAME_GROUP_IDX = 1;
-
- private static final int TYPE_ARGUMENTS_GROUP_IDX = 2;
-
- private static final int ARRAY_SIGNATURE_GROUP_IDX = 3;
-
- private static final int ARRAY_SIGNATURE_LENGTH = "[]".length();
-
- private static final String[] GUESS_PACKAGES;
-
- static {
- Class<?>[] guessPackagesClasses = {
- UIComponent.class, Behavior.class, Converter.class, Validator.class,
- FacesContext.class, Application.class, FacesEvent.class, DataModel.class,
Renderer.class,
- Collection.class, Object.class };
-
- GUESS_PACKAGES = new String[guessPackagesClasses.length];
- int i = 0;
- for (Class<?> guessPackageClass : guessPackagesClasses) {
- GUESS_PACKAGES[i++] = guessPackageClass.getPackage().getName();
- }
- }
-
- private TypesFactory() {
- }
-
- private static Type getPlainClassType(Class<?> plainClass) {
- Type plainClassType = REFLECTION_TYPES_CACHE.get(plainClass);
- if (plainClassType == null) {
- plainClassType = new PlainClassType(plainClass);
- REFLECTION_TYPES_CACHE.put(plainClass, plainClassType);
- }
-
- return plainClassType;
- }
-
- private static Type getReferencedType(String classCodeString) {
- Type type = REFERENCED_TYPES_CACHE.get(classCodeString);
- if (type == null) {
- type = new ReferencedType(classCodeString);
- REFERENCED_TYPES_CACHE.put(classCodeString, type);
- }
-
- return type;
- }
-
- private static Class<?> tryLoadClas(String className, ClassLoader classLoader)
throws ClassNotFoundException {
- int dotIndex = className.indexOf('.');
- if (dotIndex < 0) {
- // guess type
- for (String guessPackage : GUESS_PACKAGES) {
- String guessTypeName = guessPackage + "." + className;
- try {
- //while by default initialize = true for Class.forName(String)
method
- //initialize = false used here prevents loading of dependencies that
- //are accessible only in runtime, e.g. static log initializer from
API
- //depends on the concrete logger implementation provided in runtime
only
- return Class.forName(guessTypeName, false, classLoader);
- } catch (ClassNotFoundException e) {
- // ignore
- } catch (LinkageError e) {
- if (log.isInfoEnabled()) {
- log.info(MessageFormat.format("Class {0} couldn''t
be loaded because of: {1}", guessTypeName,
- e.getMessage()));
- }
- }
- }
- }
-
- Class<?> result = PRIMITIVE_CLASSES_MAP.get(className);
- if (result == null) {
- try {
- //initialize = false here for the same reason as already mentioned for
the previous load block
- result = Class.forName(className, false, classLoader);
- } catch (LinkageError e) {
- String errorMessage = MessageFormat.format("Class {0}
couldn''t be loaded because of: {1}", className,
- e.getMessage());
- if (log.isInfoEnabled()) {
- log.info(errorMessage);
- }
- throw new ClassNotFoundException(errorMessage, e);
- }
- }
-
- return result;
- }
+ ELType OBJECT_TYPE = new PlainClassType(Object.class);
+ ELType STRING_TYPE = new PlainClassType(String.class);
+ ELType BOOLEAN_TYPE = new PlainClassType(Boolean.class);
+ ELType DOUBLE_TYPE = new PlainClassType(Double.class);
+ ELType INTEGER_TYPE = new PlainClassType(Integer.class);
+ ELType INT_TYPE = new PlainClassType(Integer.TYPE);
- static Type[] parseTypeArgumentsString(String typeArguments, ClassLoader classLoader)
{
- if (typeArguments == null) {
- return null;
- }
+ ELType getType(String typeString);
+
+ ELType getType(java.lang.reflect.Type reflectionType);
+
+ ELType[] getTypesArray(java.lang.reflect.Type[] reflectionTypes);
- String[] typeArgumentsSplit = typeArguments.trim().split(",");
-
- Type[] types = new Type[typeArgumentsSplit.length];
- for (int i = 0; i < typeArgumentsSplit.length; i++) {
- types[i] = getType(typeArgumentsSplit[i], classLoader);
- }
-
- return types;
- }
-
- public static Type getType(String typeString, ClassLoader classLoader) {
- Matcher matcher = CLASS_SIGNATURE_PATTERN.matcher(typeString);
- boolean matchResult = matcher.matches();
- if (matchResult) {
- String className = matcher.group(CLASS_NAME_GROUP_IDX).trim();
-
- String typeArgumentsString = matcher.group(TYPE_ARGUMENTS_GROUP_IDX);
- Type[] typeArguments = parseTypeArgumentsString(typeArgumentsString,
classLoader);
-
- String arraySignature = matcher.group(ARRAY_SIGNATURE_GROUP_IDX);
- int arrayDepth = 0;
- if (arraySignature != null) {
- arrayDepth = arraySignature.replaceAll("\\s+",
"").length() / ARRAY_SIGNATURE_LENGTH;
- }
-
- Type baseType;
- try {
- // NB: loadedClass can have name that differs from className!
- Class<?> loadedClas = tryLoadClas(className, classLoader);
-
- baseType = getType(loadedClas);
- } catch (ClassNotFoundException e) {
- baseType = getReferencedType(className);
- }
-
- if (arrayDepth != 0 || !ArrayUtils.isEmpty(typeArguments)) {
- return new ComplexType(baseType, typeArguments, arrayDepth);
- } else {
- return baseType;
- }
- } else {
- if (log.isWarnEnabled()) {
- log.warn(MessageFormat.format("Cannot parse type signature:
''{0}''", typeString));
- }
- return getReferencedType(typeString);
- }
- }
-
- static Type createType(java.lang.reflect.Type reflectionType) {
- java.lang.reflect.Type[] actualTypeArguments = null;
- Class<?> rawType = null;
- int arrayDepth = 0;
-
- java.lang.reflect.Type localReflectionType = reflectionType;
-
- while (localReflectionType instanceof GenericArrayType) {
- localReflectionType = ((GenericArrayType)
localReflectionType).getGenericComponentType();
- arrayDepth++;
- }
-
- if (localReflectionType instanceof ParameterizedType) {
- ParameterizedType parameterizedType = (ParameterizedType)
localReflectionType;
-
- actualTypeArguments = parameterizedType.getActualTypeArguments();
- rawType = (Class<?>) parameterizedType.getRawType();
- } else if (localReflectionType instanceof Class<?>) {
- rawType = (Class<?>) localReflectionType;
- }
-
- if (rawType != null) {
- while (rawType.isArray()) {
- arrayDepth++;
- rawType = rawType.getComponentType();
- }
-
- Type[] typeArguments = null;
- if (!ArrayUtils.isEmpty(actualTypeArguments)) {
- typeArguments = getTypesArray(actualTypeArguments);
- }
-
- Type clearComponentType = getPlainClassType(rawType);
- if (!ArrayUtils.isEmpty(typeArguments) || arrayDepth != 0) {
- return new ComplexType(clearComponentType, typeArguments, arrayDepth);
- } else {
- return clearComponentType;
- }
- } else {
- //TODO better way of handling unknown types
- return getReferencedType(reflectionType.toString());
- }
- }
-
- public static Type getType(java.lang.reflect.Type reflectionType) {
- Type result = REFLECTION_TYPES_CACHE.get(reflectionType);
- if (result == null) {
- result = createType(reflectionType);
- REFLECTION_TYPES_CACHE.put(reflectionType, result);
- }
-
- return result;
- }
-
- public static Type[] getTypesArray(java.lang.reflect.Type[] reflectionTypes) {
- Type[] types = new Type[reflectionTypes.length];
- for (int i = 0; i < reflectionTypes.length; i++) {
- types[i] = getType(reflectionTypes[i]);
- }
-
- return types;
- }
-
- public static Type getNullType() {
- return NullType.INSTANCE;
- }
-
- public static void clearCaches() {
- REFLECTION_TYPES_CACHE.clear();
- REFERENCED_TYPES_CACHE.clear();
- }
-
- /**
- * Returns wrapper classes for passed-in class. If type is primitive, then
corresponding wrapper class is returned
- * (e.g. boolean -> Boolean), otherwise does nothing and returns passed-in class.
- *
- * @return wrapper for primitive types, or passed-in class
- */
- static Class<?> getWrapperClass(Class<?> inClazz) {
- if (inClazz.isPrimitive()) {
- return PRIMITIVE_TO_WRAPPER_CLASSES_MAP.get(inClazz);
- } else {
- return inClazz;
- }
- }
-
}
Copied:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/types/TypesFactoryImpl.java
(from rev 17668,
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/types/TypesFactory.java)
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/types/TypesFactoryImpl.java
(rev 0)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/types/TypesFactoryImpl.java 2010-06-25
00:01:41 UTC (rev 17669)
@@ -0,0 +1,327 @@
+/*
+ * 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.el.types;
+
+import java.lang.reflect.GenericArrayType;
+import java.lang.reflect.ParameterizedType;
+import java.text.MessageFormat;
+import java.util.Collection;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import javax.faces.application.Application;
+import javax.faces.component.UIComponent;
+import javax.faces.component.behavior.Behavior;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+import javax.faces.event.FacesEvent;
+import javax.faces.model.DataModel;
+import javax.faces.render.Renderer;
+import javax.faces.validator.Validator;
+
+import org.richfaces.cdk.Logger;
+import org.richfaces.cdk.templatecompiler.el.ELType;
+import org.richfaces.cdk.util.ArrayUtils;
+
+import com.google.common.base.Function;
+import com.google.common.collect.ImmutableCollection;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableMap.Builder;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Iterables;
+import com.google.inject.Inject;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public final class TypesFactoryImpl implements TypesFactory {
+
+ private static final ImmutableMap<Class<?>, Class<?>>
PRIMITIVE_TO_WRAPPER_CLASSES_MAP = ImmutableMap
+ .<Class<?>, Class<?>> builder().put(Boolean.TYPE,
Boolean.class).put(Float.TYPE, Float.class)
+ .put(Long.TYPE, Long.class).put(Integer.TYPE, Integer.class).put(Short.TYPE,
Short.class)
+ .put(Byte.TYPE, Byte.class).put(Double.TYPE, Double.class).put(Character.TYPE,
Character.class).build();
+
+ private static final ImmutableMap<String, Class<?>>
PRIMITIVE_CLASSES_MAP;
+
+ static {
+
+ Builder<String, Class<?>> builder = ImmutableMap.<String,
Class<?>> builder();
+ for (Class<?> primitiveClass : PRIMITIVE_TO_WRAPPER_CLASSES_MAP.keySet())
{
+ builder.put(primitiveClass.getName(), primitiveClass);
+ }
+ PRIMITIVE_CLASSES_MAP = builder.build();
+ }
+
+ private static final Pattern CLASS_SIGNATURE_PATTERN = Pattern.compile("^"
+ "\\s*([^\\[<]+)\\s*" + // class name
+ "(?:<\\s*(.*)\\s*>)?\\s*" + // generic signature
+ "((?:\\[\\s*\\]\\s*)+)?\\s*" + // array signature
+ "$");
+
+ private static final int CLASS_NAME_GROUP_IDX = 1;
+
+ private static final int TYPE_ARGUMENTS_GROUP_IDX = 2;
+
+ private static final int ARRAY_SIGNATURE_GROUP_IDX = 3;
+
+ private static final int ARRAY_SIGNATURE_LENGTH = "[]".length();
+
+ private static final Function<Class<?>, String> PACKAGE_NAME_FUNCTION =
new Function<Class<?>, String>() {
+
+ @Override
+ public String apply(Class<?> from) {
+ return from.getPackage().getName();
+ }
+ };
+
+ private static final ImmutableCollection<String> GUESS_PACKAGES =
ImmutableSet.<String> copyOf(Iterables.transform(
+ ImmutableSet.<Class<?>> of(UIComponent.class, Behavior.class,
Converter.class, Validator.class,
+ FacesContext.class, Application.class, FacesEvent.class, DataModel.class,
Renderer.class, Collection.class,
+ Object.class), PACKAGE_NAME_FUNCTION
+ ));
+
+ private final ClassLoader classLoader;
+
+ private final Logger log;
+
+ private final Map<java.lang.reflect.Type, ELType> reflectionTypesCache = new
ConcurrentHashMap<java.lang.reflect.Type, ELType>();
+
+ private final Map<String, ELType> refferencedTypesCache = new
ConcurrentHashMap<String, ELType>();
+
+ @Inject
+ public TypesFactoryImpl(Logger log, ClassLoader classLoader) {
+ this.log = log;
+ this.classLoader = classLoader;
+ }
+
+ private ELType getPlainClassType(Class<?> plainClass) {
+ ELType plainClassType = reflectionTypesCache.get(plainClass);
+ if (plainClassType == null) {
+ plainClassType = new PlainClassType(plainClass);
+ reflectionTypesCache.put(plainClass, plainClassType);
+ }
+
+ return plainClassType;
+ }
+
+ private ELType getReferencedType(String classCodeString) {
+ ELType type = refferencedTypesCache.get(classCodeString);
+ if (type == null) {
+ type = new ReferencedType(classCodeString);
+ refferencedTypesCache.put(classCodeString, type);
+ }
+
+ return type;
+ }
+
+ private Class<?> tryLoadClas(String className) throws ClassNotFoundException {
+ int dotIndex = className.indexOf('.');
+ if (dotIndex < 0) {
+ // guess type
+ for (String guessPackage : GUESS_PACKAGES) {
+ String guessTypeName = guessPackage + "." + className;
+ try {
+ // while by default initialize = true for Class.forName(String)
method
+ // initialize = false used here prevents loading of dependencies
that
+ // are accessible only in runtime, e.g. log initializer from API
+ // depends on the concrete logger implementation provided in runtime
only
+ return Class.forName(guessTypeName, false, classLoader);
+ } catch (ClassNotFoundException e) {
+ // ignore
+ } catch (LinkageError e) {
+ if (log.isInfoEnabled()) {
+ log.info(MessageFormat.format("Class {0} couldn''t
be loaded because of: {1}", guessTypeName,
+ e.getMessage()));
+ }
+ }
+ }
+ }
+
+ Class<?> result = PRIMITIVE_CLASSES_MAP.get(className);
+ if (result == null) {
+ try {
+ // initialize = false here for the same reason as already mentioned for
the previous load block
+ result = Class.forName(className, false, classLoader);
+ } catch (LinkageError e) {
+ String errorMessage = MessageFormat.format("Class {0}
couldn''t be loaded because of: {1}", className,
+ e.getMessage());
+ if (log.isInfoEnabled()) {
+ log.info(errorMessage);
+ }
+ throw new ClassNotFoundException(errorMessage, e);
+ }
+ }
+
+ return result;
+ }
+
+ ELType[] parseTypeArgumentsString(String typeArguments) {
+ if (typeArguments == null) {
+ return null;
+ }
+
+ String[] typeArgumentsSplit = typeArguments.trim().split(",");
+
+ ELType[] types = new ELType[typeArgumentsSplit.length];
+ for (int i = 0; i < typeArgumentsSplit.length; i++) {
+ types[i] = getType(typeArgumentsSplit[i]);
+ }
+
+ return types;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
org.richfaces.cdk.templatecompiler.el.types.TypesFactory#getType(java.lang.String)
+ */
+ @Override
+ public ELType getType(String typeString) {
+ Matcher matcher = CLASS_SIGNATURE_PATTERN.matcher(typeString);
+ boolean matchResult = matcher.matches();
+ if (matchResult) {
+ String className = matcher.group(CLASS_NAME_GROUP_IDX).trim();
+
+ String typeArgumentsString = matcher.group(TYPE_ARGUMENTS_GROUP_IDX);
+ ELType[] typeArguments = parseTypeArgumentsString(typeArgumentsString);
+
+ String arraySignature = matcher.group(ARRAY_SIGNATURE_GROUP_IDX);
+ int arrayDepth = 0;
+ if (arraySignature != null) {
+ arrayDepth = arraySignature.replaceAll("\\s+",
"").length() / ARRAY_SIGNATURE_LENGTH;
+ }
+
+ ELType baseType;
+ try {
+ // NB: loadedClass can have name that differs from className!
+ Class<?> loadedClas = tryLoadClas(className);
+
+ baseType = getType(loadedClas);
+ } catch (ClassNotFoundException e) {
+ baseType = getReferencedType(className);
+ }
+
+ if (arrayDepth != 0 || !ArrayUtils.isEmpty(typeArguments)) {
+ return new ComplexType(baseType, typeArguments, arrayDepth);
+ } else {
+ return baseType;
+ }
+ } else {
+ if (log.isWarnEnabled()) {
+ log.warn(MessageFormat.format("Cannot parse type signature:
''{0}''", typeString));
+ }
+ return getReferencedType(typeString);
+ }
+ }
+
+ ELType createType(java.lang.reflect.Type reflectionType) {
+ java.lang.reflect.Type[] actualTypeArguments = null;
+ Class<?> rawType = null;
+ int arrayDepth = 0;
+
+ java.lang.reflect.Type localReflectionType = reflectionType;
+
+ while (localReflectionType instanceof GenericArrayType) {
+ localReflectionType = ((GenericArrayType)
localReflectionType).getGenericComponentType();
+ arrayDepth++;
+ }
+
+ if (localReflectionType instanceof ParameterizedType) {
+ ParameterizedType parameterizedType = (ParameterizedType)
localReflectionType;
+
+ actualTypeArguments = parameterizedType.getActualTypeArguments();
+ rawType = (Class<?>) parameterizedType.getRawType();
+ } else if (localReflectionType instanceof Class<?>) {
+ rawType = (Class<?>) localReflectionType;
+ }
+
+ if (rawType != null) {
+ while (rawType.isArray()) {
+ arrayDepth++;
+ rawType = rawType.getComponentType();
+ }
+
+ ELType[] typeArguments = null;
+ if (!ArrayUtils.isEmpty(actualTypeArguments)) {
+ typeArguments = getTypesArray(actualTypeArguments);
+ }
+
+ ELType clearComponentType = getPlainClassType(rawType);
+ if (!ArrayUtils.isEmpty(typeArguments) || arrayDepth != 0) {
+ return new ComplexType(clearComponentType, typeArguments, arrayDepth);
+ } else {
+ return clearComponentType;
+ }
+ } else {
+ // TODO better way of handling unknown types
+ return getReferencedType(reflectionType.toString());
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
org.richfaces.cdk.templatecompiler.el.types.TypesFactory#getType(java.lang.reflect.Type)
+ */
+ @Override
+ public ELType getType(java.lang.reflect.Type reflectionType) {
+ ELType result = reflectionTypesCache.get(reflectionType);
+ if (result == null) {
+ result = createType(reflectionType);
+ reflectionTypesCache.put(reflectionType, result);
+ }
+
+ return result;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
org.richfaces.cdk.templatecompiler.el.types.TypesFactory#getTypesArray(java.lang.reflect.Type[])
+ */
+ @Override
+ public ELType[] getTypesArray(java.lang.reflect.Type[] reflectionTypes) {
+ ELType[] types = new ELType[reflectionTypes.length];
+ for (int i = 0; i < reflectionTypes.length; i++) {
+ types[i] = getType(reflectionTypes[i]);
+ }
+
+ return types;
+ }
+
+ /**
+ * Returns wrapper classes for passed-in class. If type is primitive, then
corresponding wrapper class is returned
+ * (e.g. boolean -> Boolean), otherwise does nothing and returns passed-in class.
+ *
+ * @return wrapper for primitive types, or passed-in class
+ */
+ static Class<?> getWrapperClass(Class<?> inClazz) {
+ if (inClazz.isPrimitive()) {
+ return PRIMITIVE_TO_WRAPPER_CLASSES_MAP.get(inClazz);
+ } else {
+ return inClazz;
+ }
+ }
+
+}
Property changes on:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/types/TypesFactoryImpl.java
___________________________________________________________________
Name: svn:keywords
+ LastChangedDate LastChangedRevision LastChangedBy HeadURL Id
Copied:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/AbstractTemplateMethodBodyStatementsContainer.java
(from rev 17668,
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/AbstractTemplateMethodBodyStatementsContainer.java)
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/AbstractTemplateMethodBodyStatementsContainer.java
(rev 0)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/AbstractTemplateMethodBodyStatementsContainer.java 2010-06-25
00:01:41 UTC (rev 17669)
@@ -0,0 +1,42 @@
+/*
+ * 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);
+ }
+
+}
Property changes on:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/AbstractTemplateMethodBodyStatementsContainer.java
___________________________________________________________________
Name: svn:keywords
+ LastChangedDate LastChangedRevision LastChangedBy HeadURL Id
Copied:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/BaseTemplateMethodBodyStatement.java
(from rev 17668,
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/BaseTemplateMethodBodyStatement.java)
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/BaseTemplateMethodBodyStatement.java
(rev 0)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/BaseTemplateMethodBodyStatement.java 2010-06-25
00:01:41 UTC (rev 17669)
@@ -0,0 +1,63 @@
+/*
+ * 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.builder.model.JavaField;
+import org.richfaces.cdk.templatecompiler.builder.model.JavaStatement;
+import org.richfaces.cdk.templatecompiler.el.HelperMethod;
+import org.richfaces.cdk.templatecompiler.el.ELType;
+
+/**
+ * @author Nick Belaevski
+ */
+public class BaseTemplateMethodBodyStatement implements TemplateStatement {
+
+ private String templateName;
+
+ protected BaseTemplateMethodBodyStatement(String templateName) {
+ super();
+ this.templateName = templateName;
+ }
+
+ @Override
+ public String getCode() {
+ return renderer.renderSnippet(templateName, this);
+ }
+
+ @Override
+ public Iterable<ELType> getRequiredImports() {
+ return Collections.emptySet();
+ }
+
+ @Override
+ public Iterable<JavaField> getRequiredFields() {
+ return Collections.emptySet();
+ }
+
+ @Override
+ public Iterable<HelperMethod> getRequiredMethods() {
+ return Collections.emptySet();
+ }
+
+}
Property changes on:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/BaseTemplateMethodBodyStatement.java
___________________________________________________________________
Name: svn:keywords
+ LastChangedDate LastChangedRevision LastChangedBy HeadURL Id
Copied:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/ConstantReturnMethodBodyStatement.java
(from rev 17668,
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/ConstantReturnMethodBodyStatement.java)
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/ConstantReturnMethodBodyStatement.java
(rev 0)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/ConstantReturnMethodBodyStatement.java 2010-06-25
00:01:41 UTC (rev 17669)
@@ -0,0 +1,41 @@
+/*
+ * 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 ConstantReturnMethodBodyStatement extends BaseTemplateMethodBodyStatement {
+
+ private String returnValue;
+
+ public ConstantReturnMethodBodyStatement(String returnValue) {
+ super("constant-return");
+
+ this.returnValue = returnValue;
+ }
+
+ public String getReturnValue() {
+ return returnValue;
+ }
+}
Copied:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/ConversionToBooleanMethodBodyStatement.java
(from rev 17668,
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/ConversionToBooleanMethodBodyStatement.java)
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/ConversionToBooleanMethodBodyStatement.java
(rev 0)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/ConversionToBooleanMethodBodyStatement.java 2010-06-25
00:01:41 UTC (rev 17669)
@@ -0,0 +1,32 @@
+/*
+ * 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"});
+ }
+}
Property changes on:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/ConversionToBooleanMethodBodyStatement.java
___________________________________________________________________
Name: svn:keywords
+ LastChangedDate LastChangedRevision LastChangedBy HeadURL Id
Copied:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/ConversionToStringMethodBodyStatement.java
(from rev 17668,
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/ConversionToStringMethodBodyStatement.java)
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/ConversionToStringMethodBodyStatement.java
(rev 0)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/ConversionToStringMethodBodyStatement.java 2010-06-25
00:01:41 UTC (rev 17669)
@@ -0,0 +1,32 @@
+/*
+ * 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"});
+ }
+}
Property changes on:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/ConversionToStringMethodBodyStatement.java
___________________________________________________________________
Name: svn:keywords
+ LastChangedDate LastChangedRevision LastChangedBy HeadURL Id
Copied:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/DefineObjectStatement.java
(from rev 17668,
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/DefineObjectStatement.java)
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/DefineObjectStatement.java
(rev 0)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/DefineObjectStatement.java 2010-06-25
00:01:41 UTC (rev 17669)
@@ -0,0 +1,66 @@
+/*
+ * 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.el.ELType;
+
+/**
+ * @author Nick Belaevski
+ */
+public class DefineObjectStatement extends BaseTemplateMethodBodyStatement {
+
+ private ELType type;
+
+ private String name;
+
+ private String initializationExpression;
+
+ public DefineObjectStatement(ELType type, String name, String
initializationExpression) {
+ super("define-object");
+
+ this.type = type;
+ this.name = name;
+ this.initializationExpression = initializationExpression != null ?
initializationExpression : "";
+ }
+
+ /**
+ * @return the type
+ */
+ public ELType getType() {
+ return type;
+ }
+
+ /**
+ * @return the name
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @return the initializationExpression
+ */
+ public String getInitializationExpression() {
+ return initializationExpression;
+ }
+
+}
Property changes on:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/DefineObjectStatement.java
___________________________________________________________________
Name: svn:keywords
+ LastChangedDate LastChangedRevision LastChangedBy HeadURL Id
Copied:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/EmptinessCheckingMethodBodyStatement.java
(from rev 17668,
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/EmptinessCheckingMethodBodyStatement.java)
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/EmptinessCheckingMethodBodyStatement.java
(rev 0)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/EmptinessCheckingMethodBodyStatement.java 2010-06-25
00:01:41 UTC (rev 17669)
@@ -0,0 +1,32 @@
+/*
+ * 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"});
+ }
+}
Property changes on:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/EmptinessCheckingMethodBodyStatement.java
___________________________________________________________________
Name: svn:keywords
+ LastChangedDate LastChangedRevision LastChangedBy HeadURL Id
Copied:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/EncodeMethodPrefaceStatement.java
(from rev 17668,
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/EncodeMethodPrefaceStatement.java)
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/EncodeMethodPrefaceStatement.java
(rev 0)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/EncodeMethodPrefaceStatement.java 2010-06-25
00:01:41 UTC (rev 17669)
@@ -0,0 +1,36 @@
+/*
+ * 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 EncodeMethodPrefaceStatement extends BaseTemplateMethodBodyStatement {
+
+ /**
+ * @param templateName
+ */
+ public EncodeMethodPrefaceStatement() {
+ super("encode-method-preface");
+ }
+
+}
Property changes on:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/EncodeMethodPrefaceStatement.java
___________________________________________________________________
Name: svn:keywords
+ LastChangedDate LastChangedRevision LastChangedBy HeadURL Id
Copied:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/EndElementStatement.java
(from rev 17668,
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/EndElementStatement.java)
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/EndElementStatement.java
(rev 0)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/EndElementStatement.java 2010-06-25
00:01:41 UTC (rev 17669)
@@ -0,0 +1,34 @@
+/*
+ * 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
+ * @since 4.0
+ */
+public class EndElementStatement extends StartElementStatement {
+
+ public EndElementStatement(String elementName) {
+ super("end-element", elementName);
+ }
+
+}
Property changes on:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/EndElementStatement.java
___________________________________________________________________
Name: svn:keywords
+ LastChangedDate LastChangedRevision LastChangedBy HeadURL Id
Copied:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/EqualsCheckingMethodBodyStatement.java
(from rev 17668,
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/EqualsCheckingMethodBodyStatement.java)
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/EqualsCheckingMethodBodyStatement.java
(rev 0)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/EqualsCheckingMethodBodyStatement.java 2010-06-25
00:01:41 UTC (rev 17669)
@@ -0,0 +1,33 @@
+/*
+ * 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"});
+ }
+}
Property changes on:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/EqualsCheckingMethodBodyStatement.java
___________________________________________________________________
Name: svn:keywords
+ LastChangedDate LastChangedRevision LastChangedBy HeadURL Id
Copied:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/ForEachStatement.java
(from rev 17668,
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/ForEachStatement.java)
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/ForEachStatement.java
(rev 0)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/ForEachStatement.java 2010-06-25
00:01:41 UTC (rev 17669)
@@ -0,0 +1,64 @@
+/*
+ * 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 ForEachStatement extends AbstractTemplateMethodBodyStatementsContainer {
+
+ private String itemsExpression;
+
+ private String var;
+
+ private String varType;
+
+ public ForEachStatement(String itemsExpression,
+ String var, String varType) {
+ super("for-each");
+ this.itemsExpression = itemsExpression;
+ this.var = var;
+ this.varType = varType;
+ }
+
+ /**
+ * @return the itemsExpression
+ */
+ public String getItemsExpression() {
+ return itemsExpression;
+ }
+
+ /**
+ * @return the var
+ */
+ public String getVar() {
+ return var;
+ }
+
+ /**
+ * @return the varType
+ */
+ public String getVarType() {
+ return varType;
+ }
+
+}
Property changes on:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/ForEachStatement.java
___________________________________________________________________
Name: svn:keywords
+ LastChangedDate LastChangedRevision LastChangedBy HeadURL Id
Copied:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/HelperMethodBodyStatement.java
(from rev 17668,
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/HelperMethodBodyStatement.java)
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/HelperMethodBodyStatement.java
(rev 0)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/HelperMethodBodyStatement.java 2010-06-25
00:01:41 UTC (rev 17669)
@@ -0,0 +1,41 @@
+/*
+ * 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;
+ }
+}
Property changes on:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/HelperMethodBodyStatement.java
___________________________________________________________________
Name: svn:keywords
+ LastChangedDate LastChangedRevision LastChangedBy HeadURL Id
Copied:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/IfElseStatement.java
(from rev 17668,
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/IfElseStatement.java)
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/IfElseStatement.java
(rev 0)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/IfElseStatement.java 2010-06-25
00:01:41 UTC (rev 17669)
@@ -0,0 +1,34 @@
+/*
+ * 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
+ * @since 4.0
+ */
+public class IfElseStatement extends AbstractTemplateMethodBodyStatementsContainer {
+
+ public IfElseStatement() {
+ super("if-else");
+ }
+
+}
Property changes on:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/IfElseStatement.java
___________________________________________________________________
Name: svn:keywords
+ LastChangedDate LastChangedRevision LastChangedBy HeadURL Id
Copied:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/IfStatement.java
(from rev 17668,
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/IfStatement.java)
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/IfStatement.java
(rev 0)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/IfStatement.java 2010-06-25
00:01:41 UTC (rev 17669)
@@ -0,0 +1,37 @@
+/*
+ * 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;
+
+
+public final class IfStatement extends StatementsContainer {
+
+ private String test;
+
+ public IfStatement(String test) {
+ super();
+ this.test = test;
+ }
+
+ public String getTest() {
+ return test;
+ }
+}
\ No newline at end of file
Property changes on:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/IfStatement.java
___________________________________________________________________
Name: svn:keywords
+ LastChangedDate LastChangedRevision LastChangedBy HeadURL Id
Copied:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/StartElementStatement.java
(from rev 17668,
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/StartElementStatement.java)
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/StartElementStatement.java
(rev 0)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/StartElementStatement.java 2010-06-25
00:01:41 UTC (rev 17669)
@@ -0,0 +1,48 @@
+/*
+ * 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
+ * @since 4.0
+ */
+public class StartElementStatement extends BaseTemplateMethodBodyStatement {
+
+ private String elementName;
+
+ public StartElementStatement(String elementName) {
+ this("start-element", elementName);
+ }
+
+ protected StartElementStatement(String templateName, String elementName) {
+ super(templateName);
+ this.elementName = elementName;
+ }
+
+ /**
+ * @return the elementName
+ */
+ public String getElementName() {
+ return elementName;
+ }
+
+}
Property changes on:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/StartElementStatement.java
___________________________________________________________________
Name: svn:keywords
+ LastChangedDate LastChangedRevision LastChangedBy HeadURL Id
Copied:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/StatementsContainer.java
(from rev 17668,
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/MethodBodyStatementsContainer.java)
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/StatementsContainer.java
(rev 0)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/StatementsContainer.java 2010-06-25
00:01:41 UTC (rev 17669)
@@ -0,0 +1,179 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.cdk.templatecompiler.statements;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.richfaces.cdk.templatecompiler.builder.model.JavaField;
+import org.richfaces.cdk.templatecompiler.builder.model.Variables;
+import org.richfaces.cdk.templatecompiler.el.HelperMethod;
+import org.richfaces.cdk.templatecompiler.el.ELType;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Maps;
+
+/**
+ * @author Nick Belaevski
+ * @since 4.0
+ */
+public class StatementsContainer implements TemplateStatement, Variables {
+
+ private static final Function<TemplateStatement, Iterable<ELType>>
IMPORTS_TRANSFORM = new Function<TemplateStatement, Iterable<ELType>>() {
+
+ @Override
+ public Iterable<ELType> apply(TemplateStatement from) {
+ return from.getRequiredImports();
+ }
+ };
+
+ 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;
+
+ private final Map<String, ELType> localVariablesMap = Maps.newHashMap();
+
+ public List<TemplateStatement> getStatements() {
+ return statements;
+ }
+
+ public void addStatement(TemplateStatement statement) {
+ setParent(statement);
+ statements.add(statement);
+ }
+
+ public void addStatement(int index, TemplateStatement statement) {
+ setParent(statement);
+ 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>
+ *
+ * @param parent
+ * the parent to set
+ */
+ public void setParent(StatementsContainer parent) {
+ this.parent = parent;
+ }
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @return the parent
+ */
+ public StatementsContainer getParent() {
+ return parent;
+ }
+
+ public boolean isEmpty() {
+ return statements.isEmpty();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.richfaces.cdk.templatecompiler.builder.model.JavaStatement#getCode()
+ */
+ @Override
+ public String getCode() {
+ StringBuilder sb = new StringBuilder();
+ for (TemplateStatement statement : statements) {
+ sb.append(statement.getCode());
+ sb.append('\n');
+ }
+
+ return sb.toString();
+ }
+
+ @Override
+ public ELType getVariable(String name) {
+ ELType type = localVariablesMap.get(name);
+ if (null == type && null != parent) {
+ type = parent.getVariable(name);
+ }
+ return type;
+ }
+
+ @Override
+ public boolean isDefined(String name) {
+ boolean defined = localVariablesMap.containsKey(name);
+ if (!defined && null != parent) {
+ defined = parent.isDefined(name);
+ }
+ return defined;
+ }
+
+ @Override
+ public ELType setVariable(String name, ELType type) {
+ ELType variable = getVariable(name);
+ localVariablesMap.put(name, type);
+ return variable;
+ }
+
+ private <T> Iterable<T> concatStatements(Function<TemplateStatement,
Iterable<T>> transform) {
+ Iterable<T> imports = Iterables.concat(Iterables.transform(statements,
transform));
+ return imports;
+ }
+
+ @Override
+ public Iterable<ELType> getRequiredImports() {
+ return concatStatements(IMPORTS_TRANSFORM);
+ }
+
+ @Override
+ public Iterable<JavaField> getRequiredFields() {
+ return concatStatements(FIELDS_TRANSFORM);
+ }
+
+ @Override
+ public Iterable<HelperMethod> getRequiredMethods() {
+ return concatStatements(HELPER_METHODS_TRANSFORM);
+ }
+}
Property changes on:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/StatementsContainer.java
___________________________________________________________________
Name: svn:keywords
+ LastChangedDate LastChangedRevision LastChangedBy HeadURL Id
Added:
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
(rev 0)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/TemplateStatement.java 2010-06-25
00:01:41 UTC (rev 17669)
@@ -0,0 +1,23 @@
+/**
+ *
+ */
+package org.richfaces.cdk.templatecompiler.statements;
+
+import org.richfaces.cdk.templatecompiler.builder.model.JavaField;
+import org.richfaces.cdk.templatecompiler.builder.model.JavaStatement;
+import org.richfaces.cdk.templatecompiler.el.HelperMethod;
+import org.richfaces.cdk.templatecompiler.el.ELType;
+
+/**
+ * @author asmirnov
+ *
+ */
+public interface TemplateStatement extends JavaStatement {
+
+ public Iterable<ELType> getRequiredImports();
+
+ public Iterable<JavaField> getRequiredFields();
+
+ public Iterable<HelperMethod> getRequiredMethods();
+
+}
Property changes on:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/TemplateStatement.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Copied:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/WriteAttributeStatement.java
(from rev 17668,
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/WriteAttributeStatement.java)
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/WriteAttributeStatement.java
(rev 0)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/WriteAttributeStatement.java 2010-06-25
00:01:41 UTC (rev 17669)
@@ -0,0 +1,47 @@
+/*
+ * 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 WriteAttributeStatement extends BaseTemplateMethodBodyStatement {
+
+ private String attributeName;
+
+ private String valueExpression;
+
+ public WriteAttributeStatement(String attributeName, String valueExpression) {
+ super("write-attribute");
+ this.attributeName = attributeName;
+ this.valueExpression = valueExpression;
+ }
+
+ public String getAttributeName() {
+ return attributeName;
+ }
+
+ public String getValueExpression() {
+ return valueExpression;
+ }
+
+}
Property changes on:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/WriteAttributeStatement.java
___________________________________________________________________
Name: svn:keywords
+ LastChangedDate LastChangedRevision LastChangedBy HeadURL Id
Copied:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/WriteAttributesSetStatement.java
(from rev 17668,
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/WriteAttributesSetStatement.java)
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/WriteAttributesSetStatement.java
(rev 0)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/WriteAttributesSetStatement.java 2010-06-25
00:01:41 UTC (rev 17669)
@@ -0,0 +1,44 @@
+/*
+ * 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 WriteAttributesSetStatement extends BaseTemplateMethodBodyStatement {
+
+ private String passThroughFieldName;
+
+ public WriteAttributesSetStatement(String passThroughFieldName) {
+ super("write-attributes-set");
+ this.passThroughFieldName = passThroughFieldName;
+ }
+
+ /**
+ * @return the passThroughFieldName
+ */
+ public String getPassThroughFieldName() {
+ return passThroughFieldName;
+ }
+
+}
Property changes on:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/WriteAttributesSetStatement.java
___________________________________________________________________
Name: svn:keywords
+ LastChangedDate LastChangedRevision LastChangedBy HeadURL Id
Copied:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/WriteTextStatement.java
(from rev 17668,
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/WriteTextStatement.java)
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/WriteTextStatement.java
(rev 0)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/WriteTextStatement.java 2010-06-25
00:01:41 UTC (rev 17669)
@@ -0,0 +1,40 @@
+/*
+ * 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 WriteTextStatement extends BaseTemplateMethodBodyStatement {
+
+ private String textExpression;
+
+ public WriteTextStatement(String textExpression) {
+ super("write-text");
+ this.textExpression = textExpression;
+ }
+
+ public String getTextExpression() {
+ return textExpression;
+ }
+
+}
Property changes on:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/WriteTextStatement.java
___________________________________________________________________
Name: svn:keywords
+ LastChangedDate LastChangedRevision LastChangedBy HeadURL Id
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-24
14:18:53 UTC (rev 17668)
+++
root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/parser/el/test/ELParserTest.java 2010-06-25
00:01:41 UTC (rev 17669)
@@ -31,27 +31,93 @@
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.richfaces.cdk.As;
+import org.richfaces.cdk.CdkTestBase;
+import org.richfaces.cdk.CdkTestRunner;
+import org.richfaces.cdk.Logger;
+import org.richfaces.cdk.Mock;
+import org.richfaces.cdk.MockController;
+import org.richfaces.cdk.templatecompiler.ELParser;
import org.richfaces.cdk.templatecompiler.builder.model.Variables;
+import org.richfaces.cdk.templatecompiler.el.ELParserImpl;
import org.richfaces.cdk.templatecompiler.el.ELVisitor;
+import org.richfaces.cdk.templatecompiler.el.HelperMethod;
import org.richfaces.cdk.templatecompiler.el.ParsingException;
-import org.richfaces.cdk.templatecompiler.el.Type;
+import org.richfaces.cdk.templatecompiler.el.ELType;
import org.richfaces.cdk.templatecompiler.el.types.TypesFactory;
+import org.richfaces.cdk.templatecompiler.el.types.TypesFactoryImpl;
+import org.richfaces.cdk.templatecompiler.statements.TemplateStatement;
-public class ELParserTest {
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Iterables;
+import com.google.inject.Binder;
+import com.google.inject.Inject;
- private ELVisitor visitor;
+(a)RunWith(CdkTestRunner.class)
+public class ELParserTest extends CdkTestBase {
- private void parseExpression(String expression) throws ParsingException {
- parseExpression(expression, Object.class);
+ @Inject
+ @As(ELParserImpl.class)
+ private ELParser parser;
+
+ @Mock
+ Logger log;
+
+ @Inject
+ @As(TypesFactoryImpl.class)
+ private TypesFactory typesFactory;
+
+ @Inject
+ private MockController controller;
+
+ @Override
+ public void configure(Binder binder) {
+ super.configure(binder);
+ binder.bind(ClassLoader.class).toInstance(createClassLoader());
}
- private void parseExpression(String expression, Class<?> returnType) throws
ParsingException {
- final Map<String, Type> contextMap = new HashMap<String, Type>();
+ private TemplateStatement parseExpression(String expression) throws ParsingException
{
+ return parseExpression(expression, Object.class);
+ }
- Variables variables = new Variables(){
+ private TemplateStatement parseAndCheck(String expression, String expected,
HelperMethod... requiredMethods)
+ throws ParsingException {
+ return parseAndCheck(expression, Object.class, expected, requiredMethods);
+ }
+ private TemplateStatement parseAndCheck(String expression, Class<?> returnType,
String expected,
+ Class<?> expectedType, HelperMethod... requiredMethods) throws
ParsingException {
+ TemplateStatement statement = parseAndCheck(expression, returnType, expected,
requiredMethods);
+ ELVisitor visitor = (ELVisitor) statement;
+ assertEquals(expectedType, visitor.getExpressionType().getRawType());
+ return statement;
+ }
+
+ private TemplateStatement parseAndCheck(String expression, Class<?> returnType,
String expected,
+ HelperMethod... requiredMethods) throws ParsingException {
+ controller.replay();
+ TemplateStatement parseExpression = parseExpression(expression, returnType);
+ controller.verify();
+ assertEquals(expected, parseExpression.getCode());
+ for (HelperMethod helperMethod : requiredMethods) {
+ assertTrue("Expect helper method " + helperMethod.getName(),
+ Iterables.contains(parseExpression.getRequiredMethods(), helperMethod));
+ }
+ for (HelperMethod helperMethod : parseExpression.getRequiredMethods()) {
+ assertTrue("Unexpected helper method " + helperMethod.getName(),
+ Iterables.contains(ImmutableSet.of(requiredMethods), helperMethod));
+ }
+ return parseExpression;
+ }
+
+ private TemplateStatement parseExpression(String expression, Class<?>
returnType) throws ParsingException {
+ final Map<String, ELType> contextMap = new HashMap<String,
ELType>();
+
+ Variables variables = new Variables() {
+
@Override
- public Type getVariable(String name) throws ParsingException {
+ public ELType getVariable(String name) throws ParsingException {
return contextMap.get(name);
}
@@ -61,104 +127,86 @@
}
@Override
- public Type setVariable(String name, Type type) throws ParsingException {
+ public ELType setVariable(String name, ELType type) throws ParsingException
{
return contextMap.put(name, type);
}
-
+
};
- contextMap.put("action",
TypesFactory.getType(org.richfaces.cdk.templatecompiler.parser.el.test.Bean.class));
- contextMap.put("clientId", TypesFactory.getType(String.class));
- contextMap.put("test", TypesFactory.getType(boolean.class));
- contextMap.put("otherTest", TypesFactory.getType(boolean.class));
- contextMap.put("this", TypesFactory.getType(Object.class));
- contextMap.put("super", TypesFactory.getType(Object.class));
- contextMap.put("objectVar", TypesFactory.getType(Object.class));
+ contextMap.put("action",
this.getType(org.richfaces.cdk.templatecompiler.parser.el.test.Bean.class));
+ contextMap.put("clientId", this.getType(String.class));
+ contextMap.put("test", this.getType(boolean.class));
+ contextMap.put("otherTest", this.getType(boolean.class));
+ contextMap.put("this", this.getType(Object.class));
+ contextMap.put("super", this.getType(Object.class));
+ contextMap.put("objectVar", this.getType(Object.class));
- visitor.parse(expression, variables, TypesFactory.getType(returnType));
+ return parser.parse(expression, variables, this.getType(returnType));
}
- @Before
- public void setUp() {
- visitor = new ELVisitor();
+ private ELType getType(Class<?> returnType) {
+ return typesFactory.getType(returnType);
}
- @After
- public void tearDown() {
- visitor = null;
+ @Test
+ public void testAnd() throws Exception {
+ parseAndCheck("#{test and otherTest}", "(test &&
otherTest)");
}
@Test
- public void testAnd() throws Exception {
- parseExpression("#{test and otherTest}");
- assertEquals("(test && otherTest)",
visitor.getParsedExpression());
- assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
+ public void testAnd1() throws Exception {
+ parseAndCheck("#{otherTest && test}", "(otherTest
&& test)");
+ // assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
+ }
- parseExpression("#{otherTest && test}");
- assertEquals("(otherTest && test)",
visitor.getParsedExpression());
- assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
+ @Test
+ public void testAnd2() throws Exception {
+ parseAndCheck("#{action and otherTest}",
"(convertToBoolean(action) && otherTest)", TO_BOOLEAN_CONVERSION);
+ }
- parseExpression("#{action and otherTest}");
- assertTrue(visitor.getUsedHelperMethods().contains(TO_BOOLEAN_CONVERSION));
- assertEquals("(convertToBoolean(action) && otherTest)",
visitor.getParsedExpression());
- assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
-
- parseExpression("#{test && action}");
- assertTrue(visitor.getUsedHelperMethods().contains(TO_BOOLEAN_CONVERSION));
- assertEquals("(test && convertToBoolean(action))",
visitor.getParsedExpression());
- assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
+ @Test
+ public void testAnd3() throws Exception {
+ parseAndCheck("#{test && action}", "(test &&
convertToBoolean(action))", TO_BOOLEAN_CONVERSION);
+ // assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
}
@Test
public void testBooleanReturnType() throws Exception {
- parseExpression("#{clientId}", Boolean.TYPE);
+ parseAndCheck("#{clientId}", Boolean.TYPE,
"convertToBoolean(clientId)",Boolean.TYPE, TO_BOOLEAN_CONVERSION);
+ }
- assertEquals("convertToBoolean(clientId)",
visitor.getParsedExpression());
- assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
- assertTrue(visitor.getUsedHelperMethods().contains(TO_BOOLEAN_CONVERSION));
-
- parseExpression("#{test}", Boolean.TYPE);
-
- assertEquals("test", visitor.getParsedExpression());
- assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
- assertFalse(visitor.getUsedHelperMethods().contains(TO_BOOLEAN_CONVERSION));
+ @Test
+ public void testBooleanReturnType1() throws Exception {
+ parseAndCheck("#{test}", Boolean.TYPE, "test",
Boolean.TYPE);
}
@Test
public void testChoice() throws Exception {
- parseExpression("#{test ? 2 : 3}");
- assertEquals("(test ? 2 : 3)", visitor.getParsedExpression());
- assertEquals(Integer.TYPE, visitor.getExpressionType().getRawType());
+ parseAndCheck("#{test ? 2 : 3}",Object.class,"(test ? 2 :
3)",Integer.TYPE);
+ }
- parseExpression("#{test ? null : 'string'}");
- assertEquals("(test ? null : \"string\")",
visitor.getParsedExpression());
- assertEquals(String.class, visitor.getExpressionType().getRawType());
+ @Test
+ public void testChoice1() throws Exception {
+ parseAndCheck("#{test ? null :
'string'}",Object.class,"(test ? null : \"string\")",
String.class);
+ }
- parseExpression("#{action ? null : 'string'}");
- assertEquals("(convertToBoolean(action) ? null :
\"string\")", visitor.getParsedExpression());
- assertEquals(String.class, visitor.getExpressionType().getRawType());
- assertTrue(visitor.getUsedHelperMethods().contains(TO_BOOLEAN_CONVERSION));
+ @Test
+ public void testChoice2() throws Exception {
+ parseAndCheck("#{action ? null :
'string'}",Object.class,"(convertToBoolean(action) ? null :
\"string\")", TO_BOOLEAN_CONVERSION);
}
@Test
public void testDiv() throws Exception {
- parseExpression("#{1/2}");
- assertEquals("(1 / 2)", visitor.getParsedExpression());
- assertEquals(Integer.TYPE, visitor.getExpressionType().getRawType());
+ parseAndCheck("#{1/2}",Object.class,"(1 / 2)",Integer.TYPE);
}
@Test
public void testEmpty() throws Exception {
- parseExpression("#{empty action.array}");
- assertEquals("isEmpty(action.getArray())",
visitor.getParsedExpression());
- assertTrue(visitor.getUsedHelperMethods().contains(EMPTINESS_CHECK));
- assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
+ parseAndCheck("#{empty
action.array}",Object.class,"isEmpty(action.getArray())",
Boolean.TYPE,EMPTINESS_CHECK);
}
@Test
public void testEmptyString() throws Exception {
- parseExpression("");
- assertEquals("\"\"", visitor.getParsedExpression());
- assertEquals(String.class, visitor.getExpressionType().getRawType());
+ parseAndCheck("",Object.class,"\"\"",
String.class);
}
@Test
@@ -226,7 +274,7 @@
public void testFunction() throws Exception {
parseExpression("#{super:getType()}");
assertEquals("super.getType()", visitor.getParsedExpression());
- Type variableType = visitor.getExpressionType();
+ ELType variableType = visitor.getExpressionType();
}
@Test
@@ -337,7 +385,7 @@
public void testMethodReturnList() throws Exception {
parseExpression("#{action.components}");
assertEquals("action.getComponents()", visitor.getParsedExpression());
- Type variableType = visitor.getExpressionType();
+ ELType variableType = visitor.getExpressionType();
assertEquals(List.class, variableType.getRawType());
assertEquals(UIComponent.class, variableType.getContainerType().getRawType());
}
@@ -365,7 +413,7 @@
public void testMethodReturnMap() throws Exception {
parseExpression("#{action.facets}");
assertEquals("action.getFacets()", visitor.getParsedExpression());
- Type variableType = visitor.getExpressionType();
+ ELType variableType = visitor.getExpressionType();
assertEquals(Map.class, variableType.getRawType());
assertEquals(UIComponent.class, variableType.getContainerType().getRawType());
@@ -407,10 +455,10 @@
@Test
public void testMethodWithParam() throws Exception {
parseExpression("#{getType(action.array[0].rendered, action.readOnly,
true)}");
-
assertEquals("this.getType(action.getArray()[0].isRendered(),action.isReadOnly(),true)",
visitor
- .getParsedExpression());
+
assertEquals("this.getType(action.getArray()[0].isRendered(),action.isReadOnly(),true)",
+ visitor.getParsedExpression());
- Type variableType = visitor.getExpressionType();
+ ELType variableType = visitor.getExpressionType();
parseExpression("#{action.count(123)}");
assertEquals("action.count(123)", visitor.getParsedExpression());
@@ -611,7 +659,7 @@
public void testThisFunction() throws Exception {
parseExpression("#{getType()}");
assertEquals("this.getType()", visitor.getParsedExpression());
- Type variableType = visitor.getExpressionType();
+ ELType variableType = visitor.getExpressionType();
parseExpression("#{this.getType()}");
assertEquals("this.getType()", visitor.getParsedExpression());
@@ -628,7 +676,7 @@
public void testVariableFunction() throws Exception {
parseExpression("#{objectVar.getType()}");
assertEquals("objectVar.getType()", visitor.getParsedExpression());
- Type variableType = visitor.getExpressionType();
+ ELType variableType = visitor.getExpressionType();
}
@Test
Modified:
root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/parser/el/test/TypesFactoryTest.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/parser/el/test/TypesFactoryTest.java 2010-06-24
14:18:53 UTC (rev 17668)
+++
root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/parser/el/test/TypesFactoryTest.java 2010-06-25
00:01:41 UTC (rev 17669)
@@ -21,22 +21,43 @@
*/
package org.richfaces.cdk.templatecompiler.parser.el.test;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
import java.io.Writer;
import java.util.List;
import java.util.Map;
import org.junit.Test;
-import org.richfaces.cdk.templatecompiler.el.Type;
-import org.richfaces.cdk.templatecompiler.el.types.TypesFactory;
+import org.junit.runner.RunWith;
+import org.richfaces.cdk.CdkTestBase;
+import org.richfaces.cdk.CdkTestRunner;
+import org.richfaces.cdk.templatecompiler.el.ELType;
+import org.richfaces.cdk.templatecompiler.el.types.TypesFactoryImpl;
+import com.google.inject.Binder;
+import com.google.inject.Inject;
+
/**
* @author Nick Belaevski
*
*/
-public class TypesFactoryTest {
+(a)RunWith(CdkTestRunner.class)
+public class TypesFactoryTest extends CdkTestBase {
+ @Inject
+ TypesFactoryImpl typesFactory;
+
+ @Override
+ public void configure(Binder binder) {
+ super.configure(binder);
+ binder.bind(ClassLoader.class).toInstance(createClassLoader());
+ }
+
private static final class ParameterizedTypesHolder {
@SuppressWarnings("unused")
@@ -78,173 +99,159 @@
@Test
public void testCaching() throws Exception {
- Type objectType = TypesFactory.getType(Object.class);
- Type objectType2 = TypesFactory.getType(Object.class);
+ ELType objectType = typesFactory.getType(Object.class);
+ ELType objectType2 = typesFactory.getType(Object.class);
assertNotNull(objectType);
assertNotNull(objectType2);
assertSame(objectType, objectType2);
- TypesFactory.clearCaches();
-
- Type objectType3 = TypesFactory.getType(Object.class);
- assertNotNull(objectType3);
-
- assertNotSame(objectType, objectType3);
}
- @Test
- public void testGetNullType() throws Exception {
- Type nullType = TypesFactory.getNullType();
- assertNotNull(nullType);
- assertTrue(nullType.isNullType());
- }
@Test
public void testGetTypeFromReflectionType() throws Exception {
- Type integerType = TypesFactory.getType(Integer.TYPE);
+ ELType integerType = typesFactory.getType(Integer.TYPE);
assertNotNull(integerType);
assertEquals(Integer.TYPE, integerType.getRawType());
assertNull(integerType.getTypeArguments());
assertFalse(integerType.isArray());
assertFalse(integerType.isNullType());
- Type stringType = TypesFactory.getType(String.class);
+ ELType stringType = typesFactory.getType(String.class);
assertNotNull(stringType);
assertEquals(String.class, stringType.getRawType());
assertNull(stringType.getTypeArguments());
assertFalse(stringType.isArray());
assertFalse(stringType.isNullType());
- Type arrayType = TypesFactory.getType(String[].class);
+ ELType arrayType = typesFactory.getType(String[].class);
assertNotNull(arrayType);
assertNull(arrayType.getTypeArguments());
assertTrue(arrayType.isArray());
assertEquals(String.class, arrayType.getContainerType().getRawType());
assertFalse(arrayType.isNullType());
- Type multiDimArrayType = TypesFactory.getType(String[][][].class);
+ ELType multiDimArrayType = typesFactory.getType(String[][][].class);
assertNotNull(multiDimArrayType);
assertNull(multiDimArrayType.getTypeArguments());
assertTrue(multiDimArrayType.isArray());
assertEquals(String[][].class,
multiDimArrayType.getContainerType().getRawType());
assertFalse(multiDimArrayType.isNullType());
- Type parameterizedMapType = TypesFactory.getType(getParameterizedMapType());
+ ELType parameterizedMapType = typesFactory.getType(getParameterizedMapType());
assertNotNull(parameterizedMapType);
assertFalse(parameterizedMapType.isArray());
assertEquals(Map.class, parameterizedMapType.getRawType());
- Type[] parameterizedMapTypeArguments = parameterizedMapType.getTypeArguments();
+ ELType[] parameterizedMapTypeArguments =
parameterizedMapType.getTypeArguments();
assertNotNull(parameterizedMapTypeArguments);
assertEquals(2, parameterizedMapTypeArguments.length);
assertEquals(String.class, parameterizedMapTypeArguments[0].getRawType());
assertEquals(Object.class, parameterizedMapTypeArguments[1].getRawType());
- Type parameterizedArrayType = TypesFactory.getType(getParameterizedArrayType());
+ ELType parameterizedArrayType =
typesFactory.getType(getParameterizedArrayType());
assertNotNull(parameterizedArrayType);
assertTrue(parameterizedArrayType.isArray());
assertEquals(List[].class, parameterizedArrayType.getRawType());
- Type[] parameterizedArrayTypeArguments =
parameterizedArrayType.getTypeArguments();
+ ELType[] parameterizedArrayTypeArguments =
parameterizedArrayType.getTypeArguments();
assertNotNull(parameterizedArrayTypeArguments);
assertEquals(1, parameterizedArrayTypeArguments.length);
- Type parameterizedArrayTypeArgument = parameterizedArrayTypeArguments[0];
+ ELType parameterizedArrayTypeArgument = parameterizedArrayTypeArguments[0];
assertEquals(String.class, parameterizedArrayTypeArgument.getRawType());
assertFalse(parameterizedArrayTypeArgument.isArray());
- Type typeVariableType = TypesFactory.getType(getTypeVariableType());
+ ELType typeVariableType = typesFactory.getType(getTypeVariableType());
assertNotNull(typeVariableType);
assertEquals("Abc", typeVariableType.getCode());
- Type wildcardTypeHolder = TypesFactory.getType(getWildcardType());
+ ELType wildcardTypeHolder = typesFactory.getType(getWildcardType());
assertNotNull(wildcardTypeHolder);
assertEquals(List.class, wildcardTypeHolder.getRawType());
- Type[] wildcardTypeHolderArguments = wildcardTypeHolder.getTypeArguments();
+ ELType[] wildcardTypeHolderArguments = wildcardTypeHolder.getTypeArguments();
assertNotNull(wildcardTypeHolderArguments);
assertEquals(1, wildcardTypeHolderArguments.length);
- Type wildcardType = wildcardTypeHolderArguments[0];
+ ELType wildcardType = wildcardTypeHolderArguments[0];
assertEquals("? extends java.lang.String", wildcardType.getCode());
}
@Test
public void testGetTypeFromString() throws Exception {
- ClassLoader classLoader = getClass().getClassLoader();
- Type primitiveIntType = TypesFactory.getType("int", classLoader);
+ ELType primitiveIntType = typesFactory.getType("int");
assertNotNull(primitiveIntType);
assertEquals(Integer.TYPE, primitiveIntType.getRawType());
- Type guessedMapType = TypesFactory.getType("Map", classLoader);
+ ELType guessedMapType = typesFactory.getType("Map");
assertNotNull(guessedMapType);
assertEquals(Map.class, guessedMapType.getRawType());
assertNull(guessedMapType.getTypeArguments());
- Type writerType = TypesFactory.getType(java.io.Writer.class.getName(),
classLoader);
+ ELType writerType = typesFactory.getType(java.io.Writer.class.getName());
assertNotNull(writerType);
assertEquals(Writer.class, writerType.getRawType());
assertNull(writerType.getTypeArguments());
- Type genericMapType = TypesFactory.getType("Map<String, Object>",
classLoader);
+ ELType genericMapType = typesFactory.getType("Map<String,
Object>");
assertNotNull(genericMapType);
assertEquals(Map.class, genericMapType.getRawType());
- Type[] genericMapTypeArguments = genericMapType.getTypeArguments();
+ ELType[] genericMapTypeArguments = genericMapType.getTypeArguments();
assertNotNull(genericMapTypeArguments);
assertFalse(genericMapType.isArray());
assertEquals(2, genericMapTypeArguments.length);
- Type genericMapTypeKeyArgument = genericMapTypeArguments[0];
+ ELType genericMapTypeKeyArgument = genericMapTypeArguments[0];
assertEquals(String.class, genericMapTypeKeyArgument.getRawType());
- Type genericMapTypeValueArgument = genericMapTypeArguments[1];
+ ELType genericMapTypeValueArgument = genericMapTypeArguments[1];
assertEquals(Object.class, genericMapTypeValueArgument.getRawType());
- Type arrayType = TypesFactory.getType("String[]", classLoader);
+ ELType arrayType = typesFactory.getType("String[]");
assertNotNull(arrayType);
assertTrue(arrayType.isArray());
assertEquals(String[].class, arrayType.getRawType());
- Type genericArrayType = TypesFactory.getType("List<String>[]",
classLoader);
+ ELType genericArrayType =
typesFactory.getType("List<String>[]");
assertNotNull(genericArrayType);
assertTrue(genericArrayType.isArray());
assertEquals(List[].class, genericArrayType.getRawType());
- Type[] genericArrayTypeArguments = genericArrayType.getTypeArguments();
+ ELType[] genericArrayTypeArguments = genericArrayType.getTypeArguments();
assertNotNull(genericArrayTypeArguments);
assertEquals(1, genericArrayTypeArguments.length);
- Type genericArrayTypeArgument = genericArrayTypeArguments[0];
+ ELType genericArrayTypeArgument = genericArrayTypeArguments[0];
assertEquals(String.class, genericArrayTypeArgument.getRawType());
}
@Test
public void testReferencedType() throws Exception {
- ClassLoader classLoader = getClass().getClassLoader();
String className = "some.not.available.Class";
- Type plainReferencedType = TypesFactory.getType(className, classLoader);
+ ELType plainReferencedType = typesFactory.getType(className);
assertNotNull(plainReferencedType);
assertEquals(className, plainReferencedType.getCode());
String arraySignature = className + "[]";
- Type arrayReferencedType = TypesFactory.getType(arraySignature, classLoader);
+ ELType arrayReferencedType = typesFactory.getType(arraySignature);
assertNotNull(arrayReferencedType);
assertTrue(arrayReferencedType.isArray());
assertEquals(arraySignature, arrayReferencedType.getCode());
String genericSignature = className + "<String>";
- Type genericReferenceType = TypesFactory.getType(genericSignature, classLoader);
+ ELType genericReferenceType = typesFactory.getType(genericSignature);
assertNotNull(genericReferenceType);
assertEquals(genericSignature, genericReferenceType.getCode());
- Type[] genericTypeArguments = genericReferenceType.getTypeArguments();
+ ELType[] genericTypeArguments = genericReferenceType.getTypeArguments();
assertNotNull(genericTypeArguments);
assertEquals(1, genericTypeArguments.length);
- Type genericTypeArgument = genericTypeArguments[0];
+ ELType genericTypeArgument = genericTypeArguments[0];
assertEquals(String.class, genericTypeArgument.getRawType());
}
}