net.siefkes.nlstego
Class NLStego

java.lang.Object
  extended by net.siefkes.nlstego.NLStego

public class NLStego
extends Object

The main entry point of this program.

Version:
$Revision: 1.13 $, $Date: 2005/07/12 17:02:07 $, $Author: siefkes $
Author:
Christian Siefkes

Field Summary
static String ID
          The ID of this software, used as base name of the config file etc.: "nlstego".
static char INVALID_COMMAND
          Marker used for invalid or missing commands.
static Log LOG
          The logger used in this system.
static String NAME
          The name of this software: "NLStego".
static ResourceBundle RES
          Messages used by this program.
static String VERSION_NO
          The current version number of this software: "0.9-dev".
 
Constructor Summary
NLStego(Configuration myConfig)
          Creates a new instance, using the standard input/output/error streams for I/O.
NLStego(Configuration myConfig, InputStream myInStream, PrintStream myOutStream, PrintStream myErrStream)
          Creates a new instance.
 
Method Summary
 TextModel buildTextModel(String[] filePaths, boolean recurse)
          Build a text model from a set of texts.
 void execute(char command, List<String> arguments)
          Executes the given command on the given arguments (if any).
 String generateText(TextModel textModel, int numWords)
          Generates random text.
static void main(String[] args)
          Static main method: create and configure a new instance and executes the given command (first argument) on the given arguments.
 void printUsage()
          Helper method that prints usage instructions to the error stream.
 void printVersion()
          Helper method that prints name and version number of this program to the error stream.
 void printWrapped(String text)
          Helper method that prints a text to the output stream, adding linebreaks after 75 characters.
 void printWrapped(String text, int n)
          Helper method that prints a text to the output stream, adding linebreaks after the specified number of characters.
 String toString()
          Returns a string representation of this object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ID

public static final String ID
The ID of this software, used as base name of the config file etc.: "nlstego".

See Also:
Constant Field Values

NAME

public static final String NAME
The name of this software: "NLStego".

See Also:
Constant Field Values

VERSION_NO

public static final String VERSION_NO
The current version number of this software: "0.9-dev".

See Also:
Constant Field Values

INVALID_COMMAND

public static final char INVALID_COMMAND
Marker used for invalid or missing commands.

See Also:
Constant Field Values

LOG

public static final Log LOG
The logger used in this system. All log messages are written to stderr (the standard error stream).


RES

public static final ResourceBundle RES
Messages used by this program.

Constructor Detail

NLStego

public NLStego(Configuration myConfig)
Creates a new instance, using the standard input/output/error streams for I/O.

Parameters:
myConfig - used to configure this instance

NLStego

public NLStego(Configuration myConfig,
               InputStream myInStream,
               PrintStream myOutStream,
               PrintStream myErrStream)
Creates a new instance.

Parameters:
myConfig - used to configure this instance
myInStream - stream used to read input
myOutStream - stream used to write output
myErrStream - stream used to write error and warn message
Method Detail

main

public static void main(String[] args)
Static main method: create and configure a new instance and executes the given command (first argument) on the given arguments.

Parameters:
args - the command-line parameters: first element must be the command to execute (e to encode, d to decode, or g to generate random text); elements starting with "-" are processed as configuration options (cf. Util.configureFromArgs(Configuration, String[]))

buildTextModel

public TextModel buildTextModel(String[] filePaths,
                                boolean recurse)
                         throws IOException
Build a text model from a set of texts.

Parameters:
filePaths - array of paths of the text to use for building the model; resolved via the Commons VFS
recurse - whether to recursively add the children of folders and other files containing nested entries
Returns:
the created text model
Throws:
IOException - if an error occurs while reading training texts

execute

public void execute(char command,
                    List<String> arguments)
             throws IOException
Executes the given command on the given arguments (if any). Also prints help and/or version info if requested ("-h"/"-v" options).

Parameters:
command - the command to execute
arguments - a list of any further arguments for this command
Throws:
IOException - if an I/O error occurs

generateText

public String generateText(TextModel textModel,
                           int numWords)
                    throws IOException
Generates random text.

Parameters:
textModel - the text model to use
numWords - the minimum number of words to generate
Returns:
the generated text
Throws:
IOException - if an I/O error occurs

printWrapped

public void printWrapped(String text)
Helper method that prints a text to the output stream, adding linebreaks after 75 characters. A final newline will be appended and the output stream will be flushed after writing the wrapped text.

Parameters:
text - the text to print

printWrapped

public void printWrapped(String text,
                         int n)
Helper method that prints a text to the output stream, adding linebreaks after the specified number of characters. A final newline will be appended and the output stream will be flushed after writing the wrapped text.

Parameters:
n - the maximum number of characters in a line
text - the text to print

printUsage

public void printUsage()
Helper method that prints usage instructions to the error stream.


printVersion

public void printVersion()
Helper method that prints name and version number of this program to the error stream.


toString

public String toString()
Returns a string representation of this object.

Overrides:
toString in class Object
Returns:
a textual representation


Copyright © 2003-2005 Christian Siefkes. All Rights Reserved.