当前位置: 首页>>代码示例>>Java>>正文


Java ChainableReader类代码示例

本文整理汇总了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);
}
 
开发者ID:apache,项目名称:ant,代码行数:15,代码来源:FilterChain.java

示例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);
}
 
开发者ID:apache,项目名称:ant,代码行数:41,代码来源:ChainReaderHelper.java

示例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);
    }
}
 
开发者ID:andrus,项目名称:japp-maven-plugin,代码行数:30,代码来源:AbstractAntWorker.java


注:本文中的org.apache.tools.ant.filters.ChainableReader类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。