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