|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectlumis.util.TextUtil
@StableMinor(version="6.1", sinceVersion="4.0") public class TextUtil
Utility methods for text-related operations.
Constructor Summary | |
---|---|
TextUtil()
|
Method Summary | |
---|---|
static void |
copyFile(java.lang.String sourceFile,
java.lang.String targetFile)
|
static java.lang.String |
escapeJs(java.lang.String javascriptString)
Escapes a javascript string so it can added to inside quotes without breaking the javascript code. |
static java.lang.String |
escapeLocalizationParameter(java.lang.String str)
Escapes a localization parameter string. |
static java.lang.String |
escapeRegexpReplacement(java.lang.String replacementString)
Escapes regexp replacement commands in a string for use as replacement. |
static java.io.FileWriter |
getFileWriter(java.lang.String filename,
boolean append)
Deprecated. Since 4.0.9 because this method uses the system default charset encoding. |
static int |
indexOfCaseInsensitive(java.lang.StringBuilder source,
java.lang.String findStr)
|
static int |
indexOfCaseInsensitive(java.lang.StringBuilder source,
java.lang.String findStr,
int fromIndex)
|
static java.lang.String |
joinStringArray(java.lang.String[] array,
java.lang.String delim)
|
static java.lang.StringBuffer |
joinStringArray(java.lang.String[] array,
java.lang.String delim,
java.lang.StringBuffer sb)
|
static java.lang.String |
joinStringCollection(java.util.Collection<java.lang.String> strings,
java.lang.String delim)
Generates a string joining the strings in the collection with the delimiter specified between them. |
static java.lang.String |
joinStringCollectionUserFriendly(java.util.List<java.lang.String> listItems)
Build a list, separating terms with the locale-defined separator. |
static java.lang.String |
leftPad(java.lang.String s,
int minimumLength,
char fillingChar)
|
static java.lang.String |
read(java.io.InputStream in,
java.lang.String encoding)
Reads an input stream as a string using the given encoding. |
static java.lang.String |
read(java.io.Reader reader)
Reads the data from the reader until its end is reached. |
static java.lang.String |
read(java.net.URL url,
java.lang.String encoding)
Reads the InputStream provided by the given
URL as a string. |
static java.lang.String |
readFile(java.lang.String filename)
Deprecated. This method uses the system default encoding, which if diferent from the file's encoding may cause data corruption. Instead of using this method use readFile(String, String) specifying the correct
encoding. |
static java.lang.String |
readFile(java.lang.String filename,
java.lang.String encoding)
|
static java.lang.String |
stringRepeat(char ch,
int count)
Generate a string repeating the 'ch' character 'count' times. |
static java.lang.String |
stringReplace(java.lang.String str,
java.lang.String target,
java.lang.String replacement)
|
static java.lang.String |
stringReplace(java.lang.String str,
java.lang.String target,
java.lang.String replacement,
boolean replaceOnlyFirstOccurrence)
|
static void |
writeFile(java.lang.String filename,
java.lang.String content,
boolean append)
Deprecated. Since 4.0.8, use writeFile(String, String, String, boolean)
because this method uses the system default charset encoding. |
static void |
writeFile(java.lang.String filename,
java.lang.String content,
java.lang.String charset,
boolean append)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public TextUtil()
Method Detail |
---|
public static java.lang.String stringReplace(java.lang.String str, java.lang.String target, java.lang.String replacement)
str
- is the original String which may contain substring target.target
- is the substring which is to be replaced.replacement
- is the replacement for target.public static java.lang.String stringReplace(java.lang.String str, java.lang.String target, java.lang.String replacement, boolean replaceOnlyFirstOccurrence)
public static java.lang.String escapeRegexpReplacement(java.lang.String replacementString)
replacementString
- the replacement string.
public static java.lang.String escapeJs(java.lang.String javascriptString)
Single quotes, double quotes, '\', next line and line feed characters are escaped.
javascriptString
- the javacript string raw value.
public static java.lang.String escapeLocalizationParameter(java.lang.String str)
str
- the string to escape.
public static java.lang.String joinStringCollection(java.util.Collection<java.lang.String> strings, java.lang.String delim)
strings
- the collectino with the strings.delim
- the delimiter.
public static java.lang.String joinStringArray(java.lang.String[] array, java.lang.String delim)
public static java.lang.StringBuffer joinStringArray(java.lang.String[] array, java.lang.String delim, java.lang.StringBuffer sb)
@Deprecated public static java.lang.String readFile(java.lang.String filename) throws java.io.FileNotFoundException, java.io.IOException
readFile(String, String)
specifying the correct
encoding.
filename
- the filename.
java.io.FileNotFoundException
java.io.IOException
public static java.lang.String readFile(java.lang.String filename, java.lang.String encoding) throws java.io.FileNotFoundException, java.io.IOException
java.io.FileNotFoundException
java.io.IOException
public static java.lang.String read(java.net.URL url, java.lang.String encoding) throws java.io.IOException
InputStream
provided by the given
URL
as a string.
url
- the URL.encoding
- the encoding to use for reading.
java.io.IOException
- if an I/O exception occurs.URL.openStream()
,
read(InputStream, String)
public static java.lang.String read(java.io.InputStream in, java.lang.String encoding) throws java.io.IOException
in
- the input stream.encoding
- the encoding.
java.io.IOException
- if an I/O exception occurs.public static java.lang.String read(java.io.Reader reader) throws java.io.IOException
reader
- the reader.
java.io.IOException
- if an I/O error occurs.@Deprecated public static void writeFile(java.lang.String filename, java.lang.String content, boolean append) throws java.io.IOException
writeFile(String, String, String, boolean)
because this method uses the system default charset encoding.
java.io.IOException
public static void writeFile(java.lang.String filename, java.lang.String content, java.lang.String charset, boolean append) throws java.io.IOException, PortalException
java.io.IOException
PortalException
public static void copyFile(java.lang.String sourceFile, java.lang.String targetFile) throws java.io.IOException
java.io.IOException
@Deprecated public static java.io.FileWriter getFileWriter(java.lang.String filename, boolean append) throws java.io.IOException
java.io.IOException
public static int indexOfCaseInsensitive(java.lang.StringBuilder source, java.lang.String findStr)
public static int indexOfCaseInsensitive(java.lang.StringBuilder source, java.lang.String findStr, int fromIndex)
public static java.lang.String leftPad(java.lang.String s, int minimumLength, char fillingChar)
public static java.lang.String stringRepeat(char ch, int count)
ch
- The character to be repeatedcount
- The number of repetitions
public static java.lang.String joinStringCollectionUserFriendly(java.util.List<java.lang.String> listItems) throws PortalException
listItems
-
PortalException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |