Package gov.usgs.util
Class StringUtils
- java.lang.Object
-
- gov.usgs.util.StringUtils
-
public class StringUtils extends java.lang.Object
String parsing and utility functions.
-
-
Constructor Summary
Constructors Constructor Description StringUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.String
encodeAsUtf8(java.lang.String value)
static java.lang.Double
getDouble(java.lang.String value)
No Exception Double parsing method.static java.lang.Float
getFloat(java.lang.String value)
No Exception Float parsing method.static java.lang.Integer
getInteger(java.lang.String value)
No Exception Integer parsing method.static java.lang.Long
getLong(java.lang.String value)
No Exception Long parsing method.static java.lang.String
join(java.util.List<java.lang.Object> list, java.lang.String delimiter)
Join objects in a list using the specified delimiter.static java.util.List<java.lang.String>
split(java.lang.String toSplit, java.lang.String delimiter)
Split a string into a list of strings using the specified delimiter.
-
-
-
Method Detail
-
encodeAsUtf8
public static java.lang.String encodeAsUtf8(java.lang.String value) throws java.io.UnsupportedEncodingException
- Parameters:
value
- value to encode- Returns:
- Utf8 encoded string
- Throws:
java.io.UnsupportedEncodingException
- if character encoding is not supported
-
getDouble
public static java.lang.Double getDouble(java.lang.String value)
No Exception Double parsing method.- Parameters:
value
- string to get double from- Returns:
- null on error, otherwise Double value.
-
getFloat
public static java.lang.Float getFloat(java.lang.String value)
No Exception Float parsing method.- Parameters:
value
- string to get float from- Returns:
- null on error, otherwise Float value.
-
getInteger
public static java.lang.Integer getInteger(java.lang.String value)
No Exception Integer parsing method.- Parameters:
value
- string to get integer from- Returns:
- null on error, otherwise Integer value.
-
getLong
public static java.lang.Long getLong(java.lang.String value)
No Exception Long parsing method.- Parameters:
value
- string to get long from- Returns:
- null on error, otherwise Integer value.
-
join
public static java.lang.String join(java.util.List<java.lang.Object> list, java.lang.String delimiter)
Join objects in a list using the specified delimiter. The objects toString method is used to get a string value.- Parameters:
delimiter
- string to insert between list items.list
- items to join.- Returns:
- string containing delimiter delimited list items.
-
split
public static java.util.List<java.lang.String> split(java.lang.String toSplit, java.lang.String delimiter)
Split a string into a list of strings using the specified delimiter. The intrinsic String.split method is used and elements of the returned String array (if any) are added to a list.- Parameters:
toSplit
- string to split.delimiter
- string used to separate items in toSplit- Returns:
- a list containing items.
-
-