FreeWRL/FreeX3D  3.0.0
FWCreateField.java
1 // the type number identificators are in CFuncs/headers.h
2 package vrml;
3 import vrml.field.*;
4 
5 public class FWCreateField {
6 
7  public static Field createField(String type) {
8  type = type.intern();
9 
10  if (type =="1") return new SFBool();
11  else if (type =="2") return new SFColor();
12  else if (type =="3") return new SFFloat();
13  else if (type =="4") return new SFTime();
14  else if (type =="5") return new SFInt32();
15  else if (type =="6") return new SFString();
16  else if (type =="7") return new SFNode();
17  else if (type =="8") return new SFRotation();
18  else if (type =="9") return new SFVec2f();
19  else if (type =="10") return new SFImage();
20  else if (type =="11") return new MFColor();
21  else if (type =="12") return new MFFloat();
22  else if (type =="13") return new MFTime();
23  else if (type =="14") return new MFInt32();
24  else if (type =="15") return new MFString();
25  else if (type =="16") return new MFNode();
26  else if (type =="17") return new MFRotation();
27  else if (type =="18") return new MFVec2f();
28  else if (type =="19") return new MFVec3f();
29  else if (type =="20") return new SFVec3f();
30  else
31  throw new IllegalArgumentException("Unknown field type "+type);
32  }
33 
34  public static ConstField createConstField(String type) {
35 
36  type = type.intern();
37  if (type =="1") return new ConstSFBool();
38  else if (type =="2") return new ConstSFColor();
39  else if (type =="3") return new ConstSFFloat();
40  else if (type =="4") return new ConstSFTime();
41  else if (type =="5") return new ConstSFInt32();
42  else if (type =="6") return new ConstSFString();
43  else if (type =="7") return new ConstSFNode();
44  else if (type =="8") return new ConstSFRotation();
45  else if (type =="9") return new ConstSFVec2f();
46  else if (type =="10") return new ConstSFImage();
47  else if (type =="11") return new ConstMFColor();
48  else if (type =="12") return new ConstMFFloat();
49  else if (type =="13") return new ConstMFTime();
50  else if (type =="14") return new ConstMFInt32();
51  else if (type =="15") return new ConstMFString();
52  else if (type =="16") return new ConstMFNode();
53  else if (type =="17") return new ConstMFRotation();
54  else if (type =="18") return new ConstMFVec2f();
55  else if (type =="19") return new ConstMFVec3f();
56  else if (type =="20") return new ConstSFVec3f();
57  else
58  throw new IllegalArgumentException("Unknown field type "+type);
59  }
60 }