|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object dk.netarkivet.common.utils.StringUtils
public class StringUtils
Utilities for working with strings.
Method Summary | ||
---|---|---|
static
|
conjoin(java.lang.String sep,
java.util.Collection<T> objects)
Concatenate all objects in a collection with the given separator between each. |
|
static
|
conjoin(java.lang.String separator,
java.util.Collection<T> objects,
int max)
Concatenate the string representation of a maximum number of objects in a collection with a given separator between them. |
|
static java.lang.String |
conjoin(java.lang.String sep,
java.lang.String... strings)
Concatenate all strings in a collection with the given separator between each. |
|
static java.lang.String |
formatDate(long millis)
Formats the given date (as elapsed milliseconds) using the default format 'yyyy/MM/dd HH:mm:ss'. |
|
static java.lang.String |
formatDate(long millis,
java.lang.String format)
Formats the given date (as elapsed milliseconds) using the provided format pattern. |
|
static java.lang.String |
formatDuration(long seconds)
Formats a duration in seconds as a string of the form "3d 04:12:56". |
|
static java.lang.String |
formatNumber(double number)
Formats a number, as a decimal number with at most 2 digits. |
|
static java.lang.String |
formatNumber(long number)
Formats a number, as a decimal number with at most 2 digits. |
|
static java.lang.String |
formatPercentage(double percentage)
Formats a numeric percentage, as a decimal number with at most 2 digits. |
|
static java.lang.String |
formatPercentage(long percentage)
Formats a numeric percentage, as a decimal number with at most 2 digits. |
|
static java.lang.String |
makeEllipsis(java.lang.String orgString,
int maxLength)
Generate a ellipsis of orgString. |
|
static java.util.List<java.lang.Integer> |
parseIntList(java.lang.String[] stringArray)
Change all Strings to Integers. |
|
static java.lang.String |
repeat(java.lang.String s,
int n)
Repeat the string n times. |
|
static java.lang.String |
replace(java.lang.String sentence,
java.lang.String oldString,
java.lang.String newString)
Replace all occurrences of oldString with newString in a string. |
|
static java.lang.String |
surjoin(java.util.List<java.lang.String> strings,
java.lang.String pre,
java.lang.String post)
Concatenate all strings in a collection, with the fixed strings appended and prepended to each. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static final java.lang.String replace(java.lang.String sentence, java.lang.String oldString, java.lang.String newString)
sentence
- the string, where all occurrences of oldString are to be
replaced with newString.oldString
- the oldString.newString
- the newString.
public static final <T> java.lang.String conjoin(java.lang.String sep, java.util.Collection<T> objects)
sep
- A string to separate the list items.objects
- A collection of object to concatenate as a string.
public static final <T> java.lang.String conjoin(java.lang.String separator, java.util.Collection<T> objects, int max) throws ArgumentNotValid
T
- The type of collection.separator
- The string to separate the entries in the collection
with. This is allowed to be the empty string.objects
- The collection to have the string representation of its
entries concatenated.max
- The maximum number of objects in the collection to
concatenate. If this number is 0 or below only the first entry in the
collection is returned.
ArgumentNotValid
- If the separator or the objects are null.public static final java.lang.String conjoin(java.lang.String sep, java.lang.String... strings)
sep
- A string to separate the list items.strings
- An array of strings to concatenate.
public static final java.lang.String surjoin(java.util.List<java.lang.String> strings, java.lang.String pre, java.lang.String post)
strings
- A list of strings to join up.pre
- A string that will be put in front of each string in the list.post
- A string that will be put after each string in the list.
public static final java.lang.String repeat(java.lang.String s, int n)
s
- A string to repeat.n
- How many times to repeat it.
ArgumentNotValid
- if a negative amount is specified.public static java.util.List<java.lang.Integer> parseIntList(java.lang.String[] stringArray)
stringArray
- the given array of Strings to convert.
public static java.lang.String makeEllipsis(java.lang.String orgString, int maxLength)
orgString
- the original string.maxLength
- the maximum length of the string before ellipsing it.
public static java.lang.String formatDuration(long seconds)
seconds
- A duration in seconds
public static final java.lang.String formatPercentage(double percentage)
percentage
- the numeric percentage to format.
public static final java.lang.String formatPercentage(long percentage)
percentage
- the numeric percentage to format.
public static final java.lang.String formatNumber(double number)
number
- the number to format.
public static final java.lang.String formatNumber(long number)
number
- the number to format.
public static final java.lang.String formatDate(long millis)
millis
- the date
public static final java.lang.String formatDate(long millis, java.lang.String format)
millis
- the dateformat
- the format pattern SimpleDateFormat
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |