Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * JBoss, Home of Professional Open Source
   * Copyright 2005, JBoss Inc., and individual contributors as indicated
   * by the @authors tag. See the copyright.txt in the distribution for a
   * full listing of individual contributors.
   *
   * This is free software; you can redistribute it and/or modify it
   * under the terms of the GNU Lesser General Public License as
   * published by the Free Software Foundation; either version 2.1 of
  * the License, or (at your option) any later version.
  *
  * This software is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this software; if not, write to the Free
  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  */
 package org.jboss.xb.binding.sunday.unmarshalling;
 
 
A default SchemaBindingResolver that uses a JBossEntityResolver to locate the schema xsd.

Author(s):
Scott.Stark@jboss.org
Version:
$Revision: 3021 $
 
 {
    private static Logger log = Logger.getLogger(DefaultSchemaResolver.class);

   
Namespace to JBossXBBuilder binding class
 
    private WeakHashMap<StringClass<?>> uriToClass = new WeakHashMap<StringClass<?>>();
   
SchemaLocation to JBossXBBuilder binding class
 
    private WeakHashMap<StringClass<?>> schemaLocationToClass = new WeakHashMap<StringClass<?>>();
 
    public DefaultSchemaResolver()
    {
       super();
    }
 
    public DefaultSchemaResolver(JBossEntityResolver resolver)
    {
       super(resolver);
    }

   
Registers a location for the namespace URI.

This method delegates to mapSchemaLocation(nsUri, location). This location is looked using the JBossEntityResolver, i.e. it is a classpath location

Parameters:
nsUri the namespace location
location the classpath location
 
    public void addSchemaLocation(String nsUriString location)
    {
       super.mapSchemaLocation(nsUrilocation);
    }
   

   
Whether to parse annotations for this namespace. This method delegates to parseXSDAnnotations(nsUri, value).

Parameters:
nsUri the namespace
value the value of the option
 
    public void addSchemaParseAnnotations(String nsUriBoolean value)
    {
       super.setParseXSDAnnotations(nsUrivalue);
    }
   
   
Removes the parse annotation configuration for this namespace. This method delegates to unsetParseXSDAnnotations(nsURI).

Parameters:
nsUri the namespace
Returns:
the previous value
 
    {
       return super.unsetParseXSDAnnotations(nsUri);
    }

   
Registers a SchemaBindingInitializer for the namespace URI. When the schema binding that corresponds to the namespace URI is resolved, the init(SchemaBinding schema) method will be invoked on the instance of SchemaBindingInitializer with the SchemaBinding returned from the XsdBinder.bind() method. This method delegates to mapSchemaInitializer(nsUri, sbiClassName).

Parameters:
nsUri the namespace URI to register the schema initializer for
sbiClassName the class name SchemaBindingInitializer
Throws:
java.lang.Exception for any error
   public void addSchemaInitializer(String nsUriString sbiClassNamethrows Exception
   {
      super.mapSchemaInitializer(nsUrisbiClassName);
   }

   
Registers an instance of SchemaBindingInitializer for the namespace URI. When the schema binding that corresponds to the namespace URI is resolved, the init(SchemaBinding schema) method will be invoked on the instance of SchemaBindingInitializer with the SchemaBinding returned from the XsdBinder.bind() method. This method delegates to mapSchemaInitializer(nsUri, sbi).

Parameters:
nsUri the namespace URI to register the schema initializer for
sbi an instance of SchemaBindingInitializer
   public void addSchemaInitializer(String nsUriSchemaBindingInitializer sbi)
   {
      super.mapSchemaInitializer(nsUrisbi);
   }

   
Add an in-memory schema.

Parameters:
nsUri schema namespace
reference the schema reference class name
Throws:
java.lang.Exception for any error
   public void addClassBinding(String nsUriString referencethrows ClassNotFoundException
   {
      super.mapURIToClass(nsUrireference);
   }
   public void addClassBinding(String nsUriClass<?> clazz)
   {
      .put(nsUriclazz);
   }
   public Class<?> removeClassBinding(String nsUri)
   {
      return .remove(nsUri);      
   }
   public void addClassBindingForLocation(String schemaLocationClass<?> clazz)
   {
      .put(schemaLocationclazz);
   }
   
   public Class<?> removeClassBindingForLocation(String schemaLocation)
   {
      return .remove(schemaLocation);
   }
   protected Class<?>[] getClassesForSchemaLocation(String uri)
   {
      Class<?> c = .get(uri);
      return c == null ? null : new Class<?>[]{c};
   }
   protected Class<?>[] getClassesForURI(String uri)
   {
      Class<?> c = .get(uri);
      return c == null ? null : new Class<?>[]{c};
   }
   public void mapLocationToClass(String schemaLocationClass<?> clazz)
   {
      this.addClassBindingForLocation(schemaLocationclazz);
   }
   public void mapLocationToClasses(String schemaLocationClass<?>... classes)
   {
      throw new UnsupportedOperationException("This implementation supports schema location mapping to a single class only.");
   }
   public void mapURIToClass(String nsUriClass<?> clazz)
   {
      this.addClassBinding(nsUriclazz);
   }
   public void mapURIToClasses(String nsUriString... referencethrows ClassNotFoundException
   {
      throw new UnsupportedOperationException("This implementation supports URI mapping to a single class only.");      
   }
   public void mapURIToClasses(String nsUriClass<?>... clazz)
   {
      throw new UnsupportedOperationException("This implementation supports URI mapping to a single class only.");      
   }
   public Class<?>[] removeLocationToClassMapping(String schemaLocation)
   {
      Class<?> c = removeClassBindingForLocation(schemaLocation);
      return c == null ? null : new Class[]{c};
   }
   public Class<?>[] removeURIToClassMapping(String nsUri)
   {
      Class<?> c = this.removeClassBinding(nsUri);
      return c == null ? null : new Class<?>[]{c};
   }
New to GrepCode? Check out our FAQ X