
org.enhydra.xml.xmlc.commands.options.OptionSet Maven / Gradle / Ivy
The newest version!
/*
* Enhydra Java Application Server Project
*
* The contents of this file are subject to the Enhydra Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License on
* the Enhydra web site ( http://www.enhydra.org/ ).
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific terms governing rights and limitations
* under the License.
*
* The Initial Developer of the Enhydra Application Server is Lutris
* Technologies, Inc. The Enhydra Application Server and portions created
* by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
* All Rights Reserved.
*
* Contributor(s):
*
* $Id: OptionSet.java,v 1.2 2005/01/26 08:29:24 jkjome Exp $
*/
package org.enhydra.xml.xmlc.commands.options;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
/**
* Class that contains a set of XMLC options.
*
* @see Option
* @see OptionsParser
*/
public class OptionSet {
/**
* Ordered list of Option objects associated with this OptionSet.
*/
private ArrayList optionList = new ArrayList();
/**
* Hash table of valid Option objects.
*/
private HashMap options = new HashMap();
/**
* Add an option to the options set.
*/
public void addOption(Option opt) {
optionList.add(opt);
options.put(opt.getName(), opt);
}
/**
* Get an enumeration of all options in the set.
*/
public Iterator getOptions() {
return optionList.iterator();
}
/**
* Get displayable string of valid options for use in error messages.
*/
public String getOptionsMsg() {
StringBuffer msg = new StringBuffer();
Iterator opts = getOptions();
while (opts.hasNext()) {
Option opt = (Option)opts.next();
msg.append(" ");
msg.append(opt.getHelp());
msg.append("\n");
}
return msg.toString();
}
/**
* Lookup an option.
*
* @param name The option name, including the leading `-'.
* @return The Option object or null if name is not found.
*/
public Option findOption(String name) {
return (Option)options.get(name);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy