nz.ac.waikato.mcennis.rat.parser
Class ToFileParser

java.lang.Object
  extended by nz.ac.waikato.mcennis.rat.parser.ToFileParser
All Implemented Interfaces:
Parser

public class ToFileParser
extends java.lang.Object
implements Parser

Class for writing the contents of a data stream to a file. Designed to be called from multiple instances and writing to the same directory without corruption.


Constructor Summary
ToFileParser()
          Create a FileParser saving to the temporary directory.
ToFileParser(java.lang.String location)
          Create a FileParser saving to the given location.
 
Method Summary
 Parser duplicate()
          Create an exact copy of this object
 ParsedObject get()
          Intentionally null
 java.lang.String getFilename()
           
 java.lang.String getName()
           
 java.lang.String getSubDirectory()
           
 void parse(java.io.InputStream data)
          Save to the next available file number
 void parse(java.io.InputStream data, Crawler crawler)
          Same as parse
 void set(ParsedObject o)
          Intentionally a no-op
 void setCount(java.lang.Integer i)
          Set the count to a pre-set value - used if continuing a previous run
 void setFilename(java.lang.String filename)
           
 void setName(java.lang.String name)
          Give this parser an id that should be globally unique
 void setSubDirectory(java.lang.String subDirectory)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ToFileParser

public ToFileParser()
Create a FileParser saving to the temporary directory.


ToFileParser

public ToFileParser(java.lang.String location)
Create a FileParser saving to the given location.

Parameters:
location - directory the files are saved in.
Method Detail

parse

public void parse(java.io.InputStream data)
Save to the next available file number

Specified by:
parse in interface Parser
Parameters:
data - data to be saved

parse

public void parse(java.io.InputStream data,
                  Crawler crawler)
Same as parse

Specified by:
parse in interface Parser
Parameters:
data - stream to be saved to a file
crawler - ignored

duplicate

public Parser duplicate()
Description copied from interface: Parser
Create an exact copy of this object

Specified by:
duplicate in interface Parser
Returns:
new Parser object

setCount

public void setCount(java.lang.Integer i)
Set the count to a pre-set value - used if continuing a previous run

Parameters:
i - filenumber to be set to

get

public ParsedObject get()
Intentionally null

Specified by:
get in interface Parser
Returns:
null

set

public void set(ParsedObject o)
Intentionally a no-op

Specified by:
set in interface Parser
Parameters:
o - ignored

setName

public void setName(java.lang.String name)
Description copied from interface: Parser
Give this parser an id that should be globally unique

Specified by:
setName in interface Parser
Parameters:
name - id for this parser

getName

public java.lang.String getName()
Specified by:
getName in interface Parser

getFilename

public java.lang.String getFilename()

setFilename

public void setFilename(java.lang.String filename)

getSubDirectory

public java.lang.String getSubDirectory()

setSubDirectory

public void setSubDirectory(java.lang.String subDirectory)