public static String toString(Object component) { try { PropertyDescriptor[] props = Introspector.getPropertyDescriptors(component.getClass()); StringBuilder builder = new StringBuilder(); for (PropertyDescriptor descriptor : props) { builder.append( descriptor.getName() ) .append("=") .append( descriptor.getReadMethod().invoke(component) ) .append("; "); } return builder.toString(); } catch (Exception e) { return ""; } }
public static String toString(Object component) { try { PropertyDescriptor[] props = Introspector.getPropertyDescriptors(component.getClass()); StringBuilder builder = new StringBuilder(); for (PropertyDescriptor descriptor : props) { builder.append( descriptor.getName() ) .append("=") .append( descriptor.getReadMethod().invoke(component) ) .append("; "); } return builder.toString(); } catch (Exception e) { return ""; } }
public static PropertyDescriptor[] getProperties(Class<?> clazz) { try { PropertyDescriptor[] properties = Introspector.getPropertyDescriptors(clazz); Field[] fields = clazz.getDeclaredFields(); for (Field field : fields) {
public static PropertyDescriptor[] getProperties(Class<?> clazz) { try { PropertyDescriptor[] properties = Introspector.getPropertyDescriptors(clazz); Field[] fields = clazz.getDeclaredFields(); for (Field field : fields) {
@Override public void defineProperty(String name) { if (type.length() == 0 || instantiator != null) properties.add(new MapProperty(converters, name)); else { try { // Try to find public getter/setter. PropertyDescriptor[] props = Introspector.getPropertyDescriptors(clazz); for (PropertyDescriptor prop : props) { if (name.equals(prop.getName()) && prop.getWriteMethod() != null && prop.getReadMethod() != null) { properties.add(new MethodProperty(converters, name, prop.getWriteMethod(), prop.getReadMethod())); return; } } // Try to find public field. Field field = clazz.getField(name); if (!Modifier.isStatic(field.getModifiers()) && !Modifier.isTransient(field.getModifiers())) properties.add(new FieldProperty(converters, field)); } catch (NoSuchFieldException e) { if ("uid".equals(name)) // ObjectProxy specific property... properties.add(new UIDProperty(converters)); else throw new RuntimeException(e); } catch (Exception e) { throw new RuntimeException(e); } } }
PropertyDescriptor[] descs = Introspector.getPropertyDescriptors(type); for (PropertyDescriptor property : descs) { String propertyName = property.getName();
@Override public void defineProperty(String name) { if (type.length() == 0 || instantiator != null) properties.add(new MapProperty(converters, name)); else { try { // Try to find public getter/setter. PropertyDescriptor[] props = Introspector.getPropertyDescriptors(clazz); for (PropertyDescriptor prop : props) { if (name.equals(prop.getName()) && prop.getWriteMethod() != null && prop.getReadMethod() != null) { properties.add(new MethodProperty(converters, name, prop.getWriteMethod(), prop.getReadMethod())); return; } } // Try to find public field. Field field = clazz.getField(name); if (!Modifier.isStatic(field.getModifiers()) && !Modifier.isTransient(field.getModifiers())) properties.add(new FieldProperty(converters, field)); } catch (NoSuchFieldException e) { if ("uid".equals(name)) // ObjectProxy specific property... properties.add(new UIDProperty(converters)); else throw new RuntimeException(e); } catch (Exception e) { throw new RuntimeException(e); } } }
@Override public void defineProperty(String name) { if (type.length() == 0 || instantiator != null) properties.add(new MapProperty(converters, name)); else { try { // Try to find public getter/setter. PropertyDescriptor[] props = Introspector.getPropertyDescriptors(clazz); for (PropertyDescriptor prop : props) { if (name.equals(prop.getName()) && prop.getWriteMethod() != null && prop.getReadMethod() != null) { properties.add(new MethodProperty(converters, name, prop.getWriteMethod(), prop.getReadMethod())); return; } } // Try to find public field. Field field = clazz.getField(name); if (!Modifier.isStatic(field.getModifiers()) && !Modifier.isTransient(field.getModifiers())) properties.add(new FieldProperty(converters, field)); } catch (NoSuchFieldException e) { if ("uid".equals(name)) // ObjectProxy specific property... properties.add(new UIDProperty(converters)); else throw new RuntimeException(e); } catch (Exception e) { throw new RuntimeException(e); } } }
PropertyDescriptor[] descs = Introspector.getPropertyDescriptors(type); for (PropertyDescriptor property : descs) { String propertyName = property.getName();
PropertyDescriptor[] descs = Introspector.getPropertyDescriptors(type); for (PropertyDescriptor property : descs) { String propertyName = property.getName();
PropertyDescriptor[] props = Introspector.getPropertyDescriptors(clazz); for (PropertyDescriptor prop : props) { if (name.equals(prop.getName()) && prop.getWriteMethod() != null && prop.getReadMethod() != null) {
PropertyDescriptor[] descs = Introspector.getPropertyDescriptors(type); for (PropertyDescriptor property : descs) { String propertyName = property.getName();
PropertyDescriptor[] descs = Introspector.getPropertyDescriptors(type); for (PropertyDescriptor property : descs) { String propertyName = property.getName();
PropertyDescriptor[] descs = Introspector.getPropertyDescriptors(type); for (PropertyDescriptor property : descs) { String propertyName = property.getName();
PropertyDescriptor[] descs = Introspector.getPropertyDescriptors(type); for (PropertyDescriptor property : descs) { String propertyName = property.getName();
PropertyDescriptor[] descs = Introspector.getPropertyDescriptors(type); for (PropertyDescriptor property : descs) { String propertyName = property.getName();
PropertyDescriptor[] properties = Introspector.getPropertyDescriptors(object.getClass()); if (properties == null) properties = new PropertyDescriptor[0];
PropertyDescriptor[] properties = Introspector.getPropertyDescriptors(object.getClass()); if (properties == null) properties = new PropertyDescriptor[0];
@Override public void setPropertyValue(Object entity, String name, Object value) { if (entity == null) return; try { boolean found = false; PropertyDescriptor[] pds = Introspector.getPropertyDescriptors(entity.getClass()); for (PropertyDescriptor pd : pds) { if (pd.getName().equals(name) && pd.getWriteMethod() != null) { Object oldValue = null; if (pd.getReadMethod() != null) oldValue = pd.getReadMethod().invoke(entity); pd.getWriteMethod().invoke(entity, value); if (pd.getReadMethod() != null) PropertyChangeHelper.firePropertyChange(entity, name, oldValue, value); found = true; break; } } if (!found) super.setPropertyValue(entity, name, value); } catch (Exception e) { throw new RuntimeException("Could not set property " + name + " on entity " + entity, e); } }
PropertyDescriptor[] properties = Introspector.getPropertyDescriptors(object.getClass()); if (properties == null) properties = new PropertyDescriptor[0];