1 /* 2 * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 * 25 * THIS FILE WAS MODIFIED BY SUN MICROSYSTEMS, INC. 26 */ 27 28 /* 29 * Copyright 2005 The Apache Software Foundation. 30 */ 31 32 package com.sun.xml.internal.stream.dtd.nonvalidating; 33 /** 34 */ 35 public class XMLSimpleType { 36 37 // 38 // Constants 39 // 40 41 /** TYPE_CDATA */ 42 public static final short TYPE_CDATA = 0; 43 44 /** TYPE_ENTITY */ 45 public static final short TYPE_ENTITY = 1; 46 47 /** TYPE_ENUMERATION */ 48 public static final short TYPE_ENUMERATION = 2; 49 50 /** TYPE_ID */ 51 public static final short TYPE_ID = 3; 52 53 /** TYPE_IDREF */ 54 public static final short TYPE_IDREF = 4; 55 56 /** TYPE_NMTOKEN */ 57 public static final short TYPE_NMTOKEN = 5; 58 59 /** TYPE_NOTATION */ 60 public static final short TYPE_NOTATION = 6; 61 62 /** TYPE_NAMED */ 63 public static final short TYPE_NAMED = 7; 64 65 /** DEFAULT_TYPE_DEFAULT */ 66 public static final short DEFAULT_TYPE_DEFAULT = 3; 67 68 /** DEFAULT_TYPE_FIXED */ 69 public static final short DEFAULT_TYPE_FIXED = 1; 70 71 /** DEFAULT_TYPE_IMPLIED */ 72 public static final short DEFAULT_TYPE_IMPLIED = 0; 73 74 /** DEFAULT_TYPE_REQUIRED */ 75 public static final short DEFAULT_TYPE_REQUIRED = 2; 76 77 // 78 // Data 79 // 80 81 /** type */ 82 public short type; 83 84 /** name */ 85 public String name; 86 87 /** enumeration */ 88 public String[] enumeration; 89 90 /** list */ 91 public boolean list; 92 93 /** defaultType */ 94 public short defaultType; 95 96 /** defaultValue */ 97 public String defaultValue; 98 99 /** non-normalized defaultValue */ 100 public String nonNormalizedDefaultValue; 101 102 103 // 104 // Methods 105 // 106 107 /** 108 * setValues 109 * 110 * @param type 111 * @param name 112 * @param enumeration 113 * @param list 114 * @param defaultType 115 * @param defaultValue 116 * @param nonNormalizedDefaultValue 117 * @param datatypeValidator 118 */ setValues(short type, String name, String[] enumeration, boolean list, short defaultType, String defaultValue, String nonNormalizedDefaultValue)119 public void setValues(short type, String name, String[] enumeration, 120 boolean list, short defaultType, 121 String defaultValue, String nonNormalizedDefaultValue){ 122 123 this.type = type; 124 this.name = name; 125 // REVISIT: Should this be a copy? -Ac 126 if (enumeration != null && enumeration.length > 0) { 127 this.enumeration = new String[enumeration.length]; 128 System.arraycopy(enumeration, 0, this.enumeration, 0, this.enumeration.length); 129 } 130 else { 131 this.enumeration = null; 132 } 133 this.list = list; 134 this.defaultType = defaultType; 135 this.defaultValue = defaultValue; 136 this.nonNormalizedDefaultValue = nonNormalizedDefaultValue; 137 138 } // setValues(short,String,String[],boolean,short,String,String,DatatypeValidator) 139 140 /** Set values. */ setValues(XMLSimpleType simpleType)141 public void setValues(XMLSimpleType simpleType) { 142 143 type = simpleType.type; 144 name = simpleType.name; 145 // REVISIT: Should this be a copy? -Ac 146 if (simpleType.enumeration != null && simpleType.enumeration.length > 0) { 147 enumeration = new String[simpleType.enumeration.length]; 148 System.arraycopy(simpleType.enumeration, 0, enumeration, 0, enumeration.length); 149 } 150 else { 151 enumeration = null; 152 } 153 list = simpleType.list; 154 defaultType = simpleType.defaultType; 155 defaultValue = simpleType.defaultValue; 156 nonNormalizedDefaultValue = simpleType.nonNormalizedDefaultValue; 157 158 } // setValues(XMLSimpleType) 159 160 /** 161 * clear 162 */ clear()163 public void clear() { 164 this.type = -1; 165 this.name = null; 166 this.enumeration = null; 167 this.list = false; 168 this.defaultType = -1; 169 this.defaultValue = null; 170 this.nonNormalizedDefaultValue = null; 171 } 172 173 } // class XMLSimpleType 174