1 26 27 package net.sourceforge.groboutils.codecoverage.v2.datastore; 28 29 import net.sourceforge.groboutils.codecoverage.v2.IAnalysisMetaData; 30 31 39 public class MarkRecord 40 { 41 private IAnalysisMetaData amd; 42 private String analysisModule; 43 private String methodSignature; 44 private short markIndex; 45 46 private short amIndex = -1; 47 private short methIndex = -1; 48 private int lineNo = -1; 49 50 51 57 public MarkRecord( IAnalysisMetaData data, String am, String methSig, 58 short markId, int lineNumber ) 59 { 60 if (data == null || am == null || methSig == null) 61 { 62 throw new IllegalArgumentException ( "No null args." ); 63 } 64 if (markId < 0) 65 { 66 throw new IllegalArgumentException ( 67 "Indicies cannot be less than 0."); 68 } 69 this.amd = data; 70 this.analysisModule = am; 71 this.methodSignature = methSig; 72 this.markIndex = markId; 73 this.lineNo = lineNumber; 74 } 75 76 77 80 void processMark( ClassRecord cr, AnalysisModuleSet ams ) 81 { 82 if (cr == null) 83 { 84 throw new IllegalArgumentException ( "No null args." ); 85 } 86 if (ams == null) 87 { 88 ams = cr.getAnalysisModuleSet(); 89 } 90 this.amIndex = ams.getMeasureIndex( getAnalysisModule() ); 91 this.methIndex = cr.getMethodIndex( getMethodSignature() ); 92 } 93 94 95 public boolean equals( Object o ) 96 { 97 if (o == null || !(o instanceof MarkRecord)) 98 { 99 return false; 100 } 101 if (this == o) 102 { 103 return true; 104 } 105 106 MarkRecord mr = (MarkRecord)o; 108 if (mr.analysisModule.equals( this.analysisModule ) && 109 mr.methodSignature.equals( this.methodSignature ) && 110 mr.markIndex == this.markIndex) 111 { 112 return true; 114 } 115 return false; 117 } 118 119 120 public int hashCode() 121 { 122 return (int)this.markIndex + 123 this.analysisModule.hashCode() + 124 this.methodSignature.hashCode(); 125 } 126 127 128 public IAnalysisMetaData getAnalysisMetaData() 129 { 130 return this.amd; 131 } 132 133 134 public String getAnalysisModule() 135 { 136 return this.analysisModule; 137 } 138 139 140 public short getAnalysisModuleIndex() 141 { 142 if (this.amIndex < 0) 143 { 144 throw new IllegalStateException ( 145 "Never processed or unknown module '"+this.analysisModule+ 146 "'." ); 147 } 148 return this.amIndex; 149 } 150 151 152 public String getMethodSignature() 153 { 154 return this.methodSignature; 155 } 156 157 158 public short getMethodIndex() 159 { 160 if (this.methIndex < 0) 161 { 162 throw new IllegalStateException ( 163 "Never processed or unknown method '"+this.methodSignature+ 164 "'." ); 165 } 166 return this.methIndex; 167 } 168 169 170 public short getMarkIndex() 171 { 172 return this.markIndex; 173 } 174 175 176 public int getLineNumber() 177 { 178 return this.lineNo; 179 } 180 181 182 public String toString() 183 { 184 return "Mark Record: "+getMethodSignature()+", mark "+getMarkIndex(); 185 } 186 } 187 188 | Popular Tags |