1 /* 2 * Redistribution and use of this software and associated documentation ("Software"), with or 3 * without modification, are permitted provided that the following conditions are met: 4 * 5 * 1. Redistributions of source code must retain copyright statements and notices. Redistributions 6 * must also contain a copy of this document. 7 * 8 * 2. Redistributions in binary form must reproduce the above copyright notice, this list of 9 * conditions and the following disclaimer in the documentation and/or other materials provided with 10 * the distribution. 11 * 12 * 3. The name "Exolab" must not be used to endorse or promote products derived from this Software 13 * without prior written permission of Intalio, Inc. For written permission, please contact 14 * info@exolab.org. 15 * 16 * 4. Products derived from this Software may not be called "Exolab" nor may "Exolab" appear in 17 * their names without prior written permission of Intalio, Inc. Exolab is a registered trademark of 18 * Intalio, Inc. 19 * 20 * 5. Due credit should be given to the Exolab Project (http://www.exolab.org/). 21 * 22 * THIS SOFTWARE IS PROVIDED BY INTALIO, INC. AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR 23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 24 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTALIO, INC. OR ITS 25 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY 29 * WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 * 31 * Copyright 1999 (C) Intalio, Inc. All Rights Reserved. 32 * 33 * $Id$ 34 */ 35 package org.exolab.castor.builder; 36 37 import org.exolab.javasource.JClass; 38 import org.exolab.javasource.JCollectionType; 39 import org.exolab.javasource.JType; 40 41 /** 42 * A collection of type definitions and factory methods to create those types, as used by the XML 43 * code generator of Castor during code generation. 44 * 45 * @author <a href="mailto:kvisco@intalio.com">Keith Visco</a> 46 * @version $Revision$ $Date: 2005-10-10 06:35:52 -0600 (Mon, 10 Oct 2005) $ 47 */ 48 public class SGTypes { 49 50 /** 51 * Represents a {@link JClass} instance of type 'org.exolab.castor.xml.MarshalException'. 52 */ 53 public static final JClass MARSHAL_EXCEPTION = 54 new JClass("org.exolab.castor.xml.MarshalException"); 55 56 /** 57 * Represents a {@link JClass} instance of type 'org.exolab.castor.xml.ValidationException'. 58 */ 59 public static final JClass VALIDATION_EXCEPTION = 60 new JClass("org.exolab.castor.xml.ValidationException"); 61 62 /** 63 * Represents a {@link JClass} instance of type 'java.lang.IndexOutOfBoundsException'. 64 */ 65 public static final JClass INDEX_OUT_OF_BOUNDS_EXCEPTION = 66 new JClass("java.lang.IndexOutOfBoundsException"); 67 68 /** 69 * Represents a {@link JClass} instance of type 'java.lang.Class'. 70 */ 71 public static final JClass CLASS = new JClass("java.lang.Class"); 72 73 /** 74 * Represents a {@link JClass} instance of type 'java.lang.Object'. 75 */ 76 public static final JClass OBJECT = new JClass("java.lang.Object"); 77 78 /** 79 * Represents a {@link JClass} instance of type 'java.lang.String'. 80 */ 81 public static final JClass STRING = new JClass("java.lang.String"); 82 83 /** 84 * Represents a {@link JClass} instance of type 'java.io.IOException'. 85 */ 86 public static final JClass IO_EXCEPTION = new JClass("java.io.IOException"); 87 88 /** 89 * Represents a {@link JClass} instance of type 'java.io.Reader'. 90 */ 91 public static final JClass READER = new JClass("java.io.Reader"); 92 93 /** 94 * Represents a {@link JClass} instance of type 'java.lang.Writer'. 95 */ 96 public static final JClass WRITER = new JClass("java.io.Writer"); 97 98 /** 99 * Represents a {@link JClass} instance of type 'java.beans.PropertyChangeSupport'. 100 */ 101 public static final JClass PROPERTY_CHANGE_SUPPORT = 102 new JClass("java.beans.PropertyChangeSupport"); 103 104 /** 105 * Factory method for creating a {@link JCollectionType} instance representing an enumeration. 106 * 107 * @param jType The content type of the collection. 108 * @param usejava50 Whether Java 5.0 is the target JVM. 109 * @return {@link JCollectionType} instance representing an enumeration 110 */ 111 public static final JType createEnumeration(final JType jType, final boolean usejava50) { 112 return createEnumeration(jType, usejava50, false); 113 } 114 115 /** 116 * Factory method for creating a {@link JCollectionType} instance representing an enumeration. 117 * 118 * @param jType The content type of the collection. 119 * @param usejava50 Whether Java 5.0 is the target JVM. 120 * @param useExtends True if '? extends' should be emitted for generics (Java 5.0 ff only). 121 * @return {@link JCollectionType} instance representing an enumeration 122 */ 123 public static final JType createEnumeration(final JType jType, final boolean usejava50, 124 final boolean useExtends) { 125 return new JCollectionType("java.util.Enumeration", jType, usejava50, useExtends); 126 } 127 128 /** 129 * Factory method for creating a {@link JCollectionType} instance representing an {@link Iterator} 130 * instance. 131 * 132 * @param jType The content type of the collection. 133 * @param usejava50 Whether Java 5.0 is the target JVM. 134 * @return {@link JCollectionType} instance representing an {@link Iterator} 135 */ 136 public static final JType createIterator(final JType jType, final boolean usejava50) { 137 return createIterator(jType, usejava50, false); 138 } 139 140 /** 141 * Factory method for creating a {@link JCollectionType} instance representing an {@link Iterator} 142 * instance. 143 * 144 * @param jType The content type of the collection. 145 * @param usejava50 Whether Java 5.0 is the target JVM. 146 * @param useExtends True if '? extends' should be emitted for generics (Java 5.0 ff only). 147 * @return {@link JCollectionType} instance representing an {@link Iterator} 148 */ 149 public static final JType createIterator(final JType jType, final boolean usejava50, 150 final boolean useExtends) { 151 return new JCollectionType("java.util.Iterator", jType, usejava50, useExtends); 152 } 153 154 /** 155 * Factory method for creating a {@link JCollectionType} instance representing an 156 * {@link Hashtable} instance. 157 * 158 * @param useJava50 Whether Java 5.0 is the target JVM. 159 * @return {@link JCollectionType} instance representing a {@link Hashtable} 160 */ 161 public static final JType createHashtable(final boolean useJava50) { 162 if (useJava50) { 163 return new JClass("java.util.Hashtable<Object,Object>"); 164 } 165 return new JClass("java.util.Hashtable"); 166 } 167 }