1 package run.readers; 2 import run.Constraint; 3 4 import run.Controlset; 5 6 import run.Element; 7 8 import run.Load; 9 10 import run.Material; 11 12 import run.ModifiedStreamTokenizer; 13 14 import run.Node; 15 16 import run.Reader; 17 18 import run.RplVector; 19 20 import run.Token; 21 22 import run.TrackWriter; 23 24 import run.Tracker; 25 26 import run.Writer; 27 28 import uka.karmi.rmi.RemoteException; 29 30 import java.io.*; 31 32 import java.text.ParseException; 33 34 import java.util.*; 35 36 import jp.lang.RemoteObject; 37 38 public class FembicReader extends Reader implements uka.patch.Patchable, uka.transport.Transportable { createPatch(Object _copy, uka.patch.PatchOutput po)39 public void createPatch(Object _copy, uka.patch.PatchOutput po) throws java.io.IOException { 40 FembicReader copy = (FembicReader)_copy; 41 super.createPatch(copy, po); 42 if (po.writeDiff(this.constraint_in_block, copy.constraint_in_block)) copy.constraint_in_block = this.constraint_in_block; 43 if (po.writeDiff(this.control_in_block, copy.control_in_block)) copy.control_in_block = this.control_in_block; 44 if (po.writeDiff(this.material_in_block, copy.material_in_block)) copy.material_in_block = this.material_in_block; 45 if (po.writeDiff(this.tracker_in_block, copy.tracker_in_block)) copy.tracker_in_block = this.tracker_in_block; 46 if (po.writeDiff(this.element_in_block, copy.element_in_block)) copy.element_in_block = this.element_in_block; 47 if (po.writeDiff(this.in_block, copy.in_block)) copy.in_block = this.in_block; 48 copy.current_constraint_type = this.current_constraint_type = (java.lang.String)po.writeDiff(this.current_constraint_type, copy.current_constraint_type); 49 copy.current_tracker_type = this.current_tracker_type = (java.lang.String)po.writeDiff(this.current_tracker_type, copy.current_tracker_type); 50 copy.current_element_type = this.current_element_type = (java.lang.String)po.writeDiff(this.current_element_type, copy.current_element_type); 51 copy.temporary_load = this.temporary_load = (run.Load)po.writeDiff(this.temporary_load, copy.temporary_load); 52 copy.temporary_node = this.temporary_node = (run.Node)po.writeDiff(this.temporary_node, copy.temporary_node); 53 copy.str = this.str = (java.io.StreamTokenizer)po.writeDiff(this.str, copy.str); 54 copy.keywords = this.keywords = (java.lang.String[])po.writeDiff(this.keywords, copy.keywords); 55 copy.filename = this.filename = (java.lang.String)po.writeDiff(this.filename, copy.filename); 56 copy.br = this.br = (java.io.BufferedReader)po.writeDiff(this.br, copy.br); 57 } applyPatch(Object _copy, uka.patch.PatchInput pi)58 public void applyPatch(Object _copy, uka.patch.PatchInput pi) throws java.io.IOException, ClassNotFoundException { 59 FembicReader copy = (FembicReader)_copy; 60 super.applyPatch(copy, pi); 61 if (pi.hasDiff()) copy.constraint_in_block = this.constraint_in_block = pi.getDiffAsBoolean(); 62 if (pi.hasDiff()) copy.control_in_block = this.control_in_block = pi.getDiffAsBoolean(); 63 if (pi.hasDiff()) copy.material_in_block = this.material_in_block = pi.getDiffAsBoolean(); 64 if (pi.hasDiff()) copy.tracker_in_block = this.tracker_in_block = pi.getDiffAsBoolean(); 65 if (pi.hasDiff()) copy.element_in_block = this.element_in_block = pi.getDiffAsBoolean(); 66 if (pi.hasDiff()) copy.in_block = this.in_block = pi.getDiffAsBoolean(); 67 if (pi.hasDiff()) copy.current_constraint_type = this.current_constraint_type = (java.lang.String)pi.getDiffAsObject(); 68 if (pi.hasDiff()) copy.current_tracker_type = this.current_tracker_type = (java.lang.String)pi.getDiffAsObject(); 69 if (pi.hasDiff()) copy.current_element_type = this.current_element_type = (java.lang.String)pi.getDiffAsObject(); 70 if (pi.hasDiff()) copy.temporary_load = this.temporary_load = (run.Load)pi.getDiffAsObject(); 71 if (pi.hasDiff()) copy.temporary_node = this.temporary_node = (run.Node)pi.getDiffAsObject(); 72 if (pi.hasDiff()) copy.str = this.str = (java.io.StreamTokenizer)pi.getDiffAsObject(); 73 if (pi.hasDiff()) copy.keywords = this.keywords = (java.lang.String[])pi.getDiffAsObject(); 74 if (pi.hasDiff()) copy.filename = this.filename = (java.lang.String)pi.getDiffAsObject(); 75 if (pi.hasDiff()) copy.br = this.br = (java.io.BufferedReader)pi.getDiffAsObject(); 76 } descendReferences(uka.patch.ReferenceConsumer c)77 public void descendReferences(uka.patch.ReferenceConsumer c) throws java.io.IOException { 78 super.descendReferences(c); 79 c.descend(this.current_constraint_type); 80 c.descend(this.current_tracker_type); 81 c.descend(this.current_element_type); 82 c.descend(this.temporary_load); 83 c.descend(this.temporary_node); 84 c.descend(this.str); 85 c.descend(this.keywords); 86 c.descend(this.filename); 87 c.descend(this.br); 88 } filterReferences(uka.patch.ReferenceFilter f)89 public void filterReferences(uka.patch.ReferenceFilter f) { 90 super.filterReferences(f); 91 this.current_constraint_type = (java.lang.String)f.filter(this.current_constraint_type); 92 this.current_tracker_type = (java.lang.String)f.filter(this.current_tracker_type); 93 this.current_element_type = (java.lang.String)f.filter(this.current_element_type); 94 this.temporary_load = (run.Load)f.filter(this.temporary_load); 95 this.temporary_node = (run.Node)f.filter(this.temporary_node); 96 this.str = (java.io.StreamTokenizer)f.filter(this.str); 97 this.keywords = (java.lang.String[])f.filter(this.keywords); 98 this.filename = (java.lang.String)f.filter(this.filename); 99 this.br = (java.io.BufferedReader)f.filter(this.br); 100 } 101 public static final uka.transport.TransportDescriptor TRANSPORT_DESCRIPTOR = new uka.transport.TransportDescriptor(){ 102 public Object unmarshalReference(uka.transport.UnmarshalStream s, int id) throws java.io.IOException, ClassNotFoundException { 103 return new FembicReader(s, id); 104 } 105 public boolean unmarshal(Object obj, uka.transport.UnmarshalStream s) throws ClassNotFoundException, java.io.IOException { 106 ((FembicReader)obj).unmarshal(s); 107 return false; 108 } 109 public void marshalReference(Object obj, uka.transport.MarshalStream s) throws java.io.IOException { 110 ((FembicReader)obj).marshalReference(s); 111 } 112 public void marshal(Object obj, uka.transport.MarshalStream s) throws java.io.IOException { 113 ((FembicReader)obj).marshal(s); 114 } 115 public Object deepClone(Object orig, int id, uka.transport.DeepClone _helper) throws CloneNotSupportedException { 116 try { 117 return new FembicReader((FembicReader)orig, id, _helper); 118 } catch (java.io.IOException ex) { 119 throw (CloneNotSupportedException)new CloneNotSupportedException().initCause(ex); 120 } 121 } 122 public boolean deepCloneReferences(Object orig, Object copy, uka.transport.DeepClone _helper) throws CloneNotSupportedException { 123 ((FembicReader)copy).deepCloneReferences((FembicReader)orig, _helper); 124 return false; 125 } 126 public Class getType() { 127 return FembicReader.class; 128 } 129 }; getTransportDescriptor()130 public uka.transport.TransportDescriptor getTransportDescriptor() { 131 return TRANSPORT_DESCRIPTOR; 132 } 133 private static final int _SIZE = uka.transport.BasicIO.SIZEOF_boolean + uka.transport.BasicIO.SIZEOF_boolean + uka.transport.BasicIO.SIZEOF_boolean + uka.transport.BasicIO.SIZEOF_boolean + uka.transport.BasicIO.SIZEOF_boolean + uka.transport.BasicIO.SIZEOF_boolean; FembicReader(uka.transport.UnmarshalStream _stream, int _id)134 public FembicReader(uka.transport.UnmarshalStream _stream, int _id) throws java.io.IOException, ClassNotFoundException { 135 super(_stream, _id); 136 } unmarshal(uka.transport.UnmarshalStream _stream)137 public void unmarshal(uka.transport.UnmarshalStream _stream) throws java.io.IOException, ClassNotFoundException { 138 super.unmarshal(_stream); 139 _stream.request(FembicReader._SIZE); 140 byte[] _buffer = _stream.getBuffer(); 141 int _pos = _stream.getPosition(); 142 this.constraint_in_block = uka.transport.BasicIO.extractBoolean(_buffer, _pos); 143 _pos += uka.transport.BasicIO.SIZEOF_boolean; 144 this.control_in_block = uka.transport.BasicIO.extractBoolean(_buffer, _pos); 145 _pos += uka.transport.BasicIO.SIZEOF_boolean; 146 this.material_in_block = uka.transport.BasicIO.extractBoolean(_buffer, _pos); 147 _pos += uka.transport.BasicIO.SIZEOF_boolean; 148 this.tracker_in_block = uka.transport.BasicIO.extractBoolean(_buffer, _pos); 149 _pos += uka.transport.BasicIO.SIZEOF_boolean; 150 this.element_in_block = uka.transport.BasicIO.extractBoolean(_buffer, _pos); 151 _pos += uka.transport.BasicIO.SIZEOF_boolean; 152 this.in_block = uka.transport.BasicIO.extractBoolean(_buffer, _pos); 153 _pos += uka.transport.BasicIO.SIZEOF_boolean; 154 _stream.accept(FembicReader._SIZE); 155 this.current_constraint_type = (java.lang.String)_stream.readReference(); 156 this.current_tracker_type = (java.lang.String)_stream.readReference(); 157 this.current_element_type = (java.lang.String)_stream.readReference(); 158 this.temporary_load = (run.Load)_stream.readReference(); 159 this.temporary_node = (run.Node)_stream.readReference(); 160 this.str = (java.io.StreamTokenizer)_stream.readReference(); 161 this.keywords = (java.lang.String[])_stream.readReference(); 162 this.filename = (java.lang.String)_stream.readReference(); 163 this.br = (java.io.BufferedReader)_stream.readReference(); 164 } marshal(uka.transport.MarshalStream _stream)165 public void marshal(uka.transport.MarshalStream _stream) throws java.io.IOException { 166 super.marshal(_stream); 167 _stream.reserve(FembicReader._SIZE); 168 byte[] _buffer = _stream.getBuffer(); 169 int _pos = _stream.getPosition(); 170 _pos = uka.transport.BasicIO.insert(_buffer, _pos, this.constraint_in_block); 171 _pos = uka.transport.BasicIO.insert(_buffer, _pos, this.control_in_block); 172 _pos = uka.transport.BasicIO.insert(_buffer, _pos, this.material_in_block); 173 _pos = uka.transport.BasicIO.insert(_buffer, _pos, this.tracker_in_block); 174 _pos = uka.transport.BasicIO.insert(_buffer, _pos, this.element_in_block); 175 _pos = uka.transport.BasicIO.insert(_buffer, _pos, this.in_block); 176 _stream.deliver(_SIZE); 177 _stream.writeReference(this.current_constraint_type); 178 _stream.writeReference(this.current_tracker_type); 179 _stream.writeReference(this.current_element_type); 180 _stream.writeReference(this.temporary_load); 181 _stream.writeReference(this.temporary_node); 182 _stream.writeReference(this.str); 183 _stream.writeReference(this.keywords); 184 _stream.writeReference(this.filename); 185 _stream.writeReference(this.br); 186 } FembicReader(FembicReader _orig, int _id, uka.transport.DeepClone _helper)187 public FembicReader(FembicReader _orig, int _id, uka.transport.DeepClone _helper) throws CloneNotSupportedException, java.io.IOException { 188 super(_orig, _id, _helper); 189 this.constraint_in_block = _orig.constraint_in_block; 190 this.control_in_block = _orig.control_in_block; 191 this.material_in_block = _orig.material_in_block; 192 this.tracker_in_block = _orig.tracker_in_block; 193 this.element_in_block = _orig.element_in_block; 194 this.in_block = _orig.in_block; 195 } deepCloneReferences(FembicReader _orig, uka.transport.DeepClone _helper)196 public void deepCloneReferences(FembicReader _orig, uka.transport.DeepClone _helper) throws CloneNotSupportedException { 197 super.deepCloneReferences(_orig, _helper); 198 this.current_constraint_type = (java.lang.String)_helper.internalDeepClone(_orig.current_constraint_type); 199 this.current_tracker_type = (java.lang.String)_helper.internalDeepClone(_orig.current_tracker_type); 200 this.current_element_type = (java.lang.String)_helper.internalDeepClone(_orig.current_element_type); 201 this.temporary_load = (run.Load)_helper.internalDeepClone(_orig.temporary_load); 202 this.temporary_node = (run.Node)_helper.internalDeepClone(_orig.temporary_node); 203 this.str = (java.io.StreamTokenizer)_helper.internalDeepClone(_orig.str); 204 this.keywords = (java.lang.String[])_helper.internalDeepClone(_orig.keywords); 205 this.filename = (java.lang.String)_helper.internalDeepClone(_orig.filename); 206 this.br = (java.io.BufferedReader)_helper.internalDeepClone(_orig.br); 207 } 208 private java.io.BufferedReader br; 209 private java.lang.String filename; 210 private java.lang.String[] keywords = {"TITLE", "CONTROLS", "ELEMENTS", "NODES", "LOADS", "CONSTRAINTS", "MATERIALS", "TRACKERS", "GROUPS", "GEOMETRY"}; 211 private boolean in_block = false; 212 private java.io.StreamTokenizer str; 213 private Node temporary_node; 214 private Load temporary_load; 215 private boolean element_in_block = false; 216 private boolean tracker_in_block = false; 217 private boolean material_in_block = false; 218 private java.lang.String current_element_type; 219 private java.lang.String current_tracker_type; 220 private java.lang.String current_constraint_type; 221 private boolean control_in_block; 222 private boolean constraint_in_block; FembicReader(String fn)223 public FembicReader(String fn) { 224 super(); 225 this.filename = new String(fn); 226 } close()227 public void close() { 228 try { 229 this.br.close(); 230 } catch (IOException ioe) { 231 System.out.println("An IOException has occurred when closing the indata file"); 232 return; 233 } 234 } getControlSet(Controlset temporary_controlset)235 public void getControlSet(Controlset temporary_controlset) throws IllegalArgumentException { 236 try { 237 if (!this.control_in_block) { 238 while (this.str.nextToken() != java.io.StreamTokenizer.TT_EOF) { 239 if (this.str.ttype == java.io.StreamTokenizer.TT_WORD) { 240 if (this.str.sval.toUpperCase().equals("CONTROLS") && this.str.nextToken() == this.str.TT_EOL) { 241 this.control_in_block = true; 242 break; 243 } 244 } 245 } 246 } 247 if (!this.control_in_block) { 248 throw new java.text.ParseException("No controls block found or missing controls ", this.str.lineno()); 249 } 250 while (this.str.nextToken() == java.io.StreamTokenizer.TT_EOL) { 251 { 252 } 253 } 254 this.str.pushBack(); 255 while (this.str.nextToken() != this.str.TT_EOF) { 256 if (this.str.ttype == this.str.TT_WORD) { 257 if (!this.isAKeyword(this.str.sval)) { 258 this.str.pushBack(); 259 temporary_controlset.parse_Fembic(tokenize(this.str), this.str.lineno()); 260 } else { 261 this.str.pushBack(); 262 break; 263 } 264 } 265 } 266 temporary_controlset.checkIndata(); 267 } catch (java.io.IOException e) { 268 throw new IllegalArgumentException("IO error in when generating control set" + e.toString()); 269 } catch (ParseException e) { 270 throw new IllegalArgumentException("Failed to generate control set, Parse exception" + e); 271 } catch (IllegalArgumentException e) { 272 throw new IllegalArgumentException(e.getMessage()); 273 } 274 } getNextElement(RplVector materiallist, RplVector nodelist, RplVector loadlist, Hashtable nodetable)275 public Element getNextElement(RplVector materiallist, RplVector nodelist, RplVector loadlist, Hashtable nodetable) throws java.text.ParseException { 276 Element temporary_element; 277 try { 278 while (this.str.nextToken() == java.io.StreamTokenizer.TT_EOL) { 279 { 280 } 281 } 282 this.str.pushBack(); 283 while (this.str.nextToken() != java.io.StreamTokenizer.TT_NUMBER) { 284 this.str.pushBack(); 285 this.element_in_block = false; 286 while (this.str.nextToken() != java.io.StreamTokenizer.TT_EOF) { 287 if (this.str.ttype == java.io.StreamTokenizer.TT_WORD) { 288 if (this.str.sval.toUpperCase().equals("ELEMENTS")) { 289 if (this.str.nextToken() == java.io.StreamTokenizer.TT_WORD) { 290 if (this.str.sval.toUpperCase().equals("OF")) { 291 { 292 } 293 } else { 294 throw new java.text.ParseException("No \'OF\' defined in element block header", this.str.lineno()); 295 } 296 } 297 if (this.str.nextToken() == java.io.StreamTokenizer.TT_WORD) { 298 if (this.str.sval.toUpperCase().equals("TYPE")) { 299 { 300 } 301 } else { 302 throw new java.text.ParseException("No \'TYPE\' defined in element block header", this.str.lineno()); 303 } 304 } 305 if (this.str.nextToken() == java.io.StreamTokenizer.TT_WORD) { 306 this.current_element_type = new String(this.str.sval.toUpperCase()); 307 } else { 308 throw new java.text.ParseException("Unknown type defined in element block header", this.str.lineno()); 309 } 310 System.out.println("Element block found!"); 311 this.element_in_block = true; 312 this.str.nextToken(); 313 break; 314 } 315 } 316 } 317 } 318 if (!this.element_in_block) { 319 throw new java.text.ParseException("No elements block found or missing elements", this.str.lineno()); 320 } 321 temporary_element = Element.getElementOfType_Fembic(this.current_element_type); 322 temporary_element.setNumber((int)this.str.nval); 323 temporary_element.parse_Fembic(tokenize(this.str), this.str.lineno(), nodelist, materiallist, loadlist, nodetable); 324 temporary_element.checkIndata(); 325 return (Element)temporary_element; 326 } catch (java.io.IOException e) { 327 throw new IllegalArgumentException("IO Exception when generating next element" + e.getMessage()); 328 } catch (ParseException e) { 329 throw new IllegalArgumentException(e.getMessage() + " in line: " + (e.getErrorOffset() - 1)); 330 } catch (IllegalArgumentException e) { 331 throw new IllegalArgumentException(e.toString()); 332 } 333 } getNextTracker(RplVector nodelist, RplVector elementlist)334 public Tracker getNextTracker(RplVector nodelist, RplVector elementlist) throws java.text.ParseException { 335 Tracker temporary_tracker; 336 try { 337 while (this.str.nextToken() == java.io.StreamTokenizer.TT_EOL) { 338 { 339 } 340 } 341 this.str.pushBack(); 342 while (this.str.nextToken() != java.io.StreamTokenizer.TT_NUMBER) { 343 this.str.pushBack(); 344 this.tracker_in_block = false; 345 while (this.str.nextToken() != java.io.StreamTokenizer.TT_EOF) { 346 if (this.str.ttype == java.io.StreamTokenizer.TT_WORD) { 347 if (this.str.sval.toUpperCase().equals("TRACKERS")) { 348 if (this.str.nextToken() == java.io.StreamTokenizer.TT_WORD) { 349 if (this.str.sval.toUpperCase().equals("OF")) { 350 { 351 } 352 } else { 353 throw new java.text.ParseException("No \'OF\' defined in tracker block header", this.str.lineno()); 354 } 355 } 356 if (this.str.nextToken() == java.io.StreamTokenizer.TT_WORD) { 357 if (this.str.sval.toUpperCase().equals("TYPE")) { 358 { 359 } 360 } else { 361 throw new java.text.ParseException("No \'TYPE\' defined in tracker block header", this.str.lineno()); 362 } 363 } 364 if (this.str.nextToken() == java.io.StreamTokenizer.TT_WORD) { 365 this.current_tracker_type = new String(this.str.sval.toUpperCase()); 366 } else { 367 throw new java.text.ParseException("Unknown type defined in tracker block header", this.str.lineno()); 368 } 369 System.out.println("Tracker block found!"); 370 this.tracker_in_block = true; 371 this.str.nextToken(); 372 break; 373 } 374 } 375 } 376 } 377 if (!this.tracker_in_block) { 378 throw new java.text.ParseException("No trackers block found or missing trackers", this.str.lineno()); 379 } 380 temporary_tracker = Tracker.getTrackerOfType_Fembic(this.current_tracker_type); 381 temporary_tracker.setNumber((int)this.str.nval); 382 temporary_tracker.parse_Fembic(tokenize(this.str), this.str.lineno(), nodelist, elementlist); 383 temporary_tracker.checkIndata(); 384 return (Tracker)temporary_tracker; 385 } catch (java.io.IOException e) { 386 throw new IllegalArgumentException("IO Exception when reading Tracker" + e.getMessage()); 387 } catch (ParseException e) { 388 throw new IllegalArgumentException(e.getMessage() + " in line: " + (e.getErrorOffset() - 1)); 389 } catch (IllegalArgumentException e) { 390 throw new IllegalArgumentException(e.getMessage()); 391 } 392 } getNextConstraint(RplVector nodelist)393 public Constraint getNextConstraint(RplVector nodelist) throws java.text.ParseException { 394 Constraint temporary_constraint; 395 try { 396 while (this.str.nextToken() == java.io.StreamTokenizer.TT_EOL) { 397 { 398 } 399 } 400 this.str.pushBack(); 401 while (this.str.nextToken() != java.io.StreamTokenizer.TT_WORD || this.isAKeyword(this.str.sval)) { 402 this.str.pushBack(); 403 this.constraint_in_block = false; 404 while (this.str.nextToken() != java.io.StreamTokenizer.TT_EOF) { 405 if (this.str.ttype == java.io.StreamTokenizer.TT_WORD) { 406 if (this.str.sval.toUpperCase().equals("CONSTRAINTS")) { 407 if (this.str.nextToken() == java.io.StreamTokenizer.TT_WORD) { 408 if (this.str.sval.toUpperCase().equals("OF")) { 409 { 410 } 411 } else { 412 throw new java.text.ParseException("No \'OF\' defined in constraint block header", this.str.lineno()); 413 } 414 } 415 if (this.str.nextToken() == java.io.StreamTokenizer.TT_WORD) { 416 if (this.str.sval.toUpperCase().equals("TYPE")) { 417 { 418 } 419 } else { 420 throw new java.text.ParseException("No \'TYPE\' defined in constraint block header", this.str.lineno()); 421 } 422 } 423 if (this.str.nextToken() == java.io.StreamTokenizer.TT_WORD) { 424 this.current_constraint_type = new String(this.str.sval.toUpperCase()); 425 } else { 426 throw new java.text.ParseException("Unknown type defined in constraint block header", this.str.lineno()); 427 } 428 System.out.println("Constraint block found!"); 429 this.constraint_in_block = true; 430 this.str.nextToken(); 431 break; 432 } 433 } 434 } 435 } 436 if (!this.constraint_in_block) { 437 throw new java.text.ParseException("No constraint block found or missing constraints", this.str.lineno()); 438 } 439 temporary_constraint = Constraint.getConstraintOfType_Fembic(this.current_constraint_type); 440 temporary_constraint.setName(this.str.sval.toUpperCase().trim()); 441 temporary_constraint.parse_Fembic(tokenize(this.str), this.str.lineno(), nodelist); 442 temporary_constraint.checkIndata(); 443 return (Constraint)temporary_constraint; 444 } catch (java.io.IOException e) { 445 throw new IllegalArgumentException("IO Exception when reading Constraint" + e.getMessage()); 446 } catch (ParseException e) { 447 throw new IllegalArgumentException(e.getMessage() + " in line: " + (e.getErrorOffset() - 1)); 448 } catch (IllegalArgumentException e) { 449 throw new IllegalArgumentException(e.getMessage()); 450 } 451 } getNextLoad(RplVector nodelist)452 public Load getNextLoad(RplVector nodelist) throws java.text.ParseException { 453 try { 454 if (!this.in_block) { 455 while (this.str.nextToken() != java.io.StreamTokenizer.TT_EOF) { 456 if (this.str.ttype == java.io.StreamTokenizer.TT_WORD) { 457 if (this.str.sval.toUpperCase().equals("LOADS") && this.str.nextToken() == this.str.TT_EOL) { 458 this.in_block = true; 459 break; 460 } 461 } 462 } 463 } 464 if (!this.in_block) { 465 throw new java.text.ParseException("No loads block found or missing loads", this.str.lineno()); 466 } 467 while (this.str.nextToken() == java.io.StreamTokenizer.TT_EOL) { 468 { 469 } 470 } 471 if (this.str.ttype != java.io.StreamTokenizer.TT_WORD) { 472 throw new java.text.ParseException("No load name found", this.str.lineno()); 473 } 474 this.temporary_load = new Load(); 475 this.temporary_load.name = this.str.sval.toUpperCase(); 476 this.temporary_load.parse_Fembic(tokenize(this.str), this.str.lineno()); 477 this.temporary_load.checkIndata(); 478 return this.temporary_load; 479 } catch (java.io.IOException e) { 480 throw new IllegalArgumentException("IO Exception when reading Load" + e.getMessage()); 481 } catch (ParseException e) { 482 throw new IllegalArgumentException(e.getMessage() + " in line: " + (e.getErrorOffset() - 1)); 483 } catch (IllegalArgumentException e) { 484 throw new IllegalArgumentException(e.getMessage()); 485 } 486 } getNextMaterial()487 public Material getNextMaterial() throws java.text.ParseException { 488 Material temporary_material; 489 try { 490 while (this.str.nextToken() == java.io.StreamTokenizer.TT_EOL) { 491 { 492 } 493 } 494 this.str.pushBack(); 495 while (this.str.nextToken() != java.io.StreamTokenizer.TT_WORD || this.isAKeyword(this.str.sval)) { 496 this.str.pushBack(); 497 this.material_in_block = false; 498 while (this.str.nextToken() != java.io.StreamTokenizer.TT_EOF) { 499 if (this.str.ttype == java.io.StreamTokenizer.TT_WORD) { 500 if (this.str.sval.toUpperCase().equals("MATERIALS")) { 501 if (this.str.nextToken() == java.io.StreamTokenizer.TT_WORD) { 502 if (this.str.sval.toUpperCase().equals("OF")) { 503 { 504 } 505 } else { 506 throw new java.text.ParseException("No \'OF\' defined in material block header", this.str.lineno()); 507 } 508 } 509 if (this.str.nextToken() == java.io.StreamTokenizer.TT_WORD) { 510 if (this.str.sval.toUpperCase().equals("TYPE")) { 511 { 512 } 513 } else { 514 throw new java.text.ParseException("No \'TYPE\' defined in material block header", this.str.lineno()); 515 } 516 } 517 if (this.str.nextToken() == java.io.StreamTokenizer.TT_WORD) { 518 this.current_element_type = new String(this.str.sval.toUpperCase()); 519 } else { 520 throw new java.text.ParseException("Unknown type defined in element block header", this.str.lineno()); 521 } 522 System.out.println("Block found!"); 523 this.material_in_block = true; 524 this.str.nextToken(); 525 break; 526 } 527 } 528 } 529 } 530 if (!this.material_in_block) { 531 throw new java.text.ParseException("No materials block found or missing materials", this.str.lineno()); 532 } 533 temporary_material = Material.getMaterialOfType_Fembic(this.current_element_type); 534 temporary_material.setName(this.str.sval.toUpperCase()); 535 temporary_material.parse_Fembic(tokenize(this.str), this.str.lineno()); 536 temporary_material.checkIndata(); 537 return (Material)temporary_material; 538 } catch (java.io.IOException e) { 539 throw new IllegalArgumentException("IO Exception when reading Material" + e.getMessage()); 540 } catch (ParseException e) { 541 throw new IllegalArgumentException(e.getMessage() + " in line: " + (e.getErrorOffset() - 1)); 542 } catch (IllegalArgumentException e) { 543 throw new IllegalArgumentException(e.getMessage()); 544 } 545 } getNextNode(RplVector constraintlist, RplVector loadlist)546 public Node getNextNode(RplVector constraintlist, RplVector loadlist) throws java.text.ParseException { 547 try { 548 while (this.str.nextToken() == java.io.StreamTokenizer.TT_EOL) { 549 { 550 } 551 } 552 this.str.pushBack(); 553 while (this.str.nextToken() != java.io.StreamTokenizer.TT_NUMBER && this.str.ttype != java.io.StreamTokenizer.TT_EOF) { 554 this.in_block = false; 555 this.str.pushBack(); 556 while (this.str.nextToken() != java.io.StreamTokenizer.TT_EOF) { 557 if (this.str.ttype == java.io.StreamTokenizer.TT_WORD) { 558 if (this.str.sval.toUpperCase().equals("NODES") && this.str.nextToken() == this.str.TT_EOL) { 559 this.in_block = true; 560 break; 561 } 562 } 563 } 564 } 565 if (!this.in_block) { 566 throw new java.text.ParseException("No nodes block found or missing nodes", this.str.lineno()); 567 } 568 this.temporary_node = new Node(); 569 this.temporary_node.setNumber((int)this.str.nval); 570 this.temporary_node.parse_Fembic(tokenize(this.str), this.str.lineno(), constraintlist, loadlist); 571 this.temporary_node.checkIndata(); 572 return this.temporary_node; 573 } catch (java.io.IOException e) { 574 throw new IllegalArgumentException(e.getMessage()); 575 } catch (ParseException e) { 576 throw new IllegalArgumentException(e.getMessage() + " in line: " + (e.getErrorOffset() - 1)); 577 } catch (IllegalArgumentException e) { 578 throw new IllegalArgumentException(e.getMessage()); 579 } 580 } isAKeyword(String param)581 private boolean isAKeyword(String param) { 582 int i; 583 for (i = 0; i < this.keywords.length; i++) { 584 if (this.keywords[i].equals(param.toUpperCase())) { 585 return true; 586 } 587 } 588 return false; 589 } numberOfConstraints()590 public int numberOfConstraints() throws java.text.ParseException { 591 int noc = 0; 592 this.open(); 593 try { 594 while (this.str.nextToken() != this.str.TT_EOF) { 595 if (this.str.ttype == this.str.TT_WORD) { 596 if (this.str.sval.toUpperCase().equals("CONSTRAINTS")) { 597 while (this.str.nextToken() != this.str.TT_EOL) { 598 { 599 } 600 } 601 this.str.pushBack(); 602 while (this.str.nextToken() != this.str.TT_EOF) { 603 if (this.str.ttype == this.str.TT_WORD) { 604 if (this.isAKeyword(this.str.sval)) { 605 this.str.pushBack(); 606 break; 607 } 608 } 609 if (this.str.ttype == this.str.TT_WORD) { 610 noc++; 611 while (this.str.nextToken() != this.str.TT_EOL && this.str.ttype != this.str.TT_EOF) { 612 { 613 } 614 } 615 } 616 } 617 } 618 } 619 } 620 System.out.println("Found " + noc + " constraints"); 621 } catch (IOException ioe) { 622 System.out.println("IOException when reading a constraintline from indata file"); 623 this.close(); 624 return -1; 625 } 626 this.close(); 627 return noc; 628 } numberOfControls()629 public int numberOfControls() throws java.text.ParseException { 630 int noc = 0; 631 this.open(); 632 try { 633 while (this.str.nextToken() != this.str.TT_EOF) { 634 if (this.str.ttype == this.str.TT_WORD) { 635 if (this.str.sval.toUpperCase().equals("CONTROLS") && this.str.nextToken() == this.str.TT_EOL) { 636 while (this.str.nextToken() != this.str.TT_EOF) { 637 if (this.str.ttype == this.str.TT_WORD) { 638 if (!this.isAKeyword(this.str.sval)) { 639 noc++; 640 while (this.str.nextToken() != this.str.TT_EOL && this.str.ttype != this.str.TT_EOF) { 641 { 642 } 643 } 644 } else { 645 this.str.pushBack(); 646 break; 647 } 648 } 649 } 650 } 651 } 652 } 653 System.out.println("Found " + noc + " controls"); 654 } catch (IOException ioe) { 655 System.out.println("IOException when reading a line from indata file"); 656 this.close(); 657 return -1; 658 } 659 if (noc == 0) { 660 this.close(); 661 throw new java.text.ParseException("No controls found", 0); 662 } 663 this.close(); 664 return noc; 665 } numberOfElements()666 public int numberOfElements() throws java.text.ParseException { 667 int noe = 0; 668 this.open(); 669 try { 670 while (this.str.nextToken() != this.str.TT_EOF) { 671 if (this.str.ttype == this.str.TT_WORD) { 672 if (this.str.sval.toUpperCase().equals("ELEMENTS")) { 673 while (this.str.nextToken() != this.str.TT_EOL) { 674 { 675 } 676 } 677 this.str.pushBack(); 678 while (this.str.nextToken() != this.str.TT_EOF) { 679 if (this.str.ttype == this.str.TT_WORD) { 680 if (this.isAKeyword(this.str.sval)) { 681 this.str.pushBack(); 682 break; 683 } 684 } 685 if (this.str.ttype == this.str.TT_NUMBER) { 686 noe++; 687 while (this.str.nextToken() != this.str.TT_EOL && this.str.ttype != this.str.TT_EOF) { 688 { 689 } 690 } 691 } 692 } 693 } 694 } 695 } 696 System.out.println("Found " + noe + " elements"); 697 } catch (IOException ioe) { 698 System.out.println("IOException when reading a line from indata file"); 699 this.close(); 700 return -1; 701 } 702 if (noe == 0) { 703 this.close(); 704 throw new java.text.ParseException("No elements found", 0); 705 } 706 this.close(); 707 return noe; 708 } numberOfTrackers()709 public int numberOfTrackers() throws java.text.ParseException { 710 int not = 0; 711 this.open(); 712 try { 713 while (this.str.nextToken() != this.str.TT_EOF) { 714 if (this.str.ttype == this.str.TT_WORD) { 715 if (this.str.sval.toUpperCase().equals("TRACKERS")) { 716 while (this.str.nextToken() != this.str.TT_EOL) { 717 { 718 } 719 } 720 this.str.pushBack(); 721 while (this.str.nextToken() != this.str.TT_EOF) { 722 if (this.str.ttype == this.str.TT_WORD) { 723 if (this.isAKeyword(this.str.sval)) { 724 this.str.pushBack(); 725 break; 726 } 727 } 728 if (this.str.ttype == this.str.TT_NUMBER) { 729 not++; 730 while (this.str.nextToken() != this.str.TT_EOL && this.str.ttype != this.str.TT_EOF) { 731 { 732 } 733 } 734 } 735 } 736 } 737 } 738 } 739 System.out.println("Found " + not + " trackers"); 740 } catch (IOException ioe) { 741 System.out.println("IOException when reading a trackerline from indata file"); 742 this.close(); 743 return -1; 744 } 745 this.close(); 746 return not; 747 } numberOfGroups()748 public int numberOfGroups() throws java.text.ParseException { 749 int noc = 0; 750 this.open(); 751 try { 752 while (this.str.nextToken() != this.str.TT_EOF) { 753 if (this.str.ttype == this.str.TT_WORD) { 754 if (this.str.sval.toUpperCase().equals("GROUPS") && this.str.nextToken() == this.str.TT_EOL) { 755 while (this.str.nextToken() != this.str.TT_EOF) { 756 if (this.str.ttype == this.str.TT_WORD) { 757 if (!this.isAKeyword(this.str.sval)) { 758 noc++; 759 while (this.str.nextToken() != this.str.TT_EOL && this.str.ttype != this.str.TT_EOF) { 760 { 761 } 762 } 763 } else { 764 this.str.pushBack(); 765 break; 766 } 767 } 768 } 769 } 770 } 771 } 772 System.out.println("Found " + noc + " groups"); 773 } catch (IOException ioe) { 774 System.out.println("IOException when reading a line from indata file"); 775 this.close(); 776 return -1; 777 } 778 this.close(); 779 return noc; 780 } numberOfLoads()781 public int numberOfLoads() throws java.text.ParseException { 782 int noc = 0; 783 this.open(); 784 try { 785 while (this.str.nextToken() != this.str.TT_EOF) { 786 if (this.str.ttype == this.str.TT_WORD) { 787 if (this.str.sval.toUpperCase().equals("LOADS") && this.str.nextToken() == this.str.TT_EOL) { 788 while (this.str.nextToken() != this.str.TT_EOF) { 789 if (this.str.ttype == this.str.TT_WORD) { 790 if (!this.isAKeyword(this.str.sval)) { 791 noc++; 792 while (this.str.nextToken() != this.str.TT_EOL && this.str.ttype != this.str.TT_EOF) { 793 { 794 } 795 } 796 } else { 797 this.str.pushBack(); 798 break; 799 } 800 } 801 } 802 } 803 } 804 } 805 System.out.println("Found " + noc + " loads"); 806 } catch (IOException ioe) { 807 System.out.println("IOException when reading a line from indata file"); 808 this.close(); 809 return -1; 810 } 811 this.close(); 812 return noc; 813 } numberOfMaterials()814 public int numberOfMaterials() throws java.text.ParseException { 815 int nom = 0; 816 this.open(); 817 try { 818 while (this.str.nextToken() != this.str.TT_EOF) { 819 if (this.str.ttype == this.str.TT_WORD) { 820 if (this.str.sval.toUpperCase().equals("MATERIALS")) { 821 while (this.str.nextToken() != this.str.TT_EOL) { 822 { 823 } 824 } 825 while (this.str.nextToken() != this.str.TT_EOF) { 826 if (this.str.ttype == this.str.TT_WORD) { 827 if (!this.isAKeyword(this.str.sval)) { 828 nom++; 829 while (this.str.nextToken() != this.str.TT_EOL && this.str.ttype != this.str.TT_EOF) { 830 { 831 } 832 } 833 } else { 834 this.str.pushBack(); 835 break; 836 } 837 } 838 } 839 } 840 } 841 } 842 System.out.println("Found " + nom + " materials"); 843 } catch (IOException ioe) { 844 System.out.println("IOException when reading a line from indata file"); 845 this.close(); 846 return -1; 847 } 848 if (nom == 0) { 849 this.close(); 850 throw new java.text.ParseException("No materials found", 0); 851 } 852 this.close(); 853 return nom; 854 } numberOfNodes()855 public int numberOfNodes() throws java.text.ParseException { 856 int non = 0; 857 this.open(); 858 try { 859 while (this.str.nextToken() != this.str.TT_EOF) { 860 if (this.str.ttype == this.str.TT_WORD) { 861 if (this.str.sval.toUpperCase().equals("NODES") && this.str.nextToken() == this.str.TT_EOL) { 862 while (this.str.nextToken() != this.str.TT_EOF) { 863 if (this.str.ttype == this.str.TT_WORD) { 864 if (this.isAKeyword(this.str.sval)) { 865 break; 866 } 867 } 868 if (this.str.ttype == this.str.TT_NUMBER) { 869 non++; 870 while (this.str.nextToken() != this.str.TT_EOL && this.str.ttype != this.str.TT_EOF) { 871 { 872 } 873 } 874 } 875 } 876 } 877 } 878 } 879 System.out.println("Found " + non + " nodes"); 880 } catch (IOException ioe) { 881 System.out.println("IOException when reading a line from indata file"); 882 this.close(); 883 return -1; 884 } 885 if (non == 0) { 886 this.close(); 887 throw new java.text.ParseException("No nodes found", 0); 888 } 889 this.close(); 890 return non; 891 } open()892 public void open() { 893 FileReader fr; 894 this.in_block = false; 895 this.control_in_block = false; 896 this.constraint_in_block = false; 897 this.element_in_block = false; 898 try { 899 fr = new FileReader(this.filename); 900 } catch (FileNotFoundException fnfe) { 901 System.out.println("Fembic file does not exist"); 902 return; 903 } 904 try { 905 this.br = new BufferedReader(fr); 906 } catch (IllegalArgumentException ioe) { 907 System.out.println("An IllegalArgumentException has occurred when opening the indata file"); 908 return; 909 } 910 this.str = new ModifiedStreamTokenizer(this.br); 911 } getWriter(RplVector nodelist, RplVector elementlist, Controlset control, RemoteObject[] cluster_nodes)912 public Writer getWriter(RplVector nodelist, RplVector elementlist, Controlset control, RemoteObject[] cluster_nodes) throws RemoteException { 913 Writer a; 914 a = Writer.getWriterOfType_Fembic(control.getWriter(), nodelist, elementlist, cluster_nodes); 915 a.checkIndata(); 916 return a; 917 } getTrackWriter(RplVector trackerlist, Controlset control, RemoteObject[] cluster_nodes)918 public TrackWriter getTrackWriter(RplVector trackerlist, Controlset control, RemoteObject[] cluster_nodes) throws RemoteException { 919 TrackWriter a; 920 a = TrackWriter.getTrackWriterOfType_Fembic(control.getTrackWriter(), trackerlist); 921 a.checkIndata(); 922 return a; 923 } tokenize(java.io.StreamTokenizer str)924 public Token[] tokenize(java.io.StreamTokenizer str) throws IOException { 925 int i; 926 String temp; 927 Vector v = new Vector(); 928 Token t; 929 Token[] arr; 930 while (str.nextToken() != java.io.StreamTokenizer.TT_EOL && str.ttype != java.io.StreamTokenizer.TT_EOF) { 931 if (str.ttype == java.io.StreamTokenizer.TT_WORD) { 932 v.add(new Token(str.sval.trim())); 933 } else { 934 v.add(new Token(str.nval)); 935 } 936 } 937 for (i = 0; i < v.size(); i++) { 938 t = (Token)v.elementAt(i); 939 if (t.is_a_word()) { 940 temp = new String(t.getw()); 941 if (temp.startsWith("[") && !temp.endsWith("]")) { 942 v.remove(i); 943 while (!temp.endsWith("]")) { 944 if (i >= v.size()) { 945 throw new IOException("IO Exception trying to find end ] of a parameter set in string\n"); 946 } 947 t = (Token)v.elementAt(i); 948 v.remove(i); 949 if (t.is_a_number()) { 950 temp += new Double(t.getn()).toString(); 951 } else { 952 temp += t.getw().trim(); 953 } 954 } 955 v.insertElementAt(new Token(temp), i); 956 } else if (temp.indexOf("=") != -1 && temp.length() > 1) { 957 v.remove(i); 958 if (temp.indexOf("=") != 0) { 959 v.insertElementAt(new Token(temp.substring(0, temp.indexOf("="))), i); 960 } else { 961 i--; 962 } 963 v.insertElementAt(new Token(new String("=")), i + 1); 964 if (temp.indexOf("=") != temp.length() - 1) { 965 v.insertElementAt(new Token(temp.substring(temp.indexOf("=") + 1, temp.length())), i + 2); 966 } 967 i--; 968 } 969 } else { 970 } 971 } 972 arr = new Token[v.size()]; 973 for (i = 0; i < v.size(); i++) { 974 arr[i] = (Token)v.elementAt(i); 975 } 976 return arr; 977 } preProcess()978 public void preProcess() throws java.text.ParseException { 979 } 980 } 981