org.wurbelizer
Class HeapFile

java.lang.Object
  extended by org.wurbelizer.HeapFile

public class HeapFile
extends Object

Utility class implementing in-memory files. Nice for here-documents that don't need to be stored on disk. Important: heapfiles are valid among all wurblets and sourcefiles within a single ant run.

Author:
harald

Constructor Summary
HeapFile(String name)
          Creates an empty heapfile.
HeapFile(String name, String text)
          Creates a heapfile.
 
Method Summary
static boolean delete(String name)
          Removes a heapfile.
static HeapFile get(String name)
          Gets the heapfile of a given name.
 int getInvocationCount()
          Gets the last invocationCounter from wurbler-container (for optional use in wurblets).
 String getName()
          Gets the name of the heapfile.
 PrintStream getPrintStream()
          Get the print stream to print into the heapfile.
 Reader getReader()
          Gets a reader for the contents.
 String getText()
          Gets the contents of a heapfile.
 void reset()
          Resets (empties) the heapfile.
 void setInvocationCount(int invocationCount)
          Sets the last invocation count.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HeapFile

public HeapFile(String name,
                String text)
         throws IOException
Creates a heapfile.

Parameters:
name - the unique name of the heapfile
text - the initial contents, null = empty.
Throws:
IOException - if the file already exists

HeapFile

public HeapFile(String name)
         throws IOException
Creates an empty heapfile.

Parameters:
name - the unique name of the heapfile
Throws:
IOException - if the file already exists
Method Detail

reset

public void reset()
Resets (empties) the heapfile.


getText

public String getText()
Gets the contents of a heapfile.

Returns:
the contents

getName

public String getName()
Gets the name of the heapfile.

Returns:
the name

getReader

public Reader getReader()
Gets a reader for the contents.

Returns:
the reader

getPrintStream

public PrintStream getPrintStream()
Get the print stream to print into the heapfile.

Returns:
the print stream

getInvocationCount

public int getInvocationCount()
Gets the last invocationCounter from wurbler-container (for optional use in wurblets).

Returns:
the last invocation count

setInvocationCount

public void setInvocationCount(int invocationCount)
Sets the last invocation count. Wurblets may use this to save their invocation count in order to check for redundant creation of heap files.

Parameters:
invocationCount - the invocation count.

get

public static HeapFile get(String name)
Gets the heapfile of a given name.

Parameters:
name - the name of the heapfile.
Returns:
the heapfile, null if no such file.

delete

public static boolean delete(String name)
Removes a heapfile.

Parameters:
name - the of heapfile
Returns:
true if removed, false if no such file.


Copyright © 2001-2008 Harald Krake, Bergstr. 48, 78098 Triberg, Germany, harald@krake.de