Package org.jboss.xb.binding.sunday.unmarshalling

Examples of org.jboss.xb.binding.sunday.unmarshalling.AttributeBinding


      return value;
   }

   public String marshalValue(MarshallingContext ctx, Object value)
   {
      AttributeBinding binding = ctx.getAttributeBinding();

      if(value == null)
      {
         if(binding.getRequired())
         {
            ElementBinding element = (ElementBinding) ctx.getParticleBinding().getTerm();
            throw new JBossXBRuntimeException("Missing value for the required attribute " + binding.getQName() + " of element " + element.getQName());
         }  
         return null;
      }

      String marshalled;

      TypeBinding attrType = binding.getType();

      if(attrType.getItemType() != null)
      {
         TypeBinding itemType = attrType.getItemType();
         if(Constants.NS_XML_SCHEMA.equals(itemType.getQName().getNamespaceURI()))
         {
            List list;
            if(value instanceof List)
            {
               list = (List)value;
            }
            else if(value.getClass().isArray())
            {
               list = Arrays.asList((Object[])value);
            }
            else
            {
               throw new JBossXBRuntimeException("Expected value for list type is an array or " +
                  List.class.getName() +
                  " but got: " +
                  value
               );
            }

            if(Constants.QNAME_QNAME.getLocalPart().equals(itemType.getQName().getLocalPart()))
            {
               String attrLocal = binding.getQName().getLocalPart();
               for(int listInd = 0; listInd < list.size(); ++listInd)
               {
                  QName item = (QName)list.get(listInd);
                  String itemNs = item.getNamespaceURI();
                  if(itemNs != null && itemNs.length() > 0)
View Full Code Here


                  attributeTypeInfo = attributeTypeInfo.getTypeInfoFactory().getTypeInfo(jbossXmlAttribute.type());
               TypeBinding attributeType = resolveTypeBinding(attributeTypeInfo);
               // Create the attribute handler
               AttributeHandler attributeHandler = new PropertyHandler(property, attributeTypeInfo);
               // Create the attributre and bind it to the type
               AttributeBinding attribute = new AttributeBinding(schemaBinding, qName, attributeType, attributeHandler);
               attribute.setRequired(xmlAttribute.required());
               typeBinding.addAttribute(attribute);
               if (trace)
                  log.trace("Bound attribute " + qName + " type=" + beanInfo.getName() + " property=" + property.getName() + " propertyType=" + attributeTypeInfo);
            }
View Full Code Here

         return null;
      }

      String marshalled;

      AttributeBinding binding = ctx.getAttributeBinding();
      TypeBinding attrType = binding.getType();

      if(attrType.getItemType() != null)
      {
         TypeBinding itemType = attrType.getItemType();
         if(Constants.NS_XML_SCHEMA.equals(itemType.getQName().getNamespaceURI()))
         {
            List list;
            if(value instanceof List)
            {
               list = (List)value;
            }
            else if(value.getClass().isArray())
            {
               list = Arrays.asList((Object[])value);
            }
            else
            {
               throw new JBossXBRuntimeException("Expected value for list type is an array or " +
                  List.class.getName() +
                  " but got: " +
                  value
               );
            }

            if(Constants.QNAME_QNAME.getLocalPart().equals(itemType.getQName().getLocalPart()))
            {
               String attrLocal = binding.getQName().getLocalPart();
               for(int listInd = 0; listInd < list.size(); ++listInd)
               {
                  QName item = (QName)list.get(listInd);
                  String itemNs = item.getNamespaceURI();
                  if(itemNs != null && itemNs.length() > 0)
View Full Code Here

                        }
                     }
                  }
                  else if(binding instanceof AttributeBinding)
                  {
                     AttributeBinding attr = (AttributeBinding)binding;
                     AttributeHandler handler = attr.getHandler();
                     if(handler != null)
                     {
                        if(parentValueList != null)
                        {
                           parentValueList.setAttributeValue(attr.getQName(), attr, valueEntry.value);
                        }
                        else
                        {
                           handler.attribute(valueEntry.qName, attr.getQName(), attr, parent, valueEntry.value);
                        }
                     }
                     else
                     {
                        throw new JBossXBRuntimeException("Attribute binding present but has no handler: element=" +
                           valueEntry.qName +
                           ", attrinute=" +
                           attr.getQName()
                        );
                     }
                  }
                  else
                  {
View Full Code Here

  
   public Object getValue(MarshallingContext ctx)
   {
      Object owner = ctx.peek();
      SchemaBinding schema = ctx.getSchemaBinding();
      AttributeBinding binding = ctx.getAttributeBinding();
      QName qName = binding.getQName();

      String fieldName = null;
      PropertyMetaData propertyMetaData = binding.getPropertyMetaData();
      if(propertyMetaData != null)
      {
         fieldName = propertyMetaData.getName();
      }

      if(fieldName == null)
      {
         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);
View Full Code Here

   {
      TypeBinding type = element.getType();
      for(int i = 0; i < attrs.getLength(); ++i)
      {
         QName attrName = new QName(attrs.getURI(i), attrs.getLocalName(i));
         AttributeBinding binding = type.getAttribute(attrName);
         if(binding != null)
         {
            AttributeHandler handler = binding.getHandler();
            if(handler != null)
            {
               Object value = handler.unmarshal(elementName, attrName, binding, nsCtx, attrs.getValue(i));
               handler.attribute(elementName, attrName, binding, o, value);
            }
View Full Code Here

/*     */   {
/* 247 */     String xmlAttrName = varMapping.getXmlAttributeName();
/* 248 */     log.trace("processXmlAttributeName: " + xmlAttrName);
/*     */
/* 250 */     QName xmlName = new QName(xmlAttrName);
/* 251 */     AttributeBinding attrBinding = typeBinding.getAttribute(xmlName);
/* 252 */     if (attrBinding == null)
/*     */     {
/* 254 */       Iterator i = typeBinding.getAttributes().iterator();
/* 255 */       while (i.hasNext())
/*     */       {
/* 257 */         AttributeBinding auxBinding = (AttributeBinding)i.next();
/* 258 */         if (auxBinding.getQName().getLocalPart().equals(xmlAttrName))
/*     */         {
/* 260 */           if (attrBinding != null) {
/* 261 */             log.warn("Ambiguous binding for attribute: " + xmlAttrName);
/*     */           }
/* 263 */           attrBinding = auxBinding;
View Full Code Here

/*      */
/*  533 */     if (!attrBindings.isEmpty())
/*      */     {
/*  535 */       for (Iterator i = attrBindings.iterator(); i.hasNext(); )
/*      */       {
/*  537 */         AttributeBinding attrBinding = (AttributeBinding)i.next();
/*  538 */         QName attrQName = attrBinding.getQName();
/*      */
/*  540 */         if (Constants.QNAME_XMIME_CONTENTTYPE.equals(attrQName))
/*      */         {
/*      */           continue;
/*      */         }
/*      */
/*  545 */         MarshallingContextImpl.access$302(this.ctx, attrBinding);
/*  546 */         AttributeMarshaller marshaller = attrBinding.getMarshaller();
/*  547 */         String marshalledAttr = marshaller.marshal(this.ctx);
/*      */
/*  549 */         if (marshalledAttr != null)
/*      */         {
/*  551 */           if (this.ctx.attrs == null)
View Full Code Here

/*     */
/*     */   public Object getValue(MarshallingContext ctx)
/*     */   {
/*  49 */     Object owner = ctx.peek();
/*  50 */     SchemaBinding schema = ctx.getSchemaBinding();
/*  51 */     AttributeBinding binding = ctx.getAttributeBinding();
/*  52 */     QName qName = binding.getQName();
/*     */
/*  54 */     String fieldName = null;
/*  55 */     PropertyMetaData propertyMetaData = binding.getPropertyMetaData();
/*  56 */     if (propertyMetaData != null)
/*     */     {
/*  58 */       fieldName = propertyMetaData.getName();
/*     */     }
/*     */
/*  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);
View Full Code Here

/*  81 */     if (value == null)
/*     */     {
/*  83 */       return null;
/*     */     }
/*     */
/*  88 */     AttributeBinding binding = ctx.getAttributeBinding();
/*  89 */     TypeBinding attrType = binding.getType();
/*     */     String marshalled;
/*     */     String marshalled;
/*  91 */     if (attrType.getItemType() != null)
/*     */     {
/*  93 */       TypeBinding itemType = attrType.getItemType();
/*     */       String marshalled;
/*  94 */       if ("http://www.w3.org/2001/XMLSchema".equals(itemType.getQName().getNamespaceURI()))
/*     */       {
/*     */         List list;
/*  97 */         if ((value instanceof List))
/*     */         {
/*  99 */           list = (List)value;
/*     */         }
/*     */         else
/*     */         {
/*     */           List list;
/* 101 */           if (value.getClass().isArray())
/*     */           {
/* 103 */             list = Arrays.asList((Object[])(Object[])value);
/*     */           }
/*     */           else
/*     */           {
/* 107 */             throw new JBossXBRuntimeException("Expected value for list type is an array or " + List.class.getName() + " but got: " + value);
/*     */           }
/*     */         }
/*     */         List list;
/* 114 */         if (Constants.QNAME_QNAME.getLocalPart().equals(itemType.getQName().getLocalPart()))
/*     */         {
/* 116 */           String attrLocal = binding.getQName().getLocalPart();
/* 117 */           for (int listInd = 0; listInd < list.size(); listInd++)
/*     */           {
/* 119 */             QName item = (QName)list.get(listInd);
/* 120 */             String itemNs = item.getNamespaceURI();
/* 121 */             if ((itemNs == null) || (itemNs.length() <= 0))
View Full Code Here

TOP

Related Classes of org.jboss.xb.binding.sunday.unmarshalling.AttributeBinding

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.