Title: [1387] trunk/qdox/src/test/java/com/thoughtworks/qdox: Move default implementation of JavaAnnotation to separate package

Diff

Modified: trunk/qdox/src/main/java/com/thoughtworks/qdox/builder/DefaultAnnotationTransformer.java (1386 => 1387)

--- trunk/qdox/src/main/java/com/thoughtworks/qdox/builder/DefaultAnnotationTransformer.java	2011-10-09 10:09:33 UTC (rev 1386)
+++ trunk/qdox/src/main/java/com/thoughtworks/qdox/builder/DefaultAnnotationTransformer.java	2011-10-09 10:16:49 UTC (rev 1387)
@@ -24,7 +24,6 @@
 import java.util.Map;
 
 import com.thoughtworks.qdox.model.AbstractBaseJavaEntity;
-import com.thoughtworks.qdox.model.Annotation;
 import com.thoughtworks.qdox.model.Type;
 import com.thoughtworks.qdox.model._expression_.Add;
 import com.thoughtworks.qdox.model._expression_.And;
@@ -57,6 +56,7 @@
 import com.thoughtworks.qdox.model._expression_.Subtract;
 import com.thoughtworks.qdox.model._expression_.TypeRef;
 import com.thoughtworks.qdox.model._expression_.UnsignedShiftRight;
+import com.thoughtworks.qdox.model.impl.DefaultJavaAnnotation;
 import com.thoughtworks.qdox.parser._expression_.AnnotationAdd;
 import com.thoughtworks.qdox.parser._expression_.AnnotationAnd;
 import com.thoughtworks.qdox.parser._expression_.AnnotationCast;
@@ -103,8 +103,8 @@
 	/* (non-Javadoc)
 	 * @see com.thoughtworks.qdox.builder.AnnotationTransformer#transform(com.thoughtworks.qdox.parser.structs.AnnoDef)
 	 */
-	public Annotation transform(AnnoDef annoDef) {
-    	Annotation annotation = new Annotation(createType(annoDef.getTypeDef(), 0), annoDef.getLineNumber());
+	public DefaultJavaAnnotation transform(AnnoDef annoDef) {
+    	DefaultJavaAnnotation annotation = new DefaultJavaAnnotation(createType(annoDef.getTypeDef(), 0), annoDef.getLineNumber());
     	for(Map.Entry<String, ElemValueDef> annoVal : annoDef.getArgs().entrySet()) {
     		annotation.setProperty(annoVal.getKey(), annoVal.getValue().transform(this));
     	}

Modified: trunk/qdox/src/main/java/com/thoughtworks/qdox/builder/ModelBuilder.java (1386 => 1387)

--- trunk/qdox/src/main/java/com/thoughtworks/qdox/builder/ModelBuilder.java	2011-10-09 10:09:33 UTC (rev 1386)
+++ trunk/qdox/src/main/java/com/thoughtworks/qdox/builder/ModelBuilder.java	2011-10-09 10:16:49 UTC (rev 1387)
@@ -27,7 +27,6 @@
 
 import com.thoughtworks.qdox.library.ClassLibrary;
 import com.thoughtworks.qdox.model.AbstractBaseJavaEntity;
-import com.thoughtworks.qdox.model.Annotation;
 import com.thoughtworks.qdox.model.DefaultJavaClass;
 import com.thoughtworks.qdox.model.DefaultJavaConstructor;
 import com.thoughtworks.qdox.model.DefaultJavaMethod;
@@ -44,6 +43,7 @@
 import com.thoughtworks.qdox.model.JavaType;
 import com.thoughtworks.qdox.model.Type;
 import com.thoughtworks.qdox.model.TypeVariable;
+import com.thoughtworks.qdox.model.impl.DefaultJavaAnnotation;
 import com.thoughtworks.qdox.model.impl.DefaultJavaField;
 import com.thoughtworks.qdox.model.impl.DefaultJavaPackage;
 import com.thoughtworks.qdox.model.impl.DefaultJavaSource;

Deleted: trunk/qdox/src/main/java/com/thoughtworks/qdox/model/Annotation.java (1386 => 1387)

--- trunk/qdox/src/main/java/com/thoughtworks/qdox/model/Annotation.java	2011-10-09 10:09:33 UTC (rev 1386)
+++ trunk/qdox/src/main/java/com/thoughtworks/qdox/model/Annotation.java	2011-10-09 10:16:49 UTC (rev 1387)
@@ -1,162 +0,0 @@
-package com.thoughtworks.qdox.model;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.Serializable;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import com.thoughtworks.qdox.model._expression_.AnnotationValue;
-import com.thoughtworks.qdox.model._expression_.AnnotationVisitor;
-import com.thoughtworks.qdox.model.impl.AbstractJavaModel;
-
-/**
- * 
- * @author Eric Redmond
- */
-public class Annotation implements AnnotationValue, Serializable, JavaAnnotation
-{
-    private final JavaClass type;
-    private final int lineNumber;
-
-    /**
-     * Annotation properties as AnnotationValues
-     * <p>
-     * This map contains the parsed AnnotationValue for each property and allows
-     * access to the full parse tree, including typerefs and expressions.
-     */
-    private final Map<String, AnnotationValue> properties = new LinkedHashMap<String, AnnotationValue>();
-
-    /**
-     * Annotation properties as Parameters
-     */
-    private final Map<String, Object> namedParameters = new LinkedHashMap<String, Object>();
-
-    private AbstractJavaModel context;
-
-    public Annotation(JavaClass type,
-            AbstractJavaModel context,
-            Map<String, Object> namedParameters,
-            int lineNumber)
-	{
-        this.type = type;
-        this.context = context;
-        this.lineNumber = lineNumber;
-        
-        if(properties != null) {
-            for(Iterator<Entry<String, AnnotationValue>> i = this.properties.entrySet().iterator(); i.hasNext(); ) {
-                Entry<String, AnnotationValue> entry = i.next();
-                String name = entry.getKey();
-                AnnotationValue value = entry.getValue();
-                
-                setProperty(name, value);
-            }
-        }
-	}
-
-    public Annotation( Type type, int line ) {
-        this(type, null, null, line);
-    }
-
-    public final void setProperty(String name, AnnotationValue value) {
-        properties.put( name, value );
-        namedParameters.put( name, value.getParameterValue() );
-    }
-
-    /* (non-Javadoc)
-	 * @see com.thoughtworks.qdox.model.JavaAnnotation#getType()
-	 */
-    public JavaClass getType() {
-    	return type;
-    }
-
-    /**
-     * @param key name of a named-parameter
-     * @return the corresponding value,
-     *   or null if no such named-parameter was present
-     */
-    public Object getNamedParameter(String key) {
-    	return namedParameters.get( key );
-    }
-
-    /**
-     * @return a Map containing all the named-parameters
-     */
-    public Map<String, Object> getNamedParameterMap() {
-    	return namedParameters;
-    }
-
-    public final AbstractJavaModel getContext() {
-        return context;
-    }
-
-    public int getLineNumber() {
-        return lineNumber;
-    }
-
-    public Object accept( AnnotationVisitor visitor ) {
-        return visitor.visit( this );
-    }
-
-    public Annotation getParameterValue() {
-        return this;
-    }
-    
-    /* (non-Javadoc)
-	 * @see com.thoughtworks.qdox.model.JavaAnnotation#getPropertyMap()
-	 */
-    public Map<String, AnnotationValue> getPropertyMap() {
-        return properties;
-    }
-    
-    /* (non-Javadoc)
-	 * @see com.thoughtworks.qdox.model.JavaAnnotation#getProperty(java.lang.String)
-	 */
-    public AnnotationValue getProperty(String name) {
-        return properties.get( name );
-    }
-
-    public void setContext( AbstractJavaModel context ) {
-        this.context = context;
-    }
-
-    public String toString()
-    {
-        StringBuffer result = new StringBuffer();
-        result.append( '@' );
-        result.append( type.getFullyQualifiedName() );
-        result.append( '(' );
-        if ( !namedParameters.isEmpty() )
-        {
-            for ( Iterator<Entry<String, Object>> i = namedParameters.entrySet().iterator(); i.hasNext(); )
-            {
-                result.append( i.next() );
-                if ( i.hasNext() )
-                {
-                    result.append( ',' );
-                }
-            }
-        }
-        result.append( ')' );
-        return result.toString();
-    }
-}

Modified: trunk/qdox/src/main/java/com/thoughtworks/qdox/model/_expression_/AnnotationValue.java (1386 => 1387)

--- trunk/qdox/src/main/java/com/thoughtworks/qdox/model/_expression_/AnnotationValue.java	2011-10-09 10:09:33 UTC (rev 1386)
+++ trunk/qdox/src/main/java/com/thoughtworks/qdox/model/_expression_/AnnotationValue.java	2011-10-09 10:16:49 UTC (rev 1387)
@@ -19,7 +19,7 @@
  * under the License.
  */
 
-import com.thoughtworks.qdox.model.Annotation;
+import com.thoughtworks.qdox.model.impl.DefaultJavaAnnotation;
 
 /**
  * Interface for all annotation model elements
@@ -37,7 +37,7 @@
     Object accept( AnnotationVisitor visitor );
 
     /**
-     * Get a parameter value for {@link Annotation#getNamedParameter(String)}.
+     * Get a parameter value for {@link DefaultJavaAnnotation#getNamedParameter(String)}.
      * 
      * @return Parameter value
      */

Copied: trunk/qdox/src/main/java/com/thoughtworks/qdox/model/impl/DefaultJavaAnnotation.java (from rev 1386, trunk/qdox/src/main/java/com/thoughtworks/qdox/model/Annotation.java) (0 => 1387)

--- trunk/qdox/src/main/java/com/thoughtworks/qdox/model/impl/DefaultJavaAnnotation.java	                        (rev 0)
+++ trunk/qdox/src/main/java/com/thoughtworks/qdox/model/impl/DefaultJavaAnnotation.java	2011-10-09 10:16:49 UTC (rev 1387)
@@ -0,0 +1,164 @@
+package com.thoughtworks.qdox.model.impl;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.Serializable;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import com.thoughtworks.qdox.model.JavaAnnotation;
+import com.thoughtworks.qdox.model.JavaClass;
+import com.thoughtworks.qdox.model.Type;
+import com.thoughtworks.qdox.model._expression_.AnnotationValue;
+import com.thoughtworks.qdox.model._expression_.AnnotationVisitor;
+
+/**
+ * 
+ * @author Eric Redmond
+ */
+public class DefaultJavaAnnotation implements AnnotationValue, Serializable, JavaAnnotation
+{
+    private final JavaClass type;
+    private final int lineNumber;
+
+    /**
+     * Annotation properties as AnnotationValues
+     * <p>
+     * This map contains the parsed AnnotationValue for each property and allows
+     * access to the full parse tree, including typerefs and expressions.
+     */
+    private final Map<String, AnnotationValue> properties = new LinkedHashMap<String, AnnotationValue>();
+
+    /**
+     * Annotation properties as Parameters
+     */
+    private final Map<String, Object> namedParameters = new LinkedHashMap<String, Object>();
+
+    private AbstractJavaModel context;
+
+    public DefaultJavaAnnotation(JavaClass type,
+            AbstractJavaModel context,
+            Map<String, Object> namedParameters,
+            int lineNumber)
+	{
+        this.type = type;
+        this.context = context;
+        this.lineNumber = lineNumber;
+        
+        if(properties != null) {
+            for(Iterator<Entry<String, AnnotationValue>> i = this.properties.entrySet().iterator(); i.hasNext(); ) {
+                Entry<String, AnnotationValue> entry = i.next();
+                String name = entry.getKey();
+                AnnotationValue value = entry.getValue();
+                
+                setProperty(name, value);
+            }
+        }
+	}
+
+    public DefaultJavaAnnotation( Type type, int line ) {
+        this(type, null, null, line);
+    }
+
+    public final void setProperty(String name, AnnotationValue value) {
+        properties.put( name, value );
+        namedParameters.put( name, value.getParameterValue() );
+    }
+
+    /* (non-Javadoc)
+	 * @see com.thoughtworks.qdox.model.JavaAnnotation#getType()
+	 */
+    public JavaClass getType() {
+    	return type;
+    }
+
+    /**
+     * @param key name of a named-parameter
+     * @return the corresponding value,
+     *   or null if no such named-parameter was present
+     */
+    public Object getNamedParameter(String key) {
+    	return namedParameters.get( key );
+    }
+
+    /**
+     * @return a Map containing all the named-parameters
+     */
+    public Map<String, Object> getNamedParameterMap() {
+    	return namedParameters;
+    }
+
+    public final AbstractJavaModel getContext() {
+        return context;
+    }
+
+    public int getLineNumber() {
+        return lineNumber;
+    }
+
+    public Object accept( AnnotationVisitor visitor ) {
+        return visitor.visit( this );
+    }
+
+    public DefaultJavaAnnotation getParameterValue() {
+        return this;
+    }
+    
+    /* (non-Javadoc)
+	 * @see com.thoughtworks.qdox.model.JavaAnnotation#getPropertyMap()
+	 */
+    public Map<String, AnnotationValue> getPropertyMap() {
+        return properties;
+    }
+    
+    /* (non-Javadoc)
+	 * @see com.thoughtworks.qdox.model.JavaAnnotation#getProperty(java.lang.String)
+	 */
+    public AnnotationValue getProperty(String name) {
+        return properties.get( name );
+    }
+
+    public void setContext( AbstractJavaModel context ) {
+        this.context = context;
+    }
+
+    public String toString()
+    {
+        StringBuffer result = new StringBuffer();
+        result.append( '@' );
+        result.append( type.getFullyQualifiedName() );
+        result.append( '(' );
+        if ( !namedParameters.isEmpty() )
+        {
+            for ( Iterator<Entry<String, Object>> i = namedParameters.entrySet().iterator(); i.hasNext(); )
+            {
+                result.append( i.next() );
+                if ( i.hasNext() )
+                {
+                    result.append( ',' );
+                }
+            }
+        }
+        result.append( ')' );
+        return result.toString();
+    }
+}

Modified: trunk/qdox/src/test/java/com/thoughtworks/qdox/AnnotationsModelTest.java (1386 => 1387)

--- trunk/qdox/src/test/java/com/thoughtworks/qdox/AnnotationsModelTest.java	2011-10-09 10:09:33 UTC (rev 1386)
+++ trunk/qdox/src/test/java/com/thoughtworks/qdox/AnnotationsModelTest.java	2011-10-09 10:16:49 UTC (rev 1387)
@@ -5,7 +5,6 @@
 
 import junit.framework.TestCase;
 
-import com.thoughtworks.qdox.model.Annotation;
 import com.thoughtworks.qdox.model.JavaAnnotation;
 import com.thoughtworks.qdox.model.JavaClass;
 import com.thoughtworks.qdox.model.JavaMethod;
@@ -16,6 +15,7 @@
 import com.thoughtworks.qdox.model._expression_.Constant;
 import com.thoughtworks.qdox.model._expression_.FieldRef;
 import com.thoughtworks.qdox.model._expression_.TypeRef;
+import com.thoughtworks.qdox.model.impl.DefaultJavaAnnotation;
 import com.thoughtworks.qdox.parser._expression_.AnnotationTypeRef;
 
 public class AnnotationsModelTest extends TestCase {

Modified: trunk/qdox/src/test/java/com/thoughtworks/qdox/JavaProjectBuilderTest.java (1386 => 1387)

--- trunk/qdox/src/test/java/com/thoughtworks/qdox/JavaProjectBuilderTest.java	2011-10-09 10:09:33 UTC (rev 1386)
+++ trunk/qdox/src/test/java/com/thoughtworks/qdox/JavaProjectBuilderTest.java	2011-10-09 10:16:49 UTC (rev 1387)
@@ -23,7 +23,6 @@
 
 import com.thoughtworks.qdox.library.ErrorHandler;
 import com.thoughtworks.qdox.library.OrderedClassLibraryBuilder;
-import com.thoughtworks.qdox.model.Annotation;
 import com.thoughtworks.qdox.model.BeanProperty;
 import com.thoughtworks.qdox.model.DocletTag;
 import com.thoughtworks.qdox.model.JavaAnnotation;
@@ -35,6 +34,7 @@
 import com.thoughtworks.qdox.model.JavaSource;
 import com.thoughtworks.qdox.model.JavaType;
 import com.thoughtworks.qdox.model.Type;
+import com.thoughtworks.qdox.model.impl.DefaultJavaAnnotation;
 import com.thoughtworks.qdox.model.util.SerializationUtils;
 import com.thoughtworks.qdox.parser.ParseException;
 import com.thoughtworks.qdox.testdata.PropertyClass;

Modified: trunk/qdox/src/test/java/com/thoughtworks/qdox/builder/EvaluatingVisitorTest.java (1386 => 1387)

--- trunk/qdox/src/test/java/com/thoughtworks/qdox/builder/EvaluatingVisitorTest.java	2011-10-09 10:09:33 UTC (rev 1386)
+++ trunk/qdox/src/test/java/com/thoughtworks/qdox/builder/EvaluatingVisitorTest.java	2011-10-09 10:16:49 UTC (rev 1387)
@@ -13,7 +13,6 @@
 import org.junit.Ignore;
 import org.junit.Test;
 
-import com.thoughtworks.qdox.model.Annotation;
 import com.thoughtworks.qdox.model.JavaField;
 import com.thoughtworks.qdox.model.Type;
 import com.thoughtworks.qdox.model._expression_.Add;
@@ -43,6 +42,7 @@
 import com.thoughtworks.qdox.model._expression_.ShiftRight;
 import com.thoughtworks.qdox.model._expression_.Subtract;
 import com.thoughtworks.qdox.model._expression_.UnsignedShiftRight;
+import com.thoughtworks.qdox.model.impl.DefaultJavaAnnotation;
 
 public class EvaluatingVisitorTest
 {
@@ -302,7 +302,7 @@
     public void testVisitAnnotation()
     {
         try{
-            visitor.visit( new Annotation( new Type("Ignore"), -1 ) );
+            visitor.visit( new DefaultJavaAnnotation( new Type("Ignore"), -1 ) );
             fail( "Visiting an annotation is not supported and should throw an UnsupportedOperationException" );
         }
         catch (UnsupportedOperationException e) {


To unsubscribe from this list please visit:

http://xircles.codehaus.org/manage_email

Reply via email to