Skip to content

Commit 6f76687

Browse files
committed
Jtratch: output fixes due to tableau issues, data: new release and script
1 parent 9509483 commit 6f76687

8 files changed

Lines changed: 78 additions & 46 deletions

File tree

src/main/java/ca/concordia/jtratch/pattern/CatchDic.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public void PrintToFileCSV()
113113
{
114114
csvBW.write("id," + OpFeaturesKey + "ExceptionType,ParentMethod,ParentType,FilePath,StartLine");
115115
csvBW.newLine();
116-
metaCSVBW.write("id," + metaKey);
116+
metaCSVBW.write("id," + metaKey + "ExceptionType,ParentMethod,ParentType,FilePath,StartLine");
117117
metaCSVBW.newLine();
118118

119119
for (Map.Entry<String,CatchList> entry : this.entrySet())

src/main/java/ca/concordia/jtratch/pattern/CommonFeature.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ public CommonFeature()
3636
OperationFeatures.put("MethodEndLine", 0);
3737
OperationFeatures.put("MethodLOC", 0);
3838

39-
MetaInfo.put("FilePath", "'-filepath");
40-
MetaInfo.put("StartLine", "'-startline");
41-
MetaInfo.put("ExceptionType", "'-exceptiontype");
42-
MetaInfo.put("ParentType", "'-parenttype");
43-
MetaInfo.put("ParentMethod", "'-parentmethod");
39+
// MetaInfo.put("FilePath", "'-filepath");
40+
// MetaInfo.put("StartLine", "'-startline");
41+
// MetaInfo.put("ExceptionType", "'-exceptiontype");
42+
// MetaInfo.put("ParentType", "'-parenttype");
43+
// MetaInfo.put("ParentMethod", "'-parentmethod");
4444

4545
MetaInfo.put("TryLine", "'-tryline");
4646

@@ -84,10 +84,10 @@ public String PrintFeaturesCSV()
8484
{
8585
csv += (entry.getValue() + ",");
8686
}
87-
csv += (ExceptionType + ",");
88-
csv += (ParentMethod + ",");
89-
csv += (ParentType + ",");
90-
csv += (FilePath + ",");
87+
csv += '"' + (ExceptionType.replace(String.valueOf('"'),"") + '"' + ",");
88+
csv += '"' + (ParentMethod.replace(String.valueOf('"'),"") + '"' + ",");
89+
csv += '"' + (ParentType.replace(String.valueOf('"'),"") + '"' + ",");
90+
csv += '"' + (FilePath.replace(String.valueOf('"'),"") + '"' + ",");
9191
csv += (StartLine);
9292

9393
return csv;
@@ -100,11 +100,11 @@ public String PrintMetaInfoCSV()
100100
{
101101
csv += '"' + (entry.getValue().replace(String.valueOf('"'),"") + '"' + ",");
102102
}
103-
// csv += (ExceptionType + ",");
104-
// csv += (ParentMethod + ",");
105-
// csv += (ParentType + ",");
106-
// csv += (FilePath + ",");
107-
// csv += (StartLine);
103+
csv += '"' + (ExceptionType.replace(String.valueOf('"'),"") + '"' + ",");
104+
csv += '"' + (ParentMethod.replace(String.valueOf('"'),"") + '"' + ",");
105+
csv += '"' + (ParentType.replace(String.valueOf('"'),"") + '"' + ",");
106+
csv += '"' + (FilePath.replace(String.valueOf('"'),"") + '"' + ",");
107+
csv += (StartLine);
108108

109109
return csv;
110110
}

src/main/java/ca/concordia/jtratch/pattern/PossibleExceptionsBlock.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@ public String PrintFeaturesCSV()
3838
{
3939
csv += (entry.getValue() + ",");
4040
}
41-
csv += (ExceptionType + ",");
42-
csv += (CaughtType + ",");
43-
csv += (DeclaringMethod + ",");
44-
csv += (InvokedMethod + ",");
41+
csv += '"' + (ExceptionType.replace(String.valueOf('"'),"") + '"' + ",");
42+
csv += '"' + (CaughtType.replace(String.valueOf('"'),"") + '"' + ",");
43+
csv += '"' + (DeclaringMethod.replace(String.valueOf('"'),"") + '"' + ",");
44+
csv += '"' + (InvokedMethod.replace(String.valueOf('"'),"") + '"' + ",");
4545
csv += (InvokedMethodLine + ",");
46-
csv += (FilePath + ",");
46+
csv += '"' + (FilePath.replace(String.valueOf('"'),"") + '"' + ",");
4747
csv += (StartLine);
4848

4949
return csv;

src/main/java/ca/concordia/jtratch/pattern/PossibleExceptionsDic.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,15 @@ public void PrintToFileCSV()
4545
logger.info("Writing PossibleExceptionsBlock features into file...");
4646
Charset charset = Charset.forName("UTF-8");
4747
Path fileCSV = Paths.get(IOFile.CompleteFileNameOutput("PossibleExceptionsBlock.csv"));
48-
Path fileMetaCSV = Paths.get(IOFile.CompleteFileNameOutput("PossibleExceptionsBlock_Meta.csv"));
48+
// Path fileMetaCSV = Paths.get(IOFile.CompleteFileNameOutput("PossibleExceptionsBlock_Meta.csv"));
4949

5050
Integer possibleExceptionsId = 0;
51-
String metaKey = "";
51+
// String metaKey = "";
5252

53-
for ( String meta : PossibleExceptionsBlock.MetaKeys)
54-
{
55-
metaKey += (meta + ",");
56-
}
53+
// for ( String meta : PossibleExceptionsBlock.MetaKeys)
54+
// {
55+
// metaKey += (meta + ",");
56+
// }
5757

5858
String OpFeaturesKey = "";
5959

@@ -65,13 +65,13 @@ public void PrintToFileCSV()
6565
try
6666
(
6767
BufferedWriter csvBW = Files.newBufferedWriter(fileCSV, charset);
68-
BufferedWriter metaCSVBW = Files.newBufferedWriter(fileMetaCSV, charset);
68+
//BufferedWriter metaCSVBW = Files.newBufferedWriter(fileMetaCSV, charset);
6969
)
7070
{
71-
csvBW.write("id," + OpFeaturesKey + "ThrownType,CaughtType,DeclaringMethod,InvokedMethod,InvokedMethodLine,CatchFilePath,CatchStartLine");
71+
csvBW.write("id," + OpFeaturesKey + "ThrownType,CaughtType,DeclaringMethod,InvokedMethod,InvokedMethodLine,FilePath,StartLine");
7272
csvBW.newLine();
73-
metaCSVBW.write("id," + metaKey);
74-
metaCSVBW.newLine();
73+
// metaCSVBW.write("id," + metaKey);
74+
// metaCSVBW.newLine();
7575

7676
for (Map.Entry<String,PossibleExceptionsList> entry : this.entrySet())
7777
{
@@ -81,16 +81,16 @@ public void PrintToFileCSV()
8181
possibleExceptionsId++;
8282
csvBW.write(possibleExceptionsId + "," + possibleExceptionsBlock.PrintFeaturesCSV());
8383
csvBW.newLine();
84-
metaCSVBW.write(possibleExceptionsId + "," + possibleExceptionsBlock.PrintMetaInfoCSV());
85-
metaCSVBW.newLine();
84+
// metaCSVBW.write(possibleExceptionsId + "," + possibleExceptionsBlock.PrintMetaInfoCSV());
85+
// metaCSVBW.newLine();
8686

8787
}
8888
csvBW.flush();
89-
metaCSVBW.flush();
89+
// metaCSVBW.flush();
9090
}
9191

9292
csvBW.close();
93-
metaCSVBW.close();
93+
// metaCSVBW.close();
9494
logger.info("Writing done.");
9595

9696
} catch (IOException e) {

src/main/java/ca/concordia/jtratch/pattern/ThrowsBlock.java

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import java.util.ArrayList;
44
import java.util.List;
5+
import java.util.Map;
56

67
public class ThrowsBlock extends CommonFeature {
78
public static List<String> MetaKeys;
@@ -23,5 +24,36 @@ public ThrowsBlock()
2324
MetaKeys = new ArrayList<String>(MetaInfo.keySet());
2425
OpFeaturesKeys = new ArrayList<String>(OperationFeatures.keySet());
2526
}
26-
27+
28+
@Override
29+
public String PrintFeaturesCSV()
30+
{
31+
String csv = "";
32+
33+
for (Map.Entry<String, Integer> entry : OperationFeatures.entrySet())
34+
{
35+
csv += (entry.getValue() + ",");
36+
}
37+
csv += '"' + (ExceptionType.replace(String.valueOf('"'),"") + '"' + ",");
38+
csv += '"' + (FilePath.replace(String.valueOf('"'),"") + '"' + ",");
39+
csv += (StartLine);
40+
41+
return csv;
42+
}
43+
44+
@Override
45+
public String PrintMetaInfoCSV()
46+
{
47+
String csv = "";
48+
49+
for (Map.Entry<String, String> entry : MetaInfo.entrySet())
50+
{
51+
csv += '"' + (entry.getValue().replace(String.valueOf('"'),"") + '"' + ",");
52+
}
53+
csv += '"' + (ExceptionType.replace(String.valueOf('"'),"") + '"' + ",");
54+
csv += '"' + (FilePath.replace(String.valueOf('"'),"") + '"' + ",");
55+
csv += (StartLine);
56+
57+
return csv;
58+
}
2759
}

src/main/java/ca/concordia/jtratch/pattern/ThrowsDic.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ public void PrintToFileCSV()
6868
BufferedWriter metaCSVBW = Files.newBufferedWriter(fileMetaCSV, charset);
6969
)
7070
{
71-
csvBW.write("id," + OpFeaturesKey + "ExceptionType,ParentMethod,ParentType,FilePath,StartLine");
71+
csvBW.write("id," + OpFeaturesKey + "ExceptionType,FilePath,StartLine");
7272
csvBW.newLine();
73-
metaCSVBW.write("id," + metaKey);
73+
metaCSVBW.write("id," + metaKey + "ExceptionType,FilePath,StartLine");
7474
metaCSVBW.newLine();
7575

7676
for (Map.Entry<String,ThrowsList> entry : this.entrySet())

src/main/java/ca/concordia/jtratch/visitors/CatchVisitor.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public boolean visit(CatchClause node) {
5454
}
5555

5656
//Basic info:
57-
catchBlockInfo.MetaInfo.put("ExceptionType", catchBlockInfo.ExceptionType);
57+
//catchBlockInfo.MetaInfo.put("ExceptionType", catchBlockInfo.ExceptionType);
5858

5959
//Try info:
6060
TryStatement tryStatement = (TryStatement) node.getParent();
@@ -86,12 +86,12 @@ public boolean visit(CatchClause node) {
8686

8787
catchBlockInfo.FilePath = filePath;
8888
catchBlockInfo.StartLine = catchStartLine;
89-
catchBlockInfo.MetaInfo.put("FilePath", filePath);
90-
catchBlockInfo.MetaInfo.put("StartLine", catchStartLine.toString());
89+
//catchBlockInfo.MetaInfo.put("FilePath", filePath);
90+
//catchBlockInfo.MetaInfo.put("StartLine", catchStartLine.toString());
9191

9292
//Common Features - parent type
9393
catchBlockInfo.ParentType = ASTUtilities.findParentType(tryStatement);
94-
catchBlockInfo.MetaInfo.put("ParentType", catchBlockInfo.ParentType);
94+
//catchBlockInfo.MetaInfo.put("ParentType", catchBlockInfo.ParentType);
9595

9696
//Common Features - parent method
9797
ASTNode parentNode = ASTUtilities.findParentMethod(tryStatement);
@@ -114,7 +114,7 @@ public boolean visit(CatchClause node) {
114114
parentMethodName = "!UNEXPECTED_KIND!";
115115

116116
catchBlockInfo.ParentMethod = parentMethodName;
117-
catchBlockInfo.MetaInfo.put("ParentMethod", parentMethodName);
117+
//catchBlockInfo.MetaInfo.put("ParentMethod", parentMethodName);
118118

119119

120120
Integer parentMethodStartLine = tree.getLineNumber(parentStartPosition + 1);
@@ -392,8 +392,8 @@ private static void getExceptionFlows(List<PossibleExceptionsBlock> possibleExce
392392
possibleExceptionsBlockInfo.FilePath = flow.getCatchFilePath();
393393
possibleExceptionsBlockInfo.StartLine = flow.getCatchStartLine();
394394

395-
possibleExceptionsBlockInfo.MetaInfo.put("FilePath", flow.getCatchFilePath());
396-
possibleExceptionsBlockInfo.MetaInfo.put("StartLine", flow.getCatchStartLine().toString());
395+
//possibleExceptionsBlockInfo.MetaInfo.put("FilePath", flow.getCatchFilePath());
396+
//possibleExceptionsBlockInfo.MetaInfo.put("StartLine", flow.getCatchStartLine().toString());
397397

398398
int kind = ASTUtilities.findKind(flow.getThrownType(), tree);
399399
possibleExceptionsBlockInfo.OperationFeatures.put("Kind", kind);

src/main/java/ca/concordia/jtratch/visitors/MethodDeclarationVisitor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ public void evaluateThrownExceptionTypes (MethodDeclaration node, int size) {
6363

6464
throwsBlockInfo.FilePath = filePath;
6565
throwsBlockInfo.StartLine = startLine;
66-
throwsBlockInfo.MetaInfo.put("FilePath", filePath);
67-
throwsBlockInfo.MetaInfo.put("StartLine", startLine.toString());
66+
//throwsBlockInfo.MetaInfo.put("FilePath", filePath);
67+
//throwsBlockInfo.MetaInfo.put("StartLine", startLine.toString());
6868

6969
//NumExceptions
7070
throwsBlockInfo.OperationFeatures.put("NumExceptions", size);

0 commit comments

Comments
 (0)