org.afcs.warts.report
Class DataHighBitAnalysisReport

java.lang.Object
  extended byorg.afcs.warts.report.DataHighBitAnalysisReport

public final class DataHighBitAnalysisReport
extends java.lang.Object

The DataHighBitAnalysisReport class creates text and HTML reports on the high-bit analysis of a single piece of data.

LICENSE: This code is released to the public domain and may be used for any purpose whatsoever without permission or acknowledgment.

Version:
Last Modified 18 September 2003
Author:
Warren Hedley ( whedley at sdsc dot edu )

Field Summary
static java.awt.Color AMBIGUOUS_CELL
          The colour to be used to indicate the presence of ambiguous characters, that may be Latin-1 or UTF-8.
static java.awt.Color ILLEGAL_CELL
          The colour to be used to indicate the presence of illegal bytes.
static java.awt.Color LATIN_1_CELL
          The colour to be used to indicate the presence of Latin-1 characters.
static java.awt.Color MIXED_CELL
          The colour to be used to indicate the presence of more than one character type within a field.
static java.awt.Color OVERSIZE_CELL
          The colour to be used to indicate the presence of oversize character data within a column.
static java.awt.Color THREE_BYTE_UTF_8_CELL
          The colour to be used to indicate the presence of 3 byte UTF-8 characters.
static java.awt.Color TWO_BYTE_UTF_8_CELL
          The colour to be used to indicate the presence of 2 byte UTF-8 characters.
 
Method Summary
static java.lang.String createAnalysisHtml(DataHighBitAnalysis analysis)
          Returns HTML containing the contents of the short report with any HTML special characters escaped, as well as a byte-by-byte analysis of the data contained in the analysis.
static java.awt.Color getColor(int byteClass)
          This method returns the appropriate color for the specified byte class, which should be one of the BYTE_CLASS_* constants from DataHighBitAnalysis.
static java.lang.String getShortReport(DataHighBitAnalysis analysis)
          Generates a short report about the results of the analysis performed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LATIN_1_CELL

public static final java.awt.Color LATIN_1_CELL
The colour to be used to indicate the presence of Latin-1 characters.


TWO_BYTE_UTF_8_CELL

public static final java.awt.Color TWO_BYTE_UTF_8_CELL
The colour to be used to indicate the presence of 2 byte UTF-8 characters.


THREE_BYTE_UTF_8_CELL

public static final java.awt.Color THREE_BYTE_UTF_8_CELL
The colour to be used to indicate the presence of 3 byte UTF-8 characters.


AMBIGUOUS_CELL

public static final java.awt.Color AMBIGUOUS_CELL
The colour to be used to indicate the presence of ambiguous characters, that may be Latin-1 or UTF-8.


ILLEGAL_CELL

public static final java.awt.Color ILLEGAL_CELL
The colour to be used to indicate the presence of illegal bytes.


MIXED_CELL

public static final java.awt.Color MIXED_CELL
The colour to be used to indicate the presence of more than one character type within a field.


OVERSIZE_CELL

public static final java.awt.Color OVERSIZE_CELL
The colour to be used to indicate the presence of oversize character data within a column. This happens when Latin-1 data could not be converted to the equivalent UTF-8 representation without overflowing the column.

Method Detail

getColor

public static java.awt.Color getColor(int byteClass)
This method returns the appropriate color for the specified byte class, which should be one of the BYTE_CLASS_* constants from DataHighBitAnalysis.

Parameters:
byteClass - The byte class to retrieve the color for.
Returns:
The standard color for the specified byte class.

getShortReport

public static java.lang.String getShortReport(DataHighBitAnalysis analysis)
Generates a short report about the results of the analysis performed. The report includes the number of each type of character found, as well as the data converted to a string using Latin-1 and UTF-8 encodings.

Parameters:
analysis - The analysis to report on.
Returns:
A short report about the results of the analysis performed.
Throws:
java.lang.NullPointerException - If analysis is null.

createAnalysisHtml

public static java.lang.String createAnalysisHtml(DataHighBitAnalysis analysis)
Returns HTML containing the contents of the short report with any HTML special characters escaped, as well as a byte-by-byte analysis of the data contained in the analysis. The latter part looks somewhat like the output of hexdump, but with the appropriate byte classification colours applied to the bytes and text sections. The contents are wrapped in a <pre> element to make sure a fixed-width font is used, but the result will need to be wrapped in an <html> element before being used in a text pane or label.

Parameters:
analysis - The analysis to report on.
Returns:
An extended report on the specified analysis formatted as HTML.
Throws:
java.lang.NullPointerException - If analysis is null.