Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
  * JBoss, Home of Professional Open Source
  * Copyright 2006, JBoss Inc., and individual contributors as indicated
  * by the @authors tag. See the copyright.txt in the distribution for a
  * full listing of individual contributors.
  *
  * This is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Lesser General Public License as
  * published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this software; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 */
 package org.jboss.xb.builder.runtime;
 
 
CollectionPropertyWildcardHandler.

Author(s):
Adrian Brock
Version:
$Revision: 1.1 $
 
 public class ChildWildcardHandler  implements ParticleHandler
 {
   
The property
 
    private PropertyInfo propertyInfo;
   
   
The wrapper type
 
    private BeanInfo beanInfo;
   
   
The wrapper property
 
    private String property;

   
Create a new ChildCollectionWildcardHandler.

Parameters:
propertyInfo the property info
Throws:
java.lang.IllegalArgumentException for a null parameter
 
    public ChildWildcardHandler(PropertyInfo propertyInfo)
    {
       if (propertyInfo == null)
          throw new IllegalArgumentException("Null propertyInfo");
       this. = propertyInfo;
    }

   
Create a new ChildCollectionWildcardHandler.

Parameters:
propertyInfo the property info
beanInfo the wrapper class
property the wrapper property
Throws:
java.lang.IllegalArgumentException for a null parameter
 
    public ChildWildcardHandler(PropertyInfo propertyInfoBeanInfo beanInfoString property)
    {
       if (propertyInfo == null)
          throw new IllegalArgumentException("Null propertyInfo");
       if (beanInfo == null)
          throw new IllegalArgumentException("Null beanInfo");
       if (property == null)
          throw new IllegalArgumentException("Null property");
       this. = propertyInfo;
       this. = beanInfo;
       this. = property;
    }
    
    public Object startParticle(Object parentQName elementNameParticleBinding particleAttributes attrsNamespaceContext nsCtx)
    {
       return parent;
    }
 
    @SuppressWarnings("unchecked")
    public void setParent(Object parentObject oQName elementNameParticleBinding particleParticleBinding parentParticle)
    {
       BeanAdapter beanAdapter = (BeanAdapterparent;
       if ( != null)
       {
          try
          {
            ClassInfo classInfo = (ClassInfo.getType();//beanInfo.getClassInfo();
            TypeInfo valueType = classInfo.getTypeInfoFactory().getTypeInfo(o.getClass());
            if (classInfo.isAssignableFrom(valueType) == false)
            {
               Object wrapper = .newInstance();
               .setProperty(wrappero);
               o = wrapper;
            }
         }
         catch (Throwable t)
         {
            throw new RuntimeException("Error wrapping object in " + .getName()); 
         }
      }
      try
      {
         beanAdapter.set(o);
      }
      catch (Throwable t)
      {
         throw new RuntimeException("Error setting wildcard property " + .getName() + " parent=" + BuilderUtil.toDebugString(parent) + " child=" + BuilderUtil.toDebugString(o));
      }
   }
   public Object endParticle(Object oQName elementNameParticleBinding particle)
   {
      return o;
   }
New to GrepCode? Check out our FAQ X