Skip to content

Commit

Permalink
working on output
Browse files Browse the repository at this point in the history
  • Loading branch information
bkarak committed Mar 30, 2014
1 parent 8085db1 commit 1cfd561
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
9 changes: 7 additions & 2 deletions src/org/jsloc/output/AbstractOutput.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import org.jsloc.project.ProjectStatistics;
import org.jsloc.project.Resource;
Expand All @@ -38,8 +39,8 @@
*/
public abstract class AbstractOutput {
protected ProjectStatistics projectStatistics;
protected ArrayList<ResourceValue> sortedLoC;
protected ArrayList<ResourceValue> sortedFiles;
private ArrayList<ResourceValue> sortedLoC;
private ArrayList<ResourceValue> sortedFiles;

protected AbstractOutput(ProjectStatistics ps) {
this.projectStatistics = ps;
Expand All @@ -53,12 +54,16 @@ protected AbstractOutput(ProjectStatistics ps) {
if(r.isText()) {
sortedLoC.add(new ResourceValue(r, ps.getLOC(r)));
}

sortedFiles.add(new ResourceValue(r, ps.getFileCount(r)));
}

Collections.sort(sortedLoC, new ResourceValue());
Collections.sort(sortedFiles, new ResourceValue());
}

public List<ResourceValue> getResourcesByLoc() { return Collections.unmodifiableList(sortedLoC); }
public List<ResourceValue> getResourcesByFiles() { return Collections.unmodifiableList(sortedFiles); }

public abstract void produce();
}
12 changes: 7 additions & 5 deletions src/org/jsloc/output/FileOutput.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,23 @@ public FileOutput(ProjectStatistics ps) {

@Override
public void produce() {
long totalFiles = this.projectStatistics.getTotalFileCount();
StringBuilder fileStatistics = new StringBuilder(),
sizeStatistics = new StringBuilder();

fileStatistics.append("Resource Type,File Count,Total File Count\n");
sizeStatistics.append("Resource Type,Source Lines of Code,Comments Lines of Code\n");

for ( ResourceValue lv : sortedFiles ) {
for ( ResourceValue lv : this.getResourcesByLoc() ) {
if (lv.getResource() == Resource.OTHER) { continue; }

List<String> values = Arrays.asList(lv.getResource().getName(), String.valueOf(lv.getValue()), String.valueOf(totalFiles));
List<String> values = Arrays.asList(lv.getResource().getName(),
String.valueOf(lv.getValue()),
String.valueOf(this.projectStatistics.getTotalFileCount()));
fileStatistics.append(StringUtil.join(",", values)).append("\n");
}

for ( ResourceValue lv : sortedLoC ) {
sizeStatistics.append("Resource Type,Source Lines of Code,Comments Lines of Code\n");

for ( ResourceValue lv : this.getResourcesByFiles() ) {
List<String> values = Arrays.asList(lv.getResource().getName(),
String.valueOf(lv.getValue()),
String.valueOf(this.projectStatistics.getLOCOM(lv.getResource())));
Expand Down

0 comments on commit 1cfd561

Please sign in to comment.