01: /*
02: * Copyright (C) 2007 Stephen Ostermiller
03: * http://ostermiller.org/contact.pl?regarding=Java+Utilities
04: *
05: * This program is free software; you can redistribute it and/or modify
06: * it under the terms of the GNU General Public License as published by
07: * the Free Software Foundation; either version 2 of the License, or
08: * (at your option) any later version.
09: *
10: * This program is distributed in the hope that it will be useful,
11: * but WITHOUT ANY WARRANTY; without even the implied warranty of
12: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13: * GNU General Public License for more details.
14: *
15: * See COPYING.TXT for details.
16: */
17: package com.Ostermiller.util;
18:
19: /**
20: * Exception thrown for a problem with a specific command line option.
21: *
22: * More information about this class and code samples for suggested use are
23: * available from <a target="_top" href=
24: * "http://ostermiller.org/utils/CmdLn.html">ostermiller.org</a>.
25: *
26: * @author Stephen Ostermiller http://ostermiller.org/contact.pl?regarding=Java+Utilities
27: * @since ostermillerutils 1.07.00
28: */
29: public class CmdLnArgumentException extends CmdLnException {
30:
31: /**
32: * serial version id
33: *
34: * @since ostermillerutils 1.07.00
35: */
36: private static final long serialVersionUID = -5457270771303129044L;
37:
38: /**
39: * @param message message explaining the exception
40: *
41: * @since ostermillerutils 1.07.00
42: */
43: CmdLnArgumentException(String message) {
44: super (message);
45: }
46:
47: private CmdLnResult result;
48:
49: /**
50: * Get the partial result with missing arguments.
51: *
52: * @return the partial result
53: *
54: * @since ostermillerutils 1.07.00
55: */
56: public CmdLnResult getResult() {
57: return result;
58: }
59:
60: /**
61: * Get the option that caused this exception
62: *
63: * @return the option
64: *
65: * @since ostermillerutils 1.07.00
66: */
67: public CmdLnOption getOption() {
68: return result.getOption();
69: }
70:
71: /**
72: * Set the result
73: *
74: * @param result partial result
75: * @return this for method chaining
76: *
77: * @since ostermillerutils 1.07.00
78: */
79: CmdLnArgumentException setResult(CmdLnResult result) {
80: this .result = result;
81: return this ;
82: }
83:
84: /**
85: * @return message with the option name
86: *
87: * @since ostermillerutils 1.07.00
88: */
89: @Override
90: public String getMessage() {
91: return super .getMessage() + ": " + getOption();
92: }
93: }
|