Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/develop' into CBRD-25515
Browse files Browse the repository at this point in the history
  • Loading branch information
kangmin5505 committed Nov 22, 2024
2 parents 8d4b050 + 2b1a584 commit 7359cec
Show file tree
Hide file tree
Showing 25 changed files with 239 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@
import com.cubrid.jsp.exception.TypeMismatchException;

public class BooleanValue extends Value {

protected String getTypeName() {
return TYPE_NAME_BOOLEAN;
}

private byte value = 0;

public BooleanValue(boolean b) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@
import java.math.BigDecimal;

public class ByteValue extends Value {

protected String getTypeName() {
return TYPE_NAME_BYTE;
}

private byte value;

public ByteValue(byte value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@
import java.util.Calendar;

public class DateValue extends Value {

protected String getTypeName() {
return TYPE_NAME_DATE;
}

private Date date;

public DateValue(int year, int mon, int day) throws TypeMismatchException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@
import java.util.Calendar;

public class DatetimeValue extends Value {

protected String getTypeName() {
return TYPE_NAME_DATETIME;
}

private Timestamp timestamp;

public DatetimeValue(int year, int mon, int day, int hour, int min, int sec, int msec)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@
import java.sql.Timestamp;

public class DoubleValue extends Value {

protected String getTypeName() {
return TYPE_NAME_DOUBLE;
}

private double value;

public DoubleValue(double value) throws TypeMismatchException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@
import java.sql.Timestamp;

public class FloatValue extends Value {

protected String getTypeName() {
return TYPE_NAME_FLOAT;
}

private float value;

public FloatValue(float value) throws TypeMismatchException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@
import java.sql.Timestamp;

public class IntValue extends Value {

protected String getTypeName() {
return TYPE_NAME_INT;
}

private int value;

public IntValue(int value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@
import java.sql.Timestamp;

public class LongValue extends Value {

protected String getTypeName() {
return TYPE_NAME_BIGINT;
}

private long value;

public LongValue(long value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@
import java.sql.Timestamp;

public class NullValue extends Value {

protected String getTypeName() {
return TYPE_NAME_NULL;
}

public NullValue() {
super();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@
import java.sql.Timestamp;

public class NumericValue extends Value {

protected String getTypeName() {
return TYPE_NAME_NUMERIC;
}

private BigDecimal value;

public NumericValue(String value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@
import java.sql.SQLException;

public class OidValue extends Value {

protected String getTypeName() {
return TYPE_NAME_OID;
}

private SOID oidValue = null;
private CUBRIDOID oidObject = null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@
import java.sql.ResultSet;

public class ResultSetValue extends Value {

protected String getTypeName() {
return TYPE_NAME_RESULTSET;
}

private long queryId;
private ResultSet rset = null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@
import java.sql.Timestamp;

public class SetValue extends Value {

protected String getTypeName() {
return TYPE_NAME_SET;
}

private Object[] values;

public SetValue(Value[] args) throws TypeMismatchException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@
import java.sql.Timestamp;

public class ShortValue extends Value {

protected String getTypeName() {
return TYPE_NAME_SHORT;
}

private short value;

public ShortValue(short value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@

public class StringValue extends Value {

protected String getTypeName() {
return TYPE_NAME_STRING;
}

private String value;

public StringValue(String value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@
import java.util.Calendar;

public class TimeValue extends Value {

protected String getTypeName() {
return TYPE_NAME_TIME;
}

private Time time;

public TimeValue(int hour, int min, int sec) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@
import java.util.Calendar;

public class TimestampValue extends Value {

protected String getTypeName() {
return TYPE_NAME_TIMESTAMP;
}

private Timestamp timestamp;

public TimestampValue(int year, int mon, int day, int hour, int min, int sec)
Expand Down
72 changes: 52 additions & 20 deletions pl_engine/pl_server/src/main/java/com/cubrid/jsp/value/Value.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,31 +66,31 @@ public int getMode() {
}

public byte toByte() throws TypeMismatchException {
throw new TypeMismatchException();
throw new TypeMismatchException(getCastErrMsg(TYPE_NAME_BYTE));
}

public short toShort() throws TypeMismatchException {
throw new TypeMismatchException();
throw new TypeMismatchException(getCastErrMsg(TYPE_NAME_SHORT));
}

public int toInt() throws TypeMismatchException {
throw new TypeMismatchException();
throw new TypeMismatchException(getCastErrMsg(TYPE_NAME_INT));
}

public long toLong() throws TypeMismatchException {
throw new TypeMismatchException();
throw new TypeMismatchException(getCastErrMsg(TYPE_NAME_BIGINT));
}

public float toFloat() throws TypeMismatchException {
throw new TypeMismatchException();
throw new TypeMismatchException(getCastErrMsg(TYPE_NAME_FLOAT));
}

public double toDouble() throws TypeMismatchException {
throw new TypeMismatchException();
throw new TypeMismatchException(getCastErrMsg(TYPE_NAME_DOUBLE));
}

public Byte toByteObject() throws TypeMismatchException {
throw new TypeMismatchException();
throw new TypeMismatchException(getCastErrMsg(TYPE_NAME_BYTE));
}

public byte[] toByteArray() throws TypeMismatchException {
Expand All @@ -102,7 +102,7 @@ public byte[][] toByteArrayArray() throws TypeMismatchException {
}

public Short toShortObject() throws TypeMismatchException {
throw new TypeMismatchException();
throw new TypeMismatchException(getCastErrMsg(TYPE_NAME_SHORT));
}

public short[] toShortArray() throws TypeMismatchException {
Expand All @@ -114,7 +114,7 @@ public short[][] toShortArrayArray() throws TypeMismatchException {
}

public Integer toIntegerObject() throws TypeMismatchException {
throw new TypeMismatchException();
throw new TypeMismatchException(getCastErrMsg(TYPE_NAME_INT));
}

public int[] toIntegerArray() throws TypeMismatchException {
Expand All @@ -126,7 +126,7 @@ public int[][] toIntegerArrayArray() throws TypeMismatchException {
}

public Long toLongObject() throws TypeMismatchException {
throw new TypeMismatchException();
throw new TypeMismatchException(getCastErrMsg(TYPE_NAME_BIGINT));
}

public long[] toLongArray() throws TypeMismatchException {
Expand All @@ -138,7 +138,7 @@ public long[][] toLongArrayArray() throws TypeMismatchException {
}

public Float toFloatObject() throws TypeMismatchException {
throw new TypeMismatchException();
throw new TypeMismatchException(getCastErrMsg(TYPE_NAME_FLOAT));
}

public float[] toFloatArray() throws TypeMismatchException {
Expand All @@ -150,7 +150,7 @@ public float[][] toFloatArrayArray() throws TypeMismatchException {
}

public Double toDoubleObject() throws TypeMismatchException {
throw new TypeMismatchException();
throw new TypeMismatchException(getCastErrMsg(TYPE_NAME_DOUBLE));
}

public double[] toDoubleArray() throws TypeMismatchException {
Expand All @@ -162,7 +162,7 @@ public double[][] toDoubleArrayArray() throws TypeMismatchException {
}

public Object toObject() throws TypeMismatchException {
throw new TypeMismatchException();
throw new TypeMismatchException(getCastErrMsg(TYPE_NAME_OBJECT));
}

public Object[] toObjectArray() throws TypeMismatchException {
Expand All @@ -174,7 +174,7 @@ public Object[][] toObjectArrayArray() throws TypeMismatchException {
}

public Date toDate() throws TypeMismatchException {
throw new TypeMismatchException();
throw new TypeMismatchException(getCastErrMsg(TYPE_NAME_DATE));
}

public Date[] toDateArray() throws TypeMismatchException {
Expand All @@ -186,7 +186,7 @@ public Date[][] toDateArrayArray() throws TypeMismatchException {
}

public Time toTime() throws TypeMismatchException {
throw new TypeMismatchException();
throw new TypeMismatchException(getCastErrMsg(TYPE_NAME_TIME));
}

public Time[] toTimeArray() throws TypeMismatchException {
Expand All @@ -198,7 +198,7 @@ public Time[][] toTimeArrayArray() throws TypeMismatchException {
}

public Timestamp toTimestamp() throws TypeMismatchException {
throw new TypeMismatchException();
throw new TypeMismatchException(getCastErrMsg(TYPE_NAME_TIMESTAMP));
}

public Timestamp[] toTimestampArray() throws TypeMismatchException {
Expand All @@ -210,7 +210,7 @@ public Timestamp[][] toTimestampArrayArray() throws TypeMismatchException {
}

public Timestamp toDatetime() throws TypeMismatchException {
throw new TypeMismatchException();
throw new TypeMismatchException(getCastErrMsg(TYPE_NAME_DATETIME));
}

public Timestamp[] toDatetimeArray() throws TypeMismatchException {
Expand All @@ -222,7 +222,7 @@ public Timestamp[][] toDatetimeArrayArray() throws TypeMismatchException {
}

public BigDecimal toBigDecimal() throws TypeMismatchException {
throw new TypeMismatchException();
throw new TypeMismatchException(getCastErrMsg(TYPE_NAME_NUMERIC));
}

public BigDecimal[] toBigDecimalArray() throws TypeMismatchException {
Expand Down Expand Up @@ -290,7 +290,7 @@ public Double[][] toDoubleObjArrayArray() throws TypeMismatchException {
}

public CUBRIDOID toOid() throws TypeMismatchException {
throw new TypeMismatchException();
throw new TypeMismatchException(getCastErrMsg(TYPE_NAME_OID));
}

public CUBRIDOID[] toOidArray() throws TypeMismatchException {
Expand All @@ -302,7 +302,7 @@ public CUBRIDOID[][] toOidArrayArray() throws TypeMismatchException {
}

public ResultSet toResultSet(SUConnection ucon) throws TypeMismatchException {
throw new TypeMismatchException();
throw new TypeMismatchException(getCastErrMsg(TYPE_NAME_RESULTSET));
}

public ResultSet[] toResultSetArray(SUConnection ucon) throws TypeMismatchException {
Expand All @@ -328,4 +328,36 @@ public int getDbType() {
public void setDbType(int type) {
dbType = type;
}

// -----------------------------------------------------

private String getCastErrMsg(String targetType) {
return String.format("cannot convert %s to %s", getTypeName(), targetType);
}

protected abstract String getTypeName();

protected static final String TYPE_NAME_NULL = "NULL";
protected static final String TYPE_NAME_OBJECT = "OBJECT";

protected static final String TYPE_NAME_BOOLEAN = "BOOLEAN";
protected static final String TYPE_NAME_STRING = "STRING";

protected static final String TYPE_NAME_BYTE = "BYTE";
protected static final String TYPE_NAME_SHORT = "SHORT";
protected static final String TYPE_NAME_INT = "INT";
protected static final String TYPE_NAME_BIGINT = "BIGINT";
protected static final String TYPE_NAME_FLOAT = "FLOAT";
protected static final String TYPE_NAME_DOUBLE = "DOUBLE";
protected static final String TYPE_NAME_NUMERIC = "NUMERIC";

protected static final String TYPE_NAME_DATE = "DATE";
protected static final String TYPE_NAME_TIME = "TIME";
protected static final String TYPE_NAME_DATETIME = "DATETIME";
protected static final String TYPE_NAME_TIMESTAMP = "TIMESTAMP";

protected static final String TYPE_NAME_OID = "OID";
protected static final String TYPE_NAME_RESULTSET = "RESULTSET";
protected static final String TYPE_NAME_SET =
"COLLECTION"; // actually, it is not only SET but also MULTISET and LIST
}
Loading

0 comments on commit 7359cec

Please sign in to comment.