1 28 29 package com.caucho.db.table; 30 31 class Row { 32 private static final int NULL_OFFSET = 2; 34 35 private Column []_columns = new Column[0]; 36 private int _rowLength = 1; 37 private int _nullOffset = 0; 38 39 42 int getLength() 43 { 44 return _rowLength; 45 } 46 47 50 int getNullOffset() 51 { 52 return _nullOffset; 53 } 54 55 58 byte getNullMask() 59 { 60 return (byte) (1 << ((_columns.length + NULL_OFFSET) % 8)); 61 } 62 63 66 Column []getColumns() 67 { 68 return _columns; 69 } 70 71 74 Column getColumn(String name) 75 { 76 for (int i = 0; i < _columns.length; i++) 77 if (name.equals(_columns[i].getName())) 78 return _columns[i]; 79 80 return null; 81 } 82 83 86 void allocateColumn() 87 { 88 if ((_columns.length + NULL_OFFSET) % 8 == 0) { 89 _nullOffset = _rowLength; 90 _rowLength++; 91 } 92 } 93 94 97 Column addColumn(Column column) 98 { 99 Column []newColumns = new Column[_columns.length + 1]; 100 101 System.arraycopy(_columns, 0, newColumns, 0, _columns.length); 102 _columns = newColumns; 103 104 _columns[_columns.length - 1] = column; 105 106 _rowLength += column.getLength(); 107 108 return column; 109 } 110 } 111 | Popular Tags |