View Javadoc
1   package org.exolab.castor.xml;
2   
3   import org.castor.mapping.BindingType;
4   import org.exolab.castor.xml.util.XMLClassDescriptorResolverImpl;
5   import org.exolab.castor.xml.util.resolvers.CastorXMLStrategy;
6   
7   /**
8    * A factory that - based upon the binding type specified - returns {@link ClassDescriptorResolver}
9    * instances.
10   * 
11   * @author <a href="mailto: wguttmn AT codehaus DOT org">Werner Guttmann</a>
12   *
13   */
14  public class ClassDescriptorResolverFactory {
15  
16    /**
17     * Returns the matching {@link ClassDescriptorResolver} instance.
18     * 
19     * @param type A binding type.
20     * @return A {@link ClassDescriptorResolver} instance.
21     */
22    public static ClassDescriptorResolver createClassDescriptorResolver(final BindingType type) {
23      if (type == BindingType.XML) {
24        XMLClassDescriptorResolver resolver = new XMLClassDescriptorResolverImpl();
25        // for cases in which users really work with the factory only and not
26        // with any kind of InternalContext...
27        resolver.setResolverStrategy(new CastorXMLStrategy());
28        return resolver;
29      }
30      // TODO: throw IllegalArgumentException instead ?
31      return null;
32    }
33  }