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

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

/*  61 */     if (fieldName == null)
/*     */     {
/*  63 */       fieldName = Util.xmlNameToFieldName(qName.getLocalPart(), schema.isIgnoreLowLine());
/*     */     }
/*     */
/*  67 */     FieldInfo fieldInfo = FieldInfo.getFieldInfo(owner.getClass(), fieldName, (binding.getRequired()) && (!schema.isIgnoreUnresolvedFieldOrClass()));
/*     */
/*  70 */     Object value = null;
/*  71 */     if (fieldInfo != null)
/*     */     {
/*  73 */       value = fieldInfo.getValue(owner);
/*     */     }
/*     */
/*  76 */     return value;
/*     */   }
View Full Code Here

/*     */
/*     */ public class RtUtil
/*     */ {
/*     */   public static void add(Object o, Object value, String prop, String colType, boolean ignoreNotFoundField, ValueAdapter valueAdapter)
/*     */   {
/*  55 */     FieldInfo fieldInfo = FieldInfo.getFieldInfo(o.getClass(), prop, !ignoreNotFoundField);
/*  56 */     if (fieldInfo == null)
/*     */     {
/*  58 */       return;
/*     */     }
/*     */
/*  61 */     Class fieldType = fieldInfo.getType();
/*     */     boolean arrType;
/*  63 */     if (fieldType.isArray())
/*     */     {
/*  65 */       arrType = true;
/*     */     }
/*     */     else
/*     */     {
/*     */       boolean arrType;
/*  67 */       if (Collection.class.isAssignableFrom(fieldType))
/*     */       {
/*  69 */         arrType = false;
/*     */       }
/*     */       else
/*     */       {
/*  73 */         throw new JBossXBRuntimeException("Expected type for " + prop + " in " + o.getClass() + " is an array or java.util.Collection but was " + fieldType);
/*     */       }
/*     */     }
/*     */     boolean arrType;
/*  79 */     if (valueAdapter != null)
/*     */     {
/*  81 */       value = valueAdapter.cast(value, fieldType);
/*     */     }
/*     */
/*  84 */     if ((!arrType) || (colType != null))
/*     */     {
/*  86 */       Collection col = (Collection)fieldInfo.getValue(o);
/*  87 */       if (col == null)
/*     */       {
/*  89 */         if (colType == null)
/*     */         {
/*  91 */           col = new ArrayList();
/*     */         }
/*     */         else
/*     */         {
/*     */           Class colCls;
/*     */           try {
/*  98 */             colCls = Thread.currentThread().getContextClassLoader().loadClass(colType);
/*     */           }
/*     */           catch (ClassNotFoundException e)
/*     */           {
/* 102 */             throw new JBossXBRuntimeException("Failed to load collection type: " + colType);
/*     */           }
/*     */
/*     */           try
/*     */           {
/* 107 */             col = (Collection)colCls.newInstance();
/*     */           }
/*     */           catch (Exception e)
/*     */           {
/* 111 */             throw new JBossXBRuntimeException("Failed to create an instance of " + colCls);
/*     */           }
/*     */         }
/*     */
/* 115 */         fieldInfo.setValue(o, col);
/*     */       }
/*     */
/* 118 */       col.add(value);
/*     */     }
/*     */     else
/*     */     {
/* 122 */       Object arr = fieldInfo.getValue(o);
/* 123 */       int length = 0;
/* 124 */       if (arr == null)
/*     */       {
/* 126 */         arr = Array.newInstance(fieldType.getComponentType(), 1);
/*     */       }
/*     */       else
/*     */       {
/* 130 */         Object tmp = arr;
/* 131 */         length = Array.getLength(arr);
/* 132 */         arr = Array.newInstance(fieldType.getComponentType(), length + 1);
/* 133 */         System.arraycopy(tmp, 0, arr, 0, length);
/*     */       }
/*     */
/* 136 */       Array.set(arr, length, value);
/* 137 */       fieldInfo.setValue(o, arr);
/*     */     }
/*     */   }
View Full Code Here

/*     */     }
/*     */   }
/*     */
/*     */   public static void set(Object o, Object value, String prop, String colType, boolean ignoreNotFoundField, ValueAdapter valueAdapter)
/*     */   {
/* 148 */     FieldInfo fieldInfo = FieldInfo.getFieldInfo(o.getClass(), prop, !ignoreNotFoundField);
/* 149 */     if (fieldInfo == null)
/*     */     {
/* 151 */       return;
/*     */     }
/*     */
/* 154 */     Class fieldType = fieldInfo.getType();
/*     */
/* 156 */     if (valueAdapter != null)
/*     */     {
/* 158 */       value = valueAdapter.cast(value, fieldType);
/*     */     }
/*     */
/* 161 */     if ((Collection.class.isAssignableFrom(fieldType)) && (!Collection.class.isAssignableFrom(value.getClass())))
/*     */     {
/* 164 */       Collection col = (Collection)fieldInfo.getValue(o);
/* 165 */       if (col == null)
/*     */       {
/* 167 */         if (colType == null)
/*     */         {
/* 169 */           col = new ArrayList();
/*     */         }
/*     */         else
/*     */         {
/*     */           Class colCls;
/*     */           try {
/* 176 */             colCls = Thread.currentThread().getContextClassLoader().loadClass(colType);
/*     */           }
/*     */           catch (ClassNotFoundException e)
/*     */           {
/* 180 */             throw new JBossXBRuntimeException("Failed to load collection type: " + colType);
/*     */           }
/*     */
/*     */           try
/*     */           {
/* 185 */             col = (Collection)colCls.newInstance();
/*     */           }
/*     */           catch (Exception e)
/*     */           {
/* 189 */             throw new JBossXBRuntimeException("Failed to create an instance of " + colCls);
/*     */           }
/*     */         }
/*     */
/* 193 */         fieldInfo.setValue(o, col);
/*     */       }
/*     */
/* 197 */       col.add(value);
/*     */     }
/*     */     else
/*     */     {
/* 228 */       Class valueClass = value == null ? null : value.getClass();
/* 229 */       if ((valueClass != null) && (fieldType.isArray()) && (Collection.class.isAssignableFrom(valueClass)))
/*     */       {
/* 231 */         Collection col = (Collection)value;
/* 232 */         Class compType = fieldType.getComponentType();
/* 233 */         value = Array.newInstance(compType, col.size());
/*     */         int i;
/*     */         Iterator iter;
/* 234 */         if (compType.isPrimitive())
/*     */         {
/* 236 */           i = 0;
/* 237 */           for (iter = col.iterator(); iter.hasNext(); )
/*     */           {
/* 239 */             Array.set(value, i++, iter.next());
/*     */           }
/*     */         }
/*     */         else
/*     */         {
/* 244 */           value = col.toArray((Object[])(Object[])value);
/*     */         }
/*     */       }
/*     */
/* 248 */       fieldInfo.setValue(o, value);
/*     */     }
/*     */   }
View Full Code Here

/* 256 */       ((Collection)o).add(value);
/*     */     }
/*     */     else
/*     */     {
/* 260 */       String fieldName = Util.xmlNameToFieldName(elementName.getLocalPart(), ignoreLowLine);
/* 261 */       FieldInfo fieldInfo = FieldInfo.getFieldInfo(o.getClass(), fieldName, true);
/* 262 */       fieldInfo.setValue(o, value);
/*     */     }
/*     */   }
View Full Code Here

/*      */       }
/*      */
/* 1488 */       String prop = resolvePropertyName();
/* 1489 */       if (prop != null)
/*      */       {
/* 1491 */         FieldInfo fieldInfo = FieldInfo.getFieldInfo(this.parent.getClass(), prop, false);
/* 1492 */         if (fieldInfo != null)
/*      */         {
/* 1494 */           return fieldInfo.getType();
/*      */         }
/*      */       }
/* 1497 */       return null;
/*      */     }
View Full Code Here

/*      */         {
/*  501 */           fieldType = parentClass.getComponentType();
/*      */         }
/*      */         else
/*      */         {
/*  509 */           FieldInfo fieldInfo = FieldInfo.getFieldInfo(parentClass, propName, false);
/*  510 */           if (fieldInfo != null)
/*      */           {
/*  512 */             fieldType = fieldInfo.getType();
/*  513 */             if ((particle.isRepeatable()) && (fieldType.isArray()))
/*      */             {
/*  515 */               fieldType = fieldType.getComponentType();
/*      */             }
/*      */           }
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.