FreeWRL / FreeX3D 4.3.0
FreeWRLField.java
1package sai;
2import org.web3d.x3d.sai.*;
3
4public class FreeWRLField implements X3DField {
5 String RLreturn;
6 String command;
7 String node;
8 String dataType;
9 String nodePtr;
10 String offset;
11 String datasize;
12 String scripttype;
13 boolean disposed;
14
15 protected FreeWRLFieldDefinition fieldDef;
16 protected Object userData;
17 protected FreeWRLBrowser browser;
18
20 fieldDef = def;
21 userData = null;
22 browser = b;
23 disposed = false;
24 }
25
26 public String toString() {
27 String str;
28 str = new String("Field with command " + command + " for node " + node);
29 return str;
30 }
31
33 checkValid();
34 return fieldDef;
35 }
36 public boolean isReadable() throws InvalidFieldException, ConnectionException {
37 checkValid();
38 int type = fieldDef.getAccessType();
39 if ((type == FreeWRLFieldTypes.INPUT_OUTPUT) || (type == FreeWRLFieldTypes.OUTPUT_ONLY))
40 return true;
41 else
42 return false;
43 }
44 public boolean isWritable() throws InvalidFieldException, ConnectionException {
45 checkValid();
46 int type = fieldDef.getAccessType();
47 if ((type == FreeWRLFieldTypes.INPUT_OUTPUT) || (type == FreeWRLFieldTypes.INPUT_ONLY))
48 return true;
49 else
50 return false;
51 }
52 public void addX3DEventListener (X3DFieldEventListener l) throws ConnectionException, InvalidFieldException {
53 int evType;
54 checkValid();
55 evType = fieldDef.getFieldType();
56 browser.RegisterListener(l, (Object) userData, nodePtr, offset, dataType, datasize, evType);
57 }
58
59 public void removeX3DEventListener(X3DFieldEventListener l) throws ConnectionException, InvalidFieldException {
60 int evType;
61 checkValid();
62 evType = fieldDef.getFieldType();
63 browser.unRegisterListener(l, nodePtr, offset, dataType, datasize, evType);
64 }
65
66 public void setUserData(Object data) throws InvalidFieldException, ConnectionException {
67 checkValid();
68 userData = data;
69 }
70
71 public Object getUserData() throws InvalidFieldException, ConnectionException {
72 checkValid();
73 return userData;
74 }
75
76 public void dispose() {
77 disposed = true;
78 }
79
80 public void checkValid() {
81 if (disposed) {
82 throw new InvalidFieldException("This field has been disposed");
83 }
84 }
85
86 public void setCommand(String com) {
87 command = com;
88 }
89
90 public void setNode(String nod) {
91 node = nod;
92 }
93
94 public void setDataType (String dt) {
95 dataType = dt;
96 }
97
98 public void setNodePtr(String np) {
99 nodePtr = np;
100 }
101
102 public void setOffset(String off) {
103 offset = off;
104 }
105
106 public void setDataSize(String ds) {
107 datasize = ds;
108 }
109
110 public void setScriptType(String st) {
111 scripttype = st;
112 }
113
114 public String getDataSize() {
115 return datasize;
116 }
117
118 public String getScriptType() {
119 return scripttype;
120 }
121
122 public String getCommand() {
123 return command;
124 }
125
126 public String getNode() {
127 return node;
128 }
129
130 public String getDataType() {
131 return dataType;
132 }
133
134 public String getNodePtr() {
135 return nodePtr;
136 }
137
138 public String getOffset() {
139 return offset;
140 }
141}