Skip to content
Snippets Groups Projects
Commit 00b4d04e authored by jlanuti's avatar jlanuti
Browse files

code clean up

parent d147bbb9
No related branches found
No related tags found
No related merge requests found
......@@ -17,52 +17,71 @@ import java.util.Map;
import java.util.List;
import java.util.ArrayList;
public class CommandOptionParser
{
private String delimiter = "-";
/**
* This is a helper class used to parse the command line options into a
* map where each option can be returned or all options.
*/
public class CommandOptionParser {
// Delimiter string
private static final String delimiter = "-"; //$NON-NLS-1$
// Map of options
private Map options;
public CommandOptionParser(String[] args)
{
/**
* Default constructor
* @param args String[]
*/
public CommandOptionParser(String[] args) {
parse(args);
}
public Map getOptions()
{
/**
* @return Map of all command line options and values
*/
public Map getOptions() {
return options;
}
public Collection getOption(String key)
{
/**
* Return the command line values for the specified command line key.
*
* @param key String
* @return Collection of values
*/
public Collection getOption(String key) {
return (Collection)options.get(key);
}
public String getOptionAsString(String key)
{
/**
* Get command line value as a string for specified option key.
*
* @param key String
* @return String command line value
*/
public String getOptionAsString(String key) {
Collection c = getOption(key);
if (c.isEmpty())
return null;
else
return (String)c.iterator().next();
return (String) c.iterator().next();
}
private void parse(String[] args)
{
/**
* Parse the string array of command line options and values into a map.
*
* @param args String[]
*/
private void parse(String[] args) {
options = new HashMap();
String option = null;
for (int i = 0; i < args.length; i++)
{
if (args[i] != null)
{
if (args[i].startsWith(delimiter))
{
for (int i = 0; i < args.length; i++) {
if (args[i] != null) {
if (args[i].startsWith(delimiter)) {
option = args[i].substring(1);
options.put(option, new ArrayList(1));
}
else if (option != null)
{
} else if (option != null)
((List)options.get(option)).add(args[i]);
}
}
}
}
......
......@@ -15,7 +15,7 @@ import org.eclipse.wtp.releng.tools.component.internal.PluginXML;
public interface IFragmentXML extends IPluginXML
{
public static final String CONST_FRAGMENT_XML = "fragment.xml";
public static final String CONST_FRAGMENT_XML = "fragment.xml"; //$NON-NLS-1$
/**
* Answers the parent plugin of this fragment
......
......@@ -15,7 +15,7 @@ import java.util.Map;
public interface ILibrary
{
public static final String EXT_CLASS = "class";
public static final String EXT_CLASS = "class"; //$NON-NLS-1$
/**
* Answers a mapping of (qualified) type names to <code>Type</code> objects
* which are found in this library.
......
......@@ -15,7 +15,7 @@ import java.util.List;
public interface IPluginXML
{
public static final String CONST_PLUGIN_XML = "plugin.xml";
public static final String CONST_PLUGIN_XML = "plugin.xml"; //$NON-NLS-1$
/**
* Answers the libraries that are declared in this plugin.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment