Package org.jboss.xb.binding.introspection

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


               }
            }

            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


            {
               ElementToFieldMapping fieldMapping = elementToFieldMapping.get(
                  new ElementToFieldMappingKey(localName, o.getClass())
               );

               FieldInfo fieldInfo;
               if(fieldMapping != null)
               {
                  fieldInfo = fieldMapping.fieldInfo;
               }
               else
               {
                  String fieldName = Util.xmlNameToFieldName(localName, true);
                  fieldInfo = FieldInfo.getFieldInfo(o.getClass(), fieldName, true);
               }

               child = get(o, localName, fieldInfo);
            }

            if(child == null)
            {
               child = newInstance(mapping.cls);
            }

            if(attrs != null)
            {
               for(int i = 0; i < attrs.getLength(); ++i)
               {
                  if(attrs.getLocalName(i).length() > 0)
                  {
                     if(!attrs.getQName(i).startsWith("xsi:")) //todo horrible
                     {
                        setAttribute(child, attrs.getLocalName(i), attrs.getValue(i), ctx);
                     }
                  }
               }
            }
         }
         catch(RuntimeException e)
         {
            throw e;
         }
         catch(Exception e)
         {
            throw new NestedRuntimeException("newChild failed for o=" +
               o +
               ", uri=" +
               namespaceURI +
               ", local="
               + localName + ", attrs=" + attrs, e
            );
         }
      }
      else
      {
         if(o instanceof Collection)
         {
            child = create(namespaceURI, localName, type);
         }
         else
         {
            Class<?> oCls;
            if(o instanceof Immutable)
            {
               oCls = ((Immutable)o).cls;
            }
            else
            {
               oCls = o.getClass();
            }

            String fieldName = Util.xmlNameToFieldName(localName, true);
            FieldInfo fieldInfo = FieldInfo.getFieldInfo(oCls, fieldName, true);
            if(Collection.class.isAssignableFrom(fieldInfo.getType()))
            {
               child = get(o, localName, fieldInfo);

               // now does this element really represent a Java collection or is it an element that can appear more than once?
               // try to load the class and create an instance
               Object item = null;
               if(type == null || type != null && type.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE)
               {
                  item = create(namespaceURI, localName, type);
               }

               if(item != null)
               {
                  if(child == null)
                  {
                     setChild(new ArrayList(), o, localName);
                  }
                  child = item;
               }
               else
               {
                  if(child == null)
                  {
                     child = new ArrayList<Object>();
                  }
               }
            }
            else if(!Util.isAttributeType(fieldInfo.getType()))
            {
               // id there is no field mapping
               ElementToFieldMapping fieldMapping = elementToFieldMapping.get(
                  new ElementToFieldMappingKey(localName, o.getClass())
               );
               TypeBinding converter = fieldMapping == null ? null : fieldMapping.converter;

               // if converter != null it will be used in setValue
               if(converter == null)
               {
                  child = newInstance(fieldInfo.getType());
               }
            }
         }
      }
View Full Code Here

            Class<?> parentCls = parent instanceof Immutable ?
               ((Immutable)parent).cls :
               parent.getClass();

            String fieldName = Util.xmlNameToFieldName(localName, true);
            FieldInfo fieldInfo = FieldInfo.getFieldInfo(parentCls, fieldName, false);
            if(trace)
            {
               log.trace("Add " + value + " to property " + fieldName + " of " + parentCls);
            }

            if(fieldInfo != null)
            {
               if(!(child instanceof Collection) && Collection.class.isAssignableFrom(fieldInfo.getType()))
               {
                  Object o = get(parent, localName, fieldInfo);
                  Collection<Object> col = (Collection<Object>)o;
                  if(trace)
                  {
View Full Code Here

            {
               oCls = o.getClass();
            }

            final String fieldName = Util.xmlNameToFieldName(localName, true);
            FieldInfo fieldInfo = FieldInfo.getFieldInfo(oCls, fieldName, true);

            fieldValue = SimpleTypeBindings.unmarshal(value, fieldInfo.getType());
            set(o, fieldValue, localName, fieldInfo);
         }
      }
   }
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

   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

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.