Secure iNet Factory

com.jscape.inet.terminal
Class ControlSequence

java.lang.Object
  extended by com.jscape.inet.terminal.ControlSequence

public class ControlSequence
extends java.lang.Object

Represents control sequence. There are several types of control sequence depending of the second character in sequence. These types are implemented as "Strategy" pattern [Gamma94]. Control sequence may be in three states: closed (if there is no sequence opening character), in-progress (if sequence opening character is received) and complete (when ending character is received). Each control sequence has "canonical" form which is used to map incoming control sequence to ControlCommand objects.


Field Summary
static char DEFAULT_OPENING_CHAR
           
 
Constructor Summary
ControlSequence()
          Creates ControlSequence object with default opening char ('\033').
ControlSequence(char openingCh)
          Creates ControlSequence object giving opening char.
 
Method Summary
static boolean addType(char keyValue, SequenceType type)
          Adds map of second sequence character to SequenceType object.
 void append(char ch)
          Adds char to current sequence.
 java.lang.String getCanonicalForm()
          Returns "canonical" form of control sequence (i.e.
 char getOpeningChar()
          Returns sequence opening char.
 int[] getParameters()
          Extracts and returns sequence parameters as array of int.
 boolean inProgress()
          Checks if sequence is in progress.
 boolean isComplete()
          Checks if sequence is complete.
 boolean isOpeningChar(char ch)
          Checks if giving char is opening char for current sequence.
static boolean removeType(char keyValue)
          Removes map.
 void reset()
          Resets current sequence.
 void startNew()
          Resets sequence and starts a new one.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_OPENING_CHAR

public static final char DEFAULT_OPENING_CHAR
See Also:
Constant Field Values
Constructor Detail

ControlSequence

public ControlSequence(char openingCh)
Creates ControlSequence object giving opening char.

Parameters:
openingCh - sequence opening char.

ControlSequence

public ControlSequence()
Creates ControlSequence object with default opening char ('\033').

Method Detail

addType

public static boolean addType(char keyValue,
                              SequenceType type)
Adds map of second sequence character to SequenceType object.

Parameters:
keyValue - second character in sequence.
type - SequenceType object.
Returns:
true if map was successfully added.

removeType

public static boolean removeType(char keyValue)
Removes map.

Parameters:
keyValue - second character in sequence.
Returns:
true if map was successfully removed.

getCanonicalForm

public java.lang.String getCanonicalForm()
Returns "canonical" form of control sequence (i.e. without parameters). For example: having "\033[0;7m" incoming sequence its "canonical" form will be "\033[m".

Returns:
string with "canonical" sequence form.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getOpeningChar

public char getOpeningChar()
Returns sequence opening char.

Returns:
sequence opening char.

isComplete

public boolean isComplete()
Checks if sequence is complete.

Returns:
true if sequence is complete.

inProgress

public boolean inProgress()
Checks if sequence is in progress.

Returns:
true if sequence is in progress.

isOpeningChar

public boolean isOpeningChar(char ch)
Checks if giving char is opening char for current sequence.

Parameters:
ch - char to check.
Returns:
true if giving char is opening char for current sequence.

getParameters

public int[] getParameters()
Extracts and returns sequence parameters as array of int.

Returns:
array of int.

append

public void append(char ch)
Adds char to current sequence.

Parameters:
ch - character to add.

reset

public void reset()
Resets current sequence.


startNew

public void startNew()
Resets sequence and starts a new one.


Secure iNet Factory

Copyright © JSCAPE LLC. 1999-2011. All Rights Reserved