LEONARDI Application Composer - 8.9.0.40 by W4 S.A.

leon.misc
Class LyString

java.lang.Object
  extended by leon.misc.LyString

public class LyString
extends java.lang.Object

This class offers general useful methods to manipulate Strings.


Field Summary
static java.lang.String __VERSION
           
static java.lang.String DEFAULT_CHARSET
          Default charset used to read input streams.
 char EXPORT_COLUMN_SEP
          Delimiter used when exporting data (between columns).
 java.lang.String EXPORT_HEADER_MARK
          First char used when exporting data to identify header line.
 java.lang.String FILE_SEPARATOR
          File separator.
static char[] HEXA_TABLE
          Hexadecimal table (used for hexadecimal conversion).
static java.lang.String HTTP_PROTOCOL
          Default http protocol scheme.
static java.lang.String HTTPS_PROTOCOL
          Default https protocol scheme.
 java.lang.String LINE_SEP
          Line separator.
static char MODIFIER
          Character used to unspecialize delimiter.
static java.lang.String MODIFIER_STRING
          String used to define a temporary delimiter.
 char SEP
          Non displayable separator.
 char VISIBLE_SEP
          Displayable delimiter.
 char VISIBLE_SEP2
          Displayable delimiter.
 java.lang.String VISIBLE_SEP3
          Displayable open delimiter associated to VISIBLE_SEP3_BIS.
 java.lang.String VISIBLE_SEP3_BIS
          Displayable close delimiter associated to VISIBLE_SEP3.
 
Constructor Summary
LyString(LyEnvironment environment)
          Constructor with a given environment.
 
Method Summary
static boolean checkFormat(LyEnvironment environment, java.lang.String format)
          Checks the validity of the given format.
static boolean checkStringFormat(LyEnvironment environment, java.lang.String format)
          Tests if a format is valid.
static void closeInput(java.io.InputStream input)
          Closes the given InputStream.
 java.lang.String compose(java.lang.String text, java.lang.Object param)
          In a string, enables replacement of one pattern (%1).
 java.lang.String compose(java.lang.String text, java.lang.Object[] params)
          In a string, enables replacement of patterns '%n' such as %1,%2, etc.
 java.lang.String compose(java.lang.String text, java.lang.Object param, java.lang.Object param2)
          In a string, enables replacement of two patterns (%1,%2).
 java.lang.String compose(java.lang.String text, java.lang.Object param, java.lang.Object param2, java.lang.Object param3)
          In a string, enables replacement of three patterns (%1,%2,%3).
static java.lang.String decodeValueFromJavascript(java.lang.String value)
          Decode a string to add into a javascript value like
static java.lang.String encodeAmpersand(java.lang.String text)
          Encodes the given string by encoding all ampersand characters. '&' is replaced by "&" except from the following sequences: "&#D;" where D is a decimal number.
static java.lang.String encodeFileURL(java.lang.String url)
          This utility method converts an URL defining the path of a file into a string that may be used in any WEB browser.
static java.lang.String encodeURL(java.lang.String str)
          Translates the given string into application/x-www-form-urlencoded format using a specific encoding scheme.
static java.lang.String encodeValueInJavascript(java.lang.String value)
          encode a string to add into a javascript value like
static java.lang.String encrypt(LyEnvironment environment, java.lang.String str)
          Encryption algorithm using SHA-1 from java.security.
 java.lang.String expand(java.lang.String text)
          Replaces all properties key found in the given String by their value found in the current environment.
 java.lang.String expand(java.lang.String text, java.lang.String defaultStr)
          Replaces all properties key found in the given String by their value found in the current environment.
 java.lang.String expandUrl(java.lang.String text)
          Replaces all properties key found in the given String by their value found in the current environment.
 java.lang.String expandUrl(java.lang.String text, java.lang.String defaultStr)
          Replaces all properties key found in the given String by their value found in the current environment.
static java.lang.String format(java.lang.String text, int step, boolean fill, char fillingChar, boolean replaceCr)
          Format the given String depending on given parameters.
static java.lang.String getCommonPart(java.util.Vector<java.lang.String> values)
          Gets the string that is the common part of all strings of the given list.
static java.lang.String getHtmlEntitiesString(java.lang.String text)
          Encodes the given string as an HTML string.
static java.lang.String getHtmlString(java.lang.String text)
          Encodes the given string as an HTML string.
static java.lang.String getJavascriptString(java.lang.String text)
          Encodes the given string as a javascript string.
static java.lang.String getJavascriptStringVar(java.lang.String text)
          Encodes the given string as a javascript variable string.
static java.lang.String getJsonString(java.lang.String str)
          Encodes the given string as an XML string and delete all surrogate characters.
static java.lang.String getLine(java.io.InputStream input)
          Reads one line from an inputStream (until the end of line is found).
static java.lang.String getLine(java.io.InputStream input, java.lang.String charset)
          Reads one line from an inputStream (until the end of line is found).
static int getMaxLineWidth(java.lang.String text)
          Gets the maximum length of a line in a text.
static int getNbLines(java.lang.String text)
          Gets the number of lines (separated by '\n') in a String.
static java.lang.String getPostscriptString(java.lang.String text)
          Replaces non postscript chars with printable postscript chars in a string.
static java.lang.String getRandomId()
          Creates randomly an identifier as a string (based on java.lang.Math.random() algorithm).
static java.lang.String getSimpleString(java.lang.String str)
          Gets a string without accent from the given string.
static java.lang.String getXmlString(java.lang.String str)
          Encodes the given string as an XML string.
static java.lang.String getXmlString(java.lang.String str, boolean quotes, boolean percent)
          Encodes the given string as an XML string.
static java.lang.String getXmlStringStrict(java.lang.String str)
          Encodes the given string as an XML string and delete all surrogate characters.
static int indexOf(java.lang.StringBuffer buffer, char delimiter, int fromIndex)
          Gets the index within the given string of the StringBuffer of the first occurrence of the specified delimiter that is not precede by the MODIFIER character, starting the search at the specified index.
static java.lang.String listToString(java.lang.String[] list, char separator)
          Concatenate the given tokens list as a String with the specified delimiter.
static java.lang.String listToString(java.lang.String[] list, java.lang.String separator)
          Concatenate the given tokens list as a String with the specified delimiter.
static boolean matchFormat(LyEnvironment environment, java.lang.String format, java.lang.String value)
          Tests if a string matches a regular expression.
static boolean matchStringFormat(LyEnvironment environment, java.lang.String format, java.lang.String value)
          Tests if a string match a simple format.
static java.lang.String replace(java.lang.String text, char[] finds, char[] replaces)
          Replaces all occurrences of the given find token by the given replace token in the given text.
static java.lang.String replace(java.lang.String text, char[] finds, java.lang.String[] replaces)
          Replaces all occurrences of the given find token by the given replace token in the given text.
static java.lang.String replace(java.lang.String text, java.lang.String find, java.lang.String replace)
          Replaces all occurrences of the given find token by the given replace token in the given text.
static java.lang.String replaceCharSet(java.lang.String value, java.lang.String newCharSet)
          Convert the Strings to bytes and analyse this using another charset
static java.lang.String revertToUTF8(java.lang.String s)
          Replace common misread characters to their UTF-8 equivalent
static java.lang.String[] sortStrings(java.lang.String[] strings)
          Sorts an array of strings.
static java.lang.String[] stringToList(java.lang.String text, char delimiter)
          Tokenize a given string into an array of tokens.
static java.lang.String[] stringToList(java.lang.String text, java.lang.String delimiter)
          Tokenize a given string into an array of tokens.
static java.lang.String strip(java.lang.String str, char modifier)
          Strip given string : removes modifier from given string.
static boolean testUTF8String(java.lang.String value)
          Check if the String is not properly encoded and contains likely UTF-8 bytes
static java.lang.String[] tokenizer(java.lang.String str, char delim)
          Decode a String which has multiple tokens separated by a character.
static java.lang.String[] tokenizer(java.lang.String str, java.lang.String delim)
          Decode a String which has multiple tokens separated by a string.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

__VERSION

public static final java.lang.String __VERSION
See Also:
Constant Field Values

HEXA_TABLE

public static final char[] HEXA_TABLE
Hexadecimal table (used for hexadecimal conversion).


MODIFIER

public static char MODIFIER
Character used to unspecialize delimiter.


MODIFIER_STRING

public static java.lang.String MODIFIER_STRING
String used to define a temporary delimiter.


DEFAULT_CHARSET

public static java.lang.String DEFAULT_CHARSET
Default charset used to read input streams.


HTTP_PROTOCOL

public static java.lang.String HTTP_PROTOCOL
Default http protocol scheme.


HTTPS_PROTOCOL

public static java.lang.String HTTPS_PROTOCOL
Default https protocol scheme.


SEP

public char SEP
Non displayable separator.


VISIBLE_SEP

public char VISIBLE_SEP
Displayable delimiter.


VISIBLE_SEP2

public char VISIBLE_SEP2
Displayable delimiter.


VISIBLE_SEP3

public java.lang.String VISIBLE_SEP3
Displayable open delimiter associated to VISIBLE_SEP3_BIS.


VISIBLE_SEP3_BIS

public java.lang.String VISIBLE_SEP3_BIS
Displayable close delimiter associated to VISIBLE_SEP3.


EXPORT_COLUMN_SEP

public char EXPORT_COLUMN_SEP
Delimiter used when exporting data (between columns).


EXPORT_HEADER_MARK

public java.lang.String EXPORT_HEADER_MARK
First char used when exporting data to identify header line.


LINE_SEP

public java.lang.String LINE_SEP
Line separator.


FILE_SEPARATOR

public java.lang.String FILE_SEPARATOR
File separator.

Constructor Detail

LyString

public LyString(LyEnvironment environment)
Constructor with a given environment. Sets the current environment with the given value the sets the LINE_SEP attribute with the environment resource.

Parameters:
environment - The environment of the LyString instance.
Method Detail

stringToList

public static java.lang.String[] stringToList(java.lang.String text,
                                              char delimiter)
Tokenize a given string into an array of tokens. Tokens are separated by the given delimiter. For example, the result of stringToList("token1/token2",'/') will be an array containing the "token1" and "token2" strings.

Parameters:
text - The string which contains tokens separated by a delimiter.
delimiter - Used to separate tokens in the string.
Returns:
An array of tokens strings.
See Also:
listToString(String[], String), tokenizer(java.lang.String, char)

stringToList

public static java.lang.String[] stringToList(java.lang.String text,
                                              java.lang.String delimiter)
Tokenize a given string into an array of tokens. The tokens are separated by the given string delimiter. For example, the result of stringToList("token1::token2","::") will be an array containing the "token1" and "token2" strings.

Parameters:
text - The string which contains tokens separated by a delimiter.
delimiter - Used to separate tokens in the string.
Returns:
An array of tokens strings.
See Also:
listToString(String[], char), tokenizer(java.lang.String, char)

listToString

public static java.lang.String listToString(java.lang.String[] list,
                                            char separator)
Concatenate the given tokens list as a String with the specified delimiter. For example, the result of listToString({"token1","token2",'/') will be the string "token1/token2".

Parameters:
list - The array of tokens.
separator - The separator that must be used between the tokens in the result.
Returns:
The concatenation of tokens.
See Also:
stringToList(String, String)

listToString

public static java.lang.String listToString(java.lang.String[] list,
                                            java.lang.String separator)
Concatenate the given tokens list as a String with the specified delimiter. For example, the result of listToString({"token1","token2",'::') will be the string "token1::token2".

Parameters:
list - The array of tokens.
separator - The separator that must be used between the tokens in the result.
Returns:
The concatenation of tokens.
See Also:
stringToList(String, char)

getMaxLineWidth

public static int getMaxLineWidth(java.lang.String text)
Gets the maximum length of a line in a text. Lines are separated by a carriage return (\n).

Parameters:
text - The text that must be parsed.
Returns:
maximum The length of the greatest line.

replace

public static java.lang.String replace(java.lang.String text,
                                       java.lang.String find,
                                       java.lang.String replace)
Replaces all occurrences of the given find token by the given replace token in the given text.

Parameters:
text - The original String that must be parsed and modified.
find - The token that should be replaced in the original string.
replace - The token that should be used to replace the first token in the original string.
Returns:
The result of the replacement action.

replace

public static java.lang.String replace(java.lang.String text,
                                       char[] finds,
                                       char[] replaces)
Replaces all occurrences of the given find token by the given replace token in the given text.

Parameters:
text - The original String that must be parsed and modified.
find - The tokens that should be replaced in the original string.
replace - The tokens that should be used to replace the tokens in the original string.
Returns:
The result of the replacement action.

replace

public static java.lang.String replace(java.lang.String text,
                                       char[] finds,
                                       java.lang.String[] replaces)
Replaces all occurrences of the given find token by the given replace token in the given text.

Parameters:
text - The original String that must be parsed and modified.
find - The tokens that should be replaced in the original string.
replace - The tokens that should be used to replace the tokens in the original string.
Returns:
The result of the replacement action.

getPostscriptString

public static java.lang.String getPostscriptString(java.lang.String text)
Replaces non postscript chars with printable postscript chars in a string.

Parameters:
text - The original string.
Returns:
The postScript printable string.

getHtmlString

public static java.lang.String getHtmlString(java.lang.String text)
Encodes the given string as an HTML string. Replace the non-authorized characters by their HTML code. For example, '&' will be replaced by '&amp;', '\n' by '<BR>', etc.

Parameters:
text - The original string.
Returns:
The HTML string (return "" if text was null).
See Also:
getHtmlString(String), getHtmlEntitiesString(String)

encodeAmpersand

public static java.lang.String encodeAmpersand(java.lang.String text)
Encodes the given string by encoding all ampersand characters. '&' is replaced by "&amp;" except from the following sequences:

Parameters:
text - The original string.
Returns:
the encoded string.

getSimpleString

public static java.lang.String getSimpleString(java.lang.String str)
Gets a string without accent from the given string.

Parameters:
str - String with accents.
Returns:
String without accents.

getHtmlEntitiesString

public static java.lang.String getHtmlEntitiesString(java.lang.String text)
Encodes the given string as an HTML string. Replace the non-authorized characters by their HTML code. For example, '<' will be replaced by '<'. This method will not replace '\n', '\t', etc.

Parameters:
text - The original string.
Returns:
The HTML string (return "" if text was null).

getJavascriptString

public static java.lang.String getJavascriptString(java.lang.String text)
Encodes the given string as a javascript string. Replace non-authorized characters by their HTML code. For example, '<' will be replaced by '&lt;'. It will handle correctly ' and " in strings. All javascript string must be between double quote.

Parameters:
text - The original string.
Returns:
The JavaScript string (return "" if text was null).

encodeValueInJavascript

public static java.lang.String encodeValueInJavascript(java.lang.String value)
encode a string to add into a javascript value like

Parameters:
value - input value
Returns:
encoded value

decodeValueFromJavascript

public static java.lang.String decodeValueFromJavascript(java.lang.String value)
Decode a string to add into a javascript value like

Parameters:
value - input value
Returns:
encoded value

getJavascriptStringVar

public static java.lang.String getJavascriptStringVar(java.lang.String text)
Encodes the given string as a javascript variable string. Replaces '.' by '_'.s

Parameters:
text - The original string.
Returns:
The JavaScript variable string (return "" if text was null).

getXmlString

public static java.lang.String getXmlString(java.lang.String str)
Encodes the given string as an XML string. Calls getXmlString(str, true, true)

Parameters:
str - The original string.
Returns:
The XML string (return "" if text was null).
See Also:
getXmlString(String, boolean, boolean)

getXmlString

public static java.lang.String getXmlString(java.lang.String str,
                                            boolean quotes,
                                            boolean percent)
Encodes the given string as an XML string. Replace non-authorized characters by their XML code. For example, '&' will be replaced by '&amp;', '%' by '&37;', etc.

Parameters:
str - The original string.
quotes - indicates if " and ' are encoded (quotes) : this is required only for attributes
percent - indicates if % is encoded : this is required only for DTD
Returns:
The XML string (return "" if text was null).

getXmlStringStrict

public static java.lang.String getXmlStringStrict(java.lang.String str)
Encodes the given string as an XML string and delete all surrogate characters. Calls getXmlString(str, true, true)

Parameters:
str - The original string.
Returns:
The XML string (return "" if text was null).
See Also:
getXmlString(String, boolean, boolean)

getJsonString

public static java.lang.String getJsonString(java.lang.String str)
Encodes the given string as an XML string and delete all surrogate characters. Calls getXmlString(str, true, true)

Parameters:
str - The original string.
Returns:
The XML string (return "" if text was null).
See Also:
getXmlString(String, boolean, boolean)

format

public static java.lang.String format(java.lang.String text,
                                      int step,
                                      boolean fill,
                                      char fillingChar,
                                      boolean replaceCr)
Format the given String depending on given parameters.

Parameters:
text - The original String to be formatted.
step - The index (number of chars) for carriage return (newLine). It also represents the length of each line in the generated string.
fill - Indicates if lines must be filled until their maximum length (step). If true, we fill the string with the specified character (fillingChar).
fillingChar - The character used to fill the string if fill is true.
replaceCr - Indicates whether '\n' should be replaced with a space in the original String.
Returns:
the formatted string or null if an error occured or if original string is null or if original string only contains spaces.

getLine

public static java.lang.String getLine(java.io.InputStream input)
Reads one line from an inputStream (until the end of line is found).

Parameters:
input - The input stream.
Returns:
The next line or null if the end of file is detected.

getLine

public static java.lang.String getLine(java.io.InputStream input,
                                       java.lang.String charset)
Reads one line from an inputStream (until the end of line is found).

Parameters:
input - The input stream.
charset - expected charset to decode the inputstream
Returns:
The next line or null if the end of file is detected.

closeInput

public static void closeInput(java.io.InputStream input)
Closes the given InputStream. This method must be used if the LyInput#getLine() was called and the file was not readed till this end.

Parameters:
input - The input stream.

sortStrings

public static java.lang.String[] sortStrings(java.lang.String[] strings)
Sorts an array of strings. Uses the String.compareTo(java.lang.String) method to compare two strings. This method compares two strings lexicographically. The comparison is based on the Unicode value of each character in the strings.

Parameters:
strings - The original array of strings.
Returns:
The sorted array of strings.

getNbLines

public static int getNbLines(java.lang.String text)
Gets the number of lines (separated by '\n') in a String.

Parameters:
text - The string to analyse.
Returns:
The number of lines of the given string.

encrypt

public static final java.lang.String encrypt(LyEnvironment environment,
                                             java.lang.String str)
Encryption algorithm using SHA-1 from java.security. The original string is converted to a 20 bytes array. The array of bytes is returned as its hexadecimal representation (String).

Parameters:
environment - The environment whitin the encryption occured.
str - The original string.
Returns:
The encrypted string or null if an error occured.

getRandomId

public static java.lang.String getRandomId()
Creates randomly an identifier as a string (based on java.lang.Math.random() algorithm).

Returns:
A unique identifier.

matchFormat

public static boolean matchFormat(LyEnvironment environment,
                                  java.lang.String format,
                                  java.lang.String value)
Tests if a string matches a regular expression.

Parameters:
environment - environment whithin the test occured.
format - The regular expression.
value - The string that must be tested.
Returns:
true if the given string match the regular expression, false otherwise.

checkStringFormat

public static boolean checkStringFormat(LyEnvironment environment,
                                        java.lang.String format)
Tests if a format is valid.

Parameters:
environment - environment whithin the test occured (parameter not used).
format - The format.
Returns:
true if the given format is valid, false otherwise.

strip

public static java.lang.String strip(java.lang.String str,
                                     char modifier)
Strip given string : removes modifier from given string.

Parameters:
str - the String to strip
modifier - the modifier to remove
Returns:
the given String without the given modifier

matchStringFormat

public static boolean matchStringFormat(LyEnvironment environment,
                                        java.lang.String format,
                                        java.lang.String value)
Tests if a string match a simple format.

Parameters:
environment - environment whithin the test occured (parameter not used).
format - The format.
value - The string that must be tested.
Returns:
true if the given string matches the format, false otherwise.

indexOf

public static int indexOf(java.lang.StringBuffer buffer,
                          char delimiter,
                          int fromIndex)
Gets the index within the given string of the StringBuffer of the first occurrence of the specified delimiter that is not precede by the MODIFIER character, starting the search at the specified index.

Parameters:
buffer - the buffer containing the string to analyse
delimiter - the delimiter to find
fromIndex - the position where to start the search
Returns:
the index of the first occurence of the delimiter not precede by MODIFIER from the given index

checkFormat

public static boolean checkFormat(LyEnvironment environment,
                                  java.lang.String format)
Checks the validity of the given format.

Parameters:
environment - the environment (not used)
format - the format to check
Returns:
true if the format is valid, false otherwise

tokenizer

public static java.lang.String[] tokenizer(java.lang.String str,
                                           char delim)
Decode a String which has multiple tokens separated by a character. This method only calls tokenizer(str, (new Character(delim)).toString())

Parameters:
str - The string to parse into an array of tokens.
delim - The delimiter between tokens.
Returns:
An array of strings which contains the tokens.
See Also:
tokenizer(java.lang.String, java.lang.String)

tokenizer

public static java.lang.String[] tokenizer(java.lang.String str,
                                           java.lang.String delim)
Decode a String which has multiple tokens separated by a string. Empty tokens are returned as empty strings but not skipped like the java.util.StringTokenizer.

Parameters:
str - The string to parse into an array of tokens.
delim - The delimiter between tokens.
Returns:
An array of strings which contains the tokens.
See Also:
tokenizer(java.lang.String, char), stringToList(String, String)

encodeFileURL

public static java.lang.String encodeFileURL(java.lang.String url)
This utility method converts an URL defining the path of a file into a string that may be used in any WEB browser. This is used to display local images or files into HTML pages generated by Leonardi applications.

Example:
The incoming URL may be defined like this:
           C:\Documents and Settings\éma\My documents\leonardi.gif
 

And the formatted URL will be:

           file:///C|/Documents and Settings/%E9ma/My documents/leonardi.gif
 

It can also be used for files retrieved from the network. The incoming URL may be defined like this:

\            \ForeignPC\docs\notes.txt
 

And the formatted URL will be:

           file:////ForeignPC/docs/notes.txt
 

Parameters:
url - the incoming URL.
Returns:
the formatted URL.

encodeURL

public static java.lang.String encodeURL(java.lang.String str)
Translates the given string into application/x-www-form-urlencoded format using a specific encoding scheme. This method uses the supplied encoding scheme to obtain the bytes for unsafe characters.

Parameters:
str - String to be translated.
Returns:
the translated String.
See Also:
URLEncoder.encode(String, String)

expand

public java.lang.String expand(java.lang.String text,
                               java.lang.String defaultStr)
Replaces all properties key found in the given String by their value found in the current environment.
Keys format must be $KEYS$. If the key is not found, it is replaced be the value specified in the defaultStr.
Also replaces '/' with File.separator mark for current OS.

Parameters:
text - The original string, before any substitution.
defaultStr - Default value for the property. If the property is not found, this value is used for the substitution.
Returns:
The string after all substitutions.
See Also:
baseExpand(String, String)

expand

public java.lang.String expand(java.lang.String text)
Replaces all properties key found in the given String by their value found in the current environment.
This method only calls expand(text, null).

Parameters:
text - The original string, before any substitution.
Returns:
The string after all substitutions.

expandUrl

public java.lang.String expandUrl(java.lang.String text)
Replaces all properties key found in the given String by their value found in the current environment.
This method only calls expandUrl(text, null).

Parameters:
text - The original string, before any substitution.
Returns:
The string after all substitutions.

expandUrl

public java.lang.String expandUrl(java.lang.String text,
                                  java.lang.String defaultStr)
Replaces all properties key found in the given String by their value found in the current environment.
This method only calls baseExpand(text, defaultStr) if the text is not null.

Parameters:
text - The original string, before any substitution.
defaultStr - Default value for the property. If the property is not found, this value is used for the substitution.
Returns:
The string after all substitutions.

compose

public java.lang.String compose(java.lang.String text,
                                java.lang.Object[] params)
In a string, enables replacement of patterns '%n' such as %1,%2, etc. The number indicates the position of the parameter in the array. If the position is not valid, the pattern is not replaced.

Parameters:
text - The original String or the key to find it.
params - Parameters that should replace the associated patterns. The toString method is called on these parameters (if a parameter is null "null" is used to replace the corresponding pattern).
Returns:
A new String, after substitution of patterns.
See Also:
compose(java.lang.String,java.lang.Object), compose(java.lang.String,java.lang.Object, java.lang.Object), compose(java.lang.String,java.lang.Object, java.lang.Object,java.lang.Object)

compose

public java.lang.String compose(java.lang.String text,
                                java.lang.Object param)
In a string, enables replacement of one pattern (%1). This method calls compose(text, [param]).

Parameters:
text - The original String.
param - The parameter which should replace the associated pattern. The toString method is called on this parameter (if the parameter is null "null" is used to replace the pattern).
Returns:
A new String, after substitution of the pattern.
See Also:
compose(String, Object[])

compose

public java.lang.String compose(java.lang.String text,
                                java.lang.Object param,
                                java.lang.Object param2)
In a string, enables replacement of two patterns (%1,%2). The number indicates the position of the parameter in the array. This method calls compose(text, [param, param2]).

Parameters:
text - The original String.
param - The first parameter that should replace the associated patterns.
param2 - The second parameter that should replace the associated patterns.
Returns:
A new String, after substitution of patterns.
See Also:
compose(String, Object[])

compose

public java.lang.String compose(java.lang.String text,
                                java.lang.Object param,
                                java.lang.Object param2,
                                java.lang.Object param3)
In a string, enables replacement of three patterns (%1,%2,%3). The number indicates the position of the parameter in the array. This method calls compose(text, [param, param2, param3]).

Parameters:
text - The original String.
param - The first parameter that should replace the associated patterns.
param2 - The second parameter that should replace the associated patterns.
param3 - The third parameter that should replace the associated patterns.
Returns:
A new String, after substitution of patterns.
See Also:
compose(String, Object[])

getCommonPart

public static java.lang.String getCommonPart(java.util.Vector<java.lang.String> values)
Gets the string that is the common part of all strings of the given list.

Parameters:
values - a list of string
Returns:
if the list contain only one element, the single element, the common part of all string of the list if any, null otherwise.

testUTF8String

public static boolean testUTF8String(java.lang.String value)
                              throws java.io.UnsupportedEncodingException
Check if the String is not properly encoded and contains likely UTF-8 bytes

Parameters:
value - String to test
Returns:
true if the String seems OK.
Throws:
java.io.UnsupportedEncodingException

replaceCharSet

public static java.lang.String replaceCharSet(java.lang.String value,
                                              java.lang.String newCharSet)
Convert the Strings to bytes and analyse this using another charset

Parameters:
value - string to check

revertToUTF8

public static java.lang.String revertToUTF8(java.lang.String s)
Replace common misread characters to their UTF-8 equivalent

Parameters:
s - String to replace
Returns:
the result string

(c) January 2013 - W4 S.A.

Website: W4 S.A., contact us: support@w4global.com