new OString(value)
Creates a new OString
, setting its value to the specified string.
It is highly recommended to use the static factory
instead as it is optimised and
more flexible.
Parameters:
Name | Type | Description |
---|---|---|
value |
string | The value of this |
Members
-
<static, constant, non-null> EMPTY :olympe.df.OString
-
Type:
-
<static, constant, non-null> SPACE :olympe.df.OString
-
Type:
Methods
-
<static> Concat(pOStr1, pOStr2)
-
Constructs a new
OString
by concatenating the 2 strings passed as parameters.Parameters:
Name Type Description pOStr1
olympe.df.POString | string the first part of the string
pOStr2
olympe.df.POString | string the second part of the string
Returns:
the concatenation of the 2 strings
- Type
- olympe.df.POString
-
<static> concat(strings)
-
Concatenate all the strings passed as parameter and returns the result as a new OString or POString.
Parameters:
Name Type Argument Description strings
olympe.df.OString | olympe.df.Proxy.<olympe.df.OString> | string <repeatable>
The strings to concatenate to this one
Returns:
A new string containing the result of the concatenation
- Type
- olympe.df.POString
-
<static> currentStringValue(p)
-
Returns the current value of a string. The argument can be an
OString
, aNode
or aProxy<OString>
.Parameters:
Name Type Description p
olympe.df.POString | string | olympe.df.Node the string
Returns:
the value as a primitive string
- Type
- string
-
<static> fromJSON(json)
-
Deserializes an
OString
from a JSON object or string.Parameters:
Name Type Description json
string | Object Returns:
- Type
- olympe.df.OString
-
concat(strings)
-
Concatenate this string with all the strings in an array and returns the result as a new OString.
Parameters:
Name Type Argument Description strings
olympe.df.POString | string <repeatable>
The strings to concatenate to this one. If an array is passed as first parameter, its elements will be concatenated, while non-first parameters are ignored.
Returns:
A new string containing the result of the concatenation
- Type
- olympe.df.POString
-
concatenate(otherOString [, separator])
-
Concatenate this string with another using an optional separator and return the result as a new OString.
Parameters:
Name Type Argument Default Description otherOString
olympe.df.POString | string The string to concatenate to this one
separator
olympe.df.POString | string <optional>
'' the string to insert between the 2 strings
Returns:
A new string containing the result of the concatenation
- Type
- olympe.df.POString
-
contains(otherOString)
-
Checks whether this
OString
contains another string.Parameters:
Name Type Description otherOString
olympe.df.POString | string The string to be searched for in this string.
Returns:
true
if thisOString
containsotherOString
- Type
- olympe.df.POBoolean
-
endsWith(otherString [, position])
-
Checks whether this String ends with a specified substring.
Parameters:
Name Type Argument Default Description otherString
olympe.df.POString | string the string to be searched for at the end of this string
position
olympe.df.PONumber | number <optional>
-1 The position in
string at which to begin searching for
otherString`Returns:
true
if the specified string matches the end of this string- Type
- olympe.df.POBoolean
-
equals( [otherOString])
-
Checks whether the value of this
OString
is equal to another string.Parameters:
Name Type Argument Description otherOString
olympe.df.OString | string <optional>
the string or
OString
to compare withReturns:
true
if both strings are equal, false otherwise- Type
- boolean
-
getLength()
-
Gets the length of this
OString
.Returns:
- Type
- olympe.df.PONumber
-
indexOf(otherString [, startPos])
-
Returns the index of (the position of) the first occurrence of a specified text in a string. For startPos values lower than 0 or greater than the length of the string, the search starts at index 0 and the end of the string respectively.
Parameters:
Name Type Argument Default Description otherString
olympe.df.POString | string The string to search
startPos
olympe.df.PONumber | number <optional>
0 The position where to start the search
Returns:
the position of the searched string, -1 if not found
- Type
- olympe.df.PONumber
-
isEmpty()
-
Checks whether this
OString
is empty or not.Returns:
true
if this string is empty.- Type
- olympe.df.OBoolean
-
lastIndexOf(otherString [, startPos])
-
Returns the index of (the position of) the last occurrence of a specified text in a string. If startPos is greater than the length of the string, the whole string is searched. If startPos is smaller than 0, the behavior will be the same as if it would be 0.
Parameters:
Name Type Argument Default Description otherString
olympe.df.POString | string The string to search
startPos
olympe.df.PONumber | number <optional>
Infinity The index of the last character in the string to be considered as the beginning of a match
Returns:
the position of the searched string, -1 if not found
- Type
- olympe.df.PONumber
-
oEquals( [otherOString])
-
Checks whether this
OString
is equal to another string.Parameters:
Name Type Argument Description otherOString
olympe.df.POString | string <optional>
the string or
OString
to compare withReturns:
true if both strings are equal, false otherwise
- Type
- olympe.df.POBoolean
-
padEnd(length, padString)
-
Pad the current string with another string (multiple times, if needed) until the resulting string reaches the specified length. The padding is applied from the current string end.
Parameters:
Name Type Description length
olympe.df.PONumber padString
olympe.df.POString Returns:
- Type
- olympe.df.POString
-
padStart(length, padString)
-
Pad the current string with another string (multiple times, if needed) until the resulting string reaches the specified length. The padding is applied from the current string start.
Parameters:
Name Type Description length
olympe.df.PONumber padString
olympe.df.POString Returns:
- Type
- olympe.df.POString
-
replace(pattern, replacement)
-
Return a new string in which the first match of
pattern
has been replaced byreplacement
. Bothpattern
andreplacement
are strings.Parameters:
Name Type Description pattern
olympe.df.POString replacement
olympe.df.POString Returns:
- Type
- olympe.df.POString
-
slice(startPos [, endPos])
-
Extracts a section of a string and returns it as a new string. If a parameter is negative, the position is counted from the end of the string. If no end position is provided, extracts to the end of the string.
Parameters:
Name Type Argument Description startPos
olympe.df.PONumber | number starting position
endPos
olympe.df.PONumber | number <optional>
end position, the character at this index will not be included.
Returns:
A new string containing the extracted section of the string.
- Type
- olympe.df.POString
-
startsWith(otherString [, position])
-
Checks whether this String starts with a specified substring.
Parameters:
Name Type Argument Default Description otherString
olympe.df.POString | string the string to be searched for at the start of this string
position
olympe.df.PONumber | number <optional>
0 The position in
string
at which to begin searching forotherString
Returns:
true
if the specified string matches the start of this string- Type
- olympe.df.POBoolean
-
subOStr(start, length)
-
Returns a new string that is a substring of this string. The substring begins at the specified
start
and that is up tolength
long.Examples:
new OString("hamburger").subOStr(4, 4) returns "urge" new OString("smiles").subOStr(1, 6) returns "miles"
Parameters:
Name Type Description start
olympe.df.PONumber | number length
olympe.df.PONumber | number Returns:
- Type
- olympe.df.POString
-
threshold(threshold)
-
Returns the full string if it is longer or equal to the threshold, otherwise return an empty string.
Parameters:
Name Type Description threshold
olympe.df.PONumber | number After which the string is returned
Returns:
- Type
- olympe.df.POString
-
toJSON()
-
Converts this
OString
into a JSON string.Returns:
- Type
- string
-
toLowerCase()
-
Converts this
OString
into all lower cases and returns the result in a new instance.Returns:
the lowercase conversion of this
OString
- Type
- olympe.df.POString
-
toONumber()
-
Converts this
OString
into a number.Returns:
the converted value
- Type
- olympe.df.PONumber
-
toONumberInt(radix)
-
Converts this string into an integer number.
Parameters:
Name Type Description radix
number - See:
-
olympe.df.ONumber#toONumber
Returns:
the converted value.
- Type
- olympe.df.PONumber
-
toOString()
-
Converts this Object into an
OString
.Returns:
this
OString
- Type
- olympe.df.POString
-
toString()
-
Gets the string value of this
OString
.- Deprecated:
-
- Use
valueOf
instead
- Use
Returns:
String representation of this OString
- Type
- string
-
toUpperCase()
-
Converts this
OString
into all upper cases and returns the result in a new instance.Returns:
the uppercase conversion of this
OString
- Type
- olympe.df.POString
-
trim()
-
Removes whitespace from both ends of a string. Whitespace in this context is all the whitespace characters (space, tab, no-break space, etc.) and all the line terminator characters (LF, CR, etc.).
Returns:
A new string representing the calling string stripped of whitespace from both ends.
- Type
- olympe.df.POString
-
valueOf()
-
Returns the value of this
OString
.Returns:
This OString as a primitive string
- Type
- string