xmlbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From p...@apache.org
Subject cvs commit: xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/internal BaseJAnnotation.java
Date Wed, 04 Feb 2004 21:31:11 GMT
pcal        2004/02/04 13:31:11

  Modified:    v2/src/jam/org/apache/xmlbeans/impl/jam JAnnotation.java
                        JClassLoader.java JElement.java JProvider.java
               v2/src/jam/org/apache/xmlbeans/impl/jam/internal
                        BaseJAnnotation.java
  Added:       v2/src/jam/org/apache/xmlbeans/impl/jam
                        JAnnotationDeclaration.java JAnnotationMember.java
                        JAnnotationMemberDeclaration.java
  Log:
  jam: sketch out new annotation interfaces
  
  Revision  Changes    Path
  1.2       +38 -14    xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/JAnnotation.java
  
  Index: JAnnotation.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/JAnnotation.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- JAnnotation.java	29 Sep 2003 21:29:05 -0000	1.1
  +++ JAnnotation.java	4 Feb 2004 21:31:11 -0000	1.2
  @@ -76,48 +76,72 @@
      * Returns the name of this annotation.  Note that in the case of
      * javadoc-style annotations, this name will NOT include the leading
      * '@'.
  +   *
  +   * REVIEW this is a little weird - it's going to be the same as
  +   * getDeclaration().getSimpleName();  it really is type information,
  +   * which I thought we didn't want to expose here.  However,
  +   * I think name is still needed here simply because we may not always
  +   * have a declaration (i.e. in the javadoc case), but we will still
  +   * have a name.
      */
     public String getName();
   
     /**
  -   * Returns the String value of the annotation.  Returns an empty string
  -   * by default.
  +   * Returns an array containing this annotation's members.  Returns an
  +   * empty array if the annotation has no members.
  +   */
  +  public JAnnotationMember[] getMembers();
  +
  +  /**
  +   * Returns the member of this annotation which has the given name,
  +   * or null if no such member exists.
  +   *
  +   * @return The named member or null.
  +   * @throws IllegalArgumentException if the parameter is null.
  +   */
  +  public JAnnotationMember getMember(String named);
  +
  +  /**
  +   * Returns a representation of this annotation's type declaration.
  +   */
  +  public JAnnotationDeclaration getDeclaration();
  +
  +
  +  // ========================================================================
  +  // These methods will all be deprecated soon
  +
  +  /**
  +   * @deprecated
      */
     public String getStringValue();
   
     /**
  -   * Returns the value as an int.  Returns 0 by default if the value
  -   * cannot be understood as an int.
  +   * @deprecated
      */
     public int getIntValue();
   
     /**
  -   * Returns the value as a boolean.  Returns false by default if the
  -   * annotation value cannot be understood as a boolean.
  +   * @deprecated
      */
     public boolean getBooleanValue();
   
     /**
  -   * Returns the value as a long.  Returns 0 by default if the
  -   * annotation value cannot be understood as a long.
  +   * @deprecated
      */
     public long getLongValue();
   
     /**
  -   * Returns the value as a short.  Returns 0 by default if the
  -   * annotation value cannot be understood as a short.
  +   * @deprecated
      */
     public short getShortValue();
   
     /**
  -   * Returns the value as a double.  Returns 0 by default if the
  -   * annotation value cannot be understood as a double.
  +   * @deprecated
      */
     public double getDoubleValue();
   
     /**
  -   * Returns the value as a byte.  Returns 0 by default if the
  -   * annotation value cannot be understood as a byte.
  +   * @deprecated
      */
     public byte getByteValue();
   }
  
  
  
  1.3       +17 -6     xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/JClassLoader.java
  
  Index: JClassLoader.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/JClassLoader.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- JClassLoader.java	3 Dec 2003 22:46:15 -0000	1.2
  +++ JClassLoader.java	4 Feb 2004 21:31:11 -0000	1.3
  @@ -79,16 +79,30 @@
      * in secion 4.3.2 of the VM spec.  This is the same name format
      * that is returned by JClass.getFieldDescriptor.</p>
      *
  -   * <p>Note that this method always returns a class.  If neither a
  +   * <p>Inner classes cannot be loaded with this method.  To load an inner
  +   * class, you must load the outer class first and then call getClasses().
  +   * </p>
  +   *
  +   * <p>Note that this method always returns some JClass - it never
  +   * returns null or throws ClassNotFoundException.  If neither a
      * sourcefile not a classfile could be located for the named class,
      * a stubbed-out JClass will be returned with the isUnresolved()
      * flag set to true.  This JClass will have a name (as determined by
      * the given descriptor), but no other information about it will be
      * available.</p>
  +   *
  +   * @throws IllegalArgumentException if the parameter is null or not
  +   * a valid class name.
      */
     public JClass loadClass(String fieldDescriptor);
   
  -  public JPackage getPackage(String name);
  +  /**
  +   * Returns a representation of a package having the given name.
  +
  +   * @throws IllegalArgumentException if the parameter is null or not
  +   * a valid package name.
  +   */
  +  public JPackage getPackage(String qualifiedPackageName);
   
     /**
      * Returns the JAnnotationLoader which should be used for retrieving
  @@ -96,11 +110,8 @@
      */
     public JAnnotationLoader getAnnotationLoader();
   
  -
     /**
      * Returns this JClassLoaders's parent.
      */
     public JClassLoader getParent();
  -
  -
  -}
  +}
  \ No newline at end of file
  
  
  
  1.3       +4 -0      xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/JElement.java
  
  Index: JElement.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/JElement.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- JElement.java	15 Jan 2004 21:31:10 -0000	1.2
  +++ JElement.java	4 Feb 2004 21:31:11 -0000	1.3
  @@ -191,6 +191,10 @@
      * <p>Returns the set of annotations associated with this
      * abstraction which have the given name.  Returns an empty array if
      * there are no such annotations.</p>
  +   *
  +   * @deprecated I don't think we should encourage people to support
  +   * multiple annotations with the same name as that does not work once
  +   * we get to 175-land.
      */
     public JAnnotation[] getAnnotations(String named);
   
  
  
  
  1.2       +5 -0      xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/JProvider.java
  
  Index: JProvider.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/JProvider.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- JProvider.java	4 Feb 2004 01:39:56 -0000	1.1
  +++ JProvider.java	4 Feb 2004 21:31:11 -0000	1.2
  @@ -88,4 +88,9 @@
      */
     public String getDescription();
   
  +  //may want to add something like this to let them interrogate the
  +  //provider about it's capabilities
  +  //
  +  //public JProviderFeatures getFeatures();
  +
   }
  
  
  
  1.1                  xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/JAnnotationDeclaration.java
  
  Index: JAnnotationDeclaration.java
  ===================================================================
  /*
  * The Apache Software License, Version 1.1
  *
  *
  * Copyright (c) 2003 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 acknowledgment:
  *       "This product includes software developed by the
  *        Apache Software Foundation (http://www.apache.org/)."
  *    Alternately, this acknowledgment may appear in the software itself,
  *    if and wherever such third-party acknowledgments normally appear.
  *
  * 4. The names "Apache" 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 apache@apache.org.
  *
  * 5. Products derived from this software may not be called "Apache
  *    XMLBeans", nor may "Apache" appear in their name, without prior
  *    written permission of the Apache Software Foundation.
  *
  * 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 and was
  * originally based on software copyright (c) 2003 BEA Systems
  * Inc., <http://www.bea.com/>. For more information on the Apache Software
  * Foundation, please see <http://www.apache.org/>.
  */
  package org.apache.xmlbeans.impl.jam;
  
  /**
   *
   * @author Patrick Calahan <pcal@bea.com>
   */
  public interface JAnnotationDeclaration extends JClass {
  
  /**
   *
   * REVIEW is JAnnotationTypeDeclaration a better name?  That's what they
   * call it in the spec, but seems kinda wordy here.  Advantage of current
   * naming is that suggests the analagous relationship between
   * Annotation/AnnotationDeclaration and
   * AnnotationMember/AnnotationMemberDeclaration more clearly.  We can't
   * call it AnnotationMemberTypeDeclaration because that is inaccurate -
   * MemberType is just the type of the member, which is a subset of what
   * AnnotationMemberDeclaration expresses.
   */
  
  //NOTE the delcarations are also returned as JMethods
  
    public JAnnotationMemberDeclaration[] getMemberDeclarations();
  }
  
  
  1.1                  xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/JAnnotationMember.java
  
  Index: JAnnotationMember.java
  ===================================================================
  /*
  * The Apache Software License, Version 1.1
  *
  *
  * Copyright (c) 2003 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 acknowledgment:
  *       "This product includes software developed by the
  *        Apache Software Foundation (http://www.apache.org/)."
  *    Alternately, this acknowledgment may appear in the software itself,
  *    if and wherever such third-party acknowledgments normally appear.
  *
  * 4. The names "Apache" 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 apache@apache.org.
  *
  * 5. Products derived from this software may not be called "Apache
  *    XMLBeans", nor may "Apache" appear in their name, without prior
  *    written permission of the Apache Software Foundation.
  *
  * 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 and was
  * originally based on software copyright (c) 2003 BEA Systems
  * Inc., <http://www.bea.com/>. For more information on the Apache Software
  * Foundation, please see <http://www.apache.org/>.
  */
  package org.apache.xmlbeans.impl.jam;
  
  /**
   *
   * @author Patrick Calahan <pcal@bea.com>
   */
  public interface JAnnotationMember {
  
    /**
     * Returns the name of this annotation member.
     *
     * REVIEW this is a little weird - it's going to be the same as
     * getDeclaration().getSimpleName();  it really is type information,
     * which I thought we didn't want to expose here.  However,
     * I think name is still needed here simply because we may not always
     * have a declaration (i.e. in the javadoc case), but we will still
     * have a name.
     */
    public String getName();
  
    /**
     * Returns the value of this annotation as an Object.  If the value
     * is primitive, one of the
     */
    public Object getValue();
  
    /**
     * <p>Returns true if the member's value was not explicitly set in the
     * annotation instance but was instead taken from the member declaration
     * default.</p>
     *
     * <p>Note that not all JAM implementations may be able to distinguish
     * the case where the value is explicitly declared to be the same value
     * as the member's default from the case where the value is not declared
     * and the value is implicitly default.  In this event, this method
     * will return true if and only if the effective value of the annotation
     * is the same as the default value (regardless of how that value was
     * declared).</p>
     */
    public boolean isDefaultValueUsed();
  
    /**
     * Returns the a representation of the declaration of this member in its
     * annotation type declaration.
     */
    public JAnnotationMemberDeclaration getDeclaration();
  
    /**
     * Returns the String value of the annotation.  Returns an empty string
     * by default.
     */
    public JAnnotation getValueAsAnnotation();
  
    /**
     * Returns the String value of the annotation.  Returns an empty string
     * by default.
     */
    public String getValueAsString();
  
    /**
     * Returns the value as an int.  Returns 0 by default if the value
     * cannot be understood as an int.
     */
    public int getValueAsInt();
  
    /**
     * Returns the value as a boolean.  Returns false by default if the
     * annotation value cannot be understood as a boolean.
     */
    public boolean getValueAsBoolean();
  
    /**
     * Returns the value as a long.  Returns 0 by default if the
     * annotation value cannot be understood as a long.
     */
    public long getValueAsLong();
  
    /**
     * Returns the value as a short.  Returns 0 by default if the
     * annotation value cannot be understood as a short.
     */
    public short getValueAsShort();
  
    /**
     * Returns the value as a double.  Returns 0 by default if the
     * annotation value cannot be understood as a double.
     */
    public double getValueAsDouble();
  
    /**
     * Returns the value as a byte.  Returns 0 by default if the
     * annotation value cannot be understood as a byte.
     */
    public byte getValueAsByte();
  
  }
  
  
  
  1.1                  xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/JAnnotationMemberDeclaration.java
  
  Index: JAnnotationMemberDeclaration.java
  ===================================================================
  /*
  * The Apache Software License, Version 1.1
  *
  *
  * Copyright (c) 2003 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 acknowledgment:
  *       "This product includes software developed by the
  *        Apache Software Foundation (http://www.apache.org/)."
  *    Alternately, this acknowledgment may appear in the software itself,
  *    if and wherever such third-party acknowledgments normally appear.
  *
  * 4. The names "Apache" 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 apache@apache.org.
  *
  * 5. Products derived from this software may not be called "Apache
  *    XMLBeans", nor may "Apache" appear in their name, without prior
  *    written permission of the Apache Software Foundation.
  *
  * 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 and was
  * originally based on software copyright (c) 2003 BEA Systems
  * Inc., <http://www.bea.com/>. For more information on the Apache Software
  * Foundation, please see <http://www.apache.org/>.
  */
  package org.apache.xmlbeans.impl.jam;
  
  /**
   *
   * @author Patrick Calahan <pcal@bea.com>
   */
  public interface JAnnotationMemberDeclaration extends JMethod {
  
    public JClass getType();
  
    public Object getDefaultValue();
  
    public JAnnotationDeclaration getContainingAnnotationDeclaration();
  }
  
  
  
  1.5       +14 -3     xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/internal/BaseJAnnotation.java
  
  Index: BaseJAnnotation.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/internal/BaseJAnnotation.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- BaseJAnnotation.java	4 Feb 2004 02:31:52 -0000	1.4
  +++ BaseJAnnotation.java	4 Feb 2004 21:31:11 -0000	1.5
  @@ -58,9 +58,8 @@
   
   import java.util.Collection;
   import java.util.StringTokenizer;
  -import org.apache.xmlbeans.impl.jam.JAnnotation;
  -import org.apache.xmlbeans.impl.jam.JElement;
  -import org.apache.xmlbeans.impl.jam.JSourcePosition;
  +
  +import org.apache.xmlbeans.impl.jam.*;
   
   /**
    * Javadoc-backed implementation of org.apache.xmlbeans.impl.jam.Annotation
  @@ -135,6 +134,18 @@
   
     // ========================================================================
     // JAnnotation implementation
  +
  +  public JAnnotationMember[] getMembers() {
  +    return new JAnnotationMember[0];
  +  }
  +
  +  public JAnnotationMember getMember(String named) {
  +    return null;
  +  }
  +
  +  public JAnnotationDeclaration getDeclaration() {
  +    return null;
  +  }
   
     public JSourcePosition getSourcePosition() {
       return mSourcePosition;
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: xmlbeans-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xmlbeans-cvs-help@xml.apache.org


Mime
View raw message