Skip to content

Commit

Permalink
[JENKINS-13235] use commas in numbers for readability
Browse files Browse the repository at this point in the history
  • Loading branch information
ssogabe committed May 19, 2012
1 parent 158024d commit 7ef65b2
Show file tree
Hide file tree
Showing 10 changed files with 54 additions and 19 deletions.
6 changes: 4 additions & 2 deletions src/main/java/hudson/plugins/sloccount/model/Countable.java
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
*/ */
public interface Countable { public interface Countable {


public int getLineCount(); int getLineCount();


public String getName(); String getLineCountString();

String getName();


} }
5 changes: 5 additions & 0 deletions src/main/java/hudson/plugins/sloccount/model/File.java
Original file line number Original file line Diff line number Diff line change
@@ -1,5 +1,6 @@
package hudson.plugins.sloccount.model; package hudson.plugins.sloccount.model;


import hudson.plugins.sloccount.util.StringUtil;
import java.io.Serializable; import java.io.Serializable;


/** /**
Expand All @@ -22,6 +23,10 @@ public int getLineCount() {
return this.lineCount; return this.lineCount;
} }


public String getLineCountString() {
return StringUtil.grouping(getLineCount());
}

public String getName() { public String getName() {
return this.name; return this.name;
} }
Expand Down
12 changes: 11 additions & 1 deletion src/main/java/hudson/plugins/sloccount/model/FileContainer.java
Original file line number Original file line Diff line number Diff line change
@@ -1,5 +1,6 @@
package hudson.plugins.sloccount.model; package hudson.plugins.sloccount.model;


import hudson.plugins.sloccount.util.StringUtil;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
Expand All @@ -10,7 +11,7 @@
* *
* @author lordofthepigs * @author lordofthepigs
*/ */
public abstract class FileContainer implements Serializable { public abstract class FileContainer implements Countable, Serializable {


private Map<String, File> files = new LinkedHashMap<String, File>(); private Map<String, File> files = new LinkedHashMap<String, File>();
private int lineCount = 0; private int lineCount = 0;
Expand All @@ -27,6 +28,10 @@ public List<File> getFiles(){
public int getFileCount(){ public int getFileCount(){
return this.files.size(); return this.files.size();
} }

public String getFileCountString() {
return StringUtil.grouping(getFileCount());
}


public void addFile(File file){ public void addFile(File file){
this.files.put(file.getName(), file); this.files.put(file.getName(), file);
Expand All @@ -36,4 +41,9 @@ public void addFile(File file){
public int getLineCount(){ public int getLineCount(){
return this.lineCount; return this.lineCount;
} }

public String getLineCountString() {
return StringUtil.grouping(getLineCount());
}

} }
4 changes: 1 addition & 3 deletions src/main/java/hudson/plugins/sloccount/model/Folder.java
Original file line number Original file line Diff line number Diff line change
@@ -1,12 +1,10 @@
package hudson.plugins.sloccount.model; package hudson.plugins.sloccount.model;


import java.io.Serializable;

/** /**
* *
* @author lordofthepigs * @author lordofthepigs
*/ */
public class Folder extends FileContainer implements Countable, Serializable { public class Folder extends FileContainer {


private String name; private String name;


Expand Down
4 changes: 1 addition & 3 deletions src/main/java/hudson/plugins/sloccount/model/Language.java
Original file line number Original file line Diff line number Diff line change
@@ -1,12 +1,10 @@
package hudson.plugins.sloccount.model; package hudson.plugins.sloccount.model;


import java.io.Serializable;

/** /**
* *
* @author lordofthepigs * @author lordofthepigs
*/ */
public class Language extends FileContainer implements Countable, Serializable { public class Language extends FileContainer {


private String name; private String name;


Expand Down
Original file line number Original file line Diff line number Diff line change
@@ -1,6 +1,5 @@
package hudson.plugins.sloccount.model; package hudson.plugins.sloccount.model;


import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
Expand All @@ -10,7 +9,7 @@
* *
* @author lordofthepigs * @author lordofthepigs
*/ */
public class SloccountReport extends FileContainer implements Serializable { public class SloccountReport extends FileContainer {


private Map<String, Folder> folders = new LinkedHashMap<String, Folder>(); private Map<String, Folder> folders = new LinkedHashMap<String, Folder>();
private Map<String, Language> languages = new LinkedHashMap<String, Language>(); private Map<String, Language> languages = new LinkedHashMap<String, Language>();
Expand Down Expand Up @@ -175,4 +174,9 @@ public void simplifyNames(){
f.simplifyName(root); f.simplifyName(root);
} }
} }

public String getName() {
return "SlocCount Report";
}

} }
18 changes: 18 additions & 0 deletions src/main/java/hudson/plugins/sloccount/util/StringUtil.java
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,18 @@
package hudson.plugins.sloccount.util;

/**
* Utility
*
* @author ssogabe
*/
public class StringUtil {

private StringUtil() {
//
}

public static String grouping(int value) {
return String.format("%,d", value);
}

}
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
<tr> <tr>
<td class="pane">${container.name}</td> <td class="pane">${container.name}</td>
<td class="pane">${container.language}</td> <td class="pane">${container.language}</td>
<td class="pane number" data="${container.lineCount}">${container.lineCount}</td> <td class="pane number" data="${container.lineCount}">${container.lineCountString}</td>
<td class="pane"><st:include page="/tabview/distribution-graph.jelly" /></td> <td class="pane"><st:include page="/tabview/distribution-graph.jelly" /></td>
</tr> </tr>
</j:forEach> </j:forEach>
<tfoot> <tfoot>
<tr class="sortbottom"> <tr class="sortbottom">
<td class="pane-header">${%Total}</td> <td class="pane-header">${%Total}</td>
<td class="pane-header"> </td> <td class="pane-header"> </td>
<td class="pane-header number" data="${it.report.lineCount}">${it.report.lineCount}</td> <td class="pane-header number" data="${it.report.lineCount}">${it.report.lineCountString}</td>
<td class="pane-header"> </td> <td class="pane-header"> </td>
</tr> </tr>
</tfoot> </tfoot>
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@
<j:forEach var="container" items="${it.report.folders}"> <j:forEach var="container" items="${it.report.folders}">
<tr> <tr>
<td class="pane"><a href="folderResult/${container.urlName}">${container.name}</a></td> <td class="pane"><a href="folderResult/${container.urlName}">${container.name}</a></td>
<td class="pane number" data="${container.fileCount}">${container.fileCount}</td> <td class="pane number" data="${container.fileCount}">${container.fileCountString}</td>
<td class="pane number" data="${container.lineCount}">${container.lineCount}</td> <td class="pane number" data="${container.lineCount}">${container.lineCountString}</td>
<td class="pane"><st:include page="/tabview/distribution-graph.jelly" /></td> <td class="pane"><st:include page="/tabview/distribution-graph.jelly" /></td>
</tr> </tr>
</j:forEach> </j:forEach>
<tfoot> <tfoot>
<tr class="sortbottom"> <tr class="sortbottom">
<td class="pane-header">${%Total}</td> <td class="pane-header">${%Total}</td>
<td class="pane-header"> </td> <td class="pane-header"> </td>
<td class="pane-header number" data="${it.report.lineCount}">${it.report.lineCount}</td> <td class="pane-header number" data="${it.report.lineCount}">${it.report.lineCountString}</td>
<td class="pane-header"> </td> <td class="pane-header"> </td>
</tr> </tr>
</tfoot> </tfoot>
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@
<j:forEach var="container" items="${it.report.languages}"> <j:forEach var="container" items="${it.report.languages}">
<tr> <tr>
<td class="pane"><a href="languageResult/${container.name}">${container.name}</a></td> <td class="pane"><a href="languageResult/${container.name}">${container.name}</a></td>
<td class="pane number" data="${container.fileCount}">${container.fileCount}</td> <td class="pane number" data="${container.fileCount}">${container.fileCountString}</td>
<td class="pane number" data="${container.lineCount}">${container.lineCount}</td> <td class="pane number" data="${container.lineCount}">${container.lineCountString}</td>
<td class="pane"><st:include page="/tabview/distribution-graph.jelly" /></td> <td class="pane"><st:include page="/tabview/distribution-graph.jelly" /></td>
</tr> </tr>
</j:forEach> </j:forEach>
<tfoot> <tfoot>
<tr class="sortbottom"> <tr class="sortbottom">
<td class="pane-header">${%Total}</td> <td class="pane-header">${%Total}</td>
<td class="pane-header"> </td> <td class="pane-header"> </td>
<td class="pane-header number" data="${it.report.lineCount}">${it.report.lineCount}</td> <td class="pane-header number" data="${it.report.lineCount}">${it.report.lineCountString}</td>
<td class="pane-header"> </td> <td class="pane-header"> </td>
</tr> </tr>
</tfoot> </tfoot>
Expand Down

0 comments on commit 7ef65b2

Please sign in to comment.