Package org.jboss.xb.binding.introspection

Examples of org.jboss.xb.binding.introspection.FieldInfo


            {
               //fieldType = FieldInfo.getFieldInfo(parentClass, propName, true).getType();
               // this was changed to false because allow overriding of handler.setParent()
               // with an interceptor.add(). See CollectionOverridePropertyUnitTestCase
               // In other words, don't treat it as an array wrapper.
               FieldInfo fieldInfo = FieldInfo.getFieldInfo(parentClass, propName, false);
               if(fieldInfo != null)
               {
                  fieldType = fieldInfo.getType();
                  if (particle.isRepeatable() && fieldType.isArray())
                  {
                     fieldType = fieldType.getComponentType();
                  }
               }
View Full Code Here


               }
            }

            if(propName != null)
            {
               FieldInfo fieldInfo = FieldInfo.getFieldInfo(parentClass, propName, false);
               Class fieldType = fieldInfo == null ? null : fieldInfo.getType();

               if(fieldType == null ||
                  Modifier.isAbstract(fieldType.getModifiers()) ||
                  Modifier.isInterface(fieldType.getModifiers()) ||
                  fieldType.isArray() ||
View Full Code Here

         }
        
         String prop = resolvePropertyName();
         if(prop != null)
         {     
            FieldInfo fieldInfo = FieldInfo.getFieldInfo(parent.getClass(), prop, false);
            if (fieldInfo != null)
            {
               return fieldInfo.getType();
            }
         }
         return null;
      }
View Full Code Here

               throw e;
            }
         }
      }

      FieldInfo fieldInfo = null;
      if(mapping != null)
      {
         fieldInfo = mapping.fieldInfo;
      }

      Object value = null;
      if(fieldInfo != null && (!forComplexType || forComplexType && !writeAsValue(fieldInfo.getType())))
      {
         value = fieldInfo.getValue(o);
      }

      if(value != null && mapping != null && mapping.converter != null)
      {
         value = mapping.converter.marshal(value);
View Full Code Here

   private static Object getJavaValue(String fieldName,
                                      Object o,
                                      boolean forComplexType,
                                      boolean ignoreNotFoundField)
   {
      FieldInfo fieldInfo = FieldInfo.getFieldInfo(o.getClass(), fieldName, !ignoreNotFoundField);
      Object value = null;
      if(fieldInfo != null && (!forComplexType || forComplexType && !writeAsValue(fieldInfo.getType())))
      {
         value = fieldInfo.getValue(o);
      }
      return value;
   }
View Full Code Here

      {
         fieldName =
            Util.xmlNameToFieldName(qName.getLocalPart(), schema.isIgnoreLowLine());
      }

      FieldInfo fieldInfo = FieldInfo.getFieldInfo(
         owner.getClass(), fieldName, binding.getRequired() && !schema.isIgnoreUnresolvedFieldOrClass()
      );
      Object value = null;
      if(fieldInfo != null)
      {
         value = fieldInfo.getValue(owner);
      }

      return value;
   }
View Full Code Here

         }
        
         String prop = resolvePropertyName();
         if(prop != null)
         {     
            FieldInfo fieldInfo = FieldInfo.getFieldInfo(parent.getClass(), prop, false);
            if (fieldInfo != null)
            {
               return fieldInfo.getType();
            }
         }
         return null;
      }
View Full Code Here

                          String prop,
                          String colType,
                          boolean ignoreNotFoundField,
                          ValueAdapter valueAdapter)
   {
      FieldInfo fieldInfo = FieldInfo.getFieldInfo(o.getClass(), prop, !ignoreNotFoundField);
      if(fieldInfo == null)
      {
         return;
      }

      Class<?> fieldType = fieldInfo.getType();
      boolean arrType;
      if(fieldType.isArray())
      {
         arrType = true;
      }
      else if(Collection.class.isAssignableFrom(fieldType))
      {
         arrType = false;
      }
      else
      {
         throw new JBossXBRuntimeException(
            "Expected type for " + prop + " in " + o.getClass() + " is an array or java.util.Collection but was " + fieldType
         );
      }


      if(valueAdapter != null)
      {
         value = valueAdapter.cast(value, fieldType);
      }

      if(!arrType || colType != null)
      {
         Collection<Object> col = (Collection<Object>)fieldInfo.getValue(o);
         if(col == null)
         {
            if(colType == null)
            {
               col = new ArrayList<Object>();
            }
            else
            {
               Class<?> colCls;
               try
               {
                  colCls = Thread.currentThread().getContextClassLoader().loadClass(colType);
               }
               catch(ClassNotFoundException e)
               {
                  throw new JBossXBRuntimeException("Failed to load collection type: " + colType);
               }

               try
               {
                  col = (Collection<Object>)colCls.newInstance();
               }
               catch(Exception e)
               {
                  throw new JBossXBRuntimeException("Failed to create an instance of " + colCls);
               }
            }

            fieldInfo.setValue(o, col);
         }

         col.add(value);
      }
      else
      {
         Object arr = fieldInfo.getValue(o);
         int length = 0;
         if(arr == null)
         {
            arr = Array.newInstance(fieldType.getComponentType(), 1);
         }
         else
         {
            Object tmp = arr;
            length = Array.getLength(arr);
            arr = Array.newInstance(fieldType.getComponentType(), length + 1);
            System.arraycopy(tmp, 0, arr, 0, length);
            //System.out.println("copied array (1)");
         }
         Array.set(arr, length, value);
         fieldInfo.setValue(o, arr);
      }
   }
View Full Code Here

                          String prop,
                          String colType,
                          boolean ignoreNotFoundField,
                          ValueAdapter valueAdapter)
   {
      FieldInfo fieldInfo = FieldInfo.getFieldInfo(o.getClass(), prop, !ignoreNotFoundField);
      if(fieldInfo == null)
      {
         return;
      }

      Class<?> fieldType = fieldInfo.getType();

      if(valueAdapter != null)
      {
         value = valueAdapter.cast(value, fieldType);
      }

      if(Collection.class.isAssignableFrom(fieldType) &&
         !Collection.class.isAssignableFrom(value.getClass()))
      {
         Collection<Object> col = (Collection<Object>)fieldInfo.getValue(o);
         if(col == null)
         {
            if(colType == null)
            {
               col = new ArrayList<Object>();
            }
            else
            {
               Class<?> colCls;
               try
               {
                  colCls = Thread.currentThread().getContextClassLoader().loadClass(colType);
               }
               catch(ClassNotFoundException e)
               {
                  throw new JBossXBRuntimeException("Failed to load collection type: " + colType);
               }

               try
               {
                  col = (Collection<Object>)colCls.newInstance();
               }
               catch(Exception e)
               {
                  throw new JBossXBRuntimeException("Failed to create an instance of " + colCls);
               }
            }

            fieldInfo.setValue(o, col);
         }

         //System.out.println("col.add(value): " + prop + "=" + value);
         col.add(value);
      }
/*
      else if(fieldType.isArray() &&
         value != null &&
         (fieldType.getComponentType().isAssignableFrom(value.getClass()) ||
         fieldType.getComponentType().isPrimitive() &&
         Classes.getPrimitiveWrapper(fieldType.getComponentType()) == value.getClass()
         ))
      {
         Object arr = fieldInfo.getValue(o);
         int length = 0;
         if(arr == null)
         {
            arr = Array.newInstance(fieldType.getComponentType(), 1);
         }
         else
         {
            Object tmp = arr;
            length = Array.getLength(arr);
            arr = Array.newInstance(fieldType.getComponentType(), length + 1);
            System.arraycopy(tmp, 0, arr, 0, length);
            throw new JBossXBRuntimeException("copied array (2)");
         }
         Array.set(arr, length, value);
         fieldInfo.setValue(o, arr);
      }
*/     
      else
      {
         // todo: unmarshalling should produce the right type instead
         Class<? extends Object> valueClass = value == null ? null : value.getClass();
         if (valueClass != null && fieldType.isArray() && Collection.class.isAssignableFrom(valueClass))
         {
            Collection<?> col = (Collection<?>) value;
            Class<?> compType = fieldType.getComponentType();
            value = Array.newInstance(compType, col.size());
            if (compType.isPrimitive())
            {
               int i = 0;
               for (Iterator<?> iter = col.iterator(); iter.hasNext();)
               {
                  Array.set(value, i++, iter.next());
               }
            }
            else
            {
               value = col.toArray((Object[]) value);
            }
         }

         fieldInfo.setValue(o, value);
      }
   }
View Full Code Here

         }
        
         String prop = resolvePropertyName();
         if(prop != null)
         {     
            FieldInfo fieldInfo = FieldInfo.getFieldInfo(parent.getClass(), prop, false);
            if (fieldInfo != null)
            {
               return fieldInfo.getType();
            }
         }
         return null;
      }
View Full Code Here

TOP

Related Classes of org.jboss.xb.binding.introspection.FieldInfo

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.