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

pellet.PelletCmdOptions Maven / Gradle / Ivy

// Copyright (c) 2006 - 2008, Clark & Parsia, LLC. 
// This source code is available under the terms of the Affero General Public
// License v3.
//
// Please see LICENSE.txt for full license terms, including the availability of
// proprietary exceptions.
// Questions, comments, or requests for clarification: [email protected]

package pellet;

import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;

/**
 * 

* Title: PelletCmdOptions *

*

* Description: Essentially a set of PelletCmdOption *

*

* Copyright: Copyright (c) 2008 *

*

* Company: Clark & Parsia, LLC. *

* * @author Markus Stocker */ public class PelletCmdOptions { private Map options; private Map shortOptions; private Set mandatory; public PelletCmdOptions() { options = new LinkedHashMap(); shortOptions = new HashMap(); mandatory = new HashSet(); } public void add(PelletCmdOption option) { String shortOption = option.getShortOption(); String longOption = option.getLongOption(); if( options.containsKey( longOption ) ) throw new PelletCmdException( "Duplicate long option for command: " + longOption ); else if( shortOption != null && shortOptions.containsKey( shortOption ) ) throw new PelletCmdException( "Duplicate short option for command: " + shortOption ); shortOptions.put( shortOption, option ); options.put( longOption, option ); if( option.isMandatory() ) mandatory.add( option ); } public PelletCmdOption getOption(String key) { // If key is short option then this matches PelletCmdOption option = shortOptions.get( key ); // Else, key is long option, retrieve its short option if( option == null ) option = options.get( key ); return option; } public Set getMandatoryOptions() { return mandatory; } public Collection getOptions() { return options.values(); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy