Package org.apache.commons.workflow.io

Implementations of Steps in the io library.

See:
          Description

Class Summary
DisplayStep For each associated Descriptor, print the value of the specified Java object to standard output.
GetStep Retrieve the contents of a specified URL resource, and push the contents as a String object onto the evaluation stack.
IoRuleSet RuleSet for the Step definitions supported by the io library.
PeekStep Write the top value from the evaluation stack to standard output, without removing it.
ReadStep Read the contents of the specified file from the filesystem, and push the contents as a String object onto the evaluation stack.
WriteStep Pop the top value from the evaluation stack, and write its contents as a string to the specified file in the filesystem (replacing any previous contents in that file).
 

Package org.apache.commons.workflow.io Description

Implementations of Steps in the io library.

I/O Step Library - Overview

This package contains org.apache.commons.workflow.Step implementations for the io library. This library includes Steps for importing information from (or exporting information to) external locations.

The sections below define each of the Step definitions included in this library, utilizing the XML syntax that is recognized by the Digester used to process your Activity definition files. Although you can use any namespace prefix, the convention is to declare io as the namespace prefix, as in the following example:

  <base:activity id="Demonstration Activity"
    xmlns:base="http://commons.apache.org/workflow/base"
    xmlns:core="http://commons.apache.org/workflow/core"
    xmlns:io="http://commons.apache.org/workflow/io"
  >

    <io:write file="topitem.txt"/>

  </base:activity>

NOTE - It is not required that you use the XML syntax, processed with a Digester, to initialize the Steps associated with each Activity. However, this usage is very convenient, and is likely to be the most common case, so the Steps are documented from that perspective. To use the underlying implementation classes directly, see the Javadocs for each Step implementation class, just as you would for any other Java class.

[io:display] [io:get] [io:peek] [io:read] [io:write]

I/O Step Library - Step Definitions

io:display

The io:display Step evaluates the properties specified by all nested <io:descriptor> elements, converts them to String (if necessary), and prints them to Java's standard output.

The io:display element recognizes the following attributes:

You may nest any number of io:descriptor elements within a io:display element. All of them will be evaluated and displayed in order specified.

In the following example, the "address" and "customer" beans will be converted to Strings (by calling their toString() methods) and the results displayed to standard output.

  <io:display >
    <io:descriptor xpath="address"/>
    <io:descriptor xpath="customer"/>
  </io:display>

io:get

The io:get Step connects to a specified URL, retrieves the corresponding value as a String, and pushes the result on to the evaluation stack.

The io:get element recognizes the following attributes:

In the following example, the home page of a local web server is retrieved and pushed on to the evaluation stack as a String:

  <io:get url="http://localhost:8080/index.html"/>

io:peek

The io:peek Step makes a copy of the top item on the evaluation stack, converts it to a String (if necesary), and prints it to standard output. This is useful for debugging, and is shorthand for the following:

  <core:duplicate/>
  <io:display>
    <io:descriptor/>
  </io:display>

The io:peek element recognizes the following attributes:

io:read

The io:read Step reads the characters of the specified file, converts them to a String, and pushes this String on to the evaluation stack.

The io:read element recognizes the following attributes:

In the example below, the contents of the specified file are read, converted to a String, and pushed on to the evaluation stack:

  <io:read file="data.txt"/>

io:write

The io:write Step pops the top item from the evaluation stack, converts it to a String (if necessary), and writes the characters to the specified file.

The io:write element recognizes the following attributes:

In the example below, the contents of the specified file are written based on the contents of the popped evaluation stack element:

  <io:write file="data.txt"/>

I/O Step Library - Nested Elements

io:descriptor

An io:descriptor element is a description of the mechanism by which an arbitrary Java object (typically a JavaBean) in some Scope, is referenced. This element recognizes the following attributes:

The syntax for XPath expressions is a sequence of one or more identifier strings, separated by forward slash ("/") characters. The expression is evaluated as follows:

When deciding what bean a particular descriptor applies to, the following rules are applied, in this priority order:

FIXME - Support the property attribute for access to bean properties via the Commons Beanutils package.



Copyright © 2001-2010 The Apache Software Foundation. All Rights Reserved.