Package edu.tufts.hrilab.util
Class Util
java.lang.Object
edu.tufts.hrilab.util.Util
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic intcalcBracketBalance(String str, int bal) static intcalcParenBalance(String str, int bal) static intcalcQuoteBalance(String str, int bal) static booleancheckNextArg(String[] args, int i) Check whether next arg is another parameter (i.e., starts with '-').static booleancontainsIgnoreCase(Collection<String> searchIn, String searchFor) searches through a collection (ArrayList, HashSet, etc) and determines if the collection contains a particular searchFor string, IGNORING case.static doublegetDistanceFrom(double x1, double y1, double x2, double y2) static doublegetHeadingFrom(double x1, double y1, double x2, double y2) static doublegetHeadingFromRel(double x1, double y1, double x2, double y2, double h) static <T> TgetIgnoreCase(Set<Map.Entry<String, T>> entrySet, String searchForKey) searches through aMap<String, Object>(can be a hashmap, treemap, etc) and returns the value associated with the key, IGNORING case.static booleanChecks if value's toString is an integer, long, float, or double.static Stringmethod for joining objects (more properly, their .toString()) with a specific deliminator to produce a string of the form "a, b, c".static doublelldist(double x1, double y1, double x2, double y2) Longitude-latitude distance.static StringConverts text numbers into digits.static intsignedInt(byte b1, byte b2) static voidSleep(long millis) Sleep.Overloaded version of tokenizeArgs, using default ',' delimitertokenizeArgs(String s, char delim) Brad: trying out this implementation vs previous one to see what happenstokenizeArgsHelper(String s, List<String> results, int parenDepth, int singleQuoteDepth, int bracketDepth, int doubleQuotesOpen, boolean first) static intunsignedInt(byte b1, byte b2) static intunsignedInt(byte b1, byte b2, byte b3) static longunsignedInt(byte b1, byte b2, byte b3, byte b4)
-
Constructor Details
-
Util
public Util()
-
-
Method Details
-
getHeadingFrom
public static double getHeadingFrom(double x1, double y1, double x2, double y2) -
getHeadingFromRel
public static double getHeadingFromRel(double x1, double y1, double x2, double y2, double h) -
getDistanceFrom
public static double getDistanceFrom(double x1, double y1, double x2, double y2) -
lldist
public static double lldist(double x1, double y1, double x2, double y2) Longitude-latitude distance. This is needed for pos servers that return the pose in longitude-latitude form instead of x,y meters (e.g., Cart). See http://en.wikipedia.org/wiki/Great-circle_distance.- Parameters:
x1- starting longitudey1- starting latitudex2- ending longitudey2- ending latitude- Returns:
- distance between the two locations
-
Sleep
public static void Sleep(long millis) Sleep. This is a convenience method to obviate the need to catch the InterruptedException any time you want to sleep.- Parameters:
millis- the sleep duration
-
calcParenBalance
-
calcBracketBalance
-
calcQuoteBalance
-
tokenizeArgs
Brad: trying out this implementation vs previous one to see what happens- Parameters:
s- string to be tokenizeddelim- delimiter- Returns:
- tokens
-
tokenizeArgsHelper
-
tokenizeArgs
Overloaded version of tokenizeArgs, using default ',' delimiter- Parameters:
s- string to be tokenized- Returns:
- tokens
-
isNumeric
Checks if value's toString is an integer, long, float, or double.- Parameters:
value-- Returns:
-
numbersTextToDigits
Converts text numbers into digits. -
checkNextArg
Check whether next arg is another parameter (i.e., starts with '-').- Returns:
- true if it's a parameter
-
signedInt
public static int signedInt(byte b1, byte b2) -
unsignedInt
public static int unsignedInt(byte b1, byte b2) -
unsignedInt
public static int unsignedInt(byte b1, byte b2, byte b3) -
unsignedInt
public static long unsignedInt(byte b1, byte b2, byte b3, byte b4) -
join
method for joining objects (more properly, their .toString()) with a specific deliminator to produce a string of the form "a, b, c". based on http://snippets.dzone.com/posts/show/91 -
containsIgnoreCase
searches through a collection (ArrayList, HashSet, etc) and determines if the collection contains a particular searchFor string, IGNORING case. -
getIgnoreCase
searches through aMap<String, Object>(can be a hashmap, treemap, etc) and returns the value associated with the key, IGNORING case. If not key matched, returns null.
-