Package eu.simuline.octave.util
Class StringUtil
- java.lang.Object
-
- eu.simuline.octave.util.StringUtil
-
public final class StringUtil extends Object
Class for holding static utility functions for string handling: quoting and for parsing numbers.- Author:
- Kim Hansen
-
-
Constructor Summary
Constructors Modifier Constructor Description privateStringUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static voidappendChar(StringBuffer buf, char c)static StringjQuote(char[] cbuf, int len)Quotes the firstlencharacters ofcbufas Java Language string literal.static StringjQuote(String str)Quotes string as Java Language string literal.static booleanparseBoolean(String line)static doubleparseDouble(String string)This is almost the same as Double.parseDouble(), but it handles a few more versions of infinity.static StringtoString(boolean bool)Returns the string representation of booleans in octave: 1 for true and 0 for false.static <T> StringtoString(T obj)Returns the string representation of the objectobjwhich is defined also for null returning just "null".
-
-
-
Method Detail
-
appendChar
private static void appendChar(StringBuffer buf, char c)
-
jQuote
public static String jQuote(String str)
Quotes string as Java Language string literal. Returns the string "null" (with length 4) ifstrisnull. Code taken from http://freemarker.sourceforge.net/- Parameters:
str-- Returns:
- the string encoded and quoted
-
jQuote
public static String jQuote(char[] cbuf, int len)
Quotes the firstlencharacters ofcbufas Java Language string literal. Returns stringnullifsisnull.- Parameters:
cbuf- the bufferlen- How much of the buffer to quote- Returns:
- the string encoded and quoted:
Starts and ends with
"
-
parseBoolean
public static boolean parseBoolean(String line)
-
toString
public static String toString(boolean bool)
Returns the string representation of booleans in octave: 1 for true and 0 for false.
-
toString
public static <T> String toString(T obj)
Returns the string representation of the objectobjwhich is defined also for null returning just "null".
-
parseDouble
public static double parseDouble(String string)
This is almost the same as Double.parseDouble(), but it handles a few more versions of infinity.- Parameters:
string-- Returns:
- The parsed Double
-
-