com.ibm.jc.tools
Class JCShell

java.lang.Object
  extended bycom.ibm.util.getopt.GetOptSpec
      extended bycom.ibm.jc.tools.JCShell

public class JCShell
extends com.ibm.util.getopt.GetOptSpec

JCShell: JavaCard shell

This shell allows on-line interoperation with a JavaCard and the applets running on such a card. In addition to this interactive mode it is also possible to run script files containing these commands.

The JCShell can be used to test applet behavior and to run regression tests automatically. The shell is extensible to address custom behavior of applets.


Nested Class Summary
static interface JCShell.InputHandler
           
static interface JCShell.ShellListener
          ShellListener functionality.
 
Field Summary
static int ABBREVMATCH
           
static int ARG_QUOTES
           
static int ARG_VARS
           
static int DEF_SCOPE
           
static int EXACTMATCH
           
static int GLOBAL_SCOPE
           
static JCShell.InputHandler inputHandler
          Shell input/output control
static int LOCAL_SCOPE
           
static int NOMATCH
          Type of matches for equalsCmd
 
Fields inherited from class com.ibm.util.getopt.GetOptSpec
argEaters, indent, leftAligned, OK
 
Method Summary
static void blockTermIO()
           
static int checkChannel(java.lang.String[] argv)
          Check if argv[0] is a channel selector.
static void clearVariables()
           
static java.lang.String dateToString(int date)
          Return a String representing a date.
static void deprecated(java.lang.String msg)
          Print info on deprecated shell features.
static void error(java.lang.String msg)
          Some error occurred.
static boolean executeDefun(java.lang.Object[] defun, java.util.Vector argv, boolean noNewScope)
           
static boolean executeScript(java.lang.String name, java.io.FileReader in, java.util.Vector argv, boolean noNewScope)
           
static void exit(int status, java.lang.String message)
          Exit shell with given status.
static void flush()
          Flush output.
static java.lang.String formatStrings(java.lang.String[] strs, int indent, int maxWidth, java.lang.String sep)
          Return a string with the formatted listing of the specified algorithms An array { A, B, C, D, E, F, G } of algorithm names is display in the form: A C E G B D F
static JCShellPlugin getAppletPlugin()
           
static java.lang.String getLastError()
          get last error message or an empty String if no error occured
static java.lang.String getLastResponse()
           
static java.io.PrintStream getOutputStream()
           
static java.lang.String getPrompt()
           
static java.lang.String[] getReturnValue()
          get return value as String[] either String or ArrayValue Hex.toString(traceTerminal.getLastResponse())
static java.lang.Object getVariable(int scope, java.lang.String name)
           
static java.lang.String getVariable(java.lang.String name)
           
static java.lang.String getVersion()
          show current program version and build timestamp
static boolean hasLastError()
          indicates if command execution caused an error
static java.util.Vector initialize(java.io.PrintStream cout, java.lang.String[] argv)
          Initialize with custom output stream used from main and also by JCOP Tools
static java.util.Vector initialize(java.lang.String[] argv)
           
static void interactiveInput()
           
static boolean isRemoteConnected()
          return true if a terminal is connected and this is a "RemoteJCTerminal"
static boolean lineInput(java.lang.String line)
          Process one line of input.
static void main(java.lang.String[] argv)
           
static int matchStrings(java.lang.String arg, java.lang.String spec)
          Compare a string against some command specification.
static java.lang.String pad(java.lang.String s, int width, boolean truncate)
          Pad some string
static JCTerminal popTerminalFilter()
          Remove top most filter terminal.
static void print(java.lang.String msg)
          Print output.
static void println(java.lang.String msg)
          Print output.
static void pushTerminalFilter(JCTerminal term)
          Applied some terminal filter to currently open terminal.
static java.lang.String releaseToString(int r)
          Return a String representing release data.
static void resetError()
           
static void revertChannels()
          Revert to settings before checkChannel has been called.
static void setChannels(int e)
          Set enabled output channels.
static void setClassLoader(java.lang.ClassLoader loader)
           
static void setReturnValue(java.lang.Object value)
          Set return value - subject to $(..) evaluation.
static void setShellListener(JCShell.ShellListener listener)
           
static void setVariable(int scope, java.lang.String name, java.lang.Object value)
           
static void setVariable(java.lang.String name, java.lang.Object value)
           
static java.util.Vector splitIntoArgv(java.lang.String arg, int offset, boolean commandLine)
           
 
Methods inherited from class com.ibm.util.getopt.GetOptSpec
cancelDialog, checkCmdFile, checkConsistency, commandLine, exit, getArgv, getDescription, getName, init, isInconsistent, makeGetOptPanel, parse, parse, parseWithCmdFile, runDialog, usage, usageFor, writeCmdFile
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

inputHandler

public static JCShell.InputHandler inputHandler
Shell input/output control


ARG_QUOTES

public static final int ARG_QUOTES
See Also:
Constant Field Values

ARG_VARS

public static final int ARG_VARS
See Also:
Constant Field Values

GLOBAL_SCOPE

public static final int GLOBAL_SCOPE
See Also:
Constant Field Values

DEF_SCOPE

public static final int DEF_SCOPE
See Also:
Constant Field Values

LOCAL_SCOPE

public static final int LOCAL_SCOPE
See Also:
Constant Field Values

NOMATCH

public static int NOMATCH
Type of matches for equalsCmd


ABBREVMATCH

public static int ABBREVMATCH

EXACTMATCH

public static int EXACTMATCH
Method Detail

initialize

public static java.util.Vector initialize(java.lang.String[] argv)
                                   throws java.io.IOException
Throws:
java.io.IOException

initialize

public static java.util.Vector initialize(java.io.PrintStream cout,
                                          java.lang.String[] argv)
                                   throws java.io.IOException
Initialize with custom output stream used from main and also by JCOP Tools

Throws:
java.io.IOException

main

public static void main(java.lang.String[] argv)

executeScript

public static boolean executeScript(java.lang.String name,
                                    java.io.FileReader in,
                                    java.util.Vector argv,
                                    boolean noNewScope)

executeDefun

public static boolean executeDefun(java.lang.Object[] defun,
                                   java.util.Vector argv,
                                   boolean noNewScope)

interactiveInput

public static void interactiveInput()

getPrompt

public static java.lang.String getPrompt()

isRemoteConnected

public static boolean isRemoteConnected()
return true if a terminal is connected and this is a "RemoteJCTerminal"


getVersion

public static java.lang.String getVersion()
show current program version and build timestamp

Returns:
current version and build timestamp

lineInput

public static boolean lineInput(java.lang.String line)
Process one line of input. Used by Eclipse tools.


pushTerminalFilter

public static void pushTerminalFilter(JCTerminal term)
Applied some terminal filter to currently open terminal.


popTerminalFilter

public static JCTerminal popTerminalFilter()
Remove top most filter terminal.

Returns:
top most filter terminal.

blockTermIO

public static void blockTermIO()

splitIntoArgv

public static java.util.Vector splitIntoArgv(java.lang.String arg,
                                             int offset,
                                             boolean commandLine)

getVariable

public static java.lang.Object getVariable(int scope,
                                           java.lang.String name)

setVariable

public static void setVariable(int scope,
                               java.lang.String name,
                               java.lang.Object value)

setVariable

public static void setVariable(java.lang.String name,
                               java.lang.Object value)

getVariable

public static java.lang.String getVariable(java.lang.String name)

clearVariables

public static void clearVariables()

getAppletPlugin

public static JCShellPlugin getAppletPlugin()

setClassLoader

public static void setClassLoader(java.lang.ClassLoader loader)

setShellListener

public static void setShellListener(JCShell.ShellListener listener)

exit

public static void exit(int status,
                        java.lang.String message)
Exit shell with given status.


deprecated

public static void deprecated(java.lang.String msg)
Print info on deprecated shell features.


error

public static void error(java.lang.String msg)
Some error occurred.


setReturnValue

public static void setReturnValue(java.lang.Object value)
Set return value - subject to $(..) evaluation.


getReturnValue

public static java.lang.String[] getReturnValue()
get return value as String[] either String or ArrayValue Hex.toString(traceTerminal.getLastResponse())

Returns:
String[]

getLastResponse

public static java.lang.String getLastResponse()

getLastError

public static java.lang.String getLastError()
get last error message or an empty String if no error occured

Returns:
String

hasLastError

public static boolean hasLastError()
indicates if command execution caused an error

Returns:
boolean

resetError

public static void resetError()

setChannels

public static void setChannels(int e)
Set enabled output channels.


checkChannel

public static int checkChannel(java.lang.String[] argv)
Check if argv[0] is a channel selector. Change outMux.enabled and save previous settings.

Returns:
index into argv

revertChannels

public static void revertChannels()
Revert to settings before checkChannel has been called.


getOutputStream

public static java.io.PrintStream getOutputStream()

println

public static void println(java.lang.String msg)
Print output. Always use this method; never write directly to System.out!


print

public static void print(java.lang.String msg)
Print output. Always use this method; never write directly to System.out!


flush

public static void flush()
Flush output. Always use this method; never directly flush System.out!


pad

public static java.lang.String pad(java.lang.String s,
                                   int width,
                                   boolean truncate)
Pad some string

Parameters:
s - String to pad
width - pad to this field length. Positive values pad on right side with blanks. Negative values pad on the left side.
truncate - if true truncate string to match field width

releaseToString

public static java.lang.String releaseToString(int r)
Return a String representing release data.

Parameters:
r - the least significant 16 bits contain the release data

dateToString

public static java.lang.String dateToString(int date)
Return a String representing a date.

Parameters:
date - the least significant 16 bits contain the date

matchStrings

public static int matchStrings(java.lang.String arg,
                               java.lang.String spec)
Compare a string against some command specification. The string might be abbreviated. Each syllable, delimited by a `-', might be abbreviated separately.


formatStrings

public static java.lang.String formatStrings(java.lang.String[] strs,
                                             int indent,
                                             int maxWidth,
                                             java.lang.String sep)
Return a string with the formatted listing of the specified algorithms An array { A, B, C, D, E, F, G } of algorithm names is display in the form:
   A C E G
   B D F
 

Parameters:
strs - the list of strings
indent - each line starts with that many spaces
maxWidth - each line shall not be longer than that
sep - the string which separates columns of algorithms.
Returns:
a string which comprises one or several lines. It ends with a new line.


Copyright (c) 2004, 2006 International Business Machines Corporation. All Rights Reserved.