All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jpos.core.SimpleConfiguration Maven / Gradle / Ivy

Go to download

jPOS is an ISO-8583 based financial transaction library/framework that can be customized and extended in order to implement financial interchanges.

There is a newer version: 3.0.0
Show newest version
/*
 * jPOS Project [http://jpos.org]
 * Copyright (C) 2000-2013 Alejandro P. Revilla
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see .
 */

package org.jpos.core;

import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.List;
import java.util.Properties;

/**
 * @author [email protected]
 * @version $Id$
 * @since jPOS 1.1
 */
public class SimpleConfiguration implements Configuration {
    private Properties props;

    public SimpleConfiguration () {
        props = new Properties();
    }
    public SimpleConfiguration (Properties props) {
        this.props = props;
    }
    public SimpleConfiguration (String filename) 
        throws FileNotFoundException, IOException
    {
        props = new Properties();
        load (filename);
    }
    public String get (String name, String def) {
        Object obj = props.get (name);
        if (obj instanceof List) {
            List l = (List) obj;
            obj = (l.size() > 0) ? l.get(0) : null;
        }
        return (obj instanceof String) ? ((String) obj) : def;
    }
    public String[] getAll (String name) {
        String[] ret;
        Object obj = props.get (name);
        if (obj instanceof String[]) {
            ret = (String[]) obj;
        } else if (obj instanceof String) {
            ret = new String[1];
            ret[0] = (String) obj;
        } else
            ret = new String[0];

        return ret;
    }
    public int[] getInts (String name) {
        String[] ss = getAll (name);
        int[] ii = new int[ss.length];
        for (int i=0; i




© 2015 - 2025 Weber Informatics LLC | Privacy Policy