1 2 29 package com.puppycrawl.tools.checkstyle.checks.usage.transmogrify; 30 31 import java.io.File ; 32 33 34 35 36 43 44 public class Reference implements Comparable { 45 46 private SymTabAST _node; 47 private Occurrence _occurrence; 48 49 public Reference( SymTabAST node ) { 50 _node = node; 51 _occurrence = new Occurrence( _node.getFile(), ASTUtil.getLine(_node), ASTUtil.getColumn(_node) ); 52 } 53 54 60 public IDefinition getDefinition() { 61 return _node.getDefinition(); 62 } 63 64 67 public SymTabAST getTreeNode() { 68 return _node; 69 } 70 71 76 public Occurrence getOccurrence() { 77 return _occurrence; 78 } 79 80 83 public int getLine() { 84 return getOccurrence().getLine(); 85 } 86 87 90 public int getColumn() { 91 return getOccurrence().getColumn(); 92 } 93 94 97 public File getFile() { 98 return getOccurrence().getFile(); 99 } 100 101 107 public String getName() { 108 return _node.getName(); 109 } 110 111 116 public String toString() { 117 return getOccurrence().toString(); 118 } 119 120 125 public boolean equals(Object obj){ 127 boolean result = false; 128 if (obj instanceof Reference) { 129 result = getOccurrence().equals(((Reference)obj).getOccurrence()); 130 } 131 return result; 132 } 133 134 public int compareTo(Object o) { 135 if (!(o instanceof Reference)) { 136 throw new ClassCastException (getClass().getName()); 137 } 138 139 return getOccurrence().compareTo(((Reference)o).getOccurrence()); 140 } 141 } 142 | Popular Tags |