FreeWRL/FreeX3D  3.0.0
VMFString.java
1 // copyright (c) 1997,1998 stephen f. white
2 //
3 // This program is free software; you can redistribute it and/or modify
4 // it under the terms of the GNU General Public License as published by
5 // the Free Software Foundation; either version 2, or (at your option)
6 // any later version.
7 //
8 // This program is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License
14 // along with this program; see the file COPYING. If not, write to
15 // the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
16 
17 package sai.eai;
18 
19 import java.io.*;
20 
21 public class VMFString extends VField
22 {
23  private String[] strings;
24 
25  public VMFString(DataInputStream in) throws IOException
26  {
27  strings = new String[in.readInt()];
28  for (int i = 0; i < strings.length; i++) {
29  strings[i] = in.readUTF();
30  }
31  }
32 
33  public VMFString(String[] strings) {
34  this.strings = strings;
35  }
36 
37  public void write(DataOutputStream out) throws IOException
38  {
39  out.writeInt(strings.length);
40  for (int i = 0; i < strings.length; i++) {
41  out.writeUTF(strings[i]);
42  }
43  }
44 
45  public byte getType() { return MFSTRING; }
46 
47  public String[] getValue() { return strings; }
48  public String get1Value(int pos) { return strings[pos]; }
49 
50  public String toString() {
51  String str = "{";
52  for (int i = 0; i < strings.length; i++) {
53  if (i != 0) str += ", ";
54  str += "\"" + strings[i] + "\"";
55  }
56  str += "}";
57  return str;
58  }
59 }