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