Package java.beans

Examples of java.beans.PropertyDescriptor


        assertEquals(Double.class, ((CollectionType) type).getComponentType().getTypeClass());
    }
   
    public void testPDType() throws Exception
    {
        PropertyDescriptor pd =
            Introspector.getBeanInfo(MapDTO.class, Object.class).getPropertyDescriptors()[0];
        Type type = creator.createType(pd);
        tm.register(type);
        assertTrue( type instanceof MapType );
       
View Full Code Here


        assertTrue(type.getTypeClass().isAssignableFrom(String.class));
    }
   
    public void testPDType() throws Exception
    {
        PropertyDescriptor pd =
            Introspector.getBeanInfo(CollectionDTO.class, Object.class).getPropertyDescriptors()[0];
        Type type = creator.createType(pd);
        tm.register(type);
        assertTrue( type instanceof CollectionType );
       
View Full Code Here

    @Override public void trash(Class<? extends DomainEntity> entityClass, UUID pk, String path) throws Exception {
        Assert.notNull(entityClass);
        if (pk != null) {
            DomainEntity entity = dao.find(entityClass, pk);
            if (entity != null) {
                PropertyDescriptor property = BeanUtils.getPropertyDescriptor(entityClass, path);
                if ((property != null) && (Document.class.isAssignableFrom(property.getPropertyType()))) {
                    Document doc = (Document) property.getReadMethod().invoke(entity);
                    if (doc != null) {
                        doc.setTemporal(true);
                        dao.update(doc);
                    }
                }
View Full Code Here

        return new QName(ns, name);
    }

    public boolean isNillable(QName name)
    {
        PropertyDescriptor desc = getPropertyDescriptorFromMappedName(name);
       
        if (isAnnotatedElement(desc))
        {
            XmlElement att = desc.getReadMethod().getAnnotation(XmlElement.class);
            return att.nillable();
        }
        else
        {
            return super.isNillable(name);
View Full Code Here

        }
    }
   
    public int getMinOccurs ( QName name )
    {
        PropertyDescriptor desc = getPropertyDescriptorFromMappedName(name);       
        if (isAnnotatedElement(desc))
        {
            XmlElement att = desc.getReadMethod().getAnnotation(XmlElement.class);
            String minOccurs = att.minOccurs();
            if ( minOccurs != null && minOccurs.length() > 0 )
            {
                return Integer.parseInt( minOccurs );
            }
View Full Code Here

    */
   private Object setInvoke(String property, Object impl, Class aClass, String[] argValuesAsStrings) throws XmlBlasterException {
      try {
         Method method = null;
         try {
            PropertyDescriptor desc = new PropertyDescriptor(property, aClass); // if property=value it looks for setValue() or getValue()
            method = desc.getWriteMethod();
         }
         catch (IntrospectionException e) { // try operations like 'addProperty' without set/get prefix
         }
         if (method == null) {
            Method[] m = aClass.getMethods();
View Full Code Here

        {
            writeMethod = (Method)classWriteMethods.get(name);
        }
        if (writeMethod == null)
        {
            final PropertyDescriptor descriptor = this.getPropertyDescriptor(
                    object.getClass(),
                    name);
            writeMethod = descriptor != null ? descriptor.getWriteMethod() : null;
            if (writeMethod != null)
            {
                classWriteMethods.put(
                    name,
                    writeMethod);
View Full Code Here

        {
            readMethod = (Method)classReadMethods.get(name);
        }
        if (readMethod == null)
        {
            final PropertyDescriptor descriptor = this.getPropertyDescriptor(
                    object.getClass(),
                    name);
            readMethod = descriptor != null ? descriptor.getReadMethod() : null;
            if (readMethod != null)
            {
                classReadMethods.put(
                    name,
                    readMethod);
View Full Code Here

     */
    private PropertyDescriptor getPropertyDescriptor(
        final Class type,
        final String name)
    {
        PropertyDescriptor propertyDescriptor = null;
        Map classPropertyDescriptors = (Map)this.propertyDescriptorsCache.get(type);
        if (classPropertyDescriptors == null)
        {
            classPropertyDescriptors = new HashMap();
        }
        else
        {
            propertyDescriptor = (PropertyDescriptor)classPropertyDescriptors.get(name);
        }
       
        if (propertyDescriptor == null)
        {
            try
            {
                final PropertyDescriptor[] descriptors =
                    java.beans.Introspector.getBeanInfo(type).getPropertyDescriptors();
                final int descriptorNumber = descriptors.length;
                for (int ctr = 0; ctr < descriptorNumber; ctr++)
                {
                    final PropertyDescriptor descriptor = descriptors[ctr];

                    // - handle names that start with a lowercased letter and have an uppercase as the second letter
                    final String compareName =
                        name.matches("\\p{Lower}\\p{Upper}.*") ? StringUtils.capitalize(name) : name;
                    if (descriptor.getName().equals(compareName))
                    {
                        propertyDescriptor = descriptor;
                        break;
                    }
                }
                if (propertyDescriptor == null && name.indexOf(NESTED_DELIMITER) != -1)
                {
                    int dotIndex = name.indexOf(NESTED_DELIMITER);
                    if (dotIndex >= name.length())
                    {
                        throw new IntrospectorException("Invalid property call --> '" + name + "'");
                    }
                    final PropertyDescriptor nextInstance =
                        this.getPropertyDescriptor(
                            type,
                            name.substring(
                                0,
                                dotIndex));
                    propertyDescriptor =
                        this.getPropertyDescriptor(
                            nextInstance.getPropertyType(),
                            name.substring(dotIndex + 1));
                }
            }
            catch (final java.beans.IntrospectionException exception)
            {
View Full Code Here

        if (object != null || name != null || name.length() > 0)
        {
            Class expectedType = null;
            if (value != null)
            {
                final PropertyDescriptor descriptor = this.getPropertyDescriptor(
                        object.getClass(),
                        name);
                if (descriptor != null)
                {
                    expectedType = this.getPropertyDescriptor(
View Full Code Here

TOP

Related Classes of java.beans.PropertyDescriptor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.