Java Code Examples for java.beans.PropertyDescriptor

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project des, under directory /daemon/lib/apache-log4j-1.2.16/src/main/java/org/apache/log4j/config/.

Source file: PropertySetter.java

  34 
vote

/** 
 * Set the properites for the object that match the <code>prefix</code> passed as parameter.
 */
public void setProperties(Properties properties,String prefix){
  int len=prefix.length();
  for (Enumeration e=properties.propertyNames(); e.hasMoreElements(); ) {
    String key=(String)e.nextElement();
    if (key.startsWith(prefix)) {
      if (key.indexOf('.',len + 1) > 0) {
        continue;
      }
      String value=OptionConverter.findAndSubst(key,properties);
      key=key.substring(len);
      if (("layout".equals(key) || "errorhandler".equals(key)) && obj instanceof Appender) {
        continue;
      }
      PropertyDescriptor prop=getPropertyDescriptor(Introspector.decapitalize(key));
      if (prop != null && OptionHandler.class.isAssignableFrom(prop.getPropertyType()) && prop.getWriteMethod() != null) {
        OptionHandler opt=(OptionHandler)OptionConverter.instantiateByKey(properties,prefix + key,prop.getPropertyType(),null);
        PropertySetter setter=new PropertySetter(opt);
        setter.setProperties(properties,prefix + key + ".");
        try {
          prop.getWriteMethod().invoke(this.obj,new Object[]{opt});
        }
 catch (        IllegalAccessException ex) {
          LogLog.warn("Failed to set property [" + key + "] to value \""+ value+ "\". ",ex);
        }
catch (        InvocationTargetException ex) {
          if (ex.getTargetException() instanceof InterruptedException || ex.getTargetException() instanceof InterruptedIOException) {
            Thread.currentThread().interrupt();
          }
          LogLog.warn("Failed to set property [" + key + "] to value \""+ value+ "\". ",ex);
        }
catch (        RuntimeException ex) {
          LogLog.warn("Failed to set property [" + key + "] to value \""+ value+ "\". ",ex);
        }
        continue;
      }
      setProperty(key,value);
    }
  }
  activate();
}
 

Example 2

From project addis, under directory /application/src/main/java/org/drugis/addis/entities/.

Source file: DomainImpl.java

  32 
vote

@SuppressWarnings("unchecked") public ObservableList<? extends Entity> getCategoryContents(EntityCategory node){
  if (node == null) {
    return null;
  }
  try {
    PropertyDescriptor propertyDescriptor=BeanUtils.getPropertyDescriptor(Domain.class,node.getPropertyName());
    return (ObservableList<? extends Entity>)BeanUtils.getValue(this,propertyDescriptor);
  }
 catch (  IntrospectionException e) {
    throw new RuntimeException(e);
  }
}
 

Example 3

From project AndroidSensorLogger, under directory /libraries/opencsv-2.3-src-with-libs/opencsv-2.3/src/au/com/bytecode/opencsv/bean/.

Source file: CsvToBean.java

  32 
vote

protected T processLine(MappingStrategy<T> mapper,String[] line) throws IllegalAccessException, InvocationTargetException, InstantiationException, IntrospectionException {
  T bean=mapper.createBean();
  for (int col=0; col < line.length; col++) {
    PropertyDescriptor prop=mapper.findDescriptor(col);
    if (null != prop) {
      String value=checkForTrim(line[col],prop);
      Object obj=convertValue(value,prop);
      prop.getWriteMethod().invoke(bean,obj);
    }
  }
  return bean;
}
 

Example 4

From project BeeQueue, under directory /src/org/beequeue/util/.

Source file: BeanProperty.java

  32 
vote

public static PropertyDescriptor findProperty(BeanInfo beanInfo,String propertyToSearch){
  PropertyDescriptor[] propertyDescriptors=beanInfo.getPropertyDescriptors();
  for (int i=0; i < propertyDescriptors.length; i++) {
    PropertyDescriptor descriptor=propertyDescriptors[i];
    if (descriptor.getName().equals(propertyToSearch)) {
      return descriptor;
    }
  }
  throw new RuntimeException("no such property:" + propertyToSearch);
}
 

Example 5

From project Bio-PEPA, under directory /uk.ac.ed.inf.biopepa.ui/lib/opencsv-2.1/src/au/com/bytecode/opencsv/bean/.

Source file: CsvToBean.java

  32 
vote

protected T processLine(MappingStrategy<T> mapper,String[] line) throws IllegalAccessException, InvocationTargetException, InstantiationException, IntrospectionException {
  T bean=mapper.createBean();
  for (int col=0; col < line.length; col++) {
    String value=line[col];
    PropertyDescriptor prop=mapper.findDescriptor(col);
    if (null != prop) {
      Object obj=convertValue(value,prop);
      prop.getWriteMethod().invoke(bean,obj);
    }
  }
  return bean;
}
 

Example 6

From project Calendar-Application, under directory /au/com/bytecode/opencsv/bean/.

Source file: CsvToBean.java

  32 
vote

protected T processLine(MappingStrategy<T> mapper,String[] line) throws IllegalAccessException, InvocationTargetException, InstantiationException, IntrospectionException {
  T bean=mapper.createBean();
  for (int col=0; col < line.length; col++) {
    PropertyDescriptor prop=mapper.findDescriptor(col);
    if (null != prop) {
      String value=checkForTrim(line[col],prop);
      Object obj=convertValue(value,prop);
      prop.getWriteMethod().invoke(bean,obj);
    }
  }
  return bean;
}
 

Example 7

From project caustic, under directory /console/src/au/com/bytecode/opencsv/bean/.

Source file: CsvToBean.java

  32 
vote

protected T processLine(MappingStrategy<T> mapper,String[] line) throws IllegalAccessException, InvocationTargetException, InstantiationException, IntrospectionException {
  T bean=mapper.createBean();
  for (int col=0; col < line.length; col++) {
    PropertyDescriptor prop=mapper.findDescriptor(col);
    if (null != prop) {
      String value=checkForTrim(line[col],prop);
      Object obj=convertValue(value,prop);
      prop.getWriteMethod().invoke(bean,obj);
    }
  }
  return bean;
}
 

Example 8

From project cdk, under directory /generator/src/main/java/org/richfaces/cdk/apt/.

Source file: AptSourceUtils.java

  32 
vote

/** 
 * <p class="changed_added_4_0"> Set model property to the corresponding annotation attribute, if annotation attribute set to non-default value. </p>
 * @param model Model object.
 * @param annotation annotation to copy property from.
 * @param modelProperty bean attribute name in model.
 * @param annotationAttribute annotation attribute name.
 */
@Override public void setModelProperty(Object model,AnnotationMirror annotation,String modelProperty,String annotationAttribute){
  if (!isDefaultValue(annotation,annotationAttribute)) {
    PropertyDescriptor propertyDescriptor=PropertyUtils.getPropertyDescriptor(model,modelProperty);
    PropertyUtils.setPropertyValue(model,modelProperty,getAnnotationValue(annotation,annotationAttribute,propertyDescriptor.getPropertyType()));
  }
}
 

Example 9

From project CIShell, under directory /libs/opencsv/src/au/com/bytecode/opencsv/bean/.

Source file: CsvToBean.java

  32 
vote

protected T processLine(MappingStrategy<T> mapper,String[] line) throws IllegalAccessException, InvocationTargetException, InstantiationException, IntrospectionException {
  T bean=mapper.createBean();
  for (int col=0; col < line.length; col++) {
    String value=line[col];
    PropertyDescriptor prop=mapper.findDescriptor(col);
    if (null != prop) {
      Object obj=convertValue(value,prop);
      prop.getWriteMethod().invoke(bean,obj);
    }
  }
  return bean;
}
 

Example 10

From project dozer, under directory /core/src/main/java/org/dozer/util/.

Source file: ReflectionUtils.java

  32 
vote

private static PropertyDescriptor findPropDescriptorByName(List<PropertyDescriptor> propDescriptors,String name){
  PropertyDescriptor result=null;
  for (  PropertyDescriptor pd : propDescriptors) {
    if (pd.getName().equals(name)) {
      result=pd;
      break;
    }
  }
  return result;
}
 

Example 11

From project echo2, under directory /src/app/java/nextapp/echo2/app/componentxml/.

Source file: ComponentIntrospector.java

  32 
vote

/** 
 * Returns the <code>Class</code> of a specific property.
 * @param propertyName the name of the property
 * @return the <code>Class</code> of the property
 */
public Class getPropertyClass(String propertyName){
  PropertyDescriptor propertyDescriptor=getPropertyDescriptor(propertyName);
  if (propertyDescriptor == null) {
    return null;
  }
 else   if (propertyDescriptor instanceof IndexedPropertyDescriptor) {
    return ((IndexedPropertyDescriptor)propertyDescriptor).getIndexedPropertyType();
  }
 else {
    return propertyDescriptor.getPropertyType();
  }
}
 

Example 12

From project echo3, under directory /src/server-java/app/nextapp/echo/app/reflect/.

Source file: ObjectIntrospector.java

  32 
vote

/** 
 * Returns the <code>Class</code> of a specific property.
 * @param propertyName the name of the property
 * @return the <code>Class</code> of the property
 */
public Class getPropertyClass(String propertyName){
  PropertyDescriptor propertyDescriptor=getPropertyDescriptor(propertyName);
  if (propertyDescriptor == null) {
    throw new IllegalArgumentException("Invalid property name: " + propertyName);
  }
  if (propertyDescriptor instanceof IndexedPropertyDescriptor) {
    return ((IndexedPropertyDescriptor)propertyDescriptor).getIndexedPropertyType();
  }
 else {
    return propertyDescriptor.getPropertyType();
  }
}
 

Example 13

From project elasticsearch-osem, under directory /src/main/java/org/elasticsearch/osem/core/impl/.

Source file: ObjectContextWriterImpl.java

  32 
vote

private void write(XContentBuilder builder,Object object) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException, IOException {
  for (  Map.Entry<PropertyDescriptor,SerializableAttribute> entry : attributes.getSerializableProperties(object.getClass()).entrySet()) {
    PropertyDescriptor property=entry.getKey();
    SerializableAttribute serializable=entry.getValue();
    IndexableAttribute indexable=attributes.getIndexableProperties(object.getClass()).get(property);
    String name=indexable != null && indexable.getIndexName() != null ? indexable.getIndexName() : property.getName();
    write(builder,name,signatures.get(property),property.getReadMethod().invoke(object));
  }
  builder.field(ObjectContextImpl.CLASS_FIELD_NAME,object.getClass().getCanonicalName());
}
 

Example 14

From project fest-assert-2.x, under directory /src/main/java/org/fest/assertions/internal/.

Source file: PropertySupport.java

  32 
vote

/** 
 * Return the value of property from a target object.
 * @param propertyName the name of the property. It may be a nested property. It is left to the clients to validate for{@code null} or empty.
 * @param target the given object
 * @param clazz type of property
 * @return a the values of the given property name
 * @throws IntrospectionError if the given target does not have a property with a matching name.
 */
public <T>T propertyValue(String propertyName,Class<T> clazz,Object target){
  PropertyDescriptor descriptor=getProperty(propertyName,target);
  try {
    return clazz.cast(javaBeanDescriptor.invokeReadMethod(descriptor,target));
  }
 catch (  ClassCastException e) {
    String msg=format("Unable to obtain the value of the property <'%s'> from <%s> - wrong property type specified <%s>",propertyName,target,clazz);
    throw new IntrospectionError(msg,e);
  }
catch (  Throwable unexpected) {
    String msg=format("Unable to obtain the value of the property <'%s'> from <%s>",propertyName,target);
    throw new IntrospectionError(msg,unexpected);
  }
}
 

Example 15

From project fest-assertions-android, under directory /fest-assert-android-test/src/main/java/org/fest/assertions/internal/.

Source file: PropertySupport_propertyValues_with_mocks_Test.java

  32 
vote

@Test public void should_throw_error_if_PropertyDescriptor_cannot_invoke_read_method() throws Exception {
  RuntimeException thrownOnPurpose=new RuntimeException("Thrown on purpose");
  PropertyDescriptor real=descriptorForProperty("id",yoda);
  when(descriptor.invokeReadMethod(real,yoda)).thenThrow(thrownOnPurpose);
  try {
    propertySupport.propertyValues("id",employees);
    fail("expecting an IntrospectionError to be thrown");
  }
 catch (  IntrospectionError expected) {
    assertSame(thrownOnPurpose,expected.getCause());
    String msg=String.format("Unable to obtain the value of the property <'id'> from <%s>",yoda.toString());
    assertEquals(msg,expected.getMessage());
  }
}
 

Example 16

From project fest-reflect, under directory /src/test/java/org/fest/reflect/beanproperty/.

Source file: Property_Test.java

  32 
vote

@Test public void should_return_real_property(){
  PropertyDescriptor property=PropertyName.startPropertyAccess("name").ofType(String.class).in(person).info();
  assertNotNull(property);
  assertEquals("name",property.getName());
  assertEquals(String.class,property.getPropertyType());
}
 

Example 17

From project flapjack, under directory /flapjack/src/main/java/flapjack/util/.

Source file: ClassUtil.java

  32 
vote

private static Method findSetter(Object parent,String fieldName){
  try {
    PropertyDescriptor descriptor=new PropertyDescriptor(fieldName,parent.getClass());
    return descriptor.getWriteMethod();
  }
 catch (  IntrospectionException e) {
    return null;
  }
}
 

Example 18

From project geronimo-xbean, under directory /xbean-blueprint/src/main/java/org/apache/xbean/blueprint/context/impl/.

Source file: XBeanNamespaceHandler.java

  32 
vote

private Metadata tryParseNestedPropertyViaIntrospection(MutableBeanMetadata beanMetadata,String className,Element element,ParserContext parserContext){
  String localName=element.getLocalName();
  PropertyDescriptor descriptor=getPropertyDescriptor(className,localName);
  if (descriptor != null) {
    return parseNestedPropertyViaIntrospection(beanMetadata,element,descriptor.getName(),descriptor.getPropertyType(),parserContext);
  }
 else {
    return parseNestedPropertyViaIntrospection(beanMetadata,element,localName,Object.class,parserContext);
  }
}
 

Example 19

From project grails-data-mapping, under directory /grails-datastore-core/src/main/groovy/org/grails/datastore/mapping/engine/.

Source file: EntityAccess.java

  32 
vote

public void setPropertyNoConversion(String name,Object value){
  final PropertyDescriptor pd=beanWrapper.getPropertyDescriptor(name);
  if (pd == null) {
    return;
  }
  final Method writeMethod=pd.getWriteMethod();
  if (writeMethod != null) {
    ReflectionUtils.invokeMethod(writeMethod,beanWrapper.getWrappedInstance(),value);
  }
}
 

Example 20

From project grails-searchable, under directory /src/java/grails/plugin/searchable/internal/.

Source file: SearchableUtils.java

  32 
vote

/** 
 * If the given domain class property is a generic collection, this method returns the element type of that collection. Otherwise, it returns <code>null</code>.
 */
public static Class getElementClass(GrailsDomainClassProperty property){
  PropertyDescriptor descriptor=BeanUtils.getPropertyDescriptor(property.getDomainClass().getClazz(),property.getName());
  Type type=descriptor.getReadMethod().getGenericReturnType();
  if (type instanceof ParameterizedType) {
    for (    Type argType : ((ParameterizedType)type).getActualTypeArguments()) {
      return (Class)argType;
    }
  }
  return null;
}
 

Example 21

From project Hackathon_Chutaum, under directory /src/au/com/bytecode/opencsv/bean/.

Source file: CsvToBean.java

  32 
vote

protected T processLine(MappingStrategy<T> mapper,String[] line) throws IllegalAccessException, InvocationTargetException, InstantiationException, IntrospectionException {
  T bean=mapper.createBean();
  for (int col=0; col < line.length; col++) {
    PropertyDescriptor prop=mapper.findDescriptor(col);
    if (null != prop) {
      String value=checkForTrim(line[col],prop);
      Object obj=convertValue(value,prop);
      prop.getWriteMethod().invoke(bean,obj);
    }
  }
  return bean;
}
 

Example 22

From project Blitz, under directory /src/com/laxser/blitz/lama/core/.

Source file: BeanPropertyRowMapper.java

  31 
vote

/** 
 * Initialize the mapping metadata for the given class.
 * @param mappedClass the mapped class.
 */
protected void initialize(){
  this.mappedFields=new HashMap<String,PropertyDescriptor>();
  PropertyDescriptor[] pds=BeanUtils.getPropertyDescriptors(mappedClass);
  if (checkProperties) {
    mappedProperties=new HashSet<String>();
  }
  for (int i=0; i < pds.length; i++) {
    PropertyDescriptor pd=pds[i];
    if (pd.getWriteMethod() != null) {
      if (checkProperties) {
        this.mappedProperties.add(pd.getName());
      }
      this.mappedFields.put(pd.getName().toLowerCase(),pd);
      for (      String underscoredName : underscoreName(pd.getName())) {
        if (underscoredName != null && !pd.getName().toLowerCase().equals(underscoredName)) {
          this.mappedFields.put(underscoredName,pd);
        }
      }
    }
  }
}
 

Example 23

From project c3p0, under directory /src/java/com/mchange/v2/c3p0/management/.

Source file: DynamicPooledDataSourceManagerMBean.java

  31 
vote

private static Map extractAttributeInfos(Object bean){
  if (bean != null) {
    try {
      Map out=new HashMap();
      BeanInfo beanInfo=Introspector.getBeanInfo(bean.getClass(),Object.class);
      PropertyDescriptor[] pds=beanInfo.getPropertyDescriptors();
      for (int i=0, len=pds.length; i < len; ++i) {
        PropertyDescriptor pd=pds[i];
        String name;
        String desc;
        Method getter;
        Method setter;
        name=pd.getName();
        if (HIDE_PROPS.contains(name))         continue;
        desc=getDescription(name);
        getter=pd.getReadMethod();
        setter=pd.getWriteMethod();
        if (FORCE_READ_ONLY_PROPS.contains(name))         setter=null;
        try {
          out.put(name,new MBeanAttributeInfo(name,desc,getter,setter));
        }
 catch (        javax.management.IntrospectionException e) {
          if (logger.isLoggable(MLevel.WARNING))           logger.log(MLevel.WARNING,"IntrospectionException while setting up MBean attribute '" + name + "'",e);
        }
      }
      return Collections.synchronizedMap(out);
    }
 catch (    java.beans.IntrospectionException e) {
      if (logger.isLoggable(MLevel.WARNING))       logger.log(MLevel.WARNING,"IntrospectionException while setting up MBean attributes for " + bean,e);
      return Collections.EMPTY_MAP;
    }
  }
 else   return Collections.EMPTY_MAP;
}
 

Example 24

From project collections-generic, under directory /src/java/org/apache/commons/collections15/.

Source file: BeanMap.java

  31 
vote

private void initialise(){
  if (getBean() == null)   return;
  Class beanClass=getBean().getClass();
  try {
    BeanInfo beanInfo=Introspector.getBeanInfo(beanClass);
    PropertyDescriptor[] propertyDescriptors=beanInfo.getPropertyDescriptors();
    if (propertyDescriptors != null) {
      for (int i=0; i < propertyDescriptors.length; i++) {
        PropertyDescriptor propertyDescriptor=propertyDescriptors[i];
        if (propertyDescriptor != null) {
          String name=propertyDescriptor.getName();
          Method readMethod=propertyDescriptor.getReadMethod();
          Method writeMethod=propertyDescriptor.getWriteMethod();
          Class aType=propertyDescriptor.getPropertyType();
          if (readMethod != null) {
            readMethods.put(name,readMethod);
          }
          if (writeMethods != null) {
            writeMethods.put(name,writeMethod);
          }
          types.put(name,aType);
        }
      }
    }
  }
 catch (  IntrospectionException e) {
    logWarn(e);
  }
}
 

Example 25

From project commons-j, under directory /src/main/java/nerds/antelax/commons/xml/.

Source file: JAXBUtils.java

  31 
vote

private static Object getJaxbProperty(final Object jaxb,final String property) throws SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException, InvocationTargetException, IntrospectionException {
  Preconditions.checkNotNull(jaxb);
  Preconditions.checkNotNull(property);
  final PropertyDescriptor descriptor=findPropertyDescriptor(propertyDescriptors(jaxb),property);
  Preconditions.checkNotNull(descriptor);
  final Field field=jaxb.getClass().getDeclaredField(property);
  Preconditions.checkNotNull(field);
  if (descriptor.getPropertyType() == Boolean.class) {
    final String booleanGetterMethodName="is" + field.getName().substring(0,1).toUpperCase() + field.getName().substring(1);
    final Method booleanGetter=findMethod(jaxb,booleanGetterMethodName);
    Preconditions.checkNotNull(booleanGetter);
    return booleanGetter.invoke(jaxb);
  }
 else   return descriptor.getReadMethod().invoke(jaxb);
}
 

Example 26

From project core_1, under directory /src/com/iCo6/util/org/apache/commons/dbutils/.

Source file: BeanProcessor.java

  31 
vote

/** 
 * Creates a new object and initializes its fields from the ResultSet.
 * @param < T > The type of bean to create
 * @param rs The result set.
 * @param type The bean type (the return type of the object).
 * @param props The property descriptors.
 * @param columnToProperty The column indices in the result set.
 * @return An initialized object.
 * @throws SQLException if a database error occurs.
 */
private <T>T createBean(ResultSet rs,Class<T> type,PropertyDescriptor[] props,int[] columnToProperty) throws SQLException {
  T bean=this.newInstance(type);
  for (int i=1; i < columnToProperty.length; i++) {
    if (columnToProperty[i] == PROPERTY_NOT_FOUND) {
      continue;
    }
    PropertyDescriptor prop=props[columnToProperty[i]];
    Class<?> propType=prop.getPropertyType();
    Object value=this.processColumn(rs,i,propType);
    if (propType != null && value == null && propType.isPrimitive()) {
      value=primitiveDefaults.get(propType);
    }
    this.callSetter(bean,prop,value);
  }
  return bean;
}
 

Example 27

From project dynalink, under directory /src/main/java/org/dynalang/dynalink/beans/.

Source file: StaticClassIntrospector.java

  31 
vote

private static void addPropertyDescriptor(Map<String,PropertyDescriptor> descs,Method method,String name){
  if (!descs.containsKey(name)) {
    try {
      descs.put(name,new PropertyDescriptor(name,method,null));
    }
 catch (    IntrospectionException e) {
      throw new UndeclaredThrowableException(e);
    }
  }
}
 

Example 28

From project entando-core-engine, under directory /src/main/java/com/agiletec/apsadmin/tags/.

Source file: AbstractObjectInfoTag.java

  31 
vote

protected Object getPropertyValue(Object masterObject,String propertyValue){
  try {
    BeanInfo beanInfo=Introspector.getBeanInfo(masterObject.getClass());
    PropertyDescriptor[] descriptors=beanInfo.getPropertyDescriptors();
    for (int i=0; i < descriptors.length; i++) {
      PropertyDescriptor descriptor=descriptors[i];
      if (!descriptor.getName().equals(propertyValue)) {
        continue;
      }
      Method method=descriptor.getReadMethod();
      Object[] args=null;
      return method.invoke(masterObject,args);
    }
    if (ApsSystemUtils.getLogger().isLoggable(Level.FINEST)) {
      ApsSystemUtils.getLogger().finest("Invalid required object property : Master Object '" + masterObject.getClass().getName() + "' - property '"+ propertyValue+ "'");
    }
  }
 catch (  Throwable t) {
    ApsSystemUtils.logThrowable(t,this,"getPropertyValue","Error extracting property value : Master Object '" + masterObject.getClass().getName() + "' - property '"+ propertyValue+ "'");
  }
  return null;
}
 

Example 29

From project fest-assert-1.x, under directory /src/test/java/org/fest/assertions/.

Source file: PropertySupport_propertyValue_Test.java

  31 
vote

@Test public void should_throw_error_if_getter_cannot_be_invoked() throws IntrospectionException {
  final Name name=new Name("Leia","Organa");
  final PropertyDescriptor realDescriptor=new PropertyDescriptor("firstName",Name.class);
  final RuntimeException cause=new RuntimeException("Failed on purpose");
  new EasyMockTemplate(descriptor){
    @Override protected void expectations() throws Throwable {
      expect(descriptor.invokeReadMethod(realDescriptor,name)).andThrow(cause);
    }
    @Override protected void codeToTest() throws Throwable {
      try {
        propertySupport.propertyValue(realDescriptor,"firstName",name);
        fail();
      }
 catch (      IntrospectionError e) {
        assertEquals("Unable to obtain the value in property 'firstName'",e.getMessage());
        assertSame(cause,e.getCause());
      }
    }
  }
.run();
}
 

Example 30

From project GeoBI, under directory /print/src/main/java/org/ho/yaml/.

Source file: CustomBeanWrapper.java

  31 
vote

public void setProperty(String name,Object value) throws PropertyAccessException {
  try {
    PropertyDescriptor prop=ReflectionUtil.getPropertyDescriptor(type,name);
    if (prop == null) {
      LOGGER.warn(type.getSimpleName() + ": unknown field '" + name+ "' with value '"+ value+ "'");
      PropertyDescriptor prop2=ReflectionUtil.getPropertyDescriptor(type,name);
      return;
    }
    if (config.isPropertyAccessibleForDecoding(prop)) {
      Method wm=prop.getWriteMethod();
      wm.setAccessible(true);
      wm.invoke(getObject(),new Object[]{value});
      return;
    }
  }
 catch (  Exception e) {
    LOGGER.warn(type.getSimpleName() + ": Error while writing '" + value+ "' to "+ name+ ": "+ e);
  }
}
 

Example 31

From project ha-jdbc, under directory /src/main/java/net/sf/hajdbc/sql/.

Source file: AbstractDatabaseClusterConfiguration.java

  31 
vote

@Override public D marshal(T object) throws Exception {
  D result=this.descriptorClass.newInstance();
  List<Property> properties=new LinkedList<Property>();
  result.setId(object.getId());
  result.setProperties(properties);
  for (  Map.Entry<PropertyDescriptor,PropertyEditor> entry : findDescriptors(object.getClass()).values()) {
    PropertyDescriptor descriptor=entry.getKey();
    PropertyEditor editor=entry.getValue();
    Object value=descriptor.getReadMethod().invoke(object);
    if (value != null) {
      editor.setValue(value);
      Property property=new Property();
      property.setName(descriptor.getName());
      property.setValue(editor.getAsText());
      properties.add(property);
    }
  }
  return result;
}
 

Example 32

From project arquillian-extension-persistence, under directory /impl/src/main/java/org/jboss/arquillian/persistence/core/configuration/.

Source file: ConfigurationImporter.java

  30 
vote

private void createConfiguration(final Map<String,String> fieldsWithValues){
  final ConfigurationTypeConverter typeConverter=new ConfigurationTypeConverter();
  final List<Field> fields=SecurityActions.getAccessibleFields(configuration.getClass());
  for (  Field field : fields) {
    final String fieldName=field.getName();
    if (fieldsWithValues.containsKey(fieldName)) {
      final String value=fieldsWithValues.get(fieldName);
      final Class<?> fieldType=field.getType();
      try {
        final Class<?> boxedFieldType=typeConverter.box(fieldType);
        final Object convertedValue=typeConverter.convert(value,boxedFieldType);
        if (convertedValue != null && boxedFieldType.isAssignableFrom(convertedValue.getClass())) {
          final Method setter=new PropertyDescriptor(fieldName,configuration.getClass()).getWriteMethod();
          setter.invoke(configuration,convertedValue);
        }
      }
 catch (      Exception e) {
        throw new PersistenceExtensionInitializationException("Unable to create persistence configuration.",e);
      }
    }
  }
}
 

Example 33

From project dawn-isencia, under directory /com.isencia.passerelle.commons/src/main/java/com/isencia/util/swing/calendar/.

Source file: JCalendarBeanInfo.java

  30 
vote

/** 
 * This method returns an array of PropertyDescriptors describing the editable properties supported by this bean.
 */
public PropertyDescriptor[] getPropertyDescriptors(){
  try {
    if (PropertyEditorManager.findEditor(Locale.class) == null) {
      BeanInfo beanInfo=Introspector.getBeanInfo(JPanel.class);
      PropertyDescriptor[] p=beanInfo.getPropertyDescriptors();
      int length=p.length;
      PropertyDescriptor[] propertyDescriptors=new PropertyDescriptor[length + 1];
      for (int i=0; i < length; i++)       propertyDescriptors[i + 1]=p[i];
      propertyDescriptors[0]=new PropertyDescriptor("locale",JCalendar.class);
      propertyDescriptors[0].setBound(true);
      propertyDescriptors[0].setConstrained(false);
      propertyDescriptors[0].setPropertyEditorClass(LocaleEditor.class);
      return propertyDescriptors;
    }
  }
 catch (  IntrospectionException e) {
    e.printStackTrace();
  }
  return null;
}
 

Example 34

From project drugis-common, under directory /common-lib/src/main/java/org/drugis/common/validation/.

Source file: ListItemsUniqueModel.java

  30 
vote

public ListItemsUniqueModel(ObservableList<E> list,Class<E> beanClass,String propertyName){
  d_list=new ContentAwareListModel<E>(list,new String[]{propertyName});
  try {
    d_propertyDescriptor=new PropertyDescriptor(propertyName,beanClass);
  }
 catch (  IntrospectionException e) {
    throw new IllegalArgumentException(e);
  }
  d_list.addListDataListener(new IndifferentListDataListener(){
    protected void update(){
      boolean oldVal=d_value;
      d_value=calculate();
      fireValueChange(oldVal,d_value);
    }
  }
);
}
 

Example 35

From project floodlight, under directory /src/main/java/org/openflow/protocol/.

Source file: OFMatchBeanInfo.java

  30 
vote

@Override public PropertyDescriptor[] getPropertyDescriptors(){
  List<PropertyDescriptor> descs=new LinkedList<PropertyDescriptor>();
  Field[] fields=OFMatch.class.getDeclaredFields();
  String name;
  for (int i=0; i < fields.length; i++) {
    int mod=fields[i].getModifiers();
    if (Modifier.isFinal(mod) || Modifier.isStatic(mod))     continue;
    name=fields[i].getName();
    Class<?> type=fields[i].getType();
    try {
      descs.add(new PropertyDescriptor(name,name2getter(OFMatch.class,name),name2setter(OFMatch.class,name,type)));
    }
 catch (    IntrospectionException e) {
      e.printStackTrace();
      throw new RuntimeException(e);
    }
  }
  return descs.toArray(new PropertyDescriptor[0]);
}
 

Example 36

From project ajah, under directory /ajah-spring-jdbc/src/main/java/com/ajah/spring/jdbc/.

Source file: AbstractAjahDao.java

  29 
vote

private static PropertyDescriptor getProp(final Field field,final PropertyDescriptor[] props){
  for (  final PropertyDescriptor prop : props) {
    if (prop.getName().equals(field.getName())) {
      return prop;
    }
  }
  return null;
}
 

Example 37

From project Amoeba-for-Aladdin, under directory /src/java/com/meidusa/amoeba/config/.

Source file: ParameterMapping.java

  29 
vote

private static PropertyDescriptor[] getDescriptors(Class<?> clazz){
  PropertyDescriptor[] descriptors;
  List<PropertyDescriptor> list;
  PropertyDescriptor[] mDescriptors=(PropertyDescriptor[])propertyDescriptorMap.get(clazz);
  if (null == mDescriptors) {
    try {
      descriptors=Introspector.getBeanInfo(clazz).getPropertyDescriptors();
      list=new ArrayList<PropertyDescriptor>();
      for (int i=0; i < descriptors.length; i++) {
        if (null != descriptors[i].getPropertyType()) {
          list.add(descriptors[i]);
        }
      }
      mDescriptors=new PropertyDescriptor[list.size()];
      list.toArray(mDescriptors);
    }
 catch (    IntrospectionException ie) {
      ie.printStackTrace();
      mDescriptors=new PropertyDescriptor[0];
    }
  }
  propertyDescriptorMap.put(clazz,mDescriptors);
  return (mDescriptors);
}
 

Example 38

From project Arecibo, under directory /alert-data-support/src/main/java/com/ning/arecibo/alert/confdata/dao/.

Source file: LowerToCamelBeanMapper.java

  29 
vote

public LowerToCamelBeanMapper(final Class<T> type){
  this.type=type;
  try {
    final BeanInfo info=Introspector.getBeanInfo(type);
    for (    final PropertyDescriptor descriptor : info.getPropertyDescriptors()) {
      properties.put(CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE,descriptor.getName()).toLowerCase(),descriptor);
    }
  }
 catch (  IntrospectionException e) {
    throw new IllegalArgumentException(e);
  }
}
 

Example 39

From project asterisk-java, under directory /src/main/java/org/asteriskjava/tools/.

Source file: HtmlEventTracer.java

  29 
vote

protected String getProperty(Object obj,String property){
  try {
    BeanInfo beanInfo=Introspector.getBeanInfo(obj.getClass());
    for (    PropertyDescriptor propertyDescriptor : beanInfo.getPropertyDescriptors()) {
      if (!propertyDescriptor.getName().equals(property)) {
        continue;
      }
      return propertyDescriptor.getReadMethod().invoke(obj).toString();
    }
  }
 catch (  Exception e) {
    System.err.println("Unable to read property '" + property + "' from object "+ obj+ ": "+ e.getMessage());
    return null;
  }
  return null;
}
 

Example 40

From project atlas, under directory /src/main/java/com/ning/atlas/space/.

Source file: BaseSpace.java

  29 
vote

@Override public void store(Identity id,Object it){
  PropertyDescriptor[] pds=PropertyUtils.getPropertyDescriptors(it.getClass());
  for (  PropertyDescriptor pd : pds) {
    if (!pd.getReadMethod().getDeclaringClass().equals(Object.class)) {
      String prop_name=CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_HYPHEN,pd.getName());
      try {
        Object value=pd.getReadMethod().invoke(it);
        Class<?> pt=pd.getPropertyType();
        String json;
        if (String.class.equals(pt) || Primitives.allPrimitiveTypes().contains(pt)) {
          json=mapper.convertValue(value,String.class);
        }
 else {
          json=mapper.writeValueAsString(value);
        }
        write(id,prop_name,json);
      }
 catch (      Exception e) {
        throw new IllegalStateException("unable to read property '" + pd.getName() + "' from "+ it,e);
      }
    }
  }
}
 

Example 41

From project BHT-FPA, under directory /mailer-common/de.bht.fpa.mail.common/rcputils/de/ralfebert/rcputils/properties/.

Source file: PropertyValue.java

  29 
vote

/** 
 * Returns the property value referred by object."propertyName"
 */
@Override public Object getValue(Object object){
  Object currentObject=object;
  for (int i=0; i < properties.length; i++) {
    if (currentObject == null) {
      return null;
    }
    if (properties[i] instanceof String) {
      properties[i]=BeanPropertyHelper.getPropertyDescriptor(currentObject.getClass(),(String)properties[i]);
    }
    if (properties[i] instanceof PropertyDescriptor) {
      currentObject=BeanPropertyHelper.readProperty(currentObject,(PropertyDescriptor)properties[i]);
    }
 else {
      throw new RuntimeException("Invalid property: " + properties[i]);
    }
  }
  return currentObject;
}
 

Example 42

From project chromattic, under directory /metamodel/src/test/java/org/chromattic/metamodel/bean/.

Source file: JavaBeanTestCase.java

  29 
vote

@Override protected Collection<PropertyMetaData> buildMetaData(Class<?> beanClass) throws Exception {
  java.beans.BeanInfo info=Introspector.getBeanInfo(beanClass,Object.class);
  List<PropertyMetaData> res=new ArrayList<PropertyMetaData>();
  for (  PropertyDescriptor pd : info.getPropertyDescriptors()) {
    res.add(new PropertyMetaData(pd));
  }
  return res;
}
 

Example 43

From project Cinch, under directory /src/com/palantir/ptoss/cinch/core/.

Source file: BindingContext.java

  29 
vote

/** 
 * Create a BindingContext for the given, non-null object.  Throws a  {@link BindingException}if there is a problem.
 * @param object the object - cannot be null
 */
public BindingContext(Object object){
  Validate.notNull(object);
  this.object=object;
  try {
    bindableModels=indexBindableModels();
    bindableMethods=indexBindableMethods();
    bindableModelMethods=indexBindableModelMethods();
    bindableConstants=indexBindableConstants();
    bindableGetters=indexBindableProperties(Reflections.getterFunction(PropertyDescriptor.class,Method.class,"readMethod"));
    bindableSetters=indexBindableProperties(Reflections.getterFunction(PropertyDescriptor.class,Method.class,"writeMethod"));
  }
 catch (  Exception e) {
    throw new BindingException("could not create BindingContext",e);
  }
}
 

Example 44

From project codjo-standalone-common, under directory /src/main/java/net/codjo/persistent/sql/.

Source file: SimpleHomeMapping.java

  29 
vote

/** 
 * Initialisation.
 * @param objectClass La classe de l'objet
 * @param initMask Le masque d'initialisation
 * @exception IntrospectionException Recherche des accesseurs impossible
 * @exception NoSuchMethodException Methode accesseur introuvable
 */
private void initAccessors(Class objectClass,int initMask) throws IntrospectionException, NoSuchMethodException {
  if ((initMask & MASK) == INIT_GETTER) {
    getterMethods=new Method[dbColumnNames.size()];
  }
  if ((initMask & MASK) == INIT_SETTER) {
    setterMethods=new Method[dbColumnNames.size()];
  }
  BeanInfo info=Introspector.getBeanInfo(objectClass);
  PropertyDescriptor[] desc=info.getPropertyDescriptors();
  for (int i=0; i < desc.length; i++) {
    int idx=propertyNames.indexOf(desc[i].getName());
    if (idx != -1 && (initMask & MASK) == INIT_GETTER) {
      getterMethods[idx]=desc[i].getReadMethod();
    }
    if (idx != -1 && (initMask & MASK) == INIT_SETTER) {
      setterMethods[idx]=desc[i].getWriteMethod();
    }
  }
  if ((initMask & MASK) == INIT_GETTER) {
    for (int i=0; i < getterMethods.length; i++) {
      if (getterMethods[i] == null) {
        throw new NoSuchMethodException("Manque getter pour " + propertyNames.get(i));
      }
    }
  }
  if ((initMask & MASK) == INIT_SETTER) {
    for (int i=0; i < setterMethods.length; i++) {
      if (setterMethods[i] == null) {
        throw new NoSuchMethodException("Manque setter pour " + propertyNames.get(i));
      }
    }
  }
}
 

Example 45

From project components-ness-config, under directory /src/main/java/com/nesscomputing/config/.

Source file: ConfigMagicDynamicMBean.java

  29 
vote

private static Map<String,Object> toMap(Object configBean){
  PropertyDescriptor[] props=ReflectUtils.getBeanGetters(configBean.getClass());
  Map<String,Object> result=Maps.newHashMap();
  for (  PropertyDescriptor prop : props) {
    if (CONFIG_MAGIC_CALLBACKS_NAME.equals(prop.getName())) {
      continue;
    }
    try {
      result.put(prop.getName(),ObjectUtils.toString(prop.getReadMethod().invoke(configBean),null));
    }
 catch (    Exception e) {
      LOG.error(e,"For class %s, unable to find config property %s",configBean.getClass(),prop);
    }
  }
  return result;
}
 

Example 46

From project components-ness-jdbi, under directory /src/main/java/com/nesscomputing/jdbi/binding/.

Source file: BindDefineBeanFactory.java

  29 
vote

@Override public Binder build(Annotation annotation){
  return new Binder<BindDefineBean,Object>(){
    @Override public void bind(    SQLStatement q,    BindDefineBean bind,    Object arg){
      final String prefix;
      if ("___jdbi_bare___".equals(bind.value())) {
        prefix="";
      }
 else {
        prefix=bind.value() + ".";
      }
      try {
        BeanInfo infos=Introspector.getBeanInfo(arg.getClass());
        PropertyDescriptor[] props=infos.getPropertyDescriptors();
        for (        PropertyDescriptor prop : props) {
          String key=prefix + prop.getName();
          Object value=prop.getReadMethod().invoke(arg);
          q.bind(key,value);
          q.define(key,value);
        }
      }
 catch (      Exception e) {
        throw new IllegalStateException("unable to bind bean properties",e);
      }
    }
  }
;
}
 

Example 47

From project constretto-core, under directory /constretto-core/src/main/java/org/constretto/internal/store/.

Source file: ObjectConfigurationStore.java

  29 
vote

private TaggedPropertySet createPropertySetForObject(Object configurationObject){
  String tag=ConfigurationValue.DEFAULT_TAG;
  String basePath="";
  Map<String,String> properties=new HashMap<String,String>();
  if (configurationObject.getClass().isAnnotationPresent(ConfigurationSource.class)) {
    ConfigurationSource configurationAnnotation=configurationObject.getClass().getAnnotation(ConfigurationSource.class);
    tag=configurationAnnotation.tag();
    if (tag.equals("")) {
      tag=ConfigurationValue.DEFAULT_TAG;
    }
    basePath=configurationAnnotation.basePath();
  }
  for (  PropertyDescriptor propertyDescriptor : PropertyUtils.getPropertyDescriptors(configurationObject)) {
    boolean canRead=propertyDescriptor.getReadMethod() != null;
    boolean isString=propertyDescriptor.getPropertyType().isAssignableFrom(String.class);
    if (canRead && isString) {
      String path=propertyDescriptor.getName();
      try {
        String value=(String)PropertyUtils.getProperty(configurationObject,path);
        if (!ConstrettoUtils.isEmpty(basePath)) {
          path=basePath + "." + path;
        }
        properties.put(path,value);
      }
 catch (      Exception e) {
        throw new ConstrettoException("Could not access data in field",e);
      }
    }
  }
  return new TaggedPropertySet(tag,properties,getClass());
}
 

Example 48

From project core_4, under directory /api/src/main/java/org/ajax4jsf/javascript/.

Source file: PropertyUtils.java

  29 
vote

public static PropertyDescriptor[] getPropertyDescriptors(Object bean){
  if (bean == null) {
    throw new IllegalArgumentException("argument is null");
  }
  PropertyDescriptor[] descriptors=null;
  try {
    BeanInfo beanInfo=Introspector.getBeanInfo(bean.getClass());
    descriptors=beanInfo.getPropertyDescriptors();
  }
 catch (  IntrospectionException e) {
    LOGGER.error(e.getMessage(),e);
  }
  if (descriptors == null) {
    descriptors=EMPTY_DESCRIPTORS_ARRAY;
  }
  return descriptors;
}
 

Example 49

From project Danroth, under directory /src/main/java/org/yaml/snakeyaml/introspector/.

Source file: MethodProperty.java

  29 
vote

public MethodProperty(PropertyDescriptor property){
  super(property.getName(),property.getPropertyType(),property.getReadMethod() == null ? null : property.getReadMethod().getGenericReturnType());
  this.property=property;
  this.readable=property.getReadMethod() != null;
  this.writable=property.getWriteMethod() != null;
}
 

Example 50

From project drools-planner, under directory /drools-planner-core/src/main/java/org/drools/planner/core/domain/common/.

Source file: DescriptorUtils.java

  29 
vote

public static Object executeGetter(PropertyDescriptor propertyDescriptor,Object bean){
  try {
    return propertyDescriptor.getReadMethod().invoke(bean);
  }
 catch (  IllegalAccessException e) {
    throw new IllegalStateException("Cannot call property (" + propertyDescriptor.getName() + ") getter on bean of class ("+ bean.getClass()+ ").",e);
  }
catch (  InvocationTargetException e) {
    throw new IllegalStateException("The property (" + propertyDescriptor.getName() + ") getter on bean of class ("+ bean.getClass()+ ") throws an exception.",e.getCause());
  }
}
 

Example 51

From project Gemini-Blueprint, under directory /core/src/test/java/org/eclipse/gemini/blueprint/blueprint/container/.

Source file: BlueprintFieldsTest.java

  29 
vote

public void testUseBlueprintExceptions() throws Exception {
  OsgiServiceProxyFactoryBean fb=new OsgiServiceProxyFactoryBean();
  BeanWrapper wrapper=PropertyAccessorFactory.forBeanPropertyAccess(fb);
  String propertyName="useBlueprintExceptions";
  for (  PropertyDescriptor desc : wrapper.getPropertyDescriptors()) {
    System.out.println(desc.getName());
  }
  Class type=wrapper.getPropertyType(propertyName);
  System.out.println("type is " + type);
  assertTrue(wrapper.isWritableProperty(propertyName));
  assertFalse(wrapper.isReadableProperty(propertyName));
}
 

Example 52

From project gemini-dbaccess, under directory /org.eclipse.gemini.dbaccess.util/src/org/eclipse/gemini/dbaccess/.

Source file: AbstractDataSourceFactory.java

  29 
vote

protected void setProperty(Object object,String name,String value) throws SQLException {
  Class<?> type=object.getClass();
  PropertyDescriptor[] descriptors;
  try {
    descriptors=Introspector.getBeanInfo(type).getPropertyDescriptors();
  }
 catch (  Exception ex) {
    SQLException sqlException=new SQLException();
    sqlException.initCause(ex);
    throw sqlException;
  }
  List<String> names=new ArrayList<String>();
  for (int i=0; i < descriptors.length; i++) {
    if (descriptors[i].getWriteMethod() == null) {
      continue;
    }
    if (descriptors[i].getName().equals(name)) {
      Method method=descriptors[i].getWriteMethod();
      Class<?> paramType=method.getParameterTypes()[0];
      Object param=toBasicType(value,paramType.getName());
      try {
        method.invoke(object,new Object[]{param});
      }
 catch (      Exception ex) {
        SQLException sqlException=new SQLException();
        sqlException.initCause(ex);
        throw sqlException;
      }
      return;
    }
    names.add(descriptors[i].getName());
  }
  throw new SQLException("No such property: " + name + ", exists.  Writable properties are: "+ names);
}
 

Example 53

From project gemini.dbaccess, under directory /org.eclipse.gemini.dbaccess.util/src/org/eclipse/gemini/dbaccess/.

Source file: AbstractDataSourceFactory.java

  29 
vote

protected void setProperty(Object object,String name,String value) throws SQLException {
  Class<?> type=object.getClass();
  PropertyDescriptor[] descriptors;
  try {
    descriptors=Introspector.getBeanInfo(type).getPropertyDescriptors();
  }
 catch (  Exception ex) {
    SQLException sqlException=new SQLException();
    sqlException.initCause(ex);
    throw sqlException;
  }
  List<String> names=new ArrayList<String>();
  for (int i=0; i < descriptors.length; i++) {
    if (descriptors[i].getWriteMethod() == null) {
      continue;
    }
    if (descriptors[i].getName().equals(name)) {
      Method method=descriptors[i].getWriteMethod();
      Class<?> paramType=method.getParameterTypes()[0];
      Object param=toBasicType(value,paramType.getName());
      try {
        method.invoke(object,new Object[]{param});
      }
 catch (      Exception ex) {
        SQLException sqlException=new SQLException();
        sqlException.initCause(ex);
        throw sqlException;
      }
      return;
    }
    names.add(descriptors[i].getName());
  }
  throw new SQLException("No such property: " + name + ", exists.  Writable properties are: "+ names);
}
 

Example 54

From project genobyte, under directory /genobyte/src/main/java/org/obiba/bitwise/annotation/.

Source file: AnnotationBasedRecord.java

  29 
vote

private void loadRecord(int index,T o){
  for (  PropertyDescriptor property : ba_.getStoredDescriptors()) {
    String propertyName=property.getName();
    String bitwiseField=ba_.getStoredFields().get(propertyName);
    try {
      Field f=store_.getField(bitwiseField);
      if (f == null) {
        continue;
      }
      BitVector vector=f.getValue(index);
      Object value=f.getDictionary().reverseLookup(vector);
      if (property.getWriteMethod() != null) {
        property.getWriteMethod().invoke(o,value);
      }
    }
 catch (    RuntimeException e) {
      throw e;
    }
catch (    Exception e) {
      throw new RuntimeException(e);
    }
  }
}
 

Example 55

From project heritrix3, under directory /commons/src/main/java/org/archive/spring/.

Source file: ConfigPathConfigurer.java

  29 
vote

/** 
 * Find any ConfigPath properties in the passed bean; ensure that if they have a null 'base', that is replaced with the job home directory. Also, remember all ConfigPaths so fixed-up for later reference. 
 * @param bean
 * @param beanName
 * @return Same bean as passed in, fixed as necessary
 */
protected Object fixupPaths(Object bean,String beanName){
  BeanWrapperImpl wrapper=new BeanWrapperImpl(bean);
  for (  PropertyDescriptor d : wrapper.getPropertyDescriptors()) {
    if (d.getPropertyType().isAssignableFrom(ConfigPath.class) || d.getPropertyType().isAssignableFrom(ConfigFile.class)) {
      Object value=wrapper.getPropertyValue(d.getName());
      if (value != null && value instanceof ConfigPath) {
        String patchName=beanName + "." + d.getName();
        fixupConfigPath((ConfigPath)value,patchName);
      }
    }
 else     if (Iterable.class.isAssignableFrom(d.getPropertyType())) {
      Iterable<?> iterable=(Iterable<?>)wrapper.getPropertyValue(d.getName());
      if (iterable != null) {
        int i=0;
        for (        Object candidate : iterable) {
          if (candidate != null && candidate instanceof ConfigPath) {
            String patchName=beanName + "." + d.getName()+ "["+ i+ "]";
            fixupConfigPath((ConfigPath)candidate,patchName);
          }
          i++;
        }
      }
    }
  }
  return bean;
}
 

Example 56

From project hibernate-tools, under directory /src/java/org/hibernate/tool/stat/.

Source file: BeanTableModel.java

  29 
vote

private void introspect(Class beanClass){
  try {
    this.beanInfo=Introspector.getBeanInfo(beanClass,Introspector.USE_ALL_BEANINFO);
    descriptors=beanInfo.getPropertyDescriptors();
  }
 catch (  IntrospectionException ie) {
  }
  List v=new ArrayList(descriptors.length);
  for (int i=0; i < descriptors.length; i++) {
    if (!descriptors[i].getName().equals("class")) {
      v.add(descriptors[i]);
    }
  }
  descriptors=(PropertyDescriptor[])v.toArray(new PropertyDescriptor[v.size()]);
}