Package org.jboss.xb.binding.introspection

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


/*      */
/*      */         }
/*      */
/* 1346 */         if (propName != null)
/*      */         {
/* 1348 */           FieldInfo fieldInfo = FieldInfo.getFieldInfo(parentClass, propName, false);
/* 1349 */           Class fieldType = fieldInfo == null ? null : fieldInfo.getType();
/*      */
/* 1351 */           if ((fieldType == null) || (Modifier.isAbstract(fieldType.getModifiers())) || (Modifier.isInterface(fieldType.getModifiers())) || (fieldType.isArray()) || (Collection.class.isAssignableFrom(fieldType)))
/*      */           {
/* 1357 */             clsName = classFromQName(element);
/*      */           }
View Full Code Here


/* 175 */           throw e;
/*     */         }
/*     */       }
/*     */     }
/*     */
/* 180 */     FieldInfo fieldInfo = null;
/* 181 */     if (mapping != null)
/*     */     {
/* 183 */       fieldInfo = mapping.fieldInfo;
/*     */     }
/*     */
/* 186 */     Object value = null;
/* 187 */     if ((fieldInfo != null) && ((!forComplexType) || ((forComplexType) && (!writeAsValue(fieldInfo.getType())))))
/*     */     {
/* 189 */       value = fieldInfo.getValue(o);
/*     */     }
/*     */
/* 192 */     if ((value != null) && (mapping != null) && (mapping.converter != null))
/*     */     {
/* 194 */       value = mapping.converter.marshal(value);
View Full Code Here

/*     */       try
/*     */       {
/* 204 */         if (!(o instanceof Collection))
/*     */         {
/* 206 */           ElementToFieldMapping fieldMapping = (ElementToFieldMapping)this.elementToFieldMapping.get(new ElementToFieldMappingKey(localName, o.getClass()));
/*     */           FieldInfo fieldInfo;
/*     */           FieldInfo fieldInfo;
/* 211 */           if (fieldMapping != null)
/*     */           {
/* 213 */             fieldInfo = fieldMapping.fieldInfo;
/*     */           }
/*     */           else
/*     */           {
/* 217 */             String fieldName = Util.xmlNameToFieldName(localName, true);
/* 218 */             fieldInfo = FieldInfo.getFieldInfo(o.getClass(), fieldName, true);
/*     */           }
/*     */
/* 221 */           child = get(o, localName, fieldInfo);
/*     */         }
/*     */
/* 224 */         if (child == null)
/*     */         {
/* 226 */           child = newInstance(mapping.cls);
/*     */         }
/*     */
/* 229 */         if (attrs != null)
/*     */         {
/* 231 */           for (int i = 0; i < attrs.getLength(); i++)
/*     */           {
/* 233 */             if (attrs.getLocalName(i).length() <= 0)
/*     */               continue;
/* 235 */             if (attrs.getQName(i).startsWith("xsi:"))
/*     */               continue;
/* 237 */             setAttribute(child, attrs.getLocalName(i), attrs.getValue(i), ctx);
/*     */           }
/*     */
/*     */         }
/*     */
/*     */       }
/*     */       catch (RuntimeException e)
/*     */       {
/* 245 */         throw e;
/*     */       }
/*     */       catch (Exception e)
/*     */       {
/* 249 */         throw new NestedRuntimeException("newChild failed for o=" + o + ", uri=" + namespaceURI + ", local=" + localName + ", attrs=" + attrs, e);
/*     */       }
/*     */
/*     */     }
/* 260 */     else if ((o instanceof Collection))
/*     */     {
/* 262 */       child = create(namespaceURI, localName, type);
/*     */     }
/*     */     else
/*     */     {
/*     */       Class oCls;
/*     */       Class oCls;
/* 267 */       if ((o instanceof Immutable))
/*     */       {
/* 269 */         oCls = ((Immutable)o).cls;
/*     */       }
/*     */       else
/*     */       {
/* 273 */         oCls = o.getClass();
/*     */       }
/*     */
/* 276 */       String fieldName = Util.xmlNameToFieldName(localName, true);
/* 277 */       FieldInfo fieldInfo = FieldInfo.getFieldInfo(oCls, fieldName, true);
/* 278 */       if (Collection.class.isAssignableFrom(fieldInfo.getType()))
/*     */       {
/* 280 */         child = get(o, localName, fieldInfo);
/*     */
/* 284 */         Object item = null;
/* 285 */         if ((type == null) || ((type != null) && (type.getTypeCategory() == 15)))
/*     */         {
/* 287 */           item = create(namespaceURI, localName, type);
/*     */         }
/*     */
/* 290 */         if (item != null)
/*     */         {
/* 292 */           if (child == null)
/*     */           {
/* 294 */             setChild(new ArrayList(), o, localName);
/*     */           }
/* 296 */           child = item;
/*     */         }
/* 300 */         else if (child == null)
/*     */         {
/* 302 */           child = new ArrayList();
/*     */         }
/*     */
/*     */       }
/* 306 */       else if (!Util.isAttributeType(fieldInfo.getType()))
/*     */       {
/* 309 */         ElementToFieldMapping fieldMapping = (ElementToFieldMapping)this.elementToFieldMapping.get(new ElementToFieldMappingKey(localName, o.getClass()));
/*     */
/* 312 */         TypeBinding converter = fieldMapping == null ? null : fieldMapping.converter;
/*     */
/* 315 */         if (converter == null)
/*     */         {
/* 317 */           child = newInstance(fieldInfo.getType());
/*     */         }
/*     */       }
/*     */
/*     */     }
/*     */
View Full Code Here

/*     */       else
/*     */       {
/* 433 */         Class parentCls = (parent instanceof Immutable) ? ((Immutable)parent).cls : parent.getClass();
/*     */
/* 437 */         String fieldName = Util.xmlNameToFieldName(localName, true);
/* 438 */         FieldInfo fieldInfo = FieldInfo.getFieldInfo(parentCls, fieldName, false);
/* 439 */         if (trace)
/*     */         {
/* 441 */           log.trace("Add " + value + " to property " + fieldName + " of " + parentCls);
/*     */         }
/*     */
/* 444 */         if (fieldInfo != null)
/*     */         {
/* 446 */           if ((!(child instanceof Collection)) && (Collection.class.isAssignableFrom(fieldInfo.getType())))
/*     */           {
/* 448 */             Object o = get(parent, localName, fieldInfo);
/* 449 */             Collection col = (Collection)o;
/* 450 */             if (trace)
/*     */             {
View Full Code Here

/*     */         {
/* 507 */           oCls = o.getClass();
/*     */         }
/*     */
/* 510 */         String fieldName = Util.xmlNameToFieldName(localName, true);
/* 511 */         FieldInfo fieldInfo = FieldInfo.getFieldInfo(oCls, fieldName, true);
/*     */
/* 513 */         fieldValue = SimpleTypeBindings.unmarshal(value, fieldInfo.getType());
/* 514 */         set(o, fieldValue, localName, fieldInfo);
/*     */       }
/*     */     }
/*     */   }
View Full Code Here

      }
   }

   public void testGetterSetterAccess() throws Exception
   {
      FieldInfo fieldInfo = ClassInfos.getClassInfo(A.class).getFieldInfo("field1", true);
      A a = new A();
      assertNull(fieldInfo.getValue(a));
      a.setField1("val1");
      assertEquals("val1", fieldInfo.getValue(a));
      fieldInfo.setValue(a, "val2");
      assertEquals("val2", fieldInfo.getValue(a));
      assertEquals("val2", a.getField1());
   }
View Full Code Here

      assertEquals("val2", a.getField1());
   }

   public void testFieldAccess() throws Exception
   {
      FieldInfo fieldInfo = ClassInfos.getClassInfo(A.class).getFieldInfo("field2", true);
      A a = new A();
      assertNull(fieldInfo.getValue(a));
      a.field2 = "val1";
      assertEquals("val1", fieldInfo.getValue(a));
      fieldInfo.setValue(a, "val2");
      assertEquals("val2", fieldInfo.getValue(a));
      assertEquals("val2", a.field2);
   }
View Full Code Here

      assertEquals("val2", fieldInfo.getValue(a));
      assertEquals("val2", a.field2);
   }
   public void testReadWriteMethodAccess() throws Exception
   {
      FieldInfo fieldInfo = ClassInfos.getClassInfo(A.class).getFieldInfo("field3", true);
      A a = new A();
      assertNull(fieldInfo.getValue(a));
      a.writeField3("val1");
      assertEquals("val1", fieldInfo.getValue(a));
      fieldInfo.setValue(a, "val2");
      assertEquals("val2", fieldInfo.getValue(a));
      assertEquals("val2", a.readField3());
   }
View Full Code Here

         ((Collection<Object>)o).add(value);
      }
      else
      {
         String fieldName = Util.xmlNameToFieldName(elementName.getLocalPart(), ignoreLowLine);
         FieldInfo fieldInfo = FieldInfo.getFieldInfo(o.getClass(), fieldName, true);
         fieldInfo.setValue(o, value);
      }
   }
View Full Code Here

            {
               //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

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.