org.starhope.util
Class LibMisc

java.lang.Object
  extended by org.starhope.util.LibMisc

public class LibMisc
extends Object

Miscellaneous utility methods that might be useful elsewhere

Author:
brpocock@star-hope.org

Field Summary
private static String[] cardinalNumberWords_English
          Word-forms of English cardinal numbers
private static HashMap<Class<?>,Class<?>> extensionClasses
          An extension class can be registered to supplement or replace methods in the basic built-in command interpreters.
(package private) static int MAX_SHUTDOWN_TRIES
          Maximum number of times to clear the socket input buffer.
private static Map<String,Properties> messages
          The currently-loaded message catalogs
 
Constructor Summary
LibMisc()
           
 
Method Summary
static boolean areWeThereYet(AbstractUser thing, long when)
          determine whether an user has (or will have, or had) reached his/her destination location at the time given.
private static String cardinalNumber_English(int number)
          Get the English string form of a cardinal number
static void closeAll(Object... things)
          Close a bunch of things carefully, ignoring exceptions.
static void commandJSON(String cmd, org.json.JSONObject jso, CanProcessCommands commandThread, AbstractUser user, Class<?> klass)
           Execute a command with a certain method signature from klass, passing it the JSON parameters as well as the environment (thread, zone, and user) to run with.
static
<T> Collection<T>
condense(Collection<Collection<T>> sets)
          Condense a collection of collections down to just a collection.
static double distance(AbstractUser from, AbstractUser to, long when)
          Get the actual, current distance between the pivot points of two users at the given time.
static double distance(double x1, double y1, double x2, double y2)
          Get the simple Pythagorean distance between two 2D coördinates.
static void executeCommand(String cmd, org.json.JSONObject jso, CanProcessCommands commandThread, AbstractUser user, Method commandProcessor)
           Execute a JSON command from a class provided with specific methods, discovered using reflection.
private static String formatFutureDate_English(Date targetDate)
           
static String formatFutureDate(Date targetDate)
          Format a date in a natural-language way that is to occur in the future.
static String formatFutureDate(Date targetDate, String language_dialect)
          Format a future date in the given language.
static String formatFutureDate(Date targetDate, String language, String dialect)
          WRITEME: document this method (brpocock@star-hope.org, Jan 18, 2010)
static String formatMemory(long numBytes)
          Create an user-visible string using metric figures accurate to 1 decimal place, expressing an amount of memory in KiB, MiB, &c.
private static String formatPastDate_English(Date targetDate)
           
static String formatPastDate(Date pastDate)
          See formatFutureDate(Date, String, String); applies the currently-selected default language of the thread context
static String formatPastDate(Date targetDate, String language, String dialect)
          WRITEME: document this method (brpocock@star-hope.org, Jan 18, 2010)
static String genFakeIP(Object o)
          Generate something that resembles an IP address, but is clearly not a valid host address.
static String getText(String string)
           
static String getText(String string, String language_dialect)
          WRITEME brpocock@star-hope.org Jul 21, 2010
static String getText(String string, String language, String dialect)
           
static String getTextOrDefault(String key, String fallback)
          Look for a string key in the message catalogue.
static String getTextOrDefault(String key, String language, String dialect, String fallback)
          Get a text message item from the catalogue, or use a supplied default if none is found.
static boolean hasText(String key)
          Determine whether the local default language message catalogue contains a message.
static boolean hasText(String key, String language, String dialect)
          Determine whether a translation for a given message key exists in the catalogue for a certain language/dialect.
static String hexify(byte[] input)
          Convert an array of bytes into a string of ASCII hexadecimal nybbles.
private static void initMessages()
           Initialise the configured message catalogues.
static double limit(double value, double min, double max)
          Limit a value to being between the minimum and maximum allowed
private static String listToDisplay_English(List<String> words)
          Internal helper method for listToDisplay(List, String, String) for English.
private static String listToDisplay_Español(List<String> words)
          Internal helper method for listToDisplay(List, String, String) for Spanish.
private static String listToDisplay_فرسئ(List<String> words)
          Internal helper method for listToDisplay(List, String, String) for Persian.
static String listToDisplay(Collection<? extends Object> words, String language, String dialect)
          Convert a list of items into an appropriately-worded phrase in the specified language.
static String listToDisplay(List<String> words, String language, String dialect)
           Given a list of strings, combine then into a string for display purposes.
static String listToDisplay(Object[] set, String language, String dialect)
           
static Class<?> loadExtension(Class<?> klass)
          Find a substitute class for a command interpreter class with local extensions.
static int makeHashCode(String string)
          Generate a hashcode using the SHA-1 algorithm.
static
<K,V> LinkedHashMap<K,V>
randomize(Map<K,V> map)
          Shuffle the contents of a map into an ordered map with pseudorandom key ordering.
static String rot13(String msg)
          Perform rot-13 on basic alphabetic characters in the font
static
<K,V> Map<K,V>
scramble(Map<K,V> stuffToRandomize)
           Given the contents of a map (presumably, of some kind of ordered map), perform a fairly sketchy randomization upon it which should be “good enough” for casual (e.g.
(package private) static void sendJSONCommandBugReport(String cmd, org.json.JSONObject jso, CanProcessCommands commandThread, AbstractUser user, Exception e)
          Send a bug report on something that occurred while attempting to process a JSON-based command
static void setMaxShutdownTries(int mst)
          Set the maximum number of times to clear the socket input buffer.
static void shutdownInput(Socket socket)
          Deprecated. just use Socket.shutdownInput() now
static
<K extends Comparable<? super K>,V extends Comparable<? super V>>
LinkedHashMap<K,V>
sortHashMapByValues(Map<K,V> stuffToSort)
          Sort the contents of a hash map based upon comparing the values of its keys.
private static void stringify_column(ResultSet rs, StringBuilder s, ResultSetMetaData meta, int i)
          convert an SQL column from a result set into a String
private static void stringify_form(ResultSet rs, StringBuilder s, ResultSetMetaData meta, int numCols)
          stringify output formatting from an SQL result set into a key:value format; the column values will be interpreted by stringify_column(ResultSet, StringBuilder, ResultSetMetaData, int)
private static void stringify_tabular(ResultSet rs, StringBuilder s, ResultSetMetaData meta, int numCols)
          stringify SQL data in tabular format, in traditional Unix tab-delimited columns, newline-delimited records, format.
static String stringify(Map<? extends Object,? extends Object> map)
          Convert a map into a string, mostly for debugging purposes.
static String stringify(Object... crap)
           
static String stringify(ResultSet rs)
          Dump an SQL ResultSet as a string table
static String stringify(StackTraceElement[] stackTrace)
          Create a pure string version of a stack backtrace
static String stringify(Throwable e)
           
static String stringJoin(String[] array, String delimiter)
          Joins an array of strings together using the given delimiter
static long timeToTarget(AbstractUser thing, long when)
          Deprecated. use Geometry.updateUserPositioning(AbstractUser, long, boolean)
static String toJavaCase(String source)
          convert a user-visible string into a javaCased moniker; takes out all non-alpha chars and uses them as upper-case indicators
static String trimWhiteSpace(String string)
           Replace all series of one or more whitespace characters (including carriage returns, newlines, and horizontal or vertical tabulations) with a single space, and trims off the leading and trailing whitespace.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cardinalNumberWords_English

private static final String[] cardinalNumberWords_English
Word-forms of English cardinal numbers


extensionClasses

private static final HashMap<Class<?>,Class<?>> extensionClasses
An extension class can be registered to supplement or replace methods in the basic built-in command interpreters. This is where they're stored.


MAX_SHUTDOWN_TRIES

static int MAX_SHUTDOWN_TRIES
Maximum number of times to clear the socket input buffer.


messages

private static Map<String,Properties> messages
The currently-loaded message catalogs

Constructor Detail

LibMisc

public LibMisc()
Method Detail

areWeThereYet

public static boolean areWeThereYet(AbstractUser thing,
                                    long when)
determine whether an user has (or will have, or had) reached his/her destination location at the time given. Uses Geometry.getTimeToTarget(AbstractUser, long)

Parameters:
thing - Who are we?
when - When are we?
Returns:
true if we've arrived on station

cardinalNumber_English

private static String cardinalNumber_English(int number)
Get the English string form of a cardinal number

Parameters:
number - a number
Returns:
a string

closeAll

public static void closeAll(Object... things)
Close a bunch of things carefully, ignoring exceptions. The “things” supported, thus far, are:

This is mostly meant for “finally” clauses.

Parameters:
things - A set of SQL statements, result sets, and database connections

commandJSON

public static void commandJSON(String cmd,
                               org.json.JSONObject jso,
                               CanProcessCommands commandThread,
                               AbstractUser user,
                               Class<?> klass)

Execute a command with a certain method signature from klass, passing it the JSON parameters as well as the environment (thread, zone, and user) to run with.

The class klass is searched for a method with the name "do_COMMAND", which must take a Zone, JSONObject, User, and Integer (as a room number in which the user is standing) as input parameters. If no such method is found, the extension class (if any) defined for klass using loadExtension(Class) will also be searched, before reporting an error back to the command thread.

Parameters:
cmd - The command's string name
jso - JSON parameters to that command
commandThread - The command processor thread
user - The user initiating the command
klass - The command-processor class in which to search for the command

condense

public static <T> Collection<T> condense(Collection<Collection<T>> sets)
Condense a collection of collections down to just a collection.

Type Parameters:
T - whatever type of stuff you want to put into it
Parameters:
sets - a collection of collections
Returns:
just a collection

distance

public static double distance(AbstractUser from,
                              AbstractUser to,
                              long when)
Get the actual, current distance between the pivot points of two users at the given time.

Parameters:
from - one thing
to - another thing
when - when is it
Returns:
the distance between the two objects

distance

public static double distance(double x1,
                              double y1,
                              double x2,
                              double y2)
Get the simple Pythagorean distance between two 2D coördinates. Prefer using Coord2D.distance(Coord2D) for most purposes.

Parameters:
x1 - start x abcessa
y1 - start y ordinate
x2 - end x abcessa
y2 - end y ordinate
Returns:
distance

executeCommand

public static void executeCommand(String cmd,
                                  org.json.JSONObject jso,
                                  CanProcessCommands commandThread,
                                  AbstractUser user,
                                  Method commandProcessor)

Execute a JSON command from a class provided with specific methods, discovered using reflection.

The JSON command name will be converted into a method name by prepending “do_” to the command verb, as a static method, returning void, with a series of parameters of the types: JSONObject, AbstractUser, and Room. The reflective command Method object must be passed in.

The provided JSONObject and AbstractUser will be passed in; if the user is non-null, the contents of RoomListener.getRoom() will be used as the final parameter; otherwise, a null will be provided.

Parameters:
cmd - The command verb
jso - JSON parameter data to be passed in to the command processing method.
commandThread - The command thread who should receive any errors from processing.
user - The user invoking the command (whose security privileges will be used to perform actions under the command's authority, as necessary)
commandProcessor - The method to be used to process the command.

formatFutureDate

public static String formatFutureDate(Date targetDate)
Format a date in a natural-language way that is to occur in the future. For example, such a phrase might be “five minutes from now” or “12 years from now” or similar.

Parameters:
targetDate - a date in the future
Returns:
a human-legible expression describing the time in the future

formatFutureDate

public static String formatFutureDate(Date targetDate,
                                      String language_dialect)
Format a future date in the given language. For example, this routine might yield something like “two years from now”

Parameters:
targetDate - The date to be described
language_dialect - The language code and dialect subcode (e.g. “en_US”) into which the message should be formatted
Returns:
the message describing the date based on today

formatFutureDate

public static String formatFutureDate(Date targetDate,
                                      String language,
                                      String dialect)
WRITEME: document this method (brpocock@star-hope.org, Jan 18, 2010)

Parameters:
targetDate - a date in the future
language - the user's language
dialect - the user's dialect
Returns:
a human-legible expression describing the time in the future

formatFutureDate_English

private static String formatFutureDate_English(Date targetDate)
Parameters:
targetDate - a date in the future
Returns:
a human-legible expression describing the time in the future

formatMemory

public static String formatMemory(long numBytes)
Create an user-visible string using metric figures accurate to 1 decimal place, expressing an amount of memory in KiB, MiB, &c. to one decimal place. For example, “12.1 KiB” or “4.2 GiB”.

Parameters:
numBytes - a number of bytes (size_t)
Returns:
a human-legible string

formatPastDate

public static String formatPastDate(Date pastDate)
See formatFutureDate(Date, String, String); applies the currently-selected default language of the thread context

Parameters:
pastDate - the date to be thus described
Returns:
a string describing the past date in general terms

formatPastDate

public static String formatPastDate(Date targetDate,
                                    String language,
                                    String dialect)
WRITEME: document this method (brpocock@star-hope.org, Jan 18, 2010)

Parameters:
targetDate - a date in the future
language - the user's language
dialect - the user's dialect
Returns:
a human-legible expression describing the time in the future

formatPastDate_English

private static String formatPastDate_English(Date targetDate)
Parameters:
targetDate - a date in the future
Returns:
a human-legible expression describing the time in the future

genFakeIP

public static String genFakeIP(Object o)
Generate something that resembles an IP address, but is clearly not a valid host address. Nonetheless, this address will contain valid byte values. Some byte in the address will be a 255 or the address will begin or end with a zero byte. Since this method uses the object's hash code, it will be consistent for an object.

Parameters:
o - The object for which to generate a fake IP address
Returns:
a string in dotted-quad form

getText

public static String getText(String string)
Parameters:
string - WRITEME
Returns:
WRITEME

getText

public static String getText(String string,
                             String language_dialect)
WRITEME brpocock@star-hope.org Jul 21, 2010

Parameters:
string - WRITEME
language_dialect - WRITEME
Returns:
WRITEME

getText

public static String getText(String string,
                             String language,
                             String dialect)
Parameters:
string - WRITEME
language - WRITEME
dialect - WRITEME
Returns:
WRITEME

getTextOrDefault

public static String getTextOrDefault(String key,
                                      String fallback)
Look for a string key in the message catalogue. If a given key does exist, return that message. If not, fall back to the provided default text.

Parameters:
key - The key name which should exist in the message catalogue.
fallback - The fallback text to be used if that message does not exist.
Returns:
Either the message from the catalogue, or the fallback message if one is unavailable.

getTextOrDefault

public static String getTextOrDefault(String key,
                                      String language,
                                      String dialect,
                                      String fallback)
Get a text message item from the catalogue, or use a supplied default if none is found.

Parameters:
key - The key to locating the correct message text
language - The language of the translation to be used
dialect - The specific dialect to be used
fallback - An expression to be returned if the specified key is not found in the message catalogue
Returns:
The given text in the provided language and dialect; or, failing that, the supplied fallback expression

hasText

public static boolean hasText(String key)
Determine whether the local default language message catalogue contains a message. FIXME: currently hard-coded to en_US.

Parameters:
key - The message text key to be checked
Returns:
True, if a translation of that message exists in the catalogue

hasText

public static boolean hasText(String key,
                              String language,
                              String dialect)
Determine whether a translation for a given message key exists in the catalogue for a certain language/dialect.

Parameters:
key - The message text key
language - The language
dialect - The specific dialect
Returns:
True, if a translation exists

hexify

public static String hexify(byte[] input)
Convert an array of bytes into a string of ASCII hexadecimal nybbles.

Parameters:
input - The bytes to be converted to hex
Returns:
the hex equivalent

initMessages

private static void initMessages()

Initialise the configured message catalogues.

Each message catalogue is loaded based upon the key named org.starhope.messages.LANG_DIALECT, and must be enumerated in the “master” list of org.starhope.messages.

In the absence of either key, the default message language set is simply en_US (US English), and the default message catalogues are /etc/appius/messages/$LANG_DIALECT.properties, e.g. /etc/appius/messages/en_US.properties


limit

public static double limit(double value,
                           double min,
                           double max)
Limit a value to being between the minimum and maximum allowed

Parameters:
value - the value
min - the least permitted value
max - the max permitted value
Returns:
the value, clipped to the range

listToDisplay

public static String listToDisplay(Collection<? extends Object> words,
                                   String language,
                                   String dialect)
Convert a list of items into an appropriately-worded phrase in the specified language. The English equivalent would be, for example: “One, two, three, and four.”

Parameters:
words - The list of words or sub-phrases (Objects with toString methods) to be enumerated
language - The major language
dialect - The specific dialect
Returns:
A natural-language phrase enumerating the list

listToDisplay

public static String listToDisplay(List<String> words,
                                   String language,
                                   String dialect)

Given a list of strings, combine then into a string for display purposes.

For English, the list will obey the traditional grammatical usage of commas: List elements are joined with commas, except that the conjunction (in our case, always “and”) occurs penultimate, and two or three element lists do not use commas.

For Spanish, works essentially the same way.

For other languages, we just join the words with commas and omit the conjunction

Parameters:
words - A list of words.
language - The user's display language
dialect - The user's sublanguage dialect
Returns:
The list formatted into a string.

listToDisplay

public static String listToDisplay(Object[] set,
                                   String language,
                                   String dialect)
Parameters:
set - array of phrases
language - major language
dialect - minor dialect
Returns:
the phrase as described by listToDisplay(Collection, String, String)
See Also:
listToDisplay(Collection, String, String)

listToDisplay_English

private static String listToDisplay_English(List<String> words)
Internal helper method for listToDisplay(List, String, String) for English.

Parameters:
words - word list
Returns:
list formatted for display in English

listToDisplay_Español

private static String listToDisplay_Español(List<String> words)
Internal helper method for listToDisplay(List, String, String) for Spanish.

Parameters:
words - word list
Returns:
list formatted for display in Spanish

listToDisplay_فرسئ

private static String listToDisplay_فرسئ(List<String> words)
Internal helper method for listToDisplay(List, String, String) for Persian.

Parameters:
words - word list
Returns:
list formatted for display in Persian

loadExtension

public static Class<?> loadExtension(Class<?> klass)
Find a substitute class for a command interpreter class with local extensions. These are defined by specifying the canonical class name in the configuration as a parameter to a key of the form "xtn." plus the canonical class name of the main class to which the extension applies.

Parameters:
klass - The class for which an extension might exist
Returns:
An extension class, if one exists; else, the same class as passed-in

makeHashCode

public static int makeHashCode(String string)
Generate a hashcode using the SHA-1 algorithm. This produces a hash integer by taking the input string, generating its SHA-1 hash, and then adding together the output bytes from that algorithm, alternate bytes being bitwise-exclusive-OR:ed with 0xaa, ignoring all overflow.

Parameters:
string - The source string
Returns:
An integral hash value

randomize

public static <K,V> LinkedHashMap<K,V> randomize(Map<K,V> map)
Shuffle the contents of a map into an ordered map with pseudorandom key ordering. Uses Collections.shuffle(List, Random) with a new Random object created using seed values in turn obtained from AppiusConfig.getRandomInt(int, int), which should provide a relatively high entropy source.

Type Parameters:
K - key type
V - value type
Parameters:
map - the map to shuffle
Returns:
Map with key ordering shuffled as an ordered LinkedHashMap

rot13

public static String rot13(String msg)
Perform rot-13 on basic alphabetic characters in the font

Parameters:
msg - The string to be rot-13:ed
Returns:
The string after rot-13

scramble

public static <K,V> Map<K,V> scramble(Map<K,V> stuffToRandomize)

Given the contents of a map (presumably, of some kind of ordered map), perform a fairly sketchy randomization upon it which should be “good enough” for casual (e.g. non-security-related) purposes.

Type Parameters:
K - key type of the input and output maps
V - value type of the input and output maps
Parameters:
stuffToRandomize - the data to be scrambled
Returns:
the scrambled data

sendJSONCommandBugReport

static void sendJSONCommandBugReport(String cmd,
                                     org.json.JSONObject jso,
                                     CanProcessCommands commandThread,
                                     AbstractUser user,
                                     Exception e)
Send a bug report on something that occurred while attempting to process a JSON-based command

Parameters:
cmd - a JSON command verb
jso - JSON data describing the bug
commandThread - the thread executing the command (which might not be the current thread)
user - the user responsible for executing the command
e - an exception thrown while processing the ocmmand

setMaxShutdownTries

public static void setMaxShutdownTries(int mst)
Set the maximum number of times to clear the socket input buffer.

Parameters:
mst - maximum number of tries to shut down a socket input buffer

shutdownInput

@Deprecated
public static void shutdownInput(Socket socket)
                          throws IOException
Deprecated. just use Socket.shutdownInput() now

This method taken from Apache Tomcat:

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Shut down the input stream of a connection

Parameters:
socket - The socket whose input stream is to be shut down
Throws:
IOException - If the input stream cannot be shut down despite best efforts

sortHashMapByValues

public static <K extends Comparable<? super K>,V extends Comparable<? super V>> LinkedHashMap<K,V> sortHashMapByValues(Map<K,V> stuffToSort)
Sort the contents of a hash map based upon comparing the values of its keys. This implementation operates on any types providing Comparable.

Type Parameters:
K - key type
V - value type
Parameters:
stuffToSort - The hash table to be sorted
Returns:
the stuff all sorted

stringify

public static String stringify(Map<? extends Object,? extends Object> map)
Convert a map into a string, mostly for debugging purposes.

Parameters:
map - a map object to be stringified
Returns:
a string containing all keys and values in the map

stringify

public static String stringify(Object... crap)
Parameters:
crap - arbitrary stuff to stringify
Returns:
a somewhat legible stringification of the set

stringify

public static String stringify(ResultSet rs)
Dump an SQL ResultSet as a string table

Parameters:
rs - result set to dump
Returns:
tabular form

stringify

public static String stringify(StackTraceElement[] stackTrace)
Create a pure string version of a stack backtrace

Parameters:
stackTrace - An array of StackTraceElements:s
Returns:
A string version of the entire stack backtrace

stringify

public static String stringify(Throwable e)
Parameters:
e - A Throwable to be stringified into a backtrace
Returns:
The string form

stringify_column

private static void stringify_column(ResultSet rs,
                                     StringBuilder s,
                                     ResultSetMetaData meta,
                                     int i)
                              throws SQLException
convert an SQL column from a result set into a String

Parameters:
rs - the result set from an SQL query
s - a StringBuilder into which the stringified column value will be appended
meta - metadata describing the result set
i - the integral column number
Throws:
SQLException - if the result set can't be interpreted for some reason

stringify_form

private static void stringify_form(ResultSet rs,
                                   StringBuilder s,
                                   ResultSetMetaData meta,
                                   int numCols)
                            throws SQLException
stringify output formatting from an SQL result set into a key:value format; the column values will be interpreted by stringify_column(ResultSet, StringBuilder, ResultSetMetaData, int)

Parameters:
rs - an SQL result set
s - a StringBuilder into which the output will be appended
meta - the metadata describing the result set
numCols - the number of columns to be written out
Throws:
SQLException - if the data cannot be formatted

stringify_tabular

private static void stringify_tabular(ResultSet rs,
                                      StringBuilder s,
                                      ResultSetMetaData meta,
                                      int numCols)
                               throws SQLException
stringify SQL data in tabular format, in traditional Unix tab-delimited columns, newline-delimited records, format.

Parameters:
rs - result set from an SQL query
s - a StringBuilder into which the formatted output will be appended
meta - metadata describing the result set
numCols - the number of columns to be written out
Throws:
SQLException - if the data can't be interpreted

stringJoin

public static String stringJoin(String[] array,
                                String delimiter)
Joins an array of strings together using the given delimiter

Parameters:
array - The array of strings
delimiter - The string to append between the other strings
Returns:
A new string with the strings all appended together

timeToTarget

@Deprecated
public static long timeToTarget(AbstractUser thing,
                                           long when)
Deprecated. use Geometry.updateUserPositioning(AbstractUser, long, boolean)

Determine the object's current position, and the time until it reaches its target (from now). Note that this was the preferred routine to be used to update the position of an object. Now, use #updateUserPositioning(AbstractUser,long)

When called through this interface, always executes side-effects

Identical to Geometry.updateUserPositioning(AbstractUser, long, boolean) with the last parameter as “true.”

Parameters:
thing - what is moving
when - what time is it now
Returns:
how long until it gets there
See Also:
Geometry.getTimeToTarget(AbstractUser, long), Geometry.updateUserPositioning(AbstractUser), Geometry.updateUserPositioning(AbstractUser, long), Geometry.updateUserPositioning(AbstractUser, long, boolean)

toJavaCase

public static String toJavaCase(String source)
convert a user-visible string into a javaCased moniker; takes out all non-alpha chars and uses them as upper-case indicators

Parameters:
source - the string provided
Returns:
the string converted into javaCased (CamelCase with initial miniscule letter)

trimWhiteSpace

public static String trimWhiteSpace(String string)

Replace all series of one or more whitespace characters (including carriage returns, newlines, and horizontal or vertical tabulations) with a single space, and trims off the leading and trailing whitespace.

Note that this performs more or less the same whitespace compression as is typically defined behaviour for HTML display.

Parameters:
string - A string to be trimmed.
Returns:
the trimmed string