// $Id: FoundException.java,v 1.4 2004/02/27 16:30:00 m31 Exp $
//
// This file is part of the program suite "Principia Mathematica II"
// which is a working prototype for the main project:
// "Hilbert II" - http://www.qedeq.org
//
// Copyright 2001-2004  Michael Meyling <mime@qedeq.org>.
//
// "Principia Mathematica II" is free software; you can redistribute
// it and/or modify it under the terms of the GNU General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

package com.meyling.principia.argument;


/**
 * Helps constructing a parent list.
 *
 *
 * @version $Revision: 1.4 $
 * @author  Michael Meyling
 */
public class FoundException extends Exception {


    /** parent children list */
    private final VariableList list;


    /**
     * Constructs an argument exception, starts with an argument.
     *
     * @param  argument this argument is the deepest node
     */
    public FoundException(final Argument argument) {
        this.list = new VariableList( new Argument[] {} );
        this.list.add(argument);
    }


    /**
     * Constructs an argument exception, starts with an argument.
     *
     * @param   argument this argument is added as an parent
     * @throws  FoundException  throws itself again
     */
    public final void addAndThrow(final Argument argument)
            throws FoundException {
        this.list.add(argument);
        throw this;
    }


    /**
     * Get current parent children list.
     *
     * @return  parent children list
     */
    public final VariableList getList() {
        return this.list;
    }

    /**
     * Get last argument entry.
     *
     * @return  last argument
     */
    public final Argument getLastEntry() {
        return this.list.getArgument(list.getArgumentSize() - 1);
    }


}
