de.hpi.fgis.dude.output
Class AbstractDuDeOutput

java.lang.Object
  extended by de.hpi.fgis.dude.output.AbstractDuDeOutput
All Implemented Interfaces:
DuDeOutput, AutoJsonable, Jsonable
Direct Known Subclasses:
JsonOutput, SimpleTextOutput

public abstract class AbstractDuDeOutput
extends Object
implements DuDeOutput, Jsonable

AbstractDuDeOuput is an abstract class which provides the common functionality of every class that implements DuDeOutput. Every concrete DuDeOutput implementation might inherit from this class instead of implementing the DuDeOutput interface directly.

Author:
Matthias Pohl

Field Summary
protected  OutputStreamWriter outputStream
          The stream writer that is used for the output.
 
Constructor Summary
protected AbstractDuDeOutput()
          Internal constructor for Jsonable deserialization.
  AbstractDuDeOutput(File out)
          Initializes a DuDeOutput with the given File.
  AbstractDuDeOutput(File out, String hdr)
          Initializes a DuDeOutput with the given File.
  AbstractDuDeOutput(File out, String hdr, String ftr)
          Initializes a DuDeOutput with the given File.
  AbstractDuDeOutput(OutputStream out)
          Initializes a DuDeOutput with the given OutputStream.
  AbstractDuDeOutput(OutputStream out, String hdr)
          Initializes a DuDeOutput with the given OutputStream.
  AbstractDuDeOutput(OutputStream out, String hdr, String ftr)
          Initializes a DuDeOutput with the given OutputStream.
 
Method Summary
 void close()
          Closes the stream.
 void fromJson(DuDeJsonParser<?> jsonParser)
          Initializes the current instance using the passed DuDeJsonParser.
protected  String getDefaultFooter()
          Returns the default footer of the implementation.
protected  String getDefaultHeader()
          Returns the default header of the implementation.
protected  boolean printDataEnabled()
          Checks whether printing the data is enable or not.
 void toJson(DuDeJsonGenerator jsonGenerator)
          Generates the Json code using the passed DuDeJsonGenerator.
 AbstractDuDeOutput withData()
          Enables printing the data.
 AbstractDuDeOutput withoutData()
          Disables printing the data.
abstract  void write(DuDeObjectPair pair)
          Writes the DuDeObjectPair onto an stream.
 void writeDuplicatesOnly(DuDeObjectPair pair)
          DuDeOutput#writeDuplicatesOnly(DuDeObjectPair)
protected  void writelnToStream(String str)
          Writes the passed string followed by a newline into the OutputStream.
protected  void writeToStream(String str)
          Writes the passed string into the OutputStream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

outputStream

protected transient OutputStreamWriter outputStream
The stream writer that is used for the output.

Constructor Detail

AbstractDuDeOutput

public AbstractDuDeOutput(OutputStream out)
                   throws IOException
Initializes a DuDeOutput with the given OutputStream. Since no specialized header and footer are set the default Strings will be printed. The data is not printed besides the source and object ids.

Parameters:
out - The OutputStream into which the information is written.
Throws:
IOException - If an error occurs while printing the header.

AbstractDuDeOutput

public AbstractDuDeOutput(OutputStream out,
                          String hdr)
                   throws IOException
Initializes a DuDeOutput with the given OutputStream. Since no specialized footer is set the default String will be printed. The data is not printed besides the source and object ids.

Parameters:
out - The OutputStream into which the information is written.
hdr - Specifies the header that is written in front of the result list.
Throws:
IOException - If an error occurs while printing the header.

AbstractDuDeOutput

public AbstractDuDeOutput(OutputStream out,
                          String hdr,
                          String ftr)
                   throws IOException
Initializes a DuDeOutput with the given OutputStream. The passed Strings will be used as header and footer.

Parameters:
out - The OutputStream into which the information is written.
hdr - Specifies the header that is written in front of the result list.
ftr - Specifies the footer that is written after the result list was printed.
Throws:
IOException - If an error occurs while printing the header.

AbstractDuDeOutput

public AbstractDuDeOutput(File out)
                   throws IOException
Initializes a DuDeOutput with the given File. Since no specialized header and footer are set the default Strings will be printed. The data is not printed besides the source and object ids.

Parameters:
out - The File into which the information is written.
Throws:
IOException - If an error occurs while printing the header.

AbstractDuDeOutput

public AbstractDuDeOutput(File out,
                          String hdr)
                   throws IOException
Initializes a DuDeOutput with the given File. Since no specialized footer is set the default String will be printed. The data is not printed besides the source and object ids.

Parameters:
out - The File into which the information is written.
hdr - Specifies the header that is written in front of the result list.
Throws:
IOException - If an error occurs while printing the header.

AbstractDuDeOutput

public AbstractDuDeOutput(File out,
                          String hdr,
                          String ftr)
                   throws IOException
Initializes a DuDeOutput with the given File. The passed Strings will be used as header and footer.

Parameters:
out - The File into which the information is written.
hdr - Specifies the header that is written in front of the result list.
ftr - Specifies the footer that is written after the result list was printed.
Throws:
IOException - If an error occurs while printing the header.

AbstractDuDeOutput

protected AbstractDuDeOutput()
Internal constructor for Jsonable deserialization.

Method Detail

printDataEnabled

protected boolean printDataEnabled()
Checks whether printing the data is enable or not.

Returns:
true, if printing the data is enabled; otherwise false.

withData

public AbstractDuDeOutput withData()
Description copied from interface: DuDeOutput
Enables printing the data. This means that the output does not only consist of the object ids but contains also the corresponding data.

Specified by:
withData in interface DuDeOutput
Returns:
The current instance.

withoutData

public AbstractDuDeOutput withoutData()
Description copied from interface: DuDeOutput
Disables printing the data. This means that each printed duplicate pair is only specified by their source and object ids.

Specified by:
withoutData in interface DuDeOutput
Returns:
The current instance.

writeToStream

protected void writeToStream(String str)
                      throws IOException
Writes the passed string into the OutputStream.

Parameters:
str - The string that will be written into the OutputStream.
Throws:
IOException - If an error occurs while writing to the OutputStream.

writelnToStream

protected void writelnToStream(String str)
                        throws IOException
Writes the passed string followed by a newline into the OutputStream.

Parameters:
str - The string that will be written into the OutputStream.
Throws:
IOException - If an error occurs while writing to the OutputStream.

close

public void close()
           throws IOException
Description copied from interface: DuDeOutput
Closes the stream.

Specified by:
close in interface DuDeOutput
Throws:
IOException - If an error occurs while closing the stream.

getDefaultHeader

protected String getDefaultHeader()
Returns the default header of the implementation. This method should be overwritten by a subclass if it shall provide another default header than an empty String.

Returns:
Returns an empty String.

getDefaultFooter

protected String getDefaultFooter()
Returns the default footer of the implementation. This method should be overwritten by a subclass if it shall provide another default header than an empty String.

Returns:
Returns an empty String.

write

public abstract void write(DuDeObjectPair pair)
                    throws IOException
Description copied from interface: DuDeOutput
Writes the DuDeObjectPair onto an stream.

Specified by:
write in interface DuDeOutput
Parameters:
pair - A pair of two DuDeObjects that are written into an OutputStream.
Throws:
IOException - If an error occurs while writing onto the stream.

writeDuplicatesOnly

public void writeDuplicatesOnly(DuDeObjectPair pair)
                         throws IOException
DuDeOutput#writeDuplicatesOnly(DuDeObjectPair)

Specified by:
writeDuplicatesOnly in interface DuDeOutput
Parameters:
pair - The pair that shall be written to the stream.
Throws:
IOException - If an error occurs while writing onto the stream.
See Also:
DuDeObjectPair.getDuplicateInfo()

fromJson

public void fromJson(DuDeJsonParser<?> jsonParser)
              throws org.codehaus.jackson.JsonParseException,
                     IOException
Description copied from interface: Jsonable
Initializes the current instance using the passed DuDeJsonParser.

Specified by:
fromJson in interface Jsonable
Parameters:
jsonParser - The parser that is used for extracting the data out of the Json.
Throws:
org.codehaus.jackson.JsonParseException - If an error occurs while parsing the Json.
IOException - If an error occurs while reading from the stream.

toJson

public void toJson(DuDeJsonGenerator jsonGenerator)
            throws org.codehaus.jackson.JsonGenerationException,
                   IOException
Description copied from interface: Jsonable
Generates the Json code using the passed DuDeJsonGenerator.

Specified by:
toJson in interface Jsonable
Parameters:
jsonGenerator - The DuDeJsonGenerator that is used internally.
Throws:
org.codehaus.jackson.JsonGenerationException - If an error occurs while generating the Json syntax.
IOException - If an error occurs while writing to the output.


Copyright © 2011 Hasso Plattner Institute - Chair of Information Systems. All Rights Reserved.