KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > SOFA > SOFAnode > Util > ProtocolRepetition


1 /* $Id: ProtocolRepetition.java,v 1.2 2004/05/20 14:23:53 bures Exp $ */
2
3 package SOFA.SOFAnode.Util;
4
5 import java.util.Iterator JavaDoc;
6
7 class ProtocolRepetition extends ProtocolOperator {
8
9     protected Protocol nested;
10     
11     public ProtocolRepetition( Protocol op ) {
12     super( "*" );
13     nested = op;
14     }
15     
16     public Protocol Copy() {
17     return new ProtocolRepetition( nested.Copy() );
18     }
19     
20     public boolean Restrict( ActionTokenArray a ) {
21     return nested.Restrict( a );
22     }
23     
24     public Machine createMachine() {
25         Machine result = nested.createMachine();
26     Debug.println(3,"Repetition parameter:");
27     ((Printer)result).Print(3);
28         Iterator JavaDoc i = result.Stop().values().iterator();
29     while( i.hasNext() )
30         result.Merge( ((Integer JavaDoc)i.next()).intValue(), result.Start() );
31     result.AddStop( result.Start() );
32
33     result.Minimize();
34
35     Debug.println(3,"Repetition result:");
36     ((Printer)result).Print(3);
37     return result;
38     }
39
40     public void Print( int level ) {
41     super.Print(level);
42     nested.Print(level);
43     Debug.println( level, "---- *");
44     }
45
46     public Protocol Left() {
47     return nested;
48     }
49
50     public Protocol getSameType( Object JavaDoc p1, Object JavaDoc p2 ) {
51     return new ProtocolRepetition( (Protocol)p1 );
52     }
53 }
54
55
Popular Tags