Skip to content

Commit 983dcfc

Browse files
committed
AJ-974: support String parsing for basic and temporal types in createScalar
1 parent 84e01d0 commit 983dcfc

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

src/com/xxdb/data/BasicEntityFactory.java

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import java.time.LocalDate;
99
import java.time.LocalDateTime;
1010
import java.time.LocalTime;
11+
import java.time.YearMonth;
1112
import java.util.Calendar;
1213
import java.util.Date;
1314
import static com.xxdb.data.Entity.DATA_TYPE.*;
@@ -1119,6 +1120,40 @@ private static Scalar createScalar(DATA_TYPE dataType, short val) {
11191120

11201121
private static Scalar createScalar(DATA_TYPE dataType, String val, int extraParam) {
11211122
switch (dataType) {
1123+
case DT_BOOL:
1124+
return new BasicBoolean(Boolean.parseBoolean(val));
1125+
case DT_BYTE:
1126+
return new BasicByte(Byte.parseByte(val));
1127+
case DT_SHORT:
1128+
return new BasicShort(Short.parseShort(val));
1129+
case DT_INT:
1130+
return new BasicInt(Integer.parseInt(val));
1131+
case DT_LONG:
1132+
return new BasicLong(Long.parseLong(val));
1133+
case DT_FLOAT:
1134+
return new BasicFloat(Float.parseFloat(val));
1135+
case DT_DOUBLE:
1136+
return new BasicDouble(Double.parseDouble(val));
1137+
case DT_DATE:
1138+
return new BasicDate(LocalDate.parse(val));
1139+
case DT_MONTH:
1140+
return new BasicMonth(YearMonth.parse(val));
1141+
case DT_TIME:
1142+
return new BasicTime(LocalTime.parse(val));
1143+
case DT_MINUTE:
1144+
return new BasicMinute(LocalTime.parse(val));
1145+
case DT_SECOND:
1146+
return new BasicSecond(LocalTime.parse(val));
1147+
case DT_DATETIME:
1148+
return new BasicDateTime(LocalDateTime.parse(val));
1149+
case DT_TIMESTAMP:
1150+
return new BasicTimestamp(LocalDateTime.parse(val));
1151+
case DT_NANOTIME:
1152+
return new BasicNanoTime(LocalTime.parse(val));
1153+
case DT_NANOTIMESTAMP:
1154+
return new BasicNanoTimestamp(LocalDateTime.parse(val));
1155+
case DT_DATEHOUR:
1156+
return new BasicDateHour(LocalDateTime.parse(val));
11221157
case DT_INT128: {
11231158
return BasicInt128.fromString(val);
11241159
}

0 commit comments

Comments
 (0)