hades.utils
Class NameMangler

java.lang.Object
  extended byhades.utils.NameMangler

public class NameMangler
extends java.lang.Object

construct valid names, i.e. without spaces or tabs. Also used to encode/decode Unicode escapes like '?'.


Constructor Summary
NameMangler()
           
 
Method Summary
static java.lang.String decodeUnicodeEscapes(java.lang.String src)
          parse String src and replace all Unicode escapes '' to '?' with the corresponding Unicode characters.
static java.lang.String encodeWithUnicodeEscapes(java.lang.String src)
          take String src and replace non-standard characters with Unicode escapes of the form '' to '?'.
static java.lang.String getBindkey(java.lang.Object sobj, java.lang.String s)
          utility method to parse the input string and convert to a 'bindkey' String for the given SimObject.
static java.lang.String getUnicodeEscape(char c)
           
static java.lang.String getValidName(java.lang.String name)
           
static boolean isAsciiLetterOrDigitOrSomething(char c)
          check whether character c is an ASCII letter (a-z, A-Z), digit (0-9), or '-', '_', ':'.
static void main(java.lang.String[] argv)
          main: encode and decode strings or run a simple selftest
static void selftest()
           
static void usage()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NameMangler

public NameMangler()
Method Detail

getValidName

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

isAsciiLetterOrDigitOrSomething

public static boolean isAsciiLetterOrDigitOrSomething(char c)
check whether character c is an ASCII letter (a-z, A-Z), digit (0-9), or '-', '_', ':'.


getUnicodeEscape

public static java.lang.String getUnicodeEscape(char c)

encodeWithUnicodeEscapes

public static java.lang.String encodeWithUnicodeEscapes(java.lang.String src)
take String src and replace non-standard characters with Unicode escapes of the form '' to '?'.

#see isAsciiLetterOrDigitOrSomething for the conversion rules


decodeUnicodeEscapes

public static java.lang.String decodeUnicodeEscapes(java.lang.String src)
parse String src and replace all Unicode escapes '' to '?' with the corresponding Unicode characters. Other characters are passed through unmodified.

This method may fail on strings that are not Unicode escaped, e.g. Strings which contain a backslash as their last character.


getBindkey

public static java.lang.String getBindkey(java.lang.Object sobj,
                                          java.lang.String s)
utility method to parse the input string and convert to a 'bindkey' String for the given SimObject. The bindkey result String is simply the first character of the input String, if this is in the range '0'..'9' or 'a'..'z'. Only lowercase chars are accepted, because the 'A'..'Z' values are used to trigger the alternative keyPressed() action on the target SimObject. For null, zero-length, or invalid input Strings, we print an error message and return null (which disables the bindkey on the given component).


usage

public static void usage()

main

public static void main(java.lang.String[] argv)
main: encode and decode strings or run a simple selftest


selftest

public static void selftest()