• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2010 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package com.android.tradefed.util;
17 
18 
19 /**
20  * Contains the result of a command.
21  */
22 public class CommandResult {
23 
24     private CommandStatus mCmdStatus = CommandStatus.TIMED_OUT;
25     private String mStdout = null;
26     private String mStderr = null;
27     private Integer mExitCode = null;
28 
29     /**
30      * Create a {@link CommandResult} with the default {@link CommandStatus#TIMED_OUT} status.
31      */
CommandResult()32     public CommandResult() {
33     }
34 
35     /**
36      * Create a {@link CommandResult} with the given status.
37      *
38      * @param status the {@link CommandStatus}
39      */
CommandResult(CommandStatus status)40     public CommandResult(CommandStatus status) {
41         mCmdStatus = status;
42     }
43 
44     /**
45      * Get status of command.
46      *
47      * @return the {@link CommandStatus}
48      */
getStatus()49     public CommandStatus getStatus() {
50         return mCmdStatus;
51     }
52 
setStatus(CommandStatus status)53     public void setStatus(CommandStatus status) {
54         mCmdStatus = status;
55     }
56 
57     /**
58      * Get the standard output produced by command.
59      *
60      * @return the standard output or <code>null</code> if output could not be retrieved
61      */
getStdout()62     public String getStdout() {
63         return mStdout;
64     }
65 
setStdout(String stdout)66     public void setStdout(String stdout) {
67         mStdout = stdout;
68     }
69 
70     /**
71      * Get the standard error output produced by command.
72      *
73      * @return the standard error or <code>null</code> if output could not be retrieved
74      */
getStderr()75     public String getStderr() {
76         return mStderr;
77     }
78 
setStderr(String stderr)79     public void setStderr(String stderr) {
80         mStderr = stderr;
81     }
82 
83     /**
84      * Get the exit/return code produced by command.
85      *
86      * @return the exit code or <code>null</code> if it is unset
87      */
getExitCode()88     public Integer getExitCode() {
89         return mExitCode;
90     }
91 
setExitCode(int exitCode)92     public void setExitCode(int exitCode) {
93         mExitCode = exitCode;
94     }
95 }
96