au.gov.tas.dpiwe.mr.tool
Class XMap

java.lang.Object
  extended by au.gov.tas.dpiwe.mr.tool.XMap

public class XMap
extends Object

This tool blindly replaces text in accordance with a mapping in a specified properties file.

It was originally intended to transform OO.org spreadsheets by changing metadata lines appearing at the heads of each worksheet within the constituent XML file.

Of course, this tool actually operates on the whole file, so the tokens on the left of the properties file need to be unique to the metadata (and similarly must not appear in the OO.org XML as mark up.)

Since:
Mr Architecture 3.1
Version:
1.0.0.4
Author:
Kade Hansson

Field Summary
protected static ThreadLocal returnCode
           
 
Constructor Summary
XMap()
           
 
Method Summary
static void generateError(String bundleName, String messageToken)
          Generates the error message for the specified token.
static void main(String[] argv)
          Initiates the XMap tool.
static void xMap(Reader input, PrintWriter output, Properties map)
          Produce an XMapped stream.
static boolean xMap(String filename, String mapFilename)
          Produce a XMapped file, renaming the original version.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

returnCode

protected static ThreadLocal returnCode
Constructor Detail

XMap

public XMap()
Method Detail

main

public static void main(String[] argv)
                 throws Exception
Initiates the XMap tool.

Throws:
IOException - if the input files could not be read or the output files could not be written.
SecurityException - if the configured security policy is too restrictive.
Exception - if something else goes wrong.

generateError

public static void generateError(String bundleName,
                                 String messageToken)
Generates the error message for the specified token.

Parameters:
bundleName - identifies the bundle.
messageToken - identifies the error message.

xMap

public static boolean xMap(String filename,
                           String mapFilename)
                    throws IOException,
                           SecurityException
Produce a XMapped file, renaming the original version.

Parameters:
filename - the name of the file to be XMapped.
Returns:
true if the file was successfully stripped, false if the file remains unchanged.
Throws:
IOException - if the input files could not be read or the output file could not be written.
SecurityException - if the configured security policy is too restrictive.

xMap

public static void xMap(Reader input,
                        PrintWriter output,
                        Properties map)
                 throws IOException
Produce an XMapped stream. The files are closed once read/written.

Parameters:
input - the Reader from which the original text/XML should be read.
output - the PrintWriter to which the remapped text/XML should be written.
Throws:
IOException - if the input file could not be read or the output file could not be written.