com.crashlytics.tools.android_2.1.0

;
    }
    if (!required) {
      buff.append("]");
    }
  }
  
  public void printUsage(PrintWriter pw, int width, String cmdLineSyntax)
  {
    int argPos = cmdLineSyntax.indexOf(' ') + 1;
    
    printWrapped(pw, width, defaultSyntaxPrefix.length() + argPos, defaultSyntaxPrefix + cmdLineSyntax);
  }
  
  public void printOptions(PrintWriter pw, int width, Options options, int leftPad, int descPad)
  {
    StringBuffer sb = new StringBuffer();
    
    renderOptions(sb, width, options, leftPad, descPad);
    pw.println(sb.toString());
  }
  
  public void printWrapped(PrintWriter pw, int width, String text)
  {
    printWrapped(pw, width, 0, text);
  }
  
  public void printWrapped(PrintWriter pw, int width, int nextLineTabStop, String text)
  {
    StringBuffer sb = new StringBuffer(text.length());
    
    renderWrappedText(sb, width, nextLineTabStop, text);
    pw.println(sb.toString());
  }
  
  protected StringBuffer renderOptions(StringBuffer sb, int width, Options options, int leftPad, int descPad)
  {
    String lpad = createPadding(leftPad);
    String dpad = createPadding(descPad);
    
    int max = 0;
    
    List prefixList = new ArrayList();
    
    List optList = options.helpOptions();
    
    Collections.sort(optList, getOptionComparator());
    for (Iterator i = optList.iterator(); i.hasNext();)
    {
      Option option = (Option)i.next();
      StringBuffer optBuf = new StringBuffer(8);
      if (option.getOpt() == null)
      {
        optBuf.append(lpad).append("   " + defaultLongOptPrefix).append(option.getLongOpt());
      }
      else
      {
        optBuf.append(lpad).append(defaultOptPrefix).append(option.getOpt());
        if (option.hasLongOpt()) {
          optBuf.append(',').append(defaultLongOptPrefix).append(option.getLongOpt());
        }
      }
      if (option.hasArg()) {
        if (option.hasArgName()) {
          optBuf.append(" <").append(option.getArgName()).append(">");
        } else {
          optBuf.append(' ');
        }
      }
      prefixList.add(optBuf);
      max = optBuf.length() > max ? optBuf.length() : max;
    }
    int x = 0;
    for (Iterator i = optList.iterator(); i.hasNext();)
    {
      Option option = (Option)i.next();
      StringBuffer optBuf = new StringBuffer(prefixList.get(x++).toString());
      if (optBuf.length() < max) {
        optBuf.append(createPadding(max - optBuf.length()));
      }
      optBuf.append(dpad);
      
      int nextLineTabStop = max + descPad;
      if (option.getDescription() != null) {
        optBuf.append(option.getDescription());
      }
      renderWrappedText(sb, width, nextLineTabStop, optBuf.toString());
      if (i.hasNext()) {
        sb.append(defaultNewLine);
      }
    }
    return sb;
  }
  
  protected StringBuffer renderWrappedText(StringBuffer sb, int width, int nextLineTabStop, String text)
  {
    int pos = findWrapPos(text, width, 0);
    if (pos == -1)
    {
      sb.append(rtrim(text));
      
      return sb;
    }
    sb.append(rtrim(text.substring(0, pos))).append(defaultNewLine);
    if (nextLineTabStop >= width) {
      nextLineTabStop = 1;
    }
    String padding = createPadding(nextLineTabStop);
    for (;;)
    {
      text = padding + text.substring(pos).trim();
      pos = findWrapPos(text, width, 0);
      if (pos == -1)
      {
        sb.append(text);
        
        return sb;
      }
      if ((text.length() > width) && (pos == nextLineTabStop - 1)) {
        pos = width;
      }
      sb.append(rtrim(text.substring(0, pos))).append(defaultNewLine);
    }
  }
  
  protected int findWrapPos(String text, int width, int startPos)
  {
    int pos = -1;
    if ((((pos = text.indexOf('\n', startPos)) != -1) && (pos <= width)) || (((pos = text.indexOf('\t', startPos)) != -1) && (pos <= width))) {
      return pos + 1;
    }
    if (startPos + width >= text.length()) {
      return -1;
    }
    pos = startPos + width;
    char c;
    while ((pos >= startPos) && ((c = text.charAt(pos)) != ' ') && (c != '\n') && (c != '\r')) {
      pos--;
    }
    if (pos > startPos) {
      return pos;
    }
    pos = startPos + width;
    char c;
    while ((pos <= text.length()) && ((c = text.charAt(pos)) != ' ') && (c != '\n') && (c != '\r')) {
      pos++;
    }
    return pos == text.length() ? -1 : pos;
  }
  
  protected String createPadding(int len)
  {
    StringBuffer sb = new StringBuffer(len);
    for (int i = 0; i < len; i++) {
      sb.append(' ');
    }
    return sb.toString();
  }
  
  protected String rtrim(String s)
  {
    if ((s == null) || (s.length() == 0)) {
      return s;
    }
    int pos = s.length();
    while ((pos > 0) && (Character.isWhitespace(s.charAt(pos - 1)))) {
      pos--;
    }
    return s.substring(0, pos);
  }
  
  private static class OptionComparator
    implements Comparator
  {
    OptionComparator(HelpFormatter.1 x0)
    {
      this();
    }
    
    public int compare(Object o1, Object o2)
    {
      Option opt1 = (Option)o1;
      Option opt2 = (Option)o2;
      
      return opt1.getKey().compareToIgnoreCase(opt2.getKey());
    }
    
    private OptionComparator() {}
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.cli.HelpFormatter
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.cli;

public class MissingArgumentException
  extends ParseException
{
  private Option option;
  
  public MissingArgumentException(String message)
  {
    super(message);
  }
  
  public MissingArgumentException(Option option)
  {
    this("Missing argument for option: " + option.getKey());
    this.option = option;
  }
  
  public Option getOption()
  {
    return option;
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.cli.MissingArgumentException
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.cli;

import java.util.Iterator;
import java.util.List;

public class MissingOptionException
  extends ParseException
{
  private List missingOptions;
  
  public MissingOptionException(String message)
  {
    super(message);
  }
  
  public MissingOptionException(List missingOptions)
  {
    this(createMessage(missingOptions));
    this.missingOptions = missingOptions;
  }
  
  public List getMissingOptions()
  {
    return missingOptions;
  }
  
  private static String createMessage(List missingOptions)
  {
    StringBuffer buff = new StringBuffer("Missing required option");
    buff.append(missingOptions.size() == 1 ? "" : "s");
    buff.append(": ");
    
    Iterator it = missingOptions.iterator();
    while (it.hasNext())
    {
      buff.append(it.next());
      if (it.hasNext()) {
        buff.append(", ");
      }
    }
    return buff.toString();
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.cli.MissingOptionException
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.cli;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

public class Option
  implements Cloneable, Serializable
{
  private static final long serialVersionUID = 1L;
  public static final int UNINITIALIZED = -1;
  public static final int UNLIMITED_VALUES = -2;
  private String opt;
  private String longOpt;
  private String argName = "arg";
  private String description;
  private boolean required;
  private boolean optionalArg;
  private int numberOfArgs = -1;
  private Object type;
  private List values = new ArrayList();
  private char valuesep;
  
  public Option(String opt, String description)
    throws IllegalArgumentException
  {
    this(opt, null, false, description);
  }
  
  public Option(String opt, boolean hasArg, String description)
    throws IllegalArgumentException
  {
    this(opt, null, hasArg, description);
  }
  
  public Option(String opt, String longOpt, boolean hasArg, String description)
    throws IllegalArgumentException
  {
    OptionValidator.validateOption(opt);
    
    this.opt = opt;
    this.longOpt = longOpt;
    if (hasArg) {
      numberOfArgs = 1;
    }
    this.description = description;
  }
  
  public int getId()
  {
    return getKey().charAt(0);
  }
  
  String getKey()
  {
    if (opt == null) {
      return longOpt;
    }
    return opt;
  }
  
  public String getOpt()
  {
    return opt;
  }
  
  public Object getType()
  {
    return type;
  }
  
  public void setType(Object type)
  {
    this.type = type;
  }
  
  public String getLongOpt()
  {
    return longOpt;
  }
  
  public void setLongOpt(String longOpt)
  {
    this.longOpt = longOpt;
  }
  
  public void setOptionalArg(boolean optionalArg)
  {
    this.optionalArg = optionalArg;
  }
  
  public boolean hasOptionalArg()
  {
    return optionalArg;
  }
  
  public boolean hasLongOpt()
  {
    return longOpt != null;
  }
  
  public boolean hasArg()
  {
    return (numberOfArgs > 0) || (numberOfArgs == -2);
  }
  
  public String getDescription()
  {
    return description;
  }
  
  public void setDescription(String description)
  {
    this.description = description;
  }
  
  public boolean isRequired()
  {
    return required;
  }
  
  public void setRequired(boolean required)
  {
    this.required = required;
  }
  
  public void setArgName(String argName)
  {
    this.argName = argName;
  }
  
  public String getArgName()
  {
    return argName;
  }
  
  public boolean hasArgName()
  {
    return (argName != null) && (argName.length() > 0);
  }
  
  public boolean hasArgs()
  {
    return (numberOfArgs > 1) || (numberOfArgs == -2);
  }
  
  public void setArgs(int num)
  {
    numberOfArgs = num;
  }
  
  public void setValueSeparator(char sep)
  {
    valuesep = sep;
  }
  
  public char getValueSeparator()
  {
    return valuesep;
  }
  
  public boolean hasValueSeparator()
  {
    return valuesep > 0;
  }
  
  public int getArgs()
  {
    return numberOfArgs;
  }
  
  void addValueForProcessing(String value)
  {
    switch (numberOfArgs)
    {
    case -1: 
      throw new RuntimeException("NO_ARGS_ALLOWED");
    }
    processValue(value);
  }
  
  private void processValue(String value)
  {
    if (hasValueSeparator())
    {
      char sep = getValueSeparator();
      
      int index = value.indexOf(sep);
      while (index != -1)
      {
        if (values.size() == numberOfArgs - 1) {
          break;
        }
        add(value.substring(0, index));
        
        value = value.substring(index + 1);
        
        index = value.indexOf(sep);
      }
    }
    add(value);
  }
  
  private void add(String value)
  {
    if ((numberOfArgs > 0) && (values.size() > numberOfArgs - 1)) {
      throw new RuntimeException("Cannot add value, list full.");
    }
    values.add(value);
  }
  
  public String getValue()
  {
    return hasNoValues() ? null : (String)values.get(0);
  }
  
  public String getValue(int index)
    throws IndexOutOfBoundsException
  {
    return hasNoValues() ? null : (String)values.get(index);
  }
  
  public String getValue(String defaultValue)
  {
    String value = getValue();
    
    return value != null ? value : defaultValue;
  }
  
  public String[] getValues()
  {
    return hasNoValues() ? null : (String[])values.toArray(new String[values.size()]);
  }
  
  public List getValuesList()
  {
    return values;
  }
  
  public String toString()
  {
    StringBuffer buf = new StringBuffer().append("[ option: ");
    
    buf.append(opt);
    if (longOpt != null) {
      buf.append(" ").append(longOpt);
    }
    buf.append(" ");
    if (hasArgs()) {
      buf.append("[ARG...]");
    } else if (hasArg()) {
      buf.append(" [ARG]");
    }
    buf.append(" :: ").append(description);
    if (type != null) {
      buf.append(" :: ").append(type);
    }
    buf.append(" ]");
    
    return buf.toString();
  }
  
  private boolean hasNoValues()
  {
    return values.isEmpty();
  }
  
  public boolean equals(Object o)
  {
    if (this == o) {
      return true;
    }
    if ((o == null) || (getClass() != o.getClass())) {
      return false;
    }
    Option option = (Option)o;
    if (opt != null ? !opt.equals(opt) : opt != null) {
      return false;
    }
    if (longOpt != null ? !longOpt.equals(longOpt) : longOpt != null) {
      return false;
    }
    return true;
  }
  
  public int hashCode()
  {
    int result = opt != null ? opt.hashCode() : 0;
    result = 31 * result + (longOpt != null ? longOpt.hashCode() : 0);
    return result;
  }
  
  public Object clone()
  {
    try
    {
      Option option = (Option)super.clone();
      values = new ArrayList(values);
      return option;
    }
    catch (CloneNotSupportedException cnse)
    {
      throw new RuntimeException("A CloneNotSupportedException was thrown: " + cnse.getMessage());
    }
  }
  
  void clearValues()
  {
    values.clear();
  }
  
  /**
   * @deprecated
   */
  public boolean addValue(String value)
  {
    throw new UnsupportedOperationException("The addValue method is not intended for client use. Subclasses should use the addValueForProcessing method instead. ");
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.cli.Option
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.cli;

public final class OptionBuilder
{
  private static String longopt;
  private static String description;
  private static String argName;
  private static boolean required;
  private static int numberOfArgs = -1;
  private static Object type;
  private static boolean optionalArg;
  private static char valuesep;
  private static OptionBuilder instance = new OptionBuilder();
  
  private static void reset()
  {
    description = null;
    argName = "arg";
    longopt = null;
    type = null;
    required = false;
    numberOfArgs = -1;
    
    optionalArg = false;
    valuesep = '\000';
  }
  
  public static OptionBuilder withLongOpt(String newLongopt)
  {
    longopt = newLongopt;
    
    return instance;
  }
  
  public static OptionBuilder hasArg()
  {
    numberOfArgs = 1;
    
    return instance;
  }
  
  public static OptionBuilder hasArg(boolean hasArg)
  {
    numberOfArgs = hasArg ? 1 : -1;
    
    return instance;
  }
  
  public static OptionBuilder withArgName(String name)
  {
    argName = name;
    
    return instance;
  }
  
  public static OptionBuilder isRequired()
  {
    required = true;
    
    return instance;
  }
  
  public static OptionBuilder withValueSeparator(char sep)
  {
    valuesep = sep;
    
    return instance;
  }
  
  public static OptionBuilder withValueSeparator()
  {
    valuesep = '=';
    
    return instance;
  }
  
  public static OptionBuilder isRequired(boolean newRequired)
  {
    required = newRequired;
    
    return instance;
  }
  
  public static OptionBuilder hasArgs()
  {
    numberOfArgs = -2;
    
    return instance;
  }
  
  public static OptionBuilder hasArgs(int num)
  {
    numberOfArgs = num;
    
    return instance;
  }
  
  public static OptionBuilder hasOptionalArg()
  {
    numberOfArgs = 1;
    optionalArg = true;
    
    return instance;
  }
  
  public static OptionBuilder hasOptionalArgs()
  {
    numberOfArgs = -2;
    optionalArg = true;
    
    return instance;
  }
  
  public static OptionBuilder hasOptionalArgs(int numArgs)
  {
    numberOfArgs = numArgs;
    optionalArg = true;
    
    return instance;
  }
  
  public static OptionBuilder withType(Object newType)
  {
    type = newType;
    
    return instance;
  }
  
  public static OptionBuilder withDescription(String newDescription)
  {
    description = newDescription;
    
    return instance;
  }
  
  public static Option create(char opt)
    throws IllegalArgumentException
  {
    return create(String.valueOf(opt));
  }
  
  public static Option create()
    throws IllegalArgumentException
  {
    if (longopt == null)
    {
      reset();
      throw new IllegalArgumentException("must specify longopt");
    }
    return create(null);
  }
  
  public static Option create(String opt)
    throws IllegalArgumentException
  {
    Option option = null;
    try
    {
      option = new Option(opt, description);
      
      option.setLongOpt(longopt);
      option.setRequired(required);
      option.setOptionalArg(optionalArg);
      option.setArgs(numberOfArgs);
      option.setType(type);
      option.setValueSeparator(valuesep);
      option.setArgName(argName);
    }
    finally
    {
      reset();
    }
    return option;
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.cli.OptionBuilder
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.cli;

import java.io.Serializable;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

public class OptionGroup
  implements Serializable
{
  private static final long serialVersionUID = 1L;
  private Map optionMap = new HashMap();
  private String selected;
  private boolean required;
  
  public OptionGroup addOption(Option option)
  {
    optionMap.put(option.getKey(), option);
    
    return this;
  }
  
  public Collection getNames()
  {
    return optionMap.keySet();
  }
  
  public Collection getOptions()
  {
    return optionMap.values();
  }
  
  public void setSelected(Option option)
    throws AlreadySelectedException
  {
    if ((selected == null) || (selected.equals(option.getOpt()))) {
      selected = option.getOpt();
    } else {
      throw new AlreadySelectedException(this, option);
    }
  }
  
  public String getSelected()
  {
    return selected;
  }
  
  public void setRequired(boolean required)
  {
    this.required = required;
  }
  
  public boolean isRequired()
  {
    return required;
  }
  
  public String toString()
  {
    StringBuffer buff = new StringBuffer();
    
    Iterator iter = getOptions().iterator();
    
    buff.append("[");
    while (iter.hasNext())
    {
      Option option = (Option)iter.next();
      if (option.getOpt() != null)
      {
        buff.append("-");
        buff.append(option.getOpt());
      }
      else
      {
        buff.append("--");
        buff.append(option.getLongOpt());
      }
      buff.append(" ");
      buff.append(option.getDescription());
      if (iter.hasNext()) {
        buff.append(", ");
      }
    }
    buff.append("]");
    
    return buff.toString();
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.cli.OptionGroup
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.cli;

class OptionValidator
{
  static void validateOption(String opt)
    throws IllegalArgumentException
  {
    if (opt == null) {
      return;
    }
    if (opt.length() == 1)
    {
      char ch = opt.charAt(0);
      if (!isValidOpt(ch)) {
        throw new IllegalArgumentException("illegal option value '" + ch + "'");
      }
    }
    else
    {
      char[] chars = opt.toCharArray();
      for (int i = 0; i < chars.length; i++) {
        if (!isValidChar(chars[i])) {
          throw new IllegalArgumentException("opt contains illegal character value '" + chars[i] + "'");
        }
      }
    }
  }
  
  private static boolean isValidOpt(char c)
  {
    return (isValidChar(c)) || (c == ' ') || (c == '?') || (c == '@');
  }
  
  private static boolean isValidChar(char c)
  {
    return Character.isJavaIdentifierPart(c);
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.cli.OptionValidator
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.cli;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

public class Options
  implements Serializable
{
  private static final long serialVersionUID = 1L;
  private Map shortOpts = new HashMap();
  private Map longOpts = new HashMap();
  private List requiredOpts = new ArrayList();
  private Map optionGroups = new HashMap();
  
  public Options addOptionGroup(OptionGroup group)
  {
    Iterator options = group.getOptions().iterator();
    if (group.isRequired()) {
      requiredOpts.add(group);
    }
    while (options.hasNext())
    {
      Option option = (Option)options.next();
      
      option.setRequired(false);
      addOption(option);
      
      optionGroups.put(option.getKey(), group);
    }
    return this;
  }
  
  Collection getOptionGroups()
  {
    return new HashSet(optionGroups.values());
  }
  
  public Options addOption(String opt, boolean hasArg, String description)
  {
    addOption(opt, null, hasArg, description);
    
    return this;
  }
  
  public Options addOption(String opt, String longOpt, boolean hasArg, String description)
  {
    addOption(new Option(opt, longOpt, hasArg, description));
    
    return this;
  }
  
  public Options addOption(Option opt)
  {
    String key = opt.getKey();
    if (opt.hasLongOpt()) {
      longOpts.put(opt.getLongOpt(), opt);
    }
    if (opt.isRequired())
    {
      if (requiredOpts.contains(key)) {
        requiredOpts.remove(requiredOpts.indexOf(key));
      }
      requiredOpts.add(key);
    }
    shortOpts.put(key, opt);
    
    return this;
  }
  
  public Collection getOptions()
  {
    return Collections.unmodifiableCollection(helpOptions());
  }
  
  List helpOptions()
  {
    return new ArrayList(shortOpts.values());
  }
  
  public List getRequiredOptions()
  {
    return requiredOpts;
  }
  
  public Option getOption(String opt)
  {
    opt = Util.stripLeadingHyphens(opt);
    if (shortOpts.containsKey(opt)) {
      return (Option)shortOpts.get(opt);
    }
    return (Option)longOpts.get(opt);
  }
  
  public boolean hasOption(String opt)
  {
    opt = Util.stripLeadingHyphens(opt);
    
    return (shortOpts.containsKey(opt)) || (longOpts.containsKey(opt));
  }
  
  public OptionGroup getOptionGroup(Option opt)
  {
    return (OptionGroup)optionGroups.get(opt.getKey());
  }
  
  public String toString()
  {
    StringBuffer buf = new StringBuffer();
    
    buf.append("[ Options: [ short ");
    buf.append(shortOpts.toString());
    buf.append(" ] [ long ");
    buf.append(longOpts);
    buf.append(" ]");
    
    return buf.toString();
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.cli.Options
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.cli;

public class ParseException
  extends Exception
{
  public ParseException(String message)
  {
    super(message);
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.cli.ParseException
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.cli;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import java.util.Properties;

public abstract class Parser
  implements CommandLineParser
{
  protected CommandLine cmd;
  private Options options;
  private List requiredOptions;
  
  protected void setOptions(Options options)
  {
    this.options = options;
    requiredOptions = new ArrayList(options.getRequiredOptions());
  }
  
  protected Options getOptions()
  {
    return options;
  }
  
  protected List getRequiredOptions()
  {
    return requiredOptions;
  }
  
  protected abstract String[] flatten(Options paramOptions, String[] paramArrayOfString, boolean paramBoolean);
  
  public CommandLine parse(Options options, String[] arguments)
    throws ParseException
  {
    return parse(options, arguments, null, false);
  }
  
  public CommandLine parse(Options options, String[] arguments, Properties properties)
    throws ParseException
  {
    return parse(options, arguments, properties, false);
  }
  
  public CommandLine parse(Options options, String[] arguments, boolean stopAtNonOption)
    throws ParseException
  {
    return parse(options, arguments, null, stopAtNonOption);
  }
  
  public CommandLine parse(Options options, String[] arguments, Properties properties, boolean stopAtNonOption)
    throws ParseException
  {
    for (Iterator it = options.helpOptions().iterator(); it.hasNext();)
    {
      Option opt = (Option)it.next();
      opt.clearValues();
    }
    setOptions(options);
    
    cmd = new CommandLine();
    
    boolean eatTheRest = false;
    if (arguments == null) {
      arguments = new String[0];
    }
    List tokenList = Arrays.asList(flatten(getOptions(), arguments, stopAtNonOption));
    
    ListIterator iterator = tokenList.listIterator();
    while (iterator.hasNext())
    {
      String t = (String)iterator.next();
      if ("--".equals(t))
      {
        eatTheRest = true;
      }
      else if ("-".equals(t))
      {
        if (stopAtNonOption) {
          eatTheRest = true;
        } else {
          cmd.addArg(t);
        }
      }
      else if (t.startsWith("-"))
      {
        if ((stopAtNonOption) && (!getOptions().hasOption(t)))
        {
          eatTheRest = true;
          cmd.addArg(t);
        }
        else
        {
          processOption(t, iterator);
        }
      }
      else
      {
        cmd.addArg(t);
        if (stopAtNonOption) {
          eatTheRest = true;
        }
      }
      if (eatTheRest) {
        while (iterator.hasNext())
        {
          String str = (String)iterator.next();
          if (!"--".equals(str)) {
            cmd.addArg(str);
          }
        }
      }
    }
    processProperties(properties);
    checkRequiredOptions();
    
    return cmd;
  }
  
  protected void processProperties(Properties properties)
  {
    if (properties == null) {
      return;
    }
    for (Enumeration e = properties.propertyNames(); e.hasMoreElements();)
    {
      String option = e.nextElement().toString();
      if (!cmd.hasOption(option))
      {
        Option opt = getOptions().getOption(option);
        
        String value = properties.getProperty(option);
        if (opt.hasArg())
        {
          if ((opt.getValues() == null) || (opt.getValues().length == 0)) {
            try
            {
              opt.addValueForProcessing(value);
            }
            catch (RuntimeException exp) {}
          }
        }
        else {
          if ((!"yes".equalsIgnoreCase(value)) && (!"true".equalsIgnoreCase(value)) && (!"1".equalsIgnoreCase(value))) {
            break;
          }
        }
        cmd.addOption(opt);
      }
    }
  }
  
  protected void checkRequiredOptions()
    throws MissingOptionException
  {
    if (!getRequiredOptions().isEmpty()) {
      throw new MissingOptionException(getRequiredOptions());
    }
  }
  
  public void processArgs(Option opt, ListIterator iter)
    throws ParseException
  {
    while (iter.hasNext())
    {
      String str = (String)iter.next();
      if ((getOptions().hasOption(str)) && (str.startsWith("-")))
      {
        iter.previous();
        break;
      }
      try
      {
        opt.addValueForProcessing(Util.stripLeadingAndTrailingQuotes(str));
      }
      catch (RuntimeException exp)
      {
        iter.previous();
        break;
      }
    }
    if ((opt.getValues() == null) && (!opt.hasOptionalArg())) {
      throw new MissingArgumentException(opt);
    }
  }
  
  protected void processOption(String arg, ListIterator iter)
    throws ParseException
  {
    boolean hasOption = getOptions().hasOption(arg);
    if (!hasOption) {
      throw new UnrecognizedOptionException("Unrecognized option: " + arg, arg);
    }
    Option opt = (Option)getOptions().getOption(arg).clone();
    if (opt.isRequired()) {
      getRequiredOptions().remove(opt.getKey());
    }
    if (getOptions().getOptionGroup(opt) != null)
    {
      OptionGroup group = getOptions().getOptionGroup(opt);
      if (group.isRequired()) {
        getRequiredOptions().remove(group);
      }
      group.setSelected(opt);
    }
    if (opt.hasArg()) {
      processArgs(opt, iter);
    }
    cmd.addOption(opt);
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.cli.Parser
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.cli;

import java.io.File;
import java.io.FileInputStream;
import java.net.URL;
import java.util.Date;

public class PatternOptionBuilder
{
  public static final Class STRING_VALUE = String.class;
  public static final Class OBJECT_VALUE = Object.class;
  public static final Class NUMBER_VALUE = Number.class;
  public static final Class DATE_VALUE = Date.class;
  public static final Class CLASS_VALUE = Class.class;
  public static final Class EXISTING_FILE_VALUE = FileInputStream.class;
  public static final Class FILE_VALUE = File.class;
  public static final Class FILES_VALUE = new File[0];
  public static final Class URL_VALUE = URL.class;
  
  public static Object getValueClass(char ch)
  {
    switch (ch)
    {
    case '@': 
      return OBJECT_VALUE;
    case ':': 
      return STRING_VALUE;
    case '%': 
      return NUMBER_VALUE;
    case '+': 
      return CLASS_VALUE;
    case '#': 
      return DATE_VALUE;
    case '<': 
      return EXISTING_FILE_VALUE;
    case '>': 
      return FILE_VALUE;
    case '*': 
      return FILES_VALUE;
    case '/': 
      return URL_VALUE;
    }
    return null;
  }
  
  public static boolean isValueCode(char ch)
  {
    return (ch == '@') || (ch == ':') || (ch == '%') || (ch == '+') || (ch == '#') || (ch == '<') || (ch == '>') || (ch == '*') || (ch == '/') || (ch == '!');
  }
  
  public static Options parsePattern(String pattern)
  {
    char opt = ' ';
    boolean required = false;
    Object type = null;
    
    Options options = new Options();
    for (int i = 0; i < pattern.length(); i++)
    {
      char ch = pattern.charAt(i);
      if (!isValueCode(ch))
      {
        if (opt != ' ')
        {
          OptionBuilder.hasArg(type != null);
          OptionBuilder.isRequired(required);
          OptionBuilder.withType(type);
          
          options.addOption(OptionBuilder.create(opt));
          required = false;
          type = null;
          opt = ' ';
        }
        opt = ch;
      }
      else if (ch == '!')
      {
        required = true;
      }
      else
      {
        type = getValueClass(ch);
      }
    }
    if (opt != ' ')
    {
      OptionBuilder.hasArg(type != null);
      OptionBuilder.isRequired(required);
      OptionBuilder.withType(type);
      
      options.addOption(OptionBuilder.create(opt));
    }
    return options;
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.cli.PatternOptionBuilder
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.cli;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;

public class PosixParser
  extends Parser
{
  private List tokens = new ArrayList();
  private boolean eatTheRest;
  private Option currentOption;
  private Options options;
  
  private void init()
  {
    eatTheRest = false;
    tokens.clear();
  }
  
  protected String[] flatten(Options options, String[] arguments, boolean stopAtNonOption)
  {
    init();
    this.options = options;
    
    Iterator iter = Arrays.asList(arguments).iterator();
    while (iter.hasNext())
    {
      String token = (String)iter.next();
      if (token.startsWith("--"))
      {
        int pos = token.indexOf('=');
        String opt = pos == -1 ? token : token.substring(0, pos);
        if (!options.hasOption(opt))
        {
          processNonOptionToken(token, stopAtNonOption);
        }
        else
        {
          currentOption = options.getOption(opt);
          
          tokens.add(opt);
          if (pos != -1) {
            tokens.add(token.substring(pos + 1));
          }
        }
      }
      else if ("-".equals(token))
      {
        tokens.add(token);
      }
      else if (token.startsWith("-"))
      {
        if ((token.length() == 2) || (options.hasOption(token))) {
          processOptionToken(token, stopAtNonOption);
        } else {
          burstToken(token, stopAtNonOption);
        }
      }
      else
      {
        processNonOptionToken(token, stopAtNonOption);
      }
      gobble(iter);
    }
    return (String[])tokens.toArray(new String[tokens.size()]);
  }
  
  private void gobble(Iterator iter)
  {
    if (eatTheRest) {
      while (iter.hasNext()) {
        tokens.add(iter.next());
      }
    }
  }
  
  private void processNonOptionToken(String value, boolean stopAtNonOption)
  {
    if ((stopAtNonOption) && ((currentOption == null) || (!currentOption.hasArg())))
    {
      eatTheRest = true;
      tokens.add("--");
    }
    tokens.add(value);
  }
  
  private void processOptionToken(String token, boolean stopAtNonOption)
  {
    if ((stopAtNonOption) && (!options.hasOption(token))) {
      eatTheRest = true;
    }
    if (options.hasOption(token)) {
      currentOption = options.getOption(token);
    }
    tokens.add(token);
  }
  
  protected void burstToken(String token, boolean stopAtNonOption)
  {
    for (int i = 1; i < token.length(); i++)
    {
      String ch = String.valueOf(token.charAt(i));
      if (options.hasOption(ch))
      {
        tokens.add("-" + ch);
        currentOption = options.getOption(ch);
        if ((currentOption.hasArg()) && (token.length() != i + 1))
        {
          tokens.add(token.substring(i + 1));
          
          break;
        }
      }
      else
      {
        if (stopAtNonOption)
        {
          processNonOptionToken(token.substring(i), true);
          break;
        }
        tokens.add(token);
        break;
      }
    }
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.cli.PosixParser
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.cli;

import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Date;

public class TypeHandler
{
  public static Object createValue(String str, Object obj)
    throws ParseException
  {
    return createValue(str, (Class)obj);
  }
  
  public static Object createValue(String str, Class clazz)
    throws ParseException
  {
    if (PatternOptionBuilder.STRING_VALUE == clazz) {
      return str;
    }
    if (PatternOptionBuilder.OBJECT_VALUE == clazz) {
      return createObject(str);
    }
    if (PatternOptionBuilder.NUMBER_VALUE == clazz) {
      return createNumber(str);
    }
    if (PatternOptionBuilder.DATE_VALUE == clazz) {
      return createDate(str);
    }
    if (PatternOptionBuilder.CLASS_VALUE == clazz) {
      return createClass(str);
    }
    if (PatternOptionBuilder.FILE_VALUE == clazz) {
      return createFile(str);
    }
    if (PatternOptionBuilder.EXISTING_FILE_VALUE == clazz) {
      return createFile(str);
    }
    if (PatternOptionBuilder.FILES_VALUE == clazz) {
      return createFiles(str);
    }
    if (PatternOptionBuilder.URL_VALUE == clazz) {
      return createURL(str);
    }
    return null;
  }
  
  public static Object createObject(String classname)
    throws ParseException
  {
    Class cl = null;
    try
    {
      cl = Class.forName(classname);
    }
    catch (ClassNotFoundException cnfe)
    {
      throw new ParseException("Unable to find the class: " + classname);
    }
    Object instance = null;
    try
    {
      instance = cl.newInstance();
    }
    catch (Exception e)
    {
      throw new ParseException(e.getClass().getName() + "; Unable to create an instance of: " + classname);
    }
    return instance;
  }
  
  public static Number createNumber(String str)
    throws ParseException
  {
    try
    {
      if (str.indexOf('.') != -1) {
        return Double.valueOf(str);
      }
      return Long.valueOf(str);
    }
    catch (NumberFormatException e)
    {
      throw new ParseException(e.getMessage());
    }
  }
  
  public static Class createClass(String classname)
    throws ParseException
  {
    try
    {
      return Class.forName(classname);
    }
    catch (ClassNotFoundException e)
    {
      throw new ParseException("Unable to find the class: " + classname);
    }
  }
  
  public static Date createDate(String str)
    throws ParseException
  {
    throw new UnsupportedOperationException("Not yet implemented");
  }
  
  public static URL createURL(String str)
    throws ParseException
  {
    try
    {
      return new URL(str);
    }
    catch (MalformedURLException e)
    {
      throw new ParseException("Unable to parse the URL: " + str);
    }
  }
  
  public static File createFile(String str)
    throws ParseException
  {
    return new File(str);
  }
  
  public static File[] createFiles(String str)
    throws ParseException
  {
    throw new UnsupportedOperationException("Not yet implemented");
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.cli.TypeHandler
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.cli;

public class UnrecognizedOptionException
  extends ParseException
{
  private String option;
  
  public UnrecognizedOptionException(String message)
  {
    super(message);
  }
  
  public UnrecognizedOptionException(String message, String option)
  {
    this(message);
    this.option = option;
  }
  
  public String getOption()
  {
    return option;
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.cli.UnrecognizedOptionException
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.cli;

class Util
{
  static String stripLeadingHyphens(String str)
  {
    if (str == null) {
      return null;
    }
    if (str.startsWith("--")) {
      return str.substring(2, str.length());
    }
    if (str.startsWith("-")) {
      return str.substring(1, str.length());
    }
    return str;
  }
  
  static String stripLeadingAndTrailingQuotes(String str)
  {
    if (str.startsWith("\"")) {
      str = str.substring(1, str.length());
    }
    if (str.endsWith("\"")) {
      str = str.substring(0, str.length() - 1);
    }
    return str;
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.cli.Util
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.codec;

public abstract interface BinaryDecoder
  extends Decoder
{
  public abstract byte[] decode(byte[] paramArrayOfByte)
    throws DecoderException;
}

/* Location:
 * Qualified Name:     org.apache.commons.codec.BinaryDecoder
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.codec;

public abstract interface BinaryEncoder
  extends Encoder
{
  public abstract byte[] encode(byte[] paramArrayOfByte)
    throws EncoderException;
}

/* Location:
 * Qualified Name:     org.apache.commons.codec.BinaryEncoder
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.codec;

public class CharEncoding
{
  public static final String ISO_8859_1 = "ISO-8859-1";
  public static final String US_ASCII = "US-ASCII";
  public static final String UTF_16 = "UTF-16";
  public static final String UTF_16BE = "UTF-16BE";
  public static final String UTF_16LE = "UTF-16LE";
  public static final String UTF_8 = "UTF-8";
}

/* Location:
 * Qualified Name:     org.apache.commons.codec.CharEncoding
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.codec;

public abstract interface Decoder
{
  public abstract Object decode(Object paramObject)
    throws DecoderException;
}

/* Location:
 * Qualified Name:     org.apache.commons.codec.Decoder
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.codec;

public class DecoderException
  extends Exception
{
  private static final long serialVersionUID = 1L;
  
  public DecoderException() {}
  
  public DecoderException(String message)
  {
    super(message);
  }
  
  public DecoderException(String message, Thro
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2019. Infinite Loop Ltd