head	1.2;
access;
symbols
	bg2_23:1.2
	bg2_22:1.2
	bg2_21:1.2
	bg2_20:1.2
	bg2_16:1.2
	bg2_15:1.2
	bg2_12:1.2
	bg2_07:1.2;
locks; strict;
comment	@# @;


1.2
date	2008.02.17.20.47.28;	author stefant;	state Exp;
branches;
next	1.1;
commitid	6be447b89d5a4567;

1.1
date	2008.01.13.20.43.53;	author stefant;	state Exp;
branches;
next	;
commitid	4e54478a77ec4567;


desc
@@


1.2
log
@initializing all actions with id, fallback for configuration to default name, new syntax for action-options.
@
text
@/*
 * Copyright (c) 2007,2008, Stefan Hepp
 *
 * This file is part of JOPtimizer.
 *
 * JOPtimizer 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 3 of the License, or
 * (at your option) any later version.
 *
 * JOPtimizer 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.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package joptimizer.config;

import java.io.PrintStream;
import java.util.Properties;

/**
 * A string argument option, requires an additional option.
 * @@author Stefan Hepp, e0026640@@student.tuwien.ac.at
 */
public class StringOption extends ArgOption {

    private String argName;

    public StringOption(String prefix, String option, String description, String argName) {
        super(prefix, option, description);
        this.argName = argName;
    }

    public int parse(String option, String[] args, int pos, Properties props) throws ArgumentException {
        if ( pos + 1 >= args.length ) {
            throw new ArgumentException("Missing text for argument '-" + option + "'.");
        }
        props.setProperty( getFullName(), replaceVariables(args[pos+1], props));
        return 1;
    }

    public void printHelp(String prefix, PrintStream out) {
        out.println( formatOption(prefix, getFullName() + " <" + argName + ">", getDescription() ) );
    }
}
@


1.1
log
@added joptimizer sources
@
text
@d1 48
a48 48
/*
 * Copyright (c) 2007,2008, Stefan Hepp
 *
 * This file is part of JOPtimizer.
 *
 * JOPtimizer 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 3 of the License, or
 * (at your option) any later version.
 *
 * JOPtimizer 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.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package joptimizer.config;

import java.io.PrintStream;
import java.util.Properties;

/**
 * A string argument option, requires an additional option.
 * @@author Stefan Hepp, e0026640@@student.tuwien.ac.at
 */
public class StringOption extends ArgOption {

    private String argName;

    public StringOption(String name, String description, String argName) {
        super(name, description);
        this.argName = argName;
    }

    public int parse(String option, String[] args, int pos, Properties props) throws ArgumentException {
        if ( pos + 1 >= args.length ) {
            throw new ArgumentException("Missing text for argument '-" + option + "'.");
        }
        props.setProperty( getName(), replaceVariables(args[pos+1], props));
        return 1;
    }

    public void printHelp(String prefix, PrintStream out) {
        out.println( formatOption(prefix, getName() + " <" + argName + ">", getDescription() ) );
    }
}
@

