1. /*
  2. * The Apache Software License, Version 1.1
  3. *
  4. *
  5. * Copyright (c) 1999-2002 The Apache Software Foundation. All rights
  6. * reserved.
  7. *
  8. * Redistribution and use in source and binary forms, with or without
  9. * modification, are permitted provided that the following conditions
  10. * are met:
  11. *
  12. * 1. Redistributions of source code must retain the above copyright
  13. * notice, this list of conditions and the following disclaimer.
  14. *
  15. * 2. Redistributions in binary form must reproduce the above copyright
  16. * notice, this list of conditions and the following disclaimer in
  17. * the documentation and/or other materials provided with the
  18. * distribution.
  19. *
  20. * 3. The end-user documentation included with the redistribution,
  21. * if any, must include the following acknowledgment:
  22. * "This product includes software developed by the
  23. * Apache Software Foundation (http://www.apache.org/)."
  24. * Alternately, this acknowledgment may appear in the software itself,
  25. * if and wherever such third-party acknowledgments normally appear.
  26. *
  27. * 4. The names "Xerces" and "Apache Software Foundation" must
  28. * not be used to endorse or promote products derived from this
  29. * software without prior written permission. For written
  30. * permission, please contact apache@apache.org.
  31. *
  32. * 5. Products derived from this software may not be called "Apache",
  33. * nor may "Apache" appear in their name, without prior written
  34. * permission of the Apache Software Foundation.
  35. *
  36. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  37. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  38. * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  39. * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  40. * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  41. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  42. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  43. * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  44. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  45. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  46. * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  47. * SUCH DAMAGE.
  48. * ====================================================================
  49. *
  50. * This software consists of voluntary contributions made by many
  51. * individuals on behalf of the Apache Software Foundation and was
  52. * originally based on software copyright (c) 1999, International
  53. * Business Machines, Inc., http://www.apache.org. For more
  54. * information on the Apache Software Foundation, please see
  55. * <http://www.apache.org/>.
  56. */
  57. package com.sun.org.apache.xerces.internal.impl.dtd;
  58. import com.sun.org.apache.xerces.internal.impl.dv.DatatypeValidator;
  59. /**
  60. * @version $Id: XMLSimpleType.java,v 1.5 2002/02/15 16:00:29 sandygao Exp $
  61. */
  62. public class XMLSimpleType {
  63. //
  64. // Constants
  65. //
  66. /** TYPE_CDATA */
  67. public static final short TYPE_CDATA = 0;
  68. /** TYPE_ENTITY */
  69. public static final short TYPE_ENTITY = 1;
  70. /** TYPE_ENUMERATION */
  71. public static final short TYPE_ENUMERATION = 2;
  72. /** TYPE_ID */
  73. public static final short TYPE_ID = 3;
  74. /** TYPE_IDREF */
  75. public static final short TYPE_IDREF = 4;
  76. /** TYPE_NMTOKEN */
  77. public static final short TYPE_NMTOKEN = 5;
  78. /** TYPE_NOTATION */
  79. public static final short TYPE_NOTATION = 6;
  80. /** TYPE_NAMED */
  81. public static final short TYPE_NAMED = 7;
  82. /** DEFAULT_TYPE_DEFAULT */
  83. public static final short DEFAULT_TYPE_DEFAULT = 3;
  84. /** DEFAULT_TYPE_FIXED */
  85. public static final short DEFAULT_TYPE_FIXED = 1;
  86. /** DEFAULT_TYPE_IMPLIED */
  87. public static final short DEFAULT_TYPE_IMPLIED = 0;
  88. /** DEFAULT_TYPE_REQUIRED */
  89. public static final short DEFAULT_TYPE_REQUIRED = 2;
  90. //
  91. // Data
  92. //
  93. /** type */
  94. public short type;
  95. /** name */
  96. public String name;
  97. /** enumeration */
  98. public String[] enumeration;
  99. /** list */
  100. public boolean list;
  101. /** defaultType */
  102. public short defaultType;
  103. /** defaultValue */
  104. public String defaultValue;
  105. /** non-normalized defaultValue */
  106. public String nonNormalizedDefaultValue;
  107. /** datatypeValidator */
  108. public DatatypeValidator datatypeValidator;
  109. //
  110. // Methods
  111. //
  112. /**
  113. * setValues
  114. *
  115. * @param type
  116. * @param name
  117. * @param enumeration
  118. * @param list
  119. * @param defaultType
  120. * @param defaultValue
  121. * @param nonNormalizedDefaultValue
  122. * @param datatypeValidator
  123. */
  124. public void setValues(short type, String name, String[] enumeration,
  125. boolean list, short defaultType,
  126. String defaultValue, String nonNormalizedDefaultValue,
  127. DatatypeValidator datatypeValidator) {
  128. this.type = type;
  129. this.name = name;
  130. // REVISIT: Should this be a copy? -Ac
  131. if (enumeration != null && enumeration.length > 0) {
  132. this.enumeration = new String[enumeration.length];
  133. System.arraycopy(enumeration, 0, this.enumeration, 0, this.enumeration.length);
  134. }
  135. else {
  136. this.enumeration = null;
  137. }
  138. this.list = list;
  139. this.defaultType = defaultType;
  140. this.defaultValue = defaultValue;
  141. this.nonNormalizedDefaultValue = nonNormalizedDefaultValue;
  142. this.datatypeValidator = datatypeValidator;
  143. } // setValues(short,String,String[],boolean,short,String,String,DatatypeValidator)
  144. /** Set values. */
  145. public void setValues(XMLSimpleType simpleType) {
  146. type = simpleType.type;
  147. name = simpleType.name;
  148. // REVISIT: Should this be a copy? -Ac
  149. if (simpleType.enumeration != null && simpleType.enumeration.length > 0) {
  150. enumeration = new String[simpleType.enumeration.length];
  151. System.arraycopy(simpleType.enumeration, 0, enumeration, 0, enumeration.length);
  152. }
  153. else {
  154. enumeration = null;
  155. }
  156. list = simpleType.list;
  157. defaultType = simpleType.defaultType;
  158. defaultValue = simpleType.defaultValue;
  159. nonNormalizedDefaultValue = simpleType.nonNormalizedDefaultValue;
  160. datatypeValidator = simpleType.datatypeValidator;
  161. } // setValues(XMLSimpleType)
  162. /**
  163. * clear
  164. */
  165. public void clear() {
  166. this.type = -1;
  167. this.name = null;
  168. this.enumeration = null;
  169. this.list = false;
  170. this.defaultType = -1;
  171. this.defaultValue = null;
  172. this.nonNormalizedDefaultValue = null;
  173. this.datatypeValidator = null;
  174. } // clear
  175. } // class XMLSimpleType