diff options
Diffstat (limited to 'framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/types/resources/selectors')
14 files changed, 0 insertions, 1300 deletions
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); - } - -} |