1 52 53 package com.go.trove.io; 54 55 63 public class SourceInfo implements Cloneable , java.io.Serializable { 64 private int mLine; 65 private int mStartPosition; 66 private int mEndPosition; 67 68 public SourceInfo(int line, int startPos, int endPos) { 69 mLine = line; 70 mStartPosition = startPos; 71 mEndPosition = endPos; 72 } 73 74 77 public int getLine() { 78 return mLine; 79 } 80 81 85 public int getStartPosition() { 86 return mStartPosition; 87 } 88 89 93 public int getEndPosition() { 94 return mEndPosition; 95 } 96 97 101 public int getDetailPosition() { 102 return mStartPosition; 103 } 104 105 private SourceInfo copy() { 106 try { 107 return (SourceInfo)super.clone(); 108 } 109 catch (CloneNotSupportedException e) { 110 throw new RuntimeException (e.toString()); 112 } 113 } 114 115 118 public SourceInfo setEndPosition(int endPos) { 119 SourceInfo infoCopy = copy(); 120 infoCopy.mEndPosition = endPos; 121 return infoCopy; 122 } 123 124 127 public SourceInfo setEndPosition(SourceInfo info) { 128 return setEndPosition(info.getEndPosition()); 129 } 130 131 public String toString() { 132 StringBuffer buf = new StringBuffer (60); 133 134 buf.append("line="); 135 buf.append(getLine()); 136 buf.append(','); 137 buf.append("start="); 138 buf.append(getStartPosition()); 139 buf.append(','); 140 buf.append("end="); 141 buf.append(getEndPosition()); 142 buf.append(','); 143 buf.append("detail="); 144 buf.append(getDetailPosition()); 145 146 return buf.toString(); 147 } 148 } 149 | Popular Tags |