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

📄 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 页
字号:
     * Returns the directory scanner needed to access the files to process.     * @param p the Project against which the DirectoryScanner should be configured.     * @return a <code>DirectoryScanner</code> instance.     */    public DirectoryScanner getDirectoryScanner(Project p) {        if (isReference()) {            return getRef(p).getDirectoryScanner(p);        }        DirectoryScanner ds = null;        synchronized (this) {            if (directoryScanner != null && p == getProject()) {                ds = directoryScanner;            } else {                if (dir == null) {                    throw new BuildException("No directory specified for "                                             + getDataTypeName() + ".");                }                if (!dir.exists() && errorOnMissingDir) {                    throw new BuildException(dir.getAbsolutePath()                                             + " not found.");                }                if (!dir.isDirectory() && dir.exists()) {                    throw new BuildException(dir.getAbsolutePath()                                             + " is not a directory.");                }                ds = new DirectoryScanner();                setupDirectoryScanner(ds, p);                ds.setFollowSymlinks(followSymlinks);                ds.setErrorOnMissingDir(errorOnMissingDir);                directoryScanner = (p == getProject()) ? ds : directoryScanner;            }        }        ds.scan();        return ds;    }    /**     * Set up the specified directory scanner against this     * AbstractFileSet's Project.     * @param ds a <code>FileScanner</code> instance.     */    public void setupDirectoryScanner(FileScanner ds) {        setupDirectoryScanner(ds, getProject());    }    /**     * Set up the specified directory scanner against the specified project.     * @param ds a <code>FileScanner</code> instance.     * @param p an Ant <code>Project</code> instance.     */    public synchronized void setupDirectoryScanner(FileScanner ds, Project p) {        if (isReference()) {            getRef(p).setupDirectoryScanner(ds, p);            return;        }        if (ds == null) {            throw new IllegalArgumentException("ds cannot be null");        }        ds.setBasedir(dir);        PatternSet ps = mergePatterns(p);        p.log(getDataTypeName() + ": Setup scanner in dir " + dir            + " with " + ps, Project.MSG_DEBUG);        ds.setIncludes(ps.getIncludePatterns(p));        ds.setExcludes(ps.getExcludePatterns(p));        if (ds instanceof SelectorScanner) {            SelectorScanner ss = (SelectorScanner) ds;            ss.setSelectors(getSelectors(p));        }        if (useDefaultExcludes) {            ds.addDefaultExcludes();        }        ds.setCaseSensitive(caseSensitive);    }    /**     * Performs the check for circular references and returns the     * referenced FileSet.     * @param p the current project     * @return the referenced FileSet     */    protected AbstractFileSet getRef(Project p) {        return (AbstractFileSet) getCheckedRef(p);    }    // SelectorContainer methods    /**     * Indicates whether there are any selectors here.     *     * @return whether any selectors are in this container.     */    public synchronized boolean hasSelectors() {        return (isReference() && getProject() != null)            ? getRef(getProject()).hasSelectors() : !(selectors.isEmpty());    }    /**     * Indicates whether there are any patterns here.     *     * @return whether any patterns are in this container.     */    public synchronized boolean hasPatterns() {        if (isReference() && getProject() != null) {            return getRef(getProject()).hasPatterns();        }        if (defaultPatterns.hasPatterns(getProject())) {            return true;        }        Enumeration e = additionalPatterns.elements();        while (e.hasMoreElements()) {            PatternSet ps = (PatternSet) e.nextElement();            if (ps.hasPatterns(getProject())) {                return true;            }        }        return false;    }    /**     * Gives the count of the number of selectors in this container.     *     * @return the number of selectors in this container as an <code>int</code>.     */    public synchronized int selectorCount() {        return (isReference() && getProject() != null)            ? getRef(getProject()).selectorCount() : selectors.size();    }    /**     * Returns the set of selectors as an array.     * @param p the current project     * @return a <code>FileSelector[]</code> of the selectors in this container.     */    public synchronized FileSelector[] getSelectors(Project p) {        return (isReference())            ? getRef(p).getSelectors(p) : (FileSelector[]) (selectors.toArray(            new FileSelector[selectors.size()]));    }    /**     * Returns an enumerator for accessing the set of selectors.     *     * @return an <code>Enumeration</code> of selectors.     */    public synchronized Enumeration selectorElements() {        return (isReference() && getProject() != null)            ? getRef(getProject()).selectorElements() : selectors.elements();    }    /**     * Add a new selector into this container.     *     * @param selector the new <code>FileSelector</code> to add.     */    public synchronized void appendSelector(FileSelector selector) {        if (isReference()) {            throw noChildrenAllowed();        }        selectors.addElement(selector);        directoryScanner = null;    }    /* Methods below all add specific selectors */    /**     * Add a "Select" selector entry on the selector list.     * @param selector the <code>SelectSelector</code> to add.     */    public void addSelector(SelectSelector selector) {        appendSelector(selector);    }    /**     * Add an "And" selector entry on the selector list.     * @param selector the <code>AndSelector</code> to add.     */    public void addAnd(AndSelector selector) {        appendSelector(selector);    }    /**     * Add an "Or" selector entry on the selector list.     * @param selector the <code>OrSelector</code> to add.     */    public void addOr(OrSelector selector) {        appendSelector(selector);    }    /**     * Add a "Not" selector entry on the selector list.     * @param selector the <code>NotSelector</code> to add.     */    public void addNot(NotSelector selector) {        appendSelector(selector);    }    /**     * Add a "None" selector entry on the selector list.     * @param selector the <code>NoneSelector</code> to add.     */    public void addNone(NoneSelector selector) {        appendSelector(selector);    }    /**     * Add a majority selector entry on the selector list.     * @param selector the <code>MajoritySelector</code> to add.     */    public void addMajority(MajoritySelector selector) {        appendSelector(selector);    }    /**     * Add a selector date entry on the selector list.     * @param selector the <code>DateSelector</code> to add.     */    public void addDate(DateSelector selector) {        appendSelector(selector);    }    /**     * Add a selector size entry on the selector list.     * @param selector the <code>SizeSelector</code> to add.     */    public void addSize(SizeSelector selector) {        appendSelector(selector);    }    /**     * Add a DifferentSelector entry on the selector list.     * @param selector the <code>DifferentSelector</code> to add.     */    public void addDifferent(DifferentSelector selector) {        appendSelector(selector);    }    /**     * Add a selector filename entry on the selector list.     * @param selector the <code>FilenameSelector</code> to add.     */    public void addFilename(FilenameSelector selector) {        appendSelector(selector);    }    /**     * Add a selector type entry on the selector list.     * @param selector the <code>TypeSelector</code> to add.     */    public void addType(TypeSelector selector) {        appendSelector(selector);    }    /**     * Add an extended selector entry on the selector list.     * @param selector the <code>ExtendSelector</code> to add.     */    public void addCustom(ExtendSelector selector) {        appendSelector(selector);    }    /**     * Add a contains selector entry on the selector list.     * @param selector the <code>ContainsSelector</code> to add.     */    public void addContains(ContainsSelector selector) {        appendSelector(selector);    }    /**     * Add a present selector entry on the selector list.     * @param selector the <code>PresentSelector</code> to add.     */    public void addPresent(PresentSelector selector) {        appendSelector(selector);    }    /**     * Add a depth selector entry on the selector list.     * @param selector the <code>DepthSelector</code> to add.     */    public void addDepth(DepthSelector selector) {        appendSelector(selector);    }    /**     * Add a depends selector entry on the selector list.     * @param selector the <code>DependSelector</code> to add.     */    public void addDepend(DependSelector selector) {        appendSelector(selector);    }    /**     * Add a regular expression selector entry on the selector list.     * @param selector the <code>ContainsRegexpSelector</code> to add.     */    public void addContainsRegexp(ContainsRegexpSelector selector) {        appendSelector(selector);    }    /**     * Add the modified selector.     * @param selector the <code>ModifiedSelector</code> to add.     * @since ant 1.6     */    public void addModified(ModifiedSelector selector) {        appendSelector(selector);    }    /**     * Add an arbitary selector.     * @param selector the <code>FileSelector</code> to add.     * @since Ant 1.6     */    public void add(FileSelector selector) {        appendSelector(selector);    }    /**     * Returns included files as a list of semicolon-separated filenames.     *     * @return a <code>String</code> of included filenames.     */    public String toString() {        DirectoryScanner ds = getDirectoryScanner(getProject());        String[] files = ds.getIncludedFiles();        StringBuffer sb = new StringBuffer();        for (int i = 0; i < files.length; i++) {            if (i > 0) {                sb.append(';');            }            sb.append(files[i]);        }        return sb.toString();    }    /**     * Creates a deep clone of this instance, except for the nested     * selectors (the list of selectors is a shallow clone of this     * instance's list).     * @return the cloned object     * @since Ant 1.6     */    public synchronized Object clone() {        if (isReference()) {            return (getRef(getProject())).clone();        } else {            try {                AbstractFileSet fs = (AbstractFileSet) super.clone();                fs.defaultPatterns = (PatternSet) defaultPatterns.clone();                fs.additionalPatterns = new Vector(additionalPatterns.size());                Enumeration e = additionalPatterns.elements();                while (e.hasMoreElements()) {                    fs.additionalPatterns                        .addElement(((PatternSet) e.nextElement()).clone());                }                fs.selectors = new Vector(selectors);                return fs;            } catch (CloneNotSupportedException e) {                throw new BuildException(e);            }        }    }    /**     * Get the merged include patterns for this AbstractFileSet.     * @param p the project to use.     * @return the include patterns of the default pattern set and all     * nested patternsets.     *     * @since Ant 1.7     */    public String[] mergeIncludes(Project p) {        return mergePatterns(p).getIncludePatterns(p);    }    /**     * Get the merged exclude patterns for this AbstractFileSet.     * @param p the project to use.     * @return the exclude patterns of the default pattern set and all     * nested patternsets.     *     * @since Ant 1.7     */    public String[] mergeExcludes(Project p) {        return mergePatterns(p).getExcludePatterns(p);    }    /**     * Get the merged patterns for this AbstractFileSet.     * @param p the project to use.     * @return the default patternset merged with the additional sets     * in a new PatternSet instance.     *     * @since Ant 1.7     */    public synchronized PatternSet mergePatterns(Project p) {        if (isReference()) {            return getRef(p).mergePatterns(p);        }        PatternSet ps = (PatternSet) defaultPatterns.clone();        final int count = additionalPatterns.size();        for (int i = 0; i < count; i++) {            Object o = additionalPatterns.elementAt(i);            ps.append((PatternSet) o, p);        }        return ps;    }}

⌨️ 快捷键说明

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