@Test(expected = SQLException.class) public void testAppendArgOrValueNull() throws Exception { cmpInt.appendArgOrValue(null, numberFieldType, new StringBuilder(), new ArrayList<ArgumentHolder>(), null); }
protected void appendArgOrValue(DatabaseType databaseType, FieldType fieldType, StringBuilder sb, List<ArgumentHolder> argList, Object argOrValue) throws SQLException { boolean appendSpace = true; if (argOrValue == null) { throw new SQLException("argument for '" + fieldType.getFieldName() + "' is null"); } else if (argOrValue instanceof ArgumentHolder) { sb.append('?'); ArgumentHolder argHolder = (ArgumentHolder) argOrValue; argHolder.setMetaInfo(columnName, fieldType); argList.add(argHolder); } else if (argOrValue instanceof ColumnArg) { ColumnArg columnArg = (ColumnArg) argOrValue; String tableName = columnArg.getTableName(); if (tableName != null) { databaseType.appendEscapedEntityName(sb, tableName); sb.append('.'); } databaseType.appendEscapedEntityName(sb, columnArg.getColumnName()); } else if (fieldType.isArgumentHolderRequired()) { sb.append('?'); ArgumentHolder argHolder = new SelectArg(); argHolder.setMetaInfo(columnName, fieldType); argHolder.setValue(argOrValue); argList.add(argHolder); } else if (fieldType.isForeign() && fieldType.getType().isAssignableFrom(argOrValue.getClass())) { FieldType idFieldType = fieldType.getForeignIdField(); appendArgOrValue(databaseType, idFieldType, sb, argList, idFieldType.extractJavaFieldValue(argOrValue)); appendSpace = false; } else if (fieldType.isEscapedValue()) { databaseType.appendEscapedWord(sb, fieldType.convertJavaFieldToSqlArgValue(argOrValue).toString()); } else if (fieldType.isForeign()) { String value = fieldType.convertJavaFieldToSqlArgValue(argOrValue).toString(); if (value.length() > 0) { if (NUMBER_CHARACTERS.indexOf(value.charAt(0)) < 0) { throw new SQLException("Foreign field " + fieldType + " does not seem to be producing a numerical value '" + value + "'. Maybe you are passing the wrong object to comparison: " + this); } } sb.append(value); } else { sb.append(fieldType.convertJavaFieldToSqlArgValue(argOrValue)); } if (appendSpace) { sb.append(' '); } }
BaseComparison implements Comparison { protected void appendArgOrValue(DatabaseType databaseType, FieldType fieldType, StringBuilder sb, List<ArgumentHolder> argList, Object argOrValue) throws SQLException { boolean appendSpace = true; if (argOrValue == null) { throw new SQLException("argument for '" + fieldType.getFieldName() + "' is null"); } else if (argOrValue instanceof ArgumentHolder) { sb.append('?'); ArgumentHolder argHolder = (ArgumentHolder) argOrValue; argHolder.setMetaInfo(columnName, fieldType); argList.add(argHolder); } else if (argOrValue instanceof ColumnArg) { ColumnArg columnArg = (ColumnArg) argOrValue; String tableName = columnArg.getTableName(); if (tableName != null) { databaseType.appendEscapedEntityName(sb, tableName); sb.append('.'); } databaseType.appendEscapedEntityName(sb, columnArg.getColumnName()); } else if (fieldType.isArgumentHolderRequired()) { sb.append('?'); ArgumentHolder argHolder = new SelectArg(); argHolder.setMetaInfo(columnName, fieldType); argHolder.setValue(argOrValue); argList.add(argHolder); } else if (fieldType.isForeign() && fieldType.getType().isAssignableFrom(argOrValue.getClass())) { FieldType idFieldType = fieldType.getForeignIdField(); appendArgOrValue(databaseType, idFieldType, sb, argList, idFieldType.extractJavaFieldValue(argOrValue)); appendSpace = false; } else if (fieldType.isEscapedValue()) { databaseType.appendEscapedWord(sb, fieldType.convertJavaFieldToSqlArgValue(argOrValue).toString()); } else if (fieldType.isForeign()) { String value = fieldType.convertJavaFieldToSqlArgValue(argOrValue).toString(); if (value.length() > 0) { if (NUMBER_CHARACTERS.indexOf(value.charAt(0)) < 0) { throw new SQLException("Foreign field " + fieldType + " does not seem to be producing a numerical value '" + value + "'. Maybe you are passing the wrong object to comparison: " + this); } } sb.append(value); } else { sb.append(fieldType.convertJavaFieldToSqlArgValue(argOrValue)); } if (appendSpace) { sb.append(' '); } } }
BaseComparison implements Comparison { protected void appendArgOrValue(DatabaseType databaseType, FieldType fieldType, StringBuilder sb, List<ArgumentHolder> argList, Object argOrValue) throws SQLException { boolean appendSpace = true; if (argOrValue == null) { throw new SQLException("argument for '" + fieldType.getFieldName() + "' is null"); } else if (argOrValue instanceof ArgumentHolder) { sb.append('?'); ArgumentHolder argHolder = (ArgumentHolder) argOrValue; argHolder.setMetaInfo(columnName, fieldType); argList.add(argHolder); } else if (argOrValue instanceof ColumnArg) { ColumnArg columnArg = (ColumnArg) argOrValue; String tableName = columnArg.getTableName(); if (tableName != null) { databaseType.appendEscapedEntityName(sb, tableName); sb.append('.'); } databaseType.appendEscapedEntityName(sb, columnArg.getColumnName()); } else if (fieldType.isArgumentHolderRequired()) { sb.append('?'); ArgumentHolder argHolder = new SelectArg(); argHolder.setMetaInfo(columnName, fieldType); argHolder.setValue(argOrValue); argList.add(argHolder); } else if (fieldType.isForeign() && fieldType.getType().isAssignableFrom(argOrValue.getClass())) { FieldType idFieldType = fieldType.getForeignIdField(); appendArgOrValue(databaseType, idFieldType, sb, argList, idFieldType.extractJavaFieldValue(argOrValue)); appendSpace = false; } else if (fieldType.isEscapedValue()) { databaseType.appendEscapedWord(sb, fieldType.convertJavaFieldToSqlArgValue(argOrValue).toString()); } else if (fieldType.isForeign()) { String value = fieldType.convertJavaFieldToSqlArgValue(argOrValue).toString(); if (value.length() > 0) { if (NUMBER_CHARACTERS.indexOf(value.charAt(0)) < 0) { throw new SQLException("Foreign field " + fieldType + " does not seem to be producing a numerical value '" + value + "'. Maybe you are passing the wrong object to comparison: " + this); } } sb.append(value); } else { sb.append(fieldType.convertJavaFieldToSqlArgValue(argOrValue)); } if (appendSpace) { sb.append(' '); } } protected  BaseComparison(String columnName, FieldType fieldType, Object value, boolean isComparison); }
BaseComparison implements Comparison { protected void appendArgOrValue(DatabaseType databaseType, FieldType fieldType, StringBuilder sb, List<ArgumentHolder> argList, Object argOrValue) throws SQLException { boolean appendSpace = true; if (argOrValue == null) { throw new SQLException("argument for '" + fieldType.getFieldName() + "' is null"); } else if (argOrValue instanceof ArgumentHolder) { sb.append('?'); ArgumentHolder argHolder = (ArgumentHolder) argOrValue; argHolder.setMetaInfo(columnName, fieldType); argList.add(argHolder); } else if (argOrValue instanceof ColumnArg) { ColumnArg columnArg = (ColumnArg) argOrValue; String tableName = columnArg.getTableName(); if (tableName != null) { databaseType.appendEscapedEntityName(sb, tableName); sb.append('.'); } databaseType.appendEscapedEntityName(sb, columnArg.getColumnName()); } else if (fieldType.isArgumentHolderRequired()) { sb.append('?'); ArgumentHolder argHolder = new SelectArg(); argHolder.setMetaInfo(columnName, fieldType); argHolder.setValue(argOrValue); argList.add(argHolder); } else if (fieldType.isForeign() && fieldType.getType().isAssignableFrom(argOrValue.getClass())) { FieldType idFieldType = fieldType.getForeignIdField(); appendArgOrValue(databaseType, idFieldType, sb, argList, idFieldType.extractJavaFieldValue(argOrValue)); appendSpace = false; } else if (fieldType.isEscapedValue()) { databaseType.appendEscapedWord(sb, fieldType.convertJavaFieldToSqlArgValue(argOrValue).toString()); } else if (fieldType.isForeign()) { String value = fieldType.convertJavaFieldToSqlArgValue(argOrValue).toString(); if (value.length() > 0) { if (NUMBER_CHARACTERS.indexOf(value.charAt(0)) < 0) { throw new SQLException("Foreign field " + fieldType + " does not seem to be producing a numerical value '" + value + "'. Maybe you are passing the wrong object to comparison: " + this); } } sb.append(value); } else { sb.append(fieldType.convertJavaFieldToSqlArgValue(argOrValue)); } if (appendSpace) { sb.append(' '); } } protected  BaseComparison(String columnName, FieldType fieldType, Object value, boolean isComparison); @Override abstract void appendOperation(StringBuilder sb); @Override void appendSql(DatabaseType databaseType, String tableName, StringBuilder sb, List<ArgumentHolder> argList); @Override String getColumnName(); @Override void appendValue(DatabaseType databaseType, StringBuilder sb, List<ArgumentHolder> argList); @Override String toString(); }
BaseComparison implements Comparison { protected void appendArgOrValue(DatabaseType databaseType, FieldType fieldType, StringBuilder sb, List<ArgumentHolder> argList, Object argOrValue) throws SQLException { boolean appendSpace = true; if (argOrValue == null) { throw new SQLException("argument for '" + fieldType.getFieldName() + "' is null"); } else if (argOrValue instanceof ArgumentHolder) { sb.append('?'); ArgumentHolder argHolder = (ArgumentHolder) argOrValue; argHolder.setMetaInfo(columnName, fieldType); argList.add(argHolder); } else if (argOrValue instanceof ColumnArg) { ColumnArg columnArg = (ColumnArg) argOrValue; String tableName = columnArg.getTableName(); if (tableName != null) { databaseType.appendEscapedEntityName(sb, tableName); sb.append('.'); } databaseType.appendEscapedEntityName(sb, columnArg.getColumnName()); } else if (fieldType.isArgumentHolderRequired()) { sb.append('?'); ArgumentHolder argHolder = new SelectArg(); argHolder.setMetaInfo(columnName, fieldType); argHolder.setValue(argOrValue); argList.add(argHolder); } else if (fieldType.isForeign() && fieldType.getType().isAssignableFrom(argOrValue.getClass())) { FieldType idFieldType = fieldType.getForeignIdField(); appendArgOrValue(databaseType, idFieldType, sb, argList, idFieldType.extractJavaFieldValue(argOrValue)); appendSpace = false; } else if (fieldType.isEscapedValue()) { databaseType.appendEscapedWord(sb, fieldType.convertJavaFieldToSqlArgValue(argOrValue).toString()); } else if (fieldType.isForeign()) { String value = fieldType.convertJavaFieldToSqlArgValue(argOrValue).toString(); if (value.length() > 0) { if (NUMBER_CHARACTERS.indexOf(value.charAt(0)) < 0) { throw new SQLException("Foreign field " + fieldType + " does not seem to be producing a numerical value '" + value + "'. Maybe you are passing the wrong object to comparison: " + this); } } sb.append(value); } else { sb.append(fieldType.convertJavaFieldToSqlArgValue(argOrValue)); } if (appendSpace) { sb.append(' '); } } protected  BaseComparison(String columnName, FieldType fieldType, Object value, boolean isComparison); @Override abstract void appendOperation(StringBuilder sb); @Override void appendSql(DatabaseType databaseType, String tableName, StringBuilder sb, List<ArgumentHolder> argList); @Override String getColumnName(); @Override void appendValue(DatabaseType databaseType, StringBuilder sb, List<ArgumentHolder> argList); @Override String toString();  }