com.google.template.soy.msgs
Class SoyMsgBundleHandler

java.lang.Object
  extended by com.google.template.soy.msgs.SoyMsgBundleHandler

public class SoyMsgBundleHandler
extends Object

Handler for writing SoyMsgBundles to file format and for creating SoyMsgBundles from files or resources.

Uses a SoyMsgPlugin to do the actual generation of the output data and the actual parsing of the input data. The SoyMsgPlugin implements the specific message file format.


Nested Class Summary
static class SoyMsgBundleHandler.OutputFileOptions
          Options for generating an output message bundle file.
 
Constructor Summary
SoyMsgBundleHandler(SoyMsgPlugin msgPlugin)
           
 
Method Summary
 SoyMsgBundle createFromFile(File inputFile)
          Reads an input messages file and creates a SoyMsgBundle.
 SoyMsgBundle createFromResource(URL inputResource)
          Reads an input messages resource and creates a SoyMsgBundle.
 void writeToFile(SoyMsgBundle msgBundle, File outputFile)
          Converts a message bundle to output file format and writes it to file.
 void writeToFile(SoyMsgBundle msgBundle, SoyMsgBundleHandler.OutputFileOptions options, File outputFile)
          Converts a message bundle to output file format and writes it to file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SoyMsgBundleHandler

@Inject
public SoyMsgBundleHandler(SoyMsgPlugin msgPlugin)
Method Detail

writeToFile

public void writeToFile(SoyMsgBundle msgBundle,
                        File outputFile)
                 throws IOException,
                        SoyMsgException
Converts a message bundle to output file format and writes it to file. Uses the default output file options (source locale "en", no target locale).

Parameters:
msgBundle - The message bundle to write to file.
outputFile - The output file to write to.
Throws:
IOException - If there's an error while accessing the file.
SoyMsgException - If there's an error while processing the messages.

writeToFile

public void writeToFile(SoyMsgBundle msgBundle,
                        SoyMsgBundleHandler.OutputFileOptions options,
                        File outputFile)
                 throws IOException,
                        SoyMsgException
Converts a message bundle to output file format and writes it to file.

Parameters:
msgBundle - The message bundle to write to file.
options - The options for generating the output file (some of the options may be needed, depending on the SoyMsgPlugin used).
outputFile - The output file to write to.
Throws:
IOException - If there's an error while accessing the file.
SoyMsgException - If there's an error while processing the messages.

createFromFile

public SoyMsgBundle createFromFile(File inputFile)
                            throws IOException,
                                   SoyMsgException
Reads an input messages file and creates a SoyMsgBundle.

Parameters:
inputFile - The input file to read from.
Returns:
The message bundle created from the messages file.
Throws:
IOException - If there's an error while accessing the file.
SoyMsgException - If there's an error while processing the messages.

createFromResource

public SoyMsgBundle createFromResource(URL inputResource)
                                throws IOException,
                                       SoyMsgException
Reads an input messages resource and creates a SoyMsgBundle.

Parameters:
inputResource - The resource to read from.
Returns:
The message bundle created from the messages resource.
Throws:
IOException - If there's an error while accessing the resource.
SoyMsgException - If there's an error while processing the messages.