001: /*
002: * $Id: AttributeDefinition.java,v 1.4 2004/07/11 09:37:37 yuvalo Exp $
003: *
004: * (C) Copyright 2002-2004 by Yuval Oren. All rights reserved.
005: *
006: * Licensed under the Apache License, Version 2.0 (the "License");
007: * you may not use this file except in compliance with the License.
008: * You may obtain a copy of the License at
009: *
010: * http://www.apache.org/licenses/LICENSE-2.0
011: *
012: * Unless required by applicable law or agreed to in writing, software
013: * distributed under the License is distributed on an "AS IS" BASIS,
014: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015: * See the License for the specific language governing permissions and
016: * limitations under the License.
017: */
018:
019: package com.bluecast.xml;
020:
021: /**
022: * A class to hold information about an attribute defined
023: * within an XML document type declaration.
024: *
025: * @author Yuval Oren, yuval@bluecast.com
026: * @version $Revision: 1.4 $
027: */
028: final public class AttributeDefinition {
029: // Attribute Defaults
030: static public final int IMPLIED = 1;
031: static public final int REQUIRED = 2;
032: static public final int FIXED = 3;
033: // Attribute Value Types
034: static public final int ENUMERATION = 1;
035: static public final int NOTATION = 2;
036: static public final int CDATA = 3;
037: static public final int ID = 4;
038: static public final int IDREF = 5;
039: static public final int IDREFS = 6;
040: static public final int ENTITY = 7;
041: static public final int ENTITIES = 8;
042: static public final int NMTOKEN = 9;
043: static public final int NMTOKENS = 10;
044: static private final String[] valueTypeStrings = { null, "NMTOKEN",
045: "NOTATION", "CDATA", "ID", "IDREF", "IDREFS", "ENTITY",
046: "ENTITIES", "NMTOKEN", "NMTOKENS" };
047: static private final String[] defaultTypeStrings = { null,
048: "#IMPLIED", "#REQUIRED", "#FIXED" };
049:
050: String prefix, localName, qName;
051: int valueType;
052: int defaultType;
053: String defaultValue;
054: String[] possibleValues;
055:
056: public AttributeDefinition(String prefix, String localName,
057: String qName, int valueType, String[] possibleValues,
058: int defaultType, String defaultValue) {
059: this .prefix = prefix;
060: this .localName = localName;
061: this .qName = qName;
062: this .valueType = valueType;
063: this .possibleValues = possibleValues;
064: this .defaultType = defaultType;
065: this .defaultValue = defaultValue;
066: }
067:
068: public String getPrefix() {
069: return prefix;
070: }
071:
072: public String getLocalName() {
073: return localName;
074: }
075:
076: public String getQName() {
077: return qName;
078: }
079:
080: public int getValueType() {
081: return valueType;
082: }
083:
084: public String getValueTypeString() {
085: return getValueTypeString(valueType);
086: }
087:
088: static public String getValueTypeString(int valueType) {
089: return valueTypeStrings[valueType];
090: }
091:
092: public int getDefaultType() {
093: return defaultType;
094: }
095:
096: public String getDefaultTypeString() {
097: return getDefaultTypeString(defaultType);
098: }
099:
100: static public String getDefaultTypeString(int defaultType) {
101: return defaultTypeStrings[defaultType];
102: }
103:
104: public String getDefaultValue() {
105: return defaultValue;
106: }
107:
108: public String[] getPossibleValues() {
109: return possibleValues;
110: }
111: }
|