The easiest way would be just invoking  
ScriptRuntime.defaultObjectToSource()

Other than that, your problem here is that you're converting propid to  
String. What you should do instead in the loop is:

...
Object propValue;
if(propid instanceof String) {
     propValue = ScriptableObject.getProperty(scriptable,  
(String)propid);
}
else if(propid instanceof Number) {
     propValue = ScriptableObject.getProperty(scriptable,  
((Number)propid).intValue());
}
else {
     continue; // or throw an exception
}
builder.append(propid);
builder.append(':');
builder.append(Context.toString(propValue));
...

Attila.

On 2007.11.24., at 1:56, Benson Margulies wrote:

> I see. I've coped with an Eclipse-compatible function that dumps the
> properties of object.
>
> However, I seem to have tied myself into a bit of a prezel writing it.
> Outlook express is making the following look silly, I apologize.  
> Should I
> use js evaluation to grab these properties? It seems so nearly  
> possible from
> the API except for the string versus number type issue.
>
> public static String scriptableToString(Scriptable scriptable) {
>
> StringBuilder builder = new StringBuilder();
>
> for (Object propid : scriptable.getIds()) {
>
> String propIdString = Context.toString(propid);
>
> String propValue = Context.toString(scriptable.get(propIdString,
> scriptable));
>
> builder.append(propIdString);
>
> builder.append(": ");
>
> builder.append(propValue);
>
> builder.append("; ");
>
> }
>
> return builder.toString();
>
> }
>
>
> 0: [EMAIL PROTECTED]: NOT_FOUND; 1:
> [EMAIL PROTECTED]: NOT_FOUND; 2:
> [EMAIL PROTECTED]: NOT_FOUND;
>
>
> _______________________________________________
> dev-tech-js-engine-rhino mailing list
> [email protected]
> https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino

Attila.

--
home: http://www.szegedi.org
weblog: http://constc.blogspot.com



_______________________________________________
dev-tech-js-engine-rhino mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino

Reply via email to