/** * Create a LOB value with the given parameters. * * @param type the data type * @param handler the file handler * @param tableId the table object id * @param objectId the object id * @param precision the precision (length in elements) * @param compression if compression is used * @return the value object */ public static ValueLob openLinked(int type, int tableId, int objectId, long precision) { String fileName = getFileName(tableId, objectId); return new ValueLob(type, fileName, tableId, objectId, true/* linked */, precision); }
@Override public void unlink() { if (linked && fileName != null) { String temp; // synchronize on the database, to avoid concurrent temp file // creation / deletion / backup temp = getFileName(-1, objectId); deleteFile(temp); renameFile(fileName, temp); fileName = temp; linked = false; } }
@Override public Value link(int tabId) { if (fileName == null) { this.tableId = tabId; return this; } if (linked) { ValueLob copy = ValueLob.copy(this); copy.objectId = getNewObjectId(); copy.tableId = tabId; String live = getFileName(copy.tableId, copy.objectId); copyFileTo(fileName, live); copy.fileName = live; copy.linked = true; return copy; } if (!linked) { this.tableId = tabId; String live = getFileName(tableId, objectId); renameFile(fileName, live); fileName = live; linked = true; } return this; }