001: /*
002: * $RCSfile: MFString.java,v $
003: *
004: * @(#)MFString.java 1.18 99/03/24 15:33:57
005: *
006: * Copyright (c) 1996-1998 Sun Microsystems, Inc. All Rights Reserved.
007: *
008: * Sun grants you ("Licensee") a non-exclusive, royalty free, license to use,
009: * modify and redistribute this software in source and binary code form,
010: * provided that i) this copyright notice and license appear on all copies of
011: * the software; and ii) Licensee does not utilize the software in a manner
012: * which is disparaging to Sun.
013: *
014: * This software is provided "AS IS," without a warranty of any kind. ALL
015: * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY
016: * IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
017: * NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE
018: * LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING
019: * OR DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS
020: * LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT,
021: * INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER
022: * CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF
023: * OR INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
024: * POSSIBILITY OF SUCH DAMAGES.
025: *
026: * This software is not designed or intended for use in on-line control of
027: * aircraft, air traffic, aircraft navigation or aircraft communications; or in
028: * the design, construction, operation or maintenance of any nuclear
029: * facility. Licensee represents and warrants that it will not use or
030: * redistribute the Software for such purposes.
031: * $Revision: 1.2 $
032: * $Date: 2005/02/03 23:06:58 $
033: * $State: Exp $
034: */
035: /*
036: * @Author: Rick Goldberg
037: * @Author: Doug Gehringer
038: *
039: */
040: package org.jdesktop.j3d.loaders.vrml97.impl;
041:
042: import java.util.Observable;
043: import java.util.Observer;
044:
045: /** Description of the Class */
046: public class MFString extends MField {
047:
048: String[] strings;
049:
050: /**Constructor for the MFString object */
051: public MFString() {
052: strings = new String[0];
053: }
054:
055: /**
056: *Constructor for the MFString object
057: *
058: *@param s Description of the Parameter
059: */
060: public MFString(String[] s) {
061: strings = new String[s.length];
062: for (int i = 0; i < s.length; i++) {
063: strings[i] = new String(s[i]);
064: }
065: }
066:
067: /**
068: *Constructor for the MFString object
069: *
070: *@param size Description of the Parameter
071: *@param s Description of the Parameter
072: */
073: public MFString(int size, String[] s) {
074: strings = new String[size];
075: for (int i = 0; i < size; i++) {
076: strings[i] = new String(s[i]);
077: }
078: }
079:
080: /**
081: * Sets the value attribute of the MFString object
082: *
083: *@param s The new value value
084: */
085: public void setValue(String[] s) {
086: strings = new String[s.length];
087: for (int i = 0; i < s.length; i++) {
088: strings[i] = new String(s[i]);
089: }
090: }
091:
092: /**
093: * Sets the value attribute of the MFString object
094: *
095: *@param field The new value value
096: */
097: public void setValue(MFString field) {
098: setValue(field.strings);
099: }
100:
101: /**
102: * Sets the value attribute of the MFString object
103: *
104: *@param field The new value value
105: */
106: public void setValue(ConstMFString field) {
107: setValue((MFString) field.ownerField);
108: }
109:
110: /**
111: * Gets the value attribute of the MFString object
112: *
113: *@param values Description of the Parameter
114: */
115: public void getValue(String[] values) {
116: try {
117: for (int i = 0; i < strings.length; i++) {
118: values[i] = strings[i];
119: }
120: } catch (ArrayIndexOutOfBoundsException e) {
121: System.out
122: .println(" string array lengths must match better ");
123: }
124: }
125:
126: /**
127: * Description of the Method
128: *
129: *@param index Description of the Parameter
130: *@return Description of the Return Value
131: */
132: public String get1Value(int index) {
133: String retval = "";
134: try {
135: retval = strings[index];
136: } catch (ArrayIndexOutOfBoundsException e) {
137: e.printStackTrace();
138: }
139: return retval;
140: }
141:
142: /**
143: * Description of the Method
144: *
145: *@param field Description of the Parameter
146: */
147: public void update(Field field) {
148: setValue((MFString) field);
149: }
150:
151: /**
152: * Description of the Method
153: *
154: *@return Description of the Return Value
155: */
156: public ConstField constify() {
157: if (constField == null) {
158: constField = new ConstMFString(this );
159: }
160: return constField;
161: }
162:
163: /**
164: * Description of the Method
165: *
166: *@return Description of the Return Value
167: */
168: public Object clone() {
169: MFString ref = new MFString(strings);
170: return ref;
171: }
172:
173: /**
174: * Gets the size attribute of the MFString object
175: *
176: *@return The size value
177: */
178: public int getSize() {
179: return strings.length;
180: }
181:
182: /** Description of the Method */
183: public void clear() {
184: strings = new String[1];
185: }
186:
187: /**
188: * Description of the Method
189: *
190: *@param i Description of the Parameter
191: */
192: public void delete(int i) {
193: ;
194: }// TBD
195:
196: /**
197: * Description of the Method
198: *
199: *@return Description of the Return Value
200: */
201: public vrml.Field wrap() {
202: return new vrml.field.MFString(this );
203: }
204:
205: /**
206: * Description of the Method
207: *
208: *@return Description of the Return Value
209: */
210: public String toString() {
211: String s = new String();
212: for (int i = 0; i < strings.length; i++) {
213: s += strings[i];
214: s += '\n';
215: }
216: return s;
217: }
218: }
|