|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectau.gov.tas.dpiwe.mr.tool.HeaderTool
public class HeaderTool
This tool adds headers to files in a specified directory in accordance with a mapping in a specified properties file.
It was originally intended to add header lines giving field name metadata to TSV files produced by an Ingres data export script.
| Field Summary | |
|---|---|
protected static ThreadLocal |
returnCode
|
| Constructor Summary | |
|---|---|
HeaderTool()
|
|
| Method Summary | |
|---|---|
static void |
addHeader(Reader input,
PrintWriter output,
String header)
Add a header to a stream. |
static boolean |
addHeaders(String filename,
String mapFilename)
Adds headers to files in a directory according to a map. |
static void |
generateError(String bundleName,
String messageToken)
Generates the error message for the specified token. |
static void |
main(String[] argv)
Initiates the header tool. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static ThreadLocal returnCode
| Constructor Detail |
|---|
public HeaderTool()
| Method Detail |
|---|
public static void main(String[] argv)
throws Exception
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.
public static void generateError(String bundleName,
String messageToken)
bundleName - identifies the bundle.messageToken - identifies the error message.
public static boolean addHeaders(String filename,
String mapFilename)
throws IOException,
SecurityException
filename - the directory containing the files to have headers added.mapFilename - a properties file where the keys are filenames
(add .txt extension) and the values are headers (spaces become tabs.)
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.
public static void addHeader(Reader input,
PrintWriter output,
String header)
throws IOException
If the header is entirely lower case, then the rest of the file is uppercased. This ensures XMap is not as likely to affect the data at a later stage.
input - the Reader from which the original text should be read.output - the PrintWriter to which the header plus original text should be written.header - the header text.
IOException - if the input file could not be read or the output
file could not be written.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||