| 1 | /********************************************************************** |
| 2 | * Copyright (c) 2012 Ericsson |
| 3 | * |
| 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 |
| 8 | * |
| 9 | * Contributors: |
| 10 | * Bernd Hufmann - Initial API and implementation |
| 11 | **********************************************************************/ |
| 12 | package org.eclipse.linuxtools.internal.lttng.ui.views.control.service; |
| 13 | |
| 14 | import java.util.Arrays; |
| 15 | |
| 16 | /** |
| 17 | * <b><u>CommandResult</u></b> |
| 18 | * <p> |
| 19 | * Class containing command result of remote command execution. |
| 20 | * </p> |
| 21 | */ |
| 22 | public class CommandResult implements ICommandResult { |
| 23 | |
| 24 | // ------------------------------------------------------------------------ |
| 25 | // Attributes |
| 26 | // ------------------------------------------------------------------------ |
| 27 | /** |
| 28 | * The result of the command. 0 if successful else > 0 |
| 29 | */ |
| 30 | private int fResult; |
| 31 | |
| 32 | /** |
| 33 | * The output as String array. |
| 34 | */ |
| 35 | private String[] fOutput = new String[0]; |
| 36 | |
| 37 | // ------------------------------------------------------------------------ |
| 38 | // Constructor |
| 39 | // ------------------------------------------------------------------------ |
| 40 | public CommandResult(int result, String[] output) { |
| 41 | fResult = result; |
| 42 | if (output != null) { |
| 43 | fOutput = Arrays.copyOf(output, output.length); |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | // ------------------------------------------------------------------------ |
| 48 | // Accessor |
| 49 | // ------------------------------------------------------------------------ |
| 50 | /* |
| 51 | * (non-Javadoc) |
| 52 | * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.service.ICommandResult#getResult() |
| 53 | */ |
| 54 | @Override |
| 55 | public int getResult() { |
| 56 | return fResult; |
| 57 | } |
| 58 | |
| 59 | /* |
| 60 | * (non-Javadoc) |
| 61 | * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.service.ICommandResult#setResult(int) |
| 62 | */ |
| 63 | @Override |
| 64 | public void setResult(int result) { |
| 65 | fResult = result; |
| 66 | } |
| 67 | |
| 68 | /* |
| 69 | * (non-Javadoc) |
| 70 | * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.service.ICommandResult#getOutput() |
| 71 | */ |
| 72 | @Override |
| 73 | public String[] getOutput() { |
| 74 | return Arrays.copyOf(fOutput, fOutput.length); |
| 75 | } |
| 76 | |
| 77 | /* |
| 78 | * (non-Javadoc) |
| 79 | * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.service.ICommandResult#setOutput(java.lang.String[]) |
| 80 | */ |
| 81 | @Override |
| 82 | public void setOutput(String[] output) { |
| 83 | fOutput = new String[0]; |
| 84 | if (output != null) { |
| 85 | fOutput = Arrays.copyOf(output, output.length); |
| 86 | } |
| 87 | } |
| 88 | } |