1 | package elements;
|
---|
2 |
|
---|
3 | import java.util.LinkedList;
|
---|
4 |
|
---|
5 | import org.etsi.common.logging.LoggingInterface.MessageClass;
|
---|
6 | import org.etsi.t3d.T3D;
|
---|
7 |
|
---|
8 |
|
---|
9 | public class TTCN3Element{
|
---|
10 |
|
---|
11 | private String type;
|
---|
12 | private int LEVEL0 = 0;
|
---|
13 | protected String behaviour;
|
---|
14 | protected TTCN3Comment comment = null;
|
---|
15 | protected String name = "";
|
---|
16 | protected String location = "";
|
---|
17 | protected String paramView = "";
|
---|
18 | protected String refs = "";
|
---|
19 | protected String path = "";
|
---|
20 | private LinkedList <String[]> descs = new LinkedList<String[]>();
|
---|
21 |
|
---|
22 | public TTCN3Element() {
|
---|
23 |
|
---|
24 | }
|
---|
25 |
|
---|
26 | //TODO: using type codes will be presumably preferable
|
---|
27 | //TODO: HELP!!! THIS IS A DISASTER!!!!! REORGANIZE AND REFACTOR
|
---|
28 | public TTCN3Element(String name, String type, String location,
|
---|
29 | String behaviour, TTCN3Comment comment,
|
---|
30 | LinkedList <String> parNames, String filename, String paramView, String path, int line){
|
---|
31 | this.name = name;
|
---|
32 | this.location = location;
|
---|
33 | this.behaviour = behaviour;
|
---|
34 | this.comment = comment;
|
---|
35 | this.type = type;
|
---|
36 | this.paramView = paramView;
|
---|
37 | this.path = path;
|
---|
38 |
|
---|
39 | for(String warning : comment.getWarnings()) {
|
---|
40 |
|
---|
41 | // TODO: revise XML usage
|
---|
42 | // T3D.printLog(LEVEL0, filename, line, line, 1, warning);
|
---|
43 | T3D.getLoggingInterface().logWarning(line, line, MessageClass.DOCUMENTATION, warning);
|
---|
44 | }
|
---|
45 |
|
---|
46 | LinkedList <String> descsStrings = comment.getDescriptions();
|
---|
47 | for(String descString : descsStrings){
|
---|
48 | String[] descArray = {descString, filename, "" + line};
|
---|
49 | descs.add(descArray);
|
---|
50 | }
|
---|
51 |
|
---|
52 |
|
---|
53 |
|
---|
54 | LinkedList <String> docParNames = comment.getDocumentedParameters();
|
---|
55 |
|
---|
56 |
|
---|
57 | LinkedList <String> unDocParNames = new LinkedList<String>();
|
---|
58 | LinkedList <String> docUnparNames = new LinkedList<String>();
|
---|
59 | if(!parNames.isEmpty() && T3D.activeProfile.isCheckUndocumentedParameters()){
|
---|
60 | for(String parString : parNames){
|
---|
61 | boolean isDocumented = false;
|
---|
62 | for(String docParString : docParNames){
|
---|
63 | if(parString.startsWith(docParString + " "))
|
---|
64 | isDocumented = true;
|
---|
65 | }
|
---|
66 | if(!isDocumented)
|
---|
67 | unDocParNames.add(parString);
|
---|
68 | }
|
---|
69 |
|
---|
70 |
|
---|
71 | for(String docParString : docParNames){
|
---|
72 | boolean isParameter = false;
|
---|
73 | for(String parString : parNames){
|
---|
74 | if(parString.startsWith(docParString + " "))
|
---|
75 | isParameter = true;
|
---|
76 | }
|
---|
77 | if(!isParameter)
|
---|
78 | docUnparNames.add(docParString);
|
---|
79 | }
|
---|
80 |
|
---|
81 | for(String s : unDocParNames){
|
---|
82 | String parName = s.substring(0, s.indexOf(' '));
|
---|
83 | Integer parLine = Integer.valueOf(s.substring(s.indexOf(' ')+1)).intValue();
|
---|
84 | String warning = "Undocumented parameter found: " + parName ;
|
---|
85 | // TODO: review XML usage
|
---|
86 | // T3D.printLog(LEVEL0, filename, parLine, parLine, 1, warning);
|
---|
87 | T3D.getLoggingInterface().logWarning(parLine, parLine, MessageClass.DOCUMENTATION, warning);
|
---|
88 | }
|
---|
89 |
|
---|
90 | for(String s : docUnparNames){
|
---|
91 | String warning = "Documented parameter not found: " + s ;
|
---|
92 | //TODO: review XML usage
|
---|
93 | // T3D.printLog(LEVEL0, filename, line, line, 1, warning);
|
---|
94 | T3D.getLoggingInterface().logWarning(line, line, MessageClass.DOCUMENTATION, warning);
|
---|
95 |
|
---|
96 | }
|
---|
97 | }
|
---|
98 | }
|
---|
99 |
|
---|
100 | public String toXML(String currentModule){
|
---|
101 | return "<element type=\"" + type + "\">\n" +
|
---|
102 | "<name>" + name + "</name>\n" +
|
---|
103 | "<location>" + location + "</location>\n" +
|
---|
104 | comment.toString() +
|
---|
105 | "<behaviour>" + behaviour.replaceAll("<tab/>", " ") + "</behaviour>" +
|
---|
106 | "<modulename>" + currentModule + "</modulename>" +
|
---|
107 | paramView +
|
---|
108 | refs +
|
---|
109 | path +
|
---|
110 | "</element>";
|
---|
111 | }
|
---|
112 |
|
---|
113 | public String getType(){
|
---|
114 | return type;
|
---|
115 | }
|
---|
116 | public LinkedList<String[]> getDescs() {
|
---|
117 | return descs;
|
---|
118 | }
|
---|
119 | public String getName(){
|
---|
120 | return name;
|
---|
121 | }
|
---|
122 | public String getLocation(){
|
---|
123 | return location;
|
---|
124 | }
|
---|
125 | }
|
---|