home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 1999 April / DPPCPRO0499.ISO / April / Notes / 50b2wic.exe / DATA1.CAB / NotesProgramFilesJavaSupport / rt.jar / java / lang / reflect / Field.class (.txt) < prev    next >
Encoding:
Java Class File  |  1998-04-23  |  2.8 KB  |  105 lines

  1. package java.lang.reflect;
  2.  
  3. public final class Field implements Member {
  4.    private Class clazz;
  5.    private int slot;
  6.    private String name;
  7.    private Class type;
  8.  
  9.    private Field() {
  10.    }
  11.  
  12.    public Class getDeclaringClass() {
  13.       return this.clazz;
  14.    }
  15.  
  16.    public String getName() {
  17.       return this.name;
  18.    }
  19.  
  20.    public native int getModifiers();
  21.  
  22.    public Class getType() {
  23.       return this.type;
  24.    }
  25.  
  26.    public boolean equals(Object var1) {
  27.       if (var1 != null && var1 instanceof Field) {
  28.          Field var2 = (Field)var1;
  29.          return this.getDeclaringClass() == var2.getDeclaringClass() && this.getName().equals(var2.getName()) && this.getType() == var2.getType();
  30.       } else {
  31.          return false;
  32.       }
  33.    }
  34.  
  35.    public int hashCode() {
  36.       return this.getDeclaringClass().getName().hashCode() ^ this.getName().hashCode();
  37.    }
  38.  
  39.    public String toString() {
  40.       int var1 = this.getModifiers();
  41.       return (var1 == 0 ? "" : Modifier.toString(var1) + " ") + getTypeName(this.getType()) + " " + getTypeName(this.getDeclaringClass()) + "." + this.getName();
  42.    }
  43.  
  44.    public native Object get(Object var1) throws IllegalArgumentException, IllegalAccessException;
  45.  
  46.    public native boolean getBoolean(Object var1) throws IllegalArgumentException, IllegalAccessException;
  47.  
  48.    public native byte getByte(Object var1) throws IllegalArgumentException, IllegalAccessException;
  49.  
  50.    public native char getChar(Object var1) throws IllegalArgumentException, IllegalAccessException;
  51.  
  52.    public native short getShort(Object var1) throws IllegalArgumentException, IllegalAccessException;
  53.  
  54.    public native int getInt(Object var1) throws IllegalArgumentException, IllegalAccessException;
  55.  
  56.    public native long getLong(Object var1) throws IllegalArgumentException, IllegalAccessException;
  57.  
  58.    public native float getFloat(Object var1) throws IllegalArgumentException, IllegalAccessException;
  59.  
  60.    public native double getDouble(Object var1) throws IllegalArgumentException, IllegalAccessException;
  61.  
  62.    public native void set(Object var1, Object var2) throws IllegalArgumentException, IllegalAccessException;
  63.  
  64.    public native void setBoolean(Object var1, boolean var2) throws IllegalArgumentException, IllegalAccessException;
  65.  
  66.    public native void setByte(Object var1, byte var2) throws IllegalArgumentException, IllegalAccessException;
  67.  
  68.    public native void setChar(Object var1, char var2) throws IllegalArgumentException, IllegalAccessException;
  69.  
  70.    public native void setShort(Object var1, short var2) throws IllegalArgumentException, IllegalAccessException;
  71.  
  72.    public native void setInt(Object var1, int var2) throws IllegalArgumentException, IllegalAccessException;
  73.  
  74.    public native void setLong(Object var1, long var2) throws IllegalArgumentException, IllegalAccessException;
  75.  
  76.    public native void setFloat(Object var1, float var2) throws IllegalArgumentException, IllegalAccessException;
  77.  
  78.    public native void setDouble(Object var1, double var2) throws IllegalArgumentException, IllegalAccessException;
  79.  
  80.    static String getTypeName(Class var0) {
  81.       if (var0.isArray()) {
  82.          try {
  83.             Class var1 = var0;
  84.  
  85.             int var2;
  86.             for(var2 = 0; var1.isArray(); var1 = var1.getComponentType()) {
  87.                ++var2;
  88.             }
  89.  
  90.             StringBuffer var3 = new StringBuffer();
  91.             var3.append(var1.getName());
  92.  
  93.             for(int var4 = 0; var4 < var2; ++var4) {
  94.                var3.append("[]");
  95.             }
  96.  
  97.             return var3.toString();
  98.          } catch (Throwable var5) {
  99.          }
  100.       }
  101.  
  102.       return var0.getName();
  103.    }
  104. }
  105.