Package org.jboss.javabean.plugins.xml.Common

Examples of org.jboss.javabean.plugins.xml.Common.Property


    */
   public void add(Object parent, Object child, QName name)
   {
      Holder holder = (Holder) parent;
      Object parentValue = holder.getValue();
      Property prop = (Property) child;
      Object value = prop.getValue();
      String property = prop.getProperty();

      try
      {
         if( parentValue instanceof Ctor )
         {
            Ctor ctor = (Ctor) parentValue;
            if( ctor.isCtorWasDeclared() )
            {
               BeanInfo beanInfo = ConfigurationUtil.getBeanInfo(ctor.getClassName());
               PropertyInfo propertyInfo = beanInfo.getProperty(property);
               value = ConfigurationUtil.convertValue(propertyInfo, prop.getType(), value);
               ctor.addParam(propertyInfo.getType().getName(), value);
            }
            else
            {
               // There was no explicit ctor to create the bean and reset the parent value
               parentValue = ctor.newInstance();
               holder.setValue(parentValue);
               add(parent, child, name);
            }
         }
         else
         {
            BeanInfo beanInfo = ConfigurationUtil.getBeanInfo(parentValue);
            value = ConfigurationUtil.convertValue(parentValue, property, prop.getType(), value);
            beanInfo.setProperty(parentValue, property, value);
         }
      }
      catch (RuntimeException e)
      {
View Full Code Here


         public void add(Object parent, Object child, QName name)
         {
            Holder holder = (Holder) parent;
            Object parentValue = holder.getValue();
           
            Property prop = (Property) child;
            String property = prop.getProperty();
            Object value = prop.getValue();
            try
            {
               BeanInfo info = ConfigurationUtil.getBeanInfo(parentValue.getClass());
               value = ConfigurationUtil.convertValue(parentValue, property, prop.getType(), value);
               info.setProperty(parentValue, property, value);
            }
            catch (RuntimeException e)
            {
               throw e;
            }
            catch (Error e)
            {
               throw e;
            }
            catch (Throwable t)
            {
               throw new RuntimeException("Error setting property " + property + " on object" + parentValue + " with value " + value, t);
            }
         }
      });

      // property binding
      TypeBinding propertyType = schema.getType(propertyTypeQName);
      propertyType.setHandler(new DefaultElementHandler()
      {
        
         public Object startElement(Object parent, QName name, ElementBinding element)
         {
            return new Property();
         }

         public void attributes(Object o, QName elementName, ElementBinding element, Attributes attrs, NamespaceContext nsCtx)
         {
            Property property = (Property) o;
            for (int i = 0; i < attrs.getLength(); ++i)
            {
               String localName = attrs.getLocalName(i);
               if ("name".equals(localName))
                  property.setProperty(attrs.getValue(i));
               else if ("class".equals(localName))
                  property.setType(attrs.getValue(i));
            }
         }
      });

      return schema;
View Full Code Here

   /** The handler */
   public static final PropertyHandler HANDLER = new PropertyHandler();

   public Object startElement(Object parent, QName name, ElementBinding element)
   {
      return new Property();
   }
View Full Code Here

      return new Property();
   }

   public void attributes(Object o, QName elementName, ElementBinding element, Attributes attrs, NamespaceContext nsCtx)
   {
      Property property = (Property) o;
      for (int i = 0; i < attrs.getLength(); ++i)
      {
         String localName = attrs.getLocalName(i);
         if ("name".equals(localName))
            property.setProperty(attrs.getValue(i));
         else if ("class".equals(localName))
            property.setType(attrs.getValue(i));
      }
   }
View Full Code Here

TOP

Related Classes of org.jboss.javabean.plugins.xml.Common.Property

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.