提交 820af1e7 authored 作者: noelgrandin's avatar noelgrandin

simplify - smarter use of constructor means we can drop a setter

上级 880a284f
...@@ -612,11 +612,14 @@ public class ValueDataType implements DataType { ...@@ -612,11 +612,14 @@ public class ValueDataType implements DataType {
precision = readVarLong(buff); precision = readVarLong(buff);
compression = buff.get() == 1; compression = buff.get() == 1;
} }
ValueLob lob = ValueLob.open(type, handler, tableId, objectId, precision, compression);
if (smallLen == -2) { if (smallLen == -2) {
lob.setFileName(readString(buff), false); String filename = readString(buff);
ValueLob lob = ValueLob.openUnlinked(type, handler, tableId, objectId, precision, compression, filename);
return lob;
} else {
ValueLob lob = ValueLob.openLinked(type, handler, tableId, objectId, precision, compression);
return lob;
} }
return lob;
} }
} }
case Value.ARRAY: { case Value.ARRAY: {
......
...@@ -806,11 +806,14 @@ public class Data { ...@@ -806,11 +806,14 @@ public class Data {
precision = readVarLong(); precision = readVarLong();
compression = readByte() == 1; compression = readByte() == 1;
} }
ValueLob lob = ValueLob.open(type, handler, tableId, objectId, precision, compression);
if (smallLen == -2) { if (smallLen == -2) {
lob.setFileName(readString(), false); String filename = readString();
ValueLob lob = ValueLob.openUnlinked(type, handler, tableId, objectId, precision, compression, filename);
return lob;
} else {
ValueLob lob = ValueLob.openLinked(type, handler, tableId, objectId, precision, compression);
return lob;
} }
return lob;
} }
} }
case Value.ARRAY: { case Value.ARRAY: {
......
...@@ -127,12 +127,28 @@ public class ValueLob extends Value { ...@@ -127,12 +127,28 @@ public class ValueLob extends Value {
* @param compression if compression is used * @param compression if compression is used
* @return the value object * @return the value object
*/ */
public static ValueLob open(int type, DataHandler handler, public static ValueLob openLinked(int type, DataHandler handler,
int tableId, int objectId, long precision, boolean compression) { int tableId, int objectId, long precision, boolean compression) {
String fileName = getFileName(handler, tableId, objectId); String fileName = getFileName(handler, tableId, objectId);
return new ValueLob(type, handler, fileName, tableId, objectId, true, precision, compression); return new ValueLob(type, handler, fileName, tableId, objectId, true/*linked*/, precision, compression);
} }
/**
* 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 openUnlinked(int type, DataHandler handler,
int tableId, int objectId, long precision, boolean compression, String fileName) {
return new ValueLob(type, handler, fileName, tableId, objectId, false/*linked*/, precision, compression);
}
/** /**
* Create a CLOB value from a stream. * Create a CLOB value from a stream.
* *
...@@ -762,17 +778,6 @@ public class ValueLob extends Value { ...@@ -762,17 +778,6 @@ public class ValueLob extends Value {
} }
} }
/**
* Set the file name of this lob value.
*
* @param fileName the file name
* @param linked if the lob is linked
*/
public void setFileName(String fileName, boolean linked) {
this.fileName = fileName;
this.linked = linked;
}
public int getMemory() { public int getMemory() {
if (small != null) { if (small != null) {
return small.length + 104; return small.length + 104;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论