📄 files.java
字号:
/** * Get whether default exclusions should be used or not. * @return the defaultexclusions value. */ public synchronized boolean getDefaultexcludes() { return (isReference()) ? getRef().getDefaultexcludes() : useDefaultExcludes; } /** * Set case-sensitivity of the Files collection. * * @param caseSensitive <code>boolean</code>. */ public synchronized void setCaseSensitive(boolean caseSensitive) { checkAttributesAllowed(); this.caseSensitive = caseSensitive; ds = null; } /** * Find out if this Files collection is case-sensitive. * * @return <code>boolean</code> indicating whether the Files * collection is case-sensitive. */ public synchronized boolean isCaseSensitive() { return (isReference()) ? getRef().isCaseSensitive() : caseSensitive; } /** * Set whether or not symbolic links should be followed. * * @param followSymlinks whether or not symbolic links should be followed. */ public synchronized void setFollowSymlinks(boolean followSymlinks) { checkAttributesAllowed(); this.followSymlinks = followSymlinks; ds = null; } /** * Find out whether symbolic links should be followed. * * @return <code>boolean</code> indicating whether symbolic links * should be followed. */ public synchronized boolean isFollowSymlinks() { return (isReference()) ? getRef().isFollowSymlinks() : followSymlinks; } /** * Fulfill the ResourceCollection contract. * @return an Iterator of Resources. */ public synchronized Iterator iterator() { if (isReference()) { return getRef().iterator(); } ensureDirectoryScannerSetup(); ds.scan(); int fct = ds.getIncludedFilesCount(); int dct = ds.getIncludedDirsCount(); if (fct + dct == 0) { return EMPTY_ITERATOR; } FileResourceIterator result = new FileResourceIterator(); if (fct > 0) { result.addFiles(ds.getIncludedFiles()); } if (dct > 0) { result.addFiles(ds.getIncludedDirectories()); } return result; } /** * Fulfill the ResourceCollection contract. * @return number of elements as int. */ public synchronized int size() { if (isReference()) { return getRef().size(); } ensureDirectoryScannerSetup(); ds.scan(); return ds.getIncludedFilesCount() + ds.getIncludedDirsCount(); } /** * Find out whether this Files collection has patterns. * * @return whether any patterns are in this container. */ public synchronized boolean hasPatterns() { if (isReference()) { return getRef().hasPatterns(); } if (hasPatterns(defaultPatterns)) { return true; } for (Iterator i = additionalPatterns.iterator(); i.hasNext();) { if (hasPatterns((PatternSet) i.next())) { return true; } } return false; } /** * 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(); } super.appendSelector(selector); ds = null; } /** * Format this Files collection as a String. * @return a descriptive <code>String</code>. */ public String toString() { if (isReference()) { return getRef().toString(); } Iterator i = iterator(); if (!i.hasNext()) { return ""; } StringBuffer sb = new StringBuffer(); while (i.hasNext()) { if (sb.length() > 0) { sb.append(File.pathSeparatorChar); } sb.append(i.next()); } return sb.toString(); } /** * Create 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 a cloned Object. */ public synchronized Object clone() { if (isReference()) { return getRef().clone(); } try { Files f = (Files) super.clone(); f.defaultPatterns = (PatternSet) defaultPatterns.clone(); f.additionalPatterns = new Vector(additionalPatterns.size()); for (Iterator iter = additionalPatterns.iterator(); iter.hasNext();) { PatternSet ps = (PatternSet) iter.next(); f.additionalPatterns.add(ps.clone()); } f.selectors = new Vector(selectors); return f; } catch (CloneNotSupportedException e) { throw new BuildException(e); } } /** * Get the merged include patterns for this Files collection. * @param p Project instance. * @return the include patterns of the default pattern set and all * nested patternsets. */ public String[] mergeIncludes(Project p) { return mergePatterns(p).getIncludePatterns(p); } /** * Get the merged exclude patterns for this Files collection. * @param p Project instance. * @return the exclude patterns of the default pattern set and all * nested patternsets. */ public String[] mergeExcludes(Project p) { return mergePatterns(p).getExcludePatterns(p); } /** * Get the merged patterns for this Files collection. * @param p Project instance. * @return the default patternset merged with the additional sets * in a new PatternSet instance. */ public synchronized PatternSet mergePatterns(Project p) { if (isReference()) { return getRef().mergePatterns(p); } PatternSet ps = new PatternSet(); ps.append(defaultPatterns, p); final int count = additionalPatterns.size(); for (int i = 0; i < count; i++) { Object o = additionalPatterns.elementAt(i); ps.append((PatternSet) o, p); } return ps; } /** * Always returns true. * @return true indicating that all elements of a Files collection * will be FileResources. */ public boolean isFilesystemOnly() { return true; } /** * Perform the check for circular references and return the * referenced Files collection. * @return <code>FileCollection</code>. */ protected Files getRef() { return (Files) getCheckedRef(); } private synchronized void ensureDirectoryScannerSetup() { if (ds == null) { ds = new DirectoryScanner(); PatternSet ps = mergePatterns(getProject()); ds.setIncludes(ps.getIncludePatterns(getProject())); ds.setExcludes(ps.getExcludePatterns(getProject())); ds.setSelectors(getSelectors(getProject())); if (useDefaultExcludes) { ds.addDefaultExcludes(); } ds.setCaseSensitive(caseSensitive); ds.setFollowSymlinks(followSymlinks); } } private boolean hasPatterns(PatternSet ps) { String[] includePatterns = ps.getIncludePatterns(getProject()); String[] excludePatterns = ps.getExcludePatterns(getProject()); return (includePatterns != null && includePatterns.length > 0) || (includePatterns != null && excludePatterns.length > 0); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -