001/* 002 * Copyright 2006-2014 the original author or authors. 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 * https://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 */ 016package org.springframework.batch.item.file.transform; 017 018/** 019 * Exception indicating that an incorrect number of tokens have been found 020 * while parsing a file. 021 * 022 * @author Lucas Ward 023 * @author "Michael Minella" 024 * @since 1.1 025 */ 026@SuppressWarnings("serial") 027public class IncorrectTokenCountException extends FlatFileFormatException { 028 029 private int actualCount; 030 private int expectedCount; 031 private String input; 032 033 public IncorrectTokenCountException(String message, int expectedCount, int actualCount, String input) { 034 super(message); 035 this.expectedCount = expectedCount; 036 this.actualCount = actualCount; 037 this.input = input; 038 } 039 040 public IncorrectTokenCountException(String message, int expectedCount, int actualCount) { 041 super(message); 042 this.expectedCount = expectedCount; 043 this.actualCount = actualCount; 044 } 045 046 public IncorrectTokenCountException(int expectedCount, int actualCount, String input) { 047 super("Incorrect number of tokens found in record: expected " + expectedCount + " actual " + actualCount); 048 this.expectedCount = expectedCount; 049 this.actualCount = actualCount; 050 this.input = input; 051 } 052 053 public IncorrectTokenCountException(int expectedCount, int actualCount) { 054 super("Incorrect number of tokens found in record: expected " + expectedCount + " actual " + actualCount); 055 this.actualCount = actualCount; 056 this.expectedCount = expectedCount; 057 } 058 059 public int getActualCount() { 060 return actualCount; 061 } 062 063 public int getExpectedCount() { 064 return expectedCount; 065 } 066 067 /** 068 * @return the line that caused the exception 069 * @since 2.2.6 070 */ 071 public String getInput() { return input; } 072}