The Robot Application Programming Interface Delegate Project
RAPID Logo

StrUtil Class Reference

String conversion utilities for base types and arrays of base types. More...

List of all members.

Static Public Member Functions

static boolean toBoolean (String str)
static int toInt (String str)
static short toShort (String str)
static float toFloat (String str)
static double toDouble (String str)
static int[] toIntArray (String str, String delim)
static short[] toShortArray (String str)
static short[] toShortArray (String str, String delim)
static int[] toIntArray (String str)
static float[] toFloatArray (String str, String delim)
static float[] toFloatArray (String str)
static double[] toDoubleArray (String str, String delim)
static double[] toDoubleArray (String str)
static double[] toDoubleArray (List< String > input)
static boolean setField (Object obj, java.lang.reflect.Field field, String str)
 Set a field from a string without knowing what type it is beforehand.
static String arrayToString (Object array)
static String arrayToString (Object array, String sep)
static String arrayToString (Object array, String sep, String beg, String end)
 convert an array/collection/hashtable to a printable string
static String upperFirstChar (String string, boolean lowerTheRest)
 Take a string.
static String lowerFirstChar (String string, boolean lowerTheRest)
 Take a string.
static String toSingleString (List< String > list, String separator)
 Convert a list to a single string separated by the given separator.
static List< String > fromSingleString (String string, String separator)
 Return a List full of strings extracted from the given string separated by the given separator.
static String trimEndQuotes (String string)
 Removes "" from around a string.
static String trimEndCurlies (String string)
 Removes "" from around a string.
static String cleanPath (String path)
static String basename (String filepath)
 removes path elements and everything following the last "." from filepath horribly inefficient, but not used very often
static String stackTrace (Throwable t)
static String getClasspathAsDirectoryName (Class myclass)
 Given a class, get it's package as a directory, eg:
static String insertNewlines (String s, int width)
 Take a string that may be very long and insert newlines at the space closest to the width given.
static int computeNumberOfLines (String s, int width)
static String getExtension (File file)
 Return the extension if any of a file not including the dot.
static int getAscii (char c)
 Get the ascii number for a character.
static char[] getCharFromAscii (int ascii)
 Get a char array by converting the number.

Static Public Attributes

static final String DELIMITERS = ", \t\n\r\f"
 our default delimiter set includes comma in addition to the standard Java whitespace delimiter set
static String SEPARATOR = "/"

Detailed Description

Author:
mallan

Member Function Documentation

static String arrayToString ( Object  array) [static]
static String arrayToString ( Object  array,
String  sep 
) [static]

Here is the call graph for this function:

static String arrayToString ( Object  array,
String  sep,
String  beg,
String  end 
) [static]
Parameters:
array
begstring to begin array (e.g. "[")
endstring to end array (e.g. "]")
sepseparator (e.g. " " or "\t", ", ", etc)
Returns:
stringified array
static String basename ( String  filepath) [static]

Here is the call graph for this function:

static String cleanPath ( String  path) [static]
static int computeNumberOfLines ( String  s,
int  width 
) [static]
static List<String> fromSingleString ( String  string,
String  separator 
) [static]
Parameters:
string
separator
Returns:
static int getAscii ( char  c) [static]
Parameters:
c
Returns:
static char [] getCharFromAscii ( int  ascii) [static]
Parameters:
ascii
Returns:
static String getClasspathAsDirectoryName ( Class  myclass) [static]

gov.nasa.util.StrUtil -> gov/nasa/util

Parameters:
myclass
Returns:
static String getExtension ( File  file) [static]

If there is no extension return the filename if file is null return empty string

Parameters:
file
Returns:
static String insertNewlines ( String  s,
int  width 
) [static]

ie turn the above into something like: Take a string that may be very long and insert newlines at the space closest to the width given.

Parameters:
s
width
Returns:
static String lowerFirstChar ( String  string,
boolean  lowerTheRest 
) [static]

Return a string that has the first character lowercase. eg First becomes first eg FIRST becomes fIRST

Parameters:
string
lowerTheRestie camelCase vs camelcase
Returns:
static boolean setField ( Object  obj,
java.lang.reflect.Field  field,
String  str 
) [static]
Parameters:
objobject owning field
fieldfield to be set (must be base type or array of base type)
strstring value of field to be set
Returns:

Here is the call graph for this function:

static String stackTrace ( Throwable  t) [static]
static boolean toBoolean ( String  str) [static]
static double toDouble ( String  str) [static]
static double [] toDoubleArray ( String  str) [static]
See also:
DELIMITERS

Here is the call graph for this function:

static double [] toDoubleArray ( String  str,
String  delim 
) [static]

Here is the call graph for this function:

static double [] toDoubleArray ( List< String >  input) [static]

Here is the call graph for this function:

static float toFloat ( String  str) [static]
static float [] toFloatArray ( String  str,
String  delim 
) [static]

Here is the call graph for this function:

static float [] toFloatArray ( String  str) [static]
See also:
DELIMITERS

Here is the call graph for this function:

static int toInt ( String  str) [static]
static int [] toIntArray ( String  str) [static]
See also:
DELIMITERS

Here is the call graph for this function:

static int [] toIntArray ( String  str,
String  delim 
) [static]

Here is the call graph for this function:

static short toShort ( String  str) [static]
static short [] toShortArray ( String  str) [static]
See also:
DELIMITERS
static short [] toShortArray ( String  str,
String  delim 
) [static]

Here is the call graph for this function:

static String toSingleString ( List< String >  list,
String  separator 
) [static]
Parameters:
list
separator
Returns:
static String trimEndCurlies ( String  string) [static]

given "henry" returns henry

Parameters:
string
Returns:
static String trimEndQuotes ( String  string) [static]

given "henry" returns henry

Parameters:
string
Returns:
static String upperFirstChar ( String  string,
boolean  lowerTheRest 
) [static]

Return a string that has the first character uppercase. eg first becomes First eg FIRST becomes First

Parameters:
string
lowerTheRestto lowercase the rest of the word, ie Camelcase vs CamelCase
Returns:

Member Data Documentation

final String DELIMITERS = ", \t\n\r\f" [static]
String SEPARATOR = "/" [static]

The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines