1 7 package org.hammurapi.inspectors.metrics; 8 9 import java.util.Iterator ; 10 import java.util.Vector ; 11 12 import org.w3c.dom.Document ; 13 import org.w3c.dom.Element ; 14 15 21 public class CodeMetric { 22 23 public String source_url = ""; 25 public int source_line = 0; 26 public int source_col = 0; 27 28 private String descriptonEntity = "NA"; 29 private String name = "NA"; 30 private String sourceURL; 31 private int number = 0; 32 private int ncss = 0; 33 private int function = 0; 34 private double functionAverage = 0.0; 35 private double classAverage = 0.0; 36 private Vector children = new Vector (); 37 38 39 public Element toDom(Document document){ 40 41 Element ret=document.createElement("SourceCodeMetric"+descriptonEntity); 42 ret.setAttribute("name", name); 43 try{ 44 if ( source_url != null && !"".equals (source_url) ){ 45 46 ret.setAttribute("source-url", source_url); 48 ret.setAttribute("line", String.valueOf(source_line)); 49 ret.setAttribute("col", String.valueOf(source_col)); 50 } else { 51 ret.setAttribute("line", "0" ); 52 ret.setAttribute("col", "0" ); 53 54 } 55 } catch ( Exception e){ 56 e.printStackTrace(); 57 } 58 59 Element entities=document.createElement("Entities"); 60 ret.appendChild(entities); 61 entities.setAttribute("number", String.valueOf(number)); 62 63 Element ncssE=document.createElement("NCSS"); 64 ret.appendChild(ncssE); 65 ncssE.setAttribute( "number", String.valueOf( this.ncss ) ); 66 67 68 Element functions=document.createElement("Functions"); 69 ret.appendChild(functions); 70 functions.setAttribute("number", String.valueOf(function)); 71 72 73 Iterator it=children.iterator(); 74 while (it.hasNext()){ 75 CodeMetric cm = (CodeMetric) it.next(); 76 ret.appendChild(cm.toDom(document)); 77 } 78 79 return ret; 80 } 81 82 public String toString(){ 83 StringBuffer sb = new StringBuffer (); 84 sb.append(descriptonEntity); 85 sb.append(" - "); 86 sb.append(this.name); 87 return sb.toString(); 88 } 89 90 93 public Vector getChildren() { 94 return children; 95 } 96 99 public void setChildren(Vector children) { 100 this.children = children; 101 } 102 105 public String getDescriptonEntity() { 106 return descriptonEntity; 107 } 108 111 public void setDescriptonEntity(String descriptonEntity) { 112 this.descriptonEntity = descriptonEntity; 113 } 114 117 public int getFunction() { 118 return function; 119 } 120 123 public void setFunction(int function) { 124 this.function = function; 125 } 126 129 public String getName() { 130 return name; 131 } 132 135 public void setName(String name) { 136 this.name = name; 137 } 138 141 public int getNcss() { 142 return ncss; 143 } 144 147 public void setNcss(int ncss) { 148 this.ncss = ncss; 149 } 150 153 public int getNumber() { 154 return number; 155 } 156 159 public void setNumber(int number) { 160 this.number = number; 161 } 162 163 166 public String getSrcCodeUrl() { 167 return source_url; 168 } 169 170 } 171 | Popular Tags |