[7] | 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 |
|
---|
| 40 |
|
---|
| 41 | for(String warning : comment.getWarnings()) {
|
---|
| 42 |
|
---|
| 43 | // TODO: revise XML usage
|
---|
| 44 | // T3D.printLog(LEVEL0, filename, line, line, 1, warning);
|
---|
| 45 | T3D.getLoggingInterface().logWarning(line, line, MessageClass.DOCUMENTATION, warning);
|
---|
| 46 | }
|
---|
| 47 |
|
---|
| 48 | LinkedList <String> descsStrings = comment.getDescriptions();
|
---|
| 49 | for(String descString : descsStrings){
|
---|
| 50 | String[] descArray = {descString, filename, "" + line};
|
---|
| 51 | descs.add(descArray);
|
---|
| 52 | }
|
---|
| 53 |
|
---|
| 54 |
|
---|
| 55 |
|
---|
| 56 | LinkedList <String> docParNames = comment.getDocumentedParameters();
|
---|
| 57 |
|
---|
| 58 |
|
---|
| 59 | LinkedList <String> unDocParNames = new LinkedList<String>();
|
---|
| 60 | LinkedList <String> docUnparNames = new LinkedList<String>();
|
---|
| 61 | if(!parNames.isEmpty() && T3D.activeProfile.isCheckUndocumentedParameters()){
|
---|
| 62 | for(String parString : parNames){
|
---|
| 63 | boolean isDocumented = false;
|
---|
| 64 | for(String docParString : docParNames){
|
---|
| 65 | if(parString.startsWith(docParString + " "))
|
---|
| 66 | isDocumented = true;
|
---|
| 67 | }
|
---|
| 68 | if(!isDocumented)
|
---|
| 69 | unDocParNames.add(parString);
|
---|
| 70 | }
|
---|
| 71 |
|
---|
| 72 |
|
---|
| 73 | for(String docParString : docParNames){
|
---|
| 74 | boolean isParameter = false;
|
---|
| 75 | for(String parString : parNames){
|
---|
| 76 | if(parString.startsWith(docParString + " "))
|
---|
| 77 | isParameter = true;
|
---|
| 78 | }
|
---|
| 79 | if(!isParameter)
|
---|
| 80 | docUnparNames.add(docParString);
|
---|
| 81 | }
|
---|
| 82 |
|
---|
| 83 | for(String s : unDocParNames){
|
---|
| 84 | String parName = s.substring(0, s.indexOf(' '));
|
---|
| 85 | Integer parLine = Integer.valueOf(s.substring(s.indexOf(' ')+1)).intValue();
|
---|
| 86 | String warning = "Undocumented parameter found: " + parName ;
|
---|
| 87 | // TODO: review XML usage
|
---|
| 88 | // T3D.printLog(LEVEL0, filename, parLine, parLine, 1, warning);
|
---|
| 89 | T3D.getLoggingInterface().logWarning(parLine, parLine, MessageClass.DOCUMENTATION, warning);
|
---|
| 90 | }
|
---|
| 91 |
|
---|
| 92 | for(String s : docUnparNames){
|
---|
| 93 | String warning = "Documented parameter not found: " + s ;
|
---|
| 94 | //TODO: review XML usage
|
---|
| 95 | // T3D.printLog(LEVEL0, filename, line, line, 1, warning);
|
---|
| 96 | T3D.getLoggingInterface().logWarning(line, line, MessageClass.DOCUMENTATION, warning);
|
---|
| 97 |
|
---|
| 98 | }
|
---|
| 99 | }
|
---|
| 100 | }
|
---|
| 101 |
|
---|
| 102 | public String toXML(String currentModule){
|
---|
| 103 | return "<element type=\"" + type + "\">\n" +
|
---|
| 104 | "<name>" + name + "</name>\n" +
|
---|
| 105 | "<location>" + location + "</location>\n" +
|
---|
| 106 | comment.toString() +
|
---|
| 107 | "<behaviour>" + behaviour.replaceAll("<tab/>", " ") + "</behaviour>" +
|
---|
| 108 | "<modulename>" + currentModule + "</modulename>" +
|
---|
| 109 | paramView +
|
---|
| 110 | refs +
|
---|
| 111 | path +
|
---|
| 112 | "</element>";
|
---|
| 113 | }
|
---|
| 114 |
|
---|
| 115 | public String getType(){
|
---|
| 116 | return type;
|
---|
| 117 | }
|
---|
| 118 | public LinkedList<String[]> getDescs() {
|
---|
| 119 | return descs;
|
---|
| 120 | }
|
---|
| 121 | public String getName(){
|
---|
| 122 | return name;
|
---|
| 123 | }
|
---|
| 124 | public String getLocation(){
|
---|
| 125 | return location;
|
---|
| 126 | }
|
---|
| 127 | }
|
---|