| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| ArgumentType |
|
| 2.0;2 |
| 1 | /** | |
| 2 | * Distribution License: | |
| 3 | * JSword is free software; you can redistribute it and/or modify it under | |
| 4 | * the terms of the GNU Lesser General Public License, version 2.1 or later | |
| 5 | * as published by the Free Software Foundation. This program is distributed | |
| 6 | * in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even | |
| 7 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |
| 8 | * See the GNU Lesser General Public License for more details. | |
| 9 | * | |
| 10 | * The License is available on the internet at: | |
| 11 | * http://www.gnu.org/copyleft/lgpl.html | |
| 12 | * or by writing to: | |
| 13 | * Free Software Foundation, Inc. | |
| 14 | * 59 Temple Place - Suite 330 | |
| 15 | * Boston, MA 02111-1307, USA | |
| 16 | * | |
| 17 | * © CrossWire Bible Society, 2008 - 2016 | |
| 18 | * | |
| 19 | */ | |
| 20 | package org.crosswire.common.options; | |
| 21 | ||
| 22 | /** | |
| 23 | * An ArgumentType indicates whether and/or how an Option is followed by an | |
| 24 | * argument. | |
| 25 | * | |
| 26 | * @see gnu.lgpl.License The GNU Lesser General Public License for details. | |
| 27 | * @author DM Smith | |
| 28 | */ | |
| 29 | 0 | public enum ArgumentType { |
| 30 | /** | |
| 31 | * The option is not followed by an argument. | |
| 32 | */ | |
| 33 | 0 | NO_ARGUMENT ("NO"), |
| 34 | ||
| 35 | /** | |
| 36 | * The option is followed by an argument. | |
| 37 | */ | |
| 38 | 0 | REQUIRED_ARGUMENT ("Required"), |
| 39 | ||
| 40 | /** | |
| 41 | * The option may be followed by an argument. | |
| 42 | */ | |
| 43 | 0 | OPTIONAL_ARGUMENT ("Optional"); |
| 44 | ||
| 45 | /** | |
| 46 | * @param name | |
| 47 | * The name of the ArgumentType | |
| 48 | */ | |
| 49 | 0 | ArgumentType(String name) { |
| 50 | 0 | this.name = name; |
| 51 | 0 | } |
| 52 | ||
| 53 | /** | |
| 54 | * Lookup method to find an ArgumentType by name | |
| 55 | * | |
| 56 | * @param name the name of the ArgumentType | |
| 57 | * @return the ArgumentType or null | |
| 58 | */ | |
| 59 | public static ArgumentType fromString(String name) { | |
| 60 | 0 | for (ArgumentType v : values()) { |
| 61 | 0 | if (v.name.equalsIgnoreCase(name)) { |
| 62 | 0 | return v; |
| 63 | } | |
| 64 | } | |
| 65 | ||
| 66 | // cannot get here | |
| 67 | 0 | assert false; |
| 68 | 0 | return null; |
| 69 | } | |
| 70 | ||
| 71 | /* (non-Javadoc) | |
| 72 | * @see java.lang.Enum#toString() | |
| 73 | */ | |
| 74 | @Override | |
| 75 | public String toString() { | |
| 76 | 0 | return name; |
| 77 | } | |
| 78 | ||
| 79 | /** | |
| 80 | * The name of the DataType | |
| 81 | */ | |
| 82 | private String name; | |
| 83 | } |