Examples of ChainReaderHelper


Examples of org.apache.tools.ant.filters.util.ChainReaderHelper

                instream = new InputStreamReader(bis);
            } else {
                instream = new InputStreamReader(bis, encoding);
            }

            ChainReaderHelper crh = new ChainReaderHelper();
            crh.setPrimaryReader(instream);
            crh.setFilterChains(filterChains);
            crh.setProject(getProject());
            instream = crh.getAssembledReader();

            String text = crh.readFully(instream);

            if (text != null) {
                if (!text.endsWith("\n")) {
                    text = text + "\n";
                }
View Full Code Here

Examples of org.apache.tools.ant.filters.util.ChainReaderHelper

            if (encoding == null) {
                instream = new InputStreamReader(bis);
            } else {
                instream = new InputStreamReader(bis, encoding);
            }
            ChainReaderHelper crh = new ChainReaderHelper();
            crh.setPrimaryReader(instream);
            crh.setFilterChains(filterChains);
            crh.setProject(getProject());
            instream = crh.getAssembledReader();

            String text = crh.readFully(instream);

            if (text != null && text.length() != 0) {
                if (!text.endsWith("\n")) {
                    text = text + "\n";
                }
View Full Code Here

Examples of org.apache.tools.ant.filters.util.ChainReaderHelper

    private Reader getFilteredReader(Reader r) {
        if (filterChains == null) {
            return r;
        }
        ChainReaderHelper helper = new ChainReaderHelper();
        helper.setBufferSize(BUFFER_SIZE);
        helper.setPrimaryReader(r);
        helper.setFilterChains(filterChains);
        helper.setProject(getProject());
        //used to be a BufferedReader here, but we should be buffering lower:
        return helper.getAssembledReader();
    }
View Full Code Here

Examples of org.apache.tools.ant.filters.util.ChainReaderHelper

                } else {
                    osw = new OutputStreamWriter(os, outputEncoding);
                }
                out = new BufferedWriter(osw);
                if (filterChainsAvailable) {
                    ChainReaderHelper crh = new ChainReaderHelper();
                    crh.setBufferSize(FileUtils.BUF_SIZE);
                    crh.setPrimaryReader(in);
                    crh.setFilterChains(filterChains);
                    crh.setProject(project);
                    Reader rdr = crh.getAssembledReader();
                    in = new BufferedReader(rdr);
                }
                LineTokenizer lineTokenizer = new LineTokenizer();
                lineTokenizer.setIncludeDelims(true);
                String newline = null;
                String line = lineTokenizer.getToken(in);
                while (line != null) {
                    if (line.length() == 0) {
                        // this should not happen, because the lines are
                        // returned with the end of line delimiter
                        out.newLine();
                    } else {
                        newline = filters.replaceTokens(line);
                        out.write(newline);
                    }
                    line = lineTokenizer.getToken(in);
                }
            } finally {
                FileUtils.close(out);
                FileUtils.close(in);
            }
        } else if (filterChainsAvailable
                   || (inputEncoding != null
                       && !inputEncoding.equals(outputEncoding))
                   || (inputEncoding == null && outputEncoding != null)) {
            BufferedReader in = null;
            BufferedWriter out = null;
            try {
                InputStreamReader isr = null;
                if (inputEncoding == null) {
                    isr = new InputStreamReader(source.getInputStream());
                } else {
                    isr = new InputStreamReader(source.getInputStream(),
                                                inputEncoding);
                }
                in = new BufferedReader(isr);
                OutputStream os = getOutputStream(dest, append, project);
                OutputStreamWriter osw;
                if (outputEncoding == null) {
                    osw = new OutputStreamWriter(os);
                } else {
                    osw = new OutputStreamWriter(os, outputEncoding);
                }
                out = new BufferedWriter(osw);
                if (filterChainsAvailable) {
                    ChainReaderHelper crh = new ChainReaderHelper();
                    crh.setBufferSize(FileUtils.BUF_SIZE);
                    crh.setPrimaryReader(in);
                    crh.setFilterChains(filterChains);
                    crh.setProject(project);
                    Reader rdr = crh.getAssembledReader();
                    in = new BufferedReader(rdr);
                }
                char[] buffer = new char[FileUtils.BUF_SIZE];
                while (true) {
                    int nRead = in.read(buffer, 0, buffer.length);
View Full Code Here

Examples of org.apache.tools.ant.filters.util.ChainReaderHelper

            } else {
                osw = new OutputStreamWriter(os, outputEncoding);
            }
            out = new BufferedWriter(osw);
            if (filterChainsAvailable) {
                ChainReaderHelper crh = new ChainReaderHelper();
                crh.setBufferSize(FileUtils.BUF_SIZE);
                crh.setPrimaryReader(in);
                crh.setFilterChains(filterChains);
                crh.setProject(project);
                Reader rdr = crh.getAssembledReader();
                in = new BufferedReader(rdr);
            }
            LineTokenizer lineTokenizer = new LineTokenizer();
            lineTokenizer.setIncludeDelims(true);
            String newline = null;
View Full Code Here

Examples of org.apache.tools.ant.filters.util.ChainReaderHelper

            } else {
                osw = new OutputStreamWriter(os, outputEncoding);
            }
            out = new BufferedWriter(osw);
            if (filterChainsAvailable) {
                ChainReaderHelper crh = new ChainReaderHelper();
                crh.setBufferSize(FileUtils.BUF_SIZE);
                crh.setPrimaryReader(in);
                crh.setFilterChains(filterChains);
                crh.setProject(project);
                Reader rdr = crh.getAssembledReader();
                in = new BufferedReader(rdr);
            }
            char[] buffer = new char[FileUtils.BUF_SIZE];
            while (true) {
                int nRead = in.read(buffer, 0, buffer.length);
View Full Code Here

Examples of org.apache.tools.ant.filters.util.ChainReaderHelper

     *          the filterchain returns an empty string.
     */
    public String[] mapFileName(String sourceFileName) {
        try {
            Reader stringReader = new StringReader(sourceFileName);
            ChainReaderHelper helper = new ChainReaderHelper();
            helper.setBufferSize(BUFFER_SIZE);
            helper.setPrimaryReader(stringReader);
            helper.setProject(getProject());
            Vector<FilterChain> filterChains = new Vector<FilterChain>();
            filterChains.add(this);
            helper.setFilterChains(filterChains);
            String result = FileUtils.safeReadFully(helper.getAssembledReader());
            if (result.length() == 0) {
                return null;
            } else {
                return new String[] {result};
            }
View Full Code Here

Examples of org.apache.tools.ant.filters.util.ChainReaderHelper

            if (encoding == null) {
                input = new InputStreamReader(bis);
            } else {
                input = new InputStreamReader(bis, encoding);
            }
            ChainReaderHelper crh = new ChainReaderHelper();
            crh.setPrimaryReader(input);
            crh.setFilterChains(filterChains);
            crh.setProject(getProject());
            BufferedReader reader = new BufferedReader(crh.getAssembledReader());

            Union streamResources = new Union();
            streamResources.setCache(true);

            String line = null;
View Full Code Here

Examples of org.apache.tools.ant.filters.util.ChainReaderHelper

                instream = new InputStreamReader(bis, encoding);
            }

            String text = "";
            if (size != 0) {
                ChainReaderHelper crh = new ChainReaderHelper();
                if (len != Resource.UNKNOWN_SIZE) {
                    crh.setBufferSize(size);
                }
                crh.setPrimaryReader(instream);
                crh.setFilterChains(filterChains);
                crh.setProject(getProject());
                instream = crh.getAssembledReader();

                text = crh.readFully(instream);
            } else {
                log("Do not set property " + property + " as its length is 0.",
                    quiet ? Project.MSG_VERBOSE : Project.MSG_INFO);
            }
View Full Code Here

Examples of org.apache.tools.ant.filters.util.ChainReaderHelper

    private Reader getFilteredReader(Reader r) {
        if (filterChains == null) {
            return r;
        }
        ChainReaderHelper helper = new ChainReaderHelper();
        helper.setBufferSize(BUFFER_SIZE);
        helper.setPrimaryReader(r);
        helper.setFilterChains(filterChains);
        helper.setProject(getProject());
        //used to be a BufferedReader here, but we should be buffering lower:
        return helper.getAssembledReader();
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.