Changeset 1404
- Timestamp:
- 04/14/09 12:34:34 (3 years ago)
- Location:
- trunk
- Files:
-
- 7 modified
-
src/java/org/jcoderz/commons/types/EmailAddress.java (modified) (11 diffs)
-
src/java/org/jcoderz/phoenix/report/CheckstyleReportReader.java (modified) (3 diffs)
-
src/java/org/jcoderz/phoenix/report/EmmaReportReader.java (modified) (8 diffs)
-
src/java/org/jcoderz/phoenix/report/Java2Html.java (modified) (6 diffs)
-
src/java/org/jcoderz/phoenix/report/ReportMerger.java (modified) (4 diffs)
-
src/java/org/jcoderz/phoenix/report/ResourceInfo.java (modified) (1 diff)
-
test/java/org/jcoderz/commons/types/samples/BaseClassTest.java (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/java/org/jcoderz/commons/types/EmailAddress.java
r1205 r1404 91 91 * </pre> 92 92 * 93 * <p>The maximum length of an email address is: 64+1+255 characters (local-part + @ + domain). 94 * The minimum length of an email address is: 1+1+4 characters (local-part + @ + domain).</p> 93 * <p>The maximum length of an email address is: 94 * 64+1+255 characters (local-part + @ + domain). 95 * The minimum length of an email address is: 96 * 1+1+4 characters (local-part + @ + domain).</p> 95 97 * 96 98 * <p>A valid list of top-level domains is defined by the IANA. A top-level … … 123 125 private static final String LET_DIG = "[a-zA-Z0-9]"; 124 126 private static final String LET_DIG_HYP = "[a-zA-Z0-9-]"; 125 private static final String RFC_LABEL = LET_DIG + LET_DIG_HYP + "{0,61}" + LET_DIG; 126 private static final String DOMAIN = RFC_LABEL + "(\\." + RFC_LABEL + ")*\\." + LETTER + "{2,6}"; 127 private static final String RFC_LABEL 128 = LET_DIG + LET_DIG_HYP + "{0,61}" + LET_DIG; 129 private static final String DOMAIN 130 = RFC_LABEL + "(\\." + RFC_LABEL + ")*\\." + LETTER + "{2,6}"; 127 131 128 132 //Combined together, these form the allowed email regexp allowed by RFC 2822: … … 141 145 * @param email The email address. 142 146 */ 143 public EmailAddress (String email)147 public EmailAddress (String email) 144 148 { 145 149 Assert.notNull(email, "email"); … … 156 160 { 157 161 throw new ArgumentMalformedException("email", email, 158 "The local part is longer than " + MAX_LENGTH_LOCAL_PART + " characters!"); 162 "The local part is longer than " + MAX_LENGTH_LOCAL_PART 163 + " characters!"); 159 164 } 160 165 if (mail.length() - at - 1 > MAX_LENGTH_DOMAIN) 161 166 { 162 167 throw new ArgumentMalformedException("email", email, 163 "The domain is longer than " + MAX_LENGTH_DOMAIN + " characters!"); 168 "The domain is longer than " + MAX_LENGTH_DOMAIN 169 + " characters!"); 164 170 } 165 171 mLocalPart = mail.substring(0, at); … … 171 177 172 178 /** 173 * Factory method for converting a String into an instance of type EmailAddress. 179 * Factory method for converting a String into an instance of type 180 * EmailAddress. 174 181 * 175 182 * @param email the email address to parse … … 183 190 /** 184 191 * Returns the local part of the address. 185 *186 192 * @return the local part of the address. 187 193 */ 188 public String getName ()194 public String getName () 189 195 { 190 196 return mLocalPart; … … 194 200 /** 195 201 * Returns the domain name of the address. 196 *197 202 * @return the domain name of the address. 198 203 */ 199 public String getDomain ()204 public String getDomain () 200 205 { 201 206 return mDomain; … … 205 210 /** 206 211 * Returns the top-level domain name of the address. 207 *208 212 * @return the top-level domain name of the address. 209 213 */ 210 public String getTopLevelDomain ()214 public String getTopLevelDomain () 211 215 { 212 216 return mTopLevelDomain; 213 217 } 214 218 215 216 /**217 * Returns the full email address.218 *219 * @return the full email address.220 */221 public String getAddress()222 {223 return mLocalPart + "@" + mDomain;224 }225 219 226 220 /** … … 228 222 * @return the full email address. 229 223 */ 230 public String toString()224 public String getAddress () 231 225 { 232 226 return mLocalPart + "@" + mDomain; … … 234 228 235 229 /** 230 * Returns the full email address. 231 * @return the full email address. 232 */ 233 public String toString () 234 { 235 return mLocalPart + "@" + mDomain; 236 } 237 238 /** 236 239 * Returns the true if this email address equals the other. 240 * @param obj the object to compare to. 237 241 * @return the true if this email address equals the other. 238 242 * @see java.lang.Object#equals(java.lang.Object) 239 243 */ 240 public boolean equals (Object obj)244 public boolean equals (Object obj) 241 245 { 242 246 boolean result = false; … … 261 265 * @return the hash code for this email. 262 266 */ 263 public int hashCode ()267 public int hashCode () 264 268 { 265 269 int hashCode = HashCodeUtil.hash(HashCodeUtil.SEED, mLocalPart); -
trunk/src/java/org/jcoderz/phoenix/report/CheckstyleReportReader.java
r1310 r1404 46 46 import javax.xml.bind.JAXBException; 47 47 48 import org.jcoderz.commons.util.IoUtil; 48 49 import org.jcoderz.phoenix.checkstyle.jaxb.Checkstyle; 49 50 import org.jcoderz.phoenix.report.jaxb.Item; … … 81 82 throws FileNotFoundException, JAXBException 82 83 { 83 mReportDocument = (Checkstyle) getUnmarshaller().unmarshal( 84 new FileInputStream(f)); 84 final FileInputStream is = new FileInputStream(f); 85 try 86 { 87 mReportDocument 88 = (Checkstyle) getUnmarshaller().unmarshal(is); 89 } 90 finally 91 { 92 IoUtil.close(is); 93 } 85 94 } 86 95 … … 190 199 } 191 200 192 private static String sourceToClass (String source)201 private static String sourceToClass (String source) 193 202 { 194 203 final int i = source.lastIndexOf('.'); -
trunk/src/java/org/jcoderz/phoenix/report/EmmaReportReader.java
r1219 r1404 33 33 package org.jcoderz.phoenix.report; 34 34 35 import java.io.File; 36 import java.io.IOException; 37 import java.util.ArrayList; 38 import java.util.HashMap; 39 import java.util.Iterator; 40 import java.util.List; 41 import java.util.Map; 42 import java.util.Map.Entry; 43 import java.util.logging.Level; 44 import java.util.logging.Logger; 45 46 import javax.xml.bind.JAXBException; 47 48 import org.jcoderz.phoenix.report.jaxb.Item; 49 import org.jcoderz.phoenix.report.jaxb.ObjectFactory; 50 35 51 import com.vladium.emma.data.ClassDescriptor; 36 52 import com.vladium.emma.data.DataFactory; … … 40 56 import com.vladium.emma.data.MethodDescriptor; 41 57 import com.vladium.emma.data.ICoverageData.DataHolder; 42 43 import java.io.File;44 import java.io.IOException;45 import java.util.ArrayList;46 import java.util.HashMap;47 import java.util.HashSet;48 import java.util.Iterator;49 import java.util.List;50 import java.util.Map;51 import java.util.Set;52 import java.util.Map.Entry;53 import java.util.logging.Level;54 import java.util.logging.Logger;55 56 import javax.xml.bind.JAXBException;57 58 import org.jcoderz.phoenix.report.jaxb.Item;59 import org.jcoderz.phoenix.report.jaxb.ObjectFactory;60 58 61 59 /** … … 105 103 { 106 104 logger.warning( 107 "Read no meta data from emma in file '" + f + "'." );105 "Read no meta data from emma in file '" + f + "'."); 108 106 } 109 107 if (mEmmaCoverageData == null) 110 108 { 111 109 logger.warning( 112 "Read no coverage info from emma in file '" + f + "'." );110 "Read no coverage info from emma in file '" + f + "'."); 113 111 } 114 112 } … … 126 124 final Map itemMap = new HashMap(); 127 125 128 final Iterator i = mEmmaMetaData.iterator();126 final Iterator<ClassDescriptor> i = mEmmaMetaData.iterator(); 129 127 while (i.hasNext()) 130 128 { 131 ClassDescriptor clazz = (ClassDescriptor)i.next();129 final ClassDescriptor clazz = i.next(); 132 130 final String srcFileName = clazz.getSrcFileName(); 133 131 final String fileName; … … 210 208 final ClassDescriptor clazz, DataHolder coverage) 211 209 { 212 MethodDescriptor[] methods = clazz.getMethods();213 final Map<Integer, CoverageDetail> lineCoverage214 = new HashMap<Integer, CoverageDetail>();210 final MethodDescriptor[] methods = clazz.getMethods(); 211 final Map<Integer, CoverageDetail> lineCoverage 212 = new HashMap<Integer, CoverageDetail>(); 215 213 for (int methodNr = 0; methodNr < methods.length; methodNr++) 216 214 { … … 220 218 { 221 219 boolean[] methodCoverage = null; 222 if (coverage != null && coverage.m_coverage.length > methodNr)220 if (coverage != null && coverage.m_coverage.length > methodNr) 223 221 { 224 222 methodCoverage = coverage.m_coverage[methodNr]; … … 228 226 blockNr < map.length; blockNr++) 229 227 { 230 int[] blockLines = map[blockNr];228 final int[] blockLines = map[blockNr]; 231 229 if (methodCoverage != null 232 230 && methodCoverage.length > blockNr … … 313 311 314 312 315 private class CoverageDetail316 { 317 int mNotVisitedBranches;318 int mVisitedBranches;313 private static class CoverageDetail 314 { 315 private int mNotVisitedBranches; 316 private int mVisitedBranches; 319 317 } 320 318 } -
trunk/src/java/org/jcoderz/phoenix/report/Java2Html.java
r1400 r1404 75 75 76 76 /** 77 * TODO: Fix CVS links78 * TODO: Refactor!79 77 * TODO: Link to current build 80 78 * TODO: Link to CC home 81 79 * TODO: Add @media printer??? 82 * TODO: Add doku83 * TODO: Codestyle84 * TODO: Generate error group view85 80 * 86 81 * @author Andreas Mandel … … 113 108 private static final String SORT_BY_COVERAGE_INDEX = "index_c.html"; 114 109 115 /** Marker for ccs sty pes used as the last row in a table. */110 /** Marker for ccs styles used as the last row in a table. */ 116 111 private static final String LAST_MARKER = "_last"; 117 112 … … 436 431 mGlobalSummary = new FileSummary(); 437 432 438 // final Iterator files = report.getFile().iterator();439 440 433 for (final org.jcoderz.phoenix.report.jaxb.File file 441 434 : (List<org.jcoderz.phoenix.report.jaxb.File>) report.getFile()) … … 443 436 try 444 437 { 445 if (file.getName().endsWith(".java")) 446 { 447 // TODO parentDir = project-home (from jcoderz report xml) 448 java2html(new java.io.File(file.getName()), file); 449 } 450 else 451 { 452 mGlobalFindings.add(file); 453 } 438 java2html(new java.io.File(file.getName()), file); 454 439 } 455 440 catch (Exception ex) 456 441 { 457 442 logger.log(Level.SEVERE, 458 "Failed to generate report for '" + file.getName() + "'.", 459 ex); 443 "Failed to generate report for '" + file.getName() + "'.", ex); 460 444 mGlobalFindings.add(file); 461 445 } … … 485 469 sc.createCharts(); 486 470 487 // copy the stylesheet and the icons488 471 copyStylesheet(); 489 472 copyIcons(); … … 828 811 bw.write(" (" + pos + ")\n"); 829 812 bw.write(" </td>\n"); 830 bw.write(" <td></td><td></td><td></td>\n"); // line number813 bw.write(" <td></td><td></td><td></td>\n"); // line number 831 814 bw.write(" <td width='100%' class='findings-data'>\n"); 832 815 bw.write(XmlUtil.escape(item.getMessage())); -
trunk/src/java/org/jcoderz/phoenix/report/ReportMerger.java
r1393 r1404 194 194 } 195 195 196 private void findNewFindings (org.jcoderz.phoenix.report.jaxb.File newFile,196 private void findNewFindings (org.jcoderz.phoenix.report.jaxb.File newFile, 197 197 org.jcoderz.phoenix.report.jaxb.File oldFile) 198 198 { … … 209 209 // the rest... 210 210 flaggAllAsNew(newFindings); 211 for (Item item:(List<Item>) oldFindings)211 for (Item item : (List<Item>) oldFindings) 212 212 { 213 213 addAsOld(newFile.getItem(), item); … … 218 218 private void flaggAllAsNew (final List<Item> newFindings) 219 219 { 220 for (Item item:(List<Item>) newFindings)220 for (Item item : (List<Item>) newFindings) 221 221 { 222 222 if (item.getSeverity().getPenalty() > 0 … … 325 325 final String fileName = newFile.getName(); 326 326 org.jcoderz.phoenix.report.jaxb.File result = null; 327 for (org.jcoderz.phoenix.report.jaxb.File file :327 for (org.jcoderz.phoenix.report.jaxb.File file : 328 328 (List<org.jcoderz.phoenix.report.jaxb.File>) oldReport.getFile()) 329 329 { -
trunk/src/java/org/jcoderz/phoenix/report/ResourceInfo.java
r1047 r1404 158 158 { 159 159 ResourceInfo result = null; 160 for (ResourceInfo resource : RESOURCES.values())160 for (ResourceInfo resource : RESOURCES.values()) 161 161 { 162 162 if (resource.getClassname().equals(className) -
trunk/test/java/org/jcoderz/commons/types/samples/BaseClassTest.java
r1293 r1404 45 45 { 46 46 /** 47 * Test the inheritance should call super.equals() ;47 * Test the inheritance should call super.equals(). 48 48 */ 49 public void testInheritanceEquals ()49 public void testInheritanceEquals () 50 50 { 51 51 final SampleValueObject value = new SampleValueObject(); … … 62 62 63 63 /** 64 * Test the inheritance should call super.hashCode() ;64 * Test the inheritance should call super.hashCode(). 65 65 */ 66 public void testInheritanceHashCode ()66 public void testInheritanceHashCode () 67 67 { 68 68 final SampleValueObject value = new SampleValueObject(); … … 74 74 value2.setTestValueBase(0); 75 75 76 assert True("Base class fields not honored in hash code.",77 value.hashCode() != value2.hashCode());76 assertFalse("Base class fields not honored in hash code.", 77 value.hashCode() == value2.hashCode()); 78 78 } 79 79 80 80 /** 81 * Test the inheritance should call super.toString() ;81 * Test the inheritance should call super.toString(). 82 82 */ 83 public void testInheritanceToString ()83 public void testInheritanceToString () 84 84 { 85 85 final SampleValueObject value = new SampleValueObject(); … … 88 88 89 89 assertTrue("Can't see base class fields in string output.", 90 value.toString().indexOf( "0") > -1);90 value.toString().indexOf('0') > -1); 91 91 } 92 92 }
