|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectoscript.data.Value
oscript.data.OObject
oscript.data.OString
A string class. An OString
is immutable, once the instance is
constructed, it won't change.
Field Summary | |
static java.lang.String[] |
MEMBER_NAMES
|
static java.lang.String |
PARENT_TYPE_NAME
|
static Value |
TYPE
The type object for an instance of String. |
static java.lang.String |
TYPE_NAME
|
Fields inherited from class oscript.data.OObject |
EMPTY_EXPR_LIST_EVALUATOR |
Fields inherited from class oscript.data.Value |
DEBUG, NULL, UNDEFINED |
Constructor Summary | |
OString()
|
|
OString(MemberTable args)
Class Constructor. |
|
OString(java.lang.String stringVal)
Construct a new string. |
Method Summary | |
static Value |
_bopCast(Value val)
|
Value |
bopEquals(Value val)
Perform the "==" operation. |
Value |
bopEqualsR(Value val,
PackagedScriptObjectException e)
|
Value |
bopGreaterThan(Value val)
Perform the ">" operation. |
Value |
bopGreaterThanOrEquals(Value val)
Perform the ">=" operation. |
Value |
bopGreaterThanOrEqualsR(Value val,
PackagedScriptObjectException e)
|
Value |
bopGreaterThanR(Value val,
PackagedScriptObjectException e)
|
Value |
bopLessThan(Value val)
Perform the "<" operation. |
Value |
bopLessThanOrEquals(Value val)
Perform the "<=" operation. |
Value |
bopLessThanOrEqualsR(Value val,
PackagedScriptObjectException e)
|
Value |
bopLessThanR(Value val,
PackagedScriptObjectException e)
|
Value |
bopNotEquals(Value val)
Perform the "!=" operation. |
Value |
bopNotEqualsR(Value val,
PackagedScriptObjectException e)
|
Value |
bopPlus(Value val)
Perform the "+" operation. |
Value |
bopPlusR(Value val,
PackagedScriptObjectException e)
|
boolean |
castToBoolean()
Convert this object to a native java boolean value. |
long |
castToExactNumber()
Convert this object to a native java long value. |
double |
castToInexactNumber()
Convert this object to a native java double value. |
java.lang.Object |
castToJavaObject()
Convert this object to a native java Object value. |
java.lang.String |
castToString()
Convert this object to a native java String value. |
static java.lang.String |
chop(java.lang.String str)
|
Value |
elementAt(Value oidx)
Get the specified index of this object. |
Value |
elementsAt(Value idx1,
Value idx2)
Get the specified range of this object, if this object is an array. |
boolean |
endsWith(java.lang.String str)
|
boolean |
equals(java.lang.Object obj)
Compare two objects for equality. |
protected Value |
getTypeImpl()
Get the type of this object. |
int |
hashCode()
Return a hash code value for this object. |
int |
indexOf(java.lang.String str)
|
int |
indexOf(java.lang.String str,
int fromIdx)
|
OString |
intern()
Return a canonical representation of this OString object. |
int |
lastIndexOf(java.lang.String str)
|
int |
lastIndexOf(java.lang.String str,
int fromIdx)
|
int |
length()
For types that implement elementAt , this returns the
number of elements. |
static OString |
makeString(java.lang.String str)
Return an intern'd OString.... |
Value |
match(Value regexp)
Returns the same thing as regexp.exec(this) . |
void |
readExternal(java.io.ObjectInput in)
Derived class that implements Externalizable must
call this if it overrides it. |
Value |
replace(Value regexp,
Value strOrFxn)
Finds a match between a regular expression and this string object, and replaces the matched substring with a new substring. |
Value |
search(Value regexp)
Executes the search for a match between a regular expression and this string object. |
boolean |
startsWith(java.lang.String str)
|
java.lang.String |
substring(int begIdx)
|
java.lang.String |
substring(int begIdx,
int endIdx)
|
java.lang.String |
toLowerCase()
|
java.lang.String |
toUpperCase()
|
java.lang.String |
trim()
|
java.lang.String |
value()
Get the value of this string. |
void |
writeExternal(java.io.ObjectOutput out)
Derived class that implements Externalizable must
call this if it overrides it. |
Methods inherited from class oscript.data.OObject |
getMember, populateMemberSet |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final Value TYPE
public static final java.lang.String PARENT_TYPE_NAME
public static final java.lang.String TYPE_NAME
public static final java.lang.String[] MEMBER_NAMES
Constructor Detail |
public OString()
public OString(java.lang.String stringVal)
stringVal
- the value of the stringpublic OString(MemberTable args)
BuiltinType
instance.
args
- arguments to this constructor
PackagedScriptObjectException(Exception)
- if wrong number of argsMethod Detail |
public void readExternal(java.io.ObjectInput in) throws java.io.IOException
Externalizable
must
call this if it overrides it. It should override it to save/restore
it's own state.
readExternal
in interface java.io.Externalizable
readExternal
in class Value
java.io.IOException
public void writeExternal(java.io.ObjectOutput out) throws java.io.IOException
Externalizable
must
call this if it overrides it. It should override it to save/restore
it's own state.
writeExternal
in interface java.io.Externalizable
writeExternal
in class Value
java.io.IOException
protected Value getTypeImpl()
Value.getType()
.
getTypeImpl
in class OObject
public final java.lang.String value()
public int hashCode()
Object.hashCode()
public OString intern()
x.intern() == y.intern()
(for x
and y
that are OString objects).
equals
) but is guaraneed to be from a unique pool of OStringspublic boolean equals(java.lang.Object obj)
obj
- the object to compare to this object
true
if equals, else false
Object.equals(java.lang.Object)
public boolean castToBoolean() throws PackagedScriptObjectException
boolean
value.
castToBoolean
in class Value
PackagedScriptObjectException(NoSuchMethodException)
PackagedScriptObjectException
public java.lang.String castToString() throws PackagedScriptObjectException
String
value.
castToString
in class OObject
PackagedScriptObjectException(NoSuchMethodException)
PackagedScriptObjectException
public static Value _bopCast(Value val)
public long castToExactNumber() throws PackagedScriptObjectException
long
value. In order
for a string to be converted to an exact number, it must be of the
form:
STRING ::== ("-")? (HEX_STRING | OCTAL_STRING | DEC_STRING) HEX_STRING ::== ("0x" | "0X") ([0-9] | [a-f] | [A-F])+ OCTAL_STRING ::== "0" ([0-7])+ DEC_STRING ::== ([0-9])+
castToExactNumber
in class Value
PackagedScriptObjectException(NoSuchMethodException)
PackagedScriptObjectException
public double castToInexactNumber() throws PackagedScriptObjectException
double
value. In
order for a string to be converted to an inexact number, it must be
of the form:
STRING ::== ("+" | "-")? EXACT_NUMBER ("." EXACT_NUMBER)? (("e" | "E") EXACT_NUMBER)? EXACT_NUMBER ::==
castToInexactNumber
in class Value
PackagedScriptObjectException(NoSuchMethodException)
PackagedScriptObjectException
public java.lang.Object castToJavaObject() throws PackagedScriptObjectException
Object
value.
castToJavaObject
in class Value
PackagedScriptObjectException(NoSuchMemberException)
PackagedScriptObjectException
public Value bopEquals(Value val) throws PackagedScriptObjectException
bopEquals
in class Value
val
- the other value
PackagedScriptObjectException(NoSuchMethodException)
PackagedScriptObjectException
public Value bopEqualsR(Value val, PackagedScriptObjectException e) throws PackagedScriptObjectException
bopEqualsR
in class Value
PackagedScriptObjectException
public Value bopNotEquals(Value val) throws PackagedScriptObjectException
bopNotEquals
in class Value
val
- the other value
PackagedScriptObjectException(NoSuchMethodException)
PackagedScriptObjectException
public Value bopNotEqualsR(Value val, PackagedScriptObjectException e) throws PackagedScriptObjectException
bopNotEqualsR
in class Value
PackagedScriptObjectException
public Value bopLessThan(Value val) throws PackagedScriptObjectException
bopLessThan
in class Value
val
- the other value
PackagedScriptObjectException(NoSuchMethodException)
PackagedScriptObjectException
public Value bopLessThanR(Value val, PackagedScriptObjectException e) throws PackagedScriptObjectException
bopLessThanR
in class Value
PackagedScriptObjectException
public Value bopGreaterThan(Value val) throws PackagedScriptObjectException
bopGreaterThan
in class Value
val
- the other value
PackagedScriptObjectException(NoSuchMethodException)
PackagedScriptObjectException
public Value bopGreaterThanR(Value val, PackagedScriptObjectException e) throws PackagedScriptObjectException
bopGreaterThanR
in class Value
PackagedScriptObjectException
public Value bopLessThanOrEquals(Value val) throws PackagedScriptObjectException
bopLessThanOrEquals
in class Value
val
- the other value
PackagedScriptObjectException(NoSuchMethodException)
PackagedScriptObjectException
public Value bopLessThanOrEqualsR(Value val, PackagedScriptObjectException e) throws PackagedScriptObjectException
bopLessThanOrEqualsR
in class Value
PackagedScriptObjectException
public Value bopGreaterThanOrEquals(Value val) throws PackagedScriptObjectException
bopGreaterThanOrEquals
in class Value
val
- the other value
PackagedScriptObjectException(NoSuchMethodException)
PackagedScriptObjectException
public Value bopGreaterThanOrEqualsR(Value val, PackagedScriptObjectException e) throws PackagedScriptObjectException
bopGreaterThanOrEqualsR
in class Value
PackagedScriptObjectException
public Value bopPlus(Value val) throws PackagedScriptObjectException
bopPlus
in class Value
val
- the other value
PackagedScriptObjectException(NoSuchMethodException)
PackagedScriptObjectException
public Value bopPlusR(Value val, PackagedScriptObjectException e) throws PackagedScriptObjectException
bopPlusR
in class Value
PackagedScriptObjectException
public int length() throws PackagedScriptObjectException
elementAt
, this returns the
number of elements. This is the same as the length property
of an object.
length
in class Value
PackagedScriptObjectException(NoSuchMethodException)
PackagedScriptObjectException
elementAt(oscript.data.Value)
public Value elementAt(Value oidx) throws PackagedScriptObjectException
elementAt
in class Value
oidx
- the index to get
PackagedScriptObjectException(NoSuchMethodException)
PackagedScriptObjectException
length()
public Value elementsAt(Value idx1, Value idx2) throws PackagedScriptObjectException
elementsAt
in class Value
idx1
- the index index of the beginning of the range, inclusiveidx2
- the index of the end of the range, inclusive
PackagedScriptObjectException(NoSuchMemberException)
PackagedScriptObjectException
length()
,
elementAt(oscript.data.Value)
public Value match(Value regexp)
regexp.exec(this)
. The
regexp
should either be a RegExp
object
or a string that can be compiled to a RegExp
object.
Note: this API is modeled after the JavaScript RegExp API, for the benefit of users already familiar with JavaScript.
regexp
- the regular expression
regexp.exec
.public Value replace(Value regexp, Value strOrFxn)
If the second parameter is a string, the following replacement patterns are evaluated and replaced with the appropriate value:
pattern | Description |
---|---|
$$ | Inserts a $ |
$& | Inserts the matched substring |
$` | Inserts the portion of the string that precedes the matched substring |
$' | Inserts the portion of the string that follows the matched substring |
$ n | Inserts the nth parenthesized submatch string |
param | Description |
---|---|
0 | the matched string |
1-n | zero or more parameters for parenthetical matches |
n+1 | offset of match |
n+2 | the original string |
Note: this API is modeled after the JavaScript RegExp API, for the benefit of users already familiar with JavaScript.
regexp
- the regular expressionstrOrFxn
- replacement string or function
public Value search(Value regexp)
Note: this API is modeled after the JavaScript RegExp API, for the benefit of users already familiar with JavaScript.
regexp
- the regular expression
-1
if nonepublic java.lang.String substring(int begIdx)
public java.lang.String substring(int begIdx, int endIdx)
public int indexOf(java.lang.String str)
public int indexOf(java.lang.String str, int fromIdx)
public int lastIndexOf(java.lang.String str)
public int lastIndexOf(java.lang.String str, int fromIdx)
public java.lang.String toUpperCase()
public java.lang.String toLowerCase()
public boolean startsWith(java.lang.String str)
public boolean endsWith(java.lang.String str)
public java.lang.String trim()
public static final OString makeString(java.lang.String str)
public static final java.lang.String chop(java.lang.String str)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |