2N/A/*
2N/A * CDDL HEADER START
2N/A *
2N/A * The contents of this file are subject to the terms of the
2N/A * Common Development and Distribution License (the "License").
2N/A * You may not use this file except in compliance with the License.
2N/A *
2N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2N/A * or http://www.opensolaris.org/os/licensing.
2N/A * See the License for the specific language governing permissions
2N/A * and limitations under the License.
2N/A *
2N/A * When distributing Covered Code, include this CDDL HEADER in each
2N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2N/A * If applicable, add the following below this CDDL HEADER, with the
2N/A * fields enclosed by brackets "[]" replaced with your own identifying
2N/A * information: Portions Copyright [yyyy] [name of copyright owner]
2N/A *
2N/A * CDDL HEADER END
2N/A */
2N/A
2N/A/*
2N/A * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
2N/A * Use is subject to license terms.
2N/A *
2N/A * ident "%Z%%M% %I% %E% SMI"
2N/A */
2N/Apackage org.opensolaris.os.dtrace;
2N/A
2N/Aimport java.io.*;
2N/Aimport java.util.EventObject;
2N/A
2N/A/**
2N/A * An event used to pass probe data generated by a DTrace {@link
2N/A * Consumer} to interested listeners.
2N/A *
2N/A * @see ConsumerListener#dataReceived(DataEvent e)
2N/A *
2N/A * @author Tom Erickson
2N/A */
2N/Apublic class DataEvent extends EventObject {
2N/A static final long serialVersionUID = 3068774547474769821L;
2N/A
2N/A /** @serial */
2N/A private ProbeData probeData;
2N/A
2N/A /**
2N/A * Creates a {@link ConsumerListener#dataReceived(DataEvent e)
2N/A * dataReceived()} event that conveys data generated by DTrace from
2N/A * a single probe firing.
2N/A *
2N/A * @throws NullPointerException if the given probe data is {@code
2N/A * null}
2N/A */
2N/A public
2N/A DataEvent(Object source, ProbeData generatedData)
2N/A {
2N/A super(source);
2N/A probeData = generatedData;
2N/A validate();
2N/A }
2N/A
2N/A private final void
2N/A validate()
2N/A {
2N/A if (probeData == null) {
2N/A throw new NullPointerException("probe data is null");
2N/A }
2N/A }
2N/A
2N/A /**
2N/A * Gets the data generated by DTrace from a single probe firing.
2N/A *
2N/A * @return non-null probe data generated by DTrace from a single
2N/A * probe firing
2N/A */
2N/A public ProbeData
2N/A getProbeData()
2N/A {
2N/A return probeData;
2N/A }
2N/A
2N/A private void
2N/A readObject(ObjectInputStream s)
2N/A throws IOException, ClassNotFoundException
2N/A {
2N/A s.defaultReadObject();
2N/A // check invariants
2N/A try {
2N/A validate();
2N/A } catch (Exception e) {
2N/A InvalidObjectException x = new InvalidObjectException(
2N/A e.getMessage());
2N/A x.initCause(e);
2N/A throw x;
2N/A }
2N/A }
2N/A
2N/A /**
2N/A * Gets a string representation of this event useful for logging and
2N/A * not intended for display. The exact details of the
2N/A * representation are unspecified and subject to change, but the
2N/A * following format may be regarded as typical:
2N/A * <pre><code>
2N/A * class-name[property1 = value1, property2 = value2]
2N/A * </code></pre>
2N/A */
2N/A public String
2N/A toString()
2N/A {
2N/A StringBuilder buf = new StringBuilder();
2N/A buf.append(DataEvent.class.getName());
2N/A buf.append("[source = ");
2N/A buf.append(getSource());
2N/A buf.append(", probeData = ");
2N/A buf.append(probeData);
2N/A buf.append(']');
2N/A return buf.toString();
2N/A }
2N/A}