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 AddRow 28 29 @description : 30 Gère la mise à jour des données d'une Table. 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 : 17/01/05 38 - Portage en actionscript 2 pour le 39 compile time type checking 40 ------------------------------------------- 41 */ 42 43 import org.omus.data.Table; 44 45 46 /** 47 * Portion de UpdateSequence. 48 * 49 * @see org.omus.data.UpdateSequence 50 * 51 * @author Jens Halm copyright http://www.spicefactory.org/ 52 * @author erixtekila copyleft http://www.v-i-a.net 53 * @version 1.2.0 54 */ 55 class org.omus.data.AddRow 56 { 57 //-------------------- 58 // PROPRIETES 59 //-------------------- 60 /** 61 * Identifiant. 62 */ 63 private var rowID:Number; 64 65 /** 66 * Objet enregistrement. 67 */ 68 private var row:Object; 69 70 //-------------------- 71 // CONSTRUCTEUR 72 //-------------------- 73 /** 74 * 75 * @param id Identifiant de l'enregistrement. 76 * @param obj Enregistrement. 77 */ 78 public function AddRow(id:Number, obj:Object) 79 { 80 // Proppriétés. 81 rowID = id; 82 row = obj; 83 84 // trace(this+ " installé."); 85 } 86 87 //-------------------- 88 // METHODES PUBLIQUES 89 //-------------------- 90 /** 91 * Utilisé dans un contexte littéral 92 * @return Une chaine définissant l'objet 93 */ 94 public function toString ():String 95 { 96 return format(0); 97 } 98 99 /** 100 * Initialisation des valeurs à mettre à jour. 101 * 102 * @param table Une référence à la Table à mettre à jour. 103 * @param clientReq true si c'est le client qui effectue la requette, false si cela vient d'un autre utilisateur. 104 */ 105 public function execute (table:Table, clientReq:Boolean):Void 106 { 107 // Toutes les noms de colonnes de la TableDefinition 108 var colNames = table.getDefinition().getColumnNames(); 109 // Génère un tableau associatif selon TableDefinition 110 row = org.omus.data.DataParser.arrayToRow(row, colNames); 111 // Active un événement de Table. 112 if (row != null) table.addEvent(rowID, row, clientReq); 113 } 114 115 /** 116 * Encodage. 117 * 118 * @return Une chaîne encodée. 119 */ 120 public function getMarshalledSequence ():String 121 { 122 // TODO : Passer la constante dans cette classe. 123 return "#p" + org.omus.data.UpdateSequence.ADD_ROW + "#x0#x" + row + "#z"; 124 } 125 126 //-------------------- 127 // METHODES PRIVEES 128 //-------------------- 129 /** 130 * Formatage d'une chaine d'informations sur cet objet. 131 * 132 * @param indent Un nombre d'espace d'indentation. 133 * @return Une chaine formatée. 134 */ 135 private function format (indent:Number):String 136 { 137 var s = "org.omus.data.AddRow - rowID = " + rowID; 138 s += "\n"; 139 for (var idx = 0; idx < indent; idx++) s += " "; 140 s += "row = " + org.omus.util.Log.format(row, indent+1); 141 return s; 142 } 143 144 //-------------------- 145 // METHODES STATIQUES 146 //-------------------- 147 /** 148 * Utilisé dans un contexte littéral 149 * @return Une chaine définissant l'objet 150 */ 151 public static function toLog():String 152 { 153 return "[Object AddRow]"; 154 } 155 }