1 /* 2 * Copyright 2006 Werner Guttmann 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 * in compliance with the License. You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software distributed under the License 10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 * or implied. See the License for the specific language governing permissions and limitations under 12 * the License. 13 */ 14 package org.exolab.castor.builder.types; 15 16 17 /** 18 * Helper class to facilitate creation of XML schema collection types. 19 * 20 * @author <a href="mailto:werner DOT guttmann AT gmx DOT net">Werner Guttmann</a> 21 * @since 1.1 22 * 23 */ 24 public final class XSCollectionFactory { 25 26 /** 27 * A private constructor as this is a factory which is never meant to be instantiated. 28 */ 29 private XSCollectionFactory() { 30 super(); 31 } 32 33 /** 34 * Factory method to create an XS collection type, i.e. an instance of {@link XSListType}. 35 * 36 * @param collectionName The name of the Java collection type,e.g. 'java.util.Collection' 37 * @param contentType the content type of the collection, ie. the type of objects that the 38 * collection will contain 39 * @param useJava50 true if source code is supposed to be generated for Java 5 40 * @return An {@link XSListType} instance. 41 * @see XSListType 42 */ 43 public static XSListType createCollection(final String collectionName, final XSType contentType, 44 final boolean useJava50) { 45 XSListType collection = null; 46 if (contentType instanceof XSIdRef) { 47 collection = new XSIdRefs(collectionName, useJava50); 48 } else if (contentType instanceof XSNMToken) { 49 collection = new XSNMTokens(collectionName, useJava50); 50 } else { 51 collection = new XSList(collectionName, contentType, useJava50); 52 } 53 return collection; 54 } 55 }