private Position position() { return new Position(locator.getLineNumber(), locator.getColumnNumber()); }
@Override public boolean equals(Object obj) { if (obj == null) return false; if (obj == this) return true; if (!(obj instanceof DocElement)) return false; final DocElement that = (DocElement)obj; return this.qname().equals(that.qname()) && this.attributes.equals(that.attributes) && this.startPosition.equals(that.startPosition) && this.endPosition.equals(that.endPosition); }
public Position searchForward(final int startLine, final int startCol, final Pattern regex) { int loopStartLine = startLine; int loopStartCol = startCol; while (loopStartLine < this.lines.size()) { final String line = this.lines.get(loopStartLine); final Matcher matcher = regex.matcher(line); if (loopStartCol < line.length() && matcher.find(loopStartCol)) { // return next line, since we're zero indexed here, but 1 indexed for lines return new Position(loopStartLine + 1, matcher.start() + 1); } else { loopStartLine++; loopStartCol = 0; } } return null; }
firstPos.equals(pos)) {
public Position position() { return new Position(this.location.getLineNumber(), this.location.getColumnNumber()); }
public Position searchBackward(final int startLine, final int startCol, final Pattern regex) { int loopStartLine = startLine; int loopStartCol = startCol; while (loopStartLine >= 0) { final String line = this.lines.get(loopStartLine); final Matcher matcher = regex.matcher(line); if (loopStartCol >= line.length()) { loopStartCol = line.length() - 1; } if (loopStartCol >= 0 && matcher.find(loopStartCol)) { // return next line, since we're zero indexed here, but 1 indexed for lines return new Position(loopStartLine + 1, matcher.start() + 1); } else if (loopStartCol > 0) { loopStartCol--; } else { loopStartLine--; loopStartCol = Integer.MAX_VALUE; } } return null; }
private Position lastPosition = new Position(1, 2);