1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
/*******************************************************************************
* Copyright (c) 2000, 2010 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* QNX Software Systems - Initial API and implementation
* Wind River Systems - Modified for new DSF Reference Implementation
* Ericsson - Modified for additional features in DSF Reference Implementation
*******************************************************************************/
package org.eclipse.cdt.dsf.mi.service.command.output;
/**
* GDB/MI response.
*/
public class MIOutput {
private final MIResultRecord rr;
private final MIOOBRecord[] oobs;
private MIStreamRecord[] streamRecords;
public MIOutput() {
this(null, (MIOOBRecord[])null);
}
/**
* @param oob
* @deprecated Use {@link #MIOutput(MIOOBRecord, MIStreamRecord[])}
*/
@Deprecated
public MIOutput(MIOOBRecord oob) {
this(null, new MIOOBRecord[] { oob });
}
/**
* Constructor used when handling a single out-of-band record
*
* @param the
* out-of-bound record
* @param streamRecords
* any stream records that preceded the out-of-bound record,
* since the last command result. This need not contain *all*
* such records if it's been a while since the last command (for
* practical reasons, there is a cap on the number of stream
* records that are remembered). This will have the most recent
* records. Must not be null; may be empty
* @since 3.0
*/
public MIOutput(MIOOBRecord oob, MIStreamRecord[] streamRecords) {
this(null, new MIOOBRecord[] { oob });
this.streamRecords = streamRecords;
assert streamRecords != null;
}
/**
* Constructor used when handling a command result.
*
* @param rr
* the result record
* @param oobs
* any out-of-band records that preceded this particular command
* result. This need not contain *all* such records if it's been
* a while since the last command (for practical reasons, there
* is a cap on the number of OOB records that are remembered).
* This will have the most recent records.
*
*/
public MIOutput(MIResultRecord rr, MIOOBRecord[] oobs) {
this.rr = rr;
this.oobs = oobs;
}
public MIResultRecord getMIResultRecord() {
return rr;
}
public MIOOBRecord[] getMIOOBRecords() {
return oobs;
}
/**
* See param in {@link #MIOutput(MIOOBRecord, MIStreamRecord[])}
*
* @return Only instances created for an OOB record will have stream
* records; may be an empty collection in that case, but not null.
* Instances created for a command result will return null from this
* method. Stream records can be retrieved from
* {@link #getMIOOBRecords()} in that case.
* @since 3.0
*/
public MIStreamRecord[] getStreamRecords() {
return streamRecords;
}
@Override
public String toString() {
StringBuffer buffer = new StringBuffer();
for (int i = 0; i < oobs.length; i++) {
buffer.append(oobs[i].toString());
}
if (rr != null) {
buffer.append(rr.toString());
}
return buffer.toString();
}
}
|