[Ecforms-commit] ECF-JSF/ipl blank_db.ipl,1.1,1.2
Brought to you by:
fcastrillo
From: Francisco C. <fca...@us...> - 2005-11-23 18:54:22
|
Update of /cvsroot/ecforms/ECF-JSF/ipl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22594/ipl Modified Files: blank_db.ipl Log Message: Empty file Index: blank_db.ipl =================================================================== RCS file: /cvsroot/ecforms/ECF-JSF/ipl/blank_db.ipl,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** blank_db.ipl 22 Nov 2005 14:56:54 -0000 1.1 --- blank_db.ipl 23 Nov 2005 18:54:13 -0000 1.2 *************** *** 1,80 **** - IDGenerator() { - var nextId = 1; - - getNextId() { - return nextId++; - } - - return {getNextId: getNextId}; - } - - Table() { - var rows = new array[100]; - - var count = 0; - - var idGenerator = IDGenerator(); - - addRow(row) { - if (isReadOnly()) - error("can't addRow in query"); - var n = length(rows); - if (count == n) { - var tmp = new array[n * 2]; - arrayCopy(rows, 0, tmp, 0, n); - rows = tmp; - } - row.id = idGenerator.getNextId(); - rows[count++] = row; - } - - getIndexForId(id) { - for (var i = 0; i < count; i++) - if (rows[i].id == id) - return i; - return -1; - } - - getRowWithId(id) { - var index = getIndexForId(id); - return index != -1 ? rows[index] : null; - } - - deleteRowWithId(id) { - if (isReadOnly()) - error("can't deleteRowWithId in query"); - var index = getIndexForId(id); - if (index == -1) - return; - arrayCopy(rows, index + 1, rows, index, count - index - 1); - count--; - } - - updateRowWithId(id, row) { - if (isReadOnly()) - error("can't updateRowWithId in query"); - var index = getIndexForId(id); - if (index == -1) - return; - var names = getNames(row); - var n = length(names); - for (var i = 0; i < n; i++) - rows[index][names[i]] = row[names[i]]; - } - - getRows() { - var result = new array[count]; - arrayCopy(rows, 0, result, 0, count); - return result; - } - - return { - addRow: addRow, - getRowWithId: getRowWithId, - deleteRowWithId: deleteRowWithId, - updateRowWithId: updateRowWithId, - getRows: getRows - }; - } - - var persons = Table(); --- 0 ---- |