Inconsistent String Comparisons, Applied patch for framework entity classes.
Thanks Devanshu Vyas for your contribution (OFBIZ-9254) git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1812257 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -1143,7 +1143,7 @@ public class GenericEntity implements Map<String, Object>, LocalizedMap<Object>,
|
||||
String name = modelField.getName();
|
||||
|
||||
String type = modelField.getType();
|
||||
if (type != null && type.equals("blob")) {
|
||||
if (type != null && "blob".equals(type)) {
|
||||
Object obj = get(name);
|
||||
boolean b1 = obj instanceof byte [];
|
||||
if (b1) {
|
||||
|
||||
@@ -856,7 +856,7 @@ public class GenericDAO {
|
||||
|
||||
protected StringBuilder makeOffsetString(StringBuilder offsetString, EntityFindOptions findOptions) {
|
||||
if (UtilValidate.isNotEmpty(datasource.getOffsetStyle())) {
|
||||
if (datasource.getOffsetStyle().equals("limit")) {
|
||||
if ("limit".equals(datasource.getOffsetStyle())) {
|
||||
// use the LIMIT/OFFSET style
|
||||
if (findOptions.getLimit() > -1) {
|
||||
offsetString.append(" LIMIT " + findOptions.getLimit());
|
||||
@@ -864,7 +864,7 @@ public class GenericDAO {
|
||||
offsetString.append(" OFFSET " + findOptions.getOffset());
|
||||
}
|
||||
}
|
||||
} else if (datasource.getOffsetStyle().equals("fetch")) {
|
||||
} else if ("fetch".equals(datasource.getOffsetStyle())) {
|
||||
// use SQL2008 OFFSET/FETCH style by default
|
||||
if (findOptions.getOffset() > -1) {
|
||||
offsetString.append(" OFFSET ").append(findOptions.getOffset()).append(" ROWS");
|
||||
|
||||
@@ -38,12 +38,12 @@ public class CursorConnection extends AbstractCursorHandler {
|
||||
}
|
||||
|
||||
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
|
||||
if (method.getName().equals("prepareStatement")) {
|
||||
if ("prepareStatement".equals(method.getName())) {
|
||||
System.err.println("prepareStatement");
|
||||
args[0] = "DECLARE " + cursorName + " CURSOR FOR " + args[0];
|
||||
PreparedStatement pstmt = (PreparedStatement) method.invoke(con, args);
|
||||
return CursorStatement.newCursorPreparedStatement(pstmt, cursorName, fetchSize);
|
||||
} else if (method.getName().equals("createStatement")) {
|
||||
} else if ("createStatement".equals(method.getName())) {
|
||||
System.err.println("createStatement");
|
||||
Statement stmt = (Statement) method.invoke(con, args);
|
||||
return CursorStatement.newCursorStatement(stmt, cursorName, fetchSize);
|
||||
|
||||
@@ -271,29 +271,29 @@ public final class ModelUtil {
|
||||
public static String induceFieldType(String sqlTypeName, int length, int precision, ModelFieldTypeReader fieldTypeReader) {
|
||||
if (sqlTypeName == null) return "invalid";
|
||||
|
||||
if (sqlTypeName.equalsIgnoreCase("VARCHAR") || sqlTypeName.equalsIgnoreCase("VARCHAR2") || (sqlTypeName.equalsIgnoreCase("CHAR") && length > 1)) {
|
||||
if ("VARCHAR".equalsIgnoreCase(sqlTypeName) || "VARCHAR2".equalsIgnoreCase(sqlTypeName) || ("CHAR".equalsIgnoreCase(sqlTypeName) && length > 1)) {
|
||||
if (length <= 10) return "very-short";
|
||||
if (length <= 60) return "short-varchar";
|
||||
if (length <= 255) return "long-varchar";
|
||||
return "very-long";
|
||||
} else if (sqlTypeName.equalsIgnoreCase("TEXT")) {
|
||||
} else if ("TEXT".equalsIgnoreCase(sqlTypeName)) {
|
||||
return "very-long";
|
||||
} else if (sqlTypeName.equalsIgnoreCase("INT") || sqlTypeName.equalsIgnoreCase("SMALLINT") ||
|
||||
sqlTypeName.equalsIgnoreCase("DECIMAL") || sqlTypeName.equalsIgnoreCase("NUMERIC")) {
|
||||
} else if ("INT".equalsIgnoreCase(sqlTypeName) || "SMALLINT".equalsIgnoreCase(sqlTypeName) ||
|
||||
"DECIMAL".equalsIgnoreCase(sqlTypeName) || "NUMERIC".equalsIgnoreCase(sqlTypeName)) {
|
||||
if (length > 18 || precision > 6) return "invalid-" + sqlTypeName + ":" + length + ":" + precision;
|
||||
if (precision == 0) return "numeric";
|
||||
if (precision == 2) return "currency-amount";
|
||||
if (precision <= 6) return "floating-point";
|
||||
return "invalid-" + sqlTypeName + ":" + length + ":" + precision;
|
||||
} else if (sqlTypeName.equalsIgnoreCase("BLOB") || sqlTypeName.equalsIgnoreCase("OID")) {
|
||||
} else if ("BLOB".equalsIgnoreCase(sqlTypeName) || "OID".equalsIgnoreCase(sqlTypeName)) {
|
||||
return "blob";
|
||||
} else if (sqlTypeName.equalsIgnoreCase("DATETIME") || sqlTypeName.equalsIgnoreCase("TIMESTAMP")) {
|
||||
} else if ("DATETIME".equalsIgnoreCase(sqlTypeName) || "TIMESTAMP".equalsIgnoreCase(sqlTypeName)) {
|
||||
return "date-time";
|
||||
} else if (sqlTypeName.equalsIgnoreCase("DATE")) {
|
||||
} else if ("DATE".equalsIgnoreCase(sqlTypeName)) {
|
||||
return "date";
|
||||
} else if (sqlTypeName.equalsIgnoreCase("TIME")) {
|
||||
} else if ("TIME".equalsIgnoreCase(sqlTypeName)) {
|
||||
return "time";
|
||||
} else if (sqlTypeName.equalsIgnoreCase("CHAR") && length == 1) {
|
||||
} else if ("CHAR".equalsIgnoreCase(sqlTypeName) && length == 1) {
|
||||
return "indicator";
|
||||
} else {
|
||||
return "invalid-" + sqlTypeName + ":" + length + ":" + precision;
|
||||
|
||||
@@ -293,7 +293,7 @@ public class XmlSerializer {
|
||||
public static Object deserializeSingle(Element element, Delegator delegator) throws SerializeException {
|
||||
String tagName = element.getLocalName();
|
||||
|
||||
if (tagName.equals("null")) return null;
|
||||
if ("null".equals(tagName)) return null;
|
||||
|
||||
if (tagName.startsWith("std-")) {
|
||||
// - Standard Objects -
|
||||
|
||||
@@ -953,7 +953,7 @@ public class EntityTestSuite extends EntityTestCase {
|
||||
/*public void testLimitOffsetOptions() throws Exception {
|
||||
String entityName = "Content";
|
||||
Datasource datasourceInfo = EntityConfig.getDatasource(delegator.getEntityHelper(entityName).getHelperName());
|
||||
if (UtilValidate.isEmpty(datasourceInfo.offsetStyle) || datasourceInfo.offsetStyle.equals("none")) {
|
||||
if (UtilValidate.isEmpty(datasourceInfo.offsetStyle) || "none".equals(datasourceInfo.offsetStyle)) {
|
||||
Debug.logInfo("The offset-stype configured in datasource is " + datasourceInfo.offsetStyle + ", this test is skipped.", module);
|
||||
return;
|
||||
} else {
|
||||
|
||||
@@ -374,7 +374,7 @@ public class EntitySaxReader extends DefaultHandler {
|
||||
ModelEntity modelEntity = currentValue.getModelEntity();
|
||||
ModelField modelField = modelEntity.getField(currentFieldName.toString());
|
||||
String type = modelField.getType();
|
||||
if (type != null && type.equals("blob")) {
|
||||
if (type != null && "blob".equals(type)) {
|
||||
byte[] binData = Base64.base64Decode((new String(currentFieldValue)).getBytes());
|
||||
currentValue.setBytes(currentFieldName.toString(), binData);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user