# Class CeaWriter

java.lang.Object
uk.ac.starlink.util.XmlWriter
uk.ac.starlink.ttools.cea.CeaWriter

Direct Known Subclasses:
  `ImplementationCeaWriter, ServiceCeaWriter`

public abstract class CeaWriter extends uk.ac.starlink.util.XmlWriter
Writes an application description file suitable for use with the AstroGrid Common Execution Architecture.

There are variants of the format according to what the purpose of the output XML will be. This class is an abstract superclass providing common methods whose concrete subclasses do the actual writing.

This makes a best effort at providing a CEA-friendly interface to the capabilities of STILTS. Call the `main(String[])` method with the `-help` flag for a usage message.

Since:
  17 March 2006
Author:
  Mark Taylor

## Constructor Summary

Constructors
Modifier
Constructor
Description
`protected`
`CeaWriter(PrintStream out, CeaConfig config, CeaTask[] tasks, boolean redirects, String cmdline)`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`abstract int`
`configure(String[] args)`
Hook for additional configuration of concrete subclasses using command-line flags.
`protected void`
`endElement(ElementDeclaration el)`
Convenience method to end an element described by an ElementDeclaration.
`abstract String`
`getSchemaLocation()`
Returns the URL of the schema to which the output of this object conforms.
`static void`
`main(String[] args)`
Main method.
`protected void`
`startElement(ElementDeclaration el)`
Convenience method to start an element described by an ElementDeclaration.
`protected void`
`startElement(ElementDeclaration el, String moreAtts)`
Convenience method to start an element described by an ElementDeclaration with supplied attributes.
`protected abstract void`
`writeContent()`
Performs the implementation-specific output of XML elements.
`void`
`writeDocument()`
Writes the configuration XML document.
`protected void`
`writeInterfaces()`
Writes an Interfaces element suitable for use with CEA.
`protected void`
`writeParameters()`
Writes a Parameters element suitable for use with CEA.

### Methods inherited from class uk.ac.starlink.util.XmlWriter

`addElement, endElement, formatAttribute, formatText, getIndent, getLevel, print, println, setOut, startElement, startElement, writeDeclaration`

### Methods inherited from class Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### CeaWriter

protected CeaWriter(PrintStream out, CeaConfig config, CeaTask[] tasks, boolean redirects, String cmdline)
Constructor.

Parameters:
  `out` - output stream for XML
  `config` - configuration object for the specific flavour of output
  `tasks` - list of tasks to be described by the output
  `redirects` - true iff you want stdout/stderr parameters for standard output/error redirection
  `cmdline` - command line string, used for logging within the output only

## Method Details

### configure

public abstract int configure(String[] args)
Hook for additional configuration of concrete subclasses using command-line flags.

Parameters:
  `args` - array of command-line arguments all of which are directed at this object (any generic ones will have been removed)
Returns:
  0 for success, otherwise an error status

### writeDocument

public void writeDocument() throws SAXException
Writes the configuration XML document.

Throws:
  `SAXException`

### writeContent

protected abstract void writeContent() throws SAXException
Performs the implementation-specific output of XML elements. Invoked by `writeDocument()`; presumably invokes `writeParameters()` and `writeInterfaces()`.

Throws:
  `SAXException`

### getSchemaLocation

public abstract String getSchemaLocation()
Returns the URL of the schema to which the output of this object conforms.

Returns:
  validation schema location

### writeParameters

protected void writeParameters() throws SAXException
Writes a Parameters element suitable for use with CEA.

Throws:
  `SAXException`

### writeInterfaces

protected void writeInterfaces() throws SAXException
Writes an Interfaces element suitable for use with CEA.

Throws:
  `SAXException`

### startElement

protected void startElement(ElementDeclaration el)
Convenience method to start an element described by an ElementDeclaration. No attributes are written.

Parameters:
  `el` - element

### startElement

protected void startElement(ElementDeclaration el, String moreAtts)
Convenience method to start an element described by an ElementDeclaration with supplied attributes.

Parameters:
  `el` - element
  `moreAtts` - formatted attribute string additional to any defined by the element declaration

### endElement

protected void endElement(ElementDeclaration el)
Convenience method to end an element described by an ElementDeclaration.

Parameters:
  `el` - element

### main

public static void main(String[] args) throws uk.ac.starlink.util.LoadException, SAXException
Main method. Run with `-help` for a usage message.

Parameters:
  `args` - argument list
Throws:
  `uk.ac.starlink.util.LoadException`
  `SAXException`