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

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


            // TODO sometimes XB wraps (maybe unnecessarily) repeatable elements into a sequence.
            // the same xml structure can be described differently in xsd
            if (/*(xsParticle.getMaxOccursUnbounded() || xsParticle.getMaxOccurs() > 1) &&*/
                  termBinding instanceof SequenceBinding)
            {
               SequenceBinding seq = (SequenceBinding) termBinding;
               Collection<ParticleBinding> particles = seq.getParticles();
               if(particles.size() == 1)
               {
                  ParticleBinding particle = particles.iterator().next();
                  if(particle.getTerm().isElement())
                  {
View Full Code Here


   @SuppressWarnings("unchecked")
   protected TermBinding assertSingleSequence(TermBinding term)
   {
      assertNotNull(term);
      assertTrue(term instanceof SequenceBinding);
      SequenceBinding sequence = (SequenceBinding) term;
      Collection<ParticleBinding> particles = sequence.getParticles();
      assertTrue(particles.size() == 1);
      ParticleBinding particle = particles.iterator().next();
      term = particle.getTerm();
      assertNotNull(term);
      return term;
View Full Code Here

      }
      else
      {
         if (trace)
            log.trace("SequenceBinding for type=" + beanInfo.getName());
         model = new SequenceBinding(schemaBinding);
      }
      model.setHandler(BuilderParticleHandler.INSTANCE);
      ParticleBinding typeParticle = new ParticleBinding(model);
      typeParticle.setMinOccurs(1);
      typeParticle.setMaxOccurs(1);
View Full Code Here

            if (propertyGroup == null)
            {
               if (xmlModelGroup.kind().equals(JBossXmlConstants.MODEL_GROUP_SEQUENCE))
               {
                  propertyGroup = new SequenceBinding(schemaBinding);
               }
               else if (xmlModelGroup.kind().equals(JBossXmlConstants.MODEL_GROUP_CHOICE))
               {
                  propertyGroup = new ChoiceBinding(schemaBinding);
               }
View Full Code Here

   }
  
   private SequenceBinding bindXmlElementWrapper(TypeInfo propertyType, ModelGroupBinding parentModel, boolean wrapperNillable, QName wrapperQName)
   {
      TypeBinding wrapperType = new TypeBinding();
      SequenceBinding seq = new SequenceBinding(schemaBinding);
      seq.setHandler(BuilderParticleHandler.INSTANCE);
      ParticleBinding particle = new ParticleBinding(seq);
      wrapperType.setParticle(particle);
      wrapperType.setHandler(new DefaultElementHandler());

      ElementBinding wrapperElement = createElementBinding(propertyType, wrapperType, wrapperQName, false);
View Full Code Here

    * @param localModel the current model
    * @return the new local model
    */
   private ModelGroupBinding createArray(ModelGroupBinding localModel)
   {
      SequenceBinding sequenceBinding = new SequenceBinding(schemaBinding);
      sequenceBinding.setHandler(BuilderParticleHandler.INSTANCE);
      ArraySequenceBinding arraySequenceBinding = new ArraySequenceBinding(schemaBinding);
      arraySequenceBinding.setHandler(BuilderParticleHandler.INSTANCE);
      ParticleBinding particle = new ParticleBinding(sequenceBinding);
      particle.setMinOccurs(0);
      particle.setMaxOccursUnbounded(true);
View Full Code Here

    * @param localModel the current model
    * @return the new local model
    */
   private ModelGroupBinding createCollection(ModelGroupBinding localModel)
   {
      SequenceBinding sequenceBinding = new SequenceBinding(schemaBinding);
      sequenceBinding.setHandler(BuilderParticleHandler.INSTANCE);
      ParticleBinding particle = new ParticleBinding(sequenceBinding);
      particle.setMinOccurs(0);
      particle.setMaxOccursUnbounded(true);
      localModel.addParticle(particle);
      return sequenceBinding;
View Full Code Here

               CharactersHandler charactersHandler = new ValueHandler(entryInfo.getProperty("value"), valueType);
               entryType.setSimpleType(charactersHandler);
            }
         }
        
         SequenceBinding keyValueSequence = null;
         if(keyElement != null)
         {
            keyValueSequence = new SequenceBinding(schemaBinding);                    
            if(entryType == null)
            {
               keyValueSequence.setSkip(Boolean.FALSE);
               keyValueSequence.setQName(propertyQName);
               schemaBinding.addGroup(keyValueSequence.getQName(), keyValueSequence);
               ParticleBinding keyValueParticle = new ParticleBinding(keyValueSequence, 0, -1, true);
               targetGroup.addParticle(keyValueParticle);
               keyValueSequence.setHandler(entryHandler);
            }
            else
            {
               ParticleBinding keyValueParticle = new ParticleBinding(keyValueSequence, 1, 1, false);
               entryType.setParticle(keyValueParticle);
            }
           
            // key element
            TypeBinding keyTypeBinding = resolveTypeBinding(keyType);                 
            String keyNs = keyElement.namespace();
            if(JBossXmlConstants.DEFAULT.equals(keyNs))
               keyNs = defaultNamespace;                 
            ElementBinding keyElementBinding = createElementBinding(keyType, keyTypeBinding, new QName(keyNs, keyElement.name()), false);
            ParticleBinding particle = new ParticleBinding(keyElementBinding, 1, 1, false);
            keyValueSequence.addParticle(particle);
            PropertyHandler keyHandler = new PropertyHandler(entryInfo.getProperty("key"), keyType);
            entryAdapterFactory.addProperty(keyElementBinding.getQName(), keyHandler);
         }
        
         if(valueElement != null)
         {
            TypeBinding valueTypeBinding = resolveTypeBinding(valueType);                 
            String valueNs = valueElement.namespace();
            if(JBossXmlConstants.DEFAULT.equals(valueNs))
               valueNs = defaultNamespace;                 
            ElementBinding valueElementBinding = createElementBinding(valueType, valueTypeBinding, new QName(valueNs, valueElement.name()), false);
            ParticleBinding particle = new ParticleBinding(valueElementBinding, 1, 1, false);
            keyValueSequence.addParticle(particle);
            PropertyHandler valueHandler = new PropertyHandler(entryInfo.getProperty("value"), valueType);
            entryAdapterFactory.addProperty(valueElementBinding.getQName(), valueHandler);
         }

         // TODO: need to verify correct binding before proceeding
View Full Code Here

               return o;
            }
         };

         ElementBinding e = SCHEMA.getElement(new javax.xml.namespace.QName("http://www.jboss.org/xml/test/xop", "e"));
         SequenceBinding seq = (SequenceBinding) e.getType().getParticle().getTerm();
         for(Iterator i = seq.getParticles().iterator(); i.hasNext();)
         {
            ParticleBinding particle = (ParticleBinding) i.next();
            ElementBinding child = (ElementBinding) particle.getTerm();
            if(! "xopContent".equals( child.getQName().getLocalPart()))
               child.setBeforeSetParentCallback(callback);
View Full Code Here

            }
         });
        
         // have to override string type's handlers
         ElementBinding global = SCHEMA.getElement(new QName("http://jboss.org/ns/test", "global"));
         SequenceBinding sequence = (SequenceBinding) global.getType().getParticle().getTerm();
         Iterator iter = sequence.getParticles().iterator();
         iter.next(); // stringType element
         ElementBinding stringElement = (ElementBinding) ((ParticleBinding)iter.next()).getTerm();
         stringElement.setBeforeMarshallingCallback(new TermBeforeMarshallingCallback()
         {
            public Object beforeMarshalling(Object o, MarshallingContext ctx)
            {
               ParticleBinding particle = ctx.getParticleBinding();
               assertNotNull(particle);
               assertTrue(particle.getTerm().isElement());
               ElementBinding element = (ElementBinding) particle.getTerm();
               assertEquals(new QName("http://jboss.org/ns/test", "stringElement"), element.getQName());
              
               TypeBinding type = element.getType();
               assertEquals(Constants.QNAME_STRING, type.getQName());
              
               return o == null ? null : (String)o;
            }
         });        
         stringElement.setBeforeSetParentCallback(new TermBeforeSetParentCallback()
         {
            public Object beforeSetParent(Object o, UnmarshallingContext ctx)
            {
               ParticleBinding particle = ctx.getParticle();
               assertNotNull(particle);
               assertTrue(particle.getTerm().isElement());
               ElementBinding element = (ElementBinding) particle.getTerm();
               assertEquals(new QName("http://jboss.org/ns/test", "stringElement"), element.getQName());
              
               assertTrue(ctx.getParentValue() instanceof GlobalElement);
               TermBinding parentTerm = ctx.getParentParticle().getTerm();
               assertTrue(parentTerm.isElement());
               assertEquals("global", ((ElementBinding)parentTerm).getQName().getLocalPart());

               assertEquals(String.class, ctx.resolvePropertyType());

               return o == null ? null : (String)o;
            }
         });
        
         // sequence
         sequence = (SequenceBinding) ((ParticleBinding)iter.next()).getTerm();
         sequence.setBeforeMarshallingCallback(new TermBeforeMarshallingCallback()
         {
            public Object beforeMarshalling(Object o, MarshallingContext ctx)
            {
               ParticleBinding particle = ctx.getParticleBinding();
               assertNotNull(particle);
               assertTrue(particle.getTerm() instanceof SequenceBinding);

               if(o != null)
               {
                  GlobalElement.Sequence seq = new GlobalElement.Sequence();
                  seq.item = (StringType) o;
                  o = seq;
               }
               return o;
            }
         });
         sequence.setBeforeSetParentCallback(new TermBeforeSetParentCallback()
         {
            public Object beforeSetParent(Object o, UnmarshallingContext ctx)
            {
               ParticleBinding particle = ctx.getParticle();
               assertTrue(particle.getTerm() instanceof SequenceBinding);
View Full Code Here

TOP

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

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.