gov.nasa.arc.brahms.common.data
Class JavaMethodWriteAccessor

java.lang.Object
  extended by gov.nasa.arc.brahms.common.data.JavaMethodWriteAccessor
All Implemented Interfaces:
IJavaWriteAccessor

public class JavaMethodWriteAccessor
extends java.lang.Object
implements IJavaWriteAccessor

JavaMethodWriteAccessor provides write access for a property's value through a method.

Version:
$Revision: 1.1 $ $Date: 2009/11/23 18:28:41 $ $Author: rnado $
Author:
Ron van Hoof

Constructor Summary
JavaMethodWriteAccessor(java.lang.reflect.Method method, IJavaPropertyDescriptor property)
          Constructor, creates JavaMethodWriteAccessor that writes the property value for the specified property using the specified Method.
 
Method Summary
 IJavaPropertyDescriptor getPropertyDescriptor()
          Returns the IJavaPropertyDescriptor for which this is a write accessor.
 void set(java.lang.Object obj, java.lang.Object value)
          Sets the property represented by this IJavaWriteAccessor object on the specified object argument to the specified new value.
 void setBoolean(java.lang.Object obj, boolean z)
          Sets the value of a property as a boolean on the specified object.
 void setByte(java.lang.Object obj, byte b)
          Sets the value of a property as a byte on the specified object.
 void setChar(java.lang.Object obj, char c)
          Sets the value of a property as a char on the specified object.
 void setDouble(java.lang.Object obj, double d)
          Sets the value of a property as a double on the specified object.
 void setFloat(java.lang.Object obj, float f)
          Sets the value of a property as a float on the specified object.
 void setInt(java.lang.Object obj, int i)
          Sets the value of a property as an int on the specified object.
 void setLong(java.lang.Object obj, long l)
          Sets the value of a property as a long on the specified object.
 void setShort(java.lang.Object obj, short s)
          Sets the value of a property as a short on the specified object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JavaMethodWriteAccessor

public JavaMethodWriteAccessor(java.lang.reflect.Method method,
                               IJavaPropertyDescriptor property)
Constructor, creates JavaMethodWriteAccessor that writes the property value for the specified property using the specified Method.

Parameters:
method - the Method used to write the property value
property - the IJavaPropertyDescriptor for the property
Method Detail

getPropertyDescriptor

public IJavaPropertyDescriptor getPropertyDescriptor()
Returns the IJavaPropertyDescriptor for which this is a write accessor.

Specified by:
getPropertyDescriptor in interface IJavaWriteAccessor
Returns:
IJavaPropertyDescriptor the property descriptor

set

public void set(java.lang.Object obj,
                java.lang.Object value)
         throws java.lang.IllegalArgumentException,
                java.lang.IllegalAccessException,
                gov.nasa.arc.brahms.common.exceptions.PropertyAccessException
Sets the property represented by this IJavaWriteAccessor object on the specified object argument to the specified new value. The new value is automatically unwrapped if the underlying property has a primitive type.

The operation proceeds as follows:

If the underlying property is static, the obj argument is ignored; it may be null.

Otherwise the underlying property is an instance property. 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 property, the method throws an IllegalArgumentException.

If the underlying property 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 property by an identity or widening conversion, the method throws an IllegalArgumentException.

The property is set to the possibly unwrapped and widened new value.

Specified by:
set in interface IJavaWriteAccessor
Parameters:
obj - the object whose property should be modified
value - the new value for the property of obj being modified
Throws:
java.lang.IllegalAccessException - if the underlying property is inaccessible.
java.lang.IllegalArgumentException - if the specified object is not an instance of the class or interface declaring the underlying property (or a subclass or implementor thereof), or if an unwrapping conversion fails.
gov.nasa.arc.brahms.common.exceptions.PropertyAccessException - if there was a problem writing/setting the property's value
java.lang.NullPointerException - if the specified object is null and the property is an instance property.
java.lang.ExceptionInInitializerError - if the initialization provoked by this method fails.

setBoolean

public void setBoolean(java.lang.Object obj,
                       boolean z)
                throws java.lang.IllegalArgumentException,
                       java.lang.IllegalAccessException,
                       gov.nasa.arc.brahms.common.exceptions.PropertyAccessException
Sets the value of a property as a boolean on the specified object. This method is equivalent to set(obj, zObj), where zObj is a Boolean object and zObj.booleanValue() == z.

Specified by:
setBoolean in interface IJavaWriteAccessor
Parameters:
obj - the object whose property should be modified
z - the new value for the property of obj being modified
Throws:
java.lang.IllegalAccessException - if the underlying property is inaccessible.
java.lang.IllegalArgumentException - if the specified object is not an instance of the class or interface declaring the underlying property (or a subclass or implementor thereof), or if an unwrapping conversion fails.
gov.nasa.arc.brahms.common.exceptions.PropertyAccessException - if there was a problem writing/setting the property's value
java.lang.NullPointerException - if the specified object is null and the property is an instance property.
java.lang.ExceptionInInitializerError - if the initialization provoked by this method fails.
See Also:
IJavaWriteAccessor.set(java.lang.Object, java.lang.Object)

setByte

public void setByte(java.lang.Object obj,
                    byte b)
             throws java.lang.IllegalArgumentException,
                    java.lang.IllegalAccessException,
                    gov.nasa.arc.brahms.common.exceptions.PropertyAccessException
Sets the value of a property as a byte on the specified object. This method is equivalent to set(obj, bObj), where bObj is a Byte object and bObj.byteValue() == b.

Specified by:
setByte in interface IJavaWriteAccessor
Parameters:
obj - the object whose property should be modified
b - the new value for the property of obj being modified
Throws:
java.lang.IllegalAccessException - if the underlying property is inaccessible.
java.lang.IllegalArgumentException - if the specified object is not an instance of the class or interface declaring the underlying property (or a subclass or implementor thereof), or if an unwrapping conversion fails.
gov.nasa.arc.brahms.common.exceptions.PropertyAccessException - if there was a problem writing/setting the property's value
java.lang.NullPointerException - if the specified object is null and the property is an instance property.
java.lang.ExceptionInInitializerError - if the initialization provoked by this method fails.
See Also:
IJavaWriteAccessor.set(java.lang.Object, java.lang.Object)

setChar

public void setChar(java.lang.Object obj,
                    char c)
             throws java.lang.IllegalArgumentException,
                    java.lang.IllegalAccessException,
                    gov.nasa.arc.brahms.common.exceptions.PropertyAccessException
Sets the value of a property as a char on the specified object. This method is equivalent to set(obj, cObj), where cObj is a Character object and cObj.charValue() == c.

Specified by:
setChar in interface IJavaWriteAccessor
Parameters:
obj - the object whose property should be modified
c - the new value for the property of obj being modified
Throws:
java.lang.IllegalAccessException - if the underlying property is inaccessible.
java.lang.IllegalArgumentException - if the specified object is not an instance of the class or interface declaring the underlying property (or a subclass or implementor thereof), or if an unwrapping conversion fails.
gov.nasa.arc.brahms.common.exceptions.PropertyAccessException - if there was a problem writing/setting the property's value
java.lang.NullPointerException - if the specified object is null and the property is an instance property.
java.lang.ExceptionInInitializerError - if the initialization provoked by this method fails.
See Also:
IJavaWriteAccessor.set(java.lang.Object, java.lang.Object)

setShort

public void setShort(java.lang.Object obj,
                     short s)
              throws java.lang.IllegalArgumentException,
                     java.lang.IllegalAccessException,
                     gov.nasa.arc.brahms.common.exceptions.PropertyAccessException
Sets the value of a property as a short on the specified object. This method is equivalent to set(obj, sObj), where sObj is a Short object and sObj.shortValue() == s.

Specified by:
setShort in interface IJavaWriteAccessor
Parameters:
obj - the object whose property should be modified
s - the new value for the property of obj being modified
Throws:
java.lang.IllegalAccessException - if the underlying property is inaccessible.
java.lang.IllegalArgumentException - if the specified object is not an instance of the class or interface declaring the underlying property (or a subclass or implementor thereof), or if an unwrapping conversion fails.
gov.nasa.arc.brahms.common.exceptions.PropertyAccessException - if there was a problem writing/setting the property's value
java.lang.NullPointerException - if the specified object is null and the property is an instance property.
java.lang.ExceptionInInitializerError - if the initialization provoked by this method fails.
See Also:
IJavaWriteAccessor.set(java.lang.Object, java.lang.Object)

setInt

public void setInt(java.lang.Object obj,
                   int i)
            throws java.lang.IllegalArgumentException,
                   java.lang.IllegalAccessException,
                   gov.nasa.arc.brahms.common.exceptions.PropertyAccessException
Sets the value of a property as an int on the specified object. This method is equivalent to set(obj, iObj), where iObj is a Integer object and iObj.intValue() == i.

Specified by:
setInt in interface IJavaWriteAccessor
Parameters:
obj - the object whose property should be modified
i - the new value for the property of obj being modified
Throws:
java.lang.IllegalAccessException - if the underlying property is inaccessible.
java.lang.IllegalArgumentException - if the specified object is not an instance of the class or interface declaring the underlying property (or a subclass or implementor thereof), or if an unwrapping conversion fails.
gov.nasa.arc.brahms.common.exceptions.PropertyAccessException - if there was a problem writing/setting the property's value
java.lang.NullPointerException - if the specified object is null and the property is an instance property.
java.lang.ExceptionInInitializerError - if the initialization provoked by this method fails.
See Also:
IJavaWriteAccessor.set(java.lang.Object, java.lang.Object)

setLong

public void setLong(java.lang.Object obj,
                    long l)
             throws java.lang.IllegalArgumentException,
                    java.lang.IllegalAccessException,
                    gov.nasa.arc.brahms.common.exceptions.PropertyAccessException
Sets the value of a property as a long on the specified object. This method is equivalent to set(obj, lObj), where lObj is a Long object and lObj.longValue() == l.

Specified by:
setLong in interface IJavaWriteAccessor
Parameters:
obj - the object whose property should be modified
l - the new value for the property of obj being modified
Throws:
java.lang.IllegalAccessException - if the underlying property is inaccessible.
java.lang.IllegalArgumentException - if the specified object is not an instance of the class or interface declaring the underlying property (or a subclass or implementor thereof), or if an unwrapping conversion fails.
gov.nasa.arc.brahms.common.exceptions.PropertyAccessException - if there was a problem writing/setting the property's value
java.lang.NullPointerException - if the specified object is null and the property is an instance property.
java.lang.ExceptionInInitializerError - if the initialization provoked by this method fails.
See Also:
IJavaWriteAccessor.set(java.lang.Object, java.lang.Object)

setFloat

public void setFloat(java.lang.Object obj,
                     float f)
              throws java.lang.IllegalArgumentException,
                     java.lang.IllegalAccessException,
                     gov.nasa.arc.brahms.common.exceptions.PropertyAccessException
Sets the value of a property as a float on the specified object. This method is equivalent to set(obj, fObj), where fObj is a Float object and fObj.floatValue() == f.

Specified by:
setFloat in interface IJavaWriteAccessor
Parameters:
obj - the object whose property should be modified
f - the new value for the property of obj being modified
Throws:
java.lang.IllegalAccessException - if the underlying property is inaccessible.
java.lang.IllegalArgumentException - if the specified object is not an instance of the class or interface declaring the underlying property (or a subclass or implementor thereof), or if an unwrapping conversion fails.
gov.nasa.arc.brahms.common.exceptions.PropertyAccessException - if there was a problem writing/setting the property's value
java.lang.NullPointerException - if the specified object is null and the property is an instance property.
java.lang.ExceptionInInitializerError - if the initialization provoked by this method fails.
See Also:
IJavaWriteAccessor.set(java.lang.Object, java.lang.Object)

setDouble

public void setDouble(java.lang.Object obj,
                      double d)
               throws java.lang.IllegalArgumentException,
                      java.lang.IllegalAccessException,
                      gov.nasa.arc.brahms.common.exceptions.PropertyAccessException
Sets the value of a property as a double on the specified object. This method is equivalent to set(obj, dObj), where dObj is a Double object and dObj.doubleValue() == d.

Specified by:
setDouble in interface IJavaWriteAccessor
Parameters:
obj - the object whose property should be modified
d - the new value for the property of obj being modified
Throws:
java.lang.IllegalAccessException - if the underlying property is inaccessible.
java.lang.IllegalArgumentException - if the specified object is not an instance of the class or interface declaring the underlying property (or a subclass or implementor thereof), or if an unwrapping conversion fails.
gov.nasa.arc.brahms.common.exceptions.PropertyAccessException - if there was a problem writing/setting the property's value
java.lang.NullPointerException - if the specified object is null and the property is an instance property.
java.lang.ExceptionInInitializerError - if the initialization provoked by this method fails.
See Also:
IJavaWriteAccessor.set(java.lang.Object, java.lang.Object)


Copyright © 1997-2012 All Rights Reserved.