/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/** Factory Implementation for XMLInputFactory.
* @author Neeraj Bajaj Sun Microsystems
* @author K.Venugopal Sun Microsystems
*/
//xxx: Should we be reusing the XMLInputSource object
//List of supported properties and default values.
private static final boolean DEBUG = false;
//Maintain a reference to last reader instantiated.
boolean fPropertyChanged = false;
//no reader reuse by default
boolean fReuseInstance = false;
/** Creates a new instance of ZephryParserFactory */
public XMLInputFactoryImpl() {
}
void initEventReader(){
fPropertyChanged = true;
}
/**
* @param inputstream
* @throws XMLStreamException
* @return
*/
//delegate everything to XMLStreamReader
}
//delegate everything to XMLStreamReader
}
//delegate everything to XMLStreamReader
}
public XMLEventReader createXMLEventReader(String systemId, InputStream inputstream) throws XMLStreamException {
//delegate everything to XMLStreamReader
}
public XMLEventReader createXMLEventReader(java.io.InputStream stream, String encoding) throws XMLStreamException {
//delegate everything to XMLStreamReader
}
public XMLEventReader createXMLEventReader(String systemId, Reader reader) throws XMLStreamException {
//delegate everything to XMLStreamReader
}
/** Create a new XMLEventReader from an XMLStreamReader. After being used
* to construct the XMLEventReader instance returned from this method
* the XMLStreamReader must not be used.
* @param reader the XMLStreamReader to read from (may not be modified)
* @return a new XMLEventReader
* @throws XMLStreamException
*/
//xxx: what do we do now -- instance is passed from the application
//probably we should check if the state is at the start document,
//eventreader call to next() should return START_DOCUMENT and
//then delegate every call to underlying streamReader
return new XMLEventReaderImpl(reader) ;
}
return getXMLStreamReaderImpl(inputSource);
}
return getXMLStreamReaderImpl(inputSource);
}
public XMLStreamReader createXMLStreamReader(String systemId, Reader reader) throws XMLStreamException {
return getXMLStreamReaderImpl(inputSource);
}
new PropertyManager(fPropertyManager));
}
public XMLStreamReader createXMLStreamReader(String systemId, InputStream inputstream) throws XMLStreamException {
return getXMLStreamReaderImpl(inputSource);
}
public XMLStreamReader createXMLStreamReader(InputStream inputstream, String encoding) throws XMLStreamException {
return getXMLStreamReaderImpl(inputSource);
}
}
}
return (XMLResolver)object;
//return (XMLResolver)fPropertyManager.getProperty(XMLInputFactory.RESOLVER);
}
}
}
/** Create a filtered event reader that wraps the filter around the event reader
* @param reader the event reader to wrap
* @param filter the filter to apply to the event reader
* @throws XMLStreamException
*/
public XMLEventReader createFilteredReader(XMLEventReader reader, EventFilter filter) throws XMLStreamException {
}
/** Create a filtered reader that wraps the filter around the reader
* @param reader the reader to filter
* @param filter the filter to apply to the reader
* @throws XMLStreamException
*/
public XMLStreamReader createFilteredReader(XMLStreamReader reader, StreamFilter filter) throws XMLStreamException {
return null;
}
* @param name The name of the property (may not be null)
* @return The value of the property
* @throws IllegalArgumentException if the property is not supported
*/
throw new IllegalArgumentException("Property not supported");
}
throw new IllegalArgumentException("Property not supported");
}
/** Query the set of fProperties that this factory supports.
*
* @param name The name of the property (may not be null)
* @return true if the property is supported and false otherwise
*/
return false ;
else
}
/** Set a user defined event allocator for events
* @param allocator the user defined allocator
*/
}
/** Allows the user to set specific feature/property on the underlying implementation. The underlying implementation
* is not required to support every setting of every property in the specification and may use IllegalArgumentException
* to signal that an unsupported property may not be set with the specified value.
* @param name The name of the property (may not be null)
* @param value The value of the property
* @throws java.lang.IllegalArgumentException if the property is not supported
*/
public void setProperty(java.lang.String name, Object value) throws java.lang.IllegalArgumentException {
}
}else{//for any other property set the flag
//REVISIT: Even in this case instance can be reused, by passing PropertyManager
fPropertyChanged = true;
}
}
XMLStreamReader getXMLStreamReaderImpl(XMLInputSource inputSource) throws javax.xml.stream.XMLStreamException{
//1. if the temp reader is null -- create the instance and return
if(fTempReader == null){
fPropertyChanged = false;
new PropertyManager(fPropertyManager));
}
//if factory is configured to reuse the instance & this instance can be reused
//& the setProperty() hasn't been called
//we can make setInputSource() call reset() and this way there wont be two function calls
fTempReader.reset();
fPropertyChanged = false;
return fTempReader;
}else{
fPropertyChanged = false;
//just return the new instance.. note that we are not setting fTempReader to the newly created instance
new PropertyManager(fPropertyManager));
}
}
if(source instanceof StreamSource){
}
}else{
}
}
throw new UnsupportedOperationException("Cannot create " +
"XMLStreamReader or XMLEventReader from a " +
}
}//XMLInputFactoryImpl