|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objecteu.webtoolkit.jwt.WString
public class WString
A localized string class.
JWt uses WString to store text that may be displayed in the browser.
A WString can either be a literal string or a localized string. A localized string is resolved using
WApplication.getLocalizedStrings(), taking into account the WApplication.getLocale().
To create a literal string, use WString(String). To create a localized string you should use tr(String)
or WObject.tr(String). The actual value of a string can be obtained using toString() or getValue().
A WString can substitute place holders by arguments that are specified using the arg(CharSequence), arg(double) or
arg(int) methods. Place holders are numbered: {n} denotes the n'th place holder.
WApplication.getLocalizedStrings(),
WApplication.getLocale()| Field Summary | |
|---|---|
static WString |
Empty
Empty WString object. |
| Constructor Summary | |
|---|---|
WString()
Creates an empty string. |
|
WString(char c)
Creates a literal string from a single character. |
|
WString(char[] buf)
Creates a literal string from a char array. |
|
WString(java.lang.String s)
Creates a literal string. |
|
| Method Summary | |
|---|---|
WString |
append(char[] buf)
Appends a string, converting the string to a literal string if necessary. |
WString |
append(java.lang.String other)
Appends a string, converting the string to a literal string if necessary. |
WString |
append(WString other)
Appends a string, converting the string to a literal string if necessary. |
WString |
arg(java.lang.CharSequence value)
Substitutes the next positional argument with a string value. |
WString |
arg(double value)
Substitutes the next positional argument with a double value. |
WString |
arg(int value)
Substitutes the next positional argument with an integer value. |
void |
changeArg(int argIndex,
double value)
Change the WString 's argument at position argIndex. |
void |
changeArg(int argIndex,
int value)
Change the WString 's argument at position argIndex. |
void |
changeArg(int argIndex,
java.lang.String value)
Change the WString 's argument at position argIndex. |
char |
charAt(int index)
Returns the character at a given index. |
int |
compareTo(WString arg0)
Compares this WString object with the specified WString object for order. |
boolean |
equals(WString other)
Indicates whether some other object is "equal to" this one. |
java.util.List<WString> |
getArgs()
Returns the arguments. |
java.lang.String |
getJsStringLiteral()
Utility method which returns the value as a JavaScript string literal. |
java.lang.String |
getJsStringLiteral(char delimiter)
Utility method which returns the value as a JavaScript string literal. |
java.lang.String |
getKey()
Returns the key for a localized string. |
int |
getLength()
Returns the string length. |
java.lang.String |
getValue()
Returns the value. |
boolean |
isEmpty()
Returns whether the string is empty. |
boolean |
isLiteral()
Returns whether the string is literal. |
int |
length()
Returns the string length. |
boolean |
refresh()
Refreshes the (localized) strings. |
java.lang.CharSequence |
subSequence(int start,
int end)
Returns a sub string. |
java.lang.String |
toString()
Returns the value of this string. |
static WString |
toWString(java.lang.CharSequence charSequence)
Converts a CharSequence to a WString. |
static WString |
tr(java.lang.String key)
Creates a localized string. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final WString Empty
| Constructor Detail |
|---|
public WString()
public WString(java.lang.String s)
public WString(char c)
public WString(char[] buf)
| Method Detail |
|---|
public boolean equals(WString other)
public WString append(WString other)
thispublic WString append(java.lang.String other)
thispublic WString append(char[] buf)
thispublic boolean isEmpty()
public java.lang.String getValue()
A localized string is resolved using the WApplication.getLocalizedStrings().
Arguments place holders are substituted with actual arguments.
public int compareTo(WString arg0)
compareTo in interface java.lang.Comparable<WString>public static WString tr(java.lang.String key)
key - the key which is used to resolve within a locale.
WLocalizedStrings.resolveKey(String)public boolean isLiteral()
public java.lang.String getKey()
null if the string is literal.public WString arg(java.lang.CharSequence value)
In the string, the n-th argument is referred to as using {n}.
For example: the string "{1} bought {2} apples in the shop." with first argument value "Bart" and second argument value 5 becomes: "Bart bought 5 apples in the shop."
thispublic WString arg(int value)
In the string, the n-th argument is referred to as using {n}.
For example: the string "{1} bought {2} apples in the shop." with first argument value "Bart" and second argument value 5 becomes: "Bart bought 5 apples in the shop."
thispublic WString arg(double value)
In the string, the n-th argument is referred to as using {n}.
For example: the string "{1} bought {2} apples in the shop." with first argument value "Bart" and second argument value 5 becomes: "Bart bought 5 apples in the shop."
thispublic java.util.List<WString> getArgs()
arg(CharSequence)public boolean refresh()
The localized string is resolved again using WApplication.getLocalizedStrings().
public java.lang.String getJsStringLiteral(char delimiter)
This method escapes the string where needed.
delimiter - the quote delimiter to be used ('\'' or '"')
public java.lang.String getJsStringLiteral()
Calls getJsStringLiteral('\'')
public void changeArg(int argIndex,
java.lang.String value)
public void changeArg(int argIndex,
int value)
public void changeArg(int argIndex,
double value)
public java.lang.String toString()
toString in interface java.lang.CharSequencetoString in class java.lang.ObjectgetValue()public static WString toWString(java.lang.CharSequence charSequence)
When the char sequence is a WString, it is casted otherwise, a new WString is created.
public char charAt(int index)
It is probably more efficient to call getValue() first and then compute on that String.
charAt in interface java.lang.CharSequencepublic int length()
It is probably more efficient to call getValue() first and then compute on that String.
length in interface java.lang.CharSequencepublic int getLength()
length()
public java.lang.CharSequence subSequence(int start,
int end)
It is probably more efficient to call getValue() first and then compute on that String.
subSequence in interface java.lang.CharSequence
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||