Class Util

java.lang.Object
edu.tufts.hrilab.util.Util

public class Util extends Object
  • 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 longitude
      y1 - starting latitude
      x2 - ending longitude
      y2 - 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

      public static int calcParenBalance(String str, int bal)
    • calcBracketBalance

      public static int calcBracketBalance(String str, int bal)
    • calcQuoteBalance

      public static int calcQuoteBalance(String str, int bal)
    • tokenizeArgs

      public static List<String> tokenizeArgs(String s, char delim)
      Brad: trying out this implementation vs previous one to see what happens
      Parameters:
      s - string to be tokenized
      delim - delimiter
      Returns:
      tokens
    • tokenizeArgsHelper

      public static List<String> tokenizeArgsHelper(String s, List<String> results, int parenDepth, int singleQuoteDepth, int bracketDepth, int doubleQuotesOpen, boolean first)
    • tokenizeArgs

      public static List<String> tokenizeArgs(String s)
      Overloaded version of tokenizeArgs, using default ',' delimiter
      Parameters:
      s - string to be tokenized
      Returns:
      tokens
    • isNumeric

      public static boolean isNumeric(Object value)
      Checks if value's toString is an integer, long, float, or double.
      Parameters:
      value -
      Returns:
    • numbersTextToDigits

      public static String numbersTextToDigits(String in)
      Converts text numbers into digits.
    • checkNextArg

      public static boolean checkNextArg(String[] args, int i)
      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

      public static String join(Iterable<? extends Object> objectCollection, String separator)
      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

      public static boolean containsIgnoreCase(Collection<String> searchIn, String searchFor)
      searches through a collection (ArrayList, HashSet, etc) and determines if the collection contains a particular searchFor string, IGNORING case.
    • getIgnoreCase

      public static <T> T getIgnoreCase(Set<Map.Entry<String,T>> entrySet, String searchForKey)
      searches through a Map<String, Object> (can be a hashmap, treemap, etc) and returns the value associated with the key, IGNORING case. If not key matched, returns null.