FreeWRL/FreeX3D  3.0.0
EventOutMFString.java
1 package vrml.external.field;
2 import java.util.*;
5 
6 
7 public class EventOutMFString extends EventOutMField {
8  // retstr is an array of string values.
9  // mySize is the size of retstr.
10 
11  String[] retstr;
12  int mySize = 0;
13  String[] spl;
14 
15  public EventOutMFString() {EventType = FieldTypes.MFSTRING;}
16 
17  public String[] getValue() {
18  String rep;
19 
20  if (command != null) {
21  rep = Browser.SendEventOut (nodeptr, offset, datasize, datatype, command);
22  // System.out.println ("rep is " + rep);
23  spl = rep.split("\"",0);
24  } else {
25  spl = RLreturn.split("\"",0);
26  }
27 
28  /*
29  System.out.println ("token count is " +
30  (tokens.countTokens());
31 
32  System.out.println ("split len is " + spl.length);
33 
34  for (int i = 0; i < spl.length; i++) {
35  System.out.println ("element " + i + " is " + spl[i]);
36  }
37  */
38  /*
39  rep is "kiwano.wrl" "TinMan.wrl" "Angel.wrl" "halfmoon.wrl" ""
40  token count is 4
41  split len is 11
42  element 0 is
43  element 1 is kiwano.wrl
44  element 2 is
45  element 3 is TinMan.wrl
46  element 4 is
47  element 5 is Angel.wrl
48  element 6 is
49  element 7 is halfmoon.wrl
50  element 8 is
51  element 9 is
52  */
53 
54  mySize = spl.length;
55  retstr = new String[mySize];
56  //System.out.println ("sizeof is " + mySize);
57  for (int i=1; i<spl.length; i++) {
58  retstr[i] = spl[i];
59  //System.out.println ("string " + i + " value: " + retstr[i]);
60  }
61  return retstr;
62  }
63 
64  public String get1Value(int index) {
65  if ((index > mySize) || (index < 0)) {
66  System.out.println ("EventOutMFString.get1Value - index " + index +
67  " out of range");
68  index = 0;
69  }
70  return retstr[index];
71  }
72 }