[Index]

copy


A Copy job. Copy either:

Property Summary

consumer A consumer of strings.
directoriesCopied The number of directories copied.
filesCopied The number of files copied.
from The file to read from.
input An input stream.
name A name, can be any text.
output An output stream.
to The file to write to.

Example Summary

Example 1 Copy a file.
Example 2 Copy a directory.
Example 3 Copy from a file to a buffer.
Example 4 Copy into a Bean Bus.

Property Detail

consumer

Configured ByELEMENT
AccessREAD_WRITE
RequiredNo. Will be set automatically in a Bean Bus.

A consumer of strings. Intended for use as the driver in a bus:bus.

directoriesCopied

AccessREAD_ONLY
RequiredRead Only.

The number of directories copied.

filesCopied

AccessREAD_ONLY
RequiredRead Only.

The number of files copied.

from

Configured ByELEMENT
AccessREAD_WRITE
RequiredYes unless input supplied.

The file to read from.

input

Configured ByELEMENT
AccessREAD_WRITE
RequiredYes unless from supplied.

An input stream.

name

Configured ByATTRIBUTE
AccessREAD_WRITE
RequiredNo.

A name, can be any text.

output

Configured ByELEMENT
AccessREAD_WRITE
RequiredYes unless to is supplied.

An output stream.

to

Configured ByATTRIBUTE
AccessREAD_WRITE
RequiredYes unless output supplied.

The file to write to.


Examples

Example 1

Copy a file.

<oddjob id="this">
    <job>
        <copy to="${work.dir}">
            <from>
                <file file="${base.dir}/test/io/reference/test1.txt"/>
            </from>
        </copy>
    </job>
</oddjob>

Example 2

Copy a directory.

<oddjob id="this">
    <job>
        <copy to="${work.dir}">
            <from>
                <file file="${base.dir}/test/io/reference/a"/>
            </from>
        </copy>
    </job>
</oddjob>

Example 3

Copy from a file to a buffer.

<oddjob id="this">
    <job>
        <sequential>
            <jobs>
                <copy name="Copy from a file to a buffer">
                    <from>
                        <file file="${this.args[0]}/test/io/reference/test1.txt"/>
                    </from>
                    <output>
                        <identify id="buff">
                            <value>
                                <buffer/>
                            </value>
                        </identify>

                    </output>
                </copy>
                <echo id="e" name="What's in the file?">${buff}</echo>
            </jobs>
        </sequential>
    </job>
</oddjob>

Example 4

Copy into a Bean Bus. The lines from the file are copied into the bus where they are mapped with a function that appends 'Foo' before writing them out in another file.

<oddjob id="oddjob">
    <job>
        <sequential>
            <jobs>
                <properties>
                    <values>
                        <value key="work.dir" value="${java.io.tmpdir}"/>
                    </values>
                </properties>
                <bus:bus xmlns:bus="oddjob:beanbus">
                    <of>
                        <copy name="Copy from a file to lines">
                            <from>
                                <file file="${oddjob.dir}/files/Lines.txt"/>
                            </from>
                        </copy>
                        <bus:map>
                            <function>
                                <value value="#{function(x) { return x + 'Foo' }}"/>
                            </function>
                        </bus:map>
                        <bus:collect>
                            <output>
                                <file file="${work.dir}/LinesFoo.txt"/>
                            </output>
                        </bus:collect>
                    </of>
                </bus:bus>
            </jobs>
        </sequential>
    </job>
</oddjob>


(c) R Gordon Ltd 2005 - Present