001: /*
002: * Portions Copyright 2006 Sun Microsystems, Inc. All Rights Reserved.
003: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004: *
005: * This code is free software; you can redistribute it and/or modify it
006: * under the terms of the GNU General Public License version 2 only, as
007: * published by the Free Software Foundation. Sun designates this
008: * particular file as subject to the "Classpath" exception as provided
009: * by Sun in the LICENSE file that accompanied this code.
010: *
011: * This code is distributed in the hope that it will be useful, but WITHOUT
012: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
014: * version 2 for more details (a copy is included in the LICENSE file that
015: * accompanied this code).
016: *
017: * You should have received a copy of the GNU General Public License version
018: * 2 along with this work; if not, write to the Free Software Foundation,
019: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020: *
021: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022: * CA 95054 USA or visit www.sun.com if you need additional information or
023: * have any questions.
024: */
025:
026: package com.sun.tools.internal.ws.wsdl.parser;
027:
028: import java.util.HashSet;
029: import java.util.Set;
030:
031: import javax.xml.namespace.QName;
032:
033: import com.sun.tools.internal.ws.wsdl.document.schema.SchemaConstants;
034: import com.sun.tools.internal.ws.wsdl.document.schema.SchemaKinds;
035: import com.sun.tools.internal.ws.wsdl.document.soap.SOAPConstants;
036: import com.sun.tools.internal.ws.wsdl.framework.EntityReferenceValidator;
037: import com.sun.tools.internal.ws.wsdl.framework.Kind;
038:
039: /**
040: * An interface implemented by a class that is capable of validating
041: * a QName/Kind pair referring to an external entity.
042: *
043: * @author WS Development Team
044: */
045: public class SOAPEntityReferenceValidator implements
046: EntityReferenceValidator {
047: public SOAPEntityReferenceValidator() {
048: }
049:
050: public boolean isValid(Kind kind, QName name) {
051:
052: // just let all "xml:" QNames through
053: if (name.getNamespaceURI().equals(Constants.NS_XML))
054: return true;
055:
056: if (kind == SchemaKinds.XSD_TYPE) {
057: return _validTypes.contains(name);
058: } else if (kind == SchemaKinds.XSD_ELEMENT) {
059: return _validElements.contains(name);
060: } else if (kind == SchemaKinds.XSD_ATTRIBUTE) {
061: return _validAttributes.contains(name);
062: } else {
063: // no luck
064: return false;
065: }
066: }
067:
068: private static final Set _validTypes;
069: private static final Set _validElements;
070: private static final Set _validAttributes;
071:
072: static {
073: // add all XML Schema and SOAP types
074: _validTypes = new HashSet();
075: _validTypes.add(SOAPConstants.QNAME_TYPE_ARRAY);
076: _validTypes.add(SchemaConstants.QNAME_TYPE_STRING);
077: _validTypes.add(SchemaConstants.QNAME_TYPE_NORMALIZED_STRING);
078: _validTypes.add(SchemaConstants.QNAME_TYPE_TOKEN);
079: _validTypes.add(SchemaConstants.QNAME_TYPE_BYTE);
080: _validTypes.add(SchemaConstants.QNAME_TYPE_UNSIGNED_BYTE);
081: _validTypes.add(SchemaConstants.QNAME_TYPE_BASE64_BINARY);
082: _validTypes.add(SchemaConstants.QNAME_TYPE_HEX_BINARY);
083: _validTypes.add(SchemaConstants.QNAME_TYPE_INTEGER);
084: _validTypes.add(SchemaConstants.QNAME_TYPE_POSITIVE_INTEGER);
085: _validTypes.add(SchemaConstants.QNAME_TYPE_NEGATIVE_INTEGER);
086: _validTypes
087: .add(SchemaConstants.QNAME_TYPE_NON_NEGATIVE_INTEGER);
088: _validTypes
089: .add(SchemaConstants.QNAME_TYPE_NON_POSITIVE_INTEGER);
090: _validTypes.add(SchemaConstants.QNAME_TYPE_INT);
091: _validTypes.add(SchemaConstants.QNAME_TYPE_UNSIGNED_INT);
092: _validTypes.add(SchemaConstants.QNAME_TYPE_LONG);
093: _validTypes.add(SchemaConstants.QNAME_TYPE_UNSIGNED_LONG);
094: _validTypes.add(SchemaConstants.QNAME_TYPE_SHORT);
095: _validTypes.add(SchemaConstants.QNAME_TYPE_UNSIGNED_SHORT);
096: _validTypes.add(SchemaConstants.QNAME_TYPE_DECIMAL);
097: _validTypes.add(SchemaConstants.QNAME_TYPE_FLOAT);
098: _validTypes.add(SchemaConstants.QNAME_TYPE_DOUBLE);
099: _validTypes.add(SchemaConstants.QNAME_TYPE_BOOLEAN);
100: _validTypes.add(SchemaConstants.QNAME_TYPE_TIME);
101: _validTypes.add(SchemaConstants.QNAME_TYPE_DATE_TIME);
102: _validTypes.add(SchemaConstants.QNAME_TYPE_DURATION);
103: _validTypes.add(SchemaConstants.QNAME_TYPE_DATE);
104: _validTypes.add(SchemaConstants.QNAME_TYPE_G_MONTH);
105: _validTypes.add(SchemaConstants.QNAME_TYPE_G_YEAR);
106: _validTypes.add(SchemaConstants.QNAME_TYPE_G_YEAR_MONTH);
107: _validTypes.add(SchemaConstants.QNAME_TYPE_G_DAY);
108: _validTypes.add(SchemaConstants.QNAME_TYPE_G_MONTH_DAY);
109: _validTypes.add(SchemaConstants.QNAME_TYPE_NAME);
110: _validTypes.add(SchemaConstants.QNAME_TYPE_QNAME);
111: _validTypes.add(SchemaConstants.QNAME_TYPE_NCNAME);
112: _validTypes.add(SchemaConstants.QNAME_TYPE_ANY_URI);
113: _validTypes.add(SchemaConstants.QNAME_TYPE_ID);
114: _validTypes.add(SchemaConstants.QNAME_TYPE_IDREF);
115: _validTypes.add(SchemaConstants.QNAME_TYPE_IDREFS);
116: _validTypes.add(SchemaConstants.QNAME_TYPE_ENTITY);
117: _validTypes.add(SchemaConstants.QNAME_TYPE_ENTITIES);
118: _validTypes.add(SchemaConstants.QNAME_TYPE_NOTATION);
119: _validTypes.add(SchemaConstants.QNAME_TYPE_NMTOKEN);
120: _validTypes.add(SchemaConstants.QNAME_TYPE_NMTOKENS);
121: _validTypes.add(SchemaConstants.QNAME_TYPE_URTYPE);
122: _validTypes.add(SchemaConstants.QNAME_TYPE_SIMPLE_URTYPE);
123: _validTypes.add(SOAPConstants.QNAME_TYPE_STRING);
124: _validTypes.add(SOAPConstants.QNAME_TYPE_NORMALIZED_STRING);
125: _validTypes.add(SOAPConstants.QNAME_TYPE_TOKEN);
126: _validTypes.add(SOAPConstants.QNAME_TYPE_BYTE);
127: _validTypes.add(SOAPConstants.QNAME_TYPE_UNSIGNED_BYTE);
128: _validTypes.add(SOAPConstants.QNAME_TYPE_BASE64_BINARY);
129: _validTypes.add(SOAPConstants.QNAME_TYPE_HEX_BINARY);
130: _validTypes.add(SOAPConstants.QNAME_TYPE_INTEGER);
131: _validTypes.add(SOAPConstants.QNAME_TYPE_POSITIVE_INTEGER);
132: _validTypes.add(SOAPConstants.QNAME_TYPE_NEGATIVE_INTEGER);
133: _validTypes.add(SOAPConstants.QNAME_TYPE_NON_NEGATIVE_INTEGER);
134: _validTypes.add(SOAPConstants.QNAME_TYPE_NON_POSITIVE_INTEGER);
135: _validTypes.add(SOAPConstants.QNAME_TYPE_INT);
136: _validTypes.add(SOAPConstants.QNAME_TYPE_UNSIGNED_INT);
137: _validTypes.add(SOAPConstants.QNAME_TYPE_LONG);
138: _validTypes.add(SOAPConstants.QNAME_TYPE_UNSIGNED_LONG);
139: _validTypes.add(SOAPConstants.QNAME_TYPE_SHORT);
140: _validTypes.add(SOAPConstants.QNAME_TYPE_UNSIGNED_SHORT);
141: _validTypes.add(SOAPConstants.QNAME_TYPE_DECIMAL);
142: _validTypes.add(SOAPConstants.QNAME_TYPE_FLOAT);
143: _validTypes.add(SOAPConstants.QNAME_TYPE_DOUBLE);
144: _validTypes.add(SOAPConstants.QNAME_TYPE_BOOLEAN);
145: _validTypes.add(SOAPConstants.QNAME_TYPE_TIME);
146: _validTypes.add(SOAPConstants.QNAME_TYPE_DATE_TIME);
147: _validTypes.add(SOAPConstants.QNAME_TYPE_DURATION);
148: _validTypes.add(SOAPConstants.QNAME_TYPE_DATE);
149: _validTypes.add(SOAPConstants.QNAME_TYPE_G_MONTH);
150: _validTypes.add(SOAPConstants.QNAME_TYPE_G_YEAR);
151: _validTypes.add(SOAPConstants.QNAME_TYPE_G_YEAR_MONTH);
152: _validTypes.add(SOAPConstants.QNAME_TYPE_G_DAY);
153: _validTypes.add(SOAPConstants.QNAME_TYPE_G_MONTH_DAY);
154: _validTypes.add(SOAPConstants.QNAME_TYPE_NAME);
155: _validTypes.add(SOAPConstants.QNAME_TYPE_QNAME);
156: _validTypes.add(SOAPConstants.QNAME_TYPE_NCNAME);
157: _validTypes.add(SOAPConstants.QNAME_TYPE_ANY_URI);
158: _validTypes.add(SOAPConstants.QNAME_TYPE_ID);
159: _validTypes.add(SOAPConstants.QNAME_TYPE_IDREF);
160: _validTypes.add(SOAPConstants.QNAME_TYPE_IDREFS);
161: _validTypes.add(SOAPConstants.QNAME_TYPE_ENTITY);
162: _validTypes.add(SOAPConstants.QNAME_TYPE_ENTITIES);
163: _validTypes.add(SOAPConstants.QNAME_TYPE_NOTATION);
164: _validTypes.add(SOAPConstants.QNAME_TYPE_NMTOKEN);
165: _validTypes.add(SOAPConstants.QNAME_TYPE_NMTOKENS);
166: _validTypes.add(SOAPConstants.QNAME_TYPE_BASE64);
167: // New types 12/3/02
168: _validTypes.add(SchemaConstants.QNAME_TYPE_LANGUAGE);
169:
170: // add all SOAP encoding elements
171: _validElements = new HashSet();
172: _validElements.add(SOAPConstants.QNAME_ELEMENT_STRING);
173: _validElements
174: .add(SOAPConstants.QNAME_ELEMENT_NORMALIZED_STRING);
175: _validElements.add(SOAPConstants.QNAME_ELEMENT_TOKEN);
176: _validElements.add(SOAPConstants.QNAME_ELEMENT_BYTE);
177: _validElements.add(SOAPConstants.QNAME_ELEMENT_UNSIGNED_BYTE);
178: _validElements.add(SOAPConstants.QNAME_ELEMENT_BASE64_BINARY);
179: _validElements.add(SOAPConstants.QNAME_ELEMENT_HEX_BINARY);
180: _validElements.add(SOAPConstants.QNAME_ELEMENT_INTEGER);
181: _validElements
182: .add(SOAPConstants.QNAME_ELEMENT_POSITIVE_INTEGER);
183: _validElements
184: .add(SOAPConstants.QNAME_ELEMENT_NEGATIVE_INTEGER);
185: _validElements
186: .add(SOAPConstants.QNAME_ELEMENT_NON_NEGATIVE_INTEGER);
187: _validElements
188: .add(SOAPConstants.QNAME_ELEMENT_NON_POSITIVE_INTEGER);
189: _validElements.add(SOAPConstants.QNAME_ELEMENT_INT);
190: _validElements.add(SOAPConstants.QNAME_ELEMENT_UNSIGNED_INT);
191: _validElements.add(SOAPConstants.QNAME_ELEMENT_LONG);
192: _validElements.add(SOAPConstants.QNAME_ELEMENT_UNSIGNED_LONG);
193: _validElements.add(SOAPConstants.QNAME_ELEMENT_SHORT);
194: _validElements.add(SOAPConstants.QNAME_ELEMENT_UNSIGNED_SHORT);
195: _validElements.add(SOAPConstants.QNAME_ELEMENT_DECIMAL);
196: _validElements.add(SOAPConstants.QNAME_ELEMENT_FLOAT);
197: _validElements.add(SOAPConstants.QNAME_ELEMENT_DOUBLE);
198: _validElements.add(SOAPConstants.QNAME_ELEMENT_BOOLEAN);
199: _validElements.add(SOAPConstants.QNAME_ELEMENT_TIME);
200: _validElements.add(SOAPConstants.QNAME_ELEMENT_DATE_TIME);
201: _validElements.add(SOAPConstants.QNAME_ELEMENT_DURATION);
202: _validElements.add(SOAPConstants.QNAME_ELEMENT_DATE);
203: _validElements.add(SOAPConstants.QNAME_ELEMENT_G_MONTH);
204: _validElements.add(SOAPConstants.QNAME_ELEMENT_G_YEAR);
205: _validElements.add(SOAPConstants.QNAME_ELEMENT_G_YEAR_MONTH);
206: _validElements.add(SOAPConstants.QNAME_ELEMENT_G_DAY);
207: _validElements.add(SOAPConstants.QNAME_ELEMENT_G_MONTH_DAY);
208: _validElements.add(SOAPConstants.QNAME_ELEMENT_NAME);
209: _validElements.add(SOAPConstants.QNAME_ELEMENT_QNAME);
210: _validElements.add(SOAPConstants.QNAME_ELEMENT_NCNAME);
211: _validElements.add(SOAPConstants.QNAME_ELEMENT_ANY_URI);
212: _validElements.add(SOAPConstants.QNAME_ELEMENT_ID);
213: _validElements.add(SOAPConstants.QNAME_ELEMENT_IDREF);
214: _validElements.add(SOAPConstants.QNAME_ELEMENT_IDREFS);
215: _validElements.add(SOAPConstants.QNAME_ELEMENT_ENTITY);
216: _validElements.add(SOAPConstants.QNAME_ELEMENT_ENTITIES);
217: _validElements.add(SOAPConstants.QNAME_ELEMENT_NOTATION);
218: _validElements.add(SOAPConstants.QNAME_ELEMENT_NMTOKEN);
219: _validElements.add(SOAPConstants.QNAME_ELEMENT_NMTOKENS);
220:
221: _validAttributes = new HashSet();
222: _validAttributes.add(SOAPConstants.QNAME_ATTR_ARRAY_TYPE);
223: _validAttributes.add(SOAPConstants.QNAME_ATTR_OFFSET);
224: _validAttributes.add(SOAPConstants.QNAME_ATTR_POSITION);
225: }
226: }
|