📄 files.java
字号:
/* * 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.resources;import java.io.File;import java.util.Vector;import java.util.Iterator;import java.util.Collections;import org.apache.tools.ant.Project;import org.apache.tools.ant.BuildException;import org.apache.tools.ant.DirectoryScanner;import org.apache.tools.ant.types.Reference;import org.apache.tools.ant.types.PatternSet;import org.apache.tools.ant.types.ResourceCollection;import org.apache.tools.ant.types.selectors.FileSelector;import org.apache.tools.ant.types.selectors.AbstractSelectorContainer;/** * ResourceCollection implementation; like AbstractFileSet with absolute paths. * @since Ant 1.7 */public class Files extends AbstractSelectorContainer implements Cloneable, ResourceCollection { private static final Iterator EMPTY_ITERATOR = Collections.EMPTY_SET.iterator(); private PatternSet defaultPatterns = new PatternSet(); private Vector additionalPatterns = new Vector(); private Vector selectors = new Vector(); private boolean useDefaultExcludes = true; private boolean caseSensitive = true; private boolean followSymlinks = true; /* cached DirectoryScanner instance */ private DirectoryScanner ds = null; /** * Construct a new <code>Files</code> collection. */ public Files() { super(); } /** * Construct a new <code>Files</code> collection, shallowly cloned * from the specified <code>Files</code>. * @param f the <code>Files</code> to use as a template. */ protected Files(Files f) { this.defaultPatterns = f.defaultPatterns; this.additionalPatterns = f.additionalPatterns; this.selectors = f.selectors; this.useDefaultExcludes = f.useDefaultExcludes; this.caseSensitive = f.caseSensitive; this.followSymlinks = f.followSymlinks; this.ds = f.ds; setProject(f.getProject()); } /** * Make 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 if there is a problem. */ public void setRefid(Reference r) throws BuildException { if (hasPatterns(defaultPatterns)) { throw tooManyAttributes(); } if (!additionalPatterns.isEmpty()) { throw noChildrenAllowed(); } if (!selectors.isEmpty()) { throw noChildrenAllowed(); } super.setRefid(r); } /** * Create a nested patternset. * @return <code>PatternSet</code>. */ public synchronized PatternSet createPatternSet() { if (isReference()) { throw noChildrenAllowed(); } PatternSet patterns = new PatternSet(); additionalPatterns.addElement(patterns); ds = 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(); } ds = 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(); } ds = 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(); } ds = 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(); } ds = null; return defaultPatterns.createExcludesFile(); } /** * Append <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) { checkAttributesAllowed(); defaultPatterns.setIncludes(includes); ds = null; } /** * Append <code>includes</code> to the current list of include * patterns. * * @param includes array containing the include patterns. */ public synchronized void appendIncludes(String[] includes) { checkAttributesAllowed(); if (includes != null) { for (int i = 0; i < includes.length; i++) { defaultPatterns.createInclude().setName(includes[i]); } ds = null; } } /** * Append <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) { checkAttributesAllowed(); defaultPatterns.setExcludes(excludes); ds = null; } /** * Append <code>excludes</code> to the current list of include * patterns. * * @param excludes array containing the exclude patterns. */ public synchronized void appendExcludes(String[] excludes) { checkAttributesAllowed(); if (excludes != null) { for (int i = 0; i < excludes.length; i++) { defaultPatterns.createExclude().setName(excludes[i]); } ds = null; } } /** * Set the <code>File</code> containing the includes patterns. * * @param incl <code>File</code> instance. * @throws BuildException if there is a problem. */ public synchronized void setIncludesfile(File incl) throws BuildException { checkAttributesAllowed(); defaultPatterns.setIncludesfile(incl); ds = null; } /** * Set the <code>File</code> containing the excludes patterns. * * @param excl <code>File</code> instance. * @throws BuildException if there is a problem. */ public synchronized void setExcludesfile(File excl) throws BuildException { checkAttributesAllowed(); defaultPatterns.setExcludesfile(excl); ds = null; } /** * Set whether default exclusions should be used or not. * * @param useDefaultExcludes <code>boolean</code>. */ public synchronized void setDefaultexcludes(boolean useDefaultExcludes) { checkAttributesAllowed(); this.useDefaultExcludes = useDefaultExcludes; ds = null; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -