001    package toolbus.tifs;
002    
003    import java.util.Iterator;
004    
005    import aterm.ATerm;
006    import aterm.ATermAppl;
007    import aterm.ATermList;
008    
009    public class Process{
010            private final ATermAppl representation;
011            private final CommunicationList communicationList;
012            
013            public Process(ATerm t){
014                    representation = (ATermAppl) t;
015                    
016                    ATermList list = (ATermList) representation.getArgument(1);
017                    communicationList = new CommunicationList(list);
018            }
019            
020            public String getName(){
021                    ATermAppl nameTerm = (ATermAppl) representation.getArgument(0);
022                    return ((ATermAppl) nameTerm.getArgument(0)).getAFun().getName();
023            }
024            
025            public Iterator<Communication> fetchCommunicationIterator(){
026                    return communicationList.iterator();
027            }
028            
029            public String toString(){
030                    StringBuilder buf = new StringBuilder();
031                    buf.append("process(");
032                    buf.append("name(");
033                    buf.append('"');
034                    buf.append(getName());
035                    buf.append('"');
036                    buf.append(')');
037                    buf.append(',');
038                    buf.append('[');
039                    Iterator<Communication> iter = fetchCommunicationIterator();
040                    while(iter.hasNext()){
041                            buf.append(iter.next());
042                            if(iter.hasNext()){
043                                    buf.append(',');
044                            }
045                    }
046                    buf.append(']');
047                    buf.append(')');
048                    return buf.toString();
049            }
050    }