0N/A/*
2362N/A * Copyright (c) 2003, 2007, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/Apackage javax.management.remote;
0N/A
0N/Aimport java.io.Serializable;
0N/A
0N/A/**
0N/A * <p>Result of a query for buffered notifications. Notifications in
0N/A * a notification buffer have positive, monotonically increasing
0N/A * sequence numbers. The result of a notification query contains the
0N/A * following elements:</p>
0N/A *
0N/A * <ul>
0N/A *
0N/A * <li>The sequence number of the earliest notification still in
0N/A * the buffer.
0N/A *
0N/A * <li>The sequence number of the next notification available for
0N/A * querying. This will be the starting sequence number for the next
0N/A * notification query.
0N/A *
0N/A * <li>An array of (Notification,listenerID) pairs corresponding to
0N/A * the returned notifications and the listeners they correspond to.
0N/A *
0N/A * </ul>
0N/A *
0N/A * <p>It is possible for the <code>nextSequenceNumber</code> to be less
0N/A * than the <code>earliestSequenceNumber</code>. This signifies that
0N/A * notifications between the two might have been lost.</p>
0N/A *
0N/A * @since 1.5
0N/A */
0N/Apublic class NotificationResult implements Serializable {
0N/A
0N/A private static final long serialVersionUID = 1191800228721395279L;
0N/A
0N/A /**
0N/A * <p>Constructs a notification query result.</p>
0N/A *
0N/A * @param earliestSequenceNumber the sequence number of the
0N/A * earliest notification still in the buffer.
0N/A * @param nextSequenceNumber the sequence number of the next
0N/A * notification available for querying.
0N/A * @param targetedNotifications the notifications resulting from
0N/A * the query, and the listeners they correspond to. This array
0N/A * can be empty.
0N/A *
0N/A * @exception IllegalArgumentException if
0N/A * <code>targetedNotifications</code> is null or if
0N/A * <code>earliestSequenceNumber</code> or
0N/A * <code>nextSequenceNumber</code> is negative.
0N/A */
0N/A public NotificationResult(long earliestSequenceNumber,
0N/A long nextSequenceNumber,
0N/A TargetedNotification[] targetedNotifications) {
0N/A if (targetedNotifications == null) {
0N/A final String msg = "Notifications null";
0N/A throw new IllegalArgumentException(msg);
0N/A }
0N/A
0N/A if (earliestSequenceNumber < 0 || nextSequenceNumber < 0)
0N/A throw new IllegalArgumentException("Bad sequence numbers");
0N/A /* We used to check nextSequenceNumber >= earliestSequenceNumber
0N/A here. But in fact the opposite can legitimately be true if
0N/A notifications have been lost. */
0N/A
0N/A this.earliestSequenceNumber = earliestSequenceNumber;
0N/A this.nextSequenceNumber = nextSequenceNumber;
6266N/A this.targetedNotifications = (targetedNotifications.length == 0 ? targetedNotifications : targetedNotifications.clone());
0N/A }
0N/A
0N/A /**
0N/A * Returns the sequence number of the earliest notification still
0N/A * in the buffer.
0N/A *
0N/A * @return the sequence number of the earliest notification still
0N/A * in the buffer.
0N/A */
0N/A public long getEarliestSequenceNumber() {
0N/A return earliestSequenceNumber;
0N/A }
0N/A
0N/A /**
0N/A * Returns the sequence number of the next notification available
0N/A * for querying.
0N/A *
0N/A * @return the sequence number of the next notification available
0N/A * for querying.
0N/A */
0N/A public long getNextSequenceNumber() {
0N/A return nextSequenceNumber;
0N/A }
0N/A
0N/A /**
0N/A * Returns the notifications resulting from the query, and the
0N/A * listeners they correspond to.
0N/A *
0N/A * @return the notifications resulting from the query, and the
0N/A * listeners they correspond to. This array can be empty.
0N/A */
0N/A public TargetedNotification[] getTargetedNotifications() {
6266N/A return targetedNotifications.length == 0 ? targetedNotifications : targetedNotifications.clone();
0N/A }
0N/A
0N/A /**
0N/A * Returns a string representation of the object. The result
0N/A * should be a concise but informative representation that is easy
0N/A * for a person to read.
0N/A *
0N/A * @return a string representation of the object.
0N/A */
0N/A public String toString() {
0N/A return "NotificationResult: earliest=" + getEarliestSequenceNumber() +
0N/A "; next=" + getNextSequenceNumber() + "; nnotifs=" +
0N/A getTargetedNotifications().length;
0N/A }
0N/A
0N/A private final long earliestSequenceNumber;
0N/A private final long nextSequenceNumber;
0N/A private final TargetedNotification[] targetedNotifications;
0N/A}