use of org.apache.commons.io.input.CloseShieldReader in project exist by eXist-db.
the class MutableCollection method closeShieldInputSource.
/**
* Creates a new InputSource that prevents the streams
* and readers of the InputSource from being closed.
*
* @param source the input source
*
* @return a new input source
*/
private InputSource closeShieldInputSource(final InputSource source) {
final InputSource protectedInputSource = new InputSource();
protectedInputSource.setEncoding(source.getEncoding());
protectedInputSource.setSystemId(source.getSystemId());
protectedInputSource.setPublicId(source.getPublicId());
if (source.getByteStream() != null) {
// TODO(AR) consider AutoCloseInputStream
final InputStream closeShieldByteStream = CloseShieldInputStream.wrap(source.getByteStream());
protectedInputSource.setByteStream(closeShieldByteStream);
}
if (source.getCharacterStream() != null) {
// TODO(AR) consider AutoCloseReader
final Reader closeShieldReader = CloseShieldReader.wrap(source.getCharacterStream());
protectedInputSource.setCharacterStream(closeShieldReader);
}
return protectedInputSource;
}
Aggregations