UMLGraph { traversal ReadAllVertices(ReadVertexVisitor rvv) { bypassing -> *,edges,* to { UMLConstVertex, UMLAltVertex, UMLTerm}; } (@ public String PrintVertices() { ReadVertexVisitor rvv= new ReadVertexVisitor(this, new String(), new Integer(0)); this.ReadAllVertices(rvv); return rvv.get_graphstring(); } public String FindVertex(Integer vertexid) { ReadVertexVisitor rvv= new ReadVertexVisitor(this, new String(), vertexid); this.ReadAllVertices(rvv); return rvv.get_graphstring(); } @) traversal ReadAllEdges(ReadEdgeVisitor rev) { bypassing -> *,vertices,* to {UMLConstEdge, UMLAltEdge}; } (@ public String FindEdge(Integer vertexid, String fromvertextype) { // We will use this string fromvertextype to differentiate // if this function was called from an alt or a const vertex // The Integer is for the pipeswitch ReadEdgeVisitor rev= new ReadEdgeVisitor(this, new String(), new String(), vertexid, fromvertextype, new Integer(0)); this.ReadAllEdges(rev); String tmp = new String(); tmp = rev.get_graphstring(); if ( ! rev.get_commonstring().equals("") ) { tmp = tmp + "\n\t\t*common*\n\t\t" + rev.get_commonstring(); } return tmp; } @) } //UVertex { (@ // public Search ReadVertexVisitor { before UMLConstVertex (@ // if lookupvid is 0 then this traversal was called by PrintVertices if (lookupvid.intValue() == 0) { graphstring = graphstring + host.get_vertexname().get_name() + " "; graphstring = graphstring + "\t= " ; graphstring = graphstring + thegraph.FindEdge(host.get_vid().get_id(), new String("const") ); graphstring = graphstring + ".\n"; // else this traversal was called by the EdgeVisitor } else if (host.get_vid().get_id().intValue() == lookupvid.intValue()){ graphstring = graphstring + host.get_vertexname().get_name() + " "; } @) before UMLAltVertex (@ // if lookupvid is 0 then this traversal was called by PrintVertices if (lookupvid.intValue() == 0) { graphstring = graphstring + host.get_vertexname().get_name() + " "; graphstring = graphstring + "\t: " ; graphstring = graphstring + thegraph.FindEdge(host.get_vid().get_id(), new String("alt") ); graphstring = graphstring + ".\n"; // else this traversal was called by the EdgeVisitor } else if (host.get_vid().get_id().intValue() == lookupvid.intValue()){ graphstring = graphstring + host.get_vertexname().get_name() + " "; } @) } ReadEdgeVisitor { before UMLConstEdge (@ if (host.get_fromVertex().get_id().intValue() == lookupvid.intValue() ) { if (fromtype.equals("alt") ) { commonstring = commonstring + "<" + host.get_edgename().get_name() + "> " ; commonstring = commonstring + thegraph.FindVertex(host.get_toVertex().get_id()); } else { graphstring = graphstring + "<" + host.get_edgename().get_name() + "> " ; // now find the toVertex graphstring = graphstring + thegraph.FindVertex(host.get_toVertex().get_id()); } } @) before UMLAltEdge (@ if (host.get_fromVertex().get_id().intValue() == lookupvid.intValue() ) { if (this.get_pipeswitch().intValue() == 0 ) { set_pipeswitch(new Integer(1) ); } else { graphstring = graphstring + "| "; } graphstring = graphstring + thegraph.FindVertex(host.get_toVertex().get_id()); } @) } Main { (@ public static void main(String args[]) throws Exception { FileInputStream fi=new FileInputStream("uml.input"); UMLGraph graph = UMLGraph.parse(fi); System.out.println(graph.PrintVertices()); } @) }