KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > org > apache > xerces > internal > util > XMLResourceIdentifierImpl


1 /*
2  * The Apache Software License, Version 1.1
3  *
4  *
5  * Copyright (c) 2002, 2003 The Apache Software Foundation. All rights
6  * reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * 1. Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  *
15  * 2. Redistributions in binary form must reproduce the above copyright
16  * notice, this list of conditions and the following disclaimer in
17  * the documentation and/or other materials provided with the
18  * distribution.
19  *
20  * 3. The end-user documentation included with the redistribution,
21  * if any, must include the following acknowledgment:
22  * "This product includes software developed by the
23  * Apache Software Foundation (http://www.apache.org/)."
24  * Alternately, this acknowledgment may appear in the software itself,
25  * if and wherever such third-party acknowledgments normally appear.
26  *
27  * 4. The names "Xerces" and "Apache Software Foundation" must
28  * not be used to endorse or promote products derived from this
29  * software without prior written permission. For written
30  * permission, please contact apache@apache.org.
31  *
32  * 5. Products derived from this software may not be called "Apache",
33  * nor may "Apache" appear in their name, without prior written
34  * permission of the Apache Software Foundation.
35  *
36  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
37  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
38  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
39  * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
40  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
42  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
43  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
44  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
45  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
46  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
47  * SUCH DAMAGE.
48  * ====================================================================
49  *
50  * This software consists of voluntary contributions made by many
51  * individuals on behalf of the Apache Software Foundation and was
52  * originally based on software copyright (c) 1999, International
53  * Business Machines, Inc., http://www.apache.org. For more
54  * information on the Apache Software Foundation, please see
55  * <http://www.apache.org/>.
56  */

57
58 package com.sun.org.apache.xerces.internal.util;
59
60 import com.sun.org.apache.xerces.internal.xni.XMLResourceIdentifier;
61
62 /**
63  * The XMLResourceIdentifierImpl class is an implementation of the
64  * XMLResourceIdentifier interface which defines the location identity
65  * of a resource.
66  *
67  * @author Andy Clark
68  *
69  * @version $Id: XMLResourceIdentifierImpl.java,v 1.2 2003/03/24 21:10:59 sandygao Exp $
70  */

71 public class XMLResourceIdentifierImpl
72     implements XMLResourceIdentifier {
73
74     //
75
// Data
76
//
77

78     /** The public identifier. */
79     protected String JavaDoc fPublicId;
80
81     /** The literal system identifier. */
82     protected String JavaDoc fLiteralSystemId;
83
84     /** The base system identifier. */
85     protected String JavaDoc fBaseSystemId;
86
87     /** The expanded system identifier. */
88     protected String JavaDoc fExpandedSystemId;
89
90     /** The namespace of the resource. */
91     protected String JavaDoc fNamespace;
92
93     //
94
// Constructors
95
//
96

97     /** Constructs an empty resource identifier. */
98     public XMLResourceIdentifierImpl() {} // <init>()
99

100     /**
101      * Constructs a resource identifier.
102      *
103      * @param publicId The public identifier.
104      * @param literalSystemId The literal system identifier.
105      * @param baseSystemId The base system identifier.
106      * @param expandedSystemId The expanded system identifier.
107      */

108     public XMLResourceIdentifierImpl(String JavaDoc publicId,
109                                      String JavaDoc literalSystemId, String JavaDoc baseSystemId,
110                                      String JavaDoc expandedSystemId) {
111         setValues(publicId, literalSystemId, baseSystemId,
112                   expandedSystemId, null);
113     } // <init>(String,String,String,String)
114

115     /**
116      * Constructs a resource identifier.
117      *
118      * @param publicId The public identifier.
119      * @param literalSystemId The literal system identifier.
120      * @param baseSystemId The base system identifier.
121      * @param expandedSystemId The expanded system identifier.
122      * @param namespace The namespace.
123      */

124     public XMLResourceIdentifierImpl(String JavaDoc publicId, String JavaDoc literalSystemId,
125                                      String JavaDoc baseSystemId, String JavaDoc expandedSystemId,
126                                      String JavaDoc namespace) {
127         setValues(publicId, literalSystemId, baseSystemId,
128                   expandedSystemId, namespace);
129     } // <init>(String,String,String,String,String)
130

131     //
132
// Public methods
133
//
134

135     /** Sets the values of the resource identifier. */
136     public void setValues(String JavaDoc publicId, String JavaDoc literalSystemId,
137                           String JavaDoc baseSystemId, String JavaDoc expandedSystemId) {
138         setValues(publicId, literalSystemId, baseSystemId,
139                   expandedSystemId, null);
140     } // setValues(String,String,String,String)
141

142     /** Sets the values of the resource identifier. */
143     public void setValues(String JavaDoc publicId, String JavaDoc literalSystemId,
144                           String JavaDoc baseSystemId, String JavaDoc expandedSystemId,
145                           String JavaDoc namespace) {
146         fPublicId = publicId;
147         fLiteralSystemId = literalSystemId;
148         fBaseSystemId = baseSystemId;
149         fExpandedSystemId = expandedSystemId;
150         fNamespace = namespace;
151     } // setValues(String,String,String,String,String)
152

153     /** Clears the values. */
154     public void clear() {
155         fPublicId = null;
156         fLiteralSystemId = null;
157         fBaseSystemId = null;
158         fExpandedSystemId = null;
159         fNamespace = null;
160     } // clear()
161

162     /** Sets the public identifier. */
163     public void setPublicId(String JavaDoc publicId) {
164         fPublicId = publicId;
165     } // setPublicId(String)
166

167     /** Sets the literal system identifier. */
168     public void setLiteralSystemId(String JavaDoc literalSystemId) {
169         fLiteralSystemId = literalSystemId;
170     } // setLiteralSystemId(String)
171

172     /** Sets the base system identifier. */
173     public void setBaseSystemId(String JavaDoc baseSystemId) {
174         fBaseSystemId = baseSystemId;
175     } // setBaseSystemId(String)
176

177     /** Sets the expanded system identifier. */
178     public void setExpandedSystemId(String JavaDoc expandedSystemId) {
179         fExpandedSystemId = expandedSystemId;
180     } // setExpandedSystemId(String)
181

182     /** Sets the namespace of the resource. */
183     public void setNamespace(String JavaDoc namespace) {
184         fNamespace = namespace;
185     } // setNamespace(String)
186

187     //
188
// XMLResourceIdentifier methods
189
//
190

191     /** Returns the public identifier. */
192     public String JavaDoc getPublicId() {
193         return fPublicId;
194     } // getPublicId():String
195

196     /** Returns the literal system identifier. */
197     public String JavaDoc getLiteralSystemId() {
198         return fLiteralSystemId;
199     } // getLiteralSystemId():String
200

201     /**
202      * Returns the base URI against which the literal SystemId is to be resolved.
203      */

204     public String JavaDoc getBaseSystemId() {
205         return fBaseSystemId;
206     } // getBaseSystemId():String
207

208     /** Returns the expanded system identifier. */
209     public String JavaDoc getExpandedSystemId() {
210         return fExpandedSystemId;
211     } // getExpandedSystemId():String
212

213     /** Returns the namespace of the resource. */
214     public String JavaDoc getNamespace() {
215         return fNamespace;
216     } // getNamespace():String
217

218     //
219
// Object methods
220
//
221

222     /** Returns a hash code for this object. */
223     public int hashCode() {
224         int code = 0;
225         if (fPublicId != null) {
226             code += fPublicId.hashCode();
227         }
228         if (fLiteralSystemId != null) {
229             code += fLiteralSystemId.hashCode();
230         }
231         if (fBaseSystemId != null) {
232             code += fBaseSystemId.hashCode();
233         }
234         if (fExpandedSystemId != null) {
235             code += fExpandedSystemId.hashCode();
236         }
237         if (fNamespace != null) {
238             code += fNamespace.hashCode();
239         }
240         return code;
241     } // hashCode():int
242

243     /** Returns a string representation of this object. */
244     public String JavaDoc toString() {
245         StringBuffer JavaDoc str = new StringBuffer JavaDoc();
246         if (fPublicId != null) {
247             str.append(fPublicId);
248         }
249         str.append(':');
250         if (fLiteralSystemId != null) {
251             str.append(fLiteralSystemId);
252         }
253         str.append(':');
254         if (fBaseSystemId != null) {
255             str.append(fBaseSystemId);
256         }
257         str.append(':');
258         if (fExpandedSystemId != null) {
259             str.append(fExpandedSystemId);
260         }
261         str.append(':');
262         if (fNamespace != null) {
263             str.append(fNamespace);
264         }
265         return str.toString();
266     } // toString():String
267

268 } // class XMLResourceIdentifierImpl
269
Popular Tags