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 | **********************************************************************/ | |
9315aeee | 12 | package org.eclipse.linuxtools.internal.lttng2.ui.views.control.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]; | |
37 | ||
38 | // ------------------------------------------------------------------------ | |
39 | // Constructor | |
40 | // ------------------------------------------------------------------------ | |
cfdb727a AM |
41 | |
42 | /** | |
43 | * Constructor | |
44 | * | |
45 | * @param result | |
46 | * The result of the command | |
47 | * @param output | |
48 | * The output, as an array of strings | |
49 | */ | |
eb1bab5b BH |
50 | public CommandResult(int result, String[] output) { |
51 | fResult = result; | |
52 | if (output != null) { | |
53 | fOutput = Arrays.copyOf(output, output.length); | |
54 | } | |
55 | } | |
56 | ||
57 | // ------------------------------------------------------------------------ | |
cfdb727a | 58 | // Accessors |
eb1bab5b | 59 | // ------------------------------------------------------------------------ |
11252342 | 60 | |
eb1bab5b BH |
61 | @Override |
62 | public int getResult() { | |
63 | return fResult; | |
64 | } | |
65 | ||
eb1bab5b BH |
66 | @Override |
67 | public void setResult(int result) { | |
68 | fResult = result; | |
69 | } | |
70 | ||
eb1bab5b BH |
71 | @Override |
72 | public String[] getOutput() { | |
73 | return Arrays.copyOf(fOutput, fOutput.length); | |
74 | } | |
75 | ||
eb1bab5b BH |
76 | @Override |
77 | public void setOutput(String[] output) { | |
78 | fOutput = new String[0]; | |
79 | if (output != null) { | |
80 | fOutput = Arrays.copyOf(output, output.length); | |
81 | } | |
82 | } | |
83 | } |