## org.apache.tools.ant.types.selectors
Class DifferentSelector

    java.lang.Object
      |
      +--org.apache.tools.ant.ProjectComponent
            |
            +--org.apache.tools.ant.types.DataType
                  |
                  +--org.apache.tools.ant.types.selectors.BaseSelector
                        |
                        +--org.apache.tools.ant.types.selectors.MappingSelector
                              |
                              +--org.apache.tools.ant.types.selectors.DifferentSelector

All Implemented Interfaces:
  FileSelector

public class DifferentSelector
extends MappingSelector

This selector selects files against a mapped set of target files, selecting all those files which are different. A byte-by-byte comparision is performed on equal length files; files with different lengths are deemed different automatically; files with identical timestamps are viewed as matching by default, unless you specify otherwise.

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.

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 descendent routines conditional.

Author:
  not specified

Field Summary

Fields inherited from class org.apache.tools.ant.types.selectors.MappingSelector
`granularity, map, mapperElement, targetdir`

Fields inherited from class org.apache.tools.ant.types.DataType
`checked, description, ref`

Fields inherited from class org.apache.tools.ant.ProjectComponent
`project`

Constructor Summary
`DifferentSelector()`

Method Summary
`protected boolean` `selectionTest(java.io.File srcfile, java.io.File destfile)` this test is our selection test that compared the file with the destfile
`void` `setIgnoreFileTimes(boolean ignoreFileTimes)` This flag tells the selector to ignore file times in the comparison

Methods inherited from class org.apache.tools.ant.types.selectors.MappingSelector
`createMapper, isSelected, setGranularity, setTargetdir, verifySettings`

Methods inherited from class org.apache.tools.ant.types.selectors.BaseSelector
`getError, setError, validate`

Methods inherited from class org.apache.tools.ant.types.DataType
`checkAttributesAllowed, checkChildrenAllowed, circularReference, dieOnCircularReference, getCheckedRef, getDescription, getRefid, isChecked, isReference, noChildrenAllowed, setChecked, setDescription, setRefid, tooManyAttributes`

Methods inherited from class org.apache.tools.ant.ProjectComponent
`getProject, log, log, setProject`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### DifferentSelector

    public DifferentSelector()

Method Detail

### setIgnoreFileTimes

    public void setIgnoreFileTimes(boolean ignoreFileTimes)

  This flag tells the selector to ignore file times in the comparison

  Parameters:
    `ignoreFileTimes` - if true ignore file times

### selectionTest

    protected boolean selectionTest(java.io.File srcfile,
                                    java.io.File destfile)

  this test is our selection test that compared the file with the destfile

  Specified by:
    `selectionTest` in class `MappingSelector`
  Parameters:
    `srcfile` - the source file
    `destfile` - the destination file
  Returns:
    true if the files are different

Copyright © 2000-2003 Apache Software Foundation. All Rights Reserved.