001/*
002 *  jDTAUS Banking SPI
003 *  Copyright (C) 2005 Christian Schulte
004 *  <cs@schulte.it>
005 *
006 *  This library is free software; you can redistribute it and/or
007 *  modify it under the terms of the GNU Lesser General Public
008 *  License as published by the Free Software Foundation; either
009 *  version 2.1 of the License, or any later version.
010 *
011 *  This library is distributed in the hope that it will be useful,
012 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
013 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014 *  Lesser General Public License for more details.
015 *
016 *  You should have received a copy of the GNU Lesser General Public
017 *  License along with this library; if not, write to the Free Software
018 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
019 *
020 */
021package org.jdtaus.banking.dtaus.spi;
022
023import java.io.IOException;
024import org.jdtaus.banking.dtaus.Header;
025import org.jdtaus.banking.dtaus.LogicalFile;
026
027/**
028 * Validates {@code Header} instances.
029 * <p>jDTAUS Banking SPI {@code HeaderValidator} specification to be used by implementations to validate {@code Header}
030 * instances to hold valid values.</p>
031 *
032 * @author <a href="mailto:cs@schulte.it">Christian Schulte</a>
033 * @version $JDTAUS: HeaderValidator.java 8661 2012-09-27 11:29:58Z schulte $
034 */
035public interface HeaderValidator
036{
037
038    /**
039     * Checks a given {@code Header} instance to hold valid values for creating a new {@code LogicalFile}.
040     *
041     * @param header The instance to check.
042     * @param result The validation result to be used or {@code null}.
043     *
044     * @return The validation result passed in as {@code result} (maybe {@code null} if the implementation did not
045     * detect illegal values).
046     *
047     * @throws NullPointerException if {@code header} is {@code null}.
048     */
049    IllegalHeaderException assertValidHeader( Header header, IllegalHeaderException result );
050
051    /**
052     * Checks a given {@code Header} instance to hold valid values for updating a given {@code LogicalFile} with.
053     *
054     * @param lFile The logical file to update with {@code header}.
055     * @param header The instance to check.
056     * @param counter A currency counter reflecting the state of {@code lFile}.
057     * @param result The validation result to be used or {@code null}.
058     *
059     * @return The validation result passed in as {@code result} (maybe {@code null} if the implementation did not
060     * detect illegal values).
061     *
062     * @throws NullPointerException if either {@code lFile}, {@code header} or {@code counter} is {@code null}.
063     * @throws IOException if reading fails.
064     */
065    IllegalHeaderException assertValidHeader( LogicalFile lFile, Header header, CurrencyCounter counter,
066                                              IllegalHeaderException result ) throws IOException;
067
068}