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

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


    */
   public static SchemaBinding build(Class<?> root)
   {
      ClassInfo classInfo = JBossXBBuilder.configuration.getClassInfo(root);

      SchemaBinding binding = classInfo.getAttachment(SchemaBinding.class);
      if (binding == null)
      {
         JBossXBNoSchemaBuilder builder = new JBossXBNoSchemaBuilder(classInfo);
         binding = builder.build();
         classInfo.setAttachment(SchemaBinding.class.getName(), binding);
View Full Code Here


    * Initialise the schema
    */
   protected void initSchema()
   {
      // Initialize the schema
      schemaBinding = new SchemaBinding();
      JBossXBBuilder.initSchema(schemaBinding, root);
      if (trace)
         log.trace("Building schema for " + root.getName() + " schemaBinding=" + schemaBinding);

      // Remember the default namespace
View Full Code Here

    */
   public static SchemaBinding build(Class<?> root)
   {
      ClassInfo classInfo = JBossXBBuilder.configuration.getClassInfo(root);

      SchemaBinding binding = classInfo.getAttachment(SchemaBinding.class);
      if (binding == null)
      {
         JBossXBNoSchemaBuilder builder = new JBossXBNoSchemaBuilder(classInfo);
         binding = builder.build();
         classInfo.setAttachment(SchemaBinding.class.getName(), binding);
View Full Code Here

    * Initialise the schema
    */
   protected void initSchema()
   {
      // Initialize the schema
      schemaBinding = new SchemaBinding();
      JBossXBBuilder.initSchema(schemaBinding, root);
      if (trace)
         log.trace("Building schema for " + root.getName() + " schemaBinding=" + schemaBinding);

      // Remember the default namespace
View Full Code Here

    * @return the schema
    */
   public SchemaBinding build()
   {
      // Initialize the schema
      schemaBinding = new SchemaBinding();
      JBossXBBuilder.initSchema(schemaBinding, root);
      initBuilder();
      createRootElements();
      return schemaBinding;
   }
View Full Code Here

   public SchemaBinding resolve(String nsURI, String baseURI, String schemaLocation)
   {
      boolean trace = log.isTraceEnabled();
      // Was the schema binding based on the nsURI
      boolean foundByNS = false;
      SchemaBinding schema = schemasByUri.get(nsURI);
      if(schema != null)
      {
         if(trace)
            log.trace("resolved cached schema, nsURI="+nsURI+", schema: " + schema);
         return schema;
      }

      // Look for a class binding by schemaLocation
      Class<?>[] classes = resolveClassFromSchemaLocation(schemaLocation, trace);
      if (classes == null)
      {
         // Next look by namespace
         classes = getClassesForURI(nsURI);
         if(classes != null)
            foundByNS = true;
      }
     
      if (classes != null)
      {
         if( trace )
         {
            log.trace("found bindingClass, nsURI=" + nsURI +
                  ", baseURI=" + baseURI +
                  ", schemaLocation=" + schemaLocation +
                  ", classes=" + Arrays.asList(classes));
         }
         schema = JBossXBBuilder.build(classes);
      }
      else
      {
         // Parse the schema
         InputSource is = getInputSource(nsURI, baseURI, schemaLocation);
         if( trace )
         {
            String msg = (is == null ? "couldn't find" : "found") +
                  " schema InputSource, nsURI=" + nsURI +
                  ", baseURI=" + baseURI + ", schemaLocation=" +
                  schemaLocation;
            log.trace(msg);
         }
        
         if (is != null)
         {
            if( baseURI == null )
               baseURI = this.baseURI;
  
            Boolean processAnnotationsBoolean = schemaParseAnnotationsByUri.get(nsURI);
            boolean processAnnotations = (processAnnotationsBoolean == null) ? true : processAnnotationsBoolean.booleanValue();
            try
            {
               schema = XsdBinder.bind(is.getByteStream(), null, baseURI, processAnnotations);
               foundByNS = true;
            }
            catch(RuntimeException e)
            {
               String msg = "Failed to parse schema for nsURI="+nsURI
                  +", baseURI="+baseURI
                  +", schemaLocation="+schemaLocation;
               throw new JBossXBRuntimeException(msg, e);
            }
         }
      }

      if(schema != null)
      {
         schema.setSchemaResolver(this);
         SchemaBindingInitializer sbi = schemaInitByUri.get(nsURI);
         if(sbi != null)
            schema = sbi.init(schema);

         if(schema != null && nsURI.length() > 0 && cacheResolvedSchemas && foundByNS)
View Full Code Here

   public static final DefaultAttributeMarshaller INSTANCE = new DefaultAttributeMarshaller();
  
   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

  
   protected <T, U> T unmarshalObject(Class<T> expected, Class<U> reference, Class... others) throws Exception
   {
      TestSchemaResolver resolver = new TestSchemaResolver();
     
      SchemaBinding schemaBinding = JBossXBBuilder.build(reference);
      resolver.addSchemaBinding(schemaBinding);
      if (others != null)
      {
         for (Class<?> other : others)
         {
            SchemaBinding otherBinding = JBossXBBuilder.build(other);
            resolver.addSchemaBinding(otherBinding);
         }
      }
     
      String testXml = findTestXml();
View Full Code Here

      super(name);
   }

   public void testCache() throws Exception
   {
      SchemaBinding schema = JBossXBBuilder.build(MyClass.class, true);
      assertEquals("ns1", schema.getNamespace("p1"));
      assertEquals("ns2", schema.getNamespace("p2"));
     
      schema.addPrefixMapping("p2", "ns22");
     
      schema = JBossXBBuilder.build(MyClass.class);
      assertEquals("ns1", schema.getNamespace("p1"));
      assertEquals("ns22", schema.getNamespace("p2"));
   }
View Full Code Here

      assertEquals("ns22", schema.getNamespace("p2"));
   }

   public void testRebuild() throws Exception
   {
      SchemaBinding schema = JBossXBBuilder.build(MyClass.class, true);
      assertEquals("ns1", schema.getNamespace("p1"));
      assertEquals("ns2", schema.getNamespace("p2"));
     
      schema.addPrefixMapping("p2", "ns22");
     
      schema = JBossXBBuilder.build(MyClass.class, true);
      assertEquals("ns1", schema.getNamespace("p1"));
      assertEquals("ns2", schema.getNamespace("p2"));
   }
View Full Code Here

TOP

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

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.