Author: alexsmirnov
Date: 2009-08-14 18:10:22 -0400 (Fri, 14 Aug 2009)
New Revision: 15180
Added:
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/ConfigExtension.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/Extensible.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/model/ClassDescriptionTest.java
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/RichFacesConventions.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/CdkCompiler.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/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/Event.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/JsfType.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/package-info.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FacesConfigParser.java
Log:
Add JAXB annotations to model
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-08-14
17:34:02 UTC (rev 15179)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/NamingConventions.java 2009-08-14
22:10:22 UTC (rev 15180)
@@ -67,4 +67,8 @@
*/
public String inferUIComponentClass(String componentType, String explicitClass, String
baseClass, boolean baseClassIsAbstract) throws InvalidNameException;
+ 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-08-14
17:34:02 UTC (rev 15179)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/RichFacesConventions.java 2009-08-14
22:10:22 UTC (rev 15180)
@@ -87,7 +87,7 @@
if(!Strings.isEmpty(explicitClass)){
// Class name provided by developer.
className = explicitClass;
- } else if (baseClassIsAbstract || baseClass.startsWith(ABSTRACT)||
baseClass.endsWith(BASE)) {
+ } else if (isAbstract(baseClass, baseClassIsAbstract)) {
// Infer UI class name from component type.
Name name = Name.create(componentType);
name.setClassifier(Classifier.component);
@@ -102,6 +102,25 @@
}
+ 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
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/CdkCompiler.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/CdkCompiler.java 2009-08-14
17:34:02 UTC (rev 15179)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/CdkCompiler.java 2009-08-14
22:10:22 UTC (rev 15180)
@@ -73,6 +73,8 @@
private Locale locale;
private CdkContext context;
+
+ private boolean initialized = false;
/**
* <p class="changed_added_4_0">Builder method that creates and
initializes compiler instance.
@@ -83,9 +85,8 @@
@Override
public void init(CdkContext context) {
this.context = context;
- CdkCompiler compiler = new CdkCompiler();
JavaCompiler javaCompiler = ToolProvider.getSystemJavaCompiler();
- compiler.setJavaCompiler(javaCompiler);
+ setJavaCompiler(javaCompiler);
ArrayList<String> options = new ArrayList<String>();
options.add("-proc:only");
options.add("-implicit:class");
@@ -129,9 +130,9 @@
}
options.add(generatedSourceFolders.toString());
}
- compiler.setOptions(options);
+ setOptions(options);
// TODO - provide source files locale.
- compiler.setLocale(Locale.getDefault());
+ setLocale(Locale.getDefault());
// TODO -set locale and charset for platform-independent processing. Provide own
diagnostics listener.
StandardJavaFileManager stdFileManager = javaCompiler
.getStandardFileManager(null, null, null);
@@ -139,11 +140,15 @@
VirtualFileManager fileManager = new VirtualFileManager(stdFileManager,
context.getLoader());
fileManager.setJavaSourceDirectory(context.getJavaSource());
- compiler.setFileManager(fileManager);
+ setFileManager(fileManager);
+ initialized = true;
}
@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);
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-08-14
17:34:02 UTC (rev 15179)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ComponentProcessor.java 2009-08-14
22:10:22 UTC (rev 15180)
@@ -49,85 +49,121 @@
import org.richfaces.cdk.util.Strings;
/**
- * <p class="changed_added_4_0"></p>
+ * <p class="changed_added_4_0">
+ * </p>
+ *
* @author asmirnov(a)exadel.com
- *
+ *
*/
@SupportedAnnotationTypes(Component.NAME)
public class ComponentProcessor extends CdkProcessor {
-
+
private final ComponentLibrary library;
/**
- * <p class="changed_added_4_0"></p>
+ * <p class="changed_added_4_0">
+ * </p>
+ *
* @param context
*/
- public ComponentProcessor(CdkContext context,ComponentLibrary library) {
+ public ComponentProcessor(CdkContext context, ComponentLibrary library) {
super(context);
this.library = library;
}
- /* (non-Javadoc)
- * @see javax.annotation.processing.AbstractProcessor#process(java.util.Set,
javax.annotation.processing.RoundEnvironment)
+ /*
+ * (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()){
+ if (null != annotations && !annotations.isEmpty()) {
ComponentLibrary library = getLibrary();
NamingConventions namingUtils = getContext().getNamingConventions();
// Process all component classes.
- Set<? extends TypeElement> componentClasses =
getClassesAnnotatedWith(Component.class, roundEnv);
+ Set<? extends TypeElement> componentClasses = getClassesAnnotatedWith(
+ Component.class, roundEnv);
for (TypeElement component : componentClasses) {
try {
// Process class-level annotations.
// Calculate type for base UI component class.
// TODO - encpsulate that into simple utility classes call.
- Component componentAnnotation = component.getAnnotation(Component.class);
- String baseClassName = component.getQualifiedName().toString();
- String componentType =
namingUtils.inferComponentType(componentAnnotation.type(),baseClassName);
- String uiComponentClass = namingUtils.inferUIComponentClass(componentType,
componentAnnotation.className(), baseClassName,
component.getModifiers().contains(Modifier.ABSTRACT));
+ Component componentAnnotation = component
+ .getAnnotation(Component.class);
+ String baseClassName = component.getQualifiedName()
+ .toString();
+ String componentType = namingUtils.inferComponentType(
+ componentAnnotation.type(), baseClassName);
// Create/get component instance.
org.richfaces.cdk.model.Component componentModel = library
- .createComponent(componentType, uiComponentClass, baseClassName);
- // Component Family. TODO - get it from 'COMPONENT_FAMILY' field or infer by
NamingConventios.
+ .createComponent(componentType)
+ .setClassName(
+ namingUtils.inferUIComponentClass(
+ componentType, componentAnnotation
+ .className(),
+ baseClassName, component
+ .getModifiers().contains(
+ Modifier.ABSTRACT)))
+ .setBaseClassName(
+ namingUtils.inferUIComponentBaseClass(
+ componentType, baseClassName,
+ component.getModifiers().contains(
+ Modifier.ABSTRACT)));
+ // Component Family. TODO - get it from 'COMPONENT_FAMILY'
+ // field or infer by NamingConventios.
Family family = component.getAnnotation(Family.class);
- componentModel.setFamily(Strings.isEmpty(family.value())?componentType:family.value());
+ componentModel
+ .setFamily(namingUtils.inferUIComponentFamily(componentType,family.value()));
// JavaDoc comments
- componentModel.setDescription(this.processingEnv.getElementUtils().getDocComment(component));
+ componentModel.setDescription(this.processingEnv
+ .getElementUtils().getDocComment(component));
// TODO - process Events attribute.
// TODO - renderers, ....
// Process attributes.
- Set<BeanProperty> properties = getBeanPropertiesAnnotatedWith(Attribute.class,
component);
+ Set<BeanProperty> properties = getBeanPropertiesAnnotatedWith(
+ Attribute.class, component);
// TODO - encapsulate attribute builder into utility class.
for (BeanProperty beanProperty : properties) {
- Property atribute = componentModel.addAttribute(beanProperty.getName());
+ Property atribute = componentModel
+ .addAttribute(beanProperty.getName());
// Documentation
atribute.setDescription(beanProperty.getDocComment());
// Type.
- atribute.setType(createClassDescription(beanProperty.getType()));
+ atribute.setPropertyClass(beanProperty
+ .getType().toString());
// Flags.
atribute.setExists(beanProperty.isExists());
}
- Attributes attributes = component.getAnnotation(Attributes.class);
- if(null != attributes){
- Attribute[] attributes2 = attributes.value();
- for (Attribute attributeAnnotation : attributes2) {
- Property attribute = componentModel.addAttribute(attributeAnnotation.name());
- attribute.setExists(false);
- try {
- Class<?> type = attributeAnnotation.type();
- attribute.setType(library.createClassDescription(type.getName()));
- } catch(MirroredTypeException ex){
- attribute.setType(createClassDescription(ex.getTypeMirror()));
- }
- // TODO - process additional properties.
+ Attributes attributes = component
+ .getAnnotation(Attributes.class);
+ if (null != attributes) {
+ Attribute[] attributes2 = attributes.value();
+ for (Attribute attributeAnnotation : attributes2) {
+ Property attribute = componentModel
+ .addAttribute(attributeAnnotation.name());
+ attribute.setExists(false);
+ try {
+ Class<?> type = attributeAnnotation.type();
+ attribute
+ .setPropertyClass(type
+ .getName());
+ } catch (MirroredTypeException ex) {
+ attribute.setPropertyClass(ex
+ .getTypeMirror().toString());
}
+ // TODO - process additional properties.
+ }
}
- // TODO - Process standard information for parent classes and intrfaces.
+ // TODO - Process standard information for parent classes
+ // and intrfaces.
} catch (InvalidNameException e) {
// rise error and continue.
- processingEnv.getMessager().printMessage(javax.tools.Diagnostic.Kind.ERROR,
e.getMessage(), component);
+ processingEnv.getMessager().printMessage(
+ javax.tools.Diagnostic.Kind.ERROR, e.getMessage(),
+ component);
continue;
}
}
@@ -140,7 +176,7 @@
return library;
}
- protected ClassDescription createClassDescription(TypeMirror mirror){
+ protected ClassDescription createClassDescription(TypeMirror mirror) {
return getLibrary().createClassDescription(mirror.toString());
}
Added:
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
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Attribute.java 2009-08-14
22:10:22 UTC (rev 15180)
@@ -0,0 +1,41 @@
+/*
+ * $Id$
+ *
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.cdk.model;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public class Attribute extends Property {
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param name
+ */
+ public Attribute(String name) {
+ super(name);
+ }
+
+}
Property changes on:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Attribute.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
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-08-14
17:34:02 UTC (rev 15179)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ClassDescription.java 2009-08-14
22:10:22 UTC (rev 15180)
@@ -40,6 +40,7 @@
*/
private static final long serialVersionUID = -846623207703750456L;
+ @SuppressWarnings("serial")
public static final class Type extends JsfType {
public Type(String type) {
super(type);
@@ -68,8 +69,6 @@
private final String boxingClassName;
- private ClassDescription superClass;
-
/**
* <p class="changed_added_4_0">Type parameters for that
class</p>
* TODO append type parameters to key.
@@ -83,15 +82,22 @@
* @param name
*/
public ClassDescription(String name) {
- this.name = name;
+ this.type = new Type(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;
}
- this.type = new Type(name);
}
@Override
@@ -100,27 +106,6 @@
}
/**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @return the superClass
- */
- public ClassDescription getSuperClass() {
- return superClass;
- }
-
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @param superClass
- * the superClass to set
- */
- public void setSuperClass(ClassDescription superClass) {
- this.superClass = superClass;
- }
-
- /**
* <p class="changed_added_4_0"></p>
* @return the typeParameters
*/
@@ -168,7 +153,7 @@
@Override
public String toString() {
- return name;
+ return type.toString();
}
/* (non-Javadoc)
@@ -197,11 +182,11 @@
return false;
}
ClassDescription other = (ClassDescription) obj;
- if (name == null) {
- if (other.name != null) {
+ if (type == null) {
+ if (other.type != null) {
return false;
}
- } else if (!name.equals(other.name)) {
+ } else if (!type.equals(other.type)) {
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-08-14
17:34:02 UTC (rev 15179)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Component.java 2009-08-14
22:10:22 UTC (rev 15180)
@@ -2,96 +2,168 @@
import java.util.Collection;
import java.util.Collections;
-import java.util.List;
import java.util.Map;
import java.util.Set;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElementWrapper;
+import javax.xml.bind.annotation.XmlElements;
+import javax.xml.bind.annotation.XmlType;
+
+import org.richfaces.cdk.util.Strings;
+
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
/**
* That class represents JSF component in the CDK.
+ * That is mapped to faces-config "component" element.
* @author asmirnov(a)exadel.com
- *
+ *
*/
@SuppressWarnings("serial")
-public final class Component implements JsfComponent {
-
+@XmlType(name="faces-config-componentType")
+@XmlAccessorType( XmlAccessType.NONE )
+public final class Component implements JsfComponent, DescriptionGroup,Extensible {
+
/**
- * <p class="changed_added_4_0">Component type</p>
+ * <p class="changed_added_4_0">Reference to component library for
which that component is belong to.</p>
*/
+ private final ComponentLibrary library;
+
+ /**
+ * <p class="changed_added_4_0">
+ * Component type
+ * </p>
+ */
private final Type type;
-
/**
- * <p class="changed_added_4_0">component family</p>
- */
+ * <p class="changed_added_4_0">
+ * component family
+ * </p>
+ */
private String family;
/**
- * <p class="changed_added_4_0">Cenerated component class</p>
- */
+ * <p class="changed_added_4_0">
+ * Cenerated component class
+ * </p>
+ */
private ClassDescription componentClass;
-
/**
- * <p class="changed_added_4_0">Long description for
documentation</p>
- */
+ * <p class="changed_added_4_0">
+ * Cenerated component class
+ * </p>
+ */
+ private ClassDescription baseClass;
+
+ /**
+ * <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>
- */
+ * <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>
- */
+ * <p class="changed_added_4_0">
+ * Icon name for IDE tools
+ * </p>
+ */
private String icon;
/**
- * <p class="changed_added_4_0">Component attributes</p>
+ * <p class="changed_added_4_0">Is that component c</p>
*/
- private final Map<String,Property> attributes = Maps.newHashMap();
-
-
+ private boolean exists = true;
+
/**
- * <p class="changed_added_4_0">Application level events fired by the
component</p>
- */
- private List<Event> events;
-
+ * <p class="changed_added_4_0">
+ * Component attributes
+ * </p>
+ */
+ private final Map<String, Property> attributes = Maps.newHashMap();
+
/**
- * <p class="changed_added_4_0">Renderer for the final component. This
is bidirectional one to one relation.</p>
- */
- private List<Renderer> renderers;
-
+ * <p class="changed_added_4_0">
+ * Facets recognised by the component
+ * </p>
+ */
+ private final Map<String,Facet> facets = Maps.newHashMap();
+
/**
- * <p class="changed_added_4_0">Facets recognised by the
component</p>
- */
- private List<Facet> facets;
+ * <p class="changed_added_4_0">
+ * Application level events fired by the component
+ * </p>
+ */
+ private final Set<Event> events = Sets.newHashSet();
/**
- * <p class="changed_added_4_0"></p>
- * @param type the type to set
+ * <p class="changed_added_4_0">
+ * Renderer for the final component. This is bidirectional many to many
+ * relation.
+ * </p>
*/
- Component(Type type) {
+ private final Set<Renderer> renderers = Sets.newHashSet();
+
+ private ComponentExtension extension;
+
+ /**
+ * <p class="changed_added_4_0">Constructor. That class can be
instantiated by model-package members only.
+ * </p>
+ *
+ * @param type
+ * the type to set
+ */
+ Component(ComponentLibrary library, Type type) {
+ this.library = library;
this.type = type;
}
@Override
- public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) {
+ public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) {
return visitor.visit(this, param);
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.richfaces.cdk.model.JsfComponent#getType()
*/
+ @XmlElement(name="component-type",required=true)
public JsfType getType() {
return type;
}
/**
* <p class="changed_added_4_0"></p>
+ * @return the extension
+ */
+ @XmlElement(name="component-extensions")
+ public ComponentExtension getExtension() {
+ if (extension == null) {
+ extension = new ComponentExtension();
+ }
+ return extension;
+ }
+
+
+ /**
+ * <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
*/
public String getFamily() {
@@ -99,15 +171,20 @@
}
/**
- * <p class="changed_added_4_0"></p>
- * @param family the family to set
+ * <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>
+ * <p class="changed_added_4_0">
+ * </p>
+ *
* @return the componentClass
*/
public ClassDescription getComponentClass() {
@@ -115,56 +192,108 @@
}
/**
- * <p class="changed_added_4_0"></p>
- * @param componentClass the componentClass to set
+ * <p class="changed_added_4_0">Represents class of that component.
+ * </p>
+ *
+ * @param componentClass
+ * the componentClass to set
*/
- public void setComponentClass(ClassDescription componentClass) {
+ @XmlElement(name="component-class")
+ void setComponentClass(ClassDescription componentClass) {
this.componentClass = componentClass;
}
/**
- * <p class="changed_added_4_0"></p>
- * @return the description
+ * <p class="changed_added_4_0">Base class for generated components.
+ * </p>
+ *
+ * @return the baseClass
*/
+ @XmlElementWrapper(name="component-extensions")
+ @XmlElement(namespace=ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
+ public ClassDescription getBaseClass() {
+ return baseClass;
+ }
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param baseClass
+ * the baseClass to set
+ */
+ void setBaseClass(ClassDescription baseClass) {
+ this.baseClass = baseClass;
+ }
+
+ /**
+ * <p class="changed_added_4_0">Create and set {@link ClassDescription}
for component class.</p>
+ * @param className canonical name for component class.
+ * @return component instance itself for chain calls.
+ */
+ public Component setClassName(String className) {
+ ClassDescription classDescription = library
+ .createClassDescription(className);
+ setComponentClass(classDescription);
+ return this;
+ }
+
+ /**
+ * <p class="changed_added_4_0">Create and set {@link ClassDescription}
for base generated component class .</p>
+ * @param className canonical name for component super class.
+ * @return component instance itself for chain calls.
+ */
+ public Component setBaseClassName(String className) {
+ if (!Strings.isEmpty(className)) {
+ ClassDescription classDescription = library
+ .createClassDescription(className);
+ setBaseClass(classDescription);
+ } else {
+ setBaseClass(null);
+ }
+ return this;
+ }
+
+ /* (non-Javadoc)
+ * @see org.richfaces.cdk.model.DescriptionGroup#getDescription()
+ */
+ @XmlElement
public String getDescription() {
return description;
}
- /**
- * <p class="changed_added_4_0"></p>
- * @param description the description to set
+ /* (non-Javadoc)
+ * @see org.richfaces.cdk.model.DescriptionGroup#setDescription(java.lang.String)
*/
public void setDescription(String description) {
this.description = description;
}
- /**
- * <p class="changed_added_4_0"></p>
- * @return the displayname
+ /* (non-Javadoc)
+ * @see org.richfaces.cdk.model.DescriptionGroup#getDisplayname()
*/
+ @XmlElement(name="display-name")
public String getDisplayname() {
return displayname;
}
- /**
- * <p class="changed_added_4_0"></p>
- * @param displayname the displayname to set
+ /* (non-Javadoc)
+ * @see org.richfaces.cdk.model.DescriptionGroup#setDisplayname(java.lang.String)
*/
public void setDisplayname(String displayname) {
this.displayname = displayname;
}
- /**
- * <p class="changed_added_4_0"></p>
- * @return the icon
+ /* (non-Javadoc)
+ * @see org.richfaces.cdk.model.DescriptionGroup#getIcon()
*/
+ @XmlElement
public String getIcon() {
return icon;
}
- /**
- * <p class="changed_added_4_0"></p>
- * @param icon the icon to set
+ /* (non-Javadoc)
+ * @see org.richfaces.cdk.model.DescriptionGroup#setIcon(java.lang.String)
*/
public void setIcon(String icon) {
this.icon = icon;
@@ -172,15 +301,35 @@
/**
* <p class="changed_added_4_0"></p>
+ * @return the exists
+ */
+ public boolean isExists() {
+ return exists;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param exists the exists to set
+ */
+ public void setExists(boolean exists) {
+ this.exists = exists;
+ }
+
+ /**
+ * <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 Collections.unmodifiableCollection(attributes.values());
}
public Property addAttribute(String attributeName) {
Property attribute;
- if(attributes.containsKey(attributeName)){
+ if (attributes.containsKey(attributeName)) {
attribute = attributes.get(attributeName);
} else {
attribute = new Property(attributeName);
@@ -189,12 +338,68 @@
return attribute;
}
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the facets
+ */
+ public Collection<Facet> getFacets() {
+ return facets.values();
+ }
+
+ public Facet addFacet(String name){
+ Facet facet = facets.get(name);
+ if(null == facets){
+ facet = new Facet(name);
+ facets.put(name, facet);
+ }
+ return facet;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the events
+ */
+ public Set<Event> getEvents() {
+ return events;
+ }
+
+ public Event addEvent(String className){
+ Event event = new Event();
+ events.add(event);
+ return event;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the renderers
+ */
+ public Set<Renderer> getRenderers() {
+ return renderers;
+ }
+
public static class Type extends JsfType {
public Type(String type) {
super(type);
}
+
+ }
+
+ /**
+ * <p class="changed_added_4_0">Inner class that wraps
<component-extension> element content</p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+ public class ComponentExtension extends ConfigExtension {
+ @XmlElement(namespace=ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
+ public String getFamily(){
+ return Component.this.getFamily();
+ }
+
+ public void setFamily(String family) {
+ Component.this.setFamily(family);
+ }
}
-
+
}
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-08-14
17:34:02 UTC (rev 15179)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ComponentLibrary.java 2009-08-14
22:10:22 UTC (rev 15180)
@@ -32,6 +32,11 @@
import java.util.NoSuchElementException;
import java.util.Set;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElements;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
import org.richfaces.cdk.model.Component.Type;
import org.richfaces.cdk.util.Strings;
@@ -53,15 +58,21 @@
* @author asmirnov(a)exadel.com
*
*/
+@XmlRootElement(name="faces-config",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
+(a)XmlType(namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE,name="faces-configType")
public class ComponentLibrary implements Serializable {
+
+ public static final String FACES_CONFIG_NAMESPACE =
"http://java.sun.com/xml/ns/javaee";
+ public static final String
CDK_EXTENSIONS_NAMESPACE="http://richfaces.org/cdk";
+
/**
* <p class="changed_added_4_0">
* </p>
*/
private static final long serialVersionUID = -6055670836731899832L;
- private final Set<Component> componentsSet = Sets.newHashSet();
+ private final Set<Component> components = Sets.newHashSet();
private final Set<ClassDescription> classes = Sets.newHashSet();
/**
@@ -108,7 +119,7 @@
}
public <R,P> R accept(LibraryVisitor<R, P> visitor,P param){
- R result = accept(componentsSet,visitor, param, null);
+ R result = accept(components,visitor, param, null);
result = accept(renderers,visitor, param, result);
result = accept(converters,visitor, param, result);
result = accept(validators,visitor, param, result);
@@ -132,8 +143,9 @@
*
* @return the components
*/
+ @XmlElement
public Collection<Component> getComponents() {
- return componentsSet;
+ return components;
}
/**
@@ -147,15 +159,15 @@
* @param create
* @return
*/
- public Component getComponent(String type, boolean create) {
+ Component getComponent(String type, boolean create) {
Component.Type componentType = new Component.Type(type);
Component component = null;
try {
- component = find(componentsSet, componentType);
+ component = find(components, componentType);
} catch (NoSuchElementException e) {
if (create) {
- component = new Component(componentType);
- componentsSet.add(component);
+ component = new Component(this,componentType);
+ components.add(component);
}
}
return component;
@@ -175,25 +187,8 @@
* already existed components.
* @return
*/
- public Component createComponent(String type, String className,
- String superClassName) {
+ public Component createComponent(String type) {
Component component = getComponent(type, true);
- ClassDescription componentClass;
- if (!Strings.isEmpty(className)) {
- componentClass = createClassDescription(className);
- if (!Strings.isEmpty(superClassName)
- && !className.equals(superClassName)) {
- componentClass
- .setSuperClass(createClassDescription(superClassName));
- }
- } else if (!Strings.isEmpty(superClassName)) {
- componentClass = createClassDescription(superClassName);
- } else {
- // Do not modify class descriptions because it would be already
- // existed component.
- return component;
- }
- component.setComponentClass(componentClass);
return component;
}
Added:
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
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ConfigExtension.java 2009-08-14
22:10:22 UTC (rev 15180)
@@ -0,0 +1,58 @@
+/*
+ * $Id$
+ *
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.cdk.model;
+
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlAnyElement;
+
+import org.dom4j.Element;
+
+/**
+ * <p class="changed_added_4_0">That class represents all faces-config
"extension" fields.</p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public class ConfigExtension {
+
+ 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>
+ * @param extensions the extensions to set
+ */
+ public void setExtensions(List<Element> extensions) {
+ this.extensions = extensions;
+ }
+
+}
Property changes on:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ConfigExtension.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
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
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/DescriptionGroup.java 2009-08-14
22:10:22 UTC (rev 15180)
@@ -0,0 +1,66 @@
+package org.richfaces.cdk.model;
+
+import javax.xml.bind.annotation.XmlElement;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public interface DescriptionGroup {
+
+ /**
+ * <p class="changed_added_4_0">Documentation description of that
element.
+ * </p>
+ *
+ * @return the description
+ */
+ @XmlElement
+ 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>
+ *
+ * @return the displayname
+ */
+ @XmlElement(name = "display-name")
+ 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>
+ *
+ * @return the icon
+ */
+ @XmlElement
+ public String getIcon();
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param icon
+ * the icon to set
+ */
+ public void setIcon(String icon);
+
+}
\ No newline at end of file
Property changes on:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/DescriptionGroup.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
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-08-14
17:34:02 UTC (rev 15179)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Event.java 2009-08-14
22:10:22 UTC (rev 15180)
@@ -23,8 +23,10 @@
package org.richfaces.cdk.model;
+import javax.faces.event.FacesEvent;
+
/**
- * <p class="changed_added_4_0"></p>
+ * <p class="changed_added_4_0">That bean represent {@link FacesEvent}
subclass that can be fired by component.</p>
* @author asmirnov(a)exadel.com
*
*/
Added:
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
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Extensible.java 2009-08-14
22:10:22 UTC (rev 15180)
@@ -0,0 +1,41 @@
+/*
+ * $Id$
+ *
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.cdk.model;
+
+/**
+ * <p class="changed_added_4_0">That interface marks all faces-config
elements that have 'extension' element.</p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+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);
+
+}
Property changes on:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Extensible.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
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-08-14
17:34:02 UTC (rev 15179)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Facet.java 2009-08-14
22:10:22 UTC (rev 15180)
@@ -30,8 +30,40 @@
*/
public class Facet {
- private String name;
+ private final String name;
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param name
+ */
+ public Facet(String name) {
+ this.name = name;
+ }
+
private String description;
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the description
+ */
+ public String getDescription() {
+ return description;
+ }
+
+ /**
+ * <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 name
+ */
+ public String getName() {
+ return name;
+ }
+
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/JsfType.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/JsfType.java 2009-08-14
17:34:02 UTC (rev 15179)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/JsfType.java 2009-08-14
22:10:22 UTC (rev 15180)
@@ -23,12 +23,15 @@
package org.richfaces.cdk.model;
+import java.io.Serializable;
+
/**
* <p class="changed_added_4_0">This is a Key class that should be used
to find JSF elements in {@link ComponentLibrary}</p>
* @author asmirnov(a)exadel.com
*
*/
-public class JsfType {
+@SuppressWarnings("serial")
+public class JsfType implements Serializable {
private final String type;
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-08-14
17:34:02 UTC (rev 15179)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Property.java 2009-08-14
22:10:22 UTC (rev 15180)
@@ -21,12 +21,20 @@
package org.richfaces.cdk.model;
+import java.io.Serializable;
+import java.util.Set;
+
+import javax.xml.bind.annotation.XmlElement;
+
+import org.richfaces.cdk.util.Strings;
+
/**
* That class represents JSF component property.
* @author asmirnov(a)exadel.com
*
*/
-public class Property {
+@SuppressWarnings("serial")
+public class Property implements Serializable, DescriptionGroup {
/**
* <p class="changed_added_4_0">Bean property name of component
attribute</p>
@@ -47,16 +55,38 @@
private String displayname;
/**
+ * <p class="changed_added_4_0">
+ * Icon name for IDE tools
+ * </p>
+ */
+ private String icon;
+
+
+ /**
* <p class="changed_added_4_0">Is that bean property exists in the
class or should be generated ?</p>
*/
private boolean exists;
+ private boolean hidden;
+
+ private boolean elExpression;
+ private String dafaultValue;
+
+ private String suggestedValue;
+
+ private boolean passThrough=false;
+
+ private boolean defaultBehavior=false;
+
+ private Set<String> behaviorNames;
+
+
/**
* <p class="changed_added_4_0"></p>
* @param name
*/
- public Property(String name) {
+ Property(String name) {
this.name = name;
}
@@ -64,6 +94,7 @@
* <p class="changed_added_4_0"></p>
* @return the name
*/
+ @XmlElement(name="property-name")
public String getName() {
return name;
}
@@ -102,6 +133,22 @@
/**
* <p class="changed_added_4_0"></p>
+ * @return the icon
+ */
+ public String getIcon() {
+ return icon;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param icon the icon to set
+ */
+ public void setIcon(String icon) {
+ this.icon = icon;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
* @return the type
*/
public ClassDescription getType() {
@@ -112,12 +159,55 @@
* <p class="changed_added_4_0"></p>
* @param type the type to set
*/
- public void setType(ClassDescription type) {
+ void setType(ClassDescription type) {
this.type = type;
}
+ @XmlElement(name = "property-class")
+ public void setPropertyClass(String propertyClass) {
+ if (!Strings.isEmpty(propertyClass)) {
+ ClassDescription type = new ClassDescription(propertyClass);
+ setType(type);
+
+ }
+ }
+
/**
* <p class="changed_added_4_0"></p>
+ * @return the dafaultValue
+ */
+ @XmlElement(name="default-value")
+ public String getDafaultValue() {
+ return dafaultValue;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param dafaultValue the dafaultValue to set
+ */
+ public void setDafaultValue(String dafaultValue) {
+ this.dafaultValue = dafaultValue;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the suggestedValue
+ */
+ @XmlElement(name="suggested-value")
+ 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;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
* @return the exists
*/
public boolean isExists() {
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-08-14
17:34:02 UTC (rev 15179)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/package-info.java 2009-08-14
22:10:22 UTC (rev 15180)
@@ -12,6 +12,11 @@
* </ul>
*
*/
+(a)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 ) })
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/xmlconfig/FacesConfigParser.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FacesConfigParser.java 2009-08-14
17:34:02 UTC (rev 15179)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FacesConfigParser.java 2009-08-14
22:10:22 UTC (rev 15180)
@@ -35,6 +35,16 @@
*/
public class FacesConfigParser implements ModelBuilder {
+ private CdkContext context;
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the context
+ */
+ public CdkContext getContext() {
+ return context;
+ }
+
/* (non-Javadoc)
* @see org.richfaces.cdk.ModelBuilder#build()
*/
@@ -49,8 +59,7 @@
*/
@Override
public void init(CdkContext context) {
- // TODO Auto-generated method stub
-
+ this.context = context;
}
}
Added:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/model/ClassDescriptionTest.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/model/ClassDescriptionTest.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/model/ClassDescriptionTest.java 2009-08-14
22:10:22 UTC (rev 15180)
@@ -0,0 +1,75 @@
+/*
+ * $Id$
+ *
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.cdk.model;
+
+import static org.junit.Assert.*;
+
+import java.util.Arrays;
+import java.util.Collection;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+(a)RunWith(Parameterized.class)
+public class ClassDescriptionTest {
+
+ private final String className;
+ private final String expectedCanonicalName;
+ private final String expectedBoxedName;
+ private final String expectedTypeParameter;
+
+ public ClassDescriptionTest(String className,String expectedCanonicalName,String
expectedBoxedName,String expectedTypeParameter) {
+ this.className = className;
+ this.expectedCanonicalName = expectedCanonicalName;
+ this.expectedBoxedName = expectedBoxedName;
+ this.expectedTypeParameter = expectedTypeParameter;
+
+ }
+ /**
+ * Test method for {@link
org.richfaces.cdk.model.ClassDescription#ClassDescription(java.lang.String)}.
+ */
+ @Test
+ public void testClassDescription() {
+ ClassDescription description = new ClassDescription(className);
+ assertEquals(className, description.toString());
+ assertEquals(expectedCanonicalName, description.getName());
+ assertEquals(expectedBoxedName, description.getBoxingName());
+ assertEquals(expectedTypeParameter, description.getTypeParameters());
+ }
+
+ @Parameters
+ public static Collection<String[]> values(){
+ return Arrays.asList(new
String[]{int.class.getName(),"int","java.lang.Integer",null},
+ new
String[]{"java.util.List<String>","java.util.List","java.util.List<String>","<String>"},
+ new
String[]{double.class.getName(),"double","java.lang.Double",null});
+ }
+
+}
Property changes on:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/model/ClassDescriptionTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain