001/* 002 * Copyright (C) 2009-2011 Mathias Doenitz 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package org.parboiled.errors; 018 019import org.parboiled.buffers.InputBuffer; 020import org.parboiled.support.MatcherPath; 021import org.parboiled.common.Preconditions; 022import org.parboiled.support.MatcherPath; 023 024import java.util.List; 025 026import static org.parboiled.common.Preconditions.checkArgNotNull; 027 028/** 029 * A {@link ParseError} describing one or more input characters that are illegal with regard to the underlying 030 * language grammar. 031 */ 032public class InvalidInputError extends BasicParseError { 033 private final List<MatcherPath> failedMatchers; 034 035 public InvalidInputError(InputBuffer inputBuffer, int startIndex, 036 List<MatcherPath> failedMatchers, String errorMessage) { 037 super(Preconditions.checkArgNotNull(inputBuffer, "inputBuffer"), startIndex, errorMessage); 038 this.failedMatchers = Preconditions.checkArgNotNull(failedMatchers, "failedMatchers"); 039 } 040 041 /** 042 * Gets the list of paths to the single character matchers that failed at the error location of this error. 043 * 044 * @return the list of paths to the single character matchers that failed at the error location of this error 045 */ 046 public List<MatcherPath> getFailedMatchers() { 047 return failedMatchers; 048 } 049} 050