本文整理汇总了Java中org.apache.tools.ant.filters.ChainableReader类的典型用法代码示例。如果您正苦于以下问题:Java ChainableReader类的具体用法?Java ChainableReader怎么用?Java ChainableReader使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ChainableReader类属于org.apache.tools.ant.filters包,在下文中一共展示了ChainableReader类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: add
import org.apache.tools.ant.filters.ChainableReader; //导入依赖的package包/类
/**
* Add a chainfilter filter.
*
* @param filter a <code>ChainableReader</code> value
* @since Ant 1.6
*/
public void add(ChainableReader filter) {
if (isReference()) {
throw noChildrenAllowed();
}
setChecked(false);
filterReaders.addElement(filter);
}
示例2: getAssembledReader
import org.apache.tools.ant.filters.ChainableReader; //导入依赖的package包/类
/**
* Assemble the reader
* @return the assembled reader
* @exception BuildException if an error occurs
*/
public ChainReader getAssembledReader() throws BuildException {
if (primaryReader == null) {
throw new BuildException("primaryReader must not be null.");
}
Reader instream = primaryReader;
final List<AntClassLoader> classLoadersToCleanUp = new ArrayList<>();
final List<Object> finalFilters =
filterChains.stream().map(FilterChain::getFilterReaders)
.flatMap(Collection::stream).collect(Collectors.toList());
if (!finalFilters.isEmpty()) {
boolean success = false;
try {
for (Object o : finalFilters) {
if (o instanceof AntFilterReader) {
instream =
expandReader((AntFilterReader) o,
instream, classLoadersToCleanUp);
} else if (o instanceof ChainableReader) {
setProjectOnObject(o);
instream = ((ChainableReader) o).chain(instream);
setProjectOnObject(instream);
}
}
success = true;
} finally {
if (!(success || classLoadersToCleanUp.isEmpty())) {
cleanUpClassLoaders(classLoadersToCleanUp);
}
}
}
return new ChainReader(instream, classLoadersToCleanUp);
}
示例3: extractCharResource
import org.apache.tools.ant.filters.ChainableReader; //导入依赖的package包/类
/**
* Extracts a char resource from plugin to a file applying a token filter.
*/
protected void extractCharResource(String fromResource, File to, ChainableReader filter) {
int bufferSize = 8 * 1024;
try(InputStream in = getClass().getClassLoader().getResourceAsStream(fromResource)) {
if (in == null) {
throw new BuildException("Resource not found: " + fromResource);
}
ensureParentDirExists(to);
Reader reader = filter.chain(new InputStreamReader(in, "UTF-8"));
char[] buffer = new char[bufferSize];
int read;
try(Writer out = new BufferedWriter(new FileWriter(to), bufferSize)) {
while ((read = reader.read(buffer, 0, bufferSize)) >= 0) {
out.write(buffer, 0, read);
}
out.flush();
}
} catch (IOException e) {
throw new BuildException("Error copying resource " + fromResource, e);
}
}