1999-05-20 00:14:26 +00:00
|
|
|
class JSString extends JSValue {
|
|
|
|
|
|
|
|
JSString(String p)
|
|
|
|
{
|
|
|
|
s = p;
|
|
|
|
}
|
|
|
|
|
1999-05-28 19:00:48 +00:00
|
|
|
JSValue eval(Environment theEnv)
|
1999-05-20 00:14:26 +00:00
|
|
|
{
|
1999-05-28 19:00:48 +00:00
|
|
|
return this;
|
1999-05-20 00:14:26 +00:00
|
|
|
}
|
|
|
|
|
1999-05-28 19:00:48 +00:00
|
|
|
JSValue typeof(Environment theEnv) {
|
|
|
|
return new JSString("string");
|
1999-05-25 21:49:40 +00:00
|
|
|
}
|
|
|
|
|
1999-05-28 19:00:48 +00:00
|
|
|
JSValue add(Environment theEnv, JSValue rV)
|
1999-05-20 21:16:11 +00:00
|
|
|
{
|
1999-05-28 19:00:48 +00:00
|
|
|
return new JSString(s + rV.toJSString(theEnv).s);
|
1999-05-20 21:16:11 +00:00
|
|
|
}
|
1999-05-21 00:54:26 +00:00
|
|
|
|
1999-05-28 19:00:48 +00:00
|
|
|
JSValue gt(Environment theEnv, JSValue rV) {
|
|
|
|
if (rV instanceof JSString)
|
|
|
|
return (s.compareTo(rV.toJSString(theEnv).s) == 1) ? JSBoolean.JSTrue : JSBoolean.JSFalse;
|
1999-05-21 00:54:26 +00:00
|
|
|
else
|
1999-05-28 19:00:48 +00:00
|
|
|
return toJSDouble(theEnv).gt(theEnv, rV);
|
1999-05-21 00:54:26 +00:00
|
|
|
}
|
|
|
|
|
1999-05-28 19:00:48 +00:00
|
|
|
JSValue ge(Environment theEnv, JSValue rV) {
|
|
|
|
if (rV instanceof JSString)
|
|
|
|
return (s.compareTo(rV.toJSString(theEnv).s) != -1) ? JSBoolean.JSTrue : JSBoolean.JSFalse;
|
1999-05-21 00:54:26 +00:00
|
|
|
else
|
1999-05-28 19:00:48 +00:00
|
|
|
return toJSDouble(theEnv).ge(theEnv, rV);
|
1999-05-21 00:54:26 +00:00
|
|
|
}
|
1999-05-20 21:16:11 +00:00
|
|
|
|
1999-05-28 19:00:48 +00:00
|
|
|
JSValue lt(Environment theEnv, JSValue rV) {
|
|
|
|
if (rV instanceof JSString)
|
|
|
|
return (s.compareTo(rV.toJSString(theEnv).s) == -1) ? JSBoolean.JSTrue : JSBoolean.JSFalse;
|
1999-05-21 00:54:26 +00:00
|
|
|
else
|
1999-05-28 19:00:48 +00:00
|
|
|
return toJSDouble(theEnv).lt(theEnv, rV);
|
1999-05-21 00:54:26 +00:00
|
|
|
}
|
|
|
|
|
1999-05-28 19:00:48 +00:00
|
|
|
JSValue le(Environment theEnv, JSValue rV) {
|
|
|
|
if (rV instanceof JSString)
|
|
|
|
return (s.compareTo(rV.toJSString(theEnv).s) != 1) ? JSBoolean.JSTrue : JSBoolean.JSFalse;
|
1999-05-21 00:54:26 +00:00
|
|
|
else
|
1999-05-28 19:00:48 +00:00
|
|
|
return toJSDouble(theEnv).le(theEnv, rV);
|
1999-05-21 00:54:26 +00:00
|
|
|
}
|
|
|
|
|
1999-05-28 19:00:48 +00:00
|
|
|
JSValue eq(Environment theEnv, JSValue rV) {
|
|
|
|
if (rV instanceof JSString)
|
|
|
|
return (s.compareTo(rV.toJSString(theEnv).s) == 0) ? JSBoolean.JSTrue : JSBoolean.JSFalse;
|
1999-05-21 00:54:26 +00:00
|
|
|
else
|
1999-05-28 19:00:48 +00:00
|
|
|
return toJSDouble(theEnv).eq(theEnv, rV);
|
1999-05-21 00:54:26 +00:00
|
|
|
}
|
|
|
|
|
1999-05-28 19:00:48 +00:00
|
|
|
JSValue ne(Environment theEnv, JSValue rV) {
|
|
|
|
if (rV instanceof JSString)
|
|
|
|
return (s.compareTo(rV.toJSString(theEnv).s) != 0) ? JSBoolean.JSTrue : JSBoolean.JSFalse;
|
1999-05-21 00:54:26 +00:00
|
|
|
else
|
1999-05-28 19:00:48 +00:00
|
|
|
return toJSDouble(theEnv).ne(theEnv, rV);
|
1999-05-21 00:54:26 +00:00
|
|
|
}
|
|
|
|
|
1999-05-26 01:01:07 +00:00
|
|
|
JSDouble toJSDouble(Environment theEnv) {
|
1999-05-21 00:54:26 +00:00
|
|
|
return new JSDouble(s); // XXX Way More To Do, see Rhino ScriptRuntime.java
|
|
|
|
}
|
|
|
|
|
1999-05-26 01:01:07 +00:00
|
|
|
JSString toJSString(Environment theEnv) {
|
1999-05-21 00:54:26 +00:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
1999-05-26 01:01:07 +00:00
|
|
|
JSValue toPrimitive(Environment theEnv, String hint) {
|
1999-05-20 21:16:11 +00:00
|
|
|
return this;
|
|
|
|
}
|
1999-05-20 00:14:26 +00:00
|
|
|
|
1999-05-26 01:01:07 +00:00
|
|
|
String print(String indent)
|
|
|
|
{
|
|
|
|
return indent + "JSString : " + s + "\n";
|
|
|
|
}
|
|
|
|
|
1999-05-25 21:49:40 +00:00
|
|
|
protected String s;
|
1999-05-20 00:14:26 +00:00
|
|
|
|
|
|
|
}
|