Class FieldVariableBinding

  • All Implemented Interfaces:
    VariableBinding, java.io.Serializable

    public class FieldVariableBinding
    extends java.lang.Object
    implements VariableBinding
    A VariableBinding which binds variables to a particular field of an object. Uses the reflection mechanism of Class.getField(String).
    Since:
    Jep 3.5
    Author:
    Richard Morris
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.lang.reflect.Field field  
      protected java.lang.String fieldName  
      protected java.lang.Object obj  
    • Constructor Summary

      Constructors 
      Constructor 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.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method 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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • obj

        protected java.lang.Object obj
      • fieldName

        protected java.lang.String fieldName
      • field

        protected java.lang.reflect.Field field
    • Constructor Detail

      • FieldVariableBinding

        public FieldVariableBinding​(java.lang.Object obj,
                                    java.lang.String fieldName)
                             throws java.lang.SecurityException,
                                    java.lang.NoSuchFieldException
        Create the binding object with the name of a field.
        Parameters:
        obj - the object
        fieldName - the name of the field
        Throws:
        java.lang.SecurityException - if the field can not be acessed.
        java.lang.NoSuchFieldException - if the field does not exists
      • FieldVariableBinding

        public FieldVariableBinding​(java.lang.Object obj,
                                    java.lang.reflect.Field field)
        Create the binding object with the name of a field.
        Parameters:
        obj - the object
        field - a field object
    • Method Detail

      • getValue

        public java.lang.Object getValue()
                                  throws java.lang.IllegalArgumentException,
                                         java.lang.IllegalAccessException
        Gets the value of the associated field.
        Specified by:
        getValue in interface VariableBinding
        Returns:
        the value
        Throws:
        java.lang.IllegalArgumentException
        java.lang.IllegalAccessException
        See Also:
        Field.get(Object)
      • setValue

        public void setValue​(java.lang.Object value)
                      throws java.lang.IllegalArgumentException,
                             java.lang.IllegalAccessException
        Sets the value of the associated field.
        Specified by:
        setValue in interface VariableBinding
        Parameters:
        value - the value
        Throws:
        java.lang.IllegalArgumentException
        java.lang.IllegalAccessException
        See Also:
        Field.set(Object, Object)