source: trunk/t3d/src/org/etsi/t3d/DependencyPrinter.java @ 7

Last change on this file since 7 was 7, checked in by phdmakk, 14 years ago
  • Property svn:mime-type set to text/plain
File size: 1.9 KB
Line 
1package org.etsi.t3d;
2
3import java.io.FileNotFoundException;
4import java.io.FileOutputStream;
5import java.io.PrintStream;
6
7import de.ugoe.cs.swe.trex.core.analyzer.rfparser.LocationAST;
8
9public class DependencyPrinter {
10        private PrintStream stream;
11        private String currentTTCN3File;
12       
13        public void finishXML(){
14                writeStream("\n</dependencies>");
15               
16        }
17       
18        public void newElement(String name, String id, int type, int line,
19                        String module, String dependencies) {
20                writeStream("\n\t<element id=\""
21                                + id
22                                + "\" name=\""
23                                + name
24                                + "\" type=\""
25                                + LocationAST.getTTCN3ParserTokenTypeTypePrettyName(type)
26                                + "\" line=\""
27                                + line
28                                + "\" module=\""
29                                + module
30                                + "\" file=\""
31                                + currentTTCN3File.substring(currentTTCN3File.lastIndexOf("/") + 1)
32                                + "\">");
33                writeStream(dependencies);
34                writeStream("\n\t</element>\n");
35        }
36
37        public void newGroup(String name, String id, int type, int line, String module,
38                        String elementList) {
39                writeStream("\n\t<element id=\""
40                                + id
41                                + "\" name=\""
42                                + name
43                                + "\" type=\""
44                                + LocationAST.getTTCN3ParserTokenTypeTypePrettyName(type)
45                                + "\" line=\""
46                                + line
47                                + "\" module=\""
48                                + module
49                                + "\" file=\""
50                                + currentTTCN3File.substring(currentTTCN3File.lastIndexOf("/") + 1)
51                                + "\">");
52                writeStream(elementList);
53                writeStream("\n\t</element>\n");
54        }
55       
56        public void setXMLPath(String xmlpath){
57                FileOutputStream file;
58                try {
59                        file = new FileOutputStream(xmlpath);
60                        stream = new PrintStream(file);
61                } catch (FileNotFoundException e) {
62                        e.printStackTrace();
63                }
64                writeStream("<?xml-stylesheet type=\"text/xsl\" href=\"../dependencies.xsl\"?>\n<dependencies>");
65        }
66
67        private void writeStream(String content){
68                stream.print(content);
69        }
70       
71        public void setCurrentTTCN3File(String currentTTCN3File) {
72                this.currentTTCN3File = currentTTCN3File;
73        }
74
75        public String getCurrentTTCN3File() {
76                return currentTTCN3File;
77        }
78}
Note: See TracBrowser for help on using the repository browser.