FreeWRL/FreeX3D  3.0.0
FWMFInt32.java
1 package sai;
2 import org.web3d.x3d.sai.*;
3 import java.util.*;
4 
5 public class FWMFInt32 extends FreeWRLMField implements MFInt32 {
6  FreeWRLBrowser browser;
7  private static final int ROWS = 1;
8 
10  super(def, b);
11  browser = b;
12  }
13 
14  public void getValue(int[] values) throws ArrayIndexOutOfBoundsException {
15  int lines;
16  int count1;
17  StringTokenizer tokens;
18  String rep;
19 
20  if (RLreturn == null) {
21  rep = browser.SendEventOut(nodePtr, offset, datasize, dataType, command);
22  } else {
23  rep = RLreturn;
24  }
25 
26  tokens = new StringTokenizer(rep);
27  lines = Integer.valueOf(tokens.nextToken()).intValue();
28 
29  if (values.length < lines) {
30  throw new ArrayIndexOutOfBoundsException("MFInt32 getValue passed array of insufficient size");
31  }
32 
33  for (count1=0; count1 < lines; count1++) {
34  values[count1] = Integer.valueOf(tokens.nextToken()).intValue();
35  }
36  }
37 
38  public int get1Value(int index) throws ArrayIndexOutOfBoundsException {
39  int lines;
40  int count1;
41  StringTokenizer tokens;
42  String rep;
43  int[] rval;
44 
45  if (RLreturn == null) {
46  rep = browser.SendEventOut(nodePtr, offset, datasize, dataType, command);
47  } else {
48  rep = RLreturn;
49  }
50 
51  tokens = new StringTokenizer(rep);
52  lines = Integer.valueOf(tokens.nextToken()).intValue();
53 
54  rval = new int[lines];
55 
56  if (index > lines) {
57  throw new ArrayIndexOutOfBoundsException("MFInt32 get1Value passed index out of bounds");
58  }
59 
60  for (count1=0; count1 < lines; count1++) {
61  rval[count1] = Integer.valueOf(tokens.nextToken()).intValue();
62  }
63  return rval[index];
64  }
65 
66  public void setValue(int size, int[] value) {
67  int count;
68  String val;
69 
70  if (size > value.length) {
71  size = value.length;
72  }
73 
74  val = " " + size;
75 
76  for (count = 0; count < size; count++) {
77  val = val + " " + value[count];
78  }
79  browser.newSendEvent(this, val);
80  }
81 
82  public void set1Value(int index, int value) throws ArrayIndexOutOfBoundsException {
83  browser.newSendEvent(this, " ONEVAL " + index + " " + value);
84  }
85 
86  public void append(int[] value) {
87  int lines;
88  int append_size;
89  int count1, count2;
90  StringTokenizer tokens;
91  String rep;
92  String val;
93 
94  if (RLreturn == null) {
95  rep = browser.SendEventOut(nodePtr, offset, datasize, dataType, command);
96  } else {
97  rep = RLreturn;
98  }
99 
100  tokens = new StringTokenizer(rep);
101  lines = Integer.valueOf(tokens.nextToken()).intValue();
102 
103  append_size = value.length;
104 
105  val = " " + (lines + append_size);
106 
107  for (count1 = 0; count1 < lines; count1++) {
108  val = val + tokens.nextToken();
109  }
110 
111  for (count1 = 0; count1 < append_size; count1++) {
112  val = val + " " + value[count1];
113  }
114 
115  browser.newSendEvent(this, val);
116  }
117  public void insertValue(int index, int[] value) {
118  int lines;
119  int insert_size;
120  int count1, count2;
121  StringTokenizer tokens;
122  String rep;
123  String val;
124 
125  if (RLreturn == null) {
126  rep = browser.SendEventOut(nodePtr, offset, datasize, dataType, command);
127  } else {
128  rep = RLreturn;
129  }
130 
131  tokens = new StringTokenizer(rep);
132  lines = Integer.valueOf(tokens.nextToken()).intValue();
133 
134  insert_size = value.length;
135 
136  if ((index > lines) || (index < 0)) {
137  throw new ArrayIndexOutOfBoundsException("MFInt32 insertValue passed index out of bounds");
138  }
139 
140  val = " " + (lines + insert_size);
141 
142  for (count1 = 0; count1 < index; count1++) {
143  val = val + tokens.nextToken();
144  }
145 
146  for (count1 = 0; count1 < insert_size; count1++) {
147  val = val + " " + value[count1];
148  }
149 
150  for (count1 = index; count1 < lines; count1++) {
151  val = val + tokens.nextToken();
152  }
153 
154  browser.newSendEvent(this, val);
155  }
156 }