📄 field.java
字号:
* @see #get(Object) */ public boolean getBoolean(Object o) throws IllegalAccessException { if (type == Boolean.TYPE) return getBoolean0(o); throw new IllegalArgumentException(); } /** * Get the value of this byte Field. If the field is static, * <code>o</code> will be ignored. * * @param o the object to get the value of this Field from * @return the value of the Field * @throws IllegalAccessException if you could not normally access this field * (i.e. it is not public) * @throws IllegalArgumentException if this is not a byte field of * <code>o</code>, or if <code>o</code> is not an instance of the * declaring class of this field * @throws NullPointerException if <code>o</code> is null and this field * requires an instance * @throws ExceptionInInitializerError if accessing a static field triggered * class initialization, which then failed * @see #get(Object) */ public byte getByte(Object o) throws IllegalAccessException { if (type == Byte.TYPE) return getByte0(o); throw new IllegalArgumentException(); } /** * Get the value of this Field as a char. If the field is static, * <code>o</code> will be ignored. * * @throws IllegalAccessException if you could not normally access this field * (i.e. it is not public) * @throws IllegalArgumentException if this is not a char field of * <code>o</code>, or if <code>o</code> is not an instance * of the declaring class of this field * @throws NullPointerException if <code>o</code> is null and this field * requires an instance * @throws ExceptionInInitializerError if accessing a static field triggered * class initialization, which then failed * @see #get(Object) */ public char getChar(Object o) throws IllegalAccessException { if (type == Character.TYPE) return getChar0(o); throw new IllegalArgumentException(); } /** * Get the value of this Field as a short. If the field is static, * <code>o</code> will be ignored. * * @param o the object to get the value of this Field from * @return the value of the Field * @throws IllegalAccessException if you could not normally access this field * (i.e. it is not public) * @throws IllegalArgumentException if this is not a byte or short * field of <code>o</code>, or if <code>o</code> is not an instance * of the declaring class of this field * @throws NullPointerException if <code>o</code> is null and this field * requires an instance * @throws ExceptionInInitializerError if accessing a static field triggered * class initialization, which then failed * @see #get(Object) */ public short getShort(Object o) throws IllegalAccessException { if (type == Short.TYPE) return getShort0(o); return getByte(o); } /** * Get the value of this Field as an int. If the field is static, * <code>o</code> will be ignored. * * @param o the object to get the value of this Field from * @return the value of the Field * @throws IllegalAccessException if you could not normally access this field * (i.e. it is not public) * @throws IllegalArgumentException if this is not a byte, short, char, or * int field of <code>o</code>, or if <code>o</code> is not an * instance of the declaring class of this field * @throws NullPointerException if <code>o</code> is null and this field * requires an instance * @throws ExceptionInInitializerError if accessing a static field triggered * class initialization, which then failed * @see #get(Object) */ public int getInt(Object o) throws IllegalAccessException { if (type == Integer.TYPE) return getInt0(o); if (type == Character.TYPE) return getChar0(o); return getShort(o); } /** * Get the value of this Field as a long. If the field is static, * <code>o</code> will be ignored. * * @param o the object to get the value of this Field from * @return the value of the Field * @throws IllegalAccessException if you could not normally access this field * (i.e. it is not public) * @throws IllegalArgumentException if this is not a byte, short, char, int, * or long field of <code>o</code>, or if <code>o</code> is not an * instance of the declaring class of this field * @throws NullPointerException if <code>o</code> is null and this field * requires an instance * @throws ExceptionInInitializerError if accessing a static field triggered * class initialization, which then failed * @see #get(Object) */ public long getLong(Object o) throws IllegalAccessException { if (type == Long.TYPE) return getLong0(o); return getInt(o); } /** * Get the value of this Field as a float. If the field is static, * <code>o</code> will be ignored. * * @param o the object to get the value of this Field from * @return the value of the Field * @throws IllegalAccessException if you could not normally access this field * (i.e. it is not public) * @throws IllegalArgumentException if this is not a byte, short, char, int, * long, or float field of <code>o</code>, or if <code>o</code> is * not an instance of the declaring class of this field * @throws NullPointerException if <code>o</code> is null and this field * requires an instance * @throws ExceptionInInitializerError if accessing a static field triggered * class initialization, which then failed * @see #get(Object) */ public float getFloat(Object o) throws IllegalAccessException { if (type == Float.TYPE) return getFloat0(o); return getLong(o); } /** * Get the value of this Field as a double. If the field is static, * <code>o</code> will be ignored. * * @param o the object to get the value of this Field from * @return the value of the Field * @throws IllegalAccessException if you could not normally access this field * (i.e. it is not public) * @throws IllegalArgumentException if this is not a byte, short, char, int, * long, float, or double field of <code>o</code>, or if * <code>o</code> is not an instance of the declaring class of this * field * @throws NullPointerException if <code>o</code> is null and this field * requires an instance * @throws ExceptionInInitializerError if accessing a static field triggered * class initialization, which then failed * @see #get(Object) */ public double getDouble(Object o) throws IllegalAccessException { if (type == Double.TYPE) return getDouble0(o); return getFloat(o); } /** * Set the value of this Field. If it is a primitive field, the value * will be unwrapped from the passed object (boolean = java.lang.Boolean).<p> * * If the field is static, <code>o</code> will be ignored. Otherwise, if * <code>o</code> is null, you get a <code>NullPointerException</code>, * and if it is incompatible with the declaring class of the field, you * get an <code>IllegalArgumentException</code>.<p> * * Next, if this Field enforces access control, your runtime context is * evaluated, and you may have an <code>IllegalAccessException</code> if * you could not access this field in similar compiled code. This also * occurs whether or not there is access control if the field is final. * If the field is primitive, and unwrapping your argument fails, you will * get an <code>IllegalArgumentException</code>; likewise, this error * happens if <code>value</code> cannot be cast to the correct object type. * If the field is static, and its class is uninitialized, you trigger class * initialization, which may end in a * <code>ExceptionInInitializerError</code>.<p> * * Finally, the field is set with the widened value. This method accesses * the field of the declaring class, even if the instance passed in belongs * to a subclass which declares another field to hide this one. * * @param o the object to set this Field on * @param value the value to set this Field to * @throws IllegalAccessException if you could not normally access this field * (i.e. it is not public) * @throws IllegalArgumentException if <code>value</code> cannot be * converted by a widening conversion to the underlying type of * the Field, or if <code>o</code> is not an instance of the class * declaring this field * @throws NullPointerException if <code>o</code> is null and this field * requires an instance * @throws ExceptionInInitializerError if accessing a static field triggered * class initialization, which then failed * @see #setBoolean(Object, boolean) * @see #setByte(Object, byte) * @see #setChar(Object, char) * @see #setShort(Object, short) * @see #setInt(Object, int) * @see #setLong(Object, long) * @see #setFloat(Object, float) * @see #setDouble(Object, double) */ public void set(Object o, Object value) throws IllegalAccessException { checkFinal(); setInternal(o, value); } /** * Set this boolean Field. If the field is static, <code>o</code> will be * ignored. * * @param o the object to set this Field on * @param value the value to set this Field to * @throws IllegalAccessException if you could not normally access this field * (i.e. it is not public) * @throws IllegalArgumentException if this is not a boolean field, or if * <code>o</code> is not an instance of the class declaring this * field * @throws NullPointerException if <code>o</code> is null and this field * requires an instance * @throws ExceptionInInitializerError if accessing a static field triggered * class initialization, which then failed * @see #set(Object, Object) */ public void setBoolean(Object o, boolean value) throws IllegalAccessException { checkFinal(); setBooleanInternal(o, value); } /** * Set this byte Field. If the field is static, <code>o</code> will be * ignored. * * @param o the object to set this Field on * @param value the value to set this Field to * @throws IllegalAccessException if you could not normally access this field * (i.e. it is not public) * @throws IllegalArgumentException if this is not a byte, short, int, long, * float, or double field, or if <code>o</code> is not an instance * of the class declaring this field * @throws NullPointerException if <code>o</code> is null and this field * requires an instance * @throws ExceptionInInitializerError if accessing a static field triggered * class initialization, which then failed * @see #set(Object, Object) */ public void setByte(Object o, byte value) throws IllegalAccessException { checkFinal(); setByteInternal(o, value); } /** * Set this char Field. If the field is static, <code>o</code> will be * ignored. * * @param o the object to set this Field on * @param value the value to set this Field to * @throws IllegalAccessException if you could not normally access this field * (i.e. it is not public) * @throws IllegalArgumentException if this is not a char, int, long, * float, or double field, or if <code>o</code> is not an instance * of the class declaring this field * @throws NullPointerException if <code>o</code> is null and this field * requires an instance * @throws ExceptionInInitializerError if accessing a static field triggered * class initialization, which then failed * @see #set(Object, Object) */ public void setChar(Object o, char value) throws IllegalAccessException { checkFinal();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -