Commit | Line | Data |
---|---|---|
eb1bab5b BH |
1 | /********************************************************************** |
2 | * Copyright (c) 2012 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 BH |
59 | // ------------------------------------------------------------------------ |
60 | /* | |
61 | * (non-Javadoc) | |
115b4a01 | 62 | * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ICommandResult#getResult() |
eb1bab5b BH |
63 | */ |
64 | @Override | |
65 | public int getResult() { | |
66 | return fResult; | |
67 | } | |
68 | ||
69 | /* | |
70 | * (non-Javadoc) | |
115b4a01 | 71 | * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ICommandResult#setResult(int) |
eb1bab5b BH |
72 | */ |
73 | @Override | |
74 | public void setResult(int result) { | |
75 | fResult = result; | |
76 | } | |
77 | ||
78 | /* | |
79 | * (non-Javadoc) | |
115b4a01 | 80 | * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ICommandResult#getOutput() |
eb1bab5b BH |
81 | */ |
82 | @Override | |
83 | public String[] getOutput() { | |
84 | return Arrays.copyOf(fOutput, fOutput.length); | |
85 | } | |
86 | ||
87 | /* | |
88 | * (non-Javadoc) | |
115b4a01 | 89 | * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ICommandResult#setOutput(java.lang.String[]) |
eb1bab5b BH |
90 | */ |
91 | @Override | |
92 | public void setOutput(String[] output) { | |
93 | fOutput = new String[0]; | |
94 | if (output != null) { | |
95 | fOutput = Arrays.copyOf(output, output.length); | |
96 | } | |
97 | } | |
98 | } |