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

📄 abstractfileset.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.util.Vector;import java.util.Enumeration;import org.apache.tools.ant.Project;import org.apache.tools.ant.FileScanner;import org.apache.tools.ant.BuildException;import org.apache.tools.ant.DirectoryScanner;import org.apache.tools.ant.types.selectors.OrSelector;import org.apache.tools.ant.types.selectors.AndSelector;import org.apache.tools.ant.types.selectors.NotSelector;import org.apache.tools.ant.types.selectors.DateSelector;import org.apache.tools.ant.types.selectors.FileSelector;import org.apache.tools.ant.types.selectors.NoneSelector;import org.apache.tools.ant.types.selectors.SizeSelector;import org.apache.tools.ant.types.selectors.TypeSelector;import org.apache.tools.ant.types.selectors.DepthSelector;import org.apache.tools.ant.types.selectors.DependSelector;import org.apache.tools.ant.types.selectors.ExtendSelector;import org.apache.tools.ant.types.selectors.SelectSelector;import org.apache.tools.ant.types.selectors.PresentSelector;import org.apache.tools.ant.types.selectors.SelectorScanner;import org.apache.tools.ant.types.selectors.ContainsSelector;import org.apache.tools.ant.types.selectors.FilenameSelector;import org.apache.tools.ant.types.selectors.MajoritySelector;import org.apache.tools.ant.types.selectors.DifferentSelector;import org.apache.tools.ant.types.selectors.SelectorContainer;import org.apache.tools.ant.types.selectors.ContainsRegexpSelector;import org.apache.tools.ant.types.selectors.modifiedselector.ModifiedSelector;/** * Class that holds an implicit patternset and supports nested * patternsets and creates a DirectoryScanner using these patterns. * * <p>Common base class for DirSet and FileSet.</p> * */public abstract class AbstractFileSet extends DataType    implements Cloneable, SelectorContainer {    private PatternSet defaultPatterns = new PatternSet();    private Vector additionalPatterns = new Vector();    private Vector selectors = new Vector();    private File dir;    private boolean useDefaultExcludes = true;    private boolean caseSensitive = true;    private boolean followSymlinks = true;    private boolean errorOnMissingDir = true;    /* cached DirectoryScanner instance for our own Project only */    private DirectoryScanner directoryScanner = null;    /**     * Construct a new <code>AbstractFileSet</code>.     */    public AbstractFileSet() {        super();    }    /**     * Construct a new <code>AbstractFileSet</code>, shallowly cloned     * from the specified <code>AbstractFileSet</code>.     * @param fileset the <code>AbstractFileSet</code> to use as a template.     */    protected AbstractFileSet(AbstractFileSet fileset) {        this.dir = fileset.dir;        this.defaultPatterns = fileset.defaultPatterns;        this.additionalPatterns = fileset.additionalPatterns;        this.selectors = fileset.selectors;        this.useDefaultExcludes = fileset.useDefaultExcludes;        this.caseSensitive = fileset.caseSensitive;        this.followSymlinks = fileset.followSymlinks;        this.errorOnMissingDir = fileset.errorOnMissingDir;        setProject(fileset.getProject());    }    /**     * Makes this instance in effect a reference to another instance.     *     * <p>You must not set another attribute or nest elements inside     * this element if you make it a reference.</p>     * @param r the <code>Reference</code> to use.     * @throws BuildException on error     */    public void setRefid(Reference r) throws BuildException {        if (dir != null || defaultPatterns.hasPatterns(getProject())) {            throw tooManyAttributes();        }        if (!additionalPatterns.isEmpty()) {            throw noChildrenAllowed();        }        if (!selectors.isEmpty()) {            throw noChildrenAllowed();        }        super.setRefid(r);    }    /**     * Sets the base-directory for this instance.     * @param dir the directory's <code>File</code> instance.     * @throws BuildException on error     */    public synchronized void setDir(File dir) throws BuildException {        if (isReference()) {            throw tooManyAttributes();        }        this.dir = dir;        directoryScanner = null;    }    /**     * Retrieves the base-directory for this instance.     * @return <code>File</code>.     */    public File getDir() {        return getDir(getProject());    }    /**     * Retrieves the base-directory for this instance.     * @param p the <code>Project</code> against which the     *          reference is resolved, if set.     * @return <code>File</code>.     */    public synchronized File getDir(Project p) {        return (isReference()) ? getRef(p).getDir(p) : dir;    }    /**     * Creates a nested patternset.     * @return <code>PatternSet</code>.     */    public synchronized PatternSet createPatternSet() {        if (isReference()) {            throw noChildrenAllowed();        }        PatternSet patterns = new PatternSet();        additionalPatterns.addElement(patterns);        directoryScanner = null;        return patterns;    }    /**     * Add a name entry to the include list.     * @return <code>PatternSet.NameEntry</code>.     */    public synchronized PatternSet.NameEntry createInclude() {        if (isReference()) {            throw noChildrenAllowed();        }        directoryScanner = null;        return defaultPatterns.createInclude();    }    /**     * Add a name entry to the include files list.     * @return <code>PatternSet.NameEntry</code>.     */    public synchronized PatternSet.NameEntry createIncludesFile() {        if (isReference()) {            throw noChildrenAllowed();        }        directoryScanner = null;        return defaultPatterns.createIncludesFile();    }    /**     * Add a name entry to the exclude list.     * @return <code>PatternSet.NameEntry</code>.     */    public synchronized PatternSet.NameEntry createExclude() {        if (isReference()) {            throw noChildrenAllowed();        }        directoryScanner = null;        return defaultPatterns.createExclude();    }    /**     * Add a name entry to the excludes files list.     * @return <code>PatternSet.NameEntry</code>.     */    public synchronized PatternSet.NameEntry createExcludesFile() {        if (isReference()) {            throw noChildrenAllowed();        }        directoryScanner = null;        return defaultPatterns.createExcludesFile();    }    /**     * Creates a single file fileset.     * @param file the single <code>File</code> included in this     *             <code>AbstractFileSet</code>.     */    public synchronized void setFile(File file) {        if (isReference()) {            throw tooManyAttributes();        }        setDir(file.getParentFile());        createInclude().setName(file.getName());    }    /**     * Appends <code>includes</code> to the current list of include     * patterns.     *     * <p>Patterns may be separated by a comma or a space.</p>     *     * @param includes the <code>String</code> containing the include patterns.     */    public synchronized void setIncludes(String includes) {        if (isReference()) {            throw tooManyAttributes();        }        defaultPatterns.setIncludes(includes);        directoryScanner = null;    }    /**     * Appends <code>includes</code> to the current list of include     * patterns.     *     * @param includes array containing the include patterns.     * @since Ant 1.7     */    public synchronized void appendIncludes(String[] includes) {        if (isReference()) {            throw tooManyAttributes();        }        if (includes != null) {            for (int i = 0; i < includes.length; i++) {                defaultPatterns.createInclude().setName(includes[i]);            }            directoryScanner = null;        }    }    /**     * Appends <code>excludes</code> to the current list of exclude     * patterns.     *     * <p>Patterns may be separated by a comma or a space.</p>     *     * @param excludes the <code>String</code> containing the exclude patterns.     */    public synchronized void setExcludes(String excludes) {        if (isReference()) {            throw tooManyAttributes();        }        defaultPatterns.setExcludes(excludes);        directoryScanner = null;    }    /**     * Appends <code>excludes</code> to the current list of include     * patterns.     *     * @param excludes array containing the exclude patterns.     * @since Ant 1.7     */    public synchronized void appendExcludes(String[] excludes) {        if (isReference()) {            throw tooManyAttributes();        }        if (excludes != null) {            for (int i = 0; i < excludes.length; i++) {                defaultPatterns.createExclude().setName(excludes[i]);            }            directoryScanner = null;        }    }    /**     * Sets the <code>File</code> containing the includes patterns.     *     * @param incl <code>File</code> instance.     * @throws BuildException on error     */    public synchronized void setIncludesfile(File incl) throws BuildException {        if (isReference()) {            throw tooManyAttributes();        }        defaultPatterns.setIncludesfile(incl);        directoryScanner = null;    }    /**     * Sets the <code>File</code> containing the excludes patterns.     *     * @param excl <code>File</code> instance.     * @throws BuildException on error     */    public synchronized void setExcludesfile(File excl) throws BuildException {        if (isReference()) {            throw tooManyAttributes();        }        defaultPatterns.setExcludesfile(excl);        directoryScanner = null;    }    /**     * Sets whether default exclusions should be used or not.     *     * @param useDefaultExcludes <code>boolean</code>.     */    public synchronized void setDefaultexcludes(boolean useDefaultExcludes) {        if (isReference()) {            throw tooManyAttributes();        }        this.useDefaultExcludes = useDefaultExcludes;        directoryScanner = null;    }    /**     * Whether default exclusions should be used or not.     * @return the default exclusions value.     * @since Ant 1.6.3     */    public synchronized boolean getDefaultexcludes() {        return (isReference())            ? getRef(getProject()).getDefaultexcludes() : useDefaultExcludes;    }    /**     * Sets case sensitivity of the file system.     *     * @param caseSensitive <code>boolean</code>.     */    public synchronized void setCaseSensitive(boolean caseSensitive) {        if (isReference()) {            throw tooManyAttributes();        }        this.caseSensitive = caseSensitive;        directoryScanner = null;    }    /**     * Find out if the fileset is case sensitive.     *     * @return <code>boolean</code> indicating whether the fileset is     * case sensitive.     *     * @since Ant 1.7     */    public synchronized boolean isCaseSensitive() {        return (isReference())            ? getRef(getProject()).isCaseSensitive() : caseSensitive;    }    /**     * Sets whether or not symbolic links should be followed.     *     * @param followSymlinks whether or not symbolic links should be followed.     */    public synchronized void setFollowSymlinks(boolean followSymlinks) {        if (isReference()) {            throw tooManyAttributes();        }        this.followSymlinks = followSymlinks;        directoryScanner = null;    }    /**     * Find out if the fileset wants to follow symbolic links.     *     * @return <code>boolean</code> indicating whether symbolic links     *         should be followed.     *     * @since Ant 1.6     */    public synchronized boolean isFollowSymlinks() {        return (isReference())            ? getRef(getProject()).isFollowSymlinks() : followSymlinks;    }    /**     * Sets whether an error is thrown if a directory does not exist.     *     * @param errorOnMissingDir true if missing directories cause errors,     *                        false if not.     */     public void setErrorOnMissingDir(boolean errorOnMissingDir) {         this.errorOnMissingDir = errorOnMissingDir;     }    /**     * Returns the directory scanner needed to access the files to process.     * @return a <code>DirectoryScanner</code> instance.     */    public DirectoryScanner getDirectoryScanner() {        return getDirectoryScanner(getProject());    }    /**

⌨️ 快捷键说明

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