//# 3 errors, 289 messages
//#
/*
    //#CLIParser.java:1:1: class: com.dmdirc.installer.cliparser.CLIParser
    //#CLIParser.java:1:1: method: com.dmdirc.installer.cliparser.CLIParser.com.dmdirc.installer.cliparser.CLIParser__static_init
 * Copyright (c) 2006-2009 Shane Mc Cormack
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

package com.dmdirc.installer.cliparser;

import java.util.ArrayList;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;

/**
 * Command Line argument parser.
 */
public class CLIParser {
	/** Singleton instance of CLIParser. */
	private static CLIParser me;
	
	/** Singleton instance of CLIParser. */
	CLIParam helpParam = null;
	
	/**
	 * Known arguments.
	 * This hashtable stores the arguments with their flags as the key.
	 */
	private final Map<String, CLIParam> params = new Hashtable<String, CLIParam>();
	
	/**
	 * Known arguments.
	 * This ArrayList stores every param type. (used for help)
	 */
	private final List<CLIParam> paramList = new ArrayList<CLIParam>();
	
	/**
	 * Redundant Strings.
	 * This ArrayList stores redundant strings found whilst parsing the params.
	 */
	private final List<String> redundant = new ArrayList<String>();
	
	/**
	 * Get a reference to the CLIParser.
	 */
	public static synchronized CLIParser getCLIParser() {
		if (me == null) { me = new CLIParser(); }
    //#CLIParser.java:62: method: CLIParser com.dmdirc.installer.cliparser.CLIParser.getCLIParser()
    //#input(CLIParser getCLIParser()): __Class_Obj.__Lock
    //#input(CLIParser getCLIParser()): me
    //#output(CLIParser getCLIParser()): me
    //#output(CLIParser getCLIParser()): new ArrayList(CLIParser#2) num objects
    //#output(CLIParser getCLIParser()): new ArrayList(CLIParser#3) num objects
    //#output(CLIParser getCLIParser()): new CLIParser(getCLIParser#1) num objects
    //#output(CLIParser getCLIParser()): new CLIParser(getCLIParser#1).__Tag
    //#output(CLIParser getCLIParser()): new CLIParser(getCLIParser#1).helpParam
    //#output(CLIParser getCLIParser()): new CLIParser(getCLIParser#1).paramList
    //#output(CLIParser getCLIParser()): new CLIParser(getCLIParser#1).params
    //#output(CLIParser getCLIParser()): new CLIParser(getCLIParser#1).redundant
    //#output(CLIParser getCLIParser()): new Hashtable(CLIParser#1) num objects
    //#output(CLIParser getCLIParser()): return_value
    //#new obj(CLIParser getCLIParser()): new ArrayList(CLIParser#2)
    //#new obj(CLIParser getCLIParser()): new ArrayList(CLIParser#3)
    //#new obj(CLIParser getCLIParser()): new CLIParser(getCLIParser#1)
    //#new obj(CLIParser getCLIParser()): new Hashtable(CLIParser#1)
    //#pre[1] (CLIParser getCLIParser()): init'ed(me)
    //#post(CLIParser getCLIParser()): me == One-of{old me, &new CLIParser(getCLIParser#1)}
    //#post(CLIParser getCLIParser()): me != null
    //#post(CLIParser getCLIParser()): return_value == me
    //#post(CLIParser getCLIParser()): new ArrayList(CLIParser#2) num objects <= 1
    //#post(CLIParser getCLIParser()): new ArrayList(CLIParser#3) num objects <= 1
    //#post(CLIParser getCLIParser()): new CLIParser(getCLIParser#1) num objects <= 1
    //#post(CLIParser getCLIParser()): new CLIParser(getCLIParser#1).__Tag == com/dmdirc/installer/cliparser/CLIParser
    //#post(CLIParser getCLIParser()): new CLIParser(getCLIParser#1).helpParam == null
    //#post(CLIParser getCLIParser()): new CLIParser(getCLIParser#1).paramList == &new ArrayList(CLIParser#2)
    //#post(CLIParser getCLIParser()): new CLIParser(getCLIParser#1).params == &new Hashtable(CLIParser#1)
    //#post(CLIParser getCLIParser()): new CLIParser(getCLIParser#1).redundant == &new ArrayList(CLIParser#3)
    //#post(CLIParser getCLIParser()): new Hashtable(CLIParser#1) num objects <= 1
    //#unanalyzed(CLIParser getCLIParser()): Effects-of-calling:java.util.Hashtable
    //#unanalyzed(CLIParser getCLIParser()): Effects-of-calling:java.util.ArrayList
    //#test_vector(CLIParser getCLIParser()): me: Inverse{null}, Addr_Set{null}
		return me;
    //#CLIParser.java:63: end of method: CLIParser com.dmdirc.installer.cliparser.CLIParser.getCLIParser()
	}
	
	/** Private constructor for CLIParser to prevent non-singleton instance. */
	private CLIParser() { }
    //#CLIParser.java:67: method: void com.dmdirc.installer.cliparser.CLIParser.com.dmdirc.installer.cliparser.CLIParser()
    //#input(void com.dmdirc.installer.cliparser.CLIParser()): this
    //#output(void com.dmdirc.installer.cliparser.CLIParser()): new ArrayList(CLIParser#2) num objects
    //#output(void com.dmdirc.installer.cliparser.CLIParser()): new ArrayList(CLIParser#3) num objects
    //#output(void com.dmdirc.installer.cliparser.CLIParser()): new Hashtable(CLIParser#1) num objects
    //#output(void com.dmdirc.installer.cliparser.CLIParser()): this.helpParam
    //#output(void com.dmdirc.installer.cliparser.CLIParser()): this.paramList
    //#output(void com.dmdirc.installer.cliparser.CLIParser()): this.params
    //#output(void com.dmdirc.installer.cliparser.CLIParser()): this.redundant
    //#new obj(void com.dmdirc.installer.cliparser.CLIParser()): new ArrayList(CLIParser#2)
    //#new obj(void com.dmdirc.installer.cliparser.CLIParser()): new ArrayList(CLIParser#3)
    //#new obj(void com.dmdirc.installer.cliparser.CLIParser()): new Hashtable(CLIParser#1)
    //#post(void com.dmdirc.installer.cliparser.CLIParser()): this.helpParam == null
    //#post(void com.dmdirc.installer.cliparser.CLIParser()): this.paramList == &new ArrayList(CLIParser#2)
    //#post(void com.dmdirc.installer.cliparser.CLIParser()): this.params == &new Hashtable(CLIParser#1)
    //#post(void com.dmdirc.installer.cliparser.CLIParser()): this.redundant == &new ArrayList(CLIParser#3)
    //#post(void com.dmdirc.installer.cliparser.CLIParser()): new ArrayList(CLIParser#2) num objects == 1
    //#post(void com.dmdirc.installer.cliparser.CLIParser()): new ArrayList(CLIParser#3) num objects == 1
    //#post(void com.dmdirc.installer.cliparser.CLIParser()): new Hashtable(CLIParser#1) num objects == 1
    //#CLIParser.java:67: end of method: void com.dmdirc.installer.cliparser.CLIParser.com.dmdirc.installer.cliparser.CLIParser()
	
	/** Clear known params from the hashtable. */
	public void clear() {
		params.clear();
    //#CLIParser.java:71: method: void com.dmdirc.installer.cliparser.CLIParser.clear()
    //#input(void clear()): this
    //#input(void clear()): this.paramList
    //#input(void clear()): this.params
    //#input(void clear()): this.redundant
    //#pre[2] (void clear()): this.paramList != null
    //#pre[3] (void clear()): this.params != null
    //#pre[4] (void clear()): this.redundant != null
		paramList.clear();
		redundant.clear();
	}
    //#CLIParser.java:74: end of method: void com.dmdirc.installer.cliparser.CLIParser.clear()
	
	/**
	 * Add a CLIParam to the cliparser.
	 *
	 * @param param CLIParam sub-class to use as a parameter.
	 * @return true if added, false if already exists.
	 */
	public boolean add(final CLIParam param) {
		final boolean validChar = param.getChr() == 0 || !params.containsKey(param.getChr());
    //#CLIParser.java:83: method: bool com.dmdirc.installer.cliparser.CLIParser.add(CLIParam)
    //#input(bool add(CLIParam)): "-"._tainted
    //#input(bool add(CLIParam)): param
    //#input(bool add(CLIParam)): param.charFlag
    //#input(bool add(CLIParam)): param.stringFlag
    //#input(bool add(CLIParam)): param.stringFlag._tainted
    //#input(bool add(CLIParam)): this
    //#input(bool add(CLIParam)): this.paramList
    //#input(bool add(CLIParam)): this.params
    //#output(bool add(CLIParam)): return_value
    //#pre[1] (bool add(CLIParam)): param != null
    //#pre[3] (bool add(CLIParam)): param.stringFlag != null
    //#pre[6] (bool add(CLIParam)): (soft) this.paramList != null
    //#pre[7] (bool add(CLIParam)): (soft) this.params != null
    //#post(bool add(CLIParam)): init'ed(return_value)
    //#test_vector(bool add(CLIParam)): param.charFlag: {1..65_535}, {0}
    //#test_vector(bool add(CLIParam)): java.lang.String:isEmpty(...)@89: {1}, {0}
		final boolean validString = param.getString().isEmpty() || !params.containsKey("-"+param.getString());
		if (validChar && validString) {
			if (param.getChr() != 0) {
				params.put(String.valueOf(param.getChr()), param);
			}
			if (!param.getString().isEmpty()) {
				params.put("-"+param.getString(), param);
			}
			paramList.add(param);
			return true;
		} else {
			return false;
    //#CLIParser.java:95: end of method: bool com.dmdirc.installer.cliparser.CLIParser.add(CLIParam)
		}
	}
	
	/**
	 * Get the number of times a param was given.
	 * In the case of params with both a char and string value, this number is
	 * the total for both.
	 *
	 * @param flag Flag to get count for
	 * @return number, or -1 if the param is invalud
	 */
	public int getParamNumber(final String flag) {
		if (params.containsKey(flag)) {
    //#CLIParser.java:108: method: int com.dmdirc.installer.cliparser.CLIParser.getParamNumber(String)
    //#input(int getParamNumber(String)): com/dmdirc/installer/cliparser/CLIParam.__Descendant_Table[com/dmdirc/installer/cliparser/BooleanParam]
    //#input(int getParamNumber(String)): com/dmdirc/installer/cliparser/CLIParam.__Descendant_Table[com/dmdirc/installer/cliparser/CLIParam]
    //#input(int getParamNumber(String)): com/dmdirc/installer/cliparser/CLIParam.__Descendant_Table[com/dmdirc/installer/cliparser/IntegerParam]
    //#input(int getParamNumber(String)): com/dmdirc/installer/cliparser/CLIParam.__Descendant_Table[com/dmdirc/installer/cliparser/StringParam]
    //#input(int getParamNumber(String)): com/dmdirc/installer/cliparser/CLIParam.__Descendant_Table[others]
    //#input(int getParamNumber(String)): flag
    //#input(int getParamNumber(String)): this
    //#input(int getParamNumber(String)): this.params
    //#output(int getParamNumber(String)): return_value
    //#pre[3] (int getParamNumber(String)): this.params != null
    //#presumption(int getParamNumber(String)): java.util.Map:get(...).__Tag@109 in {com/dmdirc/installer/cliparser/BooleanParam, com/dmdirc/installer/cliparser/CLIParam, com/dmdirc/installer/cliparser/IntegerParam, com/dmdirc/installer/cliparser/StringParam}
    //#presumption(int getParamNumber(String)): java.util.Map:get(...)@109 != null
    //#post(int getParamNumber(String)): init'ed(return_value)
    //#test_vector(int getParamNumber(String)): java.util.Map:containsKey(...)@108: {0}, {1}
			return params.get(flag).getNumber();
		} else {
			return -1;
    //#CLIParser.java:111: end of method: int com.dmdirc.installer.cliparser.CLIParser.getParamNumber(String)
		}
	}
	
	/**
	 * Get a CLIParam object for a given flag.
	 *
	 * @param flag Flag to get param for
	 * @return CLIParam object, or null if there is none.
	 */
	public CLIParam getParam(final String flag) {
		if (params.containsKey(flag)) {
    //#CLIParser.java:122: method: CLIParam com.dmdirc.installer.cliparser.CLIParser.getParam(String)
    //#input(CLIParam getParam(String)): com/dmdirc/installer/cliparser/CLIParam.__Descendant_Table[com/dmdirc/installer/cliparser/BooleanParam]
    //#input(CLIParam getParam(String)): com/dmdirc/installer/cliparser/CLIParam.__Descendant_Table[com/dmdirc/installer/cliparser/CLIParam]
    //#input(CLIParam getParam(String)): com/dmdirc/installer/cliparser/CLIParam.__Descendant_Table[com/dmdirc/installer/cliparser/IntegerParam]
    //#input(CLIParam getParam(String)): com/dmdirc/installer/cliparser/CLIParam.__Descendant_Table[com/dmdirc/installer/cliparser/StringParam]
    //#input(CLIParam getParam(String)): com/dmdirc/installer/cliparser/CLIParam.__Descendant_Table[others]
    //#input(CLIParam getParam(String)): flag
    //#input(CLIParam getParam(String)): this
    //#input(CLIParam getParam(String)): this.params
    //#output(CLIParam getParam(String)): return_value
    //#pre[3] (CLIParam getParam(String)): this.params != null
    //#presumption(CLIParam getParam(String)): java.util.Map:get(...).__Tag@123 in {com/dmdirc/installer/cliparser/BooleanParam, com/dmdirc/installer/cliparser/CLIParam, com/dmdirc/installer/cliparser/IntegerParam, com/dmdirc/installer/cliparser/StringParam}
    //#post(CLIParam getParam(String)): init'ed(return_value)
    //#test_vector(CLIParam getParam(String)): java.util.Map:containsKey(...)@122: {0}, {1}
			return params.get(flag);
		} else {
			return null;
    //#CLIParser.java:125: end of method: CLIParam com.dmdirc.installer.cliparser.CLIParser.getParam(String)
		}
	}
	
	/**
	 * Get the list of params.
	 *
	 * @return list of params.
	 */
	public List<CLIParam> getParamList() {
		return paramList;
    //#CLIParser.java:135: method: List com.dmdirc.installer.cliparser.CLIParser.getParamList()
    //#input(List getParamList()): this
    //#input(List getParamList()): this.paramList
    //#output(List getParamList()): return_value
    //#post(List getParamList()): return_value == this.paramList
    //#post(List getParamList()): init'ed(return_value)
    //#CLIParser.java:135: end of method: List com.dmdirc.installer.cliparser.CLIParser.getParamList()
	}
	
	/**
	 * Get the list of redundant strings.
	 *
	 * @return list of redundant strings.
	 */
	public List<String> getRedundant() {
		final List<String> result = new ArrayList<String>();
    //#CLIParser.java:144: method: List com.dmdirc.installer.cliparser.CLIParser.getRedundant()
    //#input(List getRedundant()): this
    //#input(List getRedundant()): this.redundant
    //#output(List getRedundant()): new ArrayList(getRedundant#1) num objects
    //#output(List getRedundant()): return_value
    //#new obj(List getRedundant()): new ArrayList(getRedundant#1)
    //#pre[2] (List getRedundant()): this.redundant != null
    //#post(List getRedundant()): return_value == &new ArrayList(getRedundant#1)
    //#post(List getRedundant()): new ArrayList(getRedundant#1) num objects == 1
    //#test_vector(List getRedundant()): java.util.Iterator:hasNext(...)@145: {0}, {1}
		for (String item : redundant) {
			result.add(item);
		}
		return result;
    //#CLIParser.java:148: end of method: List com.dmdirc.installer.cliparser.CLIParser.getRedundant()
	}
	
	/**
	 * Set the "help" command.
	 *
	 * @param param Param to look for in wantsHelp.
	 */
	public void setHelp(final CLIParam param) {
		helpParam = param;
    //#CLIParser.java:157: method: void com.dmdirc.installer.cliparser.CLIParser.setHelp(CLIParam)
    //#input(void setHelp(CLIParam)): param
    //#input(void setHelp(CLIParam)): this
    //#output(void setHelp(CLIParam)): this.helpParam
    //#post(void setHelp(CLIParam)): this.helpParam == param
    //#post(void setHelp(CLIParam)): init'ed(this.helpParam)
	}
    //#CLIParser.java:158: end of method: void com.dmdirc.installer.cliparser.CLIParser.setHelp(CLIParam)
	
	/**
	 * Check if the help parameter has been passed to the CLI.
	 */
	public boolean wantsHelp(final String[] args) {
		if (helpParam == null) { return false; }
    //#CLIParser.java:164: method: bool com.dmdirc.installer.cliparser.CLIParser.wantsHelp(String[])
    //#input(bool wantsHelp(String[])): __Descendant_Table[com/dmdirc/installer/cliparser/CLIParser]
    //#input(bool wantsHelp(String[])): __Descendant_Table[others]
    //#input(bool wantsHelp(String[])): __Dispatch_Table.getParam(Ljava/lang/String;)Lcom/dmdirc/installer/cliparser/CLIParam;
    //#input(bool wantsHelp(String[])): args
    //#input(bool wantsHelp(String[])): args.length
    //#input(bool wantsHelp(String[])): args[0..4_294_967_295]
    //#input(bool wantsHelp(String[])): args[0..4_294_967_295]._tainted
    //#input(bool wantsHelp(String[])): com/dmdirc/installer/cliparser/CLIParam.__Descendant_Table[com/dmdirc/installer/cliparser/BooleanParam]
    //#input(bool wantsHelp(String[])): com/dmdirc/installer/cliparser/CLIParam.__Descendant_Table[com/dmdirc/installer/cliparser/CLIParam]
    //#input(bool wantsHelp(String[])): com/dmdirc/installer/cliparser/CLIParam.__Descendant_Table[com/dmdirc/installer/cliparser/IntegerParam]
    //#input(bool wantsHelp(String[])): com/dmdirc/installer/cliparser/CLIParam.__Descendant_Table[com/dmdirc/installer/cliparser/StringParam]
    //#input(bool wantsHelp(String[])): com/dmdirc/installer/cliparser/CLIParam.__Descendant_Table[others]
    //#input(bool wantsHelp(String[])): this
    //#input(bool wantsHelp(String[])): this.__Tag
    //#input(bool wantsHelp(String[])): this.helpParam
    //#input(bool wantsHelp(String[])): this.params
    //#output(bool wantsHelp(String[])): return_value
    //#pre[7] (bool wantsHelp(String[])): init'ed(this.helpParam)
    //#pre[1] (bool wantsHelp(String[])): (soft) args != null
    //#pre[2] (bool wantsHelp(String[])): (soft) args.length <= 4_294_967_295
    //#pre[3] (bool wantsHelp(String[])): (soft) args[0..4_294_967_295] != null
    //#pre[6] (bool wantsHelp(String[])): (soft) this.__Tag == com/dmdirc/installer/cliparser/CLIParser
    //#pre[8] (bool wantsHelp(String[])): (soft) this.params != null
    //#post(bool wantsHelp(String[])): init'ed(return_value)
    //#unanalyzed(bool wantsHelp(String[])): Effects-of-calling:java.util.Map:containsKey
    //#unanalyzed(bool wantsHelp(String[])): Effects-of-calling:java.util.Map:get
    //#test_vector(bool wantsHelp(String[])): this.helpParam: Inverse{null}, Addr_Set{null}
    //#test_vector(bool wantsHelp(String[])): java.lang.String:charAt(...)@166: {0..44, 46..65_535}, {45}
    //#test_vector(bool wantsHelp(String[])): java.lang.String:equals(...)@168: {0}, {1}
    //#test_vector(bool wantsHelp(String[])): java.lang.String:length(...)@166: {0,1}, {2..4_294_967_295}
		for (String arg : args) {
			if (arg.length() > 1 && arg.charAt(0) == '-') {
				final String name = arg.substring(1);
				if (name.equals("-")) {
					return false;
				} else {
					final CLIParam param = getParam(name);
					if (param == helpParam) {
						return true;
					}
				}
			}
		}
		return false;
    //#CLIParser.java:178: end of method: bool com.dmdirc.installer.cliparser.CLIParser.wantsHelp(String[])
	}
	
	/**
	 * Show the help
	 */
	public void showHelp(final String title, final String usage) {
		System.out.println(title);
    //#CLIParser.java:185: method: void com.dmdirc.installer.cliparser.CLIParser.showHelp(String, String)
    //#input(void showHelp(String, String)): " "._tainted
    //#input(void showHelp(String, String)): "&#09;"._tainted
    //#input(void showHelp(String, String)): "-"._tainted
    //#input(void showHelp(String, String)): "--"._tainted
    //#input(void showHelp(String, String)): __Descendant_Table[com/dmdirc/installer/cliparser/CLIParser]
    //#input(void showHelp(String, String)): __Descendant_Table[others]
    //#input(void showHelp(String, String)): __Dispatch_Table.getParamList()Ljava/util/List;
    //#input(void showHelp(String, String)): com/dmdirc/installer/cliparser/CLIParam.__Descendant_Table[com/dmdirc/installer/cliparser/BooleanParam]
    //#input(void showHelp(String, String)): com/dmdirc/installer/cliparser/CLIParam.__Descendant_Table[com/dmdirc/installer/cliparser/CLIParam]
    //#input(void showHelp(String, String)): com/dmdirc/installer/cliparser/CLIParam.__Descendant_Table[com/dmdirc/installer/cliparser/IntegerParam]
    //#input(void showHelp(String, String)): com/dmdirc/installer/cliparser/CLIParam.__Descendant_Table[com/dmdirc/installer/cliparser/StringParam]
    //#input(void showHelp(String, String)): com/dmdirc/installer/cliparser/CLIParam.__Descendant_Table[others]
    //#input(void showHelp(String, String)): java.lang.System.out
    //#input(void showHelp(String, String)): this
    //#input(void showHelp(String, String)): this.__Tag
    //#input(void showHelp(String, String)): this.paramList
    //#input(void showHelp(String, String)): title
    //#input(void showHelp(String, String)): usage
    //#pre[2] (void showHelp(String, String)): this.__Tag == com/dmdirc/installer/cliparser/CLIParser
    //#pre[3] (void showHelp(String, String)): this.paramList != null
    //#presumption(void showHelp(String, String)): java.lang.System.out != null
    //#presumption(void showHelp(String, String)): java.util.Iterator:next(...).__Tag@189 in {com/dmdirc/installer/cliparser/BooleanParam, com/dmdirc/installer/cliparser/CLIParam, com/dmdirc/installer/cliparser/IntegerParam, com/dmdirc/installer/cliparser/StringParam}
    //#presumption(void showHelp(String, String)): java.util.Iterator:next(...)@189 != null
    //#presumption(void showHelp(String, String)): param.stringFlag@189 != null
    //#test_vector(void showHelp(String, String)): java.lang.String:isEmpty(...)@195: {0}, {1}
    //#test_vector(void showHelp(String, String)): java.util.Iterator:hasNext(...)@189: {0}, {1}
    //#test_vector(void showHelp(String, String)): param.charFlag@189: {1..65_535}, {0}
		System.out.println("------------------");
		System.out.println(usage);
		System.out.println(" ");
		for (CLIParam param : this.getParamList()) {
			if (param.getChr() == 0) {
				System.out.print("   ");
			} else {
				System.out.print("-"+param.getChr()+" ");
			}
			if (param.getString().isEmpty()) {
				System.out.print("\t\t");
			} else {
				System.out.print("--"+param.getString()+" ");
			}
			System.out.println("\t"+param.getDescription());
		}
	}
    //#CLIParser.java:202: end of method: void com.dmdirc.installer.cliparser.CLIParser.showHelp(String, String)
	
	/**
	 * Given a string array of arguments, parse as CLI Params.
	 *
	 * @param args Arguments to pass
	 * @param strict if True, will terminate if a given param is invalid.
	 */
	public void parseArgs(final String[] args, final boolean strict) {
		CLIParam lastParam = null;
    //#CLIParser.java:211: method: void com.dmdirc.installer.cliparser.CLIParser.parseArgs(String[], bool)
    //#input(void parseArgs(String[], bool)): " to get help."._tainted
    //#input(void parseArgs(String[], bool)): ""._tainted
    //#input(void parseArgs(String[], bool)): "Unknown Param: -"._tainted
    //#input(void parseArgs(String[], bool)): "Use "._tainted
    //#input(void parseArgs(String[], bool)): __Descendant_Table[com/dmdirc/installer/cliparser/CLIParser]
    //#input(void parseArgs(String[], bool)): __Descendant_Table[others]
    //#input(void parseArgs(String[], bool)): __Dispatch_Table.getParam(Ljava/lang/String;)Lcom/dmdirc/installer/cliparser/CLIParam;
    //#input(void parseArgs(String[], bool)): args
    //#input(void parseArgs(String[], bool)): args.length
    //#input(void parseArgs(String[], bool)): args[0..4_294_967_295]
    //#input(void parseArgs(String[], bool)): args[0..4_294_967_295]._tainted
    //#input(void parseArgs(String[], bool)): com/dmdirc/installer/cliparser/BooleanParam.__Dispatch_Table.setValue(Ljava/lang/String;)Z
    //#input(void parseArgs(String[], bool)): com/dmdirc/installer/cliparser/CLIParam.__Descendant_Table[com/dmdirc/installer/cliparser/BooleanParam]
    //#input(void parseArgs(String[], bool)): com/dmdirc/installer/cliparser/CLIParam.__Descendant_Table[com/dmdirc/installer/cliparser/CLIParam]
    //#input(void parseArgs(String[], bool)): com/dmdirc/installer/cliparser/CLIParam.__Descendant_Table[com/dmdirc/installer/cliparser/IntegerParam]
    //#input(void parseArgs(String[], bool)): com/dmdirc/installer/cliparser/CLIParam.__Descendant_Table[com/dmdirc/installer/cliparser/StringParam]
    //#input(void parseArgs(String[], bool)): com/dmdirc/installer/cliparser/CLIParam.__Descendant_Table[others]
    //#input(void parseArgs(String[], bool)): com/dmdirc/installer/cliparser/CLIParam.__Dispatch_Table.setValue(Ljava/lang/String;)Z
    //#input(void parseArgs(String[], bool)): com/dmdirc/installer/cliparser/IntegerParam.__Dispatch_Table.setValue(Ljava/lang/String;)Z
    //#input(void parseArgs(String[], bool)): com/dmdirc/installer/cliparser/StringParam.__Dispatch_Table.setValue(Ljava/lang/String;)Z
    //#input(void parseArgs(String[], bool)): java.lang.System.out
    //#input(void parseArgs(String[], bool)): strict
    //#input(void parseArgs(String[], bool)): this
    //#input(void parseArgs(String[], bool)): this.__Tag
    //#input(void parseArgs(String[], bool)): this.helpParam
    //#input(void parseArgs(String[], bool)): this.helpParam.charFlag
    //#input(void parseArgs(String[], bool)): this.helpParam.stringFlag
    //#input(void parseArgs(String[], bool)): this.helpParam.stringFlag._tainted
    //#input(void parseArgs(String[], bool)): this.params
    //#input(void parseArgs(String[], bool)): this.redundant
    //#output(void parseArgs(String[], bool)): java.lang.String:substring(...)._tainted
    //#new obj(void parseArgs(String[], bool)): java.lang.String:substring(...)
    //#pre[1] (void parseArgs(String[], bool)): args != null
    //#pre[2] (void parseArgs(String[], bool)): args.length <= 4_294_967_295
    //#pre[3] (void parseArgs(String[], bool)): (soft) args[0..4_294_967_295] != null
    //#pre[7] (void parseArgs(String[], bool)): (soft) this.__Tag == com/dmdirc/installer/cliparser/CLIParser
    //#pre[8] (void parseArgs(String[], bool)): (soft) init'ed(this.helpParam)
    //#pre[10] (void parseArgs(String[], bool)): (soft) this.helpParam.stringFlag != null
    //#pre[12] (void parseArgs(String[], bool)): (soft) this.params != null
    //#pre[13] (void parseArgs(String[], bool)): (soft) this.redundant != null
    //#presumption(void parseArgs(String[], bool)): java.lang.System.out != null
    //#presumption(void parseArgs(String[], bool)): lastParam.number@220 <= 4_294_967_294
    //#post(void parseArgs(String[], bool)): init'ed(java.lang.String:substring(...)._tainted)
    //#unanalyzed(void parseArgs(String[], bool)): Effects-of-calling:java.util.Map:containsKey
    //#unanalyzed(void parseArgs(String[], bool)): Effects-of-calling:java.util.Map:get
    //#unanalyzed(void parseArgs(String[], bool)): Effects-of-calling:java.lang.Integer:parseInt
    //#unanalyzed(void parseArgs(String[], bool)): Effects-of-calling:java.lang.Throwable:__curr_excep_obj
    //#unanalyzed(void parseArgs(String[], bool)): Effects-of-calling:java.lang.String:isEmpty
    //#unanalyzed(void parseArgs(String[], bool)): Effects-of-calling:java.lang.String:equals
    //#unanalyzed(void parseArgs(String[], bool)): Effects-of-calling:java.lang.String:equalsIgnoreCase
    //#test_vector(void parseArgs(String[], bool)): this.helpParam: Addr_Set{null}, Inverse{null}
    //#test_vector(void parseArgs(String[], bool)): this.helpParam.charFlag: {0}, {1..65_535}
    //#test_vector(void parseArgs(String[], bool)): java.lang.String:charAt(...)@214: {0..44, 46..65_535}, {45}
    //#test_vector(void parseArgs(String[], bool)): java.lang.String:charAt(...)@242: {0..91, 93..65_535}, {92}
    //#test_vector(void parseArgs(String[], bool)): java.lang.String:equals(...)@217: {0}, {1}
    //#test_vector(void parseArgs(String[], bool)): java.lang.String:isEmpty(...)@225: {0}, {1}
    //#test_vector(void parseArgs(String[], bool)): java.lang.String:isEmpty(...)@230: {1}, {0}
    //#test_vector(void parseArgs(String[], bool)): java.lang.String:length(...)@214: {0,1}, {2..4_294_967_295}
    //#test_vector(void parseArgs(String[], bool)): java.lang.String:length(...)@242: {0,1}, {2..4_294_967_295}
		boolean allRedundant = false;
		for (String arg : args) {
			if (arg.length() > 1 && arg.charAt(0) == '-' && !allRedundant) {
				if (lastParam != null) { lastParam.setValue(""); }
    //#CLIParser.java:215: ?null dereference
    //#    com/dmdirc/installer/cliparser/CLIParam.__Descendant_Table[lastParam.__Tag] != null
    //#    severity: SUPPRESSED
    //#    class: com.dmdirc.installer.cliparser.CLIParser
    //#    method: void parseArgs(String[], bool)
    //#    basic block: bb_7
    //#    assertion: com/dmdirc/installer/cliparser/CLIParam.__Descendant_Table[lastParam.__Tag] != null
    //#    VN: com/dmdirc/installer/cliparser/CLIParam.__Descendant_Table[lastParam.__Tag]
    //#    Expected: Inverse{null}
    //#    Bad: Addr_Set{null}
    //#    Attribs:  Ptr  null in Bad
				final String name = arg.substring(1);
				if (name.equals("-")) {
					allRedundant = true;
				} else {
					lastParam = getParam(name);
    //#CLIParser.java:220: ?null dereference
    //#    __Descendant_Table[this.__Tag] != null
    //#    severity: SUPPRESSED
    //#    class: com.dmdirc.installer.cliparser.CLIParser
    //#    method: void parseArgs(String[], bool)
    //#    basic block: bb_10
    //#    assertion: __Descendant_Table[this.__Tag] != null
    //#    VN: __Descendant_Table[this.__Tag]
    //#    Expected: Inverse{null}
    //#    Bad: Addr_Set{null}
    //#    Attribs:  Ptr  null in Bad
					if (lastParam == null) {
						System.out.println("Unknown Param: -"+name);
						if (helpParam != null) {
							String command = "";
							if (helpParam.getString().isEmpty()) {
								command = String.valueOf(helpParam.getChr());
							} else if (helpParam.getChr() != 0) {
								command = helpParam.getString();
							}
							if (!command.isEmpty()) {
								System.out.println("Use "+command+" to get help.");
							}
						}
						if (strict) {
							System.exit(1);
						}
					} else {
						lastParam.incNumber();
					}
				}
			} else {
				if (arg.charAt(0) == '\\' && arg.length() > 1) { arg = arg.substring(1); }
				if (lastParam == null || allRedundant || !lastParam.setValue(arg)) {
    //#CLIParser.java:243: ?null dereference
    //#    com/dmdirc/installer/cliparser/CLIParam.__Descendant_Table[lastParam.__Tag] != null
    //#    severity: SUPPRESSED
    //#    class: com.dmdirc.installer.cliparser.CLIParser
    //#    method: void parseArgs(String[], bool)
    //#    basic block: bb_27
    //#    assertion: com/dmdirc/installer/cliparser/CLIParam.__Descendant_Table[lastParam.__Tag] != null
    //#    VN: com/dmdirc/installer/cliparser/CLIParam.__Descendant_Table[lastParam.__Tag]
    //#    Expected: Inverse{null}
    //#    Bad: Addr_Set{null}
    //#    Attribs:  Ptr  null in Bad
					redundant.add(arg);
				}
			}
		}
	}
    //#CLIParser.java:248: end of method: void com.dmdirc.installer.cliparser.CLIParser.parseArgs(String[], bool)
}
    //#output(com.dmdirc.installer.cliparser.CLIParser__static_init): __Descendant_Table[com/dmdirc/installer/cliparser/CLIParser]
    //#output(com.dmdirc.installer.cliparser.CLIParser__static_init): __Dispatch_Table.add(Lcom/dmdirc/installer/cliparser/CLIParam;)Z
    //#output(com.dmdirc.installer.cliparser.CLIParser__static_init): __Dispatch_Table.clear()V
    //#output(com.dmdirc.installer.cliparser.CLIParser__static_init): __Dispatch_Table.getParam(Ljava/lang/String;)Lcom/dmdirc/installer/cliparser/CLIParam;
    //#output(com.dmdirc.installer.cliparser.CLIParser__static_init): __Dispatch_Table.getParamList()Ljava/util/List;
    //#output(com.dmdirc.installer.cliparser.CLIParser__static_init): __Dispatch_Table.getParamNumber(Ljava/lang/String;)I
    //#output(com.dmdirc.installer.cliparser.CLIParser__static_init): __Dispatch_Table.getRedundant()Ljava/util/List;
    //#output(com.dmdirc.installer.cliparser.CLIParser__static_init): __Dispatch_Table.parseArgs([Ljava/lang/String;Z)V
    //#output(com.dmdirc.installer.cliparser.CLIParser__static_init): __Dispatch_Table.setHelp(Lcom/dmdirc/installer/cliparser/CLIParam;)V
    //#output(com.dmdirc.installer.cliparser.CLIParser__static_init): __Dispatch_Table.showHelp(Ljava/lang/String;Ljava/lang/String;)V
    //#output(com.dmdirc.installer.cliparser.CLIParser__static_init): __Dispatch_Table.wantsHelp([Ljava/lang/String;)Z
    //#post(com.dmdirc.installer.cliparser.CLIParser__static_init): __Descendant_Table[com/dmdirc/installer/cliparser/CLIParser] == &__Dispatch_Table
    //#post(com.dmdirc.installer.cliparser.CLIParser__static_init): __Dispatch_Table.add(Lcom/dmdirc/installer/cliparser/CLIParam;)Z == &add
    //#post(com.dmdirc.installer.cliparser.CLIParser__static_init): __Dispatch_Table.clear()V == &clear
    //#post(com.dmdirc.installer.cliparser.CLIParser__static_init): __Dispatch_Table.getParam(Ljava/lang/String;)Lcom/dmdirc/installer/cliparser/CLIParam; == &getParam
    //#post(com.dmdirc.installer.cliparser.CLIParser__static_init): __Dispatch_Table.getParamList()Ljava/util/List; == &getParamList
    //#post(com.dmdirc.installer.cliparser.CLIParser__static_init): __Dispatch_Table.getParamNumber(Ljava/lang/String;)I == &getParamNumber
    //#post(com.dmdirc.installer.cliparser.CLIParser__static_init): __Dispatch_Table.getRedundant()Ljava/util/List; == &getRedundant
    //#post(com.dmdirc.installer.cliparser.CLIParser__static_init): __Dispatch_Table.parseArgs([Ljava/lang/String;Z)V == &parseArgs
    //#post(com.dmdirc.installer.cliparser.CLIParser__static_init): __Dispatch_Table.setHelp(Lcom/dmdirc/installer/cliparser/CLIParam;)V == &setHelp
    //#post(com.dmdirc.installer.cliparser.CLIParser__static_init): __Dispatch_Table.showHelp(Ljava/lang/String;Ljava/lang/String;)V == &showHelp
    //#post(com.dmdirc.installer.cliparser.CLIParser__static_init): __Dispatch_Table.wantsHelp([Ljava/lang/String;)Z == &wantsHelp
    //#CLIParser.java:: end of method: com.dmdirc.installer.cliparser.CLIParser.com.dmdirc.installer.cliparser.CLIParser__static_init
    //#CLIParser.java:: end of class: com.dmdirc.installer.cliparser.CLIParser
