001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017:
018: package org.apache.xerces.util;
019:
020: import org.apache.xerces.xni.XMLResourceIdentifier;
021:
022: /**
023: * The XMLResourceIdentifierImpl class is an implementation of the
024: * XMLResourceIdentifier interface which defines the location identity
025: * of a resource.
026: *
027: * @author Andy Clark
028: *
029: * @version $Id: XMLResourceIdentifierImpl.java 447241 2006-09-18 05:12:57Z mrglavas $
030: */
031: public class XMLResourceIdentifierImpl implements XMLResourceIdentifier {
032:
033: //
034: // Data
035: //
036:
037: /** The public identifier. */
038: protected String fPublicId;
039:
040: /** The literal system identifier. */
041: protected String fLiteralSystemId;
042:
043: /** The base system identifier. */
044: protected String fBaseSystemId;
045:
046: /** The expanded system identifier. */
047: protected String fExpandedSystemId;
048:
049: /** The namespace of the resource. */
050: protected String fNamespace;
051:
052: //
053: // Constructors
054: //
055:
056: /** Constructs an empty resource identifier. */
057: public XMLResourceIdentifierImpl() {
058: } // <init>()
059:
060: /**
061: * Constructs a resource identifier.
062: *
063: * @param publicId The public identifier.
064: * @param literalSystemId The literal system identifier.
065: * @param baseSystemId The base system identifier.
066: * @param expandedSystemId The expanded system identifier.
067: */
068: public XMLResourceIdentifierImpl(String publicId,
069: String literalSystemId, String baseSystemId,
070: String expandedSystemId) {
071: setValues(publicId, literalSystemId, baseSystemId,
072: expandedSystemId, null);
073: } // <init>(String,String,String,String)
074:
075: /**
076: * Constructs a resource identifier.
077: *
078: * @param publicId The public identifier.
079: * @param literalSystemId The literal system identifier.
080: * @param baseSystemId The base system identifier.
081: * @param expandedSystemId The expanded system identifier.
082: * @param namespace The namespace.
083: */
084: public XMLResourceIdentifierImpl(String publicId,
085: String literalSystemId, String baseSystemId,
086: String expandedSystemId, String namespace) {
087: setValues(publicId, literalSystemId, baseSystemId,
088: expandedSystemId, namespace);
089: } // <init>(String,String,String,String,String)
090:
091: //
092: // Public methods
093: //
094:
095: /** Sets the values of the resource identifier. */
096: public void setValues(String publicId, String literalSystemId,
097: String baseSystemId, String expandedSystemId) {
098: setValues(publicId, literalSystemId, baseSystemId,
099: expandedSystemId, null);
100: } // setValues(String,String,String,String)
101:
102: /** Sets the values of the resource identifier. */
103: public void setValues(String publicId, String literalSystemId,
104: String baseSystemId, String expandedSystemId,
105: String namespace) {
106: fPublicId = publicId;
107: fLiteralSystemId = literalSystemId;
108: fBaseSystemId = baseSystemId;
109: fExpandedSystemId = expandedSystemId;
110: fNamespace = namespace;
111: } // setValues(String,String,String,String,String)
112:
113: /** Clears the values. */
114: public void clear() {
115: fPublicId = null;
116: fLiteralSystemId = null;
117: fBaseSystemId = null;
118: fExpandedSystemId = null;
119: fNamespace = null;
120: } // clear()
121:
122: /** Sets the public identifier. */
123: public void setPublicId(String publicId) {
124: fPublicId = publicId;
125: } // setPublicId(String)
126:
127: /** Sets the literal system identifier. */
128: public void setLiteralSystemId(String literalSystemId) {
129: fLiteralSystemId = literalSystemId;
130: } // setLiteralSystemId(String)
131:
132: /** Sets the base system identifier. */
133: public void setBaseSystemId(String baseSystemId) {
134: fBaseSystemId = baseSystemId;
135: } // setBaseSystemId(String)
136:
137: /** Sets the expanded system identifier. */
138: public void setExpandedSystemId(String expandedSystemId) {
139: fExpandedSystemId = expandedSystemId;
140: } // setExpandedSystemId(String)
141:
142: /** Sets the namespace of the resource. */
143: public void setNamespace(String namespace) {
144: fNamespace = namespace;
145: } // setNamespace(String)
146:
147: //
148: // XMLResourceIdentifier methods
149: //
150:
151: /** Returns the public identifier. */
152: public String getPublicId() {
153: return fPublicId;
154: } // getPublicId():String
155:
156: /** Returns the literal system identifier. */
157: public String getLiteralSystemId() {
158: return fLiteralSystemId;
159: } // getLiteralSystemId():String
160:
161: /**
162: * Returns the base URI against which the literal SystemId is to be resolved.
163: */
164: public String getBaseSystemId() {
165: return fBaseSystemId;
166: } // getBaseSystemId():String
167:
168: /** Returns the expanded system identifier. */
169: public String getExpandedSystemId() {
170: return fExpandedSystemId;
171: } // getExpandedSystemId():String
172:
173: /** Returns the namespace of the resource. */
174: public String getNamespace() {
175: return fNamespace;
176: } // getNamespace():String
177:
178: //
179: // Object methods
180: //
181:
182: /** Returns a hash code for this object. */
183: public int hashCode() {
184: int code = 0;
185: if (fPublicId != null) {
186: code += fPublicId.hashCode();
187: }
188: if (fLiteralSystemId != null) {
189: code += fLiteralSystemId.hashCode();
190: }
191: if (fBaseSystemId != null) {
192: code += fBaseSystemId.hashCode();
193: }
194: if (fExpandedSystemId != null) {
195: code += fExpandedSystemId.hashCode();
196: }
197: if (fNamespace != null) {
198: code += fNamespace.hashCode();
199: }
200: return code;
201: } // hashCode():int
202:
203: /** Returns a string representation of this object. */
204: public String toString() {
205: StringBuffer str = new StringBuffer();
206: if (fPublicId != null) {
207: str.append(fPublicId);
208: }
209: str.append(':');
210: if (fLiteralSystemId != null) {
211: str.append(fLiteralSystemId);
212: }
213: str.append(':');
214: if (fBaseSystemId != null) {
215: str.append(fBaseSystemId);
216: }
217: str.append(':');
218: if (fExpandedSystemId != null) {
219: str.append(fExpandedSystemId);
220: }
221: str.append(':');
222: if (fNamespace != null) {
223: str.append(fNamespace);
224: }
225: return str.toString();
226: } // toString():String
227:
228: } // class XMLResourceIdentifierImpl
|