com.fedmest.cw.keyboard.internal
Class KeyboardUtilsDefImpl

java.lang.Object
  extended by com.fedmest.cw.keyboard.KeyboardUtils
      extended by com.fedmest.cw.keyboard.internal.KeyboardUtilsDefImpl

public final class KeyboardUtilsDefImpl
extends KeyboardUtils

This class is the default implementation of KeyboardUtils. It prompts the user for input with --> and signals an error with a ! prefix. It also allows users to cancel a cancelable input by typing nothing and pressing <enter>. The class is not meant to be used directly, but serves as an example of how to create your subclasses of KeyboardUtils. It is also the implementation returned by the KeyboardUtils.newDefaultKeyboard() method.

Version:
1.0
Author:
Federico Mestrone

Constructor Summary
KeyboardUtilsDefImpl()
           
 
Method Summary
protected  java.lang.String addErrTag(java.lang.String msg)
          Adds the error tag to a string.
protected  java.lang.String addPrompt(java.lang.String msg)
          Adds the input prompt to a string.
protected  boolean shouldCancel(java.lang.String txt)
          Checks whether a cancel sequence was typed.
 
Methods inherited from class com.fedmest.cw.keyboard.KeyboardUtils
error, isCancelable, newDefaultKeyboard, prompt, readBinaryFromKeyboard, readBinaryFromKeyboard, readBoolFromKeyboard, readBoolFromKeyboard, readCharFromKeyboard, readCharFromKeyboard, readDoubleFromKeyboard, readDoubleFromKeyboard, readFloatFromKeyboard, readFloatFromKeyboard, readFromKeyboard, readFromKeyboard, readFromKeyboard, readFromKeyboard, readHexFromKeyboard, readHexFromKeyboard, readIntFromKeyboard, readIntFromKeyboard, readIntFromKeyboard, readLongFromKeyboard, readLongFromKeyboard, readLongFromKeyboard, readOctalFromKeyboard, readOctalFromKeyboard, setCancelable, wasCanceled
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

KeyboardUtilsDefImpl

public KeyboardUtilsDefImpl()
Method Detail

addErrTag

protected java.lang.String addErrTag(java.lang.String msg)
Description copied from class: KeyboardUtils
Adds the error tag to a string. Override this method in your implementations of this class to specify how the user message combines with the input prompt.

Specified by:
addErrTag in class KeyboardUtils
Parameters:
msg - the message that should be combined with the error tag character sequence.
Returns:
the string containing the user message and input prompt ready for display.

addPrompt

protected java.lang.String addPrompt(java.lang.String msg)
Description copied from class: KeyboardUtils
Adds the input prompt to a string. Override this method in your implementations of KeyboardUtils to specify how the error tag combines with the error message.

Specified by:
addPrompt in class KeyboardUtils
Parameters:
msg - the message that should be combined with the input prompt character sequence.
Returns:
the string containing the error message and error tag ready for display.

shouldCancel

protected boolean shouldCancel(java.lang.String txt)
Description copied from class: KeyboardUtils
Checks whether a cancel sequence was typed. Override this method in your implementations of KeyboardUtils to specify whether the string typed by the user is a request to cancel current input. This method will not be invoked by the framework if the instance if not cancelable and canceling will not be possible.

Specified by:
shouldCancel in class KeyboardUtils
Parameters:
txt - the message that the user type on the keyboard.
Returns:
true if the string means the user intends to cancel input,
false if the string is not a request to cancel and should be validated and possibly converted before returning it.
See Also:
KeyboardUtils.isCancelable(), KeyboardUtils.setCancelable(boolean), KeyboardUtils.wasCanceled()


Copyright © 2008 Federico Mestrone. All Rights Reserved.