⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 filterset.java

📁 Use the links below to download a source distribution of Ant from one of our mirrors. It is good pra
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* *  Licensed to the Apache Software Foundation (ASF) under one or more *  contributor license agreements.  See the NOTICE file distributed with *  this work for additional information regarding copyright ownership. *  The ASF licenses this file to You under the Apache License, Version 2.0 *  (the "License"); you may not use this file except in compliance with *  the License.  You may obtain a copy of the License at * *      http://www.apache.org/licenses/LICENSE-2.0 * *  Unless required by applicable law or agreed to in writing, software *  distributed under the License is distributed on an "AS IS" BASIS, *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *  See the License for the specific language governing permissions and *  limitations under the License. * */package org.apache.tools.ant.types;import java.io.File;import java.io.FileInputStream;import java.util.Enumeration;import java.util.Hashtable;import java.util.Properties;import java.util.Vector;import org.apache.tools.ant.Project;import org.apache.tools.ant.BuildException;import org.apache.tools.ant.util.FileUtils;/** * A set of filters to be applied to something. * * A filter set may have begintoken and endtokens defined. * */public class FilterSet extends DataType implements Cloneable {    /**     * Individual filter component of filterset.     *     */    public static class Filter {        // CheckStyle:VisibilityModifier OFF - bc        /** Token which will be replaced in the filter operation. */        String token;        /** The value which will replace the token in the filtering operation. */        String value;        // CheckStyle:VisibilityModifier ON        /**         * Constructor for the Filter object.         *         * @param token  The token which will be replaced when filtering.         * @param value  The value which will replace the token when filtering.         */        public Filter(String token, String value) {           setToken(token);           setValue(value);        }        /**         * No-argument conmstructor.         */        public Filter() {        }        /**         * Sets the Token attribute of the Filter object.         *         * @param token  The new Token value.         */        public void setToken(String token) {           this.token = token;        }        /**         * Sets the Value attribute of the Filter object.         *         * @param value  The new Value value.         */        public void setValue(String value) {           this.value = value;        }        /**         * Gets the Token attribute of the Filter object.         *         * @return   The Token value.         */        public String getToken() {           return token;        }        /**         * Gets the Value attribute of the Filter object.         *         * @return   The Value value.         */        public String getValue() {           return value;        }     }    /**     * The filtersfile nested element.     *     */    public class FiltersFile {        /**         * Constructor for the FiltersFile object.         */        public FiltersFile() {        }        /**         * Sets the file from which filters will be read.         *         * @param file the file from which filters will be read.         */        public void setFile(File file) {           filtersFiles.add(file);        }    }    /**     * EnumeratedAttribute to set behavior WRT missing filtersfiles:     * "fail" (default), "warn", "ignore".     * @since Ant 1.7     */    public static class OnMissing extends EnumeratedAttribute {        private static final String[] VALUES            = new String[] {"fail", "warn", "ignore"};        /** Fail value */        public static final OnMissing FAIL = new OnMissing("fail");        /** Warn value */        public static final OnMissing WARN = new OnMissing("warn");        /** Ignore value */        public static final OnMissing IGNORE = new OnMissing("ignore");        private static final int FAIL_INDEX = 0;        private static final int WARN_INDEX = 1;        private static final int IGNORE_INDEX = 2;        /**         * Default constructor.         */        public OnMissing() {        }        /**         * Convenience constructor.         * @param value the value to set.         */        public OnMissing(String value) {            setValue(value);        }        //inherit doc        /** {@inheritDoc}. */        public String[] getValues() {            return VALUES;        }    }    /** The default token start string */    public static final String DEFAULT_TOKEN_START = "@";    /** The default token end string */    public static final String DEFAULT_TOKEN_END = "@";    private String startOfToken = DEFAULT_TOKEN_START;    private String endOfToken = DEFAULT_TOKEN_END;    /** Contains a list of parsed tokens */    private Vector passedTokens;    /** if a duplicate token is found, this is set to true */    private boolean duplicateToken = false;    private boolean recurse = true;    private Hashtable filterHash = null;    private Vector filtersFiles = new Vector();    private OnMissing onMissingFiltersFile = OnMissing.FAIL;    private boolean readingFiles = false;    private int recurseDepth = 0;    /**     * List of ordered filters and filter files.     */    private Vector filters = new Vector();    /**     * Default constructor.     */    public FilterSet() {    }    /**     * Create a Filterset from another filterset.     *     * @param filterset the filterset upon which this filterset will be based.     */    protected FilterSet(FilterSet filterset) {        super();        this.filters = (Vector) filterset.getFilters().clone();    }    /**     * Get the filters in the filter set.     *     * @return a Vector of Filter instances.     */    protected synchronized Vector getFilters() {        if (isReference()) {            return getRef().getFilters();        }        //silly hack to avoid stack overflow...        if (!readingFiles) {            readingFiles = true;            for (int i = 0, sz = filtersFiles.size(); i < sz; i++) {                readFiltersFromFile((File) filtersFiles.get(i));            }            filtersFiles.clear();            readingFiles = false;        }        return filters;    }    /**     * Get the referenced filter set.     *     * @return the filterset from the reference.     */    protected FilterSet getRef() {        return (FilterSet) getCheckedRef(FilterSet.class, "filterset");    }    /**     * Gets the filter hash of the FilterSet.     *     * @return   The hash of the tokens and values for quick lookup.     */    public synchronized Hashtable getFilterHash() {        if (filterHash == null) {            filterHash = new Hashtable(getFilters().size());            for (Enumeration e = getFilters().elements(); e.hasMoreElements();) {               Filter filter = (Filter) e.nextElement();               filterHash.put(filter.getToken(), filter.getValue());            }        }        return filterHash;    }    /**     * Set the file containing the filters for this filterset.     *     * @param filtersFile sets the filter file from which to read filters     *        for this filter set.     * @throws BuildException if there is an error.     */    public void setFiltersfile(File filtersFile) throws BuildException {        if (isReference()) {            throw tooManyAttributes();        }        filtersFiles.add(filtersFile);    }    /**     * Set the string used to id the beginning of a token.     *     * @param startOfToken  The new Begintoken value.     */    public void setBeginToken(String startOfToken) {        if (isReference()) {            throw tooManyAttributes();        }        if (startOfToken == null || "".equals(startOfToken)) {            throw new BuildException("beginToken must not be empty");        }        this.startOfToken = startOfToken;    }    /**     * Get the begin token for this filterset.     *     * @return the filter set's begin token for filtering.     */    public String getBeginToken() {        if (isReference()) {            return getRef().getBeginToken();        }        return startOfToken;    }    /**     * Set the string used to id the end of a token.     *     * @param endOfToken  The new Endtoken value.     */    public void setEndToken(String endOfToken) {        if (isReference()) {            throw tooManyAttributes();        }        if (endOfToken == null || "".equals(endOfToken)) {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -