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

com.greenpepper.util.cli.CommandLine Maven / Gradle / Ivy

The newest version!
/*
 * Copyright (c) 2006 Pyxis Technologies inc.
 *
 * This 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 software 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, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA,
 * or see the FSF site: http://www.fsf.org.
 */

package com.greenpepper.util.cli;

import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;

/**
 * 

CommandLine class.

* * @author oaouattara * @version $Id: $Id */ public class CommandLine { private static final Map converters = new HashMap(); static { registerConverter( String.class, new StringConverter() ); registerConverter( Integer.class, new IntegerConverter() ); registerConverter( int.class, new IntegerConverter() ); registerConverter( Locale.class, new LocaleConverter() ); registerConverter( File.class, new FileConverter() ); registerConverter( Class.class, new ClassConverter() ); } /** *

registerConverter.

* * @param type a {@link java.lang.Class} object. * @param converter a {@link com.greenpepper.util.cli.Converter} object. */ public static void registerConverter( Class type, Converter converter ) { converters.put( type, converter ); } /** *

converterFor.

* * @param type a {@link java.lang.Class} object. * @return a {@link com.greenpepper.util.cli.Converter} object. */ public static Converter converterFor( Class type ) { if (!converters.containsKey( type )) throw new IllegalArgumentException( "Don't know type: " + type ); return converters.get( type ); } private final List arguments; private final List




© 2015 - 2024 Weber Informatics LLC | Privacy Policy