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

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


   }

   protected void assertPropertiesChoiceBinding(Class<?> root, boolean inCollection)
   {
      SchemaBinding schema = JBossXBBuilder.build(root);
      ElementBinding e = schema.getElement(new QName("root"));
      assertNotNull(e);
      TermBinding t = e.getType().getParticle().getTerm();
      assertTrue(t instanceof SequenceBinding || t instanceof UnorderedSequenceBinding);
      ModelGroupBinding s = (ModelGroupBinding) t;
      Collection<ParticleBinding> particles = s.getParticles();
      assertEquals(1, particles.size());
      ParticleBinding p = particles.iterator().next();
View Full Code Here


   }

   protected void assertPropertiesAllBinding(Class<?> root, boolean inCollection)
   {
      SchemaBinding schema = JBossXBBuilder.build(root);
      ElementBinding e = schema.getElement(new QName("root"));
      assertNotNull(e);
      TermBinding t = e.getType().getParticle().getTerm();
      assertTrue(t instanceof SequenceBinding || t instanceof UnorderedSequenceBinding);
      ModelGroupBinding s = (ModelGroupBinding) t;

      Collection<ParticleBinding> particles = s.getParticles();
      assertEquals(2, particles.size());
View Full Code Here

   {
      SchemaBinding schemaBinding = JBossXBBuilder.build(ElementWildcard.class);
      assertNotNull(schemaBinding);
     
      QName qName = new QName(XMLConstants.NULL_NS_URI, "element-wildcard");
      ElementBinding element = schemaBinding.getElement(qName);
      assertNotNull(element);
      TypeBinding type = element.getType();
      assertNotNull(type);
      ParticleBinding particle = type.getParticle();
      assertNotNull(particle);
      TermBinding term = particle.getTerm();
      assertNotNull(term);
View Full Code Here

   {
      SchemaBinding schemaBinding = JBossXBBuilder.build(ElementBeforePrimitive.class);
      assertNotNull(schemaBinding);
     
      QName qName = new QName(XMLConstants.NULL_NS_URI, "element-before-primitive");
      ElementBinding element = schemaBinding.getElement(qName);
      assertNotNull(element);
      TypeBinding type = element.getType();
      assertNotNull(type);
      ParticleBinding particle = type.getParticle();
      assertNotNull(particle);
      TermBinding term = particle.getTerm();
      assertNotNull(term);
      assertTrue(term instanceof SequenceBinding || term instanceof UnorderedSequenceBinding);
           
      Collection<ParticleBinding> particles = ((ModelGroupBinding)term).getParticles();
      assertEquals(2, particles.size());

      ParticleBinding domParticle;
      ParticleBinding textParticle;
      Iterator<ParticleBinding> i = particles.iterator();
      if(term instanceof SequenceBinding)
      {
         domParticle = i.next();
         textParticle = i.next();
      }
      else
      {
         particle = i.next();
         if (((ElementBinding) particle.getTerm()).getQName().equals(new QName("dom")))
         {
            domParticle = particle;
            textParticle = i.next();
         }
         else
         {
            textParticle = particle;
            domParticle = i.next();
         }
      }

      term = domParticle.getTerm();
      assertTrue(term.isElement());
      assertEquals(0, domParticle.getMinOccurs());
      assertEquals(1, domParticle.getMaxOccurs());
      assertFalse(domParticle.getMaxOccursUnbounded());
      element = (ElementBinding) term;
      assertEquals(new QName("dom"), element.getQName());

      term = textParticle.getTerm();
      assertTrue(term.isElement());
      assertEquals(0, textParticle.getMinOccurs());
      assertEquals(1, textParticle.getMaxOccurs());
      assertFalse(textParticle.getMaxOccursUnbounded());
      element = (ElementBinding) term;
      assertEquals(new QName("text"), element.getQName());
   }
View Full Code Here

   }

   public void testBinding() throws Exception
   {
      SchemaBinding schema = JBossXBBuilder.build(RootWithParticlesChoiceCollection.class);
      ElementBinding e = schema.getElement(new QName("root"));
      assertNotNull(e);
      TermBinding t = e.getType().getParticle().getTerm();
      assertTrue(t instanceof SequenceBinding || t instanceof UnorderedSequenceBinding);
      ModelGroupBinding s = (ModelGroupBinding) t;
      Collection<ParticleBinding> particles = s.getParticles();
      assertEquals(2, particles.size());
      Iterator<ParticleBinding> i = particles.iterator();
View Full Code Here

      String xsd = findXML(getRootName() + ".xsd");
      SchemaBinding schema = XsdBinder.bind(xsd);
      schema.setStrictSchema(true);
      schema.setIgnoreUnresolvedFieldOrClass(false);
     
      ElementBinding e = schema.getElement(new QName("file:///tmp/test.xsd", "message"));
      assertNotNull(e);
      TypeBinding type = e.getType();

      ClassMetaData cmd = new ClassMetaData();
      cmd.setImpl(Root.class.getName());
      type.setClassMetaData(cmd);
     
      TermBinding t = type.getParticle().getTerm();
      assertTrue(t instanceof ChoiceBinding);
      Collection<ParticleBinding> particles = ((ChoiceBinding)t).getParticles();
      assertEquals(2, particles.size());
      Iterator<ParticleBinding> i = particles.iterator();
      ParticleBinding p = i.next();
      assertEquals(1, p.getMinOccurs());
      assertEquals(1, p.getMaxOccurs());
      assertFalse(p.getMaxOccursUnbounded());
      t = p.getTerm();
      assertTrue(t instanceof SequenceBinding);
     
      p = i.next();
      assertEquals(1, p.getMinOccurs());
      assertEquals(1, p.getMaxOccurs());
      assertFalse(p.getMaxOccursUnbounded());
      assertTrue(p.getTerm().isElement());
      assertEquals(new QName("file:///tmp/test.xsd", "bar"), ((ElementBinding)p.getTerm()).getQName());
           
      particles = ((SequenceBinding)t).getParticles();
      assertEquals(2, particles.size());
      i = particles.iterator();
      p = i.next();
      assertEquals(1, p.getMinOccurs());
      assertEquals(1, p.getMaxOccurs());
      assertFalse(p.getMaxOccursUnbounded());
      assertTrue(p.getTerm().isElement());
      assertEquals(new QName("file:///tmp/test.xsd", "foo"), ((ElementBinding)p.getTerm()).getQName());

      p = i.next();
      assertEquals(1, p.getMinOccurs());
      assertEquals(2, p.getMaxOccurs());
      assertFalse(p.getMaxOccursUnbounded());
      assertTrue(p.getTerm().isElement());
      e = (ElementBinding) p.getTerm();
      assertEquals(new QName("file:///tmp/test.xsd", "bar"), e.getQName());
      PropertyMetaData pmd = new PropertyMetaData();
      pmd.setName("barMaxOccurs2");
      e.setPropertyMetaData(pmd);
      return schema;
   }
View Full Code Here

      QName qName = new QName(XMLConstants.NULL_NS_URI, "root");
      QName elementName = qName;
      TypeBinding type = schemaBinding.getType(qName);
      assertNull(type);
     
      ElementBinding elementBinding = schemaBinding.getElement(elementName);
      assertNotNull(elementBinding);
      TypeBinding typeBinding = elementBinding.getType();
     
      ValueAdapter valueAdapter = typeBinding.getValueAdapter();
      assertNotNull(valueAdapter);
      assertTrue(valueAdapter instanceof EnumValueAdapter);
      testEnumValueAdapter((EnumValueAdapter)valueAdapter);
View Full Code Here

   {
      SchemaBinding schemaBinding = JBossXBBuilder.build(NotAnnotatedElementWildcard.class);
      assertNotNull(schemaBinding);
     
      QName qName = new QName(XMLConstants.NULL_NS_URI, "not-annotated-element-wildcard");
      ElementBinding element = schemaBinding.getElement(qName);
      assertNotNull(element);
      TypeBinding type = element.getType();
      assertNotNull(type);
      ParticleBinding particle = type.getParticle();
      assertNotNull(particle);
      TermBinding term = particle.getTerm();
      assertNotNull(term);
      term = assertSingleSequence(term);
     
      assertTrue(term.isElement());
      element = (ElementBinding) term;
      assertEquals(new QName("element"), element.getQName());
      term = element.getType().getParticle().getTerm();
      assertTrue(term instanceof SequenceBinding);
      Collection<ParticleBinding> particles = ((SequenceBinding)term).getParticles();
      assertEquals(1, particles.size());
      particle = particles.iterator().next();
      term = particle.getTerm();
     
      assertTrue(term instanceof WildcardBinding);
      type = element.getType();
      WildcardBinding wildcardBinding = type.getWildcard();
      assertNotNull(wildcardBinding);
      assertTrue(term == wildcardBinding);
      assertTrue(wildcardBinding.isProcessContentsSkip());
      assertTrue(DOMHandler.INSTANCE == wildcardBinding.getUnresolvedCharactersHandler());
View Full Code Here

   {
      SchemaBinding schemaBinding = JBossXBBuilder.build(RootArray.class);
      assertNotNull(schemaBinding);
     
      QName elementName = new QName(XMLConstants.NULL_NS_URI, "root-array");
      ElementBinding elementBinding = schemaBinding.getElement(elementName);
      assertNotNull(elementBinding);
     
      // TODO
      //ModelGroupBinding group = (ModelGroupBinding) elementBinding.getType().getParticle().getTerm();
      //assertRepeatableElementBinding(group);
View Full Code Here

      QName qName = new QName(XMLConstants.NULL_NS_URI, "enum-global-type");
      TypeBinding type = schemaBinding.getType(qName);
      assertNotNull(type);
      assertEquals(qName, type.getQName());
     
      ElementBinding elementBinding = schemaBinding.getElement(qName);
      assertNotNull(elementBinding);
      TypeBinding typeBinding = elementBinding.getType();
      assertNotNull(typeBinding);
      //System.out.println(Strings.defaultToString(type));
      //System.out.println(Strings.defaultToString(typeBinding));
      assertTrue(type == typeBinding);
   }
View Full Code Here

TOP

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

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.