001: /*
002: * The Apache Software License, Version 1.1
003: *
004: *
005: * Copyright (c) 2002 The Apache Software Foundation. All rights
006: * reserved.
007: *
008: * Redistribution and use in source and binary forms, with or without
009: * modification, are permitted provided that the following conditions
010: * are met:
011: *
012: * 1. Redistributions of source code must retain the above copyright
013: * notice, this list of conditions and the following disclaimer.
014: *
015: * 2. Redistributions in binary form must reproduce the above copyright
016: * notice, this list of conditions and the following disclaimer in
017: * the documentation and/or other materials provided with the
018: * distribution.
019: *
020: * 3. The end-user documentation included with the redistribution,
021: * if any, must include the following acknowledgment:
022: * "This product includes software developed by the
023: * Apache Software Foundation (http://www.apache.org/)."
024: * Alternately, this acknowledgment may appear in the software itself,
025: * if and wherever such third-party acknowledgments normally appear.
026: *
027: * 4. The names "Xerces" and "Apache Software Foundation" must
028: * not be used to endorse or promote products derived from this
029: * software without prior written permission. For written
030: * permission, please contact apache@apache.org.
031: *
032: * 5. Products derived from this software may not be called "Apache",
033: * nor may "Apache" appear in their name, without prior written
034: * permission of the Apache Software Foundation.
035: *
036: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
037: * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
038: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
039: * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
040: * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
041: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
042: * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
043: * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
044: * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
045: * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
046: * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
047: * SUCH DAMAGE.
048: * ====================================================================
049: *
050: * This software consists of voluntary contributions made by many
051: * individuals on behalf of the Apache Software Foundation and was
052: * originally based on software copyright (c) 1999, International
053: * Business Machines, Inc., http://www.apache.org. For more
054: * information on the Apache Software Foundation, please see
055: * <http://www.apache.org/>.
056: */
057:
058: package com.sun.xml.stream.xerces.util;
059:
060: import com.sun.xml.stream.xerces.xni.XMLResourceIdentifier;
061:
062: /**
063: * The XMLResourceIdentifierImpl class is an implementation of the
064: * XMLResourceIdentifier interface which defines the location identity
065: * of a resource.
066: *
067: * @author Andy Clark
068: *
069: * @version $Id: XMLResourceIdentifierImpl.java,v 1.2 2006/04/01 06:01:41 jeffsuttor Exp $
070: */
071: public class XMLResourceIdentifierImpl implements XMLResourceIdentifier {
072:
073: //
074: // Data
075: //
076:
077: /** The public identifier. */
078: protected String fPublicId;
079:
080: /** The literal system identifier. */
081: protected String fLiteralSystemId;
082:
083: /** The base system identifier. */
084: protected String fBaseSystemId;
085:
086: /** The expanded system identifier. */
087: protected String fExpandedSystemId;
088:
089: //
090: // Constructors
091: //
092:
093: /** Constructs an empty resource identifier. */
094: public XMLResourceIdentifierImpl() {
095: } // <init>()
096:
097: /**
098: * Constructs a resource identifier.
099: *
100: * @param publicId The public identifier.
101: * @param literalSystemId The literal system identifier.
102: * @param baseSystemId The base system identifier.
103: * @param expandedSystemId The expanded system identifier.
104: */
105: public XMLResourceIdentifierImpl(String publicId,
106: String literalSystemId, String baseSystemId,
107: String expandedSystemId) {
108: setValues(publicId, literalSystemId, baseSystemId,
109: expandedSystemId);
110: } // <init>(String,String,String,String)
111:
112: //
113: // Public methods
114: //
115:
116: /** Sets the values of the resource identifier. */
117: public void setValues(String publicId, String literalSystemId,
118: String baseSystemId, String expandedSystemId) {
119: fPublicId = publicId;
120: fLiteralSystemId = literalSystemId;
121: fBaseSystemId = baseSystemId;
122: fExpandedSystemId = expandedSystemId;
123: } // setValues(String,String,String,String)
124:
125: /** Clears the values. */
126: public void clear() {
127: fPublicId = null;
128: fLiteralSystemId = null;
129: fBaseSystemId = null;
130: fExpandedSystemId = null;
131: } // clear()
132:
133: /** Sets the public identifier. */
134: public void setPublicId(String publicId) {
135: fPublicId = publicId;
136: } // setPublicId(String)
137:
138: /** Sets the literal system identifier. */
139: public void setLiteralSystemId(String literalSystemId) {
140: fLiteralSystemId = literalSystemId;
141: } // setLiteralSystemId(String)
142:
143: /** Sets the base system identifier. */
144: public void setBaseSystemId(String baseSystemId) {
145: fBaseSystemId = baseSystemId;
146: } // setBaseSystemId(String)
147:
148: /** Sets the expanded system identifier. */
149: public void setExpandedSystemId(String expandedSystemId) {
150: fExpandedSystemId = expandedSystemId;
151: } // setExpandedSystemId(String)
152:
153: //
154: // XMLResourceIdentifier methods
155: //
156:
157: /** Returns the public identifier. */
158: public String getPublicId() {
159: return fPublicId;
160: } // getPublicId():String
161:
162: /** Returns the literal system identifier. */
163: public String getLiteralSystemId() {
164: return fLiteralSystemId;
165: } // getLiteralSystemId():String
166:
167: /**
168: * Returns the base URI against which the literal SystemId is to be resolved.
169: */
170: public String getBaseSystemId() {
171: return fBaseSystemId;
172: } // getBaseSystemId():String
173:
174: /** Returns the expanded system identifier. */
175: public String getExpandedSystemId() {
176: return fExpandedSystemId;
177: } // getExpandedSystemId():String
178:
179: //
180: // Object methods
181: //
182:
183: /** Returns a hash code for this object. */
184: public int hashCode() {
185: int code = 0;
186: if (fPublicId != null) {
187: code += fPublicId.hashCode();
188: }
189: if (fLiteralSystemId != null) {
190: code += fLiteralSystemId.hashCode();
191: }
192: if (fBaseSystemId != null) {
193: code += fBaseSystemId.hashCode();
194: }
195: if (fExpandedSystemId != null) {
196: code += fExpandedSystemId.hashCode();
197: }
198: return code;
199: } // hashCode():int
200:
201: /** Returns a string representation of this object. */
202: public String toString() {
203: StringBuffer str = new StringBuffer();
204: if (fPublicId != null) {
205: str.append(fPublicId);
206: }
207: str.append(':');
208: if (fLiteralSystemId != null) {
209: str.append(fLiteralSystemId);
210: }
211: str.append(':');
212: if (fBaseSystemId != null) {
213: str.append(fBaseSystemId);
214: }
215: str.append(':');
216: if (fExpandedSystemId != null) {
217: str.append(fExpandedSystemId);
218: }
219: return str.toString();
220: } // toString():String
221:
222: } // class XMLAttributesImpl
|