/** * Get the description for a particular attribute. * <p>The default implementation returns a description for the operation * that is the name of corresponding {@code Method}. * @param propertyDescriptor the PropertyDescriptor for the attribute * @param beanKey the key associated with the MBean in the beans map * of the {@code MBeanExporter} * @return the description for the attribute */ protected String getAttributeDescription(PropertyDescriptor propertyDescriptor, String beanKey) { return propertyDescriptor.getDisplayName(); }
Class<?> getBeanClass() { return this.beanInfo.getBeanDescriptor().getBeanClass(); }
/** * Create a new MethodInvocationException. * @param propertyChangeEvent the PropertyChangeEvent that resulted in an exception * @param cause the Throwable raised by the invoked method */ public MethodInvocationException(PropertyChangeEvent propertyChangeEvent, Throwable cause) { super(propertyChangeEvent, "Property '" + propertyChangeEvent.getPropertyName() + "' threw exception", cause); }
private boolean hasReadMethodForProperty(BeanInfo beanInfo, String propertyName) { for (PropertyDescriptor pd : beanInfo.getPropertyDescriptors()) { if (pd.getName().equals(propertyName)) { return pd.getReadMethod() != null; } } return false; }
private boolean hasWriteMethodForProperty(BeanInfo beanInfo, String propertyName) { for (PropertyDescriptor pd : beanInfo.getPropertyDescriptors()) { if (pd.getName().equals(propertyName)) { return pd.getWriteMethod() != null; } } return false; }
public BeanPropertyHandler(PropertyDescriptor pd) { super(pd.getPropertyType(), pd.getReadMethod() != null, pd.getWriteMethod() != null); this.pd = pd; }
private boolean hasIndexedReadMethodForProperty(BeanInfo beanInfo, String propertyName) { for (PropertyDescriptor pd : beanInfo.getPropertyDescriptors()) { if (pd.getName().equals(propertyName)) { if (!(pd instanceof IndexedPropertyDescriptor)) { return false; } return ((IndexedPropertyDescriptor)pd).getIndexedReadMethod() != null; } } return false; }
private boolean hasIndexedWriteMethodForProperty(BeanInfo beanInfo, String propertyName) { for (PropertyDescriptor pd : beanInfo.getPropertyDescriptors()) { if (pd.getName().equals(propertyName)) { if (!(pd instanceof IndexedPropertyDescriptor)) { return false; } return ((IndexedPropertyDescriptor)pd).getIndexedWriteMethod() != null; } } return false; }
@ConstructorProperties({"spouse", "otherSpouse", "myAge"}) public ConstructorDependenciesBean(TestBean spouse1, TestBean spouse2, int age) { this.spouse1 = spouse1; this.spouse2 = spouse2; this.age = age; }
@Override public PropertyDescriptor[] getPropertyDescriptors() { try { PropertyDescriptor pd = new PropertyDescriptor("value", ValueBean.class); pd.setPropertyEditorClass(MyNumberEditor.class); return new PropertyDescriptor[] {pd}; } catch (IntrospectionException ex) { throw new FatalBeanException("Couldn't create PropertyDescriptor", ex); } } }
@Override public BeanDescriptor getBeanDescriptor() { return this.delegate.getBeanDescriptor(); }
@Override public void setValue(Object value) { if (value instanceof Integer) { super.setValue(new Integer((Integer) value + 1)); } } });
@Override public MethodDescriptor[] getMethodDescriptors() { return this.delegate.getMethodDescriptors(); }
@Override public EventSetDescriptor[] getEventSetDescriptors() { return this.delegate.getEventSetDescriptors(); }
@Override public Image getIcon(int iconKind) { return this.delegate.getIcon(iconKind); }
@Override public int getDefaultPropertyIndex() { return this.delegate.getDefaultPropertyIndex(); }
@Override public int getDefaultEventIndex() { return this.delegate.getDefaultEventIndex(); }
@Override public BeanInfo[] getAdditionalBeanInfo() { return this.delegate.getAdditionalBeanInfo(); }
/** * Return the name of the affected property, if available. */ @Nullable public String getPropertyName() { return (this.propertyChangeEvent != null ? this.propertyChangeEvent.getPropertyName() : null); }
@SuppressWarnings("unused") protected String getAttributeDescription(PropertyDescriptor propertyDescriptor) { return propertyDescriptor.getDisplayName(); }