com.mcdermottroe.exemplar.output
Class OutputUtils

java.lang.Object
  extended by com.mcdermottroe.exemplar.output.OutputUtils

public final class OutputUtils
extends Object

Output handling utility methods.

Since:
0.1

Constructor Summary
private OutputUtils()
          Private constructor to prevent instantiation of this class.
 
Method Summary
static SortedSet<LanguageAPIPair> availableLanguageAPIPairs()
          Discover the set of output language-API pairs that are legal.
static SortedMap<String,String> availableOutputAPIs()
          Discover the available output APIs.
static SortedMap<String,String> availableOutputLanguages()
          Discover the available output languages.
static void generateParser(XMLDocumentType doctype, String filename, String language, String api)
          Generate a parser given an XMLDocumentType and the type of parser that is required.
static void writeStringToFile(String s, File file)
          Write a String to a File.
static void writeStringToFile(String s, File dir, String filename)
          Write a String to a file.
static void writeStringToFile(String s, String file)
          Write a String to a file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OutputUtils

private OutputUtils()
Private constructor to prevent instantiation of this class.

Method Detail

generateParser

public static void generateParser(XMLDocumentType doctype,
                                  String filename,
                                  String language,
                                  String api)
                           throws OutputException
Generate a parser given an XMLDocumentType and the type of parser that is required.

Parameters:
doctype - The XMLDocumentType describing the vocabulary.
filename - The name of the file to output to (directory name for multi file output).
language - The language of the parser to be output.
api - The API (if any) that the parser to be output must conform to.
Throws:
OutputException - if any of the required parameters are null, if the generator cannot be instantiated or if the generator throws an exception while trying to generate code.

writeStringToFile

public static void writeStringToFile(String s,
                                     String file)
                              throws OutputException
Write a String to a file.

Parameters:
s - The String to write to the file.
file - A String containing the full path to the file to write to.
Throws:
OutputException - if anything goes wrong

writeStringToFile

public static void writeStringToFile(String s,
                                     File dir,
                                     String filename)
                              throws OutputException
Write a String to a file.

Parameters:
s - The String to write to the file.
dir - A File for the directory in which the new file will reside.
filename - A String containing the name of the file in dir to write the String to.
Throws:
OutputException - if anything goes wrong

writeStringToFile

public static void writeStringToFile(String s,
                                     File file)
                              throws OutputException
Write a String to a File.

Parameters:
s - The String to write to the File.
file - The File to write the String to.
Throws:
OutputException - if anything goes wrong.

availableOutputLanguages

public static SortedMap<String,String> availableOutputLanguages()
Discover the available output languages.

Returns:
A SortedMap where the keys are the available output languages and the values are the descriptions of those output languages.

availableOutputAPIs

public static SortedMap<String,String> availableOutputAPIs()
Discover the available output APIs.

Returns:
A SortedMap where the keys are the available output APIs and the values are the descriptions of those output APIs.

availableLanguageAPIPairs

public static SortedSet<LanguageAPIPair> availableLanguageAPIPairs()
Discover the set of output language-API pairs that are legal.

Returns:
A SortedSet containing a LanguageAPIPair for every legal combination of language and API.