01: /*
02: Copyright 2004-2007 Paul R. Holser, Jr. All rights reserved.
03: Licensed under the Academic Free License version 3.0
04: */
05:
06: package joptsimple;
07:
08: /**
09: * Wrapper for an array of command line arguments.
10: *
11: * @since 1.0
12: * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a>
13: * @version $Id: ArgumentList.java,v 1.10 2007/04/10 20:06:25 pholser Exp $
14: */
15: class ArgumentList {
16: private final String[] arguments;
17: private int currentIndex;
18:
19: ArgumentList(String[] arguments) {
20: this .arguments = (String[]) arguments.clone();
21: }
22:
23: boolean hasMore() {
24: return currentIndex < arguments.length;
25: }
26:
27: String next() {
28: return arguments[currentIndex++];
29: }
30:
31: String peek() {
32: return arguments[currentIndex];
33: }
34:
35: // TODO: give the list a ParserRules to eliminate this duplication?
36: void treatNextAsLongOption() {
37: if ('-' != arguments[currentIndex].charAt(0))
38: arguments[currentIndex] = "--" + arguments[currentIndex];
39: }
40: }
|