1 package org.incava.jagol; 2 3 import java.io.*; 4 import java.util.*; 5 6 7 10 public class IntegerOption extends NonBooleanOption 11 { 12 private Integer value; 13 14 public IntegerOption(String longName, String description) 15 { 16 this(longName, description, null); 17 } 18 19 public IntegerOption(String longName, String description, Integer value) 20 { 21 super(longName, description); 22 this.value = value; 23 } 24 25 28 public Integer getValue() 29 { 30 return value; 31 } 32 33 36 public void setValue(Integer value) 37 { 38 this.value = value; 39 } 40 41 44 public void setValue(String value) throws InvalidTypeException 45 { 46 try { 47 setValue(new Integer (value)); 48 } 49 catch (NumberFormatException nfe) { 50 throw new InvalidTypeException(getLongName() + " expects integer argument, not '" + value + "'"); 51 } 52 } 53 54 public String toString() 55 { 56 return value == null ? "" : value.toString(); 57 } 58 59 protected String getType() 60 { 61 return "integer"; 62 } 63 64 } 65 | Popular Tags |