Source code: com/synaptics/elvis/ElvisResult.java
1 /*
2 * The contents of this file are subject to the Mozilla Public License Version
3 * 1.1 (the "License"); you may not use this file except in compliance with the
4 * License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
5 *
6 * Software distributed under the License is distributed on an "AS IS" basis,
7 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
8 * the specific language governing rights and limitations under the License.
9 *
10 * The Original Code is com.synaptics.elvis code.
11 *
12 * The Initial Developers of the Original Code are Synaptics, Inc. and Christopher Heiny.
13 * Portions created by Synaptics, Inc. and Christopher Heiny are
14 * Copyright (C) 2002 Synaptics, Inc. and Christopher Heiny. All Rights Reserved.
15 *
16 * Contributor(s):
17 * Christopher Heiny <cheiny@synaptics.com>
18 */
19
20 package com.synaptics.elvis;
21
22 public class ElvisResult {
23
24 /** The ok/fail part of the result. */
25 private ElvisResponse response;
26
27 /** This is the data associated with this particular result. */
28 private String data;
29
30 /** Create a new result with the corresponding response and data.
31 * Private to keep clients from inadvertantly creating invalid ElvisResults.
32 */
33 private ElvisResult(ElvisResponse response, String data) {
34 this.response = response;
35 this.data = data;
36 }
37
38 /** Returns the ElvisResponse for this result. This may be one of a limited
39 * number of values - see ElvisResponse for more details.
40 * @return A value indicate success, failure, and possibly other state.
41 * @see com.synaptics.ElvisResponse# ElvisResponse
42 */
43 public ElvisResponse getResponse() {
44 return response;
45 }
46
47 /** Return the data associated with this result. This is a client dependent
48 * value, and may be null or empty.
49 * @return Client data associated with this ElvisResult.
50 */
51 public String getData() {
52 return data;
53 }
54
55 /** Return a ElvisResult with a response of ElvisResponse.FAIL and the specified
56 * data string.
57 * @return An ElvisResult as just described.
58 */
59 public static final ElvisResult fail(java.lang.String data) {
60 return new ElvisResult( ElvisResponse.FAIL, data );
61 }
62
63 /** Return a ElvisResult with a response of ElvisResponse.OK and the specified
64 * data string.
65 * @return An ElvisResult as just described.
66 */
67 public static final ElvisResult succeed(java.lang.String data) {
68 return new ElvisResult( ElvisResponse.OK, data );
69 }
70
71 }
72