NCLib
Class Template

java.lang.Object
  extended by NCLib.Template

public class Template
extends java.lang.Object

Implementation of a simple file templating mechanism


Field Summary
private  java.lang.String input
          Contents of the input file
private  java.util.HashMap<java.lang.String,java.lang.String> map
          Map of the replaceables
 
Constructor Summary
Template(java.lang.String fname)
          Default constructor
 
Method Summary
 java.util.Set<java.lang.String> fields()
          Returns a set of all keywords found in the input file
static void main(java.lang.String[] args)
          Test routine
 boolean set(java.lang.String key, java.lang.String value)
          Set a string as replacement for a specific keyword
 java.lang.String toString()
          Retrieve a string representation of this object
 void write(java.lang.String fname)
          Write the resulting file
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

input

private java.lang.String input
Contents of the input file


map

private java.util.HashMap<java.lang.String,java.lang.String> map
Map of the replaceables

Constructor Detail

Template

public Template(java.lang.String fname)
Default constructor

Parameters:
fname - Filename of the input file
Method Detail

fields

public java.util.Set<java.lang.String> fields()
Returns a set of all keywords found in the input file

Returns:
The set, motherfucker!

set

public boolean set(java.lang.String key,
                   java.lang.String value)
Set a string as replacement for a specific keyword

Parameters:
key - The keyword
value - The replacement string (oh, the surprise!)
Returns:
True if the keyword was in the set of keywords found in the input file, false otherwise (and no replacing then, of course)

toString

public java.lang.String toString()
Retrieve a string representation of this object

Overrides:
toString in class java.lang.Object
Returns:
The string

write

public void write(java.lang.String fname)
Write the resulting file

Parameters:
fname - Filename of the destination file

main

public static void main(java.lang.String[] args)
Test routine