1 23 package com.tc.jrexx.set; 24 25 import com.tc.jrexx.automaton.*; 26 import java.util.*; 27 import java.io.*; 28 29 85 public class SAutomaton { 86 87 private final class SAutomatonChangeListener implements Automaton.IChangedListener { 88 89 public void stateAdded(Automaton.State state) { 90 StatePro wrapper = (StatePro)SAutomaton.this.state2wrapper.get(state); 91 if (wrapper==null) wrapper = new StatePro((AutomatonSet_String.SState)state); 92 93 final Iterator it = SAutomaton.this.listeners.iterator(); 94 for (int i=SAutomaton.this.listeners.size(); i>0; --i) { 95 ((SAutomaton.IChangeListener)it.next()).stateAdded(wrapper); 96 } 97 } 98 99 public void stateRemoved(Automaton.State state) { 100 StatePro wrapper = (StatePro)SAutomaton.this.state2wrapper.get(state); 101 if (wrapper==null) wrapper = new StatePro((AutomatonSet_String.SState)state); 102 103 final Iterator it = SAutomaton.this.listeners.iterator(); 104 for (int i=SAutomaton.this.listeners.size(); i>0; --i) { 105 ((SAutomaton.IChangeListener)it.next()).stateRemoved(wrapper); 106 } 107 } 108 109 public void startStateChanged(Automaton.State oldStartState,Automaton.State newStartState) { 110 StatePro oldWrapper = null; 111 if (oldStartState!=null) { 112 oldWrapper = (StatePro)SAutomaton.this.state2wrapper.get(oldStartState); 113 if (oldWrapper==null) oldWrapper = new StatePro((AutomatonSet_String.SState)oldStartState); 114 } 115 116 StatePro newWrapper = null; 117 if (newStartState!=null) { 118 newWrapper = (StatePro)SAutomaton.this.state2wrapper.get(newStartState); 119 if (newWrapper==null) newWrapper = new StatePro((AutomatonSet_String.SState)newStartState); 120 } 121 122 final Iterator it = SAutomaton.this.listeners.iterator(); 123 for (int i=SAutomaton.this.listeners.size(); i>0; --i) { 124 ((SAutomaton.IChangeListener)it.next()).startStateChanged(oldWrapper,newWrapper); 125 } 126 } 127 } 128 129 136 public interface IChangeListener { 137 140 public void stateAdded(IStatePro state); 141 144 public void stateRemoved(IStatePro state); 145 149 public void startStateChanged(IStatePro oldStartState, IStatePro newStartState); 150 } 151 152 protected class State implements IState { 153 protected final AutomatonSet_String.ISState state; 154 protected State(AutomatonSet_String.ISState state) { 155 this.state = state; 156 } 157 158 public boolean isFinal() { 159 return this.state.isFinal(); 160 } 161 162 public IState next(char ch) { 163 final Automaton.IState nextState = this.state.next(ch); 164 return nextState==null ? null : new State((AutomatonSet_String.ISState)nextState); 165 } 166 185 186 public StateProSet getAllReachableStates() { 187 final StateProSet result = new StateProSet(); 188 final Automaton.LinkedSet_State states = this.state.getAllReachableStates(); 189 for (Automaton.Wrapper_State w = states.elements; w!=null; w=w.next) { 190 191 StatePro wrapper = (StatePro)SAutomaton.this.state2wrapper.get(w.state); 192 if (wrapper==null) wrapper = new StatePro((AutomatonSet_String.SState)w.state); 193 result.add(wrapper); 194 } 195 return result; 196 } 197 198 public String toString() { 199 return this.state.toString(); 200 } 201 } 202 203 protected class Transition implements IStatePro.ITransition { 204 protected final Automaton.State.Transition transition; 205 protected Transition(Automaton.State.Transition transition) { 206 this.transition = transition; 207 SAutomaton.this.transition2wrapper.put(transition,this); 208 } 209 214 public IStatePro getFromState() { 215 StatePro wrapper = (StatePro)SAutomaton.this.state2wrapper.get(this.transition.getFromState()); 216 if (wrapper==null) 217 wrapper = new StatePro((AutomatonSet_String.SState)this.transition.getFromState()); 218 return wrapper; 219 } 220 221 public Set getLabels() { 222 final HashSet labels = (HashSet)this.transition.properties; 223 if (labels!=null) return labels; 225 return java.util.Collections.EMPTY_SET; 226 } 227 228 public ISet_char getCharSet() { 229 return this.transition.getCharSet(); 230 } 231 232 public IStatePro getToState() { 233 StatePro wrapper = (StatePro)SAutomaton.this.state2wrapper.get(this.transition.getToState()); 234 if (wrapper==null) 235 wrapper = new StatePro((AutomatonSet_String.SState)this.transition.getToState()); 236 return wrapper; 237 } 238 239 public String toString() { 240 final StringBuffer buffer = new StringBuffer (); 241 final AutomatonSet_String.SState fromState = (AutomatonSet_String.SState)this.transition.getFromState(); 242 final AutomatonSet_String.SState toState = (AutomatonSet_String.SState)this.transition.getToState(); 243 244 if (fromState.isFinal()) buffer.append('[').append(fromState.stateNr).append(']'); 245 else buffer.append('(').append(fromState.stateNr).append(')'); 246 247 if (this.transition.getCharSet()==null) { 248 if (this.transition.properties==null) buffer.append(" --> "); 249 else buffer.append(" - " ).append(this.transition.properties).append(": -> "); 250 } else { 251 if (this.transition.properties==null) buffer.append(" - ").append(this.transition.getCharSet()).append(" -> "); 252 else buffer.append(" - ").append(this.transition.properties).append(':').append(this.transition.getCharSet()).append(" ->"); 253 } 254 255 if (toState.isFinal()) buffer.append('[').append(toState.stateNr).append(']'); 256 else buffer.append('(').append(toState.stateNr).append(')'); 257 258 return buffer.toString(); 259 } 260 261 } 262 263 private final class StateProVisitedListener implements AutomatonSet_String.IStateVisitedListener { 264 private final StatePro statePro; 265 266 public StateProVisitedListener(StatePro statePro) { 267 this.statePro = statePro; 268 } 269 270 public void stateVisited(Automaton.State state) { 271 StatePro wrapper = (StatePro)SAutomaton.this.state2wrapper.get(state); 272 if (wrapper==null) wrapper = new StatePro((AutomatonSet_String.SState)state); 273 274 final Iterator it = statePro.visitListeners.iterator(); 275 for (int i=statePro.visitListeners.size(); i>0; --i) { 276 ((IStatePro.IVisitListener)it.next()).stateVisited(wrapper); 277 } 278 } 279 280 public void stateVisited(Automaton.State state,char ch) { 281 StatePro wrapper = (StatePro)SAutomaton.this.state2wrapper.get(state); 282 if (wrapper==null) wrapper = new StatePro((AutomatonSet_String.SState)state); 283 284 final Iterator it = statePro.visitListeners.iterator(); 285 for (int i=statePro.visitListeners.size(); i>0; --i) { 286 ((IStatePro.IVisitListener)it.next()).stateVisited(wrapper,ch); 287 } 288 } 289 290 public void stateUnVisited(Automaton.State state) { 291 StatePro wrapper = (StatePro)SAutomaton.this.state2wrapper.get(state); 292 if (wrapper==null) wrapper = new StatePro((AutomatonSet_String.SState)state); 293 294 final Iterator it = statePro.visitListeners.iterator(); 295 for (int i=statePro.visitListeners.size(); i>0; --i) { 296 ((IStatePro.IVisitListener)it.next()).stateUnVisited(wrapper); 297 } 298 } 299 } 300 301 private final class StateProChangedListener implements AutomatonSet_String.ISStateChangedListener { 302 303 private final StatePro statePro; 304 305 public StateProChangedListener(StatePro statePro) { 306 this.statePro = statePro; 307 } 308 309 public void transitionAdded(Automaton.State.Transition transition) { 310 Transition wrapper = (Transition)SAutomaton.this.transition2wrapper.get(transition); 311 if (wrapper==null) wrapper = new Transition(transition); 312 313 final Iterator it = statePro.changeListeners.iterator(); 314 for (int i=statePro.changeListeners.size(); i>0; --i) { 315 ((IStatePro.IChangeListener)it.next()).transitionAdded(wrapper); 316 } 317 } 318 319 public void transitionRemoved(Automaton.State.Transition transition) { 320 Transition wrapper = (Transition)SAutomaton.this.transition2wrapper.get(transition); 321 if (wrapper==null) wrapper = new Transition(transition); 322 final Iterator it = statePro.changeListeners.iterator(); 323 for (int i=statePro.changeListeners.size(); i>0; --i) { 324 ((IStatePro.IChangeListener)it.next()).transitionRemoved(wrapper); 325 } 326 } 327 328 public void isFinalChanged(AutomatonSet_String.SState state, boolean isFinal) { 329 StatePro wrapper = (StatePro)SAutomaton.this.state2wrapper.get(state); 330 if (wrapper==null) wrapper = new StatePro((AutomatonSet_String.SState)state); 331 332 final Iterator it = statePro.changeListeners.iterator(); 333 for (int i=statePro.changeListeners.size(); i>0; --i) { 334 ((IStatePro.IChangeListener)it.next()).isFinalChanged(wrapper,isFinal); 335 } 336 } 337 } 338 339 340 protected class StatePro implements IStatePro { 341 342 protected final Automaton.IStateVisitedListener stateVisitedListener = new StateProVisitedListener(this); 343 344 protected final Automaton.IStateChangedListener stateChangedListener = new StateProChangedListener(this); 345 346 protected LinkedList visitListeners = null; 347 protected LinkedList changeListeners = null; 348 349 public void addVisitListener(IStatePro.IVisitListener listener) { 350 if (this.visitListeners==null) { 351 this.visitListeners = new LinkedList(); 352 this.state.addVisitedListener(this.stateVisitedListener); 353 } 354 this.visitListeners.add(listener); 355 } 356 357 public boolean removeVisitListener(IStatePro.IVisitListener listener) { 358 if (this.visitListeners!=null) { 359 final Iterator it = this.visitListeners.iterator(); 360 for (int i=this.visitListeners.size(); i>0; --i) { 361 if (listener==it.next()) { 362 if (this.visitListeners.size()>1) it.remove(); 363 else { 364 this.state.removeVisitedListener(this.stateVisitedListener); 365 this.visitListeners = null; 366 } 367 return true; 368 } 369 } 370 } 371 return false; 372 } 373 374 public void addChangeListener(IStatePro.IChangeListener listener) { 375 if (this.changeListeners==null) { 376 this.changeListeners = new LinkedList(); 377 this.state.addChangedListener(this.stateChangedListener); 378 } 379 this.changeListeners.add(listener); 380 } 381 382 public boolean removeChangeListener(IStatePro.IChangeListener listener) { 383 if (this.changeListeners!=null) { 384 final Iterator it = this.changeListeners.iterator(); 385 for (int i=this.changeListeners.size(); i>0; --i) { 386 if (listener==it.next()) { 387 if (this.changeListeners.size()>1) it.remove(); 388 else { 389 this.state.removeChangedListener(this.stateChangedListener); 390 this.changeListeners = null; 391 } 392 return true; 393 } 394 } 395 } 396 return false; 397 } 398 399 protected final AutomatonSet_String.SState state; 400 protected StatePro(AutomatonSet_String.SState state) { 401 if (state==null) throw new Error ("state==null"); 402 this.state = state; 403 SAutomaton.this.state2wrapper.put(state,this); 404 } 405 406 protected void finalize() { 407 SAutomaton.this.state2wrapper.remove(this.state); 408 } 409 410 protected SAutomaton parent() { 411 return SAutomaton.this; 412 } 413 414 public boolean isFinal() { 415 return this.state.isFinal(); 416 } 417 418 public void setFinal(boolean isFinal) { 419 this.state.setFinal(isFinal); 420 } 421 422 public IState visit() { 423 return new State((AutomatonSet_String.ISState)this.state.visit()); 424 } 425 426 public IStatePro.ITransition addTransition(ISet_char charSet,IStatePro toState) { 427 final AutomatonSet_String.SState.Transition trans = this.state.addTransition(null,charSet,((StatePro)toState).state); 428 Transition wrapper = (Transition)SAutomaton.this.transition2wrapper.get(trans); 429 if (wrapper==null) wrapper = new Transition(trans); 430 return wrapper; 431 } 432 433 public boolean removeTransition(IStatePro.ITransition transition) { 434 return this.state.removeTransition(((Transition)transition).transition); 435 } 436 437 public void removeAllTransitions() { 438 this.state.removeAllTransitions(); 439 } 440 441 public StateProSet getAllReachableStates() { 442 final StateProSet result = new StateProSet(); 443 final Automaton.LinkedSet_State states = this.state.getAllReachableStates(); 444 for (Automaton.Wrapper_State w = states.elements; w!=null; w=w.next) { 445 446 StatePro wrapper = (StatePro)SAutomaton.this.state2wrapper.get(w.state); 447 if (wrapper==null) wrapper = new StatePro((AutomatonSet_String.SState)w.state); 448 result.add(wrapper); 449 } 450 return result; 451 } 452 453 454 public IStatePro.ITransition[] getTransitions() { 455 final LinkedList list = new LinkedList(); 456 for (AutomatonSet_String.State.Transition trans=this.state.transitions; trans!=null; trans=trans.next) { 457 Transition wrapper = (Transition)SAutomaton.this.transition2wrapper.get(trans); 458 if (wrapper==null) wrapper = new Transition(trans); 459 list.addFirst(wrapper); 461 } 462 return (IStatePro.ITransition[])list.toArray(new IStatePro.ITransition[list.size()]); 463 } 464 465 public IStatePro.ITransition[] getETransitions() { 466 final LinkedList list = new LinkedList(); 467 for (AutomatonSet_String.State.Transition trans=this.state.eTransitions; trans!=null; trans=trans.next) { 468 Transition wrapper = (Transition)SAutomaton.this.transition2wrapper.get(trans); 469 if (wrapper==null) wrapper = new Transition(trans); 470 list.addFirst(wrapper); 472 } 473 return (IStatePro.ITransition[])list.toArray(new IStatePro.ITransition[list.size()]); 474 } 475 476 480 public IStatePro.ITransition[] getAllTransitions() { 481 final LinkedList list = new LinkedList(); 482 for (AutomatonSet_String.State.Transition trans=this.state.transitions; trans!=null; trans=trans.next) { 483 Transition wrapper = (Transition)SAutomaton.this.transition2wrapper.get(trans); 484 if (wrapper==null) wrapper = new Transition(trans); 485 list.addFirst(wrapper); 487 } 488 for (AutomatonSet_String.State.Transition trans=this.state.eTransitions; trans!=null; trans=trans.next) { 489 Transition wrapper = (Transition)SAutomaton.this.transition2wrapper.get(trans); 490 if (wrapper==null) wrapper = new Transition(trans); 491 list.addFirst(wrapper); 493 } 494 return (IStatePro.ITransition[])list.toArray(new IStatePro.ITransition[list.size()]); 495 } 496 497 public int getStateNumber() { 498 return this.state.stateNr; 499 } 500 501 public String toString() { 502 if (this.isFinal()) return "["+this.state.stateNr+"]"; 503 return "("+this.state.stateNr+")"; 504 } 505 506 } 507 508 protected transient HashMap state2wrapper = null; 510 protected transient HashMap transition2wrapper = null; 511 512 protected transient Automaton.IChangedListener automatonChangedListener = null; 513 514 protected Automaton.IChangedListener getAutomatonChangedListener() { 515 if (this.automatonChangedListener!=null) return this.automatonChangedListener; 516 517 this.automatonChangedListener = new SAutomatonChangeListener(); 518 519 return this.automatonChangedListener; 520 } 521 522 protected transient LinkedList listeners = null; 523 524 532 public void addChangeListener(SAutomaton.IChangeListener listener) { 533 if (this.listeners==null) { 534 this.listeners = new LinkedList(); 535 ((AutomatonSet_String)this.automaton).addChangedListener(this.getAutomatonChangedListener()); 536 } 537 this.listeners.add(listener); 538 } 539 540 547 public boolean removeChangeListener(SAutomaton.IChangeListener listener) { 548 if (this.listeners!=null) { 549 final Iterator it = this.listeners.iterator(); 550 for (int i=this.listeners.size(); i>0; --i) { 551 if (listener==it.next()) { 552 if (this.listeners.size()>1) it.remove(); 553 else { 554 this.automaton.removeChangedListener(this.automatonChangedListener); 555 this.automatonChangedListener = null; 556 this.listeners = null; 557 } 558 return true; 559 } 560 } 561 } 562 return false; 563 } 564 565 566 567 568 protected transient AutomatonSet_String automaton; 569 570 573 public SAutomaton() { 574 this(new AutomatonSet_String()); 575 } 576 577 public SAutomaton(FSAData data) { 578 this(new AutomatonSet_String()); 579 this.init(data); 580 } 581 582 protected static FSAData toFSAData(Object obj) { 583 if (obj.getClass()!=FSAData.class) { 584 SAutomatonData data = (SAutomatonData)obj; 585 586 FSAData.State[] newStates = new FSAData.State[data.states==null ? 0 : data.states.length]; 587 for (int i=0; i<newStates.length; ++i) { 588 SAutomatonData.State state = data.states[i]; 589 if (state!=null) { 590 FSAData.State.Transition[] newTransitions = 591 new FSAData.State.Transition[state.transitions==null ? 0 : state.transitions.length]; 592 for (int t=0; t<newTransitions.length; ++t) { 593 SAutomatonData.State.Transition trans = state.transitions[t]; 594 newTransitions[t] = new FSAData.State.Transition(trans.properties,trans.charSet,trans.toStateNumber); 595 } 596 newStates[i] = new FSAData.State(state.number,state.isFinal,newTransitions,state.transitionsAreDeterministic); 597 } 598 } 599 return new FSAData(newStates,data.startStateNumber,data.isDeterministic); 600 601 } else { 602 FSAData data = (FSAData)obj; 603 switch(data.objectVersion) { 604 case FSAData.classVersion : return data; 605 default : return data; 606 } 607 } 608 } 609 610 public SAutomaton(InputStream automatonDataStream) throws IOException, ClassNotFoundException { 611 this(new AutomatonSet_String()); 612 this.init(toFSAData(new ObjectInputStream(automatonDataStream).readObject())); 614 } 615 616 protected SAutomaton(AutomatonSet_String automaton) { 617 this.automaton = automaton; 618 this.state2wrapper = new HashMap(); 619 this.transition2wrapper = new HashMap(); 620 } 621 622 public boolean isDeterministic() { 623 return this.automaton.isDeterministic(); 624 } 625 626 631 public IStatePro getStartState() { 632 Automaton.State startState = ((AutomatonSet_String)this.automaton).getStartState(); 633 if (startState==null) return null; 634 635 StatePro wrapper = (StatePro)this.state2wrapper.get(startState); 636 if (wrapper==null) 637 wrapper = new StatePro((AutomatonSet_String.SState)startState); 638 return wrapper; 639 } 640 641 642 650 public void setStartState(IStatePro state) { 651 if ((state instanceof StatePro)==false) throw new IllegalArgumentException ("state is no state of mine"); 652 653 final StatePro wrapper = (StatePro)state; 654 if (wrapper.parent()!=this) throw new IllegalArgumentException ("state is no state of mine"); 655 656 this.automaton.setStartState(wrapper.state); 657 } 658 659 663 public IStatePro addState() { 664 return this.addState(false); 665 } 666 667 671 public IStatePro addState(boolean isFinal) { 672 final AutomatonSet_String.SState newState = this.automaton.addState(isFinal); 673 StatePro wrapper = (StatePro)SAutomaton.this.state2wrapper.get(newState); 674 if (wrapper==null) wrapper = new StatePro((AutomatonSet_String.SState)newState); 675 return wrapper; 676 } 677 678 687 public boolean removeState(IStatePro state) { 688 if ((state instanceof StatePro)==false) throw new IllegalArgumentException ("state is no state of mine"); 689 690 final StatePro wrapper = (StatePro)state; 691 if (wrapper.parent()!=this) throw new IllegalArgumentException ("state is no state of mine"); 692 return this.automaton.removeState(wrapper.state); 693 } 694 695 698 public void clear() { 699 this.automaton.clear(); 700 } 701 702 707 public void minimize() { 708 this.automaton.minimize(); 709 } 710 711 715 public StateProSet getStates() { 716 final StateProSet result = new StateProSet(); 717 final Automaton.LinkedSet_State states = this.automaton.getStates(); 718 for (Automaton.Wrapper_State w = states.elements; w!=null; w=w.next) { 719 StatePro wrapper = (StatePro)SAutomaton.this.state2wrapper.get(w.state); 720 if (wrapper==null) wrapper = new StatePro((AutomatonSet_String.SState)w.state); 721 result.add(wrapper); 722 } 723 return result; 724 } 725 726 public void complement() { 727 this.automaton.complement(); 728 } 729 730 public void addAll(SAutomaton automaton) { 731 this.automaton.addAll(automaton.automaton); 732 } 733 734 public void retainAll(SAutomaton automaton) { 735 this.automaton.retainAll(automaton.automaton); 736 } 737 738 public void removeAll(SAutomaton automaton) { 739 this.automaton.removeAll(automaton.automaton); 740 } 741 742 public String toString() { 743 return this.automaton.toString(); 744 } 745 746 private String getCharSet(ISet_char charSet) { 747 if (charSet==null) return null; 748 final StringBuffer buffer = new StringBuffer (charSet.size()); 749 ISet_char.Iterator it_charSet = charSet.iterator(); 750 for (int i=charSet.size(); i>0; --i) buffer.append(it_charSet.next()); 751 752 ISet_char cs = new CharSet(buffer.toString()); 753 if (cs.equals(charSet)==false) 754 throw new Error (""+charSet+" "+cs); 755 756 return buffer.toString(); 757 } 758 759 public FSAData toData() { 760 Automaton.LinkedSet_State xxx = this.automaton.getStates(); 761 AutomatonSet_String.SState[] states = new AutomatonSet_String.SState[xxx.size()]; 762 int x=0; 763 for (Automaton.Wrapper_State w=xxx.elements; w!=null; w=w.next,++x) { 764 states[x] = (AutomatonSet_String.SState)w.state; 765 } 766 767 FSAData.State[] data_states = new FSAData.State[states.length]; 768 for (int i=0; i<states.length; ++i) { 769 LinkedList data_transitions = new LinkedList(); 770 for (Automaton.State.Transition trans=states[i].transitions; trans!=null; trans=trans.next) { 771 data_transitions.addFirst( 773 new FSAData.State.Transition( 774 trans.properties, 775 this.getCharSet(trans.charSet) 776 ,trans.toState.stateNr 778 ) 779 ); 780 } 781 for (Automaton.State.Transition trans=states[i].eTransitions; trans!=null; trans=trans.next) { 782 data_transitions.addFirst( 784 new FSAData.State.Transition(trans.properties,null,trans.toState.stateNr) 786 ); 787 } 788 789 FSAData.State.Transition[] transitions = 790 (FSAData.State.Transition[])data_transitions.toArray( 791 new FSAData.State.Transition[data_transitions.size()] 792 ); 793 794 data_states[i] = new FSAData.State(states[i].stateNr,states[i].isFinal,transitions,states[i].isDeterministic()); 796 } 797 798 final Automaton.State startState = this.automaton.getStartState(); 799 if (startState==null) return new FSAData(data_states,null,this.automaton.isDeterministic()); 800 801 803 FSAData result = new FSAData(data_states,new Integer (startState.stateNr),this.automaton.isDeterministic()); 804 805 return result; 806 } 807 808 protected void init(FSAData a) { 809 814 final HashMap map = new HashMap(); 815 816 if (a.states!=null) { 817 for (int i=0; i<a.states.length; ++i) { 818 Integer stateNr = new Integer (a.states[i].number); 819 if (map.containsKey(stateNr)) 820 throw new IllegalArgumentException ("bad automatonData: state with number "+stateNr+" does already exists"); 821 822 AutomatonSet_String.SState state = 823 this.automaton.addState(a.states[i].isFinal,a.states[i].number); 824 825 map.put(stateNr,state); 826 } 827 828 for (int i=0; i<a.states.length; ++i) { 829 FSAData.State stateData = a.states[i]; 830 831 AutomatonSet_String.SState state = 832 (AutomatonSet_String.SState)map.get(new Integer (stateData.number)); 833 834 if (stateData.transitions!=null) { 835 for (int t=0; t<stateData.transitions.length; ++t) { 836 FSAData.State.Transition transData = stateData.transitions[t]; 837 838 CharSet charSet = (transData.charSet==null) ? null : new CharSet(transData.charSet); 839 840 AutomatonSet_String.SState toState = 841 (AutomatonSet_String.SState)map.get(new Integer (transData.toStateNumber)); 842 843 state.addTransition(transData.properties,charSet,toState); 844 } 845 } 846 847 state.setDeterministic(stateData.transitionsAreDeterministic); 848 } 849 } 850 851 if (a.startStateNumber!=null) { 852 AutomatonSet_String.SState startState = 853 (AutomatonSet_String.SState)map.get(a.startStateNumber); 854 855 if (startState==null) 856 throw new IllegalArgumentException ("bad automatonData: startState "+a.startStateNumber+" does not exists"); 857 858 this.automaton.setStartState(startState); 859 } 860 861 this.automaton.setDeterministic( 862 a.isDeterministic 863 ); 864 } 865 866 public void toData(OutputStream automatonDataStream) throws IOException { 867 new ObjectOutputStream(automatonDataStream).writeObject(this.toData()); 868 } 869 870 871 872 } | Popular Tags |