| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
import org.mozilla.javascript.*; |
| 8 |
import org.mozilla.javascript.annotations.JSFunction; |
| 9 |
import org.mozilla.javascript.annotations.JSConstructor; |
| 10 |
import org.mozilla.javascript.annotations.JSGetter; |
| 11 |
|
| 12 |
public class Counter extends ScriptableObject { |
| 13 |
private static final long serialVersionUID = 438270592527335642L; |
| 14 |
|
| 15 |
|
| 16 |
public Counter() { } |
| 17 |
|
| 18 |
|
| 19 |
@JSConstructor |
| 20 |
public Counter(int a) { count = a; } |
| 21 |
|
| 22 |
|
| 23 |
@Override |
| 24 |
public String getClassName() { return "Counter"; } |
| 25 |
|
| 26 |
|
| 27 |
@JSGetter |
| 28 |
public int getCount() { return count++; } |
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
@JSFunction |
| 33 |
public void resetCount() { count = 0; } |
| 34 |
|
| 35 |
private int count; |
| 36 |
} |