Methods Summary |
---|
public java.lang.Object | get(java.lang.Object obj, int i)Get an indexed property
if (!isIndexed()) {
return Array.get(get(obj), i);
} else {
IndexedPropertyDescriptor id = (IndexedPropertyDescriptor)myPD;
return id.getIndexedReadMethod().invoke(obj,
new Object[] {
new Integer(i)});
}
|
public java.lang.Object | get(java.lang.Object obj)Get the property value
Method readMethod = myPD.getReadMethod();
if (readMethod != null) {
return readMethod.invoke(obj, noArgs);
} else {
throw new IllegalAccessException(Messages.getMessage("badGetter00"));
}
|
public java.lang.Class | getActualType()
return myPD.getPropertyType();
|
public java.lang.String | getName()Get our property name.
return myPD.getName();
|
public java.lang.Class | getType()Get the type of a property
if (isIndexed()) {
return ((IndexedPropertyDescriptor)myPD).getIndexedPropertyType();
} else {
return myPD.getPropertyType();
}
|
protected void | growArrayToSize(java.lang.Object obj, java.lang.Class componentType, int i)Grow the array
// Get the entire array and make sure it is large enough
Object array = get(obj);
if (array == null || Array.getLength(array) <= i) {
// Construct a larger array of the same type
Object newArray = Array.newInstance(componentType, i + 1);
// Copy over the old elements
if (array != null) {
System.arraycopy(array, 0, newArray, 0, Array.getLength(array));
}
// Set the object to use the larger array
set(obj, newArray);
}
|
public boolean | isArray()Query if property is an array (excluded byte[]).
return ((myPD.getPropertyType() != null) && myPD.getPropertyType()
.isArray());
|
public boolean | isIndexed()Query if property is indexed
return (myPD instanceof IndexedPropertyDescriptor);
|
public boolean | isIndexedOrArray()Query if property is indexed or if it' an array.
return (isIndexed() || isArray());
|
public boolean | isReadable()Query if property is readable
return (myPD.getReadMethod() != null);
|
public boolean | isWriteable()Query if property is writeable
return (myPD.getWriteMethod() != null);
|
public void | set(java.lang.Object obj, java.lang.Object newValue)Set the property value
Method writeMethod = myPD.getWriteMethod();
if (writeMethod != null) {
writeMethod.invoke(obj, new Object[] {newValue});
} else {
throw new IllegalAccessException(Messages.getMessage("badSetter00"));
}
|
public void | set(java.lang.Object obj, int i, java.lang.Object newValue)Set an indexed property value
// Set the new value
if (isIndexed()) {
IndexedPropertyDescriptor id = (IndexedPropertyDescriptor)myPD;
growArrayToSize(obj, id.getIndexedPropertyType(), i);
id.getIndexedWriteMethod().invoke(obj,
new Object[] {
new Integer(i), newValue});
} else {
// Not calling 'growArrayToSize' to avoid an extra call to the
// property's setter. The setter will be called at the end anyway.
// growArrayToSize(obj, myPD.getPropertyType().getComponentType(), i);
Object array = get(obj);
if (array == null || Array.getLength(array) <= i) {
Class componentType = getType().getComponentType();
Object newArray = Array.newInstance(componentType, i + 1);
// Copy over the old elements
if (array != null) {
System.arraycopy(array, 0, newArray, 0, Array.getLength(array));
}
array = newArray;
}
Array.set(array, i, newValue);
// Fix for non-indempondent array-type propertirs.
// Make sure we call the property's setter.
set(obj, array);
}
|