Clover coverage report -
Coverage timestamp: Sun Oct 12 2003 22:54:40 PDT
file stats: LOC: 112   Methods: 4
NCLOC: 38   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
BrokerableObject.java 66.7% 75% 75% 72.2%
coverage coverage
 1   
 /*
 2   
 
 3   
 VRMoo Common - Virtual Reality Object Oriented MUD Common Code
 4   
 Copyright (C) 2003  VRMoo Development Team
 5   
 
 6   
 
 7   
 This program is free software; you can redistribute it and/or modify
 8   
 it under the terms of the GNU General Public License as published by
 9   
 the Free Software Foundation; either version 2 of the License, or
 10   
 (at your option) any later version.
 11   
 
 12   
 This program is distributed in the hope that it will be useful,
 13   
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 14   
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 15   
 GNU General Public License for more details.
 16   
 
 17   
 You should have received a copy of the GNU General Public License
 18   
 along with this program; if not, write to the Free Software
 19   
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 20   
 
 21   
 
 22   
 For information about VRMoo and its authors, please visit the website:
 23   
 http://www.vrmoo.org/
 24   
 
 25   
 */
 26   
 
 27   
 package org.vrmoo.common.data;
 28   
 
 29   
 import java.util.ArrayList;
 30   
 import java.util.List;
 31   
 
 32   
 /**
 33   
  * Provides a standard interface for objects that can be managed by some form
 34   
  * of object broker.
 35   
  *
 36   
  * @author Jeff Weston
 37   
  */
 38   
 public abstract class BrokerableObject
 39   
 {
 40   
     /**
 41   
      * The list of <code>BrokerableObject</code> listeners.
 42   
      */
 43   
     private List brokerableObjectListeners;
 44   
 
 45   
     /**
 46   
      * Basic constructor.
 47   
      */
 48  40
     public BrokerableObject( )
 49   
     {
 50  40
         brokerableObjectListeners = new ArrayList( );
 51   
     }
 52   
 
 53   
     /**
 54   
      * Get the name of the object.
 55   
      *
 56   
      * @return the name of the object
 57   
      */
 58   
     public abstract String getName( );
 59   
 
 60   
     /**
 61   
      * Get a string encoded version of the object suitable for use in a command
 62   
      * sent between the client and the server.
 63   
      *
 64   
      * @return the string encoded version of this object
 65   
      */
 66   
     public abstract String toEncodedString( );
 67   
 
 68   
     /**
 69   
      * Add a new <code>BrokerableObjectListener</code> to the list of
 70   
      * <code>BrokerableObject</code> listeners for this class.
 71   
      *
 72   
      * @param listener   the <code>BrokerableObjectListener</code> to add
 73   
      */
 74  50
     public synchronized void addBrokerableObjectListener(
 75   
             BrokerableObjectListener listener )
 76   
     {
 77  50
         if ( ! brokerableObjectListeners.contains( listener ) )
 78   
         {
 79  34
             brokerableObjectListeners.add( listener );
 80   
         }
 81   
     }
 82   
 
 83   
     /**
 84   
      * Remove a <code>BrokerableObjectListener</code> from the list of
 85   
      * <code>BrokerableObject</code> listeners for this class.
 86   
      *
 87   
      * @param listener   the <code>BrokerableObjectListener</code> to remove
 88   
      */
 89  0
     public synchronized void removeBrokerableObjectListener(
 90   
             BrokerableObjectListener listener )
 91   
     {
 92  0
         if ( brokerableObjectListeners.contains( listener ) )
 93   
         {
 94  0
             brokerableObjectListeners.remove( listener );
 95   
         }
 96   
     }
 97   
 
 98   
     /**
 99   
      * Notify all of the <code>BrokerableObject</code> listeners that this class
 100   
      * has changed.
 101   
      */
 102  5
     protected synchronized void fireBrokerableObjectChanged( )
 103   
     {
 104  5
         for ( int i = 0; i < brokerableObjectListeners.size( ); i++ )
 105   
         {
 106  4
             BrokerableObjectListener listner = ( BrokerableObjectListener )
 107   
                     brokerableObjectListeners.get( i );
 108  4
             listner.brokerableObjectChanged( this );
 109   
         }
 110   
     }
 111   
 }
 112