1.17. Element invoke

<invoke
  method = Qualified name of a Java static method
>
  Content: [ argument ]+
</invoke>

<argument>
  Content: string
</argument>

Invokes specified Javastatic method, passing it specified arguments.

Examples:

<invoke method="TestInvoke.echo">
  <argument>args={%*}</argument>
  <argument>doc='%D'</argument>
  <argument>pwd='%W'</argument>
  <argument>conf='%C'</argument>
</invoke>

<invoke method="TestInvoke.echo2"/>

<invoke method="TestInvoke.gzip">
  <argument>__doc.xml</argument>
</invoke>

Static methods invoked by the above examples:

public final class TestInvoke {
    public static void echo(String[] arguments, File workingDir,
                            Console console) {
        console.showMessage("arguments={" + 
                            StringUtil.joinArguments(arguments) + "}",
                            Console.INFO);
        console.showMessage("workingDir='" + workingDir + "'", 
                            Console.INFO);
    }

    public static void echo2(String[] arguments, File workingDir,
                             Console console, Document docBeingEdited) {
        echo(arguments, workingDir, console);
        console.showMessage("docBeingEdited='" + docBeingEdited.getLocation() 
                            + "'", Console.INFO);
    }

    public static File gzip(String[] arguments, File workingDir) 
        throws IOException {
        if (arguments.length != 1)
            throw new IllegalArgumentException("arguments");

        File inFile = new File(workingDir, arguments[0].trim());
        if (!inFile.isFile())
            throw new FileNotFoundException(inFile.getPath());

        File outFile = new File(inFile.getPath() + ".gz");
        FileInputStream in = new FileInputStream(inFile);

        try {
            GZIPOutputStream out = 
                new GZIPOutputStream(new FileOutputStream(outFile));

            byte[] bytes = new byte[8192];
            int count;

            while ((count = in.read(bytes)) != -1) 
                out.write(bytes, 0, count);

            out.finish();
            out.close();
        } finally {
            in.close();
        }

        return outFile;
    }
}