1  //!-- UTF8
     2  /*
     3   Oregano Multiuser Server - Version 1.2.0 - January 4th, 2005
     4   
     5  	Web:  www.oregano-server.org
     6  	Mail: info@oregano-server.org
     7   
     8  	Copyright 2003 - 2004 - 2004 Jens Halm / Cologne, Germany
     9   
    10   This library is free software; you can redistribute it and/or
    11   modify it under the terms of the GNU Lesser General Public
    12   License as published by the Free Software Foundation; either
    13   version 2.1 of the License, or (at your option) any later version.
    14   
    15   This library is distributed in the hope that it will be useful,
    16   but WITHOUT ANY WARRANTY; without even the implied warranty of
    17   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    18   Lesser General Public License for more details.
    19   
    20   You should have received a copy of the GNU Lesser General Public
    21   License along with this library; if not, write to the Free Software
    22   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    23  */
    24  
    25  /*
    26   -------------------------------------------
    27  	Classe MessageFilter
    28   
    29  	@description :
    30  	Abonnement à des Messages type Mailing liste.
    31   
    32   
    33  	@author Jens Halm copyright http://www.spicefactory.org/
    34  	@author erixtekila copyleft http://www.v-i-a.net  
    35   -------------------------------------------
    36  	version history :
    37  	1.2.0 : 05/02/05
    38  			- Portage en actionscript 2 pour le
    39  			compile time type checking
    40   -------------------------------------------
    41   */
    42  
    43  import org.omus.util.EventDispatcher;
    44  import org.omus.util.iObservable;
    45  import org.omus.util._Class;
    46  
    47  /**
    48   *	Cette classe dère la lecture pour les éléments de requête SQL.
    49   *
    50   *	Elle est aggrémentée par composition des méthodes des sources d'événements (EventDispatcher).
    51   *	@see org.omus.util.EventDispatcher
    52   *	@see org.omus.util.iObservable
    53   *
    54   *	@author Jens Halm copyright http://www.spicefactory.org/
    55   *	@author erixtekila copyleft http://www.v-i-a.net 
    56   *	@version 1.2.0
    57   */
    58  class org.omus.msg.MessageFilter implements iObservable
    59  {
    60  	//--------------------
    61  	// PROPRIETES
    62  	//--------------------
    63  	/**
    64  	 *	Tableau associatif des sujets d'abonnements. 
    65  	 */
    66  	private var subjects:Object;
    67  	
    68  	/**
    69  	 *	Référence au système de génération d'événements.
    70  	 */
    71  	private var _eventSource:EventDispatcher;
    72  	
    73  	//--------------------
    74  	// CONSTRUCTEUR
    75  	//--------------------
    76  	/**
    77  	 *	TODO
    78  	 */
    79  	public function MessageFilter ()
    80  	{
    81  		// Composition avec EventDispatcher
    82  		_eventSource = new EventDispatcher();
    83  		
    84  		// Propriétés
    85  		subjects = new Object();
    86  		
    87  		// trace(this+ " installé.");
    88  	}
    89  	
    90  	//--------------------
    91  	// METHODES PUBLIQUES
    92  	//--------------------
    93  	/**
    94  	 *	Utilisé dans un contexte littéral
    95  	 *	@return	Une chaine définissant l'objet
    96  	 */
    97  	public function toString():String
    98  	{
    99  		var s = "[Objet MessageFilter]";
   100  		return s;
   101  	}
   102  	
   103  	/**
   104  	 *	Rajoute le sujjet dans la liste des abonnements.
   105  	 *
   106  	 *	@param subj			Titre du sujet.
   107  	 */
   108  	public function addSubject (subj:String):Void
   109  	{
   110  		// TODO : Accès Singleton
   111  		var clazz = _Class.getInstance();
   112  		var argCheck = [[subj, "string", true]];
   113  		if (! clazz.checkArguments("org.omus.MessageFilter.addSubject", argCheck)) return;
   114  		subjects[subj] = true;
   115  	}
   116  	
   117  	/**
   118  	 *	Supprime un suijet des abonnements.
   119  	 *
   120  	 *	@param subj			Titre du sujet.
   121  	 */
   122  	public function removeSubject (subj:String):Void
   123  	{
   124  		// TODO : Accès Singleton
   125  		var clazz = _Class.getInstance();
   126  		var argCheck = [[subj,"string",true]];
   127  		if (! clazz.checkArguments("org.omus.MessageFilter.removeSubject", argCheck)) return;
   128  		delete subjects[subj];
   129  	}
   130  	
   131  	//*** Implémentation de iObservable ***\
   132  	/**
   133  	 *	Notifie les observateurs d'un événement.
   134  	 *
   135  	 *	@param logLevel Une chaine caractérisant le niveau de logging de l'information.
   136  	 *	@param eventName Nom de l'événement.
   137  	 *	@param arg1		[option] Autant de paramêtres de voulu.
   138  	 */
   139  	private function fireEvent (logLevel:String, eventName:String):Void
   140  	{
   141  		_eventSource.fireEvent.apply (_eventSource, arguments);
   142  	}
   143  	
   144  	/**
   145  	 *	Ajoute un nouvel observateur.
   146  	 * 
   147  	 *	@param		listener Référence de l'observateur.
   148  	 *	@return Un booléen indiquant la réussite de l'opération.
   149  	 */
   150  	public function addListener (listener:Object):Boolean
   151  	{
   152  		return _eventSource.addListener(listener);
   153  	}
   154  	
   155  	/**
   156  	 *	Supprime un observateur.
   157  	 *
   158  	 *	@param		listener Référence de l'observateur.
   159  	 *	@return Un booléen indiquant la réussite de l'opération.
   160  	 */
   161  	public function removeListener (listener:Object):Boolean
   162  	{
   163  		return _eventSource.removeListener(listener);
   164  	}
   165  	
   166  	/**
   167  	 *	Supprime tous les abonnés.
   168  	 */
   169  	public function removeAllListeners ():Void
   170  	{
   171  		_eventSource.removeAllListeners();
   172  	}
   173  	
   174  	/**
   175  	 *	Retourne le nombre d'observateurs.
   176  	 *
   177  	 *	@return Le nombre d'observateurs enregistrés.
   178  	 */
   179  	public function countListeners ():Number
   180  	{
   181  		return _eventSource.countListeners();
   182  	}
   183  		
   184  	//--------------------
   185  	// METHODES PRIVEES
   186  	//--------------------
   187  	
   188  	
   189  	//--------------------
   190  	// METHODES STATIQUES
   191  	//--------------------
   192  	/**
   193  	 *	Utilisé dans un contexte littéral
   194  	 *
   195  	 *	@return Une chaine définissant l'objet.
   196  	 */
   197  	public static function toLog():String
   198  	{
   199  		return "[Objet MessageFilter]";
   200  	}
   201  }
   202