Package org.ringojs.util
Class StringUtils
- java.lang.Object
-
- org.ringojs.util.StringUtils
-
public class StringUtils extends java.lang.Object
Utility class for String manipulation.
-
-
Constructor Summary
Constructors Constructor Description StringUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.String
escapeHtml(java.lang.String str)
Escape the string to make it safe for use within an HTML document.static boolean
isZipOrJarFile(java.lang.String str)
Check whether the argument has a .zip or .jar file extensionstatic java.lang.String
join(java.lang.String[] strings, java.lang.String separator)
static int
searchNewline(java.nio.CharBuffer buffer, int from)
Scan for a newline sequence in the given CharBuffer, starting at position from until buffer.position().static java.lang.String[]
split(java.lang.String str)
Split a string into an array of strings.static java.lang.String[]
split(java.lang.String str, java.lang.String delim)
Split a string into an array of strings.static java.lang.String[]
splitLines(java.lang.String str)
Break a string into a string array, using line breaks as delimiters.static java.lang.Class[]
toClassArray(java.lang.String str, java.lang.String delim)
Split a string and try to convert to an array of classes.
-
-
-
Method Detail
-
split
public static java.lang.String[] split(java.lang.String str)
Split a string into an array of strings. Use comma and space as delimiters.- Parameters:
str
- the string to split- Returns:
- the string split into a string array
-
split
public static java.lang.String[] split(java.lang.String str, java.lang.String delim)
Split a string into an array of strings.- Parameters:
str
- the string to splitdelim
- the delimiter to split the string at- Returns:
- the string split into a string array
-
splitLines
public static java.lang.String[] splitLines(java.lang.String str)
Break a string into a string array, using line breaks as delimiters. This supports Unix, Mac and Windows style line breaks.- Parameters:
str
- the string to split- Returns:
- the string split at line breaks
-
join
public static java.lang.String join(java.lang.String[] strings, java.lang.String separator)
-
escapeHtml
public static java.lang.String escapeHtml(java.lang.String str)
Escape the string to make it safe for use within an HTML document.- Parameters:
str
- the string to escape- Returns:
- the escaped string
-
toClassArray
public static java.lang.Class[] toClassArray(java.lang.String str, java.lang.String delim) throws java.lang.ClassNotFoundException
Split a string and try to convert to an array of classes.- Parameters:
str
- a string containint class namesdelim
- the delimiter- Returns:
- an array of classes
- Throws:
java.lang.ClassNotFoundException
- if any class name contained in the string couldn't be resolved
-
isZipOrJarFile
public static boolean isZipOrJarFile(java.lang.String str)
Check whether the argument has a .zip or .jar file extension- Parameters:
str
- a file name- Returns:
- true if str ends with .zip or .jar
-
searchNewline
public static int searchNewline(java.nio.CharBuffer buffer, int from)
Scan for a newline sequence in the given CharBuffer, starting at position from until buffer.position(). A newline sequence is one of "r\n", "\r", or "\n". Returns the index of the first newline sequence, or -1 if none was found.- Parameters:
buffer
- the character bufferfrom
- the position to start searching- Returns:
- the index of first newline sequence found, or -1
-
-