Package org.jboss.xb.spi

Examples of org.jboss.xb.spi.BeanAdapter


   }

   @Override
   public WrapperBeanAdapter newInstance()
   {
      BeanAdapter adapter = wrapped.newInstance();
      return new WrapperBeanAdapter(this, adapter);
   }
View Full Code Here


         wrapper.setChildParticle(particle);
         wrapper.setParentParticle(parentParticle);
         return;
      }

      BeanAdapter beanAdapter;
      if (parent instanceof ArrayWrapper)
         beanAdapter = (BeanAdapter) ((ArrayWrapper) parent).getParent();
      else
         beanAdapter = (BeanAdapter) parent;
      AbstractPropertyHandler propertyHandler = beanAdapter.getPropertyHandler(qName);
      if (propertyHandler == null)
      {
         AbstractPropertyHandler wildcardHandler = beanAdapter.getWildcardHandler();
         if (wildcardHandler != null)
         {
            if (o != null && o instanceof ArrayWrapper)
            {
               ArrayWrapper wrapper = (ArrayWrapper) o;
               wildcardHandler.doHandle(beanAdapter, wrapper, wrapper.getElementName());
               return;
            }
         }
         TermBinding element = term;
         if (element.getSchema().isStrictSchema())
         {
            throw new RuntimeException("QName " + qName + " unknown property parent=" + BuilderUtil.toDebugString(parent) + " child=" + BuilderUtil.toDebugString(o) + " available=" + beanAdapter.getAvailable());
         }
         if (trace)
            log.trace("QName " + qName + " unknown property parent=" + BuilderUtil.toDebugString(parent) + " child=" + BuilderUtil.toDebugString(o));
         return;
      }
View Full Code Here

   public Object endParticle(Object o, QName qName, ParticleBinding particle)
   {
      if (trace)
         log.trace("endElement " + qName + " o=" + BuilderUtil.toDebugString(o));

      BeanAdapter beanAdapter = (BeanAdapter) o;
      return beanAdapter.getValue();
   }
View Full Code Here

   }

   @SuppressWarnings("unchecked")
   public void setParent(Object parent, Object o, QName elementName, ParticleBinding particle, ParticleBinding parentParticle)
   {
      BeanAdapter beanAdapter = (BeanAdapter) parent;
      if (beanInfo != null)
      {
         try
         {
            ClassInfo classInfo = (ClassInfo) propertyInfo.getType();//beanInfo.getClassInfo();
            TypeInfo valueType = classInfo.getTypeInfoFactory().getTypeInfo(o.getClass());
            if (classInfo.isAssignableFrom(valueType) == false)
            {
               Object wrapper = beanInfo.newInstance();
               beanInfo.setProperty(wrapper, property, o);
               o = wrapper;
            }
         }
         catch (Throwable t)
         {
            throw new RuntimeException("Error wrapping object in " + beanInfo.getName());
         }
      }
      try
      {
         beanAdapter.set(propertyInfo, o);
      }
      catch (Throwable t)
      {
         throw new RuntimeException("Error setting wildcard property " + propertyInfo.getName() + " parent=" + BuilderUtil.toDebugString(parent) + " child=" + BuilderUtil.toDebugString(o));
      }
View Full Code Here

  
   @Override
   @SuppressWarnings("unchecked")
   public void add(Object parent, Object child, QName qName)
   {
      BeanAdapter beanAdapter = (BeanAdapter) parent;
      Collection<Object> collection = (Collection<Object>) beanAdapter.getValue();
      collection.add(child);
   }
View Full Code Here

   }

   @SuppressWarnings("unchecked")
   public void setParent(Object parent, Object o, QName elementName, ParticleBinding particle, ParticleBinding parentParticle)
   {
      BeanAdapter beanAdapter = (BeanAdapter) parent;
      Collection<Object> collection = (Collection<Object>) beanAdapter.getValue();
     
      if (beanInfo != null)
      {
         try
         {
View Full Code Here

   public void handle(PropertyInfo propertyInfo, TypeInfo propertyType, Object parent, Object child, QName qName)
   {
      if(trace)
         log.trace("handle entry " + qName + ", property=" + propertyInfo.getName() + ", parent=" + parent + ", child=" + child);
     
      BeanAdapter beanAdapter = (BeanAdapter) parent;
     
      Map<Object, Object> m = null;
      if(mapFactory == null)
      {
         // it's wrapped, so the parent expected to be a map
         m = (Map<Object, Object>) beanAdapter.getValue();
      }
      else
      {
         try
         {
            if (propertyInfo.getGetter() != null)
               m = (Map<Object, Object>) beanAdapter.get(propertyInfo);
         }
         catch (Throwable t)
         {
            throw new RuntimeException("QName " + qName + " error getting map property " + propertyInfo.getName()
                  + " for " + BuilderUtil.toDebugString(parent), t);
         }

         // No map so create one
         if (m == null)
         {
            try
            {
               m = mapFactory.createMap();
            }
            catch (Throwable t)
            {
               throw new RuntimeException("QName " + qName + " error creating map: " + propertyType.getName(), t);
            }

            try
            {
               beanAdapter.set(propertyInfo, m);
            }
            catch (Throwable t)
            {
               throw new RuntimeException("QName " + qName + " error setting map property " + propertyInfo.getName()
                     + " for " + BuilderUtil.toDebugString(parent) + " with value " + BuilderUtil.toDebugString(m), t);
View Full Code Here

               Object wrapper = beanInfo.newInstance();
               beanInfo.setProperty(wrapper, property, value);
               value = wrapper;
            }
         }
         BeanAdapter beanAdapter = (BeanAdapter) owner;
         beanAdapter.set(propertyInfo, value);
      }
      catch (Throwable t)
      {
         throw new RuntimeException("QName " + qName + " error setting characters " + propertyInfo.getName() + " with value " + BuilderUtil.toDebugString(value) + " to " + BuilderUtil.toDebugString(owner) + " property=" + propertyInfo.getName(), t);
      }
View Full Code Here

   {
      ValueAdapter valueAdapter = binding.getValueAdapter();
      if (valueAdapter != null)
         value = valueAdapter.cast(value, null);
     
      BeanAdapter parent = (BeanAdapter) owner;
      doHandle(parent, value, attrName);
   }
View Full Code Here

      doHandle(parent, value, attrName);
   }

   public void handle(PropertyInfo propertyInfo, TypeInfo propertyType, Object parent, Object child, QName name)
   {
      BeanAdapter beanAdapter = (BeanAdapter) parent;

      Map<QName, Object> map = null;
      try
      {
         if (propertyInfo.getGetter() != null)
            map = (Map<QName, Object>) beanAdapter.get(propertyInfo);
      }
      catch (Throwable t)
      {
         throw new RuntimeException("Error getting map for property " + propertyInfo.getName()
               + " bound to any attribute from " + BuilderUtil.toDebugString(parent), t);
      }

      // No map so create one
      if (map == null)
      {
         map = new HashMap<QName, Object>();
         try
         {
            beanAdapter.set(propertyInfo, map);
         }
         catch (Throwable t)
         {
            throw new RuntimeException("Error setting map property " + propertyInfo.getName()
                  + " bound to any attribute for " + BuilderUtil.toDebugString(parent) + " with value " + BuilderUtil.toDebugString(map), t);
View Full Code Here

TOP

Related Classes of org.jboss.xb.spi.BeanAdapter

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.