From Dave: a bunch of @Override annotating and some other cleanup.

This commit is contained in:
Michael Bayne
2008-08-06 12:59:06 +00:00
parent a0731b34c1
commit a48c93be4a
14 changed files with 104 additions and 128 deletions
@@ -42,7 +42,7 @@ public interface CacheInvalidator
public void invalidate (PersistenceContext ctx) { public void invalidate (PersistenceContext ctx) {
ctx.cacheTraverse(_cacheId, new PersistenceContext.CacheEvictionFilter<T>() { ctx.cacheTraverse(_cacheId, new PersistenceContext.CacheEvictionFilter<T>() {
protected boolean testForEviction (Serializable key, T record) { @Override protected boolean testForEviction (Serializable key, T record) {
return TraverseWithFilter.this.testForEviction(key, record); return TraverseWithFilter.this.testForEviction(key, record);
} }
}); });
@@ -565,7 +565,7 @@ public class DepotMarshaller<T extends PersistentRecord>
// check to see if our schema version table exists, create it if not // check to see if our schema version table exists, create it if not
ctx.invoke(new Modifier() { ctx.invoke(new Modifier() {
public int invoke (Connection conn, DatabaseLiaison liaison) throws SQLException { @Override public int invoke (Connection conn, DatabaseLiaison liaison) throws SQLException {
liaison.createTableIfMissing( liaison.createTableIfMissing(
conn, SCHEMA_VERSION_TABLE, conn, SCHEMA_VERSION_TABLE,
new String[] { "persistentClass", "version" }, new String[] { "persistentClass", "version" },
@@ -592,7 +592,7 @@ public class DepotMarshaller<T extends PersistentRecord>
} }
final Iterable<Index> indexen = _indexes.values(); final Iterable<Index> indexen = _indexes.values();
ctx.invoke(new Modifier() { ctx.invoke(new Modifier() {
public int invoke (Connection conn, DatabaseLiaison liaison) throws SQLException { @Override public int invoke (Connection conn, DatabaseLiaison liaison) throws SQLException {
// create the table // create the table
String[] primaryKeyColumns = null; String[] primaryKeyColumns = null;
if (_pkColumns != null) { if (_pkColumns != null) {
@@ -640,7 +640,7 @@ public class DepotMarshaller<T extends PersistentRecord>
// make sure the versions match // make sure the versions match
int currentVersion = ctx.invoke(new Modifier() { int currentVersion = ctx.invoke(new Modifier() {
public int invoke (Connection conn, DatabaseLiaison liaison) throws SQLException { @Override public int invoke (Connection conn, DatabaseLiaison liaison) throws SQLException {
String query = String query =
" select " + liaison.columnSQL("version") + " select " + liaison.columnSQL("version") +
" from " + liaison.tableSQL(SCHEMA_VERSION_TABLE) + " from " + liaison.tableSQL(SCHEMA_VERSION_TABLE) +
@@ -693,7 +693,7 @@ public class DepotMarshaller<T extends PersistentRecord>
final ColumnDefinition coldef = fmarsh.getColumnDefinition(); final ColumnDefinition coldef = fmarsh.getColumnDefinition();
log.info("Adding column to " + getTableName() + ": " + fmarsh.getColumnName()); log.info("Adding column to " + getTableName() + ": " + fmarsh.getColumnName());
ctx.invoke(new Modifier.Simple() { ctx.invoke(new Modifier.Simple() {
protected String createQuery (DatabaseLiaison liaison) { @Override protected String createQuery (DatabaseLiaison liaison) {
return "alter table " + liaison.tableSQL(getTableName()) + return "alter table " + liaison.tableSQL(getTableName()) +
" add column " + liaison.columnSQL(fmarsh.getColumnName()) + " " + " add column " + liaison.columnSQL(fmarsh.getColumnName()) + " " +
liaison.expandDefinition(coldef); liaison.expandDefinition(coldef);
@@ -709,7 +709,7 @@ public class DepotMarshaller<T extends PersistentRecord>
coldef.getType().equalsIgnoreCase("datetime"))) { coldef.getType().equalsIgnoreCase("datetime"))) {
log.info("Assigning current time to " + fmarsh.getColumnName() + "."); log.info("Assigning current time to " + fmarsh.getColumnName() + ".");
ctx.invoke(new Modifier.Simple() { ctx.invoke(new Modifier.Simple() {
protected String createQuery (DatabaseLiaison liaison) { @Override protected String createQuery (DatabaseLiaison liaison) {
// TODO: is NOW() standard SQL? // TODO: is NOW() standard SQL?
return "update " + liaison.tableSQL(getTableName()) + return "update " + liaison.tableSQL(getTableName()) +
" set " + liaison.columnSQL(fmarsh.getColumnName()) + " = NOW()"; " set " + liaison.columnSQL(fmarsh.getColumnName()) + " = NOW()";
@@ -722,7 +722,7 @@ public class DepotMarshaller<T extends PersistentRecord>
if (hasPrimaryKey() && metaData.pkName == null) { if (hasPrimaryKey() && metaData.pkName == null) {
log.info("Adding primary key."); log.info("Adding primary key.");
ctx.invoke(new Modifier() { ctx.invoke(new Modifier() {
public int invoke (Connection conn, DatabaseLiaison liaison) throws SQLException { @Override public int invoke (Connection conn, DatabaseLiaison liaison) throws SQLException {
liaison.addPrimaryKey( liaison.addPrimaryKey(
conn, getTableName(), fieldsToColumns(getPrimaryKeyFields())); conn, getTableName(), fieldsToColumns(getPrimaryKeyFields()));
return 0; return 0;
@@ -733,7 +733,7 @@ public class DepotMarshaller<T extends PersistentRecord>
final String pkName = metaData.pkName; final String pkName = metaData.pkName;
log.info("Dropping primary key: " + pkName); log.info("Dropping primary key: " + pkName);
ctx.invoke(new Modifier() { ctx.invoke(new Modifier() {
public int invoke (Connection conn, DatabaseLiaison liaison) throws SQLException { @Override public int invoke (Connection conn, DatabaseLiaison liaison) throws SQLException {
liaison.dropPrimaryKey(conn, getTableName(), pkName); liaison.dropPrimaryKey(conn, getTableName(), pkName);
return 0; return 0;
} }
@@ -750,7 +750,7 @@ public class DepotMarshaller<T extends PersistentRecord>
} }
// but this is a new, named index, so we create it // but this is a new, named index, so we create it
ctx.invoke(new Modifier() { ctx.invoke(new Modifier() {
public int invoke (Connection conn, DatabaseLiaison liaison) throws SQLException { @Override public int invoke (Connection conn, DatabaseLiaison liaison) throws SQLException {
liaison.addIndexToTable( liaison.addIndexToTable(
conn, getTableName(), fieldsToColumns(index.fields()), conn, getTableName(), fieldsToColumns(index.fields()),
ixName, index.unique()); ixName, index.unique());
@@ -785,7 +785,7 @@ public class DepotMarshaller<T extends PersistentRecord>
final String[] colArr = colSet.toArray(new String[colSet.size()]); final String[] colArr = colSet.toArray(new String[colSet.size()]);
final String fName = indexName; final String fName = indexName;
ctx.invoke(new Modifier() { ctx.invoke(new Modifier() {
public int invoke (Connection conn, DatabaseLiaison liaison) throws SQLException { @Override public int invoke (Connection conn, DatabaseLiaison liaison) throws SQLException {
liaison.addIndexToTable(conn, getTableName(), colArr, fName, true); liaison.addIndexToTable(conn, getTableName(), colArr, fName, true);
return 0; return 0;
} }
@@ -806,7 +806,7 @@ public class DepotMarshaller<T extends PersistentRecord>
// but not this one, so let's create it // but not this one, so let's create it
ctx.invoke(new Modifier() { ctx.invoke(new Modifier() {
public int invoke (Connection conn, DatabaseLiaison liaison) throws SQLException { @Override public int invoke (Connection conn, DatabaseLiaison liaison) throws SQLException {
builder.addFullTextSearch(conn, DepotMarshaller.this, recordFts); builder.addFullTextSearch(conn, DepotMarshaller.this, recordFts);
return 0; return 0;
} }
@@ -832,7 +832,7 @@ public class DepotMarshaller<T extends PersistentRecord>
// last of all (re-)initialize our value generators, since one might've been added // last of all (re-)initialize our value generators, since one might've been added
if (_valueGenerators.size() > 0) { if (_valueGenerators.size() > 0) {
ctx.invoke(new Modifier() { ctx.invoke(new Modifier() {
public int invoke (Connection conn, DatabaseLiaison liaison) throws SQLException { @Override public int invoke (Connection conn, DatabaseLiaison liaison) throws SQLException {
for (ValueGenerator vg : _valueGenerators.values()) { for (ValueGenerator vg : _valueGenerators.values()) {
vg.init(conn, liaison); vg.init(conn, liaison);
} }
@@ -843,7 +843,7 @@ public class DepotMarshaller<T extends PersistentRecord>
// record our new version in the database // record our new version in the database
ctx.invoke(new Modifier() { ctx.invoke(new Modifier() {
public int invoke (Connection conn, DatabaseLiaison liaison) throws SQLException { @Override public int invoke (Connection conn, DatabaseLiaison liaison) throws SQLException {
updateVersion(conn, liaison, _schemaVersion); updateVersion(conn, liaison, _schemaVersion);
return 0; return 0;
} }
@@ -916,7 +916,7 @@ public class DepotMarshaller<T extends PersistentRecord>
throws PersistenceException throws PersistenceException
{ {
return ctx.invoke(new Query.TrivialQuery<TableMetaData>() { return ctx.invoke(new Query.TrivialQuery<TableMetaData>() {
public TableMetaData invoke (Connection conn, DatabaseLiaison dl) @Override public TableMetaData invoke (Connection conn, DatabaseLiaison dl)
throws SQLException { throws SQLException {
return new TableMetaData(conn.getMetaData(), tableName); return new TableMetaData(conn.getMetaData(), tableName);
} }
@@ -187,7 +187,7 @@ public abstract class DepotRepository
// key will be null if record was supplied without a primary key // key will be null if record was supplied without a primary key
return _ctx.invoke(new CachingModifier<T>(record, key, key) { return _ctx.invoke(new CachingModifier<T>(record, key, key) {
public int invoke (Connection conn, DatabaseLiaison liaison) throws SQLException { @Override public int invoke (Connection conn, DatabaseLiaison liaison) throws SQLException {
// set any auto-generated column values // set any auto-generated column values
Set<String> identityFields = Set<String> identityFields =
marsh.generateFieldValues(conn, liaison, _result, false); marsh.generateFieldValues(conn, liaison, _result, false);
@@ -241,7 +241,7 @@ public abstract class DepotRepository
builder.newQuery(update); builder.newQuery(update);
return _ctx.invoke(new CachingModifier<T>(record, key, key) { return _ctx.invoke(new CachingModifier<T>(record, key, key) {
public int invoke (Connection conn, DatabaseLiaison liaison) throws SQLException { @Override public int invoke (Connection conn, DatabaseLiaison liaison) throws SQLException {
PreparedStatement stmt = builder.prepare(conn); PreparedStatement stmt = builder.prepare(conn);
try { try {
return stmt.executeUpdate(); return stmt.executeUpdate();
@@ -282,7 +282,7 @@ public abstract class DepotRepository
builder.newQuery(update); builder.newQuery(update);
return _ctx.invoke(new CachingModifier<T>(record, key, key) { return _ctx.invoke(new CachingModifier<T>(record, key, key) {
public int invoke (Connection conn, DatabaseLiaison liaison) throws SQLException { @Override public int invoke (Connection conn, DatabaseLiaison liaison) throws SQLException {
PreparedStatement stmt = builder.prepare(conn); PreparedStatement stmt = builder.prepare(conn);
// clear out _result so that we don't rewrite this partial record to the cache // clear out _result so that we don't rewrite this partial record to the cache
_result = null; _result = null;
@@ -424,7 +424,7 @@ public abstract class DepotRepository
builder.newQuery(update); builder.newQuery(update);
return _ctx.invoke(new Modifier(invalidator) { return _ctx.invoke(new Modifier(invalidator) {
public int invoke (Connection conn, DatabaseLiaison liaison) throws SQLException { @Override public int invoke (Connection conn, DatabaseLiaison liaison) throws SQLException {
PreparedStatement stmt = builder.prepare(conn); PreparedStatement stmt = builder.prepare(conn);
try { try {
return stmt.executeUpdate(); return stmt.executeUpdate();
@@ -556,7 +556,7 @@ public abstract class DepotRepository
builder.newQuery(update); builder.newQuery(update);
return _ctx.invoke(new Modifier(invalidator) { return _ctx.invoke(new Modifier(invalidator) {
public int invoke (Connection conn, DatabaseLiaison liaison) throws SQLException { @Override public int invoke (Connection conn, DatabaseLiaison liaison) throws SQLException {
PreparedStatement stmt = builder.prepare(conn); PreparedStatement stmt = builder.prepare(conn);
try { try {
return stmt.executeUpdate(); return stmt.executeUpdate();
@@ -593,7 +593,7 @@ public abstract class DepotRepository
final boolean[] created = new boolean[1]; final boolean[] created = new boolean[1];
_ctx.invoke(new CachingModifier<T>(record, key, key) { _ctx.invoke(new CachingModifier<T>(record, key, key) {
public int invoke (Connection conn, DatabaseLiaison liaison) throws SQLException { @Override public int invoke (Connection conn, DatabaseLiaison liaison) throws SQLException {
PreparedStatement stmt = null; PreparedStatement stmt = null;
try { try {
if (_key != null) { if (_key != null) {
@@ -701,7 +701,7 @@ public abstract class DepotRepository
builder.newQuery(delete); builder.newQuery(delete);
return _ctx.invoke(new Modifier(invalidator) { return _ctx.invoke(new Modifier(invalidator) {
public int invoke (Connection conn, DatabaseLiaison liaison) throws SQLException { @Override public int invoke (Connection conn, DatabaseLiaison liaison) throws SQLException {
PreparedStatement stmt = builder.prepare(conn); PreparedStatement stmt = builder.prepare(conn);
try { try {
return stmt.executeUpdate(); return stmt.executeUpdate();
@@ -79,7 +79,7 @@ public class EHCacheAdapter
public T getValue () { public T getValue () {
return value; return value;
} }
public String toString () { @Override public String toString () {
return String.valueOf(value); return String.valueOf(value);
} }
}; };
@@ -147,17 +147,17 @@ public class EHCacheAdapter
/** A class to represent an explicitly Serializable concept of null for EHCache. */ /** A class to represent an explicitly Serializable concept of null for EHCache. */
protected static class NullValue implements Serializable protected static class NullValue implements Serializable
{ {
public String toString () @Override public String toString ()
{ {
return "<EHCache Null>"; return "<EHCache Null>";
} }
public boolean equals (Object other) @Override public boolean equals (Object other)
{ {
return other != null && other.getClass().equals(NullValue.class); return other != null && other.getClass().equals(NullValue.class);
} }
public int hashCode () @Override public int hashCode ()
{ {
return 1; return 1;
} }
@@ -47,7 +47,7 @@ public abstract class EntityMigration extends Modifier
_columnName = columnName; _columnName = columnName;
} }
public int invoke (Connection conn, DatabaseLiaison liaison) throws SQLException { @Override public int invoke (Connection conn, DatabaseLiaison liaison) throws SQLException {
if (!liaison.tableContainsColumn(conn, _tableName, _columnName)) { if (!liaison.tableContainsColumn(conn, _tableName, _columnName)) {
// we'll accept this inconsistency // we'll accept this inconsistency
log.warning(_tableName + "." + _columnName + " already dropped."); log.warning(_tableName + "." + _columnName + " already dropped.");
@@ -72,7 +72,7 @@ public abstract class EntityMigration extends Modifier
_newColumnName = newColumnName; _newColumnName = newColumnName;
} }
public int invoke (Connection conn, DatabaseLiaison liaison) throws SQLException { @Override public int invoke (Connection conn, DatabaseLiaison liaison) throws SQLException {
if (!liaison.tableContainsColumn(conn, _tableName, _oldColumnName)) { if (!liaison.tableContainsColumn(conn, _tableName, _oldColumnName)) {
if (liaison.tableContainsColumn(conn, _tableName, _newColumnName)) { if (liaison.tableContainsColumn(conn, _tableName, _newColumnName)) {
// we'll accept this inconsistency // we'll accept this inconsistency
@@ -97,11 +97,11 @@ public abstract class EntityMigration extends Modifier
conn, _tableName, _oldColumnName, _newColumnName, _newColumnDef) ? 1 : 0; conn, _tableName, _oldColumnName, _newColumnName, _newColumnDef) ? 1 : 0;
} }
public boolean runBeforeDefault () { @Override public boolean runBeforeDefault () {
return true; return true;
} }
protected void init (String tableName, Map<String,FieldMarshaller<?>> marshallers) { @Override protected void init (String tableName, Map<String,FieldMarshaller<?>> marshallers) {
super.init(tableName, marshallers); super.init(tableName, marshallers);
_newColumnDef = marshallers.get(_newColumnName).getColumnDefinition(); _newColumnDef = marshallers.get(_newColumnName).getColumnDefinition();
} }
@@ -122,18 +122,18 @@ public abstract class EntityMigration extends Modifier
_fieldName = fieldName; _fieldName = fieldName;
} }
public int invoke (Connection conn, DatabaseLiaison liaison) throws SQLException { @Override public int invoke (Connection conn, DatabaseLiaison liaison) throws SQLException {
log.info("Updating type of '" + _fieldName + "' in " + _tableName); log.info("Updating type of '" + _fieldName + "' in " + _tableName);
return liaison.changeColumn(conn, _tableName, _fieldName, _newColumnDef.getType(), return liaison.changeColumn(conn, _tableName, _fieldName, _newColumnDef.getType(),
_newColumnDef.isNullable(), _newColumnDef.isUnique(), _newColumnDef.isNullable(), _newColumnDef.isUnique(),
_newColumnDef.getDefaultValue()) ? 1 : 0; _newColumnDef.getDefaultValue()) ? 1 : 0;
} }
public boolean runBeforeDefault () { @Override public boolean runBeforeDefault () {
return false; return false;
} }
protected void init (String tableName, Map<String,FieldMarshaller<?>> marshallers) { @Override protected void init (String tableName, Map<String,FieldMarshaller<?>> marshallers) {
super.init(tableName, marshallers); super.init(tableName, marshallers);
_columnName = marshallers.get(_fieldName).getColumnName(); _columnName = marshallers.get(_fieldName).getColumnName();
_newColumnDef = marshallers.get(_fieldName).getColumnDefinition(); _newColumnDef = marshallers.get(_fieldName).getColumnDefinition();
@@ -227,190 +227,190 @@ public abstract class FieldMarshaller<T>
} }
protected static class BooleanMarshaller extends FieldMarshaller<Boolean> { protected static class BooleanMarshaller extends FieldMarshaller<Boolean> {
public Boolean getFromObject (Object po) @Override public Boolean getFromObject (Object po)
throws IllegalArgumentException, IllegalAccessException { throws IllegalArgumentException, IllegalAccessException {
return _field.getBoolean(po); return _field.getBoolean(po);
} }
public Boolean getFromSet (ResultSet rs) @Override public Boolean getFromSet (ResultSet rs)
throws SQLException { throws SQLException {
return rs.getBoolean(getColumnName()); return rs.getBoolean(getColumnName());
} }
public void writeToObject (Object po, Boolean value) @Override public void writeToObject (Object po, Boolean value)
throws IllegalArgumentException, IllegalAccessException { throws IllegalArgumentException, IllegalAccessException {
_field.setBoolean(po, value); _field.setBoolean(po, value);
} }
public void writeToStatement (PreparedStatement ps, int column, Boolean value) @Override public void writeToStatement (PreparedStatement ps, int column, Boolean value)
throws SQLException { throws SQLException {
ps.setBoolean(column, value); ps.setBoolean(column, value);
} }
} }
protected static class ByteMarshaller extends FieldMarshaller<Byte> { protected static class ByteMarshaller extends FieldMarshaller<Byte> {
public Byte getFromObject (Object po) @Override public Byte getFromObject (Object po)
throws IllegalArgumentException, IllegalAccessException { throws IllegalArgumentException, IllegalAccessException {
return _field.getByte(po); return _field.getByte(po);
} }
public Byte getFromSet (ResultSet rs) @Override public Byte getFromSet (ResultSet rs)
throws SQLException { throws SQLException {
return rs.getByte(getColumnName()); return rs.getByte(getColumnName());
} }
public void writeToObject (Object po, Byte value) @Override public void writeToObject (Object po, Byte value)
throws IllegalArgumentException, IllegalAccessException { throws IllegalArgumentException, IllegalAccessException {
_field.setByte(po, value); _field.setByte(po, value);
} }
public void writeToStatement (PreparedStatement ps, int column, Byte value) @Override public void writeToStatement (PreparedStatement ps, int column, Byte value)
throws SQLException { throws SQLException {
ps.setByte(column, value); ps.setByte(column, value);
} }
} }
protected static class ShortMarshaller extends FieldMarshaller<Short> { protected static class ShortMarshaller extends FieldMarshaller<Short> {
public Short getFromObject (Object po) @Override public Short getFromObject (Object po)
throws IllegalArgumentException, IllegalAccessException { throws IllegalArgumentException, IllegalAccessException {
return _field.getShort(po); return _field.getShort(po);
} }
public Short getFromSet (ResultSet rs) @Override public Short getFromSet (ResultSet rs)
throws SQLException { throws SQLException {
return rs.getShort(getColumnName()); return rs.getShort(getColumnName());
} }
public void writeToObject (Object po, Short value) @Override public void writeToObject (Object po, Short value)
throws IllegalArgumentException, IllegalAccessException { throws IllegalArgumentException, IllegalAccessException {
_field.setShort(po, value); _field.setShort(po, value);
} }
public void writeToStatement (PreparedStatement ps, int column, Short value) @Override public void writeToStatement (PreparedStatement ps, int column, Short value)
throws SQLException { throws SQLException {
ps.setShort(column, value); ps.setShort(column, value);
} }
} }
protected static class IntMarshaller extends FieldMarshaller<Integer> { protected static class IntMarshaller extends FieldMarshaller<Integer> {
public Integer getFromObject (Object po) @Override public Integer getFromObject (Object po)
throws IllegalArgumentException, IllegalAccessException { throws IllegalArgumentException, IllegalAccessException {
return _field.getInt(po); return _field.getInt(po);
} }
public Integer getFromSet (ResultSet rs) @Override public Integer getFromSet (ResultSet rs)
throws SQLException { throws SQLException {
return rs.getInt(getColumnName()); return rs.getInt(getColumnName());
} }
public void writeToObject (Object po, Integer value) @Override public void writeToObject (Object po, Integer value)
throws IllegalArgumentException, IllegalAccessException { throws IllegalArgumentException, IllegalAccessException {
_field.setInt(po, value); _field.setInt(po, value);
} }
public void writeToStatement (PreparedStatement ps, int column, Integer value) @Override public void writeToStatement (PreparedStatement ps, int column, Integer value)
throws SQLException { throws SQLException {
ps.setInt(column, value); ps.setInt(column, value);
} }
} }
protected static class LongMarshaller extends FieldMarshaller<Long> { protected static class LongMarshaller extends FieldMarshaller<Long> {
public Long getFromObject (Object po) @Override public Long getFromObject (Object po)
throws IllegalArgumentException, IllegalAccessException { throws IllegalArgumentException, IllegalAccessException {
return _field.getLong(po); return _field.getLong(po);
} }
public Long getFromSet (ResultSet rs) @Override public Long getFromSet (ResultSet rs)
throws SQLException { throws SQLException {
return rs.getLong(getColumnName()); return rs.getLong(getColumnName());
} }
public void writeToObject (Object po, Long value) @Override public void writeToObject (Object po, Long value)
throws IllegalArgumentException, IllegalAccessException { throws IllegalArgumentException, IllegalAccessException {
_field.setLong(po, value); _field.setLong(po, value);
} }
public void writeToStatement (PreparedStatement ps, int column, Long value) @Override public void writeToStatement (PreparedStatement ps, int column, Long value)
throws SQLException { throws SQLException {
ps.setLong(column, value); ps.setLong(column, value);
} }
} }
protected static class FloatMarshaller extends FieldMarshaller<Float> { protected static class FloatMarshaller extends FieldMarshaller<Float> {
public Float getFromObject (Object po) @Override public Float getFromObject (Object po)
throws IllegalArgumentException, IllegalAccessException { throws IllegalArgumentException, IllegalAccessException {
return _field.getFloat(po); return _field.getFloat(po);
} }
public Float getFromSet (ResultSet rs) @Override public Float getFromSet (ResultSet rs)
throws SQLException { throws SQLException {
return rs.getFloat(getColumnName()); return rs.getFloat(getColumnName());
} }
public void writeToObject (Object po, Float value) @Override public void writeToObject (Object po, Float value)
throws IllegalArgumentException, IllegalAccessException { throws IllegalArgumentException, IllegalAccessException {
_field.setFloat(po, value); _field.setFloat(po, value);
} }
public void writeToStatement (PreparedStatement ps, int column, Float value) @Override public void writeToStatement (PreparedStatement ps, int column, Float value)
throws SQLException { throws SQLException {
ps.setFloat(column, value); ps.setFloat(column, value);
} }
} }
protected static class DoubleMarshaller extends FieldMarshaller<Double> { protected static class DoubleMarshaller extends FieldMarshaller<Double> {
public Double getFromObject (Object po) @Override public Double getFromObject (Object po)
throws IllegalArgumentException, IllegalAccessException { throws IllegalArgumentException, IllegalAccessException {
return _field.getDouble(po); return _field.getDouble(po);
} }
public Double getFromSet (ResultSet rs) @Override public Double getFromSet (ResultSet rs)
throws SQLException { throws SQLException {
return rs.getDouble(getColumnName()); return rs.getDouble(getColumnName());
} }
public void writeToObject (Object po, Double value) @Override public void writeToObject (Object po, Double value)
throws IllegalArgumentException, IllegalAccessException { throws IllegalArgumentException, IllegalAccessException {
_field.setDouble(po, value); _field.setDouble(po, value);
} }
public void writeToStatement (PreparedStatement ps, int column, Double value) @Override public void writeToStatement (PreparedStatement ps, int column, Double value)
throws SQLException { throws SQLException {
ps.setDouble(column, value); ps.setDouble(column, value);
} }
} }
protected static class ObjectMarshaller extends FieldMarshaller<Object> { protected static class ObjectMarshaller extends FieldMarshaller<Object> {
public Object getFromObject (Object po) @Override public Object getFromObject (Object po)
throws IllegalArgumentException, IllegalAccessException { throws IllegalArgumentException, IllegalAccessException {
return _field.get(po); return _field.get(po);
} }
public Object getFromSet (ResultSet rs) @Override public Object getFromSet (ResultSet rs)
throws SQLException { throws SQLException {
return rs.getObject(getColumnName()); return rs.getObject(getColumnName());
} }
public void writeToObject (Object po, Object value) @Override public void writeToObject (Object po, Object value)
throws IllegalArgumentException, IllegalAccessException { throws IllegalArgumentException, IllegalAccessException {
_field.set(po, value); _field.set(po, value);
} }
public void writeToStatement (PreparedStatement ps, int column, Object value) @Override public void writeToStatement (PreparedStatement ps, int column, Object value)
throws SQLException { throws SQLException {
ps.setObject(column, value); ps.setObject(column, value);
} }
} }
protected static class ByteArrayMarshaller extends FieldMarshaller<byte[]> { protected static class ByteArrayMarshaller extends FieldMarshaller<byte[]> {
public byte[] getFromObject (Object po) @Override public byte[] getFromObject (Object po)
throws IllegalArgumentException, IllegalAccessException { throws IllegalArgumentException, IllegalAccessException {
return (byte[]) _field.get(po); return (byte[]) _field.get(po);
} }
public byte[] getFromSet (ResultSet rs) @Override public byte[] getFromSet (ResultSet rs)
throws SQLException { throws SQLException {
return rs.getBytes(getColumnName()); return rs.getBytes(getColumnName());
} }
public void writeToObject (Object po, byte[] value) @Override public void writeToObject (Object po, byte[] value)
throws IllegalArgumentException, IllegalAccessException { throws IllegalArgumentException, IllegalAccessException {
_field.set(po, value); _field.set(po, value);
} }
public void writeToStatement (PreparedStatement ps, int column, byte[] value) @Override public void writeToStatement (PreparedStatement ps, int column, byte[] value)
throws SQLException { throws SQLException {
ps.setBytes(column, value); ps.setBytes(column, value);
} }
} }
protected static class IntArrayMarshaller extends FieldMarshaller<int[]> { protected static class IntArrayMarshaller extends FieldMarshaller<int[]> {
public int[] getFromObject (Object po) @Override public int[] getFromObject (Object po)
throws IllegalArgumentException, IllegalAccessException { throws IllegalArgumentException, IllegalAccessException {
return (int[]) _field.get(po); return (int[]) _field.get(po);
} }
public int[] getFromSet (ResultSet rs) @Override public int[] getFromSet (ResultSet rs)
throws SQLException { throws SQLException {
return (int[]) rs.getObject(getColumnName()); return (int[]) rs.getObject(getColumnName());
} }
public void writeToObject (Object po, int[] value) @Override public void writeToObject (Object po, int[] value)
throws IllegalArgumentException, IllegalAccessException { throws IllegalArgumentException, IllegalAccessException {
_field.set(po, value); _field.set(po, value);
} }
public void writeToStatement (PreparedStatement ps, int column, int[] value) @Override public void writeToStatement (PreparedStatement ps, int column, int[] value)
throws SQLException { throws SQLException {
ps.setObject(column, value); ps.setObject(column, value);
} }
@@ -431,11 +431,11 @@ public abstract class FieldMarshaller<T>
} }
} }
public ByteEnum getFromObject (Object po) @Override public ByteEnum getFromObject (Object po)
throws IllegalArgumentException, IllegalAccessException { throws IllegalArgumentException, IllegalAccessException {
return (ByteEnum) _field.get(po); return (ByteEnum) _field.get(po);
} }
public ByteEnum getFromSet (ResultSet rs) @Override public ByteEnum getFromSet (ResultSet rs)
throws SQLException { throws SQLException {
try { try {
return (ByteEnum) _factmeth.invoke(null, rs.getByte(getColumnName())); return (ByteEnum) _factmeth.invoke(null, rs.getByte(getColumnName()));
@@ -445,11 +445,11 @@ public abstract class FieldMarshaller<T>
throw new RuntimeException(e); throw new RuntimeException(e);
} }
} }
public void writeToObject (Object po, ByteEnum value) @Override public void writeToObject (Object po, ByteEnum value)
throws IllegalArgumentException, IllegalAccessException { throws IllegalArgumentException, IllegalAccessException {
_field.set(po, value); _field.set(po, value);
} }
public void writeToStatement (PreparedStatement ps, int column, ByteEnum value) @Override public void writeToStatement (PreparedStatement ps, int column, ByteEnum value)
throws SQLException { throws SQLException {
ps.setByte(column, value.toByte()); ps.setByte(column, value.toByte());
} }
+2 -4
View File
@@ -75,8 +75,7 @@ public class Key<T extends PersistentRecord> extends WhereClause
return _values; return _values;
} }
@Override @Override public boolean equals (Object obj)
public boolean equals (Object obj)
{ {
if (this == obj) { if (this == obj) {
return true; return true;
@@ -88,8 +87,7 @@ public class Key<T extends PersistentRecord> extends WhereClause
return _pClass == other._pClass && _values.equals(other.getValues()); return _pClass == other._pClass && _values.equals(other.getValues());
} }
@Override @Override public int hashCode ()
public int hashCode ()
{ {
return _pClass.hashCode() ^ _values.hashCode(); return _pClass.hashCode() ^ _values.hashCode();
} }
@@ -41,7 +41,7 @@ public abstract class Modifier
super(null); super(null);
} }
public int invoke (Connection conn, DatabaseLiaison liaison) throws SQLException { @Override public int invoke (Connection conn, DatabaseLiaison liaison) throws SQLException {
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
try { try {
return stmt.executeUpdate(createQuery(liaison)); return stmt.executeUpdate(createQuery(liaison));
@@ -56,8 +56,7 @@ public class MySQLBuilder
{ {
public class MSBuildVisitor extends BuildVisitor public class MSBuildVisitor extends BuildVisitor
{ {
@Override @Override public void visit (FullTextMatch match)
public void visit (FullTextMatch match)
throws Exception throws Exception
{ {
_builder.append("match("); _builder.append("match(");
@@ -73,8 +72,7 @@ public class MySQLBuilder
_builder.append(") against (? in boolean mode)"); _builder.append(") against (? in boolean mode)");
} }
@Override @Override public void visit (DeleteClause<? extends PersistentRecord> deleteClause)
public void visit (DeleteClause<? extends PersistentRecord> deleteClause)
throws Exception throws Exception
{ {
_builder.append("delete from "); _builder.append("delete from ");
@@ -104,17 +102,17 @@ public class MySQLBuilder
super(types); super(types);
} }
protected void appendTableName (Class<? extends PersistentRecord> type) @Override protected void appendTableName (Class<? extends PersistentRecord> type)
{ {
_builder.append(_types.getTableName(type)); _builder.append(_types.getTableName(type));
} }
protected void appendTableAbbreviation (Class<? extends PersistentRecord> type) @Override protected void appendTableAbbreviation (Class<? extends PersistentRecord> type)
{ {
_builder.append(_types.getTableAbbreviation(type)); _builder.append(_types.getTableAbbreviation(type));
} }
protected void appendIdentifier (String field) @Override protected void appendIdentifier (String field)
{ {
_builder.append(field); _builder.append(field);
} }
@@ -127,8 +125,7 @@ public class MySQLBuilder
super(types, stmt); super(types, stmt);
} }
@Override @Override public void visit (FullTextMatch match)
public void visit (FullTextMatch match)
throws Exception throws Exception
{ {
_stmt.setString(_argIdx ++, match.getQuery()); _stmt.setString(_argIdx ++, match.getQuery());
@@ -58,8 +58,7 @@ public class PostgreSQLBuilder
{ {
public class PGBuildVisitor extends BuildVisitor public class PGBuildVisitor extends BuildVisitor
{ {
@Override @Override public void visit (FullTextMatch match)
public void visit (FullTextMatch match)
throws Exception throws Exception
{ {
appendIdentifier("ftsCol_" + match.getName()); appendIdentifier("ftsCol_" + match.getName());
@@ -79,7 +78,7 @@ public class PostgreSQLBuilder
super(types); super(types);
} }
protected void appendIdentifier (String field) @Override protected void appendIdentifier (String field)
{ {
_builder.append("\"").append(field).append("\""); _builder.append("\"").append(field).append("\"");
} }
@@ -87,8 +86,7 @@ public class PostgreSQLBuilder
public class PGBindVisitor extends BindVisitor public class PGBindVisitor extends BindVisitor
{ {
@Override @Override public void visit (FullTextMatch match)
public void visit (FullTextMatch match)
throws Exception throws Exception
{ {
// The tsearch2 engine takes queries on the form // The tsearch2 engine takes queries on the form
@@ -42,8 +42,7 @@ public abstract class Arithmetic
super(column, value); super(column, value);
} }
@Override @Override public String operator()
public String operator()
{ {
return "+"; return "+";
} }
@@ -62,8 +61,7 @@ public abstract class Arithmetic
super(column, value); super(column, value);
} }
@Override @Override public String operator()
public String operator()
{ {
return "-"; return "-";
} }
@@ -82,8 +80,7 @@ public abstract class Arithmetic
super(column, value); super(column, value);
} }
@Override @Override public String operator()
public String operator()
{ {
return "*"; return "*";
} }
@@ -102,8 +99,7 @@ public abstract class Arithmetic
super(column, value); super(column, value);
} }
@Override @Override public String operator()
public String operator()
{ {
return " / "; // Pad with spaces to work-around a MySQL bug. return " / "; // Pad with spaces to work-around a MySQL bug.
} }
@@ -122,8 +118,7 @@ public abstract class Arithmetic
super(column, value); super(column, value);
} }
@Override @Override public String operator()
public String operator()
{ {
return "&"; return "&";
} }
@@ -142,8 +137,7 @@ public abstract class Arithmetic
super(column, value); super(column, value);
} }
@Override @Override public String operator()
public String operator()
{ {
return "|"; return "|";
} }
@@ -85,8 +85,7 @@ public abstract class Conditionals
super(column, value); super(column, value);
} }
@Override @Override public String operator()
public String operator()
{ {
return "="; return "=";
} }
@@ -105,8 +104,7 @@ public abstract class Conditionals
super(column, value); super(column, value);
} }
@Override @Override public String operator()
public String operator()
{ {
return "!="; return "!=";
} }
@@ -125,8 +123,7 @@ public abstract class Conditionals
super(column, value); super(column, value);
} }
@Override @Override public String operator()
public String operator()
{ {
return "<"; return "<";
} }
@@ -145,8 +142,7 @@ public abstract class Conditionals
super(column, value); super(column, value);
} }
@Override @Override public String operator()
public String operator()
{ {
return "<="; return "<=";
} }
@@ -165,8 +161,7 @@ public abstract class Conditionals
super(column, value); super(column, value);
} }
@Override @Override public String operator()
public String operator()
{ {
return ">"; return ">";
} }
@@ -185,8 +180,7 @@ public abstract class Conditionals
super(column, value); super(column, value);
} }
@Override @Override public String operator()
public String operator()
{ {
return ">="; return ">=";
} }
@@ -260,8 +254,7 @@ public abstract class Conditionals
super(column, value); super(column, value);
} }
@Override @Override public String operator()
public String operator()
{ {
return " like "; return " like ";
} }
@@ -47,8 +47,7 @@ public abstract class Logic
super(conditions); super(conditions);
} }
@Override @Override public String operator()
public String operator()
{ {
return "or"; return "or";
} }
@@ -69,8 +68,7 @@ public abstract class Logic
super(conditions); super(conditions);
} }
@Override @Override public String operator()
public String operator()
{ {
return "and"; return "and";
} }
@@ -78,9 +78,7 @@ public class GenRecordTask extends Task
_cloader = ClasspathUtils.getClassLoaderForPath(getProject(), pathref); _cloader = ClasspathUtils.getClassLoaderForPath(getProject(), pathref);
} }
/** @Override
* Performs the actual work of the task.
*/
public void execute () throws BuildException public void execute () throws BuildException
{ {
if (_cloader == null) { if (_cloader == null) {