/*
* 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.
*/
/**
* This class provides the implementation of XMLOutputFactory.
*
* @author Neeraj Bajaj,
* @author k.venugopal@sun.com
*/
//List of supported properties and default values.
//cache the instance of XMLStreamWriterImpl
/**
* TODO: at the current time, XMLStreamWriters are not Thread safe.
*/
boolean fReuseInstance = false;
/** Creates a new instance of XMLOutputFactory */
public XMLOutputFactoryImpl() {
}
public javax.xml.stream.XMLEventWriter createXMLEventWriter(java.io.OutputStream outputStream) throws javax.xml.stream.XMLStreamException {
}
public javax.xml.stream.XMLEventWriter createXMLEventWriter(java.io.OutputStream outputStream, String encoding) throws javax.xml.stream.XMLStreamException {
}
public javax.xml.stream.XMLEventWriter createXMLEventWriter(javax.xml.transform.Result result) throws javax.xml.stream.XMLStreamException {
}
public javax.xml.stream.XMLEventWriter createXMLEventWriter(java.io.Writer writer) throws javax.xml.stream.XMLStreamException {
}
public javax.xml.stream.XMLStreamWriter createXMLStreamWriter(javax.xml.transform.Result result) throws javax.xml.stream.XMLStreamException {
if (result instanceof StreamResult) {
} else if (result instanceof StAXResult) {
} else {
throw new java.lang.UnsupportedOperationException("Result of type " + result + " is not supported");
}
} else {
//this is not correct impl of SAXResult. Keep it for now for compatibility
} else {
throw new java.lang.UnsupportedOperationException("Result of type " + result + " is not supported. " +
"Supported result types are: DOMResult, StAXResult and StreamResult.");
}
}
}
public javax.xml.stream.XMLStreamWriter createXMLStreamWriter(java.io.Writer writer) throws javax.xml.stream.XMLStreamException {
}
public javax.xml.stream.XMLStreamWriter createXMLStreamWriter(java.io.OutputStream outputStream) throws javax.xml.stream.XMLStreamException {
}
public javax.xml.stream.XMLStreamWriter createXMLStreamWriter(java.io.OutputStream outputStream, String encoding) throws javax.xml.stream.XMLStreamException {
}
throw new IllegalArgumentException("Property not supported");
}
throw new IllegalArgumentException("Property not supported");
}
return false ;
}
else{
}
}
}
// TODO: XMLStreamWriters are not Thread safe,
// don't let application think it is optimizing
if (fReuseInstance) {
throw new IllegalArgumentException(
"Property "
+ name
+ " is not supported: XMLStreamWriters are not Thread safe");
}
}else{//for any other property set the flag
//REVISIT: Even in this case instance can be reused, by passing PropertyManager
fPropertyChanged = true;
}
}
/** StreamResult object is re-used and the values are set appropriately.
*/
return sr;
}
javax.xml.stream.XMLStreamWriter createXMLStreamWriter(javax.xml.transform.stream.StreamResult sr, String encoding) throws javax.xml.stream.XMLStreamException {
//if factory is configured to reuse the instance & this instance can be reused
//& the setProperty() hasn't been called
try{
return fStreamWriter;
}
return fStreamWriter = new XMLStreamWriterImpl(sr, encoding, new PropertyManager(fPropertyManager));
throw new XMLStreamException(io);
}
}//createXMLStreamWriter(StreamResult,String)
private static final boolean DEBUG = false;
/** This flag indicates the change of property. If true,
* <code>PropertyManager</code> should be passed when creating
* <code>XMLStreamWriterImpl</code> */
private boolean fPropertyChanged ;
}//XMLOutputFactory