jstrachan    2002/11/14 00:10:05

  Added:       attributes maven.xml LICENSE.txt .cvsignore
                        project.properties project.xml
               attributes/src/java/org/apache/commons/attributes/impl
                        DefaultAttributeFinder.java package.html
               attributes/src/test/org/apache/commons/attributes
                        AttributesTest.java AttributesTestClass.java
               attributes/src/java/org/apache/commons/attributes/task
                        package.html AttributesCompiler.java
               attributes/src/java/org/apache/commons/attributes
                        AttributesException.java AttributeFinder.java
                        package.html Attributes.java
               attributes/xdocs usage.xml navigation.xml index.xml
  Log:
  Added initial version of Commons Attributes.
  
  Commons Attributes provides a simple API to runtime metadata attributes. This allows 
runtime access to doclet tags etc.
  This is a refactor by Jon Tirsén of code he wrote for the Nanning project.
  
  http://nanning.sourceforge.net/
  
  Revision  Changes    Path
  1.1                  jakarta-commons-sandbox/attributes/maven.xml
  
  Index: maven.xml
  ===================================================================
  
  <project default="java:jar" xmlns:jxr="jxr" xmlns:j="jelly:core">
  
      <preGoal name="site:generate">
        <attainGoal name="clover"/>
      </preGoal>
      
      <goal name="changelog:generate">
        <!-- don't have a repository yet, skip this -->
      </goal>
  
  </project>
  
  
  
  1.1                  jakarta-commons-sandbox/attributes/LICENSE.txt
  
  Index: LICENSE.txt
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons/LICENSE,v 1.4 2002/04/11 13:24:02 dion Exp $
   * $Revision: 1.4 $
   * $Date: 2002/04/11 13:24:02 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  
  
  
  1.1                  jakarta-commons-sandbox/attributes/.cvsignore
  
  Index: .cvsignore
  ===================================================================
  build.properties
  lib
  dist
  target
  *.log
  *.gz
  tmp
  .classpath
  .project
  
  
  
  1.1                  jakarta-commons-sandbox/attributes/project.properties
  
  Index: project.properties
  ===================================================================
  #####################################################
  # Java
  #####################################################
  maven.jarResources.basedir = ${pom.build.sourceDirectory}
  
  #####################################################
  # Properties related to project-site
  #####################################################
  maven.xdoc.date = left
  maven.xdoc.version = ${pom.currentVersion}
  
  #####################################################
  # Test
  #####################################################
  maven.junit.fork = true
  maven.test.failure.ignore = true
  
  
  
  1.1                  jakarta-commons-sandbox/attributes/project.xml
  
  Index: project.xml
  ===================================================================
  <?xml version="1.0"?>
  <project>
    <pomVersion>3</pomVersion>
    <name>Commons Attributes</name>
    <id>commons-attributes</id>
    <currentVersion>0.1</currentVersion>
  
    <organization>
      <name>Apache Software Foundation</name>
      <url>http://www.apache.org</url>
      <logo>/images/jakarta-logo-blue.gif</logo>
    </organization>
  
  <!--
    <logo>/images/logo.gif</logo>
  -->
  
    <inceptionYear>2002</inceptionYear>
    <package>org.apache.commons.attributes</package>
  
    <shortDescription>Provides runtime access to Java metadata 
attributes.</shortDescription>
  
    <description>
      Provides runtime access to Java metadata attributes.
    </description>
  
    <url>http://jakarta.apache.org/commons/sandbox/attributes/</url>
    
<issueTrackingUrl>http://jira.werken.com/BrowseProject.jspa?id=10061</issueTrackingUrl>
    <siteAddress>jakarta.apache.org</siteAddress>
    <siteDirectory>/www/jakarta.apache.org/commons/sandbox/attributes/</siteDirectory>
    
<distributionDirectory>/www/jakarta.apache.org/builds/jakarta-commons-sandbox/attributes/</distributionDirectory>
    <repository>
      
<connection>scm:cvs:pserver:[EMAIL PROTECTED]:/home/cvspublic:jakarta-commons-sandbox/attributes</connection>
      <url>http://cvs.apache.org/viewcvs/jakarta-commons-sandbox/attributes/</url>
    </repository>
    
    <versions>
      <version>
        <id>1.0-beta-1</id>
        <name>1.0-beta-1</name>
        <tag>1.0-beta-1</tag>
      </version>
    </versions>
    <branches></branches>
    
    <mailingLists>
      <mailingList>
        <name>Commons Dev List</name>
        <subscribe>[EMAIL PROTECTED]</subscribe>
        <unsubscribe>[EMAIL PROTECTED]</unsubscribe>
        
<archive>http://nagoya.apache.org/eyebrowse/SummarizeList?listName=commons-dev@;jakarta.apache.org</archive>
      </mailingList>
      <mailingList>
        <name>Commons User List</name>
        <subscribe>[EMAIL PROTECTED]</subscribe>
        <unsubscribe>[EMAIL PROTECTED]</unsubscribe>
        
<archive>http://nagoya.apache.org/eyebrowse/SummarizeList?listName=commons-user@;jakarta.apache.org</archive>
      </mailingList>
    </mailingLists>
    
    <developers>
      <developer>
        <name>Jon Tirsen</name>
        <id>tirsen</id>
        <email>[EMAIL PROTECTED]</email>
        <organization></organization>
      </developer>
  
      <developer>
        <name>James Strachan</name>
        <id>jstrachan</id>
        <email>[EMAIL PROTECTED]</email>
        <organization>SpiritSoft, Inc.</organization>
      </developer>
    </developers>
  
    <dependencies>
  
      <dependency>
        <id>qdox</id>
        <version>1.0</version>
      </dependency>
  
      <dependency>
        <id>commons-logging</id>
        <version>1.0.2</version>
      </dependency>
  
      <dependency>
        <id>junit</id>
        <version>3.8.1</version>
      </dependency>
  
      <dependency>
        <id>ant</id>
        <version>1.5</version>
      </dependency>
  
    </dependencies>
  
    <build>
  
      <nagEmailAddress>[EMAIL PROTECTED]</nagEmailAddress>
  
      <sourceDirectory>src/java</sourceDirectory>
  
      <unitTestSourceDirectory>src/test</unitTestSourceDirectory>
  
      <!-- Unit test classes -->
  
      <unitTest>
        <includes>
          <include>**/*Test.java</include>
        </includes>
        <excludes>
          <exclude>**/Abstract*.java</exclude>
        </excludes>
        <resources>
          <resource>
            <directory>src/test</directory>
            <includes>
              <include>**/*.xml</include>
              <include>**/*.properties</include>
            </includes>
          </resource>
        </resources>
      </unitTest>
  
  
      <resources>
        <directory>src/java</directory>
        <includes>
          <include>**/*.xml</include>
        </includes>
      </resources>
  
    </build>
  </project>
  
  
  1.1                  
jakarta-commons-sandbox/attributes/src/java/org/apache/commons/attributes/impl/DefaultAttributeFinder.java
  
  Index: DefaultAttributeFinder.java
  ===================================================================
  /*
   * $Header: $
   * $Revision:  $
   * $Date:  $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   * 
   * $Id: $
   */
  package org.apache.commons.attributes.impl;
  
  import org.apache.commons.attributes.AttributesException;
  import org.apache.commons.attributes.AttributeFinder;
  
  import java.io.IOException;
  import java.io.InputStream;
  import java.lang.reflect.Field;
  import java.lang.reflect.Method;
  import java.net.URL;
  import java.util.*;
  
  /**
   * DefaultAttributeFinder is a default implementation of 
   * AttributeFinder which uses properties files on the classpath.
   *
   * @author <a href="mailto:jon_tirsen@;yahoo.com">Jon Tirsén</a>
   * @version $Revision: $
   */
  public class DefaultAttributeFinder implements AttributeFinder {
        
        private static List searchPaths = new ArrayList();
  
        private Map propertiesCache = new HashMap();
  
        public String getAttribute(Class aClass, String attribute) {
                return getProperty(aClass, attributeName(aClass, attribute));
        }
  
        private String attributeName(Class aClass, String attribute) {
                return "class." + attribute;
        }
  
        private String getProperty(Class aClass, String key) {
                Properties properties = getProperties(aClass);
                return properties.getProperty(key);
        }
  
        private Properties getProperties(Class aClass) {
                Properties properties = (Properties) propertiesCache.get(aClass);
                if (properties == null) {
                        InputStream inputStream = null;
                        try {
                                String className = aClass.getName();
  
                                String fileName =
                                        className.substring(className.lastIndexOf('.') 
+ 1)
                                                + ".attributes";
                                inputStream = aClass.getResourceAsStream(fileName);
  
                                fileName = className.replace('.', '/') + ".attributes";
                                if (inputStream == null) {
                                        inputStream = aClass.getResourceAsStream('/' + 
fileName);
                                }
  
                                if (inputStream == null) {
                                        for (Iterator iterator = 
searchPaths.iterator();
                                                iterator.hasNext();
                                                ) {
                                                URL searchPath = (URL) iterator.next();
                                                URL url = new URL(searchPath, 
fileName);
                          try {
                              inputStream = url.openStream();
                          } catch (IOException ignore) {
                          }
                      }
                                }
  
                                if (inputStream != null) {
                                        properties = new Properties();
                                        properties.load(inputStream);
                                        propertiesCache.put(aClass, properties);
                                } else {
                                        throw new AttributesException(
                                                "Could not find attributes for " + 
aClass);
                                }
                        } catch (Exception e) {
                                throw new AttributesException(e);
                        } finally {
                                if (inputStream != null) {
                                        try {
                                                inputStream.close();
                                        } catch (IOException e) {
                                                throw new AttributesException(e);
                                        }
                                }
                        }
                }
                return properties;
        }
  
        public String getAttribute(Method method, String attribute) {
                String name = attributeName(method, attribute);
                return getProperty(method.getDeclaringClass(), name);
        }
  
        private String attributeName(Method method, String attribute) {
                StringBuffer stringBuffer = new StringBuffer();
                stringBuffer.append(method.getName());
                stringBuffer.append('(');
                Class[] parameterTypes = method.getParameterTypes();
                for (int i = 0; i < parameterTypes.length; i++) {
                        Class parameterType = parameterTypes[i];
                        stringBuffer.append(parameterType.getName());
                        if (i + 1 < parameterTypes.length) {
                                stringBuffer.append(',');
                        }
                }
                stringBuffer.append(')');
                stringBuffer.append('.');
                stringBuffer.append(attribute);
                String name = stringBuffer.toString();
                return name;
        }
  
        public String getAttribute(Field field, String attribute) {
                return getProperty(
                        field.getDeclaringClass(),
                        attributeName(field, attribute));
        }
  
        private String attributeName(Field field, String attribute) {
                return field.getName() + '.' + attribute;
        }
  
        public static void addSearchPath(URL searchPath) {
                searchPaths.add(searchPath);
        }
  
        public static void removeSearchPath(URL searchPath) {
                searchPaths.add(searchPath);
        }
  }
  
  
  
  1.1                  
jakarta-commons-sandbox/attributes/src/java/org/apache/commons/attributes/impl/package.html
  
  Index: package.html
  ===================================================================
  <html>
  <head>
  </head>
  <body>
    <p>
        This package contains the default implementation of the API. Other 
implementations can be plugged in.
    </p>
  </body>
  </html>
  
  
  
  1.1                  
jakarta-commons-sandbox/attributes/src/test/org/apache/commons/attributes/AttributesTest.java
  
  Index: AttributesTest.java
  ===================================================================
  /*
   * $Header: $
   * $Revision:  $
   * $Date:  $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   * 
   * $Id: $
   */
  package org.apache.commons.attributes;
  
  import junit.framework.TestCase;
  
  import java.io.File;
  import java.io.IOException;
  import java.lang.reflect.Method;
  import java.lang.reflect.Field;
  import java.net.URL;
  
  import org.apache.commons.attributes.Attributes;
  import org.apache.commons.attributes.AttributeFinder;
  import org.apache.commons.attributes.impl.DefaultAttributeFinder;
  import org.apache.commons.attributes.task.AttributesCompiler;
  
  /**
   * Test case for using the Attributes facade with the default implementation.
   *
   * @author <a href="mailto:jon_tirsen@;yahoo.com">Jon Tirsén</a>
   * @version $Revision: $
   */
  public class AttributesTest extends TestCase {
        private File targetDir;
        private URL searchPath;
      private Class testClass;
      private Field testField;
      private Method testMethod;
  
      protected void setUp() throws Exception {
                super.setUp();
          testClass = AttributesTestClass.class;
          testField = testClass.getDeclaredField("field");
          testMethod = AttributesTestClass.class.getMethod("method", null);
                targetDir = File.createTempFile("attributes", ".tmp");
                targetDir.delete();
                targetDir.mkdirs();
                searchPath = targetDir.toURL();
                DefaultAttributeFinder.addSearchPath(searchPath);
        }
  
        protected void tearDown() throws Exception {
                super.tearDown();
                DefaultAttributeFinder.removeSearchPath(searchPath);
        }
  
      public static class TestAttributesLoader implements AttributeFinder {
          private Class actualClass;
          private Class expectClass;
          private Method actualMethod;
          private Method expectMethod;
          private Field actualField;
          private Field expectField;
  
          public void expectClass(Class expectClass) {
              this.expectClass = expectClass;
          }
  
          public void expectMethod(Method expectMethod) {
              this.expectMethod = expectMethod;
          }
  
          public void expectField(Field expectField) {
              this.expectField = expectField;
          }
  
          public void verify() {
              assertSame(expectClass, actualClass);
              assertSame(expectMethod, actualMethod);
              assertSame(expectField, actualField);
          }
  
          public String getAttribute(Class aClass, String attribute) {
              actualClass = aClass;
              return null;
          }
  
          public String getAttribute(Method method, String attribute) {
              actualMethod = method;
              return null;
          }
  
          public String getAttribute(Field field, String attribute) {
              actualField = field;
              return null;
          }
  
      }
  
      public void testPluggability() {
          System.setProperty(
                        "org.apache.commons.attributes.AttributeFinder",
              TestAttributesLoader.class.getName()
          );
          
          // clear out the singleton just in case
          Attributes.setAttributeFinder(null);
          
          try {
              assertTrue(Attributes.getAttributeFinder() instanceof 
TestAttributesLoader);
              
              TestAttributesLoader testAttributesLoader = (TestAttributesLoader) 
Attributes.getAttributeFinder();
              testAttributesLoader.expectClass(testClass);
              testAttributesLoader.expectMethod(testMethod);
              testAttributesLoader.expectField(testField);
              Attributes.getAttribute(testClass, "testAttribute");
              Attributes.getAttribute(testMethod, "testAttribute");
              Attributes.getAttribute(testField, "testAttribute");
              testAttributesLoader.verify();
          } finally {
              // clear the pluggability for coming tests
              Attributes.setAttributeFinder(null);
              System.setProperty("org.apache.commons.attributes.AttributeFinder",
                      "");
          }
      }
  
      public void testError() {
          // maybe this shouldn't actually fail like this in the future
          // but that's what happens now so I write a test for it
          try {
              Attributes.getAttribute(Object.class, "someAttribute");
              //fail("didn't fail when asking for the attributes of unsupported 
class");
          } catch (AttributesException shouldHappen) {
          }
      }
  
        public void testAttributes()
                throws IOException, NoSuchMethodException, NoSuchFieldException {
                AttributesCompiler attributesCompiler = new AttributesCompiler();
                attributesCompiler.setSrc(new File("src" + File.separator + "test"));
                attributesCompiler.setDest(targetDir);
                attributesCompiler.execute();
  
                assertEquals(
                        "classValue",
                        Attributes.getAttribute(
                                AttributesTestClass.class,
                                "classAttribute"));
                assertTrue(
                        Attributes.hasAttribute(
                                AttributesTestClass.class,
                                "classAttribute"));
                assertFalse(
                        Attributes.hasAttribute(
                                AttributesTestClass.class,
                                "stupidAttribute"));
          assertEquals(
                        "fieldValue",
                        Attributes.getAttribute(testField, "fieldAttribute"));
                assertTrue(Attributes.hasAttribute(testField, "fieldAttribute"));
                assertFalse(Attributes.hasAttribute(testField, "stupidAttribute"));
          assertEquals(
                        "methodValue",
                        Attributes.getAttribute(testMethod, "methodAttribute"));
                assertTrue(Attributes.hasAttribute(testMethod, "methodAttribute"));
                assertFalse(Attributes.hasAttribute(testMethod, "stupidAttribute"));
                Method argMethod =
                        AttributesTestClass.class.getMethod(
                                "method",
                                new Class[] { String.class, String.class });
                assertEquals(
                        "argMethodValue",
                        Attributes.getAttribute(argMethod, "methodAttribute"));
                assertTrue(Attributes.hasAttribute(argMethod, "methodAttribute"));
                assertFalse(Attributes.hasAttribute(argMethod, "stupidAttribute"));
        }
  }
  
  
  
  1.1                  
jakarta-commons-sandbox/attributes/src/test/org/apache/commons/attributes/AttributesTestClass.java
  
  Index: AttributesTestClass.java
  ===================================================================
  /*
   * $Header: $
   * $Revision:  $
   * $Date:  $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   * 
   * $Id: $
   */
  package org.apache.commons.attributes;
  
  /**
   * A sample class used for the test case which contains some doclet tags
   *
   * <!-- $Id$ -->
   *
   * @author <a href="mailto:jon_tirsen@;yahoo.com">Jon Tirsén</a>
   * @version $Revision: $
   *
   * @classAttribute classValue
   */
  public class AttributesTestClass {
        ///CLOVER:OFF
        /**
         * @fieldAttribute fieldValue
       *
         */
        public String field;
  
        /**
         * @methodAttribute methodValue
         */
        public void method() {
        }
  
        /**
         * @methodAttribute argMethodValue
         */
        public void method(String arg, String arg2) {
        }
        ///CLOVER:ON
  }
  
  
  
  1.1                  
jakarta-commons-sandbox/attributes/src/java/org/apache/commons/attributes/task/package.html
  
  Index: package.html
  ===================================================================
  <html>
  <head>
  </head>
  <body>
    <p>
        A collection of Ant tasks to help integrate commons-attributes into your code.
        This mostly consists of the {@link 
org.apache.commons.attributes.task.AttributesCompiler} task which generates the
        metadata properties files from the doclet tags using QDox.
    </p>
  </body>
  </html>
  
  
  
  1.1                  
jakarta-commons-sandbox/attributes/src/java/org/apache/commons/attributes/task/AttributesCompiler.java
  
  Index: AttributesCompiler.java
  ===================================================================
  /*
   * $Header: $
   * $Revision:  $
   * $Date:  $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   * 
   * $Id: $
   */
  package org.apache.commons.attributes.task;
  
  import com.thoughtworks.qdox.JavaDocBuilder;
  import com.thoughtworks.qdox.model.*;
  
  import java.io.File;
  import java.io.FileOutputStream;
  import java.io.IOException;
  import java.io.OutputStream;
  import java.util.Properties;
  
  import org.apache.tools.ant.Task;
  import org.apache.tools.ant.BuildException;
  
  /**
   * <p><code>AttributesCompiler</code> is an Ant Task which 
   * uses QDox to generate the attributes files used by the default
   * DefaultAttributeFinder implementation
   *
   * @author <a href="mailto:jon_tirsen@;yahoo.com">Jon Tirsén</a>
   * @version $Revision: $
   */
  public class AttributesCompiler extends Task {
        
        private File src;
        private File dest;
  
        public void setSrc(File src) {
                this.src = src;
        }
  
        public void setDest(File dest) {
                this.dest = dest;
        }
  
        public void execute() {
                try {
                        System.out.println(
                                "Compiling attributes for " + src + " into " + dest);
                        JavaDocBuilder javaDocBuilder = new JavaDocBuilder();
                        javaDocBuilder.addSourceTree(src);
                        JavaSource[] sources = javaDocBuilder.getSources();
                        for (int sourceIndex = 0;
                                sourceIndex < sources.length;
                                sourceIndex++) {
                                JavaSource source = sources[sourceIndex];
                                JavaClass[] classes = source.getClasses();
                                for (int classIndex = 0;
                                        classIndex < classes.length;
                                        classIndex++) {
                                        JavaClass javaClass = classes[classIndex];
                                        JavaField[] fields = javaClass.getFields();
                                        Properties properties = new Properties();
                                        processTags("class", javaClass.getTags(), 
properties);
                                        for (int fieldIndex = 0;
                                                fieldIndex < fields.length;
                                                fieldIndex++) {
                                                JavaField field = fields[fieldIndex];
                                                processTags(
                                                        field.getName(),
                                                        field.getTags(),
                                                        properties);
                                        }
                                        JavaMethod[] methods = javaClass.getMethods();
                                        for (int methodIndex = 0;
                                                methodIndex < methods.length;
                                                methodIndex++) {
                                                JavaMethod method = 
methods[methodIndex];
                                                StringBuffer name = new StringBuffer();
                                                name.append(method.getName());
                                                name.append('(');
                                                JavaParameter[] parameters = 
method.getParameters();
                                                for (int parameterIndex = 0;
                                                        parameterIndex < 
parameters.length;
                                                        parameterIndex++) {
                                                        JavaParameter parameter =
                                                                
parameters[parameterIndex];
                                                        
name.append(parameter.getType().getValue());
                                                        if (parameterIndex + 1 < 
parameters.length) {
                                                                name.append(',');
                                                        }
                                                }
                                                name.append(')');
                                                processTags(
                                                        name.toString(),
                                                        method.getTags(),
                                                        properties);
                                        }
                                        File dir =
                                                new File(
                                                        dest,
                                                        javaClass.getPackage().replace(
                                                                '.',
                                                                File.separatorChar));
                                        dir.mkdirs();
                                        File attributeFile =
                                                new File(dir, javaClass.getName() + 
".attributes");
                                        OutputStream output = null;
                                        try {
                                                output = new 
FileOutputStream(attributeFile);
                                                properties.store(output, 
javaClass.getName());
                                        } finally {
                                                if (output != null) {
                                                        output.close();
                                                }
                                        }
                                }
                        }
                } catch (IOException e) {
                        throw new BuildException(e);
                }
        }
  
        private void processTags(
                String prefix,
                DocletTag[] tags,
                Properties properties) {
                for (int i = 0; i < tags.length; i++) {
                        DocletTag tag = tags[i];
                        properties.put(prefix + '.' + tag.getName(), tag.getValue());
                }
        }
  
  }
  
  
  
  1.1                  
jakarta-commons-sandbox/attributes/src/java/org/apache/commons/attributes/AttributesException.java
  
  Index: AttributesException.java
  ===================================================================
  /*
   * $Header: $
   * $Revision:  $
   * $Date:  $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   * 
   * $Id: $
   */
  package org.apache.commons.attributes;
  
  
  
  /**
   * TODO document AttributesException
   *
   * @author <a href="mailto:jon_tirsen@;yahoo.com">Jon Tirsén</a>
   * @version $Revision$
   */
  public class AttributesException extends RuntimeException {
      public AttributesException(Throwable e) {
          super(e.getMessage());
      }
  
      public AttributesException(String message) {
          super(message);
      }
  }
  
  
  
  1.1                  
jakarta-commons-sandbox/attributes/src/java/org/apache/commons/attributes/AttributeFinder.java
  
  Index: AttributeFinder.java
  ===================================================================
  /*
   * $Header: $
   * $Revision:  $
   * $Date:  $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * $Id: $
   */
  package org.apache.commons.attributes;
  
  import java.lang.reflect.Method;
  import java.lang.reflect.Field;
  
  /**
   * <p><code>AttributeFinder</code> is a strategy object which looks
   * up meta data attributes (typically doclet tags) for classes,
   * methods, fields.
   *
   * @author <a href="mailto:jon_tirsen@;yahoo.com">Jon Tirsén</a>
   * @version $Revision$
   */
  public interface AttributeFinder {
        
        String getAttribute(Class aClass, String attribute);
  
        String getAttribute(Method method, String attribute);
  
        String getAttribute(Field field, String attribute);
  }
  
  
  
  1.1                  
jakarta-commons-sandbox/attributes/src/java/org/apache/commons/attributes/package.html
  
  Index: package.html
  ===================================================================
  <html>
  <head>
  </head>
  <body>
  
    <p>
        This package contains the core API of commons-attributes which consists of 
        <ul>
                <li>
                        the {@link org.apache.commons.attributes.Attributes} facade 
for easy access to metadata attributes, such as doclet tags, at runtime.
                        </li>
                <li>
                        the {@link org.apache.commons.attributes.AttributeFinder} the 
core strategy interface which allows pluggable implementations of how the metadata is 
found
                        </li>
                </ul>
    </p>
  </body>
  </html>
  
  
  
  1.1                  
jakarta-commons-sandbox/attributes/src/java/org/apache/commons/attributes/Attributes.java
  
  Index: Attributes.java
  ===================================================================
  /*
   * $Header: $
   * $Revision:  $
   * $Date:  $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * $Id: $
   */
  package org.apache.commons.attributes;
  
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogFactory;
  import org.apache.commons.attributes.AttributeFinder;
  import org.apache.commons.attributes.impl.DefaultAttributeFinder;
  
  import java.io.IOException;
  import java.io.InputStream;
  import java.lang.reflect.Field;
  import java.lang.reflect.Method;
  import java.net.MalformedURLException;
  import java.net.URL;
  import java.util.*;
  
  /**
   * <p><code>Attributes</code> is a facade for accessing
   * runtime meta data attributes for classes, methods or fields.
   * This facade supports pluggable implementations and typically uses
   * doclet tags in Java source code to define the metadata.
   * </p> 
   *
   * @author <a href="mailto:jon_tirsen@;yahoo.com">Jon Tirsén</a>
   * @version $Revision: $
   */
  public class Attributes {
        private static final Log logger = LogFactory.getLog(Attributes.class);
      private static AttributeFinder finder;
  
      public static AttributeFinder getAttributeFinder() {
          if(finder == null) {
              AttributeFinder newFinder = null;
              try {
                  String implClassName = 
System.getProperty(AttributeFinder.class.getName(), null);
                  if(implClassName != null) {
                      Class implClass = 
Attributes.class.getClassLoader().loadClass(implClassName);
                      newFinder = (AttributeFinder) implClass.newInstance();
                  }
              } catch (Exception e) {
                  logger.warn("failed to initialize specified implementation " +
                          "of AttributeFinder, using default",
                          e);
              }
              if(newFinder == null) {
                  newFinder = new DefaultAttributeFinder();
              }
              setAttributeFinder(newFinder);
          }
          return finder;
      }
  
      public static void setAttributeFinder(AttributeFinder finder) {
          Attributes.finder = finder;
      }
  
        public static String getAttribute(Class aClass, String attribute) {
                return getAttributeFinder().getAttribute(aClass, attribute);
        }
  
        public static String getAttribute(Method method, String attribute) {
          return getAttributeFinder().getAttribute(method, attribute);
        }
  
        public static String getAttribute(Field field, String attribute) {
          return getAttributeFinder().getAttribute(field, attribute);
        }
  
        public static boolean hasAttribute(Class aClass, String attribute) {
                return getAttributeFinder().getAttribute(aClass, attribute) != null;
        }
  
        public static boolean hasAttribute(Method method, String attribute) {
                return getAttributeFinder().getAttribute(method, attribute) != null;
        }
  
        public static boolean hasAttribute(Field field, String attribute) {
          return getAttributeFinder().getAttribute(field, attribute) != null;
        }
  }
  
  
  
  1.1                  jakarta-commons-sandbox/attributes/xdocs/usage.xml
  
  Index: usage.xml
  ===================================================================
  <?xml version="1.0"?>
  <document>
  
      <properties>
          <author email="[EMAIL PROTECTED]">Jon Tirsen</author>
          <title>Nanning Aspects</title>
      </properties>
  
      <body>
  
          <section name="Using runtime attributes">
              <p>
                  This is an example from the unit-tests:
              </p>
              <p>
                  The class (with the attributes):
              </p>
              <source><![CDATA[
  /**
   * @classAttribute classValue
   */
  public class AttributesTestClass
  {
  /**
   * @fieldAttribute fieldValue
   */
  public String field;
  
  /**
   * @methodAttribute methodValue
   */
  public void method()
  {
  }
  
  /**
   * @methodAttribute argMethodValue
   */
  public void method(String arg)
  {
  }
  }
              ]]></source>
              <p>
                  The code that compiles and accesses these attributes:
              </p>
              <source><![CDATA[
  AttributesCompiler attributesCompiler = new AttributesCompiler();
  attributesCompiler.setSrc(new File("src" + File.separator + "test"));
  attributesCompiler.setDest(targetDir);
  attributesCompiler.execute();
  
  assertEquals("classValue", Attributes.getAttribute(AttributesTestClass.class, 
"classAttribute"));
  Field field = AttributesTestClass.class.getDeclaredField("field");
  assertEquals("fieldValue", Attributes.getAttribute(field, "fieldAttribute"));
  Method method = AttributesTestClass.class.getMethod("method", null);
  assertEquals("methodValue", Attributes.getAttribute(method, "methodAttribute"));
  Method argMethod = AttributesTestClass.class.getMethod("method", new 
Class[]{String.class});
  assertEquals("argMethodValue", Attributes.getAttribute(argMethod, 
"methodAttribute"));
              ]]></source>
              <p>
                  The attributes-compiler can also be used as an ant-task (or better 
yet! inside
                  <a
                      href="http://jakarta.apache.org/maven";>maven</a>). This is left 
as an exercise
                  for the interested reader (yeah, yeah, I'm lazy...).
              </p>
  
          </section>
  
      </body>
  </document>
  
  
  
  1.1                  jakarta-commons-sandbox/attributes/xdocs/navigation.xml
  
  Index: navigation.xml
  ===================================================================
  <?xml version="1.0" encoding="ISO-8859-1"?>
  <project name="Maven">
  
      <title>Maven</title>
  
      <body>
          <links>
              <item name="Nanning" href="http://nanning.sourceforge.net/"/>
              <item name="Maven" href="http://jakarta.apache.org/turbine/maven/"/>
              <item name="QDox" href="http://qdox.sourceforge.net/"/>
          </links>
          <menu name="Commons Attributes">
              <item name="Usage" href="/usage.html"/>
          </menu>
      </body>
  </project>
  
  
  1.1                  jakarta-commons-sandbox/attributes/xdocs/index.xml
  
  Index: index.xml
  ===================================================================
  <?xml version="1.0"?>
  <document>
  
    <properties>
      <author email="[EMAIL PROTECTED]">Jon Tirsen</author>
      <title>Commons Attributes</title>
    </properties>
  
    <body>
  
      <section name="Commons Attributes">
        <p>
          Jakarta Commons Attributes compiles and accesses runtime metadata 
attributes. 
          Metadata attributes are typically created via doclet tags embedded inside 
Java source code.
        </p>
        <p>
          Commons Attributes provides a plugin architecture allowing a variety of 
different implementations
          to be used at runtime.
        </p>
        <p>
          The code for this project was originally developed in the 
                                <a href="http://nanning.sourceforge.net/";>Nanning 
Aspects</a>-project.
        </p>
      </section>
  
    </body>
  </document>
  
  
  

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@;jakarta.apache.org>

Reply via email to