| 1 |
import java.applet.Applet; |
| 2 |
import java.lang.reflect.Array; |
| 3 |
import java.lang.reflect.Field; |
| 4 |
import netscape.javascript.JSObject; |
| 5 |
|
| 6 |
public class JSToJSet extends Applet { |
| 7 |
|
| 8 |
public int _int; |
| 9 |
public double _double; |
| 10 |
public float _float; |
| 11 |
public long _long; |
| 12 |
public boolean _boolean; |
| 13 |
public char _char; |
| 14 |
public byte _byte; |
| 15 |
public String _String; |
| 16 |
public String _specialString; |
| 17 |
public Object _Object = new String("non-null object"); |
| 18 |
public int[] _intArray = new int[1]; |
| 19 |
public Integer _Integer; |
| 20 |
public Double _Double; |
| 21 |
public Float _Float; |
| 22 |
public Long _Long; |
| 23 |
public Boolean _Boolean; |
| 24 |
public Character _Character = 'B'; |
| 25 |
public Byte _Byte; |
| 26 |
public Double[] _DoubleArray = new Double[10]; |
| 27 |
public Double[] _DoubleArray2; |
| 28 |
public char[] _charArray = new char[1]; |
| 29 |
public Character[] _CharacterArray = new Character[1]; |
| 30 |
public JSObject _JSObject; |
| 31 |
|
| 32 |
public void init() { |
| 33 |
String initStr = "JSToJSet applet initialized."; |
| 34 |
System.out.println(initStr); |
| 35 |
} |
| 36 |
|
| 37 |
public void printNewValueAndFinish(String fieldname) throws Exception { |
| 38 |
|
| 39 |
Field field = getClass().getDeclaredField(fieldname); |
| 40 |
Object value = field.get(this); |
| 41 |
System.out.println("Old value is: " + value); |
| 42 |
|
| 43 |
if (fieldname.equals("_JSObject")) { |
| 44 |
Integer mph = (Integer) _JSObject.getMember("mph"); |
| 45 |
String color = (String) _JSObject.getMember("color"); |
| 46 |
System.out.println("New value is: " + mph + ", " + color); |
| 47 |
} else if (value != null && value.getClass().isArray()) { |
| 48 |
System.out.println("New array value is: " + Array.get(value, 0)); |
| 49 |
} else { |
| 50 |
System.out.println("New value is: " + value); |
| 51 |
} |
| 52 |
System.out.println("afterTests"); |
| 53 |
} |
| 54 |
} |