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 MarshalledProperties 28 29 @description : 30 Propriétés en attente de synchronisation serveur 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 : 18/01/05 38 - Portage en actionscript 2 pour le 39 compile time type checking 40 ------------------------------------------- 41 */ 42 43 44 /** 45 * Gestion des propriétés en attente de synchronisation serveur. 46 * 47 * @author Jens Halm copyright http://www.spicefactory.org/ 48 * @author erixtekila copyleft http://www.v-i-a.net 49 * @version 1.2.0 50 */ 51 class org.omus.data.MarshalledProperties 52 { 53 //-------------------- 54 // PROPRIETES 55 //-------------------- 56 /** 57 * Les propriétés sous forme de tableau associatif. 58 */ 59 private var props:Object; 60 61 /** 62 * Nombre de propriétés. 63 */ 64 private var _size:Number; 65 66 //-------------------- 67 // CONSTRUCTEUR 68 //-------------------- 69 /** 70 * TODO 71 */ 72 public function MarshalledProperties() 73 { 74 // Propriétés 75 props = new Object(); 76 _size = 0; 77 78 // trace(this+ " installé."); 79 } 80 81 //-------------------- 82 // METHODES PUBLIQUES 83 //-------------------- 84 /** 85 * Utilisé dans un contexte littéral 86 * 87 * @return Une chaine définissant l'objet 88 */ 89 public function toString():String 90 { 91 return "[Object MarshalledProperties] \norg.omus.data.MarshalledProperties:\n" + org.omus.util.Log.formatObject(props, 1); 92 } 93 94 /** 95 * Rajoute une propriété et sa valeur. 96 * 97 * @param propName Nom de la propriété. 98 */ 99 public function addProp (propName:String, value:Object):Void 100 { 101 props[propName] = value; 102 _size++; 103 } 104 105 /** 106 * Permet de savoir si une propriété est encodée. 107 * 108 * @return true si la propriété en fait partie. 109 */ 110 public function contains (propName:String):Boolean 111 { 112 return (props[propName] != undefined); 113 } 114 115 /** 116 * Renvoie le nombre de propriétés. 117 * 118 * @return Nombre total des propriétés. 119 */ 120 public function size ():Number 121 { 122 return _size; 123 } 124 125 /** 126 * Extrait une partie des propriétés mise à jour avant synchronisation. 127 * TODO 128 * 129 * @param propertys Un tableau associatif de toutes les propriétés et leur nom. 130 * @return Un conteneur de toutes les propriétés en attente. 131 */ 132 public function extract (propertys:Object):MarshalledProperties 133 { 134 var extr = new MarshalledProperties(); 135 var ps = props; 136 for (var each:String in ps) 137 { 138 if (propertys[each] != undefined) 139 { 140 // Fait partie de la séquence de mise à jour ? 141 if (ps[each] instanceof org.omus.data.UpdateSequence) 142 { 143 extr.addProp(each, ps[each].clear()); 144 }else 145 { 146 extr.addProp(each, ps[each]); 147 } 148 delete ps[each]; 149 } 150 } 151 return extr; 152 } 153 154 //-------------------- 155 // METHODES PRIVEES 156 //-------------------- 157 158 //-------------------- 159 // METHODES STATIQUES 160 //-------------------- 161 /** 162 * Utilisé dans un contexte littéral 163 * @return Une chaine définissant l'objet 164 */ 165 public static function toLog():String 166 { 167 return "[Object MarshalledProperties]"; 168 } 169 } 170