001/*
002 * This file is part of OCaml-Java runtime.
003 * Copyright (C) 2007-2013 Xavier Clerc.
004 *
005 * OCaml-Java runtime is free software; you can redistribute it and/or modify
006 * it under the terms of the GNU Lesser General Public License as published by
007 * the Free Software Foundation; either version 3 of the License, or
008 * (at your option) any later version.
009 *
010 * OCaml-Java runtime is distributed in the hope that it will be useful,
011 * but WITHOUT ANY WARRANTY; without even the implied warranty of
012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
013 * GNU Lesser General Public License for more details.
014 *
015 * You should have received a copy of the GNU Lesser General Public License
016 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
017 */
018
019package org.ocamljava.runtime.wrappers;
020
021import org.ocamljava.runtime.kernel.FailException; import org.ocamljava.runtime.kernel.Fail;
022import org.ocamljava.runtime.values.Value;
023
024/**
025 * The {@code OCamlUndefinedRecursiveModuleException} class is the Java counterpart of
026 * the {@code Undefined_recursive_module} OCaml exception.
027 *
028 * @author <a href="mailto:xclerc@ocamljava.org">Xavier Clerc</a>
029 * @version 2.0
030 * @since 2.0
031 */
032public final class OCamlUndefinedRecursiveModuleException extends OCamlException {
033
034    /** Serialization UID. */
035    static final long serialVersionUID = -3852032773583037272L;
036
037    /** Exception file. */
038    private final String file;
039
040    /** Exception line. */
041    private final long line;
042
043    /** Exception column. */
044    private final long column;
045
046    /**
047     * Constructs a new instance.
048     * @param f exception file - should not be {@code null}
049     */
050    public OCamlUndefinedRecursiveModuleException(final String f, final long l, final long c) {
051        super(Fail.createWithArg(OCamlException.getTag("Undefined_recursive_module"),
052                                 Value.createBlock(0,
053                                                   Value.createString(f),
054                                                   Value.createLong(l),
055                                                   Value.createLong(c))));
056        assert f != null : "null f";
057        this.file = f;
058        this.line = l;
059        this.column = c;
060    } // end constructor(String, long, long)
061
062    /**
063     * Constructs a new instance based on the passed exception.
064     * @param fe original OCaml exception - should not be {@code null}
065     */
066    public OCamlUndefinedRecursiveModuleException(final FailException fe) {
067        super(fe);
068        final Value v = fe.getValue().get1();
069        this.file = v.get0().asString();
070        this.line = v.get1().asLong();
071        this.column = v.get2().asLong();
072    } // end constructor(FailException)
073
074    /**
075     * Returns exception file.
076     * @return exception file
077     */
078    public String getFile() {
079        return this.file;
080    } // end method 'getFile()'
081
082    /**
083     * Returns exception line.
084     * @return exception line
085     */
086    public long getLine() {
087        return this.line;
088    } // end method 'getLine()'
089
090    /**
091     * Returns exception column.
092     * @return exception column
093     */
094    public long getColumn() {
095        return this.column;
096    } // end method 'getColumn()'
097
098} // end class 'OCamlUndefinedRecursiveModuleException'