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

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


      assertNotNull(term);
      term = assertSingleSequence(term);
      assertTrue(term instanceof SequenceBinding);
      term = assertSingleSequence(term);
      assertTrue(term instanceof WildcardBinding);
      WildcardBinding wildcardBinding = type.getWildcard();
      assertNotNull(wildcardBinding);
      assertTrue(term == wildcardBinding);
      assertTrue(wildcardBinding.isProcessContentsStrict());
      ParticleHandler particleHandler = wildcardBinding.getWildcardHandler();
      assertNotNull(particleHandler);
      assertTrue(particleHandler instanceof CollectionPropertyWildcardHandler);
   }
View Full Code Here


      // type has a this
      typeBinding.pushInterceptor(BeanSchemaBinding20.thisQName, ThisValueElementInterceptor.THISVALUES);
     
      // type has wildcard
      WildcardBinding wcb = typeBinding.getWildcard();
      if( wcb != null )
         wcb.setWildcardHandler(ValueWildcardHandler.WILDCARD);
   }
View Full Code Here

      // type has a this
      typeBinding.pushInterceptor(BeanSchemaBinding20.thisQName, ThisValueElementInterceptor.THISVALUES);
     
      // type has wildcard
      WildcardBinding wcb = typeBinding.getWildcard();
      if (wcb == null)
         throw new IllegalStateException("Missing wildcard binding for type: " + typeBinding.getQName());
      wcb.setWildcardHandler(ValueWildcardHandler.WILDCARD);
   }
View Full Code Here

               log.trace("Wildcard " + wildcardProperty.getName() + " is a collection of type " + type.getName());
         }

         XmlAnyElement xmlAnyElement = wildcardProperty.getUnderlyingAnnotation(XmlAnyElement.class);
         boolean isLax = xmlAnyElement == null ? true : xmlAnyElement.lax();
         WildcardBinding wildcard = new WildcardBinding(schemaBinding);
         if (isLax)
            wildcard.setProcessContents((short) 3); // Lax
         else
            wildcard.setProcessContents((short) 1); // Strict

         // Dom element?
         if (Element.class.getName().equals(type.getName()))
         {
            wildcard.setUnresolvedElementHandler(DOMHandler.INSTANCE);
            wildcard.setUnresolvedCharactersHandler(DOMHandler.INSTANCE);
         }

         // Bind the particle to the model
         ParticleBinding particleBinding = new ParticleBinding(wildcard);
         particleBinding.setMinOccurs(0);
         particleBinding.setMaxOccurs(1);
         localModel.addParticle(particleBinding);
         typeBinding.getWildcard().setWildcardHandler((ParticleHandler) wildcardHandler);
         beanAdapterFactory.setWildcardHandler(wildcardHandler);
      }

      JBossXmlChildWildcard childWildcard = typeInfo.getUnderlyingAnnotation(JBossXmlChildWildcard.class);
      if (childWildcard != null)
      {
         if (beanAdapterFactory.getWildcardHandler() != null)
            throw new RuntimeException("Cannot have both @JBossXmlChildWildcard and @XmlAnyElement");

         ParticleHandler childWildcardHandler = null;
         if (typeInfo.isCollection())
         {
            if (childWildcard.wrapper() != Object.class)
            {
               BeanInfo wrapperInfo = JBossXBBuilder.configuration.getBeanInfo(childWildcard.wrapper());
               childWildcardHandler = new ChildCollectionWildcardHandler(wrapperInfo, childWildcard.property());
            }
            else
               childWildcardHandler = ChildCollectionWildcardHandler.SINGLETON;
         }
         else
            throw new UnsupportedOperationException("TODO");

         WildcardBinding wildcard = new WildcardBinding(schemaBinding);
         if (childWildcard.lax())
            wildcard.setProcessContents((short) 3); // Lax
         else
            wildcard.setProcessContents((short) 1); // Strict

         ParticleBinding particleBinding = new ParticleBinding(wildcard);
         particleBinding.setMinOccurs(0);
         particleBinding.setMaxOccurs(1);
         model.addParticle(particleBinding);
View Full Code Here

                        groupWildcardHandler = new ChildWildcardHandler(property, wrapperInfo, groupWildcard.property());
                     }
                     else
                        groupWildcardHandler = new ChildWildcardHandler(property);

                     WildcardBinding wildcard = new WildcardBinding(schemaBinding);
                     if (groupWildcard.lax())
                        wildcard.setProcessContents((short) 3); // Lax
                     else
                        wildcard.setProcessContents((short) 1); // Strict

                     particleBinding = new ParticleBinding(wildcard);
                     particleBinding.setMinOccurs(0);
                     particleBinding.setMaxOccurs(1);
                     childModel.addParticle(particleBinding);
View Full Code Here

      // type has a null
      typeBinding.pushInterceptor(SpringSchemaBinding.nullQName, NullValueElementInterceptor.NULLVALUES);

      // type has wildcard
      WildcardBinding wcb = typeBinding.getWildcard();
      if (wcb == null)
         throw new IllegalStateException("Missing wildcard binding for type: " + typeBinding.getQName());
      wcb.setWildcardHandler(ValueWildcardHandler.WILDCARD);
   }
View Full Code Here

               setMapEntryValue(mapEntryMetaData, parent, owner);
            }
         }

         // the wildcard this element is a content of
         WildcardBinding wildcard = null;
         if(parentTerm != null && !parentTerm.isModelGroup())
         {
            ElementBinding parentElement = (ElementBinding)parentTerm;
            TypeBinding parentType = parentElement.getType();
            wildcard = parentType.getWildcard();
            // there should be a better way of checking this
            if(wildcard != null && parentType.getElement(qName) != null)
            {
               wildcard = null;
            }
         }

         if(tryPut(owner, o, qName, term, trace))
         {
         }
         else if(tryAdd(owner, o, qName, term, wildcard, trace))
         {
         }
         else if (owner instanceof GenericValueContainer)
         {
            if (trace)
            {
               log.trace("setParent " + qName + " addChild");
            }
            ((GenericValueContainer) owner).addChild(qName, o);
         }
         else if (owner instanceof Collection)
         {
            if (trace)
            {
               log.trace("setParent " + qName + " collection.add()");
            }
            ((Collection) owner).add(o);
         }
         else
         {
            PropertyMetaData propertyMetaData = wildcard == null ? null : wildcard.getPropertyMetaData();
            if (propertyMetaData == null)
            {
               propertyMetaData = term.getPropertyMetaData();
            }
View Full Code Here

/*     */     {
/* 355 */       prop = new PropertyMetaData();
/* 356 */       prop.setName("_any");
/*     */     }
/*     */
/* 359 */     WildcardBinding wildcard = typeBinding.getWildcard();
/* 360 */     wildcard.setUnresolvedElementHandler(new SoapElementHandler());
/* 361 */     wildcard.setUnresolvedCharactersHandler(new SoapCharactersHandler());
/* 362 */     wildcard.setPropertyMetaData(prop);
/*     */
/* 364 */     if (log.isTraceEnabled())
/* 365 */       log.trace("Bound wildcard of " + typeBinding.getQName() + " to property " + prop.getName());
/*     */   }
View Full Code Here

/*  795 */     return marshalled;
/*      */   }
/*      */
/*      */   private boolean marshalWildcard(ParticleBinding particle, boolean declareNs)
/*      */   {
/*  800 */     WildcardBinding wildcard = (WildcardBinding)particle.getTerm();
/*  801 */     Object o = this.stack.peek();
/*  802 */     AbstractMarshaller.ClassMapping mapping = getClassMapping(o.getClass());
/*  803 */     if (mapping == null)
/*      */     {
/*  806 */       QName autoType = SimpleTypeBindings.typeQName(o.getClass());
/*  807 */       if (autoType != null)
/*      */       {
/*  809 */         String marshalled = SimpleTypeBindings.marshal(autoType.getLocalPart(), o, null);
/*  810 */         this.content.characters(marshalled.toCharArray(), 0, marshalled.length());
/*  811 */         return true;
/*      */       }
/*      */
/*  815 */       ObjectLocalMarshaller marshaller = wildcard.getUnresolvedMarshaller();
/*  816 */       if (marshaller != null)
/*      */       {
/*  818 */         marshaller.marshal(this.ctx, o);
/*  819 */         return true;
/*      */       }
/*      */
/*  822 */       String msg = "Failed to marshal wildcard: neither class mapping was found for " + o.getClass() + "@" + o.hashCode() + " (toString: " + o + ") nor marshaller for unresolved classes was setup.";
/*      */
/*  826 */       if (this.ignoreUnresolvedWildcard)
/*      */       {
/*  828 */         this.log.warn(msg);
/*  829 */         return true;
/*      */       }
/*      */
/*  833 */       throw new JBossXBRuntimeException(msg);
/*      */     }
/*      */
/*  838 */     Object parentRoot = this.root;
/*  839 */     AbstractMarshaller.Stack parentStack = this.stack;
/*  840 */     SchemaBinding parentSchema = this.schema;
/*      */
/*  842 */     this.root = o;
/*  843 */     this.stack = new AbstractMarshaller.StackImpl();
/*  844 */     this.schema = (mapping.schemaUrl == null ? this.schema : XsdBinder.bind(mapping.schemaUrl, this.schemaResolver));
/*      */
/*  847 */     if (mapping.elementName != null)
/*      */     {
/*  849 */       ParticleBinding element = this.schema.getElementParticle(mapping.elementName);
/*  850 */       if (element == null)
/*      */       {
/*  852 */         throw new JBossXBRuntimeException("Element " + mapping.elementName + " is not declared in the schema.");
/*      */       }
/*      */
/*  855 */       ParticleBinding ctxParticle = this.ctx.particle;
/*  856 */       MarshallingContextImpl.access$102(this.ctx, element);
/*  857 */       boolean marshalled = marshalElementOccurence((ElementBinding)element.getTerm(), this.root, particle.getMinOccurs() == 0, declareNs);
/*  858 */       MarshallingContextImpl.access$102(this.ctx, ctxParticle);
/*      */     }
/*  860 */     else if (mapping.typeName != null)
/*      */     {
/*  862 */       TypeBinding typeDef = this.schema.getType(mapping.typeName);
/*  863 */       if (typeDef == null)
/*      */       {
/*  865 */         throw new JBossXBRuntimeException("Type " + mapping.typeName + " is not defined in the schema.");
/*      */       }
/*      */
/*  871 */       if (wildcard.getQName() == null)
/*      */       {
/*  873 */         throw new JBossXBRuntimeException("Expected the wildcard to have a non-null QName.");
/*      */       }
/*      */
/*  876 */       ElementBinding element = new ElementBinding(this.schema, wildcard.getQName(), typeDef);
/*  877 */       ParticleBinding ctxParticle = this.ctx.particle;
/*  878 */       MarshallingContextImpl.access$102(this.ctx, new ParticleBinding(element));
/*  879 */       boolean marshalled = marshalElementOccurence(element, this.root, particle.getMinOccurs() == 0, declareNs);
/*  880 */       MarshallingContextImpl.access$102(this.ctx, ctxParticle);
/*      */     }
View Full Code Here

/*    */   {
/* 55 */     bindingType.setHandler(BindingHandler.HANDLER);
/*    */
/* 57 */     bindingType.setSimpleType(BindingCharactersHandler.HANDLER);
/*    */
/* 59 */     WildcardBinding wcb = bindingType.getWildcard();
/* 60 */     if (wcb == null)
/* 61 */       throw new IllegalStateException("Missing wildcard binding for type: " + bindingType.getQName());
/* 62 */     wcb.setWildcardHandler(BindingWildcardHandler.WILDCARD);
/*    */   }
View Full Code Here

TOP

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

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.