001package org.hl7.fhir.utilities.json.model;
002
003public class JsonLocationData {
004  private int line;
005  private int col;
006  private int lastCol;
007  
008  public JsonLocationData(int line, int col) {
009    super();
010    this.line = line;
011    this.col = col;
012    this.lastCol = col;
013  }
014  
015  public int getLine() {
016    return line;
017  }
018  
019  public int getCol() {
020    return col;
021  }
022  
023  public void newLine() {
024    line++;
025    lastCol = col;
026    col = 1;    
027  }
028
029  public JsonLocationData copy() {
030    return new JsonLocationData(line, col);
031  }
032
033  public void incCol() {
034    col++;
035  }
036
037  @Override
038  public String toString() {
039    return "(" + line + ", " + col + ")";
040  }
041
042  public JsonLocationData prev() {
043    if (col == 1) {
044      return new JsonLocationData(line-1, lastCol);
045    } else {
046      return new JsonLocationData(line, col-1);
047    }
048  }
049
050  public void back() {
051    if (col == 1) {
052      line--;
053      col = lastCol;
054    } else {
055      col--;
056    }
057  }
058  
059}