1 8 9 package com.sleepycat.je.tree; 10 11 import java.nio.ByteBuffer ; 12 13 import com.sleepycat.je.dbi.DatabaseId; 14 import com.sleepycat.je.log.LogEntryType; 15 import com.sleepycat.je.log.LogException; 16 import com.sleepycat.je.log.LogUtils; 17 18 21 public final class NameLN extends LN { 22 23 private static final String BEGIN_TAG = "<nameLN>"; 24 private static final String END_TAG = "</nameLN>"; 25 26 private DatabaseId id; 27 private boolean deleted; 28 29 34 public NameLN(DatabaseId id) { 35 super(new byte[0]); 36 this.id = id; 37 deleted = false; 38 } 39 40 43 public NameLN() { 44 super(); 45 id = new DatabaseId(); 46 } 47 48 public boolean isDeleted() { 49 return deleted; 50 } 51 52 void makeDeleted() { 53 deleted = true; 54 } 55 56 public DatabaseId getId() { 57 return id; 58 } 59 60 public void setId(DatabaseId id) { 61 this.id = id; 62 } 63 64 67 68 public String toString() { 69 return dumpString(0, true); 70 } 71 72 public String beginTag() { 73 return BEGIN_TAG; 74 } 75 76 public String endTag() { 77 return END_TAG; 78 } 79 80 public String dumpString(int nSpaces, boolean dumpTags) { 81 StringBuffer sb = new StringBuffer (); 82 sb.append(super.dumpString(nSpaces, dumpTags)); 83 sb.append('\n'); 84 sb.append(TreeUtils.indent(nSpaces)); 85 sb.append("<deleted val=\"").append(Boolean.toString(deleted)); 86 sb.append("\">"); 87 sb.append('\n'); 88 sb.append(TreeUtils.indent(nSpaces)); 89 sb.append("<id val=\"").append(id); 90 sb.append("\">"); 91 sb.append('\n'); 92 return sb.toString(); 93 } 94 95 98 99 102 protected LogEntryType getTransactionalLogType() { 103 return LogEntryType.LOG_NAMELN_TRANSACTIONAL; 104 } 105 106 109 public LogEntryType getLogType() { 110 return LogEntryType.LOG_NAMELN; 111 } 112 113 116 public int getLogSize() { 117 return 118 super.getLogSize() + id.getLogSize() + LogUtils.getBooleanLogSize(); } 122 123 126 public void writeToLog(ByteBuffer logBuffer) { 127 128 super.writeToLog(logBuffer); id.writeToLog(logBuffer); LogUtils.writeBoolean(logBuffer, deleted); } 132 133 136 public void readFromLog(ByteBuffer itemBuffer, byte entryTypeVersion) 137 throws LogException { 138 139 super.readFromLog(itemBuffer, entryTypeVersion); id.readFromLog(itemBuffer, entryTypeVersion); deleted = LogUtils.readBoolean(itemBuffer); } 143 144 148 protected void dumpLogAdditional(StringBuffer sb, boolean verbose) { 149 id.dumpLog(sb, true); 150 } 151 } 152 | Popular Tags |