00001 /* 00002 * Licensed to the Apache Software Foundation (ASF) under one 00003 * or more contributor license agreements. See the NOTICE file 00004 * distributed with this work for additional information 00005 * regarding copyright ownership. The ASF licenses this file 00006 * to you under the Apache License, Version 2.0 (the "License"); 00007 * you may not use this file except in compliance with the License. 00008 * You may obtain a copy of the License at 00009 * 00010 * http://www.apache.org/licenses/LICENSE-2.0 00011 * 00012 * Unless required by applicable law or agreed to in writing, software 00013 * distributed under the License is distributed on an "AS IS" BASIS, 00014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00015 * See the License for the specific language governing permissions and 00016 * limitations under the License. 00017 */ 00018 00019 #if !defined(XALANPARSEDURI_HEADER_GUARD_1357924680) 00020 #define XALANPARSEDURI_HEADER_GUARD_1357924680 00021 00022 00023 00024 // Base include file. Must be first. 00025 #include <xalanc/PlatformSupport/PlatformSupportDefinitions.hpp> 00026 00027 00028 00029 #include <xalanc/XalanDOM/XalanDOMString.hpp> 00030 00031 00032 00033 00034 XALAN_CPP_NAMESPACE_BEGIN 00035 00036 00037 00038 /** 00039 * URI handling (hopefully) according to RFC2396. 00040 */ 00041 class XALAN_PLATFORMSUPPORT_EXPORT XalanParsedURI 00042 { 00043 public: 00044 00045 // Flags to say if a component is defined. Note that each component may 00046 // be defined but empty, except for the path. 00047 #if defined(XALAN_INLINE_INITIALIZATION) 00048 static const int d_scheme = 1; 00049 static const int d_authority = 2; 00050 static const int d_query = 4; 00051 static const int d_fragment = 8; 00052 #else 00053 enum eComponent 00054 { 00055 d_scheme = 1, 00056 d_authority = 2, 00057 d_query = 4, 00058 d_fragment = 8 00059 }; 00060 #endif 00061 00062 /** 00063 * Default constructor 00064 */ 00065 XalanParsedURI(MemoryManager& theManager) : 00066 m_scheme(theManager), 00067 m_authority(theManager), 00068 m_path(theManager), 00069 m_query(theManager), 00070 m_fragment(theManager), 00071 m_defined(0) 00072 { 00073 } 00074 00075 /** 00076 * Constructor which parses the passed in uri 00077 * 00078 * @param uriString URI to parse 00079 * @param uriStringLen Length of the URI string 00080 */ 00081 XalanParsedURI( 00082 const XalanDOMChar* uriString, 00083 XalanDOMString::size_type uriStringLen, 00084 MemoryManager& theManager) : 00085 m_scheme(theManager), 00086 m_authority(theManager), 00087 m_path(theManager), 00088 m_query(theManager), 00089 m_fragment(theManager), 00090 m_defined(0) 00091 { 00092 parse(uriString, uriStringLen); 00093 } 00094 00095 /** 00096 * Constructor which parses the passed in uri 00097 * 00098 * @param uriString URI to parse 00099 */ 00100 XalanParsedURI( 00101 const XalanDOMString &uriString, 00102 MemoryManager& theManager) : 00103 m_scheme(theManager), 00104 m_authority(theManager), 00105 m_path(theManager), 00106 m_query(theManager), 00107 m_fragment(theManager), 00108 m_defined(0) 00109 { 00110 parse(uriString.c_str(), uriString.length()); 00111 } 00112 00113 MemoryManager& 00114 getMemoryManager() 00115 { 00116 return m_scheme.getMemoryManager(); 00117 } 00118 00119 /** 00120 * Parse the passed in uri 00121 * 00122 * @param uriString URI to parse 00123 * @param uriStringLen Length of the URI string 00124 */ 00125 void parse( 00126 const XalanDOMChar* uriString, 00127 XalanDOMString::size_type uriStringLen); 00128 00129 /** 00130 * Parse the passed in uri 00131 * 00132 * @param uriString URI to parse 00133 * @param uriStringLen Length of the URI string 00134 */ 00135 void parse( 00136 const XalanDOMString &uriString) 00137 { 00138 parse(uriString.c_str(), uriString.length()); 00139 } 00140 00141 /** 00142 * Reassemble the uri components to make a complete URI 00143 * 00144 * @return The reassembled URI 00145 */ 00146 XalanDOMString& make(XalanDOMString& theResult) const; 00147 00148 /** 00149 * Resolve this URI relative to another, according to RFC2396. 00150 * 00151 * @param base The base URI to use during resolution. 00152 */ 00153 void resolve(const XalanParsedURI &base); 00154 00155 /** 00156 * Resolve this URI relative to another. 00157 * 00158 * @param base The base URI string 00159 * @param baseLen The length of the base URI 00160 */ 00161 void resolve( 00162 const XalanDOMChar *base, 00163 const XalanDOMString::size_type baseLen) 00164 { 00165 XalanParsedURI baseURI(base, baseLen,getMemoryManager()); 00166 00167 resolve(baseURI); 00168 } 00169 00170 /** 00171 * Resolve this URI relative to another. 00172 * 00173 * @param base The base URI string 00174 */ 00175 void resolve( 00176 const XalanDOMString &base) 00177 { 00178 resolve(base.c_str(), base.length()); 00179 } 00180 00181 /** 00182 * Resolve the one URI relative to another. 00183 * 00184 * @relative The URI string to resolve 00185 * @relativeLen The lengh of the relative URI string 00186 * @base The base URI string 00187 * @baseLen The length of the base URI string 00188 * 00189 */ 00190 static XalanDOMString& resolve( 00191 const XalanDOMChar *relative, 00192 XalanDOMString::size_type relativeLen, 00193 const XalanDOMChar *base, 00194 XalanDOMString::size_type baseLen, 00195 XalanDOMString& theResult 00196 ); 00197 00198 00199 /** 00200 * Resolve the one URI relative to another. 00201 * 00202 * @relative The URI string to resolve 00203 * @base The base URI string 00204 * 00205 */ 00206 static XalanDOMString& resolve( 00207 const XalanDOMString &relative, 00208 const XalanDOMString &base, 00209 XalanDOMString& theResult 00210 ) 00211 { 00212 return resolve(relative.c_str(), relative.length(), base.c_str(), base.length(), theResult); 00213 } 00214 00215 /** 00216 * Get the scheme component 00217 */ 00218 const XalanDOMString& getScheme() const 00219 { 00220 return m_scheme; 00221 } 00222 00223 /** 00224 * See if the scheme component is defined. 00225 */ 00226 bool isSchemeDefined() const 00227 { 00228 return m_defined & d_scheme; 00229 } 00230 00231 /** 00232 * Set the scheme component. Also sets the scheme defined flag. 00233 */ 00234 void setScheme(const XalanDOMChar *scheme) 00235 { 00236 m_scheme = scheme; 00237 m_defined |= d_scheme; 00238 } 00239 00240 /** 00241 * Set the scheme component. Also sets the scheme defined flag. 00242 */ 00243 void setScheme(const XalanDOMString &scheme) 00244 { 00245 m_scheme = scheme; 00246 m_defined |= d_scheme; 00247 } 00248 00249 /** 00250 * Get the authority component 00251 */ 00252 const XalanDOMString& getAuthority() const 00253 { 00254 return m_authority; 00255 } 00256 00257 /** 00258 * See if the authority component is defined. 00259 */ 00260 bool isAuthorityDefined() const 00261 { 00262 return m_defined & d_authority ? true : false; 00263 } 00264 00265 /** 00266 * Set the authority component. Also sets the authority defined flag. 00267 */ 00268 void setAuthority(const XalanDOMChar *authority) 00269 { 00270 m_authority = authority; 00271 m_defined |= d_authority; 00272 } 00273 00274 /** 00275 * Set the authority component. Also sets the authority defined flag. 00276 */ 00277 void setAuthority(const XalanDOMString &authority) 00278 { 00279 m_authority = authority; 00280 m_defined |= d_authority; 00281 } 00282 00283 /** 00284 * Get the path component 00285 */ 00286 const XalanDOMString& getPath() const 00287 { 00288 return m_path; 00289 } 00290 00291 /** 00292 * Set the path component. 00293 */ 00294 void setPath(const XalanDOMChar *path) 00295 { 00296 m_path = path; 00297 } 00298 00299 /** 00300 * Set the path component. 00301 */ 00302 void setPath(const XalanDOMString &path) 00303 { 00304 m_path = path; 00305 } 00306 00307 /** 00308 * Get function to get the query component 00309 */ 00310 const XalanDOMString& getQuery() const 00311 { 00312 return m_query; 00313 } 00314 00315 /** 00316 * See if the query component is defined. 00317 */ 00318 bool isQueryDefined() const 00319 { 00320 return m_defined & d_query ? true : false; 00321 } 00322 00323 /** 00324 * Set the query component. Also sets the query defined flag. 00325 */ 00326 void setQuery(const XalanDOMChar *query) 00327 { 00328 m_query = query; 00329 m_defined |= d_query; 00330 } 00331 00332 /** 00333 * Set the query component. Also sets the query defined flag. 00334 */ 00335 void setQuery(const XalanDOMString &query) 00336 { 00337 m_query = query; 00338 m_defined |= d_query; 00339 } 00340 00341 /** 00342 * Get the fragment component 00343 */ 00344 const XalanDOMString& getFragment() const 00345 { 00346 return m_fragment; 00347 } 00348 00349 /** 00350 * See if the fragment component is defined. 00351 */ 00352 bool isFragmentDefined() const 00353 { 00354 return m_defined & d_fragment ? true : false; 00355 } 00356 00357 /** 00358 * Set the fragment component. Also sets the fragment defined flag. 00359 */ 00360 void setFragment(const XalanDOMChar *fragment) 00361 { 00362 m_fragment = fragment; 00363 m_defined |= d_fragment; 00364 } 00365 00366 /** 00367 * Set the fragment component. Also sets the fragment defined flag. 00368 */ 00369 void setFragment(const XalanDOMString &fragment) 00370 { 00371 m_fragment = fragment; 00372 m_defined |= d_fragment; 00373 } 00374 00375 /** 00376 * Get the defined components mask. 00377 */ 00378 unsigned int getDefined() const 00379 { 00380 return m_defined; 00381 } 00382 00383 /** 00384 * Set the defined components mask. 00385 */ 00386 void setDefined(unsigned int defined) 00387 { 00388 m_defined = defined; 00389 } 00390 00391 private: 00392 // not implemented 00393 XalanParsedURI(); 00394 XalanParsedURI(const XalanParsedURI&); 00395 00396 XalanDOMString m_scheme; 00397 XalanDOMString m_authority; 00398 XalanDOMString m_path; 00399 XalanDOMString m_query; 00400 XalanDOMString m_fragment; 00401 00402 unsigned int m_defined; 00403 }; 00404 00405 XALAN_CPP_NAMESPACE_END 00406 00407 #endif // XALANPARSEDURI_HEADER_GUARD_1357924680
Doxygen and GraphViz are used to generate this API documentation from the Xalan-C header files.
Xalan-C++ XSLT Processor Version 1.11 |
|