01: /* -*- mode: Java; c-basic-offset: 2; -*- */
02:
03: /**
04: * Javascript Class representation
05: *
06: * @author ptw@openlaszlo.org
07: */package org.openlaszlo.sc;
08:
09: import java.util.*;
10:
11: public class ScriptClass {
12: String name;
13: String super class;
14: Map attributes;
15:
16: public ScriptClass(String name, String super class, Map attributes) {
17: this .name = name;
18: this .super class = super class;
19: this .attributes = attributes;
20: }
21:
22: public String toString() {
23: String str = "class "
24: + name
25: + (super class != null ? (" extends " + super class) : "")
26: + "{\n";
27: for (Iterator i = attributes.entrySet().iterator(); i.hasNext();) {
28: Map.Entry entry = (Map.Entry) i.next();
29: String name = (String) entry.getKey();
30: Object value = entry.getValue();
31: if (value instanceof Function) {
32: Function fn = (Function) value;
33: fn.setName(name);
34: str += value.toString();
35: str += "\n";
36: } else {
37: str += "var " + name + " = " + value.toString() + ";\n";
38: }
39: }
40: str += "}\n";
41: return str;
42: }
43: }
44:
45: /**
46: * @copyright Copyright 2006-2007 Laszlo Systems, Inc. All Rights
47: * Reserved. Use is subject to license terms.
48: */
|