TelnetD at SF

net.wimpi.telnetd.io.terminal
Class Colorizer

java.lang.Object
  extended bynet.wimpi.telnetd.io.terminal.Colorizer

public final class Colorizer
extends java.lang.Object

Singleton utility class for translating internal color/style markup into ANSI defined escape sequences. It uses a very simple but effective lookup table, and does the job without sophisticated parsing routines. It should therefore perform quite fast.

Version:
2.0 (13/03/2005)
Author:
Dieter Wimberger

Method Summary
 java.lang.String colorize(java.lang.String str, boolean support)
          Translates all internal markups within the String into ANSI Escape sequences.
 java.lang.String colorize(java.lang.String str, boolean support, boolean forcebold)
          Translates all internal markups within the String into ANSI Escape sequences.
static Colorizer getReference()
          Returns the reference of the Singleton instance.
static void main(java.lang.String[] args)
          Invokes the build in test harness, and will produce styled and colored output directly on the terminal.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

colorize

public java.lang.String colorize(java.lang.String str,
                                 boolean support)
Translates all internal markups within the String into ANSI Escape sequences.
The method is hooked into BasicTerminalIO.write(String str), so it is not necessary to call it directly.

Parameters:
str - String with internal color/style markups.
support - boolean that represents Terminals ability to support GR sequences. if false, the internal markups are ripped out of the string.
Returns:
String with ANSI escape sequences (Graphics Rendition), if support is true, String without internal markups or ANSI escape sequences if support is false.

colorize

public java.lang.String colorize(java.lang.String str,
                                 boolean support,
                                 boolean forcebold)
Translates all internal markups within the String into ANSI Escape sequences.
The method is hooked into BasicTerminalIO.write(String str), so it is not necessary to call it directly.

Parameters:
str - String with internal color/style markups.
support - boolean that represents Terminals ability to support GR sequences. if false, the internal markups are ripped out of the string.
forcebold - boolean that forces the output to be bold at any time.
Returns:
String with ANSI escape sequences (Graphics Rendition), if support is true, String without internal markups or ANSI escape sequences if support is false.

getReference

public static Colorizer getReference()
Returns the reference of the Singleton instance.

Returns:
reference to Colorizer singleton instance.

main

public static void main(java.lang.String[] args)
Invokes the build in test harness, and will produce styled and colored output directly on the terminal.


TelnetD at SF

Copyright 2000-2005 Dieter Wimberger.