Commit | Line | Data |
---|---|---|
eb1bab5b | 1 | /********************************************************************** |
11252342 | 2 | * Copyright (c) 2012, 2013 Ericsson |
cfdb727a | 3 | * |
eb1bab5b BH |
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 | |
cfdb727a AM |
8 | * |
9 | * Contributors: | |
eb1bab5b BH |
10 | * Bernd Hufmann - Initial API and implementation |
11 | **********************************************************************/ | |
8e8c0226 | 12 | package org.eclipse.linuxtools.internal.lttng2.control.ui.views.remote; |
eb1bab5b BH |
13 | |
14 | import java.util.Arrays; | |
15 | ||
16 | /** | |
eb1bab5b BH |
17 | * <p> |
18 | * Class containing command result of remote command execution. | |
19 | * </p> | |
cfdb727a | 20 | * |
dbd4432d | 21 | * @author Bernd Hufmann |
eb1bab5b BH |
22 | */ |
23 | public class CommandResult implements ICommandResult { | |
cfdb727a | 24 | |
eb1bab5b BH |
25 | // ------------------------------------------------------------------------ |
26 | // Attributes | |
27 | // ------------------------------------------------------------------------ | |
28 | /** | |
29 | * The result of the command. 0 if successful else > 0 | |
30 | */ | |
31 | private int fResult; | |
32 | ||
33 | /** | |
34 | * The output as String array. | |
35 | */ | |
36 | private String[] fOutput = new String[0]; | |
6418ef54 | 37 | private String[] fErrorOutput = new String[0]; |
eb1bab5b BH |
38 | |
39 | // ------------------------------------------------------------------------ | |
40 | // Constructor | |
41 | // ------------------------------------------------------------------------ | |
cfdb727a AM |
42 | |
43 | /** | |
44 | * Constructor | |
45 | * | |
46 | * @param result | |
47 | * The result of the command | |
48 | * @param output | |
49 | * The output, as an array of strings | |
6418ef54 JRJ |
50 | * @param errorOutput |
51 | * THe error output as an array of strings | |
cfdb727a | 52 | */ |
6418ef54 | 53 | public CommandResult(int result, String[] output, String[] errorOutput) { |
eb1bab5b BH |
54 | fResult = result; |
55 | if (output != null) { | |
56 | fOutput = Arrays.copyOf(output, output.length); | |
57 | } | |
6418ef54 JRJ |
58 | if (errorOutput != null) { |
59 | fErrorOutput = Arrays.copyOf(errorOutput, errorOutput.length); | |
60 | } | |
eb1bab5b BH |
61 | } |
62 | ||
63 | // ------------------------------------------------------------------------ | |
cfdb727a | 64 | // Accessors |
eb1bab5b | 65 | // ------------------------------------------------------------------------ |
11252342 | 66 | |
eb1bab5b BH |
67 | @Override |
68 | public int getResult() { | |
69 | return fResult; | |
70 | } | |
71 | ||
eb1bab5b BH |
72 | @Override |
73 | public void setResult(int result) { | |
74 | fResult = result; | |
75 | } | |
76 | ||
eb1bab5b BH |
77 | @Override |
78 | public String[] getOutput() { | |
79 | return Arrays.copyOf(fOutput, fOutput.length); | |
80 | } | |
81 | ||
eb1bab5b BH |
82 | @Override |
83 | public void setOutput(String[] output) { | |
84 | fOutput = new String[0]; | |
85 | if (output != null) { | |
86 | fOutput = Arrays.copyOf(output, output.length); | |
87 | } | |
88 | } | |
6418ef54 JRJ |
89 | |
90 | @Override | |
91 | public String[] getErrorOutput() { | |
92 | return Arrays.copyOf(fErrorOutput, fErrorOutput.length); | |
93 | } | |
94 | ||
95 | @Override | |
96 | public void setErrorOutput(String[] output) { | |
97 | fErrorOutput = new String[0]; | |
98 | if (output != null) { | |
99 | fErrorOutput = Arrays.copyOf(output, output.length); | |
100 | } | |
101 | } | |
eb1bab5b | 102 | } |