org.oddjob.io
Class ExistsJob

java.lang.Object
  extended by org.oddjob.io.ExistsJob
All Implemented Interfaces:
Serializable, Runnable

public class ExistsJob
extends Object
implements Runnable, Serializable

Description

Test if a file exists. This job will flag complete if the file exists, not complete if it doesn't, and will signal an exception if the path to the file does not exist.

Example

A simple example checking for a single file.
<oddjob id="this">
    <job>
        <exists file="${this.args[0]}/test/io/reference/test1.txt"/>
    </job>
</oddjob>

Example

File polling.
<oddjob id="this" xmlns:scheduling="http://rgordon.co.uk/oddjob/scheduling" xmlns:schedules="http://rgordon.co.uk/oddjob/schedules">
    <job>
        <sequential name="The Classic File Polling Example">
            <jobs>
                <scheduling:retry limits="${timer.current}">
                    <schedule>
                        <schedules:interval interval="00:00:02"/>
                    </schedule>
                    <job>
                        <sequential id="echo-when-file">
                            <jobs>
                                <exists id="check" name="Check File Exists" file="${work.dir}/done.flag"/>
                                <echo>Found ${check.exists[0]}</echo>
                            </jobs>
                        </sequential>
                    </job>
                </scheduling:retry>
            </jobs>
        </sequential>
    </job>
</oddjob>

Example

Using exists and processing the files found.
<oddjob id="this">
    <job>
        <sequential name="Find Files">
            <jobs>
                <exists id="exists" file="${this.args[0]}/test/io/reference/test*.txt"/>
                <foreach id="found">
                    <values>
                        <value value="${exists.exists}"/>
                    </values>
                    <configuration>
                        <xml>
                            <foreach id="found">
                                <job>
                                    <echo>found ${found.current}</echo>
                                </job>
                            </foreach>
                        </xml>
                    </configuration>
                </foreach>
            </jobs>
        </sequential>
    </job>
</oddjob>
See Also:
Serialized Form

Constructor Summary
ExistsJob()
           
 
Method Summary
 File[] getExists()
           
 File getFile()
          Get the file.
 Date getLastModified()
           
 String getName()
          Get the name.
 int getResult()
          Get the result.
 long getSize()
           
 void run()
           
 void setFile(File file)
          Set the file.
 void setName(String name)
          Set the name
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ExistsJob

public ExistsJob()
Method Detail

getName

public String getName()
Get the name.

Returns:
The name.

setName

public void setName(String name)
Set the name

Parameters:
name - The name.

getFile

public File getFile()
Get the file.

Returns:
The file.

setFile

public void setFile(File file)
Set the file.

Parameters:
The - file.

getExists

public File[] getExists()

getResult

public int getResult()
Get the result. Used to set complete/not state.

Returns:
0 if file exists.

run

public void run()
Specified by:
run in interface Runnable

getSize

public long getSize()

Property: size

Description: If a single file is found, this is the size of the file in bytes, or -1 if a single file hasn't been found.

Required: R/O.


getLastModified

public Date getLastModified()

Property: lastModified

Description: If a single file is found, this is the last modified date of the file.

Required: R/O.


toString

public String toString()
Overrides:
toString in class Object