KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > xerces > util > XMLResourceIdentifierImpl


1 /*
2  * Copyright 2002, 2003,2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.apache.xerces.util;
18
19 import org.apache.xerces.xni.XMLResourceIdentifier;
20
21 /**
22  * The XMLResourceIdentifierImpl class is an implementation of the
23  * XMLResourceIdentifier interface which defines the location identity
24  * of a resource.
25  *
26  * @author Andy Clark
27  *
28  * @version $Id: XMLResourceIdentifierImpl.java,v 1.3 2004/02/24 23:15:53 mrglavas Exp $
29  */

30 public class XMLResourceIdentifierImpl
31     implements XMLResourceIdentifier {
32
33     //
34
// Data
35
//
36

37     /** The public identifier. */
38     protected String JavaDoc fPublicId;
39
40     /** The literal system identifier. */
41     protected String JavaDoc fLiteralSystemId;
42
43     /** The base system identifier. */
44     protected String JavaDoc fBaseSystemId;
45
46     /** The expanded system identifier. */
47     protected String JavaDoc fExpandedSystemId;
48
49     /** The namespace of the resource. */
50     protected String JavaDoc fNamespace;
51
52     //
53
// Constructors
54
//
55

56     /** Constructs an empty resource identifier. */
57     public XMLResourceIdentifierImpl() {} // <init>()
58

59     /**
60      * Constructs a resource identifier.
61      *
62      * @param publicId The public identifier.
63      * @param literalSystemId The literal system identifier.
64      * @param baseSystemId The base system identifier.
65      * @param expandedSystemId The expanded system identifier.
66      */

67     public XMLResourceIdentifierImpl(String JavaDoc publicId,
68                                      String JavaDoc literalSystemId, String JavaDoc baseSystemId,
69                                      String JavaDoc expandedSystemId) {
70         setValues(publicId, literalSystemId, baseSystemId,
71                   expandedSystemId, null);
72     } // <init>(String,String,String,String)
73

74     /**
75      * Constructs a resource identifier.
76      *
77      * @param publicId The public identifier.
78      * @param literalSystemId The literal system identifier.
79      * @param baseSystemId The base system identifier.
80      * @param expandedSystemId The expanded system identifier.
81      * @param namespace The namespace.
82      */

83     public XMLResourceIdentifierImpl(String JavaDoc publicId, String JavaDoc literalSystemId,
84                                      String JavaDoc baseSystemId, String JavaDoc expandedSystemId,
85                                      String JavaDoc namespace) {
86         setValues(publicId, literalSystemId, baseSystemId,
87                   expandedSystemId, namespace);
88     } // <init>(String,String,String,String,String)
89

90     //
91
// Public methods
92
//
93

94     /** Sets the values of the resource identifier. */
95     public void setValues(String JavaDoc publicId, String JavaDoc literalSystemId,
96                           String JavaDoc baseSystemId, String JavaDoc expandedSystemId) {
97         setValues(publicId, literalSystemId, baseSystemId,
98                   expandedSystemId, null);
99     } // setValues(String,String,String,String)
100

101     /** Sets the values of the resource identifier. */
102     public void setValues(String JavaDoc publicId, String JavaDoc literalSystemId,
103                           String JavaDoc baseSystemId, String JavaDoc expandedSystemId,
104                           String JavaDoc namespace) {
105         fPublicId = publicId;
106         fLiteralSystemId = literalSystemId;
107         fBaseSystemId = baseSystemId;
108         fExpandedSystemId = expandedSystemId;
109         fNamespace = namespace;
110     } // setValues(String,String,String,String,String)
111

112     /** Clears the values. */
113     public void clear() {
114         fPublicId = null;
115         fLiteralSystemId = null;
116         fBaseSystemId = null;
117         fExpandedSystemId = null;
118         fNamespace = null;
119     } // clear()
120

121     /** Sets the public identifier. */
122     public void setPublicId(String JavaDoc publicId) {
123         fPublicId = publicId;
124     } // setPublicId(String)
125

126     /** Sets the literal system identifier. */
127     public void setLiteralSystemId(String JavaDoc literalSystemId) {
128         fLiteralSystemId = literalSystemId;
129     } // setLiteralSystemId(String)
130

131     /** Sets the base system identifier. */
132     public void setBaseSystemId(String JavaDoc baseSystemId) {
133         fBaseSystemId = baseSystemId;
134     } // setBaseSystemId(String)
135

136     /** Sets the expanded system identifier. */
137     public void setExpandedSystemId(String JavaDoc expandedSystemId) {
138         fExpandedSystemId = expandedSystemId;
139     } // setExpandedSystemId(String)
140

141     /** Sets the namespace of the resource. */
142     public void setNamespace(String JavaDoc namespace) {
143         fNamespace = namespace;
144     } // setNamespace(String)
145

146     //
147
// XMLResourceIdentifier methods
148
//
149

150     /** Returns the public identifier. */
151     public String JavaDoc getPublicId() {
152         return fPublicId;
153     } // getPublicId():String
154

155     /** Returns the literal system identifier. */
156     public String JavaDoc getLiteralSystemId() {
157         return fLiteralSystemId;
158     } // getLiteralSystemId():String
159

160     /**
161      * Returns the base URI against which the literal SystemId is to be resolved.
162      */

163     public String JavaDoc getBaseSystemId() {
164         return fBaseSystemId;
165     } // getBaseSystemId():String
166

167     /** Returns the expanded system identifier. */
168     public String JavaDoc getExpandedSystemId() {
169         return fExpandedSystemId;
170     } // getExpandedSystemId():String
171

172     /** Returns the namespace of the resource. */
173     public String JavaDoc getNamespace() {
174         return fNamespace;
175     } // getNamespace():String
176

177     //
178
// Object methods
179
//
180

181     /** Returns a hash code for this object. */
182     public int hashCode() {
183         int code = 0;
184         if (fPublicId != null) {
185             code += fPublicId.hashCode();
186         }
187         if (fLiteralSystemId != null) {
188             code += fLiteralSystemId.hashCode();
189         }
190         if (fBaseSystemId != null) {
191             code += fBaseSystemId.hashCode();
192         }
193         if (fExpandedSystemId != null) {
194             code += fExpandedSystemId.hashCode();
195         }
196         if (fNamespace != null) {
197             code += fNamespace.hashCode();
198         }
199         return code;
200     } // hashCode():int
201

202     /** Returns a string representation of this object. */
203     public String JavaDoc toString() {
204         StringBuffer JavaDoc str = new StringBuffer JavaDoc();
205         if (fPublicId != null) {
206             str.append(fPublicId);
207         }
208         str.append(':');
209         if (fLiteralSystemId != null) {
210             str.append(fLiteralSystemId);
211         }
212         str.append(':');
213         if (fBaseSystemId != null) {
214             str.append(fBaseSystemId);
215         }
216         str.append(':');
217         if (fExpandedSystemId != null) {
218             str.append(fExpandedSystemId);
219         }
220         str.append(':');
221         if (fNamespace != null) {
222             str.append(fNamespace);
223         }
224         return str.toString();
225     } // toString():String
226

227 } // class XMLResourceIdentifierImpl
228
Popular Tags