1 /**********************************************************************
2 * Copyright (c) 2012, 2015 Ericsson
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * Bernd Hufmann - Initial API and implementation
11 **********************************************************************/
12 package org
.eclipse
.tracecompass
.internal
.tmf
.remote
.core
.shell
;
14 import static org
.eclipse
.tracecompass
.common
.core
.NonNullUtils
.nullToEmptyString
;
16 import java
.util
.List
;
18 import org
.eclipse
.jdt
.annotation
.NonNull
;
19 import org
.eclipse
.jdt
.annotation
.NonNullByDefault
;
20 import org
.eclipse
.tracecompass
.tmf
.remote
.core
.shell
.ICommandResult
;
22 import com
.google
.common
.collect
.ImmutableList
;
25 * Class containing command result of remote command execution.
27 * @author Bernd Hufmann
30 public class CommandResult
implements ICommandResult
{
32 // ------------------------------------------------------------------------
34 // ------------------------------------------------------------------------
35 /** The result of the command. 0 if successful else > 0 */
36 private final int fResult
;
38 /** The output as list of Strings. */
39 private final List
<String
> fOutput
;
41 /** The error stream output as list of Strings. */
42 private final List
<String
> fErrorOutput
;
44 // ------------------------------------------------------------------------
46 // ------------------------------------------------------------------------
52 * The result of the command
54 * The output, as an array of strings
56 * THe error output as an array of strings
58 public CommandResult(int result
, @NonNull String
[] output
, @NonNull String
[] errorOutput
) {
60 fOutput
= ImmutableList
.copyOf(output
);
61 fErrorOutput
= ImmutableList
.copyOf(errorOutput
);
64 // ------------------------------------------------------------------------
66 // ------------------------------------------------------------------------
69 public int getResult() {
74 public List
<String
> getOutput() {
79 public List
<String
> getErrorOutput() {
84 public String
toString() {
85 StringBuffer ret
= new StringBuffer();
86 ret
.append("Error Output:\n"); //$NON-NLS-1$
87 for (String string
: fErrorOutput
) {
88 ret
.append(string
).append("\n"); //$NON-NLS-1$
90 ret
.append("Return Value: "); //$NON-NLS-1$
92 ret
.append("\n"); //$NON-NLS-1$
93 for (String string
: fOutput
) {
94 ret
.append(string
).append("\n"); //$NON-NLS-1$
96 return nullToEmptyString(ret
.toString());
This page took 0.035684 seconds and 5 git commands to generate.