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 private
StringUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static void
appendChar(StringBuffer buf, char c)
static String
jQuote(char[] cbuf, int len)
Quotes the firstlen
characters ofcbuf
as Java Language string literal.static String
jQuote(String str)
Quotes string as Java Language string literal.static boolean
parseBoolean(String line)
static double
parseDouble(String string)
This is almost the same as Double.parseDouble(), but it handles a few more versions of infinity.static String
toString(boolean bool)
Returns the string representation of booleans in octave: 1 for true and 0 for false.static <T> String
toString(T obj)
Returns the string representation of the objectobj
which 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) ifstr
isnull
. 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 firstlen
characters ofcbuf
as Java Language string literal. Returns stringnull
ifs
isnull
.- 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 objectobj
which 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
-
-