Package org.jboss.xb.spi

Examples of org.jboss.xb.spi.BeanAdapter


/*     */     }
/*     */   }
/*     */
/*     */   public void handle(PropertyInfo propertyInfo, TypeInfo propertyType, Object parent, Object child, QName qName)
/*     */   {
/* 112 */     BeanAdapter beanAdapter = (BeanAdapter)parent;
/*     */
/* 114 */     Collection c = null;
/*     */     try
/*     */     {
/* 117 */       if (propertyInfo.getGetter() != null)
/* 118 */         c = (Collection)beanAdapter.get(propertyInfo);
/*     */     }
/*     */     catch (Throwable t)
/*     */     {
/* 122 */       throw new RuntimeException("QName " + qName + " error getting collection property " + propertyInfo.getName() + " for " + BuilderUtil.toDebugString(parent), t);
/*     */     }
/*     */
/* 126 */     if (c == null)
/*     */     {
/*     */       try
/*     */       {
/* 130 */         c = this.colFactory.createCollection();
/*     */       }
/*     */       catch (Throwable t)
/*     */       {
/* 134 */         throw new RuntimeException("QName " + qName + " error creating collection: " + propertyType.getName(), t);
/*     */       }
/*     */
/*     */       try
/*     */       {
/* 139 */         beanAdapter.set(propertyInfo, c);
/*     */       }
/*     */       catch (Throwable t)
/*     */       {
/* 143 */         throw new RuntimeException("QName " + qName + " error setting collection property " + propertyInfo.getName() + " for " + BuilderUtil.toDebugString(parent) + " with value " + BuilderUtil.toDebugString(c), t);
/*     */       }
View Full Code Here


/* 153 */       wrapper.add(o);
/* 154 */       wrapper.setChildParticle(particle);
/* 155 */       wrapper.setParentParticle(parentParticle);
/* 156 */       return;
/*     */     }
/*     */     BeanAdapter beanAdapter;
/*     */     BeanAdapter beanAdapter;
/* 160 */     if ((parent instanceof ArrayWrapper))
/* 161 */       beanAdapter = (BeanAdapter)((ArrayWrapper)parent).getParent();
/*     */     else
/* 163 */       beanAdapter = (BeanAdapter)parent;
/* 164 */     AbstractPropertyHandler propertyHandler = beanAdapter.getPropertyHandler(qName);
/* 165 */     if (propertyHandler == null)
/*     */     {
/* 167 */       AbstractPropertyHandler wildcardHandler = beanAdapter.getWildcardHandler();
/* 168 */       if (wildcardHandler != null)
/*     */       {
/* 170 */         if ((o != null) && ((o instanceof ArrayWrapper)))
/*     */         {
/* 172 */           ArrayWrapper wrapper = (ArrayWrapper)o;
/* 173 */           wildcardHandler.doHandle(beanAdapter, wrapper, wrapper.getElementName());
/* 174 */           return;
/*     */         }
/*     */       }
/* 177 */       TermBinding element = term;
/* 178 */       if (element.getSchema().isStrictSchema())
/*     */       {
/* 180 */         throw new RuntimeException("QName " + qName + " unknown property parent=" + BuilderUtil.toDebugString(parent) + " child=" + BuilderUtil.toDebugString(o) + " available=" + beanAdapter.getAvailable());
/*     */       }
/* 182 */       if (this.trace)
/* 183 */         this.log.trace("QName " + qName + " unknown property parent=" + BuilderUtil.toDebugString(parent) + " child=" + BuilderUtil.toDebugString(o));
/* 184 */       return;
/*     */     }
View Full Code Here

/*     */   public Object endParticle(Object o, QName qName, ParticleBinding particle)
/*     */   {
/* 223 */     if (this.trace) {
/* 224 */       this.log.trace("endElement " + qName + " o=" + BuilderUtil.toDebugString(o));
/*     */     }
/* 226 */     BeanAdapter beanAdapter = (BeanAdapter)o;
/* 227 */     return beanAdapter.getValue();
/*     */   }
View Full Code Here

/* 56 */     return parent;
/*    */   }
/*    */
/*    */   public void setParent(Object parent, Object o, QName elementName, ParticleBinding particle, ParticleBinding parentParticle)
/*    */   {
/* 61 */     BeanAdapter beanAdapter = (BeanAdapter)parent;
/* 62 */     AbstractPropertyHandler propertyHandler = beanAdapter.getPropertyHandler(elementName);
/* 63 */     if (propertyHandler != null)
/* 64 */       propertyHandler.doHandle(parent, o, elementName);
/*    */     else
/* 66 */       doHandle(parent, o, elementName);
/*    */   }
View Full Code Here

/*  89 */     return parent;
/*     */   }
/*     */
/*     */   public void setParent(Object parent, Object o, QName elementName, ParticleBinding particle, ParticleBinding parentParticle)
/*     */   {
/*  95 */     BeanAdapter beanAdapter = (BeanAdapter)parent;
/*  96 */     if (this.beanInfo != null)
/*     */     {
/*     */       try
/*     */       {
/* 100 */         ClassInfo classInfo = this.beanInfo.getClassInfo();
/* 101 */         TypeInfo valueType = classInfo.getTypeInfoFactory().getTypeInfo(o.getClass());
/* 102 */         if (!classInfo.isAssignableFrom(valueType))
/*     */         {
/* 104 */           Object wrapper = this.beanInfo.newInstance();
/* 105 */           this.beanInfo.setProperty(wrapper, this.property, o);
/* 106 */           o = wrapper;
/*     */         }
/*     */       }
/*     */       catch (Throwable t)
/*     */       {
/* 111 */         throw new RuntimeException("Error wrapping object in " + this.beanInfo.getName());
/*     */       }
/*     */     }
/*     */     try
/*     */     {
/* 116 */       beanAdapter.set(this.propertyInfo, o);
/*     */     }
/*     */     catch (Throwable t)
/*     */     {
/* 120 */       throw new RuntimeException("Error setting wildcard property " + this.propertyInfo.getName() + " parent=" + BuilderUtil.toDebugString(parent) + " child=" + BuilderUtil.toDebugString(o));
/*     */     }
View Full Code Here

/*    */ {
/* 40 */   public static final ChildCollectionInterceptor SINGLETON = new ChildCollectionInterceptor();
/*    */
/*    */   public void add(Object parent, Object child, QName qName)
/*    */   {
/* 46 */     BeanAdapter beanAdapter = (BeanAdapter)parent;
/* 47 */     Collection collection = (Collection)beanAdapter.getValue();
/* 48 */     collection.add(child);
/*    */   }
View Full Code Here

/*  80 */     return parent;
/*     */   }
/*     */
/*     */   public void setParent(Object parent, Object o, QName elementName, ParticleBinding particle, ParticleBinding parentParticle)
/*     */   {
/*  86 */     BeanAdapter beanAdapter = (BeanAdapter)parent;
/*  87 */     Collection collection = (Collection)beanAdapter.getValue();
/*     */
/*  89 */     if (this.beanInfo != null)
/*     */     {
/*     */       try
/*     */       {
View Full Code Here

/* 65 */       wrapper.setChildParticle(particle);
/* 66 */       wrapper.setParentParticle(parentParticle);
/* 67 */       return;
/*    */     }
/*    */
/* 70 */     BeanAdapter beanAdapter = (BeanAdapter)parent;
/* 71 */     AbstractPropertyHandler propertyHandler = beanAdapter.getPropertyHandler(elementName);
/* 72 */     if (propertyHandler != null)
/* 73 */       propertyHandler.doHandle(parent, o, elementName);
/*    */     else
/* 75 */       doHandle(parent, o, elementName);
/*    */   }
View Full Code Here

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

   public void handle(PropertyInfo propertyInfo, TypeInfo propertyType, Object parent, Object child, QName qName)
   {
      if (componentType != null && child != null && componentType.isInstance(child) == false)
         throw new IllegalArgumentException("Child is not an instance of " + componentType + ", child: " + child);

      BeanAdapter beanAdapter = (BeanAdapter) parent;
     
      Collection c = null;
      try
      {
         if (propertyInfo.getGetter() != null)
            c = (Collection) beanAdapter.get(propertyInfo);
      }
      catch (Throwable t)
      {
         throw new RuntimeException("QName " + qName + " error getting collection property " + propertyInfo.getName() + " for " + BuilderUtil.toDebugString(parent), t);
      }
     
      // No collection so create one
      if (c == null)
      {
         try
         {
            c = colFactory.createCollection();
         }
         catch (Throwable t)
         {
            throw new RuntimeException("QName " + qName + " error creating collection: " + propertyType.getName(), t);
         }

         try
         {
            beanAdapter.set(propertyInfo, c);
         }
         catch (Throwable t)
         {
            throw new RuntimeException("QName " + qName + " error setting collection property " + propertyInfo.getName() + " for " + BuilderUtil.toDebugString(parent) + " with value " + BuilderUtil.toDebugString(c), 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.