diff options
Diffstat (limited to 'framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types')
181 files changed, 0 insertions, 32313 deletions
diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/AbstractFileSet.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/AbstractFileSet.java deleted file mode 100644 index 8f274a09..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/AbstractFileSet.java +++ /dev/null @@ -1,922 +0,0 @@ -/* - * 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.ArrayList; -import java.util.Collections; -import java.util.Enumeration; -import java.util.List; -import java.util.Stack; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.DirectoryScanner; -import org.apache.tools.ant.FileScanner; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.types.selectors.AndSelector; -import org.apache.tools.ant.types.selectors.ContainsRegexpSelector; -import org.apache.tools.ant.types.selectors.ContainsSelector; -import org.apache.tools.ant.types.selectors.DateSelector; -import org.apache.tools.ant.types.selectors.DependSelector; -import org.apache.tools.ant.types.selectors.DepthSelector; -import org.apache.tools.ant.types.selectors.DifferentSelector; -import org.apache.tools.ant.types.selectors.ExtendSelector; -import org.apache.tools.ant.types.selectors.FileSelector; -import org.apache.tools.ant.types.selectors.FilenameSelector; -import org.apache.tools.ant.types.selectors.MajoritySelector; -import org.apache.tools.ant.types.selectors.NoneSelector; -import org.apache.tools.ant.types.selectors.NotSelector; -import org.apache.tools.ant.types.selectors.OrSelector; -import org.apache.tools.ant.types.selectors.PresentSelector; -import org.apache.tools.ant.types.selectors.ReadableSelector; -import org.apache.tools.ant.types.selectors.SelectSelector; -import org.apache.tools.ant.types.selectors.SelectorContainer; -import org.apache.tools.ant.types.selectors.SelectorScanner; -import org.apache.tools.ant.types.selectors.SizeSelector; -import org.apache.tools.ant.types.selectors.TypeSelector; -import org.apache.tools.ant.types.selectors.WritableSelector; -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 List<PatternSet> additionalPatterns = new ArrayList<PatternSet>(); - private List<FileSelector> selectors = new ArrayList<FileSelector>(); - - private File dir; - private boolean useDefaultExcludes = true; - private boolean caseSensitive = true; - private boolean followSymlinks = true; - private boolean errorOnMissingDir = true; - private int maxLevelsOfSymlinks = DirectoryScanner.MAX_LEVELS_OF_SYMLINKS; - - /* 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; - this.maxLevelsOfSymlinks = fileset.maxLevelsOfSymlinks; - 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) { - if (isReference()) { - return getRef(p).getDir(p); - } - dieOnCircularReference(); - return dir; - } - - /** - * Creates a nested patternset. - * @return <code>PatternSet</code>. - */ - public synchronized PatternSet createPatternSet() { - if (isReference()) { - throw noChildrenAllowed(); - } - PatternSet patterns = new PatternSet(); - additionalPatterns.add(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() { - if (isReference()) { - return getRef(getProject()).getDefaultexcludes(); - } - dieOnCircularReference(); - return 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() { - if (isReference()) { - return getRef(getProject()).isCaseSensitive(); - } - dieOnCircularReference(); - return 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() { - if (isReference()) { - return getRef(getProject()).isCaseSensitive(); - } - dieOnCircularReference(); - return followSymlinks; - } - - /** - * The maximum number of times a symbolic link may be followed - * during a scan. - * - * @since Ant 1.8.0 - */ - public void setMaxLevelsOfSymlinks(int max) { - maxLevelsOfSymlinks = max; - } - - /** - * The maximum number of times a symbolic link may be followed - * during a scan. - * - * @since Ant 1.8.0 - */ - public int getMaxLevelsOfSymlinks() { - return maxLevelsOfSymlinks; - } - - /** - * 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; - } - - /** - * Gets whether an error is/should be thrown if the base directory - * does not exist. - * @since Ant 1.8.2 - */ - public boolean getErrorOnMissingDir() { - return errorOnMissingDir; - } - - /** - * Returns the directory scanner needed to access the files to process. - * @return a <code>DirectoryScanner</code> instance. - */ - public DirectoryScanner getDirectoryScanner() { - return getDirectoryScanner(getProject()); - } - - /** - * 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); - } - dieOnCircularReference(); - 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() - + DirectoryScanner - .DOES_NOT_EXIST_POSTFIX); - } - 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); - ds.setMaxLevelsOfSymlinks(maxLevelsOfSymlinks); - 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; - } - dieOnCircularReference(p); - 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() { - if (isReference()) { - return getRef(getProject()).hasSelectors(); - } - dieOnCircularReference(); - return !(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(); - } - dieOnCircularReference(); - if (defaultPatterns.hasPatterns(getProject())) { - return true; - } - for (PatternSet ps : additionalPatterns) { - 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() { - if (isReference()) { - return getRef(getProject()).selectorCount(); - } - dieOnCircularReference(); - return 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) { - if (isReference()) { - return getRef(getProject()).getSelectors(p); - } - dieOnCircularReference(p); - return (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<FileSelector> selectorElements() { - if (isReference()) { - return getRef(getProject()).selectorElements(); - } - dieOnCircularReference(); - return Collections.enumeration(selectors); - } - - /** - * 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.add(selector); - directoryScanner = null; - setChecked(false); - } - - /* 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); - } - - public void addReadable(ReadableSelector r) { - appendSelector(r); - } - - public void addWritable(WritableSelector w) { - appendSelector(w); - } - - /** - * Add an arbitrary 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() { - if (isReference()) { - return getRef(getProject()).toString(); - } - dieOnCircularReference(); - 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 ArrayList<PatternSet>(additionalPatterns.size()); - for (PatternSet ps : additionalPatterns) { - fs.additionalPatterns.add((PatternSet) ps.clone()); - } - fs.selectors = new ArrayList<FileSelector>(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); - } - dieOnCircularReference(); - PatternSet ps = (PatternSet) defaultPatterns.clone(); - final int count = additionalPatterns.size(); - for (int i = 0; i < count; i++) { - ps.append(additionalPatterns.get(i), p); - } - return ps; - } - - protected synchronized void dieOnCircularReference(Stack<Object> stk, Project p) - throws BuildException { - if (isChecked()) { - return; - } - if (isReference()) { - super.dieOnCircularReference(stk, p); - } else { - for (FileSelector fileSelector : selectors) { - if (fileSelector instanceof DataType) { - pushAndInvokeCircularReferenceCheck((DataType) fileSelector, stk, p); - } - } - for (PatternSet ps : additionalPatterns) { - pushAndInvokeCircularReferenceCheck(ps, stk, p); - } - setChecked(true); - } - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/AntFilterReader.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/AntFilterReader.java deleted file mode 100644 index 20c41bc7..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/AntFilterReader.java +++ /dev/null @@ -1,178 +0,0 @@ -/* - * 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.util.Stack; -import java.util.Vector; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Project; - -/** - * An AntFilterReader is a wrapper class that encloses the classname - * and configuration of a Configurable FilterReader. - */ -public final class AntFilterReader - extends DataType implements Cloneable { - - private String className; - - private final Vector<Parameter> parameters = new Vector<Parameter>(); - - private Path classpath; - - /** - * Set the className attribute. - * - * @param className a <code>String</code> value - */ - public void setClassName(final String className) { - if (isReference()) { - throw tooManyAttributes(); - } - this.className = className; - } - - /** - * Get the className attribute. - * - * @return a <code>String</code> value - */ - public String getClassName() { - if (isReference()) { - return ((AntFilterReader) getCheckedRef()).getClassName(); - } - dieOnCircularReference(); - return className; - } - - /** - * Add a Parameter. - * - * @param param a <code>Parameter</code> value - */ - public void addParam(final Parameter param) { - if (isReference()) { - throw noChildrenAllowed(); - } - parameters.addElement(param); - } - - /** - * Set the classpath to load the FilterReader through (attribute). - * @param classpath a classpath - */ - public void setClasspath(Path classpath) { - if (isReference()) { - throw tooManyAttributes(); - } - if (this.classpath == null) { - this.classpath = classpath; - } else { - this.classpath.append(classpath); - } - setChecked(false); - } - - /** - * Set the classpath to load the FilterReader through (nested element). - * @return a classpath to be configured - */ - public Path createClasspath() { - if (isReference()) { - throw noChildrenAllowed(); - } - if (this.classpath == null) { - this.classpath = new Path(getProject()); - } - setChecked(false); - return this.classpath.createPath(); - } - - /** - * Get the classpath. - * @return the classpath - */ - public Path getClasspath() { - if (isReference()) { - ((AntFilterReader) getCheckedRef()).getClasspath(); - } - dieOnCircularReference(); - return classpath; - } - - /** - * Set the classpath to load the FilterReader through via - * reference (attribute). - * @param r a reference to a classpath - */ - public void setClasspathRef(Reference r) { - if (isReference()) { - throw tooManyAttributes(); - } - createClasspath().setRefid(r); - } - - /** - * The parameters for this filter. - * - * @return a <code>Parameter[]</code> value - */ - public Parameter[] getParams() { - if (isReference()) { - ((AntFilterReader) getCheckedRef()).getParams(); - } - dieOnCircularReference(); - Parameter[] params = new Parameter[parameters.size()]; - parameters.copyInto(params); - return params; - } - - /** - * Makes this instance in effect a reference to another AntFilterReader - * instance. - * - * <p>You must not set another attribute or nest elements inside - * this element if you make it a reference.</p> - * - * @param r the reference to which this instance is associated - * @exception BuildException if this instance already has been configured. - */ - public void setRefid(Reference r) throws BuildException { - if (!parameters.isEmpty() || className != null - || classpath != null) { - throw tooManyAttributes(); - } - super.setRefid(r); - } - - protected synchronized void dieOnCircularReference(Stack<Object> stk, Project p) - throws BuildException { - if (isChecked()) { - return; - } - if (isReference()) { - super.dieOnCircularReference(stk, p); - } else { - if (classpath != null) { - pushAndInvokeCircularReferenceCheck(classpath, stk, p); - } - setChecked(true); - } - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/ArchiveFileSet.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/ArchiveFileSet.java deleted file mode 100644 index e9a07303..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/ArchiveFileSet.java +++ /dev/null @@ -1,596 +0,0 @@ -/* - * 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.Iterator; -import java.util.Stack; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.DirectoryScanner; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.types.resources.FileProvider; -import org.apache.tools.ant.types.resources.FileResource; -import org.apache.tools.zip.UnixStat; - -/** - * A ArchiveFileSet is a FileSet with extra attributes useful in the - * context of archiving tasks. - * - * It includes a prefix attribute which is prepended to each entry in - * the output archive file as well as a fullpath attribute. It also - * supports Unix file permissions for files and directories. - * - * @since Ant 1.7 - */ -public abstract class ArchiveFileSet extends FileSet { - - private static final int BASE_OCTAL = 8; - - /** - * Default value for the dirmode attribute. - * - * @since Ant 1.5.2 - */ - public static final int DEFAULT_DIR_MODE = - UnixStat.DIR_FLAG | UnixStat.DEFAULT_DIR_PERM; - - /** - * Default value for the filemode attribute. - * - * @since Ant 1.5.2 - */ - public static final int DEFAULT_FILE_MODE = - UnixStat.FILE_FLAG | UnixStat.DEFAULT_FILE_PERM; - - private Resource src = null; - private String prefix = ""; - private String fullpath = ""; - private boolean hasDir = false; - private int fileMode = DEFAULT_FILE_MODE; - private int dirMode = DEFAULT_DIR_MODE; - - private boolean fileModeHasBeenSet = false; - private boolean dirModeHasBeenSet = false; - private static final String ERROR_DIR_AND_SRC_ATTRIBUTES = "Cannot set both dir and src attributes"; - private static final String ERROR_PATH_AND_PREFIX = "Cannot set both fullpath and prefix attributes"; - - private boolean errorOnMissingArchive = true; - - private String encoding = null; - - /** Constructor for ArchiveFileSet */ - public ArchiveFileSet() { - super(); - } - - /** - * Constructor using a fileset argument. - * @param fileset the fileset to use - */ - protected ArchiveFileSet(FileSet fileset) { - super(fileset); - } - - /** - * Constructor using a archive fileset argument. - * @param fileset the archivefileset to use - */ - protected ArchiveFileSet(ArchiveFileSet fileset) { - super(fileset); - src = fileset.src; - prefix = fileset.prefix; - fullpath = fileset.fullpath; - hasDir = fileset.hasDir; - fileMode = fileset.fileMode; - dirMode = fileset.dirMode; - fileModeHasBeenSet = fileset.fileModeHasBeenSet; - dirModeHasBeenSet = fileset.dirModeHasBeenSet; - errorOnMissingArchive = fileset.errorOnMissingArchive; - encoding = fileset.encoding; - } - - /** - * Set the directory for the fileset. - * @param dir the directory for the fileset - * @throws BuildException on error - */ - public void setDir(File dir) throws BuildException { - checkAttributesAllowed(); - if (src != null) { - throw new BuildException(ERROR_DIR_AND_SRC_ATTRIBUTES); - } - super.setDir(dir); - hasDir = true; - } - - /** - * Set the source Archive file for the archivefileset. Prevents both - * "dir" and "src" from being specified. - * @param a the archive as a single element Resource collection. - */ - public void addConfigured(ResourceCollection a) { - checkChildrenAllowed(); - if (a.size() != 1) { - throw new BuildException("only single argument resource collections" - + " are supported as archives"); - } - setSrcResource(a.iterator().next()); - } - - /** - * Set the source Archive file for the archivefileset. Prevents both - * "dir" and "src" from being specified. - * - * @param srcFile The archive from which to extract entries. - */ - public void setSrc(File srcFile) { - setSrcResource(new FileResource(srcFile)); - } - - /** - * Set the source Archive file for the archivefileset. Prevents both - * "dir" and "src" from being specified. - * - * @param src The archive from which to extract entries. - */ - public void setSrcResource(Resource src) { - checkArchiveAttributesAllowed(); - if (hasDir) { - throw new BuildException(ERROR_DIR_AND_SRC_ATTRIBUTES); - } - this.src = src; - setChecked(false); - } - - /** - * Get the archive from which entries will be extracted. - * @param p the project to use - * @return the source file - */ - public File getSrc(Project p) { - if (isReference()) { - return ((ArchiveFileSet) getRef(p)).getSrc(p); - } - return getSrc(); - } - - /** - * Sets whether an error is thrown if an archive does not exist. - * - * @param errorOnMissingArchive true if missing archives cause errors, - * false if not. - * @since Ant 1.8.0 - */ - public void setErrorOnMissingArchive(boolean errorOnMissingArchive) { - checkAttributesAllowed(); - this.errorOnMissingArchive = errorOnMissingArchive; - } - - /** - * Get the archive file from which entries will be extracted. - * @return the archive in case the archive is a file, null otherwise. - */ - public File getSrc() { - if (isReference()) { - return ((ArchiveFileSet) getCheckedRef()).getSrc(); - } - dieOnCircularReference(); - if (src != null) { - FileProvider fp = src.as(FileProvider.class); - if (fp != null) { - return fp.getFile(); - } - } - return null; - } - - /** - * Performs the check for circular references and returns the - * referenced object. - * This is an override which does not delegate to the superclass; instead it invokes - * {@link #getRef(Project)}, because that contains the special support for fileset - * references, which can be handled by all ArchiveFileSets. - * @param p the Ant Project instance against which to resolve references. - * @return the dereferenced object. - * @throws BuildException if the reference is invalid (circular ref, wrong class, etc). - * @since Ant 1.8 - */ - // TODO is the above true? AFAICT the calls look circular :/ - protected Object getCheckedRef(Project p) { - return getRef(p); - } - - /** - * Prepend this prefix to the path for each archive entry. - * Prevents both prefix and fullpath from being specified - * - * @param prefix The prefix to prepend to entries in the archive file. - */ - public void setPrefix(String prefix) { - checkArchiveAttributesAllowed(); - if (!"".equals(prefix) && !"".equals(fullpath)) { - throw new BuildException(ERROR_PATH_AND_PREFIX); - } - this.prefix = prefix; - } - - /** - * Return the prefix prepended to entries in the archive file. - * @param p the project to use - * @return the prefix - */ - public String getPrefix(Project p) { - if (isReference()) { - return ((ArchiveFileSet) getRef(p)).getPrefix(p); - } - dieOnCircularReference(p); - return prefix; - } - - /** - * Set the full pathname of the single entry in this fileset. - * Prevents both prefix and fullpath from being specified - * - * @param fullpath the full pathname of the single entry in this fileset. - */ - public void setFullpath(String fullpath) { - checkArchiveAttributesAllowed(); - if (!"".equals(prefix) && !"".equals(fullpath)) { - throw new BuildException(ERROR_PATH_AND_PREFIX); - } - this.fullpath = fullpath; - } - - /** - * Return the full pathname of the single entry in this fileset. - * @param p the project to use - * @return the full path - */ - public String getFullpath(Project p) { - if (isReference()) { - return ((ArchiveFileSet) getRef(p)).getFullpath(p); - } - dieOnCircularReference(p); - return fullpath; - } - - /** - * Set the encoding used for this ZipFileSet. - * @param enc encoding as String. - * @since Ant 1.9.5 - */ - public void setEncoding(String enc) { - checkAttributesAllowed(); - this.encoding = enc; - } - - /** - * Get the encoding used for this ZipFileSet. - * @return String encoding. - * @since Ant 1.9.5 - */ - public String getEncoding() { - if (isReference()) { - AbstractFileSet ref = getRef(getProject()); - if (ref instanceof ArchiveFileSet) { - return ((ArchiveFileSet) ref).getEncoding(); - } else { - return null; - } - } - return encoding; - } - - /** - * Creates a scanner for this type of archive. - * @return the scanner. - */ - protected abstract ArchiveScanner newArchiveScanner(); - - /** - * Return the DirectoryScanner associated with this FileSet. - * If the ArchiveFileSet defines a source Archive file, then an ArchiveScanner - * is returned instead. - * @param p the project to use - * @return a directory scanner - */ - public DirectoryScanner getDirectoryScanner(Project p) { - if (isReference()) { - return getRef(p).getDirectoryScanner(p); - } - dieOnCircularReference(); - if (src == null) { - return super.getDirectoryScanner(p); - } - if (!src.isExists() && errorOnMissingArchive) { - throw new BuildException( - "The archive " + src.getName() + " doesn't exist"); - } - if (src.isDirectory()) { - throw new BuildException("The archive " + src.getName() - + " can't be a directory"); - } - ArchiveScanner as = newArchiveScanner(); - as.setErrorOnMissingArchive(errorOnMissingArchive); - as.setSrc(src); - super.setDir(p.getBaseDir()); - setupDirectoryScanner(as, p); - as.init(); - return as; - } - - /** - * Fulfill the ResourceCollection contract. - * @return Iterator of Resources. - * @since Ant 1.7 - */ - public Iterator<Resource> iterator() { - if (isReference()) { - return ((ResourceCollection) (getRef(getProject()))).iterator(); - } - if (src == null) { - return super.iterator(); - } - ArchiveScanner as = (ArchiveScanner) getDirectoryScanner(getProject()); - return as.getResourceFiles(getProject()); - } - - /** - * Fulfill the ResourceCollection contract. - * @return size of the collection as int. - * @since Ant 1.7 - */ - public int size() { - if (isReference()) { - return ((ResourceCollection) (getRef(getProject()))).size(); - } - if (src == null) { - return super.size(); - } - ArchiveScanner as = (ArchiveScanner) getDirectoryScanner(getProject()); - return as.getIncludedFilesCount(); - } - - /** - * Indicate whether this ResourceCollection is composed entirely of - * Resources accessible via local filesystem conventions. If true, - * all Resources returned from this ResourceCollection should be - * instances of FileResource. - * @return whether this is a filesystem-only resource collection. - * @since Ant 1.7 - */ - public boolean isFilesystemOnly() { - if (isReference()) { - return ((ArchiveFileSet) getCheckedRef()).isFilesystemOnly(); - } - dieOnCircularReference(); - return src == null; - } - - /** - * A 3 digit octal string, specify the user, group and - * other modes in the standard Unix fashion; - * optional, default=0644 - * @param octalString a <code>String</code> value - */ - public void setFileMode(String octalString) { - checkArchiveAttributesAllowed(); - integerSetFileMode(Integer.parseInt(octalString, BASE_OCTAL)); - } - - /** - * specify the user, group and - * other modes in the standard Unix fashion; - * optional, default=0644 - * - * <p>We use the strange name so this method doesn't appear in - * IntrospectionHelpers list of attribute setters.</p> - * @param mode a <code>int</code> value - * @since Ant 1.7 - */ - public void integerSetFileMode(int mode) { - fileModeHasBeenSet = true; - this.fileMode = UnixStat.FILE_FLAG | mode; - } - - /** - * Get the mode of the archive fileset - * @param p the project to use - * @return the mode - */ - public int getFileMode(Project p) { - if (isReference()) { - return ((ArchiveFileSet) getRef(p)).getFileMode(p); - } - dieOnCircularReference(); - return fileMode; - } - - /** - * Whether the user has specified the mode explicitly. - * @return true if it has been set - */ - public boolean hasFileModeBeenSet() { - if (isReference()) { - return ((ArchiveFileSet) getRef(getProject())).hasFileModeBeenSet(); - } - dieOnCircularReference(); - return fileModeHasBeenSet; - } - - /** - * A 3 digit octal string, specify the user, group and - * other modes in the standard Unix fashion; - * optional, default=0755 - * @param octalString a <code>String</code> value - */ - public void setDirMode(String octalString) { - checkArchiveAttributesAllowed(); - integerSetDirMode(Integer.parseInt(octalString, BASE_OCTAL)); - } - - /** - * specify the user, group and - * other modes in the standard Unix fashion; - * optional, default=0755 - * <p>We use the strange name so this method doesn't appear in - * IntrospectionHelpers list of attribute setters.</p> - * @param mode a <code>int</code> value - * @since Ant 1.7 - */ - public void integerSetDirMode(int mode) { - dirModeHasBeenSet = true; - this.dirMode = UnixStat.DIR_FLAG | mode; - } - - /** - * Get the dir mode of the archive fileset - * @param p the project to use - * @return the mode - */ - public int getDirMode(Project p) { - if (isReference()) { - return ((ArchiveFileSet) getRef(p)).getDirMode(p); - } - dieOnCircularReference(); - return dirMode; - } - - /** - * Whether the user has specified the mode explicitly. - * - * @return true if it has been set - */ - public boolean hasDirModeBeenSet() { - if (isReference()) { - return ((ArchiveFileSet) getRef(getProject())).hasDirModeBeenSet(); - } - dieOnCircularReference(); - return dirModeHasBeenSet; - } - - /** - * A ArchiveFileset accepts another ArchiveFileSet or a FileSet as reference - * FileSets are often used by the war task for the lib attribute - * @param zfs the project to use - */ - protected void configureFileSet(ArchiveFileSet zfs) { - zfs.setPrefix(prefix); - zfs.setFullpath(fullpath); - zfs.fileModeHasBeenSet = fileModeHasBeenSet; - zfs.fileMode = fileMode; - zfs.dirModeHasBeenSet = dirModeHasBeenSet; - zfs.dirMode = dirMode; - } - - /** - * Return a ArchiveFileSet that has the same properties - * as this one. - * @return the cloned archiveFileSet - * @since Ant 1.6 - */ - public Object clone() { - if (isReference()) { - return getCheckedRef(ArchiveFileSet.class, getDataTypeName(), getProject()).clone(); - } - return super.clone(); - } - - /** - * For file-based archivefilesets, return the same as for normal filesets; - * else just return the path of the zip. - * @return for file based archivefilesets, included files as a list - * of semicolon-separated filenames. else just the name of the zip. - */ - public String toString() { - if (hasDir && getProject() != null) { - return super.toString(); - } - return src == null ? null : src.getName(); - } - - /** - * Return the prefix prepended to entries in the archive file. - * @return the prefix. - * @deprecated since 1.7. - */ - public String getPrefix() { - return prefix; - } - - /** - * Return the full pathname of the single entryZ in this fileset. - * @return the full pathname. - * @deprecated since 1.7. - */ - public String getFullpath() { - return fullpath; - } - - /** - * @return the file mode. - * @deprecated since 1.7. - */ - public int getFileMode() { - return fileMode; - } - - /** - * @return the dir mode. - * @deprecated since 1.7. - */ - public int getDirMode() { - return dirMode; - } - - /** - * A check attributes for archiveFileSet. - * If there is a reference, and - * it is a ArchiveFileSet, the archive fileset attributes - * cannot be used. - * (Note, we can only see if the reference is an archive - * fileset if the project has been set). - */ - private void checkArchiveAttributesAllowed() { - if (getProject() == null - || (isReference() - && (getRefid().getReferencedObject( - getProject()) - instanceof ArchiveFileSet))) { - checkAttributesAllowed(); - } - } - - protected synchronized void dieOnCircularReference(Stack<Object> stk, Project p) - throws BuildException { - if (isChecked()) { - return; - } - - // takes care of nested selectors - super.dieOnCircularReference(stk, p); - - if (!isReference()) { - if (src != null) { - pushAndInvokeCircularReferenceCheck(src, stk, p); - } - setChecked(true); - } - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/ArchiveScanner.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/ArchiveScanner.java deleted file mode 100644 index db5a8d46..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/ArchiveScanner.java +++ /dev/null @@ -1,363 +0,0 @@ -/* - * 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.Iterator; -import java.util.Map; -import java.util.TreeMap; - -import org.apache.tools.ant.DirectoryScanner; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.types.resources.FileProvider; -import org.apache.tools.ant.types.resources.FileResource; -import org.apache.tools.ant.types.resources.FileResourceIterator; - -/** - * ArchiveScanner accesses the pattern matching algorithm in DirectoryScanner, - * which are protected methods that can only be accessed by subclassing. - * - * This implementation of FileScanner defines getIncludedFiles to return - * the matching archive entries. - * - * @since Ant 1.7 - */ -public abstract class ArchiveScanner extends DirectoryScanner { - // CheckStyle:VisibilityModifier OFF - bc - - /** - * The archive file which should be scanned. - */ - protected File srcFile; - - // CheckStyle:VisibilityModifier ON - - /** - * The archive resource which should be scanned. - */ - private Resource src; - - /** - * to record the last scanned zip file with its modification date - */ - private Resource lastScannedResource; - - /** - * record list of all file zip entries - */ - private Map<String, Resource> fileEntries = new TreeMap<String, Resource>(); - - /** - * record list of all directory zip entries - */ - private Map<String, Resource> dirEntries = new TreeMap<String, Resource>(); - - /** - * record list of matching file zip entries - */ - private Map<String, Resource> matchFileEntries = new TreeMap<String, Resource>(); - - /** - * record list of matching directory zip entries - */ - private Map<String, Resource> matchDirEntries = new TreeMap<String, Resource>(); - - /** - * encoding of file names. - * - * @since Ant 1.6 - */ - private String encoding; - - /** - * @since Ant 1.8.0 - */ - private boolean errorOnMissingArchive = true; - - /** - * Sets whether an error is thrown if an archive does not exist. - * - * @param errorOnMissingArchive true if missing archives cause errors, - * false if not. - * @since Ant 1.8.0 - */ - public void setErrorOnMissingArchive(boolean errorOnMissingArchive) { - this.errorOnMissingArchive = errorOnMissingArchive; - } - - /** - * Don't scan when we have no zipfile. - * @since Ant 1.7 - */ - public void scan() { - if (src == null || (!src.isExists() && !errorOnMissingArchive)) { - return; - } - super.scan(); - } - - /** - * Sets the srcFile for scanning. This is the jar or zip file that - * is scanned for matching entries. - * - * @param srcFile the (non-null) archive file name for scanning - */ - public void setSrc(File srcFile) { - setSrc(new FileResource(srcFile)); - } - - /** - * Sets the src for scanning. This is the jar or zip file that - * is scanned for matching entries. - * - * @param src the (non-null) archive resource - */ - public void setSrc(Resource src) { - this.src = src; - FileProvider fp = src.as(FileProvider.class); - if (fp != null) { - srcFile = fp.getFile(); - } - } - - /** - * Sets encoding of file names. - * @param encoding the encoding format - * @since Ant 1.6 - */ - public void setEncoding(String encoding) { - this.encoding = encoding; - } - - /** - * Returns the names of the files which matched at least one of the - * include patterns and none of the exclude patterns. - * The names are relative to the base directory. - * - * @return the names of the files which matched at least one of the - * include patterns and none of the exclude patterns. - */ - public String[] getIncludedFiles() { - if (src == null) { - return super.getIncludedFiles(); - } - scanme(); - return matchFileEntries.keySet().toArray(new String[matchFileEntries.size()]); - } - - /** - * Override parent implementation. - * @return count of included files. - * @since Ant 1.7 - */ - public int getIncludedFilesCount() { - if (src == null) { - return super.getIncludedFilesCount(); - } - scanme(); - return matchFileEntries.size(); - } - - /** - * Returns the names of the directories which matched at least one of the - * include patterns and none of the exclude patterns. - * The names are relative to the base directory. - * - * @return the names of the directories which matched at least one of the - * include patterns and none of the exclude patterns. - */ - public String[] getIncludedDirectories() { - if (src == null) { - return super.getIncludedDirectories(); - } - scanme(); - return matchDirEntries.keySet().toArray(new String[matchDirEntries.size()]); - } - - /** - * Override parent implementation. - * @return count of included directories. - * @since Ant 1.7 - */ - public int getIncludedDirsCount() { - if (src == null) { - return super.getIncludedDirsCount(); - } - scanme(); - return matchDirEntries.size(); - } - - /** - * Get the set of Resources that represent files. - * @param project since Ant 1.8 - * @return an Iterator of Resources. - * @since Ant 1.7 - */ - /* package-private for now */ Iterator<Resource> getResourceFiles(Project project) { - if (src == null) { - return new FileResourceIterator(project, getBasedir(), getIncludedFiles()); - } - scanme(); - return matchFileEntries.values().iterator(); - } - - /** - * Get the set of Resources that represent directories. - * @param project since Ant 1.8 - * @return an Iterator of Resources. - * @since Ant 1.7 - */ - /* package-private for now */ Iterator<Resource> getResourceDirectories(Project project) { - if (src == null) { - return new FileResourceIterator(project, getBasedir(), getIncludedDirectories()); - } - scanme(); - return matchDirEntries.values().iterator(); - } - - /** - * Initialize DirectoryScanner data structures. - */ - public void init() { - if (includes == null) { - // No includes supplied, so set it to 'matches all' - includes = new String[1]; - includes[0] = "**"; - } - if (excludes == null) { - excludes = new String[0]; - } - } - - /** - * Matches a jar entry against the includes/excludes list, - * normalizing the path separator. - * - * @param path the (non-null) path name to test for inclusion - * - * @return <code>true</code> if the path should be included - * <code>false</code> otherwise. - */ - public boolean match(String path) { - String vpath = path; - if (path.length() > 0) { - vpath = path.replace('/', File.separatorChar). - replace('\\', File.separatorChar); - if (vpath.charAt(0) == File.separatorChar) { - vpath = vpath.substring(1); - } - } - return isIncluded(vpath) && !isExcluded(vpath); - } - - /** - * Get the named Resource. - * @param name path name of the file sought in the archive - * @return the resource - * @since Ant 1.5.2 - */ - public Resource getResource(String name) { - if (src == null) { - return super.getResource(name); - } - if (name.equals("")) { - // special case in ZIPs, we do not want this thing included - return new Resource("", true, Long.MAX_VALUE, true); - } - // first check if the archive needs to be scanned again - scanme(); - if (fileEntries.containsKey(name)) { - return fileEntries.get(name); - } - name = trimSeparator(name); - - if (dirEntries.containsKey(name)) { - return dirEntries.get(name); - } - return new Resource(name); - } - - /** - * Fills the file and directory maps with resources read from the archive. - * - * @param archive the archive to scan. - * @param encoding encoding used to encode file names inside the archive. - * @param fileEntries Map (name to resource) of non-directory - * resources found inside the archive. - * @param matchFileEntries Map (name to resource) of non-directory - * resources found inside the archive that matched all include - * patterns and didn't match any exclude patterns. - * @param dirEntries Map (name to resource) of directory - * resources found inside the archive. - * @param matchDirEntries Map (name to resource) of directory - * resources found inside the archive that matched all include - * patterns and didn't match any exclude patterns. - */ - protected abstract void fillMapsFromArchive(Resource archive, - String encoding, - Map<String, Resource> fileEntries, - Map<String, Resource> matchFileEntries, - Map<String, Resource> dirEntries, - Map<String, Resource> matchDirEntries); - - /** - * if the datetime of the archive did not change since - * lastScannedResource was initialized returns immediately else if - * the archive has not been scanned yet, then all the zip entries - * are put into the appropriate tables. - */ - private void scanme() { - if (!src.isExists() && !errorOnMissingArchive) { - return; - } - - //do not use a FileResource b/c it pulls File info from the filesystem: - Resource thisresource = new Resource(src.getName(), - src.isExists(), - src.getLastModified()); - // spare scanning again and again - if (lastScannedResource != null - && lastScannedResource.getName().equals(thisresource.getName()) - && lastScannedResource.getLastModified() - == thisresource.getLastModified()) { - return; - } - init(); - - fileEntries.clear(); - dirEntries.clear(); - matchFileEntries.clear(); - matchDirEntries.clear(); - fillMapsFromArchive(src, encoding, fileEntries, matchFileEntries, - dirEntries, matchDirEntries); - - // record data about the last scanned resource - lastScannedResource = thisresource; - } - - /** - * Remove trailing slash if present. - * @param s the file name to trim. - * @return the trimmed file name. - */ - protected static final String trimSeparator(String s) { - return s.endsWith("/") ? s.substring(0, s.length() - 1) : s; - } - -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/Assertions.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/Assertions.java deleted file mode 100644 index a54db501..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/Assertions.java +++ /dev/null @@ -1,359 +0,0 @@ -/* - * 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.util.ArrayList; -import java.util.List; -import java.util.ListIterator; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Project; - -/** - * The assertion datatype. This type describes - * assertion settings for the <java> task and others. - * One can set the system assertions, and enable/disable those in - * packages and classes. - * Assertions can only be enabled or disabled when forking Java. - * - * Example: set system assertions and all org.apache packages except - * for ant, and the class org.apache.tools.ant.Main. - * <pre> - * <assertions enableSystemAssertions="true" > - * <enable package="org.apache" /> - * <disable package="org.apache.ant" /> - * <enable class="org.apache.tools.ant.Main"/> - * </assertions> - *</pre> - * Disable system assertions; enable those in the anonymous package - * <pre> - * <assertions enableSystemAssertions="false" > - * <enable package="..." /> - * </assertions> - * </pre> - * enable assertions in a class called Test - * <pre> - * <assertions > - * <enable class="Test" /> - * </assertions> - * </pre> - * This type is a datatype, so you can declare assertions and use them later - * - * <pre> - * <assertions id="project.assertions" > - * <enable project="org.apache.test" /> - * </assertions> - * - * <assertions refid="project.assertions" /> - * - * </pre> - * @since Ant 1.6 - */ -public class Assertions extends DataType implements Cloneable { - - /** - * enable/disable sys assertions; null means undefined - */ - private Boolean enableSystemAssertions; - - /** - * list of type BaseAssertion - */ - private ArrayList<BaseAssertion> assertionList = new ArrayList<BaseAssertion>(); - - - /** - * enable assertions - * @param assertion an enable assertion nested element - */ - public void addEnable(EnabledAssertion assertion) { - checkChildrenAllowed(); - assertionList.add(assertion); - } - - /** - * disable assertions - * @param assertion a disable assertion nested element - */ - public void addDisable(DisabledAssertion assertion) { - checkChildrenAllowed(); - assertionList.add(assertion); - } - - /** - * enable or disable system assertions. - * Default is not set (neither -enablesystemassersions or -disablesytemassertions - * are used on the command line). - * @param enableSystemAssertions if true enable system assertions - */ - public void setEnableSystemAssertions(Boolean enableSystemAssertions) { - checkAttributesAllowed(); - this.enableSystemAssertions = enableSystemAssertions; - } - - /** - * Set the value of the refid attribute. - * - * <p>Subclasses may need to check whether any other attributes - * have been set as well or child elements have been created and - * thus override this method. if they do the must call - * <code>super.setRefid</code>.</p> - * @param ref the reference to use - */ - public void setRefid(Reference ref) { - if (assertionList.size() > 0 || enableSystemAssertions != null) { - throw tooManyAttributes(); - } - super.setRefid(ref); - } - - /** - * get whatever we are referencing to. This could be ourself. - * @return the object that contains the assertion info - */ - private Assertions getFinalReference() { - if (getRefid() == null) { - return this; - } else { - Object o = getRefid().getReferencedObject(getProject()); - if (!(o instanceof Assertions)) { - throw new BuildException("reference is of wrong type"); - } - return (Assertions) o; - } - } - - /** - * how many assertions are made...will resolve references before returning - * @return total # of commands to make - */ - public int size() { - Assertions clause = getFinalReference(); - return clause.getFinalSize(); - } - - - /** - * what is the final size of this object - * @return number of assertions - */ - private int getFinalSize() { - return assertionList.size() + (enableSystemAssertions != null ? 1 : 0); - } - - /** - * add the assertions to a list in a format suitable - * for adding to a command line - * @param commandList the command line to format - */ - public void applyAssertions(List<String> commandList) { - getProject().log("Applying assertions", Project.MSG_DEBUG); - Assertions clause = getFinalReference(); - //do the system assertions - if (Boolean.TRUE.equals(clause.enableSystemAssertions)) { - getProject().log("Enabling system assertions", Project.MSG_DEBUG); - commandList.add("-enablesystemassertions"); - } else if (Boolean.FALSE.equals(clause.enableSystemAssertions)) { - getProject().log("disabling system assertions", Project.MSG_DEBUG); - commandList.add("-disablesystemassertions"); - } - - //now any inner assertions - for (BaseAssertion assertion : clause.assertionList) { - String arg = assertion.toCommand(); - getProject().log("adding assertion " + arg, Project.MSG_DEBUG); - commandList.add(arg); - } - } - - /** - * apply all the assertions to the command. - * @param command the command line to format - */ - public void applyAssertions(CommandlineJava command) { - Assertions clause = getFinalReference(); - //do the system assertions - if (Boolean.TRUE.equals(clause.enableSystemAssertions)) { - addVmArgument(command, "-enablesystemassertions"); - } else if (Boolean.FALSE.equals(clause.enableSystemAssertions)) { - addVmArgument(command, "-disablesystemassertions"); - } - - //now any inner assertions - for (BaseAssertion assertion : clause.assertionList) { - String arg = assertion.toCommand(); - addVmArgument(command, arg); - } - } - - /** - * add the assertions to a list in a format suitable - * for adding to a command line - * @param commandIterator list of commands - */ - public void applyAssertions(final ListIterator<String> commandIterator) { - getProject().log("Applying assertions", Project.MSG_DEBUG); - Assertions clause = getFinalReference(); - //do the system assertions - if (Boolean.TRUE.equals(clause.enableSystemAssertions)) { - getProject().log("Enabling system assertions", Project.MSG_DEBUG); - commandIterator.add("-enablesystemassertions"); - } else if (Boolean.FALSE.equals(clause.enableSystemAssertions)) { - getProject().log("disabling system assertions", Project.MSG_DEBUG); - commandIterator.add("-disablesystemassertions"); - } - - //now any inner assertions - for (BaseAssertion assertion : clause.assertionList) { - String arg = assertion.toCommand(); - getProject().log("adding assertion " + arg, Project.MSG_DEBUG); - commandIterator.add(arg); - } - } - - /** - * helper method to add a string JVM argument to a command - * @param command - * @param arg - */ - private static void addVmArgument(CommandlineJava command, String arg) { - Commandline.Argument argument; - argument = command.createVmArgument(); - argument.setValue(arg); - } - - /** - * clone the objects. - * This is not a full depth clone; the list of assertions is cloned, - * but it does not clone the underlying assertions. - * @return a cli - * @throws CloneNotSupportedException if the super class does not support cloning - */ - public Object clone() throws CloneNotSupportedException { - Assertions that = (Assertions) super.clone(); - that.assertionList = new ArrayList<BaseAssertion>(assertionList); - return that; - } - - /** - * base class for our assertion elements. - */ - - public abstract static class BaseAssertion { - private String packageName; - private String className; - - /** - * name a class - * @param className a class name - */ - public void setClass(String className) { - this.className = className; - } - - /** - * name a package - * @param packageName a package name - */ - public void setPackage(String packageName) { - this.packageName = packageName; - } - - /** - * what is the class name? - * @return classname or null - * @see #setClass - */ - protected String getClassName() { - return className; - } - - /** - * what is the package name? - * @return package name or null - * @see #setPackage - */ - protected String getPackageName() { - return packageName; - } - - /** - * get the prefix used to begin the command; -ea or -da. - * @return prefix - */ - public abstract String getCommandPrefix(); - - /** - * create a full command string from this class - * @throws BuildException in case of trouble - * @return The command string - */ - public String toCommand() { - //catch invalidness - if (getPackageName() != null && getClassName() != null) { - throw new BuildException("Both package and class have been set"); - } - StringBuffer command = new StringBuffer(getCommandPrefix()); - //see if it is a package or a class - if (getPackageName() != null) { - //packages get a ... prefix - command.append(':'); - command.append(getPackageName()); - if (!command.toString().endsWith("...")) { - //append the ... suffix if not there already - command.append("..."); - } - } else if (getClassName() != null) { - //classes just get the classname - command.append(':'); - command.append(getClassName()); - } - return command.toString(); - } - } - - - /** - * an enabled assertion enables things - */ - public static class EnabledAssertion extends BaseAssertion { - /** - * get the prefix used to begin the command; -ea or -da. - * @return prefix - */ - public String getCommandPrefix() { - return "-ea"; - } - - } - - /** - * A disabled assertion disables things - */ - public static class DisabledAssertion extends BaseAssertion { - /** - * get the prefix used to begin the command; -ea or -da. - * @return prefix - */ - public String getCommandPrefix() { - return "-da"; - } - - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/Commandline.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/Commandline.java deleted file mode 100644 index c273d7aa..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/Commandline.java +++ /dev/null @@ -1,689 +0,0 @@ -/* - * 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.ArrayList; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.ListIterator; -import java.util.StringTokenizer; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.ProjectComponent; -import org.apache.tools.ant.taskdefs.condition.Os; -import org.apache.tools.ant.util.StringUtils; - -/** - * Commandline objects help handling command lines specifying processes to - * execute. - * - * The class can be used to define a command line as nested elements or as a - * helper to define a command line by an application. - * <p> - * <code> - * <someelement><br> - * <acommandline executable="/executable/to/run"><br> - * <argument value="argument 1" /><br> - * <argument line="argument_1 argument_2 argument_3" /><br> - * <argument value="argument 4" /><br> - * </acommandline><br> - * </someelement><br> - * </code> - * The element <code>someelement</code> must provide a method - * <code>createAcommandline</code> which returns an instance of this class. - * - */ -public class Commandline implements Cloneable { - /** win9x uses a (shudder) bat file (antRun.bat) for executing commands */ - private static final boolean IS_WIN_9X = Os.isFamily("win9x"); - - /** - * The arguments of the command - */ - private List<Argument> arguments = new ArrayList<Argument>(); - - /** - * the program to execute - */ - private String executable = null; - - protected static final String DISCLAIMER = - StringUtils.LINE_SEP - + "The \' characters around the executable and arguments are" - + StringUtils.LINE_SEP - + "not part of the command." - + StringUtils.LINE_SEP; - - /** - * Create a command line from a string. - * @param toProcess the line: the first element becomes the executable, the rest - * the arguments. - */ - public Commandline(String toProcess) { - super(); - String[] tmp = translateCommandline(toProcess); - if (tmp != null && tmp.length > 0) { - setExecutable(tmp[0]); - for (int i = 1; i < tmp.length; i++) { - createArgument().setValue(tmp[i]); - } - } - } - - /** - * Create an empty command line. - */ - public Commandline() { - super(); - } - - /** - * Used for nested xml command line definitions. - */ - public static class Argument extends ProjectComponent { - - private String[] parts; - - private String prefix = ""; - private String suffix = ""; - - /** - * Set a single commandline argument. - * - * @param value a single commandline argument. - */ - public void setValue(String value) { - parts = new String[] {value}; - } - - /** - * Set the line to split into several commandline arguments. - * - * @param line line to split into several commandline arguments. - */ - public void setLine(String line) { - if (line == null) { - return; - } - parts = translateCommandline(line); - } - - /** - * Set a single commandline argument and treats it like a - * PATH--ensuring the right separator for the local platform - * is used. - * - * @param value a single commandline argument. - */ - public void setPath(Path value) { - parts = new String[] {value.toString()}; - } - - /** - * Set a single commandline argument from a reference to a - * path--ensuring the right separator for the local platform - * is used. - * - * @param value a single commandline argument. - */ - public void setPathref(Reference value) { - Path p = new Path(getProject()); - p.setRefid(value); - parts = new String[] {p.toString()}; - } - - /** - * Set a single commandline argument to the absolute filename - * of the given file. - * - * @param value a single commandline argument. - */ - public void setFile(File value) { - parts = new String[] {value.getAbsolutePath()}; - } - - /** - * Set the prefix to be placed in front of every part of the - * argument. - * - * @param prefix fixed prefix string. - * @since Ant 1.8.0 - */ - public void setPrefix(String prefix) { - this.prefix = prefix != null ? prefix : ""; - } - - /** - * Set the suffix to be placed at the end of every part of the - * argument. - * - * @param suffix fixed suffix string. - * @since Ant 1.8.0 - */ - public void setSuffix(String suffix) { - this.suffix = suffix != null ? suffix : ""; - } - - /** - * Return the constituent parts of this Argument. - * @return an array of strings. - */ - public String[] getParts() { - if (parts == null || parts.length == 0 - || (prefix.length() == 0 && suffix.length() == 0)) { - return parts; - } - String[] fullParts = new String[parts.length]; - for (int i = 0; i < fullParts.length; ++i) { - fullParts[i] = prefix + parts[i] + suffix; - } - return fullParts; - } - } - - /** - * Class to keep track of the position of an Argument. - * - * <p>This class is there to support the srcfile and targetfile - * elements of <apply>.</p> - */ - public class Marker { - - private int position; - private int realPos = -1; - private String prefix = ""; - private String suffix = ""; - - /** - * Construct a marker for the specified position. - * @param position the position to mark. - */ - Marker(int position) { - this.position = position; - } - - /** - * Return the number of arguments that preceded this marker. - * - * <p>The name of the executable -- if set -- is counted as the - * first argument.</p> - * @return the position of this marker. - */ - public int getPosition() { - if (realPos == -1) { - realPos = (executable == null ? 0 : 1); - for (int i = 0; i < position; i++) { - Argument arg = (Argument) arguments.get(i); - realPos += arg.getParts().length; - } - } - return realPos; - } - - /** - * Set the prefix to be placed in front of the inserted argument. - * - * @param prefix fixed prefix string. - * @since Ant 1.8.0 - */ - public void setPrefix(String prefix) { - this.prefix = prefix != null ? prefix : ""; - } - - /** - * Get the prefix to be placed in front of the inserted argument. - * - * @since Ant 1.8.0 - */ - public String getPrefix() { - return prefix; - } - - /** - * Set the suffix to be placed at the end of the inserted argument. - * - * @param suffix fixed suffix string. - * @since Ant 1.8.0 - */ - public void setSuffix(String suffix) { - this.suffix = suffix != null ? suffix : ""; - } - - /** - * Get the suffix to be placed at the end of the inserted argument. - * - * @since Ant 1.8.0 - */ - public String getSuffix() { - return suffix; - } - - } - - /** - * Create an argument object. - * - * <p>Each commandline object has at most one instance of the - * argument class. This method calls - * <code>this.createArgument(false)</code>.</p> - * - * @see #createArgument(boolean) - * @return the argument object. - */ - public Argument createArgument() { - return this.createArgument(false); - } - - /** - * Create an argument object and add it to our list of args. - * - * <p>Each commandline object has at most one instance of the - * argument class.</p> - * - * @param insertAtStart if true, the argument is inserted at the - * beginning of the list of args, otherwise it is appended. - * @return an argument to be configured - */ - public Argument createArgument(boolean insertAtStart) { - Argument argument = new Argument(); - if (insertAtStart) { - arguments.add(0, argument); - } else { - arguments.add(argument); - } - return argument; - } - - /** - * Set the executable to run. All file separators in the string - * are converted to the platform specific value. - * @param executable the String executable name. - */ - public void setExecutable(String executable) { - if (executable == null || executable.length() == 0) { - return; - } - this.executable = executable.replace('/', File.separatorChar) - .replace('\\', File.separatorChar); - } - - /** - * Get the executable. - * @return the program to run--null if not yet set. - */ - public String getExecutable() { - return executable; - } - - /** - * Append the arguments to the existing command. - * @param line an array of arguments to append. - */ - public void addArguments(String[] line) { - for (int i = 0; i < line.length; i++) { - createArgument().setValue(line[i]); - } - } - - /** - * Return the executable and all defined arguments. - * @return the commandline as an array of strings. - */ - public String[] getCommandline() { - final List<String> commands = new LinkedList<String>(); - addCommandToList(commands.listIterator()); - return commands.toArray(new String[commands.size()]); - } - - /** - * Add the entire command, including (optional) executable to a list. - * @param list the list to add to. - * @since Ant 1.6 - */ - public void addCommandToList(ListIterator<String> list) { - if (executable != null) { - list.add(executable); - } - addArgumentsToList(list); - } - - /** - * Returns all arguments defined by <code>addLine</code>, - * <code>addValue</code> or the argument object. - * @return the arguments as an array of strings. - */ - public String[] getArguments() { - List<String> result = new ArrayList<String>(arguments.size() * 2); - addArgumentsToList(result.listIterator()); - return result.toArray(new String[result.size()]); - } - - /** - * Append all the arguments to the tail of a supplied list. - * @param list the list of arguments. - * @since Ant 1.6 - */ - public void addArgumentsToList(ListIterator<String> list) { - final int size = arguments.size(); - for (int i = 0; i < size; i++) { - Argument arg = arguments.get(i); - String[] s = arg.getParts(); - if (s != null) { - for (int j = 0; j < s.length; j++) { - list.add(s[j]); - } - } - } - } - - /** - * Return the command line as a string. - * @return the command line. - */ - public String toString() { - return toString(getCommandline()); - } - - /** - * Put quotes around the given String if necessary. - * - * <p>If the argument doesn't include spaces or quotes, return it - * as is. If it contains double quotes, use single quotes - else - * surround the argument by double quotes.</p> - * @param argument the argument to quote if necessary. - * @return the quoted argument. - * @exception BuildException if the argument contains both, single - * and double quotes. - */ - public static String quoteArgument(String argument) { - if (argument.indexOf("\"") > -1) { - if (argument.indexOf("\'") > -1) { - throw new BuildException("Can\'t handle single and double" - + " quotes in same argument"); - } else { - return '\'' + argument + '\''; - } - } else if (argument.indexOf("\'") > -1 - || argument.indexOf(" ") > -1 - // WIN9x uses a bat file for executing commands - || (IS_WIN_9X && argument.indexOf(';') != -1)) { - return '\"' + argument + '\"'; - } else { - return argument; - } - } - - /** - * Quote the parts of the given array in way that makes them - * usable as command line arguments. - * @param line the list of arguments to quote. - * @return empty string for null or no command, else every argument split - * by spaces and quoted by quoting rules. - */ - public static String toString(String[] line) { - // empty path return empty string - if (line == null || line.length == 0) { - return ""; - } - // path containing one or more elements - final StringBuilder result = new StringBuilder(); - for (int i = 0; i < line.length; i++) { - if (i > 0) { - result.append(' '); - } - result.append(quoteArgument(line[i])); - } - return result.toString(); - } - - /** - * Crack a command line. - * @param toProcess the command line to process. - * @return the command line broken into strings. - * An empty or null toProcess parameter results in a zero sized array. - */ - public static String[] translateCommandline(String toProcess) { - if (toProcess == null || toProcess.length() == 0) { - //no command? no string - return new String[0]; - } - // parse with a simple finite state machine - - final int normal = 0; - final int inQuote = 1; - final int inDoubleQuote = 2; - int state = normal; - final StringTokenizer tok = new StringTokenizer(toProcess, "\"\' ", true); - final ArrayList<String> result = new ArrayList<String>(); - final StringBuilder current = new StringBuilder(); - boolean lastTokenHasBeenQuoted = false; - - while (tok.hasMoreTokens()) { - String nextTok = tok.nextToken(); - switch (state) { - case inQuote: - if ("\'".equals(nextTok)) { - lastTokenHasBeenQuoted = true; - state = normal; - } else { - current.append(nextTok); - } - break; - case inDoubleQuote: - if ("\"".equals(nextTok)) { - lastTokenHasBeenQuoted = true; - state = normal; - } else { - current.append(nextTok); - } - break; - default: - if ("\'".equals(nextTok)) { - state = inQuote; - } else if ("\"".equals(nextTok)) { - state = inDoubleQuote; - } else if (" ".equals(nextTok)) { - if (lastTokenHasBeenQuoted || current.length() != 0) { - result.add(current.toString()); - current.setLength(0); - } - } else { - current.append(nextTok); - } - lastTokenHasBeenQuoted = false; - break; - } - } - if (lastTokenHasBeenQuoted || current.length() != 0) { - result.add(current.toString()); - } - if (state == inQuote || state == inDoubleQuote) { - throw new BuildException("unbalanced quotes in " + toProcess); - } - return result.toArray(new String[result.size()]); - } - - /** - * Size operator. This actually creates the command line, so it is not - * a zero cost operation. - * @return number of elements in the command, including the executable. - */ - public int size() { - return getCommandline().length; - } - - /** - * Generate a deep clone of the contained object. - * @return a clone of the contained object - */ - public Object clone() { - try { - Commandline c = (Commandline) super.clone(); - c.arguments = new ArrayList<Argument>(arguments); - return c; - } catch (CloneNotSupportedException e) { - throw new BuildException(e); - } - } - - /** - * Clear out the whole command line. - */ - public void clear() { - executable = null; - arguments.clear(); - } - - /** - * Clear out the arguments but leave the executable in place for - * another operation. - */ - public void clearArgs() { - arguments.clear(); - } - - /** - * Return a marker. - * - * <p>This marker can be used to locate a position on the - * commandline--to insert something for example--when all - * parameters have been set.</p> - * @return a marker - */ - public Marker createMarker() { - return new Marker(arguments.size()); - } - - /** - * Return a String that describes the command and arguments suitable for - * verbose output before a call to <code>Runtime.exec(String[])<code>. - * @return a string that describes the command and arguments. - * @since Ant 1.5 - */ - public String describeCommand() { - return describeCommand(this); - } - - /** - * Return a String that describes the arguments suitable for - * verbose output before a call to <code>Runtime.exec(String[])<code>. - * @return a string that describes the arguments. - * @since Ant 1.5 - */ - public String describeArguments() { - return describeArguments(this); - } - - /** - * Return a String that describes the command and arguments suitable for - * verbose output before a call to <code>Runtime.exec(String[])<code>. - * @param line the Commandline to describe. - * @return a string that describes the command and arguments. - * @since Ant 1.5 - */ - public static String describeCommand(Commandline line) { - return describeCommand(line.getCommandline()); - } - - /** - * Return a String that describes the arguments suitable for - * verbose output before a call to <code>Runtime.exec(String[])<code>. - * @param line the Commandline whose arguments to describe. - * @return a string that describes the arguments. - * @since Ant 1.5 - */ - public static String describeArguments(Commandline line) { - return describeArguments(line.getArguments()); - } - - /** - * Return a String that describes the command and arguments suitable for - * verbose output before a call to <code>Runtime.exec(String[])<code>. - * - * <p>This method assumes that the first entry in the array is the - * executable to run.</p> - * @param args the command line to describe as an array of strings - * @return a string that describes the command and arguments. - * @since Ant 1.5 - */ - public static String describeCommand(String[] args) { - if (args == null || args.length == 0) { - return ""; - } - StringBuffer buf = new StringBuffer("Executing \'"); - buf.append(args[0]); - buf.append("\'"); - if (args.length > 1) { - buf.append(" with "); - buf.append(describeArguments(args, 1)); - } else { - buf.append(DISCLAIMER); - } - return buf.toString(); - } - - /** - * Return a String that describes the arguments suitable for - * verbose output before a call to <code>Runtime.exec(String[])<code>. - * @param args the command line to describe as an array of strings. - * @return a string that describes the arguments. - * @since Ant 1.5 - */ - public static String describeArguments(String[] args) { - return describeArguments(args, 0); - } - - /** - * Return a String that describes the arguments suitable for - * verbose output before a call to <code>Runtime.exec(String[])<code>. - * - * @param args the command line to describe as an array of strings. - * @param offset ignore entries before this index. - * @return a string that describes the arguments - * - * @since Ant 1.5 - */ - protected static String describeArguments(String[] args, int offset) { - if (args == null || args.length <= offset) { - return ""; - } - StringBuffer buf = new StringBuffer("argument"); - if (args.length > offset) { - buf.append("s"); - } - buf.append(":").append(StringUtils.LINE_SEP); - for (int i = offset; i < args.length; i++) { - buf.append("\'").append(args[i]).append("\'") - .append(StringUtils.LINE_SEP); - } - buf.append(DISCLAIMER); - return buf.toString(); - } - - /** - * Get an iterator to the arguments list. - * @since Ant 1.7 - * @return an Iterator. - */ - public Iterator<Argument> iterator() { - return arguments.iterator(); - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/CommandlineJava.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/CommandlineJava.java deleted file mode 100644 index 9da354dd..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/CommandlineJava.java +++ /dev/null @@ -1,699 +0,0 @@ -/* - * 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.util.Enumeration; -import java.util.LinkedList; -import java.util.List; -import java.util.ListIterator; -import java.util.Properties; -import java.util.Vector; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.util.JavaEnvUtils; - -/** - * A representation of a Java command line that is - * a composite of 2 <tt>Commandline</tt>s. One is used for the - * vm/options and one for the classname/arguments. It provides - * specific methods for a Java command line. - * - */ -public class CommandlineJava implements Cloneable { - - /** - * commands to the JVM - */ - private Commandline vmCommand = new Commandline(); - /** - * actual java commands - */ - private Commandline javaCommand = new Commandline(); - /** - * properties to add using -D - */ - private SysProperties sysProperties = new SysProperties(); - private Path classpath = null; - private Path bootclasspath = null; - private String vmVersion; - private String maxMemory = null; - /** - * any assertions to make? Currently only supported in forked JVMs - */ - private Assertions assertions = null; - - /** - * Indicate whether it will execute a jar file or not, in this case - * the first vm option must be a -jar and the 'executable' is a jar file. - */ - private boolean executeJar = false; - - /** - * Whether system properties and bootclasspath shall be cloned. - * @since Ant 1.7 - */ - private boolean cloneVm = false; - - /** - * Specialized Environment class for System properties. - */ - public static class SysProperties extends Environment implements Cloneable { - // CheckStyle:VisibilityModifier OFF - bc - /** the system properties. */ - Properties sys = null; - // CheckStyle:VisibilityModifier ON - private Vector<PropertySet> propertySets = new Vector<PropertySet>(); - - /** - * Get the properties as an array; this is an override of the - * superclass, as it evaluates all the properties. - * @return the array of definitions; may be null. - * @throws BuildException on error. - */ - public String[] getVariables() throws BuildException { - - List<String> definitions = new LinkedList<String>(); - addDefinitionsToList(definitions.listIterator()); - if (definitions.size() == 0) { - return null; - } else { - return definitions.toArray(new String[definitions.size()]); - } - } - - /** - * Add all definitions (including property sets) to a list. - * @param listIt list iterator supporting add method. - */ - public void addDefinitionsToList(ListIterator<String> listIt) { - String[] props = super.getVariables(); - if (props != null) { - for (int i = 0; i < props.length; i++) { - listIt.add("-D" + props[i]); - } - } - Properties propertySetProperties = mergePropertySets(); - for (Enumeration<?> e = propertySetProperties.keys(); - e.hasMoreElements();) { - String key = (String) e.nextElement(); - String value = propertySetProperties.getProperty(key); - listIt.add("-D" + key + "=" + value); - } - } - - /** - * Get the size of the sysproperties instance. This merges all - * property sets, so is not an O(1) operation. - * @return the size of the sysproperties instance. - */ - public int size() { - Properties p = mergePropertySets(); - return variables.size() + p.size(); - } - - /** - * Cache the system properties and set the system properties to the - * new values. - * @throws BuildException if Security prevented this operation. - */ - public void setSystem() throws BuildException { - try { - sys = System.getProperties(); - Properties p = new Properties(); - for (Enumeration<?> e = sys.propertyNames(); e.hasMoreElements();) { - String name = (String) e.nextElement(); - String value = sys.getProperty(name); - if (name != null && value != null) { - p.put(name, value); - } - } - p.putAll(mergePropertySets()); - for (Environment.Variable v : variables) { - v.validate(); - p.put(v.getKey(), v.getValue()); - } - System.setProperties(p); - } catch (SecurityException e) { - throw new BuildException("Cannot modify system properties", e); - } - } - - /** - * Restore the system properties to the cached value. - * @throws BuildException if Security prevented this operation, or - * there were no system properties to restore. - */ - public void restoreSystem() throws BuildException { - if (sys == null) { - throw new BuildException("Unbalanced nesting of SysProperties"); - } - - try { - System.setProperties(sys); - sys = null; - } catch (SecurityException e) { - throw new BuildException("Cannot modify system properties", e); - } - } - - /** - * Create a deep clone. - * @return a cloned instance of SysProperties. - * @exception CloneNotSupportedException for signature. - */ - @SuppressWarnings("unchecked") - public Object clone() throws CloneNotSupportedException { - try { - SysProperties c = (SysProperties) super.clone(); - c.variables = (Vector<Environment.Variable>) variables.clone(); - c.propertySets = (Vector<PropertySet>) propertySets.clone(); - return c; - } catch (CloneNotSupportedException e) { - return null; - } - } - - /** - * Add a propertyset to the total set. - * @param ps the new property set. - */ - public void addSyspropertyset(PropertySet ps) { - propertySets.addElement(ps); - } - - /** - * Add a propertyset to the total set. - * @param ps the new property set. - * @since Ant 1.6.3 - */ - public void addSysproperties(SysProperties ps) { - variables.addAll(ps.variables); - propertySets.addAll(ps.propertySets); - } - - /** - * Merge all property sets into a single Properties object. - * @return the merged object. - */ - private Properties mergePropertySets() { - Properties p = new Properties(); - for (PropertySet ps : propertySets) { - p.putAll(ps.getProperties()); - } - return p; - } - - } - - /** - * Constructor uses the VM we are running on now. - */ - public CommandlineJava() { - setVm(JavaEnvUtils.getJreExecutable("java")); - setVmversion(JavaEnvUtils.getJavaVersion()); - } - - /** - * Create a new argument to the java program. - * @return an argument to be configured. - */ - public Commandline.Argument createArgument() { - return javaCommand.createArgument(); - } - - /** - * Create a new JVM argument. - * @return an argument to be configured. - */ - public Commandline.Argument createVmArgument() { - return vmCommand.createArgument(); - } - - /** - * Add a system property. - * @param sysp a property to be set in the JVM. - */ - public void addSysproperty(Environment.Variable sysp) { - sysProperties.addVariable(sysp); - } - - /** - * Add a set of system properties. - * @param sysp a set of properties. - */ - public void addSyspropertyset(PropertySet sysp) { - sysProperties.addSyspropertyset(sysp); - } - - /** - * Add a set of system properties. - * @param sysp a set of properties. - * @since Ant 1.6.3 - */ - public void addSysproperties(SysProperties sysp) { - sysProperties.addSysproperties(sysp); - } - - /** - * Set the executable used to start the new JVM. - * @param vm the executable to use. - */ - public void setVm(String vm) { - vmCommand.setExecutable(vm); - } - - /** - * Set the JVM version required. - * @param value the version required. - */ - public void setVmversion(String value) { - vmVersion = value; - } - - /** - * Set whether system properties will be copied to the cloned VM--as - * well as the bootclasspath unless you have explicitly specified - * a bootclasspath. - * @param cloneVm if true copy the system properties. - * @since Ant 1.7 - */ - public void setCloneVm(boolean cloneVm) { - this.cloneVm = cloneVm; - } - - /** - * Get the current assertions. - * @return assertions or null. - */ - public Assertions getAssertions() { - return assertions; - } - - /** - * Add an assertion set to the command. - * @param assertions assertions to make. - */ - public void setAssertions(Assertions assertions) { - this.assertions = assertions; - } - - /** - * Set a jar file to execute via the -jar option. - * @param jarpathname the pathname of the jar to execute. - */ - public void setJar(String jarpathname) { - javaCommand.setExecutable(jarpathname); - executeJar = true; - } - - /** - * Get the name of the jar to be run. - * @return the pathname of the jar file to run via -jar option - * or <tt>null</tt> if there is no jar to run. - * @see #getClassname() - */ - public String getJar() { - if (executeJar) { - return javaCommand.getExecutable(); - } - return null; - } - - /** - * Set the classname to execute. - * @param classname the fully qualified classname. - */ - public void setClassname(String classname) { - javaCommand.setExecutable(classname); - executeJar = false; - } - - /** - * Get the name of the class to be run. - * @return the name of the class to run or <tt>null</tt> if there is no class. - * @see #getJar() - */ - public String getClassname() { - if (!executeJar) { - return javaCommand.getExecutable(); - } - return null; - } - - /** - * Create a classpath. - * @param p the project to use to create the path. - * @return a path to be configured. - */ - public Path createClasspath(Project p) { - if (classpath == null) { - classpath = new Path(p); - } - return classpath; - } - - /** - * Create a boot classpath. - * @param p the project to use to create the path. - * @return a path to be configured. - * @since Ant 1.6 - */ - public Path createBootclasspath(Project p) { - if (bootclasspath == null) { - bootclasspath = new Path(p); - } - return bootclasspath; - } - - /** - * Get the vm version. - * @return the vm version. - */ - public String getVmversion() { - return vmVersion; - } - - /** - * Get the command line to run a Java vm. - * @return the list of all arguments necessary to run the vm. - */ - public String[] getCommandline() { - //create the list - List<String> commands = new LinkedList<String>(); - //fill it - addCommandsToList(commands.listIterator()); - //convert to an array - return commands.toArray(new String[commands.size()]); - } - - /** - * Add all the commands to a list identified by the iterator passed in. - * @param listIterator an iterator that supports the add method. - * @since Ant 1.6 - */ - private void addCommandsToList(final ListIterator<String> listIterator) { - //create the command to run Java, including user specified options - getActualVMCommand().addCommandToList(listIterator); - // properties are part of the vm options... - sysProperties.addDefinitionsToList(listIterator); - - if (isCloneVm()) { - SysProperties clonedSysProperties = new SysProperties(); - PropertySet ps = new PropertySet(); - PropertySet.BuiltinPropertySetName sys = - new PropertySet.BuiltinPropertySetName(); - sys.setValue("system"); - ps.appendBuiltin(sys); - clonedSysProperties.addSyspropertyset(ps); - clonedSysProperties.addDefinitionsToList(listIterator); - } - //boot classpath - Path bcp = calculateBootclasspath(true); - if (bcp.size() > 0) { - listIterator.add("-Xbootclasspath:" + bcp.toString()); - } - //main classpath - if (haveClasspath()) { - listIterator.add("-classpath"); - listIterator.add( - classpath.concatSystemClasspath("ignore").toString()); - } - //now any assertions are added - if (getAssertions() != null) { - getAssertions().applyAssertions(listIterator); - } - // JDK usage command line says that -jar must be the first option, as there is - // a bug in JDK < 1.4 that forces the jvm type to be specified as the first - // option, it is appended here as specified in the docs even though there is - // in fact no order. - if (executeJar) { - listIterator.add("-jar"); - } - // this is the classname to run as well as its arguments. - // in case of 'executeJar', the executable is a jar file. - javaCommand.addCommandToList(listIterator); - } - - /** - * Specify max memory of the JVM. - * -mx or -Xmx depending on VM version. - * @param max the string to pass to the jvm to specify the max memory. - */ - public void setMaxmemory(String max) { - this.maxMemory = max; - } - - /** - * Get a string description. - * @return the command line as a string. - */ - public String toString() { - return Commandline.toString(getCommandline()); - } - - /** - * Return a String that describes the command and arguments suitable for - * verbose output before a call to <code>Runtime.exec(String[])<code>. - * @return the description string. - * @since Ant 1.5 - */ - public String describeCommand() { - return Commandline.describeCommand(getCommandline()); - } - - /** - * Return a String that describes the java command and arguments - * for in-VM executions. - * - * <p>The class name is the executable in this context.</p> - * @return the description string. - * @since Ant 1.5 - */ - public String describeJavaCommand() { - return Commandline.describeCommand(getJavaCommand()); - } - - /** - * Get the VM command parameters, including memory settings. - * @return the VM command parameters. - */ - protected Commandline getActualVMCommand() { - Commandline actualVMCommand = (Commandline) vmCommand.clone(); - if (maxMemory != null) { - if (vmVersion.startsWith("1.1")) { - actualVMCommand.createArgument().setValue("-mx" + maxMemory); - } else { - actualVMCommand.createArgument().setValue("-Xmx" + maxMemory); - } - } - return actualVMCommand; - } - - /** - * Get the size of the java command line. This is a fairly intensive - * operation, as it has to evaluate the size of many components. - * @return the total number of arguments in the java command line. - * @see #getCommandline() - * @deprecated since 1.7. - * Please dont use this, it effectively creates the - * entire command. - */ - public int size() { - int size = getActualVMCommand().size() + javaCommand.size() - + sysProperties.size(); - // cloned system properties - if (isCloneVm()) { - size += System.getProperties().size(); - } - // classpath is "-classpath <classpath>" -> 2 args - if (haveClasspath()) { - size += 2; - } - // bootclasspath is "-Xbootclasspath:<classpath>" -> 1 arg - if (calculateBootclasspath(true).size() > 0) { - size++; - } - // jar execution requires an additional -jar option - if (executeJar) { - size++; - } - //assertions take up space too - if (getAssertions() != null) { - size += getAssertions().size(); - } - return size; - } - - /** - * Get the Java command to be used. - * @return the java command--not a clone. - */ - public Commandline getJavaCommand() { - return javaCommand; - } - - /** - * Get the VM command, including memory. - * @return A deep clone of the instance's VM command, with memory settings added. - */ - public Commandline getVmCommand() { - return getActualVMCommand(); - } - - /** - * Get the classpath for the command. - * @return the classpath or null. - */ - public Path getClasspath() { - return classpath; - } - - /** - * Get the boot classpath. - * @return boot classpath or null. - */ - public Path getBootclasspath() { - return bootclasspath; - } - - /** - * Cache current system properties and set them to those in this - * Java command. - * @throws BuildException if Security prevented this operation. - */ - public void setSystemProperties() throws BuildException { - sysProperties.setSystem(); - } - - /** - * Restore the cached system properties. - * @throws BuildException if Security prevented this operation, or - * there was no system properties to restore - */ - public void restoreSystemProperties() throws BuildException { - sysProperties.restoreSystem(); - } - - /** - * Get the system properties object. - * @return The system properties object. - */ - public SysProperties getSystemProperties() { - return sysProperties; - } - - /** - * Deep clone the object. - * @return a CommandlineJava object. - * @throws BuildException if anything went wrong. - * @throws CloneNotSupportedException never. - */ - public Object clone() throws CloneNotSupportedException { - try { - CommandlineJava c = (CommandlineJava) super.clone(); - c.vmCommand = (Commandline) vmCommand.clone(); - c.javaCommand = (Commandline) javaCommand.clone(); - c.sysProperties = (SysProperties) sysProperties.clone(); - if (classpath != null) { - c.classpath = (Path) classpath.clone(); - } - if (bootclasspath != null) { - c.bootclasspath = (Path) bootclasspath.clone(); - } - if (assertions != null) { - c.assertions = (Assertions) assertions.clone(); - } - return c; - } catch (CloneNotSupportedException e) { - throw new BuildException(e); - } - } - - /** - * Clear out the java arguments. - */ - public void clearJavaArgs() { - javaCommand.clearArgs(); - } - - /** - * Determine whether the classpath has been specified, and whether it shall - * really be used or be nulled by build.sysclasspath. - * @return true if the classpath is to be used. - * @since Ant 1.6 - */ - public boolean haveClasspath() { - Path fullClasspath = classpath != null - ? classpath.concatSystemClasspath("ignore") : null; - return fullClasspath != null - && fullClasspath.toString().trim().length() > 0; - } - - /** - * Determine whether the bootclasspath has been specified, and whether it - * shall really be used (build.sysclasspath could be set or the VM may not - * support it). - * - * @param log whether to log a warning if a bootclasspath has been - * specified but will be ignored. - * @return true if the bootclasspath is to be used. - * @since Ant 1.6 - */ - protected boolean haveBootclasspath(boolean log) { - return calculateBootclasspath(log).size() > 0; - } - - /** - * Calculate the bootclasspath based on the bootclasspath - * specified, the build.sysclasspath and ant.build.clonevm magic - * properties as well as the cloneVm attribute. - * @param log whether to write messages to the log. - * @since Ant 1.7 - */ - private Path calculateBootclasspath(boolean log) { - if (vmVersion.startsWith("1.1")) { - if (bootclasspath != null && log) { - bootclasspath.log("Ignoring bootclasspath as " - + "the target VM doesn't support it."); - } - } else { - Path b = bootclasspath; - if (b == null) { - b = new Path(null); - } - // even with no user-supplied bootclasspath - // build.sysclasspath could be set to something other than - // "ignore" and thus create one - return b.concatSystemBootClasspath(isCloneVm() ? "last" : "ignore"); - } - return new Path(null); - } - - /** - * Find out whether either of the cloneVm attribute or the magic property - * ant.build.clonevm has been set. - * @return <code>boolean</code>. - * @since 1.7 - */ - private boolean isCloneVm() { - return cloneVm - || "true".equals(System.getProperty("ant.build.clonevm")); - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/Comparison.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/Comparison.java deleted file mode 100644 index a057d0d7..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/Comparison.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * 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.util.Arrays; - -import org.apache.tools.ant.BuildException; - -/** - * EnumeratedAttribute for generic comparisons. Accepts values - * "equal", "greater", "more", "less", "ne" (not equal), - * "ge" (greater or equal), "le" (less or equal), "eq" (equal), - * "gt" (greater), "lt" (less). - * @since Ant 1.7 - */ -public class Comparison extends EnumeratedAttribute { - private static final String[] VALUES - = new String[] {"equal", "greater", "less", - "ne", "ge", "le", "eq", "gt", "lt", "more"}; - - /** Equal Comparison. */ - public static final Comparison EQUAL = new Comparison("equal"); - - /** Not-Equal Comparison. */ - public static final Comparison NOT_EQUAL = new Comparison("ne"); - - /** Greater Comparison. */ - public static final Comparison GREATER = new Comparison("greater"); - - /** Less Comparison. */ - public static final Comparison LESS = new Comparison("less"); - - /** Greater-or-Equal Comparison. */ - public static final Comparison GREATER_EQUAL = new Comparison("ge"); - - /** Less-or-Equal Comparison. */ - public static final Comparison LESS_EQUAL = new Comparison("le"); - - private static final int[] EQUAL_INDEX = {0, 4, 5, 6}; - private static final int[] LESS_INDEX = {2, 3, 5, 8}; - private static final int[] GREATER_INDEX = {1, 3, 4, 7, 9}; - - /** - * Default constructor. - */ - public Comparison() { - } - - /** - * Construct a new Comparison with the specified value. - * @param value the EnumeratedAttribute value. - */ - public Comparison(String value) { - setValue(value); - } - - /** - * Return the possible values. - * @return String[] of EnumeratedAttribute values. - */ - public String[] getValues() { - return VALUES; - } - - /** - * Evaluate a comparison result as from Comparator.compare() or Comparable.compareTo(). - * @param comparisonResult the result to evaluate. - * @return true if the comparison result fell within the parameters of this Comparison. - */ - public boolean evaluate(int comparisonResult) { - if (getIndex() == -1) { - throw new BuildException("Comparison value not set."); - } - int[] i = comparisonResult < 0 ? LESS_INDEX - : comparisonResult > 0 ? GREATER_INDEX : EQUAL_INDEX; - return Arrays.binarySearch(i, getIndex()) >= 0; - } - -} - diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/DTDLocation.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/DTDLocation.java deleted file mode 100644 index 9fdeee29..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/DTDLocation.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 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; - -/** - * <p>Helper class to handle the DTD nested element. Instances of - * this class correspond to the <code>PUBLIC</code> catalog entry type - * of the <a - * href="http://oasis-open.org/committees/entity/spec-2001-08-06.html"> - * OASIS "Open Catalog" standard</a>.</p> - * - * <p>Possible Future Enhancement: Bring the Ant element name into - * conformance with the OASIS standard.</p> - * - * @see org.apache.xml.resolver.Catalog - */ -public class DTDLocation extends ResourceLocation { -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/DataType.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/DataType.java deleted file mode 100644 index fda4af62..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/DataType.java +++ /dev/null @@ -1,367 +0,0 @@ -/* - * 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.util.Stack; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.ComponentHelper; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.ProjectComponent; -import org.apache.tools.ant.util.IdentityStack; - -/** - * Base class for those classes that can appear inside the build file - * as stand alone data types. - * - * <p>This class handles the common description attribute and provides - * a default implementation for reference handling and checking for - * circular references that is appropriate for types that can not be - * nested inside elements of the same type (i.e. <patternset> - * but not <path>).</p> - * - */ -public abstract class DataType extends ProjectComponent implements Cloneable { - // CheckStyle:VisibilityModifier OFF - - /** - * Value to the refid attribute. - * - * @deprecated since 1.7. - * The user should not be directly referencing - * variable. Please use {@link #getRefid} instead. - */ - protected Reference ref; - - /** - * Are we sure we don't hold circular references? - * - * <p>Subclasses are responsible for setting this value to false - * if we'd need to investigate this condition (usually because a - * child element has been added that is a subclass of - * DataType).</p> - * - * @deprecated since 1.7. - * The user should not be directly referencing - * variable. Please use {@link #setChecked} or - * {@link #isChecked} instead. - */ - protected boolean checked = true; - // CheckStyle:VisibilityModifier ON - - /** - * Has the refid attribute of this element been set? - * @return true if the refid attribute has been set - */ - public boolean isReference() { - return ref != null; - } - - /** - * Set the value of the refid attribute. - * - * <p>Subclasses may need to check whether any other attributes - * have been set as well or child elements have been created and - * thus override this method. if they do the must call - * <code>super.setRefid</code>.</p> - * @param ref the reference to use - */ - public void setRefid(final Reference ref) { - this.ref = ref; - checked = false; - } - - /** - * Gets as descriptive as possible a name used for this datatype instance. - * @return <code>String</code> name. - */ - protected String getDataTypeName() { - return ComponentHelper.getElementName(getProject(), this, true); - } - - /** - * Convenience method. - * @since Ant 1.7 - */ - protected void dieOnCircularReference() { - dieOnCircularReference(getProject()); - } - - /** - * Convenience method. - * @param p the Ant Project instance against which to resolve references. - * @since Ant 1.7 - */ - protected void dieOnCircularReference(Project p) { - if (checked || !isReference()) { - return; - } - dieOnCircularReference(new IdentityStack<Object>(this), p); - } - - /** - * Check to see whether any DataType we hold references to is - * included in the Stack (which holds all DataType instances that - * directly or indirectly reference this instance, including this - * instance itself). - * - * <p>If one is included, throw a BuildException created by {@link - * #circularReference circularReference}.</p> - * - * <p>This implementation is appropriate only for a DataType that - * cannot hold other DataTypes as children.</p> - * - * <p>The general contract of this method is that it shouldn't do - * anything if {@link #checked <code>checked</code>} is true and - * set it to true on exit.</p> - * @param stack the stack of references to check. - * @param project the project to use to dereference the references. - * @throws BuildException on error. - */ - protected void dieOnCircularReference(final Stack<Object> stack, - final Project project) - throws BuildException { - - if (checked || !isReference()) { - return; - } - Object o = ref.getReferencedObject(project); - - if (o instanceof DataType) { - IdentityStack<Object> id = IdentityStack.getInstance(stack); - - if (id.contains(o)) { - throw circularReference(); - } else { - id.push(o); - ((DataType) o).dieOnCircularReference(id, project); - id.pop(); - } - } - checked = true; - } - - /** - * Allow DataTypes outside org.apache.tools.ant.types to indirectly call - * dieOnCircularReference on nested DataTypes. - * @param dt the DataType to check. - * @param stk the stack of references to check. - * @param p the project to use to dereference the references. - * @throws BuildException on error. - * @since Ant 1.7 - */ - public static void invokeCircularReferenceCheck(DataType dt, Stack<Object> stk, - Project p) { - dt.dieOnCircularReference(stk, p); - } - - /** - * Allow DataTypes outside org.apache.tools.ant.types to indirectly call - * dieOnCircularReference on nested DataTypes. - * - * <p>Pushes dt on the stack, runs dieOnCircularReference and pops - * it again.</p> - * @param dt the DataType to check. - * @param stk the stack of references to check. - * @param p the project to use to dereference the references. - * @throws BuildException on error. - * @since Ant 1.8.0 - */ - public static void pushAndInvokeCircularReferenceCheck(DataType dt, - Stack<Object> stk, - Project p) { - stk.push(dt); - dt.dieOnCircularReference(stk, p); - stk.pop(); - } - - /** - * Performs the check for circular references and returns the - * referenced object. - * @return the dereferenced object. - * @throws BuildException if the reference is invalid (circular ref, wrong class, etc). - * @since Ant 1.7 - */ - protected Object getCheckedRef() { - return getCheckedRef(getProject()); - } - - /** - * Performs the check for circular references and returns the - * referenced object. - * @param p the Ant Project instance against which to resolve references. - * @return the dereferenced object. - * @throws BuildException if the reference is invalid (circular ref, wrong class, etc). - * @since Ant 1.7 - */ - protected Object getCheckedRef(Project p) { - return getCheckedRef(getClass(), getDataTypeName(), p); - } - - /** - * Performs the check for circular references and returns the - * referenced object. - * @param requiredClass the class that this reference should be a subclass of. - * @param dataTypeName the name of the datatype that the reference should be - * (error message use only). - * @return the dereferenced object. - * @throws BuildException if the reference is invalid (circular ref, wrong class, etc). - */ - protected <T> T getCheckedRef(final Class<T> requiredClass, - final String dataTypeName) { - return getCheckedRef(requiredClass, dataTypeName, getProject()); - } - - /** - * Performs the check for circular references and returns the - * referenced object. This version allows the fallback Project instance to be specified. - * @param requiredClass the class that this reference should be a subclass of. - * @param dataTypeName the name of the datatype that the reference should be - * (error message use only). - * @param project the fallback Project instance for dereferencing. - * @return the dereferenced object. - * @throws BuildException if the reference is invalid (circular ref, wrong class, etc), - * or if <code>project</code> is <code>null</code>. - * @since Ant 1.7 - */ - protected <T> T getCheckedRef(final Class<T> requiredClass, - final String dataTypeName, final Project project) { - if (project == null) { - throw new BuildException("No Project specified"); - } - dieOnCircularReference(project); - Object o = ref.getReferencedObject(project); - if (!(requiredClass.isAssignableFrom(o.getClass()))) { - log("Class " + displayName(o.getClass()) - + " is not a subclass of " - + displayName(requiredClass), - Project.MSG_VERBOSE); - String msg = ref.getRefId() + " doesn\'t denote a " + dataTypeName; - throw new BuildException(msg); - } - @SuppressWarnings("unchecked") - final T result = (T) o; - return result; - } - - /** - * Creates an exception that indicates that refid has to be the - * only attribute if it is set. - * @return the exception to throw - */ - protected BuildException tooManyAttributes() { - return new BuildException("You must not specify more than one " - + "attribute when using refid"); - } - - /** - * Creates an exception that indicates that this XML element must - * not have child elements if the refid attribute is set. - * @return the exception to throw - */ - protected BuildException noChildrenAllowed() { - return new BuildException("You must not specify nested elements " - + "when using refid"); - } - - /** - * Creates an exception that indicates the user has generated a - * loop of data types referencing each other. - * @return the exception to throw - */ - protected BuildException circularReference() { - return new BuildException("This data type contains a circular " - + "reference."); - } - - /** - * The flag that is used to indicate that circular references have been checked. - * @return true if circular references have been checked - */ - protected boolean isChecked() { - return checked; - } - - /** - * Set the flag that is used to indicate that circular references have been checked. - * @param checked if true, if circular references have been checked - */ - protected void setChecked(final boolean checked) { - this.checked = checked; - } - - /** - * get the reference set on this object - * @return the reference or null - */ - public Reference getRefid() { - return ref; - } - - /** - * check that it is ok to set attributes, i.e that no reference is defined - * @since Ant 1.6 - * @throws BuildException if not allowed - */ - protected void checkAttributesAllowed() { - if (isReference()) { - throw tooManyAttributes(); - } - } - - /** - * check that it is ok to add children, i.e that no reference is defined - * @since Ant 1.6 - * @throws BuildException if not allowed - */ - protected void checkChildrenAllowed() { - if (isReference()) { - throw noChildrenAllowed(); - } - } - - /** - * Basic DataType toString(). - * @return this DataType formatted as a String. - */ - public String toString() { - String d = getDescription(); - return d == null ? getDataTypeName() : getDataTypeName() + " " + d; - } - - /** - * @since Ant 1.7 - * @return a shallow copy of this DataType. - * @throws CloneNotSupportedException if there is a problem. - */ - public Object clone() throws CloneNotSupportedException { - DataType dt = (DataType) super.clone(); - dt.setDescription(getDescription()); - if (getRefid() != null) { - dt.setRefid(getRefid()); - } - dt.setChecked(isChecked()); - return dt; - } - - private String displayName(Class<?> clazz) { - return clazz.getName() + " (loaded via " + clazz.getClassLoader() +")"; - } -} - diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/Description.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/Description.java deleted file mode 100644 index d23f1d88..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/Description.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * 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.util.ArrayList; -import java.util.List; - -import org.apache.tools.ant.Project; -import org.apache.tools.ant.ProjectHelper; -import org.apache.tools.ant.Target; -import org.apache.tools.ant.Task; -import org.apache.tools.ant.UnknownElement; -import org.apache.tools.ant.helper.ProjectHelper2; -import org.apache.tools.ant.helper.ProjectHelperImpl; - - -/** - * Description is used to provide a project-wide description element - * (that is, a description that applies to a buildfile as a whole). - * If present, the <description> element is printed out before the - * target descriptions. - * - * Description has no attributes, only text. There can only be one - * project description per project. A second description element will - * overwrite the first. - * - * - * @ant.datatype ignore="true" - */ -public class Description extends DataType { - - /** - * Adds descriptive text to the project. - * - * @param text the descriptive text - */ - public void addText(String text) { - - ProjectHelper ph = getProject().getReference(ProjectHelper.PROJECTHELPER_REFERENCE); - if (!(ph instanceof ProjectHelperImpl)) { - // New behavior for delayed task creation. Description - // will be evaluated in Project.getDescription() - return; - } - String currentDescription = getProject().getDescription(); - if (currentDescription == null) { - getProject().setDescription(text); - } else { - getProject().setDescription(currentDescription + text); - } - } - - /** - * Return the descriptions from all the targets of - * a project. - * - * @param project the project to get the descriptions for. - * @return a string containing the concatenated descriptions of - * the targets. - */ - public static String getDescription(Project project) { - List<Target> targets = project.getReference(ProjectHelper2.REFID_TARGETS); - if (targets == null) { - return null; - } - StringBuilder description = new StringBuilder(); - for (Target t : targets) { - concatDescriptions(project, t, description); - } - return description.toString(); - } - - private static void concatDescriptions(Project project, Target t, - StringBuilder description) { - if (t == null) { - return; - } - for (Task task : findElementInTarget(project, t, "description")) { - if (!(task instanceof UnknownElement)) { - continue; - } - UnknownElement ue = ((UnknownElement) task); - String descComp = ue.getWrapper().getText().toString(); - if (descComp != null) { - description.append(project.replaceProperties(descComp)); - } - } - } - - private static List<Task> findElementInTarget(Project project, - Target t, String name) { - final List<Task> elems = new ArrayList<Task>(); - for (Task task : t.getTasks()) { - if (name.equals(task.getTaskName())) { - elems.add(task); - } - } - return elems; - } - -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/DirSet.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/DirSet.java deleted file mode 100644 index 35c02311..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/DirSet.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * 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.util.Iterator; - -import org.apache.tools.ant.DirectoryScanner; -import org.apache.tools.ant.types.resources.FileResourceIterator; - -/** - * Subclass as hint for supporting tasks that the included directories - * instead of files should be used. - * - * @since Ant 1.5 - */ -public class DirSet extends AbstractFileSet implements ResourceCollection { - - /** - * Constructor for DirSet. - */ - public DirSet() { - super(); - } - - /** - * Constructor for DirSet, with DirSet to shallowly clone. - * @param dirset the dirset to clone. - */ - protected DirSet(DirSet dirset) { - super(dirset); - } - - /** - * Return a DirSet that has the same basedir and same patternsets - * as this one. - * @return the cloned dirset. - */ - public Object clone() { - if (isReference()) { - return ((DirSet) getRef(getProject())).clone(); - } else { - return super.clone(); - } - } - - /** - * Fulfill the ResourceCollection contract. - * @return an Iterator of Resources. - * @since Ant 1.7 - */ - public Iterator<Resource> iterator() { - if (isReference()) { - return ((DirSet) getRef(getProject())).iterator(); - } - return new FileResourceIterator(getProject(), getDir(getProject()), - getDirectoryScanner(getProject()).getIncludedDirectories()); - } - - /** - * Fulfill the ResourceCollection contract. - * @return number of elements as int. - * @since Ant 1.7 - */ - public int size() { - if (isReference()) { - return ((DirSet) getRef(getProject())).size(); - } - return getDirectoryScanner(getProject()).getIncludedDirsCount(); - } - - /** - * Always returns true. - * @return true indicating that all elements will be FileResources. - * @since Ant 1.7 - */ - public boolean isFilesystemOnly() { - return true; - } - - /** - * Returns included directories as a list of semicolon-separated paths. - * - * @return a <code>String</code> of included directories. - */ - public String toString() { - DirectoryScanner ds = getDirectoryScanner(getProject()); - String[] dirs = ds.getIncludedDirectories(); - StringBuffer sb = new StringBuffer(); - - for (int i = 0; i < dirs.length; i++) { - if (i > 0) { - sb.append(';'); - } - sb.append(dirs[i]); - } - return sb.toString(); - } - -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/EnumeratedAttribute.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/EnumeratedAttribute.java deleted file mode 100644 index bc893d8d..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/EnumeratedAttribute.java +++ /dev/null @@ -1,153 +0,0 @@ -/* - * 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 org.apache.tools.ant.BuildException; - -/** - * Helper class for attributes that can only take one of a fixed list - * of values. - * - * <p>See {@link org.apache.tools.ant.taskdefs.FixCRLF FixCRLF} for an - * example. - * - */ -public abstract class EnumeratedAttribute { - // CheckStyle:VisibilityModifier OFF - bc - /** - * The selected value in this enumeration. - */ - protected String value; - - // CheckStyle:VisibilityModifier ON - - /** - * the index of the selected value in the array. - */ - private int index = -1; - - /** - * This is the only method a subclass needs to implement. - * - * @return an array holding all possible values of the enumeration. - * The order of elements must be fixed so that <tt>indexOfValue(String)</tt> - * always return the same index for the same value. - */ - public abstract String[] getValues(); - - /** bean constructor */ - protected EnumeratedAttribute() { - } - - /** - * Factory method for instantiating EAs via API in a more - * developer friendly way. - * @param clazz Class, extending EA, which to instantiate - * @param value The value to set on that EA - * @return Configured EA - * @throws BuildException If the class could not be found or the value - * is not valid for the given EA-class. - * @see <a href="http://issues.apache.org/bugzilla/show_bug.cgi?id=14831"> - * http://issues.apache.org/bugzilla/show_bug.cgi?id=14831</a> - */ - public static EnumeratedAttribute getInstance( - Class<? extends EnumeratedAttribute> clazz, - String value) throws BuildException { - if (!EnumeratedAttribute.class.isAssignableFrom(clazz)) { - throw new BuildException( - "You have to provide a subclass from EnumeratedAttribut as clazz-parameter."); - } - EnumeratedAttribute ea = null; - try { - ea = clazz.newInstance(); - } catch (Exception e) { - throw new BuildException(e); - } - ea.setValue(value); - return ea; - } - - /** - * Invoked by {@link org.apache.tools.ant.IntrospectionHelper IntrospectionHelper}. - * @param value the <code>String</code> value of the attribute - * @throws BuildException if the value is not valid for the attribute - */ - public final void setValue(String value) throws BuildException { - int idx = indexOfValue(value); - if (idx == -1) { - throw new BuildException(value + " is not a legal value for this attribute"); - } - this.index = idx; - this.value = value; - } - - /** - * Is this value included in the enumeration? - * @param value the <code>String</code> value to look up - * @return true if the value is valid - */ - public final boolean containsValue(String value) { - return (indexOfValue(value) != -1); - } - - /** - * get the index of a value in this enumeration. - * @param value the string value to look for. - * @return the index of the value in the array of strings - * or -1 if it cannot be found. - * @see #getValues() - */ - public final int indexOfValue(String value) { - String[] values = getValues(); - if (values == null || value == null) { - return -1; - } - for (int i = 0; i < values.length; i++) { - if (value.equals(values[i])) { - return i; - } - } - return -1; - } - - /** - * @return the selected value. - */ - public final String getValue() { - return value; - } - - /** - * @return the index of the selected value in the array. - * @see #getValues() - */ - public final int getIndex() { - return index; - } - - /** - * Convert the value to its string form. - * - * @return the string form of the value. - */ - public String toString() { - return getValue(); - } - -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/Environment.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/Environment.java deleted file mode 100644 index 5bc6d79e..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/Environment.java +++ /dev/null @@ -1,177 +0,0 @@ -/* - * 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.util.Vector; - -import org.apache.tools.ant.BuildException; - -/** - * Wrapper for environment variables. - * - */ -public class Environment { - // CheckStyle:VisibilityModifier OFF - bc - - /** - * a vector of type Environment.Variable - * @see Variable - */ - protected Vector<Variable> variables; - - // CheckStyle:VisibilityModifier ON - - /** - * representation of a single env value - */ - public static class Variable { - - /** - * env key and value pair; everything gets expanded to a string - * during assignment - */ - private String key, value; - - /** - * Constructor for variable - * - */ - public Variable() { - super(); - } - - /** - * set the key - * @param key string - */ - public void setKey(String key) { - this.key = key; - } - - /** - * set the value - * @param value string value - */ - public void setValue(String value) { - this.value = value; - } - - /** - * key accessor - * @return key - */ - public String getKey() { - return this.key; - } - - /** - * value accessor - * @return value - */ - public String getValue() { - return this.value; - } - - /** - * stringify path and assign to the value. - * The value will contain all path elements separated by the appropriate - * separator - * @param path path - */ - public void setPath(Path path) { - this.value = path.toString(); - } - - /** - * get the absolute path of a file and assign it to the value - * @param file file to use as the value - */ - public void setFile(java.io.File file) { - this.value = file.getAbsolutePath(); - } - - /** - * get the assignment string - * This is not ready for insertion into a property file without following - * the escaping rules of the properties class. - * @return a string of the form key=value. - * @throws BuildException if key or value are unassigned - */ - public String getContent() throws BuildException { - validate(); - StringBuffer sb = new StringBuffer(key.trim()); - sb.append("=").append(value.trim()); - return sb.toString(); - } - - /** - * checks whether all required attributes have been specified. - * @throws BuildException if key or value are unassigned - */ - public void validate() { - if (key == null || value == null) { - throw new BuildException("key and value must be specified " - + "for environment variables."); - } - } - } - - /** - * constructor - */ - public Environment() { - variables = new Vector<Variable>(); - } - - /** - * add a variable. - * Validity checking is <i>not</i> performed at this point. Duplicates - * are not caught either. - * @param var new variable. - */ - public void addVariable(Variable var) { - variables.addElement(var); - } - - /** - * get the variable list as an array - * @return array of key=value assignment strings - * @throws BuildException if any variable is misconfigured - */ - public String[] getVariables() throws BuildException { - if (variables.size() == 0) { - return null; - } - String[] result = new String[variables.size()]; - for (int i = 0; i < result.length; i++) { - result[i] = ((Variable) variables.elementAt(i)).getContent(); - } - return result; - } - - /** - * Get the raw vector of variables. This is not a clone. - * @return a potentially empty (but never null) vector of elements of type - * Variable - * @since Ant 1.7 - */ - public Vector<Variable> getVariablesVector() { - return variables; - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/FileList.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/FileList.java deleted file mode 100644 index 42e27635..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/FileList.java +++ /dev/null @@ -1,219 +0,0 @@ -/* - * 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.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.StringTokenizer; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.types.resources.FileResourceIterator; - -/** - * FileList represents an explicitly named list of files. FileLists - * are useful when you want to capture a list of files regardless of - * whether they currently exist. By contrast, FileSet operates as a - * filter, only returning the name of a matched file if it currently - * exists in the file system. - */ -public class FileList extends DataType implements ResourceCollection { - - private List<String> filenames = new ArrayList<String>(); - private File dir; - - /** - * The default constructor. - * - */ - public FileList() { - super(); - } - - /** - * A copy constructor. - * - * @param filelist a <code>FileList</code> value - */ - protected FileList(FileList filelist) { - this.dir = filelist.dir; - this.filenames = filelist.filenames; - setProject(filelist.getProject()); - } - - /** - * Makes this instance in effect a reference to another FileList - * instance. - * - * <p>You must not set another attribute or nest elements inside - * this element if you make it a reference.</p> - * @param r the reference to another filelist. - * @exception BuildException if an error occurs. - */ - public void setRefid(Reference r) throws BuildException { - if ((dir != null) || (filenames.size() != 0)) { - throw tooManyAttributes(); - } - super.setRefid(r); - } - - /** - * Set the dir attribute. - * - * @param dir the directory this filelist is relative to. - * @exception BuildException if an error occurs - */ - public void setDir(File dir) throws BuildException { - checkAttributesAllowed(); - this.dir = dir; - } - - /** - * @param p the current project - * @return the directory attribute - */ - public File getDir(Project p) { - if (isReference()) { - return getRef(p).getDir(p); - } - return dir; - } - - /** - * Set the filenames attribute. - * - * @param filenames a string contains filenames, separated by , or - * by whitespace. - */ - public void setFiles(String filenames) { - checkAttributesAllowed(); - if (filenames != null && filenames.length() > 0) { - StringTokenizer tok = new StringTokenizer( - filenames, ", \t\n\r\f", false); - while (tok.hasMoreTokens()) { - this.filenames.add(tok.nextToken()); - } - } - } - - /** - * Returns the list of files represented by this FileList. - * @param p the current project - * @return the list of files represented by this FileList. - */ - public String[] getFiles(Project p) { - if (isReference()) { - return getRef(p).getFiles(p); - } - - if (dir == null) { - throw new BuildException("No directory specified for filelist."); - } - - if (filenames.size() == 0) { - throw new BuildException("No files specified for filelist."); - } - - return filenames.toArray(new String[filenames.size()]); - } - - /** - * Performs the check for circular references and returns the - * referenced FileList. - * @param p the current project - * @return the FileList represented by a referenced filelist. - */ - protected FileList getRef(Project p) { - return (FileList) getCheckedRef(p); - } - - /** - * Inner class corresponding to the <file> nested element. - */ - public static class FileName { - private String name; - - /** - * The name attribute of the file element. - * - * @param name the name of a file to add to the file list. - */ - public void setName(String name) { - this.name = name; - } - - /** - * @return the name of the file for this element. - */ - public String getName() { - return name; - } - } - - /** - * Add a nested <file> nested element. - * - * @param name a configured file element with a name. - * @since Ant 1.6.2 - */ - public void addConfiguredFile(FileName name) { - if (name.getName() == null) { - throw new BuildException( - "No name specified in nested file element"); - } - filenames.add(name.getName()); - } - - /** - * Fulfill the ResourceCollection contract. - * @return an Iterator of Resources. - * @since Ant 1.7 - */ - public Iterator<Resource> iterator() { - if (isReference()) { - return getRef(getProject()).iterator(); - } - return new FileResourceIterator(getProject(), dir, - filenames.toArray(new String[filenames.size()])); - } - - /** - * Fulfill the ResourceCollection contract. - * @return number of elements as int. - * @since Ant 1.7 - */ - public int size() { - if (isReference()) { - return ((FileList) getRef(getProject())).size(); - } - return filenames.size(); - } - - /** - * Always returns true. - * @return true indicating that all elements will be FileResources. - * @since Ant 1.7 - */ - public boolean isFilesystemOnly() { - return true; - } - -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/FileSet.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/FileSet.java deleted file mode 100644 index c6d2127d..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/FileSet.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * 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.util.Iterator; - -import org.apache.tools.ant.types.resources.FileResourceIterator; - -/** - * Moved out of MatchingTask to make it a standalone object that could - * be referenced (by scripts for example). - * - */ -public class FileSet extends AbstractFileSet implements ResourceCollection { - - /** - * Constructor for FileSet. - */ - public FileSet() { - super(); - } - - /** - * Constructor for FileSet, with FileSet to shallowly clone. - * @param fileset the fileset to clone - */ - protected FileSet(FileSet fileset) { - super(fileset); - } - - /** - * Return a FileSet that has the same basedir and same patternsets - * as this one. - * @return the cloned fileset - */ - public Object clone() { - if (isReference()) { - return ((FileSet) getRef(getProject())).clone(); - } else { - return super.clone(); - } - } - - /** - * Fulfill the ResourceCollection contract. - * @return an Iterator of Resources. - * @since Ant 1.7 - */ - public Iterator<Resource> iterator() { - if (isReference()) { - return ((FileSet) getRef(getProject())).iterator(); - } - return new FileResourceIterator(getProject(), getDir(getProject()), - getDirectoryScanner(getProject()).getIncludedFiles()); - } - - /** - * Fulfill the ResourceCollection contract. - * @return number of elements as int. - * @since Ant 1.7 - */ - public int size() { - if (isReference()) { - return ((FileSet) getRef(getProject())).size(); - } - return getDirectoryScanner(getProject()).getIncludedFilesCount(); - } - - /** - * Always returns true. - * @return true indicating that all elements will be FileResources. - * @since Ant 1.7 - */ - public boolean isFilesystemOnly() { - return true; - } - -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/FilterChain.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/FilterChain.java deleted file mode 100644 index b495a5a3..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/FilterChain.java +++ /dev/null @@ -1,418 +0,0 @@ -/* - * 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.util.Iterator; -import java.util.Stack; -import java.util.Vector; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.filters.ChainableReader; -import org.apache.tools.ant.filters.ClassConstants; -import org.apache.tools.ant.filters.EscapeUnicode; -import org.apache.tools.ant.filters.ExpandProperties; -import org.apache.tools.ant.filters.HeadFilter; -import org.apache.tools.ant.filters.LineContains; -import org.apache.tools.ant.filters.LineContainsRegExp; -import org.apache.tools.ant.filters.PrefixLines; -import org.apache.tools.ant.filters.ReplaceTokens; -import org.apache.tools.ant.filters.StripJavaComments; -import org.apache.tools.ant.filters.StripLineBreaks; -import org.apache.tools.ant.filters.StripLineComments; -import org.apache.tools.ant.filters.SuffixLines; -import org.apache.tools.ant.filters.TabsToSpaces; -import org.apache.tools.ant.filters.TailFilter; -import org.apache.tools.ant.filters.TokenFilter; - - -/** - * FilterChain may contain a chained set of filter readers. - * - */ -public class FilterChain extends DataType - implements Cloneable { - - private Vector<Object> filterReaders = new Vector<Object>(); - - /** - * Add an AntFilterReader filter. - * - * @param filterReader an <code>AntFilterReader</code> value - */ - public void addFilterReader(final AntFilterReader filterReader) { - if (isReference()) { - throw noChildrenAllowed(); - } - setChecked(false); - filterReaders.addElement(filterReader); - } - - /** - * Return the filters. - * - * @return a <code>Vector</code> value containing the filters - */ - public Vector<Object> getFilterReaders() { - if (isReference()) { - return ((FilterChain) getCheckedRef()).getFilterReaders(); - } - dieOnCircularReference(); - return filterReaders; - } - - /** - * Add a ClassConstants filter. - * - * @param classConstants a <code>ClassConstants</code> value - */ - public void addClassConstants(final ClassConstants classConstants) { - if (isReference()) { - throw noChildrenAllowed(); - } - setChecked(false); - filterReaders.addElement(classConstants); - } - - /** - * Add an ExpandProperties filter. - * - * @param expandProperties an <code>ExpandProperties</code> value - */ - public void addExpandProperties(final ExpandProperties expandProperties) { - if (isReference()) { - throw noChildrenAllowed(); - } - setChecked(false); - filterReaders.addElement(expandProperties); - } - - /** - * Add a HeadFilter filter. - * - * @param headFilter a <code>HeadFilter</code> value - */ - public void addHeadFilter(final HeadFilter headFilter) { - if (isReference()) { - throw noChildrenAllowed(); - } - setChecked(false); - filterReaders.addElement(headFilter); - } - - /** - * Add a LineContains filter. - * - * @param lineContains a <code>LineContains</code> value - */ - public void addLineContains(final LineContains lineContains) { - if (isReference()) { - throw noChildrenAllowed(); - } - setChecked(false); - filterReaders.addElement(lineContains); - } - - /** - * Add a LineContainsRegExp filter. - * - * @param lineContainsRegExp a <code>LineContainsRegExp</code> value - */ - public void addLineContainsRegExp(final LineContainsRegExp - lineContainsRegExp) { - if (isReference()) { - throw noChildrenAllowed(); - } - setChecked(false); - filterReaders.addElement(lineContainsRegExp); - } - - /** - * Add a PrefixLines filter. - * - * @param prefixLines a <code>PrefixLines</code> value - */ - public void addPrefixLines(final PrefixLines prefixLines) { - if (isReference()) { - throw noChildrenAllowed(); - } - setChecked(false); - filterReaders.addElement(prefixLines); - } - - /** - * Add a SuffixLines filter. - * - * @param suffixLines a <code>SuffixLines</code> value - * @since Ant 1.8.0 - */ - public void addSuffixLines(final SuffixLines suffixLines) { - if (isReference()) { - throw noChildrenAllowed(); - } - setChecked(false); - filterReaders.addElement(suffixLines); - } - - /** - * Add a ReplaceTokens filter. - * - * @param replaceTokens a <code>ReplaceTokens</code> value - */ - public void addReplaceTokens(final ReplaceTokens replaceTokens) { - if (isReference()) { - throw noChildrenAllowed(); - } - setChecked(false); - filterReaders.addElement(replaceTokens); - } - - /** - * Add a StripJavaCommands filter. - * - * @param stripJavaComments a <code>StripJavaComments</code> value - */ - public void addStripJavaComments(final StripJavaComments - stripJavaComments) { - if (isReference()) { - throw noChildrenAllowed(); - } - setChecked(false); - filterReaders.addElement(stripJavaComments); - } - - /** - * Add a StripLineBreaks filter. - * - * @param stripLineBreaks a <code>StripLineBreaks</code> value - */ - public void addStripLineBreaks(final StripLineBreaks - stripLineBreaks) { - if (isReference()) { - throw noChildrenAllowed(); - } - setChecked(false); - filterReaders.addElement(stripLineBreaks); - } - - /** - * Add a StripLineComments filter. - * - * @param stripLineComments a <code>StripLineComments</code> value - */ - public void addStripLineComments(final StripLineComments - stripLineComments) { - if (isReference()) { - throw noChildrenAllowed(); - } - setChecked(false); - filterReaders.addElement(stripLineComments); - } - - /** - * Add a TabsToSpaces filter. - * - * @param tabsToSpaces a <code>TabsToSpaces</code> value - */ - public void addTabsToSpaces(final TabsToSpaces tabsToSpaces) { - if (isReference()) { - throw noChildrenAllowed(); - } - setChecked(false); - filterReaders.addElement(tabsToSpaces); - } - - /** - * Add a TailFilter filter. - * - * @param tailFilter a <code>TailFilter</code> value - */ - public void addTailFilter(final TailFilter tailFilter) { - if (isReference()) { - throw noChildrenAllowed(); - } - setChecked(false); - filterReaders.addElement(tailFilter); - } - - /** - * Add an EscapeUnicode filter. - * - * @param escapeUnicode an <code>EscapeUnicode</code> value - * @since Ant 1.6 - */ - public void addEscapeUnicode(final EscapeUnicode escapeUnicode) { - if (isReference()) { - throw noChildrenAllowed(); - } - setChecked(false); - filterReaders.addElement(escapeUnicode); - } - - /** - * Add a TokenFilter filter. - * - * @param tokenFilter a <code>TokenFilter</code> value - * @since Ant 1.6 - */ - public void addTokenFilter(final TokenFilter tokenFilter) { - if (isReference()) { - throw noChildrenAllowed(); - } - setChecked(false); - filterReaders.addElement(tokenFilter); - } - - /** - * Add a delete characters filter. - * - * @param filter a <code>TokenFilter.DeleteCharacters</code> value - * @since Ant 1.6 - */ - public void addDeleteCharacters(TokenFilter.DeleteCharacters filter) { - if (isReference()) { - throw noChildrenAllowed(); - } - setChecked(false); - filterReaders.addElement(filter); - } - - /** - * Add a containsregex filter. - * - * @param filter a <code>TokenFilter.ContainsRegex</code> value - * @since Ant 1.6 - */ - public void addContainsRegex(TokenFilter.ContainsRegex filter) { - if (isReference()) { - throw noChildrenAllowed(); - } - setChecked(false); - filterReaders.addElement(filter); - } - - /** - * Add a replaceregex filter. - * - * @param filter a <code>TokenFilter.ReplaceRegex</code> value - */ - public void addReplaceRegex(TokenFilter.ReplaceRegex filter) { - if (isReference()) { - throw noChildrenAllowed(); - } - setChecked(false); - filterReaders.addElement(filter); - } - - /** - * Add a trim filter. - * - * @param filter a <code>TokenFilter.Trim</code> value - * @since Ant 1.6 - */ - public void addTrim(TokenFilter.Trim filter) { - if (isReference()) { - throw noChildrenAllowed(); - } - setChecked(false); - filterReaders.addElement(filter); - } - - /** - * Add a replacestring filter. - * - * @param filter a <code>TokenFilter.ReplaceString</code> value - * @since Ant 1.6 - */ - public void addReplaceString( - TokenFilter.ReplaceString filter) { - if (isReference()) { - throw noChildrenAllowed(); - } - setChecked(false); - filterReaders.addElement(filter); - } - - /** - * Add an ignoreBlank filter. - * - * @param filter a <code>TokenFilter.IgnoreBlank</code> value - * @since Ant 1.6 - */ - public void addIgnoreBlank( - TokenFilter.IgnoreBlank filter) { - if (isReference()) { - throw noChildrenAllowed(); - } - setChecked(false); - filterReaders.addElement(filter); - } - - - /** - * Makes this instance in effect a reference to another FilterChain - * instance. - * - * <p>You must not set another attribute or nest elements inside - * this element if you make it a reference.</p> - * - * @param r the reference to which this instance is associated - * @exception BuildException if this instance already has been configured. - */ - @Override - public void setRefid(Reference r) throws BuildException { - if (!filterReaders.isEmpty()) { - throw tooManyAttributes(); - } - super.setRefid(r); - } - - /** - * Add a chainfilter filter. - * - * @param filter a <code>ChainableReader</code> value - * @since Ant 1.6 - */ - - public void add(ChainableReader filter) { - if (isReference()) { - throw noChildrenAllowed(); - } - setChecked(false); - filterReaders.addElement(filter); - } - - @Override - protected synchronized void dieOnCircularReference(Stack<Object> stk, Project p) - throws BuildException { - if (isChecked()) { - return; - } - if (isReference()) { - super.dieOnCircularReference(stk, p); - } else { - for (Iterator<Object> i = filterReaders.iterator(); i.hasNext();) { - Object o = i.next(); - if (o instanceof DataType) { - pushAndInvokeCircularReferenceCheck((DataType) o, stk, p); - } - } - setChecked(true); - } - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/FilterSet.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/FilterSet.java deleted file mode 100644 index 2c1f2e71..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/FilterSet.java +++ /dev/null @@ -1,654 +0,0 @@ -/* - * 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.Map; -import java.util.Properties; -import java.util.Set; -import java.util.Vector; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.util.FileUtils; -import org.apache.tools.ant.util.VectorSet; - -/** - * 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 constructor. - */ - 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}. */ - @Override - 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<String> passedTokens; - /** if a duplicate token is found, this is set to true */ - private boolean duplicateToken = false; - - private boolean recurse = true; - private Hashtable<String, String> filterHash = null; - private Vector<File> filtersFiles = new Vector<File>(); - private OnMissing onMissingFiltersFile = OnMissing.FAIL; - private boolean readingFiles = false; - - private int recurseDepth = 0; - - /** - * List of ordered filters and filter files. - */ - private Vector<Filter> filters = new Vector<Filter>(); - - /** - * 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(); - @SuppressWarnings("unchecked") - Vector<Filter> clone = (Vector<Filter>) filterset.getFilters().clone(); - this.filters = clone; - } - - /** - * Get the filters in the filter set. - * - * @return a Vector of Filter instances. - */ - protected synchronized Vector<Filter> getFilters() { - if (isReference()) { - return getRef().getFilters(); - } - dieOnCircularReference(); - //silly hack to avoid stack overflow... - if (!readingFiles) { - readingFiles = true; - final int size = filtersFiles.size(); - for (int i = 0; i < size; i++) { - readFiltersFromFile(filtersFiles.get(i)); - } - filtersFiles.clear(); - readingFiles = false; - } - return filters; - } - - /** - * Get the referenced filter set. - * - * @return the filterset from the reference. - */ - protected FilterSet getRef() { - return 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<String, String> getFilterHash() { - if (isReference()) { - return getRef().getFilterHash(); - } - dieOnCircularReference(); - if (filterHash == null) { - filterHash = new Hashtable<String, String>(getFilters().size()); - for (Enumeration<Filter> e = getFilters().elements(); e.hasMoreElements();) { - 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)) { - throw new BuildException("endToken must not be empty"); - } - this.endOfToken = endOfToken; - } - - /** - * Get the end token for this filterset. - * - * @return the filter set's end token for replacement delimiting. - */ - public String getEndToken() { - if (isReference()) { - return getRef().getEndToken(); - } - return endOfToken; - } - - /** - * Set whether recursive token expansion is enabled. - * @param recurse <code>boolean</code> whether to recurse. - */ - public void setRecurse(boolean recurse) { - this.recurse = recurse; - } - - /** - * Get whether recursive token expansion is enabled. - * @return <code>boolean</code> whether enabled. - */ - public boolean isRecurse() { - return recurse; - } - - /** - * Read the filters from the given file. - * - * @param filtersFile the file from which filters are read. - * @exception BuildException when the file cannot be read. - */ - public synchronized void readFiltersFromFile(File filtersFile) throws BuildException { - if (isReference()) { - throw tooManyAttributes(); - } - if (!filtersFile.exists()) { - handleMissingFile("Could not read filters from file " - + filtersFile + " as it doesn't exist."); - } - if (filtersFile.isFile()) { - log("Reading filters from " + filtersFile, Project.MSG_VERBOSE); - FileInputStream in = null; - try { - Properties props = new Properties(); - in = new FileInputStream(filtersFile); - props.load(in); - - Enumeration<?> e = props.propertyNames(); - Vector<Filter> filts = getFilters(); - while (e.hasMoreElements()) { - String strPropName = (String) e.nextElement(); - String strValue = props.getProperty(strPropName); - filts.addElement(new Filter(strPropName, strValue)); - } - } catch (Exception ex) { - throw new BuildException("Could not read filters from file: " - + filtersFile, ex); - } finally { - FileUtils.close(in); - } - } else { - handleMissingFile( - "Must specify a file rather than a directory in " - + "the filtersfile attribute:" + filtersFile); - } - filterHash = null; - } - - /** - * Does replacement on the given string with token matching. - * This uses the defined begintoken and endtoken values which default - * to @ for both. - * This resets the passedTokens and calls iReplaceTokens to - * do the actual replacements. - * - * @param line The line in which to process embedded tokens. - * @return The input string after token replacement. - */ - public synchronized String replaceTokens(String line) { - return iReplaceTokens(line); - } - - /** - * Add a new filter. - * - * @param filter the filter to be added. - */ - public synchronized void addFilter(Filter filter) { - if (isReference()) { - throw noChildrenAllowed(); - } - filters.addElement(filter); - filterHash = null; - } - - /** - * Create a new FiltersFile. - * - * @return The filtersfile that was created. - */ - public FiltersFile createFiltersfile() { - if (isReference()) { - throw noChildrenAllowed(); - } - return new FiltersFile(); - } - - /** - * Add a new filter made from the given token and value. - * - * @param token The token for the new filter. - * @param value The value for the new filter. - */ - public synchronized void addFilter(String token, String value) { - if (isReference()) { - throw noChildrenAllowed(); - } - addFilter(new Filter(token, value)); - } - - /** - * Add a Filterset to this filter set. - * - * @param filterSet the filterset to be added to this filterset - */ - public synchronized void addConfiguredFilterSet(FilterSet filterSet) { - if (isReference()) { - throw noChildrenAllowed(); - } - for (Filter filter : filterSet.getFilters()) { - addFilter(filter); - } - } - - /** - * Adds the properties provided by the specified PropertySet to this filterset. - * - * @param propertySet the propertyset to be added to this propertyset - */ - public synchronized void addConfiguredPropertySet(PropertySet propertySet) { - if (isReference()) { - throw noChildrenAllowed(); - } - Properties p = propertySet.getProperties(); - Set<Map.Entry<Object,Object>> entries = p.entrySet(); - for (Map.Entry<Object, Object> entry : entries) { - addFilter(new Filter(String.valueOf(entry.getKey()), - String.valueOf(entry.getValue()))); - } - } - - /** - * Test to see if this filter set has filters. - * - * @return Return true if there are filters in this set. - */ - public synchronized boolean hasFilters() { - return getFilters().size() > 0; - } - - /** - * Clone the filterset. - * - * @return a deep clone of this filterset. - * - * @throws BuildException if the clone cannot be performed. - */ - @Override - public synchronized Object clone() throws BuildException { - if (isReference()) { - return getRef().clone(); - } - try { - FilterSet fs = (FilterSet) super.clone(); - @SuppressWarnings("unchecked") - Vector<Filter> clonedFilters = (Vector<Filter>) getFilters().clone(); - fs.filters = clonedFilters; - fs.setProject(getProject()); - return fs; - } catch (CloneNotSupportedException e) { - throw new BuildException(e); - } - } - - /** - * Set the behavior WRT missing filtersfiles. - * @param onMissingFiltersFile the OnMissing describing the behavior. - */ - public void setOnMissingFiltersFile(OnMissing onMissingFiltersFile) { - this.onMissingFiltersFile = onMissingFiltersFile; - } - - /** - * Get the onMissingFiltersFile setting. - * @return the OnMissing instance. - */ - public OnMissing getOnMissingFiltersFile() { - return onMissingFiltersFile; - } - - /** - * Does replacement on the given string with token matching. - * This uses the defined begintoken and endtoken values which default - * to @ for both. - * - * @param line The line to process the tokens in. - * @return The string with the tokens replaced. - */ - private synchronized String iReplaceTokens(String line) { - String beginToken = getBeginToken(); - String endToken = getEndToken(); - int index = line.indexOf(beginToken); - - if (index > -1) { - Hashtable<String, String> tokens = getFilterHash(); - try { - StringBuilder b = new StringBuilder(); - int i = 0; - String token = null; - String value = null; - - while (index > -1) { - //can't have zero-length token - int endIndex = line.indexOf(endToken, - index + beginToken.length() + 1); - if (endIndex == -1) { - break; - } - token - = line.substring(index + beginToken.length(), endIndex); - b.append(line.substring(i, index)); - if (tokens.containsKey(token)) { - value = tokens.get(token); - if (recurse && !value.equals(token)) { - // we have another token, let's parse it. - value = replaceTokens(value, token); - } - log("Replacing: " + beginToken + token + endToken - + " -> " + value, Project.MSG_VERBOSE); - b.append(value); - i = index + beginToken.length() + token.length() - + endToken.length(); - } else { - // just append first character of beginToken - // and search further - // we can't skip the complete beginToken since - // it may contain the start of another - // candidate begin token (Bugzilla 45094) - b.append(beginToken.charAt(0)); - i = index + 1; - } - index = line.indexOf(beginToken, i); - } - - b.append(line.substring(i)); - return b.toString(); - } catch (StringIndexOutOfBoundsException e) { - return line; - } - } else { - return line; - } - } - - /** - * This parses tokens which point to tokens. - * It also maintains a list of currently used tokens, so we cannot - * get into an infinite loop. - * @param line the value / token to parse. - * @param parent the parent token (= the token it was parsed from). - */ - private synchronized String replaceTokens(String line, String parent) - throws BuildException { - String beginToken = getBeginToken(); - String endToken = getEndToken(); - if (recurseDepth == 0) { - passedTokens = new VectorSet<String>(); - } - recurseDepth++; - if (passedTokens.contains(parent) && !duplicateToken) { - duplicateToken = true; - System.out.println( - "Infinite loop in tokens. Currently known tokens : " - + passedTokens.toString() + "\nProblem token : " + beginToken - + parent + endToken + " called from " + beginToken - + passedTokens.lastElement().toString() + endToken); - recurseDepth--; - return parent; - } - passedTokens.addElement(parent); - String value = iReplaceTokens(line); - if (value.indexOf(beginToken) == -1 && !duplicateToken - && recurseDepth == 1) { - passedTokens = null; - } else if (duplicateToken) { - // should always be the case... - if (passedTokens.size() > 0) { - value = passedTokens.remove(passedTokens.size() - 1); - if (passedTokens.size() == 0) { - value = beginToken + value + endToken; - duplicateToken = false; - } - } - } else if (passedTokens.size() > 0) { - // remove last seen token when crawling out of recursion - passedTokens.remove(passedTokens.size() - 1); - } - recurseDepth--; - return value; - } - - private void handleMissingFile(String message) { - switch (onMissingFiltersFile.getIndex()) { - case OnMissing.IGNORE_INDEX: - return; - case OnMissing.FAIL_INDEX: - throw new BuildException(message); - case OnMissing.WARN_INDEX: - log(message, Project.MSG_WARN); - return; - default: - throw new BuildException("Invalid value for onMissingFiltersFile"); - } - } - -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/FilterSetCollection.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/FilterSetCollection.java deleted file mode 100644 index 8afb9631..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/FilterSetCollection.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * 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.util.ArrayList; -import java.util.List; - - -/** - * A FilterSetCollection is a collection of filtersets each of which may have - * a different start/end token settings. - * - */ -public class FilterSetCollection { - - private List<FilterSet> filterSets = new ArrayList<FilterSet>(); - - /** - * Constructor for a FilterSetCollection. - */ - public FilterSetCollection() { - } - - /** - * Constructor for a FilterSetCollection. - * @param filterSet a filterset to start the collection with - */ - public FilterSetCollection(FilterSet filterSet) { - addFilterSet(filterSet); - } - - - /** - * Add a filterset to the collection. - * - * @param filterSet a <code>FilterSet</code> value - */ - public void addFilterSet(FilterSet filterSet) { - filterSets.add(filterSet); - } - - /** - * Does replacement on the given string with token matching. - * This uses the defined begintoken and endtoken values which default to @ for both. - * - * @param line The line to process the tokens in. - * @return The string with the tokens replaced. - */ - public String replaceTokens(String line) { - String replacedLine = line; - for (FilterSet filterSet : filterSets) { - replacedLine = filterSet.replaceTokens(replacedLine); - } - return replacedLine; - } - - /** - * Test to see if this filter set it empty. - * - * @return Return true if there are filter in this set otherwise false. - */ - public boolean hasFilters() { - for (FilterSet filterSet : filterSets) { - if (filterSet.hasFilters()) { - return true; - } - } - return false; - } -} - - - diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/FlexInteger.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/FlexInteger.java deleted file mode 100644 index d757429f..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/FlexInteger.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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; - -/** - * Helper class which can be used for Ant task attribute setter methods to allow - * the build file to specify an integer in either decimal, octal, or hexadecimal - * format. - * - * @see java.lang.Integer#decode(String) - */ -public class FlexInteger { - private Integer value; - - /** - * Constructor used by Ant's introspection mechanism for attribute population - * @param value the value to decode - */ - public FlexInteger(String value) { - this.value = Integer.decode(value); - } - - /** - * Returns the decimal integer value - * @return the integer value - */ - public int intValue() { - return value.intValue(); - } - - /** - * Overridden method to return the decimal value for display - * @return a string version of the integer - */ - public String toString() { - return value.toString(); - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/LogLevel.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/LogLevel.java deleted file mode 100644 index a02b948e..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/LogLevel.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * 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 org.apache.tools.ant.Project; - -/** - * The enumerated values for Ant's log level. - */ -public class LogLevel extends EnumeratedAttribute { - - /** ERR loglevel constant. */ - public static final LogLevel ERR = new LogLevel("error"); - - /** WARN loglevel constant. */ - public static final LogLevel WARN = new LogLevel("warn"); - - /** INFO loglevel constant. */ - public static final LogLevel INFO = new LogLevel("info"); - - /** VERBOSE loglevel constant. */ - public static final LogLevel VERBOSE = new LogLevel("verbose"); - - /** DEBUG loglevel constant. */ - public static final LogLevel DEBUG = new LogLevel("debug"); - - /** - * Public constructor. - */ - public LogLevel() { - } - - private LogLevel(String value) { - this(); - setValue(value); - } - - /** - * @see EnumeratedAttribute#getValues - * @return the strings allowed for the level attribute - */ - public String[] getValues() { - return new String[] { - "error", - "warn", - "warning", - "info", - "verbose", - "debug"}; - } - - /** - * mapping of enumerated values to log levels - */ - private static int[] levels = { - Project.MSG_ERR, - Project.MSG_WARN, - Project.MSG_WARN, - Project.MSG_INFO, - Project.MSG_VERBOSE, - Project.MSG_DEBUG - }; - - /** - * get the level of the echo of the current value - * @return the level - */ - public int getLevel() { - return levels[getIndex()]; - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/Mapper.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/Mapper.java deleted file mode 100644 index 941e8dd8..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/Mapper.java +++ /dev/null @@ -1,322 +0,0 @@ -/* - * 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.util.Properties; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.util.CompositeMapper; -import org.apache.tools.ant.util.ContainerMapper; -import org.apache.tools.ant.util.FileNameMapper; - -/** - * Element to define a FileNameMapper. - * - */ -public class Mapper extends DataType implements Cloneable { - // CheckStyle:VisibilityModifier OFF - bc - - protected MapperType type = null; - protected String classname = null; - protected Path classpath = null; - protected String from = null; - protected String to = null; - - // CheckStyle:VisibilityModifier ON - - private ContainerMapper container = null; - - /** - * Construct a new <code>Mapper</code> element. - * @param p the owning Ant <code>Project</code>. - */ - public Mapper(Project p) { - setProject(p); - } - - /** - * Set the type of <code>FileNameMapper</code> to use. - * @param type the <code>MapperType</code> enumerated attribute. - */ - public void setType(MapperType type) { - if (isReference()) { - throw tooManyAttributes(); - } - this.type = type; - } - - /** - * Cannot mix add and addconfigured in same type, so - * provide this to override the add method. - * @param fileNameMapper the <code>FileNameMapper</code> to add. - */ - public void addConfigured(FileNameMapper fileNameMapper) { - add(fileNameMapper); - } - - /** - * Add a nested <code>FileNameMapper</code>. - * @param fileNameMapper the <code>FileNameMapper</code> to add. - */ - public void add(FileNameMapper fileNameMapper) { - if (isReference()) { - throw noChildrenAllowed(); - } - if (container == null) { - if (type == null && classname == null) { - container = new CompositeMapper(); - } else { - FileNameMapper m = getImplementation(); - if (m instanceof ContainerMapper) { - container = (ContainerMapper) m; - } else { - throw new BuildException(String.valueOf(m) - + " mapper implementation does not support nested mappers!"); - } - } - } - container.add(fileNameMapper); - setChecked(false); - } - - /** - * Add a Mapper - * @param mapper the mapper to add - */ - public void addConfiguredMapper(Mapper mapper) { - add(mapper.getImplementation()); - } - - /** - * Set the class name of the FileNameMapper to use. - * @param classname the name of the class - */ - public void setClassname(String classname) { - if (isReference()) { - throw tooManyAttributes(); - } - this.classname = classname; - } - - /** - * Set the classpath to load the FileNameMapper through (attribute). - * @param classpath the classpath - */ - public void setClasspath(Path classpath) { - if (isReference()) { - throw tooManyAttributes(); - } - if (this.classpath == null) { - this.classpath = classpath; - } else { - this.classpath.append(classpath); - } - } - - /** - * Set the classpath to load the FileNameMapper through (nested element). - * @return a path object to be configured - */ - public Path createClasspath() { - if (isReference()) { - throw noChildrenAllowed(); - } - if (this.classpath == null) { - this.classpath = new Path(getProject()); - } - setChecked(false); - return this.classpath.createPath(); - } - - /** - * Set the classpath to load the FileNameMapper through via - * reference (attribute). - * @param ref the reference to the FileNameMapper - */ - public void setClasspathRef(Reference ref) { - if (isReference()) { - throw tooManyAttributes(); - } - createClasspath().setRefid(ref); - } - - /** - * Set the argument to FileNameMapper.setFrom - * @param from the from attribute to pass to the FileNameMapper - */ - public void setFrom(String from) { - if (isReference()) { - throw tooManyAttributes(); - } - this.from = from; - } - - /** - * Set the argument to FileNameMapper.setTo - * @param to the to attribute to pass to the FileNameMapper - */ - public void setTo(String to) { - if (isReference()) { - throw tooManyAttributes(); - } - this.to = to; - } - - /** - * Make this Mapper instance a reference to another Mapper. - * - * <p>You must not set any other attribute if you make it a - * reference.</p> - * @param r the reference to another mapper - * @throws BuildException if other attributes are set - */ - public void setRefid(Reference r) throws BuildException { - if (type != null || from != null || to != null) { - throw tooManyAttributes(); - } - super.setRefid(r); - } - - /** - * Returns a fully configured FileNameMapper implementation. - * @return a FileNameMapper object to be configured - * @throws BuildException on error - */ - public FileNameMapper getImplementation() throws BuildException { - if (isReference()) { - dieOnCircularReference(); - Reference r = getRefid(); - Object o = r.getReferencedObject(getProject()); - if (o instanceof FileNameMapper) { - return (FileNameMapper) o; - } - if (o instanceof Mapper) { - return ((Mapper) o).getImplementation(); - } - String od = o == null ? "null" : o.getClass().getName(); - throw new BuildException(od + " at reference '" - + r.getRefId() + "' is not a valid mapper reference."); - } - - if (type == null && classname == null && container == null) { - throw new BuildException( - "nested mapper or " - + "one of the attributes type or classname is required"); - } - - if (container != null) { - return container; - } - - if (type != null && classname != null) { - throw new BuildException( - "must not specify both type and classname attribute"); - } - - try { - FileNameMapper m = getImplementationClass().newInstance(); - final Project p = getProject(); - if (p != null) { - p.setProjectReference(m); - } - m.setFrom(from); - m.setTo(to); - - return m; - } catch (BuildException be) { - throw be; - } catch (Throwable t) { - throw new BuildException(t); - } - } - - /** - * Gets the Class object associated with the mapper implementation. - * @return <code>Class</code>. - * @throws ClassNotFoundException if the class cannot be found - */ - protected Class<? extends FileNameMapper> getImplementationClass() throws ClassNotFoundException { - - String cName = this.classname; - if (type != null) { - cName = type.getImplementation(); - } - - ClassLoader loader = (classpath == null) - ? getClass().getClassLoader() - // Memory leak in line below - : getProject().createClassLoader(classpath); - - return Class.forName(cName, true, loader).asSubclass(FileNameMapper.class); - } - - /** - * Performs the check for circular references and returns the - * referenced Mapper. - * @deprecated since Ant 1.7.1 because a mapper might ref a - * FileNameMapper implementation directly. - * @return the referenced Mapper - */ - protected Mapper getRef() { - return getCheckedRef(Mapper.class, getDataTypeName()); - } - - /** - * Class as Argument to FileNameMapper.setType. - */ - public static class MapperType extends EnumeratedAttribute { - private Properties implementations; - - /** Constructor for the MapperType enumeration */ - public MapperType() { - implementations = new Properties(); - implementations.put("identity", - "org.apache.tools.ant.util.IdentityMapper"); - implementations.put("flatten", - "org.apache.tools.ant.util.FlatFileNameMapper"); - implementations.put("glob", - "org.apache.tools.ant.util.GlobPatternMapper"); - implementations.put("merge", - "org.apache.tools.ant.util.MergingMapper"); - implementations.put("regexp", - "org.apache.tools.ant.util.RegexpPatternMapper"); - implementations.put("package", - "org.apache.tools.ant.util.PackageNameMapper"); - implementations.put("unpackage", - "org.apache.tools.ant.util.UnPackageNameMapper"); - } - - /** - * @return the filenamemapper names - */ - public String[] getValues() { - return new String[] {"identity", "flatten", "glob", - "merge", "regexp", "package", "unpackage"}; - } - - /** - * @return the classname for the filenamemapper name - */ - public String getImplementation() { - return implementations.getProperty(getValue()); - } - } - -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/Parameter.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/Parameter.java deleted file mode 100644 index 6c16d2d9..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/Parameter.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * 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; - -/** - * A parameter is composed of a name, type and value. - * - */ -public final class Parameter { - private String name = null; - private String type = null; - private String value = null; - - /** - * Set the name attribute. - * - * @param name a <code>String</code> value - */ - public void setName(final String name) { - this.name = name; - } - - /** - * Set the type attribute. - * - * @param type a <code>String</code> value - */ - public void setType(final String type) { - this.type = type; - } - - /** - * Set the value attribute. - * - * @param value a <code>String</code> value - */ - public void setValue(final String value) { - this.value = value; - } - - /** - * Get the name attribute. - * - * @return a <code>String</code> value - */ - public String getName() { - return name; - } - - /** - * Get the type attribute. - * - * @return a <code>String</code> value - */ - public String getType() { - return type; - } - - /** - * Get the value attribute. - * - * @return a <code>String</code> value - */ - public String getValue() { - return value; - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/Parameterizable.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/Parameterizable.java deleted file mode 100644 index 7945a9a6..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/Parameterizable.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * 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; - -/** - * Parameterizable objects take generic key value pairs. - * - */ -public interface Parameterizable { - /** - * Set the parameters - * - * @param parameters an array of name/type/value parameters. - */ - void setParameters(Parameter[] parameters); -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/Path.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/Path.java deleted file mode 100644 index db6f5e9f..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/Path.java +++ /dev/null @@ -1,775 +0,0 @@ -/* - * 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.lang.reflect.Method; -import java.util.Collections; -import java.util.Iterator; -import java.util.Locale; -import java.util.Stack; -import java.util.Vector; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.MagicNames; -import org.apache.tools.ant.PathTokenizer; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.types.resources.FileResourceIterator; -import org.apache.tools.ant.types.resources.Union; -import org.apache.tools.ant.util.FileUtils; -import org.apache.tools.ant.util.JavaEnvUtils; - -/** - * This object represents a path as used by CLASSPATH or PATH - * environment variable. A path might also be described as a collection - * of unique filesystem resources. - * <p> - * <code> - * <sometask><br> - * <somepath><br> - * <pathelement location="/path/to/file.jar" /><br> - * <pathelement - * path="/path/to/file2.jar:/path/to/class2;/path/to/class3" /> - * <br> - * <pathelement location="/path/to/file3.jar" /><br> - * <pathelement location="/path/to/file4.jar" /><br> - * </somepath><br> - * </sometask><br> - * </code> - * <p> - * The object implementation <code>sometask</code> must provide a method called - * <code>createSomepath</code> which returns an instance of <code>Path</code>. - * Nested path definitions are handled by the Path object and must be labeled - * <code>pathelement</code>.<p> - * - * The path element takes a parameter <code>path</code> which will be parsed - * and split into single elements. It will usually be used - * to define a path from an environment variable. - */ - -public class Path extends DataType implements Cloneable, ResourceCollection { - // CheckStyle:VisibilityModifier OFF - bc - - /** The system classpath as a Path object */ - public static Path systemClasspath = - new Path(null, System.getProperty("java.class.path")); - - - /** - * The system bootclasspath as a Path object. - * - * @since Ant 1.6.2 - */ - public static Path systemBootClasspath = - new Path(null, System.getProperty("sun.boot.class.path")); - - // CheckStyle:VisibilityModifier OFF - bc - - /** - * Helper class, holds the nested <code><pathelement></code> values. - */ - public class PathElement implements ResourceCollection { - private String[] parts; - - /** - * Set the location. - * - * @param loc a <code>File</code> value - */ - public void setLocation(File loc) { - parts = new String[] {translateFile(loc.getAbsolutePath())}; - } - - /** - * Set the path. - * - * @param path a <code>String</code> value - */ - public void setPath(String path) { - parts = Path.translatePath(getProject(), path); - } - - /** - * Return the converted pathelements. - * - * @return a <code>String[]</code> value - */ - public String[] getParts() { - return parts; - } - - /** - * Create an iterator. - * @return an iterator. - */ - public Iterator<Resource> iterator() { - return new FileResourceIterator(getProject(), null, parts); - } - - /** - * Check if this resource is only for filesystems. - * @return true. - */ - public boolean isFilesystemOnly() { - return true; - } - - /** - * Get the number of resources. - * @return the number of parts. - */ - public int size() { - return parts == null ? 0 : parts.length; - } - - } - - private Boolean preserveBC; - - private Union union = null; - private boolean cache = false; - - /** - * Invoked by IntrospectionHelper for <code>setXXX(Path p)</code> - * attribute setters. - * @param p the <code>Project</code> for this path. - * @param path the <code>String</code> path definition. - */ - public Path(Project p, String path) { - this(p); - createPathElement().setPath(path); - } - - /** - * Construct an empty <code>Path</code>. - * @param project the <code>Project</code> for this path. - */ - public Path(Project project) { - setProject(project); - } - - /** - * Adds a element definition to the path. - * @param location the location of the element to add (must not be - * <code>null</code> nor empty. - * @throws BuildException on error - */ - public void setLocation(File location) throws BuildException { - checkAttributesAllowed(); - createPathElement().setLocation(location); - } - - /** - * Parses a path definition and creates single PathElements. - * @param path the <code>String</code> path definition. - * @throws BuildException on error - */ - public void setPath(String path) throws BuildException { - checkAttributesAllowed(); - createPathElement().setPath(path); - } - - /** - * Makes this instance in effect a reference to another Path instance. - * - * <p>You must not set another attribute or nest elements inside - * this element if you make it a reference.</p> - * @param r the reference to another Path - * @throws BuildException on error - */ - public void setRefid(Reference r) throws BuildException { - if (union != null) { - throw tooManyAttributes(); - } - super.setRefid(r); - } - - /** - * Creates the nested <code><pathelement></code> element. - * @return the <code>PathElement</code> to be configured - * @throws BuildException on error - */ - public PathElement createPathElement() throws BuildException { - if (isReference()) { - throw noChildrenAllowed(); - } - PathElement pe = new PathElement(); - add(pe); - return pe; - } - - /** - * Adds a nested <code><fileset></code> element. - * @param fs a <code>FileSet</code> to be added to the path - * @throws BuildException on error - */ - public void addFileset(FileSet fs) throws BuildException { - if (fs.getProject() == null) { - fs.setProject(getProject()); - } - add(fs); - } - - /** - * Adds a nested <code><filelist></code> element. - * @param fl a <code>FileList</code> to be added to the path - * @throws BuildException on error - */ - public void addFilelist(FileList fl) throws BuildException { - if (fl.getProject() == null) { - fl.setProject(getProject()); - } - add(fl); - } - - /** - * Adds a nested <code><dirset></code> element. - * @param dset a <code>DirSet</code> to be added to the path - * @throws BuildException on error - */ - public void addDirset(DirSet dset) throws BuildException { - if (dset.getProject() == null) { - dset.setProject(getProject()); - } - add(dset); - } - - /** - * Adds a nested path - * @param path a <code>Path</code> to be added to the path - * @throws BuildException on error - * @since Ant 1.6 - */ - public void add(Path path) throws BuildException { - if (path == this) { - throw circularReference(); - } - if (path.getProject() == null) { - path.setProject(getProject()); - } - add((ResourceCollection) path); - } - - /** - * Add a nested <code>ResourceCollection</code>. - * @param c the ResourceCollection to add. - * @since Ant 1.7 - */ - public void add(ResourceCollection c) { - checkChildrenAllowed(); - if (c == null) { - return; - } - if (union == null) { - union = new Union(); - union.setProject(getProject()); - union.setCache(cache); - } - union.add(c); - setChecked(false); - } - - /** - * Creates a nested <code><path></code> element. - * @return a <code>Path</code> to be configured - * @throws BuildException on error - */ - public Path createPath() throws BuildException { - Path p = new Path(getProject()); - add(p); - return p; - } - - /** - * Append the contents of the other Path instance to this. - * @param other a <code>Path</code> to be added to the path - */ - public void append(Path other) { - if (other == null) { - return; - } - add(other); - } - - /** - * Adds the components on the given path which exist to this - * Path. Components that don't exist aren't added. - * - * @param source - source path whose components are examined for existence - */ - public void addExisting(Path source) { - addExisting(source, false); - } - - /** - * Same as addExisting, but support classpath behavior if tryUserDir - * is true. Classpaths are relative to user dir, not the project base. - * That used to break jspc test - * - * @param source the source path - * @param tryUserDir if true try the user directory if the file is not present - */ - public void addExisting(Path source, boolean tryUserDir) { - String[] list = source.list(); - File userDir = (tryUserDir) ? new File(System.getProperty("user.dir")) - : null; - - for (int i = 0; i < list.length; i++) { - File f = resolveFile(getProject(), list[i]); - - // probably not the best choice, but it solves the problem of - // relative paths in CLASSPATH - if (tryUserDir && !f.exists()) { - f = new File(userDir, list[i]); - } - if (f.exists()) { - setLocation(f); - } else if (f.getParentFile() != null && f.getParentFile().exists() - && containsWildcards(f.getName())) { - setLocation(f); - log("adding " + f + " which contains wildcards and may not" - + " do what you intend it to do depending on your OS or" - + " version of Java", Project.MSG_VERBOSE); - } else { - log("dropping " + f + " from path as it doesn't exist", - Project.MSG_VERBOSE); - } - } - } - - /** - * Whether to cache the current path. - * @since Ant 1.8.0 - */ - public void setCache(boolean b) { - checkAttributesAllowed(); - cache = b; - if (union != null) { - union.setCache(b); - } - } - - /** - * Returns all path elements defined by this and nested path objects. - * @return list of path elements. - */ - public String[] list() { - if (isReference()) { - return ((Path) getCheckedRef()).list(); - } - return assertFilesystemOnly(union) == null - ? new String[0] : union.list(); - } - - /** - * Returns a textual representation of the path, which can be used as - * CLASSPATH or PATH environment variable definition. - * @return a textual representation of the path. - */ - public String toString() { - return isReference() ? getCheckedRef().toString() - : union == null ? "" : union.toString(); - } - - /** - * Splits a PATH (with : or ; as separators) into its parts. - * @param project the project to use - * @param source a <code>String</code> value - * @return an array of strings, one for each path element - */ - public static String[] translatePath(Project project, String source) { - final Vector<String> result = new Vector<String>(); - if (source == null) { - return new String[0]; - } - PathTokenizer tok = new PathTokenizer(source); - StringBuffer element = new StringBuffer(); - while (tok.hasMoreTokens()) { - String pathElement = tok.nextToken(); - try { - element.append(resolveFile(project, pathElement).getPath()); - } catch (BuildException e) { - project.log("Dropping path element " + pathElement - + " as it is not valid relative to the project", - Project.MSG_VERBOSE); - } - for (int i = 0; i < element.length(); i++) { - translateFileSep(element, i); - } - result.addElement(element.toString()); - element = new StringBuffer(); - } - return result.toArray(new String[result.size()]); - } - - /** - * Returns its argument with all file separator characters - * replaced so that they match the local OS conventions. - * @param source the path to convert - * @return the converted path - */ - public static String translateFile(String source) { - if (source == null) { - return ""; - } - final StringBuffer result = new StringBuffer(source); - for (int i = 0; i < result.length(); i++) { - translateFileSep(result, i); - } - return result.toString(); - } - - /** - * Translates occurrences at a position of / or \ to correct separator of the - * current platform and returns whether it had to do a - * replacement. - * @param buffer a buffer containing a string - * @param pos the position in the string buffer to convert - * @return true if the character was a / or \ - */ - protected static boolean translateFileSep(StringBuffer buffer, int pos) { - if (buffer.charAt(pos) == '/' || buffer.charAt(pos) == '\\') { - buffer.setCharAt(pos, File.separatorChar); - return true; - } - return false; - } - - /** - * Fulfill the ResourceCollection contract. - * @return number of elements as int. - */ - public synchronized int size() { - if (isReference()) { - return ((Path) getCheckedRef()).size(); - } - dieOnCircularReference(); - return union == null ? 0 : assertFilesystemOnly(union).size(); - } - - /** - * Clone this Path. - * @return Path with shallowly cloned Resource children. - */ - public Object clone() { - try { - Path result = (Path) super.clone(); - result.union = union == null ? union : (Union) union.clone(); - return result; - } catch (CloneNotSupportedException e) { - throw new BuildException(e); - } - } - - /** - * Overrides the version of DataType to recurse on all DataType - * child elements that may have been added. - * @param stk the stack of data types to use (recursively). - * @param p the project to use to dereference the references. - * @throws BuildException on error. - */ - protected synchronized void dieOnCircularReference(Stack<Object> stk, Project p) - throws BuildException { - if (isChecked()) { - return; - } - if (isReference()) { - super.dieOnCircularReference(stk, p); - } else { - if (union != null) { - pushAndInvokeCircularReferenceCheck(union, stk, p); - } - setChecked(true); - } - } - - /** - * Resolve a filename with Project's help - if we know one that is. - */ - private static File resolveFile(Project project, String relativeName) { - return FileUtils.getFileUtils().resolveFile( - (project == null) ? null : project.getBaseDir(), relativeName); - } - - /** - * Concatenates the system class path in the order specified by - * the ${build.sysclasspath} property - using "last" as - * default value. - * @return the concatenated path - */ - public Path concatSystemClasspath() { - return concatSystemClasspath("last"); - } - - /** - * Concatenates the system class path in the order specified by - * the ${build.sysclasspath} property - using the supplied value - * if ${build.sysclasspath} has not been set. - * @param defValue the order ("first", "last", "only") - * @return the concatenated path - */ - public Path concatSystemClasspath(String defValue) { - return concatSpecialPath(defValue, Path.systemClasspath); - } - - /** - * Concatenates the system boot class path in the order specified - * by the ${build.sysclasspath} property - using the supplied - * value if ${build.sysclasspath} has not been set. - * @param defValue the order ("first", "last", "only") - * @return the concatenated path - */ - public Path concatSystemBootClasspath(String defValue) { - return concatSpecialPath(defValue, Path.systemBootClasspath); - } - - /** - * Concatenates a class path in the order specified by the - * ${build.sysclasspath} property - using the supplied value if - * ${build.sysclasspath} has not been set. - */ - private Path concatSpecialPath(String defValue, Path p) { - Path result = new Path(getProject()); - - String order = defValue; - String o = getProject() != null - ? getProject().getProperty(MagicNames.BUILD_SYSCLASSPATH) - : System.getProperty(MagicNames.BUILD_SYSCLASSPATH); - if (o != null) { - order = o; - } - if (order.equals("only")) { - // only: the developer knows what (s)he is doing - result.addExisting(p, true); - - } else if (order.equals("first")) { - // first: developer could use a little help - result.addExisting(p, true); - result.addExisting(this); - - } else if (order.equals("ignore")) { - // ignore: don't trust anyone - result.addExisting(this); - - } else { - // last: don't trust the developer - if (!order.equals("last")) { - log("invalid value for " + MagicNames.BUILD_SYSCLASSPATH - + ": " + order, - Project.MSG_WARN); - } - result.addExisting(this); - result.addExisting(p, true); - } - return result; - } - - /** - * Add the Java Runtime classes to this Path instance. - */ - public void addJavaRuntime() { - if (JavaEnvUtils.isKaffe()) { - // newer versions of Kaffe (1.1.1+) won't have this, - // but this will be sorted by FileSet anyway. - File kaffeShare = new File(System.getProperty("java.home") - + File.separator + "share" - + File.separator + "kaffe"); - if (kaffeShare.isDirectory()) { - FileSet kaffeJarFiles = new FileSet(); - kaffeJarFiles.setDir(kaffeShare); - kaffeJarFiles.setIncludes("*.jar"); - addFileset(kaffeJarFiles); - } - } else if ("GNU libgcj".equals(System.getProperty("java.vm.name"))) { - addExisting(systemBootClasspath); - } - - if (System.getProperty("java.vendor").toLowerCase(Locale.ENGLISH).indexOf("microsoft") >= 0) { - // TODO is this code still necessary? is there any 1.2+ port? - // Pull in *.zip from packages directory - FileSet msZipFiles = new FileSet(); - msZipFiles.setDir(new File(System.getProperty("java.home") - + File.separator + "Packages")); - msZipFiles.setIncludes("*.ZIP"); - addFileset(msZipFiles); - } else { - // JDK 1.2+ seems to set java.home to the JRE directory. - addExisting(new Path(null, - System.getProperty("java.home") - + File.separator + "lib" - + File.separator + "rt.jar")); - // Just keep the old version as well and let addExisting - // sort it out. - addExisting(new Path(null, - System.getProperty("java.home") - + File.separator + "jre" - + File.separator + "lib" - + File.separator + "rt.jar")); - - // Sun's and Apple's 1.4 have JCE and JSSE in separate jars. - String[] secJars = {"jce", "jsse"}; - for (int i = 0; i < secJars.length; i++) { - addExisting(new Path(null, - System.getProperty("java.home") - + File.separator + "lib" - + File.separator + secJars[i] + ".jar")); - addExisting(new Path(null, - System.getProperty("java.home") - + File.separator + ".." - + File.separator + "Classes" - + File.separator + secJars[i] + ".jar")); - } - - // IBM's 1.4 has rt.jar split into 4 smaller jars and a combined - // JCE/JSSE in security.jar. - String[] ibmJars - = {"core", "graphics", "security", "server", "xml"}; - for (int i = 0; i < ibmJars.length; i++) { - addExisting(new Path(null, - System.getProperty("java.home") - + File.separator + "lib" - + File.separator + ibmJars[i] + ".jar")); - } - - // Added for MacOS X - addExisting(new Path(null, - System.getProperty("java.home") - + File.separator + ".." - + File.separator + "Classes" - + File.separator + "classes.jar")); - addExisting(new Path(null, - System.getProperty("java.home") - + File.separator + ".." - + File.separator + "Classes" - + File.separator + "ui.jar")); - } - } - - /** - * Emulation of extdirs feature in java >= 1.2. - * This method adds all files in the given - * directories (but not in sub-directories!) to the classpath, - * so that you don't have to specify them all one by one. - * @param extdirs - Path to append files to - */ - public void addExtdirs(Path extdirs) { - if (extdirs == null) { - String extProp = System.getProperty("java.ext.dirs"); - if (extProp != null) { - extdirs = new Path(getProject(), extProp); - } else { - return; - } - } - - String[] dirs = extdirs.list(); - for (int i = 0; i < dirs.length; i++) { - File dir = resolveFile(getProject(), dirs[i]); - if (dir.exists() && dir.isDirectory()) { - FileSet fs = new FileSet(); - fs.setDir(dir); - fs.setIncludes("*"); - addFileset(fs); - } - } - } - - /** - * Fulfill the ResourceCollection contract. The Iterator returned - * will throw ConcurrentModificationExceptions if ResourceCollections - * are added to this container while the Iterator is in use. - * @return a "fail-fast" Iterator. - */ - public final synchronized Iterator<Resource> iterator() { - if (isReference()) { - return ((Path) getCheckedRef()).iterator(); - } - dieOnCircularReference(); - if (getPreserveBC()) { - return new FileResourceIterator(getProject(), null, list()); - } - return union == null ? Collections.<Resource> emptySet().iterator() - : assertFilesystemOnly(union).iterator(); - } - - /** - * Fulfill the ResourceCollection contract. - * @return whether this is a filesystem-only resource collection. - */ - public synchronized boolean isFilesystemOnly() { - if (isReference()) { - return ((Path) getCheckedRef()).isFilesystemOnly(); - } - dieOnCircularReference(); - assertFilesystemOnly(union); - return true; - } - - /** - * Verify the specified ResourceCollection is filesystem-only. - * @param rc the ResourceCollection to check. - * @throws BuildException if <code>rc</code> is not filesystem-only. - * @return the passed in ResourceCollection. - */ - protected ResourceCollection assertFilesystemOnly(ResourceCollection rc) { - if (rc != null && !(rc.isFilesystemOnly())) { - throw new BuildException(getDataTypeName() - + " allows only filesystem resources."); - } - return rc; - } - - /** - * Helps determine whether to preserve BC by calling <code>list()</code> on subclasses. - * The default behavior of this method is to return <code>true</code> for any subclass - * that implements <code>list()</code>; this can, of course, be avoided by overriding - * this method to return <code>false</code>. It is not expected that the result of this - * method should change over time, thus it is called only once. - * @return <code>true</code> if <code>iterator()</code> should delegate to <code>list()</code>. - */ - protected boolean delegateIteratorToList() { - if (getClass().equals(Path.class)) { - return false; - } - try { - Method listMethod = getClass().getMethod("list", (Class[]) null); - return !listMethod.getDeclaringClass().equals(Path.class); - } catch (Exception e) { - //shouldn't happen, but - return false; - } - } - - private synchronized boolean getPreserveBC() { - if (preserveBC == null) { - preserveBC = delegateIteratorToList() ? Boolean.TRUE : Boolean.FALSE; - } - return preserveBC.booleanValue(); - } - - /** - * Does the given file name contain wildcards? - * @since Ant 1.8.2 - */ - private static boolean containsWildcards(String path) { - return path != null - && (path.indexOf("*") > -1 || path.indexOf("?") > -1); - } - -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/PatternSet.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/PatternSet.java deleted file mode 100644 index 9fb94050..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/PatternSet.java +++ /dev/null @@ -1,541 +0,0 @@ -/* - * 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.BufferedReader; -import java.io.File; -import java.io.FileReader; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; -import java.util.StringTokenizer; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.PropertyHelper; -import org.apache.tools.ant.util.FileUtils; - -/** - * Named collection of include/exclude tags. - * - * <p>Moved out of MatchingTask to make it a standalone object that - * could be referenced (by scripts for example). - * - */ -public class PatternSet extends DataType implements Cloneable { - private List<NameEntry> includeList = new ArrayList<NameEntry>(); - private List<NameEntry> excludeList = new ArrayList<NameEntry>(); - private List<NameEntry> includesFileList = new ArrayList<NameEntry>(); - private List<NameEntry> excludesFileList = new ArrayList<NameEntry>(); - - /** - * inner class to hold a name on list. "If" and "Unless" attributes - * may be used to invalidate the entry based on the existence of a - * property (typically set thru the use of the Available task) - * or value of an expression. - */ - public class NameEntry { - private String name; - private Object ifCond; - private Object unlessCond; - - /** - * Sets the name pattern. - * - * @param name The pattern string. - */ - public void setName(String name) { - this.name = name; - } - - /** - * Sets the if attribute. This attribute and the "unless" - * attribute are used to validate the name, based on the - * existence of the property or the value of the evaluated - * property expression. - * - * @param cond A property name or expression. If the - * expression evaluates to false or no property of - * its value is present, the name is invalid. - * @since Ant 1.8.0 - */ - public void setIf(Object cond) { - ifCond = cond; - } - - /** - * Sets the if attribute. This attribute and the "unless" - * attribute are used to validate the name, based on the - * existence of the property or the value of the evaluated - * property expression. - * - * @param cond A property name or expression. If the - * expression evaluates to false or no property of - * its value is present, the name is invalid. - */ - public void setIf(String cond) { - setIf((Object) cond); - } - - /** - * Sets the unless attribute. This attribute and the "if" - * attribute are used to validate the name, based on the - * existence of the property or the value of the evaluated - * property expression. - * - * @param cond A property name or expression. If the - * expression evaluates to true or a property of - * its value is present, the name is invalid. - * @since Ant 1.8.0 - */ - public void setUnless(Object cond) { - unlessCond = cond; - } - - /** - * Sets the unless attribute. This attribute and the "if" - * attribute are used to validate the name, based on the - * existence of the property or the value of the evaluated - * property expression. - * - * @param cond A property name or expression. If the - * expression evaluates to true or a property of - * its value is present, the name is invalid. - */ - public void setUnless(String cond) { - setUnless((Object) cond); - } - - /** - * @return the name attribute. - */ - public String getName() { - return name; - } - - /** - * This validates the name - checks the if and unless - * properties. - * - * @param p the current project, used to check the presence or - * absence of a property. - * @return the name attribute or null if the "if" or "unless" - * properties are not/are set. - */ - public String evalName(Project p) { - return valid(p) ? name : null; - } - - private boolean valid(Project p) { - PropertyHelper ph = PropertyHelper.getPropertyHelper(p); - return ph.testIfCondition(ifCond) - && ph.testUnlessCondition(unlessCond); - } - - /** - * @return a printable form of this object. - */ - public String toString() { - StringBuffer buf = new StringBuffer(); - if (name == null) { - buf.append("noname"); - } else { - buf.append(name); - } - if ((ifCond != null) || (unlessCond != null)) { - buf.append(":"); - String connector = ""; - - if (ifCond != null) { - buf.append("if->"); - buf.append(ifCond); - connector = ";"; - } - if (unlessCond != null) { - buf.append(connector); - buf.append("unless->"); - buf.append(unlessCond); - } - } - return buf.toString(); - } - } - - private static final class InvertedPatternSet extends PatternSet { - private InvertedPatternSet(PatternSet p) { - setProject(p.getProject()); - addConfiguredPatternset(p); - } - public String[] getIncludePatterns(Project p) { - return super.getExcludePatterns(p); - } - public String[] getExcludePatterns(Project p) { - return super.getIncludePatterns(p); - } - } - - /** - * Creates a new <code>PatternSet</code> instance. - */ - public PatternSet() { - super(); - } - - /** - * Makes this instance in effect a reference to another PatternSet - * instance. - * - * <p>You must not set another attribute or nest elements inside - * this element if you make it a reference.</p> - * @param r the reference to another patternset. - * @throws BuildException on error. - */ - public void setRefid(Reference r) throws BuildException { - if (!includeList.isEmpty() || !excludeList.isEmpty()) { - throw tooManyAttributes(); - } - super.setRefid(r); - } - - /** - * This is a patternset nested element. - * - * @param p a configured patternset nested element. - */ - public void addConfiguredPatternset(PatternSet p) { - if (isReference()) { - throw noChildrenAllowed(); - } - String[] nestedIncludes = p.getIncludePatterns(getProject()); - String[] nestedExcludes = p.getExcludePatterns(getProject()); - - if (nestedIncludes != null) { - for (int i = 0; i < nestedIncludes.length; i++) { - createInclude().setName(nestedIncludes[i]); - } - } - if (nestedExcludes != null) { - for (int i = 0; i < nestedExcludes.length; i++) { - createExclude().setName(nestedExcludes[i]); - } - } - } - - /** - * add a name entry on the include list - * @return a nested include element to be configured. - */ - public NameEntry createInclude() { - if (isReference()) { - throw noChildrenAllowed(); - } - return addPatternToList(includeList); - } - - /** - * add a name entry on the include files list - * @return a nested includesfile element to be configured. - */ - public NameEntry createIncludesFile() { - if (isReference()) { - throw noChildrenAllowed(); - } - return addPatternToList(includesFileList); - } - - /** - * add a name entry on the exclude list - * @return a nested exclude element to be configured. - */ - public NameEntry createExclude() { - if (isReference()) { - throw noChildrenAllowed(); - } - return addPatternToList(excludeList); - } - - /** - * add a name entry on the exclude files list - * @return a nested excludesfile element to be configured. - */ - public NameEntry createExcludesFile() { - if (isReference()) { - throw noChildrenAllowed(); - } - return addPatternToList(excludesFileList); - } - - /** - * Appends <code>includes</code> to the current list of include patterns. - * Patterns may be separated by a comma or a space. - * - * @param includes the string containing the include patterns - */ - public void setIncludes(String includes) { - if (isReference()) { - throw tooManyAttributes(); - } - if (includes != null && includes.length() > 0) { - StringTokenizer tok = new StringTokenizer(includes, ", ", false); - while (tok.hasMoreTokens()) { - createInclude().setName(tok.nextToken()); - } - } - } - - /** - * Appends <code>excludes</code> to the current list of exclude patterns. - * Patterns may be separated by a comma or a space. - * - * @param excludes the string containing the exclude patterns - */ - public void setExcludes(String excludes) { - if (isReference()) { - throw tooManyAttributes(); - } - if (excludes != null && excludes.length() > 0) { - StringTokenizer tok = new StringTokenizer(excludes, ", ", false); - while (tok.hasMoreTokens()) { - createExclude().setName(tok.nextToken()); - } - } - } - - /** - * add a name entry to the given list - */ - private NameEntry addPatternToList(List<NameEntry> list) { - NameEntry result = new NameEntry(); - list.add(result); - return result; - } - - /** - * Sets the name of the file containing the includes patterns. - * - * @param includesFile The file to fetch the include patterns from. - * @throws BuildException on error. - */ - public void setIncludesfile(File includesFile) throws BuildException { - if (isReference()) { - throw tooManyAttributes(); - } - createIncludesFile().setName(includesFile.getAbsolutePath()); - } - - /** - * Sets the name of the file containing the excludes patterns. - * - * @param excludesFile The file to fetch the exclude patterns from. - * @throws BuildException on error. - */ - public void setExcludesfile(File excludesFile) throws BuildException { - if (isReference()) { - throw tooManyAttributes(); - } - createExcludesFile().setName(excludesFile.getAbsolutePath()); - } - - /** - * Reads path matching patterns from a file and adds them to the - * includes or excludes list (as appropriate). - */ - private void readPatterns(File patternfile, List<NameEntry> patternlist, Project p) - throws BuildException { - - BufferedReader patternReader = null; - try { - // Get a FileReader - patternReader = new BufferedReader(new FileReader(patternfile)); - - // Create one NameEntry in the appropriate pattern list for each - // line in the file. - String line = patternReader.readLine(); - while (line != null) { - if (line.length() > 0) { - line = p.replaceProperties(line); - addPatternToList(patternlist).setName(line); - } - line = patternReader.readLine(); - } - } catch (IOException ioe) { - throw new BuildException("An error occurred while reading from pattern file: " - + patternfile, ioe); - } finally { - FileUtils.close(patternReader); - } - } - - /** - * Adds the patterns of the other instance to this set. - * @param other the other PatternSet instance. - * @param p the current project. - */ - public void append(PatternSet other, Project p) { - if (isReference()) { - throw new BuildException("Cannot append to a reference"); - } - dieOnCircularReference(p); - String[] incl = other.getIncludePatterns(p); - if (incl != null) { - for (int i = 0; i < incl.length; i++) { - createInclude().setName(incl[i]); - } - } - String[] excl = other.getExcludePatterns(p); - if (excl != null) { - for (int i = 0; i < excl.length; i++) { - createExclude().setName(excl[i]); - } - } - } - - /** - * Returns the filtered include patterns. - * @param p the current project. - * @return the filtered included patterns. - */ - public String[] getIncludePatterns(Project p) { - if (isReference()) { - return getRef(p).getIncludePatterns(p); - } - dieOnCircularReference(p); - readFiles(p); - return makeArray(includeList, p); - } - - /** - * Returns the filtered include patterns. - * @param p the current project. - * @return the filtered excluded patterns. - */ - public String[] getExcludePatterns(Project p) { - if (isReference()) { - return getRef(p).getExcludePatterns(p); - } - dieOnCircularReference(p); - readFiles(p); - return makeArray(excludeList, p); - } - - /** - * Helper for FileSet classes. - * Check if there are patterns defined. - * @param p the current project. - * @return true if there are patterns. - */ - public boolean hasPatterns(Project p) { - if (isReference()) { - return getRef(p).hasPatterns(p); - } - dieOnCircularReference(p); - return includesFileList.size() > 0 || excludesFileList.size() > 0 - || includeList.size() > 0 || excludeList.size() > 0; - } - - /** - * Performs the check for circular references and returns the - * referenced PatternSet. - */ - private PatternSet getRef(Project p) { - return (PatternSet) getCheckedRef(p); - } - - /** - * Convert a vector of NameEntry elements into an array of Strings. - */ - private String[] makeArray(List<NameEntry> list, Project p) { - if (list.size() == 0) { - return null; - } - ArrayList<String> tmpNames = new ArrayList<String>(); - for (NameEntry ne : list) { - String pattern = ne.evalName(p); - if (pattern != null && pattern.length() > 0) { - tmpNames.add(pattern); - } - } - return tmpNames.toArray(new String[tmpNames.size()]); - } - - /** - * Read includesfile ot excludesfile if not already done so. - */ - private void readFiles(Project p) { - if (includesFileList.size() > 0) { - for (NameEntry ne : includesFileList) { - String fileName = ne.evalName(p); - if (fileName != null) { - File inclFile = p.resolveFile(fileName); - if (!inclFile.exists()) { - throw new BuildException("Includesfile " + inclFile.getAbsolutePath() - + " not found."); - } - readPatterns(inclFile, includeList, p); - } - } - includesFileList.clear(); - } - if (excludesFileList.size() > 0) { - for (NameEntry ne : excludesFileList) { - String fileName = ne.evalName(p); - if (fileName != null) { - File exclFile = p.resolveFile(fileName); - if (!exclFile.exists()) { - throw new BuildException("Excludesfile " + exclFile.getAbsolutePath() - + " not found."); - } - readPatterns(exclFile, excludeList, p); - } - } - excludesFileList.clear(); - } - } - - /** - * @return a printable form of this object. - */ - public String toString() { - return "patternSet{ includes: " + includeList + " excludes: " + excludeList + " }"; - } - - /** - * @since Ant 1.6 - * @return a clone of this patternset. - */ - public Object clone() { - try { - PatternSet ps = (PatternSet) super.clone(); - ps.includeList = new ArrayList<NameEntry>(includeList); - ps.excludeList = new ArrayList<NameEntry>(excludeList); - ps.includesFileList = new ArrayList<NameEntry>(includesFileList); - ps.excludesFileList = new ArrayList<NameEntry>(excludesFileList); - return ps; - } catch (CloneNotSupportedException e) { - throw new BuildException(e); - } - } - - /** - * Add an inverted patternset. - * @param p the pattern to invert and add. - */ - public void addConfiguredInvert(PatternSet p) { - addConfiguredPatternset(new InvertedPatternSet(p)); - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/Permissions.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/Permissions.java deleted file mode 100644 index 96da71bd..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/Permissions.java +++ /dev/null @@ -1,356 +0,0 @@ -/* - * 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.lang.reflect.Constructor; -import java.security.UnresolvedPermission; -import java.util.HashSet; -import java.util.LinkedList; -import java.util.List; -import java.util.Set; -import java.util.StringTokenizer; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.ExitException; - -/** - * This class implements a security manager meant for usage by tasks that run inside the - * Ant VM. An examples are the Java Task and JUnitTask. - * - * The basic functionality is that nothing (except for a base set of permissions) is allowed, unless - * the permission is granted either explicitly or implicitly. - * If a permission is granted this can be overruled by explicitly revoking the permission. - * - * It is not permissible to add permissions (either granted or revoked) while the Security Manager - * is active (after calling setSecurityManager() but before calling restoreSecurityManager()). - * - * @since Ant 1.6 - */ -public class Permissions { - - private final List<Permission> grantedPermissions = new LinkedList<Permission>(); - private final List<Permission> revokedPermissions = new LinkedList<Permission>(); - private java.security.Permissions granted = null; - private SecurityManager origSm = null; - private boolean active = false; - private final boolean delegateToOldSM; - - // Mandatory constructor for permission object. - private static final Class<?>[] PARAMS = {String.class, String.class}; - - /** - * Create a set of Permissions. Equivalent to calling - * <code>new Permissions(false)</code>. - */ - public Permissions() { - this(false); - } - - /** - * Create a set of permissions. - * @param delegateToOldSM if <code>true</code> the old security manager - * will be used if the permission has not been explicitly granted or revoked - * in this instance. - */ - public Permissions(final boolean delegateToOldSM) { - this.delegateToOldSM = delegateToOldSM; - } - - /** - * Adds a permission to be granted. - * @param perm The Permissions.Permission to be granted. - */ - public void addConfiguredGrant(final Permissions.Permission perm) { - grantedPermissions.add(perm); - } - - /** - * Adds a permission to be revoked. - * @param perm The Permissions.Permission to be revoked - */ - public void addConfiguredRevoke(final Permissions.Permission perm) { - revokedPermissions.add(perm); - } - - /** - * To be used by tasks wishing to use this security model before executing the part to be - * subject to these Permissions. Note that setting the SecurityManager too early may - * prevent your part from starting, as for instance changing classloaders may be prohibited. - * The classloader for the new situation is supposed to be present. - * @throws BuildException on error - */ - public synchronized void setSecurityManager() throws BuildException { - origSm = System.getSecurityManager(); - init(); - System.setSecurityManager(new MySM()); - active = true; - } - - /** - * Initializes the list of granted permissions, checks the list of revoked permissions. - */ - private void init() throws BuildException { - granted = new java.security.Permissions(); - for (final Permissions.Permission p : revokedPermissions) { - if (p.getClassName() == null) { - throw new BuildException("Revoked permission " + p + " does not contain a class."); - } - } - for (final Permissions.Permission p : grantedPermissions) { - if (p.getClassName() == null) { - throw new BuildException("Granted permission " + p - + " does not contain a class."); - } else { - final java.security.Permission perm = createPermission(p); - granted.add(perm); - } - } - // Add base set of permissions - granted.add(new java.net.SocketPermission("localhost:1024-", "listen")); - granted.add(new java.util.PropertyPermission("java.version", "read")); - granted.add(new java.util.PropertyPermission("java.vendor", "read")); - granted.add(new java.util.PropertyPermission("java.vendor.url", "read")); - granted.add(new java.util.PropertyPermission("java.class.version", "read")); - granted.add(new java.util.PropertyPermission("os.name", "read")); - granted.add(new java.util.PropertyPermission("os.version", "read")); - granted.add(new java.util.PropertyPermission("os.arch", "read")); - granted.add(new java.util.PropertyPermission("file.encoding", "read")); - granted.add(new java.util.PropertyPermission("file.separator", "read")); - granted.add(new java.util.PropertyPermission("path.separator", "read")); - granted.add(new java.util.PropertyPermission("line.separator", "read")); - granted.add(new java.util.PropertyPermission("java.specification.version", "read")); - granted.add(new java.util.PropertyPermission("java.specification.vendor", "read")); - granted.add(new java.util.PropertyPermission("java.specification.name", "read")); - granted.add(new java.util.PropertyPermission("java.vm.specification.version", "read")); - granted.add(new java.util.PropertyPermission("java.vm.specification.vendor", "read")); - granted.add(new java.util.PropertyPermission("java.vm.specification.name", "read")); - granted.add(new java.util.PropertyPermission("java.vm.version", "read")); - granted.add(new java.util.PropertyPermission("java.vm.vendor", "read")); - granted.add(new java.util.PropertyPermission("java.vm.name", "read")); - } - - private java.security.Permission createPermission( - final Permissions.Permission permission) { - try { - // First add explicitly already resolved permissions will not be - // resolved when added as unresolved permission. - final Class<? extends java.security.Permission> clazz = Class.forName( - permission.getClassName()).asSubclass(java.security.Permission.class); - final String name = permission.getName(); - final String actions = permission.getActions(); - final Constructor<? extends java.security.Permission> ctr = clazz.getConstructor(PARAMS); - return ctr.newInstance(new Object[] {name, actions}); - } catch (final Exception e) { - // Let the UnresolvedPermission handle it. - return new UnresolvedPermission(permission.getClassName(), - permission.getName(), permission.getActions(), null); - } - } - - /** - * To be used by tasks that just finished executing the parts subject to these permissions. - */ - public synchronized void restoreSecurityManager() { - active = false; - System.setSecurityManager(origSm); - } - - /** - * This inner class implements the actual SecurityManager that can be used by tasks - * supporting Permissions. - */ - private class MySM extends SecurityManager { - - /** - * Exit is treated in a special way in order to be able to return the exit code - * towards tasks. - * An ExitException is thrown instead of a simple SecurityException to indicate the exit - * code. - * Overridden from java.lang.SecurityManager - * @param status The exit status requested. - */ - @Override - public void checkExit(final int status) { - final java.security.Permission perm = new java.lang.RuntimePermission("exitVM", null); - try { - checkPermission(perm); - } catch (final SecurityException e) { - throw new ExitException(e.getMessage(), status); - } - } - - /** - * The central point in checking permissions. - * Overridden from java.lang.SecurityManager - * - * @param perm The permission requested. - */ - @Override - public void checkPermission(final java.security.Permission perm) { - if (active) { - if (delegateToOldSM && !perm.getName().equals("exitVM")) { - boolean permOK = false; - if (granted.implies(perm)) { - permOK = true; - } - checkRevoked(perm); - /* - if the permission was not explicitly granted or revoked - the original security manager will do its work - */ - if (!permOK && origSm != null) { - origSm.checkPermission(perm); - } - } else { - if (!granted.implies(perm)) { - throw new SecurityException("Permission " + perm + " was not granted."); - } - checkRevoked(perm); - } - } - } - - /** - * throws an exception if this permission is revoked - * @param perm the permission being checked - */ - private void checkRevoked(final java.security.Permission perm) { - for (final Permissions.Permission revoked : revokedPermissions) { - if (revoked.matches(perm)) { - throw new SecurityException("Permission " + perm + " was revoked."); - } - } - } - } - - /** Represents a permission. */ - public static class Permission { - private String className; - private String name; - private String actionString; - private Set<String> actions; - - /** - * Set the class, mandatory. - * @param aClass The class name of the permission. - */ - public void setClass(final String aClass) { - className = aClass.trim(); - } - - /** - * Get the class of the permission. - * @return The class name of the permission. - */ - public String getClassName() { - return className; - } - - /** - * Set the name of the permission. - * @param aName The name of the permission. - */ - public void setName(final String aName) { - name = aName.trim(); - } - - /** - * Get the name of the permission. - * @return The name of the permission. - */ - public String getName() { - return name; - } - - /** - * Set the actions. - * @param actions The actions of the permission. - */ - public void setActions(final String actions) { - actionString = actions; - if (actions.length() > 0) { - this.actions = parseActions(actions); - } - } - - /** - * Get the actions. - * @return The actions of the permission. - */ - public String getActions() { - return actionString; - } - - /** - * Learn whether the permission matches in case of a revoked permission. - * @param perm The permission to check against. - */ - boolean matches(final java.security.Permission perm) { - if (!className.equals(perm.getClass().getName())) { - return false; - } - if (name != null) { - if (name.endsWith("*")) { - if (!perm.getName().startsWith(name.substring(0, name.length() - 1))) { - return false; - } - } else { - if (!name.equals(perm.getName())) { - return false; - } - } - } - if (actions != null) { - final Set<String> as = parseActions(perm.getActions()); - final int size = as.size(); - as.removeAll(actions); - if (as.size() == size) { - // None of the actions revoked, so all allowed. - return false; - } - } - return true; - } - - /** - * Parses the actions into a set of separate strings. - * @param actions The actions to be parsed. - */ - private Set<String> parseActions(final String actions) { - final Set<String> result = new HashSet<String>(); - final StringTokenizer tk = new StringTokenizer(actions, ","); - while (tk.hasMoreTokens()) { - final String item = tk.nextToken().trim(); - if (!item.equals("")) { - result.add(item); - } - } - return result; - } - - /** - * Get a string description of the permissions. - * @return string description of the permissions. - */ - @Override - public String toString() { - return ("Permission: " + className + " (\"" + name + "\", \"" + actions + "\")"); - } - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/PropertySet.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/PropertySet.java deleted file mode 100644 index f5992044..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/PropertySet.java +++ /dev/null @@ -1,577 +0,0 @@ -/* - * 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.util.ArrayList; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Hashtable; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Properties; -import java.util.Set; -import java.util.Stack; -import java.util.TreeMap; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.types.resources.MappedResource; -import org.apache.tools.ant.types.resources.PropertyResource; -import org.apache.tools.ant.util.FileNameMapper; -import org.apache.tools.ant.util.regexp.RegexpMatcher; -import org.apache.tools.ant.util.regexp.RegexpMatcherFactory; - -/** - * A set of properties. - * - * @since Ant 1.6 - */ -public class PropertySet extends DataType implements ResourceCollection { - - private boolean dynamic = true; - private boolean negate = false; - private Set<String> cachedNames; - private List<PropertyRef> ptyRefs = new ArrayList<PropertyRef>(); - private List<PropertySet> setRefs = new ArrayList<PropertySet>(); - private Mapper mapper; - - /** - * This is a nested class containing a reference to some properties - * and optionally a source of properties. - */ - public static class PropertyRef { - - private int count; - private String name; - private String regex; - private String prefix; - private String builtin; - - /** - * Set the name. - * @param name a <code>String</code> value. - */ - public void setName(String name) { - assertValid("name", name); - this.name = name; - } - - /** - * Set the regular expression to use to filter the properties. - * @param regex a regular expression. - */ - public void setRegex(String regex) { - assertValid("regex", regex); - this.regex = regex; - } - - /** - * Set the prefix to use. - * @param prefix a <code>String</code> value. - */ - public void setPrefix(String prefix) { - assertValid("prefix", prefix); - this.prefix = prefix; - } - - /** - * Builtin property names - all, system or commandline. - * @param b an enumerated <code>BuildinPropertySetName</code> value. - */ - public void setBuiltin(BuiltinPropertySetName b) { - String pBuiltIn = b.getValue(); - assertValid("builtin", pBuiltIn); - this.builtin = pBuiltIn; - } - - private void assertValid(String attr, String value) { - if (value == null || value.length() < 1) { - throw new BuildException("Invalid attribute: " + attr); - } - - if (++count != 1) { - throw new BuildException("Attributes name, regex, and " - + "prefix are mutually exclusive"); - } - } - - /** - * A debug toString(). - * @return a string version of this object. - */ - public String toString() { - return "name=" + name + ", regex=" + regex + ", prefix=" + prefix - + ", builtin=" + builtin; - } - - } //end nested class - - /** - * Allow properties of a particular name in the set. - * @param name the property name to allow. - */ - public void appendName(String name) { - PropertyRef r = new PropertyRef(); - r.setName(name); - addPropertyref(r); - } - - /** - * Allow properties whose names match a regex in the set. - * @param regex the regular expression to use. - */ - public void appendRegex(String regex) { - PropertyRef r = new PropertyRef(); - r.setRegex(regex); - addPropertyref(r); - } - - /** - * Allow properties whose names start with a prefix in the set. - * @param prefix the prefix to use. - */ - public void appendPrefix(String prefix) { - PropertyRef r = new PropertyRef(); - r.setPrefix(prefix); - addPropertyref(r); - } - - /** - * Allow builtin (all, system or commandline) properties in the set. - * @param b the type of builtin properties. - */ - public void appendBuiltin(BuiltinPropertySetName b) { - PropertyRef r = new PropertyRef(); - r.setBuiltin(b); - addPropertyref(r); - } - - /** - * Set a mapper to change property names. - * @param type mapper type. - * @param from source pattern. - * @param to output pattern. - */ - public void setMapper(String type, String from, String to) { - Mapper m = createMapper(); - Mapper.MapperType mapperType = new Mapper.MapperType(); - mapperType.setValue(type); - m.setType(mapperType); - m.setFrom(from); - m.setTo(to); - } - - /** - * Add a property reference (nested element) to the references to be used. - * @param ref a property reference. - */ - public void addPropertyref(PropertyRef ref) { - assertNotReference(); - setChecked(false); - ptyRefs.add(ref); - } - - /** - * Add another property set to this set. - * @param ref another property set. - */ - public void addPropertyset(PropertySet ref) { - assertNotReference(); - setChecked(false); - setRefs.add(ref); - } - - /** - * Create a mapper to map the property names. - * @return a mapper to be configured. - */ - public Mapper createMapper() { - assertNotReference(); - if (mapper != null) { - throw new BuildException("Too many <mapper>s!"); - } - mapper = new Mapper(getProject()); - setChecked(false); - return mapper; - } - - /** - * Add a nested FileNameMapper. - * @param fileNameMapper the mapper to add. - * @since Ant 1.6.3 - */ - public void add(FileNameMapper fileNameMapper) { - createMapper().add(fileNameMapper); - } - - /** - * Set whether to reevaluate the set every time the set is used. - * Default is true. - * - * @param dynamic if true, reevaluate the property set each time - * the set is used. if false cache the property set - * the first time and use the cached set on subsequent - * occasions. - */ - public void setDynamic(boolean dynamic) { - assertNotReference(); - this.dynamic = dynamic; - } - - /** - * Set whether to negate results. - * If "true", all properties not selected by nested elements will be returned. - * Default is "false". - * @param negate if true, negate the selection criteria. - */ - public void setNegate(boolean negate) { - assertNotReference(); - this.negate = negate; - } - - /** - * Get the dynamic attribute. - * @return true if the property set is to be evaluated each time it is used. - */ - public boolean getDynamic() { - if (isReference()) { - return getRef().dynamic; - } - dieOnCircularReference(); - return dynamic; - } - - /** - * Get the mapper attribute. - * @return the mapper attribute. - */ - public Mapper getMapper() { - if (isReference()) { - return getRef().mapper; - } - dieOnCircularReference(); - return mapper; - } - - /** - * Convert the system properties to a hashtable. - * Use propertynames to get the list of properties (including - * default ones). - */ - private Hashtable<String, Object> getAllSystemProperties() { - Hashtable<String, Object> ret = new Hashtable<String, Object>(); - for (Enumeration<?> e = System.getProperties().propertyNames(); - e.hasMoreElements();) { - String name = (String) e.nextElement(); - ret.put(name, System.getProperties().getProperty(name)); - } - return ret; - } - - /** - * This is the operation to get the existing or recalculated properties. - * @return the properties for this propertyset. - */ - public Properties getProperties() { - final Properties result = new Properties(); - result.putAll(getPropertyMap()); - return result; - } - - /** - * - * @return Map - * @since 1.9.0 - */ - private Map<String, Object> getPropertyMap() { - if (isReference()) { - return getRef().getPropertyMap(); - } - dieOnCircularReference(); - final Mapper myMapper = getMapper(); - final FileNameMapper m = myMapper == null ? null : myMapper.getImplementation(); - - final Map<String, Object> effectiveProperties = getEffectiveProperties(); - final Set<String> propertyNames = getPropertyNames(effectiveProperties); - final Map<String, Object> result = new HashMap<String, Object>(); - - //iterate through the names, get the matching values - for (String name : propertyNames) { - Object value = effectiveProperties.get(name); - // TODO should we include null properties? - // TODO should we query the PropertyHelper for property value to grab potentially shadowed values? - if (value != null) { - // may be null if a system property has been added - // after the project instance has been initialized - if (m != null) { - //map the names - String[] newname = m.mapFileName(name); - if (newname != null) { - name = newname[0]; - } - } - result.put(name, value); - } - } - return result; - - } - - private Map<String, Object> getEffectiveProperties() { - final Project prj = getProject(); - final Map<String, Object> result = prj == null ? getAllSystemProperties() : prj.getProperties(); - //quick & dirty, to make nested mapped p-sets work: - for (PropertySet set : setRefs) { - result.putAll(set.getPropertyMap()); - } - return result; - } - - private Set<String> getPropertyNames(Map<String, Object> props) { - Set<String> names; - if (getDynamic() || cachedNames == null) { - names = new HashSet<String>(); - addPropertyNames(names, props); - // Add this PropertySet's nested PropertySets' property names. - for (PropertySet set : setRefs) { - names.addAll(set.getPropertyMap().keySet()); - } - if (negate) { - //make a copy... - HashSet<String> complement = new HashSet<String>(props.keySet()); - complement.removeAll(names); - names = complement; - } - if (!getDynamic()) { - cachedNames = names; - } - } else { - names = cachedNames; - } - return names; - } - - /** - * @param names the output Set to fill with the property names - * matching this PropertySet selection criteria. - * @param props the current Project properties, passed in to - * avoid needless duplication of the Hashtable during recursion. - */ - private void addPropertyNames(Set<String> names, Map<String, Object> props) { - if (isReference()) { - getRef().addPropertyNames(names, props); - } - dieOnCircularReference(); - // Add this PropertySet's property names. - for (PropertyRef r : ptyRefs) { - if (r.name != null) { - if (props.get(r.name) != null) { - names.add(r.name); - } - } else if (r.prefix != null) { - for (String name : props.keySet()) { - if (name.startsWith(r.prefix)) { - names.add(name); - } - } - } else if (r.regex != null) { - RegexpMatcherFactory matchMaker = new RegexpMatcherFactory(); - RegexpMatcher matcher = matchMaker.newRegexpMatcher(); - matcher.setPattern(r.regex); - for (String name : props.keySet()) { - if (matcher.matches(name)) { - names.add(name); - } - } - } else if (r.builtin != null) { - - if (r.builtin.equals(BuiltinPropertySetName.ALL)) { - names.addAll(props.keySet()); - } else if (r.builtin.equals(BuiltinPropertySetName.SYSTEM)) { - names.addAll(getAllSystemProperties().keySet()); - } else if (r.builtin.equals(BuiltinPropertySetName - .COMMANDLINE)) { - names.addAll(getProject().getUserProperties().keySet()); - } else { - throw new BuildException("Impossible: Invalid builtin " - + "attribute!"); - } - } else { - throw new BuildException("Impossible: Invalid PropertyRef!"); - } - } - } - - /** - * Performs the check for circular references and returns the - * referenced PropertySet. - * @return the referenced PropertySet. - */ - protected PropertySet getRef() { - return (PropertySet) getCheckedRef(PropertySet.class, "propertyset"); - } - - /** - * Sets the value of the refid attribute. - * - * @param r the reference this datatype should point to. - * @throws BuildException if another attribute was set, since - * refid and all other attributes are mutually exclusive. - */ - public final void setRefid(Reference r) { - if (!noAttributeSet) { - throw tooManyAttributes(); - } - super.setRefid(r); - } - - /** - * Ensures this data type is not a reference. - * - * <p>Calling this method as the first line of every bean method of - * this data type (setXyz, addXyz, createXyz) ensure proper handling - * of the refid attribute.</p> - * - * @throws BuildException if the refid attribute was already set, since - * refid and all other attributes are mutually exclusive. - */ - protected final void assertNotReference() { - if (isReference()) { - throw tooManyAttributes(); - } - noAttributeSet = false; - } - - /** - * Flag which tracks whether any attribute has been set; used by - * {@link #assertNotReference()} and {@link #setRefid(Reference)}. - */ - private boolean noAttributeSet = true; - - /** - * Used for propertyref's builtin attribute. - */ - public static class BuiltinPropertySetName extends EnumeratedAttribute { - static final String ALL = "all"; - static final String SYSTEM = "system"; - static final String COMMANDLINE = "commandline"; - /** {@inheritDoc}. */ - public String[] getValues() { - return new String[] {ALL, SYSTEM, COMMANDLINE}; - } - } - - /** - * A debug toString. - * This gets a comma separated list of key=value pairs for - * the properties in the set. - * The output order is sorted according to the keys' <i>natural order</i>. - * @return a string rep of this object. - */ - public String toString() { - if (isReference()) { - return getRef().toString(); - } - dieOnCircularReference(); - StringBuilder b = new StringBuilder(); - TreeMap<String, Object> sorted = new TreeMap<String, Object>(getPropertyMap()); - for (Entry<String, Object> e : sorted.entrySet()) { - if (b.length() != 0) { - b.append(", "); - } - b.append(e.getKey()); - b.append("="); - b.append(e.getValue()); - } - return b.toString(); - } - - /** - * Fulfill the ResourceCollection interface. - * @return an Iterator of Resources. - * @since Ant 1.7 - */ - public Iterator<Resource> iterator() { - if (isReference()) { - return getRef().iterator(); - } - dieOnCircularReference(); - final Set<String> names = getPropertyNames(getEffectiveProperties()); - - Mapper myMapper = getMapper(); - final FileNameMapper m = myMapper == null ? null : myMapper.getImplementation(); - final Iterator<String> iter = names.iterator(); - - return new Iterator<Resource>() { - public boolean hasNext() { - return iter.hasNext(); - } - public Resource next() { - PropertyResource p = new PropertyResource(getProject(), iter.next()); - return m == null ? (Resource) p : new MappedResource(p, m); - } - public void remove() { - throw new UnsupportedOperationException(); - } - }; - } - - /** - * Fulfill the ResourceCollection contract. - * @return the size of this ResourceCollection. - */ - public int size() { - return isReference() ? getRef().size() : getProperties().size(); - } - - /** - * Fulfill the ResourceCollection contract. - * @return whether this is a filesystem-only resource collection. - */ - public boolean isFilesystemOnly() { - if (isReference()) { - return getRef().isFilesystemOnly(); - } - dieOnCircularReference(); - return false; - } - - protected synchronized void dieOnCircularReference(Stack<Object> stk, Project p) - throws BuildException { - if (isChecked()) { - return; - } - if (isReference()) { - super.dieOnCircularReference(stk, p); - } else { - if (mapper != null) { - pushAndInvokeCircularReferenceCheck(mapper, stk, p); - } - for (PropertySet propertySet : setRefs) { - pushAndInvokeCircularReferenceCheck(propertySet, stk, - p); - } - setChecked(true); - } - } - -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/Quantifier.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/Quantifier.java deleted file mode 100644 index ac1b84ce..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/Quantifier.java +++ /dev/null @@ -1,146 +0,0 @@ -/* - * 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 org.apache.tools.ant.BuildException; - -/** - * EnumeratedAttribute for quantifier comparisons. Evaluates a - * <code>boolean[]</code> or raw <code>true</code> and <code>false</code> - * counts. Accepts the following values:<ul> - * <li>"all"</li> - none <code>false</code> - * <li>"each"</li> - none <code>false</code> - * <li>"every"</li> - none <code>false</code> - * <li>"any"</li> - at least one <code>true</code> - * <li>"some"</li> - at least one <code>true</code> - * <li>"one"</li> - exactly one <code>true</code> - * <li>"majority"</li> - more <code>true</code> than <code>false</code> - * <li>"most"</li> - more <code>true</code> than <code>false</code> - * <li>"none"</li> - none <code>true</code> - * </ul> - * @since Ant 1.7 - */ -public class Quantifier extends EnumeratedAttribute { - private static final String[] VALUES - = new String[] {"all", "each", "every", "any", "some", "one", - "majority", "most", "none"}; - - /** ALL instance */ - public static final Quantifier ALL = new Quantifier("all"); - /** ANY instance */ - public static final Quantifier ANY = new Quantifier("any"); - /** ONE instance */ - public static final Quantifier ONE = new Quantifier("one"); - /** MAJORITY instance */ - public static final Quantifier MAJORITY = new Quantifier("majority"); - /** NONE instance */ - public static final Quantifier NONE = new Quantifier("none"); - - private abstract static class Predicate { - abstract boolean eval(int t, int f); - } - - private static final Predicate ALL_PRED = new Predicate() { - boolean eval(int t, int f) { return f == 0; } - }; - - private static final Predicate ANY_PRED = new Predicate() { - boolean eval(int t, int f) { return t > 0; } - }; - - private static final Predicate ONE_PRED = new Predicate() { - boolean eval(int t, int f) { return t == 1; } - }; - - private static final Predicate MAJORITY_PRED = new Predicate() { - boolean eval(int t, int f) { return t > f; } - }; - - private static final Predicate NONE_PRED = new Predicate() { - boolean eval(int t, int f) { return t == 0; } - }; - - private static final Predicate[] PREDS = new Predicate[VALUES.length]; - - static { - // CheckStyle:MagicNumber OFF - PREDS[0] = ALL_PRED; - PREDS[1] = ALL_PRED; - PREDS[2] = ALL_PRED; - PREDS[3] = ANY_PRED; - PREDS[4] = ANY_PRED; - PREDS[5] = ONE_PRED; - PREDS[6] = MAJORITY_PRED; - PREDS[7] = MAJORITY_PRED; - PREDS[8] = NONE_PRED; - // CheckStyle:MagicNumber ON - } - - /** - * Default constructor. - */ - public Quantifier() { - } - - /** - * Construct a new Quantifier with the specified value. - * @param value the EnumeratedAttribute value. - */ - public Quantifier(String value) { - setValue(value); - } - - /** - * Return the possible values. - * @return String[] of EnumeratedAttribute values. - */ - public String[] getValues() { - return VALUES; - } - - /** - * Evaluate a <code>boolean<code> array. - * @param b the <code>boolean[]</code> to evaluate. - * @return true if the argument fell within the parameters of this Quantifier. - */ - public boolean evaluate(boolean[] b) { - int t = 0; - for (int i = 0; i < b.length; i++) { - if (b[i]) { - t++; - } - } - return evaluate(t, b.length - t); - } - - /** - * Evaluate integer <code>true</code> vs. <code>false</code> counts. - * @param t the number of <code>true</code> values. - * @param f the number of <code>false</code> values. - * @return true if the arguments fell within the parameters of this Quantifier. - */ - public boolean evaluate(int t, int f) { - int index = getIndex(); - if (index == -1) { - throw new BuildException("Quantifier value not set."); - } - return PREDS[index].eval(t, f); - } - -} - diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/RedirectorElement.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/RedirectorElement.java deleted file mode 100644 index d27b199c..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/RedirectorElement.java +++ /dev/null @@ -1,630 +0,0 @@ -/* - * 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.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Stack; -import java.util.Vector; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.taskdefs.Redirector; - -/** - * Element representation of a <code>Redirector</code>. - * @since Ant 1.6.2 - */ -public class RedirectorElement extends DataType { - - /** - * Whether the input mapper was set via <code>setOutput</code>. - */ - private boolean usingInput = false; - - /** - * Whether the output mapper was set via <code>setOutput</code>. - */ - private boolean usingOutput = false; - - /** - * Whether the error mapper was set via <code>setError</code>. - */ - private boolean usingError = false; - - /** - * Indicates if standard error should be logged to Ant's log system - * rather than the output. This has no effect if standard error is - * redirected to a file or property. - */ - private Boolean logError; - - /** The name of the property into which output is to be stored */ - private String outputProperty; - - /** The name of the property into which error output is to be stored */ - private String errorProperty; - - /** String from which input is taken */ - private String inputString; - - /** Flag which indicates if error and output files are to be appended. */ - private Boolean append; - - /** Flag which indicates that output should be always sent to the log */ - private Boolean alwaysLog; - - /** Flag which indicates whether files should be created even if empty. */ - private Boolean createEmptyFiles; - - /** Input file mapper. */ - private Mapper inputMapper; - - /** Output file mapper. */ - private Mapper outputMapper; - - /** Error file mapper. */ - private Mapper errorMapper; - - /** input filter chains. */ - private Vector<FilterChain> inputFilterChains = new Vector<FilterChain>(); - - /** output filter chains. */ - private Vector<FilterChain> outputFilterChains = new Vector<FilterChain>(); - - /** error filter chains. */ - private Vector<FilterChain> errorFilterChains = new Vector<FilterChain>(); - - /** The output encoding */ - private String outputEncoding; - - /** The error encoding */ - private String errorEncoding; - - /** The input encoding */ - private String inputEncoding; - - /** whether to log the inputstring */ - private Boolean logInputString; - - /** Is the output binary or can we safely split it into lines? */ - private boolean outputIsBinary = false; - - /** - * Add the input file mapper. - * @param inputMapper <code>Mapper</code>. - */ - public void addConfiguredInputMapper(Mapper inputMapper) { - if (isReference()) { - throw noChildrenAllowed(); - } - if (this.inputMapper != null) { - if (usingInput) { - throw new BuildException("attribute \"input\"" - + " cannot coexist with a nested <inputmapper>"); - } else { - throw new BuildException("Cannot have > 1 <inputmapper>"); - } - } - setChecked(false); - this.inputMapper = inputMapper; - } - - /** - * Add the output file mapper. - * @param outputMapper <code>Mapper</code>. - */ - public void addConfiguredOutputMapper(Mapper outputMapper) { - if (isReference()) { - throw noChildrenAllowed(); - } - if (this.outputMapper != null) { - if (usingOutput) { - throw new BuildException("attribute \"output\"" - + " cannot coexist with a nested <outputmapper>"); - } else { - throw new BuildException("Cannot have > 1 <outputmapper>"); - } - } - setChecked(false); - this.outputMapper = outputMapper; - } - - /** - * Add the error file mapper. - * @param errorMapper <code>Mapper</code>. - */ - public void addConfiguredErrorMapper(Mapper errorMapper) { - if (isReference()) { - throw noChildrenAllowed(); - } - if (this.errorMapper != null) { - if (usingError) { - throw new BuildException("attribute \"error\"" - + " cannot coexist with a nested <errormapper>"); - } else { - throw new BuildException("Cannot have > 1 <errormapper>"); - } - } - setChecked(false); - this.errorMapper = errorMapper; - } - - /** - * 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 reference to use. - * @throws BuildException on error. - */ - public void setRefid(Reference r) throws BuildException { - if (usingInput - || usingOutput - || usingError - || inputString != null - || logError != null - || append != null - || createEmptyFiles != null - || inputEncoding != null - || outputEncoding != null - || errorEncoding != null - || outputProperty != null - || errorProperty != null - || logInputString != null) { - throw tooManyAttributes(); - } - super.setRefid(r); - } - - /** - * Set the input to use for the task. - * @param input the file from which input is read. - */ - public void setInput(File input) { - if (isReference()) { - throw tooManyAttributes(); - } - if (inputString != null) { - throw new BuildException("The \"input\" and \"inputstring\" " - + "attributes cannot both be specified"); - } - usingInput = true; - inputMapper = createMergeMapper(input); - } - - /** - * Set the string to use as input - * @param inputString the string which is used as the input source - */ - public void setInputString(String inputString) { - if (isReference()) { - throw tooManyAttributes(); - } - if (usingInput) { - throw new BuildException("The \"input\" and \"inputstring\" " - + "attributes cannot both be specified"); - } - this.inputString = inputString; - } - - /** - * Set whether to include the value of the input string in log messages. - * Defaults to true. - * @param logInputString true or false. - * @since Ant 1.7 - */ - public void setLogInputString(boolean logInputString) { - if (isReference()) { - throw tooManyAttributes(); - } - this.logInputString = logInputString ? Boolean.TRUE : Boolean.FALSE; - } - - /** - * File the output of the process is redirected to. If error is not - * redirected, it too will appear in the output. - * - * @param out the file to which output stream is written. - */ - public void setOutput(File out) { - if (isReference()) { - throw tooManyAttributes(); - } - if (out == null) { - throw new IllegalArgumentException("output file specified as null"); - } - usingOutput = true; - outputMapper = createMergeMapper(out); - } - - /** - * Set the output encoding. - * @param outputEncoding <code>String</code>. - */ - public void setOutputEncoding(String outputEncoding) { - if (isReference()) { - throw tooManyAttributes(); - } - this.outputEncoding = outputEncoding; - } - - /** - * Set the error encoding. - * - * @param errorEncoding <code>String</code>. - */ - public void setErrorEncoding(String errorEncoding) { - if (isReference()) { - throw tooManyAttributes(); - } - this.errorEncoding = errorEncoding; - } - - /** - * Set the input encoding. - * @param inputEncoding <code>String</code>. - */ - public void setInputEncoding(String inputEncoding) { - if (isReference()) { - throw tooManyAttributes(); - } - this.inputEncoding = inputEncoding; - } - - /** - * Controls whether error output of exec is logged. This is only useful - * when output is being redirected and error output is desired in the - * Ant log. - * @param logError if true the standard error is sent to the Ant log system - * and not sent to output. - */ - public void setLogError(boolean logError) { - if (isReference()) { - throw tooManyAttributes(); - } - this.logError = ((logError) ? Boolean.TRUE : Boolean.FALSE); - } - - /** - * Set the file to which standard error is to be redirected. - * @param error the file to which error is to be written. - */ - public void setError(File error) { - if (isReference()) { - throw tooManyAttributes(); - } - if (error == null) { - throw new IllegalArgumentException("error file specified as null"); - } - usingError = true; - errorMapper = createMergeMapper(error); - } - - /** - * Property name whose value should be set to the output of - * the process. - * @param outputProperty the name of the property to be set with the - * task's output. - */ - public void setOutputProperty(String outputProperty) { - if (isReference()) { - throw tooManyAttributes(); - } - this.outputProperty = outputProperty; - } - - /** - * Whether output should be appended to or overwrite an existing file. - * Defaults to false. - * @param append if true output and error streams are appended to their - * respective files, if specified. - */ - public void setAppend(boolean append) { - if (isReference()) { - throw tooManyAttributes(); - } - this.append = ((append) ? Boolean.TRUE : Boolean.FALSE); - } - - /** - * If true, (error and non-error) output will be "teed", redirected - * as specified while being sent to Ant's logging mechanism as if no - * redirection had taken place. Defaults to false. - * @param alwaysLog <code>boolean</code> - * @since Ant 1.6.3 - */ - public void setAlwaysLog(boolean alwaysLog) { - if (isReference()) { - throw tooManyAttributes(); - } - this.alwaysLog = ((alwaysLog) ? Boolean.TRUE : Boolean.FALSE); - } - - /** - * Whether output and error files should be created even when empty. - * Defaults to true. - * @param createEmptyFiles <code>boolean</code>. - */ - public void setCreateEmptyFiles(boolean createEmptyFiles) { - if (isReference()) { - throw tooManyAttributes(); - } - this.createEmptyFiles = ((createEmptyFiles) - ? Boolean.TRUE : Boolean.FALSE); - } - - /** - * Property name whose value should be set to the error of - * the process. - * @param errorProperty the name of the property to be set - * with the error output. - */ - public void setErrorProperty(String errorProperty) { - if (isReference()) { - throw tooManyAttributes(); - } - this.errorProperty = errorProperty; - } - - /** - * Create a nested input <code>FilterChain</code>. - * @return <code>FilterChain</code>. - */ - public FilterChain createInputFilterChain() { - if (isReference()) { - throw noChildrenAllowed(); - } - FilterChain result = new FilterChain(); - result.setProject(getProject()); - inputFilterChains.add(result); - setChecked(false); - return result; - } - - /** - * Create a nested output <code>FilterChain</code>. - * @return <code>FilterChain</code>. - */ - public FilterChain createOutputFilterChain() { - if (isReference()) { - throw noChildrenAllowed(); - } - FilterChain result = new FilterChain(); - result.setProject(getProject()); - outputFilterChains.add(result); - setChecked(false); - return result; - } - - /** - * Create a nested error <code>FilterChain</code>. - * @return <code>FilterChain</code>. - */ - public FilterChain createErrorFilterChain() { - if (isReference()) { - throw noChildrenAllowed(); - } - FilterChain result = new FilterChain(); - result.setProject(getProject()); - errorFilterChains.add(result); - setChecked(false); - return result; - } - - /** - * Whether to consider the output created by the process binary. - * - * <p>Binary output will not be split into lines which may make - * error and normal output look mixed up when they get written to - * the same stream.</p> - * @since 1.9.4 - */ - public void setBinaryOutput(boolean b) { - outputIsBinary = b; - } - - /** - * Configure the specified <code>Redirector</code>. - * @param redirector <code>Redirector</code>. - */ - public void configure(Redirector redirector) { - configure(redirector, null); - } - - /** - * Configure the specified <code>Redirector</code> - * for the specified sourcefile. - * @param redirector <code>Redirector</code>. - * @param sourcefile <code>String</code>. - */ - public void configure(Redirector redirector, String sourcefile) { - if (isReference()) { - getRef().configure(redirector, sourcefile); - return; - } - dieOnCircularReference(); - if (alwaysLog != null) { - redirector.setAlwaysLog(alwaysLog.booleanValue()); - } - if (logError != null) { - redirector.setLogError(logError.booleanValue()); - } - if (append != null) { - redirector.setAppend(append.booleanValue()); - } - if (createEmptyFiles != null) { - redirector.setCreateEmptyFiles(createEmptyFiles.booleanValue()); - } - if (outputProperty != null) { - redirector.setOutputProperty(outputProperty); - } - if (errorProperty != null) { - redirector.setErrorProperty(errorProperty); - } - if (inputString != null) { - redirector.setInputString(inputString); - } - if (logInputString != null) { - redirector.setLogInputString(logInputString.booleanValue()); - } - if (inputMapper != null) { - String[] inputTargets = null; - try { - inputTargets = - inputMapper.getImplementation().mapFileName(sourcefile); - } catch (NullPointerException enPeaEx) { - if (sourcefile != null) { - throw enPeaEx; - } - } - if (inputTargets != null && inputTargets.length > 0) { - redirector.setInput(toFileArray(inputTargets)); - } - } - if (outputMapper != null) { - String[] outputTargets = null; - try { - outputTargets = - outputMapper.getImplementation().mapFileName(sourcefile); - } catch (NullPointerException enPeaEx) { - if (sourcefile != null) { - throw enPeaEx; - } - } - if (outputTargets != null && outputTargets.length > 0) { - redirector.setOutput(toFileArray(outputTargets)); - } - } - if (errorMapper != null) { - String[] errorTargets = null; - try { - errorTargets = - errorMapper.getImplementation().mapFileName(sourcefile); - } catch (NullPointerException enPeaEx) { - if (sourcefile != null) { - throw enPeaEx; - } - } - if (errorTargets != null && errorTargets.length > 0) { - redirector.setError(toFileArray(errorTargets)); - } - } - if (inputFilterChains.size() > 0) { - redirector.setInputFilterChains(inputFilterChains); - } - if (outputFilterChains.size() > 0) { - redirector.setOutputFilterChains(outputFilterChains); - } - if (errorFilterChains.size() > 0) { - redirector.setErrorFilterChains(errorFilterChains); - } - if (inputEncoding != null) { - redirector.setInputEncoding(inputEncoding); - } - if (outputEncoding != null) { - redirector.setOutputEncoding(outputEncoding); - } - if (errorEncoding != null) { - redirector.setErrorEncoding(errorEncoding); - } - redirector.setBinaryOutput(outputIsBinary); - } - - /** - * Create a merge mapper pointing to the specified destination file. - * @param destfile <code>File</code> - * @return <code>Mapper</code>. - */ - protected Mapper createMergeMapper(File destfile) { - Mapper result = new Mapper(getProject()); - result.setClassname( - org.apache.tools.ant.util.MergingMapper.class.getName()); - result.setTo(destfile.getAbsolutePath()); - return result; - } - - /** - * Return a <code>File[]</code> from the specified set of filenames. - * @param name <code>String[]</code> - * @return <code>File[]</code>. - */ - protected File[] toFileArray(String[] name) { - if (name == null) { - return null; - } - //remove any null elements - ArrayList<File> list = new ArrayList<File>(name.length); - for (int i = 0; i < name.length; i++) { - if (name[i] != null) { - list.add(getProject().resolveFile(name[i])); - } - } - return (File[]) (list.toArray(new File[list.size()])); - } - - /** - * Overrides the version of DataType to recurse on all DataType - * child elements that may have been added. - * @param stk the stack of data types to use (recursively). - * @param p the project to use to dereference the references. - * @throws BuildException on error. - */ - protected void dieOnCircularReference(Stack<Object> stk, Project p) - throws BuildException { - if (isChecked()) { - return; - } - if (isReference()) { - super.dieOnCircularReference(stk, p); - } else { - Mapper[] m = new Mapper[] {inputMapper, outputMapper, errorMapper}; - for (int i = 0; i < m.length; i++) { - if (m[i] != null) { - stk.push(m[i]); - m[i].dieOnCircularReference(stk, p); - stk.pop(); - } - } - @SuppressWarnings("unchecked") - final List<? extends List<FilterChain>> filterChainLists = Arrays - .<List<FilterChain>> asList(inputFilterChains, outputFilterChains, - errorFilterChains); - for (List<FilterChain> filterChains : filterChainLists) { - if (filterChains != null) { - for (FilterChain fc : filterChains) { - pushAndInvokeCircularReferenceCheck(fc, stk, p); - } - } - } - setChecked(true); - } - } - - /** - * Perform the check for circular references, returning the - * referenced RedirectorElement. - * @return the referenced RedirectorElement. - */ - private RedirectorElement getRef() { - return (RedirectorElement) getCheckedRef(); - } - -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/Reference.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/Reference.java deleted file mode 100644 index e5e9b25c..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/Reference.java +++ /dev/null @@ -1,134 +0,0 @@ -/* - * 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 org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Project; - -/** - * Class to hold a reference to another object in the project. - * - */ -public class Reference { - - private String refid; - private Project project; - - /** - * Create a reference. - * @deprecated since 1.7. - * Please use {@link Reference#Reference(Project,String)} - * instead. - */ - public Reference() { - } - - /** - * Create a reference to a named ID. - * @param id the name of this reference - * @deprecated since 1.7. - * Please use {@link Reference#Reference(Project,String)} - * instead. - */ - public Reference(String id) { - setRefId(id); - } - - /** - * Create a reference to a named ID in a particular project. - * @param p the project this reference is associated with - * @param id the name of this reference - * @since Ant 1.6.3 - */ - public Reference(Project p, String id) { - setRefId(id); - setProject(p); - } - - /** - * Set the reference id. Should not normally be necessary; - * use {@link Reference#Reference(Project, String)}. - * @param id the reference id to use - */ - public void setRefId(String id) { - refid = id; - } - - /** - * Get the reference id of this reference. - * @return the reference id - */ - public String getRefId() { - return refid; - } - - /** - * Set the associated project. Should not normally be necessary; - * use {@link Reference#Reference(Project,String)}. - * @param p the project to use - * @since Ant 1.6.3 - */ - public void setProject(Project p) { - this.project = p; - } - - /** - * Get the associated project, if any; may be null. - * @return the associated project - * @since Ant 1.6.3 - */ - public Project getProject() { - return project; - } - - /** - * Resolve the reference, using the associated project if - * it set, otherwise use the passed in project. - * @param fallback the fallback project to use if the project attribute of - * reference is not set. - * @return the dereferenced object. - * @throws BuildException if the reference cannot be dereferenced. - */ - public Object getReferencedObject(Project fallback) throws BuildException { - if (refid == null) { - throw new BuildException("No reference specified"); - } - - Object o = project == null ? fallback.getReference(refid) : project.getReference(refid); - if (o == null) { - throw new BuildException("Reference " + refid + " not found."); - } - return o; - } - - /** - * Resolve the reference, looking in the associated project. - * @see Project#getReference - * @return the dereferenced object. - * @throws BuildException if the project is null or the reference cannot be dereferenced - * @since Ant 1.6.3 - */ - public Object getReferencedObject() throws BuildException { - if (project == null) { - throw new BuildException("No project set on reference to " + refid); - } - return getReferencedObject(project); - } - -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/RegularExpression.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/RegularExpression.java deleted file mode 100644 index 18ee3f1f..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/RegularExpression.java +++ /dev/null @@ -1,141 +0,0 @@ -/* - * 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 org.apache.tools.ant.Project; -import org.apache.tools.ant.util.regexp.Regexp; -import org.apache.tools.ant.util.regexp.RegexpFactory; - -/** - * A regular expression datatype. Keeps an instance of the - * compiled expression for speed purposes. This compiled - * expression is lazily evaluated (it is compiled the first - * time it is needed). The syntax is the dependent on which - * regular expression type you are using. The system property - * "ant.regexp.regexpimpl" will be the classname of the implementation - * that will be used. - * - * <pre> - * Available implementations: - * - * org.apache.tools.ant.util.regexp.Jdk14RegexpRegexp (default) - * Based on the JDK's built-in regular expression package - * - * org.apache.tools.ant.util.regexp.JakartaOroRegexp - * Based on the jakarta-oro package - * - * org.apache.tools.ant.util.regexp.JakartaRegexpRegexp - * Based on the jakarta-regexp package - * </pre> - * - * <pre> - * <regexp [ [id="id"] pattern="expression" | refid="id" ] - * /> - * </pre> - * - * @see org.apache.oro.text.regex.Perl5Compiler - * @see org.apache.regexp.RE - * @see java.util.regex.Pattern - * - * @see org.apache.tools.ant.util.regexp.Regexp - * - * @ant.datatype name="regexp" - */ -public class RegularExpression extends DataType { - /** Name of this data type */ - public static final String DATA_TYPE_NAME = "regexp"; - private boolean alreadyInit = false; - - // The regular expression factory - private static final RegexpFactory FACTORY = new RegexpFactory(); - - private Regexp regexp = null; - // temporary variable - private String myPattern; - private boolean setPatternPending = false; - - /** - * default constructor - */ - public RegularExpression() { - } - - private void init(Project p) { - if (!alreadyInit) { - this.regexp = FACTORY.newRegexp(p); - alreadyInit = true; - } - } - private void setPattern() { - if (setPatternPending) { - regexp.setPattern(myPattern); - setPatternPending = false; - } - } - /** - * sets the regular expression pattern - * @param pattern regular expression pattern - */ - public void setPattern(String pattern) { - if (regexp == null) { - myPattern = pattern; - setPatternPending = true; - } else { - regexp.setPattern(pattern); - } - } - - /*** - * Gets the pattern string for this RegularExpression in the - * given project. - * @param p project - * @return pattern - */ - public String getPattern(Project p) { - init(p); - if (isReference()) { - return getRef(p).getPattern(p); - } - setPattern(); - return regexp.getPattern(); - } - - /** - * provides a reference to the Regexp contained in this - * @param p project - * @return Regexp instance associated with this RegularExpression instance - */ - public Regexp getRegexp(Project p) { - init(p); - if (isReference()) { - return getRef(p).getRegexp(p); - } - setPattern(); - return this.regexp; - } - - /*** - * Get the RegularExpression this reference refers to in - * the given project. Check for circular references too - * @param p project - * @return resolved RegularExpression instance - */ - public RegularExpression getRef(Project p) { - return (RegularExpression) getCheckedRef(p); - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/Resource.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/Resource.java deleted file mode 100644 index 426a5b9e..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/Resource.java +++ /dev/null @@ -1,439 +0,0 @@ -/* - * 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.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.math.BigInteger; -import java.util.Iterator; -import java.util.NoSuchElementException; - -import org.apache.tools.ant.types.resources.FileProvider; - -/** - * Describes a "File-like" resource (File, ZipEntry, etc.). - * - * This class is meant to be used by classes needing to record path - * and date/time information about a file, a zip entry or some similar - * resource (URL, archive in a version control repository, ...). - * - * @since Ant 1.5.2 - * @see org.apache.tools.ant.types.resources.Touchable - */ -public class Resource extends DataType implements Comparable<Resource>, ResourceCollection { - - /** Constant unknown size */ - public static final long UNKNOWN_SIZE = -1; - - /** Constant unknown datetime for getLastModified */ - public static final long UNKNOWN_DATETIME = 0L; - - /** Magic number */ - protected static final int MAGIC = getMagicNumber("Resource".getBytes()); - - private static final int NULL_NAME = getMagicNumber("null name".getBytes()); - - /** - * Create a "magic number" for use in hashCode calculations. - * @param seed byte[] to seed with. - * @return a magic number as int. - */ - protected static int getMagicNumber(byte[] seed) { - return new BigInteger(seed).intValue(); - } - - private String name = null; - private Boolean exists = null; - private Long lastmodified = null; - private Boolean directory = null; - private Long size = null; - - /** - * Default constructor. - */ - public Resource() { - } - - /** - * Only sets the name. - * - * <p>This is a dummy, used for not existing resources.</p> - * - * @param name relative path of the resource. Expects - * "/" to be used as the directory separator. - */ - public Resource(String name) { - this(name, false, 0, false); - } - - /** - * Sets the name, lastmodified flag, and exists flag. - * - * @param name relative path of the resource. Expects - * "/" to be used as the directory separator. - * @param exists if true, this resource exists. - * @param lastmodified the last modification time of this resource. - */ - public Resource(String name, boolean exists, long lastmodified) { - this(name, exists, lastmodified, false); - } - - /** - * Sets the name, lastmodified flag, exists flag, and directory flag. - * - * @param name relative path of the resource. Expects - * "/" to be used as the directory separator. - * @param exists if true the resource exists - * @param lastmodified the last modification time of the resource - * @param directory if true, this resource is a directory - */ - public Resource(String name, boolean exists, long lastmodified, boolean directory) { - this(name, exists, lastmodified, directory, UNKNOWN_SIZE); - } - - /** - * Sets the name, lastmodified flag, exists flag, directory flag, and size. - * - * @param name relative path of the resource. Expects - * "/" to be used as the directory separator. - * @param exists if true the resource exists - * @param lastmodified the last modification time of the resource - * @param directory if true, this resource is a directory - * @param size the size of this resource. - */ - public Resource(String name, boolean exists, long lastmodified, boolean directory, long size) { - this.name = name; - setName(name); - setExists(exists); - setLastModified(lastmodified); - setDirectory(directory); - setSize(size); - } - - /** - * Name attribute will contain the path of a file relative to the - * root directory of its fileset or the recorded path of a zip - * entry. - * - * <p>example for a file with fullpath /var/opt/adm/resource.txt - * in a file set with root dir /var/opt it will be - * adm/resource.txt.</p> - * - * <p>"/" will be used as the directory separator.</p> - * @return the name of this resource. - */ - public String getName() { - return isReference() ? ((Resource) getCheckedRef()).getName() : name; - } - - /** - * Set the name of this Resource. - * @param name relative path of the resource. Expects - * "/" to be used as the directory separator. - */ - public void setName(String name) { - checkAttributesAllowed(); - this.name = name; - } - - /** - * The exists attribute tells whether a resource exists. - * @return true if this resource exists. - */ - public boolean isExists() { - if (isReference()) { - return ((Resource) getCheckedRef()).isExists(); - } - //default true: - return exists == null || exists.booleanValue(); - } - - /** - * Set the exists attribute. - * @param exists if true, this resource exists. - */ - public void setExists(boolean exists) { - checkAttributesAllowed(); - this.exists = exists ? Boolean.TRUE : Boolean.FALSE; - } - - /** - * Tells the modification time in milliseconds since 01.01.1970 (the "epoch"). - * - * @return the modification time, if that is meaningful - * (e.g. for a file resource which exists); - * 0 if the resource does not exist, to mirror the behavior - * of {@link java.io.File#lastModified}; - * or 0 if the notion of modification time is meaningless for this class - * of resource (e.g. an inline string) - */ - public long getLastModified() { - if (isReference()) { - return ((Resource) getCheckedRef()).getLastModified(); - } - if (!isExists() || lastmodified == null) { - return UNKNOWN_DATETIME; - } - long result = lastmodified.longValue(); - return result < UNKNOWN_DATETIME ? UNKNOWN_DATETIME : result; - } - - /** - * Set the last modification attribute. - * @param lastmodified the modification time in milliseconds since 01.01.1970. - */ - public void setLastModified(long lastmodified) { - checkAttributesAllowed(); - this.lastmodified = new Long(lastmodified); - } - - /** - * Tells if the resource is a directory. - * @return boolean flag indicating if the resource is a directory. - */ - public boolean isDirectory() { - if (isReference()) { - return ((Resource) getCheckedRef()).isDirectory(); - } - //default false: - return directory != null && directory.booleanValue(); - } - - /** - * Set the directory attribute. - * @param directory if true, this resource is a directory. - */ - public void setDirectory(boolean directory) { - checkAttributesAllowed(); - this.directory = directory ? Boolean.TRUE : Boolean.FALSE; - } - - /** - * Set the size of this Resource. - * @param size the size, as a long. - * @since Ant 1.6.3 - */ - public void setSize(long size) { - checkAttributesAllowed(); - this.size = new Long(size > UNKNOWN_SIZE ? size : UNKNOWN_SIZE); - } - - /** - * Get the size of this Resource. - * @return the size, as a long, 0 if the Resource does not exist (for - * compatibility with java.io.File), or UNKNOWN_SIZE if not known. - * @since Ant 1.6.3 - */ - public long getSize() { - if (isReference()) { - return ((Resource) getCheckedRef()).getSize(); - } - return isExists() - ? (size != null ? size.longValue() : UNKNOWN_SIZE) - : 0L; - } - - /** - * Clone this Resource. - * @return copy of this. - */ - public Object clone() { - try { - return super.clone(); - } catch (CloneNotSupportedException e) { - throw new UnsupportedOperationException( - "CloneNotSupportedException for a Resource caught. " - + "Derived classes must support cloning."); - } - } - - /** - * Delegates to a comparison of names. - * @param other the object to compare to. - * @return a negative integer, zero, or a positive integer as this Resource - * is less than, equal to, or greater than the specified Resource. - * @since Ant 1.6 - */ - public int compareTo(Resource other) { - if (isReference()) { - return ((Resource) getCheckedRef()).compareTo(other); - } - return toString().compareTo(other.toString()); - } - - /** - * Implement basic Resource equality. - * @param other the object to check against. - * @return true if the specified Object is equal to this Resource. - * @since Ant 1.7 - */ - public boolean equals(Object other) { - if (isReference()) { - return getCheckedRef().equals(other); - } - return other != null && other.getClass().equals(getClass()) - && compareTo((Resource) other) == 0; - } - - /** - * Get the hash code for this Resource. - * @return hash code as int. - * @since Ant 1.7 - */ - public int hashCode() { - if (isReference()) { - return getCheckedRef().hashCode(); - } - String name = getName(); - return MAGIC * (name == null ? NULL_NAME : name.hashCode()); - } - - /** - * Get an InputStream for the Resource. - * @return an InputStream containing this Resource's content. - * @throws IOException if unable to provide the content of this - * Resource as a stream. - * @throws UnsupportedOperationException if InputStreams are not - * supported for this Resource type. - * @since Ant 1.7 - */ - public InputStream getInputStream() throws IOException { - if (isReference()) { - return ((Resource) getCheckedRef()).getInputStream(); - } - throw new UnsupportedOperationException(); - } - - /** - * Get an OutputStream for the Resource. - * @return an OutputStream to which content can be written. - * @throws IOException if unable to provide the content of this - * Resource as a stream. - * @throws UnsupportedOperationException if OutputStreams are not - * supported for this Resource type. - * @since Ant 1.7 - */ - public OutputStream getOutputStream() throws IOException { - if (isReference()) { - return ((Resource) getCheckedRef()).getOutputStream(); - } - throw new UnsupportedOperationException(); - } - - /** - * Fulfill the ResourceCollection contract. - * @return an Iterator of Resources. - * @since Ant 1.7 - */ - public Iterator<Resource> iterator() { - return isReference() ? ((Resource) getCheckedRef()).iterator() - : new Iterator<Resource>() { - private boolean done = false; - public boolean hasNext() { - return !done; - } - public Resource next() { - if (done) { - throw new NoSuchElementException(); - } - done = true; - return Resource.this; - } - public void remove() { - throw new UnsupportedOperationException(); - } - }; - } - - /** - * Fulfill the ResourceCollection contract. - * @return the size of this ResourceCollection. - * @since Ant 1.7 - */ - public int size() { - return isReference() ? ((Resource) getCheckedRef()).size() : 1; - } - - /** - * Fulfill the ResourceCollection contract. - * @return whether this Resource is a FileProvider. - * @since Ant 1.7 - */ - public boolean isFilesystemOnly() { - return (isReference() && ((Resource) getCheckedRef()).isFilesystemOnly()) - || this.as(FileProvider.class) != null; - } - - /** - * Get the string representation of this Resource. - * @return this Resource formatted as a String. - * @since Ant 1.7 - */ - public String toString() { - if (isReference()) { - return getCheckedRef().toString(); - } - String n = getName(); - return n == null ? "(anonymous)" : n; - } - - /** - * Get a long String representation of this Resource. - * This typically should be the value of <code>toString()</code> - * prefixed by a type description. - * @return this Resource formatted as a long String. - * @since Ant 1.7 - */ - public final String toLongString() { - return isReference() ? ((Resource) getCheckedRef()).toLongString() - : getDataTypeName() + " \"" + toString() + '"'; - } - - /** - * Overrides the base version. - * @param r the Reference to set. - */ - public void setRefid(Reference r) { - if (name != null - || exists != null - || lastmodified != null - || directory != null - || size != null) { - throw tooManyAttributes(); - } - super.setRefid(r); - } - - /** - * Returns a view of this resource that implements the interface - * given as the argument or null if there is no such view. - * - * <p>This allows extension interfaces to be added to resources - * without growing the number of permutations of interfaces - * decorators/adapters need to implement.</p> - * - * <p>This implementation of the method will return the current - * instance itself if it can be assigned to the given class.</p> - * - * @since Ant 1.8.0 - */ - public <T> T as(Class<T> clazz) { - return clazz.isAssignableFrom(getClass()) ? clazz.cast(this) : null; - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/ResourceCollection.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/ResourceCollection.java deleted file mode 100644 index a82c8b59..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/ResourceCollection.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * 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.util.Iterator; - -/** - * Interface describing a collection of Resources. - * @since Ant 1.7 - */ -public interface ResourceCollection extends Iterable<Resource> { - - /** - * Gets the contents of this collection. - * @return all resources in the collection - */ - Iterator<Resource> iterator(); - - /** - * Learn the number of contained Resources. - * @return number of elements as int. - */ - int size(); - - /** - * Indicate whether this ResourceCollection is composed entirely of - * Resources accessible via local filesystem conventions. If true, - * all resources returned from this collection should - * respond with a {@link org.apache.tools.ant.types.resources.FileProvider} - * when asked via {@link Resource#as}. - * @return whether this is a filesystem-only resource collection. - */ - boolean isFilesystemOnly(); - -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/ResourceFactory.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/ResourceFactory.java deleted file mode 100644 index 515318ef..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/ResourceFactory.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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; - -/** - * this interface should be implemented by classes (Scanners) needing - * to deliver information about resources. - * - * @since Ant 1.5.2 - */ -public interface ResourceFactory { - - /** - * Query a resource (file, zipentry, ...) by name - * - * @param name relative path of the resource about which - * information is sought. Expects "/" to be used as the - * directory separator. - * @return instance of Resource; the exists attribute of Resource - * will tell whether the sought resource exists - */ - Resource getResource(String name); -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/ResourceLocation.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/ResourceLocation.java deleted file mode 100644 index c5a44ea2..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/ResourceLocation.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * 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.net.URL; - -/** - * <p>Helper class to handle the <code><dtd></code> and - * <code><entity></code> nested elements. These correspond to - * the <code>PUBLIC</code> and <code>URI</code> catalog entry types, - * respectively, as defined in the <a - * href="http://oasis-open.org/committees/entity/spec-2001-08-06.html"> - * OASIS "Open Catalog" standard</a>.</p> - * - * <p>Possible Future Enhancements: - * <ul> - * <li>Bring the Ant element names into conformance with the OASIS standard</li> - * <li>Add support for additional OASIS catalog entry types</li> - * </ul> - * </p> - * - * @see org.apache.xml.resolver.Catalog - * @since Ant 1.6 - */ -public class ResourceLocation { - - //-- Fields ---------------------------------------------------------------- - /** publicId of the dtd/entity. */ - private String publicId = null; - - /** location of the dtd/entity - a file/resource/URL. */ - private String location = null; - - /** - * base URL of the dtd/entity, or null. If null, the Ant project - * basedir is assumed. If the location specifies a relative - * URL/pathname, it is resolved using the base. The default base - * for an external catalog file is the directory in which it is - * located. - */ - private URL base = null; - - //-- Methods --------------------------------------------------------------- - - /** - * @param publicId uniquely identifies the resource. - */ - public void setPublicId(String publicId) { - this.publicId = publicId; - } - - /** - * @param location the location of the resource associated with the - * publicId. - */ - public void setLocation(String location) { - this.location = location; - } - - /** - * @param base the base URL of the resource associated with the - * publicId. If the location specifies a relative URL/pathname, - * it is resolved using the base. The default base for an - * external catalog file is the directory in which it is located. - */ - public void setBase(URL base) { - this.base = base; - } - - /** - * @return the publicId of the resource. - */ - public String getPublicId() { - return publicId; - } - - /** - * @return the location of the resource identified by the publicId. - */ - public String getLocation() { - return location; - } - - /** - * @return the base of the resource identified by the publicId. - */ - public URL getBase() { - return base; - } - -} //-- ResourceLocation diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/Substitution.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/Substitution.java deleted file mode 100644 index 343f4c49..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/Substitution.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * 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 org.apache.tools.ant.Project; - -/*** - * A regular expression substitution datatype. It is an expression - * that is meant to replace a regular expression. - * - * <pre> - * <substitution [ [id="id"] expression="expression" | refid="id" ] - * /> - * </pre> - * - * @see org.apache.oro.text.regex.Perl5Substitution - */ -public class Substitution extends DataType { - /** The name of this data type */ - public static final String DATA_TYPE_NAME = "substitution"; - - private String expression; - - /** Constructor for Substitution. */ - public Substitution() { - this.expression = null; - } - - /** - * Set the pattern string for this regular expression substitution. - * @param expression the regular expression to use - */ - public void setExpression(String expression) { - this.expression = expression; - } - - /*** - * Gets the pattern string for this RegularExpression in the - * given project. - * @param p the project to look for the regular expression if this object is - * a reference - * @return the pattern string - */ - public String getExpression(Project p) { - if (isReference()) { - return getRef(p).getExpression(p); - } - - return expression; - } - - /*** - * Get the RegularExpression this reference refers to in - * the given project. Check for circular references too. - * @param p the project to look for the regular expression reference - * @return the resolved reference - */ - public Substitution getRef(Project p) { - return (Substitution) getCheckedRef(p); - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/TarFileSet.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/TarFileSet.java deleted file mode 100644 index 6446e9bf..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/TarFileSet.java +++ /dev/null @@ -1,269 +0,0 @@ -/* - * 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 org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Project; - -/** - * A TarFileSet is a FileSet with extra attributes useful in the context of - * Tar/Jar tasks. - * - * A TarFileSet extends FileSets with the ability to extract a subset of the - * entries of a Tar file for inclusion in another Tar file. It also includes - * a prefix attribute which is prepended to each entry in the output Tar file. - * - */ -public class TarFileSet extends ArchiveFileSet { - - private boolean userNameSet; - private boolean groupNameSet; - private boolean userIdSet; - private boolean groupIdSet; - - private String userName = ""; - private String groupName = ""; - private int uid; - private int gid; - - /** Constructor for TarFileSet */ - public TarFileSet() { - super(); - } - - /** - * Constructor using a fileset argument. - * @param fileset the fileset to use - */ - protected TarFileSet(FileSet fileset) { - super(fileset); - } - - /** - * Constructor using a tarfileset argument. - * @param fileset the tarfileset to use - */ - protected TarFileSet(TarFileSet fileset) { - super(fileset); - } - - /** - * The username for the tar entry - * This is not the same as the UID. - * @param userName the user name for the tar entry. - */ - public void setUserName(String userName) { - checkTarFileSetAttributesAllowed(); - userNameSet = true; - this.userName = userName; - } - - /** - * @return the user name for the tar entry - */ - public String getUserName() { - if (isReference()) { - return ((TarFileSet) getCheckedRef()).getUserName(); - } - return userName; - } - - /** - * @return whether the user name has been explicitly set. - */ - public boolean hasUserNameBeenSet() { - return userNameSet; - } - - /** - * The uid for the tar entry - * This is not the same as the User name. - * @param uid the id of the user for the tar entry. - */ - public void setUid(int uid) { - checkTarFileSetAttributesAllowed(); - userIdSet = true; - this.uid = uid; - } - - /** - * @return the uid for the tar entry - */ - public int getUid() { - if (isReference()) { - return ((TarFileSet) getCheckedRef()).getUid(); - } - return uid; - } - - /** - * @return whether the user id has been explicitly set. - */ - public boolean hasUserIdBeenSet() { - return userIdSet; - } - - /** - * The groupname for the tar entry; optional, default="" - * This is not the same as the GID. - * @param groupName the group name string. - */ - public void setGroup(String groupName) { - checkTarFileSetAttributesAllowed(); - groupNameSet = true; - this.groupName = groupName; - } - - /** - * @return the group name string. - */ - public String getGroup() { - if (isReference()) { - return ((TarFileSet) getCheckedRef()).getGroup(); - } - return groupName; - } - - /** - * @return whether the group name has been explicitly set. - */ - public boolean hasGroupBeenSet() { - return groupNameSet; - } - - /** - * The GID for the tar entry; optional, default="0" - * This is not the same as the group name. - * @param gid the group id. - */ - public void setGid(int gid) { - checkTarFileSetAttributesAllowed(); - groupIdSet = true; - this.gid = gid; - } - - /** - * @return the group identifier. - */ - public int getGid() { - if (isReference()) { - return ((TarFileSet) getCheckedRef()).getGid(); - } - return gid; - } - - /** - * @return whether the group id has been explicitly set. - */ - public boolean hasGroupIdBeenSet() { - return groupIdSet; - } - - /** - * Create a new scanner. - * @return the created scanner. - */ - protected ArchiveScanner newArchiveScanner() { - TarScanner zs = new TarScanner(); - zs.setEncoding(getEncoding()); - return zs; - } - - /** - * 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 (userNameSet || userIdSet || groupNameSet || groupIdSet) { - throw tooManyAttributes(); - } - super.setRefid(r); - } - - /** - * A TarFileset accepts another TarFileSet or a FileSet as reference - * FileSets are often used by the war task for the lib attribute - * @param p the project to use - * @return the abstract fileset instance - */ - protected AbstractFileSet getRef(Project p) { - dieOnCircularReference(p); - Object o = getRefid().getReferencedObject(p); - if (o instanceof TarFileSet) { - return (AbstractFileSet) o; - } else if (o instanceof FileSet) { - TarFileSet zfs = new TarFileSet((FileSet) o); - configureFileSet(zfs); - return zfs; - } else { - String msg = getRefid().getRefId() + " doesn\'t denote a tarfileset or a fileset"; - throw new BuildException(msg); - } - } - - /** - * Configure a fileset based on this fileset. - * If the fileset is a TarFileSet copy in the tarfileset - * specific attributes. - * @param zfs the archive fileset to configure. - */ - protected void configureFileSet(ArchiveFileSet zfs) { - super.configureFileSet(zfs); - if (zfs instanceof TarFileSet) { - TarFileSet tfs = (TarFileSet) zfs; - tfs.setUserName(userName); - tfs.setGroup(groupName); - tfs.setUid(uid); - tfs.setGid(gid); - } - } - - /** - * Return a TarFileSet that has the same properties - * as this one. - * @return the cloned tarFileSet - */ - public Object clone() { - if (isReference()) { - return ((TarFileSet) getRef(getProject())).clone(); - } else { - return super.clone(); - } - } - - /** - * A check attributes for TarFileSet. - * If there is a reference, and - * it is a TarFileSet, the tar fileset attributes - * cannot be used. - */ - private void checkTarFileSetAttributesAllowed() { - if (getProject() == null - || (isReference() - && (getRefid().getReferencedObject( - getProject()) - instanceof TarFileSet))) { - checkAttributesAllowed(); - } - } - -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/TarScanner.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/TarScanner.java deleted file mode 100644 index a3c7f6d5..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/TarScanner.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * 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.IOException; -import java.util.Map; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.types.resources.TarResource; -import org.apache.tools.ant.util.FileUtils; -import org.apache.tools.tar.TarEntry; -import org.apache.tools.tar.TarInputStream; - -/** - * Scans tar archives for resources. - */ -public class TarScanner extends ArchiveScanner { - - /** - * Fills the file and directory maps with resources read from the - * archive. - * - * @param src the archive to scan. - * @param encoding encoding used to encode file names inside the archive. - * @param fileEntries Map (name to resource) of non-directory - * resources found inside the archive. - * @param matchFileEntries Map (name to resource) of non-directory - * resources found inside the archive that matched all include - * patterns and didn't match any exclude patterns. - * @param dirEntries Map (name to resource) of directory - * resources found inside the archive. - * @param matchDirEntries Map (name to resource) of directory - * resources found inside the archive that matched all include - * patterns and didn't match any exclude patterns. - */ - protected void fillMapsFromArchive(Resource src, String encoding, - Map<String, Resource> fileEntries, Map<String, Resource> matchFileEntries, - Map<String, Resource> dirEntries, Map<String, Resource> matchDirEntries) { - - TarEntry entry = null; - TarInputStream ti = null; - - try { - try { - ti = new TarInputStream(src.getInputStream(), encoding); - } catch (IOException ex) { - throw new BuildException("problem opening " + srcFile, ex); - } - while ((entry = ti.getNextEntry()) != null) { - Resource r = new TarResource(src, entry); - String name = entry.getName(); - if (entry.isDirectory()) { - name = trimSeparator(name); - dirEntries.put(name, r); - if (match(name)) { - matchDirEntries.put(name, r); - } - } else { - fileEntries.put(name, r); - if (match(name)) { - matchFileEntries.put(name, r); - } - } - } - } catch (IOException ex) { - throw new BuildException("problem reading " + srcFile, ex); - } finally { - FileUtils.close(ti); - } - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/TimeComparison.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/TimeComparison.java deleted file mode 100644 index 15c136e6..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/TimeComparison.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * 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 org.apache.tools.ant.BuildException; -import org.apache.tools.ant.util.FileUtils; - -/** - * EnumeratedAttribute for time comparisons. Accepts values - * "before", "after", "equal". - * @since Ant 1.7 - */ -public class TimeComparison extends EnumeratedAttribute { - private static final String[] VALUES - = new String[] {"before", "after", "equal"}; - - private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); - - /** Before Comparison. */ - public static final TimeComparison BEFORE = new TimeComparison("before"); - - /** After Comparison. */ - public static final TimeComparison AFTER = new TimeComparison("after"); - - /** Equal Comparison. */ - public static final TimeComparison EQUAL = new TimeComparison("equal"); - - /** - * Default constructor. - */ - public TimeComparison() { - } - - /** - * Construct a new TimeComparison with the specified value. - * @param value the EnumeratedAttribute value. - */ - public TimeComparison(String value) { - setValue(value); - } - - /** - * Return the possible values. - * @return String[] of EnumeratedAttribute values. - */ - public String[] getValues() { - return VALUES; - } - - /** - * Evaluate two times against this TimeComparison. - * @param t1 the first time to compare. - * @param t2 the second time to compare. - * @return true if the comparison result fell within the parameters of this TimeComparison. - */ - public boolean evaluate(long t1, long t2) { - return evaluate(t1, t2, FILE_UTILS.getFileTimestampGranularity()); - } - - /** - * Evaluate two times against this TimeComparison. - * @param t1 the first time to compare. - * @param t2 the second time to compare. - * @param g the timestamp granularity. - * @return true if the comparison result fell within the parameters of this TimeComparison. - */ - public boolean evaluate(long t1, long t2, long g) { - int cmp = getIndex(); - if (cmp == -1) { - throw new BuildException("TimeComparison value not set."); - } - if (cmp == 0) { - return t1 - g < t2; - } - if (cmp == 1) { - return t1 + g > t2; - } - return Math.abs(t1 - t2) <= g; - } - - /** - * Compare two times. - * @param t1 the first time to compare. - * @param t2 the second time to compare. - * @return a negative integer, a positive integer, or zero as t1 is - * before, after, or equal to t2 accounting for the default granularity. - */ - public static int compare(long t1, long t2) { - return compare(t1, t2, FILE_UTILS.getFileTimestampGranularity()); - } - - /** - * Compare two times. - * @param t1 the first time to compare. - * @param t2 the second time to compare. - * @param g the timestamp granularity. - * @return a negative integer, a positive integer, or zero as t1 is - * before, after, or equal to t2 accounting for the specified granularity. - */ - public static int compare(long t1, long t2, long g) { - long diff = t1 - t2; - long abs = Math.abs(diff); - return abs > Math.abs(g) ? (int) (diff / abs) : 0; - } - -} - diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/XMLCatalog.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/XMLCatalog.java deleted file mode 100644 index bd9be431..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/XMLCatalog.java +++ /dev/null @@ -1,1128 +0,0 @@ -/* - * 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.io.IOException; -import java.io.InputStream; -import java.lang.reflect.Method; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLConnection; -import java.util.Stack; -import java.util.Vector; - -import javax.xml.parsers.ParserConfigurationException; -import javax.xml.parsers.SAXParserFactory; -import javax.xml.transform.Source; -import javax.xml.transform.TransformerException; -import javax.xml.transform.URIResolver; -import javax.xml.transform.sax.SAXSource; - -import org.apache.tools.ant.AntClassLoader; -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.util.FileUtils; -import org.apache.tools.ant.util.JAXPUtils; -import org.xml.sax.EntityResolver; -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; -import org.xml.sax.XMLReader; - - - -/** - * <p>This data type provides a catalog of resource locations (such as - * DTDs and XML entities), based on the <a - * href="http://oasis-open.org/committees/entity/spec-2001-08-06.html"> - * OASIS "Open Catalog" standard</a>. The catalog entries are used - * both for Entity resolution and URI resolution, in accordance with - * the {@link org.xml.sax.EntityResolver EntityResolver} and {@link - * javax.xml.transform.URIResolver URIResolver} interfaces as defined - * in the <a href="http://java.sun.com/xml/jaxp">Java API for XML - * Processing Specification</a>.</p> - * - * <p>Resource locations can be specified either in-line or in - * external catalog file(s), or both. In order to use an external - * catalog file, the xml-commons resolver library ("resolver.jar") - * must be in your classpath. External catalog files may be either <a - * href="http://oasis-open.org/committees/entity/background/9401.html"> - * plain text format</a> or <a - * href="http://www.oasis-open.org/committees/entity/spec-2001-08-06.html"> - * XML format</a>. If the xml-commons resolver library is not found - * in the classpath, external catalog files, specified in - * <code><catalogpath></code> paths, will be ignored and a warning will - * be logged. In this case, however, processing of inline entries will proceed - * normally.</p> - * - * <p>Currently, only <code><dtd></code> and - * <code><entity></code> elements may be specified inline; these - * correspond to OASIS catalog entry types <code>PUBLIC</code> and - * <code>URI</code> respectively.</p> - * - * <p>The following is a usage example:</p> - * - * <code> - * <xmlcatalog><br> - * <dtd publicId="" location="/path/to/file.jar" /><br> - * <dtd publicId="" location="/path/to/file2.jar" /><br> - * <entity publicId="" location="/path/to/file3.jar" /><br> - * <entity publicId="" location="/path/to/file4.jar" /><br> - * <catalogpath><br> - * <pathelement location="/etc/sgml/catalog"/><br> - * </catalogpath><br> - * <catalogfiles dir="/opt/catalogs/" includes="**\catalog.xml" /><br> - * </xmlcatalog><br> - * </code> - * <p> - * Tasks wishing to use <code><xmlcatalog></code> must provide a method called - * <code>createXMLCatalog</code> which returns an instance of - * <code>XMLCatalog</code>. Nested DTD and entity definitions are handled by - * the XMLCatalog object and must be labeled <code>dtd</code> and - * <code>entity</code> respectively.</p> - * - * <p>The following is a description of the resolution algorithm: - * entities/URIs/dtds are looked up in each of the following contexts, - * stopping when a valid and readable resource is found: - * <ol> - * <li>In the local filesystem</li> - * <li>In the classpath</li> - * <li>Using the Apache xml-commons resolver (if it is available)</li> - * <li>In URL-space</li> - * </ol> - * </p> - * - * <p>See {@link - * org.apache.tools.ant.taskdefs.optional.XMLValidateTask - * XMLValidateTask} for an example of a task that has integrated - * support for XMLCatalogs.</p> - * - * <p>Possible future extension could provide for additional OASIS - * entry types to be specified inline.</p> - * - */ -public class XMLCatalog extends DataType - implements Cloneable, EntityResolver, URIResolver { - - /** helper for some File.toURL connversions */ - private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); - - //-- Fields ---------------------------------------------------------------- - - /** Holds dtd/entity objects until needed. */ - private Vector<ResourceLocation> elements = new Vector<ResourceLocation>(); - - /** - * Classpath in which to attempt to resolve resources. - */ - private Path classpath; - - /** - * Path listing external catalog files to search when resolving entities - */ - private Path catalogPath; - - /** - * The name of the bridge to the Apache xml-commons resolver - * class, used to determine whether resolver.jar is present in the - * classpath. - */ - public static final String APACHE_RESOLVER - = "org.apache.tools.ant.types.resolver.ApacheCatalogResolver"; - - /** - * Resolver base class - */ - public static final String CATALOG_RESOLVER - = "org.apache.xml.resolver.tools.CatalogResolver"; - - //-- Methods --------------------------------------------------------------- - - /** - * Default constructor - */ - public XMLCatalog() { - setChecked(false); - } - - /** - * Returns the elements of the catalog - ResourceLocation objects. - * - * @return the elements of the catalog - ResourceLocation objects - */ - private Vector<ResourceLocation> getElements() { - return getRef().elements; - } - - /** - * Returns the classpath in which to attempt to resolve resources. - * - * @return the classpath - */ - private Path getClasspath() { - return getRef().classpath; - } - - /** - * Allows nested classpath elements. Not allowed if this catalog - * is itself a reference to another catalog -- that is, a catalog - * cannot both refer to another <em>and</em> contain elements or - * other attributes. - * - * @return a Path instance to be configured. - */ - public Path createClasspath() { - if (isReference()) { - throw noChildrenAllowed(); - } - if (this.classpath == null) { - this.classpath = new Path(getProject()); - } - setChecked(false); - return this.classpath.createPath(); - } - - /** - * Allows simple classpath string. Not allowed if this catalog is - * itself a reference to another catalog -- that is, a catalog - * cannot both refer to another <em>and</em> contain elements or - * other attributes. - * - * @param classpath the classpath to use to look up entities. - */ - public void setClasspath(Path classpath) { - if (isReference()) { - throw tooManyAttributes(); - } - if (this.classpath == null) { - this.classpath = classpath; - } else { - this.classpath.append(classpath); - } - setChecked(false); - } - - /** - * Allows classpath reference. Not allowed if this catalog is - * itself a reference to another catalog -- that is, a catalog - * cannot both refer to another <em>and</em> contain elements or - * other attributes. - * - * @param r an Ant reference containing a classpath. - */ - public void setClasspathRef(Reference r) { - if (isReference()) { - throw tooManyAttributes(); - } - createClasspath().setRefid(r); - setChecked(false); - } - - /** Creates a nested <code><catalogpath></code> element. - * Not allowed if this catalog is itself a reference to another - * catalog -- that is, a catalog cannot both refer to another - * <em>and</em> contain elements or other attributes. - * - * @return a path to be configured as the catalog path. - * @exception BuildException - * if this is a reference and no nested elements are allowed. - */ - public Path createCatalogPath() { - if (isReference()) { - throw noChildrenAllowed(); - } - if (this.catalogPath == null) { - this.catalogPath = new Path(getProject()); - } - setChecked(false); - return this.catalogPath.createPath(); - } - - /** - * Allows catalogpath reference. Not allowed if this catalog is - * itself a reference to another catalog -- that is, a catalog - * cannot both refer to another <em>and</em> contain elements or - * other attributes. - * - * @param r an Ant reference containing a classpath to be used as - * the catalog path. - */ - public void setCatalogPathRef(Reference r) { - if (isReference()) { - throw tooManyAttributes(); - } - createCatalogPath().setRefid(r); - setChecked(false); - } - - - /** - * Returns the catalog path in which to attempt to resolve DTDs. - * - * @return the catalog path - */ - public Path getCatalogPath() { - return getRef().catalogPath; - } - - - /** - * Creates the nested <code><dtd></code> element. Not - * allowed if this catalog is itself a reference to another - * catalog -- that is, a catalog cannot both refer to another - * <em>and</em> contain elements or other attributes. - * - * @param dtd the information about the PUBLIC resource mapping to - * be added to the catalog - * @exception BuildException if this is a reference and no nested - * elements are allowed. - */ - public void addDTD(ResourceLocation dtd) throws BuildException { - if (isReference()) { - throw noChildrenAllowed(); - } - - getElements().addElement(dtd); - setChecked(false); - } - - /** - * Creates the nested <code><entity></code> element. Not - * allowed if this catalog is itself a reference to another - * catalog -- that is, a catalog cannot both refer to another - * <em>and</em> contain elements or other attributes. - * - * @param entity the information about the URI resource mapping to be - * added to the catalog. - * @exception BuildException if this is a reference and no nested - * elements are allowed. - */ - public void addEntity(ResourceLocation entity) throws BuildException { - addDTD(entity); - } - - /** - * Loads a nested <code><xmlcatalog></code> into our - * definition. Not allowed if this catalog is itself a reference - * to another catalog -- that is, a catalog cannot both refer to - * another <em>and</em> contain elements or other attributes. - * - * @param catalog Nested XMLCatalog - */ - public void addConfiguredXMLCatalog(XMLCatalog catalog) { - if (isReference()) { - throw noChildrenAllowed(); - } - - // Add all nested elements to our catalog - getElements().addAll(catalog.getElements()); - - // Append the classpath of the nested catalog - Path nestedClasspath = catalog.getClasspath(); - createClasspath().append(nestedClasspath); - - // Append the catalog path of the nested catalog - Path nestedCatalogPath = catalog.getCatalogPath(); - createCatalogPath().append(nestedCatalogPath); - setChecked(false); - } - - /** - * Makes this instance in effect a reference to another XMLCatalog - * instance. - * - * <p>You must not set another attribute or nest elements inside - * this element if you make it a reference. That is, a catalog - * cannot both refer to another <em>and</em> contain elements or - * attributes.</p> - * - * @param r the reference to which this catalog instance is associated - * @exception BuildException if this instance already has been configured. - */ - public void setRefid(Reference r) throws BuildException { - if (!elements.isEmpty()) { - throw tooManyAttributes(); - } - super.setRefid(r); - } - - /** - * Implements the EntityResolver.resolveEntity() interface method. - * @param publicId the public id to resolve. - * @param systemId the system id to resolve. - * @throws SAXException if there is a parsing problem. - * @throws IOException if there is an IO problem. - * @return the resolved entity. - * @see org.xml.sax.EntityResolver#resolveEntity - */ - public InputSource resolveEntity(String publicId, String systemId) - throws SAXException, IOException { - - if (isReference()) { - return getRef().resolveEntity(publicId, systemId); - } - - dieOnCircularReference(); - - log("resolveEntity: '" + publicId + "': '" + systemId + "'", - Project.MSG_DEBUG); - - InputSource inputSource = - getCatalogResolver().resolveEntity(publicId, systemId); - - if (inputSource == null) { - log("No matching catalog entry found, parser will use: '" - + systemId + "'", Project.MSG_DEBUG); - } - - return inputSource; - } - - /** - * Implements the URIResolver.resolve() interface method. - * @param href an href attribute. - * @param base the base URI. - * @return a Source object, or null if href cannot be resolved. - * @throws TransformerException if an error occurs. - * @see javax.xml.transform.URIResolver#resolve - */ - public Source resolve(String href, String base) - throws TransformerException { - - if (isReference()) { - return getRef().resolve(href, base); - } - - dieOnCircularReference(); - - SAXSource source = null; - - String uri = removeFragment(href); - - log("resolve: '" + uri + "' with base: '" + base + "'", Project.MSG_DEBUG); - - source = (SAXSource) getCatalogResolver().resolve(uri, base); - - if (source == null) { - log("No matching catalog entry found, parser will use: '" - + href + "'", Project.MSG_DEBUG); - // - // Cannot return a null source, because we have to call - // setEntityResolver (see setEntityResolver javadoc comment) - // - source = new SAXSource(); - URL baseURL = null; - try { - if (base == null) { - baseURL = FILE_UTILS.getFileURL(getProject().getBaseDir()); - } else { - baseURL = new URL(base); - } - URL url = (uri.length() == 0 ? baseURL : new URL(baseURL, uri)); - source.setInputSource(new InputSource(url.toString())); - } catch (MalformedURLException ex) { - // At this point we are probably in failure mode, but - // try to use the bare URI as a last gasp - source.setInputSource(new InputSource(uri)); - } - } - - setEntityResolver(source); - return source; - } - - protected synchronized void dieOnCircularReference(Stack<Object> stk, Project p) - throws BuildException { - if (isChecked()) { - return; - } - if (isReference()) { - super.dieOnCircularReference(stk, p); - } else { - if (classpath != null) { - pushAndInvokeCircularReferenceCheck(classpath, stk, p); - } - if (catalogPath != null) { - pushAndInvokeCircularReferenceCheck(catalogPath, stk, p); - } - setChecked(true); - } - } - - /** - * @since Ant 1.6 - */ - private XMLCatalog getRef() { - if (!isReference()) { - return this; - } - return getCheckedRef(XMLCatalog.class, "xmlcatalog"); - } - - /** - * The instance of the CatalogResolver strategy to use. - */ - private CatalogResolver catalogResolver = null; - - /** - * Factory method for creating the appropriate CatalogResolver - * strategy implementation. - * <p> Until we query the classpath, we don't know whether the Apache - * resolver (Norm Walsh's library from xml-commons) is available or not. - * This method determines whether the library is available and creates the - * appropriate implementation of CatalogResolver based on the answer.</p> - * <p>This is an application of the Gang of Four Strategy Pattern - * combined with Template Method.</p> - */ - private CatalogResolver getCatalogResolver() { - - if (catalogResolver == null) { - - AntClassLoader loader = null; - // Memory-Leak in line below - loader = getProject().createClassLoader(Path.systemClasspath); - - try { - Class<?> clazz = Class.forName(APACHE_RESOLVER, true, loader); - - // The Apache resolver is present - Need to check if it can - // be seen by the catalog resolver class. Start by getting - // the actual loader - ClassLoader apacheResolverLoader = clazz.getClassLoader(); - - // load the base class through this loader. - Class<?> baseResolverClass - = Class.forName(CATALOG_RESOLVER, true, apacheResolverLoader); - - // and find its actual loader - ClassLoader baseResolverLoader - = baseResolverClass.getClassLoader(); - - // We have the loader which is being used to load the - // CatalogResolver. Can it see the ApacheResolver? The - // base resolver will only be able to create the ApacheResolver - // if it can see it - doesn't use the context loader. - clazz = Class.forName(APACHE_RESOLVER, true, baseResolverLoader); - - Object obj = clazz.newInstance(); - // - // Success! The xml-commons resolver library is - // available, so use it. - // - catalogResolver = new ExternalResolver(clazz, obj); - } catch (Throwable ex) { - // - // The xml-commons resolver library is not - // available, so we can't use it. - // - catalogResolver = new InternalResolver(); - if (getCatalogPath() != null - && getCatalogPath().list().length != 0) { - log("Warning: XML resolver not found; external catalogs" - + " will be ignored", Project.MSG_WARN); - } - log("Failed to load Apache resolver: " + ex, Project.MSG_DEBUG); - } - } - return catalogResolver; - } - - /** - * <p>This is called from the URIResolver to set an EntityResolver - * on the SAX parser to be used for new XML documents that are - * encountered as a result of the document() function, xsl:import, - * or xsl:include. This is done because the XSLT processor calls - * out to the SAXParserFactory itself to create a new SAXParser to - * parse the new document. The new parser does not automatically - * inherit the EntityResolver of the original (although arguably - * it should). See below:</p> - * - * <tt>"If an application wants to set the ErrorHandler or - * EntityResolver for an XMLReader used during a transformation, - * it should use a URIResolver to return the SAXSource which - * provides (with getXMLReader) a reference to the XMLReader"</tt> - * - * <p>...quoted from page 118 of the Java API for XML - * Processing 1.1 specification</p> - * - */ - private void setEntityResolver(SAXSource source) throws TransformerException { - - XMLReader reader = source.getXMLReader(); - if (reader == null) { - SAXParserFactory spFactory = SAXParserFactory.newInstance(); - spFactory.setNamespaceAware(true); - try { - reader = spFactory.newSAXParser().getXMLReader(); - } catch (ParserConfigurationException ex) { - throw new TransformerException(ex); - } catch (SAXException ex) { - throw new TransformerException(ex); - } - } - reader.setEntityResolver(this); - source.setXMLReader(reader); - } - - /** - * Find a ResourceLocation instance for the given publicId. - * - * @param publicId the publicId of the Resource for which local information - * is required. - * @return a ResourceLocation instance with information on the local location - * of the Resource or null if no such information is available. - */ - private ResourceLocation findMatchingEntry(String publicId) { - for (ResourceLocation element : getElements()) { - if (element.getPublicId().equals(publicId)) { - return element; - } - } - return null; - } - - /** - * Utility method to remove trailing fragment from a URI. - * For example, - * <code>http://java.sun.com/index.html#chapter1</code> - * would return <code>http://java.sun.com/index.html</code>. - * - * @param uri The URI to process. It may or may not contain a - * fragment. - * @return The URI sans fragment. - */ - private String removeFragment(String uri) { - String result = uri; - int hashPos = uri.indexOf("#"); - if (hashPos >= 0) { - result = uri.substring(0, hashPos); - } - return result; - } - - /** - * Utility method to lookup a ResourceLocation in the filesystem. - * - * @return An InputSource for reading the file, or <code>null</code> - * if the file does not exist or is not readable. - */ - private InputSource filesystemLookup(ResourceLocation matchingEntry) { - - String uri = matchingEntry.getLocation(); - // the following line seems to be necessary on Windows under JDK 1.2 - uri = uri.replace(File.separatorChar, '/'); - URL baseURL = null; - - // - // The ResourceLocation may specify a relative path for its - // location attribute. This is resolved using the appropriate - // base. - // - if (matchingEntry.getBase() != null) { - baseURL = matchingEntry.getBase(); - } else { - try { - baseURL = FILE_UTILS.getFileURL(getProject().getBaseDir()); - } catch (MalformedURLException ex) { - throw new BuildException("Project basedir cannot be converted to a URL"); - } - } - - InputSource source = null; - URL url = null; - try { - url = new URL(baseURL, uri); - } catch (MalformedURLException ex) { - // this processing is useful under Windows when the location of the DTD - // has been given as an absolute path - // see Bugzilla Report 23913 - File testFile = new File(uri); - if (testFile.exists() && testFile.canRead()) { - log("uri : '" - + uri + "' matches a readable file", Project.MSG_DEBUG); - try { - url = FILE_UTILS.getFileURL(testFile); - } catch (MalformedURLException ex1) { - throw new BuildException( - "could not find an URL for :" + testFile.getAbsolutePath()); - } - } else { - log("uri : '" - + uri + "' does not match a readable file", Project.MSG_DEBUG); - - } - } - - if (url != null && url.getProtocol().equals("file")) { - String fileName = FILE_UTILS.fromURI(url.toString()); - if (fileName != null) { - log("fileName " + fileName, Project.MSG_DEBUG); - File resFile = new File(fileName); - if (resFile.exists() && resFile.canRead()) { - try { - source = new InputSource(new FileInputStream(resFile)); - String sysid = JAXPUtils.getSystemId(resFile); - source.setSystemId(sysid); - log("catalog entry matched a readable file: '" - + sysid + "'", Project.MSG_DEBUG); - } catch (IOException ex) { - // ignore - } - } - } - } - return source; - } - - /** - * Utility method to lookup a ResourceLocation in the classpath. - * - * @return An InputSource for reading the resource, or <code>null</code> - * if the resource does not exist in the classpath or is not readable. - */ - private InputSource classpathLookup(ResourceLocation matchingEntry) { - - InputSource source = null; - - AntClassLoader loader = null; - Path cp = classpath; - if (cp != null) { - cp = classpath.concatSystemClasspath("ignore"); - } else { - cp = (new Path(getProject())).concatSystemClasspath("last"); - } - loader = getProject().createClassLoader(cp); - - // - // for classpath lookup we ignore the base directory - // - InputStream is - = loader.getResourceAsStream(matchingEntry.getLocation()); - - if (is != null) { - source = new InputSource(is); - URL entryURL = loader.getResource(matchingEntry.getLocation()); - String sysid = entryURL.toExternalForm(); - source.setSystemId(sysid); - log("catalog entry matched a resource in the classpath: '" - + sysid + "'", Project.MSG_DEBUG); - } - - return source; - } - - /** - * Utility method to lookup a ResourceLocation in URL-space. - * - * @return An InputSource for reading the resource, or <code>null</code> - * if the resource does not identify a valid URL or is not readable. - */ - private InputSource urlLookup(ResourceLocation matchingEntry) { - - String uri = matchingEntry.getLocation(); - URL baseURL = null; - - // - // The ResourceLocation may specify a relative url for its - // location attribute. This is resolved using the appropriate - // base. - // - if (matchingEntry.getBase() != null) { - baseURL = matchingEntry.getBase(); - } else { - try { - baseURL = FILE_UTILS.getFileURL(getProject().getBaseDir()); - } catch (MalformedURLException ex) { - throw new BuildException("Project basedir cannot be converted to a URL"); - } - } - - InputSource source = null; - URL url = null; - - try { - url = new URL(baseURL, uri); - } catch (MalformedURLException ex) { - // ignore - } - - if (url != null) { - try { - InputStream is = null; - URLConnection conn = url.openConnection(); - if (conn != null) { - conn.setUseCaches(false); - is = conn.getInputStream(); - } - if (is != null) { - source = new InputSource(is); - String sysid = url.toExternalForm(); - source.setSystemId(sysid); - log("catalog entry matched as a URL: '" - + sysid + "'", Project.MSG_DEBUG); - } - } catch (IOException ex) { - // ignore - } - } - - return source; - - } - - /** - * Interface implemented by both the InternalResolver strategy and - * the ExternalResolver strategy. - */ - private interface CatalogResolver extends URIResolver, EntityResolver { - - InputSource resolveEntity(String publicId, String systemId); - - Source resolve(String href, String base) throws TransformerException; - } - - /** - * The InternalResolver strategy is used if the Apache resolver - * library (Norm Walsh's library from xml-commons) is not - * available. In this case, external catalog files will be - * ignored. - * - */ - private class InternalResolver implements CatalogResolver { - - public InternalResolver() { - log("Apache resolver library not found, internal resolver will be used", - Project.MSG_VERBOSE); - } - - public InputSource resolveEntity(String publicId, - String systemId) { - InputSource result = null; - ResourceLocation matchingEntry = findMatchingEntry(publicId); - - if (matchingEntry != null) { - - log("Matching catalog entry found for publicId: '" - + matchingEntry.getPublicId() + "' location: '" - + matchingEntry.getLocation() + "'", - Project.MSG_DEBUG); - - result = filesystemLookup(matchingEntry); - - if (result == null) { - result = classpathLookup(matchingEntry); - } - - if (result == null) { - result = urlLookup(matchingEntry); - } - } - return result; - } - - public Source resolve(String href, String base) - throws TransformerException { - - SAXSource result = null; - InputSource source = null; - - ResourceLocation matchingEntry = findMatchingEntry(href); - - if (matchingEntry != null) { - - log("Matching catalog entry found for uri: '" - + matchingEntry.getPublicId() + "' location: '" - + matchingEntry.getLocation() + "'", - Project.MSG_DEBUG); - - // - // Use the passed in base in preference to the base - // from matchingEntry, which is either null or the - // directory in which the external catalog file from - // which it was obtained is located. We make a copy - // so matchingEntry's original base is untouched. - // - // This is the standard behavior as per my reading of - // the JAXP and XML Catalog specs. CKS 11/7/2002 - // - ResourceLocation entryCopy = matchingEntry; - if (base != null) { - try { - URL baseURL = new URL(base); - entryCopy = new ResourceLocation(); - entryCopy.setBase(baseURL); - } catch (MalformedURLException ex) { - // ignore - } - } - entryCopy.setPublicId(matchingEntry.getPublicId()); - entryCopy.setLocation(matchingEntry.getLocation()); - - source = filesystemLookup(entryCopy); - - if (source == null) { - source = classpathLookup(entryCopy); - } - - if (source == null) { - source = urlLookup(entryCopy); - } - - if (source != null) { - result = new SAXSource(source); - } - } - return result; - } - } - - /** - * The ExternalResolver strategy is used if the Apache resolver - * library (Norm Walsh's library from xml-commons) is available in - * the classpath. The ExternalResolver is a essentially a superset - * of the InternalResolver. - * - */ - private class ExternalResolver implements CatalogResolver { - - private Method setXMLCatalog = null; - private Method parseCatalog = null; - private Method resolveEntity = null; - private Method resolve = null; - - /** The instance of the ApacheCatalogResolver bridge class */ - private Object resolverImpl = null; - - private boolean externalCatalogsProcessed = false; - - public ExternalResolver(Class<?> resolverImplClass, - Object resolverImpl) { - - this.resolverImpl = resolverImpl; - - // - // Get Method instances for each of the methods we need to - // call on the resolverImpl using reflection. We can't - // call them directly, because they require on the - // xml-commons resolver library which may not be available - // in the classpath. - // - try { - setXMLCatalog = - resolverImplClass.getMethod("setXMLCatalog", - new Class[] {XMLCatalog.class}); - - parseCatalog = - resolverImplClass.getMethod("parseCatalog", - new Class[] {String.class}); - - resolveEntity = - resolverImplClass.getMethod("resolveEntity", - new Class[] {String.class, String.class}); - - resolve = - resolverImplClass.getMethod("resolve", - new Class[] {String.class, String.class}); - } catch (NoSuchMethodException ex) { - throw new BuildException(ex); - } - - log("Apache resolver library found, xml-commons resolver will be used", - Project.MSG_VERBOSE); - } - - public InputSource resolveEntity(String publicId, - String systemId) { - InputSource result = null; - - processExternalCatalogs(); - - ResourceLocation matchingEntry = findMatchingEntry(publicId); - - if (matchingEntry != null) { - - log("Matching catalog entry found for publicId: '" - + matchingEntry.getPublicId() + "' location: '" - + matchingEntry.getLocation() + "'", - Project.MSG_DEBUG); - - result = filesystemLookup(matchingEntry); - - if (result == null) { - result = classpathLookup(matchingEntry); - } - - if (result == null) { - try { - result = - (InputSource) resolveEntity.invoke(resolverImpl, - new Object[] {publicId, systemId}); - } catch (Exception ex) { - throw new BuildException(ex); - } - } - } else { - // - // We didn't match a ResourceLocation, but since we - // only support PUBLIC and URI entry types internally, - // it is still possible that there is another entry in - // an external catalog that will match. We call - // Apache resolver's resolveEntity method to cover - // this possibility. - // - try { - result = - (InputSource) resolveEntity.invoke(resolverImpl, - new Object[] {publicId, systemId}); - } catch (Exception ex) { - throw new BuildException(ex); - } - } - - return result; - } - - public Source resolve(String href, String base) - throws TransformerException { - - SAXSource result = null; - InputSource source = null; - - processExternalCatalogs(); - - ResourceLocation matchingEntry = findMatchingEntry(href); - - if (matchingEntry != null) { - - log("Matching catalog entry found for uri: '" - + matchingEntry.getPublicId() + "' location: '" - + matchingEntry.getLocation() + "'", - Project.MSG_DEBUG); - - // - // Use the passed in base in preference to the base - // from matchingEntry, which is either null or the - // directory in which the external catalog file from - // which it was obtained is located. We make a copy - // so matchingEntry's original base is untouched. Of - // course, if there is no base, no need to make a - // copy... - // - // This is the standard behavior as per my reading of - // the JAXP and XML Catalog specs. CKS 11/7/2002 - // - ResourceLocation entryCopy = matchingEntry; - if (base != null) { - try { - URL baseURL = new URL(base); - entryCopy = new ResourceLocation(); - entryCopy.setBase(baseURL); - } catch (MalformedURLException ex) { - // ignore - } - } - entryCopy.setPublicId(matchingEntry.getPublicId()); - entryCopy.setLocation(matchingEntry.getLocation()); - - source = filesystemLookup(entryCopy); - - if (source == null) { - source = classpathLookup(entryCopy); - } - - if (source != null) { - result = new SAXSource(source); - } else { - try { - result = - (SAXSource) resolve.invoke(resolverImpl, - new Object[] {href, base}); - } catch (Exception ex) { - throw new BuildException(ex); - } - } - } else { - // - // We didn't match a ResourceLocation, but since we - // only support PUBLIC and URI entry types internally, - // it is still possible that there is another entry in - // an external catalog that will match. We call - // Apache resolver's resolveEntity method to cover - // this possibility. - // - if (base == null) { - try { - base = FILE_UTILS.getFileURL(getProject().getBaseDir()).toString(); - } catch (MalformedURLException x) { - throw new TransformerException(x); - } - } - try { - result = - (SAXSource) resolve.invoke(resolverImpl, - new Object[] {href, base}); - } catch (Exception ex) { - throw new BuildException(ex); - } - } - return result; - } - - /** - * Process each external catalog file specified in a - * <code><catalogpath></code>. It will be - * parsed by the resolver library, and the individual elements - * will be added back to us (that is, the controlling - * XMLCatalog instance) via a callback mechanism. - */ - private void processExternalCatalogs() { - - if (!externalCatalogsProcessed) { - - try { - setXMLCatalog.invoke(resolverImpl, - new Object[] {XMLCatalog.this}); - } catch (Exception ex) { - throw new BuildException(ex); - } - - // Parse each catalog listed in nested <catalogpath> elements - Path catPath = getCatalogPath(); - if (catPath != null) { - log("Using catalogpath '" + getCatalogPath() + "'", - Project.MSG_DEBUG); - String[] catPathList = getCatalogPath().list(); - - for (int i = 0; i < catPathList.length; i++) { - File catFile = new File(catPathList[i]); - log("Parsing " + catFile, Project.MSG_DEBUG); - try { - parseCatalog.invoke(resolverImpl, - new Object[] {catFile.getPath()}); - } catch (Exception ex) { - throw new BuildException(ex); - } - } - } - } - externalCatalogsProcessed = true; - } - } -} //-- XMLCatalog diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/ZipFileSet.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/ZipFileSet.java deleted file mode 100644 index 24f0ccd5..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/ZipFileSet.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * 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 org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Project; - -/** - * A ZipFileSet is a FileSet with extra attributes useful in the context of - * Zip/Jar tasks. - * - * A ZipFileSet extends FileSets with the ability to extract a subset of the - * entries of a Zip file for inclusion in another Zip file. It also includes - * a prefix attribute which is prepended to each entry in the output Zip file. - * - * Since ant 1.6 ZipFileSet can be defined with an id and referenced in packaging tasks - * - */ -public class ZipFileSet extends ArchiveFileSet { - - /** Constructor for ZipFileSet */ - public ZipFileSet() { - super(); - } - - /** - * Constructor using a fileset argument. - * @param fileset the fileset to use - */ - protected ZipFileSet(FileSet fileset) { - super(fileset); - } - - /** - * Constructor using a zipfileset argument. - * @param fileset the zipfileset to use - */ - protected ZipFileSet(ZipFileSet fileset) { - super(fileset); - } - - /** - * Return a new archive scanner based on this one. - * @return a new ZipScanner with the same encoding as this one. - */ - protected ArchiveScanner newArchiveScanner() { - ZipScanner zs = new ZipScanner(); - zs.setEncoding(getEncoding()); - return zs; - } - - /** - * A ZipFileset accepts another ZipFileSet or a FileSet as reference - * FileSets are often used by the war task for the lib attribute - * @param p the project to use - * @return the abstract fileset instance - */ - protected AbstractFileSet getRef(Project p) { - dieOnCircularReference(p); - Object o = getRefid().getReferencedObject(p); - if (o instanceof ZipFileSet) { - return (AbstractFileSet) o; - } else if (o instanceof FileSet) { - ZipFileSet zfs = new ZipFileSet((FileSet) o); - configureFileSet(zfs); - return zfs; - } else { - String msg = getRefid().getRefId() + " doesn\'t denote a zipfileset or a fileset"; - throw new BuildException(msg); - } - } - - /** - * Return a ZipFileSet that has the same properties - * as this one. - * @return the cloned zipFileSet - */ - public Object clone() { - if (isReference()) { - return ((ZipFileSet) getRef(getProject())).clone(); - } else { - return super.clone(); - } - } - - /** - * A check attributes for zipFileSet. - * If there is a reference, and - * it is a ZipFileSet, the zip fileset attributes - * cannot be used. - */ - private void checkZipFileSetAttributesAllowed() { - if (getProject() == null - || (isReference() - && (getRefid().getReferencedObject( - getProject()) - instanceof ZipFileSet))) { - checkAttributesAllowed(); - } - } - -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/ZipScanner.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/ZipScanner.java deleted file mode 100644 index e64b7172..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/ZipScanner.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * 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.IOException; -import java.util.Enumeration; -import java.util.Map; -import java.util.zip.ZipException; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.types.resources.FileProvider; -import org.apache.tools.ant.types.resources.ZipResource; -import org.apache.tools.zip.ZipEntry; -import org.apache.tools.zip.ZipFile; - -/** - * Scans zip archives for resources. - */ -public class ZipScanner extends ArchiveScanner { - - /** - * Fills the file and directory maps with resources read from the - * archive. - * - * @param src the archive to scan. - * @param encoding encoding used to encode file names inside the archive. - * @param fileEntries Map (name to resource) of non-directory - * resources found inside the archive. - * @param matchFileEntries Map (name to resource) of non-directory - * resources found inside the archive that matched all include - * patterns and didn't match any exclude patterns. - * @param dirEntries Map (name to resource) of directory - * resources found inside the archive. - * @param matchDirEntries Map (name to resource) of directory - * resources found inside the archive that matched all include - * patterns and didn't match any exclude patterns. - */ - protected void fillMapsFromArchive(Resource src, String encoding, - Map<String, Resource> fileEntries, Map<String, Resource> matchFileEntries, - Map<String, Resource> dirEntries, Map<String, Resource> matchDirEntries) { - ZipEntry entry = null; - ZipFile zf = null; - - File srcFile = null; - FileProvider fp = src.as(FileProvider.class); - if (fp != null) { - srcFile = fp.getFile(); - } else { - throw new BuildException("Only file provider resources are supported"); - } - - try { - try { - zf = new ZipFile(srcFile, encoding); - } catch (ZipException ex) { - throw new BuildException("Problem reading " + srcFile, ex); - } catch (IOException ex) { - throw new BuildException("Problem opening " + srcFile, ex); - } - Enumeration<ZipEntry> e = zf.getEntries(); - while (e.hasMoreElements()) { - entry = e.nextElement(); - Resource r = new ZipResource(srcFile, encoding, entry); - String name = entry.getName(); - if (entry.isDirectory()) { - name = trimSeparator(name); - dirEntries.put(name, r); - if (match(name)) { - matchDirEntries.put(name, r); - } - } else { - fileEntries.put(name, r); - if (match(name)) { - matchFileEntries.put(name, r); - } - } - } - } finally { - ZipFile.closeQuietly(zf); - } - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/conditions/antlib.xml b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/conditions/antlib.xml deleted file mode 100644 index ff407b28..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/conditions/antlib.xml +++ /dev/null @@ -1,93 +0,0 @@ -<?xml version="1.0"?> -<antlib> - <!-- -/* - * 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. - * - */ - - --> - <!-- Ant 1.6+ antlib declaration for conditions: - Use with the declaration xmlns:cond="antlib:org.apache.tools.ant.types.conditions" - to - trigger Ant's autoload of this file into namespace 'cond' (or whatever name - suits). - - Please keep this list in alphabetical order; it is easier to verify that way. - - Additionally, ConditionBase uses this antlib to discover built-in conditions. - Prior to Ant 1.7, a new built-in condition required an addXXX method to be - added to ConditionBase. Conditions added in or after version 1.7 need only - to be added to this antlib. - --> - - <typedef name="and" onerror="ignore" - classname="org.apache.tools.ant.taskdefs.condition.And"/> - <typedef name="antversion" onerror="ignore" - classname="org.apache.tools.ant.taskdefs.condition.AntVersion"/> - <typedef name="contains" onerror="ignore" - classname="org.apache.tools.ant.taskdefs.condition.Contains"/> - <typedef name="equals" onerror="ignore" - classname="org.apache.tools.ant.taskdefs.condition.Equals"/> - <typedef name="filesmatch" onerror="ignore" - classname="org.apache.tools.ant.taskdefs.condition.FilesMatch"/> - <typedef name="hasfreespace" onerror="ignore" - classname="org.apache.tools.ant.taskdefs.condition.HasFreeSpace"/> - <typedef name="http" onerror="ignore" - classname="org.apache.tools.ant.taskdefs.condition.Http"/> - <typedef name="isfailure" onerror="ignore" - classname="org.apache.tools.ant.taskdefs.condition.IsFailure"/> - <typedef name="isfalse" onerror="ignore" - classname="org.apache.tools.ant.taskdefs.condition.IsFalse"/> - <typedef name="isfileselected" onerror="ignore" - classname="org.apache.tools.ant.taskdefs.condition.IsFileSelected"/> - <typedef name="islastmodified" onerror="ignore" - classname="org.apache.tools.ant.taskdefs.condition.IsLastModified"/> - <typedef name="isreachable" onerror="ignore" - classname="org.apache.tools.ant.taskdefs.condition.IsReachable"/> - <typedef name="isreference" onerror="ignore" - classname="org.apache.tools.ant.taskdefs.condition.IsReference"/> - <typedef name="isset" onerror="ignore" - classname="org.apache.tools.ant.taskdefs.condition.IsSet"/> - <typedef name="issigned" onerror="ignore" - classname="org.apache.tools.ant.taskdefs.condition.IsSigned"/> - <typedef name="istrue" onerror="ignore" - classname="org.apache.tools.ant.taskdefs.condition.IsTrue"/> - <typedef name="not" onerror="ignore" - classname="org.apache.tools.ant.taskdefs.condition.Not"/> - <typedef name="matches" onerror="ignore" - classname="org.apache.tools.ant.taskdefs.condition.Matches"/> - <typedef name="or" onerror="ignore" - classname="org.apache.tools.ant.taskdefs.condition.Or"/> - <typedef name="os" onerror="ignore" - classname="org.apache.tools.ant.taskdefs.condition.Os"/> - <typedef name="parsersupports" onerror="ignore" - classname="org.apache.tools.ant.taskdefs.condition.ParserSupports"/> - <typedef name="resourceexists" onerror="ignore" - classname="org.apache.tools.ant.taskdefs.condition.ResourceExists"/> - <typedef name="resourcesmatch" onerror="ignore" - classname="org.apache.tools.ant.taskdefs.condition.ResourcesMatch"/> - <typedef name="resourcecontains" onerror="ignore" - classname="org.apache.tools.ant.taskdefs.condition.ResourceContains"/> - <typedef name="scriptcondition" onerror="ignore" - classname="org.apache.tools.ant.types.optional.ScriptCondition"/> - <typedef name="socket" onerror="ignore" - classname="org.apache.tools.ant.taskdefs.condition.Socket"/> - <typedef name="typefound" onerror="ignore" - classname="org.apache.tools.ant.taskdefs.condition.TypeFound"/> - <typedef name="xor" onerror="ignore" - classname="org.apache.tools.ant.taskdefs.condition.Xor"/> -</antlib> diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/defaults.properties b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/defaults.properties deleted file mode 100644 index 29771dbb..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/defaults.properties +++ /dev/null @@ -1,101 +0,0 @@ -# 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. -# -description=org.apache.tools.ant.types.Description -filterchain=org.apache.tools.ant.types.FilterChain -filterreader=org.apache.tools.ant.types.AntFilterReader -filterset=org.apache.tools.ant.types.FilterSet -mapper=org.apache.tools.ant.types.Mapper -redirector=org.apache.tools.ant.types.RedirectorElement -patternset=org.apache.tools.ant.types.PatternSet -regexp=org.apache.tools.ant.types.RegularExpression -substitution=org.apache.tools.ant.types.Substitution -xmlcatalog=org.apache.tools.ant.types.XMLCatalog -extensionSet=org.apache.tools.ant.taskdefs.optional.extension.ExtensionSet -extension=org.apache.tools.ant.taskdefs.optional.extension.ExtensionAdapter -selector=org.apache.tools.ant.types.selectors.SelectSelector -signedselector=org.apache.tools.ant.types.selectors.SignedSelector -scriptfilter=org.apache.tools.ant.types.optional.ScriptFilter -assertions=org.apache.tools.ant.types.Assertions -concatfilter=org.apache.tools.ant.filters.ConcatFilter -mavenrepository=org.apache.tools.ant.taskdefs.repository.MavenRepository -scriptselector=org.apache.tools.ant.types.optional.ScriptSelector -scriptmapper=org.apache.tools.ant.types.optional.ScriptMapper - -# different filename mappers -identitymapper=org.apache.tools.ant.util.IdentityMapper -flattenmapper=org.apache.tools.ant.util.FlatFileNameMapper -globmapper=org.apache.tools.ant.util.GlobPatternMapper -mergemapper=org.apache.tools.ant.util.MergingMapper -regexpmapper=org.apache.tools.ant.util.RegexpPatternMapper -packagemapper=org.apache.tools.ant.util.PackageNameMapper -unpackagemapper=org.apache.tools.ant.util.UnPackageNameMapper -compositemapper=org.apache.tools.ant.util.CompositeMapper -chainedmapper=org.apache.tools.ant.util.ChainedMapper -filtermapper=org.apache.tools.ant.types.mappers.FilterMapper -firstmatchmapper=org.apache.tools.ant.util.FirstMatchMapper -cutdirsmapper=org.apache.tools.ant.types.mappers.CutDirsMapper - -#this condition is in here because it is the sole -#condition defined in Ant1.6 -#please add new conditions to oata.types.conditions/antlib.xml instead of -#here, to avoid namespace clash with things like selectors. -isfileselected=org.apache.tools.ant.taskdefs.condition.IsFileSelected -scriptcondition=org.apache.tools.ant.types.optional.ScriptCondition - -#ResourceCollections: -dirset=org.apache.tools.ant.types.DirSet -filelist=org.apache.tools.ant.types.FileList -fileset=org.apache.tools.ant.types.FileSet -path=org.apache.tools.ant.types.Path -propertyset=org.apache.tools.ant.types.PropertySet -zipfileset=org.apache.tools.ant.types.ZipFileSet -classfileset=org.apache.tools.ant.types.optional.depend.ClassfileSet -libfileset=org.apache.tools.ant.taskdefs.optional.extension.LibFileSet -files=org.apache.tools.ant.types.resources.Files -restrict=org.apache.tools.ant.types.resources.Restrict -union=org.apache.tools.ant.types.resources.Union -difference=org.apache.tools.ant.types.resources.Difference -intersect=org.apache.tools.ant.types.resources.Intersect -sort=org.apache.tools.ant.types.resources.Sort -resources=org.apache.tools.ant.types.resources.Resources -allbutfirst=org.apache.tools.ant.types.resources.AllButFirst -allbutlast=org.apache.tools.ant.types.resources.AllButLast -first=org.apache.tools.ant.types.resources.First -last=org.apache.tools.ant.types.resources.Last -tarfileset=org.apache.tools.ant.types.TarFileSet -tokens=org.apache.tools.ant.types.resources.Tokens -mappedresources=org.apache.tools.ant.types.resources.MappedResourceCollection -archives=org.apache.tools.ant.types.resources.Archives -resourcelist=org.apache.tools.ant.types.resources.ResourceList - -#Resources (single-element ResourceCollections): -resource=org.apache.tools.ant.types.Resource -file=org.apache.tools.ant.types.resources.FileResource -url=org.apache.tools.ant.types.resources.URLResource -string=org.apache.tools.ant.types.resources.StringResource -zipentry=org.apache.tools.ant.types.resources.ZipResource -propertyresource=org.apache.tools.ant.types.resources.PropertyResource -tarentry=org.apache.tools.ant.types.resources.TarResource -gzipresource=org.apache.tools.ant.types.resources.GZipResource -bzip2resource=org.apache.tools.ant.types.resources.BZip2Resource -javaresource=org.apache.tools.ant.types.resources.JavaResource -multirootfileset=org.apache.tools.ant.types.resources.MultiRootFileSet -javaconstant=org.apache.tools.ant.types.resources.JavaConstantResource - -#tokenizer implementations -linetokenizer=org.apache.tools.ant.util.LineTokenizer -stringtokenizer=org.apache.tools.ant.util.StringTokenizer -filetokenizer=org.apache.tools.ant.util.FileTokenizer diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/mappers/CutDirsMapper.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/mappers/CutDirsMapper.java deleted file mode 100644 index b9e7cfb4..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/mappers/CutDirsMapper.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * 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.mappers; - -import java.io.File; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.util.FileNameMapper; - -/** - * A mapper that strips of the a configurable number of leading - * directories from a file name. - * - * <p>This mapper was inspired by a user-list thread that mentioned - * wget's --cut-dirs option.</p> - * - * @see <a href="http://mail-archives.apache.org/mod_mbox/ant-user/201009.mbox/%3C51772743BEA5D44A9EA5BF52AADDD6FB010E96F6@hammai008.delphi.local%3E"> - * simplify copy with regexpmapper</a> - */ -public class CutDirsMapper implements FileNameMapper { - private int dirs = 0; - - /** - * The number of leading directories to cut. - */ - public void setDirs(final int dirs) { - this.dirs = dirs; - } - - /** - * Empty implementation. - * @param ignore ignored. - */ - public void setFrom(final String ignore) { - } - - /** - * Empty implementation. - * @param ignore ignored. - */ - public void setTo(final String ignore) { - } - - /** {@inheritDoc}. */ - public String[] mapFileName(final String sourceFileName) { - if (dirs <= 0) { - throw new BuildException("dirs must be set to a positive number"); - } - final char fileSep = File.separatorChar; - final String fileSepCorrected = - sourceFileName.replace('/', fileSep).replace('\\', fileSep); - int nthMatch = fileSepCorrected.indexOf(fileSep); - for (int n = 1; nthMatch > -1 && n < dirs; n++) { - nthMatch = fileSepCorrected.indexOf(fileSep, nthMatch + 1); - } - if (nthMatch == -1) { - return null; - } - return new String[] {sourceFileName.substring(nthMatch + 1)}; - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/mappers/FilterMapper.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/mappers/FilterMapper.java deleted file mode 100644 index 501da500..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/mappers/FilterMapper.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * 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.mappers; - -import java.io.Reader; -import java.io.StringReader; -import java.util.Vector; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.UnsupportedAttributeException; -import org.apache.tools.ant.filters.util.ChainReaderHelper; -import org.apache.tools.ant.types.FilterChain; -import org.apache.tools.ant.util.FileNameMapper; -import org.apache.tools.ant.util.FileUtils; - -/** - * This is a FileNameMapper based on a FilterChain. - */ -public class FilterMapper extends FilterChain implements FileNameMapper { - - private static final int BUFFER_SIZE = 8192; - - /** - * From attribute not supported. - * @param from a string - * @throws BuildException always - */ - public void setFrom(String from) { - throw new UnsupportedAttributeException( - "filtermapper doesn't support the \"from\" attribute.", "from"); - } - - /** - * From attribute not supported. - * @param to a string - * @throws BuildException always - */ - public void setTo(String to) { - throw new UnsupportedAttributeException( - "filtermapper doesn't support the \"to\" attribute.", "to"); - } - - /** - * Return the result of the filters on the sourcefilename. - * @param sourceFileName the filename to map - * @return a one-element array of converted filenames, or null if - * the filterchain returns an empty string. - */ - public String[] mapFileName(String sourceFileName) { - try { - Reader stringReader = new StringReader(sourceFileName); - ChainReaderHelper helper = new ChainReaderHelper(); - helper.setBufferSize(BUFFER_SIZE); - helper.setPrimaryReader(stringReader); - helper.setProject(getProject()); - Vector<FilterChain> filterChains = new Vector<FilterChain>(); - filterChains.add(this); - helper.setFilterChains(filterChains); - String result = FileUtils.safeReadFully(helper.getAssembledReader()); - if (result.length() == 0) { - return null; - } else { - return new String[] {result}; - } - } catch (BuildException ex) { - throw ex; - } catch (Exception ex) { - throw new BuildException(ex); - } - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/AbstractScriptComponent.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/AbstractScriptComponent.java deleted file mode 100644 index df5a3cec..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/AbstractScriptComponent.java +++ /dev/null @@ -1,158 +0,0 @@ -/* - * 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.optional; - -import java.io.File; - -import org.apache.tools.ant.Project; -import org.apache.tools.ant.ProjectComponent; -import org.apache.tools.ant.types.Path; -import org.apache.tools.ant.types.Reference; -import org.apache.tools.ant.util.ScriptRunnerBase; -import org.apache.tools.ant.util.ScriptRunnerHelper; - -/** - * This is a {@link ProjectComponent} that has script support built in - * Use it as a foundation for scriptable things. - */ -public abstract class AbstractScriptComponent extends ProjectComponent { - /** - * script runner helper - */ - private ScriptRunnerHelper helper = new ScriptRunnerHelper(); - - /** - * script runner. - */ - private ScriptRunnerBase runner = null; - - /** - * Set the project. - * @param project the owner of this component. - */ - public void setProject(Project project) { - super.setProject(project); - helper.setProjectComponent(this); - } - - /** - * Get our script runner - * @return the runner - */ - public ScriptRunnerBase getRunner() { - initScriptRunner(); - return runner; - } - - /** - * Load the script from an external file ; optional. - * - * @param file the file containing the script source. - */ - public void setSrc(File file) { - helper.setSrc(file); - } - - /** - * The script text. - * - * @param text a component of the script text to be added. - */ - public void addText(String text) { - helper.addText(text); - } - - /** - * Defines the manager. - * - * @param manager the scripting manager. - */ - public void setManager(String manager) { - helper.setManager(manager); - } - - /** - * Defines the language (required). - * - * @param language the scripting language name for the script. - */ - public void setLanguage(String language) { - helper.setLanguage(language); - } - - /** - * Initialize the script runner. Calls this before running the system - */ - protected void initScriptRunner() { - if (runner != null) { - return; - } - helper.setProjectComponent(this); - runner = helper.getScriptRunner(); - } - /** - * Set the classpath to be used when searching for classes and resources. - * - * @param classpath an Ant Path object containing the search path. - */ - public void setClasspath(Path classpath) { - helper.setClasspath(classpath); - } - - /** - * Classpath to be used when searching for classes and resources. - * - * @return an empty Path instance to be configured by Ant. - */ - public Path createClasspath() { - return helper.createClasspath(); - } - - /** - * Set the classpath by reference. - * - * @param r a Reference to a Path instance to be used as the classpath - * value. - */ - public void setClasspathRef(Reference r) { - helper.setClasspathRef(r); - } - - /** - * Run a script - * @param execName name of the script - */ - protected void executeScript(String execName) { - getRunner().executeScript(execName); - } - - /** - * Set the setbeans attribute. - * If this is true, <script> will create variables in the - * script instance for all - * properties, targets and references of the current project. - * It this is false, only the project and self variables will - * be set. - * The default is true. - * @param setBeans the value to set. - * @since Ant 1.8.0 - */ - public void setSetBeans(boolean setBeans) { - helper.setSetBeans(setBeans); - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/ScriptCondition.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/ScriptCondition.java deleted file mode 100644 index fac02bfa..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/ScriptCondition.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * 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.optional; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.taskdefs.condition.Condition; - -/** - * A condition that lets you include script. - * The condition component sets a bean "self", whose attribute "value" - * must be set to true for the condition to succeed, false to fail. - * The default is 'false' - */ -public class ScriptCondition extends AbstractScriptComponent implements Condition { - - /** - * result field - */ - private boolean value = false; - - /** - * Is this condition true? - * - * @return true if the condition is true - * - * @throws org.apache.tools.ant.BuildException - * if an error occurs - */ - public boolean eval() throws BuildException { - initScriptRunner(); - executeScript("ant_condition"); - return getValue(); - } - - /** - * get the current value of the condition - * @return true if the condition - */ - public boolean getValue() { - return value; - } - - /** - * set the value of the condition. - * This is used by the script to pass the return value. - * It can be used by an attribute, in which case it sets the default - * value - * @param value the value to set the condition to - */ - public void setValue(boolean value) { - this.value = value; - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/ScriptFilter.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/ScriptFilter.java deleted file mode 100644 index 3f6ec88f..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/ScriptFilter.java +++ /dev/null @@ -1,183 +0,0 @@ -/* - * 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.optional; - -import java.io.File; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.filters.TokenFilter; -import org.apache.tools.ant.types.Path; -import org.apache.tools.ant.types.Reference; -import org.apache.tools.ant.util.ScriptRunnerBase; -import org.apache.tools.ant.util.ScriptRunnerHelper; - -/** - * Most of this is CAP (Cut And Paste) from the Script task - * ScriptFilter class, implements TokenFilter.Filter - * for scripts to use. - * This provides the same beans as the Script Task - * to a script. - * The script is meant to use get self.token and - * set self.token in the reply. - * - * @since Ant 1.6 - */ -public class ScriptFilter extends TokenFilter.ChainableReaderFilter { - /** script runner helper */ - private ScriptRunnerHelper helper = new ScriptRunnerHelper(); - - /** script runner. */ - private ScriptRunnerBase runner = null; - - /** the token used by the script */ - private String token; - - /** - * Set the project. - * @param project the owner of this component. - */ - public void setProject(Project project) { - super.setProject(project); - helper.setProjectComponent(this); - } - - /** - * Defines the language (required). - * - * @param language the scripting language name for the script. - */ - public void setLanguage(String language) { - helper.setLanguage(language); - } - - /** - * Initialize. - * - * @exception BuildException if someting goes wrong - */ - private void init() throws BuildException { - if (runner != null) { - return; - } - runner = helper.getScriptRunner(); - } - - /** - * The current token - * - * @param token the string filtered by the script - */ - public void setToken(String token) { - this.token = token; - } - - /** - * The current token - * - * @return the string filtered by the script - */ - public String getToken() { - return token; - } - - /** - * Called filter the token. - * This sets the token in this object, calls - * the script and returns the token. - * - * @param token the token to be filtered - * @return the filtered token - */ - public String filter(String token) { - init(); - setToken(token); - runner.executeScript("ant_filter"); - return getToken(); - } - - /** - * Load the script from an external file ; optional. - * - * @param file the file containing the script source. - */ - public void setSrc(File file) { - helper.setSrc(file); - } - - /** - * The script text. - * - * @param text a component of the script text to be added. - */ - public void addText(String text) { - helper.addText(text); - } - - /** - * Defines the manager. - * - * @param manager the scripting manager. - */ - public void setManager(String manager) { - helper.setManager(manager); - } - /** - * Set the classpath to be used when searching for classes and resources. - * - * @param classpath an Ant Path object containing the search path. - */ - public void setClasspath(Path classpath) { - helper.setClasspath(classpath); - } - - /** - * Classpath to be used when searching for classes and resources. - * - * @return an empty Path instance to be configured by Ant. - */ - public Path createClasspath() { - return helper.createClasspath(); - } - - /** - * Set the classpath by reference. - * - * @param r a Reference to a Path instance to be used as the classpath - * value. - */ - public void setClasspathRef(Reference r) { - helper.setClasspathRef(r); - } - - /** - * Set the setbeans attribute. - * If this is true, <script> will create variables in the - * script instance for all - * properties, targets and references of the current project. - * It this is false, only the project and self variables will - * be set. - * The default is true. - * @param setBeans the value to set. - * @since Ant 1.8.0 - */ - public void setSetBeans(boolean setBeans) { - helper.setSetBeans(setBeans); - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/ScriptMapper.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/ScriptMapper.java deleted file mode 100644 index 38dab0bb..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/ScriptMapper.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * 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.optional; - -import java.util.ArrayList; - -import org.apache.tools.ant.util.FileNameMapper; - -/** - * Script support at map time. - * @since Ant1.7 - */ -public class ScriptMapper extends AbstractScriptComponent implements FileNameMapper { - - private ArrayList<String> files; - - - /** - * Sets the from part of the transformation rule. - * - * @param from a string. - */ - public void setFrom(String from) { - - } - - /** - * Sets the to part of the transformation rule. - * - * @param to a string. - */ - public void setTo(String to) { - - } - - /** - * Reset the list of files - */ - public void clear() { - files = new ArrayList<String>(1); - } - - /** - * Add a mapped name - * @param mapping the value to use. - */ - public void addMappedName(String mapping) { - files.add(mapping); - } - - /** - * Returns an array containing the target filename(s) for the given source - * file. - * <p/> - * <p>if the given rule doesn't apply to the source file, implementation - * must return null. SourceFileScanner will then omit the source file in - * question.</p> - * - * @param sourceFileName the name of the source file relative to some given - * basedirectory. - * @return an array of strings if the rule applies to the source file, or - * null if it does not. - */ - - public String[] mapFileName(String sourceFileName) { - initScriptRunner(); - getRunner().addBean("source", sourceFileName); - clear(); - executeScript("ant_mapper"); - if (files.size() == 0) { - return null; - } else { - return files.toArray(new String[files.size()]); - } - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/ScriptSelector.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/ScriptSelector.java deleted file mode 100644 index ca28f69f..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/ScriptSelector.java +++ /dev/null @@ -1,223 +0,0 @@ -/* - * 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.optional; - -import java.io.File; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.types.Path; -import org.apache.tools.ant.types.Reference; -import org.apache.tools.ant.types.selectors.BaseSelector; -import org.apache.tools.ant.util.ScriptRunnerBase; -import org.apache.tools.ant.util.ScriptRunnerHelper; - -/** - * Selector that lets you run a script with selection logic inline - * @since Ant1.7 - */ -public class ScriptSelector extends BaseSelector { - - /** - * script runner helper - */ - private ScriptRunnerHelper helper = new ScriptRunnerHelper(); - - /** - * script runner - */ - private ScriptRunnerBase runner; - - /** - * fields updated for every selection - */ - private File basedir; - private String filename; - private File file; - - /** - * selected flag - */ - private boolean selected; - - /** - * Set the project. - * @param project the owner of this component. - */ - public void setProject(Project project) { - super.setProject(project); - helper.setProjectComponent(this); - } - - /** - * Defines the manager. - * - * @param manager the scripting manager. - */ - public void setManager(String manager) { - helper.setManager(manager); - } - - /** - * Defines the language (required). - * - * @param language the scripting language name for the script. - */ - public void setLanguage(String language) { - helper.setLanguage(language); - } - - /** - * Initialize on demand. - * - * @throws org.apache.tools.ant.BuildException - * if someting goes wrong - */ - private void init() throws BuildException { - if (runner != null) { - return; - } - runner = helper.getScriptRunner(); - } - - /** - * Load the script from an external file ; optional. - * - * @param file the file containing the script source. - */ - public void setSrc(File file) { - helper.setSrc(file); - } - - /** - * The script text. - * - * @param text a component of the script text to be added. - */ - public void addText(String text) { - helper.addText(text); - } - - /** - * Set the classpath to be used when searching for classes and resources. - * - * @param classpath an Ant Path object containing the search path. - */ - public void setClasspath(Path classpath) { - helper.setClasspath(classpath); - } - - /** - * Classpath to be used when searching for classes and resources. - * - * @return an empty Path instance to be configured by Ant. - */ - public Path createClasspath() { - return helper.createClasspath(); - } - - /** - * Set the classpath by reference. - * - * @param r a Reference to a Path instance to be used as the classpath - * value. - */ - public void setClasspathRef(Reference r) { - helper.setClasspathRef(r); - } - - /** - * Set the setbeans attribute. - * If this is true, <script> will create variables in the - * script instance for all - * properties, targets and references of the current project. - * It this is false, only the project and self variables will - * be set. - * The default is true. - * @param setBeans the value to set. - */ - public void setSetBeans(boolean setBeans) { - helper.setSetBeans(setBeans); - } - - /** - * Method that each selector will implement to create their selection - * behaviour. If there is a problem with the setup of a selector, it can - * throw a BuildException to indicate the problem. - * - * @param basedir A java.io.File object for the base directory - * @param filename The name of the file to check - * @param file A File object for this filename - * - * @return whether the file should be selected or not - */ - public boolean isSelected(File basedir, String filename, File file) { - init(); - setSelected(true); - this.file = file; - this.basedir = basedir; - this.filename = filename; - runner.addBean("basedir", basedir); - runner.addBean("filename", filename); - runner.addBean("file", file); - runner.executeScript("ant_selector"); - return isSelected(); - } - - /** - * get the base directory - * @return the base directory - */ - public File getBasedir() { - return basedir; - } - - /** - * get the filename of the file - * @return the filename of the file that is currently been tested - */ - public String getFilename() { - return filename; - } - - /** - * get the file that is currently to be tested - * @return the file that is currently been tested - */ - public File getFile() { - return file; - } - - /** - * get state of selected flag - * @return the selected flag - */ - public boolean isSelected() { - return selected; - } - - /** - * set the selected state - * Intended for script use, not as an Ant attribute - * @param selected the selected state - */ - public void setSelected(boolean selected) { - this.selected = selected; - } - -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/depend/ClassfileSet.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/depend/ClassfileSet.java deleted file mode 100644 index f2fe69b1..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/depend/ClassfileSet.java +++ /dev/null @@ -1,183 +0,0 @@ -/* - * 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.optional.depend; - -import java.util.ArrayList; -import java.util.List; -import java.util.Stack; -import java.util.Vector; - -import org.apache.tools.ant.DirectoryScanner; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.types.FileSet; -import org.apache.tools.ant.util.StringUtils; - -/** - * A ClassfileSet is a FileSet that enlists all classes that depend on a - * certain set of root classes. - * - * ClassfileSet extends FileSet, its inherited properties - * defining the domain searched for dependent classes. - * - */ -public class ClassfileSet extends FileSet { - /** - * The list of root classes for this class file set. These are the - * classes which must be included in the fileset and which are the - * starting point for the dependency search. - */ - private List<String> rootClasses = new ArrayList<String>(); - - /** - * The list of filesets which contain root classes. - */ - private List<FileSet> rootFileSets = new ArrayList<FileSet>(); - - /** - * Inner class used to contain info about root classes. - */ - public static class ClassRoot { - /** The name of the root class */ - private String rootClass; - - /** - * Set the root class name. - * - * @param name the name of the root class. - */ - public void setClassname(String name) { - this.rootClass = name; - } - - /** - * Get the name of the root class. - * - * @return the name of the root class. - */ - public String getClassname() { - return rootClass; - } - } - - /** - * Default constructor. - */ - public ClassfileSet() { - } - - /** - * Add a fileset to which contains a collection of root classes used to - * drive the search from classes. - * - * @param rootFileSet a root file set to be used to search for dependent - * classes. - */ - public void addRootFileset(FileSet rootFileSet) { - rootFileSets.add(rootFileSet); - setChecked(false); - } - - /** - * Create a ClassfileSet from another ClassfileSet. - * - * @param s the other classfileset. - */ - protected ClassfileSet(ClassfileSet s) { - super(s); - rootClasses.addAll(s.rootClasses); - } - - /** - * Set the root class attribute. - * - * @param rootClass the name of the root class. - */ - public void setRootClass(String rootClass) { - rootClasses.add(rootClass); - } - - /** - * Return the DirectoryScanner associated with this FileSet. - * - * @param p the project used to resolve dirs, etc. - * - * @return a dependency scanner. - */ - public DirectoryScanner getDirectoryScanner(Project p) { - if (isReference()) { - return getRef(p).getDirectoryScanner(p); - } - dieOnCircularReference(p); - DirectoryScanner parentScanner = super.getDirectoryScanner(p); - DependScanner scanner = new DependScanner(parentScanner); - final Vector<String> allRootClasses = new Vector<String>(rootClasses); - for (FileSet additionalRootSet : rootFileSets) { - DirectoryScanner additionalScanner - = additionalRootSet.getDirectoryScanner(p); - String[] files = additionalScanner.getIncludedFiles(); - for (int i = 0; i < files.length; ++i) { - if (files[i].endsWith(".class")) { - String classFilePath = StringUtils.removeSuffix(files[i], ".class"); - String className - = classFilePath.replace('/', '.').replace('\\', '.'); - allRootClasses.addElement(className); - } - } - scanner.addBasedir(additionalRootSet.getDir(p)); - } - scanner.setBasedir(getDir(p)); - scanner.setRootClasses(allRootClasses); - scanner.scan(); - return scanner; - } - - /** - * Add a nested root class definition to this class file set. - * - * @param root the configured class root. - */ - public void addConfiguredRoot(ClassRoot root) { - rootClasses.add(root.getClassname()); - } - - /** - * Clone this data type. - * - * @return a clone of the class file set. - */ - public Object clone() { - return new ClassfileSet(isReference() - ? (ClassfileSet) (getRef(getProject())) : this); - } - - protected synchronized void dieOnCircularReference(Stack<Object> stk, Project p) { - if (isChecked()) { - return; - } - - // takes care of nested selectors - super.dieOnCircularReference(stk, p); - - if (!isReference()) { - for (FileSet additionalRootSet : rootFileSets) { - pushAndInvokeCircularReferenceCheck(additionalRootSet, stk, p); - } - setChecked(true); - } - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/depend/DependScanner.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/depend/DependScanner.java deleted file mode 100644 index bb3cf54b..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/depend/DependScanner.java +++ /dev/null @@ -1,225 +0,0 @@ -/* - * 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.optional.depend; - -import java.io.File; -import java.util.Enumeration; -import java.util.Hashtable; -import java.util.Vector; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.DirectoryScanner; -import org.apache.tools.ant.types.Path; -import org.apache.tools.ant.util.depend.DependencyAnalyzer; - - -/** - * DirectoryScanner for finding class dependencies. - */ -public class DependScanner extends DirectoryScanner { - /** - * The name of the analyzer to use by default. - */ - public static final String DEFAULT_ANALYZER_CLASS - = "org.apache.tools.ant.util.depend.bcel.FullAnalyzer"; - - /** - * The root classes to drive the search for dependent classes. - */ - private Vector<String> rootClasses; - - /** - * The names of the classes to include in the fileset. - */ - private Vector<String> included; - - private Vector<File> additionalBaseDirs = new Vector<File>(); - - /** - * The parent scanner which gives the basic set of files. Only files which - * are in this set and which can be reached from a root class will end - * up being included in the result set. - */ - private DirectoryScanner parentScanner; - - /** - * Create a DependScanner, using the given scanner to provide the basic - * set of files from which class files come. - * - * @param parentScanner the DirectoryScanner which returns the files from - * which class files must come. - */ - public DependScanner(DirectoryScanner parentScanner) { - this.parentScanner = parentScanner; - } - - /** - * Sets the root classes to be used to drive the scan. - * - * @param rootClasses the rootClasses to be used for this scan. - */ - public synchronized void setRootClasses(Vector<String> rootClasses) { - this.rootClasses = rootClasses; - } - - /** - * Get the names of the class files on which baseClass depends. - * - * @return the names of the files. - */ - public String[] getIncludedFiles() { - String[] files = new String[getIncludedFilesCount()]; - for (int i = 0; i < files.length; i++) { - files[i] = (String) included.elementAt(i); - } - return files; - } - - /** {@inheritDoc}. */ - public synchronized int getIncludedFilesCount() { - if (included == null) { - throw new IllegalStateException(); - } - return included.size(); - } - - /** - * Scans the base directory for files on which baseClass depends. - * - * @exception IllegalStateException when basedir was set incorrectly. - */ - public synchronized void scan() throws IllegalStateException { - included = new Vector<String>(); - String analyzerClassName = DEFAULT_ANALYZER_CLASS; - DependencyAnalyzer analyzer = null; - try { - Class<? extends DependencyAnalyzer> analyzerClass = Class.forName(analyzerClassName) - .asSubclass(DependencyAnalyzer.class); - analyzer = analyzerClass.newInstance(); - } catch (Exception e) { - throw new BuildException("Unable to load dependency analyzer: " - + analyzerClassName, e); - } - analyzer.addClassPath(new Path(null, basedir.getPath())); - for (Enumeration<File> e = additionalBaseDirs.elements(); e.hasMoreElements();) { - File additionalBaseDir = e.nextElement(); - analyzer.addClassPath(new Path(null, additionalBaseDir.getPath())); - } - - for (Enumeration<String> e = rootClasses.elements(); e.hasMoreElements();) { - String rootClass = e.nextElement(); - analyzer.addRootClass(rootClass); - } - Enumeration<String> e = analyzer.getClassDependencies(); - - String[] parentFiles = parentScanner.getIncludedFiles(); - Hashtable<String, String> parentSet = new Hashtable<String, String>(); - for (int i = 0; i < parentFiles.length; ++i) { - parentSet.put(parentFiles[i], parentFiles[i]); - } - while (e.hasMoreElements()) { - String classname = (String) e.nextElement(); - String filename = classname.replace('.', File.separatorChar); - filename = filename + ".class"; - File depFile = new File(basedir, filename); - if (depFile.exists() && parentSet.containsKey(filename)) { - // This is included - included.addElement(filename); - } - } - } - - /** - * @see DirectoryScanner#addDefaultExcludes - */ - public void addDefaultExcludes() { - } - - /** - * @see DirectoryScanner#getExcludedDirectories - */ - /** {@inheritDoc}. */ - public String[] getExcludedDirectories() { - return null; - } - - /** - * @see DirectoryScanner#getExcludedFiles - */ - /** {@inheritDoc}. */ - public String[] getExcludedFiles() { - return null; - } - - /** - * @see DirectoryScanner#getIncludedDirectories - */ - /** {@inheritDoc}. */ - public String[] getIncludedDirectories() { - return new String[0]; - } - - /** - * @see DirectoryScanner#getIncludedDirsCount - */ - /** {@inheritDoc}. */ - public int getIncludedDirsCount() { - return 0; - } - - /** - * @see DirectoryScanner#getNotIncludedDirectories - */ - /** {@inheritDoc}. */ - public String[] getNotIncludedDirectories() { - return null; - } - - /** - * @see DirectoryScanner#getNotIncludedFiles - */ - /** {@inheritDoc}. */ - public String[] getNotIncludedFiles() { - return null; - } - - /** - * @see DirectoryScanner#setExcludes - */ - /** {@inheritDoc}. */ - public void setExcludes(String[] excludes) { - } - - /** - * @see DirectoryScanner#setIncludes - */ - /** {@inheritDoc}. */ - public void setIncludes(String[] includes) { - } - - /** - * @see DirectoryScanner#setCaseSensitive - */ - /** {@inheritDoc}. */ - public void setCaseSensitive(boolean isCaseSensitive) { - } - - public void addBasedir(File baseDir) { - additionalBaseDirs.addElement(baseDir); - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/image/Arc.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/image/Arc.java deleted file mode 100644 index 3d8b29b2..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/image/Arc.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * 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.optional.image; - -import java.awt.BasicStroke; -import java.awt.Graphics2D; -import java.awt.geom.Arc2D; -import java.awt.image.BufferedImage; - -import javax.media.jai.PlanarImage; - -/** - * Draw an arc. - */ -public class Arc extends BasicShape implements DrawOperation { - // CheckStyle:VisibilityModifier OFF - bc - protected int width = 0; - protected int height = 0; - protected int start = 0; - protected int stop = 0; - protected int type = Arc2D.OPEN; - // CheckStyle:VisibilityModifier ON - - /** - * Set the width. - * @param width the width of the arc. - */ - public void setWidth(int width) { - this.width = width; - } - - /** - * Set the height. - * @param height the height of the arc. - */ - public void setHeight(int height) { - this.height = height; - } - - /** - * Set the start of the arc. - * @param start the start of the arc. - */ - public void setStart(int start) { - this.start = start; - } - - /** - * Set the stop of the arc. - * @param stop the stop of the arc. - */ - public void setStop(int stop) { - this.stop = stop; - } - - /** - * Set the type of arc. - * @param strType the type to use - open, pie or chord. - * @todo refactor using an EnumeratedAttribute - */ - public void setType(String strType) { - if (strType.equalsIgnoreCase("open")) { - type = Arc2D.OPEN; - } else if (strType.equalsIgnoreCase("pie")) { - type = Arc2D.PIE; - } else if (strType.equalsIgnoreCase("chord")) { - type = Arc2D.CHORD; - } - } - - /** {@inheritDoc}. */ - public PlanarImage executeDrawOperation() { - BufferedImage bi = new BufferedImage(width + (stroke_width * 2), - height + (stroke_width * 2), BufferedImage.TYPE_4BYTE_ABGR_PRE); - - Graphics2D graphics = (Graphics2D) bi.getGraphics(); - - if (!stroke.equals("transparent")) { - BasicStroke bStroke = new BasicStroke(stroke_width); - graphics.setColor(ColorMapper.getColorByName(stroke)); - graphics.setStroke(bStroke); - graphics.draw(new Arc2D.Double(stroke_width, stroke_width, width, - height, start, stop, type)); - } - - if (!fill.equals("transparent")) { - graphics.setColor(ColorMapper.getColorByName(fill)); - graphics.fill(new Arc2D.Double(stroke_width, stroke_width, - width, height, start, stop, type)); - } - - - final int size = instructions.size(); - for (int i = 0; i < size; i++) { - ImageOperation instr = ((ImageOperation) instructions.elementAt(i)); - if (instr instanceof DrawOperation) { - PlanarImage img = ((DrawOperation) instr).executeDrawOperation(); - graphics.drawImage(img.getAsBufferedImage(), null, 0, 0); - } else if (instr instanceof TransformOperation) { - graphics = (Graphics2D) bi.getGraphics(); - PlanarImage image = ((TransformOperation) instr) - .executeTransformOperation(PlanarImage.wrapRenderedImage(bi)); - bi = image.getAsBufferedImage(); - } - } - return PlanarImage.wrapRenderedImage(bi); - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/image/BasicShape.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/image/BasicShape.java deleted file mode 100644 index ee2113a7..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/image/BasicShape.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * 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.optional.image; - - -/** Draw a basic shape */ -public abstract class BasicShape extends ImageOperation implements DrawOperation { - // CheckStyle:VisibilityModifier OFF - bc - // CheckStyle:MemberNameCheck OFF - bc - protected int stroke_width = 0; - // CheckStyle:MemberNameCheck ON - protected String fill = "transparent"; - protected String stroke = "black"; - // CheckStyle:VisibilityModifier ON - - - /** - * Set the fill attribute. - * @param col the color value to use. - */ - public void setFill(String col) { - fill = col; - } - - /** - * Set the stroke attribute. - * @param col the color value to use. - */ - public void setStroke(String col) { - stroke = col; - } - - /** - * Set the stroke width attribute. - * @param width the value to use. - */ - public void setStrokewidth(int width) { - stroke_width = width; - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/image/ColorMapper.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/image/ColorMapper.java deleted file mode 100644 index 88e2871a..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/image/ColorMapper.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * 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.optional.image; - -import java.awt.Color; - -/** - * - * @see org.apache.tools.ant.taskdefs.optional.image.Image - */ -public final class ColorMapper { - /** private constructor for Utility class */ - private ColorMapper() { - } - - /** black string */ - public static final String COLOR_BLACK = "black"; - /** blue string */ - public static final String COLOR_BLUE = "blue"; - /** cyan string */ - public static final String COLOR_CYAN = "cyan"; - /** black string */ - public static final String COLOR_DARKGRAY = "darkgray"; - /** gray string */ - public static final String COLOR_GRAY = "gray"; - /** lightgray string */ - public static final String COLOR_LIGHTGRAY = "lightgray"; - // Gotta at least put in the proper spelling :-P - /** darkgrey string */ - public static final String COLOR_DARKGREY = "darkgrey"; - /** grey string */ - public static final String COLOR_GREY = "grey"; - /** lightgrey string */ - public static final String COLOR_LIGHTGREY = "lightgrey"; - /** green string */ - public static final String COLOR_GREEN = "green"; - /** magenta string */ - public static final String COLOR_MAGENTA = "magenta"; - /** orange string */ - public static final String COLOR_ORANGE = "orange"; - /** pink string */ - public static final String COLOR_PINK = "pink"; - /** reg string */ - public static final String COLOR_RED = "red"; - /** white string */ - public static final String COLOR_WHITE = "white"; - /** yellow string */ - public static final String COLOR_YELLOW = "yellow"; - - /** - * Convert a color name to a color value. - * @param colorName a string repr of the color. - * @return the color value. - * @todo refactor to use an EnumeratedAttribute (maybe?) - */ - public static Color getColorByName(String colorName) { - if (colorName.equalsIgnoreCase(COLOR_BLACK)) { - return Color.black; - } else if (colorName.equalsIgnoreCase(COLOR_BLUE)) { - return Color.blue; - } else if (colorName.equalsIgnoreCase(COLOR_CYAN)) { - return Color.cyan; - } else if (colorName.equalsIgnoreCase(COLOR_DARKGRAY) || colorName.equalsIgnoreCase(COLOR_DARKGREY)) { - return Color.darkGray; - } else if (colorName.equalsIgnoreCase(COLOR_GRAY) || colorName.equalsIgnoreCase(COLOR_GREY)) { - return Color.gray; - } else if (colorName.equalsIgnoreCase(COLOR_LIGHTGRAY) || colorName.equalsIgnoreCase(COLOR_LIGHTGREY)) { - return Color.lightGray; - } else if (colorName.equalsIgnoreCase(COLOR_GREEN)) { - return Color.green; - } else if (colorName.equalsIgnoreCase(COLOR_MAGENTA)) { - return Color.magenta; - } else if (colorName.equalsIgnoreCase(COLOR_ORANGE)) { - return Color.orange; - } else if (colorName.equalsIgnoreCase(COLOR_PINK)) { - return Color.pink; - } else if (colorName.equalsIgnoreCase(COLOR_RED)) { - return Color.red; - } else if (colorName.equalsIgnoreCase(COLOR_WHITE)) { - return Color.white; - } else if (colorName.equalsIgnoreCase(COLOR_YELLOW)) { - return Color.yellow; - } - return Color.black; - } - -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/image/Draw.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/image/Draw.java deleted file mode 100644 index 2f097d5d..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/image/Draw.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * 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.optional.image; - -import java.awt.Graphics2D; -import java.awt.image.BufferedImage; - -import javax.media.jai.PlanarImage; - -/** - * - * @see org.apache.tools.ant.taskdefs.optional.image.Image - */ -public class Draw extends TransformOperation { - // CheckStyle:VisibilityModifier OFF - bc - protected int xloc = 0; - protected int yloc = 0; - // CheckStyle:VisibilityModifier ON - - /** - * Set the X location. - * @param x the value to use. - */ - public void setXloc(int x) { - xloc = x; - } - - /** - * Set the Y location. - * @param y the value to use. - */ - public void setYloc(int y) { - yloc = y; - } - - /** {@inheritDoc}. */ - public void addRectangle(Rectangle rect) { - instructions.add(rect); - } - - /** {@inheritDoc}. */ - public void addText(Text text) { - instructions.add(text); - } - - /** - * Add an ellipse. - * @param elip the ellipse to add. - */ - public void addEllipse(Ellipse elip) { - instructions.add(elip); - } - - /** - * Add an arc. - * @param arc the arc to add. - */ - public void addArc(Arc arc) { - instructions.add(arc); - } - - /** {@inheritDoc}. */ - public PlanarImage executeTransformOperation(PlanarImage image) { - BufferedImage bi = image.getAsBufferedImage(); - Graphics2D graphics = (Graphics2D) bi.getGraphics(); - - final int size = instructions.size(); - for (int i = 0; i < size; i++) { - ImageOperation instr = ((ImageOperation) instructions.elementAt(i)); - if (instr instanceof DrawOperation) { - PlanarImage op = ((DrawOperation) instr).executeDrawOperation(); - log("\tDrawing to x=" + xloc + " y=" + yloc); - graphics.drawImage(op.getAsBufferedImage(), null, xloc, yloc); - } else if (instr instanceof TransformOperation) { - PlanarImage op - = ((TransformOperation) instr).executeTransformOperation(null); - BufferedImage child = op.getAsBufferedImage(); - log("\tDrawing to x=" + xloc + " y=" + yloc); - graphics.drawImage(child, null, xloc, yloc); - PlanarImage.wrapRenderedImage(bi); - } - } - image = PlanarImage.wrapRenderedImage(bi); - - return image; - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/image/DrawOperation.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/image/DrawOperation.java deleted file mode 100644 index 4f6410ca..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/image/DrawOperation.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * 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.optional.image; - -import javax.media.jai.PlanarImage; - - -/** - * Interface which represents an Operation which is "drawable", such - * as a Rectangle, Circle or Text. The Operation is responsible for - * creating its own image buffer and drawing itself into it, then - * wrapping and returning it as a PlanarImage. This allows multible - * "drawable" objects to be nested. - * - * @see org.apache.tools.ant.taskdefs.optional.image.Image - */ -public interface DrawOperation { - /** - * Abstract method which is intended to create an image buffer - * and return it so it can be drawn into another object. Use - * an Alpha channel for a "transparent" background. - * @return a planar image - */ - PlanarImage executeDrawOperation(); -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/image/Ellipse.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/image/Ellipse.java deleted file mode 100644 index 9924d906..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/image/Ellipse.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * 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.optional.image; - -import java.awt.BasicStroke; -import java.awt.Graphics2D; -import java.awt.geom.Ellipse2D; -import java.awt.image.BufferedImage; - -import javax.media.jai.PlanarImage; - -/** - * Draw an ellipse. - * @see org.apache.tools.ant.taskdefs.optional.image.Image - */ -public class Ellipse extends BasicShape implements DrawOperation { - // CheckStyle:VisibilityModifier OFF - bc - protected int width = 0; - protected int height = 0; - // CheckStyle:VisibilityModifier ON - - /** - * Set the width. - * @param width the width of the elipse. - */ - public void setWidth(int width) { - this.width = width; - } - - /** - * Set the height. - * @param height the height of the ellipse. - */ - public void setHeight(int height) { - this.height = height; - } - - /** {@inheritDoc}. */ - public PlanarImage executeDrawOperation() { - BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR_PRE); - - Graphics2D graphics = (Graphics2D) bi.getGraphics(); - - if (!stroke.equals("transparent")) { - BasicStroke bStroke = new BasicStroke(stroke_width); - graphics.setColor(ColorMapper.getColorByName(stroke)); - graphics.setStroke(bStroke); - graphics.draw(new Ellipse2D.Double(0, 0, width, height)); - } - - if (!fill.equals("transparent")) { - graphics.setColor(ColorMapper.getColorByName(fill)); - graphics.fill(new Ellipse2D.Double(0, 0, width, height)); - } - - - final int size = instructions.size(); - for (int i = 0; i < size; i++) { - ImageOperation instr = ((ImageOperation) instructions.elementAt(i)); - if (instr instanceof DrawOperation) { - PlanarImage img = ((DrawOperation) instr).executeDrawOperation(); - graphics.drawImage(img.getAsBufferedImage(), null, 0, 0); - } else if (instr instanceof TransformOperation) { - graphics = (Graphics2D) bi.getGraphics(); - PlanarImage image = ((TransformOperation) instr) - .executeTransformOperation(PlanarImage.wrapRenderedImage(bi)); - bi = image.getAsBufferedImage(); - } - } - return PlanarImage.wrapRenderedImage(bi); - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/image/ImageOperation.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/image/ImageOperation.java deleted file mode 100644 index d72fe049..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/image/ImageOperation.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * 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.optional.image; - -import java.util.Vector; - -import org.apache.tools.ant.types.DataType; - -/** - * - * @see org.apache.tools.ant.taskdefs.optional.image.Image - */ -public abstract class ImageOperation extends DataType { - // CheckStyle:VisibilityModifier OFF - bc - protected Vector<ImageOperation> instructions = new Vector<ImageOperation>(); - // CheckStyle:VisibilityModifier ON - - /** - * Add a rotate to the operation. - * @param instr the rotate to add. - */ - public void addRotate(Rotate instr) { - instructions.add(instr); - } - - /** - * Add a draw to the operation. - * @param instr the draw to add. - */ - public void addDraw(Draw instr) { - instructions.add(instr); - } - - /** - * Add a rectangle to the operation. - * @param instr the rectangle to add. - */ - public void addRectangle(Rectangle instr) { - instructions.add(instr); - } - - /** - * Add text to the operation. - * @param instr the text to add. - */ - public void addText(Text instr) { - instructions.add(instr); - } - - /** - * Add a scale to the operation. - * @param instr the scale to add. - */ - public void addScale(Scale instr) { - instructions.add(instr); - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/image/Rectangle.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/image/Rectangle.java deleted file mode 100644 index e2d5bb1b..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/image/Rectangle.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * 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.optional.image; - -import java.awt.BasicStroke; -import java.awt.Graphics2D; -import java.awt.image.BufferedImage; - -import javax.media.jai.PlanarImage; - -/** - * - * @see org.apache.tools.ant.taskdefs.optional.image.Image - */ -public class Rectangle extends BasicShape implements DrawOperation { - // CheckStyle:VisibilityModifier OFF - bc - protected int width = 0; - protected int height = 0; - protected int arcwidth = 0; - protected int archeight = 0; - // CheckStyle:VisibilityModifier ON - - /** - * Set the width. - * @param w the value to use. - */ - public void setWidth(int w) { - width = w; - } - - /** - * Set the height. - * @param h the value to use. - */ - public void setHeight(int h) { - height = h; - } - - /** - * Set the arc width. - * @param w the value to use. - */ - public void setArcwidth(int w) { - arcwidth = w; - } - - /** - * Set the arc height. - * @param h the value to use. - */ - public void setArcheight(int h) { - archeight = h; - } - - /** {@inheritDoc}. */ - public PlanarImage executeDrawOperation() { - log("\tCreating Rectangle w=" + width + " h=" + height + " arcw=" - + arcwidth + " arch=" + archeight); - BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR_PRE); - - Graphics2D graphics = (Graphics2D) bi.getGraphics(); - - if (!stroke.equals("transparent")) { - BasicStroke bStroke = new BasicStroke(stroke_width); - graphics.setColor(ColorMapper.getColorByName(stroke)); - graphics.setStroke(bStroke); - - if ((arcwidth != 0) || (archeight != 0)) { - graphics.drawRoundRect(0, 0, width, height, arcwidth, archeight); - } else { - graphics.drawRect(0, 0, width, height); - } - } - - if (!fill.equals("transparent")) { - graphics.setColor(ColorMapper.getColorByName(fill)); - if ((arcwidth != 0) || (archeight != 0)) { - graphics.fillRoundRect(stroke_width, stroke_width, - width - (stroke_width * 2), height - (stroke_width * 2), - arcwidth, archeight); - } else { - graphics.fillRect(stroke_width, stroke_width, - width - (stroke_width * 2), height - (stroke_width * 2)); - } - } - - - final int size = instructions.size(); - for (int i = 0; i < size; i++) { - ImageOperation instr = ((ImageOperation) instructions.elementAt(i)); - if (instr instanceof DrawOperation) { - PlanarImage img = ((DrawOperation) instr).executeDrawOperation(); - graphics.drawImage(img.getAsBufferedImage(), null, 0, 0); - } else if (instr instanceof TransformOperation) { - graphics = (Graphics2D) bi.getGraphics(); - PlanarImage image - = ((TransformOperation) instr) - .executeTransformOperation(PlanarImage.wrapRenderedImage(bi)); - bi = image.getAsBufferedImage(); - } - } - return PlanarImage.wrapRenderedImage(bi); - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/image/Rotate.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/image/Rotate.java deleted file mode 100644 index 3013bde4..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/image/Rotate.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * 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.optional.image; - -import java.awt.image.BufferedImage; -import java.awt.image.renderable.ParameterBlock; - -import javax.media.jai.InterpolationNearest; -import javax.media.jai.JAI; -import javax.media.jai.PlanarImage; - -/** - * ImageOperation to rotate an image by a certain degree - * - * @see org.apache.tools.ant.taskdefs.optional.image.Image - */ -public class Rotate extends TransformOperation implements DrawOperation { - private static final float HALF_CIRCLE = 180.0F; - - // CheckStyle:VisibilityModifier OFF - bc - protected float angle = 0.0F; - // CheckStyle:VisibilityModifier ON - - /** - * Sets the angle of rotation in degrees. - * @param ang The angle at which to rotate the image - */ - public void setAngle(String ang) { - angle = Float.parseFloat(ang); - } - - - /** - * Rotate an image. - * @param image the image to rotate. - * @return the rotated image. - */ - public PlanarImage performRotate(PlanarImage image) { - float tAngle = (float) (angle * (Math.PI / HALF_CIRCLE)); - ParameterBlock pb = new ParameterBlock(); - pb.addSource(image); - pb.add(0.0F); - pb.add(0.0F); - pb.add(tAngle); - pb.add(new InterpolationNearest()); - return JAI.create("Rotate", pb, null); - } - - - /** - * Performs the image rotation when being handled as a TransformOperation. - * @param image The image to perform the transformation on. - * @return the transformed image. - */ - public PlanarImage executeTransformOperation(PlanarImage image) { - BufferedImage bi = null; - final int size = instructions.size(); - for (int i = 0; i < size; i++) { - ImageOperation instr = ((ImageOperation) instructions.elementAt(i)); - if (instr instanceof DrawOperation) { - // If this TransformOperation has DrawOperation children - // then Rotate the first child and return. - System.out.println("Execing Draws"); - PlanarImage op = ((DrawOperation) instr).executeDrawOperation(); - image = performRotate(op); - return image; - } else if (instr instanceof TransformOperation) { - bi = image.getAsBufferedImage(); - System.out.println("Execing Transforms"); - image = ((TransformOperation) instr) - .executeTransformOperation(PlanarImage.wrapRenderedImage(bi)); - bi = image.getAsBufferedImage(); - } - } - System.out.println("Execing as TransformOperation"); - image = performRotate(image); - System.out.println(image); - return image; - } - - /** - * Performs the image rotation when being handled as a DrawOperation. - * It absolutely requires that there be a DrawOperation nested beneath it, - * but only the FIRST DrawOperation will be handled since it can only return - * ONE image. - * @return the image. - */ - public PlanarImage executeDrawOperation() { - final int size = instructions.size(); - for (int i = 0; i < size; i++) { - ImageOperation instr = ((ImageOperation) instructions.elementAt(i)); - if (instr instanceof DrawOperation) { - // If this TransformOperation has DrawOperation children - // then Rotate the first child and return. - PlanarImage op = ((DrawOperation) instr).executeDrawOperation(); - op = performRotate(op); - return op; - } - } - return null; - } - -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/image/Scale.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/image/Scale.java deleted file mode 100644 index 532694d6..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/image/Scale.java +++ /dev/null @@ -1,181 +0,0 @@ -/* - * 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.optional.image; - -import java.awt.image.BufferedImage; -import java.awt.image.renderable.ParameterBlock; - -import javax.media.jai.JAI; -import javax.media.jai.PlanarImage; - -import org.apache.tools.ant.types.EnumeratedAttribute; - -/** - * - * @see org.apache.tools.ant.taskdefs.optional.image.Image - */ -public class Scale extends TransformOperation implements DrawOperation { - private static final int HUNDRED = 100; - - private String widthStr = "100%"; - private String heightStr = "100%"; - private boolean xPercent = true; - private boolean yPercent = true; - private String proportions = "ignore"; - - /** Enumerated class for proportions attribute. */ - public static class ProportionsAttribute extends EnumeratedAttribute { - /** {@inheritDoc}. */ - public String[] getValues() { - return new String[] {"ignore", "width", "height", "cover", "fit"}; - } - } - - /** - * Sets the behaviour regarding the image proportions. - * @param pa the enumerated value. - */ - public void setProportions(ProportionsAttribute pa) { - proportions = pa.getValue(); - } - - /** - * Sets the width of the image, either as an integer or a %. - * Defaults to 100%. - * @param width the value to use. - */ - public void setWidth(String width) { - widthStr = width; - } - - /** - * Sets the height of the image, either as an integer or a %. Defaults to 100%. - * @param height the value to use. - */ - public void setHeight(String height) { - heightStr = height; - } - - /** - * Get the width. - * @return the value converted from the width string. - */ - public float getWidth() { - float width = 0.0F; - int percIndex = widthStr.indexOf('%'); - if (percIndex > 0) { - width = Float.parseFloat(widthStr.substring(0, percIndex)); - xPercent = true; - return width / HUNDRED; - } else { - xPercent = false; - return Float.parseFloat(widthStr); - } - } - - /** - * Get the height. - * @return the value converted from the height string. - */ - public float getHeight() { - int percIndex = heightStr.indexOf('%'); - if (percIndex > 0) { - float height = Float.parseFloat(heightStr.substring(0, percIndex)); - yPercent = true; - return height / HUNDRED; - } else { - yPercent = false; - return Float.parseFloat(heightStr); - } - } - - /** - * Scale an image. - * @param image the image to scale. - * @return the scaled image. - */ - public PlanarImage performScale(PlanarImage image) { - ParameterBlock pb = new ParameterBlock(); - pb.addSource(image); - float xFl = getWidth(); - float yFl = getHeight(); - - if (!xPercent) { - xFl = (xFl / image.getWidth()); - } - if (!yPercent) { - yFl = (yFl / image.getHeight()); - } - - if ("width".equals(proportions)) { - yFl = xFl; - } else if ("height".equals(proportions)) { - xFl = yFl; - } else if ("fit".equals(proportions)) { - yFl = Math.min(xFl, yFl); - xFl = yFl; - } else if ("cover".equals(proportions)) { - yFl = Math.max(xFl, yFl); - xFl = yFl; - } - - pb.add(new Float(xFl)); - pb.add(new Float(yFl)); - - log("\tScaling to " + (xFl * HUNDRED) + "% x " - + (yFl * HUNDRED) + "%"); - - return JAI.create("scale", pb); - } - - - /** {@inheritDoc}. */ - public PlanarImage executeTransformOperation(PlanarImage image) { - BufferedImage bi = null; - final int size = instructions.size(); - for (int i = 0; i < size; i++) { - ImageOperation instr = ((ImageOperation) instructions.elementAt(i)); - if (instr instanceof DrawOperation) { - return performScale(image); - } else if (instr instanceof TransformOperation) { - bi = image.getAsBufferedImage(); - image = ((TransformOperation) instr) - .executeTransformOperation(PlanarImage.wrapRenderedImage(bi)); - bi = image.getAsBufferedImage(); - } - } - return performScale(image); - } - - - /** {@inheritDoc}. */ - public PlanarImage executeDrawOperation() { - final int size = instructions.size(); - for (int i = 0; i < size; i++) { - ImageOperation instr = ((ImageOperation) instructions.elementAt(i)); - if (instr instanceof DrawOperation) { - PlanarImage image = null; - // If this TransformOperation has DrawOperation children - // then Rotate the first child and return. - performScale(image); - return image; - } - } - return null; - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/image/Text.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/image/Text.java deleted file mode 100644 index 869fbac1..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/image/Text.java +++ /dev/null @@ -1,128 +0,0 @@ -/* - * 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.optional.image; - -import java.awt.Color; -import java.awt.Font; -import java.awt.FontMetrics; -import java.awt.Graphics2D; -import java.awt.RenderingHints; -import java.awt.image.BufferedImage; - -import javax.media.jai.PlanarImage; - -/** - * - * @see org.apache.tools.ant.taskdefs.optional.image.Image - */ -public class Text extends ImageOperation implements DrawOperation { - private static final int DEFAULT_POINT = 10; - - private String strText = ""; - private String font = "Arial"; - private int point = DEFAULT_POINT; - private boolean bold = false; - private boolean italic = false; - private String color = "black"; - - /** - * Set the string to be used as text. - * @param str the string to be used. - */ - public void setString(String str) { - strText = str; - } - - /** - * Set the font to be used to draw the text. - * @param f the font to be used. - */ - public void setFont(String f) { - font = f; - } - - /** - * Set the number of points to be used. - * @param p an integer value as a string. - */ - public void setPoint(String p) { - point = Integer.parseInt(p); - } - - /** - * Set the color of the text. - * @param c the color name. - */ - public void setColor(String c) { - color = c; - } - - /** - * @todo is this used? - * @param state not used at the moment. - */ - public void setBold(boolean state) { - bold = state; - } - - /** - * @todo is this used? - * @param state not used at the moment. - */ - public void setItalic(boolean state) { - italic = state; - } - - /** - * Draw the text. - * @return the resultant image. - */ - public PlanarImage executeDrawOperation() { - log("\tCreating Text \"" + strText + "\""); - - Color couloir = ColorMapper.getColorByName(color); - int width = 1; - int height = 1; - - BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR_PRE); - Graphics2D graphics = (Graphics2D) bi.getGraphics(); - graphics.setRenderingHint( - RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - graphics.setRenderingHint( - RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON); - Font f = new Font(font, Font.PLAIN, point); - FontMetrics fmetrics = graphics.getFontMetrics(f); - height = fmetrics.getMaxAscent() + fmetrics.getMaxDescent(); - width = fmetrics.stringWidth(strText); - - - bi = new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR_PRE); - graphics = (Graphics2D) bi.getGraphics(); - - graphics.setRenderingHint( - RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - graphics.setRenderingHint( - RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON); - - graphics.setFont(f); - graphics.setColor(couloir); - graphics.drawString(strText, 0, height - fmetrics.getMaxDescent()); - PlanarImage image = PlanarImage.wrapRenderedImage(bi); - return image; - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/image/TransformOperation.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/image/TransformOperation.java deleted file mode 100644 index 896e5d10..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/optional/image/TransformOperation.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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.optional.image; - -import javax.media.jai.PlanarImage; - -/** - * - * @see org.apache.tools.ant.taskdefs.optional.image.Image - */ -public abstract class TransformOperation extends ImageOperation { - /** - * Performs the transformations. - * @param img The image to perform the transformation on. - * @return the transformed image. - */ - public abstract PlanarImage executeTransformOperation(PlanarImage img); - - /** {@inheritDoc}. */ - public void addRectangle(Rectangle instr) { - instructions.add(instr); - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resolver/ApacheCatalog.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resolver/ApacheCatalog.java deleted file mode 100644 index cbf3f3fe..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resolver/ApacheCatalog.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * 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.resolver; - -import org.apache.xml.resolver.Catalog; -import org.apache.xml.resolver.CatalogEntry; -import org.apache.xml.resolver.helpers.PublicId; - - -/** - * This class extends the Catalog class provided by Norman Walsh's - * resolver library in xml-commons in order to add classpath entity - * and URI resolution. Since XMLCatalog already does classpath - * resolution, we simply add all CatalogEntry instances back to the - * controlling XMLCatalog instance. This is done via a callback - * mechanism. ApacheCatalog is <em>only</em> used for external - * catalog files. Inline entries (currently <code><dtd></code> - * and <code><entity></code>) are not added to ApacheCatalog. - * See XMLCatalog.java for the details of the entity and URI - * resolution algorithms. - * - * @see org.apache.tools.ant.types.XMLCatalog.CatalogResolver - * @since Ant 1.6 - */ -public class ApacheCatalog extends Catalog { - - /** The resolver object to callback. */ - private ApacheCatalogResolver resolver = null; - - /** - * <p>Create a new ApacheCatalog instance.</p> - * - * <p>This method overrides the superclass method of the same name - * in order to set the resolver object for callbacks. The reason - * we have to do this is that internally Catalog creates a new - * instance of itself for each external catalog file processed. - * That is, if two external catalog files are processed, there - * will be a total of two ApacheCatalog instances, and so on.</p> - * @return the catalog. - */ - protected Catalog newCatalog() { - final ApacheCatalog cat = (ApacheCatalog) super.newCatalog(); - cat.setResolver(resolver); - return cat; - } - - /** - * Set the resolver object to callback. - * @param resolver the apache catalog resolver. - */ - public void setResolver(final ApacheCatalogResolver resolver) { - this.resolver = resolver; - } - - /** - * <p>This method overrides the superclass method of the same name - * in order to add catalog entries back to the controlling - * XMLCatalog instance. In this way, we can add classpath lookup - * for these entries.</p> - * - * <p>When we add an external catalog file, the entries inside it - * get parsed by this method. Therefore, we override it to add - * each of them back to the controlling XMLCatalog instance. This - * is done by performing a callback to the ApacheCatalogResolver, - * which in turn calls the XMLCatalog.</p> - * - * <p>XMLCatalog currently only understands <code>PUBLIC</code> - * and <code>URI</code> entry types, so we ignore the other types.</p> - * - * @param entry The CatalogEntry to process. - */ - public void addEntry(final CatalogEntry entry) { - - final int type = entry.getEntryType(); - - if (type == PUBLIC) { - - final String publicid = PublicId.normalize(entry.getEntryArg(0)); - final String systemid = normalizeURI(entry.getEntryArg(1)); - - if (resolver == null) { - catalogManager.debug - .message(1, "Internal Error: null ApacheCatalogResolver"); - } else { - resolver.addPublicEntry(publicid, systemid, base); - } - - } else if (type == URI) { - - final String uri = normalizeURI(entry.getEntryArg(0)); - final String altURI = normalizeURI(entry.getEntryArg(1)); - - if (resolver == null) { - catalogManager.debug - .message(1, "Internal Error: null ApacheCatalogResolver"); - } else { - resolver.addURIEntry(uri, altURI, base); - } - - } - - super.addEntry(entry); - } - -} //- ApacheCatalog diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resolver/ApacheCatalogResolver.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resolver/ApacheCatalogResolver.java deleted file mode 100644 index 2312d3dc..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resolver/ApacheCatalogResolver.java +++ /dev/null @@ -1,174 +0,0 @@ -/* - * 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.resolver; - -import java.io.IOException; -import java.net.MalformedURLException; -import java.net.URL; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.types.ResourceLocation; -import org.apache.tools.ant.types.XMLCatalog; -import org.apache.xml.resolver.Catalog; -import org.apache.xml.resolver.CatalogManager; -import org.apache.xml.resolver.tools.CatalogResolver; - - -/** - * <p>This class extends the CatalogResolver class provided by Norman - * Walsh's resolver library in xml-commons. It provides the bridge - * between the Ant XMLCatalog datatype and the xml-commons Catalog - * class. XMLCatalog calls methods in this class using Reflection in - * order to avoid requiring the xml-commons resolver library in the - * path.</p> - * - * <p>The {@link org.apache.tools.ant.types.resolver.ApacheCatalog - * ApacheCatalog} class is used to parse external catalog files, which - * can be in either <a - * href="http://oasis-open.org/committees/entity/background/9401.html"> - * plain text format</a> or <a - * href="http://www.oasis-open.org/committees/entity/spec-2001-08-06.html"> - * XML format</a>.</p> - * - * <p>For each entry found in an external catalog file, if any, an - * instance of {@link org.apache.tools.ant.types.ResourceLocation - * ResourceLocation} is created and added to the controlling - * XMLCatalog datatype. In this way, these entries will be included - * in XMLCatalog's lookup algorithm. See XMLCatalog.java for more - * details.</p> - * - * @see org.apache.tools.ant.types.XMLCatalog.CatalogResolver - * @see org.apache.xml.resolver.CatalogManager - * @since Ant 1.6 - */ - -public class ApacheCatalogResolver extends CatalogResolver { - - /** The XMLCatalog object to callback. */ - private XMLCatalog xmlCatalog = null; - - static { - // - // If you don't do this, you get all sorts of annoying - // warnings about a missing properties file. However, it - // seems to work just fine with default values. Ultimately, - // we should probably include a "CatalogManager.properties" - // file in the ant jarfile with some default property - // settings. See CatalogManager.java for more details. - // - CatalogManager.getStaticManager().setIgnoreMissingProperties(true); - - // - // Make sure CatalogResolver instantiates ApacheCatalog, - // rather than a plain Catalog - // - System.getProperties().put("xml.catalog.className", - ApacheCatalog.class.getName()); - - CatalogManager.getStaticManager().setUseStaticCatalog(false); - - // debug - // CatalogManager.getStaticManager().setVerbosity(4); - } - - /** - * Set the XMLCatalog object to callback. - * @param xmlCatalog the XMLCatalog to use. - */ - public void setXMLCatalog(final XMLCatalog xmlCatalog) { - this.xmlCatalog = xmlCatalog; - } - - /** - * XMLCatalog calls this to add an external catalog file for each - * file within a <code><catalogfiles></code> fileset. - * @param file the external catalog file. - */ - public void parseCatalog(final String file) { - - final Catalog catalog = getCatalog(); - if (!(catalog instanceof ApacheCatalog)) { - throw new BuildException("Wrong catalog type found: " + catalog.getClass().getName()); - } - final ApacheCatalog apacheCatalog = (ApacheCatalog) catalog; - - // Pass in reference to ourselves so we can be called back. - apacheCatalog.setResolver(this); - - try { - apacheCatalog.parseCatalog(file); - } catch (final MalformedURLException ex) { - throw new BuildException(ex); - } catch (final IOException ex) { - throw new BuildException(ex); - } - } - - /** - * <p>Add a PUBLIC catalog entry to the controlling XMLCatalog instance. - * ApacheCatalog calls this for each PUBLIC entry found in an external - * catalog file.</p> - * - * @param publicid The public ID of the resource - * @param systemid The system ID (aka location) of the resource - * @param base The base URL of the resource. If the systemid - * specifies a relative URL/pathname, it is resolved using the - * base. The default base for an external catalog file is the - * directory in which the catalog is located. - * - */ - public void addPublicEntry(final String publicid, - final String systemid, - final URL base) { - - final ResourceLocation dtd = new ResourceLocation(); - dtd.setBase(base); - dtd.setPublicId(publicid); - dtd.setLocation(systemid); - - xmlCatalog.addDTD(dtd); - } - - /** - * <p>Add a URI catalog entry to the controlling XMLCatalog instance. - * ApacheCatalog calls this for each URI entry found in an external - * catalog file.</p> - * - * @param uri The URI of the resource - * @param altURI The URI to which the resource should be mapped - * (aka the location) - * @param base The base URL of the resource. If the altURI - * specifies a relative URL/pathname, it is resolved using the - * base. The default base for an external catalog file is the - * directory in which the catalog is located. - * - */ - public void addURIEntry(final String uri, - final String altURI, - final URL base) { - - final ResourceLocation entity = new ResourceLocation(); - entity.setBase(base); - entity.setPublicId(uri); - entity.setLocation(altURI); - - xmlCatalog.addEntity(entity); - } - -} //-- ApacheCatalogResolver diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resolver/package.html b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resolver/package.html deleted file mode 100644 index 11b3c773..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resolver/package.html +++ /dev/null @@ -1,35 +0,0 @@ -<!-- - 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. ---> -<body> -Ant integration with xml-commons resolver. - -<p>These classes enhance the <code><xmlcatalog></code> datatype -to support external catalog files using the xml-commons resolver, in -accordance with the -<a href="http://oasis-open.org/committees/entity/spec-2001-08-06.html"> -OASIS "Open Catalog" standard</a>. They will be used if and only if -the xml-commons resolver library is available on the classpath.</p> - -@see <A HREF="http://xml.apache.org/commons">Apache xml-commons Project</A> - -@see org.apache.tools.ant.types.XMLCatalog -@see org.apache.tools.ant.types.resolver.ApacheCatalogResolver -@see org.apache.tools.ant.types.resolver.ApacheCatalog - -@author <A HREF="mailto:cstrong@arielpartners.com">Craeg Strong</A> - -</body> diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/AbstractClasspathResource.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/AbstractClasspathResource.java deleted file mode 100644 index 417da9a7..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/AbstractClasspathResource.java +++ /dev/null @@ -1,265 +0,0 @@ -/* - * 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.FilterInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.Stack; - -import org.apache.tools.ant.AntClassLoader; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.types.Path; -import org.apache.tools.ant.types.Reference; -import org.apache.tools.ant.types.Resource; -import org.apache.tools.ant.util.FileUtils; - -/** - * - * A Resource representation of anything that is accessed via a Java classloader. - * The core methods to set/resolve the classpath are provided. - * @since Ant 1.8.0 - * - */ - -public abstract class AbstractClasspathResource extends Resource { - private Path classpath; - private Reference loader; - private boolean parentFirst = true; - - /** - * Set the classpath to use when looking up a resource. - * @param classpath to add to any existing classpath - */ - public void setClasspath(Path classpath) { - checkAttributesAllowed(); - if (this.classpath == null) { - this.classpath = classpath; - } else { - this.classpath.append(classpath); - } - setChecked(false); - } - - /** - * Add a classpath to use when looking up a resource. - * @return The classpath to be configured - */ - public Path createClasspath() { - checkChildrenAllowed(); - if (classpath == null) { - classpath = new Path(getProject()); - } - setChecked(false); - return classpath.createPath(); - } - - /** - * Set the classpath to use when looking up a resource, - * given as reference to a <path> defined elsewhere - * @param r The reference value - */ - public void setClasspathRef(Reference r) { - checkAttributesAllowed(); - createClasspath().setRefid(r); - } - - /** - * get the classpath used by this <code>LoadProperties</code>. - * @return The classpath - */ - public Path getClasspath() { - if (isReference()) { - return ((AbstractClasspathResource) getCheckedRef()).getClasspath(); - } - dieOnCircularReference(); - return classpath; - } - - /** - * Get the loader. - * @return the loader. - */ - public Reference getLoader() { - if (isReference()) { - return ((AbstractClasspathResource) getCheckedRef()).getLoader(); - } - dieOnCircularReference(); - return loader; - } - - /** - * Use the reference to locate the loader. If the loader is not - * found, taskdef will use the specified classpath and register it - * with the specified name. - * - * This allow multiple taskdef/typedef to use the same class loader, - * so they can be used together. It eliminate the need to - * put them in the CLASSPATH. - * - * @param r the reference to locate the loader. - */ - public void setLoaderRef(Reference r) { - checkAttributesAllowed(); - loader = r; - } - - /** - * Whether to consult the parent classloader first. - * - * <p>Only relevant if a classpath has been specified.</p> - * - * @since Ant 1.8.0 - */ - public void setParentFirst(boolean b) { - parentFirst = b; - } - - /** - * Overrides the super version. - * @param r the Reference to set. - */ - public void setRefid(Reference r) { - if (loader != null || classpath != null) { - throw tooManyAttributes(); - } - super.setRefid(r); - } - - /** - * Learn whether this resource exists. This implementation opens the input stream - * as the test. - * @return true if this resource exists. - */ - public boolean isExists() { - if (isReference()) { - return ((Resource) getCheckedRef()).isExists(); - } - dieOnCircularReference(); - InputStream is = null; - try { - is = getInputStream(); - return is != null; - } catch (IOException ex) { - return false; - } finally { - FileUtils.close(is); - } - } - - /** - * Return an InputStream for reading the contents of this Resource. - * @return an InputStream object. - * @throws IOException if an error occurs. - */ - public InputStream getInputStream() throws IOException { - if (isReference()) { - return ((Resource) getCheckedRef()).getInputStream(); - } - dieOnCircularReference(); - - final ClassLoaderWithFlag classLoader = getClassLoader(); - return !classLoader.needsCleanup() - ? openInputStream(classLoader.getLoader()) - : new FilterInputStream(openInputStream(classLoader.getLoader())) { - public void close() throws IOException { - FileUtils.close(in); - classLoader.cleanup(); - } - protected void finalize() throws Throwable { - try { - close(); - } finally { - super.finalize(); - } - } - }; - } - - /** - * combines the various ways that could specify a ClassLoader and - * potentially creates one that needs to be cleaned up when it is - * no longer needed so that classes can get garbage collected. - */ - protected ClassLoaderWithFlag getClassLoader() { - ClassLoader cl = null; - boolean clNeedsCleanup = false; - if (loader != null) { - cl = (ClassLoader) loader.getReferencedObject(); - } - if (cl == null) { - if (getClasspath() != null) { - Path p = getClasspath().concatSystemClasspath("ignore"); - if (parentFirst) { - cl = getProject().createClassLoader(p); - } else { - cl = AntClassLoader.newAntClassLoader(getProject() - .getCoreLoader(), - getProject(), - p, false); - } - clNeedsCleanup = loader == null; - } else { - cl = JavaResource.class.getClassLoader(); - } - if (loader != null && cl != null) { - getProject().addReference(loader.getRefId(), cl); - } - } - return new ClassLoaderWithFlag(cl, clNeedsCleanup); - } - - /** - * open the input stream from a specific classloader - * @param cl the classloader to use. Will be null if the system classloader is used - * @return an open input stream for the resource - * @throws IOException if an error occurs. - */ - protected abstract InputStream openInputStream(ClassLoader cl) throws IOException; - - protected synchronized void dieOnCircularReference(Stack<Object> stk, Project p) { - if (isChecked()) { - return; - } - if (isReference()) { - super.dieOnCircularReference(stk, p); - } else { - if (classpath != null) { - pushAndInvokeCircularReferenceCheck(classpath, stk, p); - } - setChecked(true); - } - } - - public static class ClassLoaderWithFlag { - private final ClassLoader loader; - private final boolean cleanup; - - ClassLoaderWithFlag(ClassLoader l, boolean needsCleanup) { - loader = l; - cleanup = needsCleanup && l instanceof AntClassLoader; - } - public ClassLoader getLoader() { return loader; } - public boolean needsCleanup() { return cleanup; } - public void cleanup() { - if (cleanup) { - ((AntClassLoader) loader).cleanup(); - } - } - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/AbstractResourceCollectionWrapper.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/AbstractResourceCollectionWrapper.java deleted file mode 100644 index 5e4c3a3f..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/AbstractResourceCollectionWrapper.java +++ /dev/null @@ -1,209 +0,0 @@ -/* - * 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.Iterator; -import java.util.Stack; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.types.DataType; -import org.apache.tools.ant.types.Resource; -import org.apache.tools.ant.types.ResourceCollection; - -/** - * Base class for a ResourceCollection that wraps a single nested - * ResourceCollection. - * @since Ant 1.8.2 - */ -public abstract class AbstractResourceCollectionWrapper - extends DataType implements ResourceCollection, Cloneable { - private static final String ONE_NESTED_MESSAGE - = " expects exactly one nested resource collection."; - - private ResourceCollection rc; - private boolean cache = true; - - /** - * Set whether to cache collections. - * @param b boolean cache flag. - */ - public synchronized void setCache(boolean b) { - cache = b; - } - - /** - * Learn whether to cache collections. Default is <code>true</code>. - * @return boolean cache flag. - */ - public synchronized boolean isCache() { - return cache; - } - - /** - * Add a ResourceCollection to the container. - * @param c the ResourceCollection to add. - * @throws BuildException on error. - */ - public synchronized void add(ResourceCollection c) throws BuildException { - if (isReference()) { - throw noChildrenAllowed(); - } - if (c == null) { - return; - } - if (rc != null) { - throw oneNested(); - } - rc = c; - if (Project.getProject(rc) == null) { - Project p = getProject(); - if (p != null) { - p.setProjectReference(rc); - } - } - setChecked(false); - } - - /** - * Fulfill the ResourceCollection contract. - * @return an Iterator of Resources. - */ - public final synchronized Iterator<Resource> iterator() { - if (isReference()) { - return ((AbstractResourceCollectionWrapper) getCheckedRef()).iterator(); - } - dieOnCircularReference(); - return new FailFast(this, createIterator()); - } - - /** - * Do create an iterator on the resource collection. The creation - * of the iterator is allowed to not be thread safe whereas the iterator - * itself should. The returned iterator will be wrapped into the FailFast - * one. - * - * @return the iterator on the resource collection - */ - protected abstract Iterator<Resource> createIterator(); - - /** - * Fulfill the ResourceCollection contract. - * @return number of elements as int. - */ - public synchronized int size() { - if (isReference()) { - return ((AbstractResourceCollectionWrapper) getCheckedRef()).size(); - } - dieOnCircularReference(); - return getSize(); - } - - /** - * Do compute the size of the resource collection. The implementation of - * this function is allowed to be not thread safe. - * - * @return size of resource collection. - */ - protected abstract int getSize(); - - /** - * Fulfill the ResourceCollection contract. - * @return whether this is a filesystem-only resource collection. - */ - public synchronized boolean isFilesystemOnly() { - if (isReference()) { - return ((BaseResourceCollectionContainer) getCheckedRef()).isFilesystemOnly(); - } - dieOnCircularReference(); - - if (rc == null || rc.isFilesystemOnly()) { - return true; - } - /* now check each Resource in case the child only - lets through files from any children IT may have: */ - for (Resource r : this) { - if (r.as(FileProvider.class) == null) { - return false; - } - } - return true; - } - - /** - * Overrides the version of DataType to recurse on all DataType - * child elements that may have been added. - * @param stk the stack of data types to use (recursively). - * @param p the project to use to dereference the references. - * @throws BuildException on error. - */ - protected synchronized void dieOnCircularReference(Stack<Object> stk, Project p) - throws BuildException { - if (isChecked()) { - return; - } - if (isReference()) { - super.dieOnCircularReference(stk, p); - } else { - if (rc instanceof DataType) { - pushAndInvokeCircularReferenceCheck((DataType) rc, stk, p); - } - setChecked(true); - } - } - - /** - * Get the nested ResourceCollection. - * @return a ResourceCollection. - * @throws BuildException if no nested ResourceCollection has been provided. - */ - protected final synchronized ResourceCollection getResourceCollection() { - dieOnCircularReference(); - if (rc == null) { - throw oneNested(); - } - return rc; - } - - /** - * Format this BaseResourceCollectionWrapper as a String. - * @return a descriptive <code>String</code>. - */ - public synchronized String toString() { - if (isReference()) { - return getCheckedRef().toString(); - } - if (getSize() == 0) { - return ""; - } - StringBuilder sb = new StringBuilder(); - for (Resource resource : this) { - if (sb.length() > 0) { - sb.append(File.pathSeparatorChar); - } - sb.append(resource); - } - return sb.toString(); - } - - private BuildException oneNested() { - return new BuildException(super.toString() + ONE_NESTED_MESSAGE); - } - -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/AllButFirst.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/AllButFirst.java deleted file mode 100644 index ffa665f8..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/AllButFirst.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * 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.util.ArrayList; -import java.util.Collection; -import java.util.Iterator; -import java.util.List; - -import org.apache.tools.ant.types.Resource; - -/** - * ResourceCollection that contains all resources of another - * collection except for the first <code>count</code> elements, a la - * the UNIX tail command with parameter <code>-n +count</code>. - * @since Ant 1.9.5 - */ -public class AllButFirst extends SizeLimitCollection { - - /** - * Take all elements except for the first <code>count</code> elements. - * @return a Collection of Resources. - */ - protected Collection<Resource> getCollection() { - int ct = getValidCount(); - Iterator<Resource> iter = getResourceCollection().iterator(); - List<Resource> al = new ArrayList<Resource>(); - for (int i = 0; i < ct && iter.hasNext(); i++) { - // discard - iter.next(); - } - while (iter.hasNext()) { - al.add(iter.next()); - } - return al; - } - - @Override - public synchronized int size() { - int sz = getResourceCollection().size(); - int ct = getValidCount(); - return sz > ct ? sz - ct : 0; - } - -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/AllButLast.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/AllButLast.java deleted file mode 100644 index a1e6a984..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/AllButLast.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * 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.util.Collection; -import java.util.List; - -import org.apache.tools.ant.types.Resource; -import org.apache.tools.ant.util.CollectionUtils; - -/** - * ResourceCollection that contains all resources of another - * collection except for the last <code>count</code> elements, a la - * the UNIX head command with parameter <code>-n -count</code>. - * @since Ant 1.9.5 - */ -public class AllButLast extends SizeLimitCollection { - - /** - * Take all elements except for the last <code>count</code> elements. - * @return a Collection of Resources. - */ - protected Collection<Resource> getCollection() { - int ct = getValidCount(); - List<Resource> result = - (List<Resource>) CollectionUtils.asCollection(getResourceCollection() - .iterator()); - return result.subList(0, result.size() - ct); - } - - @Override - public synchronized int size() { - int sz = getResourceCollection().size(); - int ct = getValidCount(); - return sz > ct ? sz - ct : 0; - } - -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/Appendable.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/Appendable.java deleted file mode 100644 index 14f4711a..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/Appendable.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * 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.IOException; -import java.io.OutputStream; - -/** - * Interface to be implemented by "appendable" resources. - * @since Ant 1.8 - */ -public interface Appendable { - - /** - * Get an appending OutputStream. - * @return OutputStream - * @throws IOException if anything goes wrong - */ - OutputStream getAppendOutputStream() throws IOException; -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/ArchiveResource.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/ArchiveResource.java deleted file mode 100644 index 308de03e..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/ArchiveResource.java +++ /dev/null @@ -1,293 +0,0 @@ -/* - * 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.Stack; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.types.Reference; -import org.apache.tools.ant.types.Resource; -import org.apache.tools.ant.types.ResourceCollection; - -/** - * A Resource representation of an entry inside an archive. - * @since Ant 1.7 - */ -public abstract class ArchiveResource extends Resource { - private static final int NULL_ARCHIVE - = Resource.getMagicNumber("null archive".getBytes()); - - private Resource archive; - private boolean haveEntry = false; - private boolean modeSet = false; - private int mode = 0; - - /** - * Default constructor. - */ - protected ArchiveResource() { - } - - /** - * Construct a ArchiveResource representing the specified - * entry in the specified archive. - * @param a the archive as File. - */ - protected ArchiveResource(File a) { - this(a, false); - } - - /** - * Construct a ArchiveResource representing the specified - * entry in the specified archive. - * @param a the archive as File. - * @param withEntry if the entry has been specified. - */ - protected ArchiveResource(File a, boolean withEntry) { - setArchive(a); - haveEntry = withEntry; - } - - /** - * Construct a ArchiveResource representing the specified - * entry in the specified archive. - * @param a the archive as Resource. - * @param withEntry if the entry has been specified. - */ - protected ArchiveResource(Resource a, boolean withEntry) { - addConfigured(a); - haveEntry = withEntry; - } - - /** - * Set the archive that holds this Resource. - * @param a the archive as a File. - */ - public void setArchive(File a) { - checkAttributesAllowed(); - archive = new FileResource(a); - } - - /** - * Sets the file or dir mode for this resource. - * @param mode integer representation of Unix permission mask. - */ - public void setMode(int mode) { - checkAttributesAllowed(); - this.mode = mode; - modeSet = true; - } - - /** - * Sets the archive that holds this as a single element Resource - * collection. - * @param a the archive as a single element Resource collection. - */ - public void addConfigured(ResourceCollection a) { - checkChildrenAllowed(); - if (archive != null) { - throw new BuildException("you must not specify more than one" - + " archive"); - } - if (a.size() != 1) { - throw new BuildException("only single argument resource collections" - + " are supported as archives"); - } - archive = a.iterator().next(); - } - - /** - * Get the archive that holds this Resource. - * @return the archive as a Resource. - */ - public Resource getArchive() { - return isReference() - ? ((ArchiveResource) getCheckedRef()).getArchive() : archive; - } - - /** - * Get the last modified date of this Resource. - * @return the last modification date. - */ - public long getLastModified() { - if (isReference()) { - return ((Resource) getCheckedRef()).getLastModified(); - } - checkEntry(); - return super.getLastModified(); - } - - /** - * Get the size of this Resource. - * @return the long size of this Resource. - */ - public long getSize() { - if (isReference()) { - return ((Resource) getCheckedRef()).getSize(); - } - checkEntry(); - return super.getSize(); - } - - /** - * Learn whether this Resource represents a directory. - * @return boolean flag indicating whether the entry is a directory. - */ - public boolean isDirectory() { - if (isReference()) { - return ((Resource) getCheckedRef()).isDirectory(); - } - checkEntry(); - return super.isDirectory(); - } - - /** - * Find out whether this Resource represents an existing Resource. - * @return boolean existence flag. - */ - public boolean isExists() { - if (isReference()) { - return ((Resource) getCheckedRef()).isExists(); - } - checkEntry(); - return super.isExists(); - } - - /** - * Get the file or dir mode for this Resource. - * @return integer representation of Unix permission mask. - */ - public int getMode() { - if (isReference()) { - return ((ArchiveResource) getCheckedRef()).getMode(); - } - checkEntry(); - return mode; - } - - /** - * Overrides the super version. - * @param r the Reference to set. - */ - public void setRefid(Reference r) { - if (archive != null || modeSet) { - throw tooManyAttributes(); - } - super.setRefid(r); - } - - /** - * Compare this ArchiveResource to another Resource. - * @param another the other Resource against which to compare. - * @return a negative integer, zero, or a positive integer as this Resource - * is less than, equal to, or greater than the specified Resource. - */ - public int compareTo(Resource another) { - return this.equals(another) ? 0 : super.compareTo(another); - } - - /** - * Compare another Object to this ArchiveResource for equality. - * @param another the other Object to compare. - * @return true if another is a Resource representing - * the same entry in the same archive. - */ - public boolean equals(Object another) { - if (this == another) { - return true; - } - if (isReference()) { - return getCheckedRef().equals(another); - } - if (another == null || !(another.getClass().equals(getClass()))) { - return false; - } - ArchiveResource r = (ArchiveResource) another; - return getArchive().equals(r.getArchive()) - && getName().equals(r.getName()); - } - - /** - * Get the hash code for this Resource. - * @return hash code as int. - */ - public int hashCode() { - return super.hashCode() - * (getArchive() == null ? NULL_ARCHIVE : getArchive().hashCode()); - } - - /** - * Format this Resource as a String. - * @return String representatation of this Resource. - */ - public String toString() { - return isReference() ? getCheckedRef().toString() - : getArchive().toString() + ':' + getName(); - } - - /** - * Validate settings and ensure that the represented "archive entry" - * has been established. - */ - protected final synchronized void checkEntry() throws BuildException { - dieOnCircularReference(); - if (haveEntry) { - return; - } - String name = getName(); - if (name == null) { - throw new BuildException("entry name not set"); - } - Resource r = getArchive(); - if (r == null) { - throw new BuildException("archive attribute not set"); - } - if (!r.isExists()) { - throw new BuildException(r.toString() + " does not exist."); - } - if (r.isDirectory()) { - throw new BuildException(r + " denotes a directory."); - } - fetchEntry(); - haveEntry = true; - } - - /** - * Fetch information from the named entry inside the archive. - */ - protected abstract void fetchEntry(); - - /** - * {@inheritDoc} - */ - protected synchronized void dieOnCircularReference(Stack<Object> stk, Project p) { - if (isChecked()) { - return; - } - if (isReference()) { - super.dieOnCircularReference(stk, p); - } else { - if (archive != null) { - pushAndInvokeCircularReferenceCheck(archive, stk, p); - } - setChecked(true); - } - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/Archives.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/Archives.java deleted file mode 100644 index 4b0d51c6..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/Archives.java +++ /dev/null @@ -1,194 +0,0 @@ -/* - * 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.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.Stack; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.types.ArchiveFileSet; -import org.apache.tools.ant.types.DataType; -import org.apache.tools.ant.types.Reference; -import org.apache.tools.ant.types.Resource; -import org.apache.tools.ant.types.ResourceCollection; -import org.apache.tools.ant.types.TarFileSet; -import org.apache.tools.ant.types.ZipFileSet; -import org.apache.tools.ant.util.CollectionUtils; - -/** - * A resource collection that treats all nested resources as archives - * and returns the contents of the archives as its content. - * - * @since Ant 1.8.0 - */ -public class Archives extends DataType - implements ResourceCollection, Cloneable { - - private Union zips = new Union(); - private Union tars = new Union(); - - /** - * Wrapper to identify nested resource collections as ZIP - * archives. - */ - public Union createZips() { - if (isReference()) { - throw noChildrenAllowed(); - } - setChecked(false); - return zips; - } - - /** - * Wrapper to identify nested resource collections as ZIP - * archives. - */ - public Union createTars() { - if (isReference()) { - throw noChildrenAllowed(); - } - setChecked(false); - return tars; - } - - /** - * Sums the sizes of nested archives. - */ - public int size() { - if (isReference()) { - return ((Archives) getCheckedRef()).size(); - } - dieOnCircularReference(); - int total = 0; - for (final Iterator<ArchiveFileSet> i = grabArchives(); i.hasNext();) { - total += i.next().size(); - } - return total; - } - - /** - * Merges the nested collections. - */ - public Iterator<Resource> iterator() { - if (isReference()) { - return ((Archives) getCheckedRef()).iterator(); - } - dieOnCircularReference(); - final List<Resource> l = new LinkedList<Resource>(); - for (final Iterator<ArchiveFileSet> i = grabArchives(); i.hasNext();) { - l.addAll(CollectionUtils - .asCollection(i.next().iterator())); - } - return l.iterator(); - } - - /** - * @return false - */ - public boolean isFilesystemOnly() { - if (isReference()) { - return ((Archives) getCheckedRef()).isFilesystemOnly(); - } - dieOnCircularReference(); - return false; - } - - /** - * Overrides the base version. - * @param r the Reference to set. - */ - @Override - public void setRefid(final Reference r) { - if (zips.getResourceCollections().size() > 0 - || tars.getResourceCollections().size() > 0) { - throw tooManyAttributes(); - } - super.setRefid(r); - } - - /** - * Implement clone. The nested resource collections are cloned as - * well. - * @return a cloned instance. - */ - @Override - public Object clone() { - try { - final Archives a = (Archives) super.clone(); - a.zips = (Union) zips.clone(); - a.tars = (Union) tars.clone(); - return a; - } catch (final CloneNotSupportedException e) { - throw new BuildException(e); - } - } - - // TODO this is a pretty expensive operation and so the result - // should be cached. - /** - * Turns all nested resources into corresponding ArchiveFileSets - * and returns an iterator over the collected archives. - */ - protected Iterator<ArchiveFileSet> grabArchives() { - final List<ArchiveFileSet> l = new LinkedList<ArchiveFileSet>(); - for (final Resource r : zips) { - l.add(configureArchive(new ZipFileSet(), r)); - } - for (final Resource r : tars) { - l.add(configureArchive(new TarFileSet(), r)); - } - return l.iterator(); - } - - /** - * Configures the archivefileset based on this type's settings, - * set the source. - */ - protected ArchiveFileSet configureArchive(final ArchiveFileSet afs, - final Resource src) { - afs.setProject(getProject()); - afs.setSrcResource(src); - return afs; - } - - /** - * Overrides the version of DataType to recurse on all DataType - * child elements that may have been added. - * @param stk the stack of data types to use (recursively). - * @param p the project to use to dereference the references. - * @throws BuildException on error. - */ - @Override - protected synchronized void dieOnCircularReference(final Stack<Object> stk, final Project p) - throws BuildException { - if (isChecked()) { - return; - } - if (isReference()) { - super.dieOnCircularReference(stk, p); - } else { - pushAndInvokeCircularReferenceCheck(zips, stk, p); - pushAndInvokeCircularReferenceCheck(tars, stk, p); - setChecked(true); - } - } - -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/BCFileSet.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/BCFileSet.java deleted file mode 100644 index aa99a4a3..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/BCFileSet.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * 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.util.Iterator; - -import org.apache.tools.ant.types.FileSet; -import org.apache.tools.ant.types.Resource; - -/** - * Utility FileSet that includes directories for backwards-compatibility - * with certain tasks e.g. Delete. - * @since Ant 1.7 - */ -public class BCFileSet extends FileSet { - /** - * Default constructor. - */ - public BCFileSet() { - } - - /** - * Construct a new BCFileSet from the specified FileSet. - * @param fs the FileSet from which to inherit config. - */ - public BCFileSet(FileSet fs) { - super(fs); - } - - /** - * Fulfill the ResourceCollection contract. - * @return an Iterator of Resources. - * @since Ant 1.7 - */ - public Iterator<Resource> iterator() { - if (isReference()) { - return ((FileSet) getRef(getProject())).iterator(); - } - FileResourceIterator result = new FileResourceIterator(getProject(), getDir()); - result.addFiles(getDirectoryScanner().getIncludedFiles()); - result.addFiles(getDirectoryScanner().getIncludedDirectories()); - return result; - } - - /** - * Fulfill the ResourceCollection contract. - * @return number of elements as int. - * @since Ant 1.7 - */ - public int size() { - if (isReference()) { - return ((FileSet) getRef(getProject())).size(); - } - return getDirectoryScanner().getIncludedFilesCount() - + getDirectoryScanner().getIncludedDirsCount(); - } - -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/BZip2Resource.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/BZip2Resource.java deleted file mode 100644 index 0c2dd4be..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/BZip2Resource.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * 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.IOException; -import java.io.InputStream; -import java.io.OutputStream; - -import org.apache.tools.bzip2.CBZip2InputStream; -import org.apache.tools.bzip2.CBZip2OutputStream; - -/** - * A Bzip2 compressed resource. - * - * <p>Wraps around another resource, delegates all queries to that - * other resource but uncompresses/compresses streams on the fly.</p> - * - * @since Ant 1.7 - */ -public class BZip2Resource extends CompressedResource { - private static final char[] MAGIC = new char[] {'B', 'Z'}; - - /** A no-arg constructor */ - public BZip2Resource() { - } - - /** - * Constructor with another resource to wrap. - * @param other the resource to wrap. - */ - public BZip2Resource(org.apache.tools.ant.types.ResourceCollection other) { - super(other); - } - - /** - * Decompress on the fly using {@link CBZip2InputStream}. - * @param in the stream to wrap. - * @return the wrapped stream. - * @throws IOException if there is a problem. - */ - protected InputStream wrapStream(InputStream in) throws IOException { - for (int i = 0; i < MAGIC.length; i++) { - if (in.read() != MAGIC[i]) { - throw new IOException("Invalid bz2 stream."); - } - } - return new CBZip2InputStream(in); - } - - /** - * Compress on the fly using {@link CBZip2OutputStream}. - * @param out the stream to wrap. - * @return the wrapped stream. - * @throws IOException if there is a problem. - */ - protected OutputStream wrapStream(OutputStream out) throws IOException { - for (int i = 0; i < MAGIC.length; i++) { - out.write(MAGIC[i]); - } - return new CBZip2OutputStream(out); - } - - /** - * Get the name of the compression method. - * @return the string "Bzip2". - */ - protected String getCompressionName() { - return "Bzip2"; - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/BaseResourceCollectionContainer.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/BaseResourceCollectionContainer.java deleted file mode 100644 index 281fa0f1..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/BaseResourceCollectionContainer.java +++ /dev/null @@ -1,268 +0,0 @@ -/* - * 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.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; -import java.util.Stack; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.types.DataType; -import org.apache.tools.ant.types.Resource; -import org.apache.tools.ant.types.ResourceCollection; - -/** - * Base class for ResourceCollections that nest multiple ResourceCollections. - * @since Ant 1.7 - */ -public abstract class BaseResourceCollectionContainer - extends DataType implements ResourceCollection, Cloneable { - private List<ResourceCollection> rc = new ArrayList<ResourceCollection>(); - private Collection<Resource> coll = null; - private boolean cache = true; - - /** - * Create a new BaseResourceCollectionContainer. - */ - public BaseResourceCollectionContainer() { - // TODO Auto-generated constructor stub - } - - /** - * Create a new BaseResourceCollectionContainer. - * @since Ant 1.8 - */ - public BaseResourceCollectionContainer(Project project) { - setProject(project); - } - - /** - * Set whether to cache collections. - * @param b boolean cache flag. - */ - public synchronized void setCache(boolean b) { - cache = b; - } - - /** - * Learn whether to cache collections. Default is <code>true</code>. - * @return boolean cache flag. - */ - public synchronized boolean isCache() { - return cache; - } - - /** - * Clear the container. - * @throws BuildException on error. - */ - public synchronized void clear() throws BuildException { - if (isReference()) { - throw noChildrenAllowed(); - } - rc.clear(); - FailFast.invalidate(this); - coll = null; - setChecked(false); - } - - /** - * Add a ResourceCollection to the container. - * @param c the ResourceCollection to add. - * @throws BuildException on error. - */ - public synchronized void add(ResourceCollection c) throws BuildException { - if (isReference()) { - throw noChildrenAllowed(); - } - if (c == null) { - return; - } - if (Project.getProject(c) == null) { - Project p = getProject(); - if (p != null) { - p.setProjectReference(c); - } - } - rc.add(c); - FailFast.invalidate(this); - coll = null; - setChecked(false); - } - - /** - * Add the Collection of ResourceCollections to the container. - * @param c the Collection whose elements to add. - * @throws BuildException on error. - */ - public synchronized void addAll(Collection<? extends ResourceCollection> c) throws BuildException { - if (isReference()) { - throw noChildrenAllowed(); - } - try { - for (ResourceCollection resourceCollection : c) { - add(resourceCollection); - } - } catch (ClassCastException e) { - throw new BuildException(e); - } - } - - /** - * Fulfill the ResourceCollection contract. The Iterator returned - * will throw ConcurrentModificationExceptions if ResourceCollections - * are added to this container while the Iterator is in use. - * @return a "fail-fast" Iterator. - */ - public final synchronized Iterator<Resource> iterator() { - if (isReference()) { - return ((BaseResourceCollectionContainer) getCheckedRef()).iterator(); - } - dieOnCircularReference(); - return new FailFast(this, cacheCollection().iterator()); - } - - /** - * Fulfill the ResourceCollection contract. - * @return number of elements as int. - */ - public synchronized int size() { - if (isReference()) { - return getCheckedRef(BaseResourceCollectionContainer.class, getDataTypeName()).size(); - } - dieOnCircularReference(); - return cacheCollection().size(); - } - - /** - * Fulfill the ResourceCollection contract. - * @return whether this is a filesystem-only resource collection. - */ - public synchronized boolean isFilesystemOnly() { - if (isReference()) { - return ((BaseResourceCollectionContainer) getCheckedRef()).isFilesystemOnly(); - } - dieOnCircularReference(); - //first the easy way, if all children are filesystem-only, return true: - boolean goEarly = true; - for (Iterator<ResourceCollection> i = rc.iterator(); goEarly && i.hasNext();) { - goEarly = i.next().isFilesystemOnly(); - } - if (goEarly) { - return true; - } - /* now check each Resource in case the child only - lets through files from any children IT may have: */ - for (Resource r : cacheCollection()) { - if (r.as(FileProvider.class) == null) { - return false; - } - } - return true; - } - - /** - * Overrides the version of DataType to recurse on all DataType - * child elements that may have been added. - * @param stk the stack of data types to use (recursively). - * @param p the project to use to dereference the references. - * @throws BuildException on error. - */ - protected synchronized void dieOnCircularReference(Stack<Object> stk, Project p) - throws BuildException { - if (isChecked()) { - return; - } - if (isReference()) { - super.dieOnCircularReference(stk, p); - } else { - for (ResourceCollection resourceCollection : rc) { - if (resourceCollection instanceof DataType) { - pushAndInvokeCircularReferenceCheck((DataType) resourceCollection, stk, p); - } - } - setChecked(true); - } - } - - /** - * Get the nested ResourceCollections. - * @return List. - */ - public final synchronized List<ResourceCollection> getResourceCollections() { - dieOnCircularReference(); - return Collections.unmodifiableList(rc); - } - - /** - * Template method for subclasses to return a Collection object of Resources. - * @return Collection. - */ - protected abstract Collection<Resource> getCollection(); - - /** - * Implement clone. The set of nested resource - * collections is shallowly cloned. - * @return a cloned instance. - */ - public Object clone() { - try { - BaseResourceCollectionContainer c - = (BaseResourceCollectionContainer) super.clone(); - c.rc = new ArrayList<ResourceCollection>(rc); - c.coll = null; - return c; - } catch (CloneNotSupportedException e) { - throw new BuildException(e); - } - } - - /** - * Format this BaseResourceCollectionContainer as a String. - * @return a descriptive <code>String</code>. - */ - public synchronized String toString() { - if (isReference()) { - return getCheckedRef().toString(); - } - if (cacheCollection().size() == 0) { - return ""; - } - StringBuilder sb = new StringBuilder(); - for (Resource resource : coll) { - if (sb.length() > 0) { - sb.append(File.pathSeparatorChar); - } - sb.append(resource); - } - return sb.toString(); - } - - private synchronized Collection<Resource> cacheCollection() { - if (coll == null || !isCache()) { - coll = getCollection(); - } - return coll; - } - -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/BaseResourceCollectionWrapper.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/BaseResourceCollectionWrapper.java deleted file mode 100644 index 78ba95ee..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/BaseResourceCollectionWrapper.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * 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.util.Collection; -import java.util.Iterator; - -import org.apache.tools.ant.types.Resource; - -/** - * Base class for a ResourceCollection that wraps a single nested - * ResourceCollection. - * @since Ant 1.7 - */ -public abstract class BaseResourceCollectionWrapper - extends AbstractResourceCollectionWrapper { - - private Collection<Resource> coll = null; - - protected Iterator<Resource> createIterator() { - return cacheCollection().iterator(); - } - - protected int getSize() { - return cacheCollection().size(); - } - - /** - * Template method for subclasses to return a Collection of Resources. - * @return Collection. - */ - protected abstract Collection<Resource> getCollection(); - - private synchronized Collection<Resource> cacheCollection() { - if (coll == null || !isCache()) { - coll = getCollection(); - } - return coll; - } - -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/CompressedResource.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/CompressedResource.java deleted file mode 100644 index 2c72c26f..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/CompressedResource.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * 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 org.apache.tools.ant.types.ResourceCollection; - -/** - * A compressed resource. - * - * <p>Wraps around another resource, delegates all queries (except - * getSize) to that other resource but uncompresses/compresses streams - * on the fly.</p> - * - * @since Ant 1.7 - */ -public abstract class CompressedResource extends ContentTransformingResource { - - /** no arg constructor */ - protected CompressedResource() { - } - - /** - * Constructor with another resource to wrap. - * @param other the resource to wrap. - */ - protected CompressedResource(ResourceCollection other) { - addConfigured(other); - } - - /** - * Get the string representation of this Resource. - * @return this Resource formatted as a String. - * @since Ant 1.7 - */ - public String toString() { - return getCompressionName() + " compressed " + super.toString(); - } - - /** - * Get the name of the compression method used. - * @return the name of the compression method. - */ - protected abstract String getCompressionName(); - -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/ContentTransformingResource.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/ContentTransformingResource.java deleted file mode 100644 index 79445bfd..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/ContentTransformingResource.java +++ /dev/null @@ -1,177 +0,0 @@ -/* - * 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.IOException; -import java.io.InputStream; -import java.io.OutputStream; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.types.ResourceCollection; -import org.apache.tools.ant.util.FileUtils; - -/** - * A resource that transforms the content of another resource. - * - * <p>Wraps around another resource, delegates all queries (except - * getSize) to that other resource but transforms stream content - * on the fly.</p> - * - * @since Ant 1.8 - */ -public abstract class ContentTransformingResource extends ResourceDecorator { - - private static final int BUFFER_SIZE = 8192; - - /** no arg constructor */ - protected ContentTransformingResource() { - } - - /** - * Constructor with another resource to wrap. - * @param other the resource to wrap. - */ - protected ContentTransformingResource(final ResourceCollection other) { - super(other); - } - - /** - * Get the size of this Resource. - * @return the size, as a long, 0 if the Resource does not exist (for - * compatibility with java.io.File), or UNKNOWN_SIZE if not known. - */ - @Override - public long getSize() { - if (isExists()) { - InputStream in = null; - try { - in = getInputStream(); - final byte[] buf = new byte[BUFFER_SIZE]; - int size = 0; - int readNow; - while ((readNow = in.read(buf, 0, buf.length)) > 0) { - size += readNow; - } - return size; - } catch (final IOException ex) { - throw new BuildException("caught exception while reading " - + getName(), ex); - } finally { - FileUtils.close(in); - } - } else { - return 0; - } - } - - /** - * Get an InputStream for the Resource. - * @return an InputStream containing this Resource's content. - * @throws IOException if unable to provide the content of this - * Resource as a stream. - * @throws UnsupportedOperationException if InputStreams are not - * supported for this Resource type. - */ - @Override - public InputStream getInputStream() throws IOException { - InputStream in = getResource().getInputStream(); - if (in != null) { - in = wrapStream(in); - } - return in; - } - - /** - * Get an OutputStream for the Resource. - * @return an OutputStream to which content can be written. - * @throws IOException if unable to provide the content of this - * Resource as a stream. - * @throws UnsupportedOperationException if OutputStreams are not - * supported for this Resource type. - */ - @Override - public OutputStream getOutputStream() throws IOException { - OutputStream out = getResource().getOutputStream(); - if (out != null) { - out = wrapStream(out); - } - return out; - } - - /** - * Suppress FileProvider, re-implement Appendable - */ - @Override - public <T> T as(final Class<T> clazz) { - if (Appendable.class.isAssignableFrom(clazz)) { - if (isAppendSupported()) { - final Appendable a = - getResource().as(Appendable.class); - if (a != null) { - return clazz.cast(new Appendable() { - public OutputStream getAppendOutputStream() - throws IOException { - OutputStream out = a.getAppendOutputStream(); - if (out != null) { - out = wrapStream(out); - } - return out; - } - }); - } - } - return null; - } - - return FileProvider.class.isAssignableFrom(clazz) - ? null : getResource().as(clazz); - } - - /** - * Learn whether the transformation performed allows appends. - * - * <p>In general compressed outputs will become invalid if they - * are appended to, for example.</p> - * - * <p>This implementations returns false.</p> - */ - protected boolean isAppendSupported() { - return false; - } - - /** - * Get a content-filtering/transforming InputStream. - * - * @param in InputStream to wrap, will never be null. - * @return a compressed inputstream. - * @throws IOException if there is a problem. - */ - protected abstract InputStream wrapStream(InputStream in) - throws IOException; - - /** - * Get a content-filtering/transforming OutputStream. - * - * @param out OutputStream to wrap, will never be null. - * @return a compressed outputstream. - * @throws IOException if there is a problem. - */ - protected abstract OutputStream wrapStream(OutputStream out) - throws IOException; - -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/Difference.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/Difference.java deleted file mode 100644 index 3f3c983c..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/Difference.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * 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.util.ArrayList; -import java.util.Collection; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.types.Resource; -import org.apache.tools.ant.types.ResourceCollection; - -/** - * ResourceCollection representing the difference between - * two or more nested ResourceCollections. - * @since Ant 1.7 - */ -public class Difference extends BaseResourceCollectionContainer { - - /** - * Calculate the difference of the nested ResourceCollections. - * @return a Collection of Resources. - */ - protected Collection<Resource> getCollection() { - List<ResourceCollection> rcs = getResourceCollections(); - int size = rcs.size(); - if (size < 2) { - throw new BuildException("The difference of " + size - + " resource collection" + ((size == 1) ? "" : "s") - + " is undefined."); - } - Set<Resource> hs = new HashSet<Resource>(); - List<Resource> al = new ArrayList<Resource>(); - for (ResourceCollection rc : rcs) { - for (Resource r : rc) { - if (hs.add(r)) { - al.add(r); - } else { - al.remove(r); - } - } - } - return al; - } - -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/FailFast.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/FailFast.java deleted file mode 100644 index dc962bb4..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/FailFast.java +++ /dev/null @@ -1,135 +0,0 @@ -/* - * 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.util.ConcurrentModificationException; -import java.util.HashSet; -import java.util.Iterator; -import java.util.NoSuchElementException; -import java.util.Set; -import java.util.WeakHashMap; - -import org.apache.tools.ant.types.Resource; - -/** - * Helper class for ResourceCollections to return Iterators - * that fail on changes to the object. - * @since Ant 1.7 - */ -/*package-private*/ class FailFast implements Iterator<Resource> { - private static final WeakHashMap<Object, Set<FailFast>> MAP = new WeakHashMap<Object, Set<FailFast>>(); - - /** - * Invalidate any in-use Iterators from the specified Object. - * @param o the parent Object. - */ - static synchronized void invalidate(Object o) { - Set<FailFast> s = MAP.get(o); - if (s != null) { - s.clear(); - } - } - - private static synchronized void add(FailFast f) { - Set<FailFast> s = MAP.get(f.parent); - if (s == null) { - s = new HashSet<FailFast>(); - MAP.put(f.parent, s); - } - s.add(f); - } - - private static synchronized void remove(FailFast f) { - Set<FailFast> s = MAP.get(f.parent); - if (s != null) { - s.remove(f); - } - } - - private static synchronized void failFast(FailFast f) { - Set<FailFast> s = MAP.get(f.parent); - if (!s.contains(f)) { - throw new ConcurrentModificationException(); - } - } - - private final Object parent; - private Iterator<Resource> wrapped; - - /** - * Construct a new FailFast Iterator wrapping the specified Iterator - * and dependent upon the specified parent Object. - * @param o the parent Object. - * @param i the wrapped Iterator. - */ - FailFast(Object o, Iterator<Resource> i) { - if (o == null) { - throw new IllegalArgumentException("parent object is null"); - } - if (i == null) { - throw new IllegalArgumentException("cannot wrap null iterator"); - } - parent = o; - if (i.hasNext()) { - wrapped = i; - add(this); - } - } - - /** - * Fulfill the Iterator contract. - * @return true if there are more elements. - */ - public boolean hasNext() { - if (wrapped == null) { - return false; - } - failFast(this); - return wrapped.hasNext(); - } - - /** - * Fulfill the Iterator contract. - * @return the next element. - * @throws NoSuchElementException if no more elements. - */ - public Resource next() { - if (wrapped == null || !wrapped.hasNext()) { - throw new NoSuchElementException(); - } - failFast(this); - try { - return wrapped.next(); - } finally { - if (!wrapped.hasNext()) { - wrapped = null; - remove(this); - } - } - } - - /** - * Fulfill the Iterator contract. - * @throws UnsupportedOperationException always. - */ - public void remove() { - throw new UnsupportedOperationException(); - } - -} - diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/FileProvider.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/FileProvider.java deleted file mode 100644 index aa283004..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/FileProvider.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * 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; - -/** - * This is an interface that resources that can provide a file should implement. - * This is a refactoring of {@link FileResource}, to allow other resources - * to act as sources of files (and to make components that only support - * file-based resources from only support FileResource resources. - * @since Ant 1.8 - */ -public interface FileProvider { - /** - * Get the file represented by this Resource. - * @return the file. - */ - File getFile(); -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/FileResource.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/FileResource.java deleted file mode 100644 index 3ed49b81..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/FileResource.java +++ /dev/null @@ -1,392 +0,0 @@ -/* - * 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.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.types.Reference; -import org.apache.tools.ant.types.Resource; -import org.apache.tools.ant.types.ResourceFactory; -import org.apache.tools.ant.util.FileUtils; - -/** - * A Resource representation of a File. - * @since Ant 1.7 - */ -public class FileResource extends Resource implements Touchable, FileProvider, - ResourceFactory, Appendable { - - private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); - private static final int NULL_FILE - = Resource.getMagicNumber("null file".getBytes()); - - private File file; - private File baseDir; - - /** - * Default constructor. - */ - public FileResource() { - } - - /** - * Construct a new FileResource using the specified basedir and relative name. - * @param b the basedir as File. - * @param name the relative filename. - */ - public FileResource(File b, String name) { - this.baseDir = b; - this.file = FILE_UTILS.resolveFile(b, name); - } - - /** - * Construct a new FileResource from a File. - * @param f the File represented. - */ - public FileResource(File f) { - setFile(f); - } - - /** - * Create a new FileResource. - * @param p Project - * @param f File represented - * @since Ant 1.8 - */ - public FileResource(Project p, File f) { - this(f); - setProject(p); - } - - /** - * Constructor for Ant attribute introspection. - * @param p the Project against which to resolve <code>s</code>. - * @param s the absolute or Project-relative filename as a String. - * @see org.apache.tools.ant.IntrospectionHelper - */ - public FileResource(Project p, String s) { - this(p, p.resolveFile(s)); - } - - /** - * Set the File for this FileResource. - * @param f the File to be represented. - */ - public void setFile(File f) { - checkAttributesAllowed(); - file = f; - if (f != null && (getBaseDir() == null || !FILE_UTILS.isLeadingPath(getBaseDir(), f))) { - setBaseDir(f.getParentFile()); - } - } - - /** - * Get the file represented by this FileResource. - * @return the File. - */ - public File getFile() { - if (isReference()) { - return ((FileResource) getCheckedRef()).getFile(); - } - dieOnCircularReference(); - synchronized (this) { - if (file == null) { - //try to resolve file set via basedir/name property setters: - File d = getBaseDir(); - String n = super.getName(); - if (n != null) { - setFile(FILE_UTILS.resolveFile(d, n)); - } - } - } - return file; - } - - /** - * Set the basedir for this FileResource. - * @param b the basedir as File. - */ - public void setBaseDir(File b) { - checkAttributesAllowed(); - baseDir = b; - } - - /** - * Return the basedir to which the name is relative. - * @return the basedir as File. - */ - public File getBaseDir() { - if (isReference()) { - return ((FileResource) getCheckedRef()).getBaseDir(); - } - dieOnCircularReference(); - return baseDir; - } - - /** - * Overrides the super version. - * @param r the Reference to set. - */ - public void setRefid(Reference r) { - if (file != null || baseDir != null) { - throw tooManyAttributes(); - } - super.setRefid(r); - } - - /** - * Get the name of this FileResource. If the basedir is set, - * the name will be relative to that. Otherwise the basename - * only will be returned. - * @return the name of this resource. - */ - public String getName() { - if (isReference()) { - return ((Resource) getCheckedRef()).getName(); - } - File b = getBaseDir(); - return b == null ? getNotNullFile().getName() - : FILE_UTILS.removeLeadingPath(b, getNotNullFile()); - } - - /** - * Learn whether this file exists. - * @return true if this resource exists. - */ - public boolean isExists() { - return isReference() ? ((Resource) getCheckedRef()).isExists() - : getNotNullFile().exists(); - } - - /** - * Get the modification time in milliseconds since 01.01.1970 . - * @return 0 if the resource does not exist. - */ - public long getLastModified() { - return isReference() - ? ((Resource) getCheckedRef()).getLastModified() - : getNotNullFile().lastModified(); - } - - /** - * Learn whether the resource is a directory. - * @return boolean flag indicating if the resource is a directory. - */ - public boolean isDirectory() { - return isReference() ? ((Resource) getCheckedRef()).isDirectory() - : getNotNullFile().isDirectory(); - } - - /** - * Get the size of this Resource. - * @return the size, as a long, 0 if the Resource does not exist. - */ - public long getSize() { - return isReference() ? ((Resource) getCheckedRef()).getSize() - : getNotNullFile().length(); - } - - /** - * Return an InputStream for reading the contents of this Resource. - * @return an InputStream object. - * @throws IOException if an error occurs. - */ - public InputStream getInputStream() throws IOException { - return isReference() - ? ((Resource) getCheckedRef()).getInputStream() - : new FileInputStream(getNotNullFile()); - } - - /** - * Get an OutputStream for the Resource. - * @return an OutputStream to which content can be written. - * @throws IOException if unable to provide the content of this - * Resource as a stream. - * @throws UnsupportedOperationException if OutputStreams are not - * supported for this Resource type. - */ - public OutputStream getOutputStream() throws IOException { - if (isReference()) { - return ((FileResource) getCheckedRef()).getOutputStream(); - } - return getOutputStream(false); - } - - /** - * {@inheritDoc} - */ - public OutputStream getAppendOutputStream() throws IOException { - if (isReference()) { - return ((FileResource) getCheckedRef()).getAppendOutputStream(); - } - return getOutputStream(true); - } - - private OutputStream getOutputStream(boolean append) throws IOException { - File f = getNotNullFile(); - if (f.exists()) { - if (f.isFile() && !append) { - f.delete(); - } - } else { - File p = f.getParentFile(); - if (p != null && !(p.exists())) { - p.mkdirs(); - } - } - return append ? new FileOutputStream(f.getAbsolutePath(), true) : new FileOutputStream(f); - } - - /** - * Compare this FileResource to another Resource. - * @param another the other Resource against which to compare. - * @return a negative integer, zero, or a positive integer as this FileResource - * is less than, equal to, or greater than the specified Resource. - */ - public int compareTo(Resource another) { - if (isReference()) { - return ((Resource) getCheckedRef()).compareTo(another); - } - if (this.equals(another)) { - return 0; - } - FileProvider otherFP = another.as(FileProvider.class); - if (otherFP != null) { - File f = getFile(); - if (f == null) { - return -1; - } - File of = otherFP.getFile(); - if (of == null) { - return 1; - } - return f.compareTo(of); - } - return super.compareTo(another); - } - - /** - * Compare another Object to this FileResource for equality. - * @param another the other Object to compare. - * @return true if another is a FileResource representing the same file. - */ - public boolean equals(Object another) { - if (this == another) { - return true; - } - if (isReference()) { - return getCheckedRef().equals(another); - } - if (another == null || !(another.getClass().equals(getClass()))) { - return false; - } - FileResource otherfr = (FileResource) another; - return getFile() == null - ? otherfr.getFile() == null - : getFile().equals(otherfr.getFile()); - } - - /** - * Get the hash code for this Resource. - * @return hash code as int. - */ - public int hashCode() { - if (isReference()) { - return getCheckedRef().hashCode(); - } - return MAGIC * (getFile() == null ? NULL_FILE : getFile().hashCode()); - } - - /** - * Get the string representation of this Resource. - * @return this FileResource formatted as a String. - */ - public String toString() { - if (isReference()) { - return getCheckedRef().toString(); - } - if (file == null) { - return "(unbound file resource)"; - } - String absolutePath = file.getAbsolutePath(); - return FILE_UTILS.normalize(absolutePath).getAbsolutePath(); - } - - /** - * Fulfill the ResourceCollection contract. - * @return whether this Resource is a FileResource. - */ - public boolean isFilesystemOnly() { - if (isReference()) { - return ((FileResource) getCheckedRef()).isFilesystemOnly(); - } - dieOnCircularReference(); - return true; - } - - /** - * Implement the Touchable interface. - * @param modTime new last modification time. - */ - public void touch(long modTime) { - if (isReference()) { - ((FileResource) getCheckedRef()).touch(modTime); - return; - } - if (!getNotNullFile().setLastModified(modTime)) { - log("Failed to change file modification time", Project.MSG_WARN); - } - } - - /** - * Get the file represented by this FileResource, ensuring it is not null. - * @return the not-null File. - * @throws BuildException if file is null. - */ - protected File getNotNullFile() { - if (getFile() == null) { - throw new BuildException("file attribute is null!"); - } - dieOnCircularReference(); - return getFile(); - } - - /** - * Create a new resource that matches a relative or absolute path. - * If the current instance has a compatible baseDir attribute, it is copied. - * @param path relative/absolute path to a resource - * @return a new resource of type FileResource - * @throws BuildException if desired - * @since Ant1.8 - */ - public Resource getResource(String path) { - File newfile = FILE_UTILS.resolveFile(getFile(), path); - FileResource fileResource = new FileResource(newfile); - if (FILE_UTILS.isLeadingPath(getBaseDir(), newfile)) { - fileResource.setBaseDir(getBaseDir()); - } - return fileResource; - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/FileResourceIterator.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/FileResourceIterator.java deleted file mode 100644 index 6d8849ce..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/FileResourceIterator.java +++ /dev/null @@ -1,149 +0,0 @@ -/* - * 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.Iterator; -import java.util.NoSuchElementException; - -import org.apache.tools.ant.Project; -import org.apache.tools.ant.types.Resource; - -/** - * Iterator of FileResources from filenames. - * @since Ant 1.7 - */ -public class FileResourceIterator implements Iterator<Resource> { - private Project project; - private File basedir; - private String[] files; - private int pos = 0; - - /** - * Construct a new FileResourceIterator. - * @deprecated in favor of {@link FileResourceIterator#FileResourceIterator(Project)} - */ - public FileResourceIterator() { - } - - /** - * Create a new FileResourceIterator. - * @param project associated Project instance - * @since Ant 1.8 - */ - public FileResourceIterator(Project project) { - this.project = project; - } - - /** - * Construct a new FileResourceIterator relative to the specified - * base directory. - * @param basedir the base directory of this instance. - * @deprecated in favor of {@link FileResourceIterator#FileResourceIterator(Project, File)} - */ - public FileResourceIterator(File basedir) { - this(null, basedir); - } - - /** - * Construct a new FileResourceIterator relative to the specified - * base directory. - * @param project associated Project instance - * @param basedir the base directory of this instance. - * @since Ant 1.8 - */ - public FileResourceIterator(Project project, File basedir) { - this(project); - this.basedir = basedir; - } - - /** - * Construct a new FileResourceIterator over the specified filenames, - * relative to the specified base directory. - * @param basedir the base directory of this instance. - * @param filenames the String[] of filenames. - * @deprecated in favor of {@link FileResourceIterator#FileResourceIterator(Project, File, String[])} - */ - public FileResourceIterator(File basedir, String[] filenames) { - this(null, basedir, filenames); - } - - /** - * Construct a new FileResourceIterator over the specified filenames, - * relative to the specified base directory. - * @param project associated Project instance - * @param basedir the base directory of this instance. - * @param filenames the String[] of filenames. - * @since Ant 1.8 - */ - public FileResourceIterator(Project project, File basedir, String[] filenames) { - this(project, basedir); - addFiles(filenames); - } - - /** - * Add an array of filenames to this FileResourceIterator. - * @param s the filenames to add. - */ - public void addFiles(String[] s) { - int start = (files == null) ? 0 : files.length; - String[] newfiles = new String[start + s.length]; - if (start > 0) { - System.arraycopy(files, 0, newfiles, 0, start); - } - files = newfiles; - System.arraycopy(s, 0, files, start, s.length); - } - - /** - * Find out whether this FileResourceIterator has more elements. - * @return whether there are more Resources to iterate over. - */ - public boolean hasNext() { - return pos < files.length; - } - - /** - * Get the next element from this FileResourceIterator. - * @return the next Object. - */ - public Resource next() { - return nextResource(); - } - - /** - * Not implemented. - */ - public void remove() { - throw new UnsupportedOperationException(); - } - - /** - * Convenience method to return the next resource. - * @return the next File. - */ - public FileResource nextResource() { - if (!hasNext()) { - throw new NoSuchElementException(); - } - FileResource result = new FileResource(basedir, files[pos++]); - result.setProject(project); - return result; - } - -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/Files.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/Files.java deleted file mode 100644 index 521bcc8d..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/Files.java +++ /dev/null @@ -1,503 +0,0 @@ -/* - * 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.Collections; -import java.util.Iterator; -import java.util.Vector; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.DirectoryScanner; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.types.PatternSet; -import org.apache.tools.ant.types.Reference; -import org.apache.tools.ant.types.Resource; -import org.apache.tools.ant.types.ResourceCollection; -import org.apache.tools.ant.types.selectors.AbstractSelectorContainer; -import org.apache.tools.ant.types.selectors.FileSelector; - -/** - * ResourceCollection implementation; like AbstractFileSet with absolute paths. - * @since Ant 1.7 - */ -public class Files extends AbstractSelectorContainer - implements ResourceCollection { - - private static final Iterator<Resource> EMPTY_ITERATOR - = Collections.<Resource>emptySet().iterator(); - - private PatternSet defaultPatterns = new PatternSet(); - private Vector<PatternSet> additionalPatterns = new Vector<PatternSet>(); - - 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.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 (hasSelectors()) { - 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; - setChecked(false); - 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; - } - - /** - * 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<Resource> 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(getProject()); - 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(); - } - dieOnCircularReference(); - if (hasPatterns(defaultPatterns)) { - return true; - } - for (PatternSet patternSet : additionalPatterns) { - if (hasPatterns(patternSet)) { - 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<Resource> 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(); - } - Files f = (Files) super.clone(); - f.defaultPatterns = (PatternSet) defaultPatterns.clone(); - f.additionalPatterns = new Vector<PatternSet>(additionalPatterns.size()); - for (PatternSet ps : additionalPatterns) { - f.additionalPatterns.add((PatternSet) ps.clone()); - } - return f; - } - - /** - * 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); - } - dieOnCircularReference(); - 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() { - dieOnCircularReference(); - 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); - } - -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/First.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/First.java deleted file mode 100644 index ea9e7d0a..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/First.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * 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.util.ArrayList; -import java.util.Collection; -import java.util.Iterator; -import java.util.List; - -import org.apache.tools.ant.types.Resource; - -/** - * ResourceCollection that contains the first <code>count</code> elements of - * another ResourceCollection, a la the UNIX head command. - * @since Ant 1.7 - */ -public class First extends SizeLimitCollection { - - /** - * Take the first <code>count</code> elements. - * @return a Collection of Resources. - */ - protected Collection<Resource> getCollection() { - int ct = getValidCount(); - Iterator<Resource> iter = getResourceCollection().iterator(); - List<Resource> al = new ArrayList<Resource>(ct); - for (int i = 0; i < ct && iter.hasNext(); i++) { - al.add(iter.next()); - } - return al; - } - -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/GZipResource.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/GZipResource.java deleted file mode 100644 index 3f95a698..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/GZipResource.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * 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.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.util.zip.GZIPInputStream; -import java.util.zip.GZIPOutputStream; - -/** - * A GZip compressed resource. - * - * <p>Wraps around another resource, delegates all queries to that - * other resource but uncompresses/compresses streams on the fly.</p> - * - * @since Ant 1.7 - */ -public class GZipResource extends CompressedResource { - - /** A no-arg constructor */ - public GZipResource() { - } - - /** - * Constructor with another resource to wrap. - * @param other the resource to wrap. - */ - public GZipResource(org.apache.tools.ant.types.ResourceCollection other) { - super(other); - } - - /** - * Decompress on the fly using java.util.zip.GZIPInputStream. - * @param in the stream to wrap. - * @return the wrapped stream. - * @throws IOException if there is a problem. - */ - protected InputStream wrapStream(InputStream in) throws IOException { - return new GZIPInputStream(in); - } - - /** - * Compress on the fly using java.util.zip.GZIPOutStream. - * @param out the stream to wrap. - * @return the wrapped stream. - * @throws IOException if there is a problem. - */ - protected OutputStream wrapStream(OutputStream out) throws IOException { - return new GZIPOutputStream(out); - } - - /** - * Get the name of the compression method. - * @return the string "GZip". - */ - protected String getCompressionName() { - return "GZip"; - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/ImmutableResourceException.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/ImmutableResourceException.java deleted file mode 100644 index 9dce7154..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/ImmutableResourceException.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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.IOException; - -/** - * Exception thrown when an attempt is made to get an OutputStream - * from an immutable Resource. - * @since Ant 1.7 - */ -public class ImmutableResourceException extends IOException { - private static final long serialVersionUID = 1L; - - /** - * Default constructor. - */ - public ImmutableResourceException() { - super(); - } - - /** - * Construct a new ImmutableResourceException with the specified message. - * @param s the message String. - */ - public ImmutableResourceException(String s) { - super(s); - } - -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/Intersect.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/Intersect.java deleted file mode 100644 index cdbeed0f..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/Intersect.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * 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.util.Collection; -import java.util.Iterator; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Set; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.types.Resource; -import org.apache.tools.ant.types.ResourceCollection; - -/** - * ResourceCollection representing the intersection - * of multiple nested ResourceCollections. - * @since Ant 1.7 - */ -public class Intersect extends BaseResourceCollectionContainer { - - /** - * Calculate the intersection of the nested ResourceCollections. - * @return a Collection of Resources. - */ - protected Collection<Resource> getCollection() { - List<ResourceCollection> rcs = getResourceCollections(); - int size = rcs.size(); - if (size < 2) { - throw new BuildException("The intersection of " + size - + " resource collection" + ((size == 1) ? "" : "s") - + " is undefined."); - } - Iterator<ResourceCollection> rc = rcs.iterator(); - Set<Resource> s = new LinkedHashSet<Resource>(collect(rc.next())); - while (rc.hasNext()) { - s.retainAll(collect(rc.next())); - } - return s; - } - - private Set<Resource> collect(ResourceCollection rc) { - Set<Resource> result = new LinkedHashSet<Resource>(); - for (Resource r : rc) { - result.add(r); - } - return result; - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/JavaConstantResource.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/JavaConstantResource.java deleted file mode 100644 index e8c8f02c..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/JavaConstantResource.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * 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.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.lang.reflect.Field; - -/** - * A resource that is a java constant. - * This lets you extract values off the classpath and use them elsewhere - * @since Ant 1.7 - */ -public class JavaConstantResource extends AbstractClasspathResource { - - /** - * open the input stream from a specific classloader - * - * @param cl the classloader to use. Will be null if the system classloader is used - * @return an open input stream for the resource - * @throws IOException if an error occurs. - */ - protected InputStream openInputStream(ClassLoader cl) throws IOException { - String constant = getName(); - if (constant == null) { - throw new IOException("Attribute 'name' must be set."); - } - int index = constant.lastIndexOf('.'); - if (index < 0) { - throw new IOException("No class name in " + constant); - } - String classname = constant.substring(0, index); - String fieldname = constant.substring(index + 1, constant.length()); - try { - Class<?> clazz = - cl != null - ? Class.forName(classname, true, cl) - : Class.forName(classname); - Field field = clazz.getField(fieldname); - String value = field.get(null).toString(); - return new ByteArrayInputStream(value.getBytes("UTF-8")); - } catch (ClassNotFoundException e) { - throw new IOException("Class not found:" + classname); - } catch (NoSuchFieldException e) { - throw new IOException( - "Field not found:" + fieldname + " in " + classname); - } catch (IllegalAccessException e) { - throw new IOException("Illegal access to :" + fieldname + " in " + classname); - } catch (NullPointerException npe) { - throw new IOException("Not a static field: " + fieldname + " in " + classname); - } - } - -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/JavaResource.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/JavaResource.java deleted file mode 100644 index a927d3fb..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/JavaResource.java +++ /dev/null @@ -1,141 +0,0 @@ -/* - * 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.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; -import java.net.URL; - -import org.apache.tools.ant.types.Path; -import org.apache.tools.ant.types.Resource; - -/** - * A Resource representation of something loadable via a Java classloader. - * @since Ant 1.7 - */ -public class JavaResource extends AbstractClasspathResource - implements URLProvider { - - /** - * Default constructor. - */ - public JavaResource() { - } - - /** - * Construct a new JavaResource using the specified name and - * classpath. - * - * @param name the resource name. - * @param path the classpath. - */ - public JavaResource(String name, Path path) { - setName(name); - setClasspath(path); - } - - /** - * open the input stream from a specific classloader - * @param cl the classloader to use. Will be null if the system - * classloader is used - * @return an open input stream for the resource - * @throws IOException if an error occurs. - */ - protected InputStream openInputStream(ClassLoader cl) throws IOException { - InputStream inputStream; - if (cl == null) { - inputStream = ClassLoader.getSystemResourceAsStream(getName()); - if (inputStream == null) { - throw new FileNotFoundException("No resource " + getName() - + " on Ant's classpath"); - } - } else { - inputStream = cl.getResourceAsStream(getName()); - if (inputStream == null) { - throw new FileNotFoundException("No resource " + getName() - + " on the classpath " + cl); - } - } - return inputStream; - } - - /** - * Get the URL represented by this Resource. - * @since Ant 1.8.0 - */ - public URL getURL() { - if (isReference()) { - return ((JavaResource) getCheckedRef()).getURL(); - } - AbstractClasspathResource.ClassLoaderWithFlag classLoader = - getClassLoader(); - if (classLoader.getLoader() == null) { - return ClassLoader.getSystemResource(getName()); - } else { - try { - return classLoader.getLoader().getResource(getName()); - } finally { - classLoader.cleanup(); - } - } - } - - /** - * Compare this JavaResource to another Resource. - * @param another the other Resource against which to compare. - * @return a negative integer, zero, or a positive integer as this - * JavaResource is less than, equal to, or greater than the - * specified Resource. - */ - public int compareTo(Resource another) { - if (isReference()) { - return ((Resource) getCheckedRef()).compareTo(another); - } - if (another.getClass().equals(getClass())) { - JavaResource otherjr = (JavaResource) another; - if (!getName().equals(otherjr.getName())) { - return getName().compareTo(otherjr.getName()); - } - if (getLoader() != otherjr.getLoader()) { - if (getLoader() == null) { - return -1; - } - if (otherjr.getLoader() == null) { - return 1; - } - return getLoader().getRefId() - .compareTo(otherjr.getLoader().getRefId()); - } - Path p = getClasspath(); - Path op = otherjr.getClasspath(); - if (p != op) { - if (p == null) { - return -1; - } - if (op == null) { - return 1; - } - return p.toString().compareTo(op.toString()); - } - return 0; - } - return super.compareTo(another); - } - -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/Last.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/Last.java deleted file mode 100644 index 312271b2..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/Last.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * 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.util.ArrayList; -import java.util.Collection; -import java.util.Iterator; -import java.util.List; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.types.Resource; -import org.apache.tools.ant.types.ResourceCollection; - -/** - * ResourceCollection that contains the last <code>count</code> elements of - * another ResourceCollection, a la the UNIX tail command. - * @since Ant 1.7.1 - */ -public class Last extends SizeLimitCollection { - - /** - * Take the last <code>count</code> elements. - * @return a Collection of Resources. - */ - protected Collection<Resource> getCollection() { - int count = getValidCount(); - ResourceCollection rc = getResourceCollection(); - int i = count; - Iterator<Resource> iter = rc.iterator(); - int size = rc.size(); - for (; i < size; i++) { - iter.next(); - } - - List<Resource> al = new ArrayList<Resource>(count); - for (; iter.hasNext(); i++) { - al.add(iter.next()); - } - int found = al.size(); - if (found == count || (size < count && found == size)) { - return al; - } - - //mismatch: - String msg = "Resource collection " + rc + " reports size " + size - + " but returns " + i + " elements."; - - //size was understated -> too many results; warn and continue: - if (found > count) { - log(msg, Project.MSG_WARN); - return al.subList(found - count, found); - } - //size was overstated; we missed some and are now in error-land: - throw new BuildException(msg); - } - -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/LazyResourceCollectionWrapper.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/LazyResourceCollectionWrapper.java deleted file mode 100644 index 4f9acd32..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/LazyResourceCollectionWrapper.java +++ /dev/null @@ -1,176 +0,0 @@ -/* - * 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.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.NoSuchElementException; - -import org.apache.tools.ant.types.Resource; - -/** - * Resource collection which load underlying resource collection only on demand - * with support for caching - */ -public class LazyResourceCollectionWrapper extends - AbstractResourceCollectionWrapper { - - /** List of cached resources */ - private final List<Resource> cachedResources = new ArrayList<Resource>(); - - private FilteringIterator filteringIterator; - - @Override - protected Iterator<Resource> createIterator() { - Iterator<Resource> iterator; - if (isCache()) { - if (filteringIterator == null) { - // no worry of thread safety here, see function's contract - filteringIterator = new FilteringIterator( - getResourceCollection().iterator()); - } - iterator = new CachedIterator(filteringIterator); - } else { - iterator = new FilteringIterator(getResourceCollection().iterator()); - } - return iterator; - } - - @Override - protected int getSize() { - // to compute the size, just iterate: the iterator will take care of - // caching - final Iterator<Resource> it = createIterator(); - int size = 0; - while (it.hasNext()) { - it.next(); - size++; - } - return size; - } - - /** - * Specify if the resource should be filtered or not. This function should - * be overrided in order to define the filtering algorithm - * - * @param r resource considered for filtration - * @return whether the resource should be filtered or not - */ - protected boolean filterResource(final Resource r) { - return false; - } - - private class FilteringIterator implements Iterator<Resource> { - - Resource next = null; - - boolean ended = false; - - protected final Iterator<Resource> it; - - public FilteringIterator(final Iterator<Resource> it) { - this.it = it; - } - - public boolean hasNext() { - if (ended) { - return false; - } - while (next == null) { - if (!it.hasNext()) { - ended = true; - return false; - } - next = it.next(); - if (filterResource(next)) { - next = null; - } - } - return true; - } - - public Resource next() { - if (!hasNext()) { - throw new UnsupportedOperationException(); - } - final Resource r = next; - next = null; - return r; - } - - public void remove() { - throw new UnsupportedOperationException(); - } - } - - /** - * Iterator that will put in the shared cache array list the selected - * resources - */ - private class CachedIterator implements Iterator<Resource> { - - int cusrsor = 0; - - private final Iterator<Resource> it; - - /** - * Default constructor - * - * @param it - * the iterator which will provide the resources to put in - * cache - */ - public CachedIterator(final Iterator<Resource> it) { - this.it = it; - } - - public boolean hasNext() { - synchronized (cachedResources) { - // have we already cached the next entry ? - if (cachedResources.size() > cusrsor) { - return true; - } - // does the wrapped iterator any more resource ? - if (!it.hasNext()) { - return false; - } - // put in cache the next resource - final Resource r = it.next(); - cachedResources.add(r); - } - return true; - } - - public Resource next() { - // first check that we have some to deliver - if (!hasNext()) { - throw new NoSuchElementException(); - } - synchronized (cachedResources) { - // return the cached entry as hasNext should have put one for - // this iterator - return cachedResources.get(cusrsor++); - } - } - - public void remove() { - throw new UnsupportedOperationException(); - } - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/LogOutputResource.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/LogOutputResource.java deleted file mode 100644 index cd19c9c7..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/LogOutputResource.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * 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.IOException; -import java.io.OutputStream; - -import org.apache.tools.ant.ProjectComponent; -import org.apache.tools.ant.taskdefs.LogOutputStream; -import org.apache.tools.ant.types.Resource; - -/** - * Output-only Resource that always appends to Ant's log. - * @since Ant 1.8 - */ -public class LogOutputResource extends Resource implements Appendable { - private static final String NAME = "[Ant log]"; - - private LogOutputStream outputStream; - - /** - * Create a new LogOutputResource. - * @param managingComponent - */ - public LogOutputResource(ProjectComponent managingComponent) { - super(NAME); - outputStream = new LogOutputStream(managingComponent); - } - - /** - * Create a new LogOutputResource. - * @param managingComponent owning log content - * @param level log level - */ - public LogOutputResource(ProjectComponent managingComponent, int level) { - super(NAME); - outputStream = new LogOutputStream(managingComponent, level); - } - - /** - * {@inheritDoc} - */ - public OutputStream getAppendOutputStream() throws IOException { - return outputStream; - } - - /** - * {@inheritDoc} - */ - public OutputStream getOutputStream() throws IOException { - return outputStream; - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/MappedResource.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/MappedResource.java deleted file mode 100644 index 339c88bf..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/MappedResource.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * 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 org.apache.tools.ant.types.Reference; -import org.apache.tools.ant.types.Resource; -import org.apache.tools.ant.util.FileNameMapper; - -/** - * A decorator around a different resource that uses a mapper to - * dynamically remap the resource's name. - * - * <p>Strips the FileProvider interface from decorated resources since - * it may be used to circumvent name mapping.</p> - * - * @since Ant 1.8.0 - */ -public class MappedResource extends ResourceDecorator { - private final FileNameMapper mapper; - - /** - * Wraps an existing resource. - * @param r Resource to wrap - * @param m FileNameMapper that handles mapping - */ - public MappedResource(Resource r, FileNameMapper m) { - super(r); - mapper = m; - } - - /** - * Maps the name. - */ - @Override - public String getName() { - String name = getResource().getName(); - if (isReference()) { - return name; - } - String[] mapped = mapper.mapFileName(name); - return mapped != null && mapped.length > 0 ? mapped[0] : null; - } - - /** - * Not really supported since mapper is never null. - * @param r reference to set - */ - @Override - public void setRefid(Reference r) { - if (mapper != null) { - throw noChildrenAllowed(); - } - super.setRefid(r); - } - - /** - * Suppress FileProvider - * @param clazz the type to implement - */ - @Override - public <T> T as(Class<T> clazz) { - return FileProvider.class.isAssignableFrom(clazz) - ? null : getResource().as(clazz); - } - - /** - * Get the hash code for this Resource. - * @since Ant 1.8.1 - */ - @Override - public int hashCode() { - String n = getName(); - return n == null ? super.hashCode() : n.hashCode(); - } - - /** - * Equality check based on the resource's name in addition to the - * resource itself. - * @since Ant 1.8.1 - */ - @Override - public boolean equals(Object other) { - if (other == null || !other.getClass().equals(getClass())) { - return false; - } - MappedResource m = (MappedResource) other; - String myName = getName(); - String otherName = m.getName(); - return (myName == null ? otherName == null : myName.equals(otherName)) - && getResource().equals(m.getResource()); - } - - @Override - public String toString() { - if (isReference()) { - return getCheckedRef().toString(); - } - return getName(); - } - -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/MappedResourceCollection.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/MappedResourceCollection.java deleted file mode 100644 index 2f1a926b..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/MappedResourceCollection.java +++ /dev/null @@ -1,267 +0,0 @@ -/* - * 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.ArrayList; -import java.util.Collection; -import java.util.Iterator; -import java.util.Stack; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.types.DataType; -import org.apache.tools.ant.types.Mapper; -import org.apache.tools.ant.types.Reference; -import org.apache.tools.ant.types.Resource; -import org.apache.tools.ant.types.ResourceCollection; -import org.apache.tools.ant.util.FileNameMapper; -import org.apache.tools.ant.util.IdentityMapper; -import org.apache.tools.ant.util.MergingMapper; - -/** - * Wrapper around a resource collections that maps the names of the - * other collection using a configured mapper. - * @since Ant 1.8.0 - */ -public class MappedResourceCollection - extends DataType implements ResourceCollection, Cloneable { - - private ResourceCollection nested = null; - private Mapper mapper = null; - private boolean enableMultipleMappings = false; - private boolean cache = false; - private Collection<Resource> cachedColl = null; - - /** - * Adds the required nested ResourceCollection. - * @param c the ResourceCollection to add. - * @throws BuildException on error. - */ - public synchronized void add(ResourceCollection c) throws BuildException { - if (isReference()) { - throw noChildrenAllowed(); - } - if (nested != null) { - throw new BuildException("Only one resource collection can be" - + " nested into mappedresources", - getLocation()); - } - setChecked(false); - cachedColl = null; - nested = c; - } - - /** - * Define the mapper to map source to destination files. - * @return a mapper to be configured. - * @exception BuildException if more than one mapper is defined. - */ - public Mapper createMapper() throws BuildException { - if (isReference()) { - throw noChildrenAllowed(); - } - if (mapper != null) { - throw new BuildException("Cannot define more than one mapper", - getLocation()); - } - setChecked(false); - mapper = new Mapper(getProject()); - cachedColl = null; - return mapper; - } - - /** - * Add a nested filenamemapper. - * @param fileNameMapper the mapper to add. - * @since Ant 1.6.3 - */ - public void add(FileNameMapper fileNameMapper) { - createMapper().add(fileNameMapper); - } - - /** - * Set method of handling mappers that return multiple - * mappings for a given source path. - * @param enableMultipleMappings If true the type will - * use all the mappings for a given source path, if - * false, only the first mapped name is - * processed. - * By default, this setting is false to provide backward - * compatibility with earlier releases. - * @since Ant 1.8.1 - */ - public void setEnableMultipleMappings(boolean enableMultipleMappings) { - this.enableMultipleMappings = enableMultipleMappings; - } - - /** - * Set whether to cache collections. - * @since Ant 1.8.1 - */ - public void setCache(boolean cache) { - this.cache = cache; - } - - /** - * {@inheritDoc} - */ - public boolean isFilesystemOnly() { - if (isReference()) { - return ((MappedResourceCollection) getCheckedRef()) - .isFilesystemOnly(); - } - checkInitialized(); - return false; - } - - /** - * {@inheritDoc} - */ - public int size() { - if (isReference()) { - return ((MappedResourceCollection) getCheckedRef()).size(); - } - checkInitialized(); - return cacheCollection().size(); - } - - /** - * {@inheritDoc} - */ - public Iterator<Resource> iterator() { - if (isReference()) { - return ((MappedResourceCollection) getCheckedRef()).iterator(); - } - checkInitialized(); - return cacheCollection().iterator(); - } - - /** - * Overrides the base version. - * @param r the Reference to set. - */ - public void setRefid(Reference r) { - if (nested != null || mapper != null) { - throw tooManyAttributes(); - } - super.setRefid(r); - } - - /** - * Implement clone. The nested resource collection and mapper are copied. - * @return a cloned instance. - */ - public Object clone() { - try { - MappedResourceCollection c = - (MappedResourceCollection) super.clone(); - c.nested = nested; - c.mapper = mapper; - c.cachedColl = null; - return c; - } catch (CloneNotSupportedException e) { - throw new BuildException(e); - } - } - - /** - * Overrides the version of DataType to recurse on all DataType - * child elements that may have been added. - * @param stk the stack of data types to use (recursively). - * @param p the project to use to dereference the references. - * @throws BuildException on error. - */ - protected synchronized void dieOnCircularReference(Stack<Object> stk, Project p) - throws BuildException { - if (isChecked()) { - return; - } - if (isReference()) { - super.dieOnCircularReference(stk, p); - } else { - checkInitialized(); - if (mapper != null) { - pushAndInvokeCircularReferenceCheck(mapper, stk, p); - } - if (nested instanceof DataType) { - pushAndInvokeCircularReferenceCheck((DataType) nested, stk, p); - } - setChecked(true); - } - } - - private void checkInitialized() { - if (nested == null) { - throw new BuildException("A nested resource collection element is" - + " required", getLocation()); - } - dieOnCircularReference(); - } - - private synchronized Collection<Resource> cacheCollection() { - if (cachedColl == null || !cache) { - cachedColl = getCollection(); - } - return cachedColl; - } - - private Collection<Resource> getCollection() { - Collection<Resource> collected = new ArrayList<Resource>(); - FileNameMapper m = - mapper != null ? mapper.getImplementation() : new IdentityMapper(); - for (Resource r : nested) { - if (enableMultipleMappings) { - String[] n = m.mapFileName(r.getName()); - if (n != null) { - for (int i = 0; i < n.length; i++) { - collected.add(new MappedResource(r, - new MergingMapper(n[i])) - ); - } - } - } else { - collected.add(new MappedResource(r, m)); - } - } - return collected; - } - - /** - * Format this resource collection as a String. - * @return a descriptive <code>String</code>. - */ - public String toString() { - if (isReference()) { - return getCheckedRef().toString(); - } - Iterator<Resource> 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(); - } - -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/MultiRootFileSet.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/MultiRootFileSet.java deleted file mode 100644 index d7938908..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/MultiRootFileSet.java +++ /dev/null @@ -1,237 +0,0 @@ -/* - * 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.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.DirectoryScanner; -import org.apache.tools.ant.types.AbstractFileSet; -import org.apache.tools.ant.types.Reference; -import org.apache.tools.ant.types.Resource; -import org.apache.tools.ant.types.ResourceCollection; - -/** - * Union of file/dirsets that share the same patterns and selectors - * but have different roots. - * @since Ant 1.9.4 - */ -public class MultiRootFileSet extends AbstractFileSet - implements ResourceCollection { - - private SetType type = SetType.file; - private boolean cache = true; - private List<File> baseDirs = new ArrayList<File>(); - private Union union; - - @Override - public void setDir(final File dir) { - throw new BuildException(getDataTypeName() - + " doesn't support the dir attribute"); - } - - /** - * Determines the types of resources to return. - * @param type the types of resources to return - */ - public void setType(final SetType type) { - if (isReference()) { - throw tooManyAttributes(); - } - this.type = type; - } - - /** - * Set whether to cache collections. - * @param b boolean cache flag. - */ - public synchronized void setCache(final boolean b) { - if (isReference()) { - throw tooManyAttributes(); - } - cache = b; - } - - /** - * Adds basedirs as a comma separated list. - * @param dirs directories as CSV - */ - public void setBaseDirs(final String dirs) { - if (isReference()) { - throw tooManyAttributes(); - } - if (dirs != null && dirs.length() > 0) { - final String[] ds = dirs.split(","); - for (final String d : ds) { - baseDirs.add(getProject().resolveFile(d)); - } - } - } - - /** - * Adds a basedir as nested element. - * @param r basedir - */ - public void addConfiguredBaseDir(final FileResource r) { - if (isReference()) { - throw noChildrenAllowed(); - } - baseDirs.add(r.getFile()); - } - - @Override - public void setRefid(final Reference r) { - if (!baseDirs.isEmpty()) { - throw tooManyAttributes(); - } - super.setRefid(r); - } - - /** - * Return a MultiRootFileSet that has the same basedirs and same patternsets - * as this one. - * @return the cloned MultiRootFileSet. - */ - @Override - public Object clone() { - if (isReference()) { - return ((MultiRootFileSet) getRef(getProject())).clone(); - } else { - final MultiRootFileSet fs = (MultiRootFileSet) super.clone(); - fs.baseDirs = new ArrayList<File>(baseDirs); - fs.union = null; - return fs; - } - } - - /** - * Fulfill the ResourceCollection contract. - * @return an Iterator of Resources. - */ - public Iterator<Resource> iterator() { - if (isReference()) { - return ((MultiRootFileSet) getRef(getProject())).iterator(); - } - return merge().iterator(); - } - - /** - * Fulfill the ResourceCollection contract. - * @return number of elements as int. - */ - public int size() { - if (isReference()) { - return ((MultiRootFileSet) getRef(getProject())).size(); - } - return merge().size(); - } - - /** - * Always returns true. - * @return true indicating that all elements will be FileResources. - */ - public boolean isFilesystemOnly() { - return true; - } - - /** - * Returns included directories as a list of semicolon-separated paths. - * - * @return a <code>String</code> of included directories. - */ - @Override - public String toString() { - if (isReference()) { - return ((MultiRootFileSet) getRef(getProject())).toString(); - } - return merge().toString(); - } - - private synchronized Union merge() { - if (cache && union != null) { - return union; - } - final Union u = new Union(); - setup(u); - if (cache) { - union = u; - } - return u; - } - - private void setup(final Union u) { - for (final File d : baseDirs) { - u.add(new Worker(this, type, d)); - } - } - - /** - * What to return from the set: files, directories or both. - */ - public static enum SetType { - file, dir, both - } - - private static class Worker extends AbstractFileSet - implements ResourceCollection { - - private final SetType type; - - private Worker(final MultiRootFileSet fs, final SetType type, final File dir) { - super(fs); - this.type = type; - setDir(dir); - } - - public boolean isFilesystemOnly() { - return true; - } - - public Iterator<Resource> iterator() { - final DirectoryScanner ds = getDirectoryScanner(getProject()); - String[] names = type == SetType.file - ? ds.getIncludedFiles() - : ds.getIncludedDirectories(); - if (type == SetType.both) { - final String[] files = ds.getIncludedFiles(); - final String[] merged = new String[names.length + files.length]; - System.arraycopy(names, 0, merged, 0, names.length); - System.arraycopy(files, 0, merged, names.length, files.length); - names = merged; - } - return new FileResourceIterator(getProject(), getDir(getProject()), - names); - } - - public int size() { - final DirectoryScanner ds = getDirectoryScanner(getProject()); - int count = type == SetType.file - ? ds.getIncludedFilesCount() - : ds.getIncludedDirsCount(); - if (type == SetType.both) { - count += ds.getIncludedFilesCount(); - } - return count; - } - } - -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/PropertyResource.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/PropertyResource.java deleted file mode 100644 index a7cecb4b..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/PropertyResource.java +++ /dev/null @@ -1,206 +0,0 @@ -/* - * 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.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; - -import org.apache.tools.ant.Project; -import org.apache.tools.ant.PropertyHelper; -import org.apache.tools.ant.types.Resource; -import org.apache.tools.ant.util.PropertyOutputStream; - -/** - * Exposes an Ant property as a Resource. - * @since Ant 1.7 - */ -public class PropertyResource extends Resource { - - /** Magic number */ - private static final int PROPERTY_MAGIC - = Resource.getMagicNumber("PropertyResource".getBytes()); - - private static final InputStream UNSET = new InputStream() { - public int read() { - return -1; - } - }; - - /** - * Default constructor. - */ - public PropertyResource() { - } - - /** - * Construct a new PropertyResource with the specified name. - * @param p the project to use. - * @param n the String name of this PropertyResource (Ant property name/key). - */ - public PropertyResource(Project p, String n) { - super(n); - setProject(p); - } - - /** - * Get the value of this PropertyResource. - * @return the value of the specified Property. - */ - public String getValue() { - if (isReference()) { - return ((PropertyResource) getCheckedRef()).getValue(); - } - Project p = getProject(); - return p == null ? null : p.getProperty(getName()); - } - - /** - * Get the Object value of this PropertyResource. - * @return the Object value of the specified Property. - * @since Ant 1.8.1 - */ - public Object getObjectValue() { - if (isReference()) { - return ((PropertyResource) getCheckedRef()).getObjectValue(); - } - Project p = getProject(); - return p == null ? null : PropertyHelper.getProperty(p, getName()); - } - - /** - * Find out whether this Resource exists. - * @return true if the Property is set, false otherwise. - */ - public boolean isExists() { - if (isReferenceOrProxy()) { - return getReferencedOrProxied().isExists(); - } - return getObjectValue() != null; - } - - /** - * Get the size of this Resource. - * @return the size, as a long, 0 if the Resource does not exist (for - * compatibility with java.io.File), or UNKNOWN_SIZE if not known. - */ - public long getSize() { - if (isReferenceOrProxy()) { - return getReferencedOrProxied().getSize(); - } - Object o = getObjectValue(); - return o == null ? 0L : (long) String.valueOf(o).length(); - } - - /** - * Override to implement equality with equivalent Resources, - * since we are capable of proxying them. - * @param o object to compare - * @return true if equal to o - */ - public boolean equals(Object o) { - if (super.equals(o)) { - return true; - } - return isReferenceOrProxy() && getReferencedOrProxied().equals(o); - } - - /** - * Get the hash code for this Resource. - * @return hash code as int. - */ - public int hashCode() { - if (isReferenceOrProxy()) { - return getReferencedOrProxied().hashCode(); - } - return super.hashCode() * PROPERTY_MAGIC; - } - - /** - * {@inheritDoc} - */ - public String toString() { - if (isReferenceOrProxy()) { - return getReferencedOrProxied().toString(); - } - return getValue(); - } - - /** - * Get an InputStream for the Resource. - * @return an InputStream containing this Resource's content. - * @throws IOException if unable to provide the content of this - * Resource as a stream. - * @throws UnsupportedOperationException if InputStreams are not - * supported for this Resource type. - */ - public InputStream getInputStream() throws IOException { - if (isReferenceOrProxy()) { - return getReferencedOrProxied().getInputStream(); - } - Object o = getObjectValue(); - return o == null ? UNSET : new ByteArrayInputStream(String.valueOf(o).getBytes()); - } - - /** - * Get an OutputStream for the Resource. - * @return an OutputStream to which content can be written. - * @throws IOException if unable to provide the content of this - * Resource as a stream. - * @throws UnsupportedOperationException if OutputStreams are not - * supported for this Resource type. - */ - public OutputStream getOutputStream() throws IOException { - if (isReferenceOrProxy()) { - return getReferencedOrProxied().getOutputStream(); - } - if (isExists()) { - throw new ImmutableResourceException(); - } - return new PropertyOutputStream(getProject(), getName()); - } - - /** - * Learn whether this PropertyResource either refers to another Resource - * or proxies another Resource due to its object property value being said Resource. - * @return boolean - */ - protected boolean isReferenceOrProxy() { - return isReference() || getObjectValue() instanceof Resource; - } - - /** - * Get the referenced or proxied Resource, if applicable. - * @return Resource - * @throws IllegalStateException if this PropertyResource neither proxies nor - * references another Resource. - */ - protected Resource getReferencedOrProxied() { - if (isReference()) { - return (Resource) getCheckedRef(Resource.class, "resource"); - } - Object o = getObjectValue(); - if (o instanceof Resource) { - return (Resource) o; - } - throw new IllegalStateException( - "This PropertyResource does not reference or proxy another Resource"); - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/ResourceDecorator.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/ResourceDecorator.java deleted file mode 100644 index 3806cf2c..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/ResourceDecorator.java +++ /dev/null @@ -1,270 +0,0 @@ -/* - * 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.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.util.Stack; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.types.Reference; -import org.apache.tools.ant.types.Resource; -import org.apache.tools.ant.types.ResourceCollection; - -/** - * Abstract class that delegates all reading methods of Resource to - * its wrapped resource and deals with reference handling. - * - * <p>Overwrites all setters to throw exceptions.</p> - * - * @since Ant 1.8.0 - */ -public abstract class ResourceDecorator extends Resource { - - private Resource resource; - - /** no arg constructor */ - protected ResourceDecorator() { - } - - /** - * Constructor with another resource to wrap. - * @param other the resource to wrap. - */ - protected ResourceDecorator(ResourceCollection other) { - addConfigured(other); - } - - /** - * Sets the resource to wrap using a single-element collection. - * @param a the resource to wrap as a single element Resource collection. - */ - public final void addConfigured(ResourceCollection a) { - checkChildrenAllowed(); - if (resource != null) { - throw new BuildException("you must not specify more than one" - + " resource"); - } - if (a.size() != 1) { - throw new BuildException("only single argument resource collections" - + " are supported"); - } - setChecked(false); - resource = a.iterator().next(); - } - - /** - * Get the name of the resource. - * @return the name of the wrapped resource. - */ - public String getName() { - return getResource().getName(); - } - - /** - * The exists attribute tells whether a file exists. - * @return true if this resource exists. - */ - public boolean isExists() { - return getResource().isExists(); - } - - /** - * Tells the modification time in milliseconds since 01.01.1970 . - * - * @return 0 if the resource does not exist to mirror the behavior - * of {@link java.io.File File}. - */ - public long getLastModified() { - return getResource().getLastModified(); - } - - /** - * Tells if the resource is a directory. - * @return boolean flag indicating if the resource is a directory. - */ - public boolean isDirectory() { - return getResource().isDirectory(); - } - - /** - * Get the size of this Resource. - * @return the size, as a long, 0 if the Resource does not exist (for - * compatibility with java.io.File), or UNKNOWN_SIZE if not known. - */ - public long getSize() { - return getResource().getSize(); - } - - /** - * Get an InputStream for the Resource. - * @return an InputStream containing this Resource's content. - * @throws IOException if unable to provide the content of this - * Resource as a stream. - * @throws UnsupportedOperationException if InputStreams are not - * supported for this Resource type. - */ - public InputStream getInputStream() throws IOException { - return getResource().getInputStream(); - } - - /** - * Get an OutputStream for the Resource. - * @return an OutputStream to which content can be written. - * @throws IOException if unable to provide the content of this - * Resource as a stream. - * @throws UnsupportedOperationException if OutputStreams are not - * supported for this Resource type. - */ - public OutputStream getOutputStream() throws IOException { - return getResource().getOutputStream(); - } - - /** - * Fulfill the ResourceCollection contract. - * @return whether this Resource is a FileProvider. - */ - public boolean isFilesystemOnly() { - return as(FileProvider.class) != null; - } - - /** - * Overrides the base version. - * @param r the Reference to set. - */ - public void setRefid(Reference r) { - if (resource != null) { - throw noChildrenAllowed(); - } - super.setRefid(r); - } - - /** - * {@inheritDoc} - */ - public <T> T as(Class<T> clazz) { - return getResource().as(clazz); - } - - /** - * {@inheritDoc} - */ - public int compareTo(Resource other) { - if (other == this) { - return 0; - } - if (other instanceof ResourceDecorator) { - return getResource().compareTo( - ((ResourceDecorator) other).getResource()); - } - return getResource().compareTo(other); - } - - /** - * Get the hash code for this Resource. - * @return hash code as int. - */ - public int hashCode() { - return (getClass().hashCode() << 4) | getResource().hashCode(); - } - - /** - * De-references refids if any, ensures a wrapped resource has - * been specified. - */ - protected final Resource getResource() { - if (isReference()) { - return (Resource) getCheckedRef(); - } - if (resource == null) { - throw new BuildException("no resource specified"); - } - dieOnCircularReference(); - return resource; - } - - /** - * {@inheritDoc} - */ - protected void dieOnCircularReference(final Stack<Object> stack, - final Project project) - throws BuildException { - if (isChecked()) { - return; - } - if (isReference()) { - super.dieOnCircularReference(stack, project); - } else { - pushAndInvokeCircularReferenceCheck(resource, stack, project); - setChecked(true); - } - } - - // disable modification - - /** - * Overridden, not allowed to set the name of the resource. - * @param name not used. - * @throws BuildException always. - */ - public void setName(String name) throws BuildException { - throw new BuildException("you can't change the name of a " - + getDataTypeName()); - } - - /** - * Set the exists attribute. - * @param exists if true, this resource exists. - */ - public void setExists(boolean exists) { - throw new BuildException("you can't change the exists state of a " - + getDataTypeName()); - } - - /** - * Override setLastModified. - * @param lastmodified not used. - * @throws BuildException always. - */ - public void setLastModified(long lastmodified) throws BuildException { - throw new BuildException("you can't change the timestamp of a " - + getDataTypeName()); - } - - /** - * Override setDirectory. - * @param directory not used. - * @throws BuildException always. - */ - public void setDirectory(boolean directory) throws BuildException { - throw new BuildException("you can't change the directory state of a " - + getDataTypeName()); - } - - /** - * Override setSize. - * @param size not used. - * @throws BuildException always. - */ - public void setSize(long size) throws BuildException { - throw new BuildException("you can't change the size of a " - + getDataTypeName()); - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/ResourceList.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/ResourceList.java deleted file mode 100644 index 8b77e1bb..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/ResourceList.java +++ /dev/null @@ -1,239 +0,0 @@ -/* - * 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.BufferedInputStream; -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.Reader; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.Stack; -import java.util.Vector; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.PropertyHelper; -import org.apache.tools.ant.filters.util.ChainReaderHelper; -import org.apache.tools.ant.types.DataType; -import org.apache.tools.ant.types.FilterChain; -import org.apache.tools.ant.types.Reference; -import org.apache.tools.ant.types.Resource; -import org.apache.tools.ant.types.ResourceCollection; -import org.apache.tools.ant.util.FileUtils; - -/** - * Reads a resource as text document and creates a resource for each - * line. - * @since Ant 1.8.0 - */ -public class ResourceList extends DataType implements ResourceCollection { - private final Vector<FilterChain> filterChains = new Vector<FilterChain>(); - private final ArrayList<ResourceCollection> textDocuments = new ArrayList<ResourceCollection>(); - private final Union cachedResources = new Union(); - private volatile boolean cached = false; - private String encoding = null; - - public ResourceList() { - cachedResources.setCache(true); - } - - /** - * Adds a source. - */ - public void add(ResourceCollection rc) { - if (isReference()) { - throw noChildrenAllowed(); - } - textDocuments.add(rc); - setChecked(false); - } - - /** - * Adds a FilterChain. - */ - public final void addFilterChain(FilterChain filter) { - if (isReference()) { - throw noChildrenAllowed(); - } - filterChains.add(filter); - setChecked(false); - } - - /** - * Encoding to use for input, defaults to the platform's default - * encoding. <p> - * - * For a list of possible values see - * <a href="http://java.sun.com/j2se/1.5.0/docs/guide/intl/encoding.doc.html"> - * http://java.sun.com/j2se/1.5.0/docs/guide/intl/encoding.doc.html - * </a>.</p> - */ - public final void setEncoding(String encoding) { - if (isReference()) { - throw tooManyAttributes(); - } - this.encoding = encoding; - } - - /** - * Makes this instance in effect a reference to another ResourceList - * instance. - */ - public void setRefid(Reference r) throws BuildException { - if (encoding != null) { - throw tooManyAttributes(); - } - if (filterChains.size() > 0 || textDocuments.size() > 0) { - throw noChildrenAllowed(); - } - super.setRefid(r); - } - - /** - * Fulfill the ResourceCollection contract. The Iterator returned - * will throw ConcurrentModificationExceptions if ResourceCollections - * are added to this container while the Iterator is in use. - * @return a "fail-fast" Iterator. - */ - public final synchronized Iterator<Resource> iterator() { - if (isReference()) { - return ((ResourceList) getCheckedRef()).iterator(); - } - return cache().iterator(); - } - - /** - * Fulfill the ResourceCollection contract. - * @return number of elements as int. - */ - public synchronized int size() { - if (isReference()) { - return ((ResourceList) getCheckedRef()).size(); - } - return cache().size(); - } - - /** - * Fulfill the ResourceCollection contract. - * @return whether this is a filesystem-only resource collection. - */ - public synchronized boolean isFilesystemOnly() { - if (isReference()) { - return ((ResourceList) getCheckedRef()).isFilesystemOnly(); - } - return cache().isFilesystemOnly(); - } - - /** - * Overrides the version of DataType to recurse on all DataType - * child elements that may have been added. - * @param stk the stack of data types to use (recursively). - * @param p the project to use to dereference the references. - * @throws BuildException on error. - */ - protected synchronized void dieOnCircularReference(Stack<Object> stk, Project p) - throws BuildException { - if (isChecked()) { - return; - } - if (isReference()) { - super.dieOnCircularReference(stk, p); - } else { - for (ResourceCollection resourceCollection : textDocuments) { - if (resourceCollection instanceof DataType) { - pushAndInvokeCircularReferenceCheck((DataType) resourceCollection, stk, p); - } - } - for (FilterChain filterChain : filterChains) { - pushAndInvokeCircularReferenceCheck(filterChain, stk, p); - } - setChecked(true); - } - } - - private synchronized ResourceCollection cache() { - if (!cached) { - dieOnCircularReference(); - for (ResourceCollection rc : textDocuments) { - for (Resource r : rc) { - cachedResources.add(read(r)); - } - } - cached = true; - } - return cachedResources; - } - - private ResourceCollection read(Resource r) { - BufferedInputStream bis = null; - try { - bis = new BufferedInputStream(r.getInputStream()); - Reader input = null; - if (encoding == null) { - input = new InputStreamReader(bis); - } else { - input = new InputStreamReader(bis, encoding); - } - ChainReaderHelper crh = new ChainReaderHelper(); - crh.setPrimaryReader(input); - crh.setFilterChains(filterChains); - crh.setProject(getProject()); - BufferedReader reader = new BufferedReader(crh.getAssembledReader()); - - Union streamResources = new Union(); - streamResources.setCache(true); - - String line = null; - while ((line = reader.readLine()) != null) { - streamResources.add(parse(line)); - } - - return streamResources; - } catch (final IOException ioe) { - throw new BuildException("Unable to read resource " + r.getName() - + ": " + ioe, ioe, getLocation()); - } finally { - FileUtils.close(bis); - } - } - - private Resource parse(final String line) { - PropertyHelper propertyHelper - = (PropertyHelper) PropertyHelper.getPropertyHelper(getProject()); - Object expanded = propertyHelper.parseProperties(line); - if (expanded instanceof Resource) { - return (Resource) expanded; - } - String expandedLine = expanded.toString(); - int colon = expandedLine.indexOf(":"); - if (colon != -1) { - // could be an URL or an absolute file on an OS with drives - try { - return new URLResource(expandedLine); - } catch (BuildException mfe) { - // a translated MalformedURLException - - // probably it's an absolute path fall back to file - // resource - } - } - return new FileResource(getProject(), expandedLine); - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/Resources.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/Resources.java deleted file mode 100644 index 1dd888d4..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/Resources.java +++ /dev/null @@ -1,274 +0,0 @@ -/* - * 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.AbstractCollection; -import java.util.Collection; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; -import java.util.NoSuchElementException; -import java.util.Stack; -import java.util.Vector; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.types.DataType; -import org.apache.tools.ant.types.Resource; -import org.apache.tools.ant.types.ResourceCollection; -import org.apache.tools.ant.util.CollectionUtils; - -/** - * Generic ResourceCollection: Either stores nested ResourceCollections, - * making no attempt to remove duplicates, or references another ResourceCollection. - * @since Ant 1.7 - */ -public class Resources extends DataType implements ResourceCollection { - /** static empty ResourceCollection */ - public static final ResourceCollection NONE = new ResourceCollection() { - public boolean isFilesystemOnly() { - return true; - } - public Iterator<Resource> iterator() { - return EMPTY_ITERATOR; - } - public int size() { - return 0; - } - }; - - /** static empty Iterator */ - public static final Iterator<Resource> EMPTY_ITERATOR = new Iterator<Resource>() { - public Resource next() { - throw new NoSuchElementException(); - } - public boolean hasNext() { - return false; - } - public void remove() { - throw new UnsupportedOperationException(); - } - }; - - private class MyCollection extends AbstractCollection<Resource> { - private Collection<Resource> cached; - - MyCollection() { - } - public int size() { - return getCache().size(); - } - public Iterator<Resource> iterator() { - return getCache().iterator(); - } - private synchronized Collection<Resource> getCache() { - Collection<Resource> coll = cached; - if (coll == null) { - coll = CollectionUtils.asCollection(new MyIterator()); - if (cache) { - cached = coll; - } - } - return coll; - } - private class MyIterator implements Iterator<Resource> { - private Iterator<ResourceCollection> rci = getNested().iterator(); - private Iterator<Resource> ri = null; - - public boolean hasNext() { - boolean result = ri != null && ri.hasNext(); - while (!result && rci.hasNext()) { - ri = ((ResourceCollection) rci.next()).iterator(); - result = ri.hasNext(); - } - return result; - } - public Resource next() { - if (!hasNext()) { - throw new NoSuchElementException(); - } - return ri.next(); - } - public void remove() { - throw new UnsupportedOperationException(); - } - } - } - - private Vector<ResourceCollection> rc; - private Collection<Resource> coll; - private boolean cache = false; - - /** - * Create a new Resources. - */ - public Resources() { - } - - /** - * Create a new Resources. - * @since Ant 1.8 - */ - public Resources(Project project) { - setProject(project); - } - - /** - * Set whether to cache collections. - * @param b boolean cache flag. - * @since Ant 1.8.0 - */ - public synchronized void setCache(boolean b) { - cache = b; - } - - /** - * Add a ResourceCollection. - * @param c the ResourceCollection to add. - */ - public synchronized void add(ResourceCollection c) { - if (isReference()) { - throw noChildrenAllowed(); - } - if (c == null) { - return; - } - if (rc == null) { - rc = new Vector<ResourceCollection>(); - } - rc.add(c); - invalidateExistingIterators(); - coll = null; - setChecked(false); - } - - /** - * Fulfill the ResourceCollection contract. - * @return an Iterator of Resources. - */ - public synchronized Iterator<Resource> iterator() { - if (isReference()) { - return getRef().iterator(); - } - validate(); - return new FailFast(this, coll.iterator()); - } - - /** - * Fulfill the ResourceCollection contract. - * @return number of elements as int. - */ - public synchronized int size() { - if (isReference()) { - return getRef().size(); - } - validate(); - return coll.size(); - } - - /** - * Fulfill the ResourceCollection contract. - * @return true if all Resources represent files. - */ - public boolean isFilesystemOnly() { - if (isReference()) { - return getRef().isFilesystemOnly(); - } - validate(); - - for (Iterator<ResourceCollection> i = getNested().iterator(); i.hasNext();) { - if (!i.next().isFilesystemOnly()) { - return false; - } - } - return true; - } - - /** - * Format this <code>Resources</code> as a String. - * @return a descriptive <code>String</code>. - */ - public synchronized String toString() { - if (isReference()) { - return getCheckedRef().toString(); - } - validate(); - if (coll == null || coll.isEmpty()) { - return ""; - } - StringBuffer sb = new StringBuffer(); - for (Resource r : coll) { - if (sb.length() > 0) { - sb.append(File.pathSeparatorChar); - } - sb.append(r); - } - return sb.toString(); - } - - /** - * Overrides the version of DataType to recurse on all DataType - * child elements that may have been added. - * @param stk the stack of data types to use (recursively). - * @param p the project to use to dereference the references. - * @throws BuildException on error. - */ - protected void dieOnCircularReference(Stack<Object> stk, Project p) - throws BuildException { - if (isChecked()) { - return; - } - if (isReference()) { - super.dieOnCircularReference(stk, p); - } else { - for (ResourceCollection resourceCollection : getNested()) { - if (resourceCollection instanceof DataType) { - pushAndInvokeCircularReferenceCheck((DataType) resourceCollection, stk, p); - } - } - setChecked(true); - } - } - - /** - * Allow subclasses to notify existing Iterators they have experienced concurrent modification. - */ - protected void invalidateExistingIterators() { - FailFast.invalidate(this); - } - - /** - * Resolves references, allowing any ResourceCollection. - * @return the referenced ResourceCollection. - */ - private ResourceCollection getRef() { - return (ResourceCollection) getCheckedRef( - ResourceCollection.class, "ResourceCollection"); - } - - private synchronized void validate() { - dieOnCircularReference(); - coll = (coll == null) ? new MyCollection() : coll; - } - - private synchronized List<ResourceCollection> getNested() { - return rc == null ? Collections.<ResourceCollection> emptyList() : rc; - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/Restrict.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/Restrict.java deleted file mode 100644 index 2ea1a861..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/Restrict.java +++ /dev/null @@ -1,156 +0,0 @@ -/* - * 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.util.Iterator; -import java.util.Stack; - -import org.apache.tools.ant.Project; -import org.apache.tools.ant.types.Resource; -import org.apache.tools.ant.types.ResourceCollection; -import org.apache.tools.ant.types.resources.selectors.ResourceSelector; -import org.apache.tools.ant.types.resources.selectors.ResourceSelectorContainer; - -/** - * ResourceCollection that allows a number of selectors to be - * applied to a single ResourceCollection for the purposes of - * restricting or narrowing results. - * @since Ant 1.7 - */ -public class Restrict - extends ResourceSelectorContainer implements ResourceCollection { - - private LazyResourceCollectionWrapper w = new LazyResourceCollectionWrapper() { - /** - * Restrict the nested ResourceCollection based on the nested selectors. - */ - protected boolean filterResource(Resource r) { - for (Iterator<ResourceSelector> i = getSelectors(); i.hasNext();) { - if (!i.next().isSelected(r)) { - return true; - } - } - return false; - } - }; - - /** - * Add the ResourceCollection. - * @param c the ResourceCollection to add. - */ - public synchronized void add(ResourceCollection c) { - if (isReference()) { - throw noChildrenAllowed(); - } - if (c == null) { - return; - } - w.add(c); - setChecked(false); - } - - /** - * Set whether to cache collections. - * @param b boolean cache flag. - */ - public synchronized void setCache(boolean b) { - w.setCache(b); - } - - /** - * Learn whether to cache collections. Default is <code>true</code>. - * @return boolean cache flag. - */ - public synchronized boolean isCache() { - return w.isCache(); - } - - /** - * Add a ResourceSelector. - * @param s the ResourceSelector to add. - */ - public synchronized void add(ResourceSelector s) { - if (s == null) { - return; - } - super.add(s); - FailFast.invalidate(this); - } - - /** - * Fulfill the ResourceCollection contract. - * @return an Iterator of Resources. - */ - public final synchronized Iterator<Resource> iterator() { - if (isReference()) { - return ((Restrict) getCheckedRef()).iterator(); - } - dieOnCircularReference(); - return w.iterator(); - } - - /** - * Fulfill the ResourceCollection contract. - * @return number of elements as int. - */ - public synchronized int size() { - if (isReference()) { - return ((Restrict) getCheckedRef()).size(); - } - dieOnCircularReference(); - return w.size(); - } - - /** - * Fulfill the ResourceCollection contract. - * @return whether this is a filesystem-only resource collection. - */ - public synchronized boolean isFilesystemOnly() { - if (isReference()) { - return ((Restrict) getCheckedRef()).isFilesystemOnly(); - } - dieOnCircularReference(); - return w.isFilesystemOnly(); - } - - /** - * Format this Restrict collection as a String. - * @return the String value of this collection. - */ - public synchronized String toString() { - if (isReference()) { - return getCheckedRef().toString(); - } - dieOnCircularReference(); - return w.toString(); - } - - protected synchronized void dieOnCircularReference(Stack<Object> stk, Project p) { - if (isChecked()) { - return; - } - - // takes care of Selectors - super.dieOnCircularReference(stk, p); - - if (!isReference()) { - pushAndInvokeCircularReferenceCheck(w, stk, p); - setChecked(true); - } - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/SizeLimitCollection.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/SizeLimitCollection.java deleted file mode 100644 index c8e772be..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/SizeLimitCollection.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * 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 org.apache.tools.ant.BuildException; - -/** - * ResourceCollection that imposes a size limit on another ResourceCollection. - * @since Ant 1.7.1 - */ -public abstract class SizeLimitCollection extends BaseResourceCollectionWrapper { - private static final String BAD_COUNT - = "size-limited collection count should be set to an int >= 0"; - - private int count = 1; - - /** - * Set the number of resources to be included. - * @param i the count as <code>int</count>. - */ - public synchronized void setCount(int i) { - checkAttributesAllowed(); - count = i; - } - - /** - * Get the number of resources to be included. Default is 1. - * @return the count as <code>int</count>. - */ - public synchronized int getCount() { - return count; - } - - /** - * Efficient size implementation. - * @return int size - */ - public synchronized int size() { - int sz = getResourceCollection().size(); - int ct = getValidCount(); - return sz < ct ? sz : ct; - } - - /** - * Get the count, verifying it is >= 0. - * @return int count - */ - protected int getValidCount() { - int ct = getCount(); - if (ct < 0) { - throw new BuildException(BAD_COUNT); - } - return ct; - } - -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/Sort.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/Sort.java deleted file mode 100644 index b4dc88c2..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/Sort.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * 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.util.Collection; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; -import java.util.Stack; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.types.DataType; -import org.apache.tools.ant.types.Resource; -import org.apache.tools.ant.types.ResourceCollection; -import org.apache.tools.ant.types.resources.comparators.DelegatedResourceComparator; -import org.apache.tools.ant.types.resources.comparators.ResourceComparator; -import org.apache.tools.ant.util.CollectionUtils; - -/** - * ResourceCollection that sorts another ResourceCollection. - * - * Note that Sort must not be used in cases where the ordering of the objects - * being sorted might change during the sorting process. - * - * @since Ant 1.7 - */ -public class Sort extends BaseResourceCollectionWrapper { - - private DelegatedResourceComparator comp = new DelegatedResourceComparator(); - - /** - * Sort the contained elements. - * @return a Collection of Resources. - */ - protected synchronized Collection<Resource> getCollection() { - ResourceCollection rc = getResourceCollection(); - Iterator<Resource> iter = rc.iterator(); - if (!(iter.hasNext())) { - return Collections.emptySet(); - } - List<Resource> result = (List<Resource>) CollectionUtils.asCollection(iter); - Collections.sort(result, comp); - return result; - } - - /** - * Add a ResourceComparator to this Sort ResourceCollection. - * If multiple ResourceComparators are added, they will be processed in LIFO order. - * @param c the ResourceComparator to add. - */ - public synchronized void add(ResourceComparator c) { - if (isReference()) { - throw noChildrenAllowed(); - } - comp.add(c); - FailFast.invalidate(this); - setChecked(false); - } - - /** - * Overrides the BaseResourceCollectionContainer version - * to recurse on nested ResourceComparators. - * @param stk the stack of data types to use (recursively). - * @param p the project to use to dereference the references. - * @throws BuildException on error. - */ - protected synchronized void dieOnCircularReference(Stack<Object> stk, Project p) - throws BuildException { - if (isChecked()) { - return; - } - - // check nested collection - super.dieOnCircularReference(stk, p); - - if (!isReference()) { - DataType.pushAndInvokeCircularReferenceCheck(comp, stk, p); - setChecked(true); - } - } - -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/StringResource.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/StringResource.java deleted file mode 100644 index b12a2e14..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/StringResource.java +++ /dev/null @@ -1,261 +0,0 @@ -/* - * 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.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.FilterOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.types.Reference; -import org.apache.tools.ant.types.Resource; - -/** - * Exposes a string as a Resource. - * @since Ant 1.7 - */ -public class StringResource extends Resource { - - /** Magic number */ - private static final int STRING_MAGIC - = Resource.getMagicNumber("StringResource".getBytes()); - - private static final String DEFAULT_ENCODING = "UTF-8"; - private String encoding = DEFAULT_ENCODING; - - /** - * Default constructor. - */ - public StringResource() { - } - - /** - * Construct a StringResource with the supplied value. - * @param value the value of this StringResource. - */ - public StringResource(String value) { - this(null, value); - } - - /** - * Construct a StringResource with the supplied project and value, - * doing property replacement against the project if non-null. - * @param project the owning Project. - * @param value the value of this StringResource. - */ - public StringResource(Project project, String value) { - setProject(project); - setValue(project == null ? value : project.replaceProperties(value)); - } - - /** - * Enforce String immutability. - * @param s the new name/value for this StringResource. - */ - public synchronized void setName(String s) { - if (getName() != null) { - throw new BuildException(new ImmutableResourceException()); - } - super.setName(s); - } - - /** - * The value attribute is a semantically superior alias for the name attribute. - * @param s the String's value. - */ - public synchronized void setValue(String s) { - setName(s); - } - - /** - * Synchronize access. - * @return the name/value of this StringResource. - */ - public synchronized String getName() { - return super.getName(); - } - - /** - * Get the value of this StringResource, resolving to the root reference if needed. - * @return the represented String. - */ - public synchronized String getValue() { - return getName(); - } - - /** - * The exists attribute tells whether a resource exists. - * - * @return true if this resource exists. - */ - public boolean isExists() { - return getValue() != null; - } - - /** - * Add nested text to this resource. - * Properties will be expanded during this process. - * @since Ant 1.7.1 - * @param text text to use as the string resource - */ - public void addText(String text) { - checkChildrenAllowed(); - setValue(getProject().replaceProperties(text)); - } - - /** - * Set the encoding to be used for this StringResource. - * @param s the encoding name. - */ - public synchronized void setEncoding(String s) { - checkAttributesAllowed(); - encoding = s; - } - - /** - * Get the encoding used by this StringResource. - * @return the encoding name. - */ - public synchronized String getEncoding() { - return encoding; - } - - /** - * Get the size of this Resource. - * @return the size, as a long, 0 if the Resource does not exist (for - * compatibility with java.io.File), or UNKNOWN_SIZE if not known. - */ - public synchronized long getSize() { - return isReference() ? ((Resource) getCheckedRef()).getSize() - : getContent().length(); - } - - /** - * Get the hash code for this Resource. - * @return hash code as int. - */ - public synchronized int hashCode() { - if (isReference()) { - return getCheckedRef().hashCode(); - } - return super.hashCode() * STRING_MAGIC; - } - - /** - * Get the string. See {@link #getContent()} - * - * @return the string contents of the resource. - * @since Ant 1.7 - */ - public String toString() { - return String.valueOf(getContent()); - } - - /** - * Get an InputStream for the Resource. - * @return an InputStream containing this Resource's content. - * @throws IOException if unable to provide the content of this - * Resource as a stream. - * @throws UnsupportedOperationException if InputStreams are not - * supported for this Resource type. - */ - public synchronized InputStream getInputStream() throws IOException { - if (isReference()) { - return ((Resource) getCheckedRef()).getInputStream(); - } - String content = getContent(); - if (content == null) { - throw new IllegalStateException("unset string value"); - } - return new ByteArrayInputStream(encoding == null - ? content.getBytes() : content.getBytes(encoding)); - } - - /** - * Get an OutputStream for the Resource. - * @return an OutputStream to which content can be written. - * @throws IOException if unable to provide the content of this - * Resource as a stream. - * @throws UnsupportedOperationException if OutputStreams are not - * supported for this Resource type. - */ - public synchronized OutputStream getOutputStream() throws IOException { - if (isReference()) { - return ((Resource) getCheckedRef()).getOutputStream(); - } - if (getValue() != null) { - throw new ImmutableResourceException(); - } - return new StringResourceFilterOutputStream(); - } - - /** - * Overrides the super version. - * @param r the Reference to set. - */ - public void setRefid(Reference r) { - if (encoding != DEFAULT_ENCODING) { - throw tooManyAttributes(); - } - super.setRefid(r); - } - - /** - * Get the content of this StringResource. See {@link #getValue()} - * @return a String or null if there is no value. - */ - protected synchronized String getContent() { - return getValue(); - } - - /** - * This method is only for use by our private helper output stream. - * It contains specific logic for expanding properties. - * @param output the output - */ - private void setValueFromOutputStream(String output) { - String value; - if (getProject() != null) { - value = getProject().replaceProperties(output); - } else { - value = output; - } - setValue(value); - } - - private class StringResourceFilterOutputStream extends FilterOutputStream { - private final ByteArrayOutputStream baos; - - public StringResourceFilterOutputStream() { - super(new ByteArrayOutputStream()); - baos = (ByteArrayOutputStream) out; - } - - public void close() throws IOException { - super.close(); - String result = encoding == null - ? baos.toString() : baos.toString(encoding); - - StringResource.this.setValueFromOutputStream(result); - } - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/TarResource.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/TarResource.java deleted file mode 100644 index 62f1f267..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/TarResource.java +++ /dev/null @@ -1,198 +0,0 @@ -/* - * 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.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.types.Resource; -import org.apache.tools.ant.util.FileUtils; -import org.apache.tools.tar.TarEntry; -import org.apache.tools.tar.TarInputStream; - -/** - * A Resource representation of an entry in a tar archive. - * @since Ant 1.7 - */ -public class TarResource extends ArchiveResource { - - private String userName = ""; - private String groupName = ""; - private int uid; - private int gid; - - /** - * Default constructor. - */ - public TarResource() { - } - - /** - * Construct a TarResource representing the specified - * entry in the specified archive. - * @param a the archive as File. - * @param e the TarEntry. - */ - public TarResource(File a, TarEntry e) { - super(a, true); - setEntry(e); - } - - /** - * Construct a TarResource representing the specified - * entry in the specified archive. - * @param a the archive as Resource. - * @param e the TarEntry. - */ - public TarResource(Resource a, TarEntry e) { - super(a, true); - setEntry(e); - } - - /** - * Return an InputStream for reading the contents of this Resource. - * @return an InputStream object. - * @throws IOException if the tar file cannot be opened, - * or the entry cannot be read. - */ - public InputStream getInputStream() throws IOException { - if (isReference()) { - return ((Resource) getCheckedRef()).getInputStream(); - } - Resource archive = getArchive(); - final TarInputStream i = new TarInputStream(archive.getInputStream()); - TarEntry te = null; - while ((te = i.getNextEntry()) != null) { - if (te.getName().equals(getName())) { - return i; - } - } - - FileUtils.close(i); - throw new BuildException("no entry " + getName() + " in " - + getArchive()); - } - - /** - * Get an OutputStream for the Resource. - * @return an OutputStream to which content can be written. - * @throws IOException if unable to provide the content of this - * Resource as a stream. - * @throws UnsupportedOperationException if OutputStreams are not - * supported for this Resource type. - */ - public OutputStream getOutputStream() throws IOException { - if (isReference()) { - return ((Resource) getCheckedRef()).getOutputStream(); - } - throw new UnsupportedOperationException( - "Use the tar task for tar output."); - } - - /** - * @return the user name for the tar entry - */ - public String getUserName() { - if (isReference()) { - return ((TarResource) getCheckedRef()).getUserName(); - } - checkEntry(); - return userName; - } - - /** - * @return the group name for the tar entry - */ - public String getGroup() { - if (isReference()) { - return ((TarResource) getCheckedRef()).getGroup(); - } - checkEntry(); - return groupName; - } - - /** - * @return the uid for the tar entry - */ - public int getUid() { - if (isReference()) { - return ((TarResource) getCheckedRef()).getUid(); - } - checkEntry(); - return uid; - } - - /** - * @return the gid for the tar entry - */ - public int getGid() { - if (isReference()) { - return ((TarResource) getCheckedRef()).getGid(); - } - checkEntry(); - return gid; - } - - /** - * fetches information from the named entry inside the archive. - */ - protected void fetchEntry() { - Resource archive = getArchive(); - TarInputStream i = null; - try { - i = new TarInputStream(archive.getInputStream()); - TarEntry te = null; - while ((te = i.getNextEntry()) != null) { - if (te.getName().equals(getName())) { - setEntry(te); - return; - } - } - } catch (IOException e) { - log(e.getMessage(), Project.MSG_DEBUG); - throw new BuildException(e); - } finally { - if (i != null) { - FileUtils.close(i); - } - } - setEntry(null); - } - - private void setEntry(TarEntry e) { - if (e == null) { - setExists(false); - return; - } - setName(e.getName()); - setExists(true); - setLastModified(e.getModTime().getTime()); - setDirectory(e.isDirectory()); - setSize(e.getSize()); - setMode(e.getMode()); - userName = e.getUserName(); - groupName = e.getGroupName(); - uid = e.getUserId(); - gid = e.getGroupId(); - } - -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/Tokens.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/Tokens.java deleted file mode 100644 index 0a518c3d..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/Tokens.java +++ /dev/null @@ -1,137 +0,0 @@ -/* - * 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.IOException; -import java.io.InputStreamReader; -import java.io.UnsupportedEncodingException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Stack; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.types.DataType; -import org.apache.tools.ant.types.Resource; -import org.apache.tools.ant.types.ResourceCollection; -import org.apache.tools.ant.util.ConcatResourceInputStream; -import org.apache.tools.ant.util.FileUtils; -import org.apache.tools.ant.util.LineTokenizer; -import org.apache.tools.ant.util.Tokenizer; - -/** - * ResourceCollection consisting of StringResources gathered from tokenizing - * another ResourceCollection with a Tokenizer implementation. - * @since Ant 1.7 - */ -public class Tokens extends BaseResourceCollectionWrapper { - - private Tokenizer tokenizer; - private String encoding; - - /** - * Sort the contained elements. - * @return a Collection of Resources. - */ - protected synchronized Collection<Resource> getCollection() { - ResourceCollection rc = getResourceCollection(); - if (rc.size() == 0) { - return Collections.emptySet(); - } - if (tokenizer == null) { - tokenizer = new LineTokenizer(); - } - ConcatResourceInputStream cat = new ConcatResourceInputStream(rc); - cat.setManagingComponent(this); - - try { - InputStreamReader rdr = null; - if (encoding == null) { - rdr = new InputStreamReader(cat); - } else { - try { - rdr = new InputStreamReader(cat, encoding); - } catch (UnsupportedEncodingException e) { - throw new BuildException(e); - } - } - ArrayList<Resource> result = new ArrayList<Resource>(); - for (String s = tokenizer.getToken(rdr); s != null; s = tokenizer.getToken(rdr)) { - StringResource resource = new StringResource(s); - resource.setProject(getProject()); - result.add(resource); - } - return result; - } catch (IOException e) { - throw new BuildException("Error reading tokens", e); - } finally { - FileUtils.close(cat); - } - } - - /** - * Set the encoding used to create the tokens. - * @param encoding the encoding to use. - */ - public synchronized void setEncoding(String encoding) { - this.encoding = encoding; - } - - /** - * Add the nested Tokenizer to this Tokens ResourceCollection. - * A LineTokenizer will be used by default. - * @param tokenizer the tokenizer to add. - */ - public synchronized void add(Tokenizer tokenizer) { - if (isReference()) { - throw noChildrenAllowed(); - } - if (this.tokenizer != null) { - throw new BuildException("Only one nested tokenizer allowed."); - } - this.tokenizer = tokenizer; - setChecked(false); - } - - /** - * Overrides the BaseResourceCollectionContainer version - * to check the nested Tokenizer. - * @param stk the stack of data types to use (recursively). - * @param p the project to use to dereference the references. - * @throws BuildException on error. - */ - protected synchronized void dieOnCircularReference(Stack<Object> stk, Project p) - throws BuildException { - if (isChecked()) { - return; - } - - // check nested collection - super.dieOnCircularReference(stk, p); - - if (!isReference()) { - if (tokenizer instanceof DataType) { - pushAndInvokeCircularReferenceCheck((DataType) tokenizer, stk, - p); - } - setChecked(true); - } - } - -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/Touchable.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/Touchable.java deleted file mode 100644 index 3a54a693..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/Touchable.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * 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; - -/** - * Interface to be implemented by "touchable" resources; - * that is, those whose modification time can be altered. - * @since Ant 1.7 - */ -public interface Touchable { - /** - * Method called to "touch" the resource. - * @param modTime the time to set the modified "field" of the resource, - * measured in milliseconds since the epoch. - */ - void touch(long modTime); -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/URLProvider.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/URLProvider.java deleted file mode 100644 index 81bb6697..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/URLProvider.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * 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.net.URL; - -/** - * This is an interface that resources that can provide an URL should implement. - * This is a refactoring of {@link URLResource}, to allow other resources - * to act as sources of URLs. - * @since Ant 1.8 - */ -public interface URLProvider { - /** - * Get the URL represented by this Resource. - * @return the file. - */ - URL getURL(); -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/URLResource.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/URLResource.java deleted file mode 100644 index 70d6c9ba..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/URLResource.java +++ /dev/null @@ -1,454 +0,0 @@ -/* - * 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.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.net.HttpURLConnection; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLConnection; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.types.Reference; -import org.apache.tools.ant.types.Resource; -import org.apache.tools.ant.util.FileUtils; - -/** - * Exposes a URL as a Resource. - * @since Ant 1.7 - */ -public class URLResource extends Resource implements URLProvider { - private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); - private static final int NULL_URL - = Resource.getMagicNumber("null URL".getBytes()); - - private URL url; - private URLConnection conn; - private URL baseURL; - private String relPath; - - /** - * Default constructor. - */ - public URLResource() { - } - - /** - * Convenience constructor. - * @param u the URL to expose. - */ - public URLResource(URL u) { - setURL(u); - } - - /** - * Convenience constructor. - * @param u holds the URL to expose. - */ - public URLResource(URLProvider u) { - setURL(u.getURL()); - } - - /** - * Convenience constructor. - * @param f the File to set as a URL. - */ - public URLResource(File f) { - setFile(f); - } - - /** - * String constructor for Ant attribute introspection. - * @param u String representation of this URL. - * @see org.apache.tools.ant.IntrospectionHelper - */ - public URLResource(String u) { - this(newURL(u)); - } - - /** - * Set the URL for this URLResource. - * @param u the URL to expose. - */ - public synchronized void setURL(URL u) { - checkAttributesAllowed(); - url = u; - } - - /** - * Set the URL from a File. - * @param f the File to set as a URL. - */ - public synchronized void setFile(File f) { - try { - setURL(FILE_UTILS.getFileURL(f)); - } catch (MalformedURLException e) { - throw new BuildException(e); - } - } - - /** - * Base URL which combined with the relativePath attribute defines - * the URL. - * @since Ant 1.8.0 - */ - public synchronized void setBaseURL(URL base) { - checkAttributesAllowed(); - if (url != null) { - throw new BuildException("can't define URL and baseURL attribute"); - } - baseURL = base; - } - - /** - * Relative path which combined with the baseURL attribute defines - * the URL. - * @since Ant 1.8.0 - */ - public synchronized void setRelativePath(String r) { - checkAttributesAllowed(); - if (url != null) { - throw new BuildException("can't define URL and relativePath" - + " attribute"); - } - relPath = r; - } - - - /** - * Get the URL used by this URLResource. - * @return a URL object. - */ - public synchronized URL getURL() { - if (isReference()) { - return ((URLResource) getCheckedRef()).getURL(); - } - if (url == null) { - if (baseURL != null) { - if (relPath == null) { - throw new BuildException("must provide relativePath" - + " attribute when using baseURL."); - } - try { - url = new URL(baseURL, relPath); - } catch (MalformedURLException e) { - throw new BuildException(e); - } - } - } - return url; - } - - /** - * Overrides the super version. - * @param r the Reference to set. - */ - public synchronized void setRefid(Reference r) { - //not using the accessor in this case to avoid side effects - if (url != null || baseURL != null || relPath != null) { - throw tooManyAttributes(); - } - super.setRefid(r); - } - - /** - * Get the name of this URLResource - * (its file component minus the leading separator). - * @return the name of this resource. - */ - public synchronized String getName() { - if (isReference()) { - return ((Resource) getCheckedRef()).getName(); - } - String name = getURL().getFile(); - return "".equals(name) ? name : name.substring(1); - } - - /** - * Return this URLResource formatted as a String. - * @return a String representation of this URLResource. - */ - public synchronized String toString() { - return isReference() - ? getCheckedRef().toString() : String.valueOf(getURL()); - } - - /** - * Find out whether the URL exists . - * @return true if this resource exists. - */ - public synchronized boolean isExists() { - if (isReference()) { - return ((Resource) getCheckedRef()).isExists(); - } - return isExists(false); - } - - /** - * Find out whether the URL exists, and close the connection - * opened to the URL if closeConnection is true. - * - * Note that this method does ensure that if: - * - the resource exists (if it returns true) - * - and if the current object is not a reference - * (isReference() returns false) - * - and if it was called with closeConnection to false, - * - * then the connection to the URL (stored in the conn - * private field) will be opened, and require to be closed - * by the caller. - * - * @param closeConnection true if the connection should be closed - * after the call, false if it should stay open. - * @return true if this resource exists. - */ - private synchronized boolean isExists(boolean closeConnection) { - if (getURL() == null) { - return false; - } - try { - connect(Project.MSG_VERBOSE); - if (conn instanceof HttpURLConnection) { - int sc = ((HttpURLConnection) conn).getResponseCode(); - // treating inaccessible resources as non-existent - return sc < 400; - } else if (url.getProtocol().startsWith("ftp")) { - closeConnection = true; - InputStream in = null; - try { - in = conn.getInputStream(); - } finally { - FileUtils.close(in); - } - } - return true; - } catch (IOException e) { - return false; - } finally { - if (closeConnection) { - close(); - } - } - } - - - /** - * Tells the modification time in milliseconds since 01.01.1970 . - * - * @return 0 if the resource does not exist to mirror the behavior - * of {@link java.io.File File}. - */ - public synchronized long getLastModified() { - if (isReference()) { - return ((Resource) getCheckedRef()).getLastModified(); - } - if (!isExists(false)) { - return UNKNOWN_DATETIME; - } - return withConnection(new ConnectionUser() { - public long useConnection(URLConnection c) { - return conn.getLastModified(); - } - }, UNKNOWN_DATETIME); - } - - /** - * Tells if the resource is a directory. - * @return boolean whether the resource is a directory. - */ - public synchronized boolean isDirectory() { - return isReference() - ? ((Resource) getCheckedRef()).isDirectory() - : getName().endsWith("/"); - } - - /** - * Get the size of this Resource. - * @return the size, as a long, 0 if the Resource does not exist (for - * compatibility with java.io.File), or UNKNOWN_SIZE if not known. - */ - public synchronized long getSize() { - if (isReference()) { - return ((Resource) getCheckedRef()).getSize(); - } - if (!isExists(false)) { - return 0L; - } - return withConnection(new ConnectionUser() { - public long useConnection(URLConnection c) { - return conn.getContentLength(); - } - }, UNKNOWN_SIZE); - } - - /** - * Test whether an Object equals this URLResource. - * @param another the other Object to compare. - * @return true if the specified Object is equal to this Resource. - */ - public synchronized boolean equals(Object another) { - if (this == another) { - return true; - } - if (isReference()) { - return getCheckedRef().equals(another); - } - if (another == null || !(another.getClass().equals(getClass()))) { - return false; - } - URLResource otheru = (URLResource) another; - return getURL() == null - ? otheru.getURL() == null - : getURL().equals(otheru.getURL()); - } - - /** - * Get the hash code for this Resource. - * @return hash code as int. - */ - public synchronized int hashCode() { - if (isReference()) { - return getCheckedRef().hashCode(); - } - return MAGIC * ((getURL() == null) ? NULL_URL : getURL().hashCode()); - } - - /** - * Get an InputStream for the Resource. - * @return an InputStream containing this Resource's content. - * @throws IOException if unable to provide the content of this - * Resource as a stream. - * @throws UnsupportedOperationException if InputStreams are not - * supported for this Resource type. - */ - public synchronized InputStream getInputStream() throws IOException { - if (isReference()) { - return ((Resource) getCheckedRef()).getInputStream(); - } - connect(); - try { - return conn.getInputStream(); - } finally { - conn = null; - } - } - - /** - * Get an OutputStream for the Resource. - * @return an OutputStream to which content can be written. - * @throws IOException if unable to provide the content of this - * Resource as a stream. - * @throws UnsupportedOperationException if OutputStreams are not - * supported for this Resource type. - * @throws IOException if the URL cannot be opened. - */ - public synchronized OutputStream getOutputStream() throws IOException { - if (isReference()) { - return ((Resource) getCheckedRef()).getOutputStream(); - } - connect(); - try { - return conn.getOutputStream(); - } finally { - conn = null; - } - } - - /** - * Ensure that we have a connection. - * @throws IOException if the connection cannot be established. - */ - protected void connect() throws IOException { - connect(Project.MSG_ERR); - } - - /** - * Ensure that we have a connection. - * @param logLevel severity to use when logging connection errors. - * Should be one of the <code>MSG_</code> constants in {@link - * Project Project}. - * @throws IOException if the connection cannot be established. - * @since Ant 1.8.2 - */ - protected synchronized void connect(int logLevel) throws IOException { - URL u = getURL(); - if (u == null) { - throw new BuildException("URL not set"); - } - if (conn == null) { - try { - conn = u.openConnection(); - conn.connect(); - } catch (IOException e) { - log(e.toString(), logLevel); - conn = null; - throw e; - } - } - } - - /** - * Closes the URL connection if: - * - it is opened (i.e. the field conn is not null) - * - this type of URLConnection supports some sort of close mechanism - * - * This method ensures the field conn will be null after the call. - * - */ - private synchronized void close() { - try { - FileUtils.close(conn); - } finally { - conn = null; - } - } - - private static URL newURL(String u) { - try { - return new URL(u); - } catch (MalformedURLException e) { - throw new BuildException(e); - } - } - - private interface ConnectionUser { - long useConnection(URLConnection c); - } - - private long withConnection(ConnectionUser u, long defaultValue) { - try { - if (conn != null) { - return u.useConnection(conn); - } else { - try { - connect(); - return u.useConnection(conn); - } finally { - close(); - } - } - } catch (IOException ex) { - return defaultValue; - } - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/Union.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/Union.java deleted file mode 100644 index e2f2f9f2..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/Union.java +++ /dev/null @@ -1,156 +0,0 @@ -/* - * 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.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Set; - -import org.apache.tools.ant.Project; -import org.apache.tools.ant.types.Resource; -import org.apache.tools.ant.types.ResourceCollection; - -/** - * ResourceCollection representing the union of multiple nested ResourceCollections. - * @since Ant 1.7 - */ -public class Union extends BaseResourceCollectionContainer { - - /** - * Static convenience method to union an arbitrary set of Resources. - * @param rc a ResourceCollection. - * @return a Union. - */ - public static Union getInstance(ResourceCollection rc) { - return rc instanceof Union ? (Union) rc : new Union(rc); - } - - /** - * Default constructor. - */ - public Union() { - } - - /** - * Create a new Union. - * @param project owning Project - */ - public Union(Project project) { - super(project); - } - - /** - * Convenience constructor. - * @param rc the ResourceCollection to add. - */ - public Union(ResourceCollection rc) { - this(Project.getProject(rc), rc); - } - - /** - * Convenience constructor. - * @param project owning Project - * @param rc the ResourceCollection to add. - */ - public Union(Project project, ResourceCollection rc) { - super(project); - add(rc); - } - - /** - * Returns all Resources in String format. Provided for - * convenience in implementing Path. - * @return String array of Resources. - */ - public String[] list() { - if (isReference()) { - return getCheckedRef(Union.class, getDataTypeName()).list(); - } - final Collection<String> result = getAllToStrings(); - return result.toArray(new String[result.size()]); - } - - /** - * Convenience method. - * @return Resource[] - */ - public Resource[] listResources() { - if (isReference()) { - return getCheckedRef(Union.class, getDataTypeName()).listResources(); - } - final Collection<Resource> result = getAllResources(); - return result.toArray(new Resource[result.size()]); - } - - /** - * Unify the contained Resources. - * @return a Collection of Resources. - */ - protected Collection<Resource> getCollection() { - return getAllResources(); - } - - /** - * Unify the contained Resources. - * @param asString indicates whether the resulting Collection - * should contain Strings instead of Resources. - * @return a Collection of Resources. - */ - @Deprecated - @SuppressWarnings("unchecked") - protected <T> Collection<T> getCollection(boolean asString) { // TODO untypable - return asString ? (Collection<T>) getAllToStrings() : (Collection<T>) getAllResources(); - } - - /** - * Get a collection of strings representing the unified resource set (strings may duplicate). - * @return Collection<String> - */ - protected Collection<String> getAllToStrings() { - final Set<Resource> allResources = getAllResources(); - final ArrayList<String> result = new ArrayList<String>(allResources.size()); - for (Resource r : allResources) { - result.add(r.toString()); - } - return result; - } - - /** - * Get the unified set of contained Resources. - * @return Set<Resource> - */ - protected Set<Resource> getAllResources() { - final List<ResourceCollection> resourceCollections = getResourceCollections(); - if (resourceCollections.isEmpty()) { - return Collections.emptySet(); - } - final LinkedHashSet<Resource> result = new LinkedHashSet<Resource>( - resourceCollections.size() * 2); - for (ResourceCollection resourceCollection : resourceCollections) { - for (Resource r : resourceCollection) { - result.add(r); - } - } - return result; - } - -} - diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/ZipResource.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/ZipResource.java deleted file mode 100644 index 37fc98ec..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/ZipResource.java +++ /dev/null @@ -1,226 +0,0 @@ -/* - * 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.io.FilterInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.types.Reference; -import org.apache.tools.ant.types.Resource; -import org.apache.tools.ant.types.ResourceCollection; -import org.apache.tools.ant.util.FileUtils; -import org.apache.tools.zip.ZipEntry; -import org.apache.tools.zip.ZipExtraField; -import org.apache.tools.zip.ZipFile; - -/** - * A Resource representation of an entry in a zipfile. - * @since Ant 1.7 - */ -public class ZipResource extends ArchiveResource { - - private String encoding; - private ZipExtraField[] extras; - private int method; - - /** - * Default constructor. - */ - public ZipResource() { - } - - /** - * Construct a ZipResource representing the specified - * entry in the specified zipfile. - * @param z the zipfile as File. - * @param enc the encoding used for filenames. - * @param e the ZipEntry. - */ - public ZipResource(File z, String enc, ZipEntry e) { - super(z, true); - setEncoding(enc); - setEntry(e); - } - - /** - * Set the zipfile that holds this ZipResource. - * @param z the zipfile as a File. - */ - public void setZipfile(File z) { - setArchive(z); - } - - /** - * Get the zipfile that holds this ZipResource. - * @return the zipfile as a File. - */ - public File getZipfile() { - FileProvider fp = getArchive().as(FileProvider.class); - return fp.getFile(); - } - - /** - * Sets the archive that holds this as a single element Resource - * collection. - * @param a the archive as a single element Resource collection. - */ - public void addConfigured(ResourceCollection a) { - super.addConfigured(a); - if (!a.isFilesystemOnly()) { - throw new BuildException("only filesystem resources are supported"); - } - } - - /** - * Set the encoding to use with the zipfile. - * @param enc the String encoding. - */ - public void setEncoding(String enc) { - checkAttributesAllowed(); - encoding = enc; - } - - /** - * Get the encoding to use with the zipfile. - * @return String encoding. - */ - public String getEncoding() { - return isReference() - ? ((ZipResource) getCheckedRef()).getEncoding() : encoding; - } - - /** - * Overrides the super version. - * @param r the Reference to set. - */ - public void setRefid(Reference r) { - if (encoding != null) { - throw tooManyAttributes(); - } - super.setRefid(r); - } - - /** - * Return an InputStream for reading the contents of this Resource. - * @return an InputStream object. - * @throws IOException if the zip file cannot be opened, - * or the entry cannot be read. - */ - public InputStream getInputStream() throws IOException { - if (isReference()) { - return ((Resource) getCheckedRef()).getInputStream(); - } - final ZipFile z = new ZipFile(getZipfile(), getEncoding()); - ZipEntry ze = z.getEntry(getName()); - if (ze == null) { - z.close(); - throw new BuildException("no entry " + getName() + " in " - + getArchive()); - } - return new FilterInputStream(z.getInputStream(ze)) { - public void close() throws IOException { - FileUtils.close(in); - z.close(); - } - protected void finalize() throws Throwable { - try { - close(); - } finally { - super.finalize(); - } - } - }; - } - - /** - * Get an OutputStream for the Resource. - * @return an OutputStream to which content can be written. - * @throws IOException if unable to provide the content of this - * Resource as a stream. - * @throws UnsupportedOperationException if OutputStreams are not - * supported for this Resource type. - */ - public OutputStream getOutputStream() throws IOException { - if (isReference()) { - return ((Resource) getCheckedRef()).getOutputStream(); - } - throw new UnsupportedOperationException( - "Use the zip task for zip output."); - } - - /** - * Retrieves extra fields. - * @return an array of the extra fields - * @since Ant 1.8.0 - */ - public ZipExtraField[] getExtraFields() { - if (isReference()) { - return ((ZipResource) getCheckedRef()).getExtraFields(); - } - checkEntry(); - if (extras == null) { - return new ZipExtraField[0]; - } - return extras; - } - - /** - * The compression method that has been used. - * @since Ant 1.8.0 - */ - public int getMethod() { - return method; - } - - /** - * fetches information from the named entry inside the archive. - */ - protected void fetchEntry() { - ZipFile z = null; - try { - z = new ZipFile(getZipfile(), getEncoding()); - setEntry(z.getEntry(getName())); - } catch (IOException e) { - log(e.getMessage(), Project.MSG_DEBUG); - throw new BuildException(e); - } finally { - ZipFile.closeQuietly(z); - } - } - - private void setEntry(ZipEntry e) { - if (e == null) { - setExists(false); - return; - } - setName(e.getName()); - setExists(true); - setLastModified(e.getTime()); - setDirectory(e.isDirectory()); - setSize(e.getSize()); - setMode(e.getUnixMode()); - extras = e.getExtraFields(true); - method = e.getMethod(); - } - -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/comparators/Content.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/comparators/Content.java deleted file mode 100644 index 1810b640..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/comparators/Content.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * 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.comparators; - -import java.io.IOException; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.types.Resource; -import org.apache.tools.ant.util.ResourceUtils; - -/** - * Compares Resources by content. - * @since Ant 1.7 - */ -public class Content extends ResourceComparator { - - private boolean binary = true; - - /** - * Set binary mode for this Content ResourceComparator. If this - * attribute is set to false, Resource content will be compared - * ignoring platform line-ending conventions. - * Default is <code>true</code>. - * @param b whether to compare content in binary mode. - */ - public void setBinary(boolean b) { - binary = b; - } - - /** - * Learn whether this Content ResourceComparator is operating in binary mode. - * @return boolean binary flag. - */ - public boolean isBinary() { - return binary; - } - - /** - * Compare two Resources by content. - * @param foo the first Resource. - * @param bar the second Resource. - * @return a negative integer, zero, or a positive integer as the first - * argument is less than, equal to, or greater than the second. - * @throws BuildException if I/O errors occur. - * @see org.apache.tools.ant.util.ResourceUtils#compareContent(Resource, Resource, boolean). - */ - protected int resourceCompare(Resource foo, Resource bar) { - try { - return ResourceUtils.compareContent(foo, bar, !binary); - } catch (IOException e) { - throw new BuildException(e); - } - } - -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/comparators/Date.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/comparators/Date.java deleted file mode 100644 index b6be66bb..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/comparators/Date.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * 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.comparators; - -import org.apache.tools.ant.types.Resource; - -/** - * Compares Resources by last modification date. - * @since Ant 1.7 - */ -public class Date extends ResourceComparator { - /** - * Compare two Resources. - * @param foo the first Resource. - * @param bar the second Resource. - * @return a negative integer, zero, or a positive integer as the first - * argument is less than, equal to, or greater than the second. - */ - protected int resourceCompare(Resource foo, Resource bar) { - long diff = foo.getLastModified() - bar.getLastModified(); - if (diff > 0) { - return +1; - } else if (diff < 0) { - return -1; - } else { - return 0; - } - } - -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/comparators/DelegatedResourceComparator.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/comparators/DelegatedResourceComparator.java deleted file mode 100644 index aa2f55a8..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/comparators/DelegatedResourceComparator.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * 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.comparators; - -import java.util.Iterator; -import java.util.List; -import java.util.Stack; -import java.util.Vector; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.types.DataType; -import org.apache.tools.ant.types.Resource; - -/** - * Delegates to other ResourceComparators or, if none specified, - * uses Resources' natural ordering. - * @since Ant 1.7 - */ -public class DelegatedResourceComparator extends ResourceComparator { - - private List<ResourceComparator> resourceComparators = null; - - /** - * Add a delegate ResourceComparator. - * @param c the next delegate ResourceComparator. - */ - public synchronized void add(ResourceComparator c) { - if (isReference()) { - throw noChildrenAllowed(); - } - if (c == null) { - return; - } - resourceComparators = (resourceComparators == null) ? new Vector<ResourceComparator>() : resourceComparators; - resourceComparators.add(c); - setChecked(false); - } - - /** - * Equality method based on the vector of resources, - * or if a reference, the referredto object. - * @param o the object to check against. - * @return true if there is equality. - */ - public synchronized boolean equals(Object o) { - if (o == this) { - return true; - } - if (isReference()) { - return getCheckedRef().equals(o); - } - if (!(o instanceof DelegatedResourceComparator)) { - return false; - } - List<ResourceComparator> ov = ((DelegatedResourceComparator) o).resourceComparators; - return resourceComparators == null ? ov == null : resourceComparators.equals(ov); - } - - /** - * Hashcode based on the rules for equality. - * @return a hashcode. - */ - public synchronized int hashCode() { - if (isReference()) { - return getCheckedRef().hashCode(); - } - return resourceComparators == null ? 0 : resourceComparators.hashCode(); - } - - /** {@inheritDoc} */ - protected synchronized int resourceCompare(Resource foo, Resource bar) { - //if no nested, natural order: - if (resourceComparators == null || resourceComparators.isEmpty()) { - return foo.compareTo(bar); - } - int result = 0; - for (Iterator<ResourceComparator> i = resourceComparators.iterator(); result == 0 && i.hasNext();) { - result = i.next().resourceCompare(foo, bar); - } - return result; - } - - /** - * Overrides the version from DataType to recurse on nested ResourceSelector -s. - * @param stk the Stack of references. - * @param p the Project to resolve against. - * @throws BuildException on error. - */ - protected void dieOnCircularReference(Stack<Object> stk, Project p) - throws BuildException { - if (isChecked()) { - return; - } - if (isReference()) { - super.dieOnCircularReference(stk, p); - } else { - if (!(resourceComparators == null || resourceComparators.isEmpty())) { - for (ResourceComparator resourceComparator : resourceComparators) { - if (resourceComparator instanceof DataType) { - pushAndInvokeCircularReferenceCheck((DataType) resourceComparator, stk, - p); - } - } - } - setChecked(true); - } - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/comparators/Exists.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/comparators/Exists.java deleted file mode 100644 index 58321502..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/comparators/Exists.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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.comparators; - -import org.apache.tools.ant.types.Resource; - -/** - * Compares Resources by existence. Not existing is "less than" existing. - * @since Ant 1.7 - */ -public class Exists extends ResourceComparator { - - /** - * Compare two Resources. - * @param foo the first Resource. - * @param bar the second Resource. - * @return a negative integer, zero, or a positive integer as the first - * argument is less than, equal to, or greater than the second. - */ - protected int resourceCompare(Resource foo, Resource bar) { - boolean f = foo.isExists(); - if (f == bar.isExists()) { - return 0; - } - return f ? 1 : -1; - } - -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/comparators/FileSystem.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/comparators/FileSystem.java deleted file mode 100644 index 7eafeb94..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/comparators/FileSystem.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * 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.comparators; - -import java.io.File; - -import org.apache.tools.ant.types.Resource; -import org.apache.tools.ant.types.resources.FileProvider; -import org.apache.tools.ant.util.FileUtils; - -/** - * Compares filesystem Resources. - * @since Ant 1.7 - */ -public class FileSystem extends ResourceComparator { - private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); - - /** - * Compare two Resources. - * @param foo the first Resource. - * @param bar the second Resource. - * @return a negative integer, zero, or a positive integer as the first - * argument is less than, equal to, or greater than the second. - * @throws ClassCastException if either resource is not an instance of FileResource. - */ - protected int resourceCompare(Resource foo, Resource bar) { - FileProvider fooFP = foo.as(FileProvider.class); - if (fooFP == null) { - throw new ClassCastException(foo.getClass() - + " doesn't provide files"); - } - File foofile = fooFP.getFile(); - FileProvider barFP = bar.as(FileProvider.class); - if (barFP == null) { - throw new ClassCastException(bar.getClass() - + " doesn't provide files"); - } - File barfile = barFP.getFile(); - return foofile.equals(barfile) ? 0 - : FILE_UTILS.isLeadingPath(foofile, barfile) ? -1 - : FILE_UTILS.normalize(foofile.getAbsolutePath()).compareTo( - FILE_UTILS.normalize(barfile.getAbsolutePath())); - } - -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/comparators/Name.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/comparators/Name.java deleted file mode 100644 index d048ac01..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/comparators/Name.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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.comparators; - -import org.apache.tools.ant.types.Resource; - -/** - * Compares Resources by name. - * @since Ant 1.7 - */ -public class Name extends ResourceComparator { - /** - * Compare two Resources. - * @param foo the first Resource. - * @param bar the second Resource. - * @return a negative integer, zero, or a positive integer as the first - * argument is less than, equal to, or greater than the second. - */ - protected int resourceCompare(Resource foo, Resource bar) { - return foo.getName().compareTo(bar.getName()); - } - -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/comparators/ResourceComparator.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/comparators/ResourceComparator.java deleted file mode 100644 index 3bfc9c70..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/comparators/ResourceComparator.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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.comparators; - -import java.util.Comparator; - -import org.apache.tools.ant.types.DataType; -import org.apache.tools.ant.types.Resource; - -/** - * Abstract Resource Comparator. - * @since Ant 1.7 - */ -public abstract class ResourceComparator extends DataType implements Comparator<Resource> { - - /** - * Compare two objects. - * @param foo the first Object. - * @param bar the second Object. - * @return a negative integer, zero, or a positive integer as the first - * argument is less than, equal to, or greater than the second. - * @throws ClassCastException if either argument is null. - */ - public final int compare(Resource foo, Resource bar) { - dieOnCircularReference(); - ResourceComparator c = - isReference() ? (ResourceComparator) getCheckedRef() : this; - return c.resourceCompare(foo, bar); - } - - /** - * Test for equality with this ResourceComparator. - * @param o the Object to compare against. - * @return true if the specified Object equals this one. - */ - public boolean equals(Object o) { - if (isReference()) { - return getCheckedRef().equals(o); - } - if (o == null) { - return false; - } - return o == this || o.getClass().equals(getClass()); - } - - /** - * Hashcode based on the rules for equality. - * @return a hashcode. - */ - public synchronized int hashCode() { - if (isReference()) { - return getCheckedRef().hashCode(); - } - return getClass().hashCode(); - } - - /** - * Compare two Resources. - * @param foo the first Resource. - * @param bar the second Resource. - * @return a negative integer, zero, or a positive integer as the first - * argument is less than, equal to, or greater than the second. - */ - protected abstract int resourceCompare(Resource foo, Resource bar); - -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/comparators/Reverse.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/comparators/Reverse.java deleted file mode 100644 index c787a765..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/comparators/Reverse.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * 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.comparators; - -import java.util.Stack; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.types.DataType; -import org.apache.tools.ant.types.Resource; - -/** - * Reverses another ResourceComparator. If no nested ResourceComparator - * is supplied, the compared Resources' natural order will be reversed. - * @since Ant 1.7 - */ -public class Reverse extends ResourceComparator { - private static final String ONE_NESTED - = "You must not nest more than one ResourceComparator for reversal."; - - private ResourceComparator nested; - - /** - * Default constructor. - */ - public Reverse() { - } - - /** - * Construct a new Reverse, supplying the ResourceComparator to be reversed. - * @param c the ResourceComparator to reverse. - */ - public Reverse(ResourceComparator c) { - add(c); - } - - /** - * Add the ResourceComparator to reverse. - * @param c the ResourceComparator to add. - */ - public void add(ResourceComparator c) { - if (nested != null) { - throw new BuildException(ONE_NESTED); - } - nested = c; - setChecked(false); - } - - /** - * Compare two Resources. - * @param foo the first Resource. - * @param bar the second Resource. - * @return a negative integer, zero, or a positive integer as the first - * argument is greater than, equal to, or less than the second. - */ - protected int resourceCompare(Resource foo, Resource bar) { - return -1 * (nested == null - ? foo.compareTo(bar) : nested.compare(foo, bar)); - } - - protected void dieOnCircularReference(Stack<Object> stk, Project p) - throws BuildException { - if (isChecked()) { - return; - } - if (isReference()) { - super.dieOnCircularReference(stk, p); - } else { - if (nested instanceof DataType) { - pushAndInvokeCircularReferenceCheck((DataType) nested, stk, - p); - } - setChecked(true); - } - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/comparators/Size.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/comparators/Size.java deleted file mode 100644 index b94f250b..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/comparators/Size.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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.comparators; - -import org.apache.tools.ant.types.Resource; - -/** - * Compares Resources by size. - * @since Ant 1.7 - */ -public class Size extends ResourceComparator { - /** - * Compare two Resources. - * @param foo the first Resource. - * @param bar the second Resource. - * @return a negative integer, zero, or a positive integer as the first - * argument is less than, equal to, or greater than the second. - */ - protected int resourceCompare(Resource foo, Resource bar) { - long diff = foo.getSize() - bar.getSize(); - return diff > 0 ? 1 : (diff == 0 ? 0 : -1); - } - -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/comparators/Type.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/comparators/Type.java deleted file mode 100644 index 6c082ef6..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/comparators/Type.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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.comparators; - -import org.apache.tools.ant.types.Resource; - -/** - * Compares Resources by is-directory status. As a container - * of files, a directory is deemed "greater" than a file. - * @since Ant 1.7 - */ -public class Type extends ResourceComparator { - - /** - * Compare two Resources. - * @param foo the first Resource. - * @param bar the second Resource. - * @return a negative integer, zero, or a positive integer as the first - * argument is less than, equal to, or greater than the second. - */ - protected int resourceCompare(Resource foo, Resource bar) { - boolean f = foo.isDirectory(); - if (f == bar.isDirectory()) { - return 0; - } - return f ? 1 : -1; - } - -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/selectors/And.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/selectors/And.java deleted file mode 100644 index 409ed661..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/selectors/And.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * 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.selectors; - -import java.util.Iterator; - -import org.apache.tools.ant.types.Resource; - -/** - * And ResourceSelector. - * @since Ant 1.7 - */ -public class And extends ResourceSelectorContainer implements ResourceSelector { - - /** - * Default constructor. - */ - public And() { - } - - /** - * Convenience constructor. - * @param r the ResourceSelector[] to add. - */ - public And(ResourceSelector[] r) { - super(r); - } - - /** - * Return true if this Resource is selected. - * @param r the Resource to check. - * @return whether the Resource was selected. - */ - public boolean isSelected(Resource r) { - for (Iterator<ResourceSelector> i = getSelectors(); i.hasNext();) { - if (!i.next().isSelected(r)) { - return false; - } - } - return true; - } - -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/selectors/Compare.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/selectors/Compare.java deleted file mode 100644 index f345c278..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/selectors/Compare.java +++ /dev/null @@ -1,149 +0,0 @@ -/* - * 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.selectors; - -import java.util.Stack; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.types.Comparison; -import org.apache.tools.ant.types.DataType; -import org.apache.tools.ant.types.Quantifier; -import org.apache.tools.ant.types.Resource; -import org.apache.tools.ant.types.ResourceCollection; -import org.apache.tools.ant.types.resources.Union; -import org.apache.tools.ant.types.resources.comparators.DelegatedResourceComparator; -import org.apache.tools.ant.types.resources.comparators.ResourceComparator; - -/** - * ResourceSelector that compares against "control" Resource(s) - * using ResourceComparators. - * @since Ant 1.7 - */ -public class Compare extends DataType implements ResourceSelector { - - private static final String ONE_CONTROL_MESSAGE - = " the <control> element should be specified exactly once."; - - private DelegatedResourceComparator comp = new DelegatedResourceComparator(); - private Quantifier against = Quantifier.ALL; - - private Comparison when = Comparison.EQUAL; - - private Union control; - - /** - * Add a ResourceComparator to this Compare selector. - * If multiple ResourceComparators are added, they will be processed in LIFO order. - * @param c the ResourceComparator to add. - */ - public synchronized void add(ResourceComparator c) { - if (isReference()) { - throw noChildrenAllowed(); - } - comp.add(c); - setChecked(false); - } - - /** - * Set the quantifier to be used. Default "all". - * @param against the Quantifier EnumeratedAttribute to use. - */ - public synchronized void setAgainst(Quantifier against) { - if (isReference()) { - throw tooManyAttributes(); - } - this.against = against; - } - - /** - * Set the comparison to be used. Default "equal". - * @param when the Comparison EnumeratedAttribute to use. - */ - public synchronized void setWhen(Comparison when) { - if (isReference()) { - throw tooManyAttributes(); - } - this.when = when; - } - - /** - * Create the nested control element. These are the - * resources to compare against. - * @return ResourceCollection. - */ - public synchronized ResourceCollection createControl() { - if (isReference()) { - throw noChildrenAllowed(); - } - if (control != null) { - throw oneControl(); - } - control = new Union(); - setChecked(false); - return control; - } - - //implement ResourceSelector; inherit doc - /** {@inheritDoc} */ - public synchronized boolean isSelected(Resource r) { - if (isReference()) { - return ((ResourceSelector) getCheckedRef()).isSelected(r); - } - if (control == null) { - throw oneControl(); - } - dieOnCircularReference(); - int t = 0, f = 0; - for (Resource res : control) { - if (when.evaluate(comp.compare(r, res))) { - t++; - } else { - f++; - } - } - return against.evaluate(t, f); - } - - /** - * Overrides the version from DataType - * to recurse on nested ResourceComparators. - * @param stk the stack of data types to use (recursively). - * @param p the project to use to dereference the references. - * @throws BuildException on error. - */ - protected synchronized void dieOnCircularReference(Stack<Object> stk, Project p) - throws BuildException { - if (isChecked()) { - return; - } - if (isReference()) { - super.dieOnCircularReference(stk, p); - } else { - if (control != null) { - DataType.pushAndInvokeCircularReferenceCheck(control, stk, p); - } - DataType.pushAndInvokeCircularReferenceCheck(comp, stk, p); - setChecked(true); - } - } - - private BuildException oneControl() { - return new BuildException(super.toString() + ONE_CONTROL_MESSAGE); - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/selectors/Date.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/selectors/Date.java deleted file mode 100644 index 8541e858..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/selectors/Date.java +++ /dev/null @@ -1,162 +0,0 @@ -/* - * 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.selectors; - -import java.text.DateFormat; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Locale; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.types.Resource; -import org.apache.tools.ant.types.TimeComparison; -import org.apache.tools.ant.util.FileUtils; - -/** - * Date ResourceSelector. Based on the date FileSelector, with the most - * notable difference being the lack of support for the includedirs attribute. - * It is recommended that the effect of includeDirs = "false" be achieved for - * resources by enclosing a "dir" Type ResourceSelector and a Date - * ResourceSelector in an Or ResourceSelector. - * @since Ant 1.7 - */ -public class Date implements ResourceSelector { - private static final String MILLIS_OR_DATETIME - = "Either the millis or the datetime attribute must be set."; - private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); - - private Long millis = null; - private String dateTime = null; - private String pattern = null; - private TimeComparison when = TimeComparison.EQUAL; - private long granularity = FILE_UTILS.getFileTimestampGranularity(); - - /** - * Set the date/time in milliseconds since 1970. - * @param m the number of millis. - */ - public synchronized void setMillis(long m) { - millis = new Long(m); - } - - /** - * Get the date/time in ms. - * @return long number of millis since 1970. - */ - public synchronized long getMillis() { - return millis == null ? -1L : millis.longValue(); - } - - /** - * Set the date and time as a String. - * @param s the date and time to use. - */ - public synchronized void setDateTime(String s) { - dateTime = s; - millis = null; - } - - /** - * Get the date and time in String format. - * @return a String representing a date and time. - */ - public synchronized String getDatetime() { - return dateTime; - } - - /** - * Set the granularity to use for this ResourceSelector. - * @param g the timestamp granularity. - */ - public synchronized void setGranularity(long g) { - granularity = g; - } - - /** - * Get the timestamp granularity used by this ResourceSelector. - * @return the long granularity. - */ - public synchronized long getGranularity() { - return granularity; - } - - /** - * Set the optional pattern to use with the datetime attribute. - * @param p the SimpleDateFormat-compatible pattern string. - */ - public synchronized void setPattern(String p) { - pattern = p; - } - - /** - * Get the pattern for use with the datetime attribute. - * @return a SimpleDateFormat-compatible pattern string. - */ - public synchronized String getPattern() { - return pattern; - } - - /** - * Set the comparison mode. - * @param c a TimeComparison object. - */ - public synchronized void setWhen(TimeComparison c) { - when = c; - } - - /** - * Get the comparison mode. - * @return a TimeComparison object. - */ - public synchronized TimeComparison getWhen() { - return when; - } - - /** - * Return true if this Resource is selected. - * @param r the Resource to check. - * @return whether the Resource was selected. - */ - public synchronized boolean isSelected(Resource r) { - if (dateTime == null && millis == null) { - throw new BuildException(MILLIS_OR_DATETIME); - } - if (millis == null) { - DateFormat df = ((pattern == null) - ? DateFormat.getDateTimeInstance( - DateFormat.SHORT, DateFormat.SHORT, Locale.US) - : new SimpleDateFormat(pattern)); - try { - long m = df.parse(dateTime).getTime(); - if (m < 0) { - throw new BuildException("Date of " + dateTime - + " results in negative milliseconds value" - + " relative to epoch (January 1, 1970, 00:00:00 GMT)."); - } - setMillis(m); - } catch (ParseException pe) { - throw new BuildException("Date of " + dateTime - + " Cannot be parsed correctly. It should be in" - + (pattern == null - ? " MM/DD/YYYY HH:MM AM_PM" : pattern) + " format."); - } - } - return when.evaluate(r.getLastModified(), millis.longValue(), granularity); - } - -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/selectors/Exists.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/selectors/Exists.java deleted file mode 100644 index 1b498bca..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/selectors/Exists.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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.selectors; - -import org.apache.tools.ant.types.Resource; - -/** - * Exists ResourceSelector. - * @since Ant 1.7 - */ -public class Exists implements ResourceSelector { - - /** - * Return true if this Resource is selected. - * @param r the Resource to check. - * @return whether the Resource was selected. - */ - public boolean isSelected(Resource r) { - return r.isExists(); - } - -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/selectors/InstanceOf.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/selectors/InstanceOf.java deleted file mode 100644 index 39b31088..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/selectors/InstanceOf.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * 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.selectors; - -import org.apache.tools.ant.AntTypeDefinition; -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.ComponentHelper; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.ProjectHelper; -import org.apache.tools.ant.types.Resource; - -/** - * InstanceOf ResourceSelector. - * @since Ant 1.7 - */ -public class InstanceOf implements ResourceSelector { - private static final String ONE_ONLY = "Exactly one of class|type must be set."; - - private Project project; - private Class<?> clazz; - private String type; - private String uri; - - /** - * Set the Project instance for this InstanceOf selector. - * @param p the Project instance used for type comparisons. - */ - public void setProject(Project p) { - project = p; - } - - /** - * Set the class to compare against. - * @param c the class. - */ - public void setClass(Class<?> c) { - if (clazz != null) { - throw new BuildException("The class attribute has already been set."); - } - clazz = c; - } - - /** - * Set the Ant type to compare against. - * @param s the type name. - */ - public void setType(String s) { - type = s; - } - - /** - * Set the URI in which the Ant type, if specified, should be defined. - * @param u the URI. - */ - public void setURI(String u) { - uri = u; - } - - /** - * Get the comparison class. - * @return the Class object. - */ - public Class<?> getCheckClass() { - return clazz; - } - - /** - * Get the comparison type. - * @return the String typename. - */ - public String getType() { - return type; - } - - /** - * Get the type's URI. - * @return the String URI. - */ - public String getURI() { - return uri; - } - - /** - * Return true if this Resource is selected. - * @param r the Resource to check. - * @return whether the Resource was selected. - * @throws BuildException if an error occurs. - */ - public boolean isSelected(Resource r) { - if ((clazz == null) == (type == null)) { - throw new BuildException(ONE_ONLY); - } - Class<?> c = clazz; - if (type != null) { - if (project == null) { - throw new BuildException( - "No project set for InstanceOf ResourceSelector; " - + "the type attribute is invalid."); - } - AntTypeDefinition d = ComponentHelper.getComponentHelper( - project).getDefinition(ProjectHelper.genComponentName(uri, type)); - if (d == null) { - throw new BuildException("type " + type + " not found."); - } - try { - c = d.innerGetTypeClass(); - } catch (ClassNotFoundException e) { - throw new BuildException(e); - } - } - return c.isAssignableFrom(r.getClass()); - } - -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/selectors/Majority.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/selectors/Majority.java deleted file mode 100644 index 5a7a95c0..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/selectors/Majority.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * 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.selectors; - -import java.util.Iterator; - -import org.apache.tools.ant.types.Resource; - -/** - * Majority ResourceSelector. - * @since Ant 1.7 - */ -public class Majority - extends ResourceSelectorContainer implements ResourceSelector { - - private boolean tie = true; - - /** - * Default constructor. - */ - public Majority() { - } - - /** - * Convenience constructor. - * @param r the ResourceSelector[] to add. - */ - public Majority(ResourceSelector[] r) { - super(r); - } - - /** - * Set whether ties are allowed. - * @param b whether a tie is a pass. - */ - public synchronized void setAllowtie(boolean b) { - tie = b; - } - - /** - * Return true if this Resource is selected. - * @param r the Resource to check. - * @return whether the Resource was selected. - */ - public synchronized boolean isSelected(Resource r) { - int passed = 0; - int failed = 0; - int count = selectorCount(); - boolean even = count % 2 == 0; - int threshold = count / 2; - - for (Iterator<ResourceSelector> i = getSelectors(); i.hasNext();) { - if (i.next().isSelected(r)) { - ++passed; - if (passed > threshold || (even && tie && passed == threshold)) { - return true; - } - } else { - ++failed; - if (failed > threshold || (even && !tie && failed == threshold)) { - return false; - } - } - } - //dummy - return false; - } - -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/selectors/Name.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/selectors/Name.java deleted file mode 100644 index 50c242a2..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/selectors/Name.java +++ /dev/null @@ -1,151 +0,0 @@ -/* - * 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.selectors; - -import org.apache.tools.ant.Project; -import org.apache.tools.ant.types.RegularExpression; -import org.apache.tools.ant.types.Resource; -import org.apache.tools.ant.types.selectors.SelectorUtils; -import org.apache.tools.ant.util.regexp.Regexp; -import org.apache.tools.ant.util.regexp.RegexpUtil; - -/** - * Name ResourceSelector. - * @since Ant 1.7 - */ -public class Name implements ResourceSelector { - private String regex = null; - private String pattern; - private boolean cs = true; - private boolean handleDirSep = false; - - // caches for performance reasons - private RegularExpression reg; - private Regexp expression; - - private Project project; - - public void setProject(Project p) { - project = p; - } - - /** - * Set the pattern to compare names against. - * @param n the pattern String to set. - */ - public void setName(String n) { - pattern = n; - } - - /** - * Get the pattern used by this Name ResourceSelector. - * @return the String selection pattern. - */ - public String getName() { - return pattern; - } - - /** - * Set the regular expression to compare names against. - * @param r the regex to set. - * @since Ant 1.8.0 - */ - public void setRegex(String r) { - regex = r; - reg = null; - } - - /** - * Get the regular expression used by this Name ResourceSelector. - * @return the String selection pattern. - * @since Ant 1.8.0 - */ - public String getRegex() { - return regex; - } - - /** - * Set whether the name comparisons are case-sensitive. - * @param b boolean case-sensitivity flag. - */ - public void setCaseSensitive(boolean b) { - cs = b; - } - - /** - * Learn whether this Name ResourceSelector is case-sensitive. - * @return boolean case-sensitivity flag. - */ - public boolean isCaseSensitive() { - return cs; - } - - /** - * Attribute specifying whether to ignore the difference - * between / and \ (the two common directory characters). - * @param handleDirSep a boolean, default is false. - * @since Ant 1.8.0 - */ - public void setHandleDirSep(boolean handleDirSep) { - this.handleDirSep = handleDirSep; - } - - /** - * Whether the difference between / and \ (the two common - * directory characters) is ignored. - * - * @since Ant 1.8.0 - */ - public boolean doesHandledirSep() { - return handleDirSep; - } - - /** - * Return true if this Resource is selected. - * @param r the Resource to check. - * @return whether the Resource was selected. - */ - public boolean isSelected(Resource r) { - String n = r.getName(); - if (matches(n)) { - return true; - } - String s = r.toString(); - return s.equals(n) ? false : matches(s); - } - - private boolean matches(String name) { - if (pattern != null) { - return SelectorUtils.match(modify(pattern), modify(name), cs); - } else { - if (reg == null) { - reg = new RegularExpression(); - reg.setPattern(regex); - expression = reg.getRegexp(project); - } - return expression.matches(modify(name), RegexpUtil.asOptions(cs)); - } - } - - private String modify(String s) { - if (s == null || !handleDirSep || s.indexOf("\\") == -1) { - return s; - } - return s.replace('\\', '/'); - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/selectors/None.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/selectors/None.java deleted file mode 100644 index 0de86236..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/selectors/None.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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.selectors; - -import java.util.Iterator; - -import org.apache.tools.ant.types.Resource; - -/** - * None ResourceSelector. - * @since Ant 1.7 - */ -public class None - extends ResourceSelectorContainer implements ResourceSelector { - - /** - * Default constructor. - */ - public None() { - } - - /** - * Convenience constructor. - * @param r the ResourceSelector[] to add. - */ - public None(ResourceSelector[] r) { - super(r); - } - - /** - * Return true if this Resource is selected. - * @param r the Resource to check. - * @return whether the Resource was selected. - */ - public boolean isSelected(Resource r) { - for (Iterator<ResourceSelector> i = getSelectors(); i.hasNext();) { - if (i.next().isSelected(r)) { - return false; - } - } - return true; - } - -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/selectors/Not.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/selectors/Not.java deleted file mode 100644 index dc67da1f..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/selectors/Not.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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.selectors; - -import org.apache.tools.ant.types.Resource; - -/** - * Not ResourceSelector. - * @since Ant 1.7 - */ -public class Not implements ResourceSelector { - - private ResourceSelector sel; - - /** - * Default constructor. - */ - public Not() { - } - - /** - * Convenience constructor. - * @param s the ResourceSelector to negate. - */ - public Not(ResourceSelector s) { - add(s); - } - - /** - * Set the ResourceSelector. - * @param s the ResourceSelector to negate. - * @throws IllegalStateException if already set. - */ - public void add(ResourceSelector s) { - if (sel != null) { - throw new IllegalStateException( - "The Not ResourceSelector accepts a single nested ResourceSelector"); - } - sel = s; - } - - /** - * Return true if this Resource is selected. - * @param r the Resource to check. - * @return whether the Resource was selected. - */ - public boolean isSelected(Resource r) { - return !(sel.isSelected(r)); - } - -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/selectors/Or.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/selectors/Or.java deleted file mode 100644 index b22303a4..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/selectors/Or.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * 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.selectors; - -import java.util.Iterator; - -import org.apache.tools.ant.types.Resource; - -/** - * Or ResourceSelector. - * @since Ant 1.7 - */ -public class Or extends ResourceSelectorContainer implements ResourceSelector { - - /** - * Default constructor. - */ - public Or() { - } - - /** - * Convenience constructor. - * @param r the ResourceSelector[] to add. - */ - public Or(ResourceSelector[] r) { - super(r); - } - - /** - * Return true if this Resource is selected. - * @param r the Resource to check. - * @return whether the Resource was selected. - */ - public boolean isSelected(Resource r) { - for (Iterator<ResourceSelector> i = getSelectors(); i.hasNext();) { - if (i.next().isSelected(r)) { - return true; - } - } - return false; - } - -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/selectors/ResourceSelector.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/selectors/ResourceSelector.java deleted file mode 100644 index 37151ecd..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/selectors/ResourceSelector.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * 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.selectors; - -import org.apache.tools.ant.types.Resource; - -/** - * Interface for a Resource selector. - * @since Ant 1.7 - */ -public interface ResourceSelector { - - /** - * Return true if this Resource is selected. - * @param r the Resource to check. - * @return whether the Resource was selected. - */ - boolean isSelected(Resource r); - -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/selectors/ResourceSelectorContainer.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/selectors/ResourceSelectorContainer.java deleted file mode 100644 index 6b1c8002..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/selectors/ResourceSelectorContainer.java +++ /dev/null @@ -1,128 +0,0 @@ -/* - * 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.selectors; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; -import java.util.Stack; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.types.DataType; - -/** - * ResourceSelector container. - * @since Ant 1.7 - */ -public class ResourceSelectorContainer extends DataType { - - private final List<ResourceSelector> resourceSelectors = new ArrayList<ResourceSelector>(); - - /** - * Default constructor. - */ - public ResourceSelectorContainer() { - } - - /** - * Construct a new ResourceSelectorContainer with the specified array of selectors. - * @param r the ResourceSelector[] to add. - */ - public ResourceSelectorContainer(ResourceSelector[] r) { - for (int i = 0; i < r.length; i++) { - add(r[i]); - } - } - - /** - * Add a ResourceSelector to the container. - * @param s the ResourceSelector to add. - */ - public void add(ResourceSelector s) { - if (isReference()) { - throw noChildrenAllowed(); - } - if (s == null) { - return; - } - resourceSelectors.add(s); - setChecked(false); - } - - /** - * Learn whether this ResourceSelectorContainer has selectors. - * @return boolean indicating whether selectors have been added to the container. - */ - public boolean hasSelectors() { - if (isReference()) { - return ((ResourceSelectorContainer) getCheckedRef()).hasSelectors(); - } - dieOnCircularReference(); - return !resourceSelectors.isEmpty(); - } - - /** - * Get the count of nested selectors. - * @return the selector count as int. - */ - public int selectorCount() { - if (isReference()) { - return ((ResourceSelectorContainer) getCheckedRef()).selectorCount(); - } - dieOnCircularReference(); - return resourceSelectors.size(); - } - - /** - * Return an Iterator over the nested selectors. - * @return Iterator of ResourceSelectors. - */ - public Iterator<ResourceSelector> getSelectors() { - if (isReference()) { - return ((ResourceSelectorContainer) getCheckedRef()).getSelectors(); - } - dieOnCircularReference(); - return Collections.unmodifiableList(resourceSelectors).iterator(); - } - - /** - * Overrides the version from DataType to recurse on nested ResourceSelectors. - * @param stk the Stack of references. - * @param p the Project to resolve against. - * @throws BuildException on error. - */ - protected void dieOnCircularReference(Stack<Object> stk, Project p) - throws BuildException { - if (isChecked()) { - return; - } - if (isReference()) { - super.dieOnCircularReference(stk, p); - } else { - for (ResourceSelector resourceSelector : resourceSelectors) { - if (resourceSelector instanceof DataType) { - pushAndInvokeCircularReferenceCheck((DataType) resourceSelector, stk, p); - } - } - setChecked(true); - } - } - -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/selectors/Size.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/selectors/Size.java deleted file mode 100644 index 4d6c87e2..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/selectors/Size.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * 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.selectors; - -import org.apache.tools.ant.types.Comparison; -import org.apache.tools.ant.types.Resource; - -/** - * Size ResourceSelector. - * @since Ant 1.7 - */ -public class Size implements ResourceSelector { - private long size = -1; - private Comparison when = Comparison.EQUAL; - - /** - * Set the size to compare against. - * @param l the long resource size. - */ - public void setSize(long l) { - size = l; - } - - /** - * Get the size compared to by this Size ResourceSelector. - * @return the long resource size. - */ - public long getSize() { - return size; - } - - /** - * Set the comparison mode. - * @param c a Comparison object. - */ - public void setWhen(Comparison c) { - when = c; - } - - /** - * Get the comparison mode. - * @return a Comparison object. - */ - public Comparison getWhen() { - return when; - } - - /** - * Return true if this Resource is selected. - * @param r the Resource to check. - * @return whether the Resource was selected. - */ - public boolean isSelected(Resource r) { - long diff = r.getSize() - size; - return when.evaluate(diff == 0 ? 0 : (int) (diff / Math.abs(diff))); - } - -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/selectors/Type.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/selectors/Type.java deleted file mode 100644 index 65d4a577..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/selectors/Type.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * 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.selectors; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.types.EnumeratedAttribute; -import org.apache.tools.ant.types.Resource; - -/** - * Type file/dir ResourceSelector. - * @since Ant 1.7 - */ -public class Type implements ResourceSelector { - - private static final String FILE_ATTR = "file"; - private static final String DIR_ATTR = "dir"; - private static final String ANY_ATTR = "any"; - - /** Static file type selector. */ - public static final Type FILE = new Type(new FileDir(FILE_ATTR)); - - /** Static dir type selector. */ - public static final Type DIR = new Type(new FileDir(DIR_ATTR)); - - /** Static any type selector. Since Ant 1.8. */ - public static final Type ANY = new Type(new FileDir(ANY_ATTR)); - - /** - * Implements the type attribute. - */ - public static class FileDir extends EnumeratedAttribute { - private static final String[] VALUES = new String[] {FILE_ATTR, DIR_ATTR, ANY_ATTR}; - - /** - * Default constructor. - */ - public FileDir() { - } - - /** - * Convenience constructor. - * @param value the String EnumeratedAttribute value. - */ - public FileDir(final String value) { - setValue(value); - } - - /** - * Return the possible values. - * @return a String array. - */ - @Override - public String[] getValues() { - return VALUES; - } - } - - private FileDir type = null; - - /** - * Default constructor. - */ - public Type() { - } - - /** - * Convenience constructor. - * @param fd the FileDir type. - */ - public Type(final FileDir fd) { - setType(fd); - } - - /** - * Set type; file|dir. - * @param fd a FileDir object. - */ - public void setType(final FileDir fd) { - type = fd; - } - - /** - * Return true if this Resource is selected. - * @param r the Resource to check. - * @return whether the Resource was selected. - */ - public boolean isSelected(final Resource r) { - if (type == null) { - throw new BuildException("The type attribute is required."); - } - final int i = type.getIndex(); - return i == 2 || (r.isDirectory() ? i == 1 : i == 0); - } - -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/AbstractSelectorContainer.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/AbstractSelectorContainer.java deleted file mode 100644 index b80816da..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/AbstractSelectorContainer.java +++ /dev/null @@ -1,353 +0,0 @@ -/* - * 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.selectors; - -import java.util.Enumeration; -import java.util.Stack; -import java.util.Vector; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.types.DataType; -import org.apache.tools.ant.types.selectors.modifiedselector.ModifiedSelector; - -/** - * This is the a base class a container of selectors - it does - * not need do be a selector itself. - * - * @since 1.7 - */ -public abstract class AbstractSelectorContainer extends DataType - implements Cloneable, SelectorContainer { - - private Vector<FileSelector> selectorsList = new Vector<FileSelector>(); - - /** - * Indicates whether there are any selectors here. - * @return true if there are selectors - */ - public boolean hasSelectors() { - if (isReference()) { - return ((AbstractSelectorContainer) getCheckedRef()).hasSelectors(); - } - dieOnCircularReference(); - return !(selectorsList.isEmpty()); - } - - /** - * Gives the count of the number of selectors in this container - * @return the number of selectors - */ - public int selectorCount() { - if (isReference()) { - return ((AbstractSelectorContainer) getCheckedRef()).selectorCount(); - } - dieOnCircularReference(); - return selectorsList.size(); - } - - /** - * Returns the set of selectors as an array. - * @param p the current project - * @return an array of selectors - */ - public FileSelector[] getSelectors(Project p) { - if (isReference()) { - return ((AbstractSelectorContainer) getCheckedRef(p)) - .getSelectors(p); - } - dieOnCircularReference(p); - FileSelector[] result = new FileSelector[selectorsList.size()]; - selectorsList.copyInto(result); - return result; - } - - /** - * Returns an enumerator for accessing the set of selectors. - * @return an enumerator for the selectors - */ - public Enumeration<FileSelector> selectorElements() { - if (isReference()) { - return ((AbstractSelectorContainer) getCheckedRef()) - .selectorElements(); - } - dieOnCircularReference(); - return selectorsList.elements(); - } - - /** - * Convert the Selectors within this container to a string. This will - * just be a helper class for the subclasses that put their own name - * around the contents listed here. - * - * @return comma separated list of Selectors contained in this one - */ - public String toString() { - StringBuilder buf = new StringBuilder(); - Enumeration<FileSelector> e = selectorElements(); - if (e.hasMoreElements()) { - while (e.hasMoreElements()) { - buf.append(e.nextElement().toString()); - if (e.hasMoreElements()) { - buf.append(", "); - } - } - } - - return buf.toString(); - } - - /** - * Add a new selector into this container. - * - * @param selector the new selector to add - */ - public void appendSelector(FileSelector selector) { - if (isReference()) { - throw noChildrenAllowed(); - } - selectorsList.addElement(selector); - setChecked(false); - } - - /** - * <p> - * This validates each contained selector - * provided that the selector implements the validate interface. - * </p> - * <p>Ordinarily, this will validate all the elements of a selector - * container even if the isSelected() method of some elements is - * never called. This has two effects:</p> - * <ul> - * <li>Validation will often occur twice. - * <li>Since it is not required that selectors derive from - * BaseSelector, there could be selectors in the container whose - * error conditions are not detected if their isSelected() call - * is never made. - * </ul> - */ - public void validate() { - if (isReference()) { - ((AbstractSelectorContainer) getCheckedRef()).validate(); - } - dieOnCircularReference(); - Enumeration<FileSelector> e = selectorElements(); - while (e.hasMoreElements()) { - Object o = e.nextElement(); - if (o instanceof BaseSelector) { - ((BaseSelector) o).validate(); - } - } - } - - - /* Methods below all add specific selectors */ - - /** - * add a "Select" selector entry on the selector list - * @param selector the selector to add - */ - public void addSelector(SelectSelector selector) { - appendSelector(selector); - } - - /** - * add an "And" selector entry on the selector list - * @param selector the selector to add - */ - public void addAnd(AndSelector selector) { - appendSelector(selector); - } - - /** - * add an "Or" selector entry on the selector list - * @param selector the selector to add - */ - public void addOr(OrSelector selector) { - appendSelector(selector); - } - - /** - * add a "Not" selector entry on the selector list - * @param selector the selector to add - */ - public void addNot(NotSelector selector) { - appendSelector(selector); - } - - /** - * add a "None" selector entry on the selector list - * @param selector the selector to add - */ - public void addNone(NoneSelector selector) { - appendSelector(selector); - } - - /** - * add a majority selector entry on the selector list - * @param selector the selector to add - */ - public void addMajority(MajoritySelector selector) { - appendSelector(selector); - } - - /** - * add a selector date entry on the selector list - * @param selector the selector to add - */ - public void addDate(DateSelector selector) { - appendSelector(selector); - } - - /** - * add a selector size entry on the selector list - * @param selector the selector to add - */ - public void addSize(SizeSelector selector) { - appendSelector(selector); - } - - /** - * add a selector filename entry on the selector list - * @param selector the selector to add - */ - public void addFilename(FilenameSelector selector) { - appendSelector(selector); - } - - /** - * add an extended selector entry on the selector list - * @param selector the selector to add - */ - public void addCustom(ExtendSelector selector) { - appendSelector(selector); - } - - /** - * add a contains selector entry on the selector list - * @param selector the selector to add - */ - public void addContains(ContainsSelector selector) { - appendSelector(selector); - } - - /** - * add a present selector entry on the selector list - * @param selector the selector to add - */ - public void addPresent(PresentSelector selector) { - appendSelector(selector); - } - - /** - * add a depth selector entry on the selector list - * @param selector the selector to add - */ - public void addDepth(DepthSelector selector) { - appendSelector(selector); - } - - /** - * add a depends selector entry on the selector list - * @param selector the selector to add - */ - public void addDepend(DependSelector selector) { - appendSelector(selector); - } - - /** - * adds a different selector to the selector list - * @param selector the selector to add - */ - public void addDifferent(DifferentSelector selector) { - appendSelector(selector); - } - - /** - * adds a type selector to the selector list - * @param selector the selector to add - */ - public void addType(TypeSelector selector) { - appendSelector(selector); - } - - /** - * add a regular expression selector entry on the selector list - * @param selector the selector to add - */ - public void addContainsRegexp(ContainsRegexpSelector selector) { - appendSelector(selector); - } - - /** - * add the modified selector - * @param selector the selector to add - * @since ant 1.6 - */ - public void addModified(ModifiedSelector selector) { - appendSelector(selector); - } - - public void addReadable(ReadableSelector r) { - appendSelector(r); - } - - public void addWritable(WritableSelector w) { - appendSelector(w); - } - - /** - * add an arbitrary selector - * @param selector the selector to add - * @since Ant 1.6 - */ - public void add(FileSelector selector) { - appendSelector(selector); - } - - protected synchronized void dieOnCircularReference(Stack<Object> stk, Project p) { - if (isChecked()) { - return; - } - if (isReference()) { - super.dieOnCircularReference(stk, p); - } else { - for (FileSelector fileSelector : selectorsList) { - if (fileSelector instanceof DataType) { - pushAndInvokeCircularReferenceCheck((DataType) fileSelector, stk, p); - } - } - setChecked(true); - } - } - - public synchronized Object clone() { - if (isReference()) { - return ((AbstractSelectorContainer) getCheckedRef()).clone(); - } - try { - AbstractSelectorContainer sc = - (AbstractSelectorContainer) super.clone(); - sc.selectorsList = new Vector<FileSelector>(selectorsList); - return sc; - } catch (CloneNotSupportedException e) { - throw new BuildException(e); - } - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/AndSelector.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/AndSelector.java deleted file mode 100644 index c8e96a04..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/AndSelector.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * 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.selectors; - -import java.io.File; -import java.util.Enumeration; - -/** - * This selector has a collection of other selectors, all of which have to - * select a file in order for this selector to select it. - * - * @since 1.5 - */ -public class AndSelector extends BaseSelectorContainer { - - /** - * Default constructor. - */ - public AndSelector() { - } - - /** - * @return a string representation of the selector - */ - public String toString() { - StringBuilder buf = new StringBuilder(); - if (hasSelectors()) { - buf.append("{andselect: "); - buf.append(super.toString()); - buf.append("}"); - } - return buf.toString(); - } - - /** - * Returns true (the file is selected) only if all other selectors - * agree that the file should be selected. - * - * @param basedir the base directory the scan is being done from - * @param filename the name of the file to check - * @param file a java.io.File object for the filename that the selector - * can use - * @return whether the file should be selected or not - */ - public boolean isSelected(File basedir, String filename, File file) { - validate(); - Enumeration<FileSelector> e = selectorElements(); - - while (e.hasMoreElements()) { - if (!e.nextElement().isSelected(basedir, filename, file)) { - return false; - } - } - return true; - } - -} - diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/BaseExtendSelector.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/BaseExtendSelector.java deleted file mode 100644 index f17ca027..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/BaseExtendSelector.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * 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.selectors; - -import java.io.File; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.types.Parameter; - -/** - * Convenience base class for all selectors accessed through ExtendSelector. - * It provides support for gathering the parameters together as well as for - * assigning an error message and throwing a build exception if an error is - * detected. - * - * @since 1.5 - */ -public abstract class BaseExtendSelector - extends BaseSelector - implements ExtendFileSelector { - - // CheckStyle:VisibilityModifier OFF - bc - - /** The passed in parameter array. */ - protected Parameter[] parameters = null; - - // CheckStyle:VisibilityModifier ON - - /** - * Default constructor. - */ - public BaseExtendSelector() { - } - - /** - * Set all the Parameters for this custom selector, collected by - * the ExtendSelector class. - * - * @param parameters the complete set of parameters for this selector - */ - public void setParameters(Parameter[] parameters) { - this.parameters = parameters; - } - - /** - * Allows access to the parameters gathered and set within the - * <custom> tag. - * - * @return the set of parameters defined for this selector - */ - protected Parameter[] getParameters() { - return parameters; - } - - /** - * Method that each selector will implement to create their - * selection behaviour. If there is a problem with the setup - * of a selector, it can throw a BuildException to indicate - * the problem. - * - * @param basedir A java.io.File object for the base directory - * @param filename The name of the file to check - * @param file A File object for this filename - * @return whether the file should be selected or not - * @exception BuildException if an error occurs - */ - public abstract boolean isSelected(File basedir, String filename, - File file) - throws BuildException; - -} - diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/BaseSelector.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/BaseSelector.java deleted file mode 100644 index 61d7a1a2..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/BaseSelector.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * 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.selectors; - -import java.io.File; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.types.DataType; - -/** - * A convenience base class that you can subclass Selectors from. It - * provides some helpful common behaviour. Note that there is no need - * for Selectors to inherit from this class, it is only necessary that - * they implement FileSelector. - * - * @since 1.5 - */ -public abstract class BaseSelector extends DataType implements FileSelector { - - private String errmsg = null; - - - /** - * Do nothing constructor. - */ - public BaseSelector() { - } - - /** - * Allows all selectors to indicate a setup error. Note that only - * the first error message is recorded. - * - * @param msg The error message any BuildException should throw. - */ - public void setError(String msg) { - if (errmsg == null) { - errmsg = msg; - } - } - - /** - * Returns any error messages that have been set. - * - * @return the error condition - */ - public String getError() { - return errmsg; - } - - - /** - * <p>Subclasses can override this method to provide checking of their - * state. So long as they call validate() from isSelected(), this will - * be called automatically (unless they override validate()).</p> - * <p>Implementations should check for incorrect settings and call - * setError() as necessary.</p> - */ - public void verifySettings() { - if (isReference()) { - ((BaseSelector) getCheckedRef()).verifySettings(); - } - } - - - /** - * Subclasses can use this to throw the requisite exception - * in isSelected() in the case of an error condition. - */ - public void validate() { - if (getError() == null) { - verifySettings(); - } - if (getError() != null) { - throw new BuildException(errmsg); - } - if (!isReference()) { - dieOnCircularReference(); - } - } - - /** - * Method that each selector will implement to create their - * selection behaviour. If there is a problem with the setup - * of a selector, it can throw a BuildException to indicate - * the problem. - * - * @param basedir A java.io.File object for the base directory - * @param filename The name of the file to check - * @param file A File object for this filename - * @return whether the file should be selected or not - */ - public abstract boolean isSelected(File basedir, String filename, - File file); - -} - - diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/BaseSelectorContainer.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/BaseSelectorContainer.java deleted file mode 100644 index 1edf0857..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/BaseSelectorContainer.java +++ /dev/null @@ -1,343 +0,0 @@ -/* - * 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.selectors; - -import java.io.File; -import java.util.Enumeration; -import java.util.Stack; -import java.util.Vector; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.types.DataType; -import org.apache.tools.ant.types.selectors.modifiedselector.ModifiedSelector; - -/** - * This is the base class for selectors that can contain other selectors. - * - * @since 1.5 - */ -public abstract class BaseSelectorContainer extends BaseSelector - implements SelectorContainer { - - private Vector<FileSelector> selectorsList = new Vector<FileSelector>(); - - /** - * Default constructor. - */ - public BaseSelectorContainer() { - } - - /** - * Indicates whether there are any selectors here. - * @return true if there are selectors - */ - public boolean hasSelectors() { - dieOnCircularReference(); - return !(selectorsList.isEmpty()); - } - - /** - * Gives the count of the number of selectors in this container - * @return the number of selectors - */ - public int selectorCount() { - dieOnCircularReference(); - return selectorsList.size(); - } - - /** - * Returns the set of selectors as an array. - * @param p the current project - * @return an array of selectors - */ - public FileSelector[] getSelectors(Project p) { - dieOnCircularReference(); - FileSelector[] result = new FileSelector[selectorsList.size()]; - selectorsList.copyInto(result); - return result; - } - - /** - * Returns an enumerator for accessing the set of selectors. - * @return an enumerator for the selectors - */ - public Enumeration<FileSelector> selectorElements() { - dieOnCircularReference(); - return selectorsList.elements(); - } - - /** - * Convert the Selectors within this container to a string. This will - * just be a helper class for the subclasses that put their own name - * around the contents listed here. - * - * @return comma separated list of Selectors contained in this one - */ - public String toString() { - dieOnCircularReference(); - StringBuilder buf = new StringBuilder(); - Enumeration<FileSelector> e = selectorElements(); - while (e.hasMoreElements()) { - buf.append(e.nextElement().toString()); - if (e.hasMoreElements()) { - buf.append(", "); - } - } - return buf.toString(); - } - - /** - * Add a new selector into this container. - * - * @param selector the new selector to add - */ - public void appendSelector(FileSelector selector) { - selectorsList.addElement(selector); - setChecked(false); - } - - /** - * <p>This implementation validates the container by calling - * verifySettings() and then validates each contained selector - * provided that the selector implements the validate interface. - * </p> - * <p>Ordinarily, this will validate all the elements of a selector - * container even if the isSelected() method of some elements is - * never called. This has two effects:</p> - * <ul> - * <li>Validation will often occur twice. - * <li>Since it is not required that selectors derive from - * BaseSelector, there could be selectors in the container whose - * error conditions are not detected if their isSelected() call - * is never made. - * </ul> - */ - public void validate() { - verifySettings(); - dieOnCircularReference(); - String errmsg = getError(); - if (errmsg != null) { - throw new BuildException(errmsg); - } - Enumeration<FileSelector> e = selectorElements(); - while (e.hasMoreElements()) { - Object o = e.nextElement(); - if (o instanceof BaseSelector) { - ((BaseSelector) o).validate(); - } - } - } - - - /** - * Method that each selector will implement to create their selection - * behaviour. This is what makes SelectorContainer abstract. - * - * @param basedir the base directory the scan is being done from - * @param filename the name of the file to check - * @param file a java.io.File object for the filename that the selector - * can use - * @return whether the file should be selected or not - */ - public abstract boolean isSelected(File basedir, String filename, - File file); - - - /* Methods below all add specific selectors */ - - /** - * add a "Select" selector entry on the selector list - * @param selector the selector to add - */ - public void addSelector(SelectSelector selector) { - appendSelector(selector); - } - - /** - * add an "And" selector entry on the selector list - * @param selector the selector to add - */ - public void addAnd(AndSelector selector) { - appendSelector(selector); - } - - /** - * add an "Or" selector entry on the selector list - * @param selector the selector to add - */ - public void addOr(OrSelector selector) { - appendSelector(selector); - } - - /** - * add a "Not" selector entry on the selector list - * @param selector the selector to add - */ - public void addNot(NotSelector selector) { - appendSelector(selector); - } - - /** - * add a "None" selector entry on the selector list - * @param selector the selector to add - */ - public void addNone(NoneSelector selector) { - appendSelector(selector); - } - - /** - * add a majority selector entry on the selector list - * @param selector the selector to add - */ - public void addMajority(MajoritySelector selector) { - appendSelector(selector); - } - - /** - * add a selector date entry on the selector list - * @param selector the selector to add - */ - public void addDate(DateSelector selector) { - appendSelector(selector); - } - - /** - * add a selector size entry on the selector list - * @param selector the selector to add - */ - public void addSize(SizeSelector selector) { - appendSelector(selector); - } - - /** - * add a selector filename entry on the selector list - * @param selector the selector to add - */ - public void addFilename(FilenameSelector selector) { - appendSelector(selector); - } - - /** - * add an extended selector entry on the selector list - * @param selector the selector to add - */ - public void addCustom(ExtendSelector selector) { - appendSelector(selector); - } - - /** - * add a contains selector entry on the selector list - * @param selector the selector to add - */ - public void addContains(ContainsSelector selector) { - appendSelector(selector); - } - - /** - * add a present selector entry on the selector list - * @param selector the selector to add - */ - public void addPresent(PresentSelector selector) { - appendSelector(selector); - } - - /** - * add a depth selector entry on the selector list - * @param selector the selector to add - */ - public void addDepth(DepthSelector selector) { - appendSelector(selector); - } - - /** - * add a depends selector entry on the selector list - * @param selector the selector to add - */ - public void addDepend(DependSelector selector) { - appendSelector(selector); - } - - /** - * adds a different selector to the selector list - * @param selector the selector to add - */ - public void addDifferent(DifferentSelector selector) { - appendSelector(selector); - } - - /** - * adds a type selector to the selector list - * @param selector the selector to add - */ - public void addType(TypeSelector selector) { - appendSelector(selector); - } - - /** - * add a regular expression selector entry on the selector list - * @param selector the selector to add - */ - public void addContainsRegexp(ContainsRegexpSelector selector) { - appendSelector(selector); - } - - /** - * add the modified selector - * @param selector the selector to add - * @since ant 1.6 - */ - public void addModified(ModifiedSelector selector) { - appendSelector(selector); - } - - public void addReadable(ReadableSelector r) { - appendSelector(r); - } - - public void addWritable(WritableSelector w) { - appendSelector(w); - } - - /** - * add an arbitrary selector - * @param selector the selector to add - * @since Ant 1.6 - */ - public void add(FileSelector selector) { - appendSelector(selector); - } - - protected synchronized void dieOnCircularReference(Stack<Object> stk, Project p) - throws BuildException { - if (isChecked()) { - return; - } - if (isReference()) { - super.dieOnCircularReference(stk, p); - } else { - for (FileSelector fileSelector : selectorsList) { - if (fileSelector instanceof DataType) { - pushAndInvokeCircularReferenceCheck((DataType) fileSelector, stk, p); - } - } - setChecked(true); - } - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/ContainsRegexpSelector.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/ContainsRegexpSelector.java deleted file mode 100644 index 4da3b6ff..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/ContainsRegexpSelector.java +++ /dev/null @@ -1,219 +0,0 @@ -/* - * 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.selectors; - -import java.io.BufferedReader; -import java.io.File; -import java.io.IOException; -import java.io.InputStreamReader; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.types.Parameter; -import org.apache.tools.ant.types.RegularExpression; -import org.apache.tools.ant.types.Resource; -import org.apache.tools.ant.types.resources.FileResource; -import org.apache.tools.ant.types.resources.selectors.ResourceSelector; -import org.apache.tools.ant.util.regexp.Regexp; -import org.apache.tools.ant.util.regexp.RegexpUtil; - -/** - * Selector that filters files based on a regular expression. - * - * @since Ant 1.6 - */ -public class ContainsRegexpSelector extends BaseExtendSelector - implements ResourceSelector { - - private String userProvidedExpression = null; - private RegularExpression myRegExp = null; - private Regexp myExpression = null; - private boolean caseSensitive = true; - private boolean multiLine = false; - private boolean singleLine = false; - /** Key to used for parameterized custom selector */ - public static final String EXPRESSION_KEY = "expression"; - /** Parameter name for the casesensitive attribute. */ - private static final String CS_KEY = "casesensitive"; - /** Parameter name for the multiline attribute. */ - private static final String ML_KEY = "multiline"; - /** Parameter name for the singleline attribute. */ - private static final String SL_KEY = "singleline"; - - /** - * Creates a new <code>ContainsRegexpSelector</code> instance. - */ - public ContainsRegexpSelector() { - } - - /** - * @return a string describing this object - */ - public String toString() { - StringBuilder buf = new StringBuilder( - "{containsregexpselector expression: "); - buf.append(userProvidedExpression); - buf.append("}"); - return buf.toString(); - } - - /** - * The regular expression used to search the file. - * - * @param theexpression this must match a line in the file to be selected. - */ - public void setExpression(String theexpression) { - this.userProvidedExpression = theexpression; - } - - /** - * Whether to ignore case or not. - * @param b if false, ignore case. - * @since Ant 1.8.2 - */ - public void setCaseSensitive(boolean b) { - caseSensitive = b; - } - - /** - * Whether to match should be multiline. - * @param b the value to set. - * @since Ant 1.8.2 - */ - public void setMultiLine(boolean b) { - multiLine = b; - } - - /** - * Whether to treat input as singleline ('.' matches newline). - * Corresponds to java.util.regex.Pattern.DOTALL. - * @param b the value to set. - * @since Ant 1.8.2 - */ - public void setSingleLine(boolean b) { - singleLine = b; - } - - /** - * When using this as a custom selector, this method will be called. - * It translates each parameter into the appropriate setXXX() call. - * - * @param parameters the complete set of parameters for this selector - */ - public void setParameters(Parameter[] parameters) { - super.setParameters(parameters); - if (parameters != null) { - for (int i = 0; i < parameters.length; i++) { - String paramname = parameters[i].getName(); - if (EXPRESSION_KEY.equalsIgnoreCase(paramname)) { - setExpression(parameters[i].getValue()); - } else if (CS_KEY.equalsIgnoreCase(paramname)) { - setCaseSensitive(Project - .toBoolean(parameters[i].getValue())); - } else if (ML_KEY.equalsIgnoreCase(paramname)) { - setMultiLine(Project.toBoolean(parameters[i].getValue())); - } else if (SL_KEY.equalsIgnoreCase(paramname)) { - setSingleLine(Project.toBoolean(parameters[i].getValue())); - } else { - setError("Invalid parameter " + paramname); - } - } - } - } - - /** - * Checks that an expression was specified. - * - */ - public void verifySettings() { - if (userProvidedExpression == null) { - setError("The expression attribute is required"); - } - } - - /** - * Tests a regular expression against each line of text in the file. - * - * @param basedir the base directory the scan is being done from - * @param filename is the name of the file to check - * @param file is a java.io.File object the selector can use - * @return whether the file should be selected or not - */ - public boolean isSelected(File basedir, String filename, File file) { - return isSelected(new FileResource(file)); - } - - /** - * Tests a regular expression against each line of text in a Resource. - * - * @param r the Resource to check. - * @return whether the Resource is selected or not - */ - public boolean isSelected(Resource r) { - String teststr = null; - BufferedReader in = null; - - // throw BuildException on error - - validate(); - - if (r.isDirectory()) { - return true; - } - - if (myRegExp == null) { - myRegExp = new RegularExpression(); - myRegExp.setPattern(userProvidedExpression); - myExpression = myRegExp.getRegexp(getProject()); - } - - try { - in = new BufferedReader(new InputStreamReader(r.getInputStream())); - } catch (Exception e) { - throw new BuildException("Could not get InputStream from " - + r.toLongString(), e); - } - try { - teststr = in.readLine(); - - while (teststr != null) { - - if (myExpression.matches(teststr, - RegexpUtil.asOptions(caseSensitive, - multiLine, - singleLine))) { - return true; - } - teststr = in.readLine(); - } - - return false; - } catch (IOException ioe) { - throw new BuildException("Could not read " + r.toLongString()); - } finally { - try { - in.close(); - } catch (Exception e) { - throw new BuildException("Could not close " - + r.toLongString()); - } - } - } -} - diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/ContainsSelector.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/ContainsSelector.java deleted file mode 100644 index 6dabaf4c..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/ContainsSelector.java +++ /dev/null @@ -1,221 +0,0 @@ -/* - * 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.selectors; - -import java.io.BufferedReader; -import java.io.File; -import java.io.IOException; -import java.io.InputStreamReader; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.types.Parameter; -import org.apache.tools.ant.types.Resource; -import org.apache.tools.ant.types.resources.FileResource; -import org.apache.tools.ant.types.resources.selectors.ResourceSelector; -import org.apache.tools.ant.util.FileUtils; - -/** - * Selector that filters files/resources based on whether they contain a - * particular string. - * - * @since 1.5 - */ -public class ContainsSelector extends BaseExtendSelector implements ResourceSelector { - - private String contains = null; - private boolean casesensitive = true; - private boolean ignorewhitespace = false; - private String encoding = null; - /** Key to used for parameterized custom selector */ - public static final String EXPRESSION_KEY = "expression"; - /** Used for parameterized custom selector */ - public static final String CONTAINS_KEY = "text"; - /** Used for parameterized custom selector */ - public static final String CASE_KEY = "casesensitive"; - /** Used for parameterized custom selector */ - public static final String WHITESPACE_KEY = "ignorewhitespace"; - - - /** - * Creates a new <code>ContainsSelector</code> instance. - * - */ - public ContainsSelector() { - } - - /** - * @return a string describing this object - */ - public String toString() { - StringBuilder buf = new StringBuilder("{containsselector text: "); - buf.append('"').append(contains).append('"'); - buf.append(" casesensitive: "); - buf.append(casesensitive ? "true" : "false"); - buf.append(" ignorewhitespace: "); - buf.append(ignorewhitespace ? "true" : "false"); - buf.append("}"); - return buf.toString(); - } - - /** - * The string to search for within a file. - * - * @param contains the string that a file must contain to be selected. - */ - public void setText(String contains) { - this.contains = contains; - } - - /** - * The encoding of the resources processed - * @since Ant 1.9.0 - * @param encoding encoding of the resources processed - */ - public void setEncoding(String encoding) { - this.encoding = encoding; - } - - /** - * Whether to ignore case in the string being searched. - * - * @param casesensitive whether to pay attention to case sensitivity - */ - public void setCasesensitive(boolean casesensitive) { - this.casesensitive = casesensitive; - } - - /** - * Whether to ignore whitespace in the string being searched. - * - * @param ignorewhitespace whether to ignore any whitespace - * (spaces, tabs, etc.) in the searchstring - */ - public void setIgnorewhitespace(boolean ignorewhitespace) { - this.ignorewhitespace = ignorewhitespace; - } - - /** - * When using this as a custom selector, this method will be called. - * It translates each parameter into the appropriate setXXX() call. - * - * @param parameters the complete set of parameters for this selector - */ - public void setParameters(Parameter[] parameters) { - super.setParameters(parameters); - if (parameters != null) { - for (int i = 0; i < parameters.length; i++) { - String paramname = parameters[i].getName(); - if (CONTAINS_KEY.equalsIgnoreCase(paramname)) { - setText(parameters[i].getValue()); - } else if (CASE_KEY.equalsIgnoreCase(paramname)) { - setCasesensitive(Project.toBoolean( - parameters[i].getValue())); - } else if (WHITESPACE_KEY.equalsIgnoreCase(paramname)) { - setIgnorewhitespace(Project.toBoolean( - parameters[i].getValue())); - } else { - setError("Invalid parameter " + paramname); - } - } - } - } - - /** - * Checks to make sure all settings are kosher. In this case, it - * means that the pattern attribute has been set. - * - */ - public void verifySettings() { - if (contains == null) { - setError("The text attribute is required"); - } - } - - /** - * The heart of the matter. This is where the selector gets to decide - * on the inclusion of a file in a particular fileset. - * - * @param basedir the base directory the scan is being done from - * @param filename is the name of the file to check - * @param file is a java.io.File object the selector can use - * @return whether the file should be selected or not - */ - public boolean isSelected(File basedir, String filename, File file) { - return isSelected(new FileResource(file)); - } - - /** - * The heart of the matter. This is where the selector gets to decide - * on the inclusion of a Resource. - * - * @param r the Resource to check. - * @return whether the Resource is selected. - */ - public boolean isSelected(Resource r) { - - // throw BuildException on error - validate(); - - if (r.isDirectory() || contains.length() == 0) { - return true; - } - - String userstr = contains; - if (!casesensitive) { - userstr = contains.toLowerCase(); - } - if (ignorewhitespace) { - userstr = SelectorUtils.removeWhitespace(userstr); - } - BufferedReader in = null; - try { - if (encoding != null) { - in = new BufferedReader(new InputStreamReader(r.getInputStream(), encoding)); - } else { - in = new BufferedReader(new InputStreamReader(r.getInputStream())); - } - } catch (Exception e) { - throw new BuildException("Could not get InputStream from " - + r.toLongString(), e); - } - try { - String teststr = in.readLine(); - while (teststr != null) { - if (!casesensitive) { - teststr = teststr.toLowerCase(); - } - if (ignorewhitespace) { - teststr = SelectorUtils.removeWhitespace(teststr); - } - if (teststr.indexOf(userstr) > -1) { - return true; - } - teststr = in.readLine(); - } - return false; - } catch (IOException ioe) { - throw new BuildException("Could not read " + r.toLongString()); - } finally { - FileUtils.close(in); - } - } - -} - diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/DateSelector.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/DateSelector.java deleted file mode 100644 index aea94a8b..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/DateSelector.java +++ /dev/null @@ -1,260 +0,0 @@ -/* - * 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.selectors; - -import java.io.File; -import java.text.DateFormat; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Locale; - -import org.apache.tools.ant.Project; -import org.apache.tools.ant.types.Parameter; -import org.apache.tools.ant.types.TimeComparison; -import org.apache.tools.ant.util.FileUtils; - -/** - * Selector that chooses files based on their last modified date. - * - * @since 1.5 - */ -public class DateSelector extends BaseExtendSelector { - - /** Utilities used for file operations */ - private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); - - private long millis = -1; - private String dateTime = null; - private boolean includeDirs = false; - private long granularity = 0; - private String pattern; - private TimeComparison when = TimeComparison.EQUAL; - - /** Key to used for parameterized custom selector */ - public static final String MILLIS_KEY = "millis"; - /** Key to used for parameterized custom selector */ - public static final String DATETIME_KEY = "datetime"; - /** Key to used for parameterized custom selector */ - public static final String CHECKDIRS_KEY = "checkdirs"; - /** Key to used for parameterized custom selector */ - public static final String GRANULARITY_KEY = "granularity"; - /** Key to used for parameterized custom selector */ - public static final String WHEN_KEY = "when"; - /** Key to used for parameterized custom selector */ - public static final String PATTERN_KEY = "pattern"; - - /** - * Creates a new <code>DateSelector</code> instance. - * - */ - public DateSelector() { - granularity = FILE_UTILS.getFileTimestampGranularity(); - } - - /** - * @return a string describing this object - */ - public String toString() { - StringBuilder buf = new StringBuilder("{dateselector date: "); - buf.append(dateTime); - buf.append(" compare: ").append(when.getValue()); - buf.append(" granularity: "); - buf.append(granularity); - if (pattern != null) { - buf.append(" pattern: ").append(pattern); - } - buf.append("}"); - return buf.toString(); - } - - /** - * Set the time; for users who prefer to express time in ms since 1970. - * - * @param millis the time to compare file's last modified date to, - * expressed in milliseconds. - */ - public void setMillis(long millis) { - this.millis = millis; - } - - /** - * Returns the millisecond value the selector is set for. - * @return the millisecond value. - */ - public long getMillis() { - if (dateTime != null) { - validate(); - } - return millis; - } - - /** - * Sets the date. The user must supply it in MM/DD/YYYY HH:MM AM_PM format, - * unless an alternate pattern is specified via the pattern attribute. - * - * @param dateTime a formatted date <code>String</code>. - */ - public void setDatetime(String dateTime) { - this.dateTime = dateTime; - millis = -1; - } - - /** - * Set whether to check dates on directories. - * - * @param includeDirs whether to check the timestamp on directories. - */ - public void setCheckdirs(boolean includeDirs) { - this.includeDirs = includeDirs; - } - - /** - * Sets the number of milliseconds leeway we will give before we consider - * a file not to have matched a date. - * @param granularity the number of milliseconds leeway. - */ - public void setGranularity(int granularity) { - this.granularity = granularity; - } - - /** - * Sets the type of comparison to be done on the file's last modified - * date. - * - * @param tcmp The comparison to perform, an EnumeratedAttribute. - */ - public void setWhen(TimeComparisons tcmp) { - setWhen((TimeComparison) tcmp); - } - - /** - * Set the comparison type. - * @param t TimeComparison object. - */ - public void setWhen(TimeComparison t) { - when = t; - } - - /** - * Sets the pattern to be used for the SimpleDateFormat. - * - * @param pattern the pattern that defines the date format. - */ - public void setPattern(String pattern) { - this.pattern = pattern; - } - - /** - * When using this as a custom selector, this method will be called. - * It translates each parameter into the appropriate setXXX() call. - * - * @param parameters the complete set of parameters for this selector. - */ - public void setParameters(Parameter[] parameters) { - super.setParameters(parameters); - if (parameters != null) { - for (int i = 0; i < parameters.length; i++) { - String paramname = parameters[i].getName(); - if (MILLIS_KEY.equalsIgnoreCase(paramname)) { - try { - setMillis(Long.parseLong(parameters[i].getValue())); - } catch (NumberFormatException nfe) { - setError("Invalid millisecond setting " - + parameters[i].getValue()); - } - } else if (DATETIME_KEY.equalsIgnoreCase(paramname)) { - setDatetime(parameters[i].getValue()); - } else if (CHECKDIRS_KEY.equalsIgnoreCase(paramname)) { - setCheckdirs(Project.toBoolean(parameters[i].getValue())); - } else if (GRANULARITY_KEY.equalsIgnoreCase(paramname)) { - try { - setGranularity(Integer.parseInt(parameters[i].getValue())); - } catch (NumberFormatException nfe) { - setError("Invalid granularity setting " - + parameters[i].getValue()); - } - } else if (WHEN_KEY.equalsIgnoreCase(paramname)) { - setWhen(new TimeComparison(parameters[i].getValue())); - } else if (PATTERN_KEY.equalsIgnoreCase(paramname)) { - setPattern(parameters[i].getValue()); - } else { - setError("Invalid parameter " + paramname); - } - } - } - } - - /** - * This is a consistency check to ensure the selector's required - * values have been set. - */ - public void verifySettings() { - if (dateTime == null && millis < 0) { - setError("You must provide a datetime or the number of " - + "milliseconds."); - } else if (millis < 0 && dateTime != null) { - // check millis and only set it once. - DateFormat df = ((pattern == null) - ? DateFormat.getDateTimeInstance( - DateFormat.SHORT, DateFormat.SHORT, Locale.US) - : new SimpleDateFormat(pattern)); - - try { - setMillis(df.parse(dateTime).getTime()); - if (millis < 0) { - setError("Date of " + dateTime - + " results in negative milliseconds value" - + " relative to epoch (January 1, 1970, 00:00:00 GMT)."); - } - } catch (ParseException pe) { - setError("Date of " + dateTime - + " Cannot be parsed correctly. It should be in" - + ((pattern == null) - ? " MM/DD/YYYY HH:MM AM_PM" : pattern) + " format."); - } - } - } - - /** - * The heart of the matter. This is where the selector gets to decide - * on the inclusion of a file in a particular fileset. - * - * @param basedir the base directory from which the scan is being performed. - * @param filename is the name of the file to check. - * @param file is a java.io.File object the selector can use. - * @return whether the file is selected. - */ - public boolean isSelected(File basedir, String filename, File file) { - - validate(); - - return (file.isDirectory() && !includeDirs) - || when.evaluate(file.lastModified(), millis, granularity); - } - - /** - * Enumerated attribute with the values for time comparison. - * <p> - */ - public static class TimeComparisons extends TimeComparison { - } - -} - - diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/DependSelector.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/DependSelector.java deleted file mode 100644 index 01ac2379..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/DependSelector.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * 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.selectors; - -import java.io.File; - -/** - * Selector that filters files based on whether they are newer than - * a matching file in another directory tree. It can contain a mapper - * element, so isn't available as an ExtendSelector (since those - * parameters can't hold other elements). - * - * @since 1.5 - */ -public class DependSelector extends MappingSelector { - - /** - * Creates a new <code>DependSelector</code> instance. - * - */ - public DependSelector() { - - } - - /** - * @return a string describing this object - */ - public String toString() { - StringBuilder buf = new StringBuilder("{dependselector targetdir: "); - if (targetdir == null) { - buf.append("NOT YET SET"); - } else { - buf.append(targetdir.getName()); - } - buf.append(" granularity: "); - buf.append(granularity); - if (map != null) { - buf.append(" mapper: "); - buf.append(map.toString()); - } else if (mapperElement != null) { - buf.append(" mapper: "); - buf.append(mapperElement.toString()); - } - buf.append("}"); - return buf.toString(); - } - - - /** - * this test is our selection test that compared the file with the destfile - * @param srcfile the source file - * @param destfile the destination file - * @return true if destination is out of date - */ - public boolean selectionTest(File srcfile, File destfile) { - boolean selected = SelectorUtils.isOutOfDate(srcfile, destfile, - granularity); - return selected; - } - -} - diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/DepthSelector.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/DepthSelector.java deleted file mode 100644 index a80f9aa9..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/DepthSelector.java +++ /dev/null @@ -1,185 +0,0 @@ -/* - * 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.selectors; - -import java.io.File; -import java.util.StringTokenizer; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.types.Parameter; - -/** - * Selector that filters files based on the how deep in the directory - * tree they are. - * - * @since 1.5 - */ -public class DepthSelector extends BaseExtendSelector { - - // CheckStyle:VisibilityModifier OFF - bc - - /** min attribute */ - public int min = -1; - /** max attribute */ - public int max = -1; - - // CheckStyle:VisibilityModifier ON - - /** Used for parameterized custom selector */ - public static final String MIN_KEY = "min"; - /** Used for parameterized custom selector */ - public static final String MAX_KEY = "max"; - - /** - * Creates a new <code>DepthSelector</code> instance. - * - */ - public DepthSelector() { - } - - /** - * @return a string describing this object - */ - public String toString() { - StringBuilder buf = new StringBuilder("{depthselector min: "); - buf.append(min); - buf.append(" max: "); - buf.append(max); - buf.append("}"); - return buf.toString(); - } - - /** - * The minimum depth below the basedir before a file is selected. - * - * @param min minimum directory levels below basedir to go - */ - public void setMin(int min) { - this.min = min; - } - - /** - * The minimum depth below the basedir before a file is selected. - * - * @param max maximum directory levels below basedir to go - */ - public void setMax(int max) { - this.max = max; - } - - /** - * When using this as a custom selector, this method will be called. - * It translates each parameter into the appropriate setXXX() call. - * - * @param parameters the complete set of parameters for this selector - */ - public void setParameters(Parameter[] parameters) { - super.setParameters(parameters); - if (parameters != null) { - for (int i = 0; i < parameters.length; i++) { - String paramname = parameters[i].getName(); - if (MIN_KEY.equalsIgnoreCase(paramname)) { - try { - setMin(Integer.parseInt(parameters[i].getValue())); - } catch (NumberFormatException nfe1) { - setError("Invalid minimum value " - + parameters[i].getValue()); - } - } else if (MAX_KEY.equalsIgnoreCase(paramname)) { - try { - setMax(Integer.parseInt(parameters[i].getValue())); - } catch (NumberFormatException nfe1) { - setError("Invalid maximum value " - + parameters[i].getValue()); - } - } else { - setError("Invalid parameter " + paramname); - } - } - } - } - - /** - * Checks to make sure all settings are kosher. In this case, it - * means that the max depth is not lower than the min depth. - */ - public void verifySettings() { - if (min < 0 && max < 0) { - setError("You must set at least one of the min or the " - + "max levels."); - } - if (max < min && max > -1) { - setError("The maximum depth is lower than the minimum."); - } - } - - /** - * The heart of the matter. This is where the selector gets to decide - * on the inclusion of a file in a particular fileset. Most of the work - * for this selector is offloaded into SelectorUtils, a static class - * that provides the same services for both FilenameSelector and - * DirectoryScanner. - * - * @param basedir the base directory the scan is being done from - * @param filename is the name of the file to check - * @param file is a java.io.File object the selector can use - * @return whether the file should be selected or not - */ - public boolean isSelected(File basedir, String filename, File file) { - - // throw BuildException on error - validate(); - - int depth = -1; - // If you felt daring, you could cache the basedir absolute path - String absBase = basedir.getAbsolutePath(); - String absFile = file.getAbsolutePath(); - StringTokenizer tokBase = new StringTokenizer(absBase, - File.separator); - StringTokenizer tokFile = new StringTokenizer(absFile, - File.separator); - while (tokFile.hasMoreTokens()) { - String filetoken = tokFile.nextToken(); - if (tokBase.hasMoreTokens()) { - String basetoken = tokBase.nextToken(); - // Sanity check. Ditch it if you want faster performance - if (!basetoken.equals(filetoken)) { - throw new BuildException("File " + filename - + " does not appear within " + absBase - + "directory"); - } - } else { - depth += 1; - if (max > -1 && depth > max) { - return false; - } - } - } - if (tokBase.hasMoreTokens()) { - throw new BuildException("File " + filename - + " is outside of " + absBase + "directory tree"); - } - if (min > -1 && depth < min) { - return false; - } - return true; - } - -} - diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/DifferentSelector.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/DifferentSelector.java deleted file mode 100644 index c701fb84..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/DifferentSelector.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * 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.selectors; - -import java.io.File; -import java.io.IOException; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.util.FileUtils; - -/** - * This selector selects files against a mapped set of target files, selecting - * all those files which are different. - * Files with different lengths are deemed different - * automatically - * Files with identical timestamps are viewed as matching by - * default, unless you specify otherwise. - * Contents are compared if the lengths are the same - * and the timestamps are ignored or the same, - * except if you decide to ignore contents to gain speed. - * <p> - * This is a useful selector to work with programs and tasks that don't handle - * dependency checking properly; Even if a predecessor task always creates its - * output files, followup tasks can be driven off copies made with a different - * selector, so their dependencies are driven on the absolute state of the - * files, not a timestamp. - * <p> - * Clearly, however, bulk file comparisons is inefficient; anything that can - * use timestamps is to be preferred. If this selector must be used, use it - * over as few files as possible, perhaps following it with an <uptodate;> - * to keep the descendant routines conditional. - * - */ -public class DifferentSelector extends MappingSelector { - - private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); - - private boolean ignoreFileTimes = true; - private boolean ignoreContents = false; - - - /** - * This flag tells the selector to ignore file times in the comparison - * @param ignoreFileTimes if true ignore file times - */ - public void setIgnoreFileTimes(boolean ignoreFileTimes) { - this.ignoreFileTimes = ignoreFileTimes; - } - /** - * This flag tells the selector to ignore contents - * @param ignoreContents if true ignore contents - * @since ant 1.6.3 - */ - public void setIgnoreContents(boolean ignoreContents) { - this.ignoreContents = ignoreContents; - } - /** - * this test is our selection test that compared the file with the destfile - * @param srcfile the source file - * @param destfile the destination file - * @return true if the files are different - */ - protected boolean selectionTest(File srcfile, File destfile) { - - //if either of them is missing, they are different - if (srcfile.exists() != destfile.exists()) { - return true; - } - - if (srcfile.length() != destfile.length()) { - // different size =>different files - return true; - } - - if (!ignoreFileTimes) { - //same date if dest timestamp is within granularity of the srcfile - boolean sameDate; - sameDate = destfile.lastModified() >= srcfile.lastModified() - granularity - && destfile.lastModified() <= srcfile.lastModified() + granularity; - - // different dates => different files - if (!sameDate) { - return true; - } - } - if (!ignoreContents) { - //here do a bulk comparison - try { - return !FILE_UTILS.contentEquals(srcfile, destfile); - } catch (IOException e) { - throw new BuildException("while comparing " + srcfile + " and " - + destfile, e); - } - } else { - return false; - } - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/ExtendFileSelector.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/ExtendFileSelector.java deleted file mode 100644 index fe974065..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/ExtendFileSelector.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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.selectors; - -import org.apache.tools.ant.types.Parameterizable; - -/** - * This is the interface to be used by all custom selectors, those that are - * called through the <custom> tag. It is the amalgamation of two - * interfaces, the FileSelector and the Parameterizable interface. Note that - * you will almost certainly want the default behaviour for handling - * Parameters, so you probably want to use the BaseExtendSelector class - * as the base class for your custom selector rather than implementing - * this interface from scratch. - * - * @since 1.5 - */ -public interface ExtendFileSelector extends FileSelector, Parameterizable { - - // No further methods necessary. This is just an amalgamation of two other - // interfaces. -} - diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/ExtendSelector.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/ExtendSelector.java deleted file mode 100644 index af8c920f..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/ExtendSelector.java +++ /dev/null @@ -1,201 +0,0 @@ -/* - * 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.selectors; - -import java.io.File; -import java.util.Vector; - -import org.apache.tools.ant.AntClassLoader; -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.types.Parameter; -import org.apache.tools.ant.types.Path; -import org.apache.tools.ant.types.Reference; - -/** - * Selector that selects files by forwarding the request on to other classes. - * - * @since 1.5 - */ -public class ExtendSelector extends BaseSelector { - - private String classname = null; - private FileSelector dynselector = null; - private Vector<Parameter> paramVec = new Vector<Parameter>(); - private Path classpath = null; - - /** - * Default constructor. - */ - public ExtendSelector() { - } - - /** - * Sets the classname of the custom selector. - * - * @param classname is the class which implements this selector - */ - public void setClassname(String classname) { - this.classname = classname; - } - - /** - * Instantiates the identified custom selector class. - */ - public void selectorCreate() { - if (classname != null && classname.length() > 0) { - try { - Class<?> c = null; - if (classpath == null) { - c = Class.forName(classname); - } else { - // Memory-Leak in line below - AntClassLoader al - = getProject().createClassLoader(classpath); - c = Class.forName(classname, true, al); - } - dynselector = c.asSubclass(FileSelector.class).newInstance(); - final Project p = getProject(); - if (p != null) { - p.setProjectReference(dynselector); - } - } catch (ClassNotFoundException cnfexcept) { - setError("Selector " + classname - + " not initialized, no such class"); - } catch (InstantiationException iexcept) { - setError("Selector " + classname - + " not initialized, could not create class"); - } catch (IllegalAccessException iaexcept) { - setError("Selector " + classname - + " not initialized, class not accessible"); - } - } else { - setError("There is no classname specified"); - } - } - - /** - * Create new parameters to pass to custom selector. - * - * @param p The new Parameter object - */ - public void addParam(Parameter p) { - paramVec.addElement(p); - } - - - /** - * Set the classpath to load the classname specified using an attribute. - * @param classpath the classpath to use - */ - public final void setClasspath(Path classpath) { - if (isReference()) { - throw tooManyAttributes(); - } - if (this.classpath == null) { - this.classpath = classpath; - } else { - this.classpath.append(classpath); - } - } - - /** - * Specify the classpath to use to load the Selector (nested element). - * @return a classpath to be configured - */ - public final Path createClasspath() { - if (isReference()) { - throw noChildrenAllowed(); - } - if (this.classpath == null) { - this.classpath = new Path(getProject()); - } - return this.classpath.createPath(); - } - - /** - * Get the classpath - * @return the classpath - */ - public final Path getClasspath() { - return classpath; - } - - /** - * Set the classpath to use for loading a custom selector by using - * a reference. - * @param r a reference to the classpath - */ - public void setClasspathref(Reference r) { - if (isReference()) { - throw tooManyAttributes(); - } - createClasspath().setRefid(r); - } - - /** - * These are errors specific to ExtendSelector only. If there are - * errors in the custom selector, it should throw a BuildException - * when isSelected() is called. - */ - public void verifySettings() { - // Creation is done here rather than in isSelected() because some - // containers may do a validation pass before running isSelected(), - // but we need to check for the existence of the created class. - if (dynselector == null) { - selectorCreate(); - } - if (classname == null || classname.length() < 1) { - setError("The classname attribute is required"); - } else if (dynselector == null) { - setError("Internal Error: The custom selector was not created"); - } else if (!(dynselector instanceof ExtendFileSelector) - && (paramVec.size() > 0)) { - setError("Cannot set parameters on custom selector that does not " - + "implement ExtendFileSelector"); - } - } - - - /** - * Allows the custom selector to choose whether to select a file. This - * is also where the Parameters are passed to the custom selector, - * since we know we must have them all by now. And since we must know - * both classpath and classname, creating the class is deferred to here - * as well. - * @param basedir The the base directory. - * @param filename The name of the file to check. - * @param file A File object for this filename. - * @return whether the file should be selected or not. - * @exception BuildException if an error occurs. - */ - public boolean isSelected(File basedir, String filename, File file) - throws BuildException { - validate(); - if (paramVec.size() > 0 && dynselector instanceof ExtendFileSelector) { - Parameter[] paramArray = new Parameter[paramVec.size()]; - paramVec.copyInto(paramArray); - // We know that dynselector must be non-null if no error message - ((ExtendFileSelector) dynselector).setParameters(paramArray); - } - return dynselector.isSelected(basedir, filename, file); - } - -} - diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/FileSelector.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/FileSelector.java deleted file mode 100644 index 614a9706..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/FileSelector.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * 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.selectors; - -import java.io.File; - -import org.apache.tools.ant.BuildException; - -/** - * This is the interface to be used by all selectors. - * - * @since 1.5 - */ -public interface FileSelector { - - /** - * Method that each selector will implement to create their - * selection behaviour. If there is a problem with the setup - * of a selector, it can throw a BuildException to indicate - * the problem. - * - * @param basedir A java.io.File object for the base directory - * @param filename The name of the file to check - * @param file A File object for this filename - * @return whether the file should be selected or not - * @exception BuildException if the selector was not configured correctly - */ - boolean isSelected(File basedir, String filename, File file) - throws BuildException; - -} - diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/FilenameSelector.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/FilenameSelector.java deleted file mode 100644 index 1b998f9f..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/FilenameSelector.java +++ /dev/null @@ -1,195 +0,0 @@ -/* - * 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.selectors; - -import java.io.File; - -import org.apache.tools.ant.Project; -import org.apache.tools.ant.types.Parameter; -import org.apache.tools.ant.types.RegularExpression; -import org.apache.tools.ant.util.regexp.Regexp; -import org.apache.tools.ant.util.regexp.RegexpUtil; - -/** - * Selector that filters files based on the filename. - * - * @since 1.5 - */ -public class FilenameSelector extends BaseExtendSelector { - - private String pattern = null; - private String regex = null; - private boolean casesensitive = true; - - private boolean negated = false; - /** Used for parameterized custom selector */ - public static final String NAME_KEY = "name"; - /** Used for parameterized custom selector */ - public static final String CASE_KEY = "casesensitive"; - /** Used for parameterized custom selector */ - public static final String NEGATE_KEY = "negate"; - /** Used for parameterized custom selector */ - public static final String REGEX_KEY = "regex"; - - // caches for performance reasons - private RegularExpression reg; - private Regexp expression; - - /** - * Creates a new <code>FilenameSelector</code> instance. - * - */ - public FilenameSelector() { - } - - /** - * @return a string describing this object - */ - public String toString() { - StringBuilder buf = new StringBuilder("{filenameselector name: "); - if (pattern != null) { - buf.append(pattern); - } - if (regex != null) { - buf.append(regex).append(" [as regular expression]"); - } - buf.append(" negate: ").append(negated); - buf.append(" casesensitive: ").append(casesensitive); - buf.append("}"); - return buf.toString(); - } - - /** - * The name of the file, or the pattern for the name, that - * should be used for selection. - * - * @param pattern the file pattern that any filename must match - * against in order to be selected. - */ - public void setName(String pattern) { - pattern = pattern.replace('/', File.separatorChar).replace('\\', - File.separatorChar); - if (pattern.endsWith(File.separator)) { - pattern += "**"; - } - this.pattern = pattern; - } - - /** - * The regular expression the file name will be matched against. - * - * @param pattern the regular expression that any filename must match - * against in order to be selected. - */ - public void setRegex(String pattern) { - this.regex = pattern; - this.reg = null; - } - - /** - * Whether to ignore case when checking filenames. - * - * @param casesensitive whether to pay attention to case sensitivity - */ - public void setCasesensitive(boolean casesensitive) { - this.casesensitive = casesensitive; - } - - /** - * You can optionally reverse the selection of this selector, - * thereby emulating an <exclude> tag, by setting the attribute - * negate to true. This is identical to surrounding the selector - * with <not></not>. - * - * @param negated whether to negate this selection - */ - public void setNegate(boolean negated) { - this.negated = negated; - } - - /** - * When using this as a custom selector, this method will be called. - * It translates each parameter into the appropriate setXXX() call. - * - * @param parameters the complete set of parameters for this selector - */ - public void setParameters(Parameter[] parameters) { - super.setParameters(parameters); - if (parameters != null) { - for (int i = 0; i < parameters.length; i++) { - String paramname = parameters[i].getName(); - if (NAME_KEY.equalsIgnoreCase(paramname)) { - setName(parameters[i].getValue()); - } else if (CASE_KEY.equalsIgnoreCase(paramname)) { - setCasesensitive(Project.toBoolean( - parameters[i].getValue())); - } else if (NEGATE_KEY.equalsIgnoreCase(paramname)) { - setNegate(Project.toBoolean(parameters[i].getValue())); - } else if (REGEX_KEY.equalsIgnoreCase(paramname)) { - setRegex(parameters[i].getValue()); - } else { - setError("Invalid parameter " + paramname); - } - } - } - } - - /** - * Checks to make sure all settings are kosher. In this case, it - * means that the name attribute has been set. - * - */ - public void verifySettings() { - if (pattern == null && regex == null) { - setError("The name or regex attribute is required"); - } else if (pattern != null && regex != null) { - setError("Only one of name and regex attribute is allowed"); - } - } - - /** - * The heart of the matter. This is where the selector gets to decide - * on the inclusion of a file in a particular fileset. Most of the work - * for this selector is offloaded into SelectorUtils, a static class - * that provides the same services for both FilenameSelector and - * DirectoryScanner. - * - * @param basedir the base directory the scan is being done from - * @param filename is the name of the file to check - * @param file is a java.io.File object the selector can use - * @return whether the file should be selected or not - */ - public boolean isSelected(File basedir, String filename, File file) { - validate(); - if (pattern != null) { - return (SelectorUtils.matchPath(pattern, filename, - casesensitive) == !(negated)); - } else { - if (reg == null) { - reg = new RegularExpression(); - reg.setPattern(regex); - expression = reg.getRegexp(getProject()); - } - int options = RegexpUtil.asOptions(casesensitive); - return expression.matches(filename, options) == !negated; - } - } - -} - diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/MajoritySelector.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/MajoritySelector.java deleted file mode 100644 index 842258fb..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/MajoritySelector.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * 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.selectors; - -import java.io.File; -import java.util.Enumeration; - -/** - * This selector is here just to shake up your thinking a bit. Don't get - * too caught up in boolean, there are other ways you can evaluate a - * collection of selectors. This one takes a vote of the selectors it - * contains, and majority wins. You could also have an "all-but-one" - * selector, a "weighted-average" selector, and so on. These are left - * as exercises for the reader (as are the usecases where this would - * be necessary). - * - * @since 1.5 - */ -public class MajoritySelector extends BaseSelectorContainer { - - private boolean allowtie = true; - - /** - * Default constructor. - */ - public MajoritySelector() { - } - - /** - * @return a string describing this object - */ - public String toString() { - StringBuilder buf = new StringBuilder(); - if (hasSelectors()) { - buf.append("{majorityselect: "); - buf.append(super.toString()); - buf.append("}"); - } - return buf.toString(); - } - - /** - * A attribute to specify what will happen if number - * of yes votes is the same as the number of no votes - * defaults to true - * - * @param tiebreaker the value to give if there is a tie - */ - public void setAllowtie(boolean tiebreaker) { - allowtie = tiebreaker; - } - - /** - * Returns true (the file is selected) if most of the other selectors - * agree. In case of a tie, go by the allowtie setting. That defaults - * to true, meaning in case of a tie, the file is selected. - * - * @param basedir the base directory the scan is being done from - * @param filename is the name of the file to check - * @param file is a java.io.File object for the filename that the selector - * can use - * @return whether the file should be selected or not - */ - public boolean isSelected(File basedir, String filename, File file) { - validate(); - int yesvotes = 0; - int novotes = 0; - Enumeration<FileSelector> e = selectorElements(); - - while (e.hasMoreElements()) { - if (e.nextElement().isSelected(basedir, - filename, file)) { - yesvotes++; - } else { - novotes++; - } - } - if (yesvotes > novotes) { - return true; - } else if (novotes > yesvotes) { - return false; - } - // At this point, we know we have a tie. - return allowtie; - } -} - diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/MappingSelector.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/MappingSelector.java deleted file mode 100644 index 1a274949..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/MappingSelector.java +++ /dev/null @@ -1,165 +0,0 @@ -/* - * 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.selectors; - -import java.io.File; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.types.Mapper; -import org.apache.tools.ant.util.FileNameMapper; -import org.apache.tools.ant.util.FileUtils; -import org.apache.tools.ant.util.IdentityMapper; - -/** - * A mapping selector is an abstract class adding mapping support to the base - * selector - */ -public abstract class MappingSelector extends BaseSelector { - - /** Utilities used for file operations */ - private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); - - // CheckStyle:VisibilityModifier OFF - bc - - protected File targetdir = null; - protected Mapper mapperElement = null; - protected FileNameMapper map = null; - protected int granularity = 0; - - // CheckStyle:VisibilityModifier ON - - /** - * Creates a new <code>MappingSelector</code> instance. - * - */ - public MappingSelector() { - granularity = (int) FILE_UTILS.getFileTimestampGranularity(); - } - - - /** - * The name of the file or directory which is checked for out-of-date - * files. - * - * @param targetdir the directory to scan looking for files. - */ - public void setTargetdir(File targetdir) { - this.targetdir = targetdir; - } - - /** - * Defines the FileNameMapper to use (nested mapper element). - * @return a mapper to be configured - * @throws BuildException if more than one mapper defined - */ - public Mapper createMapper() throws BuildException { - if (map != null || mapperElement != null) { - throw new BuildException("Cannot define more than one mapper"); - } - mapperElement = new Mapper(getProject()); - return mapperElement; - } - - /** - * Add a configured FileNameMapper instance. - * @param fileNameMapper the FileNameMapper to add - * @throws BuildException if more than one mapper defined - * @since Ant 1.8.0 - */ - public void addConfigured(FileNameMapper fileNameMapper) { - if (map != null || mapperElement != null) { - throw new BuildException("Cannot define more than one mapper"); - } - this.map = fileNameMapper; - } - - /** - * Checks to make sure all settings are kosher. In this case, it - * means that the dest attribute has been set and we have a mapper. - */ - @Override - public void verifySettings() { - if (targetdir == null) { - setError("The targetdir attribute is required."); - } - if (map == null) { - if (mapperElement == null) { - map = new IdentityMapper(); - } else { - map = mapperElement.getImplementation(); - if (map == null) { - setError("Could not set <mapper> element."); - } - } - } - } - - /** - * The heart of the matter. This is where the selector gets to decide - * on the inclusion of a file in a particular fileset. - * - * @param basedir the base directory the scan is being done from - * @param filename is the name of the file to check - * @param file is a java.io.File object the selector can use - * @return whether the file should be selected or not - */ - @Override - public boolean isSelected(File basedir, String filename, File file) { - - // throw BuildException on error - validate(); - - // Determine file whose out-of-dateness is to be checked - String[] destfiles = map.mapFileName(filename); - // If filename does not match the To attribute of the mapper - // then filter it out of the files we are considering - if (destfiles == null) { - return false; - } - // Sanity check - if (destfiles.length != 1 || destfiles[0] == null) { - throw new BuildException("Invalid destination file results for " - + targetdir.getName() + " with filename " + filename); - } - String destname = destfiles[0]; - File destfile = FILE_UTILS.resolveFile(targetdir, destname); - - boolean selected = selectionTest(file, destfile); - return selected; - } - - /** - * this test is our selection test that compared the file with the destfile - * @param srcfile file to test; may be null - * @param destfile destination file - * @return true if source file compares with destination file - */ - protected abstract boolean selectionTest(File srcfile, File destfile); - - /** - * Sets the number of milliseconds leeway we will give before we consider - * a file out of date. Defaults to 2000 on MS-DOS derivatives and 1000 on - * others. - * @param granularity the leeway in milliseconds - */ - public void setGranularity(int granularity) { - this.granularity = granularity; - } - -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/NoneSelector.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/NoneSelector.java deleted file mode 100644 index 536b5b5f..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/NoneSelector.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * 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.selectors; - -import java.io.File; -import java.util.Enumeration; - -/** - * This selector has a collection of other selectors. All of those selectors - * must refuse to select a file before the file is considered selected by - * this selector. - * - * @since 1.5 - */ -public class NoneSelector extends BaseSelectorContainer { - - /** - * Default constructor. - */ - public NoneSelector() { - } - - /** - * @return a string representation of the selector - */ - public String toString() { - StringBuilder buf = new StringBuilder(); - if (hasSelectors()) { - buf.append("{noneselect: "); - buf.append(super.toString()); - buf.append("}"); - } - return buf.toString(); - } - - /** - * Returns true (the file is selected) only if all other selectors - * agree that the file should not be selected. - * - * @param basedir the base directory the scan is being done from - * @param filename is the name of the file to check - * @param file is a java.io.File object for the filename that the selector - * can use - * @return whether the file should be selected or not - */ - public boolean isSelected(File basedir, String filename, File file) { - validate(); - Enumeration<FileSelector> e = selectorElements(); - - while (e.hasMoreElements()) { - if (e.nextElement().isSelected(basedir, filename, file)) { - return false; - } - } - return true; - } - -} - diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/NotSelector.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/NotSelector.java deleted file mode 100644 index 71c3940f..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/NotSelector.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * 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.selectors; - - -/** - * This selector has one other selectors whose meaning it inverts. It - * actually relies on NoneSelector for its implementation of the - * isSelected() method, but it adds a check to ensure there is only one - * other selector contained within. - * - * @since 1.5 - */ -public class NotSelector extends NoneSelector { - - /** - * Default constructor. - */ - public NotSelector() { - } - - /** - * Constructor that inverts the meaning of its argument. - * @param other the selector to invert - * @since Ant 1.7 - */ - public NotSelector(FileSelector other) { - this(); - appendSelector(other); - } - - /** - * @return a string representation of the selector - */ - public String toString() { - StringBuilder buf = new StringBuilder(); - if (hasSelectors()) { - buf.append("{notselect: "); - buf.append(super.toString()); - buf.append("}"); - } - return buf.toString(); - } - - /** - * Makes sure that there is only one entry, sets an error message if - * not. - */ - public void verifySettings() { - if (selectorCount() != 1) { - setError("One and only one selector is allowed within the " - + "<not> tag"); - } - } - -} - diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/OrSelector.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/OrSelector.java deleted file mode 100644 index b0777445..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/OrSelector.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * 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.selectors; - -import java.io.File; -import java.util.Enumeration; - -/** - * This selector has a collection of other selectors, any of which have to - * select a file in order for this selector to select it. - * - * @since 1.5 - */ -public class OrSelector extends BaseSelectorContainer { - - /** - * Default constructor. - */ - public OrSelector() { - } - - /** - * @return a string representation of the selector - */ - public String toString() { - StringBuilder buf = new StringBuilder(); - if (hasSelectors()) { - buf.append("{orselect: "); - buf.append(super.toString()); - buf.append("}"); - } - return buf.toString(); - } - - /** - * Returns true (the file is selected) if any of the other selectors - * agree that the file should be selected. - * - * @param basedir the base directory the scan is being done from - * @param filename the name of the file to check - * @param file a java.io.File object for the filename that the selector - * can use - * @return whether the file should be selected or not - */ - public boolean isSelected(File basedir, String filename, File file) { - validate(); - Enumeration<FileSelector> e = selectorElements(); - - // First, check that all elements are correctly configured - while (e.hasMoreElements()) { - if (e.nextElement().isSelected(basedir, filename, file)) { - return true; - } - } - return false; - } - -} - diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/PresentSelector.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/PresentSelector.java deleted file mode 100644 index 1c0c000c..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/PresentSelector.java +++ /dev/null @@ -1,198 +0,0 @@ -/* - * 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.selectors; - -import java.io.File; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.types.EnumeratedAttribute; -import org.apache.tools.ant.types.Mapper; -import org.apache.tools.ant.util.FileNameMapper; -import org.apache.tools.ant.util.FileUtils; -import org.apache.tools.ant.util.IdentityMapper; - -/** - * Selector that filters files based on whether they appear in another - * directory tree. It can contain a mapper element, so isn't available - * as an ExtendSelector (since those parameters can't hold other - * elements). - * - * @since 1.5 - */ -public class PresentSelector extends BaseSelector { - private File targetdir = null; - private Mapper mapperElement = null; - private FileNameMapper map = null; - private boolean destmustexist = true; - - /** - * Creates a new <code>PresentSelector</code> instance. - * - */ - public PresentSelector() { - } - - /** - * @return a string describing this object - */ - @Override - public String toString() { - final StringBuilder buf = new StringBuilder("{presentselector targetdir: "); - if (targetdir == null) { - buf.append("NOT YET SET"); - } else { - buf.append(targetdir.getName()); - } - buf.append(" present: "); - if (destmustexist) { - buf.append("both"); - } else { - buf.append("srconly"); - } - if (map != null) { - buf.append(map.toString()); - } else if (mapperElement != null) { - buf.append(mapperElement.toString()); - } - buf.append("}"); - return buf.toString(); - } - - /** - * The name of the file or directory which is checked for matching - * files. - * - * @param targetdir the directory to scan looking for matching files. - */ - public void setTargetdir(final File targetdir) { - this.targetdir = targetdir; - } - - /** - * Defines the FileNameMapper to use (nested mapper element). - * @return a mapper to be configured - * @throws BuildException if more than one mapper defined - */ - public Mapper createMapper() throws BuildException { - if (map != null || mapperElement != null) { - throw new BuildException("Cannot define more than one mapper"); - } - mapperElement = new Mapper(getProject()); - return mapperElement; - } - - /** - * Add a configured FileNameMapper instance. - * @param fileNameMapper the FileNameMapper to add - * @throws BuildException if more than one mapper defined - * @since Ant 1.8.0 - */ - public void addConfigured(final FileNameMapper fileNameMapper) { - if (map != null || mapperElement != null) { - throw new BuildException("Cannot define more than one mapper"); - } - this.map = fileNameMapper; - } - - /** - * This sets whether to select a file if its dest file is present. - * It could be a <code>negate</code> boolean, but by doing things - * this way, we get some documentation on how the system works. - * A user looking at the documentation should clearly understand - * that the ONLY files whose presence is being tested are those - * that already exist in the source directory, hence the lack of - * a <code>destonly</code> option. - * - * @param fp An attribute set to either <code>srconly</code or - * <code>both</code>. - */ - public void setPresent(final FilePresence fp) { - if (fp.getIndex() == 0) { - destmustexist = false; - } - } - - /** - * Checks to make sure all settings are kosher. In this case, it - * means that the targetdir attribute has been set and we have a mapper. - */ - @Override - public void verifySettings() { - if (targetdir == null) { - setError("The targetdir attribute is required."); - } - if (map == null) { - if (mapperElement == null) { - map = new IdentityMapper(); - } else { - map = mapperElement.getImplementation(); - if (map == null) { - setError("Could not set <mapper> element."); - } - } - } - } - - /** - * The heart of the matter. This is where the selector gets to decide - * on the inclusion of a file in a particular fileset. - * - * @param basedir the base directory the scan is being done from - * @param filename is the name of the file to check - * @param file is a java.io.File object the selector can use - * @return whether the file should be selected or not - */ - @Override - public boolean isSelected(final File basedir, final String filename, final File file) { - - // throw BuildException on error - validate(); - - // Determine file whose existence is to be checked - final String[] destfiles = map.mapFileName(filename); - // If filename does not match the To attribute of the mapper - // then filter it out of the files we are considering - if (destfiles == null) { - return false; - } - // Sanity check - if (destfiles.length != 1 || destfiles[0] == null) { - throw new BuildException("Invalid destination file results for " - + targetdir + " with filename " + filename); - } - final String destname = destfiles[0]; - final File destfile = FileUtils.getFileUtils().resolveFile(targetdir, destname); - return destfile.exists() == destmustexist; - } - - /** - * Enumerated attribute with the values for indicating where a file's - * presence is allowed and required. - */ - public static class FilePresence extends EnumeratedAttribute { - /** - * @return the values as an array of strings - */ - @Override - public String[] getValues() { - return new String[] {"srconly", "both"}; - } - } - -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/ReadableSelector.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/ReadableSelector.java deleted file mode 100644 index 20471188..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/ReadableSelector.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * 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.selectors; - -import java.io.File; - -import org.apache.tools.ant.types.Resource; -import org.apache.tools.ant.types.resources.FileProvider; -import org.apache.tools.ant.types.resources.selectors.ResourceSelector; - -/** - * A selector that selects readable files. - * - * <p>Readable is defined in terms of java.io.File#canRead, this - * means the selector will accept any file that exists and is readable - * by the application.</p> - * - * @since Ant 1.8.0 - */ -public class ReadableSelector implements FileSelector, ResourceSelector { - - public boolean isSelected(File basedir, String filename, File file) { - return file != null && file.canRead(); - } - - public boolean isSelected(Resource r) { - FileProvider fp = r.as(FileProvider.class); - if (fp != null) { - return isSelected(null, null, fp.getFile()); - } - return false; - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/SelectSelector.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/SelectSelector.java deleted file mode 100644 index 2089012c..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/SelectSelector.java +++ /dev/null @@ -1,231 +0,0 @@ -/* - * 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.selectors; - -import java.io.File; -import java.util.Enumeration; - -import org.apache.tools.ant.Project; -import org.apache.tools.ant.PropertyHelper; - -/** - * This selector just holds one other selector and forwards all - * requests to it. It exists so that there is a single selector - * type that can exist outside of any targets, as an element of - * project. It overrides all of the reference stuff so that it - * works as expected. Note that this is the only selector you - * can reference. - * - * @since 1.5 - */ -public class SelectSelector extends BaseSelectorContainer { - - private Object ifCondition; - private Object unlessCondition; - - /** - * Default constructor. - */ - public SelectSelector() { - } - - /** - * @return a string describing this object - */ - public String toString() { - StringBuffer buf = new StringBuffer(); - if (hasSelectors()) { - buf.append("{select"); - if (ifCondition != null) { - buf.append(" if: "); - buf.append(ifCondition); - } - if (unlessCondition != null) { - buf.append(" unless: "); - buf.append(unlessCondition); - } - buf.append(" "); - buf.append(super.toString()); - buf.append("}"); - } - return buf.toString(); - } - - /** - * Performs the check for circular references and returns the - * referenced Selector. - */ - private SelectSelector getRef() { - Object o = getCheckedRef(this.getClass(), "SelectSelector"); - return (SelectSelector) o; - } - - /** - * Indicates whether there are any selectors here. - * @return whether any selectors are in this container - */ - public boolean hasSelectors() { - if (isReference()) { - return getRef().hasSelectors(); - } - return super.hasSelectors(); - } - - /** - * Gives the count of the number of selectors in this container - * @return the number of selectors in this container - */ - public int selectorCount() { - if (isReference()) { - return getRef().selectorCount(); - } - return super.selectorCount(); - } - - /** - * Returns the set of selectors as an array. - * @param p the current project - * @return an array of selectors in this container - */ - public FileSelector[] getSelectors(Project p) { - if (isReference()) { - return getRef().getSelectors(p); - } - return super.getSelectors(p); - } - - /** - * Returns an enumerator for accessing the set of selectors. - * @return an enumerator that goes through each of the selectors - */ - public Enumeration<FileSelector> selectorElements() { - if (isReference()) { - return getRef().selectorElements(); - } - return super.selectorElements(); - } - - /** - * Add a new selector into this container. - * - * @param selector the new selector to add - */ - public void appendSelector(FileSelector selector) { - if (isReference()) { - throw noChildrenAllowed(); - } - super.appendSelector(selector); - } - - - /** - * Makes sure that there is only one entry, sets an error message if - * not. - */ - public void verifySettings() { - int cnt = selectorCount(); - if (cnt < 0 || cnt > 1) { - setError("Only one selector is allowed within the " - + "<selector> tag"); - } - } - - /** - * Ensures that the selector passes the conditions placed - * on it with <code>if</code> and <code>unless</code>. - * @return true if conditions are passed - */ - public boolean passesConditions() { - PropertyHelper ph = PropertyHelper.getPropertyHelper(getProject()); - return ph.testIfCondition(ifCondition) - && ph.testUnlessCondition(unlessCondition); - } - - /** - * Sets the if attribute to an expression which must evaluate to - * true or the name of an existing property for the - * selector to select any files. - * @param ifProperty the expression to check - * @since Ant 1.8.0 - */ - public void setIf(Object ifProperty) { - this.ifCondition = ifProperty; - } - - /** - * Sets the if attribute to an expression which must evaluate to - * true or the name of an existing property for the - * selector to select any files. - * @param ifProperty the expression to check - */ - public void setIf(String ifProperty) { - setIf((Object) ifProperty); - } - - /** - * Sets the unless attribute to an expression which must evaluate to - * false or the name of a property which cannot exist for the - * selector to select any files. - * @param unlessProperty the expression to check - * @since Ant 1.8.0 - */ - public void setUnless(Object unlessProperty) { - this.unlessCondition = unlessProperty; - } - - /** - * Sets the unless attribute to an expression which must evaluate to - * false or the name of a property which cannot exist for the - * selector to select any files. - * @param unlessProperty the expression to check - */ - public void setUnless(String unlessProperty) { - setUnless((Object) unlessProperty); - } - - /** - * Returns true (the file is selected) only if the if property (if any) - * exists, the unless property (if any) doesn't exist, and the - * contained selector (if any) selects the file. If there is no contained - * selector, return true (because we assume that the point was to test - * the if and unless conditions). - * - * @param basedir the base directory the scan is being done from - * @param filename the name of the file to check - * @param file a java.io.File object for the filename that the selector - * can use - * @return whether the file should be selected or not - */ - public boolean isSelected(File basedir, String filename, File file) { - validate(); - - // Deal with if and unless properties first - if (!(passesConditions())) { - return false; - } - - Enumeration<FileSelector> e = selectorElements(); - if (!e.hasMoreElements()) { - return true; - } - FileSelector f = e.nextElement(); - return f.isSelected(basedir, filename, file); - } -} - diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/SelectorContainer.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/SelectorContainer.java deleted file mode 100644 index 47e4e4fd..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/SelectorContainer.java +++ /dev/null @@ -1,187 +0,0 @@ -/* - * 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.selectors; - -import java.util.Enumeration; - -import org.apache.tools.ant.Project; -import org.apache.tools.ant.types.selectors.modifiedselector.ModifiedSelector; - -/** - * This is the interface for selectors that can contain other selectors. - * - * @since 1.5 - */ -public interface SelectorContainer { - - /** - * Indicates whether there are any selectors here. - * - * @return whether any selectors are in this container - */ - boolean hasSelectors(); - - /** - * Gives the count of the number of selectors in this container - * - * @return the number of selectors in this container - */ - int selectorCount(); - - /** - * Returns the set of selectors as an array. - * @param p the current project - * @return an array of selectors in this container - */ - FileSelector[] getSelectors(Project p); - - /** - * Returns an enumerator for accessing the set of selectors. - * - * @return an enumerator that goes through each of the selectors - */ - Enumeration<FileSelector> selectorElements(); - - /** - * Add a new selector into this container. - * - * @param selector the new selector to add - */ - void appendSelector(FileSelector selector); - - /* Methods below all add specific selectors */ - - /** - * add a "Select" selector entry on the selector list - * @param selector the selector to add - */ - void addSelector(SelectSelector selector); - - /** - * add an "And" selector entry on the selector list - * @param selector the selector to add - */ - void addAnd(AndSelector selector); - - /** - * add an "Or" selector entry on the selector list - * @param selector the selector to add - */ - void addOr(OrSelector selector); - - /** - * add a "Not" selector entry on the selector list - * @param selector the selector to add - */ - void addNot(NotSelector selector); - - /** - * add a "None" selector entry on the selector list - * @param selector the selector to add - */ - void addNone(NoneSelector selector); - - /** - * add a majority selector entry on the selector list - * @param selector the selector to add - */ - void addMajority(MajoritySelector selector); - - /** - * add a selector date entry on the selector list - * @param selector the selector to add - */ - void addDate(DateSelector selector); - - /** - * add a selector size entry on the selector list - * @param selector the selector to add - */ - void addSize(SizeSelector selector); - - /** - * add a selector filename entry on the selector list - * @param selector the selector to add - */ - void addFilename(FilenameSelector selector); - - /** - * add an extended selector entry on the selector list - * @param selector the selector to add - */ - void addCustom(ExtendSelector selector); - - /** - * add a contains selector entry on the selector list - * @param selector the selector to add - */ - void addContains(ContainsSelector selector); - - /** - * add a present selector entry on the selector list - * @param selector the selector to add - */ - void addPresent(PresentSelector selector); - - /** - * add a depth selector entry on the selector list - * @param selector the selector to add - */ - void addDepth(DepthSelector selector); - - /** - * add a depends selector entry on the selector list - * @param selector the selector to add - */ - void addDepend(DependSelector selector); - - /** - * add a regular expression selector entry on the selector list - * @param selector the selector to add - */ - void addContainsRegexp(ContainsRegexpSelector selector); - - /** - * add the type selector - * @param selector the selector to add - * @since ant 1.6 - */ - void addType(TypeSelector selector); - - /** - * add the different selector - * @param selector the selector to add - * @since ant 1.6 - */ - void addDifferent(DifferentSelector selector); - - /** - * add the modified selector - * @param selector the selector to add - * @since ant 1.6 - */ - void addModified(ModifiedSelector selector); - - /** - * add an arbitrary selector - * @param selector the selector to add - * @since Ant 1.6 - */ - void add(FileSelector selector); -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/SelectorScanner.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/SelectorScanner.java deleted file mode 100644 index df9f8a40..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/SelectorScanner.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * 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.selectors; - -/** - * An interface used to describe the actions required by any type of - * directory scanner that supports Selectors. - * - * @since 1.5 - */ -public interface SelectorScanner { - /** - * Sets the selectors the scanner should use. - * - * @param selectors the list of selectors - */ - void setSelectors(FileSelector[] selectors); - - /** - * Directories which were selected out of a scan. - * - * @return list of directories not selected - */ - String[] getDeselectedDirectories(); - - /** - * Files which were selected out of a scan. - * - * @return list of files not selected - */ - String[] getDeselectedFiles(); - - -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/SelectorUtils.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/SelectorUtils.java deleted file mode 100644 index 277470b7..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/SelectorUtils.java +++ /dev/null @@ -1,695 +0,0 @@ -/* - * 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.selectors; - -import java.io.File; -import java.util.StringTokenizer; -import java.util.Vector; - -import org.apache.tools.ant.types.Resource; -import org.apache.tools.ant.util.FileUtils; - -/** - * <p>This is a utility class used by selectors and DirectoryScanner. The - * functionality more properly belongs just to selectors, but unfortunately - * DirectoryScanner exposed these as protected methods. Thus we have to - * support any subclasses of DirectoryScanner that may access these methods. - * </p> - * <p>This is a Singleton.</p> - * - * @since 1.5 - */ -public final class SelectorUtils { - - /** - * The pattern that matches an arbitrary number of directories. - * @since Ant 1.8.0 - */ - public static final String DEEP_TREE_MATCH = "**"; - - private static final SelectorUtils instance = new SelectorUtils(); - private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); - - /** - * Private Constructor - */ - private SelectorUtils() { - } - - /** - * Retrieves the instance of the Singleton. - * @return singleton instance - */ - public static SelectorUtils getInstance() { - return instance; - } - - /** - * Tests whether or not a given path matches the start of a given - * pattern up to the first "**". - * <p> - * This is not a general purpose test and should only be used if you - * can live with false positives. For example, <code>pattern=**\a</code> - * and <code>str=b</code> will yield <code>true</code>. - * - * @param pattern The pattern to match against. Must not be - * <code>null</code>. - * @param str The path to match, as a String. Must not be - * <code>null</code>. - * - * @return whether or not a given path matches the start of a given - * pattern up to the first "**". - */ - public static boolean matchPatternStart(String pattern, String str) { - return matchPatternStart(pattern, str, true); - } - - /** - * Tests whether or not a given path matches the start of a given - * pattern up to the first "**". - * <p> - * This is not a general purpose test and should only be used if you - * can live with false positives. For example, <code>pattern=**\a</code> - * and <code>str=b</code> will yield <code>true</code>. - * - * @param pattern The pattern to match against. Must not be - * <code>null</code>. - * @param str The path to match, as a String. Must not be - * <code>null</code>. - * @param isCaseSensitive Whether or not matching should be performed - * case sensitively. - * - * @return whether or not a given path matches the start of a given - * pattern up to the first "**". - */ - public static boolean matchPatternStart(String pattern, String str, - boolean isCaseSensitive) { - // When str starts with a File.separator, pattern has to start with a - // File.separator. - // When pattern starts with a File.separator, str has to start with a - // File.separator. - if (str.startsWith(File.separator) - != pattern.startsWith(File.separator)) { - return false; - } - - String[] patDirs = tokenizePathAsArray(pattern); - String[] strDirs = tokenizePathAsArray(str); - return matchPatternStart(patDirs, strDirs, isCaseSensitive); - } - - - /** - * Tests whether or not a given path matches the start of a given - * pattern up to the first "**". - * <p> - * This is not a general purpose test and should only be used if you - * can live with false positives. For example, <code>pattern=**\a</code> - * and <code>str=b</code> will yield <code>true</code>. - * - * @param patDirs The tokenized pattern to match against. Must not be - * <code>null</code>. - * @param strDirs The tokenized path to match. Must not be - * <code>null</code>. - * @param isCaseSensitive Whether or not matching should be performed - * case sensitively. - * - * @return whether or not a given path matches the start of a given - * pattern up to the first "**". - */ - static boolean matchPatternStart(String[] patDirs, String[] strDirs, - boolean isCaseSensitive) { - int patIdxStart = 0; - int patIdxEnd = patDirs.length - 1; - int strIdxStart = 0; - int strIdxEnd = strDirs.length - 1; - - // up to first '**' - while (patIdxStart <= patIdxEnd && strIdxStart <= strIdxEnd) { - String patDir = patDirs[patIdxStart]; - if (patDir.equals(DEEP_TREE_MATCH)) { - break; - } - if (!match(patDir, strDirs[strIdxStart], isCaseSensitive)) { - return false; - } - patIdxStart++; - strIdxStart++; - } - - // CheckStyle:SimplifyBooleanReturnCheck OFF - // Check turned off as the code needs the comments for the various - // code paths. - if (strIdxStart > strIdxEnd) { - // String is exhausted - return true; - } else if (patIdxStart > patIdxEnd) { - // String not exhausted, but pattern is. Failure. - return false; - } else { - // pattern now holds ** while string is not exhausted - // this will generate false positives but we can live with that. - return true; - } - } - - /** - * Tests whether or not a given path matches a given pattern. - * - * If you need to call this method multiple times with the same - * pattern you should rather use TokenizedPath - * - * @see TokenizedPath - * - * @param pattern The pattern to match against. Must not be - * <code>null</code>. - * @param str The path to match, as a String. Must not be - * <code>null</code>. - * - * @return <code>true</code> if the pattern matches against the string, - * or <code>false</code> otherwise. - */ - public static boolean matchPath(String pattern, String str) { - String[] patDirs = tokenizePathAsArray(pattern); - return matchPath(patDirs, tokenizePathAsArray(str), true); - } - - /** - * Tests whether or not a given path matches a given pattern. - * - * If you need to call this method multiple times with the same - * pattern you should rather use TokenizedPattern - * - * @see TokenizedPattern - * - * @param pattern The pattern to match against. Must not be - * <code>null</code>. - * @param str The path to match, as a String. Must not be - * <code>null</code>. - * @param isCaseSensitive Whether or not matching should be performed - * case sensitively. - * - * @return <code>true</code> if the pattern matches against the string, - * or <code>false</code> otherwise. - */ - public static boolean matchPath(String pattern, String str, - boolean isCaseSensitive) { - String[] patDirs = tokenizePathAsArray(pattern); - return matchPath(patDirs, tokenizePathAsArray(str), isCaseSensitive); - } - - /** - * Core implementation of matchPath. It is isolated so that it - * can be called from TokenizedPattern. - */ - static boolean matchPath(String[] tokenizedPattern, String[] strDirs, - boolean isCaseSensitive) { - int patIdxStart = 0; - int patIdxEnd = tokenizedPattern.length - 1; - int strIdxStart = 0; - int strIdxEnd = strDirs.length - 1; - - // up to first '**' - while (patIdxStart <= patIdxEnd && strIdxStart <= strIdxEnd) { - String patDir = tokenizedPattern[patIdxStart]; - if (patDir.equals(DEEP_TREE_MATCH)) { - break; - } - if (!match(patDir, strDirs[strIdxStart], isCaseSensitive)) { - return false; - } - patIdxStart++; - strIdxStart++; - } - if (strIdxStart > strIdxEnd) { - // String is exhausted - for (int i = patIdxStart; i <= patIdxEnd; i++) { - if (!tokenizedPattern[i].equals(DEEP_TREE_MATCH)) { - return false; - } - } - return true; - } else { - if (patIdxStart > patIdxEnd) { - // String not exhausted, but pattern is. Failure. - return false; - } - } - - // up to last '**' - while (patIdxStart <= patIdxEnd && strIdxStart <= strIdxEnd) { - String patDir = tokenizedPattern[patIdxEnd]; - if (patDir.equals(DEEP_TREE_MATCH)) { - break; - } - if (!match(patDir, strDirs[strIdxEnd], isCaseSensitive)) { - return false; - } - patIdxEnd--; - strIdxEnd--; - } - if (strIdxStart > strIdxEnd) { - // String is exhausted - for (int i = patIdxStart; i <= patIdxEnd; i++) { - if (!tokenizedPattern[i].equals(DEEP_TREE_MATCH)) { - return false; - } - } - return true; - } - - while (patIdxStart != patIdxEnd && strIdxStart <= strIdxEnd) { - int patIdxTmp = -1; - for (int i = patIdxStart + 1; i <= patIdxEnd; i++) { - if (tokenizedPattern[i].equals(DEEP_TREE_MATCH)) { - patIdxTmp = i; - break; - } - } - if (patIdxTmp == patIdxStart + 1) { - // '**/**' situation, so skip one - patIdxStart++; - continue; - } - // Find the pattern between padIdxStart & padIdxTmp in str between - // strIdxStart & strIdxEnd - int patLength = (patIdxTmp - patIdxStart - 1); - int strLength = (strIdxEnd - strIdxStart + 1); - int foundIdx = -1; - strLoop: - for (int i = 0; i <= strLength - patLength; i++) { - for (int j = 0; j < patLength; j++) { - String subPat = tokenizedPattern[patIdxStart + j + 1]; - String subStr = strDirs[strIdxStart + i + j]; - if (!match(subPat, subStr, isCaseSensitive)) { - continue strLoop; - } - } - - foundIdx = strIdxStart + i; - break; - } - - if (foundIdx == -1) { - return false; - } - - patIdxStart = patIdxTmp; - strIdxStart = foundIdx + patLength; - } - - for (int i = patIdxStart; i <= patIdxEnd; i++) { - if (!tokenizedPattern[i].equals(DEEP_TREE_MATCH)) { - return false; - } - } - - return true; - } - - /** - * Tests whether or not a string matches against a pattern. - * The pattern may contain two special characters:<br> - * '*' means zero or more characters<br> - * '?' means one and only one character - * - * @param pattern The pattern to match against. - * Must not be <code>null</code>. - * @param str The string which must be matched against the pattern. - * Must not be <code>null</code>. - * - * @return <code>true</code> if the string matches against the pattern, - * or <code>false</code> otherwise. - */ - public static boolean match(String pattern, String str) { - return match(pattern, str, true); - } - - /** - * Tests whether or not a string matches against a pattern. - * The pattern may contain two special characters:<br> - * '*' means zero or more characters<br> - * '?' means one and only one character - * - * @param pattern The pattern to match against. - * Must not be <code>null</code>. - * @param str The string which must be matched against the pattern. - * Must not be <code>null</code>. - * @param caseSensitive Whether or not matching should be performed - * case sensitively. - * - * - * @return <code>true</code> if the string matches against the pattern, - * or <code>false</code> otherwise. - */ - public static boolean match(String pattern, String str, - boolean caseSensitive) { - char[] patArr = pattern.toCharArray(); - char[] strArr = str.toCharArray(); - int patIdxStart = 0; - int patIdxEnd = patArr.length - 1; - int strIdxStart = 0; - int strIdxEnd = strArr.length - 1; - char ch; - - boolean containsStar = false; - for (int i = 0; i < patArr.length; i++) { - if (patArr[i] == '*') { - containsStar = true; - break; - } - } - - if (!containsStar) { - // No '*'s, so we make a shortcut - if (patIdxEnd != strIdxEnd) { - return false; // Pattern and string do not have the same size - } - for (int i = 0; i <= patIdxEnd; i++) { - ch = patArr[i]; - if (ch != '?') { - if (different(caseSensitive, ch, strArr[i])) { - return false; // Character mismatch - } - } - } - return true; // String matches against pattern - } - - if (patIdxEnd == 0) { - return true; // Pattern contains only '*', which matches anything - } - - // Process characters before first star - while (true) { - ch = patArr[patIdxStart]; - if (ch == '*' || strIdxStart > strIdxEnd) { - break; - } - if (ch != '?') { - if (different(caseSensitive, ch, strArr[strIdxStart])) { - return false; // Character mismatch - } - } - patIdxStart++; - strIdxStart++; - } - if (strIdxStart > strIdxEnd) { - // All characters in the string are used. Check if only '*'s are - // left in the pattern. If so, we succeeded. Otherwise failure. - return allStars(patArr, patIdxStart, patIdxEnd); - } - - // Process characters after last star - while (true) { - ch = patArr[patIdxEnd]; - if (ch == '*' || strIdxStart > strIdxEnd) { - break; - } - if (ch != '?') { - if (different(caseSensitive, ch, strArr[strIdxEnd])) { - return false; // Character mismatch - } - } - patIdxEnd--; - strIdxEnd--; - } - if (strIdxStart > strIdxEnd) { - // All characters in the string are used. Check if only '*'s are - // left in the pattern. If so, we succeeded. Otherwise failure. - return allStars(patArr, patIdxStart, patIdxEnd); - } - - // process pattern between stars. padIdxStart and patIdxEnd point - // always to a '*'. - while (patIdxStart != patIdxEnd && strIdxStart <= strIdxEnd) { - int patIdxTmp = -1; - for (int i = patIdxStart + 1; i <= patIdxEnd; i++) { - if (patArr[i] == '*') { - patIdxTmp = i; - break; - } - } - if (patIdxTmp == patIdxStart + 1) { - // Two stars next to each other, skip the first one. - patIdxStart++; - continue; - } - // Find the pattern between padIdxStart & padIdxTmp in str between - // strIdxStart & strIdxEnd - int patLength = (patIdxTmp - patIdxStart - 1); - int strLength = (strIdxEnd - strIdxStart + 1); - int foundIdx = -1; - strLoop: - for (int i = 0; i <= strLength - patLength; i++) { - for (int j = 0; j < patLength; j++) { - ch = patArr[patIdxStart + j + 1]; - if (ch != '?') { - if (different(caseSensitive, ch, - strArr[strIdxStart + i + j])) { - continue strLoop; - } - } - } - - foundIdx = strIdxStart + i; - break; - } - - if (foundIdx == -1) { - return false; - } - - patIdxStart = patIdxTmp; - strIdxStart = foundIdx + patLength; - } - - // All characters in the string are used. Check if only '*'s are left - // in the pattern. If so, we succeeded. Otherwise failure. - return allStars(patArr, patIdxStart, patIdxEnd); - } - - private static boolean allStars(char[] chars, int start, int end) { - for (int i = start; i <= end; ++i) { - if (chars[i] != '*') { - return false; - } - } - return true; - } - - private static boolean different( - boolean caseSensitive, char ch, char other) { - return caseSensitive - ? ch != other - : Character.toUpperCase(ch) != Character.toUpperCase(other); - } - - /** - * Breaks a path up into a Vector of path elements, tokenizing on - * <code>File.separator</code>. - * - * @param path Path to tokenize. Must not be <code>null</code>. - * - * @return a Vector of path elements from the tokenized path - */ - public static Vector<String> tokenizePath(String path) { - return tokenizePath(path, File.separator); - } - - /** - * Breaks a path up into a Vector of path elements, tokenizing on - * - * @param path Path to tokenize. Must not be <code>null</code>. - * @param separator the separator against which to tokenize. - * - * @return a Vector of path elements from the tokenized path - * @since Ant 1.6 - */ - public static Vector<String> tokenizePath(String path, String separator) { - Vector<String> ret = new Vector<String>(); - if (FileUtils.isAbsolutePath(path)) { - String[] s = FILE_UTILS.dissect(path); - ret.add(s[0]); - path = s[1]; - } - StringTokenizer st = new StringTokenizer(path, separator); - while (st.hasMoreTokens()) { - ret.addElement(st.nextToken()); - } - return ret; - } - - /** - * Same as {@link #tokenizePath tokenizePath} but hopefully faster. - */ - /*package*/ static String[] tokenizePathAsArray(String path) { - String root = null; - if (FileUtils.isAbsolutePath(path)) { - String[] s = FILE_UTILS.dissect(path); - root = s[0]; - path = s[1]; - } - char sep = File.separatorChar; - int start = 0; - int len = path.length(); - int count = 0; - for (int pos = 0; pos < len; pos++) { - if (path.charAt(pos) == sep) { - if (pos != start) { - count++; - } - start = pos + 1; - } - } - if (len != start) { - count++; - } - String[] l = new String[count + ((root == null) ? 0 : 1)]; - - if (root != null) { - l[0] = root; - count = 1; - } else { - count = 0; - } - start = 0; - for (int pos = 0; pos < len; pos++) { - if (path.charAt(pos) == sep) { - if (pos != start) { - String tok = path.substring(start, pos); - l[count++] = tok; - } - start = pos + 1; - } - } - if (len != start) { - String tok = path.substring(start); - l[count/*++*/] = tok; - } - return l; - } - - /** - * Returns dependency information on these two files. If src has been - * modified later than target, it returns true. If target doesn't exist, - * it likewise returns true. Otherwise, target is newer than src and - * is not out of date, thus the method returns false. It also returns - * false if the src file doesn't even exist, since how could the - * target then be out of date. - * - * @param src the original file - * @param target the file being compared against - * @param granularity the amount in seconds of slack we will give in - * determining out of dateness - * @return whether the target is out of date - */ - public static boolean isOutOfDate(File src, File target, int granularity) { - if (!src.exists()) { - return false; - } - if (!target.exists()) { - return true; - } - if ((src.lastModified() - granularity) > target.lastModified()) { - return true; - } - return false; - } - - /** - * Returns dependency information on these two resources. If src has been - * modified later than target, it returns true. If target doesn't exist, - * it likewise returns true. Otherwise, target is newer than src and - * is not out of date, thus the method returns false. It also returns - * false if the src file doesn't even exist, since how could the - * target then be out of date. - * - * @param src the original resource - * @param target the resource being compared against - * @param granularity the int amount in seconds of slack we will give in - * determining out of dateness - * @return whether the target is out of date - */ - public static boolean isOutOfDate(Resource src, Resource target, - int granularity) { - return isOutOfDate(src, target, (long) granularity); - } - - /** - * Returns dependency information on these two resources. If src has been - * modified later than target, it returns true. If target doesn't exist, - * it likewise returns true. Otherwise, target is newer than src and - * is not out of date, thus the method returns false. It also returns - * false if the src file doesn't even exist, since how could the - * target then be out of date. - * - * @param src the original resource - * @param target the resource being compared against - * @param granularity the long amount in seconds of slack we will give in - * determining out of dateness - * @return whether the target is out of date - */ - public static boolean isOutOfDate(Resource src, Resource target, long granularity) { - long sourceLastModified = src.getLastModified(); - long targetLastModified = target.getLastModified(); - return src.isExists() - && (sourceLastModified == Resource.UNKNOWN_DATETIME - || targetLastModified == Resource.UNKNOWN_DATETIME - || (sourceLastModified - granularity) > targetLastModified); - } - - /** - * "Flattens" a string by removing all whitespace (space, tab, linefeed, - * carriage return, and formfeed). This uses StringTokenizer and the - * default set of tokens as documented in the single argument constructor. - * - * @param input a String to remove all whitespace. - * @return a String that has had all whitespace removed. - */ - public static String removeWhitespace(String input) { - StringBuffer result = new StringBuffer(); - if (input != null) { - StringTokenizer st = new StringTokenizer(input); - while (st.hasMoreTokens()) { - result.append(st.nextToken()); - } - } - return result.toString(); - } - - /** - * Tests if a string contains stars or question marks - * @param input a String which one wants to test for containing wildcard - * @return true if the string contains at least a star or a question mark - */ - public static boolean hasWildcards(String input) { - return (input.indexOf('*') != -1 || input.indexOf('?') != -1); - } - - /** - * removes from a pattern all tokens to the right containing wildcards - * @param input the input string - * @return the leftmost part of the pattern without wildcards - */ - public static String rtrimWildcardTokens(String input) { - return new TokenizedPattern(input).rtrimWildcardTokens().toString(); - } -} - diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/SignedSelector.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/SignedSelector.java deleted file mode 100644 index cd515022..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/SignedSelector.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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.selectors; -import java.io.File; - -import org.apache.tools.ant.taskdefs.condition.IsSigned; -import org.apache.tools.ant.types.DataType; - -/** - * Selector that chooses files based on whether they are signed or not. - * - * @since 1.7 - */ -public class SignedSelector extends DataType implements FileSelector { - private IsSigned isSigned = new IsSigned(); - - /** - * The signature name to check jarfile for. - * - * @param name signature to look for. - */ - public void setName(String name) { - isSigned.setName(name); - } - - /** - * The heart of the matter. This is where the selector gets to decide - * on the inclusion of a file in a particular fileset. - * - * @param basedir not used by this selector - * @param filename not used by this selector - * @param file path to file to be selected - * @return whether the file should be selected or not - */ - public boolean isSelected(File basedir, String filename, File file) { - if (file.isDirectory()) { - return false; // Quick return: directories cannot be signed - } - isSigned.setProject(getProject()); - isSigned.setFile(file); - return isSigned.eval(); - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/SizeSelector.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/SizeSelector.java deleted file mode 100644 index 9ff91ad9..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/SizeSelector.java +++ /dev/null @@ -1,279 +0,0 @@ -/* - * 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.selectors; - -import java.io.File; - -import org.apache.tools.ant.types.Comparison; -import org.apache.tools.ant.types.EnumeratedAttribute; -import org.apache.tools.ant.types.Parameter; - -/** - * Selector that filters files based on their size. - * - * @since 1.5 - */ -public class SizeSelector extends BaseExtendSelector { - - /** Constants for kilo, kibi etc */ - private static final int KILO = 1000; - private static final int KIBI = 1024; - private static final int KIBI_POS = 4; - private static final int MEGA = 1000000; - private static final int MEGA_POS = 9; - private static final int MEBI = 1048576; - private static final int MEBI_POS = 13; - private static final long GIGA = 1000000000L; - private static final int GIGA_POS = 18; - private static final long GIBI = 1073741824L; - private static final int GIBI_POS = 22; - private static final long TERA = 1000000000000L; - private static final int TERA_POS = 27; - private static final long TEBI = 1099511627776L; - private static final int TEBI_POS = 31; - private static final int END_POS = 36; - - /** Used for parameterized custom selector */ - public static final String SIZE_KEY = "value"; - /** Used for parameterized custom selector */ - public static final String UNITS_KEY = "units"; - /** Used for parameterized custom selector */ - public static final String WHEN_KEY = "when"; - - private long size = -1; - private long multiplier = 1; - private long sizelimit = -1; - private Comparison when = Comparison.EQUAL; - - /** - * Creates a new <code>SizeSelector</code> instance. - * - */ - public SizeSelector() { - } - - /** - * Returns a <code>String</code> object representing the specified - * SizeSelector. This is "{sizeselector value: " + <"compare", - * "less", "more", "equal"> + "}". - * @return a string describing this object - */ - public String toString() { - StringBuilder buf = new StringBuilder("{sizeselector value: "); - buf.append(sizelimit); - buf.append("compare: ").append(when.getValue()); - buf.append("}"); - return buf.toString(); - } - - /** - * A size selector needs to know what size to base its selecting on. - * This will be further modified by the multiplier to get an - * actual size limit. - * - * @param size the size to select against expressed in units. - */ - public void setValue(long size) { - this.size = size; - if (multiplier != 0 && size > -1) { - sizelimit = size * multiplier; - } - } - - /** - * Sets the units to use for the comparison. This is a little - * complicated because common usage has created standards that - * play havoc with capitalization rules. Thus, some people will - * use "K" for indicating 1000's, when the SI standard calls for - * "k". Others have tried to introduce "K" as a multiple of 1024, - * but that falls down when you reach "M", since "m" is already - * defined as 0.001. - * <p> - * To get around this complexity, a number of standards bodies - * have proposed the 2^10 standard, and at least one has adopted - * it. But we are still left with a populace that isn't clear on - * how capitalization should work. - * <p> - * We therefore ignore capitalization as much as possible. - * Completely mixed case is not possible, but all upper and lower - * forms are accepted for all long and short forms. Since we have - * no need to work with the 0.001 case, this practice works here. - * <p> - * This function translates all the long and short forms that a - * unit prefix can occur in and translates them into a single - * multiplier. - * - * @param units The units to compare the size to, using an - * EnumeratedAttribute. - */ - public void setUnits(ByteUnits units) { - int i = units.getIndex(); - multiplier = 0; - if (i > -1 && i < KIBI_POS) { - multiplier = KILO; - } else if (i < MEGA_POS) { - multiplier = KIBI; - } else if (i < MEBI_POS) { - multiplier = MEGA; - } else if (i < GIGA_POS) { - multiplier = MEBI; - } else if (i < GIBI_POS) { - multiplier = GIGA; - } else if (i < TERA_POS) { - multiplier = GIBI; - } else if (i < TEBI_POS) { - multiplier = TERA; - } else if (i < END_POS) { - multiplier = TEBI; - } - if (multiplier > 0 && size > -1) { - sizelimit = size * multiplier; - } - } - - /** - * This specifies when the file should be selected, whether it be - * when the file matches a particular size, when it is smaller, - * or whether it is larger. - * - * @param when The comparison to perform, an EnumeratedAttribute. - */ - public void setWhen(SizeComparisons when) { - this.when = when; - } - - /** - * When using this as a custom selector, this method will be called. - * It translates each parameter into the appropriate setXXX() call. - * - * @param parameters the complete set of parameters for this selector. - */ - public void setParameters(Parameter[] parameters) { - super.setParameters(parameters); - if (parameters != null) { - for (int i = 0; i < parameters.length; i++) { - String paramname = parameters[i].getName(); - if (SIZE_KEY.equalsIgnoreCase(paramname)) { - try { - setValue(Long.parseLong(parameters[i].getValue())); - } catch (NumberFormatException nfe) { - setError("Invalid size setting " - + parameters[i].getValue()); - } - } else if (UNITS_KEY.equalsIgnoreCase(paramname)) { - ByteUnits units = new ByteUnits(); - units.setValue(parameters[i].getValue()); - setUnits(units); - } else if (WHEN_KEY.equalsIgnoreCase(paramname)) { - SizeComparisons scmp = new SizeComparisons(); - scmp.setValue(parameters[i].getValue()); - setWhen(scmp); - } else { - setError("Invalid parameter " + paramname); - } - } - } - } - - /** - * <p>Checks to make sure all settings are kosher. In this case, it - * means that the size attribute has been set (to a positive value), - * that the multiplier has a valid setting, and that the size limit - * is valid. Since the latter is a calculated value, this can only - * fail due to a programming error. - * </p> - * <p>If a problem is detected, the setError() method is called. - * </p> - */ - public void verifySettings() { - if (size < 0) { - setError("The value attribute is required, and must be positive"); - } else if (multiplier < 1) { - setError("Invalid Units supplied, must be K,Ki,M,Mi,G,Gi,T,or Ti"); - } else if (sizelimit < 0) { - setError("Internal error: Code is not setting sizelimit correctly"); - } - } - - /** - * The heart of the matter. This is where the selector gets to decide - * on the inclusion of a file in a particular fileset. - * - * @param basedir A java.io.File object for the base directory. - * @param filename The name of the file to check. - * @param file A File object for this filename. - * @return whether the file should be selected or not. - */ - public boolean isSelected(File basedir, String filename, File file) { - - // throw BuildException on error - validate(); - - // Directory size never selected for - if (file.isDirectory()) { - return true; - } - long diff = file.length() - sizelimit; - return when.evaluate(diff == 0 ? 0 : (int) (diff / Math.abs(diff))); - } - - - /** - * Enumerated attribute with the values for units. - * <p> - * This treats the standard SI units as representing powers of ten, - * as they should. If you want the powers of 2 that approximate - * the SI units, use the first two characters followed by a - * <code>bi</code>. So 1024 (2^10) becomes <code>kibi</code>, - * 1048576 (2^20) becomes <code>mebi</code>, 1073741824 (2^30) - * becomes <code>gibi</code>, and so on. The symbols are also - * accepted, and these are the first letter capitalized followed - * by an <code>i</code>. <code>Ki</code>, <code>Mi</code>, - * <code>Gi</code>, and so on. Capitalization variations on these - * are also accepted. - * <p> - * This binary prefix system is approved by the IEC and appears on - * its way for approval by other agencies, but it is not an SI - * standard. It disambiguates things for us, though. - */ - public static class ByteUnits extends EnumeratedAttribute { - /** - * @return the values as an array of strings - */ - public String[] getValues() { - return new String[]{"K", "k", "kilo", "KILO", - "Ki", "KI", "ki", "kibi", "KIBI", - "M", "m", "mega", "MEGA", - "Mi", "MI", "mi", "mebi", "MEBI", - "G", "g", "giga", "GIGA", - "Gi", "GI", "gi", "gibi", "GIBI", - "T", "t", "tera", "TERA", - /* You wish! */ "Ti", "TI", "ti", "tebi", "TEBI" - }; - } - } - - /** - * Enumerated attribute with the values for size comparison. - */ - public static class SizeComparisons extends Comparison { - } - -} - diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/TokenizedPath.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/TokenizedPath.java deleted file mode 100644 index a712759c..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/TokenizedPath.java +++ /dev/null @@ -1,222 +0,0 @@ -/* - * 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.selectors; - -import java.io.File; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.util.FileUtils; -import org.apache.tools.ant.util.SymbolicLinkUtils; - -/** - * Container for a path that has been split into its components. - * @since 1.8.0 - */ -public class TokenizedPath { - - /** - * Instance that holds no tokens at all. - */ - public static final TokenizedPath EMPTY_PATH = - new TokenizedPath("", new String[0]); - - /** Helper. */ - private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); - /** Helper. */ - private static final SymbolicLinkUtils SYMLINK_UTILS = - SymbolicLinkUtils.getSymbolicLinkUtils(); - /** iterations for case-sensitive scanning. */ - private static final boolean[] CS_SCAN_ONLY = new boolean[] {true}; - /** iterations for non-case-sensitive scanning. */ - private static final boolean[] CS_THEN_NON_CS = new boolean[] {true, false}; - - private final String path; - private final String[] tokenizedPath; - - /** - * Initialize the TokenizedPath by parsing it. - * @param path The path to tokenize. Must not be - * <code>null</code>. - */ - public TokenizedPath(String path) { - this(path, SelectorUtils.tokenizePathAsArray(path)); - } - - /** - * Creates a new path as a child of another path. - * - * @param parent the parent path - * @param child the child, must not contain the file separator - */ - public TokenizedPath(TokenizedPath parent, String child) { - if (parent.path.length() > 0 - && parent.path.charAt(parent.path.length() - 1) - != File.separatorChar) { - path = parent.path + File.separatorChar + child; - } else { - path = parent.path + child; - } - tokenizedPath = new String[parent.tokenizedPath.length + 1]; - System.arraycopy(parent.tokenizedPath, 0, tokenizedPath, 0, - parent.tokenizedPath.length); - tokenizedPath[parent.tokenizedPath.length] = child; - } - - /* package */ TokenizedPath(String path, String[] tokens) { - this.path = path; - this.tokenizedPath = tokens; - } - - /** - * @return The original path String - */ - @Override - public String toString() { - return path; - } - - /** - * The depth (or length) of a path. - */ - public int depth() { - return tokenizedPath.length; - } - - /* package */ String[] getTokens() { - return tokenizedPath; - } - - /** - * From <code>base</code> traverse the filesystem in order to find - * a file that matches the given name. - * - * @param base base File (dir). - * @param cs whether to scan case-sensitively. - * @return File object that points to the file in question or null. - */ - public File findFile(File base, final boolean cs) { - String[] tokens = tokenizedPath; - if (FileUtils.isAbsolutePath(path)) { - if (base == null) { - String[] s = FILE_UTILS.dissect(path); - base = new File(s[0]); - tokens = SelectorUtils.tokenizePathAsArray(s[1]); - } else { - File f = FILE_UTILS.normalize(path); - String s = FILE_UTILS.removeLeadingPath(base, f); - if (s.equals(f.getAbsolutePath())) { - //removing base from path yields no change; path - //not child of base - return null; - } - tokens = SelectorUtils.tokenizePathAsArray(s); - } - } - return findFile(base, tokens, cs); - } - - /** - * Do we have to traverse a symlink when trying to reach path from - * basedir? - * @param base base File (dir). - */ - public boolean isSymlink(File base) { - for (int i = 0; i < tokenizedPath.length; i++) { - try { - if ((base != null - && SYMLINK_UTILS.isSymbolicLink(base, tokenizedPath[i])) - || - (base == null - && SYMLINK_UTILS.isSymbolicLink(tokenizedPath[i])) - ) { - return true; - } - base = new File(base, tokenizedPath[i]); - } catch (java.io.IOException ioe) { - String msg = "IOException caught while checking " - + "for links, couldn't get canonical path!"; - // will be caught and redirected to Ant's logging system - System.err.println(msg); - } - } - return false; - } - - /** - * true if the original paths are equal. - */ - @Override - public boolean equals(Object o) { - return o instanceof TokenizedPath - && path.equals(((TokenizedPath) o).path); - } - - @Override - public int hashCode() { - return path.hashCode(); - } - - /** - * From <code>base</code> traverse the filesystem in order to find - * a file that matches the given stack of names. - * - * @param base base File (dir) - must not be null. - * @param pathElements array of path elements (dirs...file). - * @param cs whether to scan case-sensitively. - * @return File object that points to the file in question or null. - */ - private static File findFile(File base, final String[] pathElements, - final boolean cs) { - for (int current = 0; current < pathElements.length; current++) { - if (!base.isDirectory()) { - return null; - } - String[] files = base.list(); - if (files == null) { - throw new BuildException("IO error scanning directory " - + base.getAbsolutePath()); - } - boolean found = false; - boolean[] matchCase = cs ? CS_SCAN_ONLY : CS_THEN_NON_CS; - for (int i = 0; !found && i < matchCase.length; i++) { - for (int j = 0; !found && j < files.length; j++) { - if (matchCase[i] - ? files[j].equals(pathElements[current]) - : files[j].equalsIgnoreCase(pathElements[current])) { - base = new File(base, files[j]); - found = true; - } - } - } - if (!found) { - return null; - } - } - return pathElements.length == 0 && !base.isDirectory() ? null : base; - } - - /** - * Creates a TokenizedPattern from the same tokens that make up - * this path. - */ - public TokenizedPattern toPattern() { - return new TokenizedPattern(path, tokenizedPath); - } - -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/TokenizedPattern.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/TokenizedPattern.java deleted file mode 100644 index dbe7ec81..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/TokenizedPattern.java +++ /dev/null @@ -1,177 +0,0 @@ -/* - * 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.selectors; - -import java.io.File; - -/** - * Provides reusable path pattern matching. PathPattern is preferable - * to equivalent SelectorUtils methods if you need to execute multiple - * matching with the same pattern because here the pattern itself will - * be parsed only once. - * @see SelectorUtils#matchPath(String, String) - * @see SelectorUtils#matchPath(String, String, boolean) - * @since 1.8.0 - */ -public class TokenizedPattern { - - /** - * Instance that holds no tokens at all. - */ - public static final TokenizedPattern EMPTY_PATTERN = - new TokenizedPattern("", new String[0]); - - private final String pattern; - private final String[] tokenizedPattern; - - /** - * Initialize the PathPattern by parsing it. - * @param pattern The pattern to match against. Must not be - * <code>null</code>. - */ - public TokenizedPattern(String pattern) { - this(pattern, SelectorUtils.tokenizePathAsArray(pattern)); - } - - TokenizedPattern(String pattern, String[] tokens) { - this.pattern = pattern; - this.tokenizedPattern = tokens; - } - - /** - * Tests whether or not a given path matches a given pattern. - * - * @param path The path to match, as a String. Must not be - * <code>null</code>. - * @param isCaseSensitive Whether or not matching should be performed - * case sensitively. - * - * @return <code>true</code> if the pattern matches against the string, - * or <code>false</code> otherwise. - */ - public boolean matchPath(TokenizedPath path, boolean isCaseSensitive) { - return SelectorUtils.matchPath(tokenizedPattern, path.getTokens(), - isCaseSensitive); - } - - /** - * Tests whether or not this pattern matches the start of - * a path. - */ - public boolean matchStartOf(TokenizedPath path, - boolean caseSensitive) { - return SelectorUtils.matchPatternStart(tokenizedPattern, - path.getTokens(), caseSensitive); - } - - /** - * @return The pattern String - */ - public String toString() { - return pattern; - } - - public String getPattern() { - return pattern; - } - - /** - * true if the original patterns are equal. - */ - public boolean equals(Object o) { - return o instanceof TokenizedPattern - && pattern.equals(((TokenizedPattern) o).pattern); - } - - public int hashCode() { - return pattern.hashCode(); - } - - /** - * The depth (or length) of a pattern. - */ - public int depth() { - return tokenizedPattern.length; - } - - /** - * Does the tokenized pattern contain the given string? - */ - public boolean containsPattern(String pat) { - for (int i = 0; i < tokenizedPattern.length; i++) { - if (tokenizedPattern[i].equals(pat)) { - return true; - } - } - return false; - } - - /** - * Returns a new TokenizedPath where all tokens of this pattern to - * the right containing wildcards have been removed - * @return the leftmost part of the pattern without wildcards - */ - public TokenizedPath rtrimWildcardTokens() { - StringBuilder sb = new StringBuilder(); - int newLen = 0; - for (; newLen < tokenizedPattern.length; newLen++) { - if (SelectorUtils.hasWildcards(tokenizedPattern[newLen])) { - break; - } - if (newLen > 0 - && sb.charAt(sb.length() - 1) != File.separatorChar) { - sb.append(File.separator); - } - sb.append(tokenizedPattern[newLen]); - } - if (newLen == 0) { - return TokenizedPath.EMPTY_PATH; - } - String[] newPats = new String[newLen]; - System.arraycopy(tokenizedPattern, 0, newPats, 0, newLen); - return new TokenizedPath(sb.toString(), newPats); - } - - /** - * true if the last token equals the given string. - */ - public boolean endsWith(String s) { - return tokenizedPattern.length > 0 - && tokenizedPattern[tokenizedPattern.length - 1].equals(s); - } - - /** - * Returns a new pattern without the last token of this pattern. - */ - public TokenizedPattern withoutLastToken() { - if (tokenizedPattern.length == 0) { - throw new IllegalStateException("can't strip a token from nothing"); - } else if (tokenizedPattern.length == 1) { - return EMPTY_PATTERN; - } else { - String toStrip = tokenizedPattern[tokenizedPattern.length - 1]; - int index = pattern.lastIndexOf(toStrip); - String[] tokens = new String[tokenizedPattern.length - 1]; - System.arraycopy(tokenizedPattern, 0, tokens, 0, - tokenizedPattern.length - 1); - return new TokenizedPattern(pattern.substring(0, index), tokens); - } - } - -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/TypeSelector.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/TypeSelector.java deleted file mode 100644 index fd3684d6..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/TypeSelector.java +++ /dev/null @@ -1,135 +0,0 @@ -/* - * 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.selectors; - -import java.io.File; - -import org.apache.tools.ant.types.EnumeratedAttribute; -import org.apache.tools.ant.types.Parameter; - -/** - * Selector that selects a certain kind of file: directory or regular. - * - * @since 1.6 - */ -public class TypeSelector extends BaseExtendSelector { - - private String type = null; - - /** Key to used for parameterized custom selector */ - public static final String TYPE_KEY = "type"; - - /** - * Creates a new <code>TypeSelector</code> instance. - * - */ - public TypeSelector() { - } - - /** - * @return a string describing this object - */ - public String toString() { - StringBuilder buf = new StringBuilder("{typeselector type: "); - buf.append(type); - buf.append("}"); - return buf.toString(); - } - - /** - * Set the type of file to require. - * @param fileTypes the type of file - file or dir - */ - public void setType(FileType fileTypes) { - this.type = fileTypes.getValue(); - } - - /** - * When using this as a custom selector, this method will be called. - * It translates each parameter into the appropriate setXXX() call. - * - * @param parameters the complete set of parameters for this selector - */ - public void setParameters(Parameter[] parameters) { - super.setParameters(parameters); - if (parameters != null) { - for (int i = 0; i < parameters.length; i++) { - String paramname = parameters[i].getName(); - if (TYPE_KEY.equalsIgnoreCase(paramname)) { - FileType t = new FileType(); - t.setValue(parameters[i].getValue()); - setType(t); - } else { - setError("Invalid parameter " + paramname); - } - } - } - } - - /** - * Checks to make sure all settings are kosher. In this case, it - * means that the pattern attribute has been set. - * - */ - public void verifySettings() { - if (type == null) { - setError("The type attribute is required"); - } - } - - /** - * The heart of the matter. This is where the selector gets to decide - * on the inclusion of a file in a particular fileset. - * - * @param basedir the base directory the scan is being done from - * @param filename is the name of the file to check - * @param file is a java.io.File object the selector can use - * @return whether the file should be selected or not - */ - public boolean isSelected(File basedir, String filename, File file) { - - // throw BuildException on error - validate(); - - if (file.isDirectory()) { - return type.equals(FileType.DIR); - } else { - return type.equals(FileType.FILE); - } - } - - /** - * Enumerated attribute with the values for types of file - */ - public static class FileType extends EnumeratedAttribute { - /** the string value for file */ - public static final String FILE = "file"; - /** the string value for dir */ - public static final String DIR = "dir"; - - /** - * @return the values as an array of strings - */ - public String[] getValues() { - return new String[]{FILE, DIR}; - } - } - - -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/WritableSelector.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/WritableSelector.java deleted file mode 100644 index c7391f02..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/WritableSelector.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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.selectors; - -import java.io.File; - -import org.apache.tools.ant.types.Resource; -import org.apache.tools.ant.types.resources.FileProvider; -import org.apache.tools.ant.types.resources.selectors.ResourceSelector; - -/** - * A selector that selects writable files. - * - * <p>Writable is defined in terms of java.io.File#canWrite, this - * means the selector will accept any file that exists and is - * writable by the application.</p> - * - * @since Ant 1.8.0 - */ -public class WritableSelector implements FileSelector, ResourceSelector { - - public boolean isSelected(File basedir, String filename, File file) { - return file != null && file.canWrite(); - } - - public boolean isSelected(Resource r) { - FileProvider fp = r.as(FileProvider.class); - return fp != null && isSelected(null, null, fp.getFile()); - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/modifiedselector/Algorithm.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/modifiedselector/Algorithm.java deleted file mode 100644 index 82e043b5..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/modifiedselector/Algorithm.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * 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.selectors.modifiedselector; - - -import java.io.File; - - -/** - * The <i>Algorithm</i> defines how a value for a file is computed. - * It must be sure that multiple calls for the same file results in the - * same value. - * The implementing class should implement a useful toString() method. - * - * @version 2003-09-13 - * @since Ant 1.6 - */ -public interface Algorithm { - - /** - * Checks its prerequisites. - * @return <i>true</i> if all is ok, otherwise <i>false</i>. - */ - boolean isValid(); - - /** - * Get the value for a file. - * @param file File object for which the value should be evaluated. - * @return The value for that file - */ - String getValue(File file); -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/modifiedselector/Cache.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/modifiedselector/Cache.java deleted file mode 100644 index 13c74c2b..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/modifiedselector/Cache.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * 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.selectors.modifiedselector; - - -import java.util.Iterator; - - -/** - * A Cache let the user store key-value-pairs in a permanent manner and access - * them. - * It is possible that a client uses get() before load() therefore the - * implementation must ensure that no error occurred because of the wrong - * <i>order</i>. - * The implementing class should implement a useful toString() method. - * - * @version 2003-09-13 - * @since Ant 1.6 - */ -public interface Cache { - - /** - * Checks its prerequisites. - * @return <i>true</i> if all is ok, otherwise <i>false</i>. - */ - boolean isValid(); - - /** Deletes the cache. If file based the file has to be deleted also. */ - void delete(); - - /** Loads the cache, must handle not existing cache. */ - void load(); - - /** Saves modification of the cache. */ - void save(); - - /** - * Returns a value for a given key from the cache. - * @param key the key - * @return the stored value - */ - Object get(Object key); - - /** - * Saves a key-value-pair in the cache. - * @param key the key - * @param value the value - */ - void put(Object key, Object value); - - /** - * Returns an iterator over the keys in the cache. - * @return An iterator over the keys. - */ - Iterator<String> iterator(); -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/modifiedselector/ChecksumAlgorithm.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/modifiedselector/ChecksumAlgorithm.java deleted file mode 100644 index 210d5dc9..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/modifiedselector/ChecksumAlgorithm.java +++ /dev/null @@ -1,151 +0,0 @@ -/* - * 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.selectors.modifiedselector; - -import java.io.BufferedInputStream; -import java.io.File; -import java.io.FileInputStream; -import java.security.NoSuchAlgorithmException; -import java.util.Locale; -import java.util.zip.Adler32; -import java.util.zip.CRC32; -import java.util.zip.CheckedInputStream; -import java.util.zip.Checksum; - -import org.apache.tools.ant.BuildException; - - -/** - * Computes a 'checksum' for the content of file using - * java.util.zip.CRC32 and java.util.zip.Adler32. - * Use of this algorithm doesn't require any additional nested <param>s. - * Supported <param>s are: - * <table> - * <tr> - * <th>name</th><th>values</th><th>description</th><th>required</th> - * </tr> - * <tr> - * <td> algorithm.algorithm </td> - * <td> ADLER | CRC ( default ) </td> - * <td> name of the algorithm the checksum should use </td> - * <td> no, defaults to CRC </td> - * </tr> - * </table> - * - * @version 2004-06-17 - * @since Ant 1.7 - */ -public class ChecksumAlgorithm implements Algorithm { - - - // ----- member variables ----- - - - /** - * Checksum algorithm to be used. - */ - private String algorithm = "CRC"; - - /** - * Checksum interface instance - */ - private Checksum checksum = null; - - - // ----- Algorithm-Configuration ----- - - - /** - * Specifies the algorithm to be used to compute the checksum. - * Defaults to "CRC". Other popular algorithms like "ADLER" may be used as well. - * @param algorithm the digest algorithm to use - */ - public void setAlgorithm(String algorithm) { - this.algorithm = - algorithm != null ? algorithm.toUpperCase(Locale.ENGLISH) : null; - } - - - /** Initialize the checksum interface. */ - public void initChecksum() { - if (checksum != null) { - return; - } - if ("CRC".equals(algorithm)) { - checksum = new CRC32(); - } else if ("ADLER".equals(algorithm)) { - checksum = new Adler32(); - } else { - throw new BuildException(new NoSuchAlgorithmException()); - } - } - - - // ----- Logic ----- - - - /** - * This algorithm supports only CRC and Adler. - * @return <i>true</i> if all is ok, otherwise <i>false</i>. - */ - public boolean isValid() { - return "CRC".equals(algorithm) || "ADLER".equals(algorithm); - } - - - /** - * Computes a value for a file content with the specified checksum algorithm. - * @param file File object for which the value should be evaluated. - * @return The value for that file - */ - public String getValue(File file) { - initChecksum(); - String rval = null; - - try { - if (file.canRead()) { - checksum.reset(); - FileInputStream fis = new FileInputStream(file); - CheckedInputStream check = new CheckedInputStream(fis, checksum); - BufferedInputStream in = new BufferedInputStream(check); - while (in.read() != -1) { - // Read the file - } - rval = Long.toString(check.getChecksum().getValue()); - in.close(); - } - } catch (Exception e) { - rval = null; - } - return rval; - } - - - /** - * Override Object.toString(). - * @return some information about this algorithm. - */ - public String toString() { - StringBuilder buf = new StringBuilder(); - buf.append("<ChecksumAlgorithm:"); - buf.append("algorithm=").append(algorithm); - buf.append(">"); - return buf.toString(); - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/modifiedselector/DigestAlgorithm.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/modifiedselector/DigestAlgorithm.java deleted file mode 100644 index 085b4fe7..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/modifiedselector/DigestAlgorithm.java +++ /dev/null @@ -1,208 +0,0 @@ -/* - * 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.selectors.modifiedselector; - - -import java.io.File; -import java.io.FileInputStream; -import java.security.DigestInputStream; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; -import java.security.NoSuchProviderException; -import java.util.Locale; - -import org.apache.tools.ant.BuildException; - - -/** - * Computes a 'hashvalue' for the content of file using - * java.security.MessageDigest. - * Use of this algorithm doesn't require any additional nested <param>s. - * Supported <param>s are: - * <table> - * <tr> - * <th>name</th><th>values</th><th>description</th><th>required</th> - * </tr> - * <tr> - * <td> algorithm.algorithm </td> - * <td> MD5 | SHA (default provider) </td> - * <td> name of the algorithm the provider should use </td> - * <td> no, defaults to MD5 </td> - * </tr> - * <tr> - * <td> algorithm.provider </td> - * <td> </td> - * <td> name of the provider to use </td> - * <td> no, defaults to <i>null</i> </td> - * </tr> - * </table> - * - * @version 2004-07-08 - * @since Ant 1.6 - */ -public class DigestAlgorithm implements Algorithm { - - private static final int BYTE_MASK = 0xFF; - private static final int BUFFER_SIZE = 8192; - - // ----- member variables ----- - - - /** - * MessageDigest algorithm to be used. - */ - private String algorithm = "MD5"; - - /** - * MessageDigest Algorithm provider - */ - private String provider = null; - - /** - * Message Digest instance - */ - private MessageDigest messageDigest = null; - - /** - * Size of the read buffer to use. - */ - private int readBufferSize = BUFFER_SIZE; - - - // ----- Algorithm-Configuration ----- - - - /** - * Specifies the algorithm to be used to compute the checksum. - * Defaults to "MD5". Other popular algorithms like "SHA" may be used as well. - * @param algorithm the digest algorithm to use - */ - public void setAlgorithm(String algorithm) { - this.algorithm = algorithm != null - ? algorithm.toUpperCase(Locale.ENGLISH) : null; - } - - - /** - * Sets the MessageDigest algorithm provider to be used - * to calculate the checksum. - * @param provider provider to use - */ - public void setProvider(String provider) { - this.provider = provider; - } - - - /** Initialize the security message digest. */ - public void initMessageDigest() { - if (messageDigest != null) { - return; - } - - if ((provider != null) && !"".equals(provider) && !"null".equals(provider)) { - try { - messageDigest = MessageDigest.getInstance(algorithm, provider); - } catch (NoSuchAlgorithmException noalgo) { - throw new BuildException(noalgo); - } catch (NoSuchProviderException noprovider) { - throw new BuildException(noprovider); - } - } else { - try { - messageDigest = MessageDigest.getInstance(algorithm); - } catch (NoSuchAlgorithmException noalgo) { - throw new BuildException(noalgo); - } - } - } - - - // ----- Logic ----- - - - /** - * This algorithm supports only MD5 and SHA. - * @return <i>true</i> if all is ok, otherwise <i>false</i>. - */ - public boolean isValid() { - return "SHA".equals(algorithm) || "MD5".equals(algorithm); - } - - - /** - * Computes a value for a file content with the specified digest algorithm. - * @param file File object for which the value should be evaluated. - * @return The value for that file - */ - // implementation adapted from ...taskdefs.Checksum, thanks to Magesh for hint - public String getValue(File file) { - initMessageDigest(); - String checksum = null; - try { - if (!file.canRead()) { - return null; - } - FileInputStream fis = null; - - byte[] buf = new byte[readBufferSize]; - try { - messageDigest.reset(); - fis = new FileInputStream(file); - DigestInputStream dis = new DigestInputStream(fis, - messageDigest); - while (dis.read(buf, 0, readBufferSize) != -1) { - // do nothing - } - dis.close(); - fis.close(); - fis = null; - byte[] fileDigest = messageDigest.digest(); - StringBuffer checksumSb = new StringBuffer(); - for (int i = 0; i < fileDigest.length; i++) { - String hexStr - = Integer.toHexString(BYTE_MASK & fileDigest[i]); - if (hexStr.length() < 2) { - checksumSb.append("0"); - } - checksumSb.append(hexStr); - } - checksum = checksumSb.toString(); - } catch (Exception e) { - return null; - } - } catch (Exception e) { - return null; - } - return checksum; - } - - - /** - * Override Object.toString(). - * @return some information about this algorithm. - */ - public String toString() { - StringBuilder buf = new StringBuilder(); - buf.append("<DigestAlgorithm:"); - buf.append("algorithm=").append(algorithm); - buf.append(";provider=").append(provider); - buf.append(">"); - return buf.toString(); - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/modifiedselector/EqualComparator.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/modifiedselector/EqualComparator.java deleted file mode 100644 index 94fb9351..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/modifiedselector/EqualComparator.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * 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.selectors.modifiedselector; - - -import java.util.Comparator; - - -/** - * Simple implementation of Comparator for use in CacheSelector. - * compare() returns '0' (should not be selected) if both parameter - * are equal otherwise '1' (should be selected). - * - * @version 2003-09-13 - * @since Ant 1.6 - */ -public class EqualComparator implements Comparator<Object> { - - /** - * Implements Comparator.compare(). - * @param o1 the first object - * @param o2 the second object - * @return 0, if both are equal, otherwise 1 - */ - public int compare(Object o1, Object o2) { - if (o1 == null) { - if (o2 == null) { - return 1; - } - return 0; - } - return (o1.equals(o2)) ? 0 : 1; - } - - /** - * Override Object.toString(). - * @return information about this comparator - */ - public String toString() { - return "EqualComparator"; - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/modifiedselector/HashvalueAlgorithm.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/modifiedselector/HashvalueAlgorithm.java deleted file mode 100644 index 8af9d12e..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/modifiedselector/HashvalueAlgorithm.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * 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.selectors.modifiedselector; - -import java.io.File; -import java.io.FileReader; -import java.io.Reader; - -import org.apache.tools.ant.util.FileUtils; - -/** - * Computes a 'hashvalue' for the content of file using String.hashValue(). - * Use of this algorithm doesn't require any additional nested <param>s and - * doesn't support any. - * - * @version 2003-09-13 - * @since Ant 1.6 - */ -public class HashvalueAlgorithm implements Algorithm { - - /** - * This algorithm doesn't need any configuration. - * Therefore it's always valid. - * @return always true - */ - public boolean isValid() { - return true; - } - - /** - * Computes a 'hashvalue' for a file content. - * It reads the content of a file, convert that to String and use the - * String.hashCode() method. - * @param file The file for which the value should be computed - * @return the hashvalue or <i>null</i> if the file couldn't be read - */ - // Because the content is only read the file will not be damaged. I tested - // with JPG, ZIP and PDF as binary files. - public String getValue(File file) { - Reader r = null; - try { - if (!file.canRead()) { - return null; - } - r = new FileReader(file); - int hash = FileUtils.readFully(r).hashCode(); - return Integer.toString(hash); - } catch (Exception e) { - return null; - } finally { - FileUtils.close(r); - } - } - - - /** - * Override Object.toString(). - * @return information about this comparator - */ - public String toString() { - return "HashvalueAlgorithm"; - } - -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/modifiedselector/ModifiedSelector.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/modifiedselector/ModifiedSelector.java deleted file mode 100644 index 9f538098..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/modifiedselector/ModifiedSelector.java +++ /dev/null @@ -1,971 +0,0 @@ -/* - * 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.selectors.modifiedselector; - - -// Java -import java.io.File; -import java.util.Comparator; -import java.util.Iterator; -import java.util.Vector; - -import org.apache.tools.ant.BuildEvent; -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.BuildListener; -import org.apache.tools.ant.IntrospectionHelper; -// Ant -import org.apache.tools.ant.Project; -import org.apache.tools.ant.types.EnumeratedAttribute; -import org.apache.tools.ant.types.Parameter; -import org.apache.tools.ant.types.Path; -import org.apache.tools.ant.types.Resource; -import org.apache.tools.ant.types.resources.FileResource; -import org.apache.tools.ant.types.resources.selectors.ResourceSelector; -import org.apache.tools.ant.types.selectors.BaseExtendSelector; -import org.apache.tools.ant.util.FileUtils; -import org.apache.tools.ant.util.ResourceUtils; - - -/** - * <p>Selector class that uses <i>Algorithm</i>, <i>Cache</i> and <i>Comparator</i> - * for its work. - * The <i>Algorithm</i> is used for computing a hashvalue for a file. - * The <i>Comparator</i> decides whether to select or not. - * The <i>Cache</i> stores the other value for comparison by the <i>Comparator</i> - * in a persistent manner.</p> - * - * <p>The ModifiedSelector is implemented as a <b>CoreSelector</b> and uses default - * values for all its attributes therefore the simplest example is <pre> - * <copy todir="dest"> - * <filelist dir="src"> - * <modified/> - * </filelist> - * </copy> - * </pre></p> - * - * <p>The same example rewritten as CoreSelector with setting the all values - * (same as defaults are) would be <pre> - * <copy todir="dest"> - * <filelist dir="src"> - * <modified update="true" - * cache="propertyfile" - * algorithm="digest" - * comparator="equal"> - * <param name="cache.cachefile" value="cache.properties"/> - * <param name="algorithm.algorithm" value="MD5"/> - * </modified> - * </filelist> - * </copy> - * </pre></p> - * - * <p>And the same rewritten as CustomSelector would be<pre> - * <copy todir="dest"> - * <filelist dir="src"> - * <custom class="org.apache.tools.ant.type.selectors.ModifiedSelector"> - * <param name="update" value="true"/> - * <param name="cache" value="propertyfile"/> - * <param name="algorithm" value="digest"/> - * <param name="comparator" value="equal"/> - * <param name="cache.cachefile" value="cache.properties"/> - * <param name="algorithm.algorithm" value="MD5"/> - * </custom> - * </filelist> - * </copy> - * </pre></p> - * - * <p>If you want to provide your own interface implementation you can do - * that via the *classname attributes. If the classes are not on Ant's core - * classpath, you will have to provide the path via nested <classpath> - * element, so that the selector can find the classes. <pre> - * <modified cacheclassname="com.mycompany.MyCache"> - * <classpath> - * <pathelement location="lib/mycompany-antutil.jar"/> - * </classpath> - * </modified> - * </pre></p> - * - * <p>All these three examples copy the files from <i>src</i> to <i>dest</i> - * using the ModifiedSelector. The ModifiedSelector uses the <i>PropertyfileCache - * </i>, the <i>DigestAlgorithm</i> and the <i>EqualComparator</i> for its - * work. The PropertyfileCache stores key-value-pairs in a simple java - * properties file. The filename is <i>cache.properties</i>. The <i>update</i> - * flag lets the selector update the values in the cache (and on first call - * creates the cache). The <i>DigestAlgorithm</i> computes a hashvalue using the - * java.security.MessageDigest class with its MD5-Algorithm and its standard - * provider. The new computed hashvalue and the stored one are compared by - * the <i>EqualComparator</i> which returns 'true' (more correct a value not - * equals zero (1)) if the values are not the same using simple String - * comparison.</p> - * - * <p>A useful scenario for this selector is inside a build environment - * for homepage generation (e.g. with <a href="http://forrest.apache.org/"> - * Apache Forrest</a>). <pre> - * <target name="generate-and-upload-site"> - * <echo> generate the site using forrest </echo> - * <antcall target="site"/> - * - * <echo> upload the changed files </echo> - * <ftp server="${ftp.server}" userid="${ftp.user}" password="${ftp.pwd}"> - * <fileset dir="htdocs/manual"> - * <modified/> - * </fileset> - * </ftp> - * </target> - * </pre> Here all <b>changed</b> files are uploaded to the server. The - * ModifiedSelector saves therefore much upload time.</p> - * - * - * <p>This selector uses reflection for setting the values of its three interfaces - * (using org.apache.tools.ant.IntrospectionHelper) therefore no special - * 'configuration interfaces' has to be implemented by new caches, algorithms or - * comparators. All present <i>set</i>XX methods can be used. E.g. the DigestAlgorithm - * can use a specified provider for computing its value. For selecting this - * there is a <i>setProvider(String providername)</i> method. So you can use - * a nested <i><param name="algorithm.provider" value="MyProvider"/></i>. - * - * - * @since Ant 1.6 - */ -public class ModifiedSelector extends BaseExtendSelector - implements BuildListener, ResourceSelector { - - private static final String CACHE_PREFIX = "cache."; - private static final String ALGORITHM_PREFIX = "algorithm."; - private static final String COMPARATOR_PREFIX = "comparator."; - - - // ----- attributes ----- - - - /** Cache name for later instantiation. */ - private CacheName cacheName = null; - - /** User specified classname for Cache. */ - private String cacheClass; - - /** Algorithm name for later instantiation. */ - private AlgorithmName algoName = null; - - /** User specified classname for Algorithm. */ - private String algorithmClass; - - /** Comparator name for later instantiation. */ - private ComparatorName compName = null; - - /** User specified classname for Comparator. */ - private String comparatorClass; - - /** Should the cache be updated? */ - private boolean update = true; - - /** Are directories selected? */ - private boolean selectDirectories = true; - - /** - * Should Resources whithout an InputStream, and - * therefore without checking, be selected? - */ - private boolean selectResourcesWithoutInputStream = true; - - /** Delay the writing of the cache file */ - private boolean delayUpdate = true; - - - // ----- internal member variables ----- - - - /** How should the cached value and the new one compared? */ - private Comparator<? super String> comparator = null; - - /** Algorithm for computing new values and updating the cache. */ - private Algorithm algorithm = null; - - /** The Cache containing the old values. */ - private Cache cache = null; - - /** Count of modified properties */ - private int modified = 0; - - /** Flag whether this object is configured. Configuration is only done once. */ - private boolean isConfigured = false; - - /** - * Parameter vector with parameters for later initialization. - * @see #configure - */ - private Vector<Parameter> configParameter = new Vector<Parameter>(); - - /** - * Parameter vector with special parameters for later initialization. - * The names have the pattern '*.*', e.g. 'cache.cachefile'. - * These parameters are used <b>after</b> the parameters with the pattern '*'. - * @see #configure - */ - private Vector<Parameter> specialParameter = new Vector<Parameter>(); - - /** The classloader of this class. */ - private ClassLoader myClassLoader = null; - - /** provided classpath for the classloader */ - private Path classpath = null; - - - // ----- constructors ----- - - - /** Bean-Constructor. */ - public ModifiedSelector() { - } - - - // ----- configuration ----- - - - /** Overrides BaseSelector.verifySettings(). */ - public void verifySettings() { - configure(); - if (cache == null) { - setError("Cache must be set."); - } else if (algorithm == null) { - setError("Algorithm must be set."); - } else if (!cache.isValid()) { - setError("Cache must be proper configured."); - } else if (!algorithm.isValid()) { - setError("Algorithm must be proper configured."); - } - } - - - /** - * Configures this Selector. - * Does this work only once per Selector object. - * <p>Because some problems while configuring from <custom>Selector - * the configuration is done in the following order:<ol> - * <li> collect the configuration data </li> - * <li> wait for the first isSelected() call </li> - * <li> set the default values </li> - * <li> set values for name pattern '*': update, cache, algorithm, comparator </li> - * <li> set values for name pattern '*.*: cache.cachefile, ... </li> - * </ol></p> - * <p>This configuration algorithm is needed because you don't know - * the order of arriving config-data. E.g. if you first set the - * <i>cache.cachefilename</i> and after that the <i>cache</i> itself, - * the default value for cachefilename is used, because setting the - * cache implies creating a new Cache instance - with its defaults.</p> - */ - public void configure() { - // - // ----- The "Singleton" ----- - // - if (isConfigured) { - return; - } - isConfigured = true; - - // - // ----- Set default values ----- - // - Project p = getProject(); - String filename = "cache.properties"; - File cachefile = null; - if (p != null) { - // normal use inside Ant - cachefile = new File(p.getBaseDir(), filename); - - // set self as a BuildListener to delay cachefile saves - getProject().addBuildListener(this); - } else { - // no reference to project - e.g. during normal JUnit tests - cachefile = new File(filename); - setDelayUpdate(false); - } - Cache defaultCache = new PropertiesfileCache(cachefile); - Algorithm defaultAlgorithm = new DigestAlgorithm(); - Comparator<? super String> defaultComparator = new EqualComparator(); - - // - // ----- Set the main attributes, pattern '*' ----- - // - for (Parameter parameter : configParameter) { - if (parameter.getName().indexOf(".") > 0) { - // this is a *.* parameter for later use - specialParameter.add(parameter); - } else { - useParameter(parameter); - } - } - configParameter = new Vector<Parameter>(); - - // specify the algorithm classname - if (algoName != null) { - // use Algorithm defined via name - if ("hashvalue".equals(algoName.getValue())) { - algorithm = new HashvalueAlgorithm(); - } else if ("digest".equals(algoName.getValue())) { - algorithm = new DigestAlgorithm(); - } else if ("checksum".equals(algoName.getValue())) { - algorithm = new ChecksumAlgorithm(); - } - } else { - if (algorithmClass != null) { - // use Algorithm specified by classname - algorithm = loadClass( - algorithmClass, - "is not an Algorithm.", - Algorithm.class); - } else { - // nothing specified - use default - algorithm = defaultAlgorithm; - } - } - - // specify the cache classname - if (cacheName != null) { - // use Cache defined via name - if ("propertyfile".equals(cacheName.getValue())) { - cache = new PropertiesfileCache(); - } - } else { - if (cacheClass != null) { - // use Cache specified by classname - cache = loadClass(cacheClass, "is not a Cache.", Cache.class); - } else { - // nothing specified - use default - cache = defaultCache; - } - } - - // specify the comparator classname - if (compName != null) { - // use Algorithm defined via name - if ("equal".equals(compName.getValue())) { - comparator = new EqualComparator(); - } else if ("rule".equals(compName.getValue())) { - // TODO there is a problem with the constructor for the RBC. - // you have to provide the rules in the constructors - no setters - // available. - throw new BuildException("RuleBasedCollator not yet supported."); - // Have to think about lazy initialization here... JHM - // comparator = new java.text.RuleBasedCollator(); - } - } else { - if (comparatorClass != null) { - // use Algorithm specified by classname - @SuppressWarnings("unchecked") - Comparator<? super String> localComparator = loadClass(comparatorClass, "is not a Comparator.", Comparator.class); - comparator = localComparator; - } else { - // nothing specified - use default - comparator = defaultComparator; - } - } - - // - // ----- Set the special attributes, pattern '*.*' ----- - // - for (Iterator<Parameter> itSpecial = specialParameter.iterator(); itSpecial.hasNext();) { - Parameter par = itSpecial.next(); - useParameter(par); - } - specialParameter = new Vector<Parameter>(); - } - - - /** - * Loads the specified class and initializes an object of that class. - * Throws a BuildException using the given message if an error occurs during - * loading/instantiation or if the object is not from the given type. - * @param classname the classname - * @param msg the message-part for the BuildException - * @param type the type to check against - * @return a castable object - */ - protected <T> T loadClass(String classname, String msg, Class<? extends T> type) { - try { - // load the specified class - ClassLoader cl = getClassLoader(); - Class<?> clazz = null; - if (cl != null) { - clazz = cl.loadClass(classname); - } else { - clazz = Class.forName(classname); - } - - Object rv = clazz.newInstance(); - - if (!type.isInstance(rv)) { - throw new BuildException("Specified class (" + classname + ") " + msg); - } - return (T) rv; - } catch (ClassNotFoundException e) { - throw new BuildException("Specified class (" + classname + ") not found."); - } catch (Exception e) { - throw new BuildException(e); - } - } - - - // ----- the selection work ----- - - - /** - * Implementation of ResourceSelector.isSelected(). - * - * @param resource The resource to check - * @return whether the resource is selected - * @see ResourceSelector#isSelected(Resource) - */ - public boolean isSelected(Resource resource) { - if (resource.isFilesystemOnly()) { - // We have a 'resourced' file, so reconvert it and use - // the 'old' implementation. - FileResource fileResource = (FileResource) resource; - File file = fileResource.getFile(); - String filename = fileResource.getName(); - File basedir = fileResource.getBaseDir(); - return isSelected(basedir, filename, file); - } else { - try { - // How to handle non-file-Resources? I copy temporarily the - // resource to a file and use the file-implementation. - FileUtils fu = FileUtils.getFileUtils(); - File tmpFile = fu.createTempFile("modified-", ".tmp", null, true, false); - Resource tmpResource = new FileResource(tmpFile); - ResourceUtils.copyResource(resource, tmpResource); - boolean isSelected = isSelected(tmpFile.getParentFile(), - tmpFile.getName(), - resource.toLongString()); - tmpFile.delete(); - return isSelected; - } catch (UnsupportedOperationException uoe) { - log("The resource '" - + resource.getName() - + "' does not provide an InputStream, so it is not checked. " - + "Akkording to 'selres' attribute value it is " - + ((selectResourcesWithoutInputStream) ? "" : " not") - + "selected.", Project.MSG_INFO); - return selectResourcesWithoutInputStream; - } catch (Exception e) { - throw new BuildException(e); - } - } - } - - - /** - * Implementation of BaseExtendSelector.isSelected(). - * - * @param basedir as described in BaseExtendSelector - * @param filename as described in BaseExtendSelector - * @param file as described in BaseExtendSelector - * @return as described in BaseExtendSelector - */ - public boolean isSelected(File basedir, String filename, File file) { - return isSelected(basedir, filename, file.getAbsolutePath()); - } - - - /** - * The business logic of this selector for use as ResourceSelector of - * FileSelector. - * - * @param basedir as described in BaseExtendSelector - * @param filename as described in BaseExtendSelector - * @param cacheKey the name for the key for storing the hashvalue - * @return <tt>true</tt> if the file is selected otherwise <tt>false</tt> - */ - private boolean isSelected(File basedir, String filename, String cacheKey) { - validate(); - File f = new File(basedir, filename); - - // You can not compute a value for a directory - if (f.isDirectory()) { - return selectDirectories; - } - - // Get the values and do the comparison - String cachedValue = String.valueOf(cache.get(f.getAbsolutePath())); - String newValue = algorithm.getValue(f); - - boolean rv = (comparator.compare(cachedValue, newValue) != 0); - - // Maybe update the cache - if (update && rv) { - cache.put(f.getAbsolutePath(), newValue); - setModified(getModified() + 1); - if (!getDelayUpdate()) { - saveCache(); - } - } - - return rv; - } - - - /** - * save the cache file - */ - protected void saveCache() { - if (getModified() > 0) { - cache.save(); - setModified(0); - } - } - - - // ----- attribute and nested element support ----- - - - /** - * Setter for algorithmClass. - * @param classname new value - */ - public void setAlgorithmClass(String classname) { - algorithmClass = classname; - } - - - /** - * Setter for comparatorClass. - * @param classname new value - */ - public void setComparatorClass(String classname) { - comparatorClass = classname; - } - - - /** - * Setter for cacheClass. - * @param classname new value - */ - public void setCacheClass(String classname) { - cacheClass = classname; - } - - - /** - * Support for <i>update</i> attribute. - * @param update new value - */ - public void setUpdate(boolean update) { - this.update = update; - } - - - /** - * Support for <i>seldirs</i> attribute. - * @param seldirs new value - */ - public void setSeldirs(boolean seldirs) { - selectDirectories = seldirs; - } - - - /** - * Support for <i>selres</i> attribute. - * @param newValue the new value - */ - public void setSelres(boolean newValue) { - this.selectResourcesWithoutInputStream = newValue; - } - - - /** - * Getter for the modified count - * @return modified count - */ - public int getModified() { - return modified; - } - - - /** - * Setter for the modified count - * @param modified count - */ - public void setModified(int modified) { - this.modified = modified; - } - - - /** - * Getter for the delay update - * @return true if we should delay for performance - */ - public boolean getDelayUpdate() { - return delayUpdate; - } - - - /** - * Setter for the delay update - * @param delayUpdate true if we should delay for performance - */ - public void setDelayUpdate(boolean delayUpdate) { - this.delayUpdate = delayUpdate; - } - - - /** - * Add the classpath. - * @param path the classpath - */ - public void addClasspath(Path path) { - if (classpath != null) { - throw new BuildException("<classpath> can be set only once."); - } - classpath = path; - } - - - /** - * Returns and initializes the classloader for this class. - * @return the classloader - */ - public ClassLoader getClassLoader() { - if (myClassLoader == null) { - myClassLoader = (classpath == null) - // the usual classloader - ? getClass().getClassLoader() - // additional use the provided classpath - // Memory leak in line below - : getProject().createClassLoader(classpath); - } - return myClassLoader; - } - - - /** - * Set the used ClassLoader. - * If you invoke this selector by API (e.g. inside some testcases) the selector - * will use a different classloader for loading the interface implementations than - * the caller. Therefore you will get a ClassCastException if you get the - * implementations from the selector and cast them. - * @param loader the ClassLoader to use - */ - public void setClassLoader(ClassLoader loader) { - myClassLoader = loader; - } - - - /** - * Support for nested <param> tags. - * @param key the key of the parameter - * @param value the value of the parameter - */ - public void addParam(String key, Object value) { - Parameter par = new Parameter(); - par.setName(key); - par.setValue(String.valueOf(value)); - configParameter.add(par); - } - - - /** - * Support for nested <param> tags. - * @param parameter the parameter object - */ - public void addParam(Parameter parameter) { - configParameter.add(parameter); - } - - - /** - * Defined in org.apache.tools.ant.types.Parameterizable. - * Overwrite implementation in superclass because only special - * parameters are valid. - * @see #addParam(String,Object). - * @param parameters the parameters to set. - */ - public void setParameters(Parameter[] parameters) { - if (parameters != null) { - for (int i = 0; i < parameters.length; i++) { - configParameter.add(parameters[i]); - } - } - } - - - /** - * Support for nested <param name="" value=""/> tags. - * Parameter named <i>cache</i>, <i>algorithm</i>, - * <i>comparator</i> or <i>update</i> are mapped to - * the respective set-Method. - * Parameter which names starts with <i>cache.</i> or - * <i>algorithm.</i> or <i>comparator.</i> are tried - * to set on the appropriate object via its set-methods. - * Other parameters are invalid and an BuildException will - * be thrown. - * - * @param parameter Key and value as parameter object - */ - public void useParameter(Parameter parameter) { - String key = parameter.getName(); - String value = parameter.getValue(); - if ("cache".equals(key)) { - CacheName cn = new CacheName(); - cn.setValue(value); - setCache(cn); - } else if ("algorithm".equals(key)) { - AlgorithmName an = new AlgorithmName(); - an.setValue(value); - setAlgorithm(an); - } else if ("comparator".equals(key)) { - ComparatorName cn = new ComparatorName(); - cn.setValue(value); - setComparator(cn); - } else if ("update".equals(key)) { - boolean updateValue = - ("true".equalsIgnoreCase(value)) - ? true - : false; - setUpdate(updateValue); - } else if ("delayupdate".equals(key)) { - boolean updateValue = - ("true".equalsIgnoreCase(value)) - ? true - : false; - setDelayUpdate(updateValue); - } else if ("seldirs".equals(key)) { - boolean sdValue = - ("true".equalsIgnoreCase(value)) - ? true - : false; - setSeldirs(sdValue); - } else if (key.startsWith(CACHE_PREFIX)) { - String name = key.substring(CACHE_PREFIX.length()); - tryToSetAParameter(cache, name, value); - } else if (key.startsWith(ALGORITHM_PREFIX)) { - String name = key.substring(ALGORITHM_PREFIX.length()); - tryToSetAParameter(algorithm, name, value); - } else if (key.startsWith(COMPARATOR_PREFIX)) { - String name = key.substring(COMPARATOR_PREFIX.length()); - tryToSetAParameter(comparator, name, value); - } else { - setError("Invalid parameter " + key); - } - } - - - /** - * Try to set a value on an object using reflection. - * Helper method for easier access to IntrospectionHelper.setAttribute(). - * @param obj the object on which the attribute should be set - * @param name the attributename - * @param value the new value - */ - protected void tryToSetAParameter(Object obj, String name, String value) { - Project prj = (getProject() != null) ? getProject() : new Project(); - IntrospectionHelper iHelper - = IntrospectionHelper.getHelper(prj, obj.getClass()); - try { - iHelper.setAttribute(prj, obj, name, value); - } catch (org.apache.tools.ant.BuildException e) { - // no-op - } - } - - - // ----- 'beautiful' output ----- - - - /** - * Override Object.toString(). - * @return information about this selector - */ - public String toString() { - StringBuffer buf = new StringBuffer("{modifiedselector"); - buf.append(" update=").append(update); - buf.append(" seldirs=").append(selectDirectories); - buf.append(" cache=").append(cache); - buf.append(" algorithm=").append(algorithm); - buf.append(" comparator=").append(comparator); - buf.append("}"); - return buf.toString(); - } - - - // ----- BuildListener interface methods ----- - - - /** - * Signals that the last target has finished. - * @param event received BuildEvent - */ - public void buildFinished(BuildEvent event) { - if (getDelayUpdate()) { - saveCache(); - } - } - - - /** - * Signals that a target has finished. - * @param event received BuildEvent - */ - public void targetFinished(BuildEvent event) { - if (getDelayUpdate()) { - saveCache(); - } - } - - - /** - * Signals that a task has finished. - * @param event received BuildEvent - */ - public void taskFinished(BuildEvent event) { - if (getDelayUpdate()) { - saveCache(); - } - } - - - /** - * Signals that a build has started. - * @param event received BuildEvent - */ - public void buildStarted(BuildEvent event) { - // no-op - } - - - /** - * Signals that a target is starting. - * @param event received BuildEvent - */ - public void targetStarted(BuildEvent event) { - // no-op - } - - - - /** - * Signals that a task is starting. - * @param event received BuildEvent - */ - public void taskStarted(BuildEvent event) { - // no-op - } - - - /** - * Signals a message logging event. - * @param event received BuildEvent - */ - public void messageLogged(BuildEvent event) { - // no-op - } - - - // The EnumeratedAttributes for the three interface implementations. - // Name-Classname mapping is done in the configure() method. - - - /** - * Get the cache type to use. - * @return the enumerated cache type - */ - public Cache getCache() { - return cache; - } - - /** - * Set the cache type to use. - * @param name an enumerated cache type. - */ - public void setCache(CacheName name) { - cacheName = name; - } - - /** - * The enumerated type for cache. - * The values are "propertyfile". - */ - public static class CacheName extends EnumeratedAttribute { - /** - * {@inheritDoc} - * @see EnumeratedAttribute#getValues() - */ - public String[] getValues() { - return new String[] {"propertyfile" }; - } - } - - /** - * Get the algorithm type to use. - * @return the enumerated algorithm type - */ - public Algorithm getAlgorithm() { - return algorithm; - } - - /** - * Set the algorithm type to use. - * @param name an enumerated algorithm type. - */ - public void setAlgorithm(AlgorithmName name) { - algoName = name; - } - - /** - * The enumerated type for algorithm. - * The values are "hashValue", "digest" and "checksum". - */ - public static class AlgorithmName extends EnumeratedAttribute { - /** - * {@inheritDoc} - * @see EnumeratedAttribute#getValues() - */ - public String[] getValues() { - return new String[] {"hashvalue", "digest", "checksum" }; - } - } - - /** - * Get the comparator type to use. - * @return the enumerated comparator type - */ - public Comparator<? super String> getComparator() { - return comparator; - } - - /** - * Set the comparator type to use. - * @param name an enumerated comparator type. - */ - public void setComparator(ComparatorName name) { - compName = name; - } - - /** - * The enumerated type for algorithm. - * The values are "equal" and "rule". - */ - public static class ComparatorName extends EnumeratedAttribute { - /** - * {@inheritDoc} - * @see EnumeratedAttribute#getValues() - */ - public String[] getValues() { - return new String[] {"equal", "rule" }; - } - } - -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/modifiedselector/PropertiesfileCache.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/modifiedselector/PropertiesfileCache.java deleted file mode 100644 index 1446e890..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/selectors/modifiedselector/PropertiesfileCache.java +++ /dev/null @@ -1,236 +0,0 @@ -/* - * 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.selectors.modifiedselector; - - -import java.io.BufferedInputStream; -import java.io.BufferedOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.util.Enumeration; -import java.util.Iterator; -import java.util.Properties; -import java.util.Vector; - - -/** - * Use java.util.Properties for storing the values. - * The use of this Cache-implementation requires the use of the parameter - * <param name="cache.cachefile" .../> for defining, where to store the - * properties file. - * - * The ModifiedSelector sets the <i>cachefile</i> to the default value - * <i>cache.properties</i>. - * - * Supported <param>s are: - * <table> - * <tr> - * <th>name</th><th>values</th><th>description</th><th>required</th> - * </tr> - * <tr> - * <td> cache.cachefile </td> - * <td> <i>path to file</i> </td> - * <td> the name of the properties file </td> - * <td> yes </td> - * </tr> - * </table> - * - * @version 2003-09-13 - * @since Ant 1.6 - */ -public class PropertiesfileCache implements Cache { - - - // ----- member variables - configuration ----- - - - /** Where to store the properties? */ - private File cachefile = null; - - /** Object for storing the key-value-pairs. */ - private Properties cache = new Properties(); - - - // ----- member variables - internal use ----- - - - /** Is the cache already loaded? Prevents from multiple load operations. */ - private boolean cacheLoaded = false; - - /** Must the cache be saved? Prevents from multiple save operations. */ - private boolean cacheDirty = true; - - - // ----- Constructors ----- - - - /** Bean-Constructor. */ - public PropertiesfileCache() { - } - - /** - * Constructor. - * @param cachefile set the cachefile - */ - public PropertiesfileCache(File cachefile) { - this.cachefile = cachefile; - } - - - // ----- Cache-Configuration ----- - - - /** - * Setter. - * @param file new value - */ - public void setCachefile(File file) { - cachefile = file; - } - - - /** - * Getter. - * @return the cachefile - */ - public File getCachefile() { - return cachefile; - } - - /** - * This cache is valid if the cachefile is set. - * @return true if all is ok false otherwise - */ - public boolean isValid() { - return (cachefile != null); - } - - - // ----- Data Access - - - /** - * Load the cache from underlying properties file. - */ - public void load() { - if ((cachefile != null) && cachefile.isFile() && cachefile.canRead()) { - try { - BufferedInputStream bis = new BufferedInputStream( - new FileInputStream(cachefile)); - cache.load(bis); - bis.close(); - } catch (Exception e) { - e.printStackTrace(); - } - } - // after loading the cache is up to date with the file - cacheLoaded = true; - cacheDirty = false; - } - - /** - * Saves modification of the cache. - * Cache is only saved if there is one ore more entries. - * Because entries can not be deleted by this API, this Cache - * implementation checks the existence of entries before creating the file - * for performance optimisation. - */ - public void save() { - if (!cacheDirty) { - return; - } - if ((cachefile != null) && cache.propertyNames().hasMoreElements()) { - try { - BufferedOutputStream bos = new BufferedOutputStream( - new FileOutputStream(cachefile)); - cache.store(bos, null); - bos.flush(); - bos.close(); - } catch (Exception e) { - e.printStackTrace(); - } - } - cacheDirty = false; - } - - /** Deletes the cache and its underlying file. */ - public void delete() { - cache = new Properties(); - cachefile.delete(); - cacheLoaded = true; - cacheDirty = false; - } - - /** - * Returns a value for a given key from the cache. - * @param key the key - * @return the stored value - */ - public Object get(Object key) { - if (!cacheLoaded) { - load(); - } - try { - return cache.getProperty(String.valueOf(key)); - } catch (ClassCastException e) { - return null; - } - } - - /** - * Saves a key-value-pair in the cache. - * @param key the key - * @param value the value - */ - public void put(Object key, Object value) { - cache.put(String.valueOf(key), String.valueOf(value)); - cacheDirty = true; - } - - /** - * Returns an iterator over the keys in the cache. - * @return An iterator over the keys. - */ - public Iterator<String> iterator() { - Vector<String> v = new Vector<String>(); - Enumeration<?> en = cache.propertyNames(); - while (en.hasMoreElements()) { - v.add(en.nextElement().toString()); - } - return v.iterator(); - } - - - // ----- additional ----- - - - /** - * Override Object.toString(). - * @return information about this cache - */ - public String toString() { - StringBuffer buf = new StringBuffer(); - buf.append("<PropertiesfileCache:"); - buf.append("cachefile=").append(cachefile); - buf.append(";noOfEntries=").append(cache.size()); - buf.append(">"); - return buf.toString(); - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/spi/Provider.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/spi/Provider.java deleted file mode 100644 index f73b0191..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/spi/Provider.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * 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.spi; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.ProjectComponent; - -/** - * ANT Jar-Task SPI extension - * This class corresponds to the nested element - * <provider type="type"> in the <service type=""> - * nested element of the jar task. - * @see <a href="http://issues.apache.org/bugzilla/show_bug.cgi?id=31520"> - * http://issues.apache.org/bugzilla/show_bug.cgi?id=31520</a> - */ -public class Provider extends ProjectComponent { - private String type; - - /** - * @return the class name for - */ - public String getClassName() { - return type; - } - - /** - * Set the provider classname. - * @param type the value to set. - */ - public void setClassName(String type) { - this.type = type; - } - - /** - * Check if the component has been configured correctly. - */ - public void check() { - if (type == null) { - throw new BuildException( - "classname attribute must be set for provider element", - getLocation()); - } - if (type.length() == 0) { - throw new BuildException( - "Invalid empty classname", getLocation()); - } - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/spi/Service.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/spi/Service.java deleted file mode 100644 index 96c8e4e5..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/spi/Service.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * 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.spi; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStreamWriter; -import java.io.Writer; -import java.util.ArrayList; -import java.util.List; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.ProjectComponent; - -/** - * ANT Jar-Task SPI extension - * - * @see <a href="http://issues.apache.org/bugzilla/show_bug.cgi?id=31520"> - * http://issues.apache.org/bugzilla/show_bug.cgi?id=31520</a> - */ -public class Service extends ProjectComponent { - private List<Provider> providerList = new ArrayList<Provider>(); - private String type; - - /** - * Set the provider classname. - * @param className the classname of a provider of this service. - */ - public void setProvider(String className) { - Provider provider = new Provider(); - provider.setClassName(className); - providerList.add(provider); - } - - /** - * Add a nested provider element. - * @param provider a provider element. - */ - public void addConfiguredProvider(Provider provider) { - provider.check(); - providerList.add(provider); - } - - /** - * @return the service type. - */ - public String getType() { - return type; - } - - /** - * Set the service type. - * @param type the service type, a classname of - * an interface or a class (normally - * abstract). - */ - public void setType(String type) { - this.type = type; - } - - /** - * Return the implementations of this - * services as an inputstream. - * @return an inputstream of the classname names - * encoded as UTF-8. - * @throws IOException if there is an error. - */ - public InputStream getAsStream() throws IOException { - ByteArrayOutputStream arrayOut = new ByteArrayOutputStream(); - Writer writer = new OutputStreamWriter(arrayOut, "UTF-8"); - for (Provider provider : providerList) { - writer.write(provider.getClassName()); - writer.write("\n"); - } - writer.close(); - return new ByteArrayInputStream(arrayOut.toByteArray()); - } - - /** - * Check if this object is configured correctly as a nested - * element. - */ - public void check() { - if (type == null) { - throw new BuildException( - "type attribute must be set for service element", - getLocation()); - } - if (type.length() == 0) { - throw new BuildException( - "Invalid empty type classname", getLocation()); - } - if (providerList.size() == 0) { - throw new BuildException( - "provider attribute or nested provider element must be set!", - getLocation()); - } - } -} |