List of usage examples for java.beans PropertyDescriptor getDisplayName
public String getDisplayName()
From source file:org.eclipse.wb.internal.core.model.description.helpers.FactoryDescriptionHelper.java
/** * @return the id of standard bean property (created using {@link StandardBeanPropertiesRule}) * with given title or <code>null</code> if no such property exists. *///from ww w . j ava 2s.co m private static String getStandardPropertyId(List<PropertyDescriptor> propertyDescriptors, String title) { for (PropertyDescriptor propertyDescriptor : propertyDescriptors) { // prepare setter Method setMethod = ReflectionUtils.getWriteMethod(propertyDescriptor); if (setMethod == null) { continue; } // check title if (title.equals(propertyDescriptor.getDisplayName())) { return StandardBeanPropertiesRule.getId(setMethod); } } // no such property return null; }
From source file:org.jtrfp.trcl.file.LVLFile.java
private static DataKey[] generateUsedKeys() { ArrayList<DataKey> result = new ArrayList<DataKey>(); try {/*from w w w . j a v a 2 s .com*/ for (PropertyDescriptor pd : Introspector.getBeanInfo(LVLFile.class).getPropertyDescriptors()) result.add(new DataKey(pd.getName(), pd.getDisplayName())); } catch (Exception e) { e.printStackTrace(); } return result.toArray(new DataKey[result.size()]); }
From source file:org.kuali.kpme.pm.position.web.PositionMaintainableServiceImpl.java
private void recordEnrouteChanges(PositionBo previousPosition, String noteTarget) { //List of fields on the position class not to compare List<String> noCompareFields = new ArrayList<String>(); noCompareFields.add("process"); noCompareFields.add("requiredQualList"); List<Note> noteList = new ArrayList<Note>(); PositionBo currentPosition = (PositionBo) this.getDataObject(); EntityNamePrincipalName approver = KimApiServiceLocator.getIdentityService() .getDefaultNamesForPrincipalId(currentPosition.getUserPrincipalId()); //compare all fields on position try {//w ww. j a v a 2s.co m for (PropertyDescriptor pd : Introspector.getBeanInfo(PositionBo.class).getPropertyDescriptors()) { if (pd.getReadMethod() != null && !noCompareFields.contains(pd.getName())) { try { Object currentObject = pd.getReadMethod().invoke(currentPosition); Object previousObject = pd.getReadMethod().invoke(previousPosition); if (currentObject instanceof Collection) { if (!compareCollections(currentObject, previousObject)) { String noteText = approver.getPrincipalName() + " changed " + pd.getDisplayName() + " from '" + previousObject.toString() + "' to '" + currentObject.toString() + "'"; noteList.add( createNote(noteText, noteTarget, currentPosition.getUserPrincipalId())); } } else { if (!(currentObject == null ? previousObject == null : currentObject.equals(previousObject))) { String noteText = approver.getPrincipalName() + " changed " + pd.getDisplayName() + " from '" + previousObject.toString() + "' to '" + currentObject.toString() + "'"; noteList.add( createNote(noteText, noteTarget, currentPosition.getUserPrincipalId())); } } } catch (Exception e) { e.printStackTrace(); } } } } catch (IntrospectionException e) { e.printStackTrace(); } KRADServiceLocator.getNoteService().saveNoteList(noteList); }
From source file:org.openamf.recordset.ASRecordSet.java
/** * @param list List of JavaBeans, all beans should be of the same type * @param ignoreProperties properties that should not be added to the RecordSet */// www . j a v a 2 s.c o m public void populate(List list, String[] ignoreProperties) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException { List names = new ArrayList(); Object firstBean = list.get(0); PropertyDescriptor[] properties = PropertyUtils.getPropertyDescriptors(firstBean); for (int i = 0; i < properties.length; i++) { PropertyDescriptor descriptor = properties[i]; if (!ignoreProperty(descriptor, ignoreProperties)) { names.add(descriptor.getDisplayName()); } } String[] columnNames = new String[names.size()]; columnNames = (String[]) names.toArray(columnNames); setColumnNames(columnNames); int rowIndex = 0; List initialData = new ArrayList(); Iterator iterator = list.iterator(); while (iterator.hasNext()) { rowIndex++; Object bean = (Object) iterator.next(); List row = new ArrayList(); for (int i = 0; i < properties.length; i++) { PropertyDescriptor descriptor = properties[i]; if (!ignoreProperty(descriptor, ignoreProperties)) { Object value = null; Method readMethod = descriptor.getReadMethod(); if (readMethod != null) { value = readMethod.invoke(bean, new Object[0]); } row.add(value); } } rows.add(row); if (rowIndex <= initialRowCount) { initialData.add(row); } } setInitialData(initialData); setTotalCount(rows.size()); log.debug(this); }
From source file:org.xmlactions.mapping.xml_to_bean.PopulateClassFromXml.java
public static PropertyDescriptor findPropertyDescriptor(Object object, String name) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { PropertyDescriptor pd = null; PropertyDescriptor[] pds = PropertyUtils.getPropertyDescriptors(object); for (PropertyDescriptor p : pds) { if (p.getName().equals(name)) { pd = p;//from w ww . j a v a2 s. c om break; } } if (pd != null) { log.debug("PropertyDescriptor [" + name + "] - " + " Name:" + pd.getName() + " DisplayName:" + pd.getDisplayName() + " ShortDescription:" + pd.getShortDescription() + " PropertyType:" + pd.getPropertyType() + " ReadMethod:" + pd.getReadMethod() + " WriteMethod:" + pd.getWriteMethod() + " Value:" + pd.getValue(name)); // } else { // log.error("PropertyDescriptor [" + name + // "] - not found in class [" + object.getClass().getName() + "]"); } return pd; }
From source file:ubic.gemma.util.PrettyPrinter.java
/** * The only class that does any real work. Recursively print an object and all its associated objects. * //from www.ja v a 2 s . co m * @throws InvocationTargetException * @throws IllegalAccessException * @throws IllegalArgumentException * @throws IntrospectionException * @param buf * @param gemmaObj * @param level Used to track indents. */ private static void print(StringBuffer buf, Object bean, int level) throws IntrospectionException, IllegalArgumentException, IllegalAccessException, InvocationTargetException { if (bean == null) return; Class<?> gemmaClass = bean.getClass(); if (bean instanceof Collection) { print(buf, (Collection<?>) bean, ++level); return; } if (!gemmaClass.getName().startsWith("ubic.gemma")) return; BeanInfo bif = Introspector.getBeanInfo(gemmaClass); PropertyDescriptor[] props = bif.getPropertyDescriptors(); StringBuffer indent = new StringBuffer(); for (int i = 0; i < level; i++) indent.append(" "); boolean first = true; level++; for (int i = 0; i < props.length; i++) { PropertyDescriptor prop = props[i]; Object o = prop.getReadMethod().invoke(bean, new Object[] {}); if (prop.getDisplayName().equals("class")) continue; // everybody has it. if (prop.getDisplayName().equals("mutable")) continue; // shows up in the enums, just clutter. // generate a 'heading' for this object. if (first) buf.append(indent + bean.getClass().getSimpleName() + " Properties:\n"); first = false; buf.append(indent + " " + bean.getClass().getSimpleName() + "." + prop.getName() + ": " + (o == null ? "---" : o) + "\n"); print(buf, o, level); } }