/** Given index into string, compute the line and char position in line */ public static Coordinate getLineCharPosition(String s, int index) { int line = 1; int charPos = 0; int p = 0; while ( p < index ) { // don't care about s[index] itself; count before if ( s.charAt(p)=='\n' ) { line++; charPos=0; } else charPos++; p++; } return new Coordinate(line,charPos); }
/** * Given {@code index} into string {@code s}, compute the line and char * position in line. */ public static Coordinate getLineCharPosition(String s, int index) { int line = 1; int charPos = 0; int p = 0; while ( p < index ) { // don't care about s[index] itself; count before if ( s.charAt(p)=='\n' ) { line++; charPos=0; } else charPos++; p++; } return new Coordinate(line,charPos); } }
/** * Given {@code index} into string {@code s}, compute the line and char * position in line. */ public static Coordinate getLineCharPosition(String s, int index) { int line = 1; int charPos = 0; int p = 0; while ( p < index ) { // don't care about s[index] itself; count before if ( s.charAt(p)=='\n' ) { line++; charPos=0; } else charPos++; p++; } return new Coordinate(line,charPos); } }
/** * Given {@code index} into string {@code s}, compute the line and char * position in line. */ public static Coordinate getLineCharPosition(String s, int index) { int line = 1; int charPos = 0; int p = 0; while ( p < index ) { // don't care about s[index] itself; count before if ( s.charAt(p)=='\n' ) { line++; charPos=0; } else charPos++; p++; } return new Coordinate(line,charPos); } }
/** * Given {@code index} into string {@code s}, compute the line and char * position in line. */ public static Coordinate getLineCharPosition(String s, int index) { int line = 1; int charPos = 0; int p = 0; while ( p < index ) { // don't care about s[index] itself; count before if ( s.charAt(p)=='\n' ) { line++; charPos=0; } else charPos++; p++; } return new Coordinate(line,charPos); } }
/** * Given {@code index} into string {@code s}, compute the line and char * position in line. */ public static Coordinate getLineCharPosition(String s, int index) { int line = 1; int charPos = 0; int p = 0; while ( p < index ) { // don't care about s[index] itself; count before if ( s.charAt(p)=='\n' ) { line++; charPos=0; } else charPos++; p++; } return new Coordinate(line,charPos); } }
/** * Given {@code index} into string {@code s}, compute the line and char * position in line. */ public static Coordinate getLineCharPosition(String s, int index) { int line = 1; int charPos = 0; int p = 0; while ( p < index ) { // don't care about s[index] itself; count before if ( s.charAt(p)=='\n' ) { line++; charPos=0; } else charPos++; p++; } return new Coordinate(line,charPos); } }
/** * Given {@code index} into string {@code s}, compute the line and char * position in line. */ public static Coordinate getLineCharPosition(String s, int index) { int line = 1; int charPos = 0; int p = 0; while ( p < index ) { // don't care about s[index] itself; count before if ( s.charAt(p)=='\n' ) { line++; charPos=0; } else charPos++; p++; } return new Coordinate(line,charPos); } }