field.java

来自「java jdk 1.4的源码」· Java 代码 · 共 835 行 · 第 1/2 页

JAVA
835
字号
  public java.lang.String getName()  {    return name;  }  /**   * Get the value of a field as a short on specified   * object.   *   *   * @param obj   *   * @throws IllegalAccessException   * if the underlying constructor is inaccessible.   * @throws IllegalArgumentException   * if the field value cannot be converted to the   * return type by a widening conversion.   */  public short getShort(Object obj)          throws IllegalArgumentException, IllegalAccessException  {    if (realfield != null)      return realfield.getShort(obj);    throw new java.lang.IllegalStateException();  }  /**   * Returns a Class object that identifies the declared   * type for the field represented by this Field object.   *   */  public Class getType()  {    if (realfield != null)      type = Class.forClass(realfield.getType());    return type;  }  /**   * Method setType    *   *   * @param type   *   * @throws SynthesisException   */  public void setType(org.apache.xml.utils.synthetic.Class type)          throws SynthesisException  {    if (realfield != null)      throw new SynthesisException(SynthesisException.REIFIED);    this.type = type;  }  /**   * Returns a hashcode for this Field. This is   * computed as the exclusive-or of the hashcodes for   * the underlying field's declaring class name and its   * name.   *   */  public int hashCode()  {    if (realfield != null)      return realfield.hashCode();    else      return declaringClass.getName().hashCode() ^ name.hashCode();  }  /**   * Sets the field represented by this Field object on   * the specified object argument to the specified new   * value. The new value is automatically unwrapped   * if the underlying field has a primitive type.   *   * The operation proceeds as follows:   *   * If the underlying field is static, the object   * argument is ignored; it may be null.   *   * Otherwise the underlying field is an instance field.   * If the specified object argument is null, the   * method throws a NullPointerException. If the   * specified object argument is not an instance of the   * class or interface declaring the underlying field,   * the method throws an IllegalArgumentException.   *   * If this Field object enforces Java language access   * control, and the underlying field is inaccessible,   * the method throws an IllegalAccessException.   *   * If the underlying field is final, the method throws   * an IllegalAccessException.   *   * If the underlying field is of a primitive type, an   * unwrapping conversion is attempted to convert the   * new value to a value of a primitive type. If this   * attempt fails, the method throws an   * IllegalArgumentException.   *   * If, after possible unwrapping, the new value   * cannot be converted to the type of the underlying   * field by an identity or widening conversion, the   * method throws an IllegalArgumentException.   *   * The field is set to the possibly unwrapped and   * widened new value.   *   *   * @param obj   * @param value   * @throws IllegalAccessException   * if the underlying constructor is inaccessible.   * @throws IllegalArgumentException   * if the specified object is not an instance of   * the class or interface declaring the   * underlying field, or if an unwrapping   * conversion fails.   * @throws NullPointerException   * if the specified object is null.   */  public void set(Object obj, Object value)          throws IllegalArgumentException, IllegalAccessException  {    if (realfield != null)      realfield.set(obj, value);    throw new java.lang.IllegalStateException();  }  /**   * Set the value of a field as a boolean on specified   * object.   *   *   * @param obj   * @param z   * @throws IllegalAccessException   * if the underlying constructor is inaccessible.   * @throws IllegalArgumentException   * if the specified object is not an instance of   * the class or interface declaring the   * underlying field, or if an unwrapping   * conversion fails.   */  public void setBoolean(Object obj, boolean z)          throws IllegalArgumentException, IllegalAccessException  {    if (realfield != null)      realfield.setBoolean(obj, z);    throw new java.lang.IllegalStateException();  }  /**   * Set the value of a field as a byte on specified   * object.   *   *   * @param obj   * @param b   * @throws IllegalAccessException   * if the underlying constructor is inaccessible.   * @throws IllegalArgumentException   * if the specified object is not an instance of   * the class or interface declaring the   * underlying field, or if an unwrapping   * conversion fails.   */  public void setByte(Object obj, byte b)          throws IllegalArgumentException, IllegalAccessException  {    if (realfield != null)      realfield.setByte(obj, b);    throw new java.lang.IllegalStateException();  }  /**   * Set the value of a field as a char on specified   * object.   *   *   * @param obj   * @param c   * @throws IllegalAccessException   * if the underlying constructor is inaccessible.   * @throws IllegalArgumentException   * if the specified object is not an instance of   * the class or interface declaring the   * underlying field, or if an unwrapping   * conversion fails.   */  public void setChar(Object obj, char c)          throws IllegalArgumentException, IllegalAccessException  {    if (realfield != null)      realfield.setChar(obj, c);    throw new java.lang.IllegalStateException();  }  /**   * Returns the Class object representing the class that   * declares the constructor represented by this   * Constructor object.   *   * @param declaringClass   */  public void setDeclaringClass(          org.apache.xml.utils.synthetic.Class declaringClass)  {    this.declaringClass = declaringClass;  }  /**   * Set the value of a field as a double on specified   * object.   *   *   * @param obj   * @param d   * @throws IllegalAccessException   * if the underlying constructor is inaccessible.   * @throws IllegalArgumentException   * if the specified object is not an instance of   * the class or interface declaring the   * underlying field, or if an unwrapping   * conversion fails.   */  public void setDouble(Object obj, double d)          throws IllegalArgumentException, IllegalAccessException  {    if (realfield != null)      realfield.setDouble(obj, d);    throw new java.lang.IllegalStateException();  }  /**   * Set the value of a field as a float on specified   * object.   *   *   * @param obj   * @param f   * @throws IllegalAccessException   * if the underlying constructor is inaccessible.   * @throws IllegalArgumentException   * if the specified object is not an instance of   * the class or interface declaring the   * underlying field, or if an unwrapping   * conversion fails.   */  public void setFloat(Object obj, float f)          throws IllegalArgumentException, IllegalAccessException  {    if (realfield != null)      realfield.setFloat(obj, f);    throw new java.lang.IllegalStateException();  }  /**   * Set the value of a field as an int on specified   * object.   *   *   * @param obj   * @param i   * @throws IllegalAccessException   * if the underlying constructor is inaccessible.   * @throws IllegalArgumentException   * if the specified object is not an instance of   * the class or interface declaring the   * underlying field, or if an unwrapping   * conversion fails.   */  public void setInt(Object obj, int i)          throws IllegalArgumentException, IllegalAccessException  {    if (realfield != null)      realfield.setInt(obj, i);    throw new java.lang.IllegalStateException();  }  /**   * Set the value of a field as a long on specified   * object.   *   *   * @param obj   * @param l   * @throws IllegalAccessException   * if the underlying constructor is inaccessible.   * @throws IllegalArgumentException   * if the specified object is not an instance of   * the class or interface declaring the   * underlying field, or if an unwrapping   * conversion fails.   */  public void setLong(Object obj, long l)          throws IllegalArgumentException, IllegalAccessException  {    if (realfield != null)      realfield.setLong(obj, l);    throw new java.lang.IllegalStateException();  }  /**   * Insert the method's description here.   * Creation date: (12-25-99 1:28:28 PM)   * @return int   * @param modifiers int   *   * @throws SynthesisException   */  public void setModifiers(int modifiers) throws SynthesisException  {    if (realfield != null)      throw new SynthesisException(SynthesisException.REIFIED);    this.modifiers = modifiers;  }  /**   * Set the value of a field as a short on specified   * object.   *   *   * @param obj   * @param s   * @throws IllegalAccessException   * if the underlying constructor is inaccessible.   * @throws IllegalArgumentException   * if the specified object is not an instance of   * the class or interface declaring the   * underlying field, or if an unwrapping   * conversion fails.   */  public void setShort(Object obj, short s)          throws IllegalArgumentException, IllegalAccessException  {    if (realfield != null)      realfield.setShort(obj, s);    throw new java.lang.IllegalStateException();  }  /**   * Return a string describing this Field. The format is   * the access modifiers for the field, if any, followed   * by the field type, followed by a space, followed by   * the fully-qualified name of the class declaring the   * field, followed by a period, followed by the name   * of the field. For example:   * <code>   * public static final int java.lang.Thread.MIN_PRIORITY   * private int java.io.FileDescriptor.fd   * </code>   *   * The modifiers are placed in canonical order as   * specified by "The Java Language Specification".   * This is public, protected or private first,   * and then other modifiers in the following order:   * static, final, transient, volatile.   *   */  public String toString()  {    if (realfield != null)      return realfield.toString();    throw new java.lang.IllegalStateException();  }  /**   * Output the Field as Java sourcecode   *   */  public String toSource()  {    StringBuffer sb = new StringBuffer(      java.lang.reflect.Modifier.toString(getModifiers())).append(' ').append(      getType().getJavaName()).append(' ').append(getName());    String i = getInitializer();    if (i != null && i.length() > 0)      sb.append('=').append(i);    sb.append(';');    return sb.toString();  }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?