1 | package org.etsi.t3d; |
---|
2 | |
---|
3 | import java.io.FileNotFoundException; |
---|
4 | import java.io.FileOutputStream; |
---|
5 | import java.io.PrintStream; |
---|
6 | |
---|
7 | import de.ugoe.cs.swe.trex.core.analyzer.rfparser.LocationAST; |
---|
8 | |
---|
9 | public 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 | } |
---|