minor fix
[cdsspec-compiler.git] / src / edu / uci / eecs / specExtraction / QualifiedName.java
1 package edu.uci.eecs.specExtraction;
2
3 /**
4  * <p>
5  * This class represents a qualified variable name in C++, e.g.
6  * Base::Mine::func. We use this class in the FunctionHeader class to represent
7  * the name of the function. However, for the sake of simplicity in usage, we
8  * only use it as a plain string with the bareName.
9  * </p>
10  * 
11  * @author Peizhao Ou
12  * 
13  */
14 public class QualifiedName {
15         // The full name --- Base::Mine::func
16         public final String fullName;
17         // The bare name --- func
18         public final String bareName;
19         // The qualified name --- Base::Mine
20         public final String qualifiedName;
21
22         public QualifiedName(String fullName) {
23                 this.fullName = fullName;
24                 this.bareName = getBareName();
25                 this.qualifiedName = getQualifiedName();
26         }
27
28         private String getBareName() {
29                 int beginIdx;
30                 beginIdx = fullName.lastIndexOf(':');
31                 if (beginIdx == -1)
32                         return fullName;
33                 else
34                         return fullName.substring(beginIdx + 1);
35         }
36
37         private String getQualifiedName() {
38                 int endIdx = fullName.lastIndexOf(bareName);
39                 if (endIdx == 0)
40                         return "";
41                 return fullName.substring(0, endIdx);
42         }
43
44         public String toString() {
45                 return fullName + "\n" + bareName;
46         }
47 }