Author: Alex.Kolonitsky
Date: 2009-11-01 11:21:55 -0500 (Sun, 01 Nov 2009)
New Revision: 15790
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkContext.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkContextBase.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkError.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkException.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkProcessingError.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkWorker.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkWriter.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/DummyBuilder.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/DummyGenerator.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/JavaLogger.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/LibraryBuilder.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/Logger.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/LoggerFactory.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/ModelBuilder.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/ModelValidator.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/NamingConventions.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/RichFacesConventions.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/StandardOutputFolders.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/StandardOutputs.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/StandardSources.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/ValidatorImpl.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptBuilder.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptException.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/CdkProcessor.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ComponentProcessor.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/VirtualFileManager.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/VirtualJavaClassPathObject.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/VirtualJavaFileObject.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/VirtualJavaFileSystemObject.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/CdkConfiguration.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/ComponentTemplateModel.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/FreeMarkerRenderer.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/LibraryModelWrapper.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/PropertyModel.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ComponentClassGenerator.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Attribute.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Behavior.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/BehaviorRenderer.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ClassDescription.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Component.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ComponentLibrary.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ConfigExtension.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Converter.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/DescriptionGroup.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Event.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/EventName.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Extensible.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Facet.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/InvalidNameException.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Key.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/LibraryVisitor.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Listener.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Merge.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Mergeable.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ModelCollection.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ModelElement.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ModelElementBase.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Name.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Properties.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Property.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/RenderKit.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Renderer.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Searchable.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/SearchableCollection.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Tag.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/TagLibrary.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Trackable.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Validator.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Visitable.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/package-info.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/package-info.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/ELReflectionUtils.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/ELVisitor.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/ParsingException.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/StringUtils.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AbstractArithmeticTreeNode.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AbstractBooleanTreeNode.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AbstractTreeNode.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstAndTreeNode.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstBracketSuffixTreeNode.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstChoiceTreeNode.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstDeferredExpressionTreeNode.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstDivTreeNode.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstEmptyTreeNode.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstEqualTreeNode.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstFalseTreeNode.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstFloatingPointTreeNode.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstFunctionTreeNode.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstGreaterThanEqualTreeNode.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstGreaterThanTreeNode.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstIdentifierTreeNode.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstIntegerTreeNode.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstLessThanEqualTreeNode.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstLessThanTreeNode.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstLiteralTreeNode.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstMethodSuffixTreeNode.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstMinusTreeNode.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstModTreeNode.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstMultTreeNode.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstNegativeTreeNode.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstNotEqualTreeNode.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstNotTreeNode.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstNullTreeNode.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstOrTreeNode.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstPlusTreeNode.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstPropertySuffixTreeNode.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstStringTreeNode.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstTrueTreeNode.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstValueTreeNode.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/ELNodeConstants.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/ITreeNode.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/util/PropertyUtils.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/util/Strings.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/CdkEntityResolver.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FacesConfigGenerator.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FacesConfigNamespacePreffixMapper.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FacesConfigParser.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FragmentParser.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/JAXBBinding.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/AttributeAdapter.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/AttributeBean.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/BehaviorRendererAdapter.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/BehaviorRendererBean.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ClassAdapter.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ClassBean.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ComponentAdapter.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ComponentBean.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/DescriptionGroupBean.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/EventAdapter.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/EventBean.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ExtensibleBean.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/FacesConfigAdapter.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/FacesConfigBean.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/FacetAdapter.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/FacetBean.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/Properties.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/PropertyAdapter.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/PropertyBean.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/RenderKitAdapter.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/RenderKitBean.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/RendererAdapter.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/RendererBean.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/package-info.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/NamesListComparator.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/ParsingException.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/XMLBody.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/XMLBodyMerge.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/XMLBodySerializer.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/XPathComparator.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/dtd/Attribute.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/dtd/DocumentDefinition.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/dtd/DocumentDefinitionFactory.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/dtd/Element.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/dtd/Node.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/dtd/wutka/WutkaDefinitionFactory.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/dtd/xerces/XercesDefinitionFactory.java
Log:
Code style policy
https://jira.jboss.org/jira/browse/RFPL-195
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkContext.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkContext.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkContext.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -4,90 +4,87 @@
import org.richfaces.cdk.CdkWriter.OutputType;
-
-
/**
* <p class="changed_added_4_0">
* That interface defines context for all CDK operations
* </p>
- *
+ *
* @author asmirnov(a)exadel.com
- *
+ *
*/
public interface CdkContext {
-
- /**
- * <p class="changed_added_4_0">Id of source files e.g. Java classes,
faces-configs, renderer templates</p>
- * @author asmirnov(a)exadel.com
- *
- */
- public interface SourceType {
- String getName();
- }
- /**
- * <p class="changed_added_4_0">
- * Tools classloader.
- * </p>
- *
- * @return the loader
- */
- public ClassLoader getLoader();
+ /**
+ * <p class="changed_added_4_0">
+ * Tools classloader.
+ * </p>
+ *
+ * @return the loader
+ */
+ public ClassLoader getLoader();
- /**
- * <p class="changed_added_4_0">Get all sources for given
type.</p>
- * @param type
- * @return
- */
- public Iterable<File> getSources(SourceType type);
-
- /**
- * <p class="changed_added_4_0">Provides default output folder for given
output type.</p>
- * TODO - define "output families" to group similar outputs ( classes,
resources, tests ... ).
- * @param type of output
- * @return output folder for requested type.
- */
- public File getOutputFolder(OutputType type);
-
-
- /**
- * <p class="changed_added_4_0">This method creates output file in the
appropriate output folder. If target file exists and its modification time is late than
model modification time from {@code lastModified} parameter, no new file will be
created.</p>
- * @param output target output folder.
- * @param relativePath path to file in the output folder.
- * @param lastModified model modification time. If that parameter is less then 0, no
checks for existing file will be performed.
- * @return new created file or null if the target file exists and its modification time
is late then model.
- */
- public File createOutputFile(OutputType output,String relativePath,long lastModified)
throws CdkException;
- /**
- * <p class="changed_added_4_0">Record recowerable CdkError. To avoid
consequence builds of the project with many errors, all non-fatal errors ( Java
compilation errors, incorrect xml fales, inconsistent component descriptions ) these error
are stored in the context and marks whole build failed.</p>
- * @param error
- */
- public void sendError(CdkError error);
+ /**
+ * <p class="changed_added_4_0">Get all sources for given
type.</p>
+ * @param type
+ * @return
+ */
+ public Iterable<File> getSources(SourceType type);
- public abstract Iterable<CdkError> getErrors();
+ /**
+ * <p class="changed_added_4_0">Provides default output folder for
given output type.</p>
+ * TODO - define "output families" to group similar outputs ( classes,
resources, tests ... ).
+ * @param type of output
+ * @return output folder for requested type.
+ */
+ public File getOutputFolder(OutputType type);
- /**
- * <p class="changed_added_4_0"></p>
- * @param type
- * @return
- */
- public Iterable<File> getSourceFolders(SourceType type);
-
- /**
- * <p class="changed_added_4_0"></p>
- * @param <W>
- * @param workerClass
- * @return
- * @throws CdkException
- */
- public <W extends CdkWorker> W getWorkerInstance(Class<W> workerClass)
throws CdkException;
-
- /**
- * <p class="changed_added_4_0">Get value of configuration
option.</p>
- * TODO make it type safe.
- * @param name option name.
- * @return option value or null.
- */
- public String getOption(String name);
+ /**
+ * <p class="changed_added_4_0">This method creates output file in
the appropriate output folder. If target file exists and its modification time is late
than model modification time from {@code lastModified} parameter, no new file will be
created.</p>
+ * @param output target output folder.
+ * @param relativePath path to file in the output folder.
+ * @param lastModified model modification time. If that parameter is less then 0, no
checks for existing file will be performed.
+ * @return new created file or null if the target file exists and its modification
time is late then model.
+ */
+ public File createOutputFile(OutputType output, String relativePath, long
lastModified) throws CdkException;
-}
\ No newline at end of file
+ /**
+ * <p class="changed_added_4_0">Record recowerable CdkError. To avoid
consequence builds of the project with many errors, all non-fatal errors ( Java
compilation errors, incorrect xml fales, inconsistent component descriptions ) these error
are stored in the context and marks whole build failed.</p>
+ * @param error
+ */
+ public void sendError(CdkError error);
+
+ public abstract Iterable<CdkError> getErrors();
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param type
+ * @return
+ */
+ public Iterable<File> getSourceFolders(SourceType type);
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param <W>
+ * @param workerClass
+ * @return
+ * @throws CdkException
+ */
+ public <W extends CdkWorker> W getWorkerInstance(Class<W> workerClass)
throws CdkException;
+
+ /**
+ * <p class="changed_added_4_0">Get value of configuration
option.</p>
+ * TODO make it type safe.
+ * @param name option name.
+ * @return option value or null.
+ */
+ public String getOption(String name);
+
+ /**
+ * <p class="changed_added_4_0">Id of source files e.g. Java classes,
faces-configs, renderer templates</p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+ public interface SourceType {
+ String getName();
+ }
+}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkContextBase.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkContextBase.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkContextBase.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -21,20 +21,22 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+
+import org.richfaces.cdk.CdkWriter.OutputType;
+
import java.io.File;
import java.io.IOException;
+
import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import org.richfaces.cdk.CdkWriter.OutputType;
-import org.richfaces.cdk.model.ComponentLibrary;
-
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-
/**
* <p class="changed_added_4_0">Base CDK context class. Particular build
tool ( Ant, Maven ) should extend that class with
* tool-specific methods.</p>
@@ -42,156 +44,161 @@
*
*/
public class CdkContextBase implements CdkContext {
+ private Map<String, String> options = Maps.newHashMap();
+ private Map<SourceType, Iterable<File>> sources = Maps.newHashMap();
+ private Map<OutputType, File> outputs = Maps.newHashMap();
+ private Map<SourceType, Iterable<File>> inputFolders =
Maps.newHashMap();
+ private Map<Class<? extends CdkWorker>, CdkWorker> workers =
Maps.newHashMap();
+ private List<CdkError> errors = Lists.newArrayList();
+ private final ClassLoader loader;
- private final ClassLoader loader;
-
- private Map<String, String> options = Maps.newHashMap();
+ public CdkContextBase(ClassLoader loader) {
+ this.loader = loader;
+ }
- private Map<SourceType, Iterable<File>> sources = Maps.newHashMap();
-
- private Map<OutputType,File> outputs = Maps.newHashMap();
-
- private Map<SourceType,Iterable<File>> inputFolders = Maps.newHashMap();
+ /*
+ * (non-Javadoc)
+ * @see org.richfaces.cdk.CdkContext#getLoader()
+ */
+ public ClassLoader getLoader() {
+ return loader;
+ }
- private Map<Class<? extends CdkWorker>,CdkWorker> workers =
Maps.newHashMap();
+ public void addSources(SourceType type, Iterable<File> files) {
+ sources.put(type, files);
+ }
- private List<CdkError> errors = Lists.newArrayList();
+ @Override
+ public Iterable<File> getSources(SourceType type) {
+ return sources.get(type);
+ }
- public CdkContextBase(ClassLoader loader) {
- this.loader = loader;
- }
+ @Override
+ public File getOutputFolder(OutputType type) {
+ File outputFolder = outputs.get(type);
+ OutputType folderType = type.getFolderType();
- /* (non-Javadoc)
- * @see org.richfaces.cdk.CdkContext#getLoader()
- */
- public ClassLoader getLoader() {
- return loader;
- }
+ if (null == outputFolder && null != folderType) {
- public void addSources(SourceType type,Iterable<File> files) {
- sources.put(type, files);
- }
-
- @Override
- public Iterable<File> getSources(SourceType type) {
- return sources.get(type);
- }
+ // Lookup for standard folder type.
+ outputFolder = outputs.get(folderType);
- @Override
- public File getOutputFolder(OutputType type) {
- File outputFolder = outputs.get(type);
- OutputType folderType = type.getFolderType();
- if(null == outputFolder && null != folderType){
- // Lookup for standard folder type.
- outputFolder = outputs.get(folderType);
- // Lookup for output with same folder type.
- Iterator<OutputType> keysIterator = outputs.keySet().iterator();
- while (null == outputFolder && keysIterator.hasNext()) {
- CdkWriter.OutputType outputType = (CdkWriter.OutputType) keysIterator
- .next();
- if(folderType.equals(outputType.getFolderType())){
- outputFolder = outputs.get(outputType);
- }
- }
- }
- return outputFolder;
- }
+ // Lookup for output with same folder type.
+ Iterator<OutputType> keysIterator = outputs.keySet().iterator();
-
- public void setOutputFolder(OutputType type, File folder) {
- outputs.put(type, folder);
- }
-
- @Override
- public void sendError(CdkError error) {
- errors.add(error);
- }
-
- @Override
- public Iterable<CdkError> getErrors() {
- return errors;
- }
-
+ while (null == outputFolder && keysIterator.hasNext()) {
+ CdkWriter.OutputType outputType = (CdkWriter.OutputType)
keysIterator.next();
- @Override
- public Iterable<File> getSourceFolders(SourceType type) {
- return inputFolders.get(type);
- }
-
-
- public void setSourceFolders(SourceType type, Iterable<File> folders){
- inputFolders.put(type, folders);
- }
+ if (folderType.equals(outputType.getFolderType())) {
+ outputFolder = outputs.get(outputType);
+ }
+ }
+ }
- @Override
- public <W extends CdkWorker> W getWorkerInstance(Class<W> workerClass)
- throws CdkException {
- CdkWorker worker = workers.get(workerClass);
- if(null == worker){
- // instantiate worker.
- try {
- worker = workerClass.newInstance();
- worker.init(this);
- workers.put(workerClass, worker);
- } catch (InstantiationException e) {
- throw new CdkException("error to instantiate cdk component
"+workerClass.getName(), e);
- } catch (IllegalAccessException e) {
- throw new CdkException("Illegal access to cdk component
"+workerClass.getName(), e);
- }
- }
- return (W) worker;
- }
-
+ return outputFolder;
+ }
- public void addWorker(Class<? extends CdkWorker> workerClass, CdkWorker
workerInstance) {
- workers.put(workerClass, workerInstance);
- }
+ public void setOutputFolder(OutputType type, File folder) {
+ outputs.put(type, folder);
+ }
- @Override
- public File createOutputFile(OutputType output, String relativePath,
- long lastModified) throws CdkException {
- if(null == relativePath){
- throw new NullPointerException();
- }
- File outputFolder = getOutputFolder(output);
- if(null == outputFolder){
- throw new CdkException("No output folder for type "+output.getName());
- }
- if(outputFolder.exists() && !outputFolder.isDirectory()){
- throw new CdkException("Output folder "+outputFolder+" not is
directory.");
- }
- // Strip leading '/'
- if(relativePath.startsWith(File.separator)){
- relativePath = relativePath.substring(1);
- }
- File outputFile = new File(outputFolder,relativePath);
- if(outputFile.exists()){
- if(lastModified > 0 && outputFile.lastModified() > lastModified){
- return null;
- } else {
- outputFile.delete();
- }
- }
- // Create file folder.
- outputFile.getParentFile().mkdirs();
- try {
- outputFile.createNewFile();
- } catch (IOException e) {
- throw new CdkException("Error create output file", e);
- }
- return outputFile;
- }
+ @Override
+ public void sendError(CdkError error) {
+ errors.add(error);
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param options the options to set
- */
- public void setOptions(Map<String, String> options) {
- this.options.putAll(options);
- }
-
- @Override
- public String getOption(String name) {
- return options.get(name);
- }
+ @Override
+ public Iterable<CdkError> getErrors() {
+ return errors;
+ }
+
+ @Override
+ public Iterable<File> getSourceFolders(SourceType type) {
+ return inputFolders.get(type);
+ }
+
+ public void setSourceFolders(SourceType type, Iterable<File> folders) {
+ inputFolders.put(type, folders);
+ }
+
+ @Override
+ public <W extends CdkWorker> W getWorkerInstance(Class<W> workerClass)
throws CdkException {
+ CdkWorker worker = workers.get(workerClass);
+
+ if (null == worker) {
+
+ // instantiate worker.
+ try {
+ worker = workerClass.newInstance();
+ worker.init(this);
+ workers.put(workerClass, worker);
+ } catch (InstantiationException e) {
+ throw new CdkException("error to instantiate cdk component " +
workerClass.getName(), e);
+ } catch (IllegalAccessException e) {
+ throw new CdkException("Illegal access to cdk component " +
workerClass.getName(), e);
+ }
+ }
+
+ return (W) worker;
+ }
+
+ public void addWorker(Class<? extends CdkWorker> workerClass, CdkWorker
workerInstance) {
+ workers.put(workerClass, workerInstance);
+ }
+
+ @Override
+ public File createOutputFile(OutputType output, String relativePath, long
lastModified) throws CdkException {
+ if (null == relativePath) {
+ throw new NullPointerException();
+ }
+
+ File outputFolder = getOutputFolder(output);
+
+ if (null == outputFolder) {
+ throw new CdkException("No output folder for type " +
output.getName());
+ }
+
+ if (outputFolder.exists() && !outputFolder.isDirectory()) {
+ throw new CdkException("Output folder " + outputFolder + " not
is directory.");
+ }
+
+ // Strip leading '/'
+ if (relativePath.startsWith(File.separator)) {
+ relativePath = relativePath.substring(1);
+ }
+
+ File outputFile = new File(outputFolder, relativePath);
+
+ if (outputFile.exists()) {
+ if (lastModified > 0 && outputFile.lastModified() >
lastModified) {
+ return null;
+ } else {
+ outputFile.delete();
+ }
+ }
+
+ // Create file folder.
+ outputFile.getParentFile().mkdirs();
+
+ try {
+ outputFile.createNewFile();
+ } catch (IOException e) {
+ throw new CdkException("Error create output file", e);
+ }
+
+ return outputFile;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param options the options to set
+ */
+ public void setOptions(Map<String, String> options) {
+ this.options.putAll(options);
+ }
+
+ @Override
+ public String getOption(String name) {
+ return options.get(name);
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkError.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkError.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkError.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk;
/**
@@ -29,29 +31,49 @@
*
*/
public class CdkError {
-
- private String message;
-
- private String description;
-
- private Throwable cause;
+ private Throwable cause;
+ private String description;
+ private String message;
- /**
- * <p class="changed_added_4_0"></p>
- * @param message
- */
- public CdkError(String message) {
- this.message = message;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param message
+ */
+ public CdkError(String message) {
+ this.message = message;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param message
- * @param cause
- */
- public CdkError(String message, Throwable cause) {
- this.message = message;
- this.cause = cause;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param message
+ * @param cause
+ */
+ public CdkError(String message, Throwable cause) {
+ this.message = message;
+ this.cause = cause;
+ }
+ public Throwable getCause() {
+ return cause;
+ }
+
+ public void setCause(Throwable cause) {
+ this.cause = cause;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkException.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkException.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkException.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk;
/**
@@ -30,35 +32,33 @@
*/
public class CdkException extends Exception {
- /**
- * <p class="changed_added_4_0"></p>
- */
- public CdkException() {
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ */
+ public CdkException() {}
- /**
- * <p class="changed_added_4_0"></p>
- * @param message
- */
- public CdkException(String message) {
- super(message);
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param message
+ */
+ public CdkException(String message) {
+ super(message);
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param cause
- */
- public CdkException(Throwable cause) {
- super(cause);
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param cause
+ */
+ public CdkException(Throwable cause) {
+ super(cause);
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param message
- * @param cause
- */
- public CdkException(String message, Throwable cause) {
- super(message, cause);
- }
-
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param message
+ * @param cause
+ */
+ public CdkException(String message, Throwable cause) {
+ super(message, cause);
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkProcessingError.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkProcessingError.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkProcessingError.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -21,52 +21,53 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk;
/**
* <p class="changed_added_4_0">That exception indicates recoverable CDK
error, that it is, means
- * errors in source code or configuration files that makes project build failed, so no
result shulde be generated, but does not
- * stop further processing of other classes or files. CDK should collect such errors but
do not
- * stop processing that let developer to know about all errors in the project.</p>
+ * errors in source code or configuration files that makes project build failed, so no
result shulde be generated,
+ * but does not stop further processing of other classes or files. CDK should collect
such errors but do not stop
+ * processing that let developer to know about all errors in the project.</p>
+ *
* @author asmirnov(a)exadel.com
*
*/
public class CdkProcessingError extends CdkException {
- /**
- * <p class="changed_added_4_0"></p>
- */
- private static final long serialVersionUID = -3696046213271071968L;
+ /**
+ * <p class="changed_added_4_0"></p>
+ */
+ private static final long serialVersionUID = -3696046213271071968L;
- /**
- * <p class="changed_added_4_0"></p>
- */
- public CdkProcessingError() {
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ */
+ public CdkProcessingError() {}
- /**
- * <p class="changed_added_4_0"></p>
- * @param message
- */
- public CdkProcessingError(String message) {
- super(message);
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param message
+ */
+ public CdkProcessingError(String message) {
+ super(message);
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param cause
- */
- public CdkProcessingError(Throwable cause) {
- super(cause);
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param cause
+ */
+ public CdkProcessingError(Throwable cause) {
+ super(cause);
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param message
- * @param cause
- */
- public CdkProcessingError(String message, Throwable cause) {
- super(message, cause);
- }
-
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param message
+ * @param cause
+ */
+ public CdkProcessingError(String message, Throwable cause) {
+ super(message, cause);
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkWorker.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkWorker.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkWorker.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk;
/**
@@ -30,7 +32,5 @@
*
*/
public interface CdkWorker {
-
- public void init(CdkContext context) throws CdkException;
-
+ public void init(CdkContext context) throws CdkException;
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkWriter.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkWriter.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkWriter.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk;
import org.richfaces.cdk.model.ComponentLibrary;
@@ -31,13 +33,11 @@
*
*/
public interface CdkWriter extends CdkWorker {
-
- interface OutputType {
- String getName();
- OutputType getFolderType();
- }
-
-
- public void render(ComponentLibrary library) throws CdkException;
+ public void render(ComponentLibrary library) throws CdkException;
+ interface OutputType {
+ String getName();
+
+ OutputType getFolderType();
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/DummyBuilder.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/DummyBuilder.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/DummyBuilder.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk;
import org.richfaces.cdk.model.ComponentLibrary;
@@ -31,26 +33,27 @@
*
*/
public class DummyBuilder implements ModelBuilder {
+ private CdkContext context;
- private CdkContext context;
+ /*
+ * (non-Javadoc)
+ * @see org.richfaces.cdk.ModelBuilder#build()
+ */
+ @Override
+ public ComponentLibrary build() throws CdkException {
+ return new ComponentLibrary();
+ }
- /* (non-Javadoc)
- * @see org.richfaces.cdk.ModelBuilder#build()
- */
- @Override
- public ComponentLibrary build() throws CdkException {
- return new ComponentLibrary();
- }
+ /*
+ * (non-Javadoc)
+ * @see org.richfaces.cdk.ModelBuilder#init(org.richfaces.cdk.CdkContext)
+ */
+ @Override
+ public void init(CdkContext context) {
+ this.context = context;
+ }
- /* (non-Javadoc)
- * @see org.richfaces.cdk.ModelBuilder#init(org.richfaces.cdk.CdkContext)
- */
- @Override
- public void init(CdkContext context) {
- this.context = context;
- }
-
- protected CdkContext getContext() {
- return context;
- }
+ protected CdkContext getContext() {
+ return context;
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/DummyGenerator.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/DummyGenerator.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/DummyGenerator.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk;
import org.richfaces.cdk.model.ComponentLibrary;
@@ -31,27 +33,28 @@
*
*/
public class DummyGenerator implements CdkWriter {
+ private CdkContext context;
- private CdkContext context;
+ /*
+ * (non-Javadoc)
+ * @see org.richfaces.cdk.CdkWriter#init(org.richfaces.cdk.CdkContext)
+ */
+ @Override
+ public void init(CdkContext context) throws CdkException {
+ this.context = context;
+ }
- /* (non-Javadoc)
- * @see org.richfaces.cdk.CdkWriter#init(org.richfaces.cdk.CdkContext)
- */
- @Override
- public void init(CdkContext context) throws CdkException {
- this.context = context;
- }
+ /*
+ * (non-Javadoc)
+ * @see org.richfaces.cdk.CdkWriter#render(org.richfaces.cdk.model.ComponentLibrary)
+ */
+ @Override
+ public void render(ComponentLibrary library) throws CdkException {
- /* (non-Javadoc)
- * @see org.richfaces.cdk.CdkWriter#render(org.richfaces.cdk.model.ComponentLibrary)
- */
- @Override
- public void render(ComponentLibrary library) throws CdkException {
- // Do nothing
- }
-
- protected CdkContext getContext() {
- return context;
- }
+ // Do nothing
+ }
+ protected CdkContext getContext() {
+ return context;
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/JavaLogger.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/JavaLogger.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/JavaLogger.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk;
import java.util.logging.Level;
@@ -31,138 +33,149 @@
*
*/
class JavaLogger implements Logger {
-
- java.util.logging.Logger jdkLogger =
java.util.logging.Logger.getLogger(LoggerFactory.CDK_LOG);
+ java.util.logging.Logger jdkLogger =
java.util.logging.Logger.getLogger(LoggerFactory.CDK_LOG);
- /* (non-Javadoc)
- * @see org.richfaces.cdk.Logger#debug(java.lang.CharSequence)
- */
- @Override
- public void debug(CharSequence content) {
- jdkLogger.fine(String.valueOf(content));
- }
+ /*
+ * (non-Javadoc)
+ * @see org.richfaces.cdk.Logger#debug(java.lang.CharSequence)
+ */
+ @Override
+ public void debug(CharSequence content) {
+ jdkLogger.fine(String.valueOf(content));
+ }
- /* (non-Javadoc)
- * @see org.richfaces.cdk.Logger#debug(java.lang.CharSequence, java.lang.Throwable)
- */
- @Override
- public void debug(CharSequence content, Throwable error) {
- jdkLogger.log(Level.FINE, String.valueOf(content), error);
- }
+ /*
+ * (non-Javadoc)
+ * @see org.richfaces.cdk.Logger#debug(java.lang.CharSequence, java.lang.Throwable)
+ */
+ @Override
+ public void debug(CharSequence content, Throwable error) {
+ jdkLogger.log(Level.FINE, String.valueOf(content), error);
+ }
- /* (non-Javadoc)
- * @see org.richfaces.cdk.Logger#debug(java.lang.Throwable)
- */
- @Override
- public void debug(Throwable error) {
- jdkLogger.log(Level.FINE, "", error);
- }
+ /*
+ * (non-Javadoc)
+ * @see org.richfaces.cdk.Logger#debug(java.lang.Throwable)
+ */
+ @Override
+ public void debug(Throwable error) {
+ jdkLogger.log(Level.FINE, "", error);
+ }
- /* (non-Javadoc)
- * @see org.richfaces.cdk.Logger#error(java.lang.CharSequence)
- */
- @Override
- public void error(CharSequence content) {
- jdkLogger.severe(String.valueOf(content));
+ /*
+ * (non-Javadoc)
+ * @see org.richfaces.cdk.Logger#error(java.lang.CharSequence)
+ */
+ @Override
+ public void error(CharSequence content) {
+ jdkLogger.severe(String.valueOf(content));
+ }
- }
+ /*
+ * (non-Javadoc)
+ * @see org.richfaces.cdk.Logger#error(java.lang.CharSequence, java.lang.Throwable)
+ */
+ @Override
+ public void error(CharSequence content, Throwable error) {
+ jdkLogger.log(Level.SEVERE, String.valueOf(content), error);
+ }
- /* (non-Javadoc)
- * @see org.richfaces.cdk.Logger#error(java.lang.CharSequence, java.lang.Throwable)
- */
- @Override
- public void error(CharSequence content, Throwable error) {
- jdkLogger.log(Level.SEVERE, String.valueOf(content), error);
- }
+ /*
+ * (non-Javadoc)
+ * @see org.richfaces.cdk.Logger#error(java.lang.Throwable)
+ */
+ @Override
+ public void error(Throwable error) {
+ jdkLogger.log(Level.SEVERE, "", error);
+ }
- /* (non-Javadoc)
- * @see org.richfaces.cdk.Logger#error(java.lang.Throwable)
- */
- @Override
- public void error(Throwable error) {
- jdkLogger.log(Level.SEVERE, "", error);
- }
+ /*
+ * (non-Javadoc)
+ * @see org.richfaces.cdk.Logger#info(java.lang.CharSequence)
+ */
+ @Override
+ public void info(CharSequence content) {
+ jdkLogger.info(String.valueOf(content));
+ }
- /* (non-Javadoc)
- * @see org.richfaces.cdk.Logger#info(java.lang.CharSequence)
- */
- @Override
- public void info(CharSequence content) {
- jdkLogger.info(String.valueOf(content));
- }
+ /*
+ * (non-Javadoc)
+ * @see org.richfaces.cdk.Logger#info(java.lang.CharSequence, java.lang.Throwable)
+ */
+ @Override
+ public void info(CharSequence content, Throwable error) {
+ jdkLogger.log(Level.INFO, String.valueOf(content), error);
+ }
- /* (non-Javadoc)
- * @see org.richfaces.cdk.Logger#info(java.lang.CharSequence, java.lang.Throwable)
- */
- @Override
- public void info(CharSequence content, Throwable error) {
- jdkLogger.log(Level.INFO, String.valueOf(content), error);
+ /*
+ * (non-Javadoc)
+ * @see org.richfaces.cdk.Logger#info(java.lang.Throwable)
+ */
+ @Override
+ public void info(Throwable error) {
+ jdkLogger.log(Level.INFO, "", error);
+ }
- }
+ /*
+ * (non-Javadoc)
+ * @see org.richfaces.cdk.Logger#isDebugEnabled()
+ */
+ @Override
+ public boolean isDebugEnabled() {
+ return jdkLogger.isLoggable(Level.FINE);
+ }
- /* (non-Javadoc)
- * @see org.richfaces.cdk.Logger#info(java.lang.Throwable)
- */
- @Override
- public void info(Throwable error) {
- jdkLogger.log(Level.INFO, "", error);
- }
+ /*
+ * (non-Javadoc)
+ * @see org.richfaces.cdk.Logger#isErrorEnabled()
+ */
+ @Override
+ public boolean isErrorEnabled() {
+ return jdkLogger.isLoggable(Level.SEVERE);
+ }
- /* (non-Javadoc)
- * @see org.richfaces.cdk.Logger#isDebugEnabled()
- */
- @Override
- public boolean isDebugEnabled() {
- return jdkLogger.isLoggable(Level.FINE);
- }
+ /*
+ * (non-Javadoc)
+ * @see org.richfaces.cdk.Logger#isInfoEnabled()
+ */
+ @Override
+ public boolean isInfoEnabled() {
+ return jdkLogger.isLoggable(Level.INFO);
+ }
- /* (non-Javadoc)
- * @see org.richfaces.cdk.Logger#isErrorEnabled()
- */
- @Override
- public boolean isErrorEnabled() {
- return jdkLogger.isLoggable(Level.SEVERE);
- }
+ /*
+ * (non-Javadoc)
+ * @see org.richfaces.cdk.Logger#isWarnEnabled()
+ */
+ @Override
+ public boolean isWarnEnabled() {
+ return jdkLogger.isLoggable(Level.WARNING);
+ }
- /* (non-Javadoc)
- * @see org.richfaces.cdk.Logger#isInfoEnabled()
- */
- @Override
- public boolean isInfoEnabled() {
- return jdkLogger.isLoggable(Level.INFO);
- }
+ /*
+ * (non-Javadoc)
+ * @see org.richfaces.cdk.Logger#warn(java.lang.CharSequence)
+ */
+ @Override
+ public void warn(CharSequence content) {
+ jdkLogger.warning(String.valueOf(content));
+ }
- /* (non-Javadoc)
- * @see org.richfaces.cdk.Logger#isWarnEnabled()
- */
- @Override
- public boolean isWarnEnabled() {
- return jdkLogger.isLoggable(Level.WARNING);
- }
+ /*
+ * (non-Javadoc)
+ * @see org.richfaces.cdk.Logger#warn(java.lang.CharSequence, java.lang.Throwable)
+ */
+ @Override
+ public void warn(CharSequence content, Throwable error) {
+ jdkLogger.log(Level.WARNING, String.valueOf(content), error);
+ }
- /* (non-Javadoc)
- * @see org.richfaces.cdk.Logger#warn(java.lang.CharSequence)
- */
- @Override
- public void warn(CharSequence content) {
- jdkLogger.warning(String.valueOf(content));
- }
-
- /* (non-Javadoc)
- * @see org.richfaces.cdk.Logger#warn(java.lang.CharSequence, java.lang.Throwable)
- */
- @Override
- public void warn(CharSequence content, Throwable error) {
- jdkLogger.log(Level.WARNING, String.valueOf(content), error);
-
- }
-
- /* (non-Javadoc)
- * @see org.richfaces.cdk.Logger#warn(java.lang.Throwable)
- */
- @Override
- public void warn(Throwable error) {
- jdkLogger.log(Level.WARNING, "", error);
- }
-
+ /*
+ * (non-Javadoc)
+ * @see org.richfaces.cdk.Logger#warn(java.lang.Throwable)
+ */
+ @Override
+ public void warn(Throwable error) {
+ jdkLogger.log(Level.WARNING, "", error);
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/LibraryBuilder.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/LibraryBuilder.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/LibraryBuilder.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -21,228 +21,230 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk;
-import java.io.File;
+import com.google.common.collect.ImmutableMap;
import org.richfaces.builder.templates.RendererClassGenerator;
import org.richfaces.builder.templates.RendererTemplateParser;
import org.richfaces.cdk.CdkContext.SourceType;
import org.richfaces.cdk.CdkWriter.OutputType;
import org.richfaces.cdk.apt.AptBuilder;
-import org.richfaces.cdk.apt.CdkProcessor;
-import org.richfaces.cdk.apt.ComponentProcessor;
import org.richfaces.cdk.generate.java.ComponentClassGenerator;
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.xmlconfig.FacesConfigGenerator;
import org.richfaces.cdk.xmlconfig.FacesConfigParser;
-import com.google.common.collect.ImmutableMap;
-
/**
* <p class="changed_added_4_0">
* That class builds JSF library model from different sources. It acts as
* "controller" for whole CDK generation process.
* </p>
- *
+ *
* @author asmirnov(a)exadel.com
- *
+ *
*/
public final class LibraryBuilder implements CdkWorker {
- /**
- * <p class="changed_added_4_0">
- * Current CDK context
- * </p>
- */
- private CdkContext context;
+ /**
+ * Map contains writer classes for standard outputs.
+ */
+ private static final ImmutableMap<OutputType, Class<? extends CdkWriter>>
WRITERS =
+ ImmutableMap.<OutputType, Class<? extends
CdkWriter>>builder().put(StandardOutputs.COMPONENT_CLASSES,
+
ComponentClassGenerator.class).put(StandardOutputs.RENDERER_CLASSES,
+
RendererClassGenerator.class).put(StandardOutputs.FACES_CONFIG,
+ FacesConfigGenerator.class).build();
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @param context
- */
- public LibraryBuilder() {
-
- }
+ /**
+ * map contain library model builder classes for each source type.
+ */
+ private static final ImmutableMap<SourceType, Class<? extends
ModelBuilder>> BUILDERS =
+ ImmutableMap.<SourceType, Class<? extends
ModelBuilder>>builder().put(StandardSources.FACES_CONFIGS,
+ FacesConfigParser.class).put(StandardSources.JAVA_SOURCES,
+ AptBuilder.class).put(StandardSources.RENDERER_TEMPLATES,
+ RendererTemplateParser.class).build();
- @Override
- public void init(CdkContext context) throws CdkException {
- this.context = context;
- // default workers.
- }
+ /**
+ * <p class="changed_added_4_0">
+ * Current CDK context
+ * </p>
+ */
+ private CdkContext context;
- /**
- * <p class="changed_added_4_0">
- * Static factory method
- * </p>
- *
- * @return
- * @throws CdkException
- */
- public static LibraryBuilder createInstance(CdkContext context) throws CdkException {
- return context.getWorkerInstance(LibraryBuilder.class);
- }
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param context
+ */
+ public LibraryBuilder() {}
- /**
- * <p class="changed_added_4_0">
- * Parse source files for annotations and populate CDK-related information
- * into model.
- * </p>
- *
- * @param sources
- * Java Source files.
- * @return generated library model.
- * @throws CdkException
- */
- public ComponentLibrary buildModel(SourceType type) throws CdkException {
- ModelBuilder modelBuilder = getBuilderFor(type);
- ComponentLibrary library = modelBuilder.build();
- getVerifier().verify(library);
- return library;
- }
+ @Override
+ public void init(CdkContext context) throws CdkException {
+ this.context = context;
- /**
- * <p class="changed_added_4_0">
- * Build library model from all available sources.
- * </p>
- *
- * @param templates
- * @throws CdkException
- */
- public ComponentLibrary buildModel() throws CdkException {
- ComponentLibrary library = null;
- for (SourceType type : StandardSources.values()) {
- ComponentLibrary model = buildModel(type);
- if (null != model) {
- if (null != library) {
- library.merge(model);
- } else {
- library = model;
- }
- }
- }
- getVerifier().verify(library);
- return library;
- }
+ // default workers.
+ }
- /**
- * Generate all types of files from library model.
- * @param library
- * @throws CdkException
- */
- public void generate(ComponentLibrary library) throws CdkException {
- for (OutputType type : StandardOutputs.values()) {
- generate(library, type);
- }
- }
+ /**
+ * <p class="changed_added_4_0">
+ * Static factory method
+ * </p>
+ *
+ * @return
+ * @throws CdkException
+ */
+ public static LibraryBuilder createInstance(CdkContext context) throws CdkException
{
+ return context.getWorkerInstance(LibraryBuilder.class);
+ }
- /**
- * <p class="changed_added_4_0">
- * Cenerate files from library model for given type ( eg. component classes,
faces-config ).
- * </p>
- *
- * @param library model
- * @param type of generated files.
- * @throws CdkException
- */
- public void generate(ComponentLibrary library, OutputType type)
- throws CdkException {
- CdkWriter generator = getGeneratorFor(type);
- generator.render(library);
- }
-
- /**
- * Map contains writer classes for standard outputs.
- */
- private static final ImmutableMap<OutputType, Class<? extends CdkWriter>>
writers = ImmutableMap
- .<OutputType, Class<? extends CdkWriter>> builder().put(
- StandardOutputs.COMPONENT_CLASSES,
- ComponentClassGenerator.class).put(
- StandardOutputs.RENDERER_CLASSES,
- RendererClassGenerator.class).put(
- StandardOutputs.FACES_CONFIG, FacesConfigGenerator.class)
- .build();
+ /**
+ * <p class="changed_added_4_0">
+ * Parse source files for annotations and populate CDK-related information
+ * into model.
+ * </p>
+ *
+ * @param sources
+ * Java Source files.
+ * @return generated library model.
+ * @throws CdkException
+ */
+ public ComponentLibrary buildModel(SourceType type) throws CdkException {
+ ModelBuilder modelBuilder = getBuilderFor(type);
+ ComponentLibrary library = modelBuilder.build();
- /**
- * This method returns instance of {@link CdkWriter} for given output type.
- * @param type
- * @return
- * @throws CdkException
- */
- protected CdkWriter getGeneratorFor(OutputType type) throws CdkException {
- CdkWriter generator = null;
- Class<? extends CdkWriter> writerClass = writers.get(type);
- if (null != writerClass) {
- generator = context.getWorkerInstance(writerClass);
- } else {
- generator = new DummyGenerator();
- generator.init(getContext());
- // TODO - make service method for new source types.
- // throw new CdkException("No generator for type " +
- // type.getName());
- }
- return generator;
- }
+ getVerifier().verify(library);
- /**
- * <p class="changed_added_4_0">
- * Builder method that creates new library instance.
- * </p>
- *
- * @return
- */
- public ComponentLibrary createLibrary() {
- return new ComponentLibrary();
- }
+ return library;
+ }
- /**
- * <p class="changed_added_4_0">
- * Getter for the current CDK context
- * </p>
- *
- * @return the context
- */
- protected CdkContext getContext() {
- return context;
- }
+ /**
+ * <p class="changed_added_4_0">
+ * Build library model from all available sources.
+ * </p>
+ *
+ * @param templates
+ * @throws CdkException
+ */
+ public ComponentLibrary buildModel() throws CdkException {
+ ComponentLibrary library = null;
+ for (SourceType type : StandardSources.values()) {
+ ComponentLibrary model = buildModel(type);
- /**
- * map contain library model builder classes for each source type.
- */
- private static final ImmutableMap<SourceType, Class<? extends ModelBuilder>>
builders = ImmutableMap
- .<SourceType, Class<? extends ModelBuilder>> builder().put(
- StandardSources.FACES_CONFIGS,
- FacesConfigParser.class).put(
- StandardSources.JAVA_SOURCES,
- AptBuilder.class).put(
- StandardSources.RENDERER_TEMPLATES, RendererTemplateParser.class)
- .build();
-
- /**
- * This method returns initialized instance of the {@link ModelBuilder} for given source
type.
- * @param type
- * @return
- * @throws CdkException
- */
- protected ModelBuilder getBuilderFor(SourceType type) throws CdkException {
- ModelBuilder builder;
- Class<? extends ModelBuilder> builderClass = builders.get(type);
- if (null != builderClass) {
- builder = context.getWorkerInstance(builderClass);
- } else {
- builder = new DummyBuilder();
- builder.init(getContext());
- // TODO - make service method for new source types.
- // throw new CdkException("No model builder for source type " +
- // type.getName());
- }
- return builder;
- }
+ if (null != model) {
+ if (null != library) {
+ library.merge(model);
+ } else {
+ library = model;
+ }
+ }
+ }
- protected ModelValidator getVerifier() throws CdkException {
- return getContext().getWorkerInstance(ModelValidator.class);
- }
+ getVerifier().verify(library);
+
+ return library;
+ }
+
+ /**
+ * Generate all types of files from library model.
+ * @param library
+ * @throws CdkException
+ */
+ public void generate(ComponentLibrary library) throws CdkException {
+ for (OutputType type : StandardOutputs.values()) {
+ generate(library, type);
+ }
+ }
+
+ /**
+ * <p class="changed_added_4_0">
+ * Cenerate files from library model for given type ( eg. component classes,
faces-config ).
+ * </p>
+ *
+ * @param library model
+ * @param type of generated files.
+ * @throws CdkException
+ */
+ public void generate(ComponentLibrary library, OutputType type) throws CdkException
{
+ CdkWriter generator = getGeneratorFor(type);
+
+ generator.render(library);
+ }
+
+ /**
+ * This method returns instance of {@link CdkWriter} for given output type.
+ * @param type
+ * @return
+ * @throws CdkException
+ */
+ protected CdkWriter getGeneratorFor(OutputType type) throws CdkException {
+ CdkWriter generator = null;
+ Class<? extends CdkWriter> writerClass = WRITERS.get(type);
+
+ if (null != writerClass) {
+ generator = context.getWorkerInstance(writerClass);
+ } else {
+ generator = new DummyGenerator();
+ generator.init(getContext());
+
+ // TODO - make service method for new source types.
+ // throw new CdkException("No generator for type " +
+ // type.getName());
+ }
+
+ return generator;
+ }
+
+ /**
+ * <p class="changed_added_4_0">
+ * Builder method that creates new library instance.
+ * </p>
+ *
+ * @return
+ */
+ public ComponentLibrary createLibrary() {
+ return new ComponentLibrary();
+ }
+
+ /**
+ * <p class="changed_added_4_0">
+ * Getter for the current CDK context
+ * </p>
+ *
+ * @return the context
+ */
+ protected CdkContext getContext() {
+ return context;
+ }
+
+ /**
+ * This method returns initialized instance of the {@link ModelBuilder} for given
source type.
+ * @param type
+ * @return
+ * @throws CdkException
+ */
+ protected ModelBuilder getBuilderFor(SourceType type) throws CdkException {
+ ModelBuilder builder;
+ Class<? extends ModelBuilder> builderClass = BUILDERS.get(type);
+
+ if (null != builderClass) {
+ builder = context.getWorkerInstance(builderClass);
+ } else {
+ builder = new DummyBuilder();
+ builder.init(getContext());
+
+ // TODO - make service method for new source types.
+ // throw new CdkException("No model builder for source type " +
+ // type.getName());
+ }
+
+ return builder;
+ }
+
+ protected ModelValidator getVerifier() throws CdkException {
+ return getContext().getWorkerInstance(ModelValidator.class);
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/Logger.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/Logger.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/Logger.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -19,6 +19,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk;
/**
@@ -29,38 +31,35 @@
*
*/
public interface Logger {
-
boolean isDebugEnabled();
-
- void debug( CharSequence content );
- void debug( CharSequence content, Throwable error );
+ void debug(CharSequence content);
- void debug( Throwable error );
+ void debug(CharSequence content, Throwable error);
+ void debug(Throwable error);
+
boolean isInfoEnabled();
-
- void info( CharSequence content );
- void info( CharSequence content, Throwable error );
+ void info(CharSequence content);
- void info( Throwable error );
+ void info(CharSequence content, Throwable error);
+ void info(Throwable error);
+
boolean isWarnEnabled();
-
- void warn( CharSequence content );
- void warn( CharSequence content, Throwable error );
+ void warn(CharSequence content);
- void warn( Throwable error );
+ void warn(CharSequence content, Throwable error);
+ void warn(Throwable error);
+
boolean isErrorEnabled();
-
- void error( CharSequence content );
- void error( CharSequence content, Throwable error );
+ void error(CharSequence content);
- void error( Throwable error );
+ void error(CharSequence content, Throwable error);
-
+ void error(Throwable error);
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/LoggerFactory.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/LoggerFactory.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/LoggerFactory.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk;
/**
@@ -29,115 +31,115 @@
*
*/
public final class LoggerFactory {
-
- private static final class LoggerWrapper implements Logger {
- @Override
- public void debug(CharSequence content) {
- logger.debug(content);
- }
+ public static final String CDK_LOG = "org.richfaces.cdk";
- @Override
- public void debug(CharSequence content, Throwable error) {
- logger.debug(content, error);
- }
+ /**
+ * <p class="changed_added_4_0">Current logger. By default all calls
will be sent to system
+ * {@link java.util.logging.Logger}</p>
+ */
+ private static Logger logger = new JavaLogger();
- @Override
- public void debug(Throwable error) {
- logger.debug(error);
- }
+ /**
+ * <p class="changed_added_4_0">
+ * That constant wraps current logger object to allow access to logger at
+ * the class instantiation time.
+ * </p>
+ */
+ private static final Logger WRAPPER = new LoggerWrapper();
- @Override
- public void error(CharSequence content) {
- logger.error(content);
- }
+ private LoggerFactory() {
- @Override
- public void error(CharSequence content, Throwable error) {
- logger.error(content, error);
- }
+ // That class has static methods only.
+ }
- @Override
- public void error(Throwable error) {
- logger.error(error);
- }
+ public static Logger getLogger() {
+ return WRAPPER;
+ }
- @Override
- public void info(CharSequence content) {
- logger.info(content);
- }
+ public static void setLogger(Logger newLogger) {
+ assert null != newLogger;
+ logger = newLogger;
+ }
- @Override
- public void info(CharSequence content, Throwable error) {
- logger.info(content, error);
- }
+ private static final class LoggerWrapper implements Logger {
+ @Override
+ public void debug(CharSequence content) {
+ logger.debug(content);
+ }
- @Override
- public void info(Throwable error) {
- logger.info(error);
- }
+ @Override
+ public void debug(CharSequence content, Throwable error) {
+ logger.debug(content, error);
+ }
- @Override
- public boolean isDebugEnabled() {
- return logger.isDebugEnabled();
- }
+ @Override
+ public void debug(Throwable error) {
+ logger.debug(error);
+ }
- @Override
- public boolean isErrorEnabled() {
- return logger.isErrorEnabled();
- }
+ @Override
+ public void error(CharSequence content) {
+ logger.error(content);
+ }
- @Override
- public boolean isInfoEnabled() {
- return logger.isInfoEnabled();
- }
+ @Override
+ public void error(CharSequence content, Throwable error) {
+ logger.error(content, error);
+ }
- @Override
- public boolean isWarnEnabled() {
- return logger.isWarnEnabled();
- }
+ @Override
+ public void error(Throwable error) {
+ logger.error(error);
+ }
- @Override
- public void warn(CharSequence content) {
- logger.warn(content);
- }
+ @Override
+ public void info(CharSequence content) {
+ logger.info(content);
+ }
- @Override
- public void warn(CharSequence content, Throwable error) {
- logger.warn(content, error);
-
- }
+ @Override
+ public void info(CharSequence content, Throwable error) {
+ logger.info(content, error);
+ }
- @Override
- public void warn(Throwable error) {
- logger.warn(error);
- }
- }
+ @Override
+ public void info(Throwable error) {
+ logger.info(error);
+ }
- /**
- * <p class="changed_added_4_0">Current logger. By default all calls
will be sent to system {@link java.util.logging.Logger}</p>
- */
- private static Logger logger = new JavaLogger();
+ @Override
+ public boolean isDebugEnabled() {
+ return logger.isDebugEnabled();
+ }
- /**
- * <p class="changed_added_4_0">
- * That constant wraps current logger object to allow access to logger at
- * the class instantiation time.
- * </p>
- */
- private static final Logger wrapper = new LoggerWrapper();
+ @Override
+ public boolean isErrorEnabled() {
+ return logger.isErrorEnabled();
+ }
- public static final String CDK_LOG = "org.richfaces.cdk";
-
- private LoggerFactory() {
- // That class has static methods only.
- }
+ @Override
+ public boolean isInfoEnabled() {
+ return logger.isInfoEnabled();
+ }
- public static Logger getLogger(){
- return wrapper;
- }
-
- public static void setLogger(Logger newLogger){
- assert(null != newLogger);
- logger = newLogger;
- }
+ @Override
+ public boolean isWarnEnabled() {
+ return logger.isWarnEnabled();
+ }
+
+ @Override
+ public void warn(CharSequence content) {
+ logger.warn(content);
+ }
+
+ @Override
+ public void warn(CharSequence content, Throwable error) {
+ logger.warn(content, error);
+ }
+
+ @Override
+ public void warn(Throwable error) {
+ logger.warn(error);
+ }
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/ModelBuilder.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/ModelBuilder.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/ModelBuilder.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk;
import org.richfaces.cdk.model.ComponentLibrary;
@@ -31,19 +33,18 @@
*
*/
public interface ModelBuilder extends CdkWorker {
-
- /**
- * <p class="changed_added_4_0">Initialize builder.</p>
- * @param context
- * @throws CdkException
- */
- public void init(CdkContext context) throws CdkException;
-
- /**
- * <p class="changed_added_4_0">Build library model.</p>
- * @return
- * @throws CdkException
- */
- public ComponentLibrary build() throws CdkException;
+ /**
+ * <p class="changed_added_4_0">Initialize builder.</p>
+ * @param context
+ * @throws CdkException
+ */
+ public void init(CdkContext context) throws CdkException;
+
+ /**
+ * <p class="changed_added_4_0">Build library model.</p>
+ * @return
+ * @throws CdkException
+ */
+ public ComponentLibrary build() throws CdkException;
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/ModelValidator.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/ModelValidator.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/ModelValidator.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk;
import org.richfaces.cdk.model.ComponentLibrary;
@@ -31,12 +33,11 @@
*
*/
public interface ModelValidator extends CdkWorker {
-
- /**
- * <p class="changed_added_4_0">Perform verify procedure on the library
model.</p>
- * @param library
- * @throws CdkException
- */
- public void verify(ComponentLibrary library) throws CdkException;
+ /**
+ * <p class="changed_added_4_0">Perform verify procedure on the
library model.</p>
+ * @param library
+ * @throws CdkException
+ */
+ public void verify(ComponentLibrary library) throws CdkException;
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/NamingConventions.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/NamingConventions.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/NamingConventions.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -21,12 +21,11 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk;
-import org.richfaces.cdk.model.ClassDescription;
-import org.richfaces.cdk.model.Component;
import org.richfaces.cdk.model.InvalidNameException;
-import org.richfaces.cdk.model.Component.Type;
/**
* <p class="changed_added_4_0">
@@ -34,41 +33,42 @@
*
href="http://www.jboss.org/community/docs/DOC-13693">CDK naming
* conventions</>
* </p>
- *
+ *
* @author asmirnov(a)exadel.com
- *
+ *
*/
public interface NamingConventions extends CdkWorker {
-
- /**
- * <p class="changed_added_4_0">Calculates component type from explicit
value or base class name.</p>
- * <ul>
- *
<li><code><prefix>.component.Abstract<Name></code>
=> <code><prefix>.<Name></code>
</li>
- *
<li><code><prefix>.component.<Name>Base</code>
=> <code><prefix>.<Name></code>
</li>
- *
<li><code><prefix>.component.UI<Name></code>
=> <code><prefix>.<Name></code>
</li>
- * </ul>
- * @param explicitType
- * @param className
- * @return
- * @throws InvalidNameException if className does not match naming conventions.
- */
- public String inferComponentType(String explicitType, String className) throws
InvalidNameException;
- /**
- * <p class="changed_added_4_0">Calculates concrete component class from
explicit value or type.</p>
- * <ul>
- * <li>Use explicit class name if it was provided by developer.</li>
- * <li>Calculate name from type as
<code><prefix>.<Name></code> =>
<code><prefix>.component.UI<Name></code> for an
abstract class.</li>
- * <li>Use base class name if concrete class should not be generated.
- * </ul>
- * @param explicitClass
- * @param className
- * @return
- */
- public String inferUIComponentClass(String componentType, String explicitClass, String
baseClass, boolean baseClassIsAbstract) throws InvalidNameException;
+ /**
+ * <p class="changed_added_4_0">Calculates component type from
explicit value or base class name.</p>
+ * <ul>
+ *
<li><code><prefix>.component.Abstract<Name></code>
=><code><prefix>.<Name></code></li>
+ *
<li><code><prefix>.component.<Name>Base</code>
=> <code><prefix>.<Name></code>
</li>
+ *
<li><code><prefix>.component.UI<Name></code>
=> <code><prefix>.<Name></code>
</li>
+ * </ul>
+ * @param explicitType
+ * @param className
+ * @return
+ * @throws InvalidNameException if className does not match naming conventions.
+ */
+ public String inferComponentType(String explicitType, String className) throws
InvalidNameException;
- public String inferUIComponentBaseClass(String componentType,String baseClassName,
boolean baseClassIsAbstract);
+ /**
+ * <p class="changed_added_4_0">Calculates concrete component class
from explicit value or type.</p>
+ * <ul>
+ * <li>Use explicit class name if it was provided by developer.</li>
+ * <li>Calculate name from type as
<code><prefix>.<Name></code> =>
+ * <code><prefix>.component.UI<Name></code>
for an abstract class.</li>
+ * <li>Use base class name if concrete class should not be generated.
+ * </ul>
+ * @param explicitClass
+ * @param className
+ * @return
+ */
+ public String inferUIComponentClass(String componentType, String explicitClass,
String baseClass,
+ boolean baseClassIsAbstract) throws InvalidNameException;
- public String inferUIComponentFamily(String componentType, String explicitFamily);
+ public String inferUIComponentBaseClass(String componentType, String baseClassName,
boolean baseClassIsAbstract);
+ public String inferUIComponentFamily(String componentType, String explicitFamily);
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/RichFacesConventions.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/RichFacesConventions.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/RichFacesConventions.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -1,138 +1,133 @@
package org.richfaces.cdk;
-import org.richfaces.cdk.model.ClassDescription;
-import org.richfaces.cdk.model.Component;
import org.richfaces.cdk.model.InvalidNameException;
import org.richfaces.cdk.model.Name;
-import org.richfaces.cdk.model.Component.Type;
import org.richfaces.cdk.model.Name.Classifier;
import org.richfaces.cdk.util.Strings;
/**
* <p class="changed_added_4_0">
* </p>
- *
+ *
* @author asmirnov(a)exadel.com
- *
+ *
*/
public final class RichFacesConventions implements NamingConventions {
+ private static final String ABSTRACT = "Abstract";
+ private static final String BASE = "Base";
+ private static final String UI = "UI";
+ private static final String[] COMPONENT_SUFFIXES = {BASE};
+ private static final String[] COMPONENT_PREFIXES = {UI, ABSTRACT};
- private static final String ABSTRACT = "Abstract";
- private static final String UI = "UI";
- private static final String BASE = "Base";
- /**
- * <p class="changed_added_4_0">
- * </p>
- */
- private String baseName;
- private CdkContext context;
+ private String baseName;
+ private CdkContext context;
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @param componentLibrary
- */
- public RichFacesConventions() {
- }
+ public RichFacesConventions() {}
- @Override
- public void init(CdkContext context) throws CdkException {
- this.context = context;
- }
+ @Override
+ public void init(CdkContext context) throws CdkException {
+ this.context = context;
+ }
- private final String[] COMPONENT_SUFFIXES = { BASE };
- private final String[] COMPONENT_PREFIXES = { UI, ABSTRACT };
+ @Override
+ public String inferComponentType(String explicitType, String className) throws
InvalidNameException {
- @Override
- public String inferComponentType(String explicitType, String className)
- throws InvalidNameException {
- // check parameters.
- if (Strings.isEmpty(explicitType)) {
- if (Strings.isEmpty(className)) {
- throw new IllegalArgumentException();
- }
- Name name = Name.create(className);
- // Use base library prefix.
- String baseName = this.getBaseName();
- if (null != baseName) {
- name.setPrefix(baseName);
- }
- // Component type does not contain class or markup parts.
- name.setClassifier(null);
- name.setMarkup(null);
- String simpleName = name.getSimpleName();
- // Remove common prefixes.
- for (int i = 0; i < COMPONENT_PREFIXES.length; i++) {
- if (simpleName.startsWith(COMPONENT_PREFIXES[i])) {
- simpleName = simpleName.substring(COMPONENT_PREFIXES[i]
- .length());
- break;
- }
- }
- // Remove common suffixes.
- for (int i = 0; i < COMPONENT_SUFFIXES.length; i++) {
- if (simpleName.endsWith(COMPONENT_SUFFIXES[i])) {
- simpleName = simpleName.substring(0, simpleName.length()
- - COMPONENT_SUFFIXES[i].length());
- break;
- }
- }
- name.setSimpleName(simpleName);
- return name.toString();
- } else {
- return explicitType;
- }
- }
+ // check parameters.
+ if (Strings.isEmpty(explicitType)) {
+ if (Strings.isEmpty(className)) {
+ throw new IllegalArgumentException();
+ }
- @Override
- public String inferUIComponentClass(String componentType,
- String explicitClass, String baseClass, boolean baseClassIsAbstract)
- throws InvalidNameException {
- String className;
- if (!Strings.isEmpty(explicitClass)) {
- // Class name provided by developer.
- className = explicitClass;
- } else if (isAbstract(baseClass, baseClassIsAbstract)) {
- // Infer UI class name from component type.
- Name name = Name.create(componentType);
- name.setClassifier(Classifier.component);
- name.setMarkup(null);
- name.setSimpleName(UI + name.getSimpleName());
- className = name.toString();
- } else {
- // Do not generate class, use base name.
- className = baseClass;
- }
- return className;
- }
+ Name name = Name.create(className);
- private boolean isAbstract(String baseClass, boolean baseClassIsAbstract) {
- return baseClassIsAbstract || baseClass.startsWith(ABSTRACT)
- || baseClass.endsWith(BASE);
- }
+ // Use base library prefix.
+ String baseName = this.getBaseName();
- @Override
- public String inferUIComponentBaseClass(String componentType,
- String baseClassName, boolean baseClassIsAbstract) {
- return isAbstract(baseClassName, baseClassIsAbstract) ? baseClassName
- : null;
- }
+ if (null != baseName) {
+ name.setPrefix(baseName);
+ }
- @Override
- public String inferUIComponentFamily(String componentType,
- String explicitFamily) {
- return Strings.isEmpty(explicitFamily) ? componentType : explicitFamily;
- }
+ // Component type does not contain class or markup parts.
+ name.setClassifier(null);
+ name.setMarkup(null);
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @return the baseName
- */
- protected String getBaseName() {
- return baseName;
- }
+ String simpleName = name.getSimpleName();
-}
\ No newline at end of file
+ // Remove common prefixes.
+ for (int i = 0; i < COMPONENT_PREFIXES.length; i++) {
+ if (simpleName.startsWith(COMPONENT_PREFIXES[i])) {
+ simpleName = simpleName.substring(COMPONENT_PREFIXES[i].length());
+
+ break;
+ }
+ }
+
+ // Remove common suffixes.
+ for (int i = 0; i < COMPONENT_SUFFIXES.length; i++) {
+ if (simpleName.endsWith(COMPONENT_SUFFIXES[i])) {
+ simpleName = simpleName.substring(0, simpleName.length() -
COMPONENT_SUFFIXES[i].length());
+
+ break;
+ }
+ }
+
+ name.setSimpleName(simpleName);
+
+ return name.toString();
+ } else {
+ return explicitType;
+ }
+ }
+
+ @Override
+ public String inferUIComponentClass(String componentType, String explicitClass,
String baseClass,
+ boolean baseClassIsAbstract) throws InvalidNameException {
+
+ String className;
+
+ if (!Strings.isEmpty(explicitClass)) {
+
+ // Class name provided by developer.
+ className = explicitClass;
+ } else if (isAbstract(baseClass, baseClassIsAbstract)) {
+
+ // Infer UI class name from component type.
+ Name name = Name.create(componentType);
+
+ name.setClassifier(Classifier.component);
+ name.setMarkup(null);
+ name.setSimpleName(UI + name.getSimpleName());
+ className = name.toString();
+ } else {
+
+ // Do not generate class, use base name.
+ className = baseClass;
+ }
+
+ return className;
+ }
+
+ private boolean isAbstract(String baseClass, boolean baseClassIsAbstract) {
+ return baseClassIsAbstract || baseClass.startsWith(ABSTRACT) ||
baseClass.endsWith(BASE);
+ }
+
+ @Override
+ public String inferUIComponentBaseClass(String componentType, String baseClassName,
boolean baseClassIsAbstract) {
+ return isAbstract(baseClassName, baseClassIsAbstract) ? baseClassName : null;
+ }
+
+ @Override
+ public String inferUIComponentFamily(String componentType, String explicitFamily) {
+ return Strings.isEmpty(explicitFamily) ? componentType : explicitFamily;
+ }
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @return the baseName
+ */
+ protected String getBaseName() {
+ return baseName;
+ }
+}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/StandardOutputFolders.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/StandardOutputFolders.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/StandardOutputFolders.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk;
import org.richfaces.cdk.CdkWriter.OutputType;
@@ -31,20 +33,15 @@
*
*/
public enum StandardOutputFolders implements OutputType {
- JAVA_CLASSES,
- RESOURCES,
- TEST_JAVA_CLASSES,
- TEST_RESOURCES,
- DOCUMENTATION;
+ JAVA_CLASSES, RESOURCES, TEST_JAVA_CLASSES, TEST_RESOURCES, DOCUMENTATION;
- @Override
- public OutputType getFolderType() {
- return null;
- }
+ @Override
+ public OutputType getFolderType() {
+ return null;
+ }
- @Override
- public String getName() {
- return name();
- }
-
+ @Override
+ public String getName() {
+ return name();
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/StandardOutputs.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/StandardOutputs.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/StandardOutputs.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk;
import org.richfaces.cdk.CdkWriter.OutputType;
@@ -31,34 +33,30 @@
*
*/
public enum StandardOutputs implements OutputType {
- COMPONENT_CLASSES(StandardOutputFolders.JAVA_CLASSES),
- RENDERER_CLASSES(StandardOutputFolders.JAVA_CLASSES),
- EVENT_LISTENER_CLASSES(StandardOutputFolders.JAVA_CLASSES),
- EVENT_SOURCE_CLASSES(StandardOutputFolders.JAVA_CLASSES),
- TAG_HANDLER_CLASSES(StandardOutputFolders.JAVA_CLASSES),
- FACES_CONFIG(StandardOutputFolders.RESOURCES),
- TAG_LIBRARY(StandardOutputFolders.RESOURCES),
- JBDS_RENDERERS(StandardOutputFolders.JAVA_CLASSES),
- XML_SCHEMA(StandardOutputFolders.RESOURCES),
- COMPONENT_TEST(StandardOutputFolders.TEST_JAVA_CLASSES);
+ COMPONENT_CLASSES(StandardOutputFolders.JAVA_CLASSES),
RENDERER_CLASSES(StandardOutputFolders.JAVA_CLASSES),
+ EVENT_LISTENER_CLASSES(StandardOutputFolders.JAVA_CLASSES),
+ EVENT_SOURCE_CLASSES(StandardOutputFolders.JAVA_CLASSES),
+ TAG_HANDLER_CLASSES(StandardOutputFolders.JAVA_CLASSES),
FACES_CONFIG(StandardOutputFolders.RESOURCES),
+ TAG_LIBRARY(StandardOutputFolders.RESOURCES),
JBDS_RENDERERS(StandardOutputFolders.JAVA_CLASSES),
+ XML_SCHEMA(StandardOutputFolders.RESOURCES),
COMPONENT_TEST(StandardOutputFolders.TEST_JAVA_CLASSES);
- private final OutputType folderType;
- /**
- * <p class="changed_added_4_0"></p>
- * @param folderType
- */
- private StandardOutputs(OutputType folderType) {
- this.folderType = folderType;
- }
+ private final OutputType folderType;
- @Override
- public String getName() {
- return name();
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param folderType
+ */
+ private StandardOutputs(OutputType folderType) {
+ this.folderType = folderType;
+ }
- @Override
- public OutputType getFolderType() {
- return folderType;
- }
+ @Override
+ public String getName() {
+ return name();
+ }
+ @Override
+ public OutputType getFolderType() {
+ return folderType;
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/StandardSources.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/StandardSources.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/StandardSources.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk;
import org.richfaces.cdk.CdkContext.SourceType;
@@ -31,14 +33,10 @@
*
*/
public enum StandardSources implements SourceType {
-
- JAVA_SOURCES,
- FACES_CONFIGS,
- RENDERER_TEMPLATES;
+ JAVA_SOURCES, FACES_CONFIGS, RENDERER_TEMPLATES;
- @Override
- public String getName() {
- return name();
- }
-
+ @Override
+ public String getName() {
+ return name();
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/ValidatorImpl.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/ValidatorImpl.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/ValidatorImpl.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -21,85 +21,91 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.richfaces.cdk;
-import java.util.Collection;
+package org.richfaces.cdk;
import org.richfaces.cdk.model.Component;
import org.richfaces.cdk.model.ComponentLibrary;
-import org.richfaces.cdk.model.ModelCollection;
import org.richfaces.cdk.model.RenderKit;
import org.richfaces.cdk.model.Renderer;
+import java.util.Collection;
+
/**
* <p class="changed_added_4_0"></p>
* @author asmirnov(a)exadel.com
*
*/
public class ValidatorImpl implements ModelValidator {
+ private CdkContext context;
+ private NamingConventions namingConventions;
- private CdkContext context;
-
- private NamingConventions namingConventions;
+ public void init(CdkContext context) throws CdkException {
+ this.context = context;
+ this.namingConventions = context.getWorkerInstance(NamingConventions.class);
+ }
- public void init(CdkContext context) throws CdkException {
- this.context = context;
- this.namingConventions = context.getWorkerInstance(NamingConventions.class);
- }
+ /*
+ * (non-Javadoc)
+ * @see
org.richfaces.cdk.ModelValidator#verify(org.richfaces.cdk.model.ComponentLibrary)
+ */
+ @Override
+ public void verify(ComponentLibrary library) throws CdkException {
+ verifyRenderers(library);
+ verifyComponents(library);
- /* (non-Javadoc)
- * @see
org.richfaces.cdk.ModelValidator#verify(org.richfaces.cdk.model.ComponentLibrary)
- */
- @Override
- public void verify(ComponentLibrary library) throws CdkException {
- verifyRenderers(library);
- verifyComponents(library);
- // After all, merge all similar elements.
- compact(library.getComponents());
- compact(library.getRenderKits());
- compact(library.getRenderKits());
- }
+ // After all, merge all similar elements.
+ compact(library.getComponents());
+ compact(library.getRenderKits());
+ compact(library.getRenderKits());
+ }
- protected void verifyRenderers(ComponentLibrary library) {
- for (RenderKit renderKit : library.getRenderKits()) {
- // Check render kit name and class.
- for (Renderer renderer : renderKit.getRenderers()) {
- // Check type.
- // Check family.
- // Check generated class.
- // Check superclass.
- // Check component type.
- }
- compact(renderKit.getRenderers());
- }
-
- }
+ protected void verifyRenderers(ComponentLibrary library) {
+ for (RenderKit renderKit : library.getRenderKits()) {
- protected void verifyComponents(ComponentLibrary library) {
- NamingConventions namingConventions = getNamingConventions();
- for (Component component : library.getComponents()) {
- // Check classes.
- // Check Component type.
- if(null == component.getType()){
-// component.setType(new
Component.Type(namingConventions.inferComponentType(explicitType, className)));
- }
- // Check family.
- // Check attributes.
- // Check renderers.
- compact(component.getAttributes());
- }
-
- }
+ // Check render kit name and class.
+ for (Renderer renderer : renderKit.getRenderers()) {
- private NamingConventions getNamingConventions() {
- return namingConventions;
- }
+ // Check type.
+ // Check family.
+ // Check generated class.
+ // Check superclass.
+ // Check component type.
+ }
- protected void compact(Collection<?> collection) {
-// if (collection instanceof ModelCollection) {
-// ModelCollection model = (ModelCollection) collection;
-// model.mergeKeys();
-// }
- }
+ compact(renderKit.getRenderers());
+ }
+ }
+
+ protected void verifyComponents(ComponentLibrary library) {
+ NamingConventions namingConventions = getNamingConventions();
+
+ for (Component component : library.getComponents()) {
+
+ // Check classes.
+ // Check Component type.
+ if (null == component.getType()) {
+
+// component.setType(new
Component.Type(namingConventions.inferComponentType(explicitType, className)));
+ }
+
+ // Check family.
+ // Check attributes.
+ // Check renderers.
+ compact(component.getAttributes());
+ }
+ }
+
+ private NamingConventions getNamingConventions() {
+ return namingConventions;
+ }
+
+ protected void compact(Collection<?> collection) {
+
+// if (collection instanceof ModelCollection) {
+// ModelCollection model = (ModelCollection) collection;
+// model.mergeKeys();
+// }
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptBuilder.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptBuilder.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptBuilder.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -21,18 +21,22 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.apt;
import java.io.File;
+
import java.net.URL;
import java.net.URLClassLoader;
+
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Collection;
import java.util.List;
import java.util.Locale;
import javax.annotation.processing.Processor;
+
import javax.tools.Diagnostic;
import javax.tools.DiagnosticListener;
import javax.tools.JavaCompiler;
@@ -57,201 +61,216 @@
* <p class="changed_added_4_0">
* That class compiles files from sources and process annotations
* </p>
- *
+ *
* @author asmirnov(a)exadel.com
- *
+ *
*/
public class AptBuilder implements ModelBuilder {
-
- private static final Logger log = LoggerFactory.getLogger();
+ private static final Logger LOG = LoggerFactory.getLogger();
+ private boolean initialized = false;
+ private CdkContext context;
+ private VirtualFileManager fileManager;
+ private JavaCompiler javaCompiler;
+ private Locale locale;
+ private Iterable<String> options;
- private VirtualFileManager fileManager;
+ /**
+ * <p class="changed_added_4_0">Builder method that creates and
initializes compiler instance.
+ * That instance can be reused for consecuence processing.</p>
+ * @param context
+ * @return
+ */
+ @Override
+ public void init(CdkContext context) {
+ this.context = context;
- private Iterable<String> options;
+ JavaCompiler javaCompiler = ToolProvider.getSystemJavaCompiler();
- private JavaCompiler javaCompiler;
-
- private Locale locale;
+ setJavaCompiler(javaCompiler);
- private CdkContext context;
-
- private boolean initialized = false;
+ ArrayList<String> options = new ArrayList<String>();
- /**
- * <p class="changed_added_4_0">Builder method that creates and
initializes compiler instance.
- * That instance can be reused for consecuence processing.</p>
- * @param context
- * @return
- */
- @Override
- public void init(CdkContext context) {
- this.context = context;
- JavaCompiler javaCompiler = ToolProvider.getSystemJavaCompiler();
- setJavaCompiler(javaCompiler);
- ArrayList<String> options = new ArrayList<String>();
- options.add("-proc:only");
- options.add("-implicit:class");
- options.add("-verbose");
- ClassLoader classPathLoader = context.getLoader();
- StringBuilder classPathOption = new StringBuilder();
- boolean hasClassPathElement=false;
- while (null != classPathLoader && classPathLoader instanceof URLClassLoader)
{
- URLClassLoader urlLoader = (URLClassLoader) classPathLoader;
+ options.add("-proc:only");
+ options.add("-implicit:class");
+ options.add("-verbose");
+
+ ClassLoader classPathLoader = context.getLoader();
+ StringBuilder classPathOption = new StringBuilder();
+ boolean hasClassPathElement = false;
+
+ while (null != classPathLoader && classPathLoader instanceof
URLClassLoader) {
+ URLClassLoader urlLoader = (URLClassLoader) classPathLoader;
+
for (URL cpElement : urlLoader.getURLs()) {
- if(hasClassPathElement){
- classPathOption.append(File.pathSeparatorChar);
- } else {
+ if (hasClassPathElement) {
+ classPathOption.append(File.pathSeparatorChar);
+ } else {
options.add("-classpath");
- hasClassPathElement = true;
- }
- classPathOption.append(cpElement.getFile());
- }
+ hasClassPathElement = true;
+ }
+
+ classPathOption.append(cpElement.getFile());
+ }
+
classPathLoader = classPathLoader.getParent();
- }
- if (hasClassPathElement) {
- options.add(classPathOption.toString());
- log.info("Compiler classpath:" + classPathOption);
+ }
- }
- Iterable<File> sourceFolders =
context.getSourceFolders(StandardSources.JAVA_SOURCES);
- File javaSource;
- if(null != sourceFolders && sourceFolders.iterator().hasNext()){
- options.add("-sourcepath");
- javaSource = sourceFolders.iterator().next();
- options.add(javaSource.getAbsolutePath());
- } else {
- javaSource = null;
- }
- if(null != context.getOutputFolder(StandardOutputs.COMPONENT_CLASSES)){
- options.add("-s");
- options.add(context.getOutputFolder(StandardOutputs.COMPONENT_CLASSES).getAbsolutePath());
- }
- setOptions(options);
- // TODO - provide source files locale.
- setLocale(Locale.getDefault());
- // TODO -set locale and charset for platform-independent processing. Provide own
diagnostics listener.
- StandardJavaFileManager stdFileManager = javaCompiler
- .getStandardFileManager(null, null, null);
- // TODO - use standard file manager for all tasks.
- VirtualFileManager fileManager = new VirtualFileManager(stdFileManager,
- context.getLoader());
- fileManager.setJavaSourceDirectory(javaSource);
- setFileManager(fileManager);
- initialized = true;
- }
+ if (hasClassPathElement) {
+ options.add(classPathOption.toString());
+ LOG.info("Compiler classpath:" + classPathOption);
+ }
- @Override
- public ComponentLibrary build() throws CdkException {
- if(!initialized){
- throw new CdkException("Annotation processor is not initialized");
- }
- ComponentLibrary library = new ComponentLibrary();
- ComponentProcessor processor = new ComponentProcessor(context,library);
- process(context.getSources(StandardSources.JAVA_SOURCES),processor);
- return library;
- }
- /**
- * <p class="changed_added_4_0">That method process source files and
call appropriate annotation processors</p>
- * @param sources
- * @param processors
- * @throws AptException
- */
- protected void process(Iterable<File> sources, Processor...processors) throws
AptException {
- final List<String> messages = Lists.newArrayList();
- DiagnosticListener<JavaFileObject> listener = new
DiagnosticListener<JavaFileObject>() {
+ Iterable<File> sourceFolders =
context.getSourceFolders(StandardSources.JAVA_SOURCES);
+ File javaSource;
- @Override
- public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
- log.debug("LOG: " + diagnostic.getMessage(null));
- if(Kind.ERROR.equals(diagnostic.getKind())){
- messages.add(diagnostic.getMessage(null));
- }
- }
+ if (null != sourceFolders && sourceFolders.iterator().hasNext()) {
+ options.add("-sourcepath");
+ javaSource = sourceFolders.iterator().next();
+ options.add(javaSource.getAbsolutePath());
+ } else {
+ javaSource = null;
+ }
- };
- ArrayList<VirtualJavaFileObject> sourceObjects = new
ArrayList<VirtualJavaFileObject>();
- for (File file : sources) {
- VirtualJavaFileObject sourceObject = new VirtualJavaFileSystemObject(file);
- sourceObjects.add(sourceObject);
- }
- CompilationTask task = getJavaCompiler().getTask(null, getFileManager(), listener,
getOptions(), null, sourceObjects);
- task.setProcessors(Arrays.asList(processors));
- task.setLocale(locale);
- if(!task.call()){
- throw new AptException("Compilation error: "+messages);
- }
- }
+ if (null != context.getOutputFolder(StandardOutputs.COMPONENT_CLASSES)) {
+ options.add("-s");
+
options.add(context.getOutputFolder(StandardOutputs.COMPONENT_CLASSES).getAbsolutePath());
+ }
+ setOptions(options);
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @return the options
- */
- protected Iterable<String> getOptions() {
- return options;
- }
+ // TODO - provide source files locale.
+ setLocale(Locale.getDefault());
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @param options
- * the options to set
- */
- protected void setOptions(Iterable<String> options) {
- this.options = options;
- }
+ // TODO -set locale and charset for platform-independent processing. Provide own
diagnostics listener.
+ StandardJavaFileManager stdFileManager =
javaCompiler.getStandardFileManager(null, null, null);
- /**
- * <p class="changed_added_4_0"></p>
- * @return the fileManager
- */
- protected VirtualFileManager getFileManager() {
- return fileManager;
- }
+ // TODO - use standard file manager for all tasks.
+ VirtualFileManager fileManager = new VirtualFileManager(stdFileManager,
context.getLoader());
- /**
- * <p class="changed_added_4_0"></p>
- * @param fileManager the fileManager to set
- */
- protected void setFileManager(VirtualFileManager fileManager) {
- this.fileManager = fileManager;
- }
+ fileManager.setJavaSourceDirectory(javaSource);
+ setFileManager(fileManager);
+ initialized = true;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param javaCompiler the javaCompiler to set
- */
- protected void setJavaCompiler(JavaCompiler javaCompiler) {
- this.javaCompiler = javaCompiler;
- }
+ @Override
+ public ComponentLibrary build() throws CdkException {
+ if (!initialized) {
+ throw new CdkException("Annotation processor is not initialized");
+ }
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @return the javaCompiler
- */
- protected JavaCompiler getJavaCompiler() {
- return javaCompiler;
- }
+ ComponentLibrary library = new ComponentLibrary();
+ ComponentProcessor processor = new ComponentProcessor(context, library);
- /**
- * <p class="changed_added_4_0"></p>
- * @return the locale
- */
- public Locale getLocale() {
- return locale;
- }
+ process(context.getSources(StandardSources.JAVA_SOURCES), processor);
- /**
- * <p class="changed_added_4_0"></p>
- * @param locale the locale to set
- */
- public void setLocale(Locale locale) {
- this.locale = locale;
- }
+ return library;
+ }
+ /**
+ * <p class="changed_added_4_0">That method process source files and
call appropriate annotation processors</p>
+ * @param sources
+ * @param processors
+ * @throws AptException
+ */
+ protected void process(Iterable<File> sources, Processor... processors) throws
AptException {
+ final List<String> messages = Lists.newArrayList();
+ DiagnosticListener<JavaFileObject> listener = new
DiagnosticListener<JavaFileObject>() {
+ @Override
+ public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
+ LOG.debug("LOG: " + diagnostic.getMessage(null));
+
+ if (Kind.ERROR.equals(diagnostic.getKind())) {
+ messages.add(diagnostic.getMessage(null));
+ }
+ }
+ };
+ ArrayList<VirtualJavaFileObject> sourceObjects = new
ArrayList<VirtualJavaFileObject>();
+
+ for (File file : sources) {
+ VirtualJavaFileObject sourceObject = new VirtualJavaFileSystemObject(file);
+
+ sourceObjects.add(sourceObject);
+ }
+
+ CompilationTask task = getJavaCompiler().getTask(null, getFileManager(),
listener, getOptions(), null,
+ sourceObjects);
+
+ task.setProcessors(Arrays.asList(processors));
+ task.setLocale(locale);
+
+ if (!task.call()) {
+ throw new AptException("Compilation error: " + messages);
+ }
+ }
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @return the options
+ */
+ protected Iterable<String> getOptions() {
+ return options;
+ }
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param options
+ * the options to set
+ */
+ protected void setOptions(Iterable<String> options) {
+ this.options = options;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the fileManager
+ */
+ protected VirtualFileManager getFileManager() {
+ return fileManager;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param fileManager the fileManager to set
+ */
+ protected void setFileManager(VirtualFileManager fileManager) {
+ this.fileManager = fileManager;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param javaCompiler the javaCompiler to set
+ */
+ protected void setJavaCompiler(JavaCompiler javaCompiler) {
+ this.javaCompiler = javaCompiler;
+ }
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @return the javaCompiler
+ */
+ protected JavaCompiler getJavaCompiler() {
+ return javaCompiler;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the locale
+ */
+ public Locale getLocale() {
+ return locale;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param locale the locale to set
+ */
+ public void setLocale(Locale locale) {
+ this.locale = locale;
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptException.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptException.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptException.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.apt;
import org.richfaces.cdk.CdkException;
@@ -32,40 +34,38 @@
*/
public class AptException extends CdkException {
- /**
- * <p class="changed_added_4_0"></p>
- */
- private static final long serialVersionUID = 8023042422371321042L;
+ /**
+ * <p class="changed_added_4_0"></p>
+ */
+ private static final long serialVersionUID = 8023042422371321042L;
- /**
- * <p class="changed_added_4_0"></p>
- */
- public AptException() {
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ */
+ public AptException() {}
- /**
- * <p class="changed_added_4_0"></p>
- * @param message
- */
- public AptException(String message) {
- super(message);
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param message
+ */
+ public AptException(String message) {
+ super(message);
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param cause
- */
- public AptException(Throwable cause) {
- super(cause);
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param cause
+ */
+ public AptException(Throwable cause) {
+ super(cause);
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param message
- * @param cause
- */
- public AptException(String message, Throwable cause) {
- super(message, cause);
- }
-
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param message
+ * @param cause
+ */
+ public AptException(String message, Throwable cause) {
+ super(message, cause);
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/CdkProcessor.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/CdkProcessor.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/CdkProcessor.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -21,278 +21,290 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.apt;
-import java.lang.annotation.Annotation;
-import java.util.List;
-import java.util.Set;
+import com.google.common.collect.Sets;
+import org.richfaces.cdk.CdkContext;
+import org.richfaces.cdk.CdkException;
+import org.richfaces.cdk.NamingConventions;
+import org.richfaces.cdk.model.InvalidNameException;
+import org.richfaces.cdk.util.PropertyUtils;
+
import javax.annotation.processing.AbstractProcessor;
import javax.annotation.processing.RoundEnvironment;
-import javax.annotation.processing.SupportedSourceVersion;
+
import javax.lang.model.SourceVersion;
-import javax.lang.model.element.Element;
-import javax.lang.model.element.ElementKind;
-import javax.lang.model.element.ExecutableElement;
-import javax.lang.model.element.Modifier;
-import javax.lang.model.element.TypeElement;
-import javax.lang.model.element.TypeParameterElement;
-import javax.lang.model.element.VariableElement;
-import javax.lang.model.type.DeclaredType;
+import javax.lang.model.element.*;
import javax.lang.model.type.TypeKind;
import javax.lang.model.type.TypeMirror;
-import javax.lang.model.util.ElementFilter;
-import org.richfaces.cdk.CdkContext;
-import org.richfaces.cdk.CdkException;
-import org.richfaces.cdk.NamingConventions;
-import org.richfaces.cdk.annotations.Icon;
-import org.richfaces.cdk.model.ClassDescription;
-import org.richfaces.cdk.model.InvalidNameException;
-import org.richfaces.cdk.util.PropertyUtils;
+import java.lang.annotation.Annotation;
-import com.google.common.collect.Sets;
+import java.util.List;
+import java.util.Set;
/**
* <p class="changed_added_4_0">
* Base class for all CDK Annotation processors. That class provides access to
* current CDK context and utility methods for Java source models.
* </p>
- *
+ *
* @author asmirnov(a)exadel.com
- *
+ *
*/
public abstract class CdkProcessor extends AbstractProcessor {
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @author asmirnov(a)exadel.com
- *
- */
- protected final class BeanProperty {
+ /**
+ * <p class="changed_added_4_0">
+ * CDK context.
+ * </p>
+ */
+ protected final CdkContext context;
- private TypeMirror type;
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param context
+ * current CDK context
+ */
+ protected CdkProcessor(CdkContext context) {
+ super();
+ this.context = context;
+ }
- private Element element;
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @return the context
+ */
+ protected CdkContext getContext() {
+ return context;
+ }
- private final String name;
+ @Override
+ public SourceVersion getSupportedSourceVersion() {
- private boolean exists;
+ // CDK supports Java 5 or 6 source code.
+ return SourceVersion.RELEASE_6;
+ }
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#hashCode()
- */
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((name == null) ? 0 : name.hashCode());
- return result;
- }
+ /**
+ * <p class="changed_added_4_0">
+ * Get all classes annotated with particular annotation.
+ * </p>
+ * @param round
+ * current round environment.
+ * @param annotation
+ * annotation class.
+ *
+ * @return {@link Set} of all classes annotated with {@code annotation}
+ * type.
+ */
+ protected Set<? extends TypeElement> getClassesAnnotatedWith(RoundEnvironment
round,
+ Class<? extends Annotation> annotation) {
+ Set<TypeElement> classes = Sets.newHashSet();
+ Set<? extends Element> annotatedWith =
round.getElementsAnnotatedWith(annotation);
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#equals(java.lang.Object)
- */
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- BeanProperty other = (BeanProperty) obj;
- if (name == null) {
- if (other.name != null)
- return false;
- } else if (!name.equals(other.name))
- return false;
- return true;
- }
+ for (Element element : annotatedWith) {
+ if (ElementKind.CLASS.equals(element.getKind())) {
+ TypeElement classElement = (TypeElement) element;
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @param name
- */
- public BeanProperty(String name) {
- this.name = name;
- }
+ classes.add(classElement);
+ }
+ }
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @return the name
- */
- public String getName() {
- return name;
- }
+ return classes;
+ }
- /**
- * <p class="changed_added_4_0">Get JavaDoc comment of appropriate bean
property element.</p>
- * @return
- */
- public String getDocComment() {
- return processingEnv.getElementUtils().getDocComment(element);
- }
+ /**
+ * <p class="changed_added_4_0">
+ * Get all fields and bean properties that are annotated with given
+ * annotation.
+ * </p>
+ *
+ * @param annotation
+ * @param type
+ * @return
+ */
+ protected Set<BeanProperty> getBeanPropertiesAnnotatedWith(Class<? extends
Annotation> annotation,
+ TypeElement type) {
+ Set<BeanProperty> properties = Sets.newHashSet();
+ List<? extends Element> members =
this.processingEnv.getElementUtils().getAllMembers(type);
- public TypeMirror getType() {
- return type;
- }
+ // Get all methods and fields annotated by annotation.
+ for (Element childElement : members) {
+ if (null != childElement.getAnnotation(annotation)) {
+ // Have an annotation, infer property name.
+ String name;
+ TypeMirror propertyType;
+ boolean exists = false;
- /**
- * <p class="changed_added_4_0"></p>
- * @return the exists
- */
- public boolean isExists() {
- return exists;
- }
+ if (ElementKind.METHOD.equals(childElement.getKind())) {
+ ExecutableElement method = (ExecutableElement) childElement;
- public <T extends Annotation> T getAnnotation(Class<T> annotationType) {
- return element.getAnnotation(annotationType);
- }
+ propertyType = method.getReturnType();
- }
+ List<? extends VariableElement> parameters =
method.getParameters();
- /**
- * <p class="changed_added_4_0">
- * CDK context.
- * </p>
- */
- protected final CdkContext context;
+ if (TypeKind.VOID.equals(propertyType.getKind()) && 1 ==
parameters.size()) {
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @param context
- * current CDK context
- */
- protected CdkProcessor(CdkContext context) {
- super();
- this.context = context;
- }
+ // That is setter method, get type from parameter.
+ propertyType = parameters.get(0).asType();
+ } else if (!parameters.isEmpty()) {
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @return the context
- */
- protected CdkContext getContext() {
- return context;
- }
+ // TODO Invalid method signature for a bean property,
+ // throw exception ?
+ continue;
+ }
- @Override
- public SourceVersion getSupportedSourceVersion() {
- // CDK supports Java 5 or 6 source code.
- return SourceVersion.RELEASE_6;
- }
+ try {
+ name =
PropertyUtils.methodToName(childElement.getSimpleName().toString());
+ } catch (InvalidNameException e) {
- /**
- * <p class="changed_added_4_0">
- * Get all classes annotated with particular annotation.
- * </p>
- * @param round
- * current round environment.
- * @param annotation
- * annotation class.
- *
- * @return {@link Set} of all classes annotated with {@code annotation}
- * type.
- */
- protected Set<? extends TypeElement> getClassesAnnotatedWith(
- RoundEnvironment round, Class<? extends Annotation> annotation) {
- Set<TypeElement> classes = Sets.newHashSet();
- Set<? extends Element> annotatedWith = round
- .getElementsAnnotatedWith(annotation);
- for (Element element : annotatedWith) {
- if (ElementKind.CLASS.equals(element.getKind())) {
- TypeElement classElement = (TypeElement) element;
- classes.add(classElement);
- }
- }
- return classes;
- }
+ // TODO Invalid method name for a bean property, throw
+ // exception ?
+ continue;
+ }
- /**
- * <p class="changed_added_4_0">
- * Get all fields and bean properties that are annotated with given
- * annotation.
- * </p>
- *
- * @param annotation
- * @param type
- * @return
- */
- protected Set<BeanProperty> getBeanPropertiesAnnotatedWith(
- Class<? extends Annotation> annotation, TypeElement type) {
- Set<BeanProperty> properties = Sets.newHashSet();
- List<? extends Element> members =
this.processingEnv.getElementUtils().getAllMembers(
- type);
- // Get all methods and fields annotated by annotation.
- for (Element childElement : members) {
- if (null != childElement.getAnnotation(annotation)) {
- // Have an annotation, infer property name.
- String name;
- TypeMirror propertyType;
- boolean exists = false;
- if (ElementKind.METHOD.equals(childElement.getKind())) {
- ExecutableElement method = (ExecutableElement) childElement;
- propertyType = method.getReturnType();
- List<? extends VariableElement> parameters = method
- .getParameters();
- if (TypeKind.VOID.equals(propertyType.getKind())
- && 1 == parameters.size()) {
- // That is setter method, get type from parameter.
- propertyType = parameters.get(0).asType();
- } else if (!parameters.isEmpty()) {
- // TODO Invalid method signature for a bean property,
- // throw exception ?
- continue;
- }
- try {
- name = PropertyUtils
- .methodToName(childElement.getSimpleName()
- .toString());
- } catch (InvalidNameException e) {
- // TODO Invalid method name for a bean property, throw
- // exception ?
- continue;
- }
- exists = !method.getModifiers().contains(Modifier.ABSTRACT);
- // List<? extends TypeParameterElement> typeParameters =
method.getTypeParameters();
- } else if (ElementKind.FIELD
- .equals(childElement.getKind())) {
- name = childElement.getSimpleName().toString();
- propertyType = childElement.asType();
- // TODO - find getter/setter, check them for abstract.
- exists = true;
- } else {
- continue;
- }
- BeanProperty property = new BeanProperty(name);
- property.type = propertyType;
- property.element = childElement;
- property.exists = exists;
- // TODO - merge properties with same name ?
- properties.add(property);
- }
- }
- return properties;
- }
+ exists = !method.getModifiers().contains(Modifier.ABSTRACT);
- protected NamingConventions getNamingConventions() throws CdkException {
- return getContext().getWorkerInstance(NamingConventions.class);
- }
-
+ // List<? extends TypeParameterElement> typeParameters =
method.getTypeParameters();
+ } else if (ElementKind.FIELD.equals(childElement.getKind())) {
+ name = childElement.getSimpleName().toString();
+ propertyType = childElement.asType();
+
+ // TODO - find getter/setter, check them for abstract.
+ exists = true;
+ } else {
+ continue;
+ }
+
+ BeanProperty property = new BeanProperty(name);
+
+ property.type = propertyType;
+ property.element = childElement;
+ property.exists = exists;
+
+ // TODO - merge properties with same name ?
+ properties.add(property);
+ }
+ }
+
+ return properties;
+ }
+
+ protected NamingConventions getNamingConventions() throws CdkException {
+ return getContext().getWorkerInstance(NamingConventions.class);
+ }
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @author asmirnov(a)exadel.com
+ *
+ */
+ protected final class BeanProperty {
+ private Element element;
+ private boolean exists;
+ private final String name;
+ private TypeMirror type;
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param name
+ */
+ public BeanProperty(String name) {
+ this.name = name;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+
+ result = prime * result + ((name == null) ? 0 : name.hashCode());
+
+ return result;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+
+ if (obj == null) {
+ return false;
+ }
+
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+
+ BeanProperty other = (BeanProperty) obj;
+
+ if (name == null) {
+ if (other.name != null) {
+ return false;
+ }
+ } else if (!name.equals(other.name)) {
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @return the name
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * <p class="changed_added_4_0">Get JavaDoc comment of
appropriate bean property element.</p>
+ * @return
+ */
+ public String getDocComment() {
+ return processingEnv.getElementUtils().getDocComment(element);
+ }
+
+ public TypeMirror getType() {
+ return type;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the exists
+ */
+ public boolean isExists() {
+ return exists;
+ }
+
+ public <T extends Annotation> T getAnnotation(Class<T>
annotationType) {
+ return element.getAnnotation(annotationType);
+ }
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ComponentProcessor.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ComponentProcessor.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ComponentProcessor.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -21,47 +21,15 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.apt;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.Map.Entry;
+import com.google.common.collect.Lists;
-import javax.annotation.processing.RoundEnvironment;
-import javax.annotation.processing.SupportedAnnotationTypes;
-import javax.faces.component.FacesComponent;
-import javax.faces.event.FacesEvent;
-import javax.lang.model.element.AnnotationMirror;
-import javax.lang.model.element.AnnotationValue;
-import javax.lang.model.element.Element;
-import javax.lang.model.element.ExecutableElement;
-import javax.lang.model.element.Modifier;
-import javax.lang.model.element.Name;
-import javax.lang.model.element.TypeElement;
-import javax.lang.model.element.VariableElement;
-import javax.lang.model.type.MirroredTypesException;
-import javax.lang.model.type.TypeMirror;
-import javax.lang.model.util.ElementFilter;
-
import org.richfaces.cdk.CdkContext;
import org.richfaces.cdk.CdkException;
-import org.richfaces.cdk.annotations.Attribute;
-import org.richfaces.cdk.annotations.Attributes;
-import org.richfaces.cdk.annotations.Component;
-import org.richfaces.cdk.annotations.DefaultValue;
-import org.richfaces.cdk.annotations.DisplayName;
-import org.richfaces.cdk.annotations.EventName;
-import org.richfaces.cdk.annotations.EventNames;
-import org.richfaces.cdk.annotations.Facet;
-import org.richfaces.cdk.annotations.Facets;
-import org.richfaces.cdk.annotations.Family;
-import org.richfaces.cdk.annotations.Fires;
-import org.richfaces.cdk.annotations.Generate;
-import org.richfaces.cdk.annotations.Icon;
-import org.richfaces.cdk.annotations.Signature;
-import org.richfaces.cdk.annotations.SuggestedValue;
+import org.richfaces.cdk.annotations.*;
import org.richfaces.cdk.model.ClassDescription;
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.DescriptionGroup;
@@ -70,367 +38,449 @@
import org.richfaces.cdk.xmlconfig.CdkEntityResolver;
import org.richfaces.cdk.xmlconfig.FragmentParser;
-import com.google.common.collect.Lists;
+import javax.annotation.processing.RoundEnvironment;
+import javax.annotation.processing.SupportedAnnotationTypes;
+import javax.faces.event.FacesEvent;
+
+import javax.lang.model.element.*;
+import javax.lang.model.type.MirroredTypesException;
+import javax.lang.model.type.TypeMirror;
+import javax.lang.model.util.ElementFilter;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+
/**
- * <p class="changed_added_4_0">That class process component-related
annotations such as {@link Component} or {@link FacesComponent} and stores information in
model.
+ * <p class="changed_added_4_0">That class process component-related
annotations such as {@link Component} or
+ * {@link javax.faces.component.FacesComponent} and stores information in model.
* </p>
- *
+ *
* @author asmirnov(a)exadel.com
- *
+ *
*/
-(a)SupportedAnnotationTypes({"javax.faces.component.FacesComponent",Component.NAME})
+(a)SupportedAnnotationTypes({"javax.faces.component.FacesComponent",
Component.NAME})
public class ComponentProcessor extends CdkProcessor {
+ private static final String FACES_COMPONENT =
"javax.faces.component.FacesComponent";
+ private FragmentParser fragmentParser;
+ private final ComponentLibrary library;
- private static final String FACES_COMPONENT =
"javax.faces.component.FacesComponent";
- private final ComponentLibrary library;
- private FragmentParser fragmentParser;
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param context
+ * @throws CdkException
+ */
+ public ComponentProcessor(CdkContext context, ComponentLibrary library) throws
CdkException {
+ super(context);
+ this.library = library;
+ fragmentParser = context.getWorkerInstance(FragmentParser.class);
+ }
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @param context
- * @throws CdkException
- */
- public ComponentProcessor(CdkContext context, ComponentLibrary library) throws
CdkException {
- super(context);
- this.library = library;
- fragmentParser = context.getWorkerInstance(FragmentParser.class);
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.annotation.processing.AbstractProcessor#process(java.util.Set,
+ * javax.annotation.processing.RoundEnvironment)
+ */
+ @Override
+ public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment
roundEnv) {
+ if (null != annotations && !annotations.isEmpty()) {
+ ComponentLibrary library = getLibrary();
- /*
- * (non-Javadoc)
- *
- * @see javax.annotation.processing.AbstractProcessor#process(java.util.Set,
- * javax.annotation.processing.RoundEnvironment)
- */
- @Override
- public boolean process(Set<? extends TypeElement> annotations,
- RoundEnvironment roundEnv) {
- if (null != annotations && !annotations.isEmpty()) {
- ComponentLibrary library = getLibrary();
- // Process all component classes annotated with CDK @Component.
- Set<? extends TypeElement> componentClasses = getClassesAnnotatedWith(
- roundEnv, Component.class);
- for (TypeElement componentElement : componentClasses) {
- try {
- // Process class-level annotations.
- // Calculate type for base UI component class.
- Component componentAnnotation = componentElement
- .getAnnotation(Component.class);
- // Because component type is a primary key for components collection, we have to
infer explicit value here.
- String type =
getNamingConventions().inferComponentType(componentAnnotation.value(),componentElement.getQualifiedName().toString());
- org.richfaces.cdk.model.Component component = library.findOrCreateComponent(type);
- // Should that component be generated ?
- setClassNames(componentElement, component);
- setComponentProperties(componentElement, component);
- } catch (Exception e) {
- // rise error and continue.
- processingEnv.getMessager().printMessage(
- javax.tools.Diagnostic.Kind.ERROR, e.getMessage(),
- componentElement);
- continue;
- }
- }
- // process classes annotated as "FacesComponent".
- TypeElement facesComponentAnnotation =
this.processingEnv.getElementUtils().getTypeElement(FACES_COMPONENT);
- // TODO - extrach AnnotationMirror processing into separate methods.
- Set<? extends TypeElement> annotatedWith =
ElementFilter.typesIn(roundEnv.getElementsAnnotatedWith(facesComponentAnnotation));
- for (TypeElement element : annotatedWith) {
- List<? extends AnnotationMirror> mirrors = element.getAnnotationMirrors();
- for (AnnotationMirror mirror : mirrors) {
- if(FACES_COMPONENT.equals(mirror.getAnnotationType().toString())){
- Map<? extends ExecutableElement, ? extends AnnotationValue>
valuesWithDefaults =
processingEnv.getElementUtils().getElementValuesWithDefaults(mirror);
- for (Entry<? extends ExecutableElement, ? extends AnnotationValue> valueEntry
: valuesWithDefaults.entrySet()) {
- Name name = valueEntry.getKey().getSimpleName();
- if("value".equals(name.toString())){
- try {
- Object value = valueEntry.getValue().getValue();
- if(null!=value && value instanceof String){
- org.richfaces.cdk.model.Component component =
library.findOrCreateComponent(value.toString());
- ClassDescription componentClass = new ClassDescription(element
- .getQualifiedName().toString());
- component.setComponentClass(componentClass);
- component.setGenerate(false);
- setComponentProperties(element, component);
- }
- } catch (Exception e) {
- // rise error and continue.
- processingEnv.getMessager().printMessage(
- javax.tools.Diagnostic.Kind.ERROR, e.getMessage(),
- element);
- continue;
- }
- }
- }
- }
- }
- }
- return true;
- }
- return false;
- }
+ // Process all component classes annotated with CDK @Component.
+ Set<? extends TypeElement> componentClasses =
getClassesAnnotatedWith(roundEnv, Component.class);
- private void setComponentProperties(TypeElement componentElement,
- org.richfaces.cdk.model.Component component) throws CdkException {
- // Component family
- setComponeneFamily(componentElement, component);
- setComponentDescription(componentElement, component);
- processFacets(componentElement,component);
- // TODO - process Events attribute.
- // TODO - process renderers ( @Renderer and @RendererTemplate attribute.
- // TODO - process @Test annotations.
- // Process attributes.
- processAttributes(componentElement, component);
- }
+ for (TypeElement componentElement : componentClasses) {
+ try {
- private void processFacets(TypeElement componentElement,
- org.richfaces.cdk.model.Component component) throws CdkException {
- Set<BeanProperty> properties = getBeanPropertiesAnnotatedWith(
- Facet.class, componentElement);
- // TODO - encapsulate attribute builder into utility class.
- for (BeanProperty beanProperty : properties) {
- org.richfaces.cdk.model.Facet facet = component.findOrCreateFacet(beanProperty
- .getName());
- // Documentation
- facet.setDescription(beanProperty.getDocComment());
- Icon icon = beanProperty.getAnnotation(Icon.class);
- if (null != icon) {
- setIcon(facet, icon);
- }
- DisplayName displayName = beanProperty
- .getAnnotation(DisplayName.class);
- if (null != displayName) {
- facet.setDisplayname(displayName.value());
- }
- // Flags.
- facet.setGenerate(beanProperty.isExists());
- }
- // @Facets annotation.
- Facets facetsAnnotation = componentElement
- .getAnnotation(Facets.class);
- if (null != facetsAnnotation) {
- Facet[] facets = facetsAnnotation.value();
- for (Facet facet : facets) {
- if (!Strings.isEmpty(facet.value())) {
- component.findOrCreateFacet(facet.value());
- } else {
- // TODO - record error.
- }
- }
- }
-
- }
+ // Process class-level annotations.
+ // Calculate type for base UI component class.
+ Component componentAnnotation =
componentElement.getAnnotation(Component.class);
- private void setComponentDescription(TypeElement componentElement,
- org.richfaces.cdk.model.Component component) {
- // JavaDoc comments
- component.setDescription(this.processingEnv.getElementUtils()
- .getDocComment(componentElement));
- Icon icon = componentElement.getAnnotation(Icon.class);
- if (null != icon) {
- setIcon(component, icon);
- }
- DisplayName displayName = componentElement
- .getAnnotation(DisplayName.class);
- if (null != displayName) {
- component.setDisplayname(displayName.value());
- }
- }
+ // Because component type is a primary key for components collection,
we have to infer explicit
+ // value here.
+ String type =
getNamingConventions().inferComponentType(componentAnnotation.value(),
+ componentElement.getQualifiedName().toString());
+ org.richfaces.cdk.model.Component component =
library.findOrCreateComponent(type);
- /**
- * <p class="changed_added_4_0"></p>
- * @param component
- * @param icon
- */
- private void setIcon(DescriptionGroup component, Icon icon) {
- DescriptionGroup.Icon iconValue = new DescriptionGroup.Icon();
- if (icon.small().length() > 0) {
- iconValue.setSmallIcon(icon.small());
- }
- if (icon.large().length() > 0) {
- iconValue.setLargeIcon(icon.large());
- }
- component.setIcon(iconValue);
- }
+ // Should that component be generated ?
+ setClassNames(componentElement, component);
+ setComponentProperties(componentElement, component);
+ } catch (Exception e) {
- private void setComponeneFamily(TypeElement componentElement,
- org.richfaces.cdk.model.Component component) {
- Family family = componentElement.getAnnotation(Family.class);
- if (null != family) {
- // @Family annotation
- component.setFamily(family.value());
- } else {
- // static final COMPONENT_FAMILY string constant.
- List<VariableElement> fieldsIn =
ElementFilter.fieldsIn(this.processingEnv.getElementUtils().getAllMembers(componentElement));
- for (VariableElement field : fieldsIn) {
- Set<Modifier> modifiers = field.getModifiers();
- if(modifiers.contains(Modifier.FINAL)&&modifiers.contains(Modifier.STATIC)&&field.getSimpleName().equals("COMPONENT_FAMILY")){
- Object value = field.getConstantValue();
- if(null != value){
- component.setFamily(value.toString());
- }
- }
- }
- }
- }
+ // rise error and continue.
+
processingEnv.getMessager().printMessage(javax.tools.Diagnostic.Kind.ERROR,
e.getMessage(),
+ componentElement);
- private void setEvents(TypeElement componentElement,
- org.richfaces.cdk.model.Component component) {
- Fires fires = componentElement.getAnnotation(Fires.class);
- if(null != fires){
- try {
- for (Class<? extends FacesEvent> eventClass : fires.value()) {
- component.addEvent(eventClass.getName());
- }
- } catch (MirroredTypesException mirror) {
- for(TypeMirror eventType :mirror.getTypeMirrors()){
- component.addEvent(eventType.toString());
- // TODO - check does component already implement eventSource interface
- }
- }
- }
- }
+ continue;
+ }
+ }
-
- private void setClassNames(TypeElement componentElement,
- org.richfaces.cdk.model.Component component) {
- Generate generate = componentElement.getAnnotation(Generate.class);
- // Set generated and base class names.
- ClassDescription baseClass = new ClassDescription(componentElement
- .getQualifiedName().toString());
- if (null != generate) {
- component.setComponentClass(new ClassDescription(generate.value()));
- component.setBaseClass(baseClass);
- component.setGenerate(true);
- } else if (componentElement.getModifiers().contains(Modifier.ABSTRACT)) {
- // Final component class will be set by validator.
- component.setBaseClass(baseClass);
- component.setGenerate(true);
- } else {
- component.setComponentClass(baseClass);
- component.setGenerate(false);
- }
- }
+ // process classes annotated as "FacesComponent".
+ TypeElement facesComponentAnnotation =
this.processingEnv.getElementUtils().getTypeElement(FACES_COMPONENT);
- protected void processAttributes(TypeElement componentElement,
- org.richfaces.cdk.model.Component component) throws CdkException {
- Set<BeanProperty> properties = getBeanPropertiesAnnotatedWith(
- Attribute.class, componentElement);
- // TODO - encapsulate attribute builder into utility class.
- for (BeanProperty beanProperty : properties) {
- Property attribute = component.findOrCreateAttribute(beanProperty
- .getName());
- // Flags
- Attribute attributeAnnotarion = beanProperty.getAnnotation(Attribute.class);
- attribute.setHidden(attributeAnnotarion.hidden());
- attribute.setLiteral(attributeAnnotarion.literal());
- attribute.setPassThrough(attributeAnnotarion.passThough());
- attribute.setRequired(attributeAnnotarion.required());
- attribute.setReadOnly(attributeAnnotarion.readOnly());
- // Documentation
- attribute.setDescription(beanProperty.getDocComment());
- Icon icon = beanProperty.getAnnotation(Icon.class);
- if (null != icon) {
- setIcon(attribute,icon);
- }
- DisplayName displayName = beanProperty
- .getAnnotation(DisplayName.class);
- if (null != displayName) {
- attribute.setDisplayname(displayName.value());
- }
- // type.
- attribute.setType(new ClassDescription(beanProperty.getType()
- .toString()));
- // MethodExpression call signature.
- Signature signature = beanProperty.getAnnotation(Signature.class);
- if(null != signature){
- List<ClassDescription> parameters = Lists.newArrayList();
- try {
- for (Class<?> parameterType : signature.parameters()) {
- parameters.add(new ClassDescription(parameterType.getName()));
- }
- } catch (MirroredTypesException e) {
- for(TypeMirror parameterType :e.getTypeMirrors()){
- parameters.add(new ClassDescription(parameterType.toString()));
- }
- }
- // signature parameters always should be replaced.
- attribute.setSignature(parameters);
- // TODO - set method return type.
- }
- // Behavior events.
- EventName eventName = beanProperty.getAnnotation(EventName.class);
- setBehaviorEvent(attribute, eventName);
- EventNames eventNames = beanProperty.getAnnotation(EventNames.class);
- if(null != eventNames){
- for (EventName eventNameInstance : eventNames.value()) {
- setBehaviorEvent(attribute, eventNameInstance);
- }
- }
- // DefaultValues
- DefaultValue defaultValue = beanProperty.getAnnotation(DefaultValue.class);
- if(null != defaultValue){
- attribute.setDefaultValue(defaultValue.value());
- }
- SuggestedValue suggestedValue = beanProperty.getAnnotation(SuggestedValue.class);
- if(null != suggestedValue){
- attribute.setSuggestedValue(suggestedValue.value());
- }
- // Flags.
- attribute.setGenerate(!beanProperty.isExists()||null !=
beanProperty.getAnnotation(Generate.class));
- }
- // Process XML files with standard attributes definitions.
- Attributes attributes = componentElement
- .getAnnotation(Attributes.class);
- if (null != attributes) {
- String[] includes = attributes.value();
- for (String attributesConfig : includes) {
- // process additional properties.
- component.getAttributes().addAll(fragmentParser.parseProperties(attributesConfig));
- }
- }
- // Process standard information for parent classes
- processTypeProperties(component,componentElement.getSuperclass());
- // and interfaces.
- List<? extends TypeMirror> interfaces = componentElement.getInterfaces();
- for (TypeMirror interfaceMirror : interfaces) {
- processTypeProperties(component,interfaceMirror);
- }
- }
+ // TODO - extrach AnnotationMirror processing into separate methods.
+ Set<? extends TypeElement> annotatedWith =
+
ElementFilter.typesIn(roundEnv.getElementsAnnotatedWith(facesComponentAnnotation));
- private void setBehaviorEvent(Property attribute, EventName eventName) {
- if(null != eventName){
- org.richfaces.cdk.model.EventName event = new org.richfaces.cdk.model.EventName();
- event.setName(eventName.value());
- event.setDefaultEvent(eventName.defaultEvent());
- attribute.getEventNames().add(event);
- }
- }
+ for (TypeElement element : annotatedWith) {
+ List<? extends AnnotationMirror> mirrors =
element.getAnnotationMirrors();
- /**
- * <p class="changed_added_4_0">Reccursive method to find and process
standard class or interface attributes.</p>
- * @param component
- * @param interfaceMirror
- */
- private void processTypeProperties(
- org.richfaces.cdk.model.Component component,
- TypeMirror interfaceMirror) {
- String name = interfaceMirror.toString();
- try{
- component.getAttributes().addAll(fragmentParser.parseProperties(CdkEntityResolver.URN_ATTRIBUTES+name+".xml"));
- } catch(CdkException e){
- // TODO - log errors ?
- }
- List<? extends TypeMirror> supertypes =
processingEnv.getTypeUtils().directSupertypes(interfaceMirror);
- for (TypeMirror supertype : supertypes) {
- processTypeProperties(component, supertype);
- }
- }
+ for (AnnotationMirror mirror : mirrors) {
+ if (FACES_COMPONENT.equals(mirror.getAnnotationType().toString())) {
+ Map<? extends ExecutableElement, ? extends AnnotationValue>
valuesWithDefaults =
+
processingEnv.getElementUtils().getElementValuesWithDefaults(mirror);
- public ComponentLibrary getLibrary() {
- return library;
- }
+ for (Entry<? extends ExecutableElement, ? extends
AnnotationValue> valueEntry
+ : valuesWithDefaults.entrySet()) {
+ Name name = valueEntry.getKey().getSimpleName();
+ if ("value".equals(name.toString())) {
+ try {
+ Object value = valueEntry.getValue().getValue();
+
+ if (null != value && value instanceof String)
{
+ org.richfaces.cdk.model.Component component =
+
library.findOrCreateComponent(value.toString());
+ ClassDescription componentClass =
+ new
ClassDescription(element.getQualifiedName().toString());
+
+ component.setComponentClass(componentClass);
+ component.setGenerate(false);
+ setComponentProperties(element, component);
+ }
+ } catch (Exception e) {
+
+ // rise error and continue.
+
processingEnv.getMessager().printMessage(javax.tools.Diagnostic.Kind.ERROR,
+ e.getMessage(), element);
+
+ continue;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return true;
+ }
+
+ return false;
+ }
+
+ private void setComponentProperties(TypeElement componentElement,
org.richfaces.cdk.model.Component component)
+ throws CdkException {
+
+ // Component family
+ setComponeneFamily(componentElement, component);
+ setComponentDescription(componentElement, component);
+ processFacets(componentElement, component);
+
+ // TODO - process Events attribute.
+ // TODO - process renderers ( @Renderer and @RendererTemplate attribute.
+ // TODO - process @Test annotations.
+ // Process attributes.
+ processAttributes(componentElement, component);
+ }
+
+ private void processFacets(TypeElement componentElement,
org.richfaces.cdk.model.Component component) {
+ Set<BeanProperty> properties = getBeanPropertiesAnnotatedWith(Facet.class,
componentElement);
+
+ // TODO - encapsulate attribute builder into utility class.
+ for (BeanProperty beanProperty : properties) {
+ org.richfaces.cdk.model.Facet facet =
component.findOrCreateFacet(beanProperty.getName());
+
+ // Documentation
+ facet.setDescription(beanProperty.getDocComment());
+
+ Icon icon = beanProperty.getAnnotation(Icon.class);
+
+ if (null != icon) {
+ setIcon(facet, icon);
+ }
+
+ DisplayName displayName = beanProperty.getAnnotation(DisplayName.class);
+
+ if (null != displayName) {
+ facet.setDisplayname(displayName.value());
+ }
+
+ // Flags.
+ facet.setGenerate(beanProperty.isExists());
+ }
+
+ // @Facets annotation.
+ Facets facetsAnnotation = componentElement.getAnnotation(Facets.class);
+
+ if (null != facetsAnnotation) {
+ Facet[] facets = facetsAnnotation.value();
+
+ for (Facet facet : facets) {
+ if (!Strings.isEmpty(facet.value())) {
+ component.findOrCreateFacet(facet.value());
+ } else {
+
+ // TODO - record error.
+ }
+ }
+ }
+ }
+
+ private void setComponentDescription(TypeElement componentElement,
org.richfaces.cdk.model.Component component) {
+
+ // JavaDoc comments
+
component.setDescription(this.processingEnv.getElementUtils().getDocComment(componentElement));
+
+ Icon icon = componentElement.getAnnotation(Icon.class);
+
+ if (null != icon) {
+ setIcon(component, icon);
+ }
+
+ DisplayName displayName = componentElement.getAnnotation(DisplayName.class);
+
+ if (null != displayName) {
+ component.setDisplayname(displayName.value());
+ }
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param component
+ * @param icon
+ */
+ private void setIcon(DescriptionGroup component, Icon icon) {
+ DescriptionGroup.Icon iconValue = new DescriptionGroup.Icon();
+
+ if (icon.small().length() > 0) {
+ iconValue.setSmallIcon(icon.small());
+ }
+
+ if (icon.large().length() > 0) {
+ iconValue.setLargeIcon(icon.large());
+ }
+
+ component.setIcon(iconValue);
+ }
+
+ private void setComponeneFamily(TypeElement componentElement,
org.richfaces.cdk.model.Component component) {
+ Family family = componentElement.getAnnotation(Family.class);
+
+ if (null != family) {
+
+ // @Family annotation
+ component.setFamily(family.value());
+ } else {
+
+ // static final COMPONENT_FAMILY string constant.
+ List<VariableElement> fieldsIn =
+
ElementFilter.fieldsIn(this.processingEnv.getElementUtils().getAllMembers(componentElement));
+
+ for (VariableElement field : fieldsIn) {
+ Set<Modifier> modifiers = field.getModifiers();
+
+ if (modifiers.contains(Modifier.FINAL) &&
modifiers.contains(Modifier.STATIC)
+ &&
field.getSimpleName().equals("COMPONENT_FAMILY")) {
+ Object value = field.getConstantValue();
+
+ if (null != value) {
+ component.setFamily(value.toString());
+ }
+ }
+ }
+ }
+ }
+
+ private void setEvents(TypeElement componentElement,
org.richfaces.cdk.model.Component component) {
+ Fires fires = componentElement.getAnnotation(Fires.class);
+
+ if (null != fires) {
+ try {
+ for (Class<? extends FacesEvent> eventClass : fires.value()) {
+ component.addEvent(eventClass.getName());
+ }
+ } catch (MirroredTypesException mirror) {
+ for (TypeMirror eventType : mirror.getTypeMirrors()) {
+ component.addEvent(eventType.toString());
+
+ // TODO - check does component already implement eventSource
interface
+ }
+ }
+ }
+ }
+
+ private void setClassNames(TypeElement componentElement,
org.richfaces.cdk.model.Component component) {
+ Generate generate = componentElement.getAnnotation(Generate.class);
+
+ // Set generated and base class names.
+ ClassDescription baseClass = new
ClassDescription(componentElement.getQualifiedName().toString());
+
+ if (null != generate) {
+ component.setComponentClass(new ClassDescription(generate.value()));
+ component.setBaseClass(baseClass);
+ component.setGenerate(true);
+ } else if (componentElement.getModifiers().contains(Modifier.ABSTRACT)) {
+
+ // Final component class will be set by validator.
+ component.setBaseClass(baseClass);
+ component.setGenerate(true);
+ } else {
+ component.setComponentClass(baseClass);
+ component.setGenerate(false);
+ }
+ }
+
+ protected void processAttributes(TypeElement componentElement,
org.richfaces.cdk.model.Component component)
+ throws CdkException {
+
+ Set<BeanProperty> properties =
getBeanPropertiesAnnotatedWith(Attribute.class, componentElement);
+
+ // TODO - encapsulate attribute builder into utility class.
+ for (BeanProperty beanProperty : properties) {
+ Property attribute =
component.findOrCreateAttribute(beanProperty.getName());
+
+ // Flags
+ Attribute attributeAnnotarion = beanProperty.getAnnotation(Attribute.class);
+
+ attribute.setHidden(attributeAnnotarion.hidden());
+ attribute.setLiteral(attributeAnnotarion.literal());
+ attribute.setPassThrough(attributeAnnotarion.passThough());
+ attribute.setRequired(attributeAnnotarion.required());
+ attribute.setReadOnly(attributeAnnotarion.readOnly());
+
+ // Documentation
+ attribute.setDescription(beanProperty.getDocComment());
+
+ Icon icon = beanProperty.getAnnotation(Icon.class);
+
+ if (null != icon) {
+ setIcon(attribute, icon);
+ }
+
+ DisplayName displayName = beanProperty.getAnnotation(DisplayName.class);
+
+ if (null != displayName) {
+ attribute.setDisplayname(displayName.value());
+ }
+
+ // type.
+ attribute.setType(new ClassDescription(beanProperty.getType().toString()));
+
+ // MethodExpression call signature.
+ Signature signature = beanProperty.getAnnotation(Signature.class);
+
+ if (null != signature) {
+ List<ClassDescription> parameters = Lists.newArrayList();
+
+ try {
+ for (Class<?> parameterType : signature.parameters()) {
+ parameters.add(new ClassDescription(parameterType.getName()));
+ }
+ } catch (MirroredTypesException e) {
+ for (TypeMirror parameterType : e.getTypeMirrors()) {
+ parameters.add(new ClassDescription(parameterType.toString()));
+ }
+ }
+
+ // signature parameters always should be replaced.
+ attribute.setSignature(parameters);
+
+ // TODO - set method return type.
+ }
+
+ // Behavior events.
+ EventName eventName = beanProperty.getAnnotation(EventName.class);
+
+ setBehaviorEvent(attribute, eventName);
+
+ EventNames eventNames = beanProperty.getAnnotation(EventNames.class);
+
+ if (null != eventNames) {
+ for (EventName eventNameInstance : eventNames.value()) {
+ setBehaviorEvent(attribute, eventNameInstance);
+ }
+ }
+
+ // DefaultValues
+ DefaultValue defaultValue = beanProperty.getAnnotation(DefaultValue.class);
+
+ if (null != defaultValue) {
+ attribute.setDefaultValue(defaultValue.value());
+ }
+
+ SuggestedValue suggestedValue =
beanProperty.getAnnotation(SuggestedValue.class);
+
+ if (null != suggestedValue) {
+ attribute.setSuggestedValue(suggestedValue.value());
+ }
+
+ // Flags.
+ attribute.setGenerate(!beanProperty.isExists() || null !=
beanProperty.getAnnotation(Generate.class));
+ }
+
+ // Process XML files with standard attributes definitions.
+ Attributes attributes = componentElement.getAnnotation(Attributes.class);
+
+ if (null != attributes) {
+ String[] includes = attributes.value();
+
+ for (String attributesConfig : includes) {
+
+ // process additional properties.
+
component.getAttributes().addAll(fragmentParser.parseProperties(attributesConfig));
+ }
+ }
+
+ // Process standard information for parent classes
+ processTypeProperties(component, componentElement.getSuperclass());
+
+ // and interfaces.
+ List<? extends TypeMirror> interfaces = componentElement.getInterfaces();
+
+ for (TypeMirror interfaceMirror : interfaces) {
+ processTypeProperties(component, interfaceMirror);
+ }
+ }
+
+ private void setBehaviorEvent(Property attribute, EventName eventName) {
+ if (null != eventName) {
+ org.richfaces.cdk.model.EventName event = new
org.richfaces.cdk.model.EventName();
+
+ event.setName(eventName.value());
+ event.setDefaultEvent(eventName.defaultEvent());
+ attribute.getEventNames().add(event);
+ }
+ }
+
+ /**
+ * <p class="changed_added_4_0">Reccursive method to find and process
standard class or interface attributes.</p>
+ * @param component
+ * @param interfaceMirror
+ */
+ private void processTypeProperties(org.richfaces.cdk.model.Component component,
TypeMirror interfaceMirror) {
+ String name = interfaceMirror.toString();
+
+ try {
+
component.getAttributes().addAll(fragmentParser.parseProperties(CdkEntityResolver.URN_ATTRIBUTES
+ name
+ + ".xml"));
+ } catch (CdkException e) {
+
+ // TODO - log errors ?
+ }
+
+ List<? extends TypeMirror> supertypes =
processingEnv.getTypeUtils().directSupertypes(interfaceMirror);
+
+ for (TypeMirror supertype : supertypes) {
+ processTypeProperties(component, supertype);
+ }
+ }
+
+ public ComponentLibrary getLibrary() {
+ return library;
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/VirtualFileManager.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/VirtualFileManager.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/VirtualFileManager.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -21,543 +21,559 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.apt;
+import com.google.common.collect.BiMap;
+import com.google.common.collect.HashBiMap;
+import com.google.common.collect.Lists;
+
+import org.richfaces.cdk.Logger;
+import org.richfaces.cdk.LoggerFactory;
+
+import javax.tools.*;
+import javax.tools.JavaFileObject.Kind;
+
import java.io.File;
import java.io.FilenameFilter;
import java.io.IOException;
-import java.io.InputStream;
import java.io.Serializable;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.util.ArrayList;
+
import java.util.Collections;
-import java.util.Enumeration;
import java.util.Iterator;
import java.util.List;
-import java.util.Map;
import java.util.Set;
-import javax.tools.FileObject;
-import javax.tools.ForwardingJavaFileManager;
-import javax.tools.JavaFileManager;
-import javax.tools.JavaFileObject;
-import javax.tools.StandardJavaFileManager;
-import javax.tools.StandardLocation;
-import javax.tools.JavaFileObject.Kind;
-
-import org.richfaces.cdk.Logger;
-import org.richfaces.cdk.LoggerFactory;
-
-import com.google.common.collect.BiMap;
-import com.google.common.collect.HashBiMap;
-import com.google.common.collect.Lists;
-
/**
* <p class="changed_added_4_0">
* That class wraps {@link StandardJavaFileManager}
* </p>
- *
+ *
* @author asmirnov(a)exadel.com
- *
+ *
*/
-final class VirtualFileManager extends
- ForwardingJavaFileManager<JavaFileManager> {
+final class VirtualFileManager extends ForwardingJavaFileManager<JavaFileManager>
{
+ private static final Logger LOG = LoggerFactory.getLogger();
- private static final Logger log = LoggerFactory.getLogger();
+// private final BiMap<FileObjectKey, FileObject> classPathFiles;
+// private final BiMap<FileObject, FileObjectKey> inversedClassPathFiles;
+ private final ClassLoader classPathLoader;
+ private final BiMap<FileObject, FileObjectKey> inversedSources;
+ private final BiMap<FileObjectKey, FileObject> sources;
- private final BiMap<FileObjectKey, FileObject> sources;
- private final BiMap<FileObject, FileObjectKey> inversedSources;
+ private File javaSourceDirectory;
+ private File outputDirectory;
-// private final BiMap<FileObjectKey, FileObject> classPathFiles;
-// private final BiMap<FileObject, FileObjectKey> inversedClassPathFiles;
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param fileManager
+ */
+ public VirtualFileManager(JavaFileManager fileManager, ClassLoader classPathLoader)
{
+ super(fileManager);
+ this.classPathLoader = classPathLoader;
+ this.sources = HashBiMap.create(128);
+ inversedSources = this.sources.inverse();
- private final ClassLoader classPathLoader;
+// this.classPathFiles = HashBiMap.create(128);
+// inversedClassPathFiles = this.classPathFiles.inverse();
+ }
- private File outputDirectory;
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * javax.tools.ForwardingJavaFileManager#getJavaFileForInput(javax.tools
+ * .JavaFileManager.Location, java.lang.String,
+ * javax.tools.JavaFileObject.Kind)
+ */
+ @Override
+ public JavaFileObject getJavaFileForInput(Location location, String className, Kind
kind) throws IOException {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("VirtualFileManager.getJavaFileForInput(" +
String.valueOf(location) + "," + className + ","
+ + String.valueOf(kind) + ")");
+ }
- private File javaSourceDirectory;
+ FileObjectKey key = new FileObjectKey(className, kind);
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @param fileManager
- */
- public VirtualFileManager(JavaFileManager fileManager,
- ClassLoader classPathLoader) {
- super(fileManager);
- this.classPathLoader = classPathLoader;
- this.sources = HashBiMap.create(128);
- inversedSources = this.sources.inverse();
-// this.classPathFiles = HashBiMap.create(128);
-// inversedClassPathFiles = this.classPathFiles.inverse();
- }
+ if (StandardLocation.SOURCE_PATH.equals(location)) {
+ JavaFileObject fileObject = null;
- /*
- * (non-Javadoc)
- *
- * @see
- * javax.tools.ForwardingJavaFileManager#getJavaFileForInput(javax.tools
- * .JavaFileManager.Location, java.lang.String,
- * javax.tools.JavaFileObject.Kind)
- */
- @Override
- public JavaFileObject getJavaFileForInput(Location location,
- String className, Kind kind) throws IOException {
- if (log.isDebugEnabled()) {
- log.debug("VirtualFileManager.getJavaFileForInput("
- + String.valueOf(location) + "," + className + ","
- + String.valueOf(kind) + ")");
- }
- FileObjectKey key = new FileObjectKey(className, kind);
- if (StandardLocation.SOURCE_PATH.equals(location)) {
- JavaFileObject fileObject = null;
- fileObject = (JavaFileObject) sources.get(key);
- if (null == fileObject && null != javaSourceDirectory) {
- String fileName = className.replace('.', File.separatorChar)
- + kind.extension;
- File resource = new File(javaSourceDirectory, fileName);
- if (resource.exists()) {
- fileObject = new VirtualJavaFileSystemObject(resource, kind);
- sources.put(key, fileObject);
- }
- }
- return fileObject;
- }
- return super.getJavaFileForInput(location, className, kind);
- }
+ fileObject = (JavaFileObject) sources.get(key);
- @Override
- public ClassLoader getClassLoader(Location location) {
- if (log.isDebugEnabled()) {
- log.debug("VirtualFileManager.getClassLoader("
- + String.valueOf(location) + ")");
- }
- if (StandardLocation.CLASS_OUTPUT.equals(location)
- || StandardLocation.SOURCE_PATH.equals(location)
- || StandardLocation.SOURCE_OUTPUT.equals(location)) {
- return getClassPathLoader();
- } else {
- return super.getClassLoader(location);
- }
- }
+ if (null == fileObject && null != javaSourceDirectory) {
+ String fileName = className.replace('.', File.separatorChar) +
kind.extension;
+ File resource = new File(javaSourceDirectory, fileName);
- /*
- * (non-Javadoc)
- *
- * @see
- * javax.tools.ForwardingJavaFileManager#getJavaFileForOutput(javax.tools
- * .JavaFileManager.Location, java.lang.String,
- * javax.tools.JavaFileObject.Kind, javax.tools.FileObject)
- */
- @Override
- public JavaFileObject getJavaFileForOutput(Location location,
- String className, Kind kind, FileObject sibling) throws IOException {
- if (log.isDebugEnabled()) {
- log.debug("VirtualFileManager.getJavaFileForOutput("
- + String.valueOf(location) + "," + className + ","
- + String.valueOf(kind) + "," + String.valueOf(sibling)
- + ")");
- }
- JavaFileObject fileForOutput = null;
- if (StandardLocation.CLASS_OUTPUT.equals(location)
- && null != getOutputDirectory()) {
- String fileName = className.replace('.', '/') + kind.extension;
- File outputFile = new File(getOutputDirectory(), fileName);
- fileForOutput = new VirtualJavaFileSystemObject(outputFile, kind);
- }
- return fileForOutput;
- }
+ if (resource.exists()) {
+ fileObject = new VirtualJavaFileSystemObject(resource, kind);
+ sources.put(key, fileObject);
+ }
+ }
- /*
- * (non-Javadoc)
- *
- * @see
- * javax.tools.ForwardingJavaFileManager#hasLocation(javax.tools.JavaFileManager
- * .Location)
- */
- @Override
- public boolean hasLocation(Location location) {
- boolean hasLocation;
- if (log.isDebugEnabled()) {
- log.debug("VirtualFileManager.hasLocation("
- + String.valueOf(location) + ")");
- }
- if (StandardLocation.SOURCE_PATH.equals(location)) {
- hasLocation = null != getJavaSourceDirectory()
- || !sources.isEmpty();
- } else if (StandardLocation.CLASS_OUTPUT.equals(location)) {
- hasLocation = null != getOutputDirectory();
- } else {
- hasLocation = super.hasLocation(location);
- }
- return hasLocation;
- }
+ return fileObject;
+ }
-
- @Override
- public Iterable<JavaFileObject> list(final Location location,
- final String packageName, final Set<Kind> kinds,
- final boolean recurse) throws IOException {
- if (log.isDebugEnabled()) {
- log.debug("VirtualFileManager.list(" + String.valueOf(location)
- + "," + packageName + "," + String.valueOf(kinds) +
","
- + String.valueOf(recurse) + ")");
- }
- Iterable<JavaFileObject> list;
- if (StandardLocation.SOURCE_PATH.equals(location)) {
- if (null != getJavaSourceDirectory()) {
- String fileName = packageName.replace('.', File.separatorChar);
- File packageDirectory = new File(getJavaSourceDirectory(),
- fileName);
- if (packageDirectory.exists()) {
- final List<JavaFileObject> fileslist = Lists.newArrayList();
- File[] files = packageDirectory
- .listFiles(new FilenameFilter() {
+ return super.getJavaFileForInput(location, className, kind);
+ }
- @Override
- public boolean accept(File dir, String name) {
- File child = new File(dir, name);
- if (child.isDirectory() && recurse) {
- // Recursive add directory content.
- try {
- Iterable<JavaFileObject> childList = list(
- location, packageName + '.'
- + name, kinds,
- recurse);
- for (JavaFileObject javaFileObject : childList) {
- fileslist.add(javaFileObject);
- }
- } catch (IOException e) {
- return false;
- }
- } else {
- for (Kind kind : kinds) {
- if (name.endsWith(kind.extension)) {
- return true;
- }
- }
- }
- return false;
- }
- });
- for (File file : files) {
- String name = file.getName();
- Kind kind = Kind.SOURCE;
- int indexOfPeriod = name.lastIndexOf('.');
- if (indexOfPeriod > 0) {
- name = name.substring(0, indexOfPeriod);
- String ext = name.substring(indexOfPeriod);
- for (Kind requestedKind : kinds) {
- if (ext.equals(requestedKind.extension)) {
- kind = requestedKind;
- }
- }
- }
- String className = packageName + '.' + name;
- FileObjectKey key = new FileObjectKey(className, kind);
- JavaFileObject javaFileObject = (JavaFileObject) sources
- .get(key);
- if (null == javaFileObject) {
- javaFileObject = new VirtualJavaFileSystemObject(
- file, kind);
- sources.put(key, javaFileObject);
- }
- fileslist.add(javaFileObject);
- }
- list = fileslist;
+ @Override
+ public ClassLoader getClassLoader(Location location) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("VirtualFileManager.getClassLoader(" +
String.valueOf(location) + ")");
+ }
- } else {
- list = Collections.emptyList();
- }
- } else {
- list = Collections.emptyList();
- }
- } else {
- list = super.list(location, packageName, kinds, recurse);
- }
- return list;
- }
+ if (StandardLocation.CLASS_OUTPUT.equals(location) ||
StandardLocation.SOURCE_PATH.equals(location)
+ || StandardLocation.SOURCE_OUTPUT.equals(location)) {
+ return getClassPathLoader();
+ } else {
+ return super.getClassLoader(location);
+ }
+ }
- /*
- * (non-Javadoc)
- *
- * @see javax.tools.ForwardingJavaFileManager#close()
- */
- @Override
- public void close() throws IOException {
- if (log.isDebugEnabled()) {
- log.debug("VirtualFileManager.close()");
- }
- super.close();
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * javax.tools.ForwardingJavaFileManager#getJavaFileForOutput(javax.tools
+ * .JavaFileManager.Location, java.lang.String,
+ * javax.tools.JavaFileObject.Kind, javax.tools.FileObject)
+ */
+ @Override
+ public JavaFileObject getJavaFileForOutput(Location location, String className, Kind
kind, FileObject sibling) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("VirtualFileManager.getJavaFileForOutput(" +
String.valueOf(location) + "," + className + ","
+ + String.valueOf(kind) + "," + String.valueOf(sibling) +
")");
+ }
- /*
- * (non-Javadoc)
- *
- * @see javax.tools.ForwardingJavaFileManager#flush()
- */
- @Override
- public void flush() throws IOException {
- if (log.isDebugEnabled()) {
- log.debug("VirtualFileManager.flush()");
- }
- super.flush();
- }
+ JavaFileObject fileForOutput = null;
- /*
- * (non-Javadoc)
- *
- * @seejavax.tools.ForwardingJavaFileManager#getFileForInput(javax.tools.
- * JavaFileManager.Location, java.lang.String, java.lang.String)
- */
- @Override
- public FileObject getFileForInput(Location location, String packageName,
- String relativeName) throws IOException {
- if (log.isDebugEnabled()) {
- log.debug("VirtualFileManager.getFileForInput("
- + String.valueOf(location) + "," + packageName + ","
- + relativeName + ")");
- }
- if (StandardLocation.SOURCE_PATH.equals(location)) {
- String fileName = packageName.replace('.', File.separatorChar)
- + File.separator + relativeName;
- if (null != javaSourceDirectory) {
- File resource = new File(javaSourceDirectory, fileName);
- if (resource.exists()) {
- return new VirtualJavaFileSystemObject(resource, Kind.OTHER);
- }
- }
- return null;
- }
- return super.getFileForInput(location, packageName, relativeName);
- }
+ if (StandardLocation.CLASS_OUTPUT.equals(location) && null !=
getOutputDirectory()) {
+ String fileName = className.replace('.', '/') +
kind.extension;
+ File outputFile = new File(getOutputDirectory(), fileName);
- /*
- * (non-Javadoc)
- *
- * @seejavax.tools.ForwardingJavaFileManager#getFileForOutput(javax.tools.
- * JavaFileManager.Location, java.lang.String, java.lang.String,
- * javax.tools.FileObject)
- */
- @Override
- public FileObject getFileForOutput(Location location, String packageName,
- String relativeName, FileObject sibling) throws IOException {
- if (log.isDebugEnabled()) {
- log.debug("VirtualFileManager.getFileForOutput("
- + String.valueOf(location) + "," + packageName + ","
- + relativeName + "," + String.valueOf(sibling) + ")");
- }
- return super.getFileForOutput(location, packageName, relativeName,
- sibling);
- }
+ fileForOutput = new VirtualJavaFileSystemObject(outputFile, kind);
+ }
- /*
- * (non-Javadoc)
- *
- * @see javax.tools.ForwardingJavaFileManager#handleOption(java.lang.String,
- * java.util.Iterator)
- */
- @Override
- public boolean handleOption(String current, Iterator<String> remaining) {
- if (log.isDebugEnabled()) {
- log.debug("VirtualFileManager.handleOption(" + current
- + ",remaining)");
- }
- return super.handleOption(current, remaining);
- }
+ return fileForOutput;
+ }
- /*
- * (non-Javadoc)
- *
- * @seejavax.tools.ForwardingJavaFileManager#inferBinaryName(javax.tools.
- * JavaFileManager.Location, javax.tools.JavaFileObject)
- */
- @Override
- public String inferBinaryName(Location location, JavaFileObject file) {
- if (log.isDebugEnabled()) {
- log.debug("VirtualFileManager.inferBinaryName("
- + String.valueOf(location) + "," + String.valueOf(file)
- + ")");
- }
- if (StandardLocation.SOURCE_PATH.equals(location)) {
- FileObjectKey fileObjectKey = inversedSources.get(file);
- if (null != fileObjectKey) {
- return fileObjectKey.getBinaryName();
- } else {
- return null;
- }
- } else {
- return super.inferBinaryName(location, file);
- }
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * javax.tools.ForwardingJavaFileManager#hasLocation(javax.tools.JavaFileManager
+ * .Location)
+ */
+ @Override
+ public boolean hasLocation(Location location) {
+ boolean hasLocation;
- /*
- * (non-Javadoc)
- *
- * @see
- * javax.tools.ForwardingJavaFileManager#isSameFile(javax.tools.FileObject,
- * javax.tools.FileObject)
- */
- @Override
- public boolean isSameFile(FileObject a, FileObject b) {
- if (log.isDebugEnabled()) {
- log.debug("VirtualFileManager.isSameFile(" + String.valueOf(a)
- + "," + String.valueOf(b) + ")");
- }
- if (a instanceof VirtualJavaFileObject) {
- return a.equals(b);
- }
- return super.isSameFile(a, b);
- }
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("VirtualFileManager.hasLocation(" +
String.valueOf(location) + ")");
+ }
- /*
- * (non-Javadoc)
- *
- * @see
- * javax.tools.ForwardingJavaFileManager#isSupportedOption(java.lang.String)
- */
- @Override
- public int isSupportedOption(String option) {
- if (log.isDebugEnabled()) {
- log.debug("VirtualFileManager.isSupportedOption(" + option +
")");
- }
- return super.isSupportedOption(option);
- }
+ if (StandardLocation.SOURCE_PATH.equals(location)) {
+ hasLocation = null != getJavaSourceDirectory() || !sources.isEmpty();
+ } else if (StandardLocation.CLASS_OUTPUT.equals(location)) {
+ hasLocation = null != getOutputDirectory();
+ } else {
+ hasLocation = super.hasLocation(location);
+ }
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @return the classPathLoader
- */
- private ClassLoader getClassPathLoader() {
- return classPathLoader;
- }
+ return hasLocation;
+ }
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @return the outputDirectory
- */
- public File getOutputDirectory() {
- return outputDirectory;
- }
+ @Override
+ public Iterable<JavaFileObject> list(final Location location, final String
packageName, final Set<Kind> kinds,
+ final boolean recurse) throws IOException {
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @param outputDirectory
- * the outputDirectory to set
- */
- public void setOutputDirectory(File outputDirectory) {
- this.outputDirectory = outputDirectory;
- }
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("VirtualFileManager.list(" + String.valueOf(location) +
"," + packageName + ","
+ + String.valueOf(kinds) + "," + String.valueOf(recurse) +
")");
+ }
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @return the javaSourceDirectory
- */
- public File getJavaSourceDirectory() {
- return javaSourceDirectory;
- }
+ Iterable<JavaFileObject> list;
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @param javaSourceDirectory
- * the javaSourceDirectory to set
- */
- public void setJavaSourceDirectory(File javaSourceDirectory) {
- this.javaSourceDirectory = javaSourceDirectory;
- }
+ if (StandardLocation.SOURCE_PATH.equals(location)) {
+ if (null != getJavaSourceDirectory()) {
+ String fileName = packageName.replace('.', File.separatorChar);
+ File packageDirectory = new File(getJavaSourceDirectory(), fileName);
- @SuppressWarnings("serial")
- private static class FileObjectKey implements Serializable {
- private final String binaryName;
- private final Kind kind;
+ if (packageDirectory.exists()) {
+ final List<JavaFileObject> fileslist = Lists.newArrayList();
+ File[] files = packageDirectory.listFiles(new FilenameFilter() {
+ @Override
+ public boolean accept(File dir, String name) {
+ File child = new File(dir, name);
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @param binaryName
- * @param kind
- */
- public FileObjectKey(String binaryName, Kind kind) {
- super();
- this.binaryName = binaryName;
- this.kind = kind;
- }
+ if (child.isDirectory() && recurse) {
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @return the binaryName
- */
- public String getBinaryName() {
- return binaryName;
- }
+ // Recursive add directory content.
+ try {
+ Iterable<JavaFileObject> childList =
list(location, packageName + '.' + name,
+ kinds,
recurse);
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @return the kind
- */
- public Kind getKind() {
- return kind;
- }
+ for (JavaFileObject javaFileObject : childList) {
+ fileslist.add(javaFileObject);
+ }
+ } catch (IOException e) {
+ return false;
+ }
+ } else {
+ for (Kind kind : kinds) {
+ if (name.endsWith(kind.extension)) {
+ return true;
+ }
+ }
+ }
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#hashCode()
- */
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result
- + ((binaryName == null) ? 0 : binaryName.hashCode());
- result = prime * result + ((kind == null) ? 0 : kind.hashCode());
- return result;
- }
+ return false;
+ }
+ });
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#equals(java.lang.Object)
- */
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- FileObjectKey other = (FileObjectKey) obj;
- if (binaryName == null) {
- if (other.binaryName != null)
- return false;
- } else if (!binaryName.equals(other.binaryName))
- return false;
- if (kind == null) {
- if (other.kind != null)
- return false;
- } else if (!kind.equals(other.kind))
- return false;
- return true;
- }
- }
+ for (File file : files) {
+ String name = file.getName();
+ Kind kind = Kind.SOURCE;
+ int indexOfPeriod = name.lastIndexOf('.');
-}
\ No newline at end of file
+ if (indexOfPeriod > 0) {
+ name = name.substring(0, indexOfPeriod);
+
+ String ext = name.substring(indexOfPeriod);
+
+ for (Kind requestedKind : kinds) {
+ if (ext.equals(requestedKind.extension)) {
+ kind = requestedKind;
+ }
+ }
+ }
+
+ String className = packageName + '.' + name;
+ FileObjectKey key = new FileObjectKey(className, kind);
+ JavaFileObject javaFileObject = (JavaFileObject)
sources.get(key);
+
+ if (null == javaFileObject) {
+ javaFileObject = new VirtualJavaFileSystemObject(file,
kind);
+ sources.put(key, javaFileObject);
+ }
+
+ fileslist.add(javaFileObject);
+ }
+
+ list = fileslist;
+ } else {
+ list = Collections.emptyList();
+ }
+ } else {
+ list = Collections.emptyList();
+ }
+ } else {
+ list = super.list(location, packageName, kinds, recurse);
+ }
+
+ return list;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.tools.ForwardingJavaFileManager#close()
+ */
+ @Override
+ public void close() throws IOException {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("VirtualFileManager.close()");
+ }
+
+ super.close();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.tools.ForwardingJavaFileManager#flush()
+ */
+ @Override
+ public void flush() throws IOException {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("VirtualFileManager.flush()");
+ }
+
+ super.flush();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @seejavax.tools.ForwardingJavaFileManager#getFileForInput(javax.tools.
+ * JavaFileManager.Location, java.lang.String, java.lang.String)
+ */
+ @Override
+ public FileObject getFileForInput(Location location, String packageName, String
relativeName) throws IOException {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("VirtualFileManager.getFileForInput(" +
String.valueOf(location) + "," + packageName + ","
+ + relativeName + ")");
+ }
+
+ if (StandardLocation.SOURCE_PATH.equals(location)) {
+ String fileName = packageName.replace('.', File.separatorChar) +
File.separator + relativeName;
+
+ if (null != javaSourceDirectory) {
+ File resource = new File(javaSourceDirectory, fileName);
+
+ if (resource.exists()) {
+ return new VirtualJavaFileSystemObject(resource, Kind.OTHER);
+ }
+ }
+
+ return null;
+ }
+
+ return super.getFileForInput(location, packageName, relativeName);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @seejavax.tools.ForwardingJavaFileManager#getFileForOutput(javax.tools.
+ * JavaFileManager.Location, java.lang.String, java.lang.String,
+ * javax.tools.FileObject)
+ */
+ @Override
+ public FileObject getFileForOutput(Location location, String packageName, String
relativeName, FileObject sibling)
+ throws IOException {
+
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("VirtualFileManager.getFileForOutput(" +
String.valueOf(location) + "," + packageName + ","
+ + relativeName + "," + String.valueOf(sibling) +
")");
+ }
+
+ return super.getFileForOutput(location, packageName, relativeName, sibling);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.tools.ForwardingJavaFileManager#handleOption(java.lang.String,
+ * java.util.Iterator)
+ */
+ @Override
+ public boolean handleOption(String current, Iterator<String> remaining) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("VirtualFileManager.handleOption(" + current +
",remaining)");
+ }
+
+ return super.handleOption(current, remaining);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @seejavax.tools.ForwardingJavaFileManager#inferBinaryName(javax.tools.
+ * JavaFileManager.Location, javax.tools.JavaFileObject)
+ */
+ @Override
+ public String inferBinaryName(Location location, JavaFileObject file) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("VirtualFileManager.inferBinaryName(" +
String.valueOf(location) + "," + String.valueOf(file)
+ + ")");
+ }
+
+ if (StandardLocation.SOURCE_PATH.equals(location)) {
+ FileObjectKey fileObjectKey = inversedSources.get(file);
+
+ if (null != fileObjectKey) {
+ return fileObjectKey.getBinaryName();
+ } else {
+ return null;
+ }
+ } else {
+ return super.inferBinaryName(location, file);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * javax.tools.ForwardingJavaFileManager#isSameFile(javax.tools.FileObject,
+ * javax.tools.FileObject)
+ */
+ @Override
+ public boolean isSameFile(FileObject a, FileObject b) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("VirtualFileManager.isSameFile(" + String.valueOf(a) +
"," + String.valueOf(b) + ")");
+ }
+
+ if (a instanceof VirtualJavaFileObject) {
+ return a.equals(b);
+ }
+
+ return super.isSameFile(a, b);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * javax.tools.ForwardingJavaFileManager#isSupportedOption(java.lang.String)
+ */
+ @Override
+ public int isSupportedOption(String option) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("VirtualFileManager.isSupportedOption(" + option +
")");
+ }
+
+ return super.isSupportedOption(option);
+ }
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @return the classPathLoader
+ */
+ private ClassLoader getClassPathLoader() {
+ return classPathLoader;
+ }
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @return the outputDirectory
+ */
+ public File getOutputDirectory() {
+ return outputDirectory;
+ }
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param outputDirectory
+ * the outputDirectory to set
+ */
+ public void setOutputDirectory(File outputDirectory) {
+ this.outputDirectory = outputDirectory;
+ }
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @return the javaSourceDirectory
+ */
+ public File getJavaSourceDirectory() {
+ return javaSourceDirectory;
+ }
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param javaSourceDirectory
+ * the javaSourceDirectory to set
+ */
+ public void setJavaSourceDirectory(File javaSourceDirectory) {
+ this.javaSourceDirectory = javaSourceDirectory;
+ }
+
+ @SuppressWarnings("serial")
+ private static class FileObjectKey implements Serializable {
+ private final String binaryName;
+ private final Kind kind;
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param binaryName
+ * @param kind
+ */
+ public FileObjectKey(String binaryName, Kind kind) {
+ super();
+ this.binaryName = binaryName;
+ this.kind = kind;
+ }
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @return the binaryName
+ */
+ public String getBinaryName() {
+ return binaryName;
+ }
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @return the kind
+ */
+ public Kind getKind() {
+ return kind;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+
+ result = prime * result + ((binaryName == null) ? 0 :
binaryName.hashCode());
+ result = prime * result + ((kind == null) ? 0 : kind.hashCode());
+
+ return result;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+
+ if (obj == null) {
+ return false;
+ }
+
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+
+ FileObjectKey other = (FileObjectKey) obj;
+
+ if (binaryName == null) {
+ if (other.binaryName != null) {
+ return false;
+ }
+ } else if (!binaryName.equals(other.binaryName)) {
+ return false;
+ }
+
+ if (kind == null) {
+ if (other.kind != null) {
+ return false;
+ }
+ } else if (!kind.equals(other.kind)) {
+ return false;
+ }
+
+ return true;
+ }
+ }
+}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/VirtualJavaClassPathObject.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/VirtualJavaClassPathObject.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/VirtualJavaClassPathObject.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -21,114 +21,113 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.apt;
-import java.io.File;
-import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
+
import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLConnection;
-import java.nio.ByteBuffer;
-import java.nio.channels.Channels;
-import java.nio.channels.ReadableByteChannel;
-import java.nio.charset.Charset;
-import javax.tools.JavaFileObject;
-import javax.tools.SimpleJavaFileObject;
-
/**
- * <p class="changed_added_4_0">This class represents read-only {@link
JavaFileObject} created from {@link File} or {@link URL}</p>
+ * <p class="changed_added_4_0">This class represents read-only {@link
javax.tools.JavaFileObject} created
+ * from {@link java.io.File} or {@link URL}</p>
+ *
* @author asmirnov(a)exadel.com
*
*/
public class VirtualJavaClassPathObject extends VirtualJavaFileObject {
+ private final URL url;
+ /**
+ * <p class="changed_added_4_0">Create file object from
URL</p>
+ * @param url
+ * @param kind
+ * @throws URISyntaxException
+ */
+ public VirtualJavaClassPathObject(URL url, Kind kind) throws URISyntaxException {
+ super(url.toURI(), kind);
+ this.url = url;
+ }
- private final URL url;
+ /*
+ * (non-Javadoc)
+ * @see javax.tools.SimpleJavaFileObject#openInputStream()
+ */
+ @Override
+ public InputStream openInputStream() throws IOException {
+ return url.openStream();
+ }
+ /*
+ * (non-Javadoc)
+ * @see javax.tools.SimpleJavaFileObject#getLastModified()
+ */
+ @Override
+ public long getLastModified() {
+ try {
+ URLConnection connection = url.openConnection();
- /**
- * <p class="changed_added_4_0">Create file object from URL</p>
- * @param url
- * @param kind
- * @throws URISyntaxException
- */
- public VirtualJavaClassPathObject(URL url, Kind kind) throws URISyntaxException {
- super(url.toURI(),kind);
- this.url = url;
- }
-
- /* (non-Javadoc)
- * @see javax.tools.SimpleJavaFileObject#openInputStream()
- */
- @Override
- public InputStream openInputStream() throws IOException {
- return url.openStream();
- }
+ return connection.getLastModified();
+ } catch (IOException e) {
+ return super.getLastModified();
+ }
+ }
+ /*
+ * (non-Javadoc)
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
- /* (non-Javadoc)
- * @see javax.tools.SimpleJavaFileObject#getLastModified()
- */
- @Override
- public long getLastModified() {
- try {
- URLConnection connection = url.openConnection();
- return connection.getLastModified();
- } catch (IOException e) {
- return super.getLastModified();
- }
- }
-
-
+ result = prime * result + ((url == null) ? 0 : url.hashCode());
+ result = prime * result + ((getKind() == null) ? 0 : getKind().hashCode());
- /* (non-Javadoc)
- * @see java.lang.Object#hashCode()
- */
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((url == null) ? 0 : url.hashCode());
- result = prime * result + ((getKind() == null) ? 0 : getKind().hashCode());
- return result;
- }
+ return result;
+ }
- /* (non-Javadoc)
- * @see java.lang.Object#equals(java.lang.Object)
- */
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (!(obj instanceof VirtualJavaClassPathObject)) {
- return false;
- }
- VirtualJavaClassPathObject other = (VirtualJavaClassPathObject) obj;
- if (url == null) {
- if (other.uri != null) {
- return false;
- }
- } else if (!url.equals(other.uri)) {
- return false;
- }
- if(getKind() == null){
- if(other.getKind()!=null){
- return false;
- }
- } else if (!getKind().equals(other.getKind())) {
- return false;
- }
- return true;
- }
-
-
-}
\ No newline at end of file
+ /*
+ * (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+
+ if (obj == null) {
+ return false;
+ }
+
+ if (!(obj instanceof VirtualJavaClassPathObject)) {
+ return false;
+ }
+
+ VirtualJavaClassPathObject other = (VirtualJavaClassPathObject) obj;
+
+ if (url == null) {
+ if (other.uri != null) {
+ return false;
+ }
+ } else if (!url.equals(other.uri)) {
+ return false;
+ }
+
+ if (getKind() == null) {
+ if (other.getKind() != null) {
+ return false;
+ }
+ } else if (!getKind().equals(other.getKind())) {
+ return false;
+ }
+
+ return true;
+ }
+}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/VirtualJavaFileObject.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/VirtualJavaFileObject.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/VirtualJavaFileObject.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -21,100 +21,93 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.apt;
-import java.io.File;
-import java.io.FileInputStream;
+import javax.tools.SimpleJavaFileObject;
+
import java.io.IOException;
import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
+
import java.net.URI;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.net.URLConnection;
+
import java.nio.ByteBuffer;
import java.nio.channels.Channels;
import java.nio.channels.ReadableByteChannel;
import java.nio.charset.Charset;
-import javax.tools.JavaFileObject;
-import javax.tools.SimpleJavaFileObject;
-
/**
- * <p class="changed_added_4_0">This class represents read-only {@link
JavaFileObject} created from {@link File} or {@link URL}</p>
+ * <p class="changed_added_4_0">This class represents read-only {@link
javax.tools.JavaFileObject} created
+ * from {@link java.io.File} or {@link java.net.URL}</p>
+ *
* @author asmirnov(a)exadel.com
*
*/
public class VirtualJavaFileObject extends SimpleJavaFileObject {
- /**
- * <p class="changed_added_4_0">base file object. One of {@link file}
or {@link url} fields should be set</p>
- */
+ /**
+ * <p class="changed_added_4_0">base file object. One of {@link
file} or {@link url} fields should be set</p>
+ */
+ private Charset charset = Charset.defaultCharset();
- private Charset charset = Charset.defaultCharset();
-
- /**
- * <p class="changed_added_4_0">Cached content</p>
- */
- private CharSequence content;
+ /**
+ * <p class="changed_added_4_0">Cached content</p>
+ */
+ private CharSequence content;
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param classFile
+ * @param kind
+ */
+ protected VirtualJavaFileObject(URI classFile, Kind kind) {
+ super(classFile, kind);
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param classFile
- * @param kind
- */
- protected VirtualJavaFileObject(URI classFile, Kind kind) {
- super(classFile, kind);
- }
+ /*
+ * (non-Javadoc)
+ * @see javax.tools.SimpleJavaFileObject#getCharContent(boolean)
+ */
+ @Override
+ public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException
{
+ if (null == content) {
+ StringBuilder builder = new StringBuilder((int) (4096f *
getCharset().newDecoder().averageCharsPerByte()));
+ InputStream inputStream = openInputStream();
+ if (null != inputStream) {
+ ReadableByteChannel channel = Channels.newChannel(inputStream);
-
+ for (ByteBuffer buff = ByteBuffer.allocate(4096); channel.read(buff)
>= 0; buff.clear()) {
+ buff.flip();
+ builder.append(getCharset().decode(buff));
+ }
- /* (non-Javadoc)
- * @see javax.tools.SimpleJavaFileObject#getCharContent(boolean)
- */
- @Override
- public CharSequence getCharContent(boolean ignoreEncodingErrors)
- throws IOException {
- if (null == content) {
- StringBuilder builder = new StringBuilder((int) (4096f * getCharset().newDecoder()
- .averageCharsPerByte()));
- InputStream inputStream = openInputStream();
- if (null != inputStream) {
- ReadableByteChannel channel = Channels.newChannel(inputStream);
- for (ByteBuffer buff = ByteBuffer.allocate(4096); channel
- .read(buff) >= 0; buff.clear()) {
- buff.flip();
- builder.append(getCharset().decode(buff));
- }
- channel.close();
- inputStream.close();
- content = builder.toString();
- }
- }
- return content;
- }
+ channel.close();
+ inputStream.close();
+ content = builder.toString();
+ }
+ }
+ return content;
+ }
-
-
- /**
- * <p class="changed_added_4_0">Set {@link Charset} for read
operations</p>
- * @param charset the charset to set
- */
- public void setCharset(Charset charset) {
- this.charset = charset;
- // Reset cached content
- this.content = null;
- }
+ /**
+ * <p class="changed_added_4_0">Set {@link Charset} for read
operations</p>
+ * @param charset the charset to set
+ */
+ public void setCharset(Charset charset) {
+ this.charset = charset;
- /**
- * <p class="changed_added_4_0"></p>
- * @return the charset
- */
- public Charset getCharset() {
- return charset;
- }
-}
\ No newline at end of file
+ // Reset cached content
+ this.content = null;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the charset
+ */
+ public Charset getCharset() {
+ return charset;
+ }
+}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/VirtualJavaFileSystemObject.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/VirtualJavaFileSystemObject.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/VirtualJavaFileSystemObject.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -21,117 +21,111 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.apt;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.net.URLConnection;
-import java.nio.ByteBuffer;
-import java.nio.channels.Channels;
-import java.nio.channels.ReadableByteChannel;
-import java.nio.charset.Charset;
-import javax.tools.JavaFileObject;
-import javax.tools.SimpleJavaFileObject;
-
/**
- * <p class="changed_added_4_0">This class represents read-only {@link
JavaFileObject} created from {@link File} or {@link URL}</p>
+ * <p class="changed_added_4_0">This class represents read-only {@link
javax.tools.JavaFileObject} created from
+ * {@link File} or {@link java.net.URL}</p>
+ *
* @author asmirnov(a)exadel.com
*
*/
public class VirtualJavaFileSystemObject extends VirtualJavaFileObject {
- /**
- * <p class="changed_added_4_0">base file object. One of {@link file}
or {@link url} fields should be set</p>
- */
- private final File classFile;
+ /**
+ * <p class="changed_added_4_0">base file object. One of {@link
file} or {@link url} fields should be set</p>
+ */
+ private final File classFile;
-
+ /**
+ * <p class="changed_added_4_0">Create source from {@link
File}</p>
+ * @param classFile
+ */
+ public VirtualJavaFileSystemObject(File classFile) {
+ this(classFile, Kind.SOURCE);
+ }
- /**
- * <p class="changed_added_4_0">Create source from {@link
File}</p>
- * @param classFile
- */
- public VirtualJavaFileSystemObject(File classFile) {
- this(classFile, Kind.SOURCE);
- }
+ public VirtualJavaFileSystemObject(File classFile, Kind kind) {
+ super(classFile.toURI(), kind);
+ this.classFile = classFile;
+ }
- public VirtualJavaFileSystemObject(File classFile, Kind kind) {
- super(classFile.toURI(), kind);
- this.classFile = classFile;
- }
+ /*
+ * (non-Javadoc)
+ * @see javax.tools.SimpleJavaFileObject#openInputStream()
+ */
+ @Override
+ public InputStream openInputStream() throws IOException {
+ return new FileInputStream(classFile);
+ }
+ /*
+ * (non-Javadoc)
+ * @see javax.tools.SimpleJavaFileObject#getLastModified()
+ */
+ @Override
+ public long getLastModified() {
+ return classFile.lastModified();
+ }
-
- /* (non-Javadoc)
- * @see javax.tools.SimpleJavaFileObject#openInputStream()
- */
- @Override
- public InputStream openInputStream() throws IOException {
- return new FileInputStream(classFile);
- }
+ /*
+ * (non-Javadoc)
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((classFile == null) ? 0 : classFile.hashCode());
+ result = prime * result + ((getKind() == null) ? 0 : getKind().hashCode());
- /* (non-Javadoc)
- * @see javax.tools.SimpleJavaFileObject#getLastModified()
- */
- @Override
- public long getLastModified() {
- return classFile.lastModified();
- }
-
-
+ return result;
+ }
- /* (non-Javadoc)
- * @see java.lang.Object#hashCode()
- */
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result
- + ((classFile == null) ? 0 : classFile.hashCode());
- result = prime * result + ((getKind() == null) ? 0 : getKind().hashCode());
- return result;
- }
+ /*
+ * (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
- /* (non-Javadoc)
- * @see java.lang.Object#equals(java.lang.Object)
- */
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (!(obj instanceof VirtualJavaFileSystemObject)) {
- return false;
- }
- VirtualJavaFileSystemObject other = (VirtualJavaFileSystemObject) obj;
- if (classFile == null) {
- if (other.classFile != null) {
- return false;
- }
- } else if (!classFile.equals(other.classFile)) {
- return false;
- }
- if(getKind() == null){
- if(other.getKind()!=null){
- return false;
- }
- } else if (!getKind().equals(other.getKind())) {
- return false;
- }
- return true;
- }
-
-
-}
\ No newline at end of file
+ if (obj == null) {
+ return false;
+ }
+
+ if (!(obj instanceof VirtualJavaFileSystemObject)) {
+ return false;
+ }
+
+ VirtualJavaFileSystemObject other = (VirtualJavaFileSystemObject) obj;
+
+ if (classFile == null) {
+ if (other.classFile != null) {
+ return false;
+ }
+ } else if (!classFile.equals(other.classFile)) {
+ return false;
+ }
+
+ if (getKind() == null) {
+ if (other.getKind() != null) {
+ return false;
+ }
+ } else if (!getKind().equals(other.getKind())) {
+ return false;
+ }
+
+ return true;
+ }
+}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/CdkConfiguration.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/CdkConfiguration.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/CdkConfiguration.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.freemarker;
import org.richfaces.cdk.CdkContext;
@@ -36,39 +38,39 @@
*
*/
public class CdkConfiguration extends Configuration {
-
- private static final String TEMPLATES = "/META-INF/templates";
- private final CdkContext context;
+ private static final String TEMPLATES = "/META-INF/templates";
+ private final CdkContext context;
- /**
- * <p class="changed_added_4_0"></p>
- * @return the context
- */
- protected CdkContext getContext() {
- return context;
- }
+ public CdkConfiguration(CdkContext context) {
+ super();
+ this.context = context;
- public CdkConfiguration(CdkContext context) {
- super();
- this.context = context;
- // TODO set proper template loader.
- setClassForTemplateLoading(context.getClass(), TEMPLATES);
- // TODO create an object wrapper for library model.
- setObjectWrapper(new LibraryModelWrapper());
- // Add context variables
- this.setSharedVariable("context", new TemplateHashModel() {
+ // TODO set proper template loader.
+ setClassForTemplateLoading(context.getClass(), TEMPLATES);
- @Override
- public TemplateModel get(String key) throws TemplateModelException {
- // TODO - define context parameters that could be exposed to template.
- return null;
- }
+ // TODO create an object wrapper for library model.
+ setObjectWrapper(new LibraryModelWrapper());
- @Override
- public boolean isEmpty() throws TemplateModelException {
- return false;
- }
- });
- }
+ // Add context variables
+ this.setSharedVariable("context", new TemplateHashModel() {
+ @Override
+ public TemplateModel get(String key) throws TemplateModelException {
+ // TODO - define context parameters that could be exposed to template.
+ return null;
+ }
+ @Override
+ public boolean isEmpty() throws TemplateModelException {
+ return false;
+ }
+ });
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the context
+ */
+ protected CdkContext getContext() {
+ return context;
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/ComponentTemplateModel.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/ComponentTemplateModel.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/ComponentTemplateModel.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.freemarker;
import java.util.NoSuchElementException;
@@ -37,83 +39,87 @@
import freemarker.ext.beans.BeanModel;
import freemarker.ext.beans.BeansWrapper;
+
import freemarker.template.TemplateModel;
import freemarker.template.TemplateModelException;
/**
* <p class="changed_added_4_0">
* </p>
- *
+ *
* @author asmirnov(a)exadel.com
- *
+ *
*/
public class ComponentTemplateModel extends BeanModel implements TemplateModel {
+ private final Component component;
+ private Set<EventName> eventNames;
- private final Component component;
- private Set<EventName> eventNames;
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param object
+ * @param wrapper
+ */
+ public ComponentTemplateModel(Component object, BeansWrapper wrapper) {
+ super(object, wrapper);
+ component = object;
+ }
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @param object
- * @param wrapper
- */
- public ComponentTemplateModel(Component object, BeansWrapper wrapper) {
- super(object, wrapper);
- component = object;
- }
+ @Override
+ public TemplateModel get(String key) throws TemplateModelException {
+ if ("generatedAttributes".equals(key)) {
+ return generatedAttributes();
+ } else if ("eventNames".equals(key)) {
+ return eventNames();
+ } else if ("defaultEvent".equals(key)) {
+ return defaultEvent();
+ }
- @Override
- public TemplateModel get(String key) throws TemplateModelException {
- if ("generatedAttributes".equals(key)) {
- return generatedAttributes();
- } else if ("eventNames".equals(key)) {
- return eventNames();
- } else if ("defaultEvent".equals(key)) {
- return defaultEvent();
- }
- return super.get(key);
- }
+ return super.get(key);
+ }
- private TemplateModel eventNames() throws TemplateModelException {
- Set<EventName> eventNames = getEventNames();
- return wrapper.wrap(eventNames);
- }
+ private TemplateModel eventNames() throws TemplateModelException {
+ Set<EventName> eventNames = getEventNames();
- private TemplateModel defaultEvent() throws TemplateModelException {
- Set<EventName> names = getEventNames();
- try{
- EventName defaultEvent = Iterables.find(names, new Predicate<EventName>() {
+ return wrapper.wrap(eventNames);
+ }
- @Override
- public boolean apply(EventName event) {
- return event.isDefaultEvent();
- }
- });
- return wrapper.wrap(defaultEvent);
- } catch(NoSuchElementException e){
- return wrapper.wrap(null);
- }
- }
- private Set<EventName> getEventNames() {
- if (null == eventNames) {
- eventNames = Sets.newHashSet();
- for (Property property : component.getAttributes()) {
- eventNames.addAll(property.getEventNames());
- }
- }
- return eventNames;
- }
+ private TemplateModel defaultEvent() throws TemplateModelException {
+ Set<EventName> names = getEventNames();
- private TemplateModel generatedAttributes() throws TemplateModelException {
- return wrapper.wrap(Collections2.filter(component.getAttributes(),
- new Predicate<Property>() {
+ try {
+ EventName defaultEvent = Iterables.find(names, new
Predicate<EventName>() {
+ @Override
+ public boolean apply(EventName event) {
+ return event.isDefaultEvent();
+ }
+ });
- @Override
- public boolean apply(Property input) {
- return input.isGenerate();
- }
- }));
- }
+ return wrapper.wrap(defaultEvent);
+ } catch (NoSuchElementException e) {
+ return wrapper.wrap(null);
+ }
+ }
+
+ private Set<EventName> getEventNames() {
+ if (null == eventNames) {
+ eventNames = Sets.newHashSet();
+
+ for (Property property : component.getAttributes()) {
+ eventNames.addAll(property.getEventNames());
+ }
+ }
+
+ return eventNames;
+ }
+
+ private TemplateModel generatedAttributes() throws TemplateModelException {
+ return wrapper.wrap(Collections2.filter(component.getAttributes(), new
Predicate<Property>() {
+ @Override
+ public boolean apply(Property input) {
+ return input.isGenerate();
+ }
+ }));
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/FreeMarkerRenderer.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/FreeMarkerRenderer.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/FreeMarkerRenderer.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.freemarker;
import java.io.File;
@@ -33,7 +35,6 @@
import org.richfaces.cdk.CdkWriter;
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.LibraryVisitor;
-import org.richfaces.cdk.model.Searchable;
import org.richfaces.cdk.model.Trackable;
import org.richfaces.cdk.model.Visitable;
@@ -46,83 +47,91 @@
* @author asmirnov(a)exadel.com
*
*/
-public abstract class FreeMarkerRenderer<C extends Visitable,P> implements
CdkWriter,LibraryVisitor<Boolean, P> {
+public abstract class FreeMarkerRenderer<C extends Visitable, P> implements
CdkWriter, LibraryVisitor<Boolean, P> {
+ private Configuration configuration;
+ private CdkContext context;
+ private Template template;
- private CdkContext context;
- private Configuration configuration;
- private Template template;
+ @Override
+ public void init(CdkContext context) throws CdkException {
+ this.context = context;
+ this.configuration = new CdkConfiguration(context);
- @Override
- public void init(CdkContext context) throws CdkException {
- this.context = context;
- this.configuration = new CdkConfiguration(context);
- try {
- template = configuration.getTemplate(getTemplateName());
- } catch (IOException e) {
- throw new CdkException(e);
- }
- }
+ try {
+ template = configuration.getTemplate(getTemplateName());
+ } catch (IOException e) {
+ throw new CdkException(e);
+ }
+ }
- @Override
- public void render(ComponentLibrary library) throws CdkException {
- library.accept(this, getVisitorParameter());
- }
+ @Override
+ public void render(ComponentLibrary library) throws CdkException {
+ library.accept(this, getVisitorParameter());
+ }
- private P getVisitorParameter() {
- return null;
- }
+ private P getVisitorParameter() {
+ return null;
+ }
- @Override
- public Boolean visit(Visitable c, P param) throws CdkException {
- if(isMyComponent(c)){
- return processComponent((C)c, param);
- }
- return null;
- }
+ @Override
+ public Boolean visit(Visitable c, P param) throws CdkException {
+ if (isMyComponent(c)) {
+ return processComponent((C) c, param);
+ }
- protected boolean processComponent(C c, P param) throws CdkException {
- try {
- Writer out = getOutput(c);
- template.process(c, out);
- out.close();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (TemplateException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } finally {
- }
- return false;
- }
+ return null;
+ }
- protected Writer getOutput(C c) throws CdkException {
- long lastModified = Long.MIN_VALUE;
- if (c instanceof Trackable) {
- Trackable trackuble = (Trackable) c;
- lastModified = trackuble.lastModified();
- }
- File sourceOutput = getContext().createOutputFile(getOutputType(), getOutputFile(c),
lastModified);
- try {
- return new FileWriter(sourceOutput);
- } catch (IOException e) {
- throw new CdkException(e);
- }
- }
+ protected boolean processComponent(C c, P param) throws CdkException {
+ try {
+ Writer out = getOutput(c);
- protected abstract String getOutputFile(C c) throws CdkException;
+ template.process(c, out);
+ out.close();
+ } catch (IOException e) {
- protected abstract boolean isMyComponent(Visitable c);
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (TemplateException e) {
- protected abstract String getTemplateName();
-
- protected abstract OutputType getOutputType();
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the context
- */
- protected CdkContext getContext() {
- return context;
- }
+ return false;
+ }
+
+ protected Writer getOutput(C c) throws CdkException {
+ long lastModified = Long.MIN_VALUE;
+
+ if (c instanceof Trackable) {
+ Trackable trackuble = (Trackable) c;
+
+ lastModified = trackuble.lastModified();
+ }
+
+ File sourceOutput = getContext().createOutputFile(getOutputType(),
getOutputFile(c), lastModified);
+
+ try {
+ return new FileWriter(sourceOutput);
+ } catch (IOException e) {
+ throw new CdkException(e);
+ }
+ }
+
+ protected abstract String getOutputFile(C c) throws CdkException;
+
+ protected abstract boolean isMyComponent(Visitable c);
+
+ protected abstract String getTemplateName();
+
+ protected abstract OutputType getOutputType();
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the context
+ */
+ protected CdkContext getContext() {
+ return context;
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/LibraryModelWrapper.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/LibraryModelWrapper.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/LibraryModelWrapper.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -21,45 +21,48 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.freemarker;
-import org.richfaces.cdk.model.Component;
-import org.richfaces.cdk.model.Property;
+import freemarker.ext.beans.BeansWrapper;
-import freemarker.ext.beans.BeansWrapper;
-import freemarker.template.DefaultObjectWrapper;
import freemarker.template.ObjectWrapper;
import freemarker.template.TemplateModel;
import freemarker.template.TemplateModelException;
-import freemarker.template.TemplateScalarModel;
+import org.richfaces.cdk.model.Component;
+import org.richfaces.cdk.model.Property;
+
/**
* <p class="changed_added_4_0"></p>
* @author asmirnov(a)exadel.com
*
*/
-public class LibraryModelWrapper extends BeansWrapper implements
- ObjectWrapper {
+public class LibraryModelWrapper extends BeansWrapper implements ObjectWrapper {
+ public LibraryModelWrapper() {
+ super();
+ setStrict(true);
+ setSimpleMapWrapper(true);
- public LibraryModelWrapper() {
- super();
- setStrict(true);
- setSimpleMapWrapper(true);
-// setNullModel(TemplateScalarModel.EMPTY_STRING);
- setUseCache(true);
- }
+// setNullModel(TemplateScalarModel.EMPTY_STRING);
+ setUseCache(true);
+ }
- @Override
- public TemplateModel wrap(Object obj) throws TemplateModelException {
- // TODO wrap specified model classes.
- TemplateModel templateModel;
- if (obj instanceof Component) {
- templateModel = new ComponentTemplateModel((Component)obj,this);
- } else if (obj instanceof Property) {
- templateModel = new PropertyModel((Property)obj,this);
- }else {
- templateModel = super.wrap(obj);
- }
- return templateModel;
- }
+ @Override
+ public TemplateModel wrap(Object obj) throws TemplateModelException {
+
+ // TODO wrap specified model classes.
+ TemplateModel templateModel;
+
+ if (obj instanceof Component) {
+ templateModel = new ComponentTemplateModel((Component) obj, this);
+ } else if (obj instanceof Property) {
+ templateModel = new PropertyModel((Property) obj, this);
+ } else {
+ templateModel = super.wrap(obj);
+ }
+
+ return templateModel;
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/PropertyModel.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/PropertyModel.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/PropertyModel.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.freemarker;
import org.richfaces.cdk.model.Property;
@@ -28,6 +30,7 @@
import freemarker.ext.beans.BeanModel;
import freemarker.ext.beans.BeansWrapper;
+
import freemarker.template.TemplateModel;
import freemarker.template.TemplateModelException;
@@ -37,39 +40,39 @@
*
*/
public class PropertyModel extends BeanModel implements TemplateModel {
+ private final Property property;
- private final Property property;
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param object
+ * @param wrapper
+ */
+ public PropertyModel(Property object, BeansWrapper wrapper) {
+ super(object, wrapper);
+ property = object;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param object
- * @param wrapper
- */
- public PropertyModel(Property object, BeansWrapper wrapper) {
- super(object, wrapper);
- property = object;
- }
-
- @Override
- public TemplateModel get(String key) throws TemplateModelException {
- Object value;
- if("getterName".equals(key)){
- value = getGetterName();
- } else if("setterName".equals(key)){
- value = getSetterName();
- } else {
- return super.get(key);
- }
- return wrapper.wrap(value);
- }
- // Model utility methods.
-
- public String getGetterName(){
- return
property.getType().getGetterPrefix()+Strings.firstToUpperCase(property.getName().toString());
- }
+ @Override
+ public TemplateModel get(String key) throws TemplateModelException {
+ Object value;
- public String getSetterName(){
- return "set"+Strings.firstToUpperCase(property.getName().toString());
- }
+ if ("getterName".equals(key)) {
+ value = getGetterName();
+ } else if ("setterName".equals(key)) {
+ value = getSetterName();
+ } else {
+ return super.get(key);
+ }
+ return wrapper.wrap(value);
+ }
+
+ // Model utility methods.
+ public String getGetterName() {
+ return property.getType().getGetterPrefix() +
Strings.firstToUpperCase(property.getName().toString());
+ }
+
+ public String getSetterName() {
+ return "set" +
Strings.firstToUpperCase(property.getName().toString());
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ComponentClassGenerator.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ComponentClassGenerator.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ComponentClassGenerator.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -21,11 +21,10 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.richfaces.cdk.generate.java;
-import java.io.File;
-import java.io.IOException;
+package org.richfaces.cdk.generate.java;
+
import org.richfaces.cdk.CdkContext;
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.CdkWriter;
@@ -33,9 +32,10 @@
import org.richfaces.cdk.freemarker.FreeMarkerRenderer;
import org.richfaces.cdk.model.Component;
import org.richfaces.cdk.model.ComponentLibrary;
-import org.richfaces.cdk.model.Searchable;
import org.richfaces.cdk.model.Visitable;
+import java.io.File;
+
/**
* <p class="changed_added_4_0"></p>
* @author asmirnov(a)exadel.com
@@ -43,40 +43,38 @@
*/
public class ComponentClassGenerator extends FreeMarkerRenderer<Component,
ComponentLibrary> implements CdkWriter {
- /* (non-Javadoc)
- * @see org.richfaces.cdk.CdkWriter#init(org.richfaces.cdk.CdkContext)
- */
- @Override
- public void init(CdkContext context) throws CdkException {
- super.init(context);
+ /*
+ * (non-Javadoc)
+ * @see org.richfaces.cdk.CdkWriter#init(org.richfaces.cdk.CdkContext)
+ */
+ @Override
+ public void init(CdkContext context) throws CdkException {
+ super.init(context);
+ }
- }
+ @Override
+ protected boolean isMyComponent(Visitable c) {
+ if (c instanceof Component) {
+ Component component = (Component) c;
+ return component.isGenerate();
+ }
- @Override
- protected boolean isMyComponent(Visitable c) {
- if (c instanceof Component) {
- Component component = (Component) c;
- return component.isGenerate();
- }
- return false;
- }
+ return false;
+ }
+ @Override
+ protected String getOutputFile(Component c) throws CdkException {
+ return c.getComponentClass().getName().replace('.', File.separatorChar) +
".java";
+ }
- @Override
- protected String getOutputFile(Component c) throws CdkException {
- return c.getComponentClass().getName().replace('.',
File.separatorChar)+".java";
- }
+ @Override
+ protected String getTemplateName() {
+ return "component.ftl";
+ }
-
- @Override
- protected String getTemplateName() {
- return "component.ftl";
- }
-
-
- @Override
- protected OutputType getOutputType() {
- return StandardOutputs.COMPONENT_CLASSES;
- }
+ @Override
+ protected OutputType getOutputType() {
+ return StandardOutputs.COMPONENT_CLASSES;
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Attribute.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Attribute.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Attribute.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.model;
/**
@@ -31,12 +33,11 @@
@SuppressWarnings("serial")
public class Attribute extends Property {
- /**
- * <p class="changed_added_4_0"></p>
- * @param name
- */
- public Attribute(Property.Name name) {
- super(name);
- }
-
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param name
+ */
+ public Attribute(Property.Name name) {
+ super(name);
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Behavior.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Behavior.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Behavior.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.model;
import org.richfaces.cdk.CdkException;
@@ -31,37 +33,36 @@
*
*/
@SuppressWarnings("serial")
-public class Behavior implements ModelElement<Behavior,Behavior.Type> {
+public class Behavior implements ModelElement<Behavior, Behavior.Type> {
+ private final Type type;
- public static final class Type extends Key {
-
- public Type(String name) {
- super(name);
- }
- }
- private final Type type;
+ public Behavior(Type type) {
+ this.type = type;
+ }
- public Behavior(Type type) {
- this.type = type;
- }
- /* (non-Javadoc)
- * @see org.richfaces.cdk.model.ModelElement#getType()
- */
- @Override
- public Type getKey() {
- return type;
- }
+ /*
+ * (non-Javadoc)
+ * @see org.richfaces.cdk.model.ModelElement#getType()
+ */
+ @Override
+ public Type getKey() {
+ return type;
+ }
+ @Override
+ public void merge(Behavior other) {
- @Override
- public void merge(Behavior other) {
- // TODO Auto-generated method stub
-
- }
+ // TODO Auto-generated method stub
+ }
- @Override
- public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) throws
CdkException {
- return visitor.visit(this, param);
- }
+ @Override
+ public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) throws
CdkException {
+ return visitor.visit(this, param);
+ }
+ public static final class Type extends Key {
+ public Type(String name) {
+ super(name);
+ }
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/BehaviorRenderer.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/BehaviorRenderer.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/BehaviorRenderer.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.model;
import org.richfaces.cdk.CdkException;
@@ -31,71 +33,67 @@
*
*/
@SuppressWarnings("serial")
-public class BehaviorRenderer implements ModelElement<BehaviorRenderer,
BehaviorRenderer.Type>{
+public class BehaviorRenderer implements ModelElement<BehaviorRenderer,
BehaviorRenderer.Type> {
+ private ClassDescription rendererClass;
+ private final Type type;
- /**
- * <p class="changed_added_4_0"></p>
- * @author asmirnov(a)exadel.com
- *
- */
- @SuppressWarnings("serial")
- public static final class Type extends Key {
+ public BehaviorRenderer(Type type) {
+ this.type = type;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param type
- */
- public Type(String type) {
- super(type);
- }
+ @Override
+ public Type getKey() {
+ return type;
+ }
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the type
+ */
+ public Type getType() {
+ return type;
+ }
- private final Type type;
-
- private ClassDescription rendererClass;
-
- public BehaviorRenderer(Type type) {
- this.type = type;
- }
-
- @Override
- public Type getKey() {
- return type;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the rendererClass
+ */
+ public ClassDescription getRendererClass() {
+ return rendererClass;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the type
- */
- public Type getType() {
- return type;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param rendererClass the rendererClass to set
+ */
+ public void setRendererClass(ClassDescription rendererClass) {
+ this.rendererClass = rendererClass;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the rendererClass
- */
- public ClassDescription getRendererClass() {
- return rendererClass;
- }
+ @Override
+ public void merge(BehaviorRenderer other) {
+ ComponentLibrary.merge(this, other);
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param rendererClass the rendererClass to set
- */
- public void setRendererClass(ClassDescription rendererClass) {
- this.rendererClass = rendererClass;
- }
+ @Override
+ public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) throws
CdkException {
+ return visitor.visit(this, param);
+ }
- @Override
- public void merge(BehaviorRenderer other) {
- ComponentLibrary.merge(this, other);
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+ @SuppressWarnings("serial")
+ public static final class Type extends Key {
- @Override
- public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) throws
CdkException {
- return visitor.visit(this, param);
- }
-
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param type
+ */
+ public Type(String type) {
+ super(type);
+ }
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ClassDescription.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ClassDescription.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ClassDescription.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -21,206 +21,214 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.model;
-import javax.annotation.Generated;
-
import com.google.common.collect.ImmutableMap;
/**
* <p class="changed_added_4_0">
* Tthat class represents information about Jsf object class.
* </p>
- *
+ *
* @author asmirnov(a)exadel.com
- *
+ *
*/
-public class ClassDescription {
+public class ClassDescription {
- /**
- * <p class="changed_added_4_0"></p>
- */
- private static final long serialVersionUID = -846623207703750456L;
+ /**
+ * <p class="changed_added_4_0"></p>
+ */
+ private static final long serialVersionUID = -846623207703750456L;
+ private static final ImmutableMap<String, String> PRIMITIVE_TYPES =
+ ImmutableMap.<String, String>builder().put(boolean.class.getName(),
+ Boolean.class.getName()).put(byte.class.getName(),
+ Byte.class.getName()).put(char.class.getName(),
+ Character.class.getName()).put(short.class.getName(),
+ Short.class.getName()).put(int.class.getName(),
+ Integer.class.getName()).put(long.class.getName(),
+
Long.class.getName()).put(float.class.getName(),
+
Float.class.getName()).put(double.class.getName(),
+ Double.class.getName()).build();
+ private final String boxingClassName;
+ private final String fullName;
- private static final ImmutableMap<String, String> primitiveTypes = ImmutableMap
- .<String, String> builder().put(boolean.class.getName(),
- Boolean.class.getName()).put(byte.class.getName(),
- Byte.class.getName()).put(char.class.getName(),
- Character.class.getName()).put(short.class.getName(),
- Short.class.getName()).put(int.class.getName(),
- Integer.class.getName()).put(long.class.getName(),
- Long.class.getName()).put(float.class.getName(),
- Float.class.getName()).put(double.class.getName(),
- Double.class.getName()).build();
+ /**
+ * <p class="changed_added_4_0"></p>
+ */
+ private final String name;
+ private final boolean primitive;
- /**
- * <p class="changed_added_4_0"></p>
- */
- private final String name;
+ /**
+ * <p class="changed_added_4_0">Id parameters for that
class</p>
+ * TODO append type parameters to key.
+ */
+ private String typeParameters;
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param cl
+ */
+ public ClassDescription(Class<?> cl) {
- private final boolean primitive;
+ // TODO get information directly from class.
+ this(cl.getName());
+ }
- private final String boxingClassName;
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param name
+ */
+ public ClassDescription(String name) {
+ fullName = name;
- /**
- * <p class="changed_added_4_0">Id parameters for that class</p>
- * TODO append type parameters to key.
- */
- private String typeParameters;
+ if (PRIMITIVE_TYPES.containsKey(name)) {
+ this.name = name;
+ boxingClassName = PRIMITIVE_TYPES.get(name);
+ primitive = true;
+ } else {
+ int i = name.indexOf('<');
- private final String fullName;
+ if (i > 0) {
+ this.name = name.substring(0, i);
+ this.typeParameters = name.substring(i);
+ } else {
+ this.name = name;
+ }
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @param name
- */
- public ClassDescription(String name) {
- fullName = name;
- if (primitiveTypes.containsKey(name)) {
- this.name = name;
- boxingClassName = primitiveTypes.get(name);
- primitive = true;
- } else {
- int i = name.indexOf('<');
- if(i>0){
- this.name = name.substring(0,i);
- this.typeParameters=name.substring(i);
- } else {
- this.name = name;
- }
- boxingClassName = name;
- primitive = false;
- }
- }
+ boxingClassName = name;
+ primitive = false;
+ }
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param cl
- */
- public ClassDescription(Class<?>cl) {
- // TODO get information directly from class.
- this(cl.getName());
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the typeParameters
+ */
+ public String getTypeParameters() {
+ return typeParameters;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the typeParameters
- */
- public String getTypeParameters() {
- return typeParameters;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param typeParameters the typeParameters to set
+ */
+ public void setTypeParameters(String typeParameters) {
+ this.typeParameters = typeParameters;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param typeParameters the typeParameters to set
- */
- public void setTypeParameters(String typeParameters) {
- this.typeParameters = typeParameters;
- }
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @return the name
+ */
+ public String getName() {
+ return name;
+ }
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @return the name
- */
- public String getName() {
- return name;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return package name.
+ */
+ public String getPackage() {
+ int indexOfPeriod = name.lastIndexOf('.');
- /**
- * <p class="changed_added_4_0"></p>
- * @return package name.
- */
- public String getPackage() {
- int indexOfPeriod = name.lastIndexOf('.');
- if(indexOfPeriod>0){
- return name.substring(0,indexOfPeriod);
- } else {
- return null;
- }
- }
+ if (indexOfPeriod > 0) {
+ return name.substring(0, indexOfPeriod);
+ } else {
+ return null;
+ }
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return package name.
- */
- public String getSimpleName() {
- int indexOfPeriod = name.lastIndexOf('.');
- if(indexOfPeriod>0){
- return name.substring(indexOfPeriod+1);
- } else {
- return name;
- }
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return package name.
+ */
+ public String getSimpleName() {
+ int indexOfPeriod = name.lastIndexOf('.');
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @return the primitive
- */
- public boolean isPrimitive() {
- return primitive;
- }
+ if (indexOfPeriod > 0) {
+ return name.substring(indexOfPeriod + 1);
+ } else {
+ return name;
+ }
+ }
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @return the boxingClassName
- */
- public String getBoxingName() {
- return boxingClassName;
- }
-
- public String getGetterPrefix(){
- return Boolean.class.getName().equals(boxingClassName)?"is":"get";
- }
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @return the primitive
+ */
+ public boolean isPrimitive() {
+ return primitive;
+ }
- @Override
- public String toString() {
- return fullName;
- }
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @return the boxingClassName
+ */
+ public String getBoxingName() {
+ return boxingClassName;
+ }
- /* (non-Javadoc)
- * @see java.lang.Object#hashCode()
- */
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((name == null) ? 0 : name.hashCode());
- return result;
- }
+ public String getGetterPrefix() {
+ return Boolean.class.getName().equals(boxingClassName) ? "is" :
"get";
+ }
- /* (non-Javadoc)
- * @see java.lang.Object#equals(java.lang.Object)
- */
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (!(obj instanceof ClassDescription)) {
- return false;
- }
- ClassDescription other = (ClassDescription) obj;
- if (fullName == null) {
- if (other.fullName != null) {
- return false;
- }
- } else if (!fullName.equals(other.fullName)) {
- return false;
- }
- return true;
- }
+ @Override
+ public String toString() {
+ return fullName;
+ }
+ /*
+ * (non-Javadoc)
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((name == null) ? 0 : name.hashCode());
+
+ return result;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+
+ if (obj == null) {
+ return false;
+ }
+
+ if (!(obj instanceof ClassDescription)) {
+ return false;
+ }
+
+ ClassDescription other = (ClassDescription) obj;
+
+ if (fullName == null) {
+ if (other.fullName != null) {
+ return false;
+ }
+ } else if (!fullName.equals(other.fullName)) {
+ return false;
+ }
+
+ return true;
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Component.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Component.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Component.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -18,269 +18,266 @@
* That class represents JSF component in the CDK.
* That is mapped to faces-config "component" element.
* @author asmirnov(a)exadel.com
- *
+ *
*/
@SuppressWarnings("serial")
-@XmlType(name="faces-config-componentType")
-@XmlAccessorType( XmlAccessType.NONE )
-public final class Component extends ModelElementBase implements
ModelElement<Component,Component.Type> {
+@XmlType(name = "faces-config-componentType")
+(a)XmlAccessorType(XmlAccessType.NONE)
+public final class Component extends ModelElementBase implements
ModelElement<Component, Component.Type> {
+ /**
+ * <p class="changed_added_4_0">Is that component c</p>
+ */
+ private boolean generate = true;
- /**
- * <p class="changed_added_4_0">
- * Component type
- * </p>
- */
- private final Type type;
+ /**
+ * <p class="changed_added_4_0">
+ * Facets recognised by the component
+ * </p>
+ */
+ private final SearchableCollection<Facet, Facet.Name> facets = new
ModelCollection<Facet, Facet.Name>() {
+ @Override
+ public Facet create(Name key) {
+ return new Facet(key);
+ }
+ };
- /**
- * <p class="changed_added_4_0">
- * Cenerated component class
- * </p>
- */
- private ClassDescription componentClass;
+ /**
+ * <p class="changed_added_4_0">
+ * Application level events fired by the component
+ * </p>
+ */
+ private final SearchableCollection<Event, Event.Type> events = new
ModelCollection<Event, Event.Type>() {
+ @Override
+ public Event create(Event.Type key) {
+ return new Event(key);
+ }
+ };
- /**
- * <p class="changed_added_4_0">
- * Cenerated component class
- * </p>
- */
- private ClassDescription baseClass;
+ /**
+ * <p class="changed_added_4_0">
+ * Component attributes
+ * </p>
+ */
+ private final SearchableCollection<Property, Property.Name> attributes = new
ModelCollection<Property,
+
Property.Name>() {
+ @Override
+ public Property create(Property.Name key) {
+ return new Property(key);
+ }
+ };
- private String family;
- /**
- * <p class="changed_added_4_0">Is that component c</p>
- */
- private boolean generate = true;
+ /**
+ * <p class="changed_added_4_0">
+ * Renderer for the final component. This is bidirectional many to many
+ * relation.
+ * </p>
+ */
+ private final Set<Renderer> renderers = Sets.newHashSet();
- /**
- * <p class="changed_added_4_0">
- * Component attributes
- * </p>
- */
- private final SearchableCollection<Property, Property.Name> attributes = new
ModelCollection<Property, Property.Name>() {
+ /**
+ * <p class="changed_added_4_0">
+ * Cenerated component class
+ * </p>
+ */
+ private ClassDescription baseClass;
- @Override
- public Property create(Property.Name key) {
- return new Property(key);
- }
- };
+ /**
+ * <p class="changed_added_4_0">
+ * Cenerated component class
+ * </p>
+ */
+ private ClassDescription componentClass;
+ private String family;
- /**
- * <p class="changed_added_4_0">
- * Facets recognised by the component
- * </p>
- */
- private final SearchableCollection<Facet,Facet.Name> facets = new
ModelCollection<Facet, Facet.Name>() {
+ /**
+ * <p class="changed_added_4_0">
+ * Component type
+ * </p>
+ */
+ private final Type type;
- @Override
- public Facet create(Name key) {
- return new Facet(key);
- }
- };
+ public Component(Type key) {
+ this.type = key;
+ }
- /**
- * <p class="changed_added_4_0">
- * Application level events fired by the component
- * </p>
- */
- private final SearchableCollection<Event,Event.Type> events = new
ModelCollection<Event, Event.Type>() {
+ @Override
+ public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) throws
CdkException {
+ return visitor.visit(this, param);
+ }
- @Override
- public Event create(Event.Type key) {
- return new Event(key);
- }
- };
+ @Override
+ public void merge(Component otherComponent) {
+ ComponentLibrary.merge(renderers, otherComponent.getRenderers());
- /**
- * <p class="changed_added_4_0">
- * Renderer for the final component. This is bidirectional many to many
- * relation.
- * </p>
- */
- private final Set<Renderer> renderers = Sets.newHashSet();
-
- public Component(Type key) {
- this.type = key;
- }
+// TODO - merge facets, renderers, events ...
+ ComponentLibrary.merge(attributes, otherComponent.getAttributes());
+ ComponentLibrary.merge(facets, otherComponent.getFacets());
+// ComponentLibrary.merge(events, otherComponent.getEvents());
+ ComponentLibrary.merge(this, otherComponent);
+ }
- @Override
- public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) throws
CdkException {
- return visitor.visit(this, param);
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.richfaces.cdk.model.ModelElement#getType()
+ */
+ @Override
+ public Type getKey() {
+ return type;
+ }
- @Override
- public void merge(Component otherComponent) {
- ComponentLibrary.merge(renderers, otherComponent.getRenderers());
-// TODO - merge facets, renderers, events ...
- ComponentLibrary.merge(attributes, otherComponent.getAttributes());
- ComponentLibrary.merge(facets, otherComponent.getFacets());
-// ComponentLibrary.merge(events, otherComponent.getEvents());
- ComponentLibrary.merge(this,otherComponent);
- }
+ @XmlElement(name = "component-type", required = true)
+ public Type getType() {
+ return type;
+ }
- /*
- * (non-Javadoc)
- *
- * @see org.richfaces.cdk.model.ModelElement#getType()
- */
- @Override
- public Type getKey() {
- return type;
- }
+ /**
+ * <p class="changed_added_4_0">
+ * Reepresent a component family. In the faces-config element that property encoded
as
+ * <component><component-extension><cdk:component-family>....
+ * </p>
+ *
+ * @return the family
+ */
+ @Merge
+ public String getFamily() {
+ return family;
+ }
-
-
- @XmlElement(name="component-type",required=true)
- public Type getType() {
- return type;
- }
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param family
+ * the family to set
+ */
+ public void setFamily(String family) {
+ this.family = family;
+ }
- /**
- * <p class="changed_added_4_0">
- * Reepresent a component family. In the faces-config element that property encoded as
- * <component><component-extension><cdk:component-family>....
- * </p>
- *
- * @return the family
- */
- @Merge
- public String getFamily() {
- return family;
- }
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @return the componentClass
+ */
+ @Merge
+ public ClassDescription getComponentClass() {
+ return componentClass;
+ }
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @param family
- * the family to set
- */
- public void setFamily(String family) {
- this.family = family;
- }
+ /**
+ * <p class="changed_added_4_0">Represents class of that component.
+ * </p>
+ *
+ * @param componentClass
+ * the componentClass to set
+ */
+ @XmlElement(name = "component-class")
+ public void setComponentClass(ClassDescription componentClass) {
+ this.componentClass = componentClass;
+ }
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @return the componentClass
- */
- @Merge
- public ClassDescription getComponentClass() {
- return componentClass;
- }
+ /**
+ * <p class="changed_added_4_0">Base class for generated components.
+ * </p>
+ *
+ * @return the baseClass
+ */
+ @Merge
+ public ClassDescription getBaseClass() {
+ return baseClass;
+ }
- /**
- * <p class="changed_added_4_0">Represents class of that component.
- * </p>
- *
- * @param componentClass
- * the componentClass to set
- */
- @XmlElement(name="component-class")
- public void setComponentClass(ClassDescription componentClass) {
- this.componentClass = componentClass;
- }
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param baseClass
+ * the baseClass to set
+ */
+ public void setBaseClass(ClassDescription baseClass) {
+ this.baseClass = baseClass;
+ }
- /**
- * <p class="changed_added_4_0">Base class for generated components.
- * </p>
- *
- * @return the baseClass
- */
- @Merge
- public ClassDescription getBaseClass() {
- return baseClass;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the generate
+ */
+ @Merge
+ public boolean isGenerate() {
+ return generate;
+ }
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @param baseClass
- * the baseClass to set
- */
- public void setBaseClass(ClassDescription baseClass) {
- this.baseClass = baseClass;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param generate the generate to set
+ */
+ public void setGenerate(boolean exists) {
+ this.generate = exists;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the generate
- */
- @Merge
- public boolean isGenerate() {
- return generate;
- }
+ /**
+ * <p class="changed_added_4_0">
+ * Represents JSF component attributes and properties.
+ * </p>
+ *
+ * @return the attributes
+ */
+ @XmlElements({@XmlElement(name = "property", type = Property.class) ,
+ @XmlElement(name = "attribute", type = Attribute.class) })
+ public Collection<Property> getAttributes() {
+ return attributes;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param generate the generate to set
- */
- public void setGenerate(boolean exists) {
- this.generate = exists;
- }
+ public Property findOrCreateAttribute(String attributeName) {
+ Property attribute;
- /**
- * <p class="changed_added_4_0">
- * Represents JSF component attributes and properties.
- * </p>
- *
- * @return the attributes
- */
- @XmlElements({@XmlElement(name="property",type=Property.class),(a)XmlElement(name="attribute",type=Attribute.class)})
- public Collection<Property> getAttributes() {
- return attributes;
- }
+ attribute = attributes.findOrCreate(new Property.Name(attributeName));
- public Property findOrCreateAttribute(String attributeName) {
- Property attribute;
- attribute = attributes.findOrCreate(new Property.Name(attributeName));
- return attribute;
- }
+ return attribute;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the facets
- */
- public Collection<Facet> getFacets() {
- return facets;
- }
-
- public Facet findOrCreateFacet(String name){
- return facets.findOrCreate(new Facet.Name(name));
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the facets
+ */
+ public Collection<Facet> getFacets() {
+ return facets;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the events
- */
- public Collection<Event> getEvents() {
- return events;
- }
-
- public Event addEvent(String className){
- // TODO - use a single events collection from library.
- return events.findOrCreate(new Event.Type(className));
- }
+ public Facet findOrCreateFacet(String name) {
+ return facets.findOrCreate(new Facet.Name(name));
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * TODO - synchronize renderers collection with library ?
- * @return the renderers
- */
- public Set<Renderer> getRenderers() {
- return renderers;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the events
+ */
+ public Collection<Event> getEvents() {
+ return events;
+ }
- public static class Type extends Key {
+ public Event addEvent(String className) {
- public Type(String type) {
- super(type);
- }
+ // TODO - use a single events collection from library.
+ return events.findOrCreate(new Event.Type(className));
+ }
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * TODO - synchronize renderers collection with library ?
+ * @return the renderers
+ */
+ public Set<Renderer> getRenderers() {
+ return renderers;
+ }
+ public static class Type extends Key {
+ public Type(String type) {
+ super(type);
+ }
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ComponentLibrary.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ComponentLibrary.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ComponentLibrary.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -21,14 +21,19 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.model;
import java.beans.IntrospectionException;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
+
import java.io.Serializable;
+
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
+
import java.util.Collection;
import java.util.NoSuchElementException;
@@ -49,362 +54,362 @@
* To keep consistence of library references, only library methods are allowed
* to components manipulations.
* </p>
- *
+ *
* @author asmirnov(a)exadel.com
- *
+ *
*/
@XmlRootElement(name = "faces-config", namespace =
ComponentLibrary.FACES_CONFIG_NAMESPACE)
@XmlType(namespace = ComponentLibrary.FACES_CONFIG_NAMESPACE, name =
"faces-configType")
-public class ComponentLibrary implements
Serializable,Extensible<ConfigExtension>,Trackable {
+public class ComponentLibrary implements Serializable, Extensible<ConfigExtension>,
Trackable {
+ public static final String CDK_EXTENSIONS_NAMESPACE =
"http://richfaces.org/cdk/extensions";
+ public static final String FACES_CONFIG_NAMESPACE =
"http://java.sun.com/xml/ns/javaee";
+ public static final String FACES_CONFIG_SCHEMA_LOCATION =
+ "http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd";
- public static final String FACES_CONFIG_NAMESPACE =
"http://java.sun.com/xml/ns/javaee";
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ */
+ private static final long serialVersionUID = -6055670836731899832L;
+ private final SearchableCollection<Component, Component.Type> components = new
ModelCollection<Component,
+
Component.Type>() {
+ @Override
+ public Component create(Component.Type key) {
+ return new Component(key);
+ }
+ };
- public static final String FACES_CONFIG_SCHEMA_LOCATION =
"http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd";
+ /**
+ * <p class="changed_added_4_0">
+ * JSF renderer associated with that library
+ * </p>
+ */
+ private final SearchableCollection<RenderKit, RenderKit.Id> renderKits = new
ModelCollection<RenderKit,
+
RenderKit.Id>() {
+ @Override
+ public RenderKit create(RenderKit.Id key) {
+ RenderKit rendererKit = new RenderKit(key);
- public static final String CDK_EXTENSIONS_NAMESPACE =
"http://richfaces.org/cdk/extensions";
+ return rendererKit;
+ }
+ };
+ private final SearchableCollection<Converter, Key> converters = new
ModelCollection<Converter, Key>() {
+ @Override
+ public Converter create(Key key) {
+ Converter converter = new Converter(key);
- /**
- * <p class="changed_added_4_0">
- * </p>
- */
- private static final long serialVersionUID = -6055670836731899832L;
+ return converter;
+ }
+ };
+ private final SearchableCollection<Validator, Key> validators = new
ModelCollection<Validator, Key>() {
+ @Override
+ public Validator create(Key key) {
+ Validator validator = new Validator(key);
- private final SearchableCollection<Component, Component.Type> components = new
ModelCollection<Component, Component.Type>() {
+ return validator;
+ }
+ };
+ private final SearchableCollection<Listener, Key> listeners = new
ModelCollection<Listener, Key>() {
+ @Override
+ public Listener create(Key key) {
+ Listener listener = new Listener(key);
- @Override
- public Component create(Component.Type key) {
- return new Component(key);
- }
- };
+ return listener;
+ }
+ };
+ private long lastModified = Long.MIN_VALUE;
- /**
- * <p class="changed_added_4_0">
- * JSF renderer associated with that library
- * </p>
- */
- private final SearchableCollection<RenderKit, RenderKit.Id> renderKits = new
ModelCollection<RenderKit, RenderKit.Id>() {
+ /**
+ * <p class="changed_added_4_0">
+ * Application level events fired by the component
+ * </p>
+ */
+ private final SearchableCollection<Event, Event.Type> events = new
ModelCollection<Event, Event.Type>() {
+ @Override
+ public Event create(Event.Type key) {
+ return new Event(key);
+ }
+ };
+ private final SearchableCollection<Behavior, Behavior.Type> behaviors = new
ModelCollection<Behavior,
+
Behavior.Type>() {
+ @Override
+ public Behavior create(Behavior.Type key) {
+ Behavior behavior = new Behavior(key);
- @Override
- public RenderKit create(RenderKit.Id key) {
- RenderKit rendererKit = new RenderKit(key);
- return rendererKit;
- }
- };
+ return behavior;
+ }
+ };
+ private ConfigExtension extension;
- private final SearchableCollection<Converter, Key> converters = new
ModelCollection<Converter, Key>() {
+ /**
+ * <p class="changed_added_4_0">
+ * Tag library with references of all used tags
+ * </p>
+ */
+ private final TagLibrary tagLibrary;
- @Override
- public Converter create(Key key) {
- Converter converter = new Converter(key);
- return converter;
- }
- };
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param baseName
+ */
+ public ComponentLibrary() {
+ this.tagLibrary = new TagLibrary();
+ }
- private final SearchableCollection<Validator, Key> validators = new
ModelCollection<Validator, Key>() {
+ /**
+ * <p class="changed_added_4_0">
+ * Merge component library model with other.
+ * </p>
+ *
+ * @param otherLibrary
+ */
+ public void merge(ComponentLibrary otherLibrary) {
+ components.merge(otherLibrary.components);
+ renderKits.merge(otherLibrary.renderKits);
+ converters.merge(otherLibrary.converters);
+ validators.merge(otherLibrary.validators);
+ listeners.merge(otherLibrary.listeners);
+ events.merge(otherLibrary.events);
+ behaviors.merge(otherLibrary.behaviors);
+ }
- @Override
- public Validator create(Key key) {
- Validator validator = new Validator(key);
- return validator;
- }
- };
+ public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) throws
CdkException {
+ R result = accept(components, visitor, param, null);
- private final SearchableCollection<Behavior, Behavior.Type> behaviors = new
ModelCollection<Behavior, Behavior.Type>() {
+ result = accept(renderKits, visitor, param, result);
+ result = accept(converters, visitor, param, result);
+ result = accept(validators, visitor, param, result);
+ result = accept(listeners, visitor, param, result);
+ result = accept(events, visitor, param, result);
+ result = accept(behaviors, visitor, param, result);
- @Override
- public Behavior create(Behavior.Type key) {
- Behavior behavior = new Behavior(key);
- return behavior;
- }
- };
+ return result;
+ }
- /**
- * <p class="changed_added_4_0">
- * Application level events fired by the component
- * </p>
- */
- private final SearchableCollection<Event,Event.Type> events = new
ModelCollection<Event, Event.Type>() {
+ /**
+ * <p class="changed_added_4_0">
+ * Create a new component description.
+ * </p>
+ *
+ * @param type
+ * component type.
+ * @param className
+ * final component class name.
+ * @param superClassName
+ * name of the component superclass. May be empty or null for
+ * already existed components.
+ * @return
+ */
+ public Component findOrCreateComponent(String type) {
+ Component component = components.findOrCreate(new Component.Type(type));
- @Override
- public Event create(Event.Type key) {
- return new Event(key);
- }
- };
-
- private final SearchableCollection<Listener, Key> listeners = new
ModelCollection<Listener, Key>() {
+ return component;
+ }
- @Override
- public Listener create(Key key) {
- Listener listener = new Listener(key);
- return listener;
- }
- };
-
- private ConfigExtension extension;
- /**
- * <p class="changed_added_4_0">
- * Tag library with references of all used tags
- * </p>
- */
- private final TagLibrary tagLibrary;
-
- private long lastModified = Long.MIN_VALUE;
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param renderKitId
+ * @param rendererType
+ * @return
+ */
+ public RenderKit findOrCreateRenderKit(String renderKitId) {
+ RenderKit.Id renderKitType = new RenderKit.Id(renderKitId);
+ RenderKit renderKit = renderKits.findOrCreate(renderKitType);
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @param baseName
- */
- public ComponentLibrary() {
- this.tagLibrary = new TagLibrary();
- }
+ return renderKit;
+ }
- /**
- * <p class="changed_added_4_0">
- * Merge component library model with other.
- * </p>
- *
- * @param otherLibrary
- */
- public void merge(ComponentLibrary otherLibrary) {
- components.merge(otherLibrary.components);
- renderKits.merge(otherLibrary.renderKits);
- converters.merge(otherLibrary.converters);
- validators.merge(otherLibrary.validators);
- listeners.merge(otherLibrary.listeners);
- events.merge(otherLibrary.events);
- behaviors.merge(otherLibrary.behaviors);
- }
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @return the components
+ */
+ @XmlElement
+ public Collection<Component> getComponents() {
+ return components;
+ }
- public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) throws
CdkException {
- R result = accept(components, visitor, param, null);
- result = accept(renderKits, visitor, param, result);
- result = accept(converters, visitor, param, result);
- result = accept(validators, visitor, param, result);
- result = accept(listeners, visitor, param, result);
- result = accept(events, visitor, param, result);
- result = accept(behaviors, visitor, param, result);
- return result;
- }
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @return the renderKits
+ */
+ public Collection<RenderKit> getRenderKits() {
+ return renderKits;
+ }
- /**
- * <p class="changed_added_4_0">
- * Create a new component description.
- * </p>
- *
- * @param type
- * component type.
- * @param className
- * final component class name.
- * @param superClassName
- * name of the component superclass. May be empty or null for
- * already existed components.
- * @return
- */
- public Component findOrCreateComponent(String type) {
- Component component = components.findOrCreate(new Component.Type(type));
- return component;
- }
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @return the converters
+ */
+ public Collection<Converter> getConverters() {
+ return converters;
+ }
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @param renderKitId
- * @param rendererType
- * @return
- */
- public RenderKit findOrCreateRenderKit(String renderKitId) {
- RenderKit.Id renderKitType = new RenderKit.Id(renderKitId);
- RenderKit renderKit = renderKits.findOrCreate(renderKitType);
- return renderKit;
- }
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @return the validators
+ */
+ public Collection<Validator> getValidators() {
+ return validators;
+ }
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @return the components
- */
- @XmlElement
- public Collection<Component> getComponents() {
- return components;
- }
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @return the behaviors
+ */
+ public Collection<Behavior> getBehaviors() {
+ return behaviors;
+ }
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @return the renderKits
- */
- public Collection<RenderKit> getRenderKits() {
- return renderKits;
- }
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @return the listeners
+ */
+ public Collection<Listener> getListeners() {
+ return listeners;
+ }
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @return the converters
- */
- public Collection<Converter> getConverters() {
- return converters;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the events
+ */
+ public SearchableCollection<Event, Event.Type> getEvents() {
+ return events;
+ }
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @return the validators
- */
- public Collection<Validator> getValidators() {
- return validators;
- }
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @return the tagLibrary
+ */
+ public TagLibrary getTagLibrary() {
+ return tagLibrary;
+ }
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @return the behaviors
- */
- public Collection<Behavior> getBehaviors() {
- return behaviors;
- }
+ // Utility methods.
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @return the listeners
- */
- public Collection<Listener> getListeners() {
- return listeners;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the extension
+ */
+ public ConfigExtension getExtension() {
+ return extension;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the events
- */
- public SearchableCollection<Event, Event.Type> getEvents() {
- return events;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param extension the extension to set
+ */
+ public void setExtension(ConfigExtension extension) {
+ this.extension = extension;
+ }
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @return the tagLibrary
- */
- public TagLibrary getTagLibrary() {
- return tagLibrary;
- }
+ @Override
+ public long lastModified() {
+ return lastModified;
+ }
- // Utility methods.
+ static <K extends Key, T extends ModelElement<T, K>> void
merge(Collection<T> target, Collection<T> source) {
+ for (T element : source) {
+ T targetElement = find(target, element.getKey());
- /**
- * <p class="changed_added_4_0"></p>
- * @return the extension
- */
- public ConfigExtension getExtension() {
- return extension;
- }
+ if (null == targetElement) {
+ target.add(element);
+ } else {
+ targetElement.merge(element);
+ }
+ }
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param extension the extension to set
- */
- public void setExtension(ConfigExtension extension) {
- this.extension = extension;
- }
-
- @Override
- public long lastModified() {
- return lastModified;
- }
+ static <T extends Mergeable<T>> void merge(T target, T source) {
+ try {
+ PropertyDescriptor[] properties =
Introspector.getBeanInfo(target.getClass()).getPropertyDescriptors();
- static <K extends Key,T extends ModelElement<T,K>> void
merge(Collection<T> target,
- Collection<T> source) {
- for (T element : source) {
- T targetElement = find(target, element.getKey());
- if (null == targetElement) {
- target.add(element);
- } else {
- targetElement.merge(element);
- }
- }
- }
+ for (PropertyDescriptor propertyDescriptor : properties) {
+ Method readMethod = propertyDescriptor.getReadMethod();
+ Method writeMethod = propertyDescriptor.getWriteMethod();
- static <T extends Mergeable<T>> void merge(T target, T source) {
- try {
- PropertyDescriptor[] properties = Introspector.getBeanInfo(
- target.getClass()).getPropertyDescriptors();
- for (PropertyDescriptor propertyDescriptor : properties) {
- Method readMethod = propertyDescriptor.getReadMethod();
- Method writeMethod = propertyDescriptor.getWriteMethod();
- if (null != readMethod && null != writeMethod
- && readMethod.isAnnotationPresent(Merge.class)) {
- boolean overwrite = readMethod.getAnnotation(Merge.class)
- .value();
- Object oldValue = readMethod.invoke(target);
- Object newValue = readMethod.invoke(source);
- if (null != newValue && (overwrite || null == oldValue)) {
- writeMethod.invoke(target, newValue);
- }
- }
- }
- } catch (IntrospectionException e) {
- // TODO Auto-generated catch block
- } catch (IllegalArgumentException e) {
- // TODO Auto-generated catch block
- } catch (IllegalAccessException e) {
- // TODO Auto-generated catch block
- } catch (InvocationTargetException e) {
- // TODO Auto-generated catch block
- }
- }
+ if (null != readMethod && null != writeMethod &&
readMethod.isAnnotationPresent(Merge.class)) {
+ boolean overwrite = readMethod.getAnnotation(Merge.class).value();
+ Object oldValue = readMethod.invoke(target);
+ Object newValue = readMethod.invoke(source);
- static <R, P, T extends ModelElement<T,?>> R accept(Iterable<T>
components,
- LibraryVisitor<R, P> visitor, P param, R result) throws CdkException {
- if (null == result) {
- for (T t : components) {
- R accept = t.accept(visitor, param);
- if (null != accept) {
- result = accept;
- break;
- }
- }
+ if (null != newValue && (overwrite || null == oldValue)) {
+ writeMethod.invoke(target, newValue);
+ }
+ }
+ }
+ } catch (IntrospectionException e) {
- }
- return result;
- }
+ // TODO Auto-generated catch block
+ } catch (IllegalArgumentException e) {
- /**
- * <p class="changed_added_4_0">
- * Find element in the model collection.
- * </p>
- *
- * @param <T>
- * type of element to find.
- * @param collection
- * of elements.
- * @param key
- * for search.
- * @return existing element in the collection.
- * @throws NoSuchElementException
- * if there was no such element in collection.
- */
- static <K extends Key,T extends Searchable<K>> T find(Iterable<T>
collection, final K key)
- throws NoSuchElementException {
- return Iterables.find(collection, new Predicate<T>() {
+ // TODO Auto-generated catch block
+ } catch (IllegalAccessException e) {
- @Override
- public boolean apply(T input) {
+ // TODO Auto-generated catch block
+ } catch (InvocationTargetException e) {
- return key.equals(input.getKey());
- }
+ // TODO Auto-generated catch block
+ }
+ }
- });
- }
+ static <R, P, T extends ModelElement<T, ?>> R accept(Iterable<T>
components, LibraryVisitor<R, P> visitor, P param,
+ R result) throws CdkException {
+ if (null == result) {
+ for (T t : components) {
+ R accept = t.accept(visitor, param);
+ if (null != accept) {
+ result = accept;
+
+ break;
+ }
+ }
+ }
+
+ return result;
+ }
+
+ /**
+ * <p class="changed_added_4_0">
+ * Find element in the model collection.
+ * </p>
+ *
+ * @param <T>
+ * type of element to find.
+ * @param collection
+ * of elements.
+ * @param key
+ * for search.
+ * @return existing element in the collection.
+ * @throws NoSuchElementException
+ * if there was no such element in collection.
+ */
+ static <K extends Key, T extends Searchable<K>> T find(Iterable<T>
collection, final K key)
+ throws NoSuchElementException {
+
+ return Iterables.find(collection, new Predicate<T>() {
+ @Override
+ public boolean apply(T input) {
+ return key.equals(input.getKey());
+ }
+ });
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ConfigExtension.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ConfigExtension.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ConfigExtension.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.model;
import java.util.List;
@@ -35,24 +37,22 @@
*
*/
public class ConfigExtension {
-
- private List<Element> extensions;
+ private List<Element> extensions;
- /**
- * <p class="changed_added_4_0"></p>
- * @return the extensions
- */
- @XmlAnyElement
- public List<Element> getExtensions() {
- return extensions;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the extensions
+ */
+ @XmlAnyElement
+ public List<Element> getExtensions() {
+ return extensions;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param extensions the extensions to set
- */
- public void setExtensions(List<Element> extensions) {
- this.extensions = extensions;
- }
-
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param extensions the extensions to set
+ */
+ public void setExtensions(List<Element> extensions) {
+ this.extensions = extensions;
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Converter.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Converter.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Converter.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.model;
import org.richfaces.cdk.CdkException;
@@ -31,34 +33,33 @@
*
*/
@SuppressWarnings("serial")
-public class Converter implements ModelElement <Converter,Key>{
+public class Converter implements ModelElement<Converter, Key> {
+ private final Key type;
- private final Key type;
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param type the type to set
+ */
+ public Converter(Key type) {
+ this.type = type;
+ }
- @Override
- public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) throws
CdkException {
- return visitor.visit(this, param);
- }
+ @Override
+ public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) throws
CdkException {
+ return visitor.visit(this, param);
+ }
- /* (non-Javadoc)
- * @see org.richfaces.cdk.model.ModelElement#getType()
- */
- public Key getKey() {
- return type;
- }
+ /*
+ * (non-Javadoc)
+ * @see org.richfaces.cdk.model.ModelElement#getType()
+ */
+ public Key getKey() {
+ return type;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param type the type to set
- */
- public Converter(Key type) {
- this.type = type;
- }
+ @Override
+ public void merge(Converter other) {
- @Override
- public void merge(Converter other) {
- // TODO Auto-generated method stub
-
- }
-
+ // TODO Auto-generated method stub
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/DescriptionGroup.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/DescriptionGroup.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/DescriptionGroup.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -10,102 +10,105 @@
*/
public interface DescriptionGroup {
- /**
- * <p class="changed_added_4_0"></p>
- * @author asmirnov(a)exadel.com
- *
- */
- @XmlType(name="icon-type",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
- public static final class Icon {
- private String smallIcon;
- /**
- * <p class="changed_added_4_0"></p>
- * @return the smallIcon
- */
- @XmlElement(name = "small-icon", namespace =
ComponentLibrary.FACES_CONFIG_NAMESPACE)
- public String getSmallIcon() {
- return smallIcon;
- }
- /**
- * <p class="changed_added_4_0"></p>
- * @param smallIcon the smallIcon to set
- */
- public void setSmallIcon(String smallIcon) {
- this.smallIcon = smallIcon;
- }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the largeIcon
- */
- @XmlElement(name = "large-icon", namespace =
ComponentLibrary.FACES_CONFIG_NAMESPACE)
- public String getLargeIcon() {
- return largeIcon;
- }
- /**
- * <p class="changed_added_4_0"></p>
- * @param largeIcon the largeIcon to set
- */
- public void setLargeIcon(String largeIcon) {
- this.largeIcon = largeIcon;
- }
- private String largeIcon;
- }
+ /**
+ * <p class="changed_added_4_0">Documentation description of that
element.
+ * </p>
+ *
+ * @return the description
+ */
+ @XmlElement
+ @Merge
+ public String getDescription();
- /**
- * <p class="changed_added_4_0">Documentation description of that
element.
- * </p>
- *
- * @return the description
- */
- @XmlElement
- @Merge
- public String getDescription();
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param description
+ * the description to set
+ */
+ public void setDescription(String description);
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @param description
- * the description to set
- */
- public void setDescription(String description);
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @return the displayname
+ */
+ @XmlElement(name = "display-name")
+ @Merge
+ public String getDisplayname();
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @return the displayname
- */
- @XmlElement(name = "display-name")
- @Merge
- public String getDisplayname();
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param displayname
+ * the displayname to set
+ */
+ public void setDisplayname(String displayname);
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @param displayname
- * the displayname to set
- */
- public void setDisplayname(String displayname);
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @return the icon
+ */
+ @XmlElement
+ @Merge
+ public Icon getIcon();
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @return the icon
- */
- @XmlElement
- @Merge
- public Icon getIcon();
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param icon
+ * the icon to set
+ */
+ public void setIcon(Icon icon);
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @param icon
- * the icon to set
- */
- public void setIcon(Icon icon);
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+ @XmlType(name = "icon-type", namespace =
ComponentLibrary.FACES_CONFIG_NAMESPACE)
+ public static final class Icon {
+ private String largeIcon;
+ private String smallIcon;
-}
\ No newline at end of file
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the smallIcon
+ */
+ @XmlElement(name = "small-icon", namespace =
ComponentLibrary.FACES_CONFIG_NAMESPACE)
+ public String getSmallIcon() {
+ return smallIcon;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param smallIcon the smallIcon to set
+ */
+ public void setSmallIcon(String smallIcon) {
+ this.smallIcon = smallIcon;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the largeIcon
+ */
+ @XmlElement(name = "large-icon", namespace =
ComponentLibrary.FACES_CONFIG_NAMESPACE)
+ public String getLargeIcon() {
+ return largeIcon;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param largeIcon the largeIcon to set
+ */
+ public void setLargeIcon(String largeIcon) {
+ this.largeIcon = largeIcon;
+ }
+ }
+}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Event.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Event.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Event.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -21,146 +21,139 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.richfaces.cdk.model;
-import javax.faces.event.FacesEvent;
+package org.richfaces.cdk.model;
+
import org.richfaces.cdk.CdkException;
/**
- * <p class="changed_added_4_0">That bean represent {@link FacesEvent}
subclass that can be fired by component.</p>
+ * <p class="changed_added_4_0">That bean represent {@link
javax.faces.event.FacesEvent} subclass that can be fired by
+ * component.</p>
+ *
* @author asmirnov(a)exadel.com
*
*/
@SuppressWarnings("serial")
-public class Event implements ModelElement<Event,Event.Type>{
+public class Event implements ModelElement<Event, Event.Type> {
+ private String description;
+ private ClassDescription listenerInterface;
+ private ClassDescription sourceInterface;
+ private ClassDescription tagHandler;
- /**
- * <p class="changed_added_4_0"></p>
- * @author asmirnov(a)exadel.com
- *
- */
- public static final class Type extends Key {
+ /**
+ * <p class="changed_added_4_0"></p>
+ */
+ private final Type type;
- /**
- * <p class="changed_added_4_0"></p>
- * @param type
- */
- public Type(String type) {
- super(type);
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param type the type to set
+ */
+ public Event(Type name) {
+ this.type = name;
+ }
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the type
+ */
+ public Key getType() {
+ return type;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- */
- private final Type type;
+ @Override
+ public Type getKey() {
+ return type;
+ }
- private String description;
-
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the description
+ */
+ public String getDescription() {
+ return description;
+ }
- private ClassDescription listenerInterface;
-
- private ClassDescription sourceInterface;
-
- private ClassDescription tagHandler;
-
-
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param description the description to set
+ */
+ public void setDescription(String description) {
+ this.description = description;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param type the type to set
- */
- public Event(Type name) {
- this.type = name;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the listenerInterface
+ */
+ public ClassDescription getListenerInterface() {
+ return listenerInterface;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the type
- */
- public Key getType() {
- return type;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param listenerInterface the listenerInterface to set
+ */
+ public void setListenerInterface(ClassDescription listenerInterface) {
+ this.listenerInterface = listenerInterface;
+ }
- @Override
- public Type getKey() {
- return type;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the sourceInterface
+ */
+ public ClassDescription getSourceInterface() {
+ return sourceInterface;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the description
- */
- public String getDescription() {
- return description;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param sourceInterface the sourceInterface to set
+ */
+ public void setSourceInterface(ClassDescription sourceInterface) {
+ this.sourceInterface = sourceInterface;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param description the description to set
- */
- public void setDescription(String description) {
- this.description = description;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the tagHandler
+ */
+ public ClassDescription getTagHandler() {
+ return tagHandler;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the listenerInterface
- */
- public ClassDescription getListenerInterface() {
- return listenerInterface;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param tagHandler the tagHandler to set
+ */
+ public void setTagHandler(ClassDescription tagHandler) {
+ this.tagHandler = tagHandler;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param listenerInterface the listenerInterface to set
- */
- public void setListenerInterface(ClassDescription listenerInterface) {
- this.listenerInterface = listenerInterface;
- }
+ @Override
+ public void merge(Event other) {
+ ComponentLibrary.merge(this, other);
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the sourceInterface
- */
- public ClassDescription getSourceInterface() {
- return sourceInterface;
- }
+ @Override
+ public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) throws
CdkException {
+ return visitor.visit(this, param);
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param sourceInterface the sourceInterface to set
- */
- public void setSourceInterface(ClassDescription sourceInterface) {
- this.sourceInterface = sourceInterface;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+ public static final class Type extends Key {
- /**
- * <p class="changed_added_4_0"></p>
- * @return the tagHandler
- */
- public ClassDescription getTagHandler() {
- return tagHandler;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @param tagHandler the tagHandler to set
- */
- public void setTagHandler(ClassDescription tagHandler) {
- this.tagHandler = tagHandler;
- }
-
- @Override
- public void merge(Event other) {
- ComponentLibrary.merge(this, other);
- }
-
- @Override
- public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) throws
CdkException {
- return visitor.visit(this, param);
- }
-
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param type
+ */
+ public Type(String type) {
+ super(type);
+ }
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/EventName.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/EventName.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/EventName.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.model;
import java.io.Serializable;
@@ -35,83 +37,90 @@
*/
@SuppressWarnings("serial")
public class EventName implements Serializable {
-
- private String name;
-
- private boolean defaultEvent = false;
+ private boolean defaultEvent = false;
+ private String name;
- /**
- * <p class="changed_added_4_0"></p>
- * @return the name
- */
- @XmlValue
- public String getName() {
- return name;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the name
+ */
+ @XmlValue
+ public String getName() {
+ return name;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param name the name to set
- */
- public void setName(String name) {
- this.name = name;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param name the name to set
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the defaultEvent
- */
- @XmlAttribute(name="default")
- public boolean isDefaultEvent() {
- return defaultEvent;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the defaultEvent
+ */
+ @XmlAttribute(name = "default")
+ public boolean isDefaultEvent() {
+ return defaultEvent;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param defaultEvent the defaultEvent to set
- */
- public void setDefaultEvent(boolean defaultEvent) {
- this.defaultEvent = defaultEvent;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param defaultEvent the defaultEvent to set
+ */
+ public void setDefaultEvent(boolean defaultEvent) {
+ this.defaultEvent = defaultEvent;
+ }
- @Override
- public String toString() {
- return name;
- }
- /* (non-Javadoc)
- * @see java.lang.Object#hashCode()
- */
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((name == null) ? 0 : name.hashCode());
- return result;
- }
+ @Override
+ public String toString() {
+ return name;
+ }
- /* (non-Javadoc)
- * @see java.lang.Object#equals(java.lang.Object)
- */
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- EventName other = (EventName) obj;
- if (name == null) {
- if (other.name != null) {
- return false;
- }
- } else if (!name.equals(other.name)) {
- return false;
- }
- return true;
- }
+ /*
+ * (non-Javadoc)
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((name == null) ? 0 : name.hashCode());
+
+ return result;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+
+ if (obj == null) {
+ return false;
+ }
+
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+
+ EventName other = (EventName) obj;
+
+ if (name == null) {
+ if (other.name != null) {
+ return false;
+ }
+ } else if (!name.equals(other.name)) {
+ return false;
+ }
+
+ return true;
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Extensible.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Extensible.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Extensible.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.model;
/**
@@ -30,12 +32,11 @@
*/
public interface Extensible<E extends ConfigExtension> {
- /**
- * <p class="changed_added_4_0">Return extension object that holds
CDK-related tags and any other content as well.</p>
- * @return
- */
- public E getExtension();
-
- public void setExtension(E ext);
-
+ /**
+ * <p class="changed_added_4_0">Return extension object that holds
CDK-related tags and any other content as well.</p>
+ * @return
+ */
+ public E getExtension();
+
+ public void setExtension(E ext);
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Facet.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Facet.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Facet.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.model;
import org.richfaces.cdk.CdkException;
@@ -31,62 +33,60 @@
*
*/
@SuppressWarnings("serial")
-public class Facet extends ModelElementBase implements
ModelElement<Facet,Facet.Name> {
-
- public static final class Name extends Key {
-
- public Name(String name) {
- super(name);
- }
- }
+public class Facet extends ModelElementBase implements ModelElement<Facet,
Facet.Name> {
+ private boolean generate;
+ private final Name name;
- private final Name name;
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param name
+ */
+ public Facet(Name name) {
+ this.name = name;
+ }
- private boolean generate;
- /**
- * <p class="changed_added_4_0"></p>
- * @param name
- */
- public Facet(Name name) {
- this.name = name;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the name
+ */
+ public Name getName() {
+ return name;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the name
- */
- public Name getName() {
- return name;
- }
+ @Override
+ public Name getKey() {
+ return name;
+ }
- @Override
- public Name getKey() {
- return name;
- }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the generate
- */
- public boolean isGenerate() {
- return generate;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the generate
+ */
+ public boolean isGenerate() {
+ return generate;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param generate the generate to set
- */
- public void setGenerate(boolean generate) {
- this.generate = generate;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param generate the generate to set
+ */
+ public void setGenerate(boolean generate) {
+ this.generate = generate;
+ }
- @Override
- public void merge(Facet other) {
- ComponentLibrary.merge(this, other);
- }
+ @Override
+ public void merge(Facet other) {
+ ComponentLibrary.merge(this, other);
+ }
- @Override
- public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) throws
CdkException {
- return visitor.visit(this, param);
- }
+ @Override
+ public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) throws
CdkException {
+ return visitor.visit(this, param);
+ }
+ public static final class Name extends Key {
+ public Name(String name) {
+ super(name);
+ }
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/InvalidNameException.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/InvalidNameException.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/InvalidNameException.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.model;
import org.richfaces.cdk.CdkException;
@@ -33,36 +35,35 @@
@SuppressWarnings("serial")
public class InvalidNameException extends CdkException {
- /**
- * <p class="changed_added_4_0"></p>
- */
- public InvalidNameException() {
- super();
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ */
+ public InvalidNameException() {
+ super();
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param message
- */
- public InvalidNameException(String message) {
- super(message);
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param message
+ */
+ public InvalidNameException(String message) {
+ super(message);
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param cause
- */
- public InvalidNameException(Throwable cause) {
- super(cause);
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param cause
+ */
+ public InvalidNameException(Throwable cause) {
+ super(cause);
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param message
- * @param cause
- */
- public InvalidNameException(String message, Throwable cause) {
- super(message, cause);
- }
-
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param message
+ * @param cause
+ */
+ public InvalidNameException(String message, Throwable cause) {
+ super(message, cause);
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Key.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Key.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Key.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.model;
import java.io.Serializable;
@@ -32,59 +34,71 @@
*/
@SuppressWarnings("serial")
public class Key implements Serializable {
-
- private final String type;
+ private final String type;
- /**
- * <p class="changed_added_4_0"></p>
- * @param type
- */
- public Key(String type) {
- this.type = type;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param type
+ */
+ public Key(String type) {
+ this.type = type;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the type
- */
- public String getType() {
- return type;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the type
+ */
+ public String getType() {
+ return type;
+ }
- @Override
- public String toString() {
- return type;
- }
- /* (non-Javadoc)
- * @see java.lang.Object#hashCode()
- */
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((type == null) ? 0 : type.hashCode());
- return result;
- }
+ @Override
+ public String toString() {
+ return type;
+ }
- /* (non-Javadoc)
- * @see java.lang.Object#equals(java.lang.Object)
- */
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- Key other = (Key) obj;
- if (type == null) {
- if (other.type != null)
- return false;
- } else if (!type.equals(other.type))
- return false;
- return true;
- }
+ /*
+ * (non-Javadoc)
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((type == null) ? 0 : type.hashCode());
+ return result;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+
+ if (obj == null) {
+ return false;
+ }
+
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+
+ Key other = (Key) obj;
+
+ if (type == null) {
+ if (other.type != null) {
+ return false;
+ }
+ } else if (!type.equals(other.type)) {
+ return false;
+ }
+
+ return true;
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/LibraryVisitor.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/LibraryVisitor.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/LibraryVisitor.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.model;
import org.richfaces.cdk.CdkException;
@@ -32,15 +34,14 @@
* @param <R> return type
* @param <P> optional parameter type.
*/
-public interface LibraryVisitor<R,P> {
-
- /**
- * <p class="changed_added_4_0"></p>
- * @param c
- * @param param
- * @return
- * @throws CdkException
- */
- public R visit(Visitable c, P param) throws CdkException;
+public interface LibraryVisitor<R, P> {
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param c
+ * @param param
+ * @return
+ * @throws CdkException
+ */
+ public R visit(Visitable c, P param) throws CdkException;
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Listener.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Listener.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Listener.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.model;
import org.richfaces.cdk.CdkException;
@@ -31,33 +33,33 @@
*
*/
@SuppressWarnings("serial")
-public class Listener implements ModelElement<Listener,Key> {
-
- /**
- * <p class="changed_added_4_0"></p>
- */
- private final Key type;
+public class Listener implements ModelElement<Listener, Key> {
- @Override
- public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) throws
CdkException {
- return visitor.visit(this, param);
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ */
+ private final Key type;
- public Listener(Key type) {
- this.type = type;
- }
- /* (non-Javadoc)
- * @see org.richfaces.cdk.model.ModelElement#getType()
- */
- public Key getKey() {
- return type;
- }
+ public Listener(Key type) {
+ this.type = type;
+ }
+ @Override
+ public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) throws
CdkException {
+ return visitor.visit(this, param);
+ }
- @Override
- public void merge(Listener other) {
- // TODO Auto-generated method stub
-
- }
+ /*
+ * (non-Javadoc)
+ * @see org.richfaces.cdk.model.ModelElement#getType()
+ */
+ public Key getKey() {
+ return type;
+ }
+ @Override
+ public void merge(Listener other) {
+
+ // TODO Auto-generated method stub
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Merge.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Merge.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Merge.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.model;
import java.lang.annotation.ElementType;
@@ -38,11 +40,10 @@
@Target({ElementType.METHOD})
@Inherited
public @interface Merge {
-
- /**
- * <p class="changed_added_4_0">If true, target value should be
overwritten, otherwise only null values will bw replaced.</p>
- * @return
- */
- boolean value() default true;
+ /**
+ * <p class="changed_added_4_0">If true, target value should be
overwritten, otherwise only null values will bw replaced.</p>
+ * @return
+ */
+ boolean value() default true;
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Mergeable.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Mergeable.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Mergeable.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -1,7 +1,5 @@
package org.richfaces.cdk.model;
public interface Mergeable<T> {
-
- public void merge(T other);
-
-}
\ No newline at end of file
+ public void merge(T other);
+}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ModelCollection.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ModelCollection.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ModelCollection.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.model;
import java.util.Collection;
@@ -36,163 +38,172 @@
* <p class="changed_added_4_0">
* Base class for all model collections.
* </p>
- *
+ *
* @author asmirnov(a)exadel.com
- *
+ *
*/
-public abstract class ModelCollection<E extends ModelElement<E,K>, K extends
Key>
- implements SearchableCollection<E, K>, Visitable,
- Mergeable<SearchableCollection<E, K>> {
+public abstract class ModelCollection<E extends ModelElement<E, K>, K extends
Key>
+ implements SearchableCollection<E, K>, Visitable,
Mergeable<SearchableCollection<E, K>> {
+ private final BiMap<K, E> elementsMap = HashBiMap.create();
+ private final BiMap<E, K> reverseMap = elementsMap.inverse();
- @SuppressWarnings("unused")
- private final class SearchPredicate implements Predicate<E> {
+ // TODO -provide factory methods.
+ // private final Method factoryMethod;
+ @Override
+ public E find(final K key) {
+ if (null != key) {
+ return elementsMap.get(key);
+ } else {
+ return null;
+ }
+ }
- private final K key;
+ @Override
+ public E findOrCreate(K key) {
+ E element = find(key);
- private SearchPredicate(K key) {
- this.key = key;
- }
+ if (null == element) {
+ element = create(key);
+ elementsMap.put(key, element);
+ }
- @Override
- public boolean apply(E input) {
- return key.equals(input.getKey());
- }
- }
+ return element;
+ }
- private final BiMap<K, E> elementsMap = HashBiMap.create();
-
- private final BiMap<E, K> reverseMap = elementsMap.inverse();
+ @Override
+ public Iterable<K> keys() {
+ return elementsMap.keySet();
+ }
- // TODO -provide factory methods.
- // private final Method factoryMethod;
+ @Override
+ public boolean add(E e) {
+ E old = elementsMap.put(e.getKey(), e);
- @Override
- public E find(final K key) {
- if (null != key) {
- return elementsMap.get(key);
- } else {
- return null;
- }
- }
+ if (null != old) {
- @Override
- public E findOrCreate(K key) {
- E element = find(key);
- if (null == element) {
- element = create(key);
- elementsMap.put(key,element);
- }
- return element;
- }
+ // TODO - merge values ?
+ }
- @Override
- public Iterable<K> keys() {
- return elementsMap.keySet();
- }
+ return null != old;
+ }
- @Override
- public boolean add(E e) {
- E old = elementsMap.put(e.getKey(),e);
- if(null != old){
- // TODO - merge values ?
- }
- return null != old;
- }
+ @Override
+ public boolean addAll(Collection<? extends E> c) {
+ boolean changed = false;
- @Override
- public boolean addAll(Collection<? extends E> c) {
- boolean changed = false;
- for (E e : c) {
- changed |= add(e);
- }
- return changed;
- }
+ for (E e : c) {
+ changed |= add(e);
+ }
- @Override
- public void clear() {
- elementsMap.clear();
- }
+ return changed;
+ }
- @SuppressWarnings("unchecked")
- @Override
- public boolean contains(Object o) {
- if (o instanceof ModelElement<?,?>) {
- K key = ((ModelElement<E,K>) o).getKey();
- return elementsMap.containsKey(key);
- }
- return false;
- }
+ @Override
+ public void clear() {
+ elementsMap.clear();
+ }
- @Override
- public boolean containsAll(Collection<?> c) {
- return elementsMap.values().containsAll(c);
- }
+ @SuppressWarnings("unchecked")
+ @Override
+ public boolean contains(Object o) {
+ if (o instanceof ModelElement<?, ?>) {
+ K key = ((ModelElement<E, K>) o).getKey();
- @Override
- public boolean isEmpty() {
- return elementsMap.isEmpty();
- }
+ return elementsMap.containsKey(key);
+ }
- @Override
- public Iterator<E> iterator() {
- return elementsMap.values().iterator();
- }
+ return false;
+ }
- @Override
- public boolean remove(Object o) {
- return null != reverseMap.remove(o);
- }
+ @Override
+ public boolean containsAll(Collection<?> c) {
+ return elementsMap.values().containsAll(c);
+ }
- @Override
- public boolean removeAll(Collection<?> c) {
- boolean changed = false;
- for (Object e : c) {
- changed |= remove(e);
- }
- return changed;
- }
+ @Override
+ public boolean isEmpty() {
+ return elementsMap.isEmpty();
+ }
- @Override
- public boolean retainAll(Collection<?> c) {
-// return elements.retainAll(c);
- return false;
- }
+ @Override
+ public Iterator<E> iterator() {
+ return elementsMap.values().iterator();
+ }
- @Override
- public int size() {
- return elementsMap.size();
- }
+ @Override
+ public boolean remove(Object o) {
+ return null != reverseMap.remove(o);
+ }
- @Override
- public Object[] toArray() {
- return elementsMap.values().toArray();
- }
+ @Override
+ public boolean removeAll(Collection<?> c) {
+ boolean changed = false;
- @Override
- public <T> T[] toArray(T[] a) {
- return elementsMap.values().toArray(a);
- }
+ for (Object e : c) {
+ changed |= remove(e);
+ }
- public <R, P> R accept(
- org.richfaces.cdk.model.LibraryVisitor<R, P> visitor, P param) throws
CdkException {
- R result = null;
- Iterator<E> iterator = iterator();
- while (null == result && iterator.hasNext()) {
- result = iterator.next().accept(visitor, param);
- }
- return result;
- };
+ return changed;
+ }
- @Override
- public void merge(SearchableCollection<E, K> other) {
- for (E element : other) {
- K key = element.getKey();
- E old = find(key);
- if (null == old) {
- elementsMap.put(key,element);
- } else {
- old.merge(element);
- }
- }
- }
+ @Override
+ public boolean retainAll(Collection<?> c) {
+
+// return elements.retainAll(c);
+ return false;
+ }
+
+ @Override
+ public int size() {
+ return elementsMap.size();
+ }
+
+ @Override
+ public Object[] toArray() {
+ return elementsMap.values().toArray();
+ }
+
+ @Override
+ public <T> T[] toArray(T[] a) {
+ return elementsMap.values().toArray(a);
+ }
+
+ public <R, P> R accept(org.richfaces.cdk.model.LibraryVisitor<R, P>
visitor, P param) throws CdkException {
+ R result = null;
+ Iterator<E> iterator = iterator();
+
+ while (null == result && iterator.hasNext()) {
+ result = iterator.next().accept(visitor, param);
+ }
+
+ return result;
+ }
+
+ @Override
+ public void merge(SearchableCollection<E, K> other) {
+ for (E element : other) {
+ K key = element.getKey();
+ E old = find(key);
+
+ if (null == old) {
+ elementsMap.put(key, element);
+ } else {
+ old.merge(element);
+ }
+ }
+ }
+
+ @SuppressWarnings("unused")
+ private final class SearchPredicate implements Predicate<E> {
+ private final K key;
+
+ private SearchPredicate(K key) {
+ this.key = key;
+ }
+
+ @Override
+ public boolean apply(E input) {
+ return key.equals(input.getKey());
+ }
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ModelElement.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ModelElement.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ModelElement.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -2,6 +2,5 @@
import java.io.Serializable;
-public interface ModelElement<T extends ModelElement<T, K>,K extends Key>
extends Serializable, Mergeable<T>, Searchable<K>, Visitable {
-
-}
\ No newline at end of file
+public interface ModelElement<T extends ModelElement<T, K>, K extends Key>
+ extends Serializable, Mergeable<T>, Searchable<K>, Visitable {}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ModelElementBase.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ModelElementBase.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ModelElementBase.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -2,72 +2,71 @@
import javax.xml.bind.annotation.XmlElement;
-import org.richfaces.cdk.model.Component.Type;
+public class ModelElementBase implements DescriptionGroup,
Extensible<ConfigExtension> {
-public class ModelElementBase implements
DescriptionGroup,Extensible<ConfigExtension> {
+ /**
+ * <p class="changed_added_4_0">
+ * Long description for documentation
+ * </p>
+ */
+ private String description;
- /**
- * <p class="changed_added_4_0">
- * Long description for documentation
- * </p>
- */
- private String description;
- /**
- * <p class="changed_added_4_0">
- * Short name for IDE tools
- * </p>
- */
- private String displayname;
- /**
- * <p class="changed_added_4_0">
- * Icon name for IDE tools
- * </p>
- */
- private Icon icon;
- private ConfigExtension extension;
+ /**
+ * <p class="changed_added_4_0">
+ * Short name for IDE tools
+ * </p>
+ */
+ private String displayname;
+ private ConfigExtension extension;
- public ModelElementBase() {
- super();
- }
+ /**
+ * <p class="changed_added_4_0">
+ * Icon name for IDE tools
+ * </p>
+ */
+ private Icon icon;
- @XmlElement
- public final String getDescription() {
- return description;
- }
+ public ModelElementBase() {
+ super();
+ }
- public final void setDescription(String description) {
- this.description = description;
- }
+ @XmlElement
+ public final String getDescription() {
+ return description;
+ }
- @XmlElement(name = "display-name")
- public final String getDisplayname() {
- return displayname;
- }
+ public final void setDescription(String description) {
+ this.description = description;
+ }
- public final void setDisplayname(String displayname) {
- this.displayname = displayname;
- }
+ @XmlElement(name = "display-name")
+ public final String getDisplayname() {
+ return displayname;
+ }
- @XmlElement
- public final Icon getIcon() {
- return icon;
- }
+ public final void setDisplayname(String displayname) {
+ this.displayname = displayname;
+ }
- public final void setIcon(Icon icon) {
- this.icon = icon;
- }
+ @XmlElement
+ public final Icon getIcon() {
+ return icon;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the extension
- */
- @XmlElement(name = "component-extensions")
- public final ConfigExtension getExtension() {
- return extension;
- }
+ public final void setIcon(Icon icon) {
+ this.icon = icon;
+ }
- public final void setExtension(ConfigExtension extension) {
- this.extension = extension;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the extension
+ */
+ @XmlElement(name = "component-extensions")
+ public final ConfigExtension getExtension() {
+ return extension;
+ }
-}
\ No newline at end of file
+ public final void setExtension(ConfigExtension extension) {
+ this.extension = extension;
+ }
+}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Name.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Name.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Name.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.model;
import java.util.regex.Pattern;
@@ -30,243 +32,248 @@
* Represents parts of component type/family/classname according to CDK naming
* conventions.
* </p>
- *
+ *
* @author asmirnov(a)exadel.com
- *
+ *
*/
public class Name {
+ private static final Pattern NAME_PATTERN =
Pattern.compile("^(?:(.+)\\.)?(?:(" + Classifier.component + "|"
+ + Classifier.renderkit +
"|" + Classifier.event + "|"
+ + Classifier.taglib +
")\\.(?:([^\\.]+)\\.)?)?([^\\.]+)$");
- /**
- * <p class="changed_added_4_0">
- * Standard package names for components, renderers, event listeners and taglib.
- * </p>
- *
- * @author asmirnov(a)exadel.com
- *
- */
- public enum Classifier {
- /**
- * <p class="changed_added_4_0"></p>
- */
- component,
- /**
- * <p class="changed_added_4_0"></p>
- */
- renderkit,
- /**
- * <p class="changed_added_4_0"></p>
- */
- event,
- /**
- * <p class="changed_added_4_0"></p>
- */
- taglib;
- }
+ /**
+ * <p class="changed_added_4_0">
+ * Element type classifier -
"component","event","renderkit","taglib"
+ * </p>
+ */
+ private Classifier classifier;
- private static final Pattern namePattern = Pattern
- .compile("^(?:(.+)\\.)?(?:(" + Classifier.component + "|"
- + Classifier.renderkit + "|" + Classifier.event + "|"
- + Classifier.taglib + ")\\.(?:([^\\.]+)\\.)?)?([^\\.]+)$");
+ /**
+ * <p class="changed_added_4_0">
+ * Markup-specific part of name ( "html","xhtml","wml"
... )
+ * </p>
+ */
+ private String markup;
- /**
- * <p class="changed_added_4_0">
- * represents library part prefix of name.
- * </p>
- */
- private String prefix;
+ /**
+ * <p class="changed_added_4_0">
+ * represents library part prefix of name.
+ * </p>
+ */
+ private String prefix;
- /**
- * <p class="changed_added_4_0">
- * Element type classifier -
"component","event","renderkit","taglib"
- * </p>
- */
- private Classifier classifier;
+ /**
+ * <p class="changed_added_4_0">
+ * Simple name ( last word after a period ).
+ * </p>
+ */
+ private String simpleName;
- /**
- * <p class="changed_added_4_0">
- * Markup-specific part of name ( "html","xhtml","wml" ...
)
- * </p>
- */
- private String markup;
+ /**
+ * <p class="changed_added_4_0">
+ * Standard package names for components, renderers, event listeners and taglib.
+ * </p>
+ *
+ * @author asmirnov(a)exadel.com
+ *
+ */
+ public enum Classifier {
- /**
- * <p class="changed_added_4_0">
- * Simple name ( last word after a period ).
- * </p>
- */
- private String simpleName;
+ /**
+ * <p class="changed_added_4_0"></p>
+ */
+ component,
- /**
- * <p class="changed_added_4_0">
- * Creates RichFaces name representation from string.
- * </p>
- *
- * @param name
- * @return
- * @throws InvalidNameException
- */
- public static Name create(String name) throws InvalidNameException {
- Name cdkName = new Name();
- StringBuilder prefix = new StringBuilder(name.length());
- String[] parts = name.split("\\.");
- cdkName.setSimpleName(parts[parts.length - 1]);
- if (parts.length > 1) {
- try {
- cdkName.setClassifier(Classifier
- .valueOf(parts[parts.length - 2]));
- fillPrefix(prefix, parts, parts.length - 2);
- } catch (IllegalArgumentException e) {
- if (parts.length > 2) {
- try {
- cdkName.setClassifier(Classifier
- .valueOf(parts[parts.length - 3]));
- fillPrefix(prefix, parts, parts.length - 3);
- cdkName.setMarkup(parts[parts.length - 2]);
- } catch (IllegalArgumentException e1) {
- fillPrefix(prefix, parts, parts.length - 1);
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ */
+ renderkit,
- } else {
- prefix.append(parts[0]);
- }
- }
- if (prefix.length() > 0) {
- cdkName.setPrefix(prefix.toString());
- }
- }
- return cdkName;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ */
+ event,
- /**
- * <p class="changed_added_4_0">Utility method that composes library
prefix from first elements of array</p>
- * @param prefix buffer that collects prefix.
- * @param parts package name parts
- * @param size size of prefix part of array.
- */
- private static void fillPrefix(StringBuilder prefix, String[] parts,
- int size) {
- for (int i = 0; i < size; i++) {
- if (i != 0) {
- prefix.append('.');
- }
- prefix.append(parts[i]);
- }
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ */
+ taglib;
+ }
- public static Name create(String prefix, String name)
- throws InvalidNameException {
- Name cdkName = create(name);
- if (prefix.equals(cdkName.getPrefix())) {
- return new Name();
- } else {
- throw new InvalidNameException("Nape " + name
- + " does not start with prefix " + prefix);
- }
- }
+ /**
+ * <p class="changed_added_4_0">
+ * Creates RichFaces name representation from string.
+ * </p>
+ *
+ * @param name
+ * @return
+ * @throws InvalidNameException
+ */
+ public static Name create(String name) throws InvalidNameException {
+ Name cdkName = new Name();
+ StringBuilder prefix = new StringBuilder(name.length());
+ String[] parts = name.split("\\.");
- public static Name create(String prefix, Classifier classifier, String name)
- throws InvalidNameException {
- return new Name();
- }
+ cdkName.setSimpleName(parts[parts.length - 1]);
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @return the prefix
- */
- public String getPrefix() {
- return prefix;
- }
+ if (parts.length > 1) {
+ try {
+ cdkName.setClassifier(Classifier.valueOf(parts[parts.length - 2]));
+ fillPrefix(prefix, parts, parts.length - 2);
+ } catch (IllegalArgumentException e) {
+ if (parts.length > 2) {
+ try {
+ cdkName.setClassifier(Classifier.valueOf(parts[parts.length -
3]));
+ fillPrefix(prefix, parts, parts.length - 3);
+ cdkName.setMarkup(parts[parts.length - 2]);
+ } catch (IllegalArgumentException e1) {
+ fillPrefix(prefix, parts, parts.length - 1);
+ }
+ } else {
+ prefix.append(parts[0]);
+ }
+ }
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @param prefix
- * the prefix to set
- */
- public void setPrefix(String prefix) {
- this.prefix = prefix;
- }
+ if (prefix.length() > 0) {
+ cdkName.setPrefix(prefix.toString());
+ }
+ }
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @return the classifier
- */
- public Classifier getClassifier() {
- return classifier;
- }
+ return cdkName;
+ }
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @param classifier
- * the classifier to set
- */
- public void setClassifier(Classifier classifier) {
- this.classifier = classifier;
- }
+ /**
+ * <p class="changed_added_4_0">Utility method that composes library
prefix from first elements of array</p>
+ * @param prefix buffer that collects prefix.
+ * @param parts package name parts
+ * @param size size of prefix part of array.
+ */
+ private static void fillPrefix(StringBuilder prefix, String[] parts, int size) {
+ for (int i = 0; i < size; i++) {
+ if (i != 0) {
+ prefix.append('.');
+ }
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @return the markup
- */
- public String getMarkup() {
- return markup;
- }
+ prefix.append(parts[i]);
+ }
+ }
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @param markup
- * the markup to set
- */
- public void setMarkup(String markup) {
- this.markup = markup;
- }
+ public static Name create(String prefix, String name) throws InvalidNameException {
+ Name cdkName = create(name);
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @return the simpleName
- */
- public String getSimpleName() {
- return simpleName;
- }
+ if (prefix.equals(cdkName.getPrefix())) {
+ return new Name();
+ } else {
+ throw new InvalidNameException("Nape " + name + " does not
start with prefix " + prefix);
+ }
+ }
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @param simpleName
- * the simpleName to set
- */
- public void setSimpleName(String simpleName) {
- this.simpleName = simpleName;
- }
-
- @Override
- public String toString() {
- StringBuilder result = new StringBuilder();
- if(null != prefix){
- result.append(prefix).append('.');
- }
- if(null != classifier){
- result.append(classifier).append('.');
- }
- if(null != markup){
- result.append(markup).append('.');
- }
- result.append(simpleName);
- return result.toString();
- }
+ public static Name create(String prefix, Classifier classifier, String name) throws
InvalidNameException {
+ return new Name();
+ }
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @return the prefix
+ */
+ public String getPrefix() {
+ return prefix;
+ }
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param prefix
+ * the prefix to set
+ */
+ public void setPrefix(String prefix) {
+ this.prefix = prefix;
+ }
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @return the classifier
+ */
+ public Classifier getClassifier() {
+ return classifier;
+ }
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param classifier
+ * the classifier to set
+ */
+ public void setClassifier(Classifier classifier) {
+ this.classifier = classifier;
+ }
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @return the markup
+ */
+ public String getMarkup() {
+ return markup;
+ }
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param markup
+ * the markup to set
+ */
+ public void setMarkup(String markup) {
+ this.markup = markup;
+ }
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @return the simpleName
+ */
+ public String getSimpleName() {
+ return simpleName;
+ }
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param simpleName
+ * the simpleName to set
+ */
+ public void setSimpleName(String simpleName) {
+ this.simpleName = simpleName;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder result = new StringBuilder();
+
+ if (null != prefix) {
+ result.append(prefix).append('.');
+ }
+
+ if (null != classifier) {
+ result.append(classifier).append('.');
+ }
+
+ if (null != markup) {
+ result.append(markup).append('.');
+ }
+
+ result.append(simpleName);
+
+ return result.toString();
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Properties.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Properties.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Properties.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.model;
import java.util.List;
@@ -33,23 +35,21 @@
*
*/
public class Properties {
-
- private List<? extends Property> properties = Lists.newArrayList();
+ private List<? extends Property> properties = Lists.newArrayList();
- /**
- * <p class="changed_added_4_0"></p>
- * @return the properties
- */
- public List<? extends Property> getProperties() {
- return properties;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the properties
+ */
+ public List<? extends Property> getProperties() {
+ return properties;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param properties the properties to set
- */
- public void setProperties(List<? extends Property> properties) {
- this.properties = properties;
- }
-
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param properties the properties to set
+ */
+ public void setProperties(List<? extends Property> properties) {
+ this.properties = properties;
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Property.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Property.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Property.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -19,313 +19,283 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.richfaces.cdk.model;
-import java.util.List;
-import java.util.Set;
-import org.richfaces.cdk.CdkException;
-import org.richfaces.cdk.util.Strings;
+package org.richfaces.cdk.model;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
+import org.richfaces.cdk.CdkException;
+
+import java.util.List;
+import java.util.Set;
+
/**
* That class represents JSF component property.
* @author asmirnov(a)exadel.com
*
*/
@SuppressWarnings("serial")
-public class Property extends ModelElementBase implements
ModelElement<Property,Property.Name> {
-
- public static final class Name extends Key {
-
- public Name(String name) {
- super(name);
- }
- }
- /**
- * <p class="changed_added_4_0">Bean property name of component
attribute</p>
- */
- private final Name name;
-
-
- private ClassDescription type;
-
- /**
- * <p class="changed_added_4_0">Is that bean property generate in the
class or should be generated ?</p>
- */
- private boolean generate=false;
-
- private boolean hidden=false;
-
- private boolean literal=false;
-
- private boolean required=false;
-
- private boolean readOnly = false;
+public class Property extends ModelElementBase implements ModelElement<Property,
Property.Name> {
- private String defaultValue;
-
- private String suggestedValue;
-
- private boolean passThrough=false;
+ /**
+ * <p class="changed_added_4_0">Is that bean property generate in
the class or should be generated ?</p>
+ */
+ private boolean generate = false;
+ private boolean hidden = false;
+ private boolean literal = false;
+ private boolean required = false;
+ private boolean readOnly = false;
+ private boolean passThrough = false;
+ private Set<EventName> eventNames = Sets.newHashSet();
+ private List<ClassDescription> signature = Lists.newArrayList();
+ private Set<String> aliases = Sets.newHashSet();
+ private String defaultValue;
- private Set<EventName> eventNames = Sets.newHashSet();
-
- private List<ClassDescription> signature = Lists.newArrayList();
-
- private Set<String> aliases = Sets.newHashSet();
-
- /**
- * <p class="changed_added_4_0"></p>
- * @param name
- */
- public Property(Name name) {
- if(null==name){
- throw new NullPointerException();
- }
- this.name = name;
- }
+ /**
+ * <p class="changed_added_4_0">Bean property name of component
attribute</p>
+ */
+ private final Name name;
+ private String suggestedValue;
+ private ClassDescription type;
-
- @Override
- public Name getKey() {
- return name;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param name
+ */
+ public Property(Name name) {
+ if (null == name) {
+ throw new NullPointerException();
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the name
- */
- public Name getName() {
- return name;
- }
+ this.name = name;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the type
- */
- @Merge
- public ClassDescription getType() {
- return type;
- }
+ @Override
+ public Name getKey() {
+ return name;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param type the type to set
- */
- public void setType(ClassDescription type) {
- this.type = type;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the name
+ */
+ public Name getName() {
+ return name;
+ }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the type
+ */
+ @Merge
+ public ClassDescription getType() {
+ return type;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the defaultValue
- */
- @Merge
- public String getDefaultValue() {
- return defaultValue;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param type the type to set
+ */
+ public void setType(ClassDescription type) {
+ this.type = type;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param defaultValue the defaultValue to set
- */
- public void setDefaultValue(String dafaultValue) {
- this.defaultValue = dafaultValue;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the defaultValue
+ */
+ @Merge
+ public String getDefaultValue() {
+ return defaultValue;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the suggestedValue
- */
- @Merge
- public String getSuggestedValue() {
- return suggestedValue;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param defaultValue the defaultValue to set
+ */
+ public void setDefaultValue(String dafaultValue) {
+ this.defaultValue = dafaultValue;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param suggestedValue the suggestedValue to set
- */
- public void setSuggestedValue(String suggestedValue) {
- this.suggestedValue = suggestedValue;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the suggestedValue
+ */
+ @Merge
+ public String getSuggestedValue() {
+ return suggestedValue;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the generate
- */
- @Merge
- public boolean isGenerate() {
- return generate;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param suggestedValue the suggestedValue to set
+ */
+ public void setSuggestedValue(String suggestedValue) {
+ this.suggestedValue = suggestedValue;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param generate the generate to set
- */
- public void setGenerate(boolean exists) {
- this.generate = exists;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the generate
+ */
+ @Merge
+ public boolean isGenerate() {
+ return generate;
+ }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param generate the generate to set
+ */
+ public void setGenerate(boolean exists) {
+ this.generate = exists;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the eventNames
- */
- @Merge
- public Set<EventName> getEventNames() {
- return eventNames;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the eventNames
+ */
+ @Merge
+ public Set<EventName> getEventNames() {
+ return eventNames;
+ }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param eventNames the eventNames to set
+ */
+ public void setEventNames(Set<EventName> eventNames) {
+ this.eventNames = eventNames;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param eventNames the eventNames to set
- */
- public void setEventNames(Set<EventName> eventNames) {
- this.eventNames = eventNames;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the hidden
+ */
+ public boolean isHidden() {
+ return hidden;
+ }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param hidden the hidden to set
+ */
+ public void setHidden(boolean hidden) {
+ this.hidden = hidden;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the hidden
- */
- public boolean isHidden() {
- return hidden;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the literal
+ */
+ public boolean isLiteral() {
+ return literal;
+ }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param literal the literal to set
+ */
+ public void setLiteral(boolean literal) {
+ this.literal = literal;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param hidden the hidden to set
- */
- public void setHidden(boolean hidden) {
- this.hidden = hidden;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the required
+ */
+ public boolean isRequired() {
+ return required;
+ }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param required the required to set
+ */
+ public void setRequired(boolean required) {
+ this.required = required;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the literal
- */
- public boolean isLiteral() {
- return literal;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param readOnly the readOnly to set
+ */
+ public void setReadOnly(boolean readOnly) {
+ this.readOnly = readOnly;
+ }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the readOnly
+ */
+ public boolean isReadOnly() {
+ return readOnly;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param literal the literal to set
- */
- public void setLiteral(boolean literal) {
- this.literal = literal;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the passThrough
+ */
+ public boolean isPassThrough() {
+ return passThrough;
+ }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param passThrough the passThrough to set
+ */
+ public void setPassThrough(boolean passThrough) {
+ this.passThrough = passThrough;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the required
- */
- public boolean isRequired() {
- return required;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the signature
+ */
+ @Merge(true)
+ public List<ClassDescription> getSignature() {
+ return signature;
+ }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param signature the signature to set
+ */
+ public void setSignature(List<ClassDescription> signature) {
+ this.signature = signature;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param required the required to set
- */
- public void setRequired(boolean required) {
- this.required = required;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the aliases
+ */
+ public Set<String> getAliases() {
+ return aliases;
+ }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param aliases the aliases to set
+ */
+ public void setAliases(Set<String> aliases) {
+ this.aliases = aliases;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param readOnly the readOnly to set
- */
- public void setReadOnly(boolean readOnly) {
- this.readOnly = readOnly;
- }
+ @Override
+ public void merge(Property other) {
+ ComponentLibrary.merge(this, other);
+ }
+ @Override
+ public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) throws
CdkException {
+ return visitor.visit(this, param);
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the readOnly
- */
- public boolean isReadOnly() {
- return readOnly;
- }
-
-
- /**
- * <p class="changed_added_4_0"></p>
- * @return the passThrough
- */
- public boolean isPassThrough() {
- return passThrough;
- }
-
-
- /**
- * <p class="changed_added_4_0"></p>
- * @param passThrough the passThrough to set
- */
- public void setPassThrough(boolean passThrough) {
- this.passThrough = passThrough;
- }
-
-
- /**
- * <p class="changed_added_4_0"></p>
- * @return the signature
- */
- @Merge(true)
- public List<ClassDescription> getSignature() {
- return signature;
- }
-
-
- /**
- * <p class="changed_added_4_0"></p>
- * @param signature the signature to set
- */
- public void setSignature(List<ClassDescription> signature) {
- this.signature = signature;
- }
-
-
- /**
- * <p class="changed_added_4_0"></p>
- * @return the aliases
- */
- public Set<String> getAliases() {
- return aliases;
- }
-
-
- /**
- * <p class="changed_added_4_0"></p>
- * @param aliases the aliases to set
- */
- public void setAliases(Set<String> aliases) {
- this.aliases = aliases;
- }
-
-
- @Override
- public void merge(Property other) {
- ComponentLibrary.merge(this, other);
- }
-
- @Override
- public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) throws
CdkException {
- return visitor.visit(this, param);
- }
-
+ public static final class Name extends Key {
+ public Name(String name) {
+ super(name);
+ }
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/RenderKit.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/RenderKit.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/RenderKit.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.model;
import java.util.Collection;
@@ -35,138 +37,142 @@
*
*/
@SuppressWarnings("serial")
-public class RenderKit extends ModelElementBase implements
ModelElement<RenderKit,RenderKit.Id> {
+public class RenderKit extends ModelElementBase implements ModelElement<RenderKit,
RenderKit.Id> {
+ private final SearchableCollection<Renderer, Renderer.Type> renderers = new
ModelCollection<Renderer,
+
Renderer.Type>() {
+ @Override
+ public Renderer create(Renderer.Type key) {
+ Renderer renderer = new Renderer(key);
- /**
- * <p class="changed_added_4_0"></p>
- * @author asmirnov(a)exadel.com
- *
- */
- @SuppressWarnings("serial")
- public static final class Id extends Key {
+ return renderer;
+ }
+ };
+ private final SearchableCollection<BehaviorRenderer, BehaviorRenderer.Type>
behaviorRenderers =
+ new ModelCollection<BehaviorRenderer, BehaviorRenderer.Type>() {
+ @Override
+ public BehaviorRenderer create(BehaviorRenderer.Type key) {
+ return new BehaviorRenderer(key);
+ }
+ };
- /**
- * <p class="changed_added_4_0"></p>
- * @param id
- */
- public Id(String type) {
- // Null value means default render kit.
- super(null==type?RenderKitFactory.HTML_BASIC_RENDER_KIT:type);
- }
+ private final Id id;
+ private ClassDescription renderKitClass;
- public String getId(){
- return super.getType();
- }
- }
+ public RenderKit(Id id) {
+ this.id = id;
+ }
- private final Id id;
-
- private ClassDescription renderKitClass;
-
- private final SearchableCollection<Renderer,Renderer.Type> renderers = new
ModelCollection<Renderer, Renderer.Type>() {
+ /*
+ * (non-Javadoc)
+ * @see org.richfaces.cdk.model.ModelElement#getType()
+ */
+ @Override
+ public Id getKey() {
+ return getId();
+ }
- @Override
- public Renderer create(Renderer.Type key) {
- Renderer renderer = new Renderer(key);
- return renderer;
- }
- };
-
- private final SearchableCollection<BehaviorRenderer,BehaviorRenderer.Type>
behaviorRenderers = new ModelCollection<BehaviorRenderer, BehaviorRenderer.Type>()
{
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the id
+ */
+ public Id getId() {
+ return id;
+ }
- @Override
- public BehaviorRenderer create(BehaviorRenderer.Type key) {
- BehaviorRenderer renderer = new BehaviorRenderer(key);
- return renderer;
- }
- };
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the renderKitClass
+ */
+ @Merge
+ public ClassDescription getRenderKitClass() {
+ return renderKitClass;
+ }
- public RenderKit(Id id) {
- this.id = id;
- }
-
- /* (non-Javadoc)
- * @see org.richfaces.cdk.model.ModelElement#getType()
- */
- @Override
- public Id getKey() {
- return getId();
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param renderKitClass the renderKitClass to set
+ */
+ public void setRenderKitClass(ClassDescription renderKitClass) {
+ this.renderKitClass = renderKitClass;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the id
- */
- public Id getId() {
- return id;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the renderers
+ */
+ public Collection<Renderer> getRenderers() {
+ return renderers;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the renderKitClass
- */
- @Merge
- public ClassDescription getRenderKitClass() {
- return renderKitClass;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the behaviorRenderers
+ */
+ public SearchableCollection<BehaviorRenderer, BehaviorRenderer.Type>
getBehaviorRenderers() {
+ return behaviorRenderers;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param renderKitClass the renderKitClass to set
- */
- public void setRenderKitClass(ClassDescription renderKitClass) {
- this.renderKitClass = renderKitClass;
- }
+ /*
+ * (non-Javadoc)
+ * @see
org.richfaces.cdk.model.ModelElement#accept(org.richfaces.cdk.model.LibraryVisitor,
java.lang.Object)
+ */
+ @Override
+ public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) throws
CdkException {
+ R result = visitor.visit(this, param);
- /**
- * <p class="changed_added_4_0"></p>
- * @return the renderers
- */
- public Collection<Renderer> getRenderers() {
- return renderers;
- }
+ return ComponentLibrary.accept(renderers, visitor, param, result);
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the behaviorRenderers
- */
- public SearchableCollection<BehaviorRenderer, BehaviorRenderer.Type>
getBehaviorRenderers() {
- return behaviorRenderers;
- }
+ @Override
+ public void merge(RenderKit other) {
+ renderers.merge(other.renderers);
+ ComponentLibrary.merge(this, other);
+ }
- /* (non-Javadoc)
- * @see
org.richfaces.cdk.model.ModelElement#accept(org.richfaces.cdk.model.LibraryVisitor,
java.lang.Object)
- */
- @Override
- public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) throws
CdkException {
- R result = visitor.visit(this, param);
- return ComponentLibrary.accept(renderers, visitor, param, result);
- }
+ public Renderer getOrCreateRenderer(String rendererType) {
+ Renderer.Type type = new Renderer.Type(rendererType);
- @Override
- public void merge(RenderKit other) {
- renderers.merge(other.renderers);
- ComponentLibrary.merge(this, other);
- }
+ return renderers.find(type);
+ }
- public Renderer getOrCreateRenderer(String rendererType) {
- Renderer.Type type = new Renderer.Type(rendererType);
- return renderers.find(type);
- }
+ public Renderer findOrCreateRenderer(String rendererType) {
+ Renderer.Type type = new Renderer.Type(rendererType);
- public Renderer findOrCreateRenderer(String rendererType) {
- Renderer.Type type = new Renderer.Type(rendererType);
- return renderers.findOrCreate(type);
- }
-
- public BehaviorRenderer getOrCreateBehaviorRenderer(String rendererType) {
- BehaviorRenderer.Type type = new BehaviorRenderer.Type(rendererType);
- return behaviorRenderers.find(type);
- }
+ return renderers.findOrCreate(type);
+ }
- public BehaviorRenderer findOrCreateBehaviorRenderer(String rendererType) {
- BehaviorRenderer.Type type = new BehaviorRenderer.Type(rendererType);
- return behaviorRenderers.findOrCreate(type);
- }
-
+ public BehaviorRenderer getOrCreateBehaviorRenderer(String rendererType) {
+ BehaviorRenderer.Type type = new BehaviorRenderer.Type(rendererType);
+
+ return behaviorRenderers.find(type);
+ }
+
+ public BehaviorRenderer findOrCreateBehaviorRenderer(String rendererType) {
+ BehaviorRenderer.Type type = new BehaviorRenderer.Type(rendererType);
+
+ return behaviorRenderers.findOrCreate(type);
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+ @SuppressWarnings("serial")
+ public static final class Id extends Key {
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param id
+ */
+ public Id(String type) {
+
+ // Null value means default render kit.
+ super(null == type ? RenderKitFactory.HTML_BASIC_RENDER_KIT : type);
+ }
+
+ public String getId() {
+ return super.getType();
+ }
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Renderer.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Renderer.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Renderer.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.model;
import org.richfaces.builder.model.JavaClass;
@@ -32,118 +34,113 @@
*
*/
@SuppressWarnings("serial")
-public class Renderer extends ModelElementBase implements
ModelElement<Renderer,Renderer.Type> {
+public class Renderer extends ModelElementBase implements ModelElement<Renderer,
Renderer.Type> {
+ private String family;
+ private ClassDescription rendererClass;
+ private JavaClass template;
+ private Type type;
- private Type type;
-
- private JavaClass template;
-
- private String family;
-
- private ClassDescription rendererClass;
+ public Renderer() {}
-
- public Renderer() {
- }
+ public Renderer(Type type) {
+ this.type = type;
+ }
- public Renderer(Type type) {
- this.type=type;
- }
-
- /* (non-Javadoc)
- * @see org.richfaces.cdk.model.ModelElement#getType()
- */
- public Type getKey() {
- return type;
- }
+ /*
+ * (non-Javadoc)
+ * @see org.richfaces.cdk.model.ModelElement#getType()
+ */
+ public Type getKey() {
+ return type;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param type the type to set
- */
- public void setType(Type type) {
- this.type = type;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param type the type to set
+ */
+ public void setType(Type type) {
+ this.type = type;
+ }
- public Type getType() {
- return type;
- }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the template
- */
- @Merge
- public JavaClass getTemplate() {
- return template;
- }
- /**
- * <p class="changed_added_4_0"></p>
- * @param template the template to set
- */
- public void setTemplate(JavaClass template) {
- this.template = template;
- }
+ public Type getType() {
+ return type;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the family
- */
- @Merge
- public String getFamily() {
- return family;
- }
- /**
- * <p class="changed_added_4_0"></p>
- * @param family the family to set
- */
- public void setFamily(String family) {
- this.family = family;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the template
+ */
+ @Merge
+ public JavaClass getTemplate() {
+ return template;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the rendererClass
- */
- public ClassDescription getRendererClass() {
- return rendererClass;
- }
- /**
- * <p class="changed_added_4_0"></p>
- * @param rendererClass the rendererClass to set
- */
- public void setRendererClass(ClassDescription rendererClass) {
- this.rendererClass = rendererClass;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param template the template to set
+ */
+ public void setTemplate(JavaClass template) {
+ this.template = template;
+ }
- @Override
- public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) throws
CdkException {
- return visitor.visit(this, param);
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the family
+ */
+ @Merge
+ public String getFamily() {
+ return family;
+ }
- @Override
- public void merge(Renderer other) {
- ComponentLibrary.merge(this, other);
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param family the family to set
+ */
+ public void setFamily(String family) {
+ this.family = family;
+ }
- /**
- * <p class="changed_added_4_0">Key for lookup renderer in the
model.</p>
- * @author asmirnov(a)exadel.com
- *
- */
- @SuppressWarnings("serial")
- public static class Type extends Key {
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the rendererClass
+ */
+ public ClassDescription getRendererClass() {
+ return rendererClass;
+ }
-
- /**
- * <p class="changed_added_4_0"></p>
- * TODO - use family as part of key ?
- * @param type
- */
- public Type(String type) {
- super(type);
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param rendererClass the rendererClass to set
+ */
+ public void setRendererClass(ClassDescription rendererClass) {
+ this.rendererClass = rendererClass;
+ }
+ @Override
+ public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) throws
CdkException {
+ return visitor.visit(this, param);
+ }
- }
+ @Override
+ public void merge(Renderer other) {
+ ComponentLibrary.merge(this, other);
+ }
+ /**
+ * <p class="changed_added_4_0">Key for lookup renderer in the
model.</p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+ @SuppressWarnings("serial")
+ public static class Type extends Key {
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * TODO - use family as part of key ?
+ * @param type
+ */
+ public Type(String type) {
+ super(type);
+ }
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Searchable.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Searchable.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Searchable.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -2,13 +2,12 @@
public interface Searchable<K extends Key> {
- /**
- * <p class="changed_added_4_0">Marker interface for all JSF objects:
- * {@code Validator}, {@code Converter}, {@code Behavior}, {@code
- * FacesListener}</p>
- *
- * @return the type of JSF object.
- */
- public K getKey();
-
-}
\ No newline at end of file
+ /**
+ * <p class="changed_added_4_0">Marker interface for all JSF
objects:
+ * {@code Validator}, {@code Converter}, {@code Behavior}, {@code
+ * FacesListener}</p>
+ *
+ * @return the type of JSF object.
+ */
+ public K getKey();
+}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/SearchableCollection.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/SearchableCollection.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/SearchableCollection.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.model;
import java.util.Collection;
@@ -30,34 +32,33 @@
* @author asmirnov(a)exadel.com
*
*/
-public interface SearchableCollection<E extends Searchable,K extends Key> extends
Collection<E>, Visitable,
-Mergeable<SearchableCollection<E, K>> {
-
- /**
- * <p class="changed_added_4_0">Find element in collection by
Key</p>
- * @param key
- * @return element from collection for that key, null if no such element.
- */
- public E find(K key);
-
- /**
- * <p class="changed_added_4_0">Look for ilement in collection by key.
If such element exists in collection, return that, otherwise create a new one.</p>
- * @param key
- * @return
- */
- public E findOrCreate(K key);
-
- /**
- * <p class="changed_added_4_0">Factory method used to create a
component instance.</p>
- * @param key
- * @return
- */
- E create(K key);
-
- /**
- * <p class="changed_added_4_0">Return collection of all components
keys.</p>
- * @return
- */
- public Iterable<K> keys();
+public interface SearchableCollection<E extends Searchable, K extends Key>
+ extends Collection<E>, Visitable, Mergeable<SearchableCollection<E,
K>> {
+ /**
+ * <p class="changed_added_4_0">Find element in collection by
Key</p>
+ * @param key
+ * @return element from collection for that key, null if no such element.
+ */
+ public E find(K key);
+
+ /**
+ * <p class="changed_added_4_0">Look for ilement in collection by
key. If such element exists in collection, return that, otherwise create a new
one.</p>
+ * @param key
+ * @return
+ */
+ public E findOrCreate(K key);
+
+ /**
+ * <p class="changed_added_4_0">Factory method used to create a
component instance.</p>
+ * @param key
+ * @return
+ */
+ E create(K key);
+
+ /**
+ * <p class="changed_added_4_0">Return collection of all components
keys.</p>
+ * @return
+ */
+ public Iterable<K> keys();
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Tag.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Tag.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Tag.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.model;
/**
@@ -30,36 +32,83 @@
*/
public class Tag {
- /**
- * <p class="changed_added_4_0">Tag name</p>
- */
- private String name;
+ /**
+ * <p class="changed_added_4_0">Component that the tag creates. This
in bidirectional one to one relation.</p>
+ * TODO - tag should also works with {@code Validator}, {@code Converter}, {@code
Behavior}, {@code FacesListener}
+ */
+ private Searchable component;
- /**
- * <p class="changed_added_4_0">Tag library for which that tag is
belong.
- * This is bidirectional many to one relation.</p>
- */
- private TagLibrary library;
+ /**
+ * <p class="changed_added_4_0">Jsp tag class</p>
+ */
+ private String jspClass;
- /**
- * <p class="changed_added_4_0">Facelets VDL tag handler
class.</p>
- */
- private String tagHandlerClass;
+ /**
+ * <p class="changed_added_4_0">Tag library for which that tag is
belong.
+ * This is bidirectional many to one relation.</p>
+ */
+ private TagLibrary library;
- /**
- * <p class="changed_added_4_0">Facelets VDL tag handler base class for
generation.</p>
- */
- private String tagHandlerSuperClass;
+ /**
+ * <p class="changed_added_4_0">Tag name</p>
+ */
+ private String name;
- /**
- * <p class="changed_added_4_0">Jsp tag class</p>
- */
- private String jspClass;
-
- /**
- * <p class="changed_added_4_0">Component that the tag creates. This in
bidirectional one to one relation.</p>
- * TODO - tag should also works with {@code Validator}, {@code Converter}, {@code
Behavior}, {@code FacesListener}
- */
- private Searchable component;
+ /**
+ * <p class="changed_added_4_0">Facelets VDL tag handler
class.</p>
+ */
+ private String tagHandlerClass;
+ /**
+ * <p class="changed_added_4_0">Facelets VDL tag handler base class
for generation.</p>
+ */
+ private String tagHandlerSuperClass;
+
+ public Searchable getComponent() {
+ return component;
+ }
+
+ public void setComponent(Searchable component) {
+ this.component = component;
+ }
+
+ public String getJspClass() {
+ return jspClass;
+ }
+
+ public void setJspClass(String jspClass) {
+ this.jspClass = jspClass;
+ }
+
+ public TagLibrary getLibrary() {
+ return library;
+ }
+
+ public void setLibrary(TagLibrary library) {
+ this.library = library;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getTagHandlerClass() {
+ return tagHandlerClass;
+ }
+
+ public void setTagHandlerClass(String tagHandlerClass) {
+ this.tagHandlerClass = tagHandlerClass;
+ }
+
+ public String getTagHandlerSuperClass() {
+ return tagHandlerSuperClass;
+ }
+
+ public void setTagHandlerSuperClass(String tagHandlerSuperClass) {
+ this.tagHandlerSuperClass = tagHandlerSuperClass;
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/TagLibrary.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/TagLibrary.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/TagLibrary.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.model;
import java.util.ArrayList;
@@ -32,19 +34,17 @@
*
*/
public class TagLibrary {
-
- /**
- * <p class="changed_added_4_0">Collection of tags associated with that
library</p>
- */
- private final List<Tag> tags = new ArrayList<Tag>();
-
- /**
- * <p class="changed_added_4_0"></p>
- * @return the tags
- */
- public List<Tag> getTags() {
- return tags;
- }
+ /**
+ * <p class="changed_added_4_0">Collection of tags associated with
that library</p>
+ */
+ private final List<Tag> tags = new ArrayList<Tag>();
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the tags
+ */
+ public List<Tag> getTags() {
+ return tags;
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Trackable.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Trackable.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Trackable.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -7,10 +7,9 @@
*/
public interface Trackable {
- /**
- * <p class="changed_added_4_0">Last modification time for model
information.</p>
- * @return
- */
- public long lastModified();
-
+ /**
+ * <p class="changed_added_4_0">Last modification time for model
information.</p>
+ * @return
+ */
+ public long lastModified();
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Validator.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Validator.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Validator.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.model;
import org.richfaces.cdk.CdkException;
@@ -31,34 +33,33 @@
*
*/
@SuppressWarnings("serial")
-public class Validator implements ModelElement<Validator,Key> {
+public class Validator implements ModelElement<Validator, Key> {
+ private final Key type;
- private final Key type;
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param type the type to set
+ */
+ public Validator(Key type) {
+ this.type = type;
+ }
- @Override
- public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) throws
CdkException {
- return visitor.visit(this, param);
- }
+ @Override
+ public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) throws
CdkException {
+ return visitor.visit(this, param);
+ }
- /* (non-Javadoc)
- * @see org.richfaces.cdk.model.ModelElement#getType()
- */
- public Key getKey() {
- return type;
- }
+ /*
+ * (non-Javadoc)
+ * @see org.richfaces.cdk.model.ModelElement#getType()
+ */
+ public Key getKey() {
+ return type;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param type the type to set
- */
- public Validator(Key type) {
- this.type = type;
- }
+ @Override
+ public void merge(Validator other) {
- @Override
- public void merge(Validator other) {
- // TODO Auto-generated method stub
-
- }
-
+ // TODO Auto-generated method stub
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Visitable.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Visitable.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Visitable.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -4,14 +4,13 @@
public interface Visitable {
- /**
- * <p class="changed_added_4_0"></p>
- * @param <R>
- * @param <P>
- * @param visitor
- * @param param
- * @return
- */
- public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) throws
CdkException;
-
-}
\ No newline at end of file
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param <R>
+ * @param <P>
+ * @param visitor
+ * @param param
+ * @return
+ */
+ public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) throws
CdkException;
+}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/package-info.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/package-info.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/package-info.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -1,22 +1,25 @@
/**
* <h2>CDK library model classes used by all generation tasks.</h2>
- * <p>CDK architecture seems like MVC-pattern implementation. The controller {@link
org.richfaces.cdk.LibraryBuilder} class
- * generates model from different sources ( Java Annotations, XML files and so on ). That
model will be used to generate all necessary
- * classes by the appropriate "renderers" that act as 'View' part of
pattern.</p>
+ * <p>CDK architecture seems like MVC-pattern implementation. The controller {@link
org.richfaces.cdk.LibraryBuilder}
+ * class generates model from different sources ( Java Annotations, XML files and so on
). That model will be used to
+ * generate all necessary classes by the appropriate "renderers" that act as
'View' part of pattern.</p>
* <p>That model:</p>
* <ul>
* <li>Contains all information about JSF library components and their
properties</li>
- * <li>Encapsulates restrictions and references for model components, therefore it
should be modified by model metods only.</li>
+ * <li>Encapsulates restrictions and references for model components, therefore it
should be modified by model metods
+ * only.</li>
* <li>Encapsulates <a
href="http://www.jboss.org/community/docs/DOC-13693">CDK naming
conventions</a></li>
* <li>Provides 'Visitor' pattern methods. see {@link LibraryVisitor} for
reference.</li>
* </ul>
- *
+ *
*/
@XmlAccessorType(XmlAccessType.NONE)
-(a)javax.xml.bind.annotation.XmlSchema(namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE,
- xmlns = { @javax.xml.bind.annotation.XmlNs( prefix = "cdk",
- namespaceURI = ComponentLibrary.CDK_EXTENSIONS_NAMESPACE ) })
+(a)javax.xml.bind.annotation.XmlSchema(
+ namespace = ComponentLibrary.FACES_CONFIG_NAMESPACE,
+ xmlns = {(a)javax.xml.bind.annotation.XmlNs(prefix = "cdk", namespaceURI =
ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)}
+)
package org.richfaces.cdk.model;
+
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAccessType;
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/package-info.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/package-info.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/package-info.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -1,7 +1,6 @@
+
/**
* <h2>Public CDK API classes.</h2>
- *
+ *
*/
package org.richfaces.cdk;
-
-
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/ELReflectionUtils.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/ELReflectionUtils.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/ELReflectionUtils.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -18,6 +18,9 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
+
package org.richfaces.cdk.parser.el;
import java.beans.BeanInfo;
@@ -25,10 +28,12 @@
import java.beans.IntrospectionException;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
+
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
+
import java.util.HashMap;
import java.util.Map;
@@ -64,6 +69,7 @@
import org.jboss.el.parser.AstTrue;
import org.jboss.el.parser.AstValue;
import org.jboss.el.parser.Node;
+
import org.richfaces.cdk.parser.el.node.AstAndTreeNode;
import org.richfaces.cdk.parser.el.node.AstBracketSuffixTreeNode;
import org.richfaces.cdk.parser.el.node.AstChoiceTreeNode;
@@ -97,180 +103,192 @@
import org.richfaces.cdk.parser.el.node.AstValueTreeNode;
import org.richfaces.cdk.parser.el.node.ELNodeConstants;
import org.richfaces.cdk.parser.el.node.ITreeNode;
+
/**
- * Class, that encapsulate all functionality, related to Reflection calls, such as
loading classes, get property descriptors etc...
+ * Class, that encapsulate all functionality, related to Reflection calls, such as
loading classes, get property
+ * descriptors etc...
* @author amarkhel
- *
+ *
*/
-public class ELReflectionUtils {
+public final class ELReflectionUtils {
+ private static final Class<?>[] EMPTY_CLASS_PARAMETERS = new
Class<?>[0];
+ private static Map<String, Map<String, PropertyDescriptor>>
resolvedProperties =
+ new HashMap<String, Map<String, PropertyDescriptor>>();
- private static final Class<?>[] EMPTY_CLASS_PARAMETERS = new Class<?>[0];
-
- /**
- * This method determine type of parsed node and create wrapper for them, that extends
AbstractTreeNode. If node type is not recognized - throws ParsingException.
- * @param child - parsed node
- * @throws ParsingException - if node type is not recognized.
- * @return wrapper for parsed node(if node type is recognized), that implement ITreeNode
interface.
- */
+ private ELReflectionUtils() { }
+
+ /**
+ * This method determine type of parsed node and create wrapper for them, that
extends AbstractTreeNode.
+ * If node type is not recognized - throws ParsingException.
+ * @param child - parsed node
+ * @throws ParsingException - if node type is not recognized.
+ * @return wrapper for parsed node(if node type is recognized), that implement
ITreeNode interface.
+ */
public static ITreeNode determineNodeType(Node child) throws ParsingException {
- ITreeNode treeNode = null;
- if (child instanceof AstIdentifier) {
- treeNode = new AstIdentifierTreeNode(child);
- } else if (child instanceof AstValue) {
- treeNode = new AstValueTreeNode(child);
- } else if (child instanceof AstInteger) {
- treeNode = new AstIntegerTreeNode(child);
- } else if (child instanceof AstString) {
- treeNode = new AstStringTreeNode(child);
- } else if (child instanceof AstFunction) {
- treeNode = new AstFunctionTreeNode(child);
- } else if (child instanceof AstDeferredExpression) {
- treeNode = new AstDeferredExpressionTreeNode(child);
- } else if (child instanceof AstNot) {
- treeNode = new AstNotTreeNode(child);
- } else if (child instanceof AstChoice) {
- treeNode = new AstChoiceTreeNode(child);
- } else if (child instanceof AstEmpty) {
- treeNode = new AstEmptyTreeNode(child);
- } else if (child instanceof AstLiteralExpression) {
- treeNode = new AstLiteralTreeNode(child);
- } else if (child instanceof AstFalse) {
- treeNode = new AstFalseTreeNode(child);
- } else if (child instanceof AstTrue) {
- treeNode = new AstTrueTreeNode(child);
- } else if (child instanceof AstAnd) {
- treeNode = new AstAndTreeNode(child);
- } else if (child instanceof AstEqual) {
- treeNode = new AstEqualTreeNode(child);
- } else if (child instanceof AstGreaterThan) {
- treeNode = new AstGreaterThanTreeNode(child);
- } else if (child instanceof AstGreaterThanEqual) {
- treeNode = new AstGreaterThanEqualTreeNode(child);
- } else if (child instanceof AstLessThan) {
- treeNode = new AstLessThanTreeNode(child);
- } else if (child instanceof AstLessThanEqual) {
- treeNode = new AstLessThanEqualTreeNode(child);
- } else if (child instanceof AstNotEqual) {
- treeNode = new AstNotEqualTreeNode(child);
- } else if (child instanceof AstOr) {
- treeNode = new AstOrTreeNode(child);
- } else if (child instanceof AstDiv) {
- treeNode = new AstDivTreeNode(child);
- } else if (child instanceof AstMult) {
- treeNode = new AstMultTreeNode(child);
- } else if (child instanceof AstMod) {
- treeNode = new AstModTreeNode(child);
- } else if (child instanceof AstPlus) {
- treeNode = new AstPlusTreeNode(child);
- } else if (child instanceof AstMinus) {
- treeNode = new AstMinusTreeNode(child);
- } else if (child instanceof AstBracketSuffix) {
- treeNode = new AstBracketSuffixTreeNode(child);
- } else if (child instanceof AstNegative) {
- treeNode = new AstNegativeTreeNode(child);
- } else if (child instanceof AstNull) {
- treeNode = new AstNullTreeNode(child);
- } else if (child instanceof AstFloatingPoint) {
- treeNode = new AstFloatingPointTreeNode(child);
- } else if (child instanceof AstMethodSuffix) {
- treeNode = new AstMethodSuffixTreeNode(child);
- } else if (child instanceof AstPropertySuffix) {
- treeNode = new AstPropertySuffixTreeNode(child);
- } else if (child instanceof AstBracketSuffix) {
- treeNode = new AstBracketSuffixTreeNode(child);
- } else{
- throw new ParsingException("Node " + child.getImage() + " is not
recognized;");
- }
- return treeNode;
- }
+ ITreeNode treeNode = null;
+ if (child instanceof AstIdentifier) {
+ treeNode = new AstIdentifierTreeNode(child);
+ } else if (child instanceof AstValue) {
+ treeNode = new AstValueTreeNode(child);
+ } else if (child instanceof AstInteger) {
+ treeNode = new AstIntegerTreeNode(child);
+ } else if (child instanceof AstString) {
+ treeNode = new AstStringTreeNode(child);
+ } else if (child instanceof AstFunction) {
+ treeNode = new AstFunctionTreeNode(child);
+ } else if (child instanceof AstDeferredExpression) {
+ treeNode = new AstDeferredExpressionTreeNode(child);
+ } else if (child instanceof AstNot) {
+ treeNode = new AstNotTreeNode(child);
+ } else if (child instanceof AstChoice) {
+ treeNode = new AstChoiceTreeNode(child);
+ } else if (child instanceof AstEmpty) {
+ treeNode = new AstEmptyTreeNode(child);
+ } else if (child instanceof AstLiteralExpression) {
+ treeNode = new AstLiteralTreeNode(child);
+ } else if (child instanceof AstFalse) {
+ treeNode = new AstFalseTreeNode(child);
+ } else if (child instanceof AstTrue) {
+ treeNode = new AstTrueTreeNode(child);
+ } else if (child instanceof AstAnd) {
+ treeNode = new AstAndTreeNode(child);
+ } else if (child instanceof AstEqual) {
+ treeNode = new AstEqualTreeNode(child);
+ } else if (child instanceof AstGreaterThan) {
+ treeNode = new AstGreaterThanTreeNode(child);
+ } else if (child instanceof AstGreaterThanEqual) {
+ treeNode = new AstGreaterThanEqualTreeNode(child);
+ } else if (child instanceof AstLessThan) {
+ treeNode = new AstLessThanTreeNode(child);
+ } else if (child instanceof AstLessThanEqual) {
+ treeNode = new AstLessThanEqualTreeNode(child);
+ } else if (child instanceof AstNotEqual) {
+ treeNode = new AstNotEqualTreeNode(child);
+ } else if (child instanceof AstOr) {
+ treeNode = new AstOrTreeNode(child);
+ } else if (child instanceof AstDiv) {
+ treeNode = new AstDivTreeNode(child);
+ } else if (child instanceof AstMult) {
+ treeNode = new AstMultTreeNode(child);
+ } else if (child instanceof AstMod) {
+ treeNode = new AstModTreeNode(child);
+ } else if (child instanceof AstPlus) {
+ treeNode = new AstPlusTreeNode(child);
+ } else if (child instanceof AstMinus) {
+ treeNode = new AstMinusTreeNode(child);
+ } else if (child instanceof AstBracketSuffix) {
+ treeNode = new AstBracketSuffixTreeNode(child);
+ } else if (child instanceof AstNegative) {
+ treeNode = new AstNegativeTreeNode(child);
+ } else if (child instanceof AstNull) {
+ treeNode = new AstNullTreeNode(child);
+ } else if (child instanceof AstFloatingPoint) {
+ treeNode = new AstFloatingPointTreeNode(child);
+ } else if (child instanceof AstMethodSuffix) {
+ treeNode = new AstMethodSuffixTreeNode(child);
+ } else if (child instanceof AstPropertySuffix) {
+ treeNode = new AstPropertySuffixTreeNode(child);
+ } else if (child instanceof AstBracketSuffix) {
+ treeNode = new AstBracketSuffixTreeNode(child);
+ } else {
+ throw new ParsingException("Node " + child.getImage() + " is
not recognized;");
+ }
+
+ return treeNode;
+ }
+
/**
- * This method return PropertyDescriptor by specified propertyName and clazz.
- * @param clazz - class to search
- * @param propertyName - propertyName to search
- * @return property descriptor if found.
+ * This method return PropertyDescriptor by specified propertyName and clazz.
+ * @param clazz - class to search
+ * @param propertyName - propertyName to search
+ * @return property descriptor if found.
* @throws ParsingException if error occured.
- */
- private static PropertyDescriptor getPropertyDescriptor(Class<?> clazz, String
propertyName) throws ParsingException {
-
- Map<String, PropertyDescriptor> descriptors =
resolvedProperties.get(clazz.getName());
-
- if (descriptors == null) {
- descriptors = resolveProperties(clazz);
- resolvedProperties.put(clazz.getName(), descriptors);
- }
-
- return descriptors.get(propertyName);
- }
+ */
+ private static PropertyDescriptor getPropertyDescriptor(Class<?> clazz, String
propertyName)
+ throws ParsingException {
+ Map<String, PropertyDescriptor> descriptors =
resolvedProperties.get(clazz.getName());
+
+ if (descriptors == null) {
+ descriptors = resolveProperties(clazz);
+ resolvedProperties.put(clazz.getName(), descriptors);
+ }
+
+ return descriptors.get(propertyName);
+ }
+
/**
- * This method resolve all properties of specified class.
- * @param clazz - class to resolve
- * @return Map<String, PropertyDescriptor>, populated by property descriptors.
+ * This method resolve all properties of specified class.
+ * @param clazz - class to resolve
+ * @return Map<String, PropertyDescriptor>, populated by property descriptors.
* @throws ParsingException if error occured.
- */
- private static Map<String, PropertyDescriptor> resolveProperties(Class<?>
clazz) throws ParsingException {
- final Map<String, PropertyDescriptor> descriptors = new HashMap<String,
PropertyDescriptor>();
-
- new ClassWalkingLogic(clazz).walk(new ClassVisitor() {
- public void visit(Class<?> clazz) throws ParsingException {
- PropertyDescriptor[] pds = getPropertyDescriptors(clazz);
- for (PropertyDescriptor descriptor : pds) {
- descriptors.put(descriptor.getName(), descriptor);
- }
- }
- });
- return descriptors;
- }
-
- /**
- * This method load specified class.
- * @param className - class to load.
- * @throws ClassNotFoundException if class not found.
- * @return loaded class.
- */
- private static Class<?> loadClass(Class<?> className) throws
ClassNotFoundException {
- Class<?> clazz = null;
- try {
- if (className.isPrimitive()) {
- clazz = getPrimitiveWrapper(className);
- } else {
- clazz = loadClass(className.getName());
- }
- } catch (ClassNotFoundException e) {
- throw e;
- }
+ */
+ private static Map<String, PropertyDescriptor> resolveProperties(Class<?>
clazz) throws ParsingException {
+ final Map<String, PropertyDescriptor> descriptors = new HashMap<String,
PropertyDescriptor>();
- if (null == clazz) {
- throw new ClassNotFoundException(className.getName());
- }
- return clazz;
- }
-
- /**
- * This method load class by specified representation of class name..
- * @param className - string representation of class.
- * @throws ClassNotFoundException if class not found.
- * @return loaded class.
- */
- private static Class<?> loadClass(String className) throws ClassNotFoundException
{
- Class<?> clazz = null;
- try {
- clazz = Thread.currentThread().getContextClassLoader().loadClass(className);
- } catch (ClassNotFoundException e) {
- throw e;
- }
+ new ClassWalkingLogic(clazz).walk(new ClassVisitor() {
+ public void visit(Class<?> clazz) throws ParsingException {
+ PropertyDescriptor[] pds = getPropertyDescriptors(clazz);
- if (null == clazz) {
- throw new ClassNotFoundException(className);
- }
- return clazz;
- }
-
- private static Map<String, Map<String, PropertyDescriptor>>
resolvedProperties =
- new HashMap<String, Map<String,PropertyDescriptor>>();
-
+ for (PropertyDescriptor descriptor : pds) {
+ descriptors.put(descriptor.getName(), descriptor);
+ }
+ }
+ });
+
+ return descriptors;
+ }
+
/**
+ * This method load specified class.
+ * @param className - class to load.
+ * @throws ClassNotFoundException if class not found.
+ * @return loaded class.
+ */
+ private static Class<?> loadClass(Class<?> className) throws
ClassNotFoundException {
+ Class<?> clazz = null;
+
+ try {
+ if (className.isPrimitive()) {
+ clazz = getPrimitiveWrapper(className);
+ } else {
+ clazz = loadClass(className.getName());
+ }
+ } catch (ClassNotFoundException e) {
+ throw e;
+ }
+
+ if (null == clazz) {
+ throw new ClassNotFoundException(className.getName());
+ }
+
+ return clazz;
+ }
+
+ /**
+ * This method load class by specified representation of class name..
+ * @param className - string representation of class.
+ * @throws ClassNotFoundException if class not found.
+ * @return loaded class.
+ */
+ private static Class<?> loadClass(String className) throws
ClassNotFoundException {
+ Class<?> clazz = null;
+
+ try {
+ clazz = Thread.currentThread().getContextClassLoader().loadClass(className);
+ } catch (ClassNotFoundException e) {
+ throw e;
+ }
+
+ if (null == clazz) {
+ throw new ClassNotFoundException(className);
+ }
+
+ return clazz;
+ }
+
+ /**
* <p>Retrieve the property descriptors for the specified class,
* introspecting and caching them the first time a particular bean class
* is encountered.</p>
@@ -283,8 +301,7 @@
*
* @exception IllegalArgumentException if <code>beanClass</code> is null
*/
- private static PropertyDescriptor[] getPropertyDescriptors(Class<?> beanClass)
throws ParsingException {
-
+ private static PropertyDescriptor[] getPropertyDescriptors(Class<?> beanClass)
throws ParsingException {
if (beanClass == null) {
throw new IllegalArgumentException("No bean class specified");
}
@@ -294,53 +311,57 @@
// Introspect the bean and cache the generated descriptors
BeanInfo beanInfo = null;
+
try {
beanInfo = Introspector.getBeanInfo(beanClass);
} catch (IntrospectionException e) {
- return (new PropertyDescriptor[0]);
+ return new PropertyDescriptor[0];
}
+
descriptors = beanInfo.getPropertyDescriptors();
+
if (descriptors == null) {
descriptors = new PropertyDescriptor[0];
}
+
for (int i = 0; i < descriptors.length; i++) {
if (descriptors[i] instanceof IndexedPropertyDescriptor) {
- IndexedPropertyDescriptor descriptor =
(IndexedPropertyDescriptor)descriptors[i];
- String propName = descriptor.getName().substring(0, 1).toUpperCase() +
- descriptor.getName().substring(1);
+ IndexedPropertyDescriptor descriptor = (IndexedPropertyDescriptor)
descriptors[i];
+ String propName = descriptor.getName().substring(0, 1).toUpperCase()
+ + descriptor.getName().substring(1);
if (descriptor.getReadMethod() == null) {
String methodName = descriptor.getIndexedReadMethod() != null
- ? descriptor.getIndexedReadMethod().getName()
- : "get" + propName;
- Method readMethod = getMatchingAccessibleMethod(beanClass,
- methodName,
- EMPTY_CLASS_PARAMETERS);
+ ? descriptor.getIndexedReadMethod().getName() :
"get" + propName;
+ Method readMethod = getMatchingAccessibleMethod(beanClass,
methodName, EMPTY_CLASS_PARAMETERS);
+
if (readMethod != null) {
try {
descriptor.setReadMethod(readMethod);
- } catch(Exception e) {
- }
+ } catch (Exception e) {
+
+ // TODO Refactoring
+ }
}
}
}
}
- return (descriptors);
+ return descriptors;
}
-
+
/**
* <p>Find an accessible method that matches the given name and has compatible
parameters.
- * Compatible parameters mean that every method parameter is assignable from
+ * Compatible parameters mean that every method parameter is assignable from
* the given parameters.
- * In other words, it finds a method with the given name
+ * In other words, it finds a method with the given name
* that will take the parameters given.<p>
*
- * <p>This method is slightly undeterminstic since it loops
+ * <p>This method is slightly undeterminstic since it loops
* through methods names and return the first matching method.</p>
- *
- * <p>This method is used by
- * {@link
+ *
+ * <p>This method is used by
+ * {@link
* #invokeMethod(Object object,String methodName,Object [] args,Class[]
parameterTypes)}.
*
* <p>This method can match primitive parameter by passing in wrapper classes.
@@ -349,64 +370,74 @@
*
* @param clazz find method in this class
* @param methodName find method with this name
- * @param parameterTypes find method with compatible parameters
+ * @param parameterTypes find method with compatible parameters
* @return The accessible method
* @throws ParsingException if error occured.
*/
- private static Method getMatchingAccessibleMethod(Class<?> clazz, String
methodName, Class<?>[] parameterTypes) throws ParsingException {
+ private static Method getMatchingAccessibleMethod(Class<?> clazz, String
methodName, Class<?>[] parameterTypes)
+ throws ParsingException {
+
// see if we can find the method directly
// most of the time this works and it's much faster
try {
+ Method method = clazz.getMethod(methodName, parameterTypes);
- Method method = clazz.getMethod(methodName, parameterTypes);
-
setMethodAccessible(method); // Default access superclass workaround
return method;
-
- } catch (NoSuchMethodException e) { /* SWALLOW */ }
-
- // search through all methods
+ } catch (NoSuchMethodException e) {
+
+ /* SWALLOW */
+ }
+
+ // search through all methods
int paramSize = parameterTypes.length;
Method bestMatch = null;
Method[] methods = clazz.getMethods();
float bestMatchCost = Float.MAX_VALUE;
float myCost = Float.MAX_VALUE;
- for (int i = 0, size = methods.length; i < size ; i++) {
- if (methods[i].getName().equals(methodName)) {
-
+ int size = methods.length;
+
+ for (int i = 0; i < size; i++) {
+ if (methods[i].getName().equals(methodName)) {
+
// compare parameters
- Class<?>[] methodsParams = methods[i].getParameterTypes();
+ Class<?>[] methodsParams = methods[i].getParameterTypes();
int methodParamSize = methodsParams.length;
- if (methodParamSize == paramSize) {
+
+ if (methodParamSize == paramSize) {
boolean match = true;
- for (int n = 0 ; n < methodParamSize; n++) {
- if (!isAssignmentCompatible(methodsParams[n], parameterTypes[n]))
{
+
+ for (int n = 0; n < methodParamSize; n++) {
+ if (!isAssignmentCompatible(methodsParams[n], parameterTypes[n]))
{
match = false;
+
break;
}
}
-
+
if (match) {
+
// get accessible version of method
Method method = getAccessibleMethod(clazz, methods[i]);
+
if (method != null) {
setMethodAccessible(method); // Default access superclass
workaround
- myCost =
getTotalTransformationCost(parameterTypes,method.getParameterTypes());
- if ( myCost < bestMatchCost ) {
- bestMatch = method;
- bestMatchCost = myCost;
+ myCost = getTotalTransformationCost(parameterTypes,
method.getParameterTypes());
+
+ if (myCost < bestMatchCost) {
+ bestMatch = method;
+ bestMatchCost = myCost;
}
}
-
}
}
}
}
-
- return bestMatch;
+
+ return bestMatch;
}
-
+
/**
* <p>Return an accessible method (that is, one that can be invoked via
* reflection) that implements the specified Method. If no such method
@@ -417,26 +448,28 @@
* @return The accessible method
* @throws ParsingException if error occured.
*/
- private static Method getAccessibleMethod(Class<?> clazz, Method method) throws
ParsingException {
+ private static Method getAccessibleMethod(Class<?> clazz, Method method) throws
ParsingException {
// Make sure we have a method to check
if (method == null) {
- return (null);
+ return null;
}
// If the requested method is not public we cannot call it
if (!Modifier.isPublic(method.getModifiers())) {
- return (null);
+ return null;
}
boolean sameClass = true;
+
if (clazz == null) {
clazz = method.getDeclaringClass();
} else {
sameClass = clazz.equals(method.getDeclaringClass());
+
if (!method.getDeclaringClass().isAssignableFrom(clazz)) {
- throw new IllegalArgumentException(clazz.getName() +
- " is not assignable from " +
method.getDeclaringClass().getName());
+ throw new IllegalArgumentException(clazz.getName() + " is not
assignable from "
+ +
method.getDeclaringClass().getName());
}
}
@@ -445,24 +478,24 @@
if (!sameClass &&
!Modifier.isPublic(method.getDeclaringClass().getModifiers())) {
setMethodAccessible(method); // Default access superclass workaround
}
- return (method);
+
+ return method;
}
- String methodName = method.getName();
+ String methodName = method.getName();
Class<?>[] parameterTypes = method.getParameterTypes();
// Check the implemented interfaces and subinterfaces
- method = getAccessibleMethodFromInterfaceNest(clazz, methodName,
parameterTypes);
+ method = getAccessibleMethodFromInterfaceNest(clazz, methodName,
parameterTypes);
// Check the superclass chain
if (method == null) {
method = getAccessibleMethodFromSuperclass(clazz, methodName,
parameterTypes);
}
- return (method);
+ return method;
+ }
- }
-
/**
* <p>Return an accessible method (that is, one that can be invoked via
* reflection) by scanning through the superclasses. If no such method
@@ -472,9 +505,10 @@
* @param methodName Method name of the method we wish to call
* @param parameterTypes The parameter type signatures
*/
- private static Method getAccessibleMethodFromSuperclass(Class<?> clazz, String
methodName, Class<?>[] parameterTypes) {
+ private static Method getAccessibleMethodFromSuperclass(Class<?> clazz, String
methodName,
+ Class<?>[] parameterTypes) {
+ Class<?> parentClazz = clazz.getSuperclass();
- Class<?> parentClazz = clazz.getSuperclass();
while (parentClazz != null) {
if (Modifier.isPublic(parentClazz.getModifiers())) {
try {
@@ -483,8 +517,10 @@
return null;
}
}
+
parentClazz = parentClazz.getSuperclass();
}
+
return null;
}
@@ -502,15 +538,16 @@
* @param methodName Method name of the method we wish to call
* @param parameterTypes The parameter type signatures
*/
- private static Method getAccessibleMethodFromInterfaceNest(Class<?> clazz, String
methodName, Class<?>[] parameterTypes) {
-
+ private static Method getAccessibleMethodFromInterfaceNest(Class<?> clazz,
String methodName,
+ Class<?>[] parameterTypes) {
Method method = null;
// Search up the superclass chain
for (; clazz != null; clazz = clazz.getSuperclass()) {
// Check the implemented interfaces of the parent class
- Class<?>[] interfaces = clazz.getInterfaces();
+ Class<?>[] interfaces = clazz.getInterfaces();
+
for (int i = 0; i < interfaces.length; i++) {
// Is this interface public?
@@ -522,34 +559,35 @@
try {
method = interfaces[i].getDeclaredMethod(methodName,
parameterTypes);
} catch (NoSuchMethodException e) {
- /* Swallow, if no method is found after the loop then this
+
+ /*
+ * Swallow, if no method is found after the loop then this
* method returns null.
*/
}
+
if (method != null) {
return method;
}
// Recursively check our parent interfaces
method = getAccessibleMethodFromInterfaceNest(interfaces[i], methodName,
parameterTypes);
+
if (method != null) {
return method;
}
-
}
-
}
// If we found a method return it
if (method != null) {
- return (method);
+ return method;
}
// We did not find anything
- return (null);
+ return null;
+ }
- }
-
/**
* Returns the sum of the object transformation cost for each class in the source
* argument list.
@@ -557,44 +595,48 @@
* @param destArgs The destination arguments
* @return The total transformation cost
*/
- private static float getTotalTransformationCost(Class<?>[] srcArgs,
Class<?>[] destArgs) {
+ private static float getTotalTransformationCost(Class<?>[] srcArgs,
Class<?>[] destArgs) {
+ float totalCost = 0.0f;
- float totalCost = 0.0f;
for (int i = 0; i < srcArgs.length; i++) {
- Class<?> srcClass, destClass;
- srcClass = srcArgs[i];
- destClass = destArgs[i];
+ Class<?> srcClass = srcArgs[i];
+ Class<?> destClass = destArgs[i];
+
totalCost += getObjectTransformationCost(srcClass, destClass);
}
return totalCost;
}
-
+
/**
- * Gets the number of steps required needed to turn the source class into the
- * destination class. This represents the number of steps in the object hierarchy
+ * Gets the number of steps required needed to turn the source class into the
+ * destination class. This represents the number of steps in the object hierarchy
* graph.
* @param srcClass The source class
* @param destClass The destination class
* @return The cost of transforming an object
*/
- private static float getObjectTransformationCost(Class<?> srcClass, Class<?>
destClass) {
+ private static float getObjectTransformationCost(Class<?> srcClass,
Class<?> destClass) {
float cost = 0.0f;
+
while (destClass != null && !destClass.equals(srcClass)) {
- if (destClass.isInterface() &&
isAssignmentCompatible(destClass,srcClass)) {
- // slight penalty for interface match.
- // we still want an exact match to override an interface match, but
- // an interface match should override anything where we have to get a
+ if (destClass.isInterface() && isAssignmentCompatible(destClass,
srcClass)) {
+
+ // slight penalty for interface match.
+ // we still want an exact match to override an interface match, but
+ // an interface match should override anything where we have to get a
// superclass.
cost += 0.25f;
+
break;
}
+
cost++;
destClass = destClass.getSuperclass();
}
/*
- * If the destination class is null, we've travelled all the way up to
+ * If the destination class is null, we've travelled all the way up to
* an Object match. We'll penalize this by adding 1.5 to the cost.
*/
if (destClass == null) {
@@ -603,7 +645,7 @@
return cost;
}
-
+
/**
* <p>Determine whether a type can be used as a parameter in a method
invocation.
* This method handles primitive conversions correctly.</p>
@@ -617,36 +659,40 @@
* For example, a <code>Long</code> will not match a
<code>int</code>.
*
* @param parameterType the type of parameter accepted by the method
- * @param parameterization the type of parameter being tested
+ * @param parameterization the type of parameter being tested
*
* @return true if the assignement is compatible.
*/
- private static final boolean isAssignmentCompatible(Class<?> parameterType,
Class<?> parameterization) {
+ private static boolean isAssignmentCompatible(Class<?> parameterType,
Class<?> parameterization) {
+
// try plain assignment
if (parameterType.isAssignableFrom(parameterization)) {
return true;
}
-
+
if (parameterType.isPrimitive()) {
+
// this method does *not* do widening - you must specify exactly
// is this the right behaviour?
- Class<?> parameterWrapperClazz = getPrimitiveWrapper(parameterType);
+ Class<?> parameterWrapperClazz = getPrimitiveWrapper(parameterType);
+
if (parameterWrapperClazz != null) {
return parameterWrapperClazz.equals(parameterization);
}
}
-
+
return false;
}
-
+
/**
* Gets the wrapper object class for the given primitive type class.
* For example, passing <code>boolean.class</code> returns
<code>Boolean.class</code>
* @param primitiveType the primitive type class for which a match is to be found
- * @return the wrapper type associated with the given primitive
+ * @return the wrapper type associated with the given primitive
* or null if no match is found
*/
- private static Class<?> getPrimitiveWrapper(Class<?> primitiveType) {
+ private static Class<?> getPrimitiveWrapper(Class<?> primitiveType) {
+
// does anyone know a better strategy than comparing names?
if (boolean.class.equals(primitiveType)) {
return Boolean.class;
@@ -665,11 +711,10 @@
} else if (char.class.equals(primitiveType)) {
return Character.class;
} else {
-
return null;
}
}
-
+
/**
* Try to make the method accessible
* @param method The source arguments
@@ -677,6 +722,7 @@
*/
private static void setMethodAccessible(Method method) throws ParsingException {
try {
+
//
// XXX Default access superclass workaround
//
@@ -689,17 +735,17 @@
// modifer is public.
//
// The following workaround solves the problem but will only
- // work from sufficiently privilages code.
+ // work from sufficiently privilages code.
//
// Better workarounds would be greatfully accepted.
//
method.setAccessible(true);
-
} catch (SecurityException se) {
- throw new ParsingException("Cannot setAccessible on method. Therefore
cannot use jvm access bug workaround.", se);
+ throw new ParsingException(
+ "Cannot setAccessible on method. Therefore cannot use jvm access bug
workaround.", se);
}
}
-
+
/**
* Gets the name of read method for specified property name.
* @param propertyName - property to lookup
@@ -707,74 +753,91 @@
* @throws ParsingException - if property not found or class not found.
* @return String representation of read method of specified property.
*/
- public static String getReadMethodName(String propertyName, ELVisitor visitor) throws
ParsingException{
- try{
- Class<?> clazz = loadClass(visitor.getLastVariableType());
- PropertyDescriptor propertyDescriptor = getPropertyDescriptor(clazz,
propertyName);
- if (propertyDescriptor == null) {
- throw new ParsingException("property: " + propertyName + " not
found in class: " + visitor.getLastVariableType());
- }
- Class<?> propertyType = propertyDescriptor.getPropertyType();
- visitor.setLastVariableType(propertyType);
- if (visitor.getLastVariableType().getName().compareTo(ELNodeConstants.JAVA_UTIL_MAP)
== 0) {
- Method readMethod = propertyDescriptor.getReadMethod();
- Type genericReturnType = readMethod.getGenericReturnType();
- if (genericReturnType instanceof ParameterizedType) {
- ParameterizedType type = (ParameterizedType) genericReturnType;
- Type[] typeArguments = type.getActualTypeArguments();
- visitor.setCollectionVariableType(((Class<?>) typeArguments[1]));
- }
- }
- if (visitor.getLastVariableType().getName().compareTo(ELNodeConstants.JAVA_UTIL_LIST)
== 0) {
- Method readMethod = propertyDescriptor.getReadMethod();
- Type genericReturnType = readMethod.getGenericReturnType();
- if (genericReturnType instanceof ParameterizedType) {
- ParameterizedType type = (ParameterizedType) genericReturnType;
- Type[] typeArguments = type.getActualTypeArguments();
- visitor.setCollectionVariableType(((Class<?>) typeArguments[0]));
- }
- }
- if
(visitor.getLastVariableType().getName().startsWith(ELNodeConstants.ARRAY_INDICATOR)) {
- Method readMethod = propertyDescriptor.getReadMethod();
- visitor.setCollectionVariableType(readMethod.getReturnType());
- String className = visitor.getCollectionVariableType().getName().substring(0,
- visitor.getCollectionVariableType().getName().length() - 1).substring(2);
- visitor.setCollectionVariableType(loadClass(className));
- }
- return propertyDescriptor.getReadMethod().getName();
- }catch(ClassNotFoundException cnfe){
- throw new ParsingException(cnfe.getMessage());
- }
+ public static String getReadMethodName(String propertyName, ELVisitor visitor) throws
ParsingException {
+ try {
+ Class<?> clazz = loadClass(visitor.getLastVariableType());
+ PropertyDescriptor propertyDescriptor = getPropertyDescriptor(clazz,
propertyName);
+
+ if (propertyDescriptor == null) {
+ throw new ParsingException("property: " + propertyName + "
not found in class: "
+ + visitor.getLastVariableType());
+ }
+
+ Class<?> propertyType = propertyDescriptor.getPropertyType();
+
+ visitor.setLastVariableType(propertyType);
+
+ if
(visitor.getLastVariableType().getName().compareTo(ELNodeConstants.JAVA_UTIL_MAP) == 0) {
+ Method readMethod = propertyDescriptor.getReadMethod();
+ Type genericReturnType = readMethod.getGenericReturnType();
+
+ if (genericReturnType instanceof ParameterizedType) {
+ ParameterizedType type = (ParameterizedType) genericReturnType;
+ Type[] typeArguments = type.getActualTypeArguments();
+
+ visitor.setCollectionVariableType((Class<?>)
typeArguments[1]);
+ }
+ }
+
+ if
(visitor.getLastVariableType().getName().compareTo(ELNodeConstants.JAVA_UTIL_LIST) == 0)
{
+ Method readMethod = propertyDescriptor.getReadMethod();
+ Type genericReturnType = readMethod.getGenericReturnType();
+
+ if (genericReturnType instanceof ParameterizedType) {
+ ParameterizedType type = (ParameterizedType) genericReturnType;
+ Type[] typeArguments = type.getActualTypeArguments();
+
+ visitor.setCollectionVariableType((Class<?>)
typeArguments[0]);
+ }
+ }
+
+ if
(visitor.getLastVariableType().getName().startsWith(ELNodeConstants.ARRAY_INDICATOR)) {
+ Method readMethod = propertyDescriptor.getReadMethod();
+
+ visitor.setCollectionVariableType(readMethod.getReturnType());
+
+ String className =
visitor.getCollectionVariableType().getName().substring(0,
+
visitor.getCollectionVariableType().getName().length() - 1).substring(2);
+
+ visitor.setCollectionVariableType(loadClass(className));
+ }
+
+ return propertyDescriptor.getReadMethod().getName();
+ } catch (ClassNotFoundException cnfe) {
+ throw new ParsingException(cnfe.getMessage());
+ }
}
-
- static class ClassWalkingLogic {
- private Class<?> clazz;
- public ClassWalkingLogic(Class<?> clazz) {
- super();
- this.clazz = clazz;
- }
-
- public void walk(ClassVisitor visitor) throws ParsingException {
- walkClass(clazz, visitor);
- }
-
- private void walkClass(Class<?> c, ClassVisitor visitor) throws ParsingException
{
- if (c == null || Object.class.getName().equals(c.getName())) {
- return;
- }
-
- Class<?>[] interfaces = c.getInterfaces();
- for (Class<?> class1 : interfaces) {
- walkClass(class1, visitor);
- }
- walkClass(c.getSuperclass(), visitor);
-
- visitor.visit(c);
- }
- }
-
- interface ClassVisitor {
- public void visit(Class<?> clazz) throws ParsingException;
- }
+ interface ClassVisitor {
+ public void visit(Class<?> clazz) throws ParsingException;
+ }
+
+
+ static class ClassWalkingLogic {
+ private Class<?> clazz;
+
+ public ClassWalkingLogic(Class<?> clazz) {
+ super();
+ this.clazz = clazz;
+ }
+
+ public void walk(ClassVisitor visitor) throws ParsingException {
+ walkClass(clazz, visitor);
+ }
+
+ private void walkClass(Class<?> c, ClassVisitor visitor) throws
ParsingException {
+ if (c == null || Object.class.getName().equals(c.getName())) {
+ return;
+ }
+
+ Class<?>[] interfaces = c.getInterfaces();
+
+ for (Class<?> class1 : interfaces) {
+ walkClass(class1, visitor);
+ }
+
+ walkClass(c.getSuperclass(), visitor);
+ visitor.visit(c);
+ }
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/ELVisitor.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/ELVisitor.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/ELVisitor.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -18,6 +18,9 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
+
package org.richfaces.cdk.parser.el;
import java.util.ArrayList;
@@ -27,137 +30,141 @@
import org.jboss.el.parser.AstLiteralExpression;
import org.jboss.el.parser.ELParser;
import org.jboss.el.parser.Node;
+
import org.richfaces.cdk.parser.el.node.ITreeNode;
+
/**
* Entry point for parsing EL expressions. @see parse() method.
* @author amarkhel
- *
+ *
*/
-public class ELVisitor {
+public final class ELVisitor {
+ private static ELVisitor elVisitor;
+ Class<?> collectionVariableType = null;
+ String lastIndexValue = "null";
+ Class<?> lastVariableType = null;
+ List<Object> propertyResolved = new ArrayList<Object>();
+ boolean needConversion;
- private ELVisitor() {
- }
+ private ELVisitor() {}
- private static ELVisitor elVisitor;
-
- public static ELVisitor getInstance() {
- if (elVisitor == null) {
- elVisitor = new ELVisitor();
- }
- elVisitor.refresh();
- return elVisitor;
- }
-
- String lastIndexValue = "null";
-
- Class<?> lastVariableType = null;
-
- Class<?> collectionVariableType = null;
-
- List<Object> propertyResolved = new ArrayList<Object>();
-
- boolean needConversion;
-
- public boolean isNeedConversion() {
- return needConversion;
- }
+ public static ELVisitor getInstance() {
+ if (elVisitor == null) {
+ elVisitor = new ELVisitor();
+ }
- public void setNeedConversion(boolean needConversion) {
- this.needConversion = needConversion;
- }
+ elVisitor.refresh();
- public String getLastIndexValue() {
- return lastIndexValue;
- }
+ return elVisitor;
+ }
- public void setLastIndexValue(String lastIndexValue) {
- this.lastIndexValue = lastIndexValue;
- }
+ public boolean isNeedConversion() {
+ return needConversion;
+ }
- public Class<?> getLastVariableType() {
- return lastVariableType;
- }
+ public void setNeedConversion(boolean needConversion) {
+ this.needConversion = needConversion;
+ }
- public void setLastVariableType(Class<?> lastVariableType) {
- this.lastVariableType = lastVariableType;
- }
+ public String getLastIndexValue() {
+ return lastIndexValue;
+ }
- public Class<?> getCollectionVariableType() {
- return collectionVariableType;
- }
+ public void setLastIndexValue(String lastIndexValue) {
+ this.lastIndexValue = lastIndexValue;
+ }
- public void setCollectionVariableType(Class<?> collectionVariableType) {
- this.collectionVariableType = collectionVariableType;
- }
+ public Class<?> getLastVariableType() {
+ return lastVariableType;
+ }
- /**
- * Parse specified EL expression and return Java code, that represent this expression
- * @param expression - expression to resolve
- * @param contextMap - Map<String, Class<?>> - context for search classes.
- * @return generated Java code.
- * @throws ParsingException - if error occurred during parsing.
- */
- public String parse(String expression, Map<String, Class<?>> contextMap)
throws ParsingException{
- Node ret = ELParser.parse(expression);
- return ELVisitor.getInstance().visit(ret, contextMap);
- }
-
- private String visit(Node node, Map<String, Class<?>> context) throws
ParsingException {
- int numChildren = node.jjtGetNumChildren();
- StringBuilder sb = new StringBuilder();
- for (int i = 0; i < numChildren; i++) {
- Node child = node.jjtGetChild(i);
- if(child instanceof AstLiteralExpression){
- this.setNeedConversion(true);
- }
- ITreeNode treeNode = ELReflectionUtils.determineNodeType(child);
- treeNode.visit(sb, context, this);
- if(i != numChildren -1){
- sb.append(" + ");
- }
- }
- return sb.toString();
- }
+ public void setLastVariableType(Class<?> lastVariableType) {
+ this.lastVariableType = lastVariableType;
+ }
- /**
- * Reset internal state of elVisitor instance. Called after each AstValue resolved and
parsed.
- */
- public void reset() {
- lastIndexValue = "null";
- lastVariableType = null;
- collectionVariableType = null;
- }
-
- private void refresh() {
- lastIndexValue = "null";
- lastVariableType = null;
- collectionVariableType = null;
- needConversion = false;
- propertyResolved = new ArrayList<Object>();
- }
+ public Class<?> getCollectionVariableType() {
+ return collectionVariableType;
+ }
- /**
- * This method called after parse process handle AstValue node, to include special logic
in that case.
- */
- public void setValueHandled() {
- propertyResolved.add(new Object());
- }
+ public void setCollectionVariableType(Class<?> collectionVariableType) {
+ this.collectionVariableType = collectionVariableType;
+ }
- /**
- * This method called after AstValue node is completely parsed.
- * NOTE: AstValue can be nested.
- */
- public void unSetValueHandled() {
- if(propertyResolved.size() > 0){
- propertyResolved.remove(propertyResolved.size() - 1);
- }
- }
-
- /**
- * This method determine if AstValue node now parsed, to include special logic.
- * @return true if AstValue node now parsed, otherwise -false.
- */
- public boolean isValueHandled(){
- return propertyResolved.size() > 0;
- }
+ /**
+ * Parse specified EL expression and return Java code, that represent this
expression
+ * @param expression - expression to resolve
+ * @param contextMap - Map<String, Class<?>> - context for search
classes.
+ * @return generated Java code.
+ * @throws ParsingException - if error occurred during parsing.
+ */
+ public String parse(String expression, Map<String, Class<?>> contextMap)
throws ParsingException {
+ Node ret = ELParser.parse(expression);
+
+ return ELVisitor.getInstance().visit(ret, contextMap);
+ }
+
+ private String visit(Node node, Map<String, Class<?>> context) throws
ParsingException {
+ int numChildren = node.jjtGetNumChildren();
+ StringBuilder sb = new StringBuilder();
+
+ for (int i = 0; i < numChildren; i++) {
+ Node child = node.jjtGetChild(i);
+
+ if (child instanceof AstLiteralExpression) {
+ this.setNeedConversion(true);
+ }
+
+ ITreeNode treeNode = ELReflectionUtils.determineNodeType(child);
+
+ treeNode.visit(sb, context, this);
+
+ if (i != numChildren - 1) {
+ sb.append(" + ");
+ }
+ }
+
+ return sb.toString();
+ }
+
+ /**
+ * Reset internal state of elVisitor instance. Called after each AstValue resolved
and parsed.
+ */
+ public void reset() {
+ lastIndexValue = "null";
+ lastVariableType = null;
+ collectionVariableType = null;
+ }
+
+ private void refresh() {
+ lastIndexValue = "null";
+ lastVariableType = null;
+ collectionVariableType = null;
+ needConversion = false;
+ propertyResolved = new ArrayList<Object>();
+ }
+
+ /**
+ * This method called after parse process handle AstValue node, to include special
logic in that case.
+ */
+ public void setValueHandled() {
+ propertyResolved.add(new Object());
+ }
+
+ /**
+ * This method called after AstValue node is completely parsed.
+ * NOTE: AstValue can be nested.
+ */
+ public void unSetValueHandled() {
+ if (propertyResolved.size() > 0) {
+ propertyResolved.remove(propertyResolved.size() - 1);
+ }
+ }
+
+ /**
+ * This method determine if AstValue node now parsed, to include special logic.
+ * @return true if AstValue node now parsed, otherwise -false.
+ */
+ public boolean isValueHandled() {
+ return propertyResolved.size() > 0;
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/ParsingException.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/ParsingException.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/ParsingException.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -19,40 +19,39 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.parser.el;
/**
* Parsing Exception
* @author amarkhel
- *
+ *
*/
public class ParsingException extends Exception {
+ private static final long serialVersionUID = 6045782920008419804L;
- private static final long serialVersionUID = 6045782920008419804L;
+ public ParsingException() {}
- public ParsingException() {
- }
+ /**
+ * @param message
+ */
+ public ParsingException(String message) {
+ super(message);
+ }
- /**
- * @param message
- */
- public ParsingException(String message) {
- super(message);
- }
+ /**
+ * @param cause
+ */
+ public ParsingException(Throwable cause) {
+ super(cause);
+ }
- /**
- * @param cause
- */
- public ParsingException(Throwable cause) {
- super(cause);
- }
-
- /**
- * @param message
- * @param cause
- */
- public ParsingException(String message, Throwable cause) {
- super(message, cause);
- }
-
+ /**
+ * @param message
+ * @param cause
+ */
+ public ParsingException(String message, Throwable cause) {
+ super(message, cause);
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/StringUtils.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/StringUtils.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/StringUtils.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -19,69 +19,79 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.parser.el;
-public class StringUtils {
+public final class StringUtils {
+ private StringUtils() {}
- static public String getEscapedString(final String text) {
- StringBuffer buf = new StringBuffer();
+ public static String getEscapedString(final String text) {
+ StringBuffer buf = new StringBuffer();
+ int i = 0;
- int i = 0;
- while (i < text.length()) {
- char c = text.charAt(i);
- if (isalnum(c)) {
- buf.append(c);
- } else {
- switch (c) {
- case '"':
- buf.append("\\\"");
- break;
- case '\n':
- buf.append("\\n");
- break;
- default:
- buf.append(c);
- break;
- }
- }
- i++;
- }
- return buf.toString();
- }
+ while (i < text.length()) {
+ char c = text.charAt(i);
- /**
- * Returns true if the char isalpha() or isdigit().
- */
- public static boolean isalnum(char c) {
- return (isalpha(c) || isdigit(c));
- }
+ if (isalnum(c)) {
+ buf.append(c);
+ } else {
+ switch (c) {
+ case '"' :
+ buf.append("\\\"");
- /**
- * Returns true if the char isupper() or islower().
- */
- public static boolean isalpha(char c) {
- return (isupper(c) || islower(c));
- }
+ break;
- /**
- * Returns true if the char is from 'A' to 'Z' inclusive.
- */
- public static boolean isupper(char c) {
- return ((c >= 'A') && (c <= 'Z'));
- }
+ case '\n' :
+ buf.append("\\n");
- /**
- * Returns true if the char is from 'a' to 'z' inclusive.
- */
- public static boolean islower(char c) {
- return ((c >= 'a') && (c <= 'z'));
- }
+ break;
- /**
- * Returns true if the char is from '0' to '9' inclusive.
- */
- public static boolean isdigit(char c) {
- return ((c >= '0') && (c <= '9'));
- }
+ default :
+ buf.append(c);
+ break;
+ }
+ }
+
+ i++;
+ }
+
+ return buf.toString();
+ }
+
+ /**
+ * Returns true if the char isalpha() or isdigit().
+ */
+ public static boolean isalnum(char c) {
+ return isalpha(c) || isdigit(c);
+ }
+
+ /**
+ * Returns true if the char isupper() or islower().
+ */
+ public static boolean isalpha(char c) {
+ return isupper(c) || islower(c);
+ }
+
+ /**
+ * Returns true if the char is from 'A' to 'Z' inclusive.
+ */
+ public static boolean isupper(char c) {
+ return (c >= 'A') && (c <= 'Z');
+ }
+
+ /**
+ * Returns true if the char is from 'a' to 'z' inclusive.
+ */
+ public static boolean islower(char c) {
+ return (c >= 'a') && (c <= 'z');
+ }
+
+ /**
+ * Returns true if the char is from '0' to '9' inclusive.
+ */
+ public static boolean isdigit(char c) {
+ return (c >= '0') && (c <= '9');
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AbstractArithmeticTreeNode.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AbstractArithmeticTreeNode.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AbstractArithmeticTreeNode.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -18,49 +18,53 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
+
package org.richfaces.cdk.parser.el.node;
import java.util.Map;
import org.jboss.el.parser.Node;
+
import org.richfaces.cdk.parser.el.ELVisitor;
import org.richfaces.cdk.parser.el.ParsingException;
/**
* This class extend AbstractTreeNode and wrap any Arithmetic node.
* getOperator() method must be overridden in subclasses.
- *
+ *
* @author amarkhel
- *
+ *
*/
public abstract class AbstractArithmeticTreeNode extends AbstractTreeNode {
+ public AbstractArithmeticTreeNode(Node node) {
+ super(node);
+ }
- public AbstractArithmeticTreeNode(Node node) {
- super(node);
- }
+ @Override
+ public void visit(StringBuilder sb, Map<String, Class<?>> context,
ELVisitor visitor) throws ParsingException {
+ StringBuilder sb1 = new StringBuilder();
+ StringBuilder sb2 = new StringBuilder();
+ ITreeNode node1 = getChild(0);
- @Override
- public void visit(StringBuilder sb, Map<String, Class<?>> context, ELVisitor
visitor) throws ParsingException {
- StringBuilder sb1 = new StringBuilder();
- StringBuilder sb2 = new StringBuilder();
-
- ITreeNode node1 = getChild(0);
- node1.visit(sb1, context, visitor);
- ITreeNode node2 = getChild(1);
- node2.visit(sb2, context, visitor);
- sb.append(ELNodeConstants.LEFT_BRACKET);
- sb.append(sb1);
- sb.append(getOperator());
- sb.append(sb2);
- sb.append(ELNodeConstants.RIGHT_BRACKET);
- }
+ node1.visit(sb1, context, visitor);
- /**
- * This abstract method return string representation of arithmetic operation.
- *
- * @return string representation of arithmetic operation of current node.
- *
- */
- public abstract String getOperator();
+ ITreeNode node2 = getChild(1);
+ node2.visit(sb2, context, visitor);
+ sb.append(ELNodeConstants.LEFT_BRACKET);
+ sb.append(sb1);
+ sb.append(getOperator());
+ sb.append(sb2);
+ sb.append(ELNodeConstants.RIGHT_BRACKET);
+ }
+
+ /**
+ * This abstract method return string representation of arithmetic operation.
+ *
+ * @return string representation of arithmetic operation of current node.
+ *
+ */
+ public abstract String getOperator();
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AbstractBooleanTreeNode.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AbstractBooleanTreeNode.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AbstractBooleanTreeNode.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -18,48 +18,53 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
+
package org.richfaces.cdk.parser.el.node;
import java.util.Map;
import org.jboss.el.parser.Node;
+
import org.richfaces.cdk.parser.el.ELVisitor;
import org.richfaces.cdk.parser.el.ParsingException;
+
/**
* This class extend AbstractTreeNode and wrap any Boolean node.
* getDelimiter() method must be overridden in subclasses.
- *
+ *
* @author amarkhel
- *
+ *
*/
-public abstract class AbstractBooleanTreeNode extends AbstractTreeNode{
-
- public AbstractBooleanTreeNode(Node node) {
- super(node);
- }
+public abstract class AbstractBooleanTreeNode extends AbstractTreeNode {
+ public AbstractBooleanTreeNode(Node node) {
+ super(node);
+ }
- @Override
- public void visit(StringBuilder sb, Map<String, Class<?>> context, ELVisitor
visitor) throws ParsingException {
- StringBuilder sb1 = new StringBuilder();
- StringBuilder sb2 = new StringBuilder();
-
- ITreeNode node1 = getChild(0);
- node1.visit(sb1, context, visitor);
- ITreeNode node2 = getChild(1);
- node2.visit(sb2, context, visitor);
- sb.append(ELNodeConstants.LEFT_BRACKET);
- sb.append(sb1);
- sb.append(getDelimiter());
- sb.append(sb2);
- sb.append(ELNodeConstants.RIGHT_BRACKET);
- }
+ @Override
+ public void visit(StringBuilder sb, Map<String, Class<?>> context,
ELVisitor visitor) throws ParsingException {
+ StringBuilder sb1 = new StringBuilder();
+ StringBuilder sb2 = new StringBuilder();
+ ITreeNode node1 = getChild(0);
- /**
- * This abstract method return string representation of comparison operation.
- *
- * @return string representation of comparison operation of current node.
- *
- */
- public abstract String getDelimiter();
+ node1.visit(sb1, context, visitor);
+ ITreeNode node2 = getChild(1);
+
+ node2.visit(sb2, context, visitor);
+ sb.append(ELNodeConstants.LEFT_BRACKET);
+ sb.append(sb1);
+ sb.append(getDelimiter());
+ sb.append(sb2);
+ sb.append(ELNodeConstants.RIGHT_BRACKET);
+ }
+
+ /**
+ * This abstract method return string representation of comparison operation.
+ *
+ * @return string representation of comparison operation of current node.
+ *
+ */
+ public abstract String getDelimiter();
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AbstractTreeNode.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AbstractTreeNode.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AbstractTreeNode.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -18,63 +18,69 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
+
package org.richfaces.cdk.parser.el.node;
import java.util.Map;
import org.jboss.el.parser.Node;
+
import org.richfaces.cdk.parser.el.ELReflectionUtils;
import org.richfaces.cdk.parser.el.ELVisitor;
import org.richfaces.cdk.parser.el.ParsingException;
/**
* This abstract class implement some methods of ITreeNode interface to using in
subclasses.
- *
+ *
* @author amarkhel
- *
+ *
*/
public abstract class AbstractTreeNode implements ITreeNode {
+ private Node node;
- public AbstractTreeNode(Node node){
- this.node = node;
- }
-
- private Node node;
-
- /**
- * Return node of current wrapper.
- * @return instance of org.jboss.el.parser.Node
- *
- */
- public Node getNode() {
- return node;
- }
-
- /**
- * Visit current node. Generate Java code, that represent current node.
- * @param stringBuilder instance to collect information.
- * @param context - context to resolve beans
- * @param visitor - ELVisitor
- * @throws ParsingException - if error occurred during parsing process.
- * @return instance of org.jboss.el.parser.Node
- *
- */
- public ITreeNode getChild(int index) throws ParsingException{
- Node childNode = getNode().jjtGetChild(index);
- if (null != childNode) {
- ITreeNode treeNode = ELReflectionUtils.determineNodeType(childNode);
- return treeNode;
- }else{
- throw new ParsingException("Child node not found of node " +
node.getImage());
- }
- }
-
- /**
- * Return child of wrapped node by specified index. Abstract operation to override in
subclasses.
- * @param index - index of child.
- * @throws ParsingException - if error occurred(child not found).
- * @return wrapper for child
- *
- */
- public abstract void visit(StringBuilder sb, Map<String, Class<?>> context,
ELVisitor visitor) throws ParsingException;
+ public AbstractTreeNode(Node node) {
+ this.node = node;
+ }
+
+ /**
+ * Return node of current wrapper.
+ * @return instance of org.jboss.el.parser.Node
+ *
+ */
+ public Node getNode() {
+ return node;
+ }
+
+ /**
+ * Visit current node. Generate Java code, that represent current node.
+ * @param stringBuilder instance to collect information.
+ * @param context - context to resolve beans
+ * @param visitor - ELVisitor
+ * @throws ParsingException - if error occurred during parsing process.
+ * @return instance of org.jboss.el.parser.Node
+ *
+ */
+ public ITreeNode getChild(int index) throws ParsingException {
+ Node childNode = getNode().jjtGetChild(index);
+
+ if (null != childNode) {
+ ITreeNode treeNode = ELReflectionUtils.determineNodeType(childNode);
+
+ return treeNode;
+ } else {
+ throw new ParsingException("Child node not found of node " +
node.getImage());
+ }
+ }
+
+ /**
+ * Return child of wrapped node by specified index. Abstract operation to override in
subclasses.
+ * @param index - index of child.
+ * @throws ParsingException - if error occurred(child not found).
+ * @return wrapper for child
+ *
+ */
+ public abstract void visit(StringBuilder sb, Map<String, Class<?>>
context, ELVisitor visitor)
+ throws ParsingException;
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstAndTreeNode.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstAndTreeNode.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstAndTreeNode.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -18,24 +18,26 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
+
package org.richfaces.cdk.parser.el.node;
import org.jboss.el.parser.Node;
+
/**
* This class extend AbstractTreeNode and wrap AstAnd node.
- *
+ *
* @author amarkhel
- *
+ *
*/
-public class AstAndTreeNode extends AbstractBooleanTreeNode{
+public class AstAndTreeNode extends AbstractBooleanTreeNode {
+ public AstAndTreeNode(Node node) {
+ super(node);
+ }
- public AstAndTreeNode(Node node) {
- super(node);
- }
-
- @Override
- public String getDelimiter() {
- return ELNodeConstants.AND_DELIMITER;
- }
-
+ @Override
+ public String getDelimiter() {
+ return ELNodeConstants.AND_DELIMITER;
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstBracketSuffixTreeNode.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstBracketSuffixTreeNode.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstBracketSuffixTreeNode.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -18,56 +18,64 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
+
package org.richfaces.cdk.parser.el.node;
import java.util.Map;
import org.jboss.el.parser.Node;
+
import org.richfaces.cdk.parser.el.ELVisitor;
import org.richfaces.cdk.parser.el.ParsingException;
+
/**
* This class extend AbstractTreeNode and wrap AstBracketSuffix node.
- *
+ *
* @author amarkhel
- *
+ *
*/
public class AstBracketSuffixTreeNode extends AbstractTreeNode {
+ public AstBracketSuffixTreeNode(Node node) {
+ super(node);
+ }
- public AstBracketSuffixTreeNode(Node node) {
- super(node);
- }
+ @Override
+ public void visit(StringBuilder sb, Map<String, Class<?>> context,
ELVisitor visitor) throws ParsingException {
+ ITreeNode node = getChild(0);
- @Override
- public void visit(StringBuilder sb, Map<String, Class<?>> context, ELVisitor
visitor) throws ParsingException {
- ITreeNode node = getChild(0);
- node.visit(sb, context, visitor);
- String bracketSuffix = sb.toString();
- if(visitor.isValueHandled()){
- sb.setLength(0);
- if (visitor.getLastVariableType() != null) {
- if
(visitor.getLastVariableType().getName().startsWith(ELNodeConstants.ARRAY_INDICATOR)) {
- sb.append(ELNodeConstants.LEFT_SQUARE_BRACKET);
- sb.append(bracketSuffix);
- sb.append(ELNodeConstants.RIGHT_SQUARE_BRACKET);
- visitor.setLastVariableType(visitor.getCollectionVariableType());
- }
- if
((visitor.getLastVariableType().getName().compareTo(ELNodeConstants.JAVA_UTIL_LIST) == 0)
- ||
(visitor.getLastVariableType().getName().compareTo(ELNodeConstants.JAVA_UTIL_MAP) == 0))
{
- sb.append(ELNodeConstants.GET_FUNCTION);
- sb.append(ELNodeConstants.LEFT_BRACKET);
- sb.append(bracketSuffix);
- sb.append(ELNodeConstants.RIGHT_BRACKET);
- visitor.setLastVariableType(visitor.getCollectionVariableType());
- }
- } else {
- sb.append(ELNodeConstants.GET_ELELMENT_BY_INDEX_FUNCTION);
- sb.append(ELNodeConstants.LEFT_BRACKET);
- sb.append(visitor.getLastIndexValue());
- sb.append(ELNodeConstants.COMMA);
- sb.append(bracketSuffix);
- sb.append(ELNodeConstants.RIGHT_BRACKET);
- }
- }
- }
+ node.visit(sb, context, visitor);
+ String bracketSuffix = sb.toString();
+
+ if (visitor.isValueHandled()) {
+ sb.setLength(0);
+
+ if (visitor.getLastVariableType() != null) {
+ if
(visitor.getLastVariableType().getName().startsWith(ELNodeConstants.ARRAY_INDICATOR)) {
+ sb.append(ELNodeConstants.LEFT_SQUARE_BRACKET);
+ sb.append(bracketSuffix);
+ sb.append(ELNodeConstants.RIGHT_SQUARE_BRACKET);
+ visitor.setLastVariableType(visitor.getCollectionVariableType());
+ }
+
+ if
((visitor.getLastVariableType().getName().compareTo(ELNodeConstants.JAVA_UTIL_LIST) == 0)
+ ||
(visitor.getLastVariableType().getName().compareTo(ELNodeConstants.JAVA_UTIL_MAP) == 0))
{
+ sb.append(ELNodeConstants.GET_FUNCTION);
+ sb.append(ELNodeConstants.LEFT_BRACKET);
+ sb.append(bracketSuffix);
+ sb.append(ELNodeConstants.RIGHT_BRACKET);
+ visitor.setLastVariableType(visitor.getCollectionVariableType());
+ }
+ } else {
+ sb.append(ELNodeConstants.GET_ELELMENT_BY_INDEX_FUNCTION);
+ sb.append(ELNodeConstants.LEFT_BRACKET);
+ sb.append(visitor.getLastIndexValue());
+ sb.append(ELNodeConstants.COMMA);
+ sb.append(bracketSuffix);
+ sb.append(ELNodeConstants.RIGHT_BRACKET);
+ }
+ }
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstChoiceTreeNode.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstChoiceTreeNode.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstChoiceTreeNode.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -18,44 +18,51 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
+
package org.richfaces.cdk.parser.el.node;
import java.util.Map;
import org.jboss.el.parser.Node;
+
import org.richfaces.cdk.parser.el.ELVisitor;
import org.richfaces.cdk.parser.el.ParsingException;
+
/**
* This class extend AbstractTreeNode and wrap AstChoice node.
- *
+ *
* @author amarkhel
- *
+ *
*/
-public class AstChoiceTreeNode extends AbstractTreeNode{
+public class AstChoiceTreeNode extends AbstractTreeNode {
+ public AstChoiceTreeNode(Node node) {
+ super(node);
+ }
- public AstChoiceTreeNode(Node node) {
- super(node);
- }
+ @Override
+ public void visit(StringBuilder sb, Map<String, Class<?>> context,
ELVisitor visitor) throws ParsingException {
+ StringBuilder sb1 = new StringBuilder();
+ StringBuilder sb2 = new StringBuilder();
+ StringBuilder sb3 = new StringBuilder();
+ ITreeNode node1 = getChild(0);
- @Override
- public void visit(StringBuilder sb, Map<String, Class<?>> context, ELVisitor
visitor) throws ParsingException{
- StringBuilder sb1 = new StringBuilder();
- StringBuilder sb2 = new StringBuilder();
- StringBuilder sb3 = new StringBuilder();
-
- ITreeNode node1 = getChild(0);
- node1.visit(sb1, context, visitor);
- ITreeNode node2 = getChild(1);
- node2.visit(sb2, context, visitor);
- ITreeNode node3 = getChild(2);
- node3.visit(sb3, context, visitor);
- sb.append(ELNodeConstants.LEFT_BRACKET);
- sb.append(sb1);
- sb.append(ELNodeConstants.QUESTION_SIGN);
- sb.append(sb2);
- sb.append(ELNodeConstants.COLON);
- sb.append(sb3);
- sb.append(ELNodeConstants.RIGHT_BRACKET);
- }
+ node1.visit(sb1, context, visitor);
+ ITreeNode node2 = getChild(1);
+
+ node2.visit(sb2, context, visitor);
+
+ ITreeNode node3 = getChild(2);
+
+ node3.visit(sb3, context, visitor);
+ sb.append(ELNodeConstants.LEFT_BRACKET);
+ sb.append(sb1);
+ sb.append(ELNodeConstants.QUESTION_SIGN);
+ sb.append(sb2);
+ sb.append(ELNodeConstants.COLON);
+ sb.append(sb3);
+ sb.append(ELNodeConstants.RIGHT_BRACKET);
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstDeferredExpressionTreeNode.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstDeferredExpressionTreeNode.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstDeferredExpressionTreeNode.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -18,39 +18,46 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
+
package org.richfaces.cdk.parser.el.node;
import java.util.Map;
import org.jboss.el.parser.Node;
+
import org.richfaces.cdk.parser.el.ELVisitor;
import org.richfaces.cdk.parser.el.ParsingException;
+
/**
* This class extend AbstractTreeNode and wrap AstDeferredExpression node.
- *
+ *
* @author amarkhel
- *
+ *
*/
public class AstDeferredExpressionTreeNode extends AbstractTreeNode {
+ public AstDeferredExpressionTreeNode(Node node) {
+ super(node);
+ }
- public AstDeferredExpressionTreeNode(Node node) {
- super(node);
- }
+ @Override
+ public void visit(StringBuilder sb, Map<String, Class<?>> context,
ELVisitor visitor) throws ParsingException {
+ int numChildren = getNode().jjtGetNumChildren();
- @Override
- public void visit(StringBuilder sb, Map<String, Class<?>> context, ELVisitor
visitor) throws ParsingException {
- int numChildren = getNode().jjtGetNumChildren();
- for (int i = 0; i < numChildren; i++) {
- if(visitor.isNeedConversion()){
- sb.append(ELNodeConstants.CONVERT_TO_STRING_FUNCTION);
- sb.append(ELNodeConstants.LEFT_BRACKET);
- }
- ITreeNode treeNode = getChild(i);
- treeNode.visit(sb, context, visitor);
- if(visitor.isNeedConversion()){
- sb.append(ELNodeConstants.RIGHT_BRACKET);
- }
- }
- }
+ for (int i = 0; i < numChildren; i++) {
+ if (visitor.isNeedConversion()) {
+ sb.append(ELNodeConstants.CONVERT_TO_STRING_FUNCTION);
+ sb.append(ELNodeConstants.LEFT_BRACKET);
+ }
+ ITreeNode treeNode = getChild(i);
+
+ treeNode.visit(sb, context, visitor);
+
+ if (visitor.isNeedConversion()) {
+ sb.append(ELNodeConstants.RIGHT_BRACKET);
+ }
+ }
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstDivTreeNode.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstDivTreeNode.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstDivTreeNode.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -18,24 +18,26 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
+
package org.richfaces.cdk.parser.el.node;
import org.jboss.el.parser.Node;
+
/**
* This class extend AbstractTreeNode and wrap AstDiv node.
- *
+ *
* @author amarkhel
- *
+ *
*/
public class AstDivTreeNode extends AbstractArithmeticTreeNode {
+ public AstDivTreeNode(Node node) {
+ super(node);
+ }
- public AstDivTreeNode(Node node) {
- super(node);
- }
-
- @Override
- public String getOperator() {
- return ELNodeConstants.DIV_OPERATOR;
- }
-
+ @Override
+ public String getOperator() {
+ return ELNodeConstants.DIV_OPERATOR;
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstEmptyTreeNode.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstEmptyTreeNode.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstEmptyTreeNode.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -18,35 +18,38 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
+
package org.richfaces.cdk.parser.el.node;
import java.util.Map;
import org.jboss.el.parser.Node;
+
import org.richfaces.cdk.parser.el.ELVisitor;
import org.richfaces.cdk.parser.el.ParsingException;
+
/**
* This class extend AbstractTreeNode and wrap AstEmpty node.
- *
+ *
* @author amarkhel
- *
+ *
*/
-public class AstEmptyTreeNode extends AbstractTreeNode{
+public class AstEmptyTreeNode extends AbstractTreeNode {
+ public AstEmptyTreeNode(Node node) {
+ super(node);
+ }
- public AstEmptyTreeNode(Node node) {
- super(node);
- }
+ @Override
+ public void visit(StringBuilder sb, Map<String, Class<?>> context,
ELVisitor visitor) throws ParsingException {
+ StringBuilder sb1 = new StringBuilder();
+ ITreeNode treeNode = getChild(0);
- @Override
- public void visit(StringBuilder sb, Map<String, Class<?>> context, ELVisitor
visitor) throws ParsingException {
-
- StringBuilder sb1 = new StringBuilder();
- ITreeNode treeNode = getChild(0);
- treeNode.visit(sb1 , context, visitor);
- sb.append(ELNodeConstants.THIS_GET_UTILS_IS_EMPTY_FUNCTION);
- sb.append(ELNodeConstants.LEFT_BRACKET);
- sb.append(sb1);
- sb.append(ELNodeConstants.RIGHT_BRACKET);
- }
-
+ treeNode.visit(sb1, context, visitor);
+ sb.append(ELNodeConstants.THIS_GET_UTILS_IS_EMPTY_FUNCTION);
+ sb.append(ELNodeConstants.LEFT_BRACKET);
+ sb.append(sb1);
+ sb.append(ELNodeConstants.RIGHT_BRACKET);
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstEqualTreeNode.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstEqualTreeNode.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstEqualTreeNode.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -18,24 +18,26 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
+
package org.richfaces.cdk.parser.el.node;
import org.jboss.el.parser.Node;
+
/**
* This class extend AbstractTreeNode and wrap AstEqual node.
- *
+ *
* @author amarkhel
- *
+ *
*/
-public class AstEqualTreeNode extends AbstractBooleanTreeNode{
+public class AstEqualTreeNode extends AbstractBooleanTreeNode {
+ public AstEqualTreeNode(Node node) {
+ super(node);
+ }
- public AstEqualTreeNode(Node node) {
- super(node);
- }
-
- @Override
- public String getDelimiter() {
- return ELNodeConstants.EQUAL;
- }
-
+ @Override
+ public String getDelimiter() {
+ return ELNodeConstants.EQUAL;
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstFalseTreeNode.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstFalseTreeNode.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstFalseTreeNode.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -18,29 +18,31 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
+
package org.richfaces.cdk.parser.el.node;
import java.util.Map;
import org.jboss.el.parser.Node;
+
import org.richfaces.cdk.parser.el.ELVisitor;
import org.richfaces.cdk.parser.el.ParsingException;
+
/**
* This class extend AbstractTreeNode and wrap AstFalse node.
- *
+ *
* @author amarkhel
- *
+ *
*/
public class AstFalseTreeNode extends AbstractTreeNode {
+ public AstFalseTreeNode(Node node) {
+ super(node);
+ }
- public AstFalseTreeNode(Node node) {
- super(node);
- }
-
- @Override
- public void visit(StringBuilder sb, Map<String, Class<?>> context, ELVisitor
visitor)
- throws ParsingException {
- sb.append(ELNodeConstants.FALSE);
- }
-
+ @Override
+ public void visit(StringBuilder sb, Map<String, Class<?>> context,
ELVisitor visitor) throws ParsingException {
+ sb.append(ELNodeConstants.FALSE);
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstFloatingPointTreeNode.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstFloatingPointTreeNode.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstFloatingPointTreeNode.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -18,32 +18,34 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
+
package org.richfaces.cdk.parser.el.node;
import java.util.Map;
import org.jboss.el.parser.Node;
+
import org.richfaces.cdk.parser.el.ELVisitor;
import org.richfaces.cdk.parser.el.ParsingException;
+
/**
* This class extend AbstractTreeNode and wrap AstFloatingPoint node.
- *
+ *
* @author amarkhel
- *
+ *
*/
public class AstFloatingPointTreeNode extends AbstractTreeNode {
+ public AstFloatingPointTreeNode(Node node) {
+ super(node);
+ }
- public AstFloatingPointTreeNode(Node node) {
- super(node);
- }
-
- @Override
- public void visit(StringBuilder sb, Map<String, Class<?>> context, ELVisitor
visitor)
- throws ParsingException {
- sb.append(ELNodeConstants.DOUBLE_VALUE_OF_FUNCTION);
- sb.append(ELNodeConstants.LEFT_BRACKET);
- sb.append(getNode().getImage());
- sb.append(ELNodeConstants.RIGHT_BRACKET);
- }
-
+ @Override
+ public void visit(StringBuilder sb, Map<String, Class<?>> context,
ELVisitor visitor) throws ParsingException {
+ sb.append(ELNodeConstants.DOUBLE_VALUE_OF_FUNCTION);
+ sb.append(ELNodeConstants.LEFT_BRACKET);
+ sb.append(getNode().getImage());
+ sb.append(ELNodeConstants.RIGHT_BRACKET);
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstFunctionTreeNode.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstFunctionTreeNode.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstFunctionTreeNode.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -18,43 +18,54 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
+
package org.richfaces.cdk.parser.el.node;
import java.util.Map;
import org.jboss.el.parser.AstFunction;
import org.jboss.el.parser.Node;
+
import org.richfaces.cdk.parser.el.ELVisitor;
import org.richfaces.cdk.parser.el.ParsingException;
+
/**
* This class extend AbstractTreeNode and wrap AstFunction node.
- *
+ *
* @author amarkhel
- *
+ *
*/
public class AstFunctionTreeNode extends AbstractTreeNode {
+ public AstFunctionTreeNode(Node node) {
+ super(node);
+ }
- public AstFunctionTreeNode(Node node) {
- super(node);
- }
+ @Override
+ public void visit(StringBuilder sb, Map<String, Class<?>> context,
ELVisitor visitor) throws ParsingException {
+ String functionName = ((AstFunction) getNode()).getOutputName();
- @Override
- public void visit(StringBuilder sb, Map<String, Class<?>> context, ELVisitor
visitor) throws ParsingException {
- String functionName = ((AstFunction) getNode()).getOutputName();
- sb.append(ELNodeConstants.THIS_PREFIX);
- sb.append(ELNodeConstants.DOT);
- sb.append(functionName.substring(1));
- sb.append(ELNodeConstants.LEFT_BRACKET);
- int numChildren = getNode().jjtGetNumChildren();
- for (int i = 0; i < numChildren; i++) {
- ITreeNode childNode = getChild(i);
- StringBuilder sb1 = new StringBuilder();
- childNode.visit(sb1, context, visitor);
- if (i != 0) {
- sb.append(ELNodeConstants.COMMA);
- }
- sb.append(sb1);
- }
- sb.append(ELNodeConstants.RIGHT_BRACKET);
- }
+ sb.append(ELNodeConstants.THIS_PREFIX);
+ sb.append(ELNodeConstants.DOT);
+ sb.append(functionName.substring(1));
+ sb.append(ELNodeConstants.LEFT_BRACKET);
+
+ int numChildren = getNode().jjtGetNumChildren();
+
+ for (int i = 0; i < numChildren; i++) {
+ ITreeNode childNode = getChild(i);
+ StringBuilder sb1 = new StringBuilder();
+
+ childNode.visit(sb1, context, visitor);
+
+ if (i != 0) {
+ sb.append(ELNodeConstants.COMMA);
+ }
+
+ sb.append(sb1);
+ }
+
+ sb.append(ELNodeConstants.RIGHT_BRACKET);
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstGreaterThanEqualTreeNode.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstGreaterThanEqualTreeNode.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstGreaterThanEqualTreeNode.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -18,24 +18,26 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
+
package org.richfaces.cdk.parser.el.node;
import org.jboss.el.parser.Node;
+
/**
* This class extend AbstractTreeNode and wrap AstGreaterThanEqual node.
- *
+ *
* @author amarkhel
- *
+ *
*/
-public class AstGreaterThanEqualTreeNode extends AbstractBooleanTreeNode{
+public class AstGreaterThanEqualTreeNode extends AbstractBooleanTreeNode {
+ public AstGreaterThanEqualTreeNode(Node node) {
+ super(node);
+ }
- public AstGreaterThanEqualTreeNode(Node node) {
- super(node);
- }
-
- @Override
- public String getDelimiter() {
- return ELNodeConstants.GREAT_THEN_EQUAL;
- }
-
+ @Override
+ public String getDelimiter() {
+ return ELNodeConstants.GREAT_THEN_EQUAL;
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstGreaterThanTreeNode.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstGreaterThanTreeNode.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstGreaterThanTreeNode.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -18,24 +18,26 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
+
package org.richfaces.cdk.parser.el.node;
import org.jboss.el.parser.Node;
+
/**
* This class extend AbstractTreeNode and wrap AstGreaterThan node.
- *
+ *
* @author amarkhel
- *
+ *
*/
-public class AstGreaterThanTreeNode extends AbstractBooleanTreeNode{
+public class AstGreaterThanTreeNode extends AbstractBooleanTreeNode {
+ public AstGreaterThanTreeNode(Node node) {
+ super(node);
+ }
- public AstGreaterThanTreeNode(Node node) {
- super(node);
- }
-
- @Override
- public String getDelimiter() {
- return ELNodeConstants.GREAT_THEN;
- }
-
+ @Override
+ public String getDelimiter() {
+ return ELNodeConstants.GREAT_THEN;
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstIdentifierTreeNode.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstIdentifierTreeNode.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstIdentifierTreeNode.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -18,52 +18,57 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
+
package org.richfaces.cdk.parser.el.node;
import java.util.Map;
import org.jboss.el.parser.Node;
+
import org.richfaces.cdk.parser.el.ELVisitor;
import org.richfaces.cdk.parser.el.ParsingException;
+
/**
* This class extend AbstractTreeNode and wrap AstIdentifier node.
- *
+ *
* @author amarkhel
- *
+ *
*/
public class AstIdentifierTreeNode extends AbstractTreeNode {
+ public AstIdentifierTreeNode(Node node) {
+ super(node);
+ }
- public AstIdentifierTreeNode(Node node) {
- super(node);
- }
+ @Override
+ public void visit(StringBuilder sb, Map<String, Class<?>> context,
ELVisitor visitor) throws ParsingException {
+ String variableName = getNode().getImage();
- @Override
- public void visit(StringBuilder sb, Map<String, Class<?>> context, ELVisitor
visitor) throws ParsingException {
- String variableName = getNode().getImage();
- if (visitor.isValueHandled()){
- if(context.containsKey(variableName)){
- visitor.setLastVariableType(context.get(variableName));
- sb.append(variableName);
- } else {
- if(variableName.equals(ELNodeConstants.THIS_PREFIX)){
- sb.append(variableName);
- }else if(variableName.equals(ELNodeConstants.UTILS_PREFIX)){
- sb.append(ELNodeConstants.THIS_PREFIX);
- sb.append(ELNodeConstants.DOT);
- sb.append(ELNodeConstants.GET_UTILS_FUNCTION);
- sb.append(ELNodeConstants.LEFT_BRACKET);
- sb.append(ELNodeConstants.RIGHT_BRACKET);
- }else{
- throw new ParsingException("No instance found in context for identifier "
+ variableName);
- }
- }
- } else{
- sb.append(ELNodeConstants.VARIABLES_GET_VARIABLE_FUNCTION);
- sb.append(ELNodeConstants.LEFT_BRACKET);
- sb.append(ELNodeConstants.QUOTE);
- sb.append(variableName);
- sb.append(ELNodeConstants.QUOTE);
- sb.append(ELNodeConstants.RIGHT_BRACKET);
- }
- }
+ if (visitor.isValueHandled()) {
+ if (context.containsKey(variableName)) {
+ visitor.setLastVariableType(context.get(variableName));
+ sb.append(variableName);
+ } else {
+ if (variableName.equals(ELNodeConstants.THIS_PREFIX)) {
+ sb.append(variableName);
+ } else if (variableName.equals(ELNodeConstants.UTILS_PREFIX)) {
+ sb.append(ELNodeConstants.THIS_PREFIX);
+ sb.append(ELNodeConstants.DOT);
+ sb.append(ELNodeConstants.GET_UTILS_FUNCTION);
+ sb.append(ELNodeConstants.LEFT_BRACKET);
+ sb.append(ELNodeConstants.RIGHT_BRACKET);
+ } else {
+ throw new ParsingException("No instance found in context for
identifier " + variableName);
+ }
+ }
+ } else {
+ sb.append(ELNodeConstants.VARIABLES_GET_VARIABLE_FUNCTION);
+ sb.append(ELNodeConstants.LEFT_BRACKET);
+ sb.append(ELNodeConstants.QUOTE);
+ sb.append(variableName);
+ sb.append(ELNodeConstants.QUOTE);
+ sb.append(ELNodeConstants.RIGHT_BRACKET);
+ }
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstIntegerTreeNode.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstIntegerTreeNode.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstIntegerTreeNode.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -18,28 +18,31 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
+
package org.richfaces.cdk.parser.el.node;
import java.util.Map;
import org.jboss.el.parser.Node;
+
import org.richfaces.cdk.parser.el.ELVisitor;
import org.richfaces.cdk.parser.el.ParsingException;
+
/**
* This class extend AbstractTreeNode and wrap AstInteger node.
- *
+ *
* @author amarkhel
- *
+ *
*/
public class AstIntegerTreeNode extends AbstractTreeNode {
+ public AstIntegerTreeNode(Node node) {
+ super(node);
+ }
- public AstIntegerTreeNode(Node node) {
- super(node);
- }
-
- @Override
- public void visit(StringBuilder sb, Map<String, Class<?>> context, ELVisitor
visitor) throws ParsingException{
- sb.append(getNode().getImage());
- }
-
+ @Override
+ public void visit(StringBuilder sb, Map<String, Class<?>> context,
ELVisitor visitor) throws ParsingException {
+ sb.append(getNode().getImage());
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstLessThanEqualTreeNode.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstLessThanEqualTreeNode.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstLessThanEqualTreeNode.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -18,24 +18,26 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
+
package org.richfaces.cdk.parser.el.node;
import org.jboss.el.parser.Node;
+
/**
* This class extend AbstractTreeNode and wrap AstLessThanEqual node.
- *
+ *
* @author amarkhel
- *
+ *
*/
-public class AstLessThanEqualTreeNode extends AbstractBooleanTreeNode{
+public class AstLessThanEqualTreeNode extends AbstractBooleanTreeNode {
+ public AstLessThanEqualTreeNode(Node node) {
+ super(node);
+ }
- public AstLessThanEqualTreeNode(Node node) {
- super(node);
- }
-
- @Override
- public String getDelimiter() {
- return ELNodeConstants.LESS_THEN_EQUAL;
- }
-
+ @Override
+ public String getDelimiter() {
+ return ELNodeConstants.LESS_THEN_EQUAL;
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstLessThanTreeNode.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstLessThanTreeNode.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstLessThanTreeNode.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -18,24 +18,26 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
+
package org.richfaces.cdk.parser.el.node;
import org.jboss.el.parser.Node;
+
/**
* This class extend AbstractTreeNode and wrap AstLessThan node.
- *
+ *
* @author amarkhel
- *
+ *
*/
-public class AstLessThanTreeNode extends AbstractBooleanTreeNode{
+public class AstLessThanTreeNode extends AbstractBooleanTreeNode {
+ public AstLessThanTreeNode(Node node) {
+ super(node);
+ }
- public AstLessThanTreeNode(Node node) {
- super(node);
- }
-
- @Override
- public String getDelimiter() {
- return ELNodeConstants.LESS_THEN;
- }
-
+ @Override
+ public String getDelimiter() {
+ return ELNodeConstants.LESS_THEN;
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstLiteralTreeNode.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstLiteralTreeNode.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstLiteralTreeNode.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -18,33 +18,36 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
+
package org.richfaces.cdk.parser.el.node;
import java.util.Map;
import org.jboss.el.parser.Node;
+
import org.richfaces.cdk.parser.el.ELVisitor;
import org.richfaces.cdk.parser.el.ParsingException;
import org.richfaces.cdk.parser.el.StringUtils;
+
/**
* This class extend AbstractTreeNode and wrap AstLiteral node.
- *
+ *
* @author amarkhel
- *
+ *
*/
-public class AstLiteralTreeNode extends AbstractTreeNode{
+public class AstLiteralTreeNode extends AbstractTreeNode {
+ public AstLiteralTreeNode(Node node) {
+ super(node);
+ }
- public AstLiteralTreeNode(Node node) {
- super(node);
- }
-
- @Override
- public void visit(StringBuilder sb, Map<String, Class<?>> context, ELVisitor
visitor) throws ParsingException {
- if (getNode().getImage() != null) {
- sb.append(ELNodeConstants.QUOTE);
- sb.append(StringUtils.getEscapedString(getNode().getImage()));
- sb.append(ELNodeConstants.QUOTE);
- }
- }
-
+ @Override
+ public void visit(StringBuilder sb, Map<String, Class<?>> context,
ELVisitor visitor) throws ParsingException {
+ if (getNode().getImage() != null) {
+ sb.append(ELNodeConstants.QUOTE);
+ sb.append(StringUtils.getEscapedString(getNode().getImage()));
+ sb.append(ELNodeConstants.QUOTE);
+ }
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstMethodSuffixTreeNode.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstMethodSuffixTreeNode.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstMethodSuffixTreeNode.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -18,44 +18,54 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
+
package org.richfaces.cdk.parser.el.node;
import java.util.Map;
import org.jboss.el.parser.Node;
+
import org.richfaces.cdk.parser.el.ELVisitor;
import org.richfaces.cdk.parser.el.ParsingException;
+
/**
* This class extend AbstractTreeNode and wrap AstMethodSuffix node.
- *
+ *
* @author amarkhel
- *
+ *
*/
-public class AstMethodSuffixTreeNode extends AbstractTreeNode{
+public class AstMethodSuffixTreeNode extends AbstractTreeNode {
+ public AstMethodSuffixTreeNode(Node node) {
+ super(node);
+ }
- public AstMethodSuffixTreeNode(Node node) {
- super(node);
- }
+ @Override
+ public void visit(StringBuilder sb, Map<String, Class<?>> context,
ELVisitor visitor) throws ParsingException {
+ StringBuilder sb1 = new StringBuilder();
- @Override
- public void visit(StringBuilder sb, Map<String, Class<?>> context, ELVisitor
visitor) throws ParsingException {
- StringBuilder sb1 = new StringBuilder();
- sb1.append(getNode().getImage());
- sb1.append(ELNodeConstants.LEFT_BRACKET);
- int numChildren = getNode().jjtGetNumChildren();
- for (int k = 0; k < numChildren; k++) {
- StringBuilder sb2 = new StringBuilder();
- ITreeNode treeNode = getChild(k);
- treeNode.visit(sb2, context, visitor);
- sb1.append(sb2);
- if (k == numChildren - 1) {
- //Do nothing. Last argument.
- } else {
- sb1.append(ELNodeConstants.COMMA);
- }
- }
- sb1.append(ELNodeConstants.RIGHT_BRACKET);
- sb.append(sb1);
- }
+ sb1.append(getNode().getImage());
+ sb1.append(ELNodeConstants.LEFT_BRACKET);
+ int numChildren = getNode().jjtGetNumChildren();
+
+ for (int k = 0; k < numChildren; k++) {
+ StringBuilder sb2 = new StringBuilder();
+ ITreeNode treeNode = getChild(k);
+
+ treeNode.visit(sb2, context, visitor);
+ sb1.append(sb2);
+
+ if (k == numChildren - 1) {
+
+ // Do nothing. Last argument.
+ } else {
+ sb1.append(ELNodeConstants.COMMA);
+ }
+ }
+
+ sb1.append(ELNodeConstants.RIGHT_BRACKET);
+ sb.append(sb1);
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstMinusTreeNode.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstMinusTreeNode.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstMinusTreeNode.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -18,24 +18,26 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
+
package org.richfaces.cdk.parser.el.node;
import org.jboss.el.parser.Node;
+
/**
* This class extend AbstractTreeNode and wrap AstMinus node.
- *
+ *
* @author amarkhel
- *
+ *
*/
public class AstMinusTreeNode extends AbstractArithmeticTreeNode {
+ public AstMinusTreeNode(Node node) {
+ super(node);
+ }
- public AstMinusTreeNode(Node node) {
- super(node);
- }
-
- @Override
- public String getOperator() {
- return ELNodeConstants.MINUS_SIGN;
- }
-
+ @Override
+ public String getOperator() {
+ return ELNodeConstants.MINUS_SIGN;
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstModTreeNode.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstModTreeNode.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstModTreeNode.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -18,24 +18,26 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
+
package org.richfaces.cdk.parser.el.node;
import org.jboss.el.parser.Node;
+
/**
* This class extend AbstractTreeNode and wrap AstMod node.
- *
+ *
* @author amarkhel
- *
+ *
*/
public class AstModTreeNode extends AbstractArithmeticTreeNode {
+ public AstModTreeNode(Node node) {
+ super(node);
+ }
- public AstModTreeNode(Node node) {
- super(node);
- }
-
- @Override
- public String getOperator() {
- return ELNodeConstants.MOD_SIGN;
- }
-
+ @Override
+ public String getOperator() {
+ return ELNodeConstants.MOD_SIGN;
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstMultTreeNode.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstMultTreeNode.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstMultTreeNode.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -18,24 +18,26 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
+
package org.richfaces.cdk.parser.el.node;
import org.jboss.el.parser.Node;
+
/**
* This class extend AbstractTreeNode and wrap AstMult node.
- *
+ *
* @author amarkhel
- *
+ *
*/
-public class AstMultTreeNode extends AbstractArithmeticTreeNode{
+public class AstMultTreeNode extends AbstractArithmeticTreeNode {
+ public AstMultTreeNode(Node node) {
+ super(node);
+ }
- public AstMultTreeNode(Node node) {
- super(node);
- }
-
- @Override
- public String getOperator() {
- return ELNodeConstants.MULT_SIGN;
- }
-
+ @Override
+ public String getOperator() {
+ return ELNodeConstants.MULT_SIGN;
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstNegativeTreeNode.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstNegativeTreeNode.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstNegativeTreeNode.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -18,33 +18,36 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
+
package org.richfaces.cdk.parser.el.node;
import java.util.Map;
import org.jboss.el.parser.Node;
+
import org.richfaces.cdk.parser.el.ELVisitor;
import org.richfaces.cdk.parser.el.ParsingException;
+
/**
* This class extend AbstractTreeNode and wrap AstNegative node.
- *
+ *
* @author amarkhel
- *
+ *
*/
public class AstNegativeTreeNode extends AbstractTreeNode {
+ public AstNegativeTreeNode(Node node) {
+ super(node);
+ }
- public AstNegativeTreeNode(Node node) {
- super(node);
- }
+ @Override
+ public void visit(StringBuilder sb, Map<String, Class<?>> context,
ELVisitor visitor) throws ParsingException {
+ ITreeNode node = getChild(0);
+ StringBuilder sb1 = new StringBuilder();
- @Override
- public void visit(StringBuilder sb, Map<String, Class<?>> context, ELVisitor
visitor)
- throws ParsingException {
- ITreeNode node = getChild(0);
- StringBuilder sb1 = new StringBuilder();
- sb.append(ELNodeConstants.NEGATIVE);
- node.visit(sb1, context, visitor);
- sb.append(sb1);
- }
-
+ sb.append(ELNodeConstants.NEGATIVE);
+ node.visit(sb1, context, visitor);
+ sb.append(sb1);
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstNotEqualTreeNode.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstNotEqualTreeNode.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstNotEqualTreeNode.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -18,24 +18,26 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
+
package org.richfaces.cdk.parser.el.node;
import org.jboss.el.parser.Node;
+
/**
* This class extend AbstractTreeNode and wrap AstNotEqual node.
- *
+ *
* @author amarkhel
- *
+ *
*/
-public class AstNotEqualTreeNode extends AbstractBooleanTreeNode{
+public class AstNotEqualTreeNode extends AbstractBooleanTreeNode {
+ public AstNotEqualTreeNode(Node node) {
+ super(node);
+ }
- public AstNotEqualTreeNode(Node node) {
- super(node);
- }
-
- @Override
- public String getDelimiter() {
- return ELNodeConstants.NOT_EQUAL;
- }
-
+ @Override
+ public String getDelimiter() {
+ return ELNodeConstants.NOT_EQUAL;
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstNotTreeNode.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstNotTreeNode.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstNotTreeNode.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -18,34 +18,38 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
+
package org.richfaces.cdk.parser.el.node;
import java.util.Map;
import org.jboss.el.parser.Node;
+
import org.richfaces.cdk.parser.el.ELVisitor;
import org.richfaces.cdk.parser.el.ParsingException;
+
/**
* This class extend AbstractTreeNode and wrap AstNot node.
- *
+ *
* @author amarkhel
- *
+ *
*/
-public class AstNotTreeNode extends AbstractTreeNode{
+public class AstNotTreeNode extends AbstractTreeNode {
+ public AstNotTreeNode(Node node) {
+ super(node);
+ }
- public AstNotTreeNode(Node node) {
- super(node);
- }
+ @Override
+ public void visit(StringBuilder sb, Map<String, Class<?>> context,
ELVisitor visitor) throws ParsingException {
+ StringBuilder sb1 = new StringBuilder();
+ ITreeNode node1 = getChild(0);
- @Override
- public void visit(StringBuilder sb, Map<String, Class<?>> context, ELVisitor
visitor) throws ParsingException {
- StringBuilder sb1 = new StringBuilder();
- ITreeNode node1 = getChild(0);
- node1.visit(sb1, context, visitor);
- sb.append(ELNodeConstants.LEFT_BRACKET);
- sb.append(ELNodeConstants.EXCLAMATION_MARK);
- sb.append(sb1);
- sb.append(ELNodeConstants.RIGHT_BRACKET);
- }
-
+ node1.visit(sb1, context, visitor);
+ sb.append(ELNodeConstants.LEFT_BRACKET);
+ sb.append(ELNodeConstants.EXCLAMATION_MARK);
+ sb.append(sb1);
+ sb.append(ELNodeConstants.RIGHT_BRACKET);
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstNullTreeNode.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstNullTreeNode.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstNullTreeNode.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -18,29 +18,31 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
+
package org.richfaces.cdk.parser.el.node;
import java.util.Map;
import org.jboss.el.parser.Node;
+
import org.richfaces.cdk.parser.el.ELVisitor;
import org.richfaces.cdk.parser.el.ParsingException;
+
/**
* This class extend AbstractTreeNode and wrap AstNull node.
- *
+ *
* @author amarkhel
- *
+ *
*/
public class AstNullTreeNode extends AbstractTreeNode {
+ public AstNullTreeNode(Node node) {
+ super(node);
+ }
- public AstNullTreeNode(Node node) {
- super(node);
- }
-
- @Override
- public void visit(StringBuilder sb, Map<String, Class<?>> context, ELVisitor
visitor)
- throws ParsingException {
- sb.append(ELNodeConstants.NULL);
- }
-
+ @Override
+ public void visit(StringBuilder sb, Map<String, Class<?>> context,
ELVisitor visitor) throws ParsingException {
+ sb.append(ELNodeConstants.NULL);
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstOrTreeNode.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstOrTreeNode.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstOrTreeNode.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -18,24 +18,26 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
+
package org.richfaces.cdk.parser.el.node;
import org.jboss.el.parser.Node;
+
/**
* This class extend AbstractTreeNode and wrap AstOr node.
- *
+ *
* @author amarkhel
- *
+ *
*/
-public class AstOrTreeNode extends AbstractBooleanTreeNode{
+public class AstOrTreeNode extends AbstractBooleanTreeNode {
+ public AstOrTreeNode(Node node) {
+ super(node);
+ }
- public AstOrTreeNode(Node node) {
- super(node);
- }
-
- @Override
- public String getDelimiter() {
- return ELNodeConstants.OR;
- }
-
+ @Override
+ public String getDelimiter() {
+ return ELNodeConstants.OR;
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstPlusTreeNode.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstPlusTreeNode.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstPlusTreeNode.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -18,24 +18,26 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
+
package org.richfaces.cdk.parser.el.node;
import org.jboss.el.parser.Node;
+
/**
* This class extend AbstractTreeNode and wrap AstPlus node.
- *
+ *
* @author amarkhel
- *
+ *
*/
public class AstPlusTreeNode extends AbstractArithmeticTreeNode {
+ public AstPlusTreeNode(Node node) {
+ super(node);
+ }
- public AstPlusTreeNode(Node node) {
- super(node);
- }
-
- @Override
- public String getOperator() {
- return ELNodeConstants.PLUS_SIGN;
- }
-
+ @Override
+ public String getOperator() {
+ return ELNodeConstants.PLUS_SIGN;
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstPropertySuffixTreeNode.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstPropertySuffixTreeNode.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstPropertySuffixTreeNode.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -18,37 +18,43 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
+
package org.richfaces.cdk.parser.el.node;
import java.util.Map;
import org.jboss.el.parser.Node;
+
import org.richfaces.cdk.parser.el.ELReflectionUtils;
import org.richfaces.cdk.parser.el.ELVisitor;
import org.richfaces.cdk.parser.el.ParsingException;
+
/**
* This class extend AbstractTreeNode and wrap AstPropertySuffix node.
- *
+ *
* @author amarkhel
- *
+ *
*/
public class AstPropertySuffixTreeNode extends AbstractTreeNode {
+ public AstPropertySuffixTreeNode(Node node) {
+ super(node);
+ }
- public AstPropertySuffixTreeNode(Node node) {
- super(node);
- }
+ @Override
+ public void visit(StringBuilder sb, Map<String, Class<?>> context,
ELVisitor visitor) throws ParsingException {
+ String propertyName = getNode().getImage();
- @Override
- public void visit(StringBuilder sb, Map<String, Class<?>> context, ELVisitor
visitor) throws ParsingException {
- String propertyName = getNode().getImage();
- if (visitor.getLastVariableType() != null) {
- StringBuilder sb1 = new StringBuilder();
- sb1.append(ELReflectionUtils.getReadMethodName(propertyName, visitor));
- sb1.append(ELNodeConstants.LEFT_BRACKET);
- sb1.append(ELNodeConstants.RIGHT_BRACKET);
- sb.append(sb1);
- } else{
- throw new ParsingException("Property not found: " + propertyName);
- }
- }
-}
\ No newline at end of file
+ if (visitor.getLastVariableType() != null) {
+ StringBuilder sb1 = new StringBuilder();
+
+ sb1.append(ELReflectionUtils.getReadMethodName(propertyName, visitor));
+ sb1.append(ELNodeConstants.LEFT_BRACKET);
+ sb1.append(ELNodeConstants.RIGHT_BRACKET);
+ sb.append(sb1);
+ } else {
+ throw new ParsingException("Property not found: " + propertyName);
+ }
+ }
+}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstStringTreeNode.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstStringTreeNode.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstStringTreeNode.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -18,31 +18,34 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
+
package org.richfaces.cdk.parser.el.node;
import java.util.Map;
import org.jboss.el.parser.AstString;
import org.jboss.el.parser.Node;
+
import org.richfaces.cdk.parser.el.ELVisitor;
import org.richfaces.cdk.parser.el.ParsingException;
+
/**
* This class extend AbstractTreeNode and wrap AstString node.
- *
+ *
* @author amarkhel
- *
+ *
*/
public class AstStringTreeNode extends AbstractTreeNode {
+ public AstStringTreeNode(Node node) {
+ super(node);
+ }
- public AstStringTreeNode(Node node) {
- super(node);
- }
-
- @Override
- public void visit(StringBuilder sb, Map<String, Class<?>> context, ELVisitor
visitor) throws ParsingException {
- sb.append(ELNodeConstants.QUOTE);
- sb.append(((AstString)getNode()).getString());
- sb.append(ELNodeConstants.QUOTE);
- }
-
+ @Override
+ public void visit(StringBuilder sb, Map<String, Class<?>> context,
ELVisitor visitor) throws ParsingException {
+ sb.append(ELNodeConstants.QUOTE);
+ sb.append(((AstString) getNode()).getString());
+ sb.append(ELNodeConstants.QUOTE);
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstTrueTreeNode.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstTrueTreeNode.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstTrueTreeNode.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -18,29 +18,31 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
+
package org.richfaces.cdk.parser.el.node;
import java.util.Map;
import org.jboss.el.parser.Node;
+
import org.richfaces.cdk.parser.el.ELVisitor;
import org.richfaces.cdk.parser.el.ParsingException;
+
/**
* This class extend AbstractTreeNode and wrap AstTrue node.
- *
+ *
* @author amarkhel
- *
+ *
*/
-public class AstTrueTreeNode extends AbstractTreeNode{
+public class AstTrueTreeNode extends AbstractTreeNode {
+ public AstTrueTreeNode(Node node) {
+ super(node);
+ }
- public AstTrueTreeNode(Node node) {
- super(node);
- }
-
- @Override
- public void visit(StringBuilder sb, Map<String, Class<?>> context, ELVisitor
visitor)
- throws ParsingException {
- sb.append(ELNodeConstants.TRUE);
- }
-
+ @Override
+ public void visit(StringBuilder sb, Map<String, Class<?>> context,
ELVisitor visitor) throws ParsingException {
+ sb.append(ELNodeConstants.TRUE);
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstValueTreeNode.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstValueTreeNode.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstValueTreeNode.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -18,6 +18,9 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
+
package org.richfaces.cdk.parser.el.node;
import java.util.ArrayList;
@@ -25,43 +28,52 @@
import java.util.Map;
import org.jboss.el.parser.Node;
+
import org.richfaces.cdk.parser.el.ELVisitor;
import org.richfaces.cdk.parser.el.ParsingException;
+
/**
* This class extend AbstractTreeNode and wrap AstValue node.
- *
+ *
* @author amarkhel
- *
+ *
*/
public class AstValueTreeNode extends AbstractTreeNode {
+ public AstValueTreeNode(Node node) {
+ super(node);
+ }
- public AstValueTreeNode(Node node) {
- super(node);
- }
+ @Override
+ public void visit(StringBuilder sb, Map<String, Class<?>> context,
ELVisitor visitor) throws ParsingException {
+ List<String> tokens = new ArrayList<String>();
- @Override
- public void visit(StringBuilder sb, Map<String, Class<?>> context, ELVisitor
visitor) throws ParsingException {
- List<String> tokens = new ArrayList<String>();
- visitor.setValueHandled();
- for (int i = 0; i < getNode().jjtGetNumChildren(); i++) {
- StringBuilder sb1 = new StringBuilder();
- ITreeNode subChild = getChild(i);
- subChild.visit(sb1, context, visitor);
- tokens.add(sb1.toString());
- }
- if (tokens.size() != 0) {
- StringBuilder sb2 = new StringBuilder();
- for (String element : tokens) {
- if (sb2.length() != 0 &&
!element.startsWith(ELNodeConstants.LEFT_SQUARE_BRACKET)) {
- sb2.append(ELNodeConstants.DOT);
- }
- sb2.append(element);
- }
- sb.append(sb2);
- } else {
- sb.append(visitor.getLastIndexValue());
- }
- visitor.unSetValueHandled();
- visitor.reset();
- }
+ visitor.setValueHandled();
+
+ for (int i = 0; i < getNode().jjtGetNumChildren(); i++) {
+ StringBuilder sb1 = new StringBuilder();
+ ITreeNode subChild = getChild(i);
+
+ subChild.visit(sb1, context, visitor);
+ tokens.add(sb1.toString());
+ }
+
+ if (tokens.size() != 0) {
+ StringBuilder sb2 = new StringBuilder();
+
+ for (String element : tokens) {
+ if (sb2.length() != 0 &&
!element.startsWith(ELNodeConstants.LEFT_SQUARE_BRACKET)) {
+ sb2.append(ELNodeConstants.DOT);
+ }
+
+ sb2.append(element);
+ }
+
+ sb.append(sb2);
+ } else {
+ sb.append(visitor.getLastIndexValue());
+ }
+
+ visitor.unSetValueHandled();
+ visitor.reset();
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/ELNodeConstants.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/ELNodeConstants.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/ELNodeConstants.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -18,51 +18,51 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
+
package org.richfaces.cdk.parser.el.node;
-public class ELNodeConstants {
+public final class ELNodeConstants {
+ public static final String AND_DELIMITER = " && ";
+ public static final String ARRAY_INDICATOR = "[L";
+ public static final String COLON = " : ";
+ public static final String COMMA = ",";
+ public static final String CONVERT_TO_STRING_FUNCTION = "convertToString";
+ public static final String DIV_OPERATOR = " / ";
+ public static final String DOT = ".";
+ public static final String DOUBLE_VALUE_OF_FUNCTION = "Double.valueOf";
+ public static final String EQUAL = " == ";
+ public static final String EXCLAMATION_MARK = "!";
+ public static final String FALSE = "false";
+ public static final String GET_ELELMENT_BY_INDEX_FUNCTION =
"getElelmentByIndex";
+ public static final String GET_FUNCTION = "get";
+ public static final String GET_UTILS_FUNCTION = "getUtils";
+ public static final String GREAT_THEN = " > ";
+ public static final String GREAT_THEN_EQUAL = " >= ";
+ public static final String JAVA_UTIL_LIST = "java.util.List";
+ public static final String JAVA_UTIL_MAP = "java.util.Map";
+ public static final String LEFT_BRACKET = "(";
+ public static final String LEFT_SQUARE_BRACKET = "[";
+ public static final String LESS_THEN = " < ";
+ public static final String LESS_THEN_EQUAL = " <= ";
+ public static final String MINUS_SIGN = " - ";
+ public static final String MOD_SIGN = " % ";
+ public static final String MULT_SIGN = " * ";
+ public static final String NEGATIVE = "-";
+ public static final String NOT_EQUAL = " != ";
+ public static final String NULL = "null";
+ public static final String OR = " || ";
+ public static final String PLUS_SIGN = " + ";
+ public static final String QUESTION_SIGN = " ? ";
+ public static final String QUOTE = "\"";
+ public static final String RIGHT_BRACKET = ")";
+ public static final String RIGHT_SQUARE_BRACKET = "]";
+ public static final String THIS_GET_UTILS_IS_EMPTY_FUNCTION =
"this.getUtils().isEmpty";
+ public static final String THIS_PREFIX = "this";
+ public static final String TRUE = "true";
+ public static final String UTILS_PREFIX = "utils";
+ public static final String VARIABLES_GET_VARIABLE_FUNCTION =
"variables.getVariable";
- public static final String RIGHT_BRACKET = ")";
- public static final String LEFT_BRACKET = "(";
- public static final String LEFT_SQUARE_BRACKET = "[";
- public static final String DOT = ".";
- public static final String TRUE = "true";
- public static final String QUOTE = "\"";
- public static final String RIGHT_SQUARE_BRACKET = "]";
- public static final String ARRAY_INDICATOR = "[L";
- public static final String GET_FUNCTION = "get";
- public static final String COMMA = ",";
- public static final String GET_ELELMENT_BY_INDEX_FUNCTION =
"getElelmentByIndex";
- public static final String JAVA_UTIL_MAP = "java.util.Map";
- public static final String JAVA_UTIL_LIST = "java.util.List";
- public static final String PLUS_SIGN = " + ";
- public static final String OR = " || ";
- public static final String NULL = "null";
- public static final String EXCLAMATION_MARK = "!";
- public static final String NOT_EQUAL = " != ";
- public static final String NEGATIVE = "-";
- public static final String MULT_SIGN = " * ";
- public static final String MOD_SIGN = " % ";
- public static final String MINUS_SIGN = " - ";
- public static final String LESS_THEN = " < ";
- public static final String LESS_THEN_EQUAL = " <= ";
- public static final String VARIABLES_GET_VARIABLE_FUNCTION =
"variables.getVariable";
- public static final String GREAT_THEN = " > ";
- public static final String GREAT_THEN_EQUAL = " >= ";
- public static final String THIS_PREFIX = "this";
- public static final String DOUBLE_VALUE_OF_FUNCTION = "Double.valueOf";
- public static final String FALSE = "false";
- public static final String EQUAL = " == ";
- public static final String THIS_GET_UTILS_IS_EMPTY_FUNCTION =
"this.getUtils().isEmpty";
- public static final String DIV_OPERATOR = " / ";
- public static final String CONVERT_TO_STRING_FUNCTION = "convertToString";
- public static final String COLON = " : ";
- public static final String QUESTION_SIGN = " ? ";
- public static final String AND_DELIMITER = " && ";
- public static final String UTILS_PREFIX = "utils";
- public static final String GET_UTILS_FUNCTION = "getUtils";
-
- private ELNodeConstants(){
-
- }
+ private ELNodeConstants() {}
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/ITreeNode.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/ITreeNode.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/ITreeNode.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -18,46 +18,49 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
+
package org.richfaces.cdk.parser.el.node;
import java.util.Map;
import org.jboss.el.parser.Node;
+
import org.richfaces.cdk.parser.el.ELVisitor;
import org.richfaces.cdk.parser.el.ParsingException;
/**
* Interface for all wrappers of org.jboss.el.parser.Node class.
* @author amarkhel
- *
+ *
*/
-
public interface ITreeNode {
- /**
- * Return node of current wrapper.
- * @return instance of org.jboss.el.parser.Node
- *
- */
- Node getNode();
+ /**
+ * Return node of current wrapper.
+ * @return instance of org.jboss.el.parser.Node
+ *
+ */
+ Node getNode();
- /**
- * Visit current node. Generate Java code, that represent current node.
- * @param stringBuilder instance to collect information.
- * @param context - context to resolve beans
- * @param visitor - ELVisitor
- * @throws ParsingException - if error occurred during parsing process.
- * @return instance of org.jboss.el.parser.Node
- *
- */
- void visit(StringBuilder sb, Map<String, Class<?>> context, ELVisitor
visitor) throws ParsingException;
+ /**
+ * Visit current node. Generate Java code, that represent current node.
+ * @param stringBuilder instance to collect information.
+ * @param context - context to resolve beans
+ * @param visitor - ELVisitor
+ * @throws ParsingException - if error occurred during parsing process.
+ * @return instance of org.jboss.el.parser.Node
+ *
+ */
+ void visit(StringBuilder sb, Map<String, Class<?>> context, ELVisitor
visitor) throws ParsingException;
- /**
- * Return child of wrapped node by specified index
- * @param index - index of child.
- * @throws ParsingException - if error occurred(child not found).
- * @return wrapper for child
- *
- */
- ITreeNode getChild(int index) throws ParsingException;
+ /**
+ * Return child of wrapped node by specified index
+ * @param index - index of child.
+ * @throws ParsingException - if error occurred(child not found).
+ * @return wrapper for child
+ *
+ */
+ ITreeNode getChild(int index) throws ParsingException;
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/util/PropertyUtils.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/util/PropertyUtils.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/util/PropertyUtils.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.util;
import org.richfaces.cdk.model.InvalidNameException;
@@ -30,17 +32,20 @@
* @author asmirnov(a)exadel.com
*
*/
-public class PropertyUtils {
-
- public static String methodToName(String methodName) throws InvalidNameException {
- if(null != methodName ){
- if(methodName.length()>3 && Character.isUpperCase(methodName.charAt(3))
&&(methodName.startsWith("set")||methodName.startsWith("get"))){
- return Strings.firstToLowerCase(methodName.substring(3));
- } else if(methodName.length()>2 &&
Character.isUpperCase(methodName.charAt(2)) &&
methodName.startsWith("is")) {
- return Strings.firstToLowerCase(methodName.substring(2));
- }
- }
- throw new InvalidNameException("Method name "+methodName+" is not valid
bean property getter or setter");
- }
+public final class PropertyUtils {
+ private PropertyUtils() {}
+ public static String methodToName(String methodName) throws InvalidNameException {
+ if (null != methodName) {
+ if (methodName.length() > 3 &&
Character.isUpperCase(methodName.charAt(3))
+ && (methodName.startsWith("set") ||
methodName.startsWith("get"))) {
+ return Strings.firstToLowerCase(methodName.substring(3));
+ } else if (methodName.length() > 2 &&
Character.isUpperCase(methodName.charAt(2))
+ && methodName.startsWith("is")) {
+ return Strings.firstToLowerCase(methodName.substring(2));
+ }
+ }
+
+ throw new InvalidNameException("Method name " + methodName + " is
not valid bean property getter or setter");
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/util/Strings.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/util/Strings.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/util/Strings.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.util;
/**
@@ -29,57 +31,59 @@
*
*/
public final class Strings {
+ private Strings() {
- private Strings() {
- // this is utility class with static methods only.
- }
-
- /**
- * <p class="changed_added_4_0">Remove characters from string
end</p>
- * @param in input string
- * @param size number of characters to remove.
- * @return
- */
- public static String cut(String in, int size) {
- if(size >0){
- return in.substring(0, in.length()-size);
- }
- return in;
- }
-
- /**
- * <p class="changed_added_4_0">Change case of the first character to
lower, as it required by the Java Beans property and setter/getter method name
conventions:</p>
- * <p>"PropertyFoo" will be changed to
"propertyFoo"</p>
- * @param in
- * @return {@code in} with first character changed to lower case.
- */
- public static String firstToLowerCase(String in) {
- if(!isEmpty(in)){
- in = in.substring(0,1).toLowerCase()+in.substring(1);
- }
- return in;
- }
-
- /**
- * <p class="changed_added_4_0">Change case of the first character to
upper, as it required by the Java Beans property and setter/getter method name
conventions:</p>
- * <p>"propertyFoo" will be changed to
"PropertyFoo"</p>
- * @param in
- * @return {@code in} with first character changed to lower case.
- */
- public static String firstToUpperCase(String in) {
- if(!isEmpty(in)){
- in = in.substring(0,1).toUpperCase()+in.substring(1);
- }
- return in;
- }
-
- /**
- * <p class="changed_added_4_0">Check string for null or empty
value</p>
- * @param type
- * @return true if {@code type} is null or zero-length string.
- */
- public static boolean isEmpty(String type) {
- return type == null || type.length()==0;
- }
+ // this is utility class with static methods only.
+ }
+ /**
+ * <p class="changed_added_4_0">Remove characters from string
end</p>
+ * @param in input string
+ * @param size number of characters to remove.
+ * @return
+ */
+ public static String cut(String in, int size) {
+ if (size > 0) {
+ return in.substring(0, in.length() - size);
+ }
+
+ return in;
+ }
+
+ /**
+ * <p class="changed_added_4_0">Change case of the first character to
lower, as it required by the Java Beans property and setter/getter method name
conventions:</p>
+ * <p>"PropertyFoo" will be changed to
"propertyFoo"</p>
+ * @param in
+ * @return {@code in} with first character changed to lower case.
+ */
+ public static String firstToLowerCase(String in) {
+ if (!isEmpty(in)) {
+ in = in.substring(0, 1).toLowerCase() + in.substring(1);
+ }
+
+ return in;
+ }
+
+ /**
+ * <p class="changed_added_4_0">Change case of the first character to
upper, as it required by the Java Beans property and setter/getter method name
conventions:</p>
+ * <p>"propertyFoo" will be changed to
"PropertyFoo"</p>
+ * @param in
+ * @return {@code in} with first character changed to lower case.
+ */
+ public static String firstToUpperCase(String in) {
+ if (!isEmpty(in)) {
+ in = in.substring(0, 1).toUpperCase() + in.substring(1);
+ }
+
+ return in;
+ }
+
+ /**
+ * <p class="changed_added_4_0">Check string for null or empty
value</p>
+ * @param type
+ * @return true if {@code type} is null or zero-length string.
+ */
+ public static boolean isEmpty(String type) {
+ return type == null || type.length() == 0;
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/CdkEntityResolver.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/CdkEntityResolver.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/CdkEntityResolver.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.xmlconfig;
import java.io.File;
@@ -28,11 +30,13 @@
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
+
import java.net.URI;
import org.richfaces.cdk.CdkContext;
import org.richfaces.cdk.StandardSources;
import org.richfaces.cdk.CdkContext.SourceType;
+
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.ext.EntityResolver2;
@@ -44,186 +48,190 @@
* That class resolves entities used by CDK ( standard JSF schemas, extensions,
* configuration fragments.)
* </p>
- *
+ *
* @author asmirnov(a)exadel.com
- *
+ *
*/
public class CdkEntityResolver implements EntityResolver2 {
+ // configure a validating SAX2.0 parser (Xerces2)
+ public static final String JAXP_SCHEMA_LANGUAGE =
"http://java.sun.com/xml/jaxp/properties/schemaLanguage";
+ public static final String JAXP_SCHEMA_LOCATION =
"http://java.sun.com/xml/jaxp/properties/schemaSource";
+ public static final String URN_ATTRIBUTES = "urn:attributes:";
+ public static final String URN_CONFIG = "urn:config:";
+ public static final String URN_RESOURCE = "urn:resource:";
+ public static final String URN_TEMPLATES = "urn:templates:";
+ public static final String W3C_XML_SCHEMA =
"http://www.w3.org/2001/XMLSchema";
- // configure a validating SAX2.0 parser (Xerces2)
- public static final String JAXP_SCHEMA_LANGUAGE =
"http://java.sun.com/xml/jaxp/properties/schemaLanguage";
- public static final String JAXP_SCHEMA_LOCATION =
"http://java.sun.com/xml/jaxp/properties/schemaSource";
- public static final String W3C_XML_SCHEMA =
"http://www.w3.org/2001/XMLSchema";
+ private static final String RESOURCE_PREFIX = "";
+ private static final String ATTRIBUTES_PREFIX =
"META-INF/cdk/attributes/";
+ private static final String SYSTEM_PREFIX = "/META-INF/schema";
+ private static final String URN_SYSTEM = "urn:system:";
+ private static final ImmutableMap<String, String> SYSTEM_ENTITIES =
+ ImmutableMap.<String, String>builder().put(
+ "http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd",
URN_SYSTEM + "/web-facesconfig_2_0.xsd").put(
+ "http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd",
URN_SYSTEM + "/web-facesconfig_1_2.xsd").put(
+ "http://java.sun.com/xml/ns/javaee/javaee_5.xsd", URN_SYSTEM +
"/javaee_5.xsd").put(
+ "http://java.sun.com/xml/ns/javaee/javaee_web_services_1_2.xsd",
+ URN_SYSTEM + "/javaee_web_services_1_2.xsd").put(
+
"http://java.sun.com/xml/ns/javaee/javaee_web_services_client_1_2.xsd",
+ URN_SYSTEM + "/javaee_web_services_client_1_2.xsd").put(
+ "http://www.w3.org/2001/03/xml.xsd", URN_SYSTEM +
"/xml.xsd").build();
+
+ private final CdkContext context;
- private static final String URN_SYSTEM = "urn:system:";
+ public CdkEntityResolver(CdkContext context) {
+ this.context = context;
+ }
- private static final ImmutableMap<String, String> systemEntities = ImmutableMap
- .<String, String> builder()
- .put("http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd",
- URN_SYSTEM + "/web-facesconfig_2_0.xsd")
- .put("http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd",
- URN_SYSTEM + "/web-facesconfig_1_2.xsd")
- .put("http://java.sun.com/xml/ns/javaee/javaee_5.xsd",
- URN_SYSTEM + "/javaee_5.xsd")
- .put(
- "http://java.sun.com/xml/ns/javaee/javaee_web_services_1_2.xsd",
- URN_SYSTEM + "/javaee_web_services_1_2.xsd")
- .put(
- "http://java.sun.com/xml/ns/javaee/javaee_web_services_client_1_2.xsd",
- URN_SYSTEM + "/javaee_web_services_client_1_2.xsd")
- .put("http://www.w3.org/2001/03/xml.xsd", URN_SYSTEM +
"/xml.xsd")
- .build();
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.xml.sax.ext.EntityResolver2#getExternalSubset(java.lang.String,
+ * java.lang.String)
+ */
+ @Override
+ public InputSource getExternalSubset(String name, String baseURI) throws
SAXException, IOException {
- private static final String SYSTEM_PREFIX = "/META-INF/schema";
+ // do nothing because we use XML schema only.
+ return null;
+ }
- public static final String URN_RESOURCE = "urn:resource:";
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.xml.sax.ext.EntityResolver2#resolveEntity(java.lang.String,
+ * java.lang.String, java.lang.String, java.lang.String)
+ */
+ @Override
+ public InputSource resolveEntity(String name, String publicId, String baseURI, String
systemId)
+ throws SAXException, IOException {
+
+ String temSystemId = systemId;
- private static final String RESOURCE_PREFIX = "";
+ // perform conversions with baseURI
+ if (null != temSystemId) {
+ try {
+ URI sourceURI = URI.create(temSystemId);
- public static final String URN_CONFIG = "urn:config:";
+ if (!sourceURI.isAbsolute() && null != baseURI) {
+ temSystemId = URI.create(baseURI).resolve(sourceURI).toString();
+ }
+ } catch (IllegalArgumentException e) {
- public static final String URN_TEMPLATES = "urn:templates:";
+ // Ignore ?
+ }
+ }
- public static final String URN_ATTRIBUTES = "urn:attributes:";
+ return resolveSystemId(temSystemId);
+ }
- private static final String ATTRIBUTES_PREFIX = "META-INF/cdk/attributes/";
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.xml.sax.EntityResolver#resolveEntity(java.lang.String,
+ * java.lang.String)
+ */
+ @Override
+ public InputSource resolveEntity(String publicId, String systemId) throws
SAXException, IOException {
+ InputSource entity = null;
- private final CdkContext context;
+ if (null != systemId) {
+ entity = resolveSystemId(systemId);
+ }
- public CdkEntityResolver(CdkContext context) {
- this.context = context;
+ return entity;
+ }
- }
+ protected InputSource resolveSystemId(String systemId) throws FileNotFoundException
{
+ InputSource entity = null;
- /*
- * (non-Javadoc)
- *
- * @see org.xml.sax.ext.EntityResolver2#getExternalSubset(java.lang.String,
- * java.lang.String)
- */
- @Override
- public InputSource getExternalSubset(String name, String baseURI)
- throws SAXException, IOException {
- // do nothing because we use XML schema only.
- return null;
- }
+ // first step - convert known system url's:
+ String systemIdInternal;
- /*
- * (non-Javadoc)
- *
- * @see org.xml.sax.ext.EntityResolver2#resolveEntity(java.lang.String,
- * java.lang.String, java.lang.String, java.lang.String)
- */
- @Override
- public InputSource resolveEntity(String name, String publicId,
- String baseURI, String systemId) throws SAXException, IOException {
- // perform conversions with baseURI
- if (null != systemId) {
- try {
- URI sourceURI = URI.create(systemId);
- if (!sourceURI.isAbsolute() && null != baseURI) {
- systemId = URI.create(baseURI).resolve(sourceURI).toString();
- }
- } catch (IllegalArgumentException e){
- // Ignore ?
- }
- }
- return resolveSystemId(systemId);
- }
+ if (SYSTEM_ENTITIES.containsKey(systemId)) {
+ systemIdInternal = SYSTEM_ENTITIES.get(systemId);
+ } else {
+ systemIdInternal = systemId;
+ }
- /*
- * (non-Javadoc)
- *
- * @see org.xml.sax.EntityResolver#resolveEntity(java.lang.String,
- * java.lang.String)
- */
- @Override
- public InputSource resolveEntity(String publicId, String systemId)
- throws SAXException, IOException {
- InputSource entity = null;
- if (null != systemId) {
- entity = resolveSystemId(systemId);
- }
- return entity;
- }
+ // Check registered urn's:
+ if (systemIdInternal.startsWith(URN_SYSTEM)) {
- protected InputSource resolveSystemId(String systemId)
- throws FileNotFoundException {
- InputSource entity = null;
- // first step - convert known system url's:
- String systemIdInternal;
- if (systemEntities.containsKey(systemId)) {
- systemIdInternal = systemEntities.get(systemId);
- } else {
- systemIdInternal = systemId;
- }
- // Check registered urn's:
- if (systemIdInternal.startsWith(URN_SYSTEM)) {
- // Cdk resources
- String path = systemIdInternal.substring(URN_SYSTEM.length());
- InputStream inputStream = CdkEntityResolver.class
- .getResourceAsStream(SYSTEM_PREFIX + path);
- if (null != inputStream) {
- entity = new InputSource(inputStream);
- }
- } else if (systemIdInternal.startsWith(URN_RESOURCE)) {
- // Project resources
- String path = systemIdInternal.substring(URN_RESOURCE.length());
- InputStream inputStream = getContext().getLoader()
- .getResourceAsStream(RESOURCE_PREFIX + path);
- if (null != inputStream) {
- entity = new InputSource(inputStream);
- }
- } else if (systemIdInternal.startsWith(URN_ATTRIBUTES)) {
- // Standard attributes. Look for them in the satndard place via
- // project classloader.
- String path = systemIdInternal.substring(URN_ATTRIBUTES.length());
- InputStream inputStream = getContext().getLoader()
- .getResourceAsStream(ATTRIBUTES_PREFIX + path);
- if (null != inputStream) {
- entity = new InputSource(inputStream);
- }
- } else if (systemIdInternal.startsWith(URN_CONFIG)) {
- // Config folder.
- String path = systemIdInternal.substring(URN_CONFIG.length());
- entity = getProjectInputSource(StandardSources.FACES_CONFIGS, path);
- } else if (systemIdInternal.startsWith(URN_TEMPLATES)) {
- // Templates folder.
- String path = systemIdInternal.substring(URN_TEMPLATES.length());
- entity = getProjectInputSource(StandardSources.RENDERER_TEMPLATES,
- path);
- }
- if(null != entity){
- entity.setSystemId(systemId);
- }
- return entity;
- }
+ // Cdk resources
+ String path = systemIdInternal.substring(URN_SYSTEM.length());
+ InputStream inputStream =
CdkEntityResolver.class.getResourceAsStream(SYSTEM_PREFIX + path);
- protected InputSource getProjectInputSource(SourceType type, String path)
- throws FileNotFoundException {
- Iterable<File> folders = getContext().getSourceFolders(type);
- InputSource entity = null;
- for (File folder : folders) {
- if (folder.exists() && folder.isDirectory()) {
- File configFile = new File(folder, path);
- if (configFile.exists()) {
- InputStream inputStream = new FileInputStream(configFile);
- entity = new InputSource(inputStream);
- break;
- }
- }
- }
- return entity;
- }
+ if (null != inputStream) {
+ entity = new InputSource(inputStream);
+ }
+ } else if (systemIdInternal.startsWith(URN_RESOURCE)) {
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @return the context
- */
- public CdkContext getContext() {
- return context;
- }
+ // Project resources
+ String path = systemIdInternal.substring(URN_RESOURCE.length());
+ InputStream inputStream =
getContext().getLoader().getResourceAsStream(RESOURCE_PREFIX + path);
+ if (null != inputStream) {
+ entity = new InputSource(inputStream);
+ }
+ } else if (systemIdInternal.startsWith(URN_ATTRIBUTES)) {
+
+ // Standard attributes. Look for them in the satndard place via
+ // project classloader.
+ String path = systemIdInternal.substring(URN_ATTRIBUTES.length());
+ InputStream inputStream =
getContext().getLoader().getResourceAsStream(ATTRIBUTES_PREFIX + path);
+
+ if (null != inputStream) {
+ entity = new InputSource(inputStream);
+ }
+ } else if (systemIdInternal.startsWith(URN_CONFIG)) {
+
+ // Config folder.
+ String path = systemIdInternal.substring(URN_CONFIG.length());
+
+ entity = getProjectInputSource(StandardSources.FACES_CONFIGS, path);
+ } else if (systemIdInternal.startsWith(URN_TEMPLATES)) {
+
+ // Templates folder.
+ String path = systemIdInternal.substring(URN_TEMPLATES.length());
+
+ entity = getProjectInputSource(StandardSources.RENDERER_TEMPLATES, path);
+ }
+
+ if (null != entity) {
+ entity.setSystemId(systemId);
+ }
+
+ return entity;
+ }
+
+ protected InputSource getProjectInputSource(SourceType type, String path) throws
FileNotFoundException {
+ Iterable<File> folders = getContext().getSourceFolders(type);
+ InputSource entity = null;
+
+ for (File folder : folders) {
+ if (folder.exists() && folder.isDirectory()) {
+ File configFile = new File(folder, path);
+
+ if (configFile.exists()) {
+ InputStream inputStream = new FileInputStream(configFile);
+
+ entity = new InputSource(inputStream);
+
+ break;
+ }
+ }
+ }
+
+ return entity;
+ }
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @return the context
+ */
+ public CdkContext getContext() {
+ return context;
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FacesConfigGenerator.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FacesConfigGenerator.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FacesConfigGenerator.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -21,11 +21,10 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.xmlconfig;
-import java.io.File;
-import java.io.IOException;
-
import org.richfaces.cdk.CdkContext;
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.CdkWriter;
@@ -33,61 +32,62 @@
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.xmlconfig.model.FacesConfigAdapter;
+import java.io.File;
+
/**
* <p class="changed_added_4_0">
* </p>
- *
+ *
* @author asmirnov(a)exadel.com
- *
+ *
*/
public class FacesConfigGenerator implements CdkWriter {
+ private static final String FACES_CONFIG_XML =
"META-INF/faces-config.xml";
+ public static final String FACES_SCHEMA_LOCATION =
ComponentLibrary.FACES_CONFIG_NAMESPACE + " "
+ +
ComponentLibrary.FACES_CONFIG_SCHEMA_LOCATION;
+ private CdkContext context;
+ private JAXBBinding jaxbBinding;
+ private FacesConfigAdapter libraryAdapter;
- private static final String FACES_CONFIG_XML = "META-INF/faces-config.xml";
- private CdkContext context;
- private JAXBBinding jaxbBinding;
- private FacesConfigAdapter libraryAdapter;
- public static final String FACES_SCHEMA_LOCATION =
ComponentLibrary.FACES_CONFIG_NAMESPACE
- + " " + ComponentLibrary.FACES_CONFIG_SCHEMA_LOCATION;
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.richfaces.cdk.CdkWriter#init(org.richfaces.cdk.CdkContext)
+ */
+ @Override
+ public void init(CdkContext context) throws CdkException {
+ this.context = context;
+ jaxbBinding = context.getWorkerInstance(JAXBBinding.class);
+ libraryAdapter = new FacesConfigAdapter();
+ }
- /*
- * (non-Javadoc)
- *
- * @see org.richfaces.cdk.CdkWriter#init(org.richfaces.cdk.CdkContext)
- */
- @Override
- public void init(CdkContext context) throws CdkException {
- this.context = context;
- jaxbBinding = context.getWorkerInstance(JAXBBinding.class);
- libraryAdapter = new FacesConfigAdapter();
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.richfaces.cdk.CdkWriter#render(org.richfaces.cdk.model.ComponentLibrary
+ * )
+ */
+ @Override
+ public void render(ComponentLibrary library) throws CdkException {
- /*
- * (non-Javadoc)
- *
- * @see
- * org.richfaces.cdk.CdkWriter#render(org.richfaces.cdk.model.ComponentLibrary
- * )
- */
- @Override
- public void render(ComponentLibrary library) throws CdkException {
- // TODO - check modification time.
- File facesConfigXml = context.createOutputFile(
- StandardOutputs.FACES_CONFIG, FACES_CONFIG_XML, library.lastModified());
- if (null != facesConfigXml) {
- try {
- // TODO - transform output to strip prefixes from faces-config
- // namespace.
- jaxbBinding.marshal(facesConfigXml, FACES_SCHEMA_LOCATION,
- libraryAdapter.marshal(library));
- } catch (Exception e) {
- if (e instanceof CdkException) {
- throw (CdkException) e;
- } else {
- throw new CdkException(e);
- }
- }
+ // TODO - check modification time.
+ File facesConfigXml = context.createOutputFile(StandardOutputs.FACES_CONFIG,
FACES_CONFIG_XML,
+ library.lastModified());
- }
- }
+ if (null != facesConfigXml) {
+ try {
+ // TODO - transform output to strip prefixes from faces-config
+ // namespace.
+ jaxbBinding.marshal(facesConfigXml, FACES_SCHEMA_LOCATION,
libraryAdapter.marshal(library));
+ } catch (Exception e) {
+ if (e instanceof CdkException) {
+ throw(CdkException) e;
+ } else {
+ throw new CdkException(e);
+ }
+ }
+ }
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FacesConfigNamespacePreffixMapper.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FacesConfigNamespacePreffixMapper.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FacesConfigNamespacePreffixMapper.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.xmlconfig;
import org.richfaces.cdk.model.ComponentLibrary;
@@ -32,18 +34,19 @@
* @author asmirnov(a)exadel.com
*
*/
-public class FacesConfigNamespacePreffixMapper /*extends NamespacePrefixMapper*/ {
+public class FacesConfigNamespacePreffixMapper /* extends NamespacePrefixMapper */ {
- /* (non-Javadoc)
- * @see
com.sun.xml.internal.bind.marshaller.NamespacePrefixMapper#getPreferredPrefix(java.lang.String,
java.lang.String, boolean)
- */
- public String getPreferredPrefix(String namespaceUri, String suggestion, boolean
required) {
- if(ComponentLibrary.FACES_CONFIG_NAMESPACE.equals(namespaceUri)){
- return "";
- } else if (ComponentLibrary.CDK_EXTENSIONS_NAMESPACE.equals(namespaceUri)) {
- return "cdk";
- }
- return suggestion;
- }
+ /*
+ * (non-Javadoc)
+ * @see
com.sun.xml.internal.bind.marshaller.NamespacePrefixMapper#getPreferredPrefix(java.lang.String,
java.lang.String, boolean)
+ */
+ public String getPreferredPrefix(String namespaceUri, String suggestion, boolean
required) {
+ if (ComponentLibrary.FACES_CONFIG_NAMESPACE.equals(namespaceUri)) {
+ return "";
+ } else if (ComponentLibrary.CDK_EXTENSIONS_NAMESPACE.equals(namespaceUri)) {
+ return "cdk";
+ }
+ return suggestion;
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FacesConfigParser.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FacesConfigParser.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FacesConfigParser.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -21,11 +21,9 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.richfaces.cdk.xmlconfig;
-import java.io.File;
-import javax.xml.bind.JAXB;
+package org.richfaces.cdk.xmlconfig;
import org.richfaces.cdk.CdkContext;
import org.richfaces.cdk.CdkException;
@@ -34,54 +32,60 @@
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.xmlconfig.model.FacesConfigBean;
+import java.io.File;
+
/**
* <p class="changed_added_4_0"></p>
* @author asmirnov(a)exadel.com
*
*/
public class FacesConfigParser implements ModelBuilder {
+ private CdkContext context;
+ private JAXBBinding jaxbBinding;
- private CdkContext context;
- private JAXBBinding jaxbBinding;
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the context
+ */
+ public CdkContext getContext() {
+ return context;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the context
- */
- public CdkContext getContext() {
- return context;
- }
+ /*
+ * (non-Javadoc)
+ * @see org.richfaces.cdk.ModelBuilder#build()
+ */
+ @Override
+ public ComponentLibrary build() throws CdkException {
+ ComponentLibrary library = new ComponentLibrary();
- /* (non-Javadoc)
- * @see org.richfaces.cdk.ModelBuilder#build()
- */
- @Override
- public ComponentLibrary build() throws CdkException {
- ComponentLibrary library = new ComponentLibrary();
- for(File file :context.getSources(StandardSources.FACES_CONFIGS)){
- FacesConfigBean unmarshal = unmarshalFacesConfig(file);
- library.getComponents().addAll(unmarshal.getComponents());
- // TODO - merge changes into library.
-// library.getRenderers().addAll(unmarshal.getRenderers());
-// library.getValidators().addAll(unmarshal.getValidators);
-// library.getConverters().addAll(unmarshal.getConverters());
-// library.getBehaviors().addAll(unmarshal.getBehaviors());
-// library.setExtensions(unmarshal.getExtensions());
- }
- return library;
- }
+ for (File file : context.getSources(StandardSources.FACES_CONFIGS)) {
+ FacesConfigBean unmarshal = unmarshalFacesConfig(file);
- protected FacesConfigBean unmarshalFacesConfig(File file) throws CdkException {
- return jaxbBinding.unmarshal(file,
ComponentLibrary.FACES_CONFIG_SCHEMA_LOCATION,FacesConfigBean.class);
- }
+ library.getComponents().addAll(unmarshal.getComponents());
- /* (non-Javadoc)
- * @see org.richfaces.cdk.ModelBuilder#init(org.richfaces.cdk.CdkContext)
- */
- @Override
- public void init(CdkContext context) throws CdkException {
- this.context = context;
- jaxbBinding = context.getWorkerInstance(JAXBBinding.class);
- }
+ // TODO - merge changes into library.
+// library.getRenderers().addAll(unmarshal.getRenderers());
+// library.getValidators().addAll(unmarshal.getValidators);
+// library.getConverters().addAll(unmarshal.getConverters());
+// library.getBehaviors().addAll(unmarshal.getBehaviors());
+// library.setExtensions(unmarshal.getExtensions());
+ }
+ return library;
+ }
+
+ protected FacesConfigBean unmarshalFacesConfig(File file) throws CdkException {
+ return jaxbBinding.unmarshal(file, ComponentLibrary.FACES_CONFIG_SCHEMA_LOCATION,
FacesConfigBean.class);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.richfaces.cdk.ModelBuilder#init(org.richfaces.cdk.CdkContext)
+ */
+ @Override
+ public void init(CdkContext context) throws CdkException {
+ this.context = context;
+ jaxbBinding = context.getWorkerInstance(JAXBBinding.class);
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FragmentParser.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FragmentParser.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FragmentParser.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.xmlconfig;
import java.util.Collection;
@@ -38,44 +40,41 @@
* That class parses xml document with fragment of faces-config ( eg, standard
* component attributes )
* </p>
- *
+ *
* @author asmirnov(a)exadel.com
- *
+ *
*/
public class FragmentParser implements CdkWorker {
+ private JAXBBinding binding;
+ private CdkContext context;
- private CdkContext context;
- private JAXBBinding binding;
+ public FragmentParser() {}
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param context
+ * @throws CdkException
+ */
+ public void init(CdkContext context) throws CdkException {
+ this.context = context;
+ binding = context.getWorkerInstance(JAXBBinding.class);
+ }
-
- public FragmentParser() {
- }
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @param context
- * @throws CdkException
- */
- public void init(CdkContext context) throws CdkException {
- this.context = context;
- binding = context.getWorkerInstance(JAXBBinding.class);
- }
+ /**
+ * <p class="changed_added_4_0">
+ * Parses faces-config.xml fragment with component/renderer properties.
+ * </p>
+ *
+ * @param url
+ * @return
+ */
+ public Collection<Property> parseProperties(String url) throws CdkException {
+ String schemaLocation = ComponentLibrary.FACES_CONFIG_SCHEMA_LOCATION;
+ Class<Properties> bindClass = Properties.class;
+ Properties unmarshal = binding.unmarshal(url, schemaLocation, bindClass);
- /**
- * <p class="changed_added_4_0">
- * Parses faces-config.xml fragment with component/renderer properties.
- * </p>
- *
- * @param url
- * @return
- */
- public Collection<Property> parseProperties(String url) throws CdkException {
- String schemaLocation = ComponentLibrary.FACES_CONFIG_SCHEMA_LOCATION;
- Class<Properties> bindClass = Properties.class;
- Properties unmarshal = binding.unmarshal(url, schemaLocation, bindClass);
- return null ==
unmarshal?Collections.<Property>emptySet():unmarshal.getProperty();
- }
-
+ return null == unmarshal ? Collections.<Property>emptySet() :
unmarshal.getProperty();
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/JAXBBinding.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/JAXBBinding.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/JAXBBinding.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -21,10 +21,13 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.xmlconfig;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
+
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
@@ -32,10 +35,13 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
+
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
+
import java.net.URI;
import java.net.URISyntaxException;
+
import java.util.Collection;
import javax.xml.bind.JAXBContext;
@@ -50,6 +56,7 @@
import javax.xml.transform.stream.StreamResult;
import org.apache.cocoon.pipeline.component.sax.XIncludeTransformer;
+
import org.richfaces.cdk.CdkContext;
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.CdkWorker;
@@ -57,6 +64,7 @@
import org.richfaces.cdk.model.Extensible;
import org.richfaces.cdk.model.Key;
import org.richfaces.cdk.model.ModelElement;
+
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
@@ -67,344 +75,362 @@
/**
* <p class="changed_added_4_0">
* </p>
- *
+ *
* @author asmirnov(a)exadel.com
- *
+ *
*/
public class JAXBBinding implements CdkWorker {
+ private static final FacesConfigNamespacePreffixMapper PREFFIX_MAPPER = new
FacesConfigNamespacePreffixMapper();
+ private static final ImmutableSet<String> IGNORE_PROPERTIES =
ImmutableSet.of("class", "extension");
- private static final FacesConfigNamespacePreffixMapper PREFFIX_MAPPER = new
FacesConfigNamespacePreffixMapper();
+ private CdkContext context;
+ private CdkEntityResolver resolver;
- private CdkContext context;
+ public JAXBBinding() { }
- private CdkEntityResolver resolver;
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param context
+ */
+ public void init(CdkContext context) throws CdkException {
+ this.context = context;
+ this.resolver = new CdkEntityResolver(context);
+ }
- public JAXBBinding() {
+ public <T> T unmarshal(File file, String schemaLocation, Class<T>
bindClass) throws CdkException {
+ try {
+ InputSource input = new InputSource(new FileInputStream(file));
- }
+ input.setSystemId(file.toURI().toString());
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @param context
- */
- public void init(CdkContext context) throws CdkException {
- this.context = context;
- this.resolver = new CdkEntityResolver(context);
- }
+ T unmarshal = unmarshal(schemaLocation, bindClass, input);
- public <T> T unmarshal(File file, String schemaLocation, Class<T>
bindClass)
- throws CdkException {
- try {
- InputSource input = new InputSource(new FileInputStream(file));
- input.setSystemId(file.toURI().toString());
- T unmarshal = unmarshal(schemaLocation, bindClass, input);
- return unmarshal;
- } catch (FileNotFoundException e) {
- throw new CdkException("XML file not found", e);
- }
- }
+ return unmarshal;
+ } catch (FileNotFoundException e) {
+ throw new CdkException("XML file not found", e);
+ }
+ }
- public <T> T unmarshal(String url, String schemaLocation, Class<T>
bindClass)
- throws CdkException {
- try {
- InputSource inputSource = resolver.resolveSystemId(url);
- if (null == inputSource) {
- inputSource = new InputSource(url);
- }
- T unmarshal = unmarshal(schemaLocation, bindClass, inputSource);
- return unmarshal;
- } catch (FileNotFoundException e) {
- throw new CdkException("XML file not found", e);
- }
- }
+ public <T> T unmarshal(String url, String schemaLocation, Class<T>
bindClass) throws CdkException {
+ try {
+ InputSource inputSource = resolver.resolveSystemId(url);
- @SuppressWarnings("unchecked")
- public <T> T unmarshal(String schemaLocation, Class<T> bindClass,
- InputSource inputSource) throws CdkException {
- T unmarshal = null;
- try {
+ if (null == inputSource) {
+ inputSource = new InputSource(url);
+ }
+
+ T unmarshal = unmarshal(schemaLocation, bindClass, inputSource);
+
+ return unmarshal;
+ } catch (FileNotFoundException e) {
+ throw new CdkException("XML file not found", e);
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public <T> T unmarshal(String schemaLocation, Class<T> bindClass,
InputSource inputSource) throws CdkException {
+ T unmarshal = null;
+
+ try {
XMLReader xmlReader = XMLReaderFactory.createXMLReader();
+
xmlReader.setEntityResolver(resolver);
xmlReader.setFeature("http://xml.org/sax/features/validation",
true);
xmlReader.setFeature("http://apache.org/xml/features/validation/sche...;, true);
xmlReader.setFeature("http://apache.org/xml/features/validation/dyna...;,
true);
- // Setup JAXB to unmarshal
- // TODO - create xinclude content handler that process xinclude directives
- // and send SAX event to the unmarshaller handler.
- JAXBContext jc = JAXBContext.newInstance(bindClass);
- Unmarshaller u = jc.createUnmarshaller();
- ValidationEventCollector vec = new ValidationEventCollector();
- u.setEventHandler(vec);
+
+ // Setup JAXB to unmarshal
+ // TODO - create xinclude content handler that process xinclude directives
+ // and send SAX event to the unmarshaller handler.
+ JAXBContext jc = JAXBContext.newInstance(bindClass);
+ Unmarshaller u = jc.createUnmarshaller();
+ ValidationEventCollector vec = new ValidationEventCollector();
+
+ u.setEventHandler(vec);
+
XIncludeTransformer xIncludeTransformer = new XIncludeTransformer();
- if(null != inputSource.getSystemId()){
- xIncludeTransformer.setBaseUri(new URI(inputSource.getSystemId()));
+
+ if (null != inputSource.getSystemId()) {
+ xIncludeTransformer.setBaseUri(new URI(inputSource.getSystemId()));
}
+
UnmarshallerHandler unmarshallerHandler = u.getUnmarshallerHandler();
- xIncludeTransformer.setContentHandler(unmarshallerHandler);
- xIncludeTransformer.setResolver(resolver);
- xmlReader.setContentHandler(xIncludeTransformer);
+
+ xIncludeTransformer.setContentHandler(unmarshallerHandler);
+ xIncludeTransformer.setResolver(resolver);
+ xmlReader.setContentHandler(xIncludeTransformer);
xmlReader.setProperty("http://xml.org/sax/properties/lexical-handler...;,
xIncludeTransformer);
- xmlReader.parse(inputSource);
- // turn off the JAXB provider's default validation mechanism to
- // avoid duplicate validation
- // u.setValidating(false);
- unmarshal = (T) unmarshallerHandler.getResult();
- } catch (JAXBException e) {
- throw new CdkException("JAXB Unmarshaller error", e);
- } catch (URISyntaxException e) {
- throw new CdkException("Invalid XML source URI", e);
- } catch (IOException e) {
- throw new CdkException("JAXB Unmarshaller input error", e);
- } catch (SAXException e) {
- throw new CdkException("XML error", e);
- } finally {
- }
- return unmarshal;
- }
-
- public <T> void marshal(File output,String schemaLocation,T model) throws
CdkException {
- try {
- FileOutputStream outputStream = new FileOutputStream(output);
- StreamResult result = new StreamResult(outputStream);
- marshal(result, schemaLocation, model);
- outputStream.flush();
- outputStream.close();
- } catch (FileNotFoundException e) {
- throw new CdkException("File not found", e);
- } catch (IOException e) {
- throw new CdkException("XML file writting error", e);
- }
-
- }
+ xmlReader.parse(inputSource);
+ // turn off the JAXB provider's default validation mechanism to
+ // avoid duplicate validation
+ // u.setValidating(false);
+ unmarshal = (T) unmarshallerHandler.getResult();
+ } catch (JAXBException e) {
+ throw new CdkException("JAXB Unmarshaller error", e);
+ } catch (URISyntaxException e) {
+ throw new CdkException("Invalid XML source URI", e);
+ } catch (IOException e) {
+ throw new CdkException("JAXB Unmarshaller input error", e);
+ } catch (SAXException e) {
+ throw new CdkException("XML error", e);
+ } finally {
- public <T> void marshal(Result output,String schemaLocation,T model) throws
CdkException {
- try {
- JAXBContext jc = JAXBContext.newInstance(model.getClass());
- Marshaller marshaller = jc.createMarshaller();
- marshaller.setProperty("jaxb.formatted.output", Boolean.TRUE);
- // TODO - let writer to define additional schemes.
-// marshaller.setProperty("jaxb.schemaLocation", Boolean.TRUE);
- marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT,
- true);
- if (null != schemaLocation) {
- marshaller.setProperty(Marshaller.JAXB_SCHEMA_LOCATION,
- schemaLocation);
-// marshaller.setProperty("com.sun.xml.bind.namespacePrefixMapper",
PREFFIX_MAPPER);
- }
- marshaller.marshal(model, output);
- } catch (JAXBException e) {
- throw new CdkException("JAXB Marshaller error", e);
- } finally {
-
- }
- }
- /**
- * <p class="changed_added_4_0">
- * Close input source after parsing.
- * </p>
- *
- * @param source
- */
- private void closeSource(Source source) {
- if (source instanceof SAXSource) {
- SAXSource saxSource = (SAXSource) source;
- InputSource inputSource = saxSource.getInputSource();
- try {
- Reader stream = inputSource.getCharacterStream();
- if (null != stream) {
- stream.close();
- } else {
- InputStream byteStream = inputSource.getByteStream();
- if (null != byteStream) {
- byteStream.close();
- }
- }
- } catch (IOException e) {
- // Can be ignored because source has already been read.
- }
- }
- }
+ // TODO Refactoring
+ }
- private static final ImmutableSet<String> ignoreProperties =
ImmutableSet.of("class","extension");
- /**
- * <p class="changed_added_4_0">
- * This method creates adapter object and copies properties from model
- * object to adapter.
- * </p>
- *
- * @param <A>
- * type of adapter object
- * @param <T>
- * type of model object.
- * @param adapterClass
- * adapter class.
- * @param modelObject
- * model object class.
- * @return initialized instance of adapter object.
- */
- public static <A, T> A createAdapter(Class<A> adapterClass, T modelObject)
- throws CdkException {
- try {
- A adapter = adapterClass.newInstance();
- // Copy properties from model to adapter.
- copyProperties(modelObject, adapter);
- copyExtensions(modelObject, adapter, true);
- return adapter;
- } catch (InstantiationException e) {
- throw new CdkException("JAXB adapter class instantiation error", e);
- } catch (IllegalAccessException e) {
- throw new CdkException("JAXB adapter class instantiation error", e);
- }
- }
+ return unmarshal;
+ }
- public static <A, T extends ModelElement<? super T, K>, K extends Key> T
createModelElement(
- Class<T> modelClass, A adapter, K key) throws CdkException {
- try {
- Constructor<T> constructor = modelClass.getConstructor(key
- .getClass());
- T modelBean = constructor.newInstance(key);
- copyProperties(adapter, modelBean);
- copyExtensions(adapter, modelBean, false);
- return modelBean;
- } catch (Exception e) {
- throw new CdkException("CDK model class instantiation error", e);
- }
- }
+ public <T> void marshal(File output, String schemaLocation, T model) throws
CdkException {
+ try {
+ FileOutputStream outputStream = new FileOutputStream(output);
+ StreamResult result = new StreamResult(outputStream);
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @param <S>
- * @param <D>
- * @param source
- * @param destination
- * @param fromModel
- * @throws CdkException
- */
- public static <S, D> void copyExtensions(S source, D destination,
- boolean fromModel) throws CdkException {
- try {
- if (source instanceof Extensible
- && destination instanceof Extensible) {
- Extensible extensibleSource = (Extensible) source;
- Extensible<ConfigExtension> extensibleDestination =
(Extensible<ConfigExtension>) destination;
- ConfigExtension sourceExtension = extensibleSource
- .getExtension();
- if (null != sourceExtension) {
- ConfigExtension destinationExtension = createExtension(destination);
- destinationExtension.setExtensions(sourceExtension
- .getExtensions());
- if (fromModel) {
- copyProperties(source, destinationExtension);
- } else {
- copyProperties(sourceExtension, destination);
- }
- extensibleDestination.setExtension(destinationExtension);
- } else if (fromModel) {
- ConfigExtension destinationExtension = createExtension(destination);
- copyProperties(source, destinationExtension);
- extensibleDestination.setExtension(destinationExtension);
- }
- }
- } catch (Exception e) {
- throw new CdkException("Properties copiing error", e);
- }
- }
+ marshal(result, schemaLocation, model);
+ outputStream.flush();
+ outputStream.close();
+ } catch (FileNotFoundException e) {
+ throw new CdkException("File not found", e);
+ } catch (IOException e) {
+ throw new CdkException("XML file writting error", e);
+ }
+ }
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @param <D>
- * @param destination
- * @return
- * @throws NoSuchMethodException
- * @throws InstantiationException
- * @throws IllegalAccessException
- */
- private static <D> ConfigExtension createExtension(D destination)
- throws NoSuchMethodException, InstantiationException,
- IllegalAccessException {
- Method method = destination.getClass().getMethod("getExtension");
- Class<? extends ConfigExtension> destinationExtensionType = (Class<? extends
ConfigExtension>) method
- .getReturnType();
- ConfigExtension destinationExtension = destinationExtensionType
- .newInstance();
- return destinationExtension;
- }
+ public <T> void marshal(Result output, String schemaLocation, T model) throws
CdkException {
+ try {
+ JAXBContext jc = JAXBContext.newInstance(model.getClass());
+ Marshaller marshaller = jc.createMarshaller();
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @param <S>
- * @param <D>
- * @param source
- * @param destination
- * @throws CdkException
- */
- public static <S, D> void copyProperties(S source, D destination)
- throws CdkException {
- try {
- PropertyDescriptor[] targetProperties = Introspector.getBeanInfo(
- destination.getClass()).getPropertyDescriptors();
- PropertyDescriptor[] sourceProperties = Introspector.getBeanInfo(
- source.getClass()).getPropertyDescriptors();
- for (PropertyDescriptor targetProperty : targetProperties) {
- Method writeMethod = targetProperty.getWriteMethod();
- String name = targetProperty.getName();
- for (PropertyDescriptor sourceProperty : sourceProperties) {
- Method readMethod = sourceProperty.getReadMethod();
- if (!ignoreProperties.contains(name) &&
name.equals(sourceProperty.getName())
- && null != readMethod) {
- Class<?> targetType = targetProperty.getPropertyType();
- Class<?> sourceType = sourceProperty.getPropertyType();
- Object propertyValue = readMethod.invoke(source);
- if (null != propertyValue) {
- if (null != writeMethod) {
- if (targetType.equals(sourceType)) {
- writeMethod.invoke(destination,
- propertyValue);
- } else if (targetType.equals(String.class)) {
- writeMethod.invoke(destination,
- propertyValue.toString());
- } else if (isCollections(targetType, propertyValue)) {
- Collection targetCollection = (Collection) targetProperty
- .getReadMethod()
- .invoke(destination);
- if (null != targetCollection) {
- targetCollection
- .addAll((Collection) propertyValue);
- } else {
- writeMethod.invoke(destination,
- propertyValue);
- }
- }
- } else if (isCollections(targetType, propertyValue)) {
- Collection targetCollection = (Collection) targetProperty
- .getReadMethod().invoke(destination);
- if (null != targetCollection) {
- targetCollection
- .addAll((Collection) propertyValue);
- }
- }
- }
- }
- }
- }
- } catch (Exception e) {
- throw new CdkException("Properties copiing error", e);
- }
- }
+ marshaller.setProperty("jaxb.formatted.output", Boolean.TRUE);
- private static boolean isCollections(Class<?> targetType, Object propertyValue) {
- return Collection.class
- .isAssignableFrom(targetType)
- && propertyValue instanceof Collection;
- }
+ // TODO - let writer to define additional schemes.
+// marshaller.setProperty("jaxb.schemaLocation", Boolean.TRUE);
+ marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
+ if (null != schemaLocation) {
+ marshaller.setProperty(Marshaller.JAXB_SCHEMA_LOCATION, schemaLocation);
+
+//
marshaller.setProperty("com.sun.xml.bind.namespacePrefixMapper",
PREFFIX_MAPPER);
+ }
+
+ marshaller.marshal(model, output);
+ } catch (JAXBException e) {
+ throw new CdkException("JAXB Marshaller error", e);
+ } finally {
+
+ // TODO Refactoring
+ }
+ }
+
+ /**
+ * <p class="changed_added_4_0">
+ * Close input source after parsing.
+ * </p>
+ *
+ * @param source
+ */
+ private void closeSource(Source source) {
+ if (source instanceof SAXSource) {
+ SAXSource saxSource = (SAXSource) source;
+ InputSource inputSource = saxSource.getInputSource();
+
+ try {
+ Reader stream = inputSource.getCharacterStream();
+
+ if (null != stream) {
+ stream.close();
+ } else {
+ InputStream byteStream = inputSource.getByteStream();
+
+ if (null != byteStream) {
+ byteStream.close();
+ }
+ }
+ } catch (IOException e) {
+
+ // Can be ignored because source has already been read.
+ }
+ }
+ }
+
+ /**
+ * <p class="changed_added_4_0">
+ * This method creates adapter object and copies properties from model
+ * object to adapter.
+ * </p>
+ *
+ * @param <A>
+ * type of adapter object
+ * @param <T>
+ * type of model object.
+ * @param adapterClass
+ * adapter class.
+ * @param modelObject
+ * model object class.
+ * @return initialized instance of adapter object.
+ */
+ public static <A, T> A createAdapter(Class<A> adapterClass, T
modelObject) throws CdkException {
+ try {
+ A adapter = adapterClass.newInstance();
+
+ // Copy properties from model to adapter.
+ copyProperties(modelObject, adapter);
+ copyExtensions(modelObject, adapter, true);
+
+ return adapter;
+ } catch (InstantiationException e) {
+ throw new CdkException("JAXB adapter class instantiation error",
e);
+ } catch (IllegalAccessException e) {
+ throw new CdkException("JAXB adapter class instantiation error",
e);
+ }
+ }
+
+ public static <A, T extends ModelElement<? super T, K>, K extends Key> T
createModelElement(Class<T> modelClass,
+ A adapter, K key) throws CdkException {
+
+ try {
+ Constructor<T> constructor =
modelClass.getConstructor(key.getClass());
+ T modelBean = constructor.newInstance(key);
+
+ copyProperties(adapter, modelBean);
+ copyExtensions(adapter, modelBean, false);
+
+ return modelBean;
+ } catch (Exception e) {
+ throw new CdkException("CDK model class instantiation error", e);
+ }
+ }
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param <S>
+ * @param <D>
+ * @param source
+ * @param destination
+ * @param fromModel
+ * @throws CdkException
+ */
+ public static <S, D> void copyExtensions(S source, D destination, boolean
fromModel) throws CdkException {
+ try {
+ if (source instanceof Extensible && destination instanceof
Extensible) {
+ Extensible extensibleSource = (Extensible) source;
+ Extensible<ConfigExtension> extensibleDestination =
(Extensible<ConfigExtension>) destination;
+ ConfigExtension sourceExtension = extensibleSource.getExtension();
+
+ if (null != sourceExtension) {
+ ConfigExtension destinationExtension = createExtension(destination);
+
+ destinationExtension.setExtensions(sourceExtension.getExtensions());
+
+ if (fromModel) {
+ copyProperties(source, destinationExtension);
+ } else {
+ copyProperties(sourceExtension, destination);
+ }
+
+ extensibleDestination.setExtension(destinationExtension);
+ } else if (fromModel) {
+ ConfigExtension destinationExtension = createExtension(destination);
+
+ copyProperties(source, destinationExtension);
+ extensibleDestination.setExtension(destinationExtension);
+ }
+ }
+ } catch (Exception e) {
+ throw new CdkException("Properties copiing error", e);
+ }
+ }
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param <D>
+ * @param destination
+ * @return
+ * @throws NoSuchMethodException
+ * @throws InstantiationException
+ * @throws IllegalAccessException
+ */
+ private static <D> ConfigExtension createExtension(D destination)
+ throws NoSuchMethodException, InstantiationException, IllegalAccessException {
+
+ Method method = destination.getClass().getMethod("getExtension");
+ Class<? extends ConfigExtension> destinationExtensionType =
+ (Class<? extends ConfigExtension>) method.getReturnType();
+
+ return destinationExtensionType.newInstance();
+ }
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param <S>
+ * @param <D>
+ * @param source
+ * @param destination
+ * @throws CdkException
+ */
+ public static <S, D> void copyProperties(S source, D destination) throws
CdkException {
+ try {
+ PropertyDescriptor[] targetProperties =
+
Introspector.getBeanInfo(destination.getClass()).getPropertyDescriptors();
+ PropertyDescriptor[] sourceProperties =
+ Introspector.getBeanInfo(source.getClass()).getPropertyDescriptors();
+
+ for (PropertyDescriptor targetProperty : targetProperties) {
+ Method writeMethod = targetProperty.getWriteMethod();
+ String name = targetProperty.getName();
+
+ for (PropertyDescriptor sourceProperty : sourceProperties) {
+ Method readMethod = sourceProperty.getReadMethod();
+
+ if (!IGNORE_PROPERTIES.contains(name) &&
name.equals(sourceProperty.getName())
+ && null != readMethod) {
+ Class<?> targetType = targetProperty.getPropertyType();
+ Class<?> sourceType = sourceProperty.getPropertyType();
+ Object propertyValue = readMethod.invoke(source);
+
+ if (null != propertyValue) {
+ if (null != writeMethod) {
+ if (targetType.equals(sourceType)) {
+ writeMethod.invoke(destination, propertyValue);
+ } else if (targetType.equals(String.class)) {
+ writeMethod.invoke(destination,
propertyValue.toString());
+ } else if (isCollections(targetType, propertyValue)) {
+ Collection targetCollection =
+ (Collection)
targetProperty.getReadMethod().invoke(destination);
+
+ if (null != targetCollection) {
+ targetCollection.addAll((Collection)
propertyValue);
+ } else {
+ writeMethod.invoke(destination, propertyValue);
+ }
+ }
+ } else if (isCollections(targetType, propertyValue)) {
+ Collection targetCollection =
+ (Collection)
targetProperty.getReadMethod().invoke(destination);
+
+ if (null != targetCollection) {
+ targetCollection.addAll((Collection) propertyValue);
+ }
+ }
+ }
+ }
+ }
+ }
+ } catch (Exception e) {
+ throw new CdkException("Properties copiing error", e);
+ }
+ }
+
+ private static boolean isCollections(Class<?> targetType, Object propertyValue)
{
+ return Collection.class.isAssignableFrom(targetType) && propertyValue
instanceof Collection;
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/AttributeAdapter.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/AttributeAdapter.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/AttributeAdapter.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.xmlconfig.model;
import javax.xml.bind.annotation.adapters.XmlAdapter;
@@ -35,15 +37,13 @@
*
*/
public class AttributeAdapter extends XmlAdapter<AttributeBean, Attribute> {
+ @Override
+ public AttributeBean marshal(Attribute v) throws Exception {
+ return JAXBBinding.createAdapter(AttributeBean.class, v);
+ }
- @Override
- public AttributeBean marshal(Attribute v) throws Exception {
- return JAXBBinding.createAdapter(AttributeBean.class, v);
- }
-
- @Override
- public Attribute unmarshal(AttributeBean v) throws Exception {
- return JAXBBinding.createModelElement(Attribute.class, v, new
Property.Name(v.getName()));
- }
-
+ @Override
+ public Attribute unmarshal(AttributeBean v) throws Exception {
+ return JAXBBinding.createModelElement(Attribute.class, v, new
Property.Name(v.getName()));
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/AttributeBean.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/AttributeBean.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/AttributeBean.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.xmlconfig.model;
import javax.xml.bind.annotation.XmlElement;
@@ -36,99 +38,94 @@
* @author asmirnov(a)exadel.com
*
*/
-public class AttributeBean extends DescriptionGroupBean implements
Extensible<PropertyBean.PropertyExtension>{
- private String name;
+public class AttributeBean extends DescriptionGroupBean implements
Extensible<PropertyBean.PropertyExtension> {
+ private String defaultValue;
+ private PropertyExtension extension;
+ private String name;
+ private String suggestedValue;
+ private ClassDescription type;
- private ClassDescription type;
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the name
+ */
+ @XmlElement(name = "attribute-name", namespace =
ComponentLibrary.FACES_CONFIG_NAMESPACE)
+ public String getName() {
+ return name;
+ }
- private String defaultValue;
-
- private String suggestedValue;
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param name the name to set
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
- private PropertyExtension extension;
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the type
+ */
+ @XmlElement(name = "attribute-class", namespace =
ComponentLibrary.FACES_CONFIG_NAMESPACE)
+ @XmlJavaTypeAdapter(ClassAdapter.class)
+ public ClassDescription getType() {
+ return type;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the name
- */
- @XmlElement(name="attribute-name",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
- public String getName() {
- return name;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param type the type to set
+ */
+ public void setType(ClassDescription type) {
+ this.type = type;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param name the name to set
- */
- public void setName(String name) {
- this.name = name;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the defaultValue
+ */
+ @XmlElement(name = "default-value", namespace =
ComponentLibrary.FACES_CONFIG_NAMESPACE)
+ public String getDefaultValue() {
+ return defaultValue;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the type
- */
- @XmlElement(name="attribute-class",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
- @XmlJavaTypeAdapter(ClassAdapter.class)
- public ClassDescription getType() {
- return type;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param defaultValue the defaultValue to set
+ */
+ public void setDefaultValue(String defaultValue) {
+ this.defaultValue = defaultValue;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param type the type to set
- */
- public void setType(ClassDescription type) {
- this.type = type;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the suggestedValue
+ */
+ @XmlElement(name = "suggested-value", namespace =
ComponentLibrary.FACES_CONFIG_NAMESPACE)
+ public String getSuggestedValue() {
+ return suggestedValue;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the defaultValue
- */
- @XmlElement(name="default-value",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
- public String getDefaultValue() {
- return defaultValue;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param suggestedValue the suggestedValue to set
+ */
+ public void setSuggestedValue(String suggestedValue) {
+ this.suggestedValue = suggestedValue;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param defaultValue the defaultValue to set
- */
- public void setDefaultValue(String defaultValue) {
- this.defaultValue = defaultValue;
- }
+ @Override
+ @XmlElement(name = "attribute-extension", namespace =
ComponentLibrary.FACES_CONFIG_NAMESPACE)
+ public PropertyExtension getExtension() {
+ return extension;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the suggestedValue
- */
- @XmlElement(name="suggested-value",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
- public String getSuggestedValue() {
- return suggestedValue;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @param suggestedValue the suggestedValue to set
- */
- public void setSuggestedValue(String suggestedValue) {
- this.suggestedValue = suggestedValue;
- }
-
- @Override
- @XmlElement(name="attribute-extension",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
- public PropertyExtension getExtension() {
- return extension;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @param extension the extension to set
- */
- @Override
- public void setExtension(PropertyExtension extension) {
- this.extension = extension;
- }
-
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param extension the extension to set
+ */
+ @Override
+ public void setExtension(PropertyExtension extension) {
+ this.extension = extension;
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/BehaviorRendererAdapter.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/BehaviorRendererAdapter.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/BehaviorRendererAdapter.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.xmlconfig.model;
import javax.xml.bind.annotation.adapters.XmlAdapter;
@@ -34,15 +36,13 @@
*
*/
public class BehaviorRendererAdapter extends XmlAdapter<BehaviorRendererBean,
BehaviorRenderer> {
+ @Override
+ public BehaviorRendererBean marshal(BehaviorRenderer v) throws Exception {
+ return JAXBBinding.createAdapter(BehaviorRendererBean.class, v);
+ }
- @Override
- public BehaviorRendererBean marshal(BehaviorRenderer v) throws Exception {
- return JAXBBinding.createAdapter(BehaviorRendererBean.class, v);
- }
-
- @Override
- public BehaviorRenderer unmarshal(BehaviorRendererBean v) throws Exception {
- return JAXBBinding.createModelElement(BehaviorRenderer.class, v, new
BehaviorRenderer.Type(v.getType()));
- }
-
+ @Override
+ public BehaviorRenderer unmarshal(BehaviorRendererBean v) throws Exception {
+ return JAXBBinding.createModelElement(BehaviorRenderer.class, v, new
BehaviorRenderer.Type(v.getType()));
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/BehaviorRendererBean.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/BehaviorRendererBean.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/BehaviorRendererBean.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.xmlconfig.model;
import javax.xml.bind.annotation.XmlElement;
@@ -36,65 +38,60 @@
* @author asmirnov(a)exadel.com
*
*/
-@XmlType(name="faces-config-client-behavior-rendererType",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
+@XmlType(name = "faces-config-client-behavior-rendererType", namespace =
ComponentLibrary.FACES_CONFIG_NAMESPACE)
public class BehaviorRendererBean {
+ private ClassDescription rendererClass;
+ private String type;
- /**
- * <p class="changed_added_4_0"></p>
- * @author asmirnov(a)exadel.com
- *
- */
- public static class BehaviorRendererExtension extends ConfigExtension {
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the type
+ */
+ @XmlElement(name = "client-behavior-renderer-type", namespace =
ComponentLibrary.FACES_CONFIG_NAMESPACE)
+ public String getType() {
+ return type;
+ }
- }
-
- private String type;
-
-
- private ClassDescription rendererClass;
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param type the type to set
+ */
+ public void setType(String type) {
+ this.type = type;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the type
- */
- @XmlElement(name="client-behavior-renderer-type",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
- public String getType() {
- return type;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the rendererClass
+ */
+ @XmlElement(name = "client-behavior-renderer-class", namespace =
ComponentLibrary.FACES_CONFIG_NAMESPACE)
+ @XmlJavaTypeAdapter(ClassAdapter.class)
+ public ClassDescription getRendererClass() {
+ return rendererClass;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param type the type to set
- */
- public void setType(String type) {
- this.type = type;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param rendererClass the rendererClass to set
+ */
+ public void setRendererClass(ClassDescription rendererClass) {
+ this.rendererClass = rendererClass;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the rendererClass
- */
- @XmlElement(name="client-behavior-renderer-class",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
- @XmlJavaTypeAdapter(ClassAdapter.class)
- public ClassDescription getRendererClass() {
- return rendererClass;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+ public static class BehaviorRendererExtension extends ConfigExtension {}
- /**
- * <p class="changed_added_4_0"></p>
- * @param rendererClass the rendererClass to set
- */
- public void setRendererClass(ClassDescription rendererClass) {
- this.rendererClass = rendererClass;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the extension
+ */
- /**
- * <p class="changed_added_4_0"></p>
- * @return the extension
- */
-// @XmlElement(name="client-behavior-renderer-extension",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
-// public BehaviorRendererExtension getExtension() {
-// return super.getExtension();
-// }
-
+//
@XmlElement(name="client-behavior-renderer-extension",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
+// public BehaviorRendererExtension getExtension() {
+// return super.getExtension();
+// }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ClassAdapter.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ClassAdapter.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ClassAdapter.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.xmlconfig.model;
import javax.xml.bind.annotation.adapters.XmlAdapter;
@@ -33,17 +35,17 @@
*
*/
public class ClassAdapter extends XmlAdapter<ClassBean, ClassDescription> {
+ @Override
+ public ClassBean marshal(ClassDescription v) throws Exception {
+ ClassBean bean = new ClassBean();
- @Override
- public ClassBean marshal(ClassDescription v) throws Exception {
- ClassBean bean = new ClassBean();
- bean.setName(v.getName());
- return bean;
- }
+ bean.setName(v.getName());
- @Override
- public ClassDescription unmarshal(ClassBean v) throws Exception {
- return new ClassDescription(v.getName());
- }
+ return bean;
+ }
+ @Override
+ public ClassDescription unmarshal(ClassBean v) throws Exception {
+ return new ClassDescription(v.getName());
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ClassBean.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ClassBean.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ClassBean.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.xmlconfig.model;
import javax.xml.bind.annotation.XmlType;
@@ -33,26 +35,24 @@
* @author asmirnov(a)exadel.com
*
*/
-@XmlType(name="fully-qualified-classType",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
+@XmlType(name = "fully-qualified-classType", namespace =
ComponentLibrary.FACES_CONFIG_NAMESPACE)
public class ClassBean {
-
- private String name;
+ private String name;
- /**
- * <p class="changed_added_4_0"></p>
- * @return the name
- */
- @XmlValue
- public String getName() {
- return name;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the name
+ */
+ @XmlValue
+ public String getName() {
+ return name;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param name the name to set
- */
- public void setName(String name) {
- this.name = name;
- }
-
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param name the name to set
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ComponentAdapter.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ComponentAdapter.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ComponentAdapter.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.xmlconfig.model;
import javax.xml.bind.annotation.adapters.XmlAdapter;
@@ -34,19 +36,19 @@
*
*/
public class ComponentAdapter extends XmlAdapter<ComponentBean, Component> {
+ @Override
+ public ComponentBean marshal(Component v) throws Exception {
+ ComponentBean bean = JAXBBinding.createAdapter(ComponentBean.class, v);
- @Override
- public ComponentBean marshal(Component v) throws Exception {
- ComponentBean bean = JAXBBinding.createAdapter(ComponentBean.class, v);
- // TODO - copy renderer types.
- return bean;
- }
+ // TODO - copy renderer types.
+ return bean;
+ }
- @Override
- public Component unmarshal(ComponentBean v) throws Exception {
- Component component = JAXBBinding.createModelElement(Component.class, v, new
Component.Type(v.getType()));
- // TODO - copy renderer types.
- return component;
- }
+ @Override
+ public Component unmarshal(ComponentBean v) throws Exception {
+ Component component = JAXBBinding.createModelElement(Component.class, v, new
Component.Type(v.getType()));
+ // TODO - copy renderer types.
+ return component;
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ComponentBean.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ComponentBean.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ComponentBean.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.xmlconfig.model;
import java.util.List;
@@ -44,199 +46,200 @@
* @author asmirnov(a)exadel.com
*
*/
-@XmlType(name="faces-config-componentType",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
+@XmlType(name = "faces-config-componentType", namespace =
ComponentLibrary.FACES_CONFIG_NAMESPACE)
public class ComponentBean extends ExtensibleBean<ComponentBean.ComponentExtension>
{
+ private List<Property> attributes = Lists.newArrayList();
+ private List<Facet> facets = Lists.newArrayList();
+ private ClassDescription componentClass;
+ private String type;
- private String type;
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the type
+ */
+ @XmlElement(name = "component-type", namespace =
ComponentLibrary.FACES_CONFIG_NAMESPACE)
+ public String getType() {
+ return type;
+ }
- private ClassDescription componentClass;
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param type the type to set
+ */
+ public void setType(String type) {
+ this.type = type;
+ }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the componentClass
+ */
+ @XmlElement(name = "component-class", namespace =
ComponentLibrary.FACES_CONFIG_NAMESPACE)
+ @XmlJavaTypeAdapter(ClassAdapter.class)
+ public ClassDescription getComponentClass() {
+ return componentClass;
+ }
- private List<Property> attributes = Lists.newArrayList();
-
- private List<Facet> facets = Lists.newArrayList();
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param componentClass the componentClass to set
+ */
+ public void setComponentClass(ClassDescription className) {
+ this.componentClass = className;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the type
- */
- @XmlElement(name="component-type",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
- public String getType() {
- return type;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the attributes
+ */
+ @XmlElements({@XmlElement(
+ name = "property",
+ namespace = ComponentLibrary.FACES_CONFIG_NAMESPACE,
+ type = PropertyBean.class
+ ) , @XmlElement(
+ name = "attribute",
+ namespace = ComponentLibrary.FACES_CONFIG_NAMESPACE,
+ type = AttributeBean.class
+ ) })
- /**
- * <p class="changed_added_4_0"></p>
- * @param type the type to set
- */
- public void setType(String type) {
- this.type = type;
- }
+//
@XmlElement(name="attributes",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
+ public List<Property> getAttributes() {
+ return attributes;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the componentClass
- */
- @XmlElement(name="component-class",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
- @XmlJavaTypeAdapter(ClassAdapter.class)
- public ClassDescription getComponentClass() {
- return componentClass;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param attributes the attributes to set
+ */
+ public void setAttributes(List<Property> property) {
+ this.attributes = property;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param componentClass the componentClass to set
- */
- public void setComponentClass(ClassDescription className) {
- this.componentClass = className;
- }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the attributes
- */
- @XmlElements({@XmlElement(name="property",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE,type=PropertyBean.class),@XmlElement(name="attribute",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE,type=AttributeBean.class)})
-// @XmlElement(name="attributes",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
- public List<Property> getAttributes() {
- return attributes;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the facets
+ */
+ @XmlElement(name = "facet", namespace =
ComponentLibrary.FACES_CONFIG_NAMESPACE)
+ @XmlJavaTypeAdapter(FacetAdapter.class)
+ public List<Facet> getFacets() {
+ return facets;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param attributes the attributes to set
- */
- public void setAttributes(List<Property> property) {
- this.attributes = property;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @return the facets
- */
- @XmlElement(name="facet",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
- @XmlJavaTypeAdapter(FacetAdapter.class)
- public List<Facet> getFacets() {
- return facets;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param facets the facets to set
+ */
+ public void setFacets(List<Facet> facets) {
+ this.facets = facets;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param facets the facets to set
- */
- public void setFacets(List<Facet> facets) {
- this.facets = facets;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the extension
+ */
+ @XmlElement(name = "component-extension", namespace =
ComponentLibrary.FACES_CONFIG_NAMESPACE)
+ @Override
+ public ComponentExtension getExtension() {
+ return super.getExtension();
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the extension
- */
- @XmlElement(name="component-extension",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
- @Override
- public ComponentExtension getExtension() {
- return super.getExtension();
- }
-
- @Override
- public void setExtension(ComponentExtension extension) {
- super.setExtension(extension);
- }
+ @Override
+ public void setExtension(ComponentExtension extension) {
+ super.setExtension(extension);
+ }
- public static class ComponentExtension extends ConfigExtension {
-
- private String family;
+ public static class ComponentExtension extends ConfigExtension {
+ private List<String> rendererTypes = Lists.newArrayList();
+ private List<Event> events = Lists.newArrayList();
+ private ClassDescription baseClass;
+ private String family;
+ private boolean generate;
- private ClassDescription baseClass;
-
- private boolean generate;
-
- private List<String> rendererTypes = Lists.newArrayList();
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param family the family to set
+ */
+ public void setFamily(String family) {
+ this.family = family;
+ }
- private List<Event> events = Lists.newArrayList();
- /**
- * <p class="changed_added_4_0"></p>
- * @param family the family to set
- */
- public void setFamily(String family) {
- this.family = family;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the family
+ */
+ @XmlElement(name = "component-family", namespace =
ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
+ public String getFamily() {
+ return family;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the family
- */
- @XmlElement(name="component-family",namespace=ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
- public String getFamily() {
- return family;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the baseClass
+ */
+ @XmlElement(name = "base-class", namespace =
ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
+ @XmlJavaTypeAdapter(ClassAdapter.class)
+ public ClassDescription getBaseClass() {
+ return baseClass;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the baseClass
- */
- @XmlElement(name="base-class",namespace=ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
- @XmlJavaTypeAdapter(ClassAdapter.class)
- public ClassDescription getBaseClass() {
- return baseClass;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param baseClass the baseClass to set
+ */
+ public void setBaseClass(ClassDescription baseClass) {
+ this.baseClass = baseClass;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param baseClass the baseClass to set
- */
- public void setBaseClass(ClassDescription baseClass) {
- this.baseClass = baseClass;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the generate
+ */
+ @XmlElement(name = "generate", namespace =
ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
+ public boolean isGenerate() {
+ return generate;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the generate
- */
- @XmlElement(name="generate",namespace=ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
- public boolean isGenerate() {
- return generate;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param generate the generate to set
+ */
+ public void setGenerate(boolean generate) {
+ this.generate = generate;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param generate the generate to set
- */
- public void setGenerate(boolean generate) {
- this.generate = generate;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param rendererTypes the rendererTypes to set
+ */
+ @XmlElement(name = "renderer-type", namespace =
ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
+ public void setRendererTypes(List<String> rendererTypes) {
+ this.rendererTypes = rendererTypes;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param rendererTypes the rendererTypes to set
- */
- @XmlElement(name="renderer-type",namespace=ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
- public void setRendererTypes(List<String> rendererTypes) {
- this.rendererTypes = rendererTypes;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the rendererTypes
+ */
+ public List<String> getRendererTypes() {
+ return rendererTypes;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the rendererTypes
- */
- public List<String> getRendererTypes() {
- return rendererTypes;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the events
+ */
+ @XmlElement(name = "fires", namespace =
ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
+ @XmlJavaTypeAdapter(EventAdapter.class)
+ public List<Event> getEvents() {
+ return events;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the events
- */
- @XmlElement(name="fires",namespace=ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
- @XmlJavaTypeAdapter(EventAdapter.class)
- public List<Event> getEvents() {
- return events;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @param events the events to set
- */
- public void setEvents(List<Event> events) {
- this.events = events;
- }
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param events the events to set
+ */
+ public void setEvents(List<Event> events) {
+ this.events = events;
+ }
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/DescriptionGroupBean.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/DescriptionGroupBean.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/DescriptionGroupBean.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -6,64 +6,62 @@
import org.richfaces.cdk.model.DescriptionGroup;
public class DescriptionGroupBean implements DescriptionGroup {
+ private String description;
+ private String displayname;
+ private Icon icon;
- private Icon icon;
- private String description;
- private String displayname;
+ public DescriptionGroupBean() {
+ super();
+ }
- public DescriptionGroupBean() {
- super();
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the icon
+ */
+ @XmlElement(name = "icon", namespace =
ComponentLibrary.FACES_CONFIG_NAMESPACE)
+ public final Icon getIcon() {
+ return icon;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the icon
- */
- @XmlElement(name = "icon", namespace =
ComponentLibrary.FACES_CONFIG_NAMESPACE)
- public final Icon getIcon() {
- return icon;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param icon the icon to set
+ */
+ public final void setIcon(Icon icon) {
+ this.icon = icon;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param icon the icon to set
- */
- public final void setIcon(Icon icon) {
- this.icon = icon;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the description
+ */
+ @XmlElement(name = "description", namespace =
ComponentLibrary.FACES_CONFIG_NAMESPACE)
+ public final String getDescription() {
+ return description;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the description
- */
- @XmlElement(name = "description", namespace =
ComponentLibrary.FACES_CONFIG_NAMESPACE)
- public final String getDescription() {
- return description;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param description the description to set
+ */
+ public final void setDescription(String description) {
+ this.description = description;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param description the description to set
- */
- public final void setDescription(String description) {
- this.description = description;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the displayname
+ */
+ @XmlElement(name = "display-name", namespace =
ComponentLibrary.FACES_CONFIG_NAMESPACE)
+ public final String getDisplayname() {
+ return displayname;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the displayname
- */
- @XmlElement(name = "display-name", namespace =
ComponentLibrary.FACES_CONFIG_NAMESPACE)
- public final String getDisplayname() {
- return displayname;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @param displayname the displayname to set
- */
- public final void setDisplayname(String displayname) {
- this.displayname = displayname;
- }
-
-}
\ No newline at end of file
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param displayname the displayname to set
+ */
+ public final void setDisplayname(String displayname) {
+ this.displayname = displayname;
+ }
+}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/EventAdapter.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/EventAdapter.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/EventAdapter.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.xmlconfig.model;
import javax.xml.bind.annotation.adapters.XmlAdapter;
@@ -34,15 +36,13 @@
*
*/
public class EventAdapter extends XmlAdapter<EventBean, Event> {
+ @Override
+ public EventBean marshal(Event v) throws Exception {
+ return JAXBBinding.createAdapter(EventBean.class, v);
+ }
- @Override
- public EventBean marshal(Event v) throws Exception {
- return JAXBBinding.createAdapter(EventBean.class, v);
- }
-
- @Override
- public Event unmarshal(EventBean v) throws Exception {
- return JAXBBinding.createModelElement(Event.class, v, new Event.Type(v.getType()));
- }
-
+ @Override
+ public Event unmarshal(EventBean v) throws Exception {
+ return JAXBBinding.createModelElement(Event.class, v, new
Event.Type(v.getType()));
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/EventBean.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/EventBean.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/EventBean.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.xmlconfig.model;
import javax.xml.bind.annotation.XmlElement;
@@ -35,105 +37,99 @@
* @author asmirnov(a)exadel.com
*
*/
-@XmlType(name="faces-eventType",namespace=ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
+@XmlType(name = "faces-eventType", namespace =
ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
public class EventBean {
+ private String description;
+ private ClassDescription listenerInterface;
+ private ClassDescription sourceInterface;
+ private ClassDescription tagHandler;
+ private String type;
- private String type;
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the type
+ */
+ @XmlElement(name = "event-class", namespace =
ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
+ public String getType() {
+ return type;
+ }
- private String description;
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param type the type to set
+ */
+ public void setType(String type) {
+ this.type = type;
+ }
- private ClassDescription listenerInterface;
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the description
+ */
+ @XmlElement(name = "description", namespace =
ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
+ public String getDescription() {
+ return description;
+ }
- private ClassDescription sourceInterface;
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param description the description to set
+ */
+ public void setDescription(String description) {
+ this.description = description;
+ }
- private ClassDescription tagHandler;
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the listenerInterface
+ */
+ @XmlElement(name = "listener-class", namespace =
ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
+ @XmlJavaTypeAdapter(ClassAdapter.class)
+ public ClassDescription getListenerInterface() {
+ return listenerInterface;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the type
- */
- @XmlElement(name="event-class",namespace=ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
- public String getType() {
- return type;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param listenerInterface the listenerInterface to set
+ */
+ public void setListenerInterface(ClassDescription listenerInterface) {
+ this.listenerInterface = listenerInterface;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param type the type to set
- */
- public void setType(String type) {
- this.type = type;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the sourceInterface
+ */
+ @XmlElement(name = "source-class", namespace =
ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
+ @XmlJavaTypeAdapter(ClassAdapter.class)
+ public ClassDescription getSourceInterface() {
+ return sourceInterface;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the description
- */
- @XmlElement(name="description",namespace=ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
- public String getDescription() {
- return description;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param sourceInterface the sourceInterface to set
+ */
+ public void setSourceInterface(ClassDescription sourceInterface) {
+ this.sourceInterface = sourceInterface;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param description the description to set
- */
- public void setDescription(String description) {
- this.description = description;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the tagHandler
+ */
+ @XmlElement(name = "tag-handler-class", namespace =
ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
+ @XmlJavaTypeAdapter(ClassAdapter.class)
+ public ClassDescription getTagHandler() {
+ return tagHandler;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the listenerInterface
- */
- @XmlElement(name="listener-class",namespace=ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
- @XmlJavaTypeAdapter(ClassAdapter.class)
- public ClassDescription getListenerInterface() {
- return listenerInterface;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @param listenerInterface the listenerInterface to set
- */
- public void setListenerInterface(ClassDescription listenerInterface) {
- this.listenerInterface = listenerInterface;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @return the sourceInterface
- */
- @XmlElement(name="source-class",namespace=ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
- @XmlJavaTypeAdapter(ClassAdapter.class)
- public ClassDescription getSourceInterface() {
- return sourceInterface;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @param sourceInterface the sourceInterface to set
- */
- public void setSourceInterface(ClassDescription sourceInterface) {
- this.sourceInterface = sourceInterface;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @return the tagHandler
- */
- @XmlElement(name="tag-handler-class",namespace=ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
- @XmlJavaTypeAdapter(ClassAdapter.class)
- public ClassDescription getTagHandler() {
- return tagHandler;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @param tagHandler the tagHandler to set
- */
- public void setTagHandler(ClassDescription tagHandler) {
- this.tagHandler = tagHandler;
- }
-
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param tagHandler the tagHandler to set
+ */
+ public void setTagHandler(ClassDescription tagHandler) {
+ this.tagHandler = tagHandler;
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ExtensibleBean.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ExtensibleBean.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ExtensibleBean.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.xmlconfig.model;
import org.richfaces.cdk.model.ConfigExtension;
@@ -31,25 +33,22 @@
* @author asmirnov(a)exadel.com
*
*/
-public class ExtensibleBean<E extends ConfigExtension> extends DescriptionGroupBean
implements
- Extensible<E> {
-
- private E extension;
+public class ExtensibleBean<E extends ConfigExtension> extends DescriptionGroupBean
implements Extensible<E> {
+ private E extension;
- /**
- * <p class="changed_added_4_0"></p>
- * @return the extension
- */
- public E getExtension() {
- return extension;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the extension
+ */
+ public E getExtension() {
+ return extension;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param extension the extension to set
- */
- public void setExtension(E extension) {
- this.extension = extension;
- }
-
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param extension the extension to set
+ */
+ public void setExtension(E extension) {
+ this.extension = extension;
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/FacesConfigAdapter.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/FacesConfigAdapter.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/FacesConfigAdapter.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.xmlconfig.model;
import javax.xml.bind.annotation.adapters.XmlAdapter;
@@ -34,19 +36,20 @@
*
*/
public class FacesConfigAdapter extends XmlAdapter<FacesConfigBean,
ComponentLibrary> {
+ @Override
+ public FacesConfigBean marshal(ComponentLibrary v) throws Exception {
+ FacesConfigBean facesConfigBean =
JAXBBinding.createAdapter(FacesConfigBean.class, v);
- @Override
- public FacesConfigBean marshal(ComponentLibrary v) throws Exception {
- FacesConfigBean facesConfigBean = JAXBBinding.createAdapter(FacesConfigBean.class, v);
- return facesConfigBean;
- }
+ return facesConfigBean;
+ }
- @Override
- public ComponentLibrary unmarshal(FacesConfigBean v) throws Exception {
- ComponentLibrary library = new ComponentLibrary();
- JAXBBinding.copyProperties(v, library);
- JAXBBinding.copyExtensions(v, library, false);
- return library;
- }
+ @Override
+ public ComponentLibrary unmarshal(FacesConfigBean v) throws Exception {
+ ComponentLibrary library = new ComponentLibrary();
+ JAXBBinding.copyProperties(v, library);
+ JAXBBinding.copyExtensions(v, library, false);
+
+ return library;
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/FacesConfigBean.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/FacesConfigBean.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/FacesConfigBean.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.xmlconfig.model;
import java.util.List;
@@ -44,101 +46,98 @@
* @author asmirnov(a)exadel.com
*
*/
-@XmlRootElement(name="faces-config",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
+@XmlRootElement(name = "faces-config", namespace =
ComponentLibrary.FACES_CONFIG_NAMESPACE)
public class FacesConfigBean implements
Extensible<FacesConfigBean.FacesConfigExtension> {
+ @XmlElement(name = "component", namespace =
ComponentLibrary.FACES_CONFIG_NAMESPACE)
+ @XmlJavaTypeAdapter(ComponentAdapter.class)
+ private List<Component> components = Lists.newArrayList();
+ @XmlElement(name = "render-kit", namespace =
ComponentLibrary.FACES_CONFIG_NAMESPACE)
+ @XmlJavaTypeAdapter(RenderKitAdapter.class)
+ private List<RenderKit> renderKits = Lists.newArrayList();
+ private String version = "2.0";
+ private FacesConfigExtension extension;
- public static final class FacesConfigExtension extends ConfigExtension {
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the version
+ */
+ @XmlAttribute
+ public String getVersion() {
+ return version;
+ }
- private List<Event> events = Lists.newArrayList();
- @XmlElement(name="faces-event",namespace=ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
- @XmlJavaTypeAdapter(EventAdapter.class)
- public List<Event> getEvents() {
- return events;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param version the version to set
+ */
+ public void setVersion(String version) {
+ this.version = version;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param events the events to set
- */
- public void setEvents(List<Event> events) {
- this.events = events;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the components
+ */
+ public List<Component> getComponents() {
+ return components;
+ }
- }
- @XmlElement(name="component",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
- @XmlJavaTypeAdapter(ComponentAdapter.class)
- private List<Component> components = Lists.newArrayList();
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param components the components to set
+ */
+ public void setComponents(List<Component> components) {
+ this.components = components;
+ }
- @XmlElement(name="render-kit",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
- @XmlJavaTypeAdapter(RenderKitAdapter.class)
- private List<RenderKit> renderKits = Lists.newArrayList();
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the renderKits
+ */
+ public List<RenderKit> getRenderKits() {
+ return renderKits;
+ }
- private FacesConfigExtension extension;
-
- private String version="2.0";
- /**
- * <p class="changed_added_4_0"></p>
- * @return the version
- */
- @XmlAttribute
- public String getVersion() {
- return version;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param renderKits the renderKits to set
+ */
+ public void setRenderKits(List<RenderKit> renderKits) {
+ this.renderKits = renderKits;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param version the version to set
- */
- public void setVersion(String version) {
- this.version = version;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the extension
+ */
+ @XmlElement(name = "faces-config-extension", namespace =
ComponentLibrary.FACES_CONFIG_NAMESPACE)
+ public FacesConfigExtension getExtension() {
+ return extension;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the components
- */
- public List<Component> getComponents() {
- return components;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param extension the extension to set
+ */
+ public void setExtension(FacesConfigExtension extension) {
+ this.extension = extension;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param components the components to set
- */
- public void setComponents(List<Component> components) {
- this.components = components;
- }
+ public static final class FacesConfigExtension extends ConfigExtension {
+ private List<Event> events = Lists.newArrayList();
- /**
- * <p class="changed_added_4_0"></p>
- * @return the renderKits
- */
- public List<RenderKit> getRenderKits() {
- return renderKits;
- }
+ @XmlElement(name = "faces-event", namespace =
ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
+ @XmlJavaTypeAdapter(EventAdapter.class)
+ public List<Event> getEvents() {
+ return events;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param renderKits the renderKits to set
- */
- public void setRenderKits(List<RenderKit> renderKits) {
- this.renderKits = renderKits;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @return the extension
- */
- @XmlElement(name="faces-config-extension",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
- public FacesConfigExtension getExtension() {
- return extension;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @param extension the extension to set
- */
- public void setExtension(FacesConfigExtension extension) {
- this.extension = extension;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param events the events to set
+ */
+ public void setEvents(List<Event> events) {
+ this.events = events;
+ }
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/FacetAdapter.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/FacetAdapter.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/FacetAdapter.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.xmlconfig.model;
import javax.xml.bind.annotation.adapters.XmlAdapter;
@@ -34,15 +36,13 @@
*
*/
public class FacetAdapter extends XmlAdapter<FacetBean, Facet> {
+ @Override
+ public FacetBean marshal(Facet v) throws Exception {
+ return JAXBBinding.createAdapter(FacetBean.class, v);
+ }
- @Override
- public FacetBean marshal(Facet v) throws Exception {
- return JAXBBinding.createAdapter(FacetBean.class, v);
- }
-
- @Override
- public Facet unmarshal(FacetBean v) throws Exception {
- return JAXBBinding.createModelElement(Facet.class, v, new Facet.Name(v.getName()));
- }
-
+ @Override
+ public Facet unmarshal(FacetBean v) throws Exception {
+ return JAXBBinding.createModelElement(Facet.class, v, new
Facet.Name(v.getName()));
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/FacetBean.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/FacetBean.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/FacetBean.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.xmlconfig.model;
import javax.xml.bind.annotation.XmlElement;
@@ -33,67 +35,63 @@
* @author asmirnov(a)exadel.com
*
*/
-public class FacetBean extends ExtensibleBean<FacetBean.FacetExtension>{
+public class FacetBean extends ExtensibleBean<FacetBean.FacetExtension> {
+ private String name;
- /**
- * <p class="changed_added_4_0"></p>
- * @author asmirnov(a)exadel.com
- *
- */
- public static final class FacetExtension extends ConfigExtension {
-
- private boolean generate;
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the name
+ */
+ @XmlElement(name = "facet-name", namespace =
ComponentLibrary.FACES_CONFIG_NAMESPACE)
+ public String getName() {
+ return name;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the generate
- */
- @XmlElement(name="generate",namespace=ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
- public boolean isGenerate() {
- return generate;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param name the name to set
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param generate the generate to set
- */
- public void setGenerate(boolean generate) {
- this.generate = generate;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the extension
+ */
+ @XmlElement(name = "facet-extension", namespace =
ComponentLibrary.FACES_CONFIG_NAMESPACE)
+ public FacetExtension getExtension() {
+ return super.getExtension();
+ }
- }
-
- private String name;
+ @Override
+ public void setExtension(FacetExtension extension) {
+ super.setExtension(extension);
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the name
- */
- @XmlElement(name="facet-name",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
- public String getName() {
- return name;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+ public static final class FacetExtension extends ConfigExtension {
+ private boolean generate;
- /**
- * <p class="changed_added_4_0"></p>
- * @param name the name to set
- */
- public void setName(String name) {
- this.name = name;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the generate
+ */
+ @XmlElement(name = "generate", namespace =
ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
+ public boolean isGenerate() {
+ return generate;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the extension
- */
- @XmlElement(name="facet-extension",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
- public FacetExtension getExtension() {
- return super.getExtension();
- }
-
- @Override
- public void setExtension(FacetExtension extension) {
- super.setExtension(extension);
- }
-
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param generate the generate to set
+ */
+ public void setGenerate(boolean generate) {
+ this.generate = generate;
+ }
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/Properties.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/Properties.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/Properties.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.xmlconfig.model;
import java.util.List;
@@ -39,25 +41,30 @@
* @author asmirnov(a)exadel.com
*
*/
-@XmlRootElement(name="properties",namespace=ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
+@XmlRootElement(name = "properties", namespace =
ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
public class Properties {
- private List<Property> property = Lists.newArrayList();
+ private List<Property> property = Lists.newArrayList();
- /**
- * <p class="changed_added_4_0"></p>
- * @return the property
- */
- @XmlElements({@XmlElement(name="property",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE,type=PropertyBean.class),(a)XmlElement(name="attribute",type=PropertyBean.class)})
-// @XmlElement(name="property",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
- public List<Property> getProperty() {
- return property;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the property
+ */
+ @XmlElements({@XmlElement(
+ name = "property",
+ namespace = ComponentLibrary.FACES_CONFIG_NAMESPACE,
+ type = PropertyBean.class
+ ) , @XmlElement(name = "attribute", type = PropertyBean.class) })
- /**
- * <p class="changed_added_4_0"></p>
- * @param property the property to set
- */
- public void setProperty(List<Property> property) {
- this.property = property;
- }
+//
@XmlElement(name="property",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
+ public List<Property> getProperty() {
+ return property;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param property the property to set
+ */
+ public void setProperty(List<Property> property) {
+ this.property = property;
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/PropertyAdapter.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/PropertyAdapter.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/PropertyAdapter.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.xmlconfig.model;
import javax.xml.bind.annotation.adapters.XmlAdapter;
@@ -34,15 +36,13 @@
*
*/
public class PropertyAdapter extends XmlAdapter<PropertyBean, Property> {
+ @Override
+ public PropertyBean marshal(Property v) throws Exception {
+ return JAXBBinding.createAdapter(PropertyBean.class, v);
+ }
- @Override
- public PropertyBean marshal(Property v) throws Exception {
- return JAXBBinding.createAdapter(PropertyBean.class, v);
- }
-
- @Override
- public Property unmarshal(PropertyBean v) throws Exception {
- return JAXBBinding.createModelElement(Property.class, v, new
Property.Name(v.getName()));
- }
-
+ @Override
+ public Property unmarshal(PropertyBean v) throws Exception {
+ return JAXBBinding.createModelElement(Property.class, v, new
Property.Name(v.getName()));
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/PropertyBean.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/PropertyBean.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/PropertyBean.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.xmlconfig.model;
import java.util.List;
@@ -44,273 +46,259 @@
*
*/
public class PropertyBean extends ExtensibleBean<PropertyBean.PropertyExtension> {
+ private String defaultValue;
+ private String name;
+ private String suggestedValue;
+ private ClassDescription type;
- /**
- * <p class="changed_added_4_0"></p>
- * @author asmirnov(a)exadel.com
- *
- */
- public static class PropertyExtension extends ConfigExtension {
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the name
+ */
+ @XmlElement(name = "property-name", namespace =
ComponentLibrary.FACES_CONFIG_NAMESPACE)
+ public String getName() {
+ return name;
+ }
- private boolean generate;
-
- private boolean hidden;
-
- private boolean literal;
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param name the name to set
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
- private boolean required;
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the type
+ */
+ @XmlElement(name = "property-class", namespace =
ComponentLibrary.FACES_CONFIG_NAMESPACE)
+ @XmlJavaTypeAdapter(ClassAdapter.class)
+ public ClassDescription getType() {
+ return type;
+ }
- private boolean readOnly;
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param type the type to set
+ */
+ public void setType(ClassDescription type) {
+ this.type = type;
+ }
- private boolean passThrough=false;
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the defaultValue
+ */
+ @XmlElement(name = "default-value", namespace =
ComponentLibrary.FACES_CONFIG_NAMESPACE)
+ public String getDefaultValue() {
+ return defaultValue;
+ }
- private Set<EventName> eventNames = Sets.newHashSet();
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param defaultValue the defaultValue to set
+ */
+ public void setDefaultValue(String defaultValue) {
+ this.defaultValue = defaultValue;
+ }
- private List<ClassDescription> signature = Lists.newArrayList();
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the suggestedValue
+ */
+ @XmlElement(name = "suggested-value", namespace =
ComponentLibrary.FACES_CONFIG_NAMESPACE)
+ public String getSuggestedValue() {
+ return suggestedValue;
+ }
- private Set<String> aliases = Sets.newHashSet();
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param suggestedValue the suggestedValue to set
+ */
+ public void setSuggestedValue(String suggestedValue) {
+ this.suggestedValue = suggestedValue;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the generate
- */
- @XmlElement(name="generate",namespace=ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
- public boolean isGenerate() {
- return generate;
- }
+ @Override
+ @XmlElement(name = "property-extension", namespace =
ComponentLibrary.FACES_CONFIG_NAMESPACE)
+ public PropertyExtension getExtension() {
+ return super.getExtension();
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param generate the generate to set
- */
- public void setGenerate(boolean generate) {
- this.generate = generate;
- }
+ @Override
+ public void setExtension(PropertyExtension extension) {
+ super.setExtension(extension);
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the hidden
- */
- @XmlElement(name="hidden",namespace=ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
- public boolean isHidden() {
- return hidden;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+ public static class PropertyExtension extends ConfigExtension {
+ private boolean passThrough = false;
+ private Set<EventName> eventNames = Sets.newHashSet();
+ private List<ClassDescription> signature = Lists.newArrayList();
+ private Set<String> aliases = Sets.newHashSet();
+ private boolean generate;
+ private boolean hidden;
+ private boolean literal;
+ private boolean readOnly;
+ private boolean required;
- /**
- * <p class="changed_added_4_0"></p>
- * @param hidden the hidden to set
- */
- public void setHidden(boolean hidden) {
- this.hidden = hidden;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the generate
+ */
+ @XmlElement(name = "generate", namespace =
ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
+ public boolean isGenerate() {
+ return generate;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the literal
- */
- @XmlElement(name="literal",namespace=ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
- public boolean isLiteral() {
- return literal;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param generate the generate to set
+ */
+ public void setGenerate(boolean generate) {
+ this.generate = generate;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param literal the literal to set
- */
- public void setLiteral(boolean literal) {
- this.literal = literal;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the hidden
+ */
+ @XmlElement(name = "hidden", namespace =
ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
+ public boolean isHidden() {
+ return hidden;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the required
- */
- @XmlElement(name="required",namespace=ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
- public boolean isRequired() {
- return required;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param hidden the hidden to set
+ */
+ public void setHidden(boolean hidden) {
+ this.hidden = hidden;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param required the required to set
- */
- public void setRequired(boolean required) {
- this.required = required;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the literal
+ */
+ @XmlElement(name = "literal", namespace =
ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
+ public boolean isLiteral() {
+ return literal;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the readOnly
- */
- public boolean isReadOnly() {
- return readOnly;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param literal the literal to set
+ */
+ public void setLiteral(boolean literal) {
+ this.literal = literal;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param readOnly the readOnly to set
- */
- public void setReadOnly(boolean readOnly) {
- this.readOnly = readOnly;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the required
+ */
+ @XmlElement(name = "required", namespace =
ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
+ public boolean isRequired() {
+ return required;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the passThrough
- */
- @XmlElement(name="pass-through",namespace=ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
- public boolean isPassThrough() {
- return passThrough;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param required the required to set
+ */
+ public void setRequired(boolean required) {
+ this.required = required;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param passThrough the passThrough to set
- */
- public void setPassThrough(boolean passThrough) {
- this.passThrough = passThrough;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the readOnly
+ */
+ public boolean isReadOnly() {
+ return readOnly;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the eventNames
- */
- @XmlElement(name="event-name",namespace=ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
- public Set<EventName> getEventNames() {
- return eventNames;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param readOnly the readOnly to set
+ */
+ public void setReadOnly(boolean readOnly) {
+ this.readOnly = readOnly;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param eventNames the eventNames to set
- */
- public void setEventNames(Set<EventName> eventNames) {
- this.eventNames = eventNames;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the passThrough
+ */
+ @XmlElement(name = "pass-through", namespace =
ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
+ public boolean isPassThrough() {
+ return passThrough;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the signature
- */
- @XmlElementWrapper(name="signature",namespace=ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
- @XmlElement(name="param",namespace=ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
- @XmlJavaTypeAdapter(ClassAdapter.class)
- public List<ClassDescription> getSignature() {
- return signature;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param passThrough the passThrough to set
+ */
+ public void setPassThrough(boolean passThrough) {
+ this.passThrough = passThrough;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param signature the signature to set
- */
- public void setSignature(List<ClassDescription> signature) {
- this.signature = signature;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the eventNames
+ */
+ @XmlElement(name = "event-name", namespace =
ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
+ public Set<EventName> getEventNames() {
+ return eventNames;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the aliases
- */
- @XmlElement(name="alias",namespace=ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
- public Set<String> getAliases() {
- return aliases;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param eventNames the eventNames to set
+ */
+ public void setEventNames(Set<EventName> eventNames) {
+ this.eventNames = eventNames;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param aliases the aliases to set
- */
- public void setAliases(Set<String> aliases) {
- this.aliases = aliases;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the signature
+ */
+ @XmlElementWrapper(name = "signature", namespace =
ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
+ @XmlElement(name = "param", namespace =
ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
+ @XmlJavaTypeAdapter(ClassAdapter.class)
+ public List<ClassDescription> getSignature() {
+ return signature;
+ }
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param signature the signature to set
+ */
+ public void setSignature(List<ClassDescription> signature) {
+ this.signature = signature;
+ }
- private String name;
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the aliases
+ */
+ @XmlElement(name = "alias", namespace =
ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
+ public Set<String> getAliases() {
+ return aliases;
+ }
- private ClassDescription type;
-
- private String defaultValue;
-
- private String suggestedValue;
-
- /**
- * <p class="changed_added_4_0"></p>
- * @return the name
- */
- @XmlElement(name="property-name",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
- public String getName() {
- return name;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @param name the name to set
- */
- public void setName(String name) {
- this.name = name;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @return the type
- */
- @XmlElement(name="property-class",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
- @XmlJavaTypeAdapter(ClassAdapter.class)
- public ClassDescription getType() {
- return type;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @param type the type to set
- */
- public void setType(ClassDescription type) {
- this.type = type;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @return the defaultValue
- */
- @XmlElement(name="default-value",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
- public String getDefaultValue() {
- return defaultValue;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @param defaultValue the defaultValue to set
- */
- public void setDefaultValue(String defaultValue) {
- this.defaultValue = defaultValue;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @return the suggestedValue
- */
- @XmlElement(name="suggested-value",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
- public String getSuggestedValue() {
- return suggestedValue;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @param suggestedValue the suggestedValue to set
- */
- public void setSuggestedValue(String suggestedValue) {
- this.suggestedValue = suggestedValue;
- }
-
- @Override
- @XmlElement(name="property-extension",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
- public PropertyExtension getExtension() {
- return super.getExtension();
- }
-
- @Override
- public void setExtension(PropertyExtension extension) {
- super.setExtension(extension);
- }
-}
\ No newline at end of file
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param aliases the aliases to set
+ */
+ public void setAliases(Set<String> aliases) {
+ this.aliases = aliases;
+ }
+ }
+}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/RenderKitAdapter.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/RenderKitAdapter.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/RenderKitAdapter.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.xmlconfig.model;
import javax.xml.bind.annotation.adapters.XmlAdapter;
@@ -34,15 +36,13 @@
*
*/
public class RenderKitAdapter extends XmlAdapter<RenderKitBean, RenderKit> {
+ @Override
+ public RenderKitBean marshal(RenderKit v) throws Exception {
+ return JAXBBinding.createAdapter(RenderKitBean.class, v);
+ }
- @Override
- public RenderKitBean marshal(RenderKit v) throws Exception {
- return JAXBBinding.createAdapter(RenderKitBean.class, v);
- }
-
- @Override
- public RenderKit unmarshal(RenderKitBean v) throws Exception {
- return JAXBBinding.createModelElement(RenderKit.class, v, new
RenderKit.Id(v.getId()));
- }
-
+ @Override
+ public RenderKit unmarshal(RenderKitBean v) throws Exception {
+ return JAXBBinding.createModelElement(RenderKit.class, v, new
RenderKit.Id(v.getId()));
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/RenderKitBean.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/RenderKitBean.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/RenderKitBean.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -21,12 +21,14 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.richfaces.cdk.xmlconfig.model;
+package org.richfaces.cdk.xmlconfig.model;
+
import java.util.List;
import javax.faces.render.RenderKitFactory;
+
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
@@ -43,95 +45,88 @@
* @author asmirnov(a)exadel.com
*
*/
-public class RenderKitBean extends
ExtensibleBean<RenderKitBean.RenderKitExtension>{
+public class RenderKitBean extends ExtensibleBean<RenderKitBean.RenderKitExtension>
{
+ @XmlElement(name = "render-kit-id", namespace =
ComponentLibrary.FACES_CONFIG_NAMESPACE)
+ private String id = RenderKitFactory.HTML_BASIC_RENDER_KIT;
+ @XmlElement(name = "renderer", namespace =
ComponentLibrary.FACES_CONFIG_NAMESPACE)
+ @XmlJavaTypeAdapter(RendererAdapter.class)
+ private List<Renderer> renderers = Lists.newArrayList();
+ @XmlElement(name = "client-behavior-renderer", namespace =
ComponentLibrary.FACES_CONFIG_NAMESPACE)
+ @XmlJavaTypeAdapter(BehaviorRendererAdapter.class)
+ private List<BehaviorRenderer> behaviorRenderers = Lists.newArrayList();
+ @XmlElement(name = "render-kit-class", namespace =
ComponentLibrary.FACES_CONFIG_NAMESPACE)
+ @XmlJavaTypeAdapter(ClassAdapter.class)
+ private ClassDescription renderkitClass;
- /**
- * <p class="changed_added_4_0"></p>
- * @author asmirnov(a)exadel.com
- *
- */
- public static class RenderKitExtension extends ConfigExtension {
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the renderkitClass
+ */
+ public ClassDescription getRenderkitClass() {
+ return renderkitClass;
+ }
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param renderkitClass the renderkitClass to set
+ */
+ public void setRenderkitClass(ClassDescription renderkitClass) {
+ this.renderkitClass = renderkitClass;
+ }
-
- @XmlElement(name="render-kit-id",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
- private String id = RenderKitFactory.HTML_BASIC_RENDER_KIT;
-
- @XmlElement(name="render-kit-class",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
- @XmlJavaTypeAdapter(ClassAdapter.class)
- private ClassDescription renderkitClass;
-
- @XmlElement(name="renderer",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
- @XmlJavaTypeAdapter(RendererAdapter.class)
- private List<Renderer> renderers = Lists.newArrayList();
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the id
+ */
+ public String getId() {
+ return id;
+ }
- @XmlElement(name="client-behavior-renderer",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
- @XmlJavaTypeAdapter(BehaviorRendererAdapter.class)
- private List<BehaviorRenderer> behaviorRenderers = Lists.newArrayList();
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param id the id to set
+ */
+ public void setId(String id) {
+ this.id = id;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the renderkitClass
- */
- public ClassDescription getRenderkitClass() {
- return renderkitClass;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the renderers
+ */
+ public List<Renderer> getRenderers() {
+ return renderers;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param renderkitClass the renderkitClass to set
- */
- public void setRenderkitClass(ClassDescription renderkitClass) {
- this.renderkitClass = renderkitClass;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param renderers the renderers to set
+ */
+ public void setRenderers(List<Renderer> renderers) {
+ this.renderers = renderers;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the id
- */
- public String getId() {
- return id;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the extension
+ */
+ @XmlElement(name = "render-kit-extension", namespace =
ComponentLibrary.FACES_CONFIG_NAMESPACE)
+ public RenderKitExtension getExtension() {
+ return super.getExtension();
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param id the id to set
- */
- public void setId(String id) {
- this.id = id;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param extension the extension to set
+ */
+ public void setExtension(RenderKitExtension extension) {
+ super.setExtension(extension);
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the renderers
- */
- public List<Renderer> getRenderers() {
- return renderers;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @param renderers the renderers to set
- */
- public void setRenderers(List<Renderer> renderers) {
- this.renderers = renderers;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @return the extension
- */
- @XmlElement(name="render-kit-extension",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
- public RenderKitExtension getExtension() {
- return super.getExtension();
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @param extension the extension to set
- */
- public void setExtension(RenderKitExtension extension) {
- super.setExtension(extension);
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+ public static class RenderKitExtension extends ConfigExtension {}
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/RendererAdapter.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/RendererAdapter.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/RendererAdapter.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.xmlconfig.model;
import javax.xml.bind.annotation.adapters.XmlAdapter;
@@ -34,15 +36,13 @@
*
*/
public class RendererAdapter extends XmlAdapter<RendererBean, Renderer> {
+ @Override
+ public RendererBean marshal(Renderer v) throws Exception {
+ return JAXBBinding.createAdapter(RendererBean.class, v);
+ }
- @Override
- public RendererBean marshal(Renderer v) throws Exception {
- return JAXBBinding.createAdapter(RendererBean.class, v);
- }
-
- @Override
- public Renderer unmarshal(RendererBean v) throws Exception {
- return JAXBBinding.createModelElement(Renderer.class, v, new
Renderer.Type(v.getType()));
- }
-
+ @Override
+ public Renderer unmarshal(RendererBean v) throws Exception {
+ return JAXBBinding.createModelElement(Renderer.class, v, new
Renderer.Type(v.getType()));
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/RendererBean.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/RendererBean.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/RendererBean.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.xmlconfig.model;
import javax.xml.bind.annotation.XmlElement;
@@ -36,87 +38,82 @@
* @author asmirnov(a)exadel.com
*
*/
-@XmlType(name="faces-config-rendererType",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
-public class RendererBean extends ExtensibleBean<RendererBean.RendererExtension>{
+@XmlType(name = "faces-config-rendererType", namespace =
ComponentLibrary.FACES_CONFIG_NAMESPACE)
+public class RendererBean extends ExtensibleBean<RendererBean.RendererExtension> {
+ private String family;
+ private ClassDescription rendererClass;
+ private String type;
- /**
- * <p class="changed_added_4_0"></p>
- * @author asmirnov(a)exadel.com
- *
- */
- public static class RendererExtension extends ConfigExtension {
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the type
+ */
+ @XmlElement(name = "renderer-type", namespace =
ComponentLibrary.FACES_CONFIG_NAMESPACE)
+ public String getType() {
+ return type;
+ }
- }
-
- private String type;
-
- private String family;
-
- private ClassDescription rendererClass;
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param type the type to set
+ */
+ public void setType(String type) {
+ this.type = type;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the type
- */
- @XmlElement(name="renderer-type",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
- public String getType() {
- return type;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the family
+ */
+ @XmlElement(name = "component-family", namespace =
ComponentLibrary.FACES_CONFIG_NAMESPACE)
+ public String getFamily() {
+ return family;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param type the type to set
- */
- public void setType(String type) {
- this.type = type;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param family the family to set
+ */
+ public void setFamily(String family) {
+ this.family = family;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the family
- */
- @XmlElement(name="component-family",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
- public String getFamily() {
- return family;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the rendererClass
+ */
+ @XmlElement(name = "renderer-class", namespace =
ComponentLibrary.FACES_CONFIG_NAMESPACE)
+ @XmlJavaTypeAdapter(ClassAdapter.class)
+ public ClassDescription getRendererClass() {
+ return rendererClass;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param family the family to set
- */
- public void setFamily(String family) {
- this.family = family;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param rendererClass the rendererClass to set
+ */
+ public void setRendererClass(ClassDescription rendererClass) {
+ this.rendererClass = rendererClass;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the rendererClass
- */
- @XmlElement(name="renderer-class",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
- @XmlJavaTypeAdapter(ClassAdapter.class)
- public ClassDescription getRendererClass() {
- return rendererClass;
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the extension
+ */
+ @XmlElement(name = "renderer-extension", namespace =
ComponentLibrary.FACES_CONFIG_NAMESPACE)
+ public RendererExtension getExtension() {
+ return super.getExtension();
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param rendererClass the rendererClass to set
- */
- public void setRendererClass(ClassDescription rendererClass) {
- this.rendererClass = rendererClass;
- }
+ @Override
+ public void setExtension(RendererExtension extension) {
+ super.setExtension(extension);
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the extension
- */
- @XmlElement(name="renderer-extension",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
- public RendererExtension getExtension() {
- return super.getExtension();
- }
-
- @Override
- public void setExtension(RendererExtension extension) {
- super.setExtension(extension);
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+ public static class RendererExtension extends ConfigExtension {}
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/package-info.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/package-info.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/package-info.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -1,21 +1,22 @@
/**
* <h2>JAXB classes that wraps real model classes.</h2>
- * <p>Some model requirements do not match JAXB plain bean model. The most
important case is requirements for unique Id's like component and renderer type.
- * the other important difference is model properties which do not map to faces-config
schema but moved into <<....-extension> elements.</p>
- *
+ * <p>Some model requirements do not match JAXB plain bean model. The most
important case is requirements for unique
+ * Id's like component and renderer type. the other important difference is model
properties which do not map to
+ * faces-config schema but moved into <<....-extension>
elements.</p>
+ *
*/
@XmlAccessorType(XmlAccessType.NONE)
-(a)javax.xml.bind.annotation.XmlSchema(namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE,
- location=ComponentLibrary.FACES_CONFIG_SCHEMA_LOCATION,
- xmlns = { @javax.xml.bind.annotation.XmlNs( prefix = "cdk",
- namespaceURI = ComponentLibrary.CDK_EXTENSIONS_NAMESPACE ) })
-@XmlJavaTypeAdapters({(a)XmlJavaTypeAdapter(type=Property.class,value=PropertyAdapter.class),
- @XmlJavaTypeAdapter(type=Attribute.class,value=AttributeAdapter.class),
- @XmlJavaTypeAdapter(type=ClassDescription.class,value=ClassAdapter.class),
- @XmlJavaTypeAdapter(type=ComponentLibrary.class,value=FacesConfigAdapter.class)
- })
+(a)javax.xml.bind.annotation.XmlSchema(namespace =
ComponentLibrary.FACES_CONFIG_NAMESPACE,
+ location = ComponentLibrary.FACES_CONFIG_SCHEMA_LOCATION,
+ xmlns = {(a)javax.xml.bind.annotation.XmlNs(prefix = "cdk",
+ namespaceURI = ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)})
+@XmlJavaTypeAdapters({@XmlJavaTypeAdapter(type = Property.class, value =
PropertyAdapter.class),
+ @XmlJavaTypeAdapter(type = Attribute.class, value = AttributeAdapter.class),
+ @XmlJavaTypeAdapter(type = ClassDescription.class, value = ClassAdapter.class),
+ @XmlJavaTypeAdapter(type = ComponentLibrary.class, value =
FacesConfigAdapter.class)
+})
+package org.richfaces.cdk.xmlconfig.model;
-package org.richfaces.cdk.xmlconfig.model;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/NamesListComparator.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/NamesListComparator.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/NamesListComparator.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -19,6 +19,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.xmlutils;
import java.util.Comparator;
@@ -29,60 +31,60 @@
* @author Nick Belaevski
* @since 3.2.2
*/
-
public class NamesListComparator implements Comparator<Node> {
+ private Comparator<Node> comparator;
+ private String[] names;
- private Comparator<Node> comparator;
- private String[] names;
-
- public NamesListComparator(Comparator<Node> comparator, String[] names) {
- super();
- this.comparator = comparator;
- this.names = names;
- }
+ public NamesListComparator(Comparator<Node> comparator, String[] names) {
+ super();
+ this.comparator = comparator;
+ this.names = names;
+ }
- private final int getOrder(String s) {
- for (int i = 0; i < names.length; i++) {
- if (names[i].equals(s)) {
- return i;
- }
- }
-
- return -1;
- }
+ private final int getOrder(String s) {
+ for (int i = 0; i < names.length; i++) {
+ if (names[i].equals(s)) {
+ return i;
+ }
+ }
- private String getNodeName(Node node) {
- String name = node.getLocalName();
- if (name == null) {
- name = node.getNodeName();
- }
-
- return name;
- }
-
- public int compare(Node o1, Node o2) {
- String name1 = getNodeName(o1);
- String name2 = getNodeName(o2);
-
- if (name1 != null && name2 != null && !name1.equals(name2)) {
- int order1 = getOrder(name1);
- if (order1 < 0) {
- System.out.println("Tag: " + name1 + " is unknown!");
- }
-
- int order2 = getOrder(name2);
- if (order2 < 0) {
- System.out.println("Tag: " + name2 + " is unknown!");
- }
+ return -1;
+ }
- if (order1 < order2) {
- return -1;
- } else if (order1 > order2) {
- return 1;
- }
- }
-
- return comparator.compare(o1, o2);
- }
+ private String getNodeName(Node node) {
+ String name = node.getLocalName();
+ if (name == null) {
+ name = node.getNodeName();
+ }
+
+ return name;
+ }
+
+ public int compare(Node o1, Node o2) {
+ String name1 = getNodeName(o1);
+ String name2 = getNodeName(o2);
+
+ if (name1 != null && name2 != null && !name1.equals(name2)) {
+ int order1 = getOrder(name1);
+
+ if (order1 < 0) {
+ System.out.println("Tag: " + name1 + " is
unknown!");
+ }
+
+ int order2 = getOrder(name2);
+
+ if (order2 < 0) {
+ System.out.println("Tag: " + name2 + " is
unknown!");
+ }
+
+ if (order1 < order2) {
+ return -1;
+ } else if (order1 > order2) {
+ return 1;
+ }
+ }
+
+ return comparator.compare(o1, o2);
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/ParsingException.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/ParsingException.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/ParsingException.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -4,41 +4,40 @@
public class ParsingException extends CdkException {
- /**
- * <p class="changed_added_4_0"></p>
- */
- private static final long serialVersionUID = 1629210103196620913L;
+ /**
+ * <p class="changed_added_4_0"></p>
+ */
+ private static final long serialVersionUID = 1629210103196620913L;
- /**
- * <p class="changed_added_4_0"></p>
- */
- public ParsingException() {
- super();
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ */
+ public ParsingException() {
+ super();
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param message
- * @param cause
- */
- public ParsingException(String message, Throwable cause) {
- super(message, cause);
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param message
+ */
+ public ParsingException(String message) {
+ super(message);
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param message
- */
- public ParsingException(String message) {
- super(message);
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param cause
+ */
+ public ParsingException(Throwable cause) {
+ super(cause);
+ }
- /**
- * <p class="changed_added_4_0"></p>
- * @param cause
- */
- public ParsingException(Throwable cause) {
- super(cause);
- }
-
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param message
+ * @param cause
+ */
+ public ParsingException(String message, Throwable cause) {
+ super(message, cause);
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/XMLBody.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/XMLBody.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/XMLBody.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -19,11 +19,14 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.xmlutils;
import java.io.IOException;
import java.io.InputStream;
import java.io.StringReader;
+
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
@@ -40,180 +43,189 @@
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
+
import org.xml.sax.EntityResolver;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
+class ArrayNodeList implements NodeList {
+ private Node[] nodes;
+
+ public ArrayNodeList(Node[] nodes) {
+ super();
+ this.nodes = nodes;
+ }
+
+ public int getLength() {
+ return nodes.length;
+ }
+
+ public Node item(int index) {
+ if (index < nodes.length) {
+ return this.nodes[index];
+ }
+
+ return null;
+ }
+}
+
+
/**
* This class must read XML file from input stream and can extract body of root
* element for include into target in generation.
- *
+ *
* @author shura
- *
+ *
*/
public class XMLBody {
- private Document xmlDocument;
+ private Element rootElement;
+ private Document xmlDocument;
- private Element rootElement;
+ /**
+ * Load XML document and parse it into DOM.
+ *
+ * @param input
+ * @throws ParsingException
+ */
+ public void loadXML(InputStream input) throws ParsingException {
+ loadXML(input, false);
+ }
- /**
- * Load XML document and parse it into DOM.
- *
- * @param input
- * @throws ParsingException
- */
- public void loadXML(InputStream input) throws ParsingException {
- loadXML(input,false);
- }
+ /**
+ * Load XML document and parse it into DOM.
+ *
+ * @param input
+ * @throws ParsingException
+ */
+ public void loadXML(InputStream input, boolean namespaceAware) throws
ParsingException {
+ try {
-
- /**
- * Load XML document and parse it into DOM.
- *
- * @param input
- * @throws ParsingException
- */
- public void loadXML(InputStream input, boolean namespaceAware) throws ParsingException
{
- try {
- // Create Document Builder Factory
- DocumentBuilderFactory docFactory = DocumentBuilderFactory
- .newInstance();
- docFactory.setIgnoringElementContentWhitespace(true);
- docFactory.setValidating(false);
- docFactory.setNamespaceAware(namespaceAware);
- // Create Document Builder
- DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
- //docBuilder.
- //docBuilder.isValidating();
-
- // Disable loading of external Entityes
- docBuilder.setEntityResolver(new EntityResolver() {
- // Dummi resolver - alvays do nothing
- public InputSource resolveEntity(String publicId, String systemId)
- throws SAXException, IOException {
- return new InputSource(new StringReader(""));
- }
+ // Create Document Builder Factory
+ DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
- });
+ docFactory.setIgnoringElementContentWhitespace(true);
+ docFactory.setValidating(false);
+ docFactory.setNamespaceAware(namespaceAware);
- // open and parse XML-file
- xmlDocument = docBuilder.parse(input);
+ // Create Document Builder
+ DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
- // Get Root xmlElement
- rootElement = xmlDocument.getDocumentElement();
- } catch (Exception e) {
- throw new ParsingException("Error load XML ", e);
- }
+ // docBuilder.
+ // docBuilder.isValidating();
+ // Disable loading of external Entityes
+ docBuilder.setEntityResolver(new EntityResolver() {
- }
+ // Dummi resolver - alvays do nothing
+ public InputSource resolveEntity(String publicId, String systemId) throws
SAXException, IOException {
+ return new InputSource(new StringReader(""));
+ }
+ });
- /**
- * Check name of root element is as expected.
- *
- * @param name
- * @return
- */
- public boolean isRootName(String name) {
- return rootElement.getNodeName().equals(name);
- }
+ // open and parse XML-file
+ xmlDocument = docBuilder.parse(input);
- public String getDoctype() {
- DocumentType doctype = xmlDocument.getDoctype();
- if (null != doctype) {
- return doctype.getName();
- }
- return null;
- }
+ // Get Root xmlElement
+ rootElement = xmlDocument.getDocumentElement();
+ } catch (Exception e) {
+ throw new ParsingException("Error load XML ", e);
+ }
+ }
- public String getPiblicId() {
- DocumentType doctype = xmlDocument.getDoctype();
- if (null != doctype) {
- return doctype.getPublicId();
- }
- return null;
- }
+ /**
+ * Check name of root element is as expected.
+ *
+ * @param name
+ * @return
+ */
+ public boolean isRootName(String name) {
+ return rootElement.getNodeName().equals(name);
+ }
- public String getRootTypeName() {
- return rootElement.getSchemaTypeInfo().getTypeName();
- }
+ public String getDoctype() {
+ DocumentType doctype = xmlDocument.getDoctype();
- public String getContent() throws ParsingException {
- NodeList childNodes = rootElement.getChildNodes();
- return serializeNodes(childNodes);
- }
+ if (null != doctype) {
+ return doctype.getName();
+ }
- private String serializeNodes(NodeList childNodes) throws ParsingException {
- try {
- return new XMLBodySerializer().serialize(childNodes, xmlDocument);
- } catch (Exception e) {
- throw new ParsingException(e);
- }
- }
-
- public String getContent(String xpath) throws ParsingException{
- return serializeNodes(getByXpath(xpath));
- }
+ return null;
+ }
- public NodeList getByXpath(String xpath) throws ParsingException {
- XPath path = XPathFactory.newInstance().newXPath();
- NodeList childNodes;
- try {
- childNodes = (NodeList) path.evaluate(xpath, xmlDocument, XPathConstants.NODESET);
- } catch (XPathExpressionException e) {
- throw new ParsingException("Error evaluate xpath",e);
- }
- return childNodes;
- }
-
- public NodeList getByXpathUnique(String xpath, String keyXPath, Set<String>
keySet) throws ParsingException {
- if (keyXPath == null) {
- return getByXpath(xpath);
- } else {
- XPath path = XPathFactory.newInstance().newXPath();
- NodeList childNodes;
- try {
- childNodes = getByXpath(xpath);
-
- List<Node> nodeSet = new ArrayList<Node>();
-
- for (int i = 0; i < childNodes.getLength(); i++) {
- Node node = childNodes.item(i).cloneNode(true);
-
- String key = serializeNodes((NodeList) path.evaluate(keyXPath, node,
XPathConstants.NODESET));
- if (!keySet.contains(key)) {
- keySet.add(key);
- nodeSet.add(node);
- }
- }
- return new ArrayNodeList(nodeSet.toArray(new Node[nodeSet.size()]));
- } catch (XPathExpressionException e) {
- throw new ParsingException("Error evaluate xpath",e);
- }
+ public String getPiblicId() {
+ DocumentType doctype = xmlDocument.getDoctype();
- }
- }
- public String getContentUnique(String xpath, String keyXPath, Set<String> keySet)
throws ParsingException{
- return serializeNodes(getByXpathUnique(xpath, keyXPath, keySet));
- }
-}
+ if (null != doctype) {
+ return doctype.getPublicId();
+ }
-class ArrayNodeList implements NodeList {
- private Node[] nodes;
+ return null;
+ }
- public ArrayNodeList(Node[] nodes) {
- super();
- this.nodes = nodes;
- }
+ public String getRootTypeName() {
+ return rootElement.getSchemaTypeInfo().getTypeName();
+ }
- public int getLength() {
- return nodes.length;
- }
+ public String getContent() throws ParsingException {
+ NodeList childNodes = rootElement.getChildNodes();
- public Node item(int index) {
- if (index < nodes.length) {
- return this.nodes[index];
- }
-
- return null;
- }
+ return serializeNodes(childNodes);
+ }
+
+ private String serializeNodes(NodeList childNodes) throws ParsingException {
+ try {
+ return new XMLBodySerializer().serialize(childNodes, xmlDocument);
+ } catch (Exception e) {
+ throw new ParsingException(e);
+ }
+ }
+
+ public String getContent(String xpath) throws ParsingException {
+ return serializeNodes(getByXpath(xpath));
+ }
+
+ public NodeList getByXpath(String xpath) throws ParsingException {
+ XPath path = XPathFactory.newInstance().newXPath();
+ NodeList childNodes;
+
+ try {
+ childNodes = (NodeList) path.evaluate(xpath, xmlDocument,
XPathConstants.NODESET);
+ } catch (XPathExpressionException e) {
+ throw new ParsingException("Error evaluate xpath", e);
+ }
+
+ return childNodes;
+ }
+
+ public NodeList getByXpathUnique(String xpath, String keyXPath, Set<String>
keySet) throws ParsingException {
+ if (keyXPath == null) {
+ return getByXpath(xpath);
+ } else {
+ XPath path = XPathFactory.newInstance().newXPath();
+ NodeList childNodes;
+
+ try {
+ childNodes = getByXpath(xpath);
+
+ List<Node> nodeSet = new ArrayList<Node>();
+
+ for (int i = 0; i < childNodes.getLength(); i++) {
+ Node node = childNodes.item(i).cloneNode(true);
+ String key = serializeNodes((NodeList) path.evaluate(keyXPath, node,
XPathConstants.NODESET));
+
+ if (!keySet.contains(key)) {
+ keySet.add(key);
+ nodeSet.add(node);
+ }
+ }
+
+ return new ArrayNodeList(nodeSet.toArray(new Node[nodeSet.size()]));
+ } catch (XPathExpressionException e) {
+ throw new ParsingException("Error evaluate xpath", e);
+ }
+ }
+ }
+
+ public String getContentUnique(String xpath, String keyXPath, Set<String>
keySet) throws ParsingException {
+ return serializeNodes(getByXpathUnique(xpath, keyXPath, keySet));
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/XMLBodyMerge.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/XMLBodyMerge.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/XMLBodyMerge.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -19,6 +19,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.xmlutils;
import java.util.ArrayList;
@@ -38,110 +40,109 @@
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
-
/**
* @author Maksim Kaszynski
*
*/
-public class XMLBodyMerge implements NodeList{
-
- private String xpath;
-
- private List<Node> nodes = new ArrayList<Node>();
-
- private Document document = null;
-
- private XPathExpression keyXpath = null;
-
- private StringBuffer content = new StringBuffer();
-
- private Set<String> keys = new HashSet<String>();
-
-
-
- public XMLBodyMerge(String xpath) {
- super();
- this.xpath = xpath;
- }
-
- public XMLBodyMerge(String xpath, String keyXpath) {
- this(xpath);
- if (keyXpath != null) {
- try {
- XPath newXPath = XPathFactory.newInstance().newXPath();
- this.keyXpath = newXPath.compile(keyXpath);
- } catch (XPathExpressionException e) {
- e.printStackTrace();
- }
- }
- }
-
- public void add(Node node) {
-
- if (keyXpath != null) {
- String key = getKey(node);
- if (key == null || keys.contains(key)) {
- return;
- }
- }
-
- if (document == null) {
- document = node.getOwnerDocument();
- } else {
- node = document.importNode(node, true);
- }
- nodes.add(node);
- }
-
- public void add(XMLBody xmlBody) throws ParsingException {
-
- if (xpath != null) {
- NodeList nodeList = xmlBody.getByXpath(xpath);
- if (nodeList != null) {
- for(int i = 0; i < nodeList.getLength(); i++) {
- add(nodeList.item(i));
- }
- }
- } else {
- content.append(xmlBody.getContent());
- }
-
- }
-
- public int getLength() {
- return nodes.size();
- }
-
- public Node item(int index) {
- if (index < nodes.size()) {
- return nodes.get(index);
- }
- return null;
- }
-
-
- public void sort(Comparator<Node> comparator) {
- Collections.sort(nodes, comparator);
- }
-
- public String getContent() throws Exception{
- StringBuilder buf = new StringBuilder();
- if (content != null) {
- buf.append(content);
- }
- if (document != null) {
- buf.append(new XMLBodySerializer().serialize(this, document));
- }
-
- return buf.toString();
- }
-
- private String getKey(Node node) {
- try {
- NodeList list = (NodeList) keyXpath.evaluate(node, XPathConstants.NODESET);
- return new XMLBodySerializer().serialize(list, node.getOwnerDocument());
- } catch (Exception e) {
- }
- return null;
- }
+public class XMLBodyMerge implements NodeList {
+ private Document document = null;
+ private XPathExpression keyXpath = null;
+ private List<Node> nodes = new ArrayList<Node>();
+ private Set<String> keys = new HashSet<String>();
+ private StringBuffer content = new StringBuffer();
+ private String xpath;
+
+ public XMLBodyMerge(String xpath) {
+ super();
+ this.xpath = xpath;
+ }
+
+ public XMLBodyMerge(String xpath, String keyXpath) {
+ this(xpath);
+
+ if (keyXpath != null) {
+ try {
+ XPath newXPath = XPathFactory.newInstance().newXPath();
+
+ this.keyXpath = newXPath.compile(keyXpath);
+ } catch (XPathExpressionException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ public void add(Node node) {
+ if (keyXpath != null) {
+ String key = getKey(node);
+
+ if (key == null || keys.contains(key)) {
+ return;
+ }
+ }
+
+ if (document == null) {
+ document = node.getOwnerDocument();
+ } else {
+ node = document.importNode(node, true);
+ }
+
+ nodes.add(node);
+ }
+
+ public void add(XMLBody xmlBody) throws ParsingException {
+ if (xpath != null) {
+ NodeList nodeList = xmlBody.getByXpath(xpath);
+
+ if (nodeList != null) {
+ for (int i = 0; i < nodeList.getLength(); i++) {
+ add(nodeList.item(i));
+ }
+ }
+ } else {
+ content.append(xmlBody.getContent());
+ }
+ }
+
+ public int getLength() {
+ return nodes.size();
+ }
+
+ public Node item(int index) {
+ if (index < nodes.size()) {
+ return nodes.get(index);
+ }
+
+ return null;
+ }
+
+ public void sort(Comparator<Node> comparator) {
+ Collections.sort(nodes, comparator);
+ }
+
+ public String getContent() throws Exception {
+ StringBuilder buf = new StringBuilder();
+
+ if (content != null) {
+ buf.append(content);
+ }
+
+ if (document != null) {
+ buf.append(new XMLBodySerializer().serialize(this, document));
+ }
+
+ return buf.toString();
+ }
+
+ private String getKey(Node node) {
+ try {
+ NodeList list = (NodeList) keyXpath.evaluate(node, XPathConstants.NODESET);
+
+ return new XMLBodySerializer().serialize(list, node.getOwnerDocument());
+ } catch (Exception e) {
+
+ // TODO Refactoring
+ }
+
+ return null;
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/XMLBodySerializer.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/XMLBodySerializer.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/XMLBodySerializer.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -19,6 +19,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.xmlutils;
import java.io.StringWriter;
@@ -34,44 +36,39 @@
import org.w3c.dom.DocumentFragment;
import org.w3c.dom.NodeList;
-
/**
* @author Maksim Kaszynski
*
*/
public class XMLBodySerializer {
- public String serialize(NodeList childNodes, Document xmlDocument) throws
ParsingException {
- try {
- StringWriter out;
- DocumentFragment fragment = xmlDocument.createDocumentFragment();
- for (int i = 0; i < childNodes.getLength(); i++) {
- fragment.appendChild(childNodes.item(i).cloneNode(true));
- }
- TransformerFactory transformerFactory = TransformerFactory.newInstance();
- Transformer transformer = transformerFactory.newTransformer();
- transformer.setErrorListener(new ErrorListener(){
+ public String serialize(NodeList childNodes, Document xmlDocument) throws
ParsingException {
+ try {
+ StringWriter out;
+ DocumentFragment fragment = xmlDocument.createDocumentFragment();
- public void error(TransformerException exception)
- throws TransformerException {
- }
+ for (int i = 0; i < childNodes.getLength(); i++) {
+ fragment.appendChild(childNodes.item(i).cloneNode(true));
+ }
- public void fatalError(TransformerException exception)
- throws TransformerException {
- }
+ TransformerFactory transformerFactory = TransformerFactory.newInstance();
+ Transformer transformer = transformerFactory.newTransformer();
- public void warning(TransformerException exception)
- throws TransformerException {
- }
-
- });
- transformer.setOutputProperty("indent", "yes");
- transformer.setOutputProperty("omit-xml-declaration", "yes");
- out = new StringWriter();
- StreamResult result = new StreamResult(out);
- transformer.transform(new DOMSource(fragment), result);
- return out.toString();
- } catch (Exception e) {
- throw new ParsingException(e);
- }
- }
+ transformer.setErrorListener(new ErrorListener() {
+ public void error(TransformerException exception) throws
TransformerException {}
+ public void fatalError(TransformerException exception) throws
TransformerException {}
+ public void warning(TransformerException exception) throws
TransformerException {}
+ });
+ transformer.setOutputProperty("indent", "yes");
+ transformer.setOutputProperty("omit-xml-declaration",
"yes");
+ out = new StringWriter();
+
+ StreamResult result = new StreamResult(out);
+
+ transformer.transform(new DOMSource(fragment), result);
+
+ return out.toString();
+ } catch (Exception e) {
+ throw new ParsingException(e);
+ }
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/XPathComparator.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/XPathComparator.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/XPathComparator.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -19,6 +19,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.xmlutils;
import java.util.Comparator;
@@ -34,64 +36,68 @@
*
*/
public class XPathComparator implements Comparator<Node> {
+ private XPathCompatorCriterion[] criteria;
- class XPathCompatorCriterion {
- private XPathExpression expression = null;
-
- public XPathCompatorCriterion(String xPath){
- try {
- expression = XPathFactory.newInstance().newXPath().compile(xPath);
- } catch (XPathExpressionException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-
- public String getValue(Object node) throws XPathExpressionException {
- return expression == null ? null : expression.evaluate(node);
- }
- }
+ public XPathComparator(String... criteria) {
+ this.criteria = new XPathCompatorCriterion[criteria.length];
- private XPathCompatorCriterion [] criteria;
-
- public XPathComparator(String ... criteria) {
- this.criteria = new XPathCompatorCriterion[criteria.length];
- for(int i = 0; i < criteria.length; i++) {
- this.criteria[i] = new XPathCompatorCriterion(criteria[i]);
- }
- }
-
- public int compare(Node o1, Node o2) {
- int result = 0;
-
- for(int i = 0; i < criteria.length && result == 0; i++) {
- String s1 = null;
- String s2 = null;
- try {
- s1 = this.criteria[i].getValue(o1);
- } catch (XPathExpressionException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- try {
- s2 = this.criteria[i].getValue(o2);
- } catch (XPathExpressionException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- if (s1 != null) {
- if (s2 != null) {
- result = s1.compareTo(s2);
- } else {
- result = 1;
- }
- } else if (s2 != null) {
- result = -1;
- }
- }
-
- return result;
- }
+ for (int i = 0; i < criteria.length; i++) {
+ this.criteria[i] = new XPathCompatorCriterion(criteria[i]);
+ }
+ }
+ public int compare(Node o1, Node o2) {
+ int result = 0;
+
+ for (int i = 0; i < criteria.length && result == 0; i++) {
+ String s1 = null;
+ String s2 = null;
+
+ try {
+ s1 = this.criteria[i].getValue(o1);
+ } catch (XPathExpressionException e) {
+
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ try {
+ s2 = this.criteria[i].getValue(o2);
+ } catch (XPathExpressionException e) {
+
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ if (s1 != null) {
+ if (s2 != null) {
+ result = s1.compareTo(s2);
+ } else {
+ result = 1;
+ }
+ } else if (s2 != null) {
+ result = -1;
+ }
+ }
+
+ return result;
+ }
+
+ class XPathCompatorCriterion {
+ private XPathExpression expression = null;
+
+ public XPathCompatorCriterion(String xPath) {
+ try {
+ expression = XPathFactory.newInstance().newXPath().compile(xPath);
+ } catch (XPathExpressionException e) {
+
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ public String getValue(Object node) throws XPathExpressionException {
+ return expression == null ? null : expression.evaluate(node);
+ }
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/dtd/Attribute.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/dtd/Attribute.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/dtd/Attribute.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -19,17 +19,16 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.xmlutils.dtd;
/**
* @author Maksim Kaszynski
*
*/
-public class Attribute extends Node{
-
- public Attribute(String name) {
- super(name);
- }
-
-
+public class Attribute extends Node {
+ public Attribute(String name) {
+ super(name);
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/dtd/DocumentDefinition.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/dtd/DocumentDefinition.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/dtd/DocumentDefinition.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -19,9 +19,12 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.xmlutils.dtd;
import java.net.URL;
+
import java.util.HashMap;
import java.util.Map;
@@ -30,33 +33,29 @@
*
*/
public class DocumentDefinition {
- private Map<String, Element> elements = new HashMap<String, Element>();
-
- private URL url;
-
- private Element rootElement;
-
- public DocumentDefinition(URL url, Element rootElement) {
- super();
- this.url = url;
- this.rootElement = rootElement;
- }
+ private Map<String, Element> elements = new HashMap<String, Element>();
+ private Element rootElement;
+ private URL url;
- public void addElement(Element e) {
- elements.put(e.getName(), e);
- }
-
- public Element getElement(String name) {
- return elements.get(name);
- }
+ public DocumentDefinition(URL url, Element rootElement) {
+ super();
+ this.url = url;
+ this.rootElement = rootElement;
+ }
- public URL getUrl() {
- return url;
- }
+ public void addElement(Element e) {
+ elements.put(e.getName(), e);
+ }
- public Element getRootElement() {
- return rootElement;
- }
+ public Element getElement(String name) {
+ return elements.get(name);
+ }
-
+ public URL getUrl() {
+ return url;
+ }
+
+ public Element getRootElement() {
+ return rootElement;
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/dtd/DocumentDefinitionFactory.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/dtd/DocumentDefinitionFactory.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/dtd/DocumentDefinitionFactory.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -19,6 +19,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.xmlutils.dtd;
import java.net.URL;
@@ -30,13 +32,11 @@
*
*/
public abstract class DocumentDefinitionFactory {
+ private static DocumentDefinitionFactory instance = new WutkaDefinitionFactory();
- private static DocumentDefinitionFactory instance =
- new WutkaDefinitionFactory();
-
- public static DocumentDefinitionFactory instance() {
- return instance;
- }
-
- public abstract DocumentDefinition getDocumentDefinition(URL resource);
+ public static DocumentDefinitionFactory instance() {
+ return instance;
+ }
+
+ public abstract DocumentDefinition getDocumentDefinition(URL resource);
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/dtd/Element.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/dtd/Element.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/dtd/Element.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -19,6 +19,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.xmlutils.dtd;
import java.util.HashMap;
@@ -28,21 +30,18 @@
* @author Maksim Kaszynski
*
*/
-public class Element extends Node{
+public class Element extends Node {
+ private Map<String, Attribute> attributes = new HashMap<String,
Attribute>();
- private Map<String, Attribute> attributes = new HashMap<String,
Attribute>();
+ public Element(String name) {
+ super(name);
+ }
- public Element(String name) {
- super(name);
- }
-
- public void addAttribute(Attribute attribute) {
- attributes.put(attribute.getName(), attribute);
- }
-
- public Map<String, Attribute> getAttributes() {
- return attributes;
- }
+ public void addAttribute(Attribute attribute) {
+ attributes.put(attribute.getName(), attribute);
+ }
-
+ public Map<String, Attribute> getAttributes() {
+ return attributes;
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/dtd/Node.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/dtd/Node.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/dtd/Node.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -19,6 +19,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.xmlutils.dtd;
/**
@@ -27,16 +29,14 @@
*
*/
public class Node {
-
- private String name;
+ private String name;
- public String getName() {
- return name;
- }
+ public Node(String name) {
+ super();
+ this.name = name;
+ }
- public Node(String name) {
- super();
- this.name = name;
- }
-
+ public String getName() {
+ return name;
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/dtd/wutka/WutkaDefinitionFactory.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/dtd/wutka/WutkaDefinitionFactory.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/dtd/wutka/WutkaDefinitionFactory.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -19,9 +19,12 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.xmlutils.dtd.wutka;
import java.net.URL;
+
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
@@ -42,74 +45,62 @@
* @author Maksim Kaszynski
*
*/
-public class WutkaDefinitionFactory extends DocumentDefinitionFactory{
-
- private final Logger log = LoggerFactory.getLogger();
-
- private Map<URL, DocumentDefinition> definitions
- = new HashMap<URL, DocumentDefinition>();
-
- @Override
- public synchronized DocumentDefinition getDocumentDefinition(URL resource) {
- DocumentDefinition def = null;
- if (definitions.containsKey(resource)) {
- def = definitions.get(resource);
- } else {
-
- try {
- def = initDefinition(resource);
- } catch(Exception e) {
- log.error("An error has occured", e);
- }
-
- if (def != null) {
- definitions.put(resource, def);
- }
- }
- return def;
- }
-
-
- private DocumentDefinition initDefinition(URL resource) throws Exception{
+public class WutkaDefinitionFactory extends DocumentDefinitionFactory {
+ private final Logger log = LoggerFactory.getLogger();
+ private Map<URL, DocumentDefinition> definitions = new HashMap<URL,
DocumentDefinition>();
- DTD dtd = new DTDParser(resource).parse();
-
- Element rootElement = fromWutka(dtd.rootElement);
-
- DocumentDefinition definition = new DocumentDefinition(resource, rootElement);
-
- @SuppressWarnings("unchecked")
- Enumeration<DTDElement> elements = dtd.elements.elements();
-
- while(elements.hasMoreElements()) {
- DTDElement element = elements.nextElement();
-
- definition.addElement(fromWutka(element));
- }
-
- return definition;
- }
-
- private Attribute fromWutka(DTDAttribute attr) {
- return new Attribute(attr.name);
- }
-
- private Element fromWutka(DTDElement element) {
-
- if (element == null) {
- return null;
- }
-
- Element e = new Element(element.getName());
+ @Override
+ public synchronized DocumentDefinition getDocumentDefinition(URL resource) {
+ DocumentDefinition def = null;
- @SuppressWarnings("unchecked")
- Enumeration<DTDAttribute> attrs =
- element.attributes.elements();
-
- while(attrs.hasMoreElements()) {
- e.addAttribute(fromWutka(attrs.nextElement()));
- }
-
- return e;
- }
+ if (definitions.containsKey(resource)) {
+ def = definitions.get(resource);
+ } else {
+ try {
+ def = initDefinition(resource);
+ } catch (Exception e) {
+ log.error("An error has occured", e);
+ }
+
+ if (def != null) {
+ definitions.put(resource, def);
+ }
+ }
+
+ return def;
+ }
+
+ private DocumentDefinition initDefinition(URL resource) throws Exception {
+ DTD dtd = new DTDParser(resource).parse();
+ Element rootElement = fromWutka(dtd.rootElement);
+ DocumentDefinition definition = new DocumentDefinition(resource, rootElement);
+ @SuppressWarnings("unchecked") Enumeration<DTDElement> elements =
dtd.elements.elements();
+
+ while (elements.hasMoreElements()) {
+ DTDElement element = elements.nextElement();
+
+ definition.addElement(fromWutka(element));
+ }
+
+ return definition;
+ }
+
+ private Attribute fromWutka(DTDAttribute attr) {
+ return new Attribute(attr.name);
+ }
+
+ private Element fromWutka(DTDElement element) {
+ if (element == null) {
+ return null;
+ }
+
+ Element e = new Element(element.getName());
+ @SuppressWarnings("unchecked") Enumeration<DTDAttribute> attrs =
element.attributes.elements();
+
+ while (attrs.hasMoreElements()) {
+ e.addAttribute(fromWutka(attrs.nextElement()));
+ }
+
+ return e;
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/dtd/xerces/XercesDefinitionFactory.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/dtd/xerces/XercesDefinitionFactory.java 2009-11-01
16:17:29 UTC (rev 15789)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/dtd/xerces/XercesDefinitionFactory.java 2009-11-01
16:21:55 UTC (rev 15790)
@@ -21,10 +21,14 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.xmlutils.dtd.xerces;
import java.io.IOException;
+
import java.net.URL;
+
import java.util.HashMap;
import java.util.Map;
@@ -36,6 +40,7 @@
import org.apache.xerces.xni.grammars.XSGrammar;
import org.apache.xerces.xni.parser.XMLInputSource;
import org.apache.xerces.xs.XSModel;
+
import org.richfaces.cdk.Logger;
import org.richfaces.cdk.LoggerFactory;
import org.richfaces.cdk.xmlutils.dtd.DocumentDefinition;
@@ -46,98 +51,103 @@
* That class implements {@link DocumentDefinitionFactory} that parses XML
* schema using Xerces Xml Schema API
* </p>
- *
+ *
* @author asmirnov(a)exadel.com
- *
+ *
*/
public class XercesDefinitionFactory extends DocumentDefinitionFactory {
- private final Logger log = LoggerFactory.getLogger();
- /** Namespaces feature id (
http://xml.org/sax/features/namespaces). */
- public static final String NAMESPACES_FEATURE_ID =
"http://xml.org/sax/features/namespaces";
- /** Validation feature id (
http://xml.org/sax/features/validation). */
- public static final String VALIDATION_FEATURE_ID =
"http://xml.org/sax/features/validation";
- /**
- * Schema validation feature id
- * (
http://apache.org/xml/features/validation/schema).
- */
- public static final String SCHEMA_VALIDATION_FEATURE_ID =
"http://apache.org/xml/features/validation/schema";
- /**
- * Schema full checking feature id
- * (
http://apache.org/xml/features/validation/schema-full-checking).
- */
- public static final String SCHEMA_FULL_CHECKING_FEATURE_ID =
"http://apache.org/xml/features/validation/schema-full-checking";
+ /** Namespaces feature id (
http://xml.org/sax/features/namespaces). */
+ public static final String NAMESPACES_FEATURE_ID =
"http://xml.org/sax/features/namespaces";
- // feature: continue-after-fatal-error
- public final static String CONTINUE_AFTER_FATAL_ERROR = Constants.XERCES_FEATURE_PREFIX
- + Constants.CONTINUE_AFTER_FATAL_ERROR_FEATURE;
- /** Property identifier: symbol table. */
- public static final String SYMBOL_TABLE = Constants.XERCES_PROPERTY_PREFIX
- + Constants.SYMBOL_TABLE_PROPERTY;
- /** Property identifier: error reporter. */
- public static final String ERROR_REPORTER = Constants.XERCES_PROPERTY_PREFIX
- + Constants.ERROR_REPORTER_PROPERTY;
- /** Property identifier: error handler. */
- public static final String ERROR_HANDLER = Constants.XERCES_PROPERTY_PREFIX
- + Constants.ERROR_HANDLER_PROPERTY;
- /** Property identifier: entity resolver. */
- public static final String ENTITY_RESOLVER = Constants.XERCES_PROPERTY_PREFIX
- + Constants.ENTITY_RESOLVER_PROPERTY;
- /** Property identifier: grammar pool . */
- public static final String GRAMMAR_POOL = Constants.XERCES_PROPERTY_PREFIX
- + Constants.XMLGRAMMAR_POOL_PROPERTY;
+ /**
+ * Schema full checking feature id
+ * (
http://apache.org/xml/features/validation/schema-full-checking).
+ */
+ public static final String SCHEMA_FULL_CHECKING_FEATURE_ID =
+ "http://apache.org/xml/features/validation/schema-full-checking";
- private Map<URL, DocumentDefinition> definitions = new HashMap<URL,
DocumentDefinition>();
+ /**
+ * Schema validation feature id
+ * (
http://apache.org/xml/features/validation/schema).
+ */
+ public static final String SCHEMA_VALIDATION_FEATURE_ID =
"http://apache.org/xml/features/validation/schema";
- @Override
- public synchronized DocumentDefinition getDocumentDefinition(URL resource) {
- DocumentDefinition def = null;
- if (definitions.containsKey(resource)) {
- def = definitions.get(resource);
- } else {
+ /** Validation feature id (
http://xml.org/sax/features/validation). */
+ public static final String VALIDATION_FEATURE_ID =
"http://xml.org/sax/features/validation";
- try {
- def = initDefinition(resource);
- } catch (Exception e) {
- log.error("An error has occured", e);
- }
+ /** Property identifier: symbol table. */
+ public static final String SYMBOL_TABLE = Constants.XERCES_PROPERTY_PREFIX +
Constants.SYMBOL_TABLE_PROPERTY;
- if (def != null) {
- definitions.put(resource, def);
- }
- }
- return def;
- }
+ /** Property identifier: grammar pool . */
+ public static final String GRAMMAR_POOL = Constants.XERCES_PROPERTY_PREFIX +
Constants.XMLGRAMMAR_POOL_PROPERTY;
- public DocumentDefinition initDefinition(URL resource) {
- XMLGrammarPreparser preparser = new XMLGrammarPreparser();
- // preparser.registerPreparser(XMLGrammarDescription.XML_DTD, null);
- preparser.registerPreparser(XMLGrammarDescription.XML_SCHEMA, null);
+ /** Property identifier: error reporter. */
+ public static final String ERROR_REPORTER = Constants.XERCES_PROPERTY_PREFIX +
Constants.ERROR_REPORTER_PROPERTY;
- // preparser.setProperty(GRAMMAR_POOL, grammarPool);
- preparser.setFeature(NAMESPACES_FEATURE_ID, true);
- preparser.setFeature(VALIDATION_FEATURE_ID, true);
- // note we can set schema features just in case...
- preparser.setFeature(SCHEMA_VALIDATION_FEATURE_ID, true);
- preparser.setFeature(SCHEMA_FULL_CHECKING_FEATURE_ID, true);
+ /** Property identifier: error handler. */
+ public static final String ERROR_HANDLER = Constants.XERCES_PROPERTY_PREFIX +
Constants.ERROR_HANDLER_PROPERTY;
- try {
- Grammar g = preparser.preparseGrammar(
- XMLGrammarDescription.XML_SCHEMA,
- createInputSource(resource));
- XSGrammar grammar = (XSGrammar) g;
- XSModel model = grammar.toXSModel();
- // TODO - make DocumentDefinition from XML schema.
- } catch (XNIException e) {
- log.error(e);
- } catch (IOException e) {
- log.error(e);
- }
- return null;
- }
+ /** Property identifier: entity resolver. */
+ public static final String ENTITY_RESOLVER = Constants.XERCES_PROPERTY_PREFIX +
Constants.ENTITY_RESOLVER_PROPERTY;
- protected XMLInputSource createInputSource(URL resource) {
- return new XMLInputSource(null, resource.toExternalForm(), null);
- }
+ // feature: continue-after-fatal-error
+ public static final String CONTINUE_AFTER_FATAL_ERROR =
Constants.XERCES_FEATURE_PREFIX
+ +
Constants.CONTINUE_AFTER_FATAL_ERROR_FEATURE;
+ private final Logger log = LoggerFactory.getLogger();
+ private Map<URL, DocumentDefinition> definitions = new HashMap<URL,
DocumentDefinition>();
+ @Override
+ public synchronized DocumentDefinition getDocumentDefinition(URL resource) {
+ DocumentDefinition def = null;
+
+ if (definitions.containsKey(resource)) {
+ def = definitions.get(resource);
+ } else {
+ try {
+ def = initDefinition(resource);
+ } catch (Exception e) {
+ log.error("An error has occured", e);
+ }
+
+ if (def != null) {
+ definitions.put(resource, def);
+ }
+ }
+
+ return def;
+ }
+
+ public DocumentDefinition initDefinition(URL resource) {
+ XMLGrammarPreparser preparser = new XMLGrammarPreparser();
+
+ // preparser.registerPreparser(XMLGrammarDescription.XML_DTD, null);
+ preparser.registerPreparser(XMLGrammarDescription.XML_SCHEMA, null);
+
+ // preparser.setProperty(GRAMMAR_POOL, grammarPool);
+ preparser.setFeature(NAMESPACES_FEATURE_ID, true);
+ preparser.setFeature(VALIDATION_FEATURE_ID, true);
+
+ // note we can set schema features just in case...
+ preparser.setFeature(SCHEMA_VALIDATION_FEATURE_ID, true);
+ preparser.setFeature(SCHEMA_FULL_CHECKING_FEATURE_ID, true);
+
+ try {
+ Grammar g = preparser.preparseGrammar(XMLGrammarDescription.XML_SCHEMA,
createInputSource(resource));
+ XSGrammar grammar = (XSGrammar) g;
+ XSModel model = grammar.toXSModel();
+
+ // TODO - make DocumentDefinition from XML schema.
+ } catch (XNIException e) {
+ log.error(e);
+ } catch (IOException e) {
+ log.error(e);
+ }
+
+ return null;
+ }
+
+ protected XMLInputSource createInputSource(URL resource) {
+ return new XMLInputSource(null, resource.toExternalForm(), null);
+ }
}