Package hudson.plugins.ansicolor
Class AnsiHtmlOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- java.io.FilterOutputStream
-
- hudson.plugins.ansicolor.AnsiOutputStream
-
- hudson.plugins.ansicolor.AnsiHtmlOutputStream
-
- All Implemented Interfaces:
Closeable
,Flushable
,AutoCloseable
public class AnsiHtmlOutputStream extends AnsiOutputStream
Filters an output stream of ANSI escape sequences and emits appropriate HTML elements instead. Overlapping ANSI attribute combinations are handled by rewinding the HTML element stack. How the HTML is actually emitted depends on the specifiedAnsiAttributeElement.Emitter
. For Jenkins, the Emitter createsConsoleNote
s as part of the stream, but for other software or testing the HTML may be emitted otherwise. The only thing that ties this class to Jenkins is the rather unfortunateConsoleNote
preamble/postamble handling via state machine. Simply remove this if you plan to use this class somewhere else.
-
-
Field Summary
Fields Modifier and Type Field Description protected static int
ATTRIBUTE_ENCIRCLED
protected static int
ATTRIBUTE_FRAMED
protected static int
ATTRIBUTE_FRAMED_OFF
protected static int
ATTRIBUTE_ITALIC_OFF
protected static int
ATTRIBUTE_OVERLINE
protected static int
ATTRIBUTE_OVERLINE_OFF
protected static int
ATTRIBUTE_STRIKEOUT
protected static int
ATTRIBUTE_STRIKEOUT_OFF
-
Fields inherited from class hudson.plugins.ansicolor.AnsiOutputStream
ATTRIBUTE_BLINK_FAST, ATTRIBUTE_BLINK_OFF, ATTRIBUTE_BLINK_SLOW, ATTRIBUTE_CONCEAL_OFF, ATTRIBUTE_CONCEAL_ON, ATTRIBUTE_INTENSITY_BOLD, ATTRIBUTE_INTENSITY_FAINT, ATTRIBUTE_INTENSITY_NORMAL, ATTRIBUTE_ITALIC, ATTRIBUTE_NEGATIVE_Off, ATTRIBUTE_NEGATIVE_ON, ATTRIBUTE_UNDERLINE, ATTRIBUTE_UNDERLINE_DOUBLE, ATTRIBUTE_UNDERLINE_OFF, BLACK, BLUE, CYAN, ERASE_LINE, ERASE_LINE_TO_BEGINING, ERASE_LINE_TO_END, ERASE_SCREEN, ERASE_SCREEN_TO_BEGINING, ERASE_SCREEN_TO_END, GREEN, MAGENTA, RED, REST_CODE, WHITE, YELLOW
-
Fields inherited from class java.io.FilterOutputStream
out
-
-
Constructor Summary
Constructors Constructor Description AnsiHtmlOutputStream(OutputStream os, AnsiColorMap colorMap, hudson.plugins.ansicolor.AnsiAttributeElement.Emitter emitter)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
protected void
processAttributeRest()
protected void
processChangeIconName(String label)
protected void
processChangeWindowTitle(String label)
protected void
processCharsetSelect(int set, char seq)
protected void
processCursorDown(int count)
protected void
processCursorDownLine(int count)
protected void
processCursorLeft(int count)
protected void
processCursorRight(int count)
protected void
processCursorTo(int row, int col)
protected void
processCursorToColumn(int x)
protected void
processCursorUp(int count)
protected void
processCursorUpLine(int count)
protected void
processDefaultBackgroundColor()
protected void
processDefaultTextColor()
protected void
processEraseLine(int eraseOption)
protected void
processEraseScreen(int eraseOption)
protected void
processRestoreCursorPosition()
protected void
processSaveCursorPosition()
protected void
processScrollDown(int optionInt)
protected void
processScrollUp(int optionInt)
protected void
processSetAttribute(int attribute)
protected void
processSetBackgroundColor(int color)
protected void
processSetBackgroundColor(int color, boolean bright)
protected void
processSetBackgroundColorExt(int paletteIndex)
protected void
processSetBackgroundColorExt(int r, int g, int b)
protected void
processSetForegroundColor(int color)
protected void
processSetForegroundColor(int color, boolean bright)
protected void
processSetForegroundColorExt(int paletteIndex)
protected void
processSetForegroundColorExt(int r, int g, int b)
protected void
processUnknownExtension(ArrayList<Object> options, int command)
protected void
processUnknownOperatingSystemCommand(int command, String param)
void
setBackgroundColor(String color)
void
write(int data)
-
Methods inherited from class hudson.plugins.ansicolor.AnsiOutputStream
processChangeIconNameAndWindowTitle
-
Methods inherited from class java.io.FilterOutputStream
flush, write, write
-
Methods inherited from class java.io.OutputStream
nullOutputStream
-
-
-
-
Field Detail
-
ATTRIBUTE_STRIKEOUT
protected static final int ATTRIBUTE_STRIKEOUT
- See Also:
- Constant Field Values
-
ATTRIBUTE_ITALIC_OFF
protected static final int ATTRIBUTE_ITALIC_OFF
- See Also:
- Constant Field Values
-
ATTRIBUTE_STRIKEOUT_OFF
protected static final int ATTRIBUTE_STRIKEOUT_OFF
- See Also:
- Constant Field Values
-
ATTRIBUTE_FRAMED
protected static final int ATTRIBUTE_FRAMED
- See Also:
- Constant Field Values
-
ATTRIBUTE_ENCIRCLED
protected static final int ATTRIBUTE_ENCIRCLED
- See Also:
- Constant Field Values
-
ATTRIBUTE_OVERLINE
protected static final int ATTRIBUTE_OVERLINE
- See Also:
- Constant Field Values
-
ATTRIBUTE_FRAMED_OFF
protected static final int ATTRIBUTE_FRAMED_OFF
- See Also:
- Constant Field Values
-
ATTRIBUTE_OVERLINE_OFF
protected static final int ATTRIBUTE_OVERLINE_OFF
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
AnsiHtmlOutputStream
public AnsiHtmlOutputStream(OutputStream os, AnsiColorMap colorMap, hudson.plugins.ansicolor.AnsiAttributeElement.Emitter emitter)
-
-
Method Detail
-
write
public void write(int data) throws IOException
- Overrides:
write
in classAnsiOutputStream
- Throws:
IOException
-
close
public void close() throws IOException
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classAnsiOutputStream
- Throws:
IOException
-
setBackgroundColor
public void setBackgroundColor(String color)
-
processSetAttribute
protected void processSetAttribute(int attribute)
- Overrides:
processSetAttribute
in classAnsiOutputStream
-
processAttributeRest
protected void processAttributeRest()
- Overrides:
processAttributeRest
in classAnsiOutputStream
-
processSetForegroundColor
protected void processSetForegroundColor(int color)
- Overrides:
processSetForegroundColor
in classAnsiOutputStream
-
processSetForegroundColor
protected void processSetForegroundColor(int color, boolean bright)
- Overrides:
processSetForegroundColor
in classAnsiOutputStream
-
processSetForegroundColorExt
protected void processSetForegroundColorExt(int paletteIndex)
- Overrides:
processSetForegroundColorExt
in classAnsiOutputStream
-
processSetForegroundColorExt
protected void processSetForegroundColorExt(int r, int g, int b)
- Overrides:
processSetForegroundColorExt
in classAnsiOutputStream
-
processSetBackgroundColor
protected void processSetBackgroundColor(int color)
- Overrides:
processSetBackgroundColor
in classAnsiOutputStream
-
processSetBackgroundColor
protected void processSetBackgroundColor(int color, boolean bright)
- Overrides:
processSetBackgroundColor
in classAnsiOutputStream
-
processSetBackgroundColorExt
protected void processSetBackgroundColorExt(int paletteIndex)
- Overrides:
processSetBackgroundColorExt
in classAnsiOutputStream
-
processSetBackgroundColorExt
protected void processSetBackgroundColorExt(int r, int g, int b)
- Overrides:
processSetBackgroundColorExt
in classAnsiOutputStream
-
processDefaultTextColor
protected void processDefaultTextColor()
- Overrides:
processDefaultTextColor
in classAnsiOutputStream
-
processDefaultBackgroundColor
protected void processDefaultBackgroundColor()
- Overrides:
processDefaultBackgroundColor
in classAnsiOutputStream
-
processEraseLine
protected void processEraseLine(int eraseOption)
- Overrides:
processEraseLine
in classAnsiOutputStream
-
processCursorDown
protected void processCursorDown(int count)
- Overrides:
processCursorDown
in classAnsiOutputStream
-
processCursorUp
protected void processCursorUp(int count)
- Overrides:
processCursorUp
in classAnsiOutputStream
-
processCursorLeft
protected void processCursorLeft(int count)
- Overrides:
processCursorLeft
in classAnsiOutputStream
-
processCursorUpLine
protected void processCursorUpLine(int count)
- Overrides:
processCursorUpLine
in classAnsiOutputStream
-
processRestoreCursorPosition
protected void processRestoreCursorPosition()
- Overrides:
processRestoreCursorPosition
in classAnsiOutputStream
-
processSaveCursorPosition
protected void processSaveCursorPosition()
- Overrides:
processSaveCursorPosition
in classAnsiOutputStream
-
processScrollDown
protected void processScrollDown(int optionInt)
- Overrides:
processScrollDown
in classAnsiOutputStream
-
processScrollUp
protected void processScrollUp(int optionInt)
- Overrides:
processScrollUp
in classAnsiOutputStream
-
processEraseScreen
protected void processEraseScreen(int eraseOption)
- Overrides:
processEraseScreen
in classAnsiOutputStream
-
processCursorTo
protected void processCursorTo(int row, int col)
- Overrides:
processCursorTo
in classAnsiOutputStream
-
processCursorToColumn
protected void processCursorToColumn(int x)
- Overrides:
processCursorToColumn
in classAnsiOutputStream
-
processCursorDownLine
protected void processCursorDownLine(int count)
- Overrides:
processCursorDownLine
in classAnsiOutputStream
-
processCursorRight
protected void processCursorRight(int count)
- Overrides:
processCursorRight
in classAnsiOutputStream
-
processUnknownExtension
protected void processUnknownExtension(ArrayList<Object> options, int command)
- Overrides:
processUnknownExtension
in classAnsiOutputStream
-
processChangeIconName
protected void processChangeIconName(String label)
- Overrides:
processChangeIconName
in classAnsiOutputStream
-
processChangeWindowTitle
protected void processChangeWindowTitle(String label)
- Overrides:
processChangeWindowTitle
in classAnsiOutputStream
-
processUnknownOperatingSystemCommand
protected void processUnknownOperatingSystemCommand(int command, String param)
- Overrides:
processUnknownOperatingSystemCommand
in classAnsiOutputStream
-
processCharsetSelect
protected void processCharsetSelect(int set, char seq)
- Overrides:
processCharsetSelect
in classAnsiOutputStream
-
-