more changes
[cdsspec-compiler.git] / src / edu / uci / eecs / specCompiler / specExtraction / SpecConstruct.java
1 package edu.uci.eecs.specCompiler.specExtraction;
2
3 import java.io.File;
4
5 /**
6  * <p>
7  * This class represents the plain context for each specification construct.
8  * Besides, it also stores some useful information such as interfaceDeclBody,
9  * which is used in @Interface construct to wrap and rename interface calls.
10  * </p>
11  * @author peizhaoo
12  *
13  */
14 public class SpecConstruct {
15         public final String plainText;
16         public final File file;
17         public final int beginLineNum;
18         public final int endLineNum;
19         public final String interfaceDeclBody;
20         public final Construct construct;
21         
22         public SpecConstruct(String plainText, File file,
23                         int beginLineNum, int endLineNum, Construct construct) {
24                 this.plainText = plainText;
25                 this.file = file;
26                 this.beginLineNum = beginLineNum;
27                 this.endLineNum = endLineNum;
28                 this.construct = construct;
29                 this.interfaceDeclBody = ""; 
30         }
31         
32         public SpecConstruct(String plainText, File file,
33                         int beginLineNum, int endLineNum, Construct construct,
34                         String interfaceDeclBody) {
35                 this.plainText = plainText;
36                 this.file = file;
37                 this.beginLineNum = beginLineNum;
38                 this.endLineNum = endLineNum;
39                 this.construct = construct;
40                 this.interfaceDeclBody = interfaceDeclBody; 
41         }
42         
43         public String toString() {
44                 StringBuilder sb = new StringBuilder();
45                 sb.append("File: " + file.getAbsolutePath() + "\n");
46                 sb.append("Begin: "
47                                 + beginLineNum + "  End: " + endLineNum + "\n");
48                 sb.append(construct);
49                 if (construct instanceof InterfaceConstruct
50                                 || construct instanceof InterfaceDefineConstruct) {
51                         sb.append("Function declaration: " + interfaceDeclBody);
52                 }
53                 return sb.toString();
54                 
55         }
56 }