|
LEONARDI Application Composer - 8.9.0.40 by W4 S.A. | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectleon.misc.LyString
public class LyString
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 |
---|
public static final java.lang.String __VERSION
public static final char[] HEXA_TABLE
public static char MODIFIER
public static java.lang.String MODIFIER_STRING
public static java.lang.String DEFAULT_CHARSET
public static java.lang.String HTTP_PROTOCOL
public static java.lang.String HTTPS_PROTOCOL
public char SEP
public char VISIBLE_SEP
public char VISIBLE_SEP2
public java.lang.String VISIBLE_SEP3
VISIBLE_SEP3_BIS
.
public java.lang.String VISIBLE_SEP3_BIS
VISIBLE_SEP3
.
public char EXPORT_COLUMN_SEP
public java.lang.String EXPORT_HEADER_MARK
public java.lang.String LINE_SEP
public java.lang.String FILE_SEPARATOR
Constructor Detail |
---|
public LyString(LyEnvironment environment)
LINE_SEP
attribute with the environment resource.
environment
- The environment of the LyString instance.Method Detail |
---|
public static java.lang.String[] stringToList(java.lang.String text, char delimiter)
text
- The string which contains tokens separated by a delimiter.delimiter
- Used to separate tokens in the string.
listToString(String[], String)
,
tokenizer(java.lang.String, char)
public static java.lang.String[] stringToList(java.lang.String text, java.lang.String delimiter)
text
- The string which contains tokens separated by a delimiter.delimiter
- Used to separate tokens in the string.
listToString(String[], char)
,
tokenizer(java.lang.String, char)
public static java.lang.String listToString(java.lang.String[] list, char separator)
list
- The array of tokens.separator
- The separator that must be used between the tokens in the result.
stringToList(String, String)
public static java.lang.String listToString(java.lang.String[] list, java.lang.String separator)
list
- The array of tokens.separator
- The separator that must be used between the tokens in the result.
stringToList(String, char)
public static int getMaxLineWidth(java.lang.String text)
\n
).
text
- The text that must be parsed.
public static java.lang.String replace(java.lang.String text, java.lang.String find, java.lang.String replace)
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.
public static java.lang.String replace(java.lang.String text, char[] finds, char[] replaces)
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.
public static java.lang.String replace(java.lang.String text, char[] finds, java.lang.String[] replaces)
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.
public static java.lang.String getPostscriptString(java.lang.String text)
text
- The original string.
public static java.lang.String getHtmlString(java.lang.String text)
text
- The original string.
getHtmlString(String)
,
getHtmlEntitiesString(String)
public static java.lang.String encodeAmpersand(java.lang.String text)
text
- The original string.
public static java.lang.String getSimpleString(java.lang.String str)
str
- String with accents.
public static java.lang.String getHtmlEntitiesString(java.lang.String text)
text
- The original string.
public static java.lang.String getJavascriptString(java.lang.String text)
text
- The original string.
public static java.lang.String encodeValueInJavascript(java.lang.String value)
value
- input value
public static java.lang.String decodeValueFromJavascript(java.lang.String value)
value
- input value
public static java.lang.String getJavascriptStringVar(java.lang.String text)
text
- The original string.
public static java.lang.String getXmlString(java.lang.String str)
getXmlString(str, true, true)
str
- The original string.
getXmlString(String, boolean, boolean)
public static java.lang.String getXmlString(java.lang.String str, boolean quotes, boolean percent)
str
- The original string.quotes
- indicates if " and ' are encoded (quotes) : this is required only for
attributespercent
- indicates if % is encoded : this is required only for DTD
public static java.lang.String getXmlStringStrict(java.lang.String str)
getXmlString(str, true, true)
str
- The original string.
getXmlString(String, boolean, boolean)
public static java.lang.String getJsonString(java.lang.String str)
getXmlString(str, true, true)
str
- The original string.
getXmlString(String, boolean, boolean)
public static java.lang.String format(java.lang.String text, int step, boolean fill, char fillingChar, boolean replaceCr)
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.
public static java.lang.String getLine(java.io.InputStream input)
input
- The input stream.
public static java.lang.String getLine(java.io.InputStream input, java.lang.String charset)
input
- The input stream.charset
- expected charset to decode the inputstream
public static void closeInput(java.io.InputStream input)
LyInput#getLine()
was
called and the file was not readed till this end.
input
- The input stream.public static java.lang.String[] sortStrings(java.lang.String[] strings)
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.
strings
- The original array of strings.
public static int getNbLines(java.lang.String text)
text
- The string to analyse.
public static final java.lang.String encrypt(LyEnvironment environment, java.lang.String str)
environment
- The environment whitin the encryption occured.str
- The original string.
public static java.lang.String getRandomId()
public static boolean matchFormat(LyEnvironment environment, java.lang.String format, java.lang.String value)
environment
- environment whithin the test occured.format
- The regular expression.value
- The string that must be tested.
public static boolean checkStringFormat(LyEnvironment environment, java.lang.String format)
environment
- environment whithin the test occured (parameter not used).format
- The format.
public static java.lang.String strip(java.lang.String str, char modifier)
str
- the String to stripmodifier
- the modifier to remove
public static boolean matchStringFormat(LyEnvironment environment, java.lang.String format, java.lang.String value)
environment
- environment whithin the test occured (parameter not used).format
- The format.value
- The string that must be tested.
public static int indexOf(java.lang.StringBuffer buffer, char delimiter, int fromIndex)
MODIFIER
character, starting the
search at the specified index.
buffer
- the buffer containing the string to analysedelimiter
- the delimiter to findfromIndex
- the position where to start the search
MODIFIER
from the given indexpublic static boolean checkFormat(LyEnvironment environment, java.lang.String format)
environment
- the environment (not used)format
- the format to check
public static java.lang.String[] tokenizer(java.lang.String str, char delim)
tokenizer(str, (new Character(delim)).toString())
str
- The string to parse into an array of tokens.delim
- The delimiter between tokens.
tokenizer(java.lang.String, java.lang.String)
public static java.lang.String[] tokenizer(java.lang.String str, java.lang.String delim)
str
- The string to parse into an array of tokens.delim
- The delimiter between tokens.
tokenizer(java.lang.String, char)
,
stringToList(String, String)
public static java.lang.String encodeFileURL(java.lang.String url)
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
url
- the incoming URL.
public static java.lang.String encodeURL(java.lang.String str)
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.
str
- String to be translated.
URLEncoder.encode(String, String)
public java.lang.String expand(java.lang.String text, java.lang.String defaultStr)
defaultStr
.
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.
baseExpand(String, String)
public java.lang.String expand(java.lang.String text)
expand(text, null)
.
text
- The original string, before any substitution.
public java.lang.String expandUrl(java.lang.String text)
expandUrl(text, null)
.
text
- The original string, before any substitution.
public java.lang.String expandUrl(java.lang.String text, java.lang.String defaultStr)
baseExpand(text, defaultStr)
if
the text is not null.
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.
public java.lang.String compose(java.lang.String text, java.lang.Object[] params)
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).
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)
public java.lang.String compose(java.lang.String text, java.lang.Object param)
compose(text, [param])
.
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).
compose(String, Object[])
public java.lang.String compose(java.lang.String text, java.lang.Object param, java.lang.Object param2)
compose(text, [param, param2])
.
text
- The original String.param
- The first parameter that should replace the associated patterns.param2
- The second parameter that should replace the associated patterns.
compose(String, Object[])
public java.lang.String compose(java.lang.String text, java.lang.Object param, java.lang.Object param2, java.lang.Object param3)
compose(text, [param, param2, param3])
.
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.
compose(String, Object[])
public static java.lang.String getCommonPart(java.util.Vector<java.lang.String> values)
values
- a list of string
public static boolean testUTF8String(java.lang.String value) throws java.io.UnsupportedEncodingException
value
- String to test
java.io.UnsupportedEncodingException
public static java.lang.String replaceCharSet(java.lang.String value, java.lang.String newCharSet)
value
- string to checkpublic static java.lang.String revertToUTF8(java.lang.String s)
s
- String to replace
|
(c) January 2013 - W4 S.A. | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |