public class FieldVariableBinding extends java.lang.Object implements VariableBinding
VariableBinding
which binds variables to a particular field of an object.
Uses the reflection mechanism of Class.getField(String)
.Modifier and Type | Field and Description |
---|---|
protected java.lang.reflect.Field |
field |
protected java.lang.String |
fieldName |
protected java.lang.Object |
obj |
Constructor and Description |
---|
FieldVariableBinding(java.lang.Object obj,
java.lang.reflect.Field field)
Create the binding object with the name of a field.
|
FieldVariableBinding(java.lang.Object obj,
java.lang.String fieldName)
Create the binding object with the name of a field.
|
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
getValue()
Gets the value of the associated field.
|
void |
setValue(java.lang.Object value)
Sets the value of the associated field.
|
protected java.lang.Object obj
protected java.lang.String fieldName
protected java.lang.reflect.Field field
public FieldVariableBinding(java.lang.Object obj, java.lang.String fieldName) throws java.lang.SecurityException, java.lang.NoSuchFieldException
obj
- the objectfieldName
- the name of the fieldjava.lang.SecurityException
- if the field can not be acessed.java.lang.NoSuchFieldException
- if the field does not existspublic FieldVariableBinding(java.lang.Object obj, java.lang.reflect.Field field)
obj
- the objectfield
- a field objectpublic java.lang.Object getValue() throws java.lang.IllegalArgumentException, java.lang.IllegalAccessException
getValue
in interface VariableBinding
java.lang.IllegalArgumentException
java.lang.IllegalAccessException
Field.get(Object)
public void setValue(java.lang.Object value) throws java.lang.IllegalArgumentException, java.lang.IllegalAccessException
setValue
in interface VariableBinding
value
- the valuejava.lang.IllegalArgumentException
java.lang.IllegalAccessException
Field.set(Object, Object)
Copyright © 2018 Singular Systems http://www.singularsys.com/jep