下面列出了怎么用java.io.FilterReader的API类实例代码及写法,或者点击链接到github查看源代码。
/**
* @see #getReader
*/
public Reader getInternalReader(long characterPosition)
throws IOException, SQLException {
if (this.internalReader == null) {
// getCSD obtains a descriptor for the stream to allow the reader
// to configure itself.
this.internalReader = new UTF8Reader(getCSD(), conChild,
conChild.getConnectionSynchronization());
this.unclosableInternalReader =
new FilterReader(this.internalReader) {
public void close() {
// Do nothing.
// Stream will be closed when the Clob is released.
}
};
}
try {
this.internalReader.reposition(characterPosition);
} catch (StandardException se) {
throw Util.generateCsSQLException(se);
}
return this.unclosableInternalReader;
}
public static Reader nonClosingReader(Reader reader) {
return new FilterReader(reader) {
@Override
public void close() {
// do nothing
}
};
}
public CopySpec filter(final Class<? extends FilterReader> filterType) {
copyActions.add(new Action<FileCopyDetails>() {
public void execute(FileCopyDetails fileCopyDetails) {
fileCopyDetails.filter(filterType);
}
});
return this;
}
public CopySpec filter(final Map<String, ?> properties, final Class<? extends FilterReader> filterType) {
copyActions.add(new Action<FileCopyDetails>() {
public void execute(FileCopyDetails fileCopyDetails) {
fileCopyDetails.filter(properties, filterType);
}
});
return this;
}
public CopySpec filter(final Class<? extends FilterReader> filterType) {
actions.add(new Action<FileCopyDetails>() {
public void execute(FileCopyDetails fileCopyDetails) {
fileCopyDetails.filter(filterType);
}
});
return this;
}
public CopySpec filter(final Map<String, ?> properties, final Class<? extends FilterReader> filterType) {
actions.add(new Action<FileCopyDetails>() {
public void execute(FileCopyDetails fileCopyDetails) {
fileCopyDetails.filter(properties, filterType);
}
});
return this;
}
public InputStream getInputStream() throws IOException {
if (inputOutput == null) {
throw new IllegalStateException("not started");
}
return new ReaderInputStream(
new FilterReader(inputOutput.getIn()) {
@Override
public void close() throws IOException {
// do not close the input, JShell may be reset.
}
}, "UTF-8" // NOI18N
);
}
private static Reader doNotClose(Reader input) {
return new FilterReader(input) {
@Override
public void close() {
// NOTHING.
}
};
}
/** Parses the given InputStream as XML, disabling any external entities with secure processing enabled.
* The given Reader is not closed. */
public static Document parseUntrustedXML(Logger log, Reader reader) throws SAXException, IOException {
final InputSource is = new InputSource(new FilterReader(reader) {
@Override public void close() {}
});
is.setSystemId(SYSTEMID_UNTRUSTED);
return getUntrustedDocumentBuilder(log).parse(is);
}
public CopySpec filter(final Class<? extends FilterReader> filterType) {
copyActions.add(new Action<FileCopyDetails>() {
public void execute(FileCopyDetails fileCopyDetails) {
fileCopyDetails.filter(filterType);
}
});
return this;
}
public CopySpec filter(final Map<String, ?> properties, final Class<? extends FilterReader> filterType) {
copyActions.add(new Action<FileCopyDetails>() {
public void execute(FileCopyDetails fileCopyDetails) {
fileCopyDetails.filter(properties, filterType);
}
});
return this;
}
public CopySpec filter(final Class<? extends FilterReader> filterType) {
actions.add(new Action<FileCopyDetails>() {
public void execute(FileCopyDetails fileCopyDetails) {
fileCopyDetails.filter(filterType);
}
});
return this;
}
public CopySpec filter(final Map<String, ?> properties, final Class<? extends FilterReader> filterType) {
actions.add(new Action<FileCopyDetails>() {
public void execute(FileCopyDetails fileCopyDetails) {
fileCopyDetails.filter(properties, filterType);
}
});
return this;
}
public void test_ConstructorLjava_io_Reader() {
FilterReader myReader = null;
called = true;
try {
myReader = new MyFilterReader(null);
fail("NullPointerException expected.");
} catch (NullPointerException e) {
// expected
}
}
private static Reader doNotClose(Reader input) {
return new FilterReader(input) {
@Override
public void close() {
// NOTHING.
}
};
}
/**
* {@inheritDoc}
*/
public AbstractCopyTask filter(Map<String, ?> properties, Class<? extends FilterReader> filterType) {
getMainSpec().filter(properties, filterType);
return this;
}
/**
* {@inheritDoc}
*/
public AbstractCopyTask filter(Class<? extends FilterReader> filterType) {
getMainSpec().filter(filterType);
return this;
}
public CopySpec filter(Map<String, ?> properties, Class<? extends FilterReader> filterType) {
delegate.filter(properties, filterType);
return this;
}
public CopySpec filter(Class<? extends FilterReader> filterType) {
delegate.filter(filterType);
return this;
}
public CopySpec filter(Map<String, ?> properties, Class<? extends FilterReader> filterType) {
return getDelegateCopySpec().filter(properties, filterType);
}
public CopySpec filter(Class<? extends FilterReader> filterType) {
return getDelegateCopySpec().filter(filterType);
}
public ContentFilterable filter(Map<String, ?> properties, Class<? extends FilterReader> filterType) {
throw new UnsupportedOperationException();
}
public ContentFilterable filter(Class<? extends FilterReader> filterType) {
throw new UnsupportedOperationException();
}
/**
* {@inheritDoc}
*/
public AbstractCopyTask filter(Map<String, ?> properties, Class<? extends FilterReader> filterType) {
getMainSpec().filter(properties, filterType);
return this;
}
/**
* {@inheritDoc}
*/
public AbstractCopyTask filter(Class<? extends FilterReader> filterType) {
getMainSpec().filter(filterType);
return this;
}
public CopySpec filter(Map<String, ?> properties, Class<? extends FilterReader> filterType) {
delegate.filter(properties, filterType);
return this;
}
public CopySpec filter(Class<? extends FilterReader> filterType) {
delegate.filter(filterType);
return this;
}
public CopySpec filter(Map<String, ?> properties, Class<? extends FilterReader> filterType) {
return getDelegateCopySpec().filter(properties, filterType);
}
public CopySpec filter(Class<? extends FilterReader> filterType) {
return getDelegateCopySpec().filter(filterType);
}
public ContentFilterable filter(Map<String, ?> properties, Class<? extends FilterReader> filterType) {
throw new UnsupportedOperationException();
}