001/*
002 * This file is part of lzo-java, an implementation of LZO in Java.
003 * https://github.com/shevek/lzo-java
004 *
005 * The Java portion of this library is:
006 * Copyright (C) 2011 Shevek <shevek@anarres.org>
007 * All Rights Reserved.
008 *
009 * The preprocessed C portion of this library is:
010 * Copyright (C) 2006-2011 Markus Franz Xaver Johannes Oberhumer
011 * All Rights Reserved.
012 *
013 * This library is free software; you can redistribute it and/or
014 * modify it under the terms of the GNU General Public License 
015 * as published by the Free Software Foundation; either version 
016 * 2 of the License, or (at your option) any later version.
017 *
018 * This library is distributed in the hope that it will be useful, 
019 * but WITHOUT ANY WARRANTY; without even the implied warranty
020 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
021 * See the GNU General Public License for more details.
022 *
023 * You should have received a copy of the GNU General Public
024 * License along with the LZO library; see the file COPYING.
025 * If not, see <http://www.gnu.org/licenses/> or write to the
026 * Free Software Foundation, Inc., 51 Franklin Street, Fifth
027 * Floor, Boston, MA 02110-1301, USA.
028
029 * As a special exception, the copyright holders of this file
030 * give you permission to link this file with independent
031 * modules to produce an executable, regardless of the license 
032 * terms of these independent modules, and to copy and distribute
033 * the resulting executable under terms of your choice, provided
034 * that you also meet, for each linked independent module, 
035 * the terms and conditions of the license of that module. An
036 * independent module is a module which is not derived from or 
037 * based on this library or file. If you modify this file, you may 
038 * extend this exception to your version of the file, but
039 * you are not obligated to do so. If you do not wish to do so,
040 * delete this exception statement from your version.
041 */
042package org.anarres.lzo;
043
044/**
045 *
046 * @author shevek
047 */
048public class AbstractLzoTransformer implements LzoTransformer {
049
050    private final LzoAlgorithm algorithm;
051    private final LzoConstraint[] constraints;
052
053    @SuppressWarnings("EI_EXPOSE_REP2")
054    public AbstractLzoTransformer(LzoAlgorithm algorithm, LzoConstraint... constraints) {
055        this.algorithm = algorithm;
056        this.constraints = constraints;
057    }
058
059    @Override
060    public LzoAlgorithm getAlgorithm() {
061        return algorithm;
062    }
063
064    @Override
065    @SuppressWarnings("EI_EXPOSE_REP")
066    public LzoConstraint[] getConstraints() {
067        return constraints;
068    }
069
070    @Override
071    public String toErrorString(int code) {
072        switch (code) {
073            case LZO_E_OK:
074                return "OK";
075            case LZO_E_ERROR:
076                return "Error";
077            case LZO_E_OUT_OF_MEMORY:
078                return "Out of memory";
079            case LZO_E_NOT_COMPRESSIBLE:
080                return "Not compressible";
081            case LZO_E_INPUT_OVERRUN:
082                return "Input overrun";
083            case LZO_E_OUTPUT_OVERRUN:
084                return "Output overrun";
085            case LZO_E_LOOKBEHIND_OVERRUN:
086                return "Lookbehind overrun";
087            case LZO_E_EOF_NOT_FOUND:
088                return "EOF not found";
089            case LZO_E_INPUT_NOT_CONSUMED:
090                return "Input not consumed";
091            default:
092                return "Unknown-" + code;
093        }
094    }
095}