| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| CommandLine |
|
| 1.5;1.5 |
| 1 | /* | |
| 2 | ||
| 3 | dsh-commandline Command line parser based on typed arguments. | |
| 4 | Copyright (c) 2004-2012 held jointly by the individual authors. | |
| 5 | ||
| 6 | This library is free software; you can redistribute it and/or modify it | |
| 7 | under the terms of the GNU Lesser General Public License as published | |
| 8 | by the Free Software Foundation; either version 3 of the License, or (at | |
| 9 | your option) any later version. | |
| 10 | ||
| 11 | This library is distributed in the hope that it will be useful, but WITHOUT | |
| 12 | ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or | |
| 13 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public | |
| 14 | License for more details. | |
| 15 | ||
| 16 | You should have received a copy of the GNU Lesser General Public License | |
| 17 | along with this library; if not, write to the Free Software Foundation, | |
| 18 | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. | |
| 19 | ||
| 20 | > http://www.fsf.org/licensing/licenses/lgpl.html | |
| 21 | > http://www.opensource.org/licenses/lgpl-license.php | |
| 22 | ||
| 23 | */ | |
| 24 | package org.dishevelled.commandline; | |
| 25 | ||
| 26 | import java.util.List; | |
| 27 | import java.util.Arrays; | |
| 28 | import java.util.ListIterator; | |
| 29 | ||
| 30 | /** | |
| 31 | * Command line. | |
| 32 | * | |
| 33 | * @author Michael Heuer | |
| 34 | * @version $Revision: 1059 $ $Date: 2012-01-03 14:03:02 -0600 (Tue, 03 Jan 2012) $ | |
| 35 | */ | |
| 36 | 0 | public final class CommandLine |
| 37 | implements ListIterator<String> | |
| 38 | { | |
| 39 | /** Wrapped iterator. */ | |
| 40 | private final ListIterator<String> iterator; | |
| 41 | ||
| 42 | ||
| 43 | /** | |
| 44 | * Create a new command line with the specified arguments. | |
| 45 | * | |
| 46 | * @param args command line arguments | |
| 47 | */ | |
| 48 | public CommandLine(final String[] args) | |
| 49 | 478 | { |
| 50 | 478 | if (args == null) |
| 51 | { | |
| 52 | 1 | throw new IllegalArgumentException("args must not be null"); |
| 53 | } | |
| 54 | ||
| 55 | 477 | List<String> argumentList = Arrays.asList(args); |
| 56 | 477 | iterator = argumentList.listIterator(); |
| 57 | 477 | } |
| 58 | ||
| 59 | ||
| 60 | /** {@inheritDoc} */ | |
| 61 | public void add(final String s) | |
| 62 | { | |
| 63 | 2 | throw new UnsupportedOperationException("add operation not supported by CommandLine"); |
| 64 | } | |
| 65 | ||
| 66 | /** {@inheritDoc} */ | |
| 67 | public boolean hasNext() | |
| 68 | { | |
| 69 | 1301 | return iterator.hasNext(); |
| 70 | } | |
| 71 | ||
| 72 | /** {@inheritDoc} */ | |
| 73 | public boolean hasPrevious() | |
| 74 | { | |
| 75 | 1004 | return iterator.hasPrevious(); |
| 76 | } | |
| 77 | ||
| 78 | /** {@inheritDoc} */ | |
| 79 | public String next() | |
| 80 | { | |
| 81 | 1704 | return iterator.next(); |
| 82 | } | |
| 83 | ||
| 84 | /** {@inheritDoc} */ | |
| 85 | public int nextIndex() | |
| 86 | { | |
| 87 | 1 | return iterator.nextIndex(); |
| 88 | } | |
| 89 | ||
| 90 | /** {@inheritDoc} */ | |
| 91 | public String previous() | |
| 92 | { | |
| 93 | 949 | return iterator.previous(); |
| 94 | } | |
| 95 | ||
| 96 | /** {@inheritDoc} */ | |
| 97 | public int previousIndex() | |
| 98 | { | |
| 99 | 1 | return iterator.previousIndex(); |
| 100 | } | |
| 101 | ||
| 102 | /** {@inheritDoc} */ | |
| 103 | public void remove() | |
| 104 | { | |
| 105 | 2 | throw new UnsupportedOperationException("remove operation not supported by CommandLine"); |
| 106 | } | |
| 107 | ||
| 108 | /** {@inheritDoc} */ | |
| 109 | public void set(final String s) | |
| 110 | { | |
| 111 | 2 | throw new UnsupportedOperationException("set operation not supported by CommandLine"); |
| 112 | } | |
| 113 | } |