Home | History | Annotate | Download | only in dtrace
      1 /*
      2  * CDDL HEADER START
      3  *
      4  * The contents of this file are subject to the terms of the
      5  * Common Development and Distribution License (the "License").
      6  * You may not use this file except in compliance with the License.
      7  *
      8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
      9  * or http://www.opensolaris.org/os/licensing.
     10  * See the License for the specific language governing permissions
     11  * and limitations under the License.
     12  *
     13  * When distributing Covered Code, include this CDDL HEADER in each
     14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
     15  * If applicable, add the following below this CDDL HEADER, with the
     16  * fields enclosed by brackets "[]" replaced with your own identifying
     17  * information: Portions Copyright [yyyy] [name of copyright owner]
     18  *
     19  * CDDL HEADER END
     20  */
     21 
     22 /*
     23  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
     24  * Use is subject to license terms.
     25  *
     26  * ident	"%Z%%M%	%I%	%E% SMI"
     27  */
     28 package org.opensolaris.os.dtrace;
     29 
     30 /**
     31  * An abstract adapter class for getting events from a {@link Consumer}.
     32  * The methods in this class are empty except for a few that implement
     33  * the default behavior of terminating a consumer by throwing an
     34  * exception.  This class exists as a convenience for implementing
     35  * consumer listeners.
     36  *
     37  * @see Consumer#addConsumerListener(ConsumerListener l)
     38  *
     39  * @author Tom Erickson
     40  */
     41 public abstract class ConsumerAdapter implements ConsumerListener {
     42     /** Empty method */
     43     public void dataReceived(DataEvent e) throws ConsumerException {}
     44 
     45     /**
     46      * Terminates a running {@link Consumer} by throwing an exception.
     47      *
     48      * @throws ConsumerException
     49      */
     50     public void
     51     dataDropped(DropEvent e) throws ConsumerException
     52     {
     53 	Drop drop = e.getDrop();
     54 	throw new ConsumerException(drop.getDefaultMessage(), drop);
     55     }
     56 
     57     /**
     58      * Terminates a running {@link Consumer} by throwing an exception.
     59      *
     60      * @throws ConsumerException
     61      */
     62     public void
     63     errorEncountered(ErrorEvent e) throws ConsumerException
     64     {
     65 	Error error = e.getError();
     66 	throw new ConsumerException(error.getDefaultMessage(), error);
     67     }
     68 
     69     /** Empty method */
     70     public void processStateChanged(ProcessEvent e) throws ConsumerException {}
     71     /** Empty method */
     72     public void consumerStarted(ConsumerEvent e) {}
     73     /** Empty method */
     74     public void consumerStopped(ConsumerEvent e) {}
     75     /** Empty method */
     76     public void intervalBegan(ConsumerEvent e) {}
     77     /** Empty method */
     78     public void intervalEnded(ConsumerEvent e) {}
     79 }
     80