Methods Summary |
---|
boolean | compareMethods(java.lang.reflect.Method a, java.lang.reflect.Method b)Package private helper method for Descriptor .equals methods.
// Note: perhaps this should be a protected method in FeatureDescriptor
if ((a == null) != (b == null)) {
return false;
}
if (a != null && b != null) {
if (!a.equals(b)) {
return false;
}
}
return true;
|
public java.beans.PropertyEditor | createPropertyEditor(java.lang.Object bean)Constructs an instance of a property editor using the current
property editor class.
If the property editor class has a public constructor that takes an
Object argument then it will be invoked using the bean parameter
as the argument. Otherwise, the default constructor will be invoked.
Object editor = null;
Class cls = getPropertyEditorClass();
if (cls != null) {
Constructor ctor = null;
if (bean != null) {
try {
ctor = cls.getConstructor(new Class[] { Object.class });
} catch (Exception ex) {
// Fall through
}
}
try {
if (ctor == null) {
editor = cls.newInstance();
} else {
editor = ctor.newInstance(new Object[] { bean });
}
} catch (Exception ex) {
// A serious error has occured.
// Proably due to an invalid property editor.
throw new RuntimeException("PropertyEditor not instantiated",
ex);
}
}
return (PropertyEditor)editor;
|
public boolean | equals(java.lang.Object obj)Compares this PropertyDescriptor against the specified object.
Returns true if the objects are the same. Two PropertyDescriptor s
are the same if the read, write, property types, property editor and
flags are equivalent.
if (this == obj) {
return true;
}
if (obj != null && obj instanceof PropertyDescriptor) {
PropertyDescriptor other = (PropertyDescriptor)obj;
Method otherReadMethod = other.getReadMethod();
Method otherWriteMethod = other.getWriteMethod();
if (!compareMethods(getReadMethod(), otherReadMethod)) {
return false;
}
if (!compareMethods(getWriteMethod(), otherWriteMethod)) {
return false;
}
if (getPropertyType() == other.getPropertyType() &&
getPropertyEditorClass() == other.getPropertyEditorClass() &&
bound == other.isBound() && constrained == other.isConstrained() &&
writeMethodName == other.writeMethodName &&
readMethodName == other.readMethodName) {
return true;
}
}
return false;
|
private java.lang.Class | findPropertyType(java.lang.reflect.Method readMethod, java.lang.reflect.Method writeMethod)Returns the property type that corresponds to the read and write method.
The type precedence is given to the readMethod.
Class propertyType = null;
try {
if (readMethod != null) {
Class[] params = readMethod.getParameterTypes();
if (params.length != 0) {
throw new IntrospectionException("bad read method arg count: "
+ readMethod);
}
propertyType = readMethod.getReturnType();
if (propertyType == Void.TYPE) {
throw new IntrospectionException("read method " +
readMethod.getName() + " returns void");
}
}
if (writeMethod != null) {
Class params[] = writeMethod.getParameterTypes();
if (params.length != 1) {
throw new IntrospectionException("bad write method arg count: "
+ writeMethod);
}
if (propertyType != null && propertyType != params[0]) {
throw new IntrospectionException("type mismatch between read and write methods");
}
propertyType = params[0];
}
} catch (IntrospectionException ex) {
throw ex;
}
return propertyType;
|
java.lang.String | getBaseName()
if (baseName == null) {
baseName = capitalize(getName());
}
return baseName;
|
public java.lang.Class | getPropertyEditorClass()Gets any explicit PropertyEditor Class that has been registered
for this property.
return (Class)getObject(propertyEditorClassRef);
|
public synchronized java.lang.Class | getPropertyType()Gets the Class object for the property.
Class type = getPropertyType0();
if (type == null) {
try {
type = findPropertyType(getReadMethod(), getWriteMethod());
setPropertyType(type);
} catch (IntrospectionException ex) {
// Fall
}
}
return type;
|
private java.lang.Class | getPropertyType0()
return (Class)getObject(propertyTypeRef);
|
public synchronized java.lang.reflect.Method | getReadMethod()Gets the method that should be used to read the property value.
Method readMethod = getReadMethod0();
if (readMethod == null) {
Class cls = getClass0();
if (cls == null || (readMethodName == null && readMethodRef == null)) {
// The read method was explicitly set to null.
return null;
}
if (readMethodName == null) {
Class type = getPropertyType0();
if (type == boolean.class || type == null) {
readMethodName = "is" + getBaseName();
} else {
readMethodName = "get" + getBaseName();
}
}
// Since there can be multiple write methods but only one getter
// method, find the getter method first so that you know what the
// property type is. For booleans, there can be "is" and "get"
// methods. If an "is" method exists, this is the official
// reader method so look for this one first.
readMethod = Introspector.findMethod(cls, readMethodName, 0);
if (readMethod == null) {
readMethodName = "get" + getBaseName();
readMethod = Introspector.findMethod(cls, readMethodName, 0);
}
try {
setReadMethod(readMethod);
} catch (IntrospectionException ex) {
// fall
}
}
return readMethod;
|
private java.lang.reflect.Method | getReadMethod0()
return (Method)getObject(readMethodRef);
|
public synchronized java.lang.reflect.Method | getWriteMethod()Gets the method that should be used to write the property value.
Method writeMethod = getWriteMethod0();
if (writeMethod == null) {
Class cls = getClass0();
if (cls == null || (writeMethodName == null && writeMethodRef == null)) {
// The write method was explicitly set to null.
return null;
}
// We need the type to fetch the correct method.
Class type = getPropertyType0();
if (type == null) {
try {
// Can't use getPropertyType since it will lead to recursive loop.
type = findPropertyType(getReadMethod(), null);
setPropertyType(type);
} catch (IntrospectionException ex) {
// Without the correct property type we can't be guaranteed
// to find the correct method.
return null;
}
}
if (writeMethodName == null) {
writeMethodName = "set" + getBaseName();
}
writeMethod = Introspector.findMethod(cls, writeMethodName, 1,
(type == null) ? null : new Class[] { type });
try {
setWriteMethod(writeMethod);
} catch (IntrospectionException ex) {
// fall through
}
}
return writeMethod;
|
private java.lang.reflect.Method | getWriteMethod0()
return (Method)getObject(writeMethodRef);
|
public int | hashCode()Returns a hash code value for the object.
See {@link java.lang.Object#hashCode} for a complete description.
int result = 7;
result = 37 * result + ((getPropertyType() == null) ? 0 :
getPropertyType().hashCode());
result = 37 * result + ((getReadMethod() == null) ? 0 :
getReadMethod().hashCode());
result = 37 * result + ((getWriteMethod() == null) ? 0 :
getWriteMethod().hashCode());
result = 37 * result + ((getPropertyEditorClass() == null) ? 0 :
getPropertyEditorClass().hashCode());
result = 37 * result + ((writeMethodName == null) ? 0 :
writeMethodName.hashCode());
result = 37 * result + ((readMethodName == null) ? 0 :
readMethodName.hashCode());
result = 37 * result + getName().hashCode();
result = 37 * result + ((bound == false) ? 0 : 1);
result = 37 * result + ((constrained == false) ? 0 : 1);
return result;
|
public boolean | isBound()Updates to "bound" properties will cause a "PropertyChange" event to
get fired when the property is changed.
return bound;
|
public boolean | isConstrained()Attempted updates to "Constrained" properties will cause a "VetoableChange"
event to get fired when the property is changed.
return constrained;
|
public void | setBound(boolean bound)Updates to "bound" properties will cause a "PropertyChange" event to
get fired when the property is changed.
this.bound = bound;
|
void | setClass0(java.lang.Class clz)Overridden to ensure that a super class doesn't take precedent
if (getClass0() != null && clz.isAssignableFrom(getClass0())) {
// dont replace a subclass with a superclass
return;
}
super.setClass0(clz);
|
public void | setConstrained(boolean constrained)Attempted updates to "Constrained" properties will cause a "VetoableChange"
event to get fired when the property is changed.
this.constrained = constrained;
|
public void | setPropertyEditorClass(java.lang.Class propertyEditorClass)Normally PropertyEditors will be found using the PropertyEditorManager.
However if for some reason you want to associate a particular
PropertyEditor with a given property, then you can do it with
this method.
propertyEditorClassRef = createReference(propertyEditorClass);
|
private void | setPropertyType(java.lang.Class type)
propertyTypeRef = createReference(type);
|
public synchronized void | setReadMethod(java.lang.reflect.Method readMethod)Sets the method that should be used to read the property value.
if (readMethod == null) {
readMethodName = null;
readMethodRef = null;
return;
}
// The property type is determined by the read method.
setPropertyType(findPropertyType(readMethod, getWriteMethod0()));
setClass0(readMethod.getDeclaringClass());
readMethodName = readMethod.getName();
readMethodRef = createReference(readMethod, true);
|
public synchronized void | setWriteMethod(java.lang.reflect.Method writeMethod)Sets the method that should be used to write the property value.
if (writeMethod == null) {
writeMethodName = null;
writeMethodRef = null;
return;
}
// Set the property type - which validates the method
setPropertyType(findPropertyType(getReadMethod(), writeMethod));
setClass0(writeMethod.getDeclaringClass());
writeMethodName = writeMethod.getName();
writeMethodRef = createReference(writeMethod, true);
|