1 package org.metricshub.wmi.windows.remote;
2
3 /*-
4 * ╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲
5 * WMI Java Client
6 * ჻჻჻჻჻჻
7 * Copyright (C) 2023 - 2025 MetricsHub
8 * ჻჻჻჻჻჻
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
12 *
13 * http://www.apache.org/licenses/LICENSE-2.0
14 *
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 * ╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱
21 */
22
23 public class WindowsRemoteCommandResult {
24
25 private final String stdout;
26 private final String stderr;
27 private final float executionTime;
28 private final int statusCode;
29
30 /**
31 * Command Result constructor
32 *
33 * @param stdout The stdout of the command
34 * @param stderr The stderr of the command
35 * @param executionTime The execution time of the command in milliseconds
36 * @param statusCode The command return status code
37 */
38 public WindowsRemoteCommandResult(
39 final String stdout,
40 final String stderr,
41 final float executionTime,
42 final int statusCode
43 ) {
44 this.stdout = stdout;
45 this.stderr = stderr;
46 this.executionTime = executionTime;
47 this.statusCode = statusCode;
48 }
49
50 /**
51 * Get the stdout of the command.
52 * @return
53 */
54 public String getStdout() {
55 return stdout;
56 }
57
58 /**
59 * Get the stderr of the command.
60 * @return
61 */
62 public String getStderr() {
63 return stderr;
64 }
65
66 /**
67 * Get the execution time of the command in seconds.
68 * @return
69 */
70 public float getExecutionTime() {
71 return executionTime;
72 }
73
74 /**
75 * Get the return status code of the command
76 * @return
77 */
78 public int getStatusCode() {
79 return statusCode;
80 }
81
82 @Override
83 public String toString() {
84 return new StringBuilder()
85 .append("WindowsRemoteCommandResult:\nstdout:\n")
86 .append(stdout)
87 .append("\nstderr:\n")
88 .append(stderr)
89 .append("\nexecutionTime = ")
90 .append(executionTime)
91 .append("\nstatusCode = ")
92 .append(statusCode)
93 .toString();
94 }
95 }