1 cananian 1.15.2.6  // HField.java, created Fri Jul 31  9:33:47 1998 by cananian
  2 cananian 1.11      // Copyright (C) 1998 C. Scott Ananian <cananian@alumni.princeton.edu>
  3 cananian 1.11      // Licensed under the terms of the GNU GPL; see COPYING for details.
  4 cananian 1.1       package harpoon.ClassFile;
  5 cananian 1.1       
  6 cananian 1.15.2.2  import harpoon.Util.ArrayFactory;
  7 cananian 1.15.2.2  
  8 cananian 1.1       import java.lang.reflect.Modifier;
  9 cananian 1.1       
 10 cananian 1.1       /**
 11 cananian 1.1        * A <code>HField</code> provides information about a single field of a class
 12 cananian 1.1        * or an interface.  The reflected field may be a class (static) field or
 13 cananian 1.1        * an instance field.
 14 cananian 1.1        *
 15 cananian 1.6        * @author  C. Scott Ananian <cananian@alumni.princeton.edu>
 16 salcianu 1.19       * @version $Id: HField.java,v 1.19 2003/03/18 03:52:53 salcianu Exp $
 17 cananian 1.1        * @see HMember
 18 cananian 1.1        * @see HClass
 19 cananian 1.1        */
 20 cananian 1.15.2.10 public interface HField extends HMember {
 21 cananian 1.1         /** 
 22 cananian 1.1          * Returns the <code>HClass</code> object representing the class or
 23 cananian 1.1          * interface that declares the field represented by this 
 24 cananian 1.1          * <code>HField</code> object. 
 25 cananian 1.1          */
 26 cananian 1.15.2.10   public HClass getDeclaringClass();
 27 cananian 1.15.2.10 
 28 cananian 1.1         /**
 29 cananian 1.1          * Returns the name of the field represented by this 
 30 cananian 1.1          * <code>HField</code> object.
 31 cananian 1.1          */
 32 cananian 1.15.2.10   public String getName();
 33 cananian 1.15.2.10 
 34 cananian 1.1         /**
 35 cananian 1.1          * Returns the Java language modifiers for the field represented by this
 36 cananian 1.1          * <code>HField</code> object, as an integer.  The <code>Modifier</code>
 37 cananian 1.1          * class should be used to decode the modifiers.
 38 cananian 1.1          * @see java.lang.reflect.Modifier
 39 cananian 1.1          */
 40 cananian 1.15.2.10   public int getModifiers();
 41 cananian 1.15.2.10 
 42 cananian 1.1         /**
 43 cananian 1.1          * Returns an <code>HClass</code> object that identifies the declared
 44 cananian 1.1          * type for the field represented by this <code>HField</code> object.
 45 cananian 1.1          */
 46 cananian 1.15.2.10   public HClass getType();
 47 cananian 1.15.2.10 
 48 cananian 1.8         /**
 49 salcianu 1.19         * Return the type descriptor for this <code>HField</code>
 50 salcianu 1.19         * object. The format of a field string descriptor is defined in <a
 51 salcianu 1.19         * href="http://java.sun.com/docs/books/vmspec/html/ClassFile.doc.html#1169">Section
 52 salcianu 1.19         * 4.3</a> of the JVM specification.  */
 53 cananian 1.15.2.10   public String getDescriptor();
 54 cananian 1.15.2.10 
 55 cananian 1.9         /**
 56 cananian 1.9          * Returns the constant value of this <code>HField</code>, if
 57 cananian 1.9          * it is a constant field.
 58 cananian 1.9          * @return the wrapped value, or <code>null</code> if 
 59 cananian 1.9          *         <code>!isConstant()</code>.
 60 cananian 1.15.2.10    * @see HClass#getWrapper
 61 cananian 1.9          */
 62 cananian 1.15.2.10   public Object getConstant();
 63 cananian 1.8       
 64 cananian 1.1         /**
 65 cananian 1.1          * Determines whether this <code>HField</code> represents a constant
 66 cananian 1.1          * field.
 67 cananian 1.1          */
 68 cananian 1.15.2.10   public boolean isConstant();
 69 cananian 1.12      
 70 cananian 1.7         /**
 71 cananian 1.7          * Determines whether this <code>HField</code> is synthetic.
 72 cananian 1.7          */
 73 cananian 1.15.2.10   public boolean isSynthetic();
 74 cananian 1.10      
 75 cananian 1.10        /** Determines whether this is a static field. */
 76 cananian 1.15.2.10   public boolean isStatic();
 77 cananian 1.15.2.10 
 78 cananian 1.15.2.10   /** Returns a mutator for this <code>HField</code>, or <code>null</code>
 79 cananian 1.15.2.10    *  if the object is immutable. */
 80 cananian 1.15.2.10   public HFieldMutator getMutator();
 81 cananian 1.1       
 82 cananian 1.1         /** 
 83 cananian 1.1          * Compares this <code>HField</code> against the specified object.
 84 cananian 1.1          * Returns <code>true</code> if the objects are the same.  Two
 85 cananian 1.1          * <code>HFields</code> are the same if they were declared by the same
 86 cananian 1.1          * class and have the same name and type.
 87 cananian 1.1          */
 88 cananian 1.15.2.10   public boolean equals(Object object);
 89 cananian 1.1       
 90 cananian 1.1         /**
 91 cananian 1.1          * Return a string describing this <code>HField</code>.  The format
 92 cananian 1.1          * is the access modifiers for the field, if any, followed by the
 93 cananian 1.1          * field type, followed by a space, followed by the fully-qualified
 94 cananian 1.1          * name of the class declaring the field, followed by a period,
 95 cananian 1.3          * followed by the name of the field.  For example:<p>
 96 cananian 1.1          * <DL>
 97 cananian 1.1          * <DD><CODE>public static final int java.lang.Thread.MIN_PRIORITY</CODE>
 98 cananian 1.1          * <DD><CODE>private int java.io.FileDescriptor.fd</CODE>
 99 cananian 1.3          * </DL><p>
100 cananian 1.1          * The modifiers are placed in canonical order as specified by
101 cananian 1.1          * "The Java Language Specification."  This is
102 cananian 1.1          * <code>public</code>, <code>protected</code>, or <code>private</code>
103 cananian 1.1          * first, and then other modifiers in the following order:
104 cananian 1.1          * <code>static</code>, <code>final</code>, <code>transient</code>,
105 cananian 1.1          * <code>volatile</code>.
106 cananian 1.1          */
107 cananian 1.15.2.10   public String toString();
108 cananian 1.18      
109 cananian 1.18        /*****************************************************************/
110 cananian 1.18        // JSR-14 extensions.
111 cananian 1.18      
112 cananian 1.18        /**
113 cananian 1.18         * Returns an <code>HType</code> object that represents the declared
114 cananian 1.18         * compile-time type for the field represented by this
115 cananian 1.18         * <code>HField</code> object.  In particular, if the compile-time
116 cananian 1.18         * type of this field is a type variable or a parameterized type,
117 cananian 1.18         * than an object of the appropriate type (i.e.,
118 cananian 1.18         * <code>HTypeVariable</code> or <code>HParameterizedType</code>)
119 cananian 1.18         * will be returned.
120 cananian 1.18         */
121 cananian 1.18        public HType getGenericType();
122 cananian 1.15.2.10 
123 cananian 1.15.2.2    /** Array factory: returns new <code>HField[]</code>. */
124 cananian 1.16.2.1    public static final ArrayFactory<HField> arrayFactory =
125 cananian 1.15.2.10     Factories.hfieldArrayFactory;
126 cananian 1.1       }
127 cananian 1.9       // set emacs indentation style.
128 cananian 1.9       // Local Variables:
129 cananian 1.9       // c-basic-offset:2
130 cananian 1.9       // End: