01: /*
02: * Copyright (C) The MX4J Contributors.
03: * All rights reserved.
04: *
05: * This software is distributed under the terms of the MX4J License version 1.0.
06: * See the terms of the MX4J License in the documentation provided with this software.
07: */
08:
09: package javax.management.remote;
10:
11: import java.io.Serializable;
12: import java.util.Arrays;
13: import java.util.List;
14:
15: /**
16: * @version $Revision: 1.4 $
17: */
18: public class NotificationResult implements Serializable {
19: private static final long serialVersionUID = 1191800228721395279l;
20:
21: /**
22: * @serial The earliest sequence number
23: */
24: private final long earliestSequenceNumber;
25: /**
26: * @serial The next sequence number
27: */
28: private final long nextSequenceNumber;
29: /**
30: * @serial The notifications
31: */
32: private final TargetedNotification[] targetedNotifications;
33:
34: public NotificationResult(long earliestSequenceNumber,
35: long nextSequenceNumber,
36: TargetedNotification[] targetedNotifications) {
37: // Checks required by the specification (javadocs)
38: if (earliestSequenceNumber < 0)
39: throw new IllegalArgumentException(
40: "Earliest sequence number cannot be negative");
41: if (nextSequenceNumber < 0)
42: throw new IllegalArgumentException(
43: "Next sequence number cannot be negative");
44: if (targetedNotifications == null)
45: throw new IllegalArgumentException(
46: "TargetedNotification array cannot be null");
47: this .earliestSequenceNumber = earliestSequenceNumber;
48: this .nextSequenceNumber = nextSequenceNumber;
49: this .targetedNotifications = targetedNotifications;
50: }
51:
52: public long getEarliestSequenceNumber() {
53: return earliestSequenceNumber;
54: }
55:
56: public long getNextSequenceNumber() {
57: return nextSequenceNumber;
58: }
59:
60: public TargetedNotification[] getTargetedNotifications() {
61: return targetedNotifications;
62: }
63:
64: public String toString() {
65: StringBuffer buffer = new StringBuffer(
66: "NotificationResult[earliest=");
67: buffer.append(getEarliestSequenceNumber()).append(", next=");
68: buffer.append(getNextSequenceNumber()).append(
69: ", notifications=");
70: TargetedNotification[] notifs = getTargetedNotifications();
71: List list = notifs == null ? null : Arrays.asList(notifs);
72: buffer.append(list).append("]");
73: return buffer.toString();
74: }
75: }
|