1 21 package com.db4o.inside.marshall; 22 23 import com.db4o.*; 24 25 26 class ArrayMarshaller0 extends ArrayMarshaller{ 27 28 public void deleteEmbedded(YapArray arrayHandler, YapWriter reader) { 29 int address = reader.readInt(); 30 int length = reader.readInt(); 31 if (address <= 0) { 32 return; 33 } 34 Transaction trans = reader.getTransaction(); 35 if (reader.cascadeDeletes() > 0 && arrayHandler.i_handler instanceof YapClass) { 36 YapWriter bytes = 37 reader.getStream().readWriterByAddress( 38 trans, 39 address, 40 length); 41 if (bytes != null) { 42 if (Deploy.debug) { 43 bytes.readBegin(arrayHandler.identifier()); 44 } 45 bytes.setCascadeDeletes(reader.cascadeDeletes()); 46 for (int i = arrayHandler.elementCount(trans, bytes); i > 0; i--) { 47 arrayHandler.i_handler.deleteEmbedded(_family, bytes); 48 } 49 } 50 } 51 trans.slotFreeOnCommit(address, address, length); 52 } 53 54 public void calculateLengths(Transaction trans, ObjectHeaderAttributes header, YapArray handler, Object obj, boolean topLevel){ 55 } 57 58 public Object writeNew(YapArray arrayHandler, Object a_object, boolean topLevel, YapWriter a_bytes) { 59 if (a_object == null) { 60 a_bytes.writeEmbeddedNull(); 61 return null; 62 } 63 int length = arrayHandler.objectLength(a_object); 64 YapWriter bytes = new YapWriter(a_bytes.getTransaction(), length); 65 bytes.setUpdateDepth(a_bytes.getUpdateDepth()); 66 arrayHandler.writeNew1(a_object, bytes); 67 bytes.setID(a_bytes._offset); 68 a_bytes.getStream().writeEmbedded(a_bytes, bytes); 69 a_bytes.incrementOffset(YapConst.ID_LENGTH); 70 a_bytes.writeInt(length); 71 return a_object; 72 } 73 74 public Object read(YapArray arrayHandler, YapWriter a_bytes) throws CorruptionException{ 75 YapWriter bytes = a_bytes.readEmbeddedObject(); 76 if (bytes == null) { 77 return null; 78 } 79 return arrayHandler.read1(_family, bytes); 80 } 81 82 public void readCandidates(YapArray arrayHandler, YapReader reader, QCandidates candidates) { 83 YapReader bytes = reader.readEmbeddedObject(candidates.i_trans); 84 if (bytes == null) { 85 return; 86 } 87 if(Deploy.debug){ 88 bytes.readBegin(arrayHandler.identifier()); 89 } 90 int count = arrayHandler.elementCount(candidates.i_trans, bytes); 91 for (int i = 0; i < count; i++) { 92 candidates.addByIdentity(new QCandidate(candidates, null, bytes.readInt(), true)); 93 } 94 } 95 96 97 public final Object readQuery(YapArray arrayHandler, Transaction trans, YapReader reader) throws CorruptionException{ 98 YapReader bytes = reader.readEmbeddedObject(trans); 99 if (bytes == null) { 100 return null; 101 } 102 Object array = arrayHandler.read1Query(trans,_family, bytes); 103 return array; 104 } 105 106 protected YapReader prepareIDReader(Transaction trans,YapReader reader) { 107 return reader.readEmbeddedObject(trans); 108 } 109 110 public void defragIDs(YapArray arrayHandler,ReaderPair readers) { 111 } 112 } 113 | Popular Tags |