Examples of BeanAdapter


Examples of org.apache.pivot.beans.BeanAdapter

        } catch (SerializationException e) {
            e.printStackTrace();
        }

        EnumBean enumBean = new EnumBean();
        BeanAdapter ba = new BeanAdapter(enumBean);

        ba.put("orientationField", Orientation.HORIZONTAL);
        dumpField(enumBean, ba);
        ba.put("orientationField", "vertical");
        dumpField(enumBean, ba);

        ba.put("orientation", Orientation.HORIZONTAL);
        dumpSetter(enumBean, ba);
        ba.put("orientation", Orientation.VERTICAL);
        dumpSetter(enumBean, ba);
        ba.put("orientation", null);
        dumpSetter(enumBean, ba);

        // Force an error to check the IllegalArgumentException message
        // ba.put("orientation", Vote.APPROVE);
    }
View Full Code Here

Examples of org.jboss.xb.spi.BeanAdapter

   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
TOP
Copyright © 2018 www.massapi.com. 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.