001 package org.hackystat.telemetry.analyzer.language.ast; 002 003 /** 004 * Text position indiating start and end location of telemetry definition. 005 * 006 * @author (Cedric) Qin ZHANG 007 * @version $Id$ 008 */ 009 public class TextPosition { 010 011 /** 012 * BeginLine and beginColumn describe the position of the first character 013 * of the text; endLine and endColumn describe the position of the 014 * last character of the text. 015 */ 016 private int beginLine, beginColumn, endLine, endColumn; 017 018 /** 019 * Constructs this instance. 020 * 021 * @param beginLine The row position of the first character of the text. 022 * @param beginColumn The column position of the first character of the text. 023 * @param endLine The row position of the last character of the text. 024 * @param endColumn The column position of the last character of the text. 025 */ 026 public TextPosition(int beginLine, int beginColumn, int endLine, int endColumn) { 027 this.beginLine = beginLine; 028 this.beginColumn = beginColumn; 029 this.endLine = endLine; 030 this.endColumn = endColumn; 031 } 032 033 /** 034 * Gets the row position of the first character of the text. 035 * @return The row position of the first character of the text. 036 */ 037 public int getBeginLine() { 038 return this.beginLine; 039 } 040 041 /** 042 * Gets the column position of the first character of the text. 043 * @return The column position of the first character of the text. 044 */ 045 public int getBeginColumn() { 046 return this.beginColumn; 047 } 048 049 /** 050 * Gets the row position of the last character of the text. 051 * @return The row position of the last character of the text. 052 */ 053 public int getEndLine() { 054 return this.endLine; 055 } 056 057 /** 058 * Gets the column position of the last character of the text. 059 * @return The column position of the last character of the text. 060 */ 061 public int getEndColumn() { 062 return this.endColumn; 063 } 064 065 /** 066 * Gets string representation of this instance. 067 * @return The string representation. 068 */ 069 @Override 070 public String toString() { 071 return "TextPosition: (" + this.beginLine + ", " + this.beginColumn + ") - (" 072 + this.endLine + ", " + this.endColumn + ")"; 073 } 074 }