public class LeoString extends LeoObject
LeoString
instance, leaving the LeoString
more or less immutable. The one exception is the indexing into the string itself:
var aString = "Hello" aString[2] = "X" println(aString) // HeXllo ; the indexing does an insert
This might change in the future, I'm a bit undecided if this is a desirable feature -- furthermore this probably can cause
issues with the LeoString
interning (due to the original string referencing the LeoString, which if altered would no
longer match).
LeoObject.LeoType
Constructor and Description |
---|
LeoString() |
LeoString(String value) |
LeoString(StringBuilder value) |
Modifier and Type | Method and Description |
---|---|
void |
_for(int start,
int end,
LeoObject function)
Iterates through the string, invoking the supplied
function object for each element.
|
LeoObject |
$add(double other) |
LeoObject |
$add(int other) |
LeoObject |
$add(LeoObject other) |
LeoObject |
$add(long other) |
boolean |
$eq(LeoObject other)
Determines if it equals another object.
|
boolean |
$gt(LeoObject other)
If it's greater than to another object
|
boolean |
$gte(LeoObject other)
If it's greater than or equal to another object.
|
LeoObject |
$index(double other) |
LeoObject |
$index(int other) |
LeoObject |
$index(LeoObject other) |
LeoObject |
$index(long other) |
boolean |
$lt(LeoObject other)
If it's less than to another object
|
boolean |
$lte(LeoObject other)
If it's less than or equal to another object.
|
void |
$sindex(LeoObject key,
LeoObject other) |
LeoObject |
$sub(LeoObject other) |
LeoString |
append(LeoObject v)
Appends to this string.
|
int |
byteAt(int n) |
LeoString |
charAt(int n) |
LeoObject |
clone() |
boolean |
contains(LeoObject v)
Determines if this string contains the supplied string (v)
|
boolean |
empty() |
boolean |
endsWith(LeoObject v) |
LeoString |
filter(LeoObject function)
Returns a sequence consisting of those items from the sequence for which function(item) is true
|
LeoObject |
foreach(LeoObject function)
Iterates through the array, invoking the supplied
function object for each element
|
LeoString |
format(Object... args)
Formats the current string according to
String.format(String, Object...) . |
LeoObject |
getObject(LeoObject key)
Retrieves a property from this object.
|
String |
getString() |
Object |
getValue() |
Object |
getValue(Class<?> type)
Attempts to narrow the
LeoObject to a more specific Java Type |
int |
hashCode() |
boolean |
hasObject(LeoObject key)
Determines if the supplied key has an associated value
|
LeoArray |
indexesOf(LeoObject v)
Retrieves all of the indexes where 'v' is found in this string.
|
int |
indexOf(LeoObject v)
The index of the supplied string
|
LeoString |
insert(int position,
LeoObject v)
inserts a string into the supplied position.
|
boolean |
isAssignable(Class<?> javaType)
Determines if the supplied Java type can be assigned to this
LeoObject . |
boolean |
isString() |
LeoString |
join(String delimiter,
Object... args)
Combines the list of arguments (separating them by the supplied delimiter) and appending them
to this string.
|
int |
length() |
LeoString |
map(LeoObject function)
Maps the supplied function to each element in the string.
|
static LeoString |
read(DataInput in)
|
LeoString |
replace(int start,
int end,
LeoObject v)
Replaces a portion of the string.
|
LeoString |
replaceAll(LeoObject replaceMe,
LeoObject v)
Replaces all occurrences of the supplied string.
|
LeoString |
rest(int i)
The rest of the string from position i.
|
void |
setObject(LeoObject key,
LeoObject value)
Sets a property on this object.
|
LeoArray |
split(LeoObject v)
Splits the string by the regex
|
boolean |
startsWith(LeoObject v) |
boolean |
startsWith(String prefix,
int toffset) |
LeoString |
substring(int start,
int end)
Gets the substring.
|
LeoString |
toLeoString() |
LeoString |
toLower() |
String |
toString() |
LeoString |
toUpper() |
LeoString |
trim() |
static LeoString |
valueOf(String str)
Interns the
LeoString . |
void |
write(DataOutput out)
Writes this object out
|
LeoObject |
xgetObject(LeoObject key)
Similar to
LeoObject.getObject(LeoObject) in every way, with the exception that
this will throw a LeolaRuntimeException is the attribute is not found. |
$band, $band, $band, $band, $bnot, $bor, $bor, $bor, $bor, $bsl, $bsl, $bsl, $bsl, $bsr, $bsr, $bsr, $bsr, $div, $div, $div, $div, $eq, $eq, $eq, $eq, $gt, $gt, $gt, $gte, $gte, $gte, $lt, $lt, $lt, $lte, $lte, $lte, $mod, $mod, $mod, $mod, $mul, $mul, $mul, $mul, $neg, $neq, $neq, $neq, $neq, $req, $sub, $sub, $sub, $xor, $xor, $xor, $xor, as, as, asByte, asChar, asDouble, asFloat, asInt, asLong, asShort, call, call, call, call, call, call, call, compareTo, equals, getLocals, getNativeMember, getNativeMethod, getNativeMethod, getNumberOfArgs, getObject, getOuters, getScope, getType, hasNativeMethod, hasNativeMethod, hasObject, hasVarargs, isArray, isBoolean, isClass, isError, isFunction, isGenerator, isMap, isNamespace, isNativeClass, isNativeFunction, isNull, isNumber, isOfType, isOfType, isOfType, isOfType, isOuter, isScopedObject, isTrue, isTrue, read, removeInterfaceMethods, rethrow, setObject, throwAttributeAccessError, throwAttributeError, throwAttributeError, throwClassNotFoundError, throwDivideByZeroError, throwIfError, throwMethodError, throwNativeMethodError, throwNotImplementedError, toJavaObject, valueOf, xcall, xcall, xcall, xcall, xcall, xcall, xcall, xgetObject
public LeoString(String value)
value
- public LeoString(StringBuilder value)
value
- public LeoString()
public static LeoString valueOf(String str)
LeoString
.str
- public LeoString toLeoString()
toLeoString
in class LeoObject
public String getString()
public LeoString map(LeoObject function)
var result = "hi".map(def(e) return e+"2") println(result) // h2i2
function
- LeoString
public LeoString filter(LeoObject function)
function
- public void _for(int start, int end, LeoObject function)
"hi".for(0, 1, def(c) println(c)) // prints: // h
start
- starting index (inclusive)end
- ending index (exclusive)function
- public LeoObject foreach(LeoObject function)
"hi".foreach(def(c) println(c)) // prints: // h // i
function
- LeoObject
returned from the supplied function if returned true
public LeoString join(String delimiter, Object... args)
delimiter
- args
- public LeoString format(Object... args)
String.format(String, Object...)
.args
- public LeoString toLower()
public LeoString toUpper()
public void setObject(LeoObject key, LeoObject value)
LeoObject
public LeoObject xgetObject(LeoObject key)
LeoObject
LeoObject.getObject(LeoObject)
in every way, with the exception that
this will throw a LeolaRuntimeException
is the attribute is not found.xgetObject
in class LeoObject
public LeoObject getObject(LeoObject key)
LeoObject
LeoObject
supports associations, this
will attempt to find the object with the associated key. If the key is not found, this will return LeoObject.NULL
.getObject
in class LeoObject
LeoObject.NULL
LeoObject.xgetObject(LeoObject)
public boolean hasObject(LeoObject key)
LeoObject
public LeoString insert(int position, LeoObject v)
position
- v
- public boolean contains(LeoObject v)
v
- public int indexOf(LeoObject v)
v
- public LeoString rest(int i)
i
- public LeoString substring(int start, int end)
start
- end
- public LeoString replace(int start, int end, LeoObject v)
start
- end
- v
- public LeoString replaceAll(LeoObject replaceMe, LeoObject v)
replaceMe
- v
- public LeoArray split(LeoObject v)
v
- LeoArray
public boolean endsWith(LeoObject v)
public boolean startsWith(LeoObject v)
public boolean startsWith(String prefix, int toffset)
public LeoArray indexesOf(LeoObject v)
v
- public LeoString trim()
public int length()
public boolean empty()
public LeoString charAt(int n)
n
- public int byteAt(int n)
n
- public boolean $eq(LeoObject other)
LeoObject
public boolean $gt(LeoObject other)
LeoObject
public boolean $gte(LeoObject other)
LeoObject
public boolean $lt(LeoObject other)
LeoObject
public boolean $lte(LeoObject other)
LeoObject
public Object getValue()
public Object getValue(Class<?> type)
LeoObject
LeoObject
to a more specific Java Typepublic boolean isAssignable(Class<?> javaType)
LeoObject
LeoObject
.isAssignable
in class LeoObject
LeoObject
public LeoObject clone()
public void write(DataOutput out) throws IOException
LeoObject
write
in class LeoObject
IOException
public static LeoString read(DataInput in) throws IOException
in
- LeoObject
IOException
Copyright © 2010–2015. All rights reserved.