[seam-commits] Seam SVN: r12825 - in modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml: fieldset and 2 other directories.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Wed May 26 18:01:39 EDT 2010


Author: swd847
Date: 2010-05-26 18:01:37 -0400 (Wed, 26 May 2010)
New Revision: 12825

Modified:
   modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/core/XmlResult.java
   modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/fieldset/ArrayFieldSet.java
   modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/fieldset/CollectionFieldSet.java
   modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/fieldset/DirectFieldSetter.java
   modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/fieldset/InjectionTargetWrapper.java
   modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/fieldset/MapFieldSet.java
   modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/fieldset/MethodFieldSetter.java
   modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/fieldset/SimpleFieldValue.java
   modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/AbstractXmlItem.java
   modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/AnnotationXmlItem.java
   modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/ArrayXmlItem.java
   modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/ModelBuilder.java
   modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/parser/namespace/CompositeNamespaceElementResolver.java
   modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/parser/namespace/PackageNamespaceElementResolver.java
   modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/parser/namespace/RootNamespaceElementResolver.java
Log:
minor refactoring



Modified: modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/core/XmlResult.java
===================================================================
--- modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/core/XmlResult.java	2010-05-26 21:41:38 UTC (rev 12824)
+++ modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/core/XmlResult.java	2010-05-26 22:01:37 UTC (rev 12825)
@@ -38,25 +38,25 @@
 public class XmlResult
 {
 
-   private Map<Class<? extends Annotation>, Annotation[]> stereotypes = new HashMap<Class<? extends Annotation>, Annotation[]>();
+   private final Map<Class<? extends Annotation>, Annotation[]> stereotypes = new HashMap<Class<? extends Annotation>, Annotation[]>();
 
-   private List<Class<? extends Annotation>> qualifiers = new ArrayList<Class<? extends Annotation>>();
+   private final List<Class<? extends Annotation>> qualifiers = new ArrayList<Class<? extends Annotation>>();
 
-   private List<Class<? extends Annotation>> interceptorBindings = new ArrayList<Class<? extends Annotation>>();
+   private final List<Class<? extends Annotation>> interceptorBindings = new ArrayList<Class<? extends Annotation>>();
 
-   private List<Class<?>> veto = new ArrayList<Class<?>>();
+   private final List<Class<?>> veto = new ArrayList<Class<?>>();
 
-   private List<String> problems = new ArrayList<String>();
+   private final List<String> problems = new ArrayList<String>();
 
-   private List<BeanResult<?>> beans = new ArrayList<BeanResult<?>>();
+   private final List<BeanResult<?>> beans = new ArrayList<BeanResult<?>>();
 
-   private List<BeanResult<?>> interfaces = new ArrayList<BeanResult<?>>();
+   private final List<BeanResult<?>> interfaces = new ArrayList<BeanResult<?>>();
 
-   private List<GenericBeanResult> genericBeans = new ArrayList<GenericBeanResult>();
+   private final List<GenericBeanResult> genericBeans = new ArrayList<GenericBeanResult>();
 
-   private Map<BeanResult<?>, List<FieldValueObject>> fieldValues = new HashMap<BeanResult<?>, List<FieldValueObject>>();
+   private final Map<BeanResult<?>, List<FieldValueObject>> fieldValues = new HashMap<BeanResult<?>, List<FieldValueObject>>();
 
-   private Map<Class<?>, List<FieldValueObject>> interfaceFieldValues = new HashMap<Class<?>, List<FieldValueObject>>();
+   private final Map<Class<?>, List<FieldValueObject>> interfaceFieldValues = new HashMap<Class<?>, List<FieldValueObject>>();
 
    public void addStereotype(Class<? extends Annotation> an, Annotation[] values)
    {

Modified: modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/fieldset/ArrayFieldSet.java
===================================================================
--- modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/fieldset/ArrayFieldSet.java	2010-05-26 21:41:38 UTC (rev 12824)
+++ modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/fieldset/ArrayFieldSet.java	2010-05-26 22:01:37 UTC (rev 12825)
@@ -36,9 +36,9 @@
  */
 public class ArrayFieldSet implements FieldValueObject
 {
-   FieldValueSetter field;
-   List<AFS> values;
-   Class arrayType;
+   final private FieldValueSetter field;
+   final private List<AFS> values;
+   final private Class arrayType;
 
    public ArrayFieldSet(FieldValueSetter field, List<XmlItem> items)
    {

Modified: modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/fieldset/CollectionFieldSet.java
===================================================================
--- modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/fieldset/CollectionFieldSet.java	2010-05-26 21:41:38 UTC (rev 12824)
+++ modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/fieldset/CollectionFieldSet.java	2010-05-26 22:01:37 UTC (rev 12825)
@@ -48,37 +48,16 @@
  */
 public class CollectionFieldSet implements FieldValueObject
 {
-   FieldValueSetter field;
-   List<CFS> values;
-   Class<?> elementType;
-   Class<? extends Collection> collectionType;
+   private final FieldValueSetter field;
+   private final List<CFS> values;
+   private final Class<?> elementType;
+   private final Class<? extends Collection> collectionType;
 
    public CollectionFieldSet(FieldValueSetter field, List<XmlItem> items)
    {
       this.field = field;
       this.values = new ArrayList<CFS>();
-      discoverElementType();
 
-      CFS setter;
-      for (XmlItem i : items)
-      {
-         final Object fv = XmlObjectConverter.convert(elementType, i.getInnerText());
-
-         setter = new CFS()
-         {
-            public void add(Collection<Object> o) throws IllegalAccessException
-            {
-               o.add(fv);
-            }
-         };
-
-         values.add(setter);
-      }
-
-   }
-
-   public void discoverElementType()
-   {
       Type type = field.getGenericType();
       if (type instanceof ParameterizedType)
       {
@@ -131,6 +110,22 @@
          throw new RuntimeException("Could not determine element type for " + field.getDeclaringClass().getName() + "." + field.getName());
       }
 
+      CFS setter;
+      for (XmlItem i : items)
+      {
+         final Object fv = XmlObjectConverter.convert(elementType, i.getInnerText());
+
+         setter = new CFS()
+         {
+            public void add(Collection<Object> o) throws IllegalAccessException
+            {
+               o.add(fv);
+            }
+         };
+
+         values.add(setter);
+      }
+
    }
 
    public void setValue(Object instance)

Modified: modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/fieldset/DirectFieldSetter.java
===================================================================
--- modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/fieldset/DirectFieldSetter.java	2010-05-26 21:41:38 UTC (rev 12824)
+++ modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/fieldset/DirectFieldSetter.java	2010-05-26 22:01:37 UTC (rev 12825)
@@ -34,7 +34,7 @@
 public class DirectFieldSetter implements FieldValueSetter
 {
 
-   Field field;
+   private final Field field;
 
    public DirectFieldSetter(Field field)
    {

Modified: modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/fieldset/InjectionTargetWrapper.java
===================================================================
--- modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/fieldset/InjectionTargetWrapper.java	2010-05-26 21:41:38 UTC (rev 12824)
+++ modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/fieldset/InjectionTargetWrapper.java	2010-05-26 22:01:37 UTC (rev 12825)
@@ -30,8 +30,8 @@
 
 public class InjectionTargetWrapper<T> implements InjectionTarget<T>
 {
-   InjectionTarget<T> target;
-   List<FieldValueObject> fieldValues;
+   private final InjectionTarget<T> target;
+   private final List<FieldValueObject> fieldValues;
 
    public InjectionTargetWrapper(InjectionTarget<T> target, List<FieldValueObject> fieldValues)
    {

Modified: modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/fieldset/MapFieldSet.java
===================================================================
--- modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/fieldset/MapFieldSet.java	2010-05-26 21:41:38 UTC (rev 12824)
+++ modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/fieldset/MapFieldSet.java	2010-05-26 22:01:37 UTC (rev 12825)
@@ -44,39 +44,17 @@
  */
 public class MapFieldSet implements FieldValueObject
 {
-   FieldValueSetter field;
-   List<MFS> values;
-   Class<?> keyType;
-   Class<?> valueType;
-   Class<? extends Map> collectionType;
+   private final FieldValueSetter field;
+   private final List<MFS> values;
+   private final Class<?> keyType;
+   private final Class<?> valueType;
+   private final Class<? extends Map> collectionType;
 
    public MapFieldSet(FieldValueSetter field, List<EntryXmlItem> items)
    {
       this.field = field;
       this.values = new ArrayList<MFS>();
-      discoverElementType();
-
-      for (EntryXmlItem i : items)
-      {
-         MFS setter;
-         final Object key = XmlObjectConverter.convert(keyType, i.getKey().getInnerText());
-         final Object value = XmlObjectConverter.convert(valueType, i.getValue().getInnerText());
-         setter = new MFS()
-         {
-            @SuppressWarnings("unchecked")
-            public void add(Map m) throws IllegalAccessException
-            {
-               m.put(key, value);
-            }
-         };
-
-         values.add(setter);
-      }
-
-   }
-
-   public void discoverElementType()
-   {
+      // figure out the collection type
       Type type = field.getGenericType();
       if (type instanceof ParameterizedType)
       {
@@ -96,8 +74,6 @@
          }
          else if (parameterizedType.getRawType() == SortedMap.class)
          {
-            keyType = (Class<?>) parameterizedType.getActualTypeArguments()[0];
-            valueType = (Class<?>) parameterizedType.getActualTypeArguments()[1];
             collectionType = TreeMap.class;
          }
          else if (parameterizedType.getRawType() == TreeMap.class)
@@ -117,8 +93,30 @@
          throw new RuntimeException("Could not determine element type for map " + field.getDeclaringClass().getName() + "." + field.getName());
       }
 
+      for (EntryXmlItem i : items)
+      {
+         MFS setter;
+         final Object key = XmlObjectConverter.convert(keyType, i.getKey().getInnerText());
+         final Object value = XmlObjectConverter.convert(valueType, i.getValue().getInnerText());
+         setter = new MFS()
+         {
+            @SuppressWarnings("unchecked")
+            public void add(Map m) throws IllegalAccessException
+            {
+               m.put(key, value);
+            }
+         };
+
+         values.add(setter);
+      }
+
    }
 
+   public void discoverElementType()
+   {
+
+   }
+
    public void setValue(Object instance)
    {
       try

Modified: modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/fieldset/MethodFieldSetter.java
===================================================================
--- modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/fieldset/MethodFieldSetter.java	2010-05-26 21:41:38 UTC (rev 12824)
+++ modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/fieldset/MethodFieldSetter.java	2010-05-26 22:01:37 UTC (rev 12825)
@@ -33,7 +33,7 @@
  */
 public class MethodFieldSetter implements FieldValueSetter
 {
-   Method method;
+   private final Method method;
 
    public MethodFieldSetter(Method method)
    {

Modified: modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/fieldset/SimpleFieldValue.java
===================================================================
--- modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/fieldset/SimpleFieldValue.java	2010-05-26 21:41:38 UTC (rev 12824)
+++ modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/fieldset/SimpleFieldValue.java	2010-05-26 22:01:37 UTC (rev 12825)
@@ -28,9 +28,9 @@
 public class SimpleFieldValue implements FieldValueObject
 {
 
-   final FieldValueSetter field;
+   private final FieldValueSetter field;
 
-   FS setter;
+   private final FS setter;
 
    public SimpleFieldValue(Class<?> javaObject, final FieldValueSetter f, final String value)
    {

Modified: modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/AbstractXmlItem.java
===================================================================
--- modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/AbstractXmlItem.java	2010-05-26 21:41:38 UTC (rev 12824)
+++ modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/AbstractXmlItem.java	2010-05-26 22:01:37 UTC (rev 12825)
@@ -29,16 +29,16 @@
 
 public abstract class AbstractXmlItem implements XmlItem
 {
-   final XmlItemType type;
-   final XmlItem parent;
-   final Class<?> javaClass;
+   protected final XmlItemType type;
+   protected final XmlItem parent;
+   protected final Class<?> javaClass;
 
-   final String innerText;
-   final Map<String, String> attributes;
+   protected final String innerText;
+   protected final Map<String, String> attributes;
 
-   final int lineno;
+   protected final int lineno;
 
-   final String document;
+   protected final String document;
 
    public String getInnerText()
    {

Modified: modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/AnnotationXmlItem.java
===================================================================
--- modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/AnnotationXmlItem.java	2010-05-26 21:41:38 UTC (rev 12824)
+++ modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/AnnotationXmlItem.java	2010-05-26 22:01:37 UTC (rev 12825)
@@ -27,7 +27,7 @@
 
 public class AnnotationXmlItem extends AbstractXmlItem
 {
-   HashSet<XmlItemType> allowed = new HashSet<XmlItemType>();
+   private final HashSet<XmlItemType> allowed = new HashSet<XmlItemType>();
 
    public AnnotationXmlItem(XmlItem parent, Class<?> c, String innerText, Map<String, String> attributes, String document, int lineno)
    {

Modified: modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/ArrayXmlItem.java
===================================================================
--- modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/ArrayXmlItem.java	2010-05-26 21:41:38 UTC (rev 12824)
+++ modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/ArrayXmlItem.java	2010-05-26 22:01:37 UTC (rev 12825)
@@ -30,7 +30,7 @@
 public class ArrayXmlItem extends ParameterXmlItem
 {
 
-   Class javaClass = null;
+   Class<?> javaClass = null;
 
    int dimensions = 1;
 

Modified: modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/ModelBuilder.java
===================================================================
--- modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/ModelBuilder.java	2010-05-26 21:41:38 UTC (rev 12824)
+++ modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/ModelBuilder.java	2010-05-26 22:01:37 UTC (rev 12825)
@@ -62,21 +62,19 @@
 public class ModelBuilder
 {
 
-   AnnotationInstanceProvider ac = new AnnotationInstanceProvider();
+   final AnnotationInstanceProvider ac = new AnnotationInstanceProvider();
 
    static final String ROOT_NAMESPACE = "urn:java:seam:core";
 
    static final String BEANS_ROOT_NAMESPACE = "http://java.sun.com/xml/ns/javaee";
 
-   Map<String, NamespaceElementResolver> resolvers;
-
    /**
     * builds an XML result from a parsed xml document
     */
    public XmlResult build(SaxNode root)
    {
 
-      resolvers = new HashMap<String, NamespaceElementResolver>();
+      Map<String, NamespaceElementResolver> resolvers = new HashMap<String, NamespaceElementResolver>();
 
       XmlResult ret = new XmlResult();
 
@@ -104,7 +102,7 @@
                {
                   continue;
                }
-               XmlItem rb = resolveNode(node, null);
+               XmlItem rb = resolveNode(node, null, resolvers);
                // validateXmlItem(rb);
                addNodeToResult(ret, rb);
             }
@@ -213,9 +211,9 @@
    /**
     * resolves the appropriate java elements from the xml
     */
-   protected XmlItem resolveNode(SaxNode node, XmlItem parent)
+   protected XmlItem resolveNode(SaxNode node, XmlItem parent, Map<String, NamespaceElementResolver> resolvers)
    {
-      NamespaceElementResolver resolver = resolveNamepsace(node.getNamespaceUri());
+      NamespaceElementResolver resolver = resolveNamepsace(node.getNamespaceUri(), resolvers);
 
       XmlItem ret = resolver.getItemForNamespace(node, parent);
 
@@ -228,7 +226,7 @@
       {
          if (n.getNamespaceUri() != null)
          {
-            XmlItem rb = resolveNode(n, ret);
+            XmlItem rb = resolveNode(n, ret, resolvers);
             ret.addChild(rb);
          }
       }
@@ -237,7 +235,7 @@
 
    }
 
-   protected NamespaceElementResolver resolveNamepsace(String namespaceURI)
+   protected NamespaceElementResolver resolveNamepsace(String namespaceURI, Map<String, NamespaceElementResolver> resolvers)
    {
       if (resolvers.containsKey(namespaceURI))
       {

Modified: modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/parser/namespace/CompositeNamespaceElementResolver.java
===================================================================
--- modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/parser/namespace/CompositeNamespaceElementResolver.java	2010-05-26 21:41:38 UTC (rev 12824)
+++ modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/parser/namespace/CompositeNamespaceElementResolver.java	2010-05-26 22:01:37 UTC (rev 12825)
@@ -39,8 +39,8 @@
 public class CompositeNamespaceElementResolver implements NamespaceElementResolver
 {
 
-   Set<String> notFound = new HashSet<String>();
-   List<PackageNamespaceElementResolver> resolvers = new ArrayList<PackageNamespaceElementResolver>();
+   private final Set<String> notFound = new HashSet<String>();
+   private final List<PackageNamespaceElementResolver> resolvers = new ArrayList<PackageNamespaceElementResolver>();
 
    public CompositeNamespaceElementResolver(Collection<String> packages)
    {

Modified: modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/parser/namespace/PackageNamespaceElementResolver.java
===================================================================
--- modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/parser/namespace/PackageNamespaceElementResolver.java	2010-05-26 21:41:38 UTC (rev 12824)
+++ modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/parser/namespace/PackageNamespaceElementResolver.java	2010-05-26 22:01:37 UTC (rev 12825)
@@ -42,9 +42,9 @@
 
 public class PackageNamespaceElementResolver implements NamespaceElementResolver
 {
-   String pack;
-   Map<String, Class<?>> cache = new HashMap<String, Class<?>>();
-   Set<String> notFound = new HashSet<String>();
+   private final String pack;
+   private final Map<String, Class<?>> cache = new HashMap<String, Class<?>>();
+   private final Set<String> notFound = new HashSet<String>();
 
    public PackageNamespaceElementResolver(String pack)
    {

Modified: modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/parser/namespace/RootNamespaceElementResolver.java
===================================================================
--- modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/parser/namespace/RootNamespaceElementResolver.java	2010-05-26 21:41:38 UTC (rev 12824)
+++ modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/parser/namespace/RootNamespaceElementResolver.java	2010-05-26 22:01:37 UTC (rev 12825)
@@ -39,7 +39,7 @@
 public class RootNamespaceElementResolver implements NamespaceElementResolver
 {
 
-   CompositeNamespaceElementResolver delegate;
+   private final CompositeNamespaceElementResolver delegate;
    static final String[] namspaces = { "java.lang", "java.util", "javax.annotation", "javax.inject", "javax.enterprise.inject", "javax.enterprise.context", "javax.enterprise.event", "javax.decorator", "javax.interceptor", "org.jboss.seam.xml.annotations.internal" };
 
    public RootNamespaceElementResolver()



More information about the seam-commits mailing list