mirror of
https://github.com/CodePhiliaX/Chat2DB.git
synced 2025-07-29 02:32:33 +08:00
fix(chat2db-oracle): Temporary processing of binary data
This commit is contained in:
@ -15,7 +15,24 @@ public class OracleBlobProcessor extends DefaultValueProcessor {
|
||||
|
||||
@Override
|
||||
public String convertSQLValueByType(SQLDataValue dataValue) {
|
||||
return EasyStringUtils.quoteString(dataValue.getBlobHexString());
|
||||
String value = dataValue.getValue();
|
||||
if (value.startsWith("0x")) {
|
||||
// 0xabcd
|
||||
return EasyStringUtils.quoteString(value.substring(2));
|
||||
} else {
|
||||
//example: hello,world
|
||||
for (int i = 0; i < value.length(); i++) {
|
||||
char c = value.charAt(i);
|
||||
boolean isDigit = (c >= '0' && c <= '9');
|
||||
boolean isUpperCaseHex = (c >= 'A' && c <= 'F');
|
||||
boolean isLowerCaseHex = (c >= 'a' && c <= 'f');
|
||||
if (!isDigit && !isUpperCaseHex && !isLowerCaseHex) {
|
||||
return EasyStringUtils.quoteString(dataValue.getBlobHexString());
|
||||
}
|
||||
}
|
||||
// example: abcd1234
|
||||
return EasyStringUtils.quoteString(value);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -15,7 +15,25 @@ public class OracleLongRawProcessor extends DefaultValueProcessor {
|
||||
|
||||
@Override
|
||||
public String convertSQLValueByType(SQLDataValue dataValue) {
|
||||
return EasyStringUtils.quoteString(dataValue.getValue());
|
||||
String value = dataValue.getValue();
|
||||
if (value.startsWith("0x")) {
|
||||
// 0xabcd
|
||||
return EasyStringUtils.quoteString(value.substring(2));
|
||||
} else {
|
||||
//example: hello,world
|
||||
// TODO: Need to optimize recognition of hexadecimal strings
|
||||
for (int i = 0; i < value.length(); i++) {
|
||||
char c = value.charAt(i);
|
||||
boolean isDigit = (c >= '0' && c <= '9');
|
||||
boolean isUpperCaseHex = (c >= 'A' && c <= 'F');
|
||||
boolean isLowerCaseHex = (c >= 'a' && c <= 'f');
|
||||
if (!isDigit && !isUpperCaseHex && !isLowerCaseHex) {
|
||||
return EasyStringUtils.quoteString(dataValue.getBlobHexString());
|
||||
}
|
||||
}
|
||||
// example: abcd1234
|
||||
return EasyStringUtils.quoteString(value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -34,4 +52,9 @@ public class OracleLongRawProcessor extends DefaultValueProcessor {
|
||||
return EasyStringUtils.quoteString(blobHexString);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
String value = "0x123456";
|
||||
value = value.substring(2);
|
||||
System.out.println("value = " + value);
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,24 @@ public class OracleRawValueProcessor extends DefaultValueProcessor {
|
||||
|
||||
@Override
|
||||
public String convertSQLValueByType(SQLDataValue dataValue) {
|
||||
return EasyStringUtils.quoteString(dataValue.getValue());
|
||||
String value = dataValue.getValue();
|
||||
if (value.startsWith("0x")) {
|
||||
// 0xabcd
|
||||
return EasyStringUtils.quoteString(value.substring(2));
|
||||
} else {
|
||||
//example: hello,world
|
||||
for (int i = 0; i < value.length(); i++) {
|
||||
char c = value.charAt(i);
|
||||
boolean isDigit = (c >= '0' && c <= '9');
|
||||
boolean isUpperCaseHex = (c >= 'A' && c <= 'F');
|
||||
boolean isLowerCaseHex = (c >= 'a' && c <= 'f');
|
||||
if (!isDigit && !isUpperCaseHex && !isLowerCaseHex) {
|
||||
return EasyStringUtils.quoteString(dataValue.getBlobHexString());
|
||||
}
|
||||
}
|
||||
// example: abcd1234
|
||||
return EasyStringUtils.quoteString(value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user