Calculates the column and line number in a string.
()
| 99 | * Calculates the column and line number in a string. |
| 100 | */ |
| 101 | private void init() { |
| 102 | // positions have already been calculated |
| 103 | if(line != 0) return; |
| 104 | |
| 105 | final int cl = Math.min(column, input.length); |
| 106 | int l = 1, c = 1; |
| 107 | for(int i = 0; i < cl; i++) { |
| 108 | final int cp = input[i]; |
| 109 | if(cp == '\n') { l++; c = 1; } else { c++; } |
| 110 | } |
| 111 | line = l; |
| 112 | column = c; |
| 113 | } |
| 114 | |
| 115 | /** |
| 116 | * Returns the check flag (invoked by {@link QueryError#get(InputInfo, Object...)}). |