/** * Record a new captured variable. If it clashes with an existing one then report an error. */ private void recordCapturedVariable(int pos, String variableName) { if (this.capturedVariableNames == null) { this.capturedVariableNames = new ArrayList<>(); } if (this.capturedVariableNames.contains(variableName)) { throw new PatternParseException(pos, this.pathPatternData, PatternMessage.ILLEGAL_DOUBLE_CAPTURE, variableName); } this.capturedVariableNames.add(variableName); }
/** * Return a detailed message that includes the original pattern text * with a pointer to the error position, as well as the error message. */ public String toDetailedString() { StringBuilder buf = new StringBuilder(); buf.append(this.pattern).append('\n'); for (int i = 0; i < this.position; i++) { buf.append(' '); } buf.append("^\n"); buf.append(getMessage()); return buf.toString(); }
private void checkError(String pattern, int expectedPos, PatternMessage expectedMessage, String... expectedInserts) { try { pathPattern = parse(pattern); fail("Expected to fail"); } catch (PatternParseException ppe) { assertEquals(ppe.toDetailedString(), expectedPos, ppe.getPosition()); assertEquals(ppe.toDetailedString(), expectedMessage, ppe.getMessageType()); if (expectedInserts.length != 0) { assertEquals(ppe.getInserts().length, expectedInserts.length); for (int i = 0; i < expectedInserts.length; i++) { assertEquals("Insert at position " + i + " is wrong", expectedInserts[i], ppe.getInserts()[i]); } } } }
if (curlyBracketDepth == 0) { if (regexStart == this.pos) { throw new PatternParseException(regexStart, this.pathPatternData, PatternMessage.MISSING_REGEX_CONSTRAINT); throw new PatternParseException(this.pos, this.pathPatternData, PatternMessage.MISSING_CLOSE_CAPTURE); throw new PatternParseException(this.pos - 1, this.pathPatternData, PatternMessage.MISSING_CLOSE_CAPTURE);
/** * Return a detailed message that includes the original pattern text * with a pointer to the error position, as well as the error message. */ public String toDetailedString() { StringBuilder buf = new StringBuilder(); buf.append(this.pattern).append('\n'); for (int i = 0; i < this.position; i++) { buf.append(' '); } buf.append("^\n"); buf.append(getMessage()); return buf.toString(); }
/** * Record a new captured variable. If it clashes with an existing one then report an error. */ private void recordCapturedVariable(int pos, String variableName) { if (this.capturedVariableNames == null) { this.capturedVariableNames = new ArrayList<>(); } if (this.capturedVariableNames.contains(variableName)) { throw new PatternParseException(pos, this.pathPatternData, PatternMessage.ILLEGAL_DOUBLE_CAPTURE, variableName); } this.capturedVariableNames.add(variableName); }
/** * Return a detailed message that includes the original pattern text * with a pointer to the error position, as well as the error message. */ public String toDetailedString() { StringBuilder buf = new StringBuilder(); buf.append(this.pattern).append('\n'); for (int i = 0; i < this.position; i++) { buf.append(' '); } buf.append("^\n"); buf.append(getMessage()); return buf.toString(); }
if (curlyBracketDepth == 0) { if (regexStart == this.pos) { throw new PatternParseException(regexStart, this.pathPatternData, PatternMessage.MISSING_REGEX_CONSTRAINT); throw new PatternParseException(this.pos, this.pathPatternData, PatternMessage.MISSING_CLOSE_CAPTURE); throw new PatternParseException(this.pos - 1, this.pathPatternData, PatternMessage.MISSING_CLOSE_CAPTURE);
/** * Return a detailed message that includes the original pattern text * with a pointer to the error position, as well as the error message. */ public String toDetailedString() { StringBuilder buf = new StringBuilder(); buf.append(this.pattern).append('\n'); for (int i = 0; i < this.position; i++) { buf.append(' '); } buf.append("^\n"); buf.append(getMessage()); return buf.toString(); }
String variableName = matcher.group(1); if (this.variableNames.contains(variableName)) { throw new PatternParseException(this.pos, completePattern, PatternParseException.PatternMessage.ILLEGAL_DOUBLE_CAPTURE, variableName); String variableName = match.substring(1, colonIdx); if (this.variableNames.contains(variableName)) { throw new PatternParseException(this.pos, completePattern, PatternParseException.PatternMessage.ILLEGAL_DOUBLE_CAPTURE, variableName);
String variableName = matcher.group(1); if (this.variableNames.contains(variableName)) { throw new PatternParseException(this.pos, completePattern, PatternParseException.PatternMessage.ILLEGAL_DOUBLE_CAPTURE, variableName); String variableName = match.substring(1, colonIdx); if (this.variableNames.contains(variableName)) { throw new PatternParseException(this.pos, completePattern, PatternParseException.PatternMessage.ILLEGAL_DOUBLE_CAPTURE, variableName);
throw new PatternParseException(this.pos, this.pathPatternData, PatternMessage.ILLEGAL_NESTED_CAPTURE); throw new PatternParseException(this.pos, this.pathPatternData, PatternMessage.MISSING_OPEN_CAPTURE); throw new PatternParseException(this.pos + 1, this.pathPatternData, PatternMessage.NO_MORE_DATA_EXPECTED_AFTER_CAPTURE_THE_REST); if ((this.variableCaptureStart + 1 + (this.isCaptureTheRestVariable ? 1 : 0)) == this.pos && !Character.isJavaIdentifierStart(ch)) { throw new PatternParseException(this.pos, this.pathPatternData, PatternMessage.ILLEGAL_CHARACTER_AT_START_OF_CAPTURE_DESCRIPTOR, Character.toString(ch)); throw new PatternParseException(this.pos, this.pathPatternData, PatternMessage.ILLEGAL_CHARACTER_IN_CAPTURE_DESCRIPTOR, Character.toString(ch));
throw new PatternParseException(this.pos, this.pathPatternData, PatternMessage.ILLEGAL_NESTED_CAPTURE); throw new PatternParseException(this.pos, this.pathPatternData, PatternMessage.MISSING_OPEN_CAPTURE); throw new PatternParseException(this.pos + 1, this.pathPatternData, PatternMessage.NO_MORE_DATA_EXPECTED_AFTER_CAPTURE_THE_REST); if ((this.variableCaptureStart + 1 + (this.isCaptureTheRestVariable ? 1 : 0)) == this.pos && !Character.isJavaIdentifierStart(ch)) { throw new PatternParseException(this.pos, this.pathPatternData, PatternMessage.ILLEGAL_CHARACTER_AT_START_OF_CAPTURE_DESCRIPTOR, Character.toString(ch)); throw new PatternParseException(this.pos, this.pathPatternData, PatternMessage.ILLEGAL_CHARACTER_IN_CAPTURE_DESCRIPTOR, Character.toString(ch));
throw new PatternParseException(this.pos, this.pathPatternData, PatternMessage.MISSING_CLOSE_CAPTURE); throw new PatternParseException(pse, findRegexStart(this.pathPatternData, this.pathElementStart) + pse.getIndex(), this.pathPatternData, PatternMessage.REGEX_PATTERN_SYNTAX_EXCEPTION); throw new PatternParseException(this.pathElementStart, this.pathPatternData, PatternMessage.CAPTURE_ALL_IS_STANDALONE_CONSTRUCT);
throw new PatternParseException(this.pos, this.pathPatternData, PatternMessage.MISSING_CLOSE_CAPTURE); throw new PatternParseException(pse, findRegexStart(this.pathPatternData, this.pathElementStart) + pse.getIndex(), this.pathPatternData, PatternMessage.REGEX_PATTERN_SYNTAX_EXCEPTION); throw new PatternParseException(this.pathElementStart, this.pathPatternData, PatternMessage.CAPTURE_ALL_IS_STANDALONE_CONSTRUCT);
/** * Record a new captured variable. If it clashes with an existing one then report an error. */ private void recordCapturedVariable(int pos, String variableName) { if (this.capturedVariableNames == null) { this.capturedVariableNames = new ArrayList<>(); } if (this.capturedVariableNames.contains(variableName)) { throw new PatternParseException(pos, this.pathPatternData, PatternMessage.ILLEGAL_DOUBLE_CAPTURE, variableName); } this.capturedVariableNames.add(variableName); }
/** * Record a new captured variable. If it clashes with an existing one then report an error. */ private void recordCapturedVariable(int pos, String variableName) { if (this.capturedVariableNames == null) { this.capturedVariableNames = new ArrayList<>(); } if (this.capturedVariableNames.contains(variableName)) { throw new PatternParseException(pos, this.pathPatternData, PatternMessage.ILLEGAL_DOUBLE_CAPTURE, variableName); } this.capturedVariableNames.add(variableName); }
if (curlyBracketDepth == 0) { if (regexStart == this.pos) { throw new PatternParseException(regexStart, this.pathPatternData, PatternMessage.MISSING_REGEX_CONSTRAINT); throw new PatternParseException(this.pos, this.pathPatternData, PatternMessage.MISSING_CLOSE_CAPTURE); throw new PatternParseException(this.pos - 1, this.pathPatternData, PatternMessage.MISSING_CLOSE_CAPTURE);
if (curlyBracketDepth == 0) { if (regexStart == this.pos) { throw new PatternParseException(regexStart, this.pathPatternData, PatternMessage.MISSING_REGEX_CONSTRAINT); throw new PatternParseException(this.pos, this.pathPatternData, PatternMessage.MISSING_CLOSE_CAPTURE); throw new PatternParseException(this.pos - 1, this.pathPatternData, PatternMessage.MISSING_CLOSE_CAPTURE);
String variableName = matcher.group(1); if (this.variableNames.contains(variableName)) { throw new PatternParseException(this.pos, completePattern, PatternParseException.PatternMessage.ILLEGAL_DOUBLE_CAPTURE, variableName); String variableName = match.substring(1, colonIdx); if (this.variableNames.contains(variableName)) { throw new PatternParseException(this.pos, completePattern, PatternParseException.PatternMessage.ILLEGAL_DOUBLE_CAPTURE, variableName);