Class ClientBase

java.lang.Object
cl.netswitch.lib.client.ClientBase

public abstract class ClientBase extends Object
Implements the common logic of a client application.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static interface 
    Executes the logic of a client action using a connected channel.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Constructs a new ClientBase instance.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    Connects to HyperNet and executes the specified action.
    protected String
    format(String format, Object... args)
    Returns a formatted message built using format and arguments.
    protected void
    print(String format, Object... args)
    Prints a formatted message using arguments.
    protected static void
    Prints a compact stack trace of a throwable in standard error.
    protected void
    println(String format, Object... args)
    Prints a formatted message using arguments then terminates the line.
    protected void
    Register a new test indexed by specified name.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ClientBase

      protected ClientBase()
      Constructs a new ClientBase instance.
  • Method Details

    • register

      protected void register(String name, ClientBase.Action action)
      Register a new test indexed by specified name.
      Parameters:
      name - the name of the action.
      action - the client action to be executed.
      Throws:
      NullPointerException - if an argument is null.
      IllegalArgumentException - if name already defined.
    • println

      protected void println(String format, Object... args)
      Prints a formatted message using arguments then terminates the line.
      Parameters:
      format - the format of formatted message.
      args - an array of optional format arguments.
      See Also:
    • print

      protected void print(String format, Object... args)
      Prints a formatted message using arguments.
      Parameters:
      format - the format of formatted message.
      args - an array of optional format arguments.
      See Also:
    • format

      protected String format(String format, Object... args)
      Returns a formatted message built using format and arguments.
      Parameters:
      format - the format of formatted message.
      args - an array of optional format arguments.
      Returns:
      a formatted message built using format and arguments.
      See Also:
    • connectAndExecute

      protected void connectAndExecute() throws Exception
      Connects to HyperNet and executes the specified action.
      Throws:
      Exception - if an unexpected error occurs.
    • printCompactStackTrace

      protected static void printCompactStackTrace(Throwable thrown)
      Prints a compact stack trace of a throwable in standard error. After the compact stack trace is printed, this method terminates the execution of the JVM calling System.exit(1).
      Parameters:
      thrown - the throwable whose compact stack will be printed.