1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements.  See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License.  You may obtain a copy of the License at
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 /**
19  * $Id: URLInputSource.cpp 471747 2006-11-06 14:31:56Z amassari $
20  */
21 
22 
23 // ---------------------------------------------------------------------------
24 //  Includes
25 // ---------------------------------------------------------------------------
26 #include <xercesc/util/BinFileInputStream.hpp>
27 #include <xercesc/util/Janitor.hpp>
28 #include <xercesc/util/XMLURL.hpp>
29 #include <xercesc/util/XMLString.hpp>
30 #include <xercesc/framework/URLInputSource.hpp>
31 
32 XERCES_CPP_NAMESPACE_BEGIN
33 
34 // ---------------------------------------------------------------------------
35 //  URLInputSource: Constructors and Destructor
36 // ---------------------------------------------------------------------------
URLInputSource(const XMLURL & urlId,MemoryManager * const manager)37 URLInputSource::URLInputSource( const XMLURL&         urlId
38                               , MemoryManager* const  manager) :
39 
40     InputSource(manager)
41     , fURL(urlId)
42 {
43     setSystemId(fURL.getURLText());
44 }
45 
URLInputSource(const XMLCh * const baseId,const XMLCh * const systemId,MemoryManager * const manager)46 URLInputSource::URLInputSource( const XMLCh* const    baseId
47                               , const XMLCh* const    systemId
48                               , MemoryManager* const  manager) :
49     InputSource(manager)
50     , fURL(baseId, systemId)
51 {
52     // Create a URL that will build up the full URL and store as the system id
53     setSystemId(fURL.getURLText());
54 }
55 
URLInputSource(const XMLCh * const baseId,const XMLCh * const systemId,const XMLCh * const publicId,MemoryManager * const manager)56 URLInputSource::URLInputSource( const XMLCh* const    baseId
57                               , const XMLCh* const    systemId
58                               , const XMLCh* const    publicId
59                               , MemoryManager* const  manager) :
60     InputSource(0, publicId, manager)
61     , fURL(baseId, systemId)
62 {
63     setSystemId(fURL.getURLText());
64 }
65 
URLInputSource(const XMLCh * const baseId,const char * const systemId,MemoryManager * const manager)66 URLInputSource::URLInputSource( const XMLCh* const    baseId
67                               , const char* const     systemId
68                               , MemoryManager* const  manager) :
69     InputSource(manager)
70     , fURL(baseId, systemId)
71 {
72     setSystemId(fURL.getURLText());
73 }
74 
URLInputSource(const XMLCh * const baseId,const char * const systemId,const char * const publicId,MemoryManager * const manager)75 URLInputSource::URLInputSource( const   XMLCh* const   baseId
76                                 , const char* const    systemId
77                                 , const char* const    publicId
78                                 , MemoryManager* const  manager) :
79     InputSource(0, publicId, manager)
80     , fURL(baseId, systemId)
81 {
82     setSystemId(fURL.getURLText());
83 }
84 
~URLInputSource()85 URLInputSource::~URLInputSource()
86 {
87 }
88 
89 
90 // ---------------------------------------------------------------------------
91 //  URLInputSource: Implementation of the input source interface
92 // ---------------------------------------------------------------------------
makeStream() const93 BinInputStream* URLInputSource::makeStream() const
94 {
95     // Ask the URL to create us an appropriate input stream
96     return fURL.makeNewStream();
97 }
98 
99 XERCES_CPP_NAMESPACE_END
100 
101