gt: 					if (o.value > o.maxValue || o.value < o.minValue) {
context: /*
   * Arguments.java
   *
   * Copyright (C) 2002-2006 Alexei Drummond and Andrew Rambaut
   *
   * This file is part of BEAST.
   * See the NOTICE file distributed with this work for additional
   * information regarding copyright ownership and licensing.
   *
   * BEAST is free software; you can redistribute it and/or modify
   * it under the terms of the GNU Lesser General Public License as
   * published by the Free Software Foundation; either version 2
   * of the License, or (at your option) any later version.
   *
   *  BEAST 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 Lesser General Public License for more details.
   *
   * You should have received a copy of the GNU Lesser General Public
   * License along with BEAST; if not, write to the
   * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
   * Boston, MA  02110-1301  USA
   */
  
  package dr.app.util;
  
  import java.util.StringTokenizer;
  
  public class Arguments {
  
  	public static final String ARGUMENT_CHARACTER = "-";
  
  	public static class ArgumentException extends Exception {
  		/**
  		 *
  		 */
  		private static final long serialVersionUID = -3229759954341228233L;
  		public ArgumentException() { super(); }
  		public ArgumentException(String message) { super(message); }
  	}
  
  	public static class Option {
  
  		public Option(String label, String description) {
  			this.label = label;
  			this.description = description;
  		}
  
  		String label;
  		String description;
  		boolean isAvailable = false;
  	}
  
  	public static class StringOption extends Option {
          /**
           *
           * @param label  Option name:
           * @param tag    Descriptive name of option argument.
           * Example - tag "file-name" will show '-save <file-name>' in the usage.
           * @param description
           */
  		public StringOption(String label, String tag, String description) {
  			super(label, description);
  			this.tag = tag;
  		}
  
  		public StringOption(String label, String[] options, boolean caseSensitive, String description) {
  			super(label, description);
  			this.options = options;
  			this.caseSensitive = caseSensitive;
  		}
  		String[] options = null;
  		String tag = null;
  		boolean caseSensitive = false;
  
  		String value = null;
  	}
  
  	public static class IntegerOption extends Option {
  
  		public IntegerOption(String label, String description) {
  			super(label, description);
  		}
  
  		public IntegerOption(String label, int minValue, int maxValue, String description) {
  			super(label, description);
  			this.minValue = minValue;
  			this.maxValue = maxValue;
  		}
  
  		int minValue = Integer.MIN_VALUE;
  		int maxValue = Integer.MAX_VALUE;
  
  		int value = 0;
  	}
  
  	public static class IntegerArrayOption extends IntegerOption {
  
          public IntegerArrayOption(String label, String description) {
              this(label, 0, Integer.MIN_VALUE, Integer.MAX_VALUE, description);
          }
  
  		public IntegerArrayOption(String label, int count, String description) {
              this(label, count, Integer.MIN_VALUE, Integer.MAX_VALUE, description);
  		}
  
          public IntegerArrayOption(String label, int minValue, int maxValue, String description) {
              this(label, 0, minValue, maxValue, description);
          }
  
  		public IntegerArrayOption(String label, int count, int minValue, int maxValue, String description) {
  			super(label, minValue, maxValue, description);
  			this.count = count;		}
  
  		int count;
  
  		int[] values = null;
  	}
  
      public static class LongOption extends Option {
  
          public LongOption(String label, String description) {
              super(label, description);
          }
  
          public LongOption(String label, long minValue, long maxValue, String description) {
              super(label, description);
              this.minValue = minValue;
              this.maxValue = maxValue;
          }
  
          long minValue = Long.MIN_VALUE;
          long maxValue = Long.MAX_VALUE;
  
          long value = 0;
      }
  
  	public static class RealOption extends Option {
  
  		public RealOption(String label, String description) {
  			super(label, description);
  		}
  
  		public RealOption(String label, double minValue, double maxValue, String description) {
  			super(label, description);
  			this.minValue = minValue;
  			this.maxValue = maxValue;
  		}
  
  		double minValue = Double.NEGATIVE_INFINITY;
  		double maxValue = Double.POSITIVE_INFINITY;
  
  		double value = 0;
  	}
  
  	public static class RealArrayOption extends RealOption {
  
          public RealArrayOption(String label, String description) {
              this(label, 0, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, description);
          }
  
  		public RealArrayOption(String label, int count, String description) {
              this(label, count, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, description);
  		}
  
          public RealArrayOption(String label, double minValue, double maxValue, String description) {
              this(label, 0, minValue, maxValue, description);
          }
  
  		public RealArrayOption(String label, int count, double minValue, double maxValue, String description) {
  			super(label, minValue, maxValue, description);
  			this.count = count;
          }
  
  		private int count;
  
  		double[] values = null;
  	}
  
  	/**
  	 * Parse a list of arguments ready for accessing
  	 */
  	public Arguments(Option[] options) {
  		this.options = options;
  	}
  
  	public Arguments(Option[] options, boolean caseSensitive) {
  		this.options = options;
  		this.caseSensitive = caseSensitive;
  	}
  
  	/**
  	 * Parse a list of arguments ready for accessing
  	 */
  	public void parseArguments(String[] arguments) throws ArgumentException {
  
  		int[] optionIndex = new int[arguments.length];
  		for (int i = 0; i < optionIndex.length; i++) {
  			optionIndex[i] = -1;
  		}
  
  		for (int i = 0; i < options.length; i++) {
  			Option option = options[i];
  
  			int index = findArgument(arguments, option.label);
  			if (index != -1) {
  
  				if (optionIndex[index] != -1) {
  					throw new ArgumentException("Argument, " + arguments[index] + " overlaps with another argument");
  				}
  
  				// the first value may be appended to the option label (e.g., '-t1.0'):
  				String arg = arguments[index].substring(option.label.length() + 1);
  				optionIndex[index] = i;
  				option.isAvailable = true;
  
  				if (option instanceof IntegerArrayOption) {
  
  					IntegerArrayOption o = (IntegerArrayOption)option;
  					o.values = new int[o.count];
  					int k = index;
  					int j = 0;
  
  					while (j < o.count) {
  						if (arg.length() > 0) {
  							StringTokenizer tokenizer = new StringTokenizer(arg, ",\t ");
  							while (tokenizer.hasMoreTokens()) {
  								String token = tokenizer.nextToken();
  								if (token.length() > 0) {
  									try {
  										o.values[j] = Integer.parseInt(token);
  									} catch (NumberFormatException nfe) {
  										throw new ArgumentException("Argument, " + arguments[index] +
  											" has a bad integer value: " + token);
  									}
  									if (o.values[j] > o.maxValue || o.values[j] < o.minValue) {
  										throw new ArgumentException("Argument, " + arguments[index] +
  											" has a bad integer value: " + token);
  									}
  									j++;
  								}
  							}
  						}
  
  						k++;
  
  						if (j < o.count) {
  							if (k >= arguments.length) {
  								throw new ArgumentException("Argument, " + arguments[index] +
  									" is missing one or more values: expecting " + o.count + " integers");
  							}
  
  							if (optionIndex[k] != -1) {
  								throw new ArgumentException("Argument, " + arguments[index] + " overlaps with another argument");
  							}
  
  							arg = arguments[k];
  							optionIndex[k] = i;
  						}
  					}
  				} else if (option instanceof IntegerOption) {
  
  					IntegerOption o = (IntegerOption)option;
  					if (arg.length() == 0) {
  						int k = index + 1;
  						if (k >= arguments.length) {
  							throw new ArgumentException("Argument, " + arguments[index] +
  								" is missing its value: expecting an integer");
  						}
  
  						if (optionIndex[k] != -1) {
  							throw new ArgumentException("Argument, " + arguments[index] + " overlaps with another argument");
  						}
  						arg = arguments[k];
  						optionIndex[k] = i;
  					}
  
  					try {
  						o.value = Integer.parseInt(arg);
  					} catch (NumberFormatException nfe) {
  						throw new ArgumentException("Argument, " + arguments[index] +
  							" has a bad integer value: " + arg);
  					}
  