Le metric crapload of generics cleanup.

git-svn-id: https://samskivert.googlecode.com/svn/trunk@2350 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
mdb
2008-07-30 13:53:24 +00:00
parent 4ff9dd2bc7
commit 1d146da100
63 changed files with 780 additions and 778 deletions
@@ -37,7 +37,7 @@ public class SimpleRepository extends Repository
public static interface PreCondition public static interface PreCondition
{ {
/** See {@link #setExecutePreCondition}. */ /** See {@link #setExecutePreCondition}. */
public boolean validate (String dbident, Operation op); public boolean validate (String dbident, Operation<?> op);
} }
/** /**
@@ -102,7 +102,7 @@ public class SimpleRepository extends Repository
* @return whatever value is returned by the invoked operation. * @return whatever value is returned by the invoked operation.
*/ */
protected <V> V execute (Operation<V> op) protected <V> V execute (Operation<V> op)
throws PersistenceException throws PersistenceException
{ {
return execute(op, true, true); return execute(op, true, true);
} }
@@ -114,7 +114,7 @@ public class SimpleRepository extends Repository
* @return whatever value is returned by the invoked operation. * @return whatever value is returned by the invoked operation.
*/ */
protected <V> V executeUpdate (Operation<V> op) protected <V> V executeUpdate (Operation<V> op)
throws PersistenceException throws PersistenceException
{ {
return execute(op, true, false); return execute(op, true, false);
} }
@@ -132,7 +132,7 @@ public class SimpleRepository extends Repository
* @return whatever value is returned by the invoked operation. * @return whatever value is returned by the invoked operation.
*/ */
protected <V> V execute (Operation<V> op, boolean retryOnTransientFailure, boolean readOnly) protected <V> V execute (Operation<V> op, boolean retryOnTransientFailure, boolean readOnly)
throws PersistenceException throws PersistenceException
{ {
Connection conn = null; Connection conn = null;
DatabaseLiaison liaison = null; DatabaseLiaison liaison = null;
@@ -194,14 +194,12 @@ public class StaticConnectionProvider implements ConnectionProvider
public void shutdown () public void shutdown ()
{ {
// close all of the connections // close all of the connections
Iterator iter = _keys.keySet().iterator(); for (Map.Entry<String, Mapping> entry : _keys.entrySet()) {
while (iter.hasNext()) { Mapping conmap = entry.getValue();
String key = (String)iter.next();
Mapping conmap = _keys.get(key);
try { try {
conmap.connection.close(); conmap.connection.close();
} catch (SQLException sqe) { } catch (SQLException sqe) {
log.warning("Error shutting down connection [key=" + key + ", err=" + sqe + "]."); log.warning("Error shutting down connection", "key", entry.getKey(), "err", sqe);
} }
} }
@@ -62,7 +62,7 @@ public class TransitionRepository extends SimpleRepository
/** /**
* Perform a transition if it has not already been applied, and record that it was applied. * Perform a transition if it has not already been applied, and record that it was applied.
*/ */
public void transition (Class clazz, String name, Transition trans) public void transition (Class<?> clazz, String name, Transition trans)
throws PersistenceException throws PersistenceException
{ {
if (!isTransitionApplied(clazz, name)) { if (!isTransitionApplied(clazz, name)) {
@@ -94,7 +94,7 @@ public class TransitionRepository extends SimpleRepository
/** /**
* Has the specified name transition been applied. * Has the specified name transition been applied.
*/ */
public boolean isTransitionApplied (Class clazz, final String name) public boolean isTransitionApplied (Class<?> clazz, final String name)
throws PersistenceException throws PersistenceException
{ {
final String cname = clazz.getName(); final String cname = clazz.getName();
@@ -130,7 +130,7 @@ public class TransitionRepository extends SimpleRepository
* @return true if the transition was noted, false if it could not be noted because another * @return true if the transition was noted, false if it could not be noted because another
* process noted it first. * process noted it first.
*/ */
public boolean noteTransition (Class clazz, final String name) public boolean noteTransition (Class<?> clazz, final String name)
throws PersistenceException throws PersistenceException
{ {
final String cname = clazz.getName(); final String cname = clazz.getName();
@@ -168,7 +168,7 @@ public class TransitionRepository extends SimpleRepository
/** /**
* Clear the transition. * Clear the transition.
*/ */
public void clearTransition (Class clazz, final String name) public void clearTransition (Class<?> clazz, final String name)
throws PersistenceException throws PersistenceException
{ {
final String cname = clazz.getName(); final String cname = clazz.getName();
@@ -73,14 +73,14 @@ public class BindVisitor implements ExpressionVisitor
public void visit (WhereCondition<? extends PersistentRecord> whereCondition) public void visit (WhereCondition<? extends PersistentRecord> whereCondition)
throws Exception throws Exception
{ {
for (Comparable value : whereCondition.getValues()) { for (Comparable<?> value : whereCondition.getValues()) {
if (value != null) { if (value != null) {
_stmt.setObject(_argIdx ++, value); _stmt.setObject(_argIdx ++, value);
} }
} }
} }
public void visit (Key key) public void visit (Key<? extends PersistentRecord> key)
throws Exception throws Exception
{ {
key.condition.accept(this); key.condition.accept(this);
@@ -89,12 +89,13 @@ public class BindVisitor implements ExpressionVisitor
public void visit (MultiKey<? extends PersistentRecord> key) public void visit (MultiKey<? extends PersistentRecord> key)
throws Exception throws Exception
{ {
for (Map.Entry entry : key.getSingleFieldsMap().entrySet()) {
for (Map.Entry<String, Comparable<?>> entry : key.getSingleFieldsMap().entrySet()) {
if (entry.getValue() != null) { if (entry.getValue() != null) {
_stmt.setObject(_argIdx ++, entry.getValue()); _stmt.setObject(_argIdx ++, entry.getValue());
} }
} }
Comparable[] values = key.getMultiValues(); Comparable<?>[] values = key.getMultiValues();
for (int ii = 0; ii < values.length; ii++) { for (int ii = 0; ii < values.length; ii++) {
_stmt.setObject(_argIdx ++, values[ii]); _stmt.setObject(_argIdx ++, values[ii]);
} }
@@ -130,7 +131,7 @@ public class BindVisitor implements ExpressionVisitor
public void visit (In in) throws Exception public void visit (In in) throws Exception
{ {
Comparable[] values = in.getValues(); Comparable<?>[] values = in.getValues();
for (int ii = 0; ii < values.length; ii++) { for (int ii = 0; ii < values.length; ii++) {
_stmt.setObject(_argIdx ++, values[ii]); _stmt.setObject(_argIdx ++, values[ii]);
} }
@@ -229,7 +230,7 @@ public class BindVisitor implements ExpressionVisitor
public void visit (UpdateClause<? extends PersistentRecord> updateClause) throws Exception public void visit (UpdateClause<? extends PersistentRecord> updateClause) throws Exception
{ {
DepotMarshaller marsh = _types.getMarshaller(updateClause.getPersistentClass()); DepotMarshaller<?> marsh = _types.getMarshaller(updateClause.getPersistentClass());
// bind the update arguments // bind the update arguments
String[] fields = updateClause.getFields(); String[] fields = updateClause.getFields();
@@ -251,7 +252,7 @@ public class BindVisitor implements ExpressionVisitor
public void visit (InsertClause<? extends PersistentRecord> insertClause) throws Exception public void visit (InsertClause<? extends PersistentRecord> insertClause) throws Exception
{ {
DepotMarshaller marsh = _types.getMarshaller(insertClause.getPersistentClass()); DepotMarshaller<?> marsh = _types.getMarshaller(insertClause.getPersistentClass());
Object pojo = insertClause.getPojo(); Object pojo = insertClause.getPojo();
Set<String> idFields = insertClause.getIdentityFields(); Set<String> idFields = insertClause.getIdentityFields();
@@ -98,7 +98,7 @@ public abstract class BuildVisitor implements ExpressionVisitor
{ {
Class<? extends PersistentRecord> pClass = whereCondition.getPersistentClass(); Class<? extends PersistentRecord> pClass = whereCondition.getPersistentClass();
String[] keyFields = Key.getKeyFields(pClass); String[] keyFields = Key.getKeyFields(pClass);
List<Comparable> values = whereCondition.getValues(); List<Comparable<?>> values = whereCondition.getValues();
for (int ii = 0; ii < keyFields.length; ii ++) { for (int ii = 0; ii < keyFields.length; ii ++) {
if (ii > 0) { if (ii > 0) {
_builder.append(" and "); _builder.append(" and ");
@@ -113,7 +113,7 @@ public abstract class BuildVisitor implements ExpressionVisitor
} }
} }
public void visit (Key key) public void visit (Key<? extends PersistentRecord> key)
throws Exception throws Exception
{ {
_builder.append(" where "); _builder.append(" where ");
@@ -125,7 +125,7 @@ public abstract class BuildVisitor implements ExpressionVisitor
{ {
_builder.append(" where "); _builder.append(" where ");
boolean first = true; boolean first = true;
for (Map.Entry<String, Comparable> entry : key.getSingleFieldsMap().entrySet()) { for (Map.Entry<String, Comparable<?>> entry : key.getSingleFieldsMap().entrySet()) {
if (first) { if (first) {
first = false; first = false;
} else { } else {
@@ -145,7 +145,7 @@ public abstract class BuildVisitor implements ExpressionVisitor
appendRhsColumn(key.getPersistentClass(), key.getMultiField()); appendRhsColumn(key.getPersistentClass(), key.getMultiField());
_builder.append(" in ("); _builder.append(" in (");
Comparable[] values = key.getMultiValues(); Comparable<?>[] values = key.getMultiValues();
for (int ii = 0; ii < values.length; ii ++) { for (int ii = 0; ii < values.length; ii ++) {
if (ii > 0) { if (ii > 0) {
_builder.append(", "); _builder.append(", ");
@@ -206,7 +206,7 @@ public abstract class BuildVisitor implements ExpressionVisitor
{ {
in.getColumn().accept(this); in.getColumn().accept(this);
_builder.append(" in ("); _builder.append(" in (");
Comparable[] values = in.getValues(); Comparable<?>[] values = in.getValues();
for (int ii = 0; ii < values.length; ii ++) { for (int ii = 0; ii < values.length; ii ++) {
if (ii > 0) { if (ii > 0) {
_builder.append(", "); _builder.append(", ");
@@ -465,7 +465,7 @@ public abstract class BuildVisitor implements ExpressionVisitor
throws Exception throws Exception
{ {
Class<? extends PersistentRecord> pClass = insertClause.getPersistentClass(); Class<? extends PersistentRecord> pClass = insertClause.getPersistentClass();
DepotMarshaller marsh = _types.getMarshaller(pClass); DepotMarshaller<?> marsh = _types.getMarshaller(pClass);
_innerClause = true; _innerClause = true;
String[] fields = marsh.getColumnFieldNames(); String[] fields = marsh.getColumnFieldNames();
@@ -514,8 +514,8 @@ public abstract class BuildVisitor implements ExpressionVisitor
protected void appendLhsColumn (Class<? extends PersistentRecord> type, String field) protected void appendLhsColumn (Class<? extends PersistentRecord> type, String field)
throws Exception throws Exception
{ {
DepotMarshaller dm = _types.getMarshaller(type); DepotMarshaller<?> dm = _types.getMarshaller(type);
FieldMarshaller fm = dm.getFieldMarshaller(field); FieldMarshaller<?> fm = dm.getFieldMarshaller(field);
if (dm == null) { if (dm == null) {
throw new IllegalArgumentException( throw new IllegalArgumentException(
"Unknown field on persistent record [record=" + type + ", field=" + field + "]"); "Unknown field on persistent record [record=" + type + ", field=" + field + "]");
@@ -529,8 +529,8 @@ public abstract class BuildVisitor implements ExpressionVisitor
protected void appendRhsColumn (Class<? extends PersistentRecord> type, String field) protected void appendRhsColumn (Class<? extends PersistentRecord> type, String field)
throws Exception throws Exception
{ {
DepotMarshaller dm = _types.getMarshaller(type); DepotMarshaller<?> dm = _types.getMarshaller(type);
FieldMarshaller fm = dm.getFieldMarshaller(field); FieldMarshaller<?> fm = dm.getFieldMarshaller(field);
if (dm == null) { if (dm == null) {
throw new IllegalArgumentException( throw new IllegalArgumentException(
"Unknown field on persistent record [record=" + type + ", field=" + field + "]"); "Unknown field on persistent record [record=" + type + ", field=" + field + "]");
@@ -120,14 +120,14 @@ public class DepotMarshaller<T extends PersistentRecord>
continue; continue;
} }
FieldMarshaller fm = FieldMarshaller.createMarshaller(field); FieldMarshaller<?> fm = FieldMarshaller.createMarshaller(field);
_fields.put(field.getName(), fm); _fields.put(field.getName(), fm);
fields.add(field.getName()); fields.add(field.getName());
// check to see if this is our primary key // check to see if this is our primary key
if (field.getAnnotation(Id.class) != null) { if (field.getAnnotation(Id.class) != null) {
if (_pkColumns == null) { if (_pkColumns == null) {
_pkColumns = new ArrayList<FieldMarshaller>(); _pkColumns = new ArrayList<FieldMarshaller<?>>();
} }
_pkColumns.add(fm); _pkColumns.add(fm);
} }
@@ -194,7 +194,7 @@ public class DepotMarshaller<T extends PersistentRecord>
String[] conFields = constraint.fieldNames(); String[] conFields = constraint.fieldNames();
Set<String> colSet = new HashSet<String>(); Set<String> colSet = new HashSet<String>();
for (int ii = 0; ii < conFields.length; ii ++) { for (int ii = 0; ii < conFields.length; ii ++) {
FieldMarshaller fm = _fields.get(conFields[ii]); FieldMarshaller<?> fm = _fields.get(conFields[ii]);
if (fm == null) { if (fm == null) {
throw new IllegalArgumentException( throw new IllegalArgumentException(
"Unknown unique constraint field: " + conFields[ii]); "Unknown unique constraint field: " + conFields[ii]);
@@ -287,7 +287,7 @@ public class DepotMarshaller<T extends PersistentRecord>
/** /**
* Returns the {@link FieldMarshaller} for a named field on our persistent class. * Returns the {@link FieldMarshaller} for a named field on our persistent class.
*/ */
public FieldMarshaller getFieldMarshaller (String fieldName) public FieldMarshaller<?> getFieldMarshaller (String fieldName)
{ {
return _fields.get(fieldName); return _fields.get(fieldName);
} }
@@ -349,11 +349,11 @@ public class DepotMarshaller<T extends PersistentRecord>
} }
try { try {
Comparable[] values = new Comparable[_pkColumns.size()]; Comparable<?>[] values = new Comparable<?>[_pkColumns.size()];
int nulls = 0; int nulls = 0;
for (int ii = 0; ii < _pkColumns.size(); ii++) { for (int ii = 0; ii < _pkColumns.size(); ii++) {
FieldMarshaller field = _pkColumns.get(ii); FieldMarshaller<?> field = _pkColumns.get(ii);
if ((values[ii] = (Comparable)field.getField().get(object)) == null) { if ((values[ii] = (Comparable<?>)field.getField().get(object)) == null) {
nulls++; nulls++;
} }
} }
@@ -383,7 +383,7 @@ public class DepotMarshaller<T extends PersistentRecord>
* Creates a primary key record for the type of object handled by this marshaller, using the * Creates a primary key record for the type of object handled by this marshaller, using the
* supplied primary key value. * supplied primary key value.
*/ */
public Key<T> makePrimaryKey (Comparable... values) public Key<T> makePrimaryKey (Comparable<?>... values)
{ {
if (!hasPrimaryKey()) { if (!hasPrimaryKey()) {
throw new UnsupportedOperationException( throw new UnsupportedOperationException(
@@ -407,14 +407,14 @@ public class DepotMarshaller<T extends PersistentRecord>
throw new UnsupportedOperationException( throw new UnsupportedOperationException(
getClass().getName() + " does not define a primary key"); getClass().getName() + " does not define a primary key");
} }
Comparable[] values = new Comparable[_pkColumns.size()]; Comparable<?>[] values = new Comparable<?>[_pkColumns.size()];
for (int ii = 0; ii < _pkColumns.size(); ii++) { for (int ii = 0; ii < _pkColumns.size(); ii++) {
Object keyValue = _pkColumns.get(ii).getFromSet(rs); Object keyValue = _pkColumns.get(ii).getFromSet(rs);
if (!(keyValue instanceof Comparable)) { if (!(keyValue instanceof Comparable<?>)) {
throw new IllegalArgumentException("Key field must be Comparable [field=" + throw new IllegalArgumentException("Key field must be Comparable<?> [field=" +
_pkColumns.get(ii).getColumnName() + "]"); _pkColumns.get(ii).getColumnName() + "]");
} }
values[ii] = (Comparable) keyValue; values[ii] = (Comparable<?>) keyValue;
} }
return makePrimaryKey(values); return makePrimaryKey(values);
} }
@@ -445,7 +445,7 @@ public class DepotMarshaller<T extends PersistentRecord>
// then create and populate the persistent object // then create and populate the persistent object
T po = _pClass.newInstance(); T po = _pClass.newInstance();
for (FieldMarshaller fm : _fields.values()) { for (FieldMarshaller<?> fm : _fields.values()) {
if (!fields.contains(fm.getColumnName())) { if (!fields.contains(fm.getColumnName())) {
// this field was not in the result set, make sure that's OK // this field was not in the result set, make sure that's OK
if (fm.getComputed() != null && !fm.getComputed().required()) { if (fm.getComputed() != null && !fm.getComputed().required()) {
@@ -530,7 +530,7 @@ public class DepotMarshaller<T extends PersistentRecord>
final SQLBuilder builder = ctx.getSQLBuilder(new DepotTypes(ctx, _pClass)); final SQLBuilder builder = ctx.getSQLBuilder(new DepotTypes(ctx, _pClass));
// perform the context-sensitive initialization of the field marshallers // perform the context-sensitive initialization of the field marshallers
for (FieldMarshaller fm : _fields.values()) { for (FieldMarshaller<?> fm : _fields.values()) {
fm.init(builder); fm.init(builder);
} }
@@ -545,7 +545,7 @@ public class DepotMarshaller<T extends PersistentRecord>
ColumnDefinition[] declarations = new ColumnDefinition[_allFields.length]; ColumnDefinition[] declarations = new ColumnDefinition[_allFields.length];
int jj = 0; int jj = 0;
for (int ii = 0; ii < _allFields.length; ii++) { for (int ii = 0; ii < _allFields.length; ii++) {
FieldMarshaller fm = _fields.get(_allFields[ii]); FieldMarshaller<?> fm = _fields.get(_allFields[ii]);
// include all persistent non-computed fields // include all persistent non-computed fields
ColumnDefinition colDef = fm.getColumnDefinition(); ColumnDefinition colDef = fm.getColumnDefinition();
if (colDef != null) { if (colDef != null) {
@@ -684,7 +684,7 @@ public class DepotMarshaller<T extends PersistentRecord>
// add any missing columns // add any missing columns
for (String fname : _columnFields) { for (String fname : _columnFields) {
final FieldMarshaller fmarsh = _fields.get(fname); final FieldMarshaller<?> fmarsh = _fields.get(fname);
if (metaData.tableColumns.remove(fmarsh.getColumnName())) { if (metaData.tableColumns.remove(fmarsh.getColumnName())) {
continue; continue;
} }
@@ -873,7 +873,7 @@ public class DepotMarshaller<T extends PersistentRecord>
throws PersistenceException throws PersistenceException
{ {
for (String fname : _columnFields) { for (String fname : _columnFields) {
FieldMarshaller fmarsh = _fields.get(fname); FieldMarshaller<?> fmarsh = _fields.get(fname);
meta.tableColumns.remove(fmarsh.getColumnName()); meta.tableColumns.remove(fmarsh.getColumnName());
} }
for (String column : meta.tableColumns) { for (String column : meta.tableColumns) {
@@ -977,11 +977,11 @@ public class DepotMarshaller<T extends PersistentRecord>
protected Map<String, ValueGenerator> _valueGenerators = new HashMap<String, ValueGenerator>(); protected Map<String, ValueGenerator> _valueGenerators = new HashMap<String, ValueGenerator>();
/** A field marshaller for each persistent field in our object. */ /** A field marshaller for each persistent field in our object. */
protected Map<String, FieldMarshaller> _fields = new HashMap<String, FieldMarshaller>(); protected Map<String, FieldMarshaller<?>> _fields = new HashMap<String, FieldMarshaller<?>>();
/** The field marshallers for our persistent object's primary key columns or null if it did not /** The field marshallers for our persistent object's primary key columns or null if it did not
* define a primary key. */ * define a primary key. */
protected ArrayList<FieldMarshaller> _pkColumns; protected ArrayList<FieldMarshaller<?>> _pkColumns;
/** The persisent fields of our object, in definition order. */ /** The persisent fields of our object, in definition order. */
protected String[] _allFields; protected String[] _allFields;
@@ -78,7 +78,7 @@ public abstract class DepotRepository
/** /**
* Loads the persistent object that matches the specified primary key. * Loads the persistent object that matches the specified primary key.
*/ */
protected <T extends PersistentRecord> T load (Class<T> type, Comparable primaryKey, protected <T extends PersistentRecord> T load (Class<T> type, Comparable<?> primaryKey,
QueryClause... clauses) QueryClause... clauses)
throws PersistenceException throws PersistenceException
{ {
@@ -89,7 +89,7 @@ public abstract class DepotRepository
/** /**
* Loads the persistent object that matches the specified primary key. * Loads the persistent object that matches the specified primary key.
*/ */
protected <T extends PersistentRecord> T load (Class<T> type, String ix, Comparable val, protected <T extends PersistentRecord> T load (Class<T> type, String ix, Comparable<?> val,
QueryClause... clauses) QueryClause... clauses)
throws PersistenceException throws PersistenceException
{ {
@@ -100,8 +100,8 @@ public abstract class DepotRepository
/** /**
* Loads the persistent object that matches the specified two-column primary key. * Loads the persistent object that matches the specified two-column primary key.
*/ */
protected <T extends PersistentRecord> T load (Class<T> type, String ix1, Comparable val1, protected <T extends PersistentRecord> T load (Class<T> type, String ix1, Comparable<?> val1,
String ix2, Comparable val2, String ix2, Comparable<?> val2,
QueryClause... clauses) QueryClause... clauses)
throws PersistenceException throws PersistenceException
{ {
@@ -112,9 +112,9 @@ public abstract class DepotRepository
/** /**
* Loads the persistent object that matches the specified three-column primary key. * Loads the persistent object that matches the specified three-column primary key.
*/ */
protected <T extends PersistentRecord> T load (Class<T> type, String ix1, Comparable val1, protected <T extends PersistentRecord> T load (Class<T> type, String ix1, Comparable<?> val1,
String ix2, Comparable val2, String ix3, String ix2, Comparable<?> val2, String ix3,
Comparable val3, QueryClause... clauses) Comparable<?> val3, QueryClause... clauses)
throws PersistenceException throws PersistenceException
{ {
clauses = ArrayUtil.append(clauses, new Key<T>(type, ix1, val1, ix2, val2, ix3, val3)); clauses = ArrayUtil.append(clauses, new Key<T>(type, ix1, val1, ix2, val2, ix3, val3));
@@ -231,7 +231,7 @@ public abstract class DepotRepository
requireNotComputed(pClass, "update"); requireNotComputed(pClass, "update");
DepotMarshaller<T> marsh = _ctx.getMarshaller(pClass); DepotMarshaller<T> marsh = _ctx.getMarshaller(pClass);
Key key = marsh.getPrimaryKey(record); Key<T> key = marsh.getPrimaryKey(record);
if (key == null) { if (key == null) {
throw new IllegalArgumentException("Can't update record with null primary key."); throw new IllegalArgumentException("Can't update record with null primary key.");
} }
@@ -269,7 +269,8 @@ public abstract class DepotRepository
requireNotComputed(pClass, "updatePartial"); requireNotComputed(pClass, "updatePartial");
DepotMarshaller<T> marsh = _ctx.getMarshaller(pClass); DepotMarshaller<T> marsh = _ctx.getMarshaller(pClass);
Key key = marsh.getPrimaryKey(record);
Key<T> key = marsh.getPrimaryKey(record);
if (key == null) { if (key == null) {
throw new IllegalArgumentException("Can't update record with null primary key."); throw new IllegalArgumentException("Can't update record with null primary key.");
@@ -305,7 +306,7 @@ public abstract class DepotRepository
* @return the number of rows modified by this action. * @return the number of rows modified by this action.
*/ */
protected <T extends PersistentRecord> int updatePartial ( protected <T extends PersistentRecord> int updatePartial (
Class<T> type, Comparable primaryKey, Map<String,Object> updates) Class<T> type, Comparable<?> primaryKey, Map<String,Object> updates)
throws PersistenceException throws PersistenceException
{ {
Object[] fieldsValues = new Object[updates.size()*2]; Object[] fieldsValues = new Object[updates.size()*2];
@@ -328,7 +329,7 @@ public abstract class DepotRepository
* @return the number of rows modified by this action. * @return the number of rows modified by this action.
*/ */
protected <T extends PersistentRecord> int updatePartial ( protected <T extends PersistentRecord> int updatePartial (
Class<T> type, Comparable primaryKey, Object... fieldsValues) Class<T> type, Comparable<?> primaryKey, Object... fieldsValues)
throws PersistenceException throws PersistenceException
{ {
return updatePartial(_ctx.getMarshaller(type).makePrimaryKey(primaryKey), fieldsValues); return updatePartial(_ctx.getMarshaller(type).makePrimaryKey(primaryKey), fieldsValues);
@@ -346,7 +347,7 @@ public abstract class DepotRepository
* @return the number of rows modified by this action. * @return the number of rows modified by this action.
*/ */
protected <T extends PersistentRecord> int updatePartial ( protected <T extends PersistentRecord> int updatePartial (
Class<T> type, String ix1, Comparable val1, String ix2, Comparable val2, Class<T> type, String ix1, Comparable<?> val1, String ix2, Comparable<?> val2,
Object... fieldsValues) Object... fieldsValues)
throws PersistenceException throws PersistenceException
{ {
@@ -365,8 +366,8 @@ public abstract class DepotRepository
* @return the number of rows modified by this action. * @return the number of rows modified by this action.
*/ */
protected <T extends PersistentRecord> int updatePartial ( protected <T extends PersistentRecord> int updatePartial (
Class<T> type, String ix1, Comparable val1, String ix2, Comparable val2, Class<T> type, String ix1, Comparable<?> val1, String ix2, Comparable<?> val2,
String ix3, Comparable val3, Object... fieldsValues) String ix3, Comparable<?> val3, Object... fieldsValues)
throws PersistenceException throws PersistenceException
{ {
return updatePartial(new Key<T>(type, ix1, val1, ix2, val2, ix3, val3), fieldsValues); return updatePartial(new Key<T>(type, ix1, val1, ix2, val2, ix3, val3), fieldsValues);
@@ -452,7 +453,7 @@ public abstract class DepotRepository
* @return the number of rows modified by this action. * @return the number of rows modified by this action.
*/ */
protected <T extends PersistentRecord> int updateLiteral ( protected <T extends PersistentRecord> int updateLiteral (
Class<T> type, Comparable primaryKey, Map<String, SQLExpression> fieldsToValues) Class<T> type, Comparable<?> primaryKey, Map<String, SQLExpression> fieldsToValues)
throws PersistenceException throws PersistenceException
{ {
Key<T> key = _ctx.getMarshaller(type).makePrimaryKey(primaryKey); Key<T> key = _ctx.getMarshaller(type).makePrimaryKey(primaryKey);
@@ -477,7 +478,7 @@ public abstract class DepotRepository
* @return the number of rows modified by this action. * @return the number of rows modified by this action.
*/ */
protected <T extends PersistentRecord> int updateLiteral ( protected <T extends PersistentRecord> int updateLiteral (
Class<T> type, String ix1, Comparable val1, String ix2, Comparable val2, Class<T> type, String ix1, Comparable<?> val1, String ix2, Comparable<?> val2,
Map<String, SQLExpression> fieldsToValues) Map<String, SQLExpression> fieldsToValues)
throws PersistenceException throws PersistenceException
{ {
@@ -503,8 +504,8 @@ public abstract class DepotRepository
* @return the number of rows modified by this action. * @return the number of rows modified by this action.
*/ */
protected <T extends PersistentRecord> int updateLiteral ( protected <T extends PersistentRecord> int updateLiteral (
Class<T> type, String ix1, Comparable val1, String ix2, Comparable val2, Class<T> type, String ix1, Comparable<?> val1, String ix2, Comparable<?> val2,
String ix3, Comparable val3, Map<String, SQLExpression> fieldsToValues) String ix3, Comparable<?> val3, Map<String, SQLExpression> fieldsToValues)
throws PersistenceException throws PersistenceException
{ {
Key<T> key = new Key<T>(type, ix1, val1, ix2, val2, ix3, val3); Key<T> key = new Key<T>(type, ix1, val1, ix2, val2, ix3, val3);
@@ -662,7 +663,8 @@ public abstract class DepotRepository
* *
* @return the number of rows deleted by this action. * @return the number of rows deleted by this action.
*/ */
protected <T extends PersistentRecord> int delete (Class<T> type, Comparable primaryKeyValue) protected <T extends PersistentRecord> int delete (
Class<T> type, Comparable<?> primaryKeyValue)
throws PersistenceException throws PersistenceException
{ {
return delete(type, _ctx.getMarshaller(type).makePrimaryKey(primaryKeyValue)); return delete(type, _ctx.getMarshaller(type).makePrimaryKey(primaryKeyValue));
@@ -714,7 +716,7 @@ public abstract class DepotRepository
protected void requireNotComputed (Class<? extends PersistentRecord> type, String action) protected void requireNotComputed (Class<? extends PersistentRecord> type, String action)
throws PersistenceException throws PersistenceException
{ {
DepotMarshaller marsh = _ctx.getMarshaller(type); DepotMarshaller<?> marsh = _ctx.getMarshaller(type);
if (marsh == null) { if (marsh == null) {
throw new PersistenceException("Unknown persistent type [class=" + type + "]"); throw new PersistenceException("Unknown persistent type [class=" + type + "]");
} }
@@ -152,9 +152,9 @@ public class DepotTypes
* *
* @exception IllegalArgumentException thrown if the specified class is not known. * @exception IllegalArgumentException thrown if the specified class is not known.
*/ */
public DepotMarshaller getMarshaller (Class<? extends PersistentRecord> cl) public DepotMarshaller<?> getMarshaller (Class<? extends PersistentRecord> cl)
{ {
DepotMarshaller marsh = _classMap.get(cl); DepotMarshaller<?> marsh = _classMap.get(cl);
if (marsh == null) { if (marsh == null) {
throw new IllegalArgumentException("Persistent class not known: " + cl); throw new IllegalArgumentException("Persistent class not known: " + cl);
} }
@@ -202,10 +202,11 @@ public class DepotTypes
} }
/** Classes mapped to integers, used for table abbreviation indexing. */ /** Classes mapped to integers, used for table abbreviation indexing. */
protected Map<Class, Integer> _classIx = new HashMap<Class, Integer>(); protected Map<Class<?>, Integer> _classIx = new HashMap<Class<?>, Integer>();
/** Classes mapped to marshallers, used for table names and field lists. */ /** Classes mapped to marshallers, used for table names and field lists. */
protected Map<Class, DepotMarshaller> _classMap = new HashMap<Class, DepotMarshaller>(); protected Map<Class<?>, DepotMarshaller<?>> _classMap =
new HashMap<Class<?>, DepotMarshaller<?>>();
/** When false, override the normal table abbreviations and return full table names instead. */ /** When false, override the normal table abbreviations and return full table names instead. */
protected boolean _useTableAbbreviations = true; protected boolean _useTableAbbreviations = true;
@@ -101,7 +101,7 @@ public abstract class EntityMigration extends Modifier
return true; return true;
} }
protected void init (String tableName, Map<String,FieldMarshaller> marshallers) { 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();
} }
@@ -133,7 +133,7 @@ public abstract class EntityMigration extends Modifier
return false; return false;
} }
protected void init (String tableName, Map<String,FieldMarshaller> marshallers) { 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();
@@ -174,7 +174,7 @@ public abstract class EntityMigration extends Modifier
* migration has been determined to be runnable so one cannot rely on this method having been * migration has been determined to be runnable so one cannot rely on this method having been
* called in {@link #shouldRunMigration}. * called in {@link #shouldRunMigration}.
*/ */
protected void init (String tableName, Map<String,FieldMarshaller> marshallers) protected void init (String tableName, Map<String,FieldMarshaller<?>> marshallers)
{ {
_tableName = tableName; _tableName = tableName;
} }
@@ -52,10 +52,10 @@ public abstract class FieldMarshaller<T>
* Creates and returns a field marshaller for the specified field. Throws an exception if the * Creates and returns a field marshaller for the specified field. Throws an exception if the
* field in question cannot be marshalled. * field in question cannot be marshalled.
*/ */
public static FieldMarshaller createMarshaller (Field field) public static FieldMarshaller<?> createMarshaller (Field field)
{ {
Class<?> ftype = field.getType(); Class<?> ftype = field.getType();
FieldMarshaller marshaller; FieldMarshaller<?> marshaller;
// primitive types // primitive types
if (ftype.equals(Boolean.TYPE)) { if (ftype.equals(Boolean.TYPE)) {
@@ -117,7 +117,7 @@ public abstract class FindAllQuery<T extends PersistentRecord>
if (_marsh.getPrimaryKeyFields().length == 1) { if (_marsh.getPrimaryKeyFields().length == 1) {
// Single-column keys result in the compact IN(keyVal1, keyVal2, ...) // Single-column keys result in the compact IN(keyVal1, keyVal2, ...)
Comparable[] keyFieldValues = new Comparable[fetchKeys.size()]; Comparable<?>[] keyFieldValues = new Comparable<?>[fetchKeys.size()];
int ii = 0; int ii = 0;
for (Key<T> key : fetchKeys) { for (Key<T> key : fetchKeys) {
keyFieldValues[ii ++] = key.condition.getValues().get(0); keyFieldValues[ii ++] = key.condition.getValues().get(0);
@@ -31,7 +31,7 @@ import com.samskivert.jdbc.depot.annotation.GeneratedValue;
*/ */
public class IdentityValueGenerator extends ValueGenerator public class IdentityValueGenerator extends ValueGenerator
{ {
public IdentityValueGenerator (GeneratedValue gv, DepotMarshaller dm, FieldMarshaller fm) public IdentityValueGenerator (GeneratedValue gv, DepotMarshaller<?> dm, FieldMarshaller<?> fm)
{ {
super(gv, dm, fm); super(gv, dm, fm);
} }
+16 -15
View File
@@ -24,6 +24,7 @@ import java.io.Serializable;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.List;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@@ -46,7 +47,7 @@ public class Key<T extends PersistentRecord> extends WhereClause
public static class WhereCondition<U extends PersistentRecord> public static class WhereCondition<U extends PersistentRecord>
implements SQLExpression, Serializable implements SQLExpression, Serializable
{ {
public WhereCondition (Class<U> pClass, ArrayList<Comparable> values) public WhereCondition (Class<U> pClass, ArrayList<Comparable<?>> values)
{ {
_pClass = pClass; _pClass = pClass;
_values = values; _values = values;
@@ -69,7 +70,7 @@ public class Key<T extends PersistentRecord> extends WhereClause
return _pClass; return _pClass;
} }
public ArrayList<Comparable> getValues () public ArrayList<Comparable<?>> getValues ()
{ {
return _values; return _values;
} }
@@ -83,7 +84,7 @@ public class Key<T extends PersistentRecord> extends WhereClause
if (obj == null || getClass() != obj.getClass()) { if (obj == null || getClass() != obj.getClass()) {
return false; return false;
} }
WhereCondition other = (WhereCondition) obj; WhereCondition<?> other = (WhereCondition<?>) obj;
return _pClass == other._pClass && _values.equals(other.getValues()); return _pClass == other._pClass && _values.equals(other.getValues());
} }
@@ -94,7 +95,7 @@ public class Key<T extends PersistentRecord> extends WhereClause
} }
protected Class<U> _pClass; protected Class<U> _pClass;
protected ArrayList<Comparable> _values; protected ArrayList<Comparable<?>> _values; // List is not Serializable
} }
/** The expression that identifies our row. */ /** The expression that identifies our row. */
@@ -103,7 +104,7 @@ public class Key<T extends PersistentRecord> extends WhereClause
/** /**
* Constructs a new single-column {@code Key} with the given value. * Constructs a new single-column {@code Key} with the given value.
*/ */
public Key (Class<T> pClass, String ix, Comparable val) public Key (Class<T> pClass, String ix, Comparable<?> val)
{ {
this(pClass, new String[] { ix }, new Comparable[] { val }); this(pClass, new String[] { ix }, new Comparable[] { val });
} }
@@ -111,8 +112,8 @@ public class Key<T extends PersistentRecord> extends WhereClause
/** /**
* Constructs a new two-column {@code Key} with the given values. * Constructs a new two-column {@code Key} with the given values.
*/ */
public Key (Class<T> pClass, String ix1, Comparable val1, public Key (Class<T> pClass, String ix1, Comparable<?> val1,
String ix2, Comparable val2) String ix2, Comparable<?> val2)
{ {
this(pClass, new String[] { ix1, ix2 }, new Comparable[] { val1, val2 }); this(pClass, new String[] { ix1, ix2 }, new Comparable[] { val1, val2 });
} }
@@ -120,8 +121,8 @@ public class Key<T extends PersistentRecord> extends WhereClause
/** /**
* Constructs a new three-column {@code Key} with the given values. * Constructs a new three-column {@code Key} with the given values.
*/ */
public Key (Class<T> pClass, String ix1, Comparable val1, public Key (Class<T> pClass, String ix1, Comparable<?> val1,
String ix2, Comparable val2, String ix3, Comparable val3) String ix2, Comparable<?> val2, String ix3, Comparable<?> val3)
{ {
this(pClass, new String[] { ix1, ix2, ix3 }, new Comparable[] { val1, val2, val3 }); this(pClass, new String[] { ix1, ix2, ix3 }, new Comparable[] { val1, val2, val3 });
} }
@@ -129,14 +130,14 @@ public class Key<T extends PersistentRecord> extends WhereClause
/** /**
* Constructs a new multi-column {@code Key} with the given values. * Constructs a new multi-column {@code Key} with the given values.
*/ */
public Key (Class<T> pClass, String[] fields, Comparable[] values) public Key (Class<T> pClass, String[] fields, Comparable<?>[] values)
{ {
if (fields.length != values.length) { if (fields.length != values.length) {
throw new IllegalArgumentException("Field and Value arrays must be of equal length."); throw new IllegalArgumentException("Field and Value arrays must be of equal length.");
} }
// build a local map of field name -> field value // build a local map of field name -> field value
Map<String, Comparable> map = new HashMap<String, Comparable>(); Map<String, Comparable<?>> map = new HashMap<String, Comparable<?>>();
for (int i = 0; i < fields.length; i ++) { for (int i = 0; i < fields.length; i ++) {
map.put(fields[i], values[i]); map.put(fields[i], values[i]);
} }
@@ -145,9 +146,9 @@ public class Key<T extends PersistentRecord> extends WhereClause
String[] keyFields = getKeyFields(pClass); String[] keyFields = getKeyFields(pClass);
// now extract the values in field order and ensure none are extra or missing // now extract the values in field order and ensure none are extra or missing
ArrayList<Comparable> newValues = new ArrayList<Comparable>(); ArrayList<Comparable<?>> newValues = new ArrayList<Comparable<?>>();
for (int ii = 0; ii < keyFields.length; ii++) { for (int ii = 0; ii < keyFields.length; ii++) {
Comparable nugget = map.remove(keyFields[ii]); Comparable<?> nugget = map.remove(keyFields[ii]);
if (nugget == null) { if (nugget == null) {
// make sure we were provided with a value for this primary key field // make sure we were provided with a value for this primary key field
throw new IllegalArgumentException("Missing value for key field: " + keyFields[ii]); throw new IllegalArgumentException("Missing value for key field: " + keyFields[ii]);
@@ -227,7 +228,7 @@ public class Key<T extends PersistentRecord> extends WhereClause
if (obj == null || getClass() != obj.getClass()) { if (obj == null || getClass() != obj.getClass()) {
return false; return false;
} }
return condition.equals(((Key) obj).condition); return condition.equals(((Key<?>) obj).condition);
} }
@Override @Override
@@ -260,7 +261,7 @@ public class Key<T extends PersistentRecord> extends WhereClause
{ {
String[] fields = _keyFields.get(pClass); String[] fields = _keyFields.get(pClass);
if (fields == null) { if (fields == null) {
ArrayList<String> kflist = new ArrayList<String>(); List<String> kflist = new ArrayList<String>();
for (Field field : pClass.getFields()) { for (Field field : pClass.getFields()) {
// look for @Id fields // look for @Id fields
if (field.getAnnotation(Id.class) != null) { if (field.getAnnotation(Id.class) != null) {
@@ -38,7 +38,7 @@ public class MultiKey<T extends PersistentRecord> extends WhereClause
/** /**
* Constructs a new single-column {@code MultiKey} with the given value range. * Constructs a new single-column {@code MultiKey} with the given value range.
*/ */
public MultiKey (Class<T> pClass, String ix, Comparable... val) public MultiKey (Class<T> pClass, String ix, Comparable<?>... val)
{ {
this(pClass, new String[0], new Comparable[0], ix, val); this(pClass, new String[0], new Comparable[0], ix, val);
} }
@@ -46,7 +46,8 @@ public class MultiKey<T extends PersistentRecord> extends WhereClause
/** /**
* Constructs a new two-column {@code MultiKey} with the given value range. * Constructs a new two-column {@code MultiKey} with the given value range.
*/ */
public MultiKey (Class<T> pClass, String ix1, Comparable val1, String ix2, Comparable... val2) public MultiKey (Class<T> pClass, String ix1, Comparable<?> val1, String ix2,
Comparable<?>... val2)
{ {
this(pClass, new String[] { ix1 }, new Comparable[] { val1 }, ix2, val2); this(pClass, new String[] { ix1 }, new Comparable[] { val1 }, ix2, val2);
} }
@@ -54,8 +55,8 @@ public class MultiKey<T extends PersistentRecord> extends WhereClause
/** /**
* Constructs a new three-column {@code MultiKey} with the given value range. * Constructs a new three-column {@code MultiKey} with the given value range.
*/ */
public MultiKey (Class<T> pClass, String ix1, Comparable val1, String ix2, Comparable val2, public MultiKey (Class<T> pClass, String ix1, Comparable<?> val1,
String ix3, Comparable... val3) String ix2, Comparable<?> val2, String ix3, Comparable<?>... val3)
{ {
this(pClass, new String[] { ix1, ix2 }, new Comparable[] { val1, val2 }, ix3, val3); this(pClass, new String[] { ix1, ix2 }, new Comparable[] { val1, val2 }, ix3, val3);
} }
@@ -64,8 +65,8 @@ public class MultiKey<T extends PersistentRecord> extends WhereClause
* Constructs a new multi-column {@code MultiKey} with the given value range. * Constructs a new multi-column {@code MultiKey} with the given value range.
* @TODO: See {@link Key#Key(Class, String[], Comparable[]) for somewhat relevant comments. * @TODO: See {@link Key#Key(Class, String[], Comparable[]) for somewhat relevant comments.
*/ */
public MultiKey (Class<T> pClass, String[] sFields, Comparable[] sValues, public MultiKey (Class<T> pClass, String[] sFields, Comparable<?>[] sValues,
String mField, Comparable[] mValues) String mField, Comparable<?>[] mValues)
{ {
if (sFields.length != sValues.length) { if (sFields.length != sValues.length) {
throw new IllegalArgumentException( throw new IllegalArgumentException(
@@ -74,7 +75,7 @@ public class MultiKey<T extends PersistentRecord> extends WhereClause
_pClass = pClass; _pClass = pClass;
_mField = mField; _mField = mField;
_mValues = mValues; _mValues = mValues;
_map = new HashMap<String, Comparable>(); _map = new HashMap<String, Comparable<?>>();
for (int i = 0; i < sFields.length; i ++) { for (int i = 0; i < sFields.length; i ++) {
_map.put(sFields[i], sValues[i]); _map.put(sFields[i], sValues[i]);
} }
@@ -85,7 +86,7 @@ public class MultiKey<T extends PersistentRecord> extends WhereClause
return _pClass; return _pClass;
} }
public Map<String, Comparable> getSingleFieldsMap () public Map<String, Comparable<?>> getSingleFieldsMap ()
{ {
return _map; return _map;
} }
@@ -95,7 +96,7 @@ public class MultiKey<T extends PersistentRecord> extends WhereClause
return _mField; return _mField;
} }
public Comparable[] getMultiValues () public Comparable<?>[] getMultiValues ()
{ {
return _mValues; return _mValues;
} }
@@ -126,7 +127,7 @@ public class MultiKey<T extends PersistentRecord> extends WhereClause
// from CacheInvalidator // from CacheInvalidator
public void invalidate (PersistenceContext ctx) public void invalidate (PersistenceContext ctx)
{ {
HashMap<String, Comparable> newMap = new HashMap<String, Comparable>(_map); HashMap<String, Comparable<?>> newMap = new HashMap<String, Comparable<?>>(_map);
for (int i = 0; i < _mValues.length; i ++) { for (int i = 0; i < _mValues.length; i ++) {
newMap.put(_mField, _mValues[i]); newMap.put(_mField, _mValues[i]);
ctx.cacheInvalidate(new SimpleCacheKey(_pClass, newMap)); ctx.cacheInvalidate(new SimpleCacheKey(_pClass, newMap));
@@ -141,7 +142,7 @@ public class MultiKey<T extends PersistentRecord> extends WhereClause
} }
protected String _mField; protected String _mField;
protected Comparable[] _mValues; protected Comparable<?>[] _mValues;
protected Class<T> _pClass; protected Class<T> _pClass;
protected HashMap<String, Comparable> _map; protected HashMap<String, Comparable<?>> _map;
} }
@@ -205,7 +205,7 @@ public class MySQLBuilder
} }
@Override @Override
protected <T> String getColumnType (FieldMarshaller fm, int length) protected <T> String getColumnType (FieldMarshaller<?> fm, int length)
{ {
if (fm instanceof ByteMarshaller) { if (fm instanceof ByteMarshaller) {
return "TINYINT"; return "TINYINT";
@@ -316,9 +316,8 @@ public class PersistenceContext
log.debug("storing [key=" + key + ", value=" + entry + "]"); log.debug("storing [key=" + key + ", value=" + entry + "]");
CacheAdapter.CacheBin<T> bin = _cache.getCache(key.getCacheId()); CacheAdapter.CacheBin<T> bin = _cache.getCache(key.getCacheId());
CacheAdapter.CachedValue element = bin.lookup(key.getCacheKey()); CacheAdapter.CachedValue<T> element = bin.lookup(key.getCacheKey());
@SuppressWarnings("unchecked") T oldEntry = T oldEntry = (element != null ? element.getValue() : null);
(element != null ? (T) element.getValue() : null);
// update the cache // update the cache
bin.store(key.getCacheKey(), entry); bin.store(key.getCacheKey(), entry);
@@ -353,7 +352,7 @@ public class PersistenceContext
* Evicts the cache entry indexed under the given class and cache key, if there is one. The * Evicts the cache entry indexed under the given class and cache key, if there is one. The
* eviction may trigger further cache invalidations. * eviction may trigger further cache invalidations.
*/ */
public void cacheInvalidate (Class pClass, Serializable cacheKey) public void cacheInvalidate (Class<? extends PersistentRecord> pClass, Serializable cacheKey)
{ {
cacheInvalidate(pClass.getName(), cacheKey); cacheInvalidate(pClass.getName(), cacheKey);
} }
@@ -397,7 +396,8 @@ public class PersistenceContext
* Brutally iterates over the entire contents of the cache associated with the given class, * Brutally iterates over the entire contents of the cache associated with the given class,
* invoking the callback for each cache entry. * invoking the callback for each cache entry.
*/ */
public <T extends Serializable> void cacheTraverse (Class pClass, CacheTraverser<T> filter) public <T extends Serializable> void cacheTraverse (
Class<? extends PersistentRecord> pClass, CacheTraverser<T> filter)
{ {
cacheTraverse(pClass.getName(), filter); cacheTraverse(pClass.getName(), filter);
} }
@@ -212,7 +212,7 @@ public class PostgreSQLBuilder
} }
@Override @Override
protected <T> String getColumnType (FieldMarshaller fm, int length) protected <T> String getColumnType (FieldMarshaller<?> fm, int length)
{ {
if (fm instanceof ByteMarshaller) { if (fm instanceof ByteMarshaller) {
return "SMALLINT"; return "SMALLINT";
@@ -109,7 +109,7 @@ public abstract class SQLBuilder
* TODO: This method should be split into several parts that are more easily overridden on a * TODO: This method should be split into several parts that are more easily overridden on a
* case-by-case basis in the dialectal subclasses. * case-by-case basis in the dialectal subclasses.
*/ */
public ColumnDefinition buildColumnDefinition (FieldMarshaller fm) public ColumnDefinition buildColumnDefinition (FieldMarshaller<?> fm)
{ {
// if this field is @Computed, it has no SQL definition // if this field is @Computed, it has no SQL definition
if (fm.getComputed() != null) { if (fm.getComputed() != null) {
@@ -228,7 +228,7 @@ public abstract class SQLBuilder
* Overridden by subclasses to figure the dialect-specific SQL type of the given field. * Overridden by subclasses to figure the dialect-specific SQL type of the given field.
* @param length * @param length
*/ */
protected abstract <T> String getColumnType (FieldMarshaller fm, int length); protected abstract <T> String getColumnType (FieldMarshaller<?> fm, int length);
/** The class that maps persistent classes to marshallers. */ /** The class that maps persistent classes to marshallers. */
protected DepotTypes _types; protected DepotTypes _types;
@@ -42,7 +42,7 @@ public class SimpleCacheKey
* Construct a {@link SimpleCacheKey} associated with the given persistent class with * Construct a {@link SimpleCacheKey} associated with the given persistent class with
* the given cache key. * the given cache key.
*/ */
public SimpleCacheKey (Class cacheClass, Serializable cacheKey) public SimpleCacheKey (Class<?> cacheClass, Serializable cacheKey)
{ {
this(cacheClass.getName(), cacheKey); this(cacheClass.getName(), cacheKey);
} }
@@ -37,7 +37,8 @@ import com.samskivert.jdbc.JDBCUtil;
*/ */
public class TableValueGenerator extends ValueGenerator public class TableValueGenerator extends ValueGenerator
{ {
public TableValueGenerator (TableGenerator tg, GeneratedValue gv, DepotMarshaller dm, FieldMarshaller fm) public TableValueGenerator (
TableGenerator tg, GeneratedValue gv, DepotMarshaller<?> dm, FieldMarshaller<?> fm)
{ {
super(gv, dm, fm); super(gv, dm, fm);
_valueTable = defStr(tg.table(), "IdSequences"); _valueTable = defStr(tg.table(), "IdSequences");
@@ -36,7 +36,7 @@ import static com.samskivert.jdbc.depot.Log.log;
*/ */
public abstract class ValueGenerator public abstract class ValueGenerator
{ {
public ValueGenerator (GeneratedValue gv, DepotMarshaller dm, FieldMarshaller fm) public ValueGenerator (GeneratedValue gv, DepotMarshaller<?> dm, FieldMarshaller<?> fm)
{ {
_allocationSize = gv.allocationSize(); _allocationSize = gv.allocationSize();
_initialValue = gv.initialValue(); _initialValue = gv.initialValue();
@@ -101,12 +101,12 @@ public abstract class ValueGenerator
} }
} }
public DepotMarshaller getDepotMarshaller () public DepotMarshaller<?> getDepotMarshaller ()
{ {
return _dm; return _dm;
} }
public FieldMarshaller getFieldMarshaller () public FieldMarshaller<?> getFieldMarshaller ()
{ {
return _fm; return _fm;
} }
@@ -115,6 +115,6 @@ public abstract class ValueGenerator
protected int _allocationSize; protected int _allocationSize;
protected boolean _migrateIfExists; protected boolean _migrateIfExists;
protected DepotMarshaller _dm; protected DepotMarshaller<?> _dm;
protected FieldMarshaller _fm; protected FieldMarshaller<?> _fm;
} }
@@ -38,26 +38,26 @@ import com.samskivert.jdbc.depot.operator.Logic.And;
*/ */
public class Where extends WhereClause public class Where extends WhereClause
{ {
public Where (ColumnExp column, Comparable value) public Where (ColumnExp column, Comparable<?> value)
{ {
this(new ColumnExp[] { column }, new Comparable[] { value }); this(new ColumnExp[] { column }, new Comparable<?>[] { value });
} }
public Where (ColumnExp index1, Comparable value1, public Where (ColumnExp index1, Comparable<?> value1,
ColumnExp index2, Comparable value2) ColumnExp index2, Comparable<?> value2)
{ {
this(new ColumnExp[] { index1, index2 }, new Comparable[] { value1, value2 }); this(new ColumnExp[] { index1, index2 }, new Comparable<?>[] { value1, value2 });
} }
public Where (ColumnExp index1, Comparable value1, public Where (ColumnExp index1, Comparable<?> value1,
ColumnExp index2, Comparable value2, ColumnExp index2, Comparable<?> value2,
ColumnExp index3, Comparable value3) ColumnExp index3, Comparable<?> value3)
{ {
this(new ColumnExp[] { index1, index2, index3 }, this(new ColumnExp[] { index1, index2, index3 },
new Comparable[] { value1, value2, value3 }); new Comparable<?>[] { value1, value2, value3 });
} }
public Where (ColumnExp[] columns, Comparable[] values) public Where (ColumnExp[] columns, Comparable<?>[] values)
{ {
this(toCondition(columns, values)); this(toCondition(columns, values));
} }
@@ -84,7 +84,7 @@ public class Where extends WhereClause
_condition.addClasses(classSet); _condition.addClasses(classSet);
} }
protected static SQLExpression toCondition (ColumnExp[] columns, Comparable[] values) protected static SQLExpression toCondition (ColumnExp[] columns, Comparable<?>[] values)
{ {
SQLExpression[] comparisons = new SQLExpression[columns.length]; SQLExpression[] comparisons = new SQLExpression[columns.length];
for (int ii = 0; ii < columns.length; ii ++) { for (int ii = 0; ii < columns.length; ii ++) {
@@ -55,7 +55,7 @@ public interface ExpressionVisitor
throws Exception; throws Exception;
public void visit (WhereCondition<? extends PersistentRecord> whereCondition) public void visit (WhereCondition<? extends PersistentRecord> whereCondition)
throws Exception; throws Exception;
public void visit (Key key) public void visit (Key<? extends PersistentRecord> key)
throws Exception; throws Exception;
public void visit (MultiKey<? extends PersistentRecord> key) public void visit (MultiKey<? extends PersistentRecord> key)
throws Exception; throws Exception;
@@ -32,7 +32,7 @@ public abstract class Arithmetic
/** The SQL '+' operator. */ /** The SQL '+' operator. */
public static class Add extends BinaryOperator public static class Add extends BinaryOperator
{ {
public Add (SQLExpression column, Comparable value) public Add (SQLExpression column, Comparable<?> value)
{ {
super(column, value); super(column, value);
} }
@@ -52,7 +52,7 @@ public abstract class Arithmetic
/** The SQL '-' operator. */ /** The SQL '-' operator. */
public static class Sub extends BinaryOperator public static class Sub extends BinaryOperator
{ {
public Sub (SQLExpression column, Comparable value) public Sub (SQLExpression column, Comparable<?> value)
{ {
super(column, value); super(column, value);
} }
@@ -72,7 +72,7 @@ public abstract class Arithmetic
/** The SQL '*' operator. */ /** The SQL '*' operator. */
public static class Mul extends BinaryOperator public static class Mul extends BinaryOperator
{ {
public Mul (SQLExpression column, Comparable value) public Mul (SQLExpression column, Comparable<?> value)
{ {
super(column, value); super(column, value);
} }
@@ -92,7 +92,7 @@ public abstract class Arithmetic
/** The SQL '/' operator. */ /** The SQL '/' operator. */
public static class Div extends BinaryOperator public static class Div extends BinaryOperator
{ {
public Div (SQLExpression column, Comparable value) public Div (SQLExpression column, Comparable<?> value)
{ {
super(column, value); super(column, value);
} }
@@ -112,7 +112,7 @@ public abstract class Arithmetic
/** The SQL '&' operator. */ /** The SQL '&' operator. */
public static class BitAnd extends BinaryOperator public static class BitAnd extends BinaryOperator
{ {
public BitAnd (SQLExpression column, Comparable value) public BitAnd (SQLExpression column, Comparable<?> value)
{ {
super(column, value); super(column, value);
} }
@@ -132,7 +132,7 @@ public abstract class Arithmetic
/** The SQL '|' operator. */ /** The SQL '|' operator. */
public static class BitOr extends BinaryOperator public static class BitOr extends BinaryOperator
{ {
public BitOr (SQLExpression column, Comparable value) public BitOr (SQLExpression column, Comparable<?> value)
{ {
super(column, value); super(column, value);
} }
@@ -75,7 +75,7 @@ public abstract class Conditionals
/** The SQL '=' operator. */ /** The SQL '=' operator. */
public static class Equals extends SQLOperator.BinaryOperator public static class Equals extends SQLOperator.BinaryOperator
{ {
public Equals (SQLExpression column, Comparable value) public Equals (SQLExpression column, Comparable<?> value)
{ {
super(column, value); super(column, value);
} }
@@ -95,7 +95,7 @@ public abstract class Conditionals
/** The SQL '!=' operator. */ /** The SQL '!=' operator. */
public static class NotEquals extends SQLOperator.BinaryOperator public static class NotEquals extends SQLOperator.BinaryOperator
{ {
public NotEquals (SQLExpression column, Comparable value) public NotEquals (SQLExpression column, Comparable<?> value)
{ {
super(column, value); super(column, value);
} }
@@ -115,7 +115,7 @@ public abstract class Conditionals
/** The SQL '<' operator. */ /** The SQL '<' operator. */
public static class LessThan extends SQLOperator.BinaryOperator public static class LessThan extends SQLOperator.BinaryOperator
{ {
public LessThan (SQLExpression column, Comparable value) public LessThan (SQLExpression column, Comparable<?> value)
{ {
super(column, value); super(column, value);
} }
@@ -135,7 +135,7 @@ public abstract class Conditionals
/** The SQL '<=' operator. */ /** The SQL '<=' operator. */
public static class LessThanEquals extends SQLOperator.BinaryOperator public static class LessThanEquals extends SQLOperator.BinaryOperator
{ {
public LessThanEquals (SQLExpression column, Comparable value) public LessThanEquals (SQLExpression column, Comparable<?> value)
{ {
super(column, value); super(column, value);
} }
@@ -155,7 +155,7 @@ public abstract class Conditionals
/** The SQL '>' operator. */ /** The SQL '>' operator. */
public static class GreaterThan extends SQLOperator.BinaryOperator public static class GreaterThan extends SQLOperator.BinaryOperator
{ {
public GreaterThan (SQLExpression column, Comparable value) public GreaterThan (SQLExpression column, Comparable<?> value)
{ {
super(column, value); super(column, value);
} }
@@ -175,7 +175,7 @@ public abstract class Conditionals
/** The SQL '>=' operator. */ /** The SQL '>=' operator. */
public static class GreaterThanEquals extends SQLOperator.BinaryOperator public static class GreaterThanEquals extends SQLOperator.BinaryOperator
{ {
public GreaterThanEquals (SQLExpression column, Comparable value) public GreaterThanEquals (SQLExpression column, Comparable<?> value)
{ {
super(column, value); super(column, value);
} }
@@ -196,18 +196,18 @@ public abstract class Conditionals
public static class In public static class In
implements SQLOperator implements SQLOperator
{ {
public In (Class<? extends PersistentRecord> pClass, String pColumn, Comparable... values) public In (Class<? extends PersistentRecord> pClass, String pColumn, Comparable<?>... values)
{ {
this(new ColumnExp(pClass, pColumn), values); this(new ColumnExp(pClass, pColumn), values);
} }
public In (Class<? extends PersistentRecord> pClass, String pColumn, public In (Class<? extends PersistentRecord> pClass, String pColumn,
Collection<? extends Comparable> values) Collection<? extends Comparable<?>> values)
{ {
this(new ColumnExp(pClass, pColumn), values.toArray(new Comparable[values.size()])); this(new ColumnExp(pClass, pColumn), values.toArray(new Comparable<?>[values.size()]));
} }
public In (ColumnExp column, Comparable... values) public In (ColumnExp column, Comparable<?>... values)
{ {
if (values.length == 0) { if (values.length == 0) {
throw new IllegalArgumentException("In() condition needs at least one value."); throw new IllegalArgumentException("In() condition needs at least one value.");
@@ -216,9 +216,9 @@ public abstract class Conditionals
_values = values; _values = values;
} }
public In (ColumnExp pColumn, Collection<? extends Comparable> values) public In (ColumnExp pColumn, Collection<? extends Comparable<?>> values)
{ {
this(pColumn, values.toArray(new Comparable[values.size()])); this(pColumn, values.toArray(new Comparable<?>[values.size()]));
} }
public ColumnExp getColumn () public ColumnExp getColumn ()
@@ -226,7 +226,7 @@ public abstract class Conditionals
return _column; return _column;
} }
public Comparable[] getValues () public Comparable<?>[] getValues ()
{ {
return _values; return _values;
} }
@@ -244,13 +244,13 @@ public abstract class Conditionals
} }
protected ColumnExp _column; protected ColumnExp _column;
protected Comparable[] _values; protected Comparable<?>[] _values;
} }
/** The SQL ' like ' operator. */ /** The SQL ' like ' operator. */
public static class Like extends SQLOperator.BinaryOperator public static class Like extends SQLOperator.BinaryOperator
{ {
public Like (SQLExpression column, Comparable value) public Like (SQLExpression column, Comparable<?> value)
{ {
super(column, value); super(column, value);
} }
@@ -83,7 +83,7 @@ public interface SQLOperator extends SQLExpression
_rhs = rhs; _rhs = rhs;
} }
public BinaryOperator (SQLExpression lhs, Comparable rhs) public BinaryOperator (SQLExpression lhs, Comparable<?> rhs)
{ {
this(lhs, new ValueExp(rhs)); this(lhs, new ValueExp(rhs));
} }
@@ -140,7 +140,7 @@ public class GenRecordTask extends Task
} }
/** Processes a resolved persistent record class instance. */ /** Processes a resolved persistent record class instance. */
protected void processRecord (File source, Class rclass) protected void processRecord (File source, Class<?> rclass)
{ {
// make sure we extend persistent record // make sure we extend persistent record
if (!_prclass.isAssignableFrom(rclass)) { if (!_prclass.isAssignableFrom(rclass)) {
@@ -391,7 +391,7 @@ class FieldDescriptor
protected String name; // full (compound) name of component protected String name; // full (compound) name of component
protected Field field; // field info from java.lang.reflect protected Field field; // field info from java.lang.reflect
protected Constructor constructor; // constructor of object component protected Constructor<?> constructor; // constructor of object component
protected static final int t_byte = 0; protected static final int t_byte = 0;
protected static final int t_short = 1; protected static final int t_short = 1;
@@ -100,7 +100,7 @@ public class FieldMask
* Returns true only if the set of modified fields is a subset of the * Returns true only if the set of modified fields is a subset of the
* fields specified. * fields specified.
*/ */
public final boolean onlySubsetModified (Set fieldSet) public final boolean onlySubsetModified (Set<String> fieldSet)
{ {
for (String field : _descripMap.keySet()) { for (String field : _descripMap.keySet()) {
if (isModified(field) && (!fieldSet.contains(field))) { if (isModified(field) && (!fieldSet.contains(field))) {
+8 -7
View File
@@ -486,11 +486,11 @@ public class Table<T>
} }
protected final int buildFieldsList (ArrayList<FieldDescriptor> buf, protected final int buildFieldsList (ArrayList<FieldDescriptor> buf,
Class _rowClass, String prefix) Class<?> _rowClass, String prefix)
{ {
Field[] f = _rowClass.getDeclaredFields(); Field[] f = _rowClass.getDeclaredFields();
Class superclass = _rowClass; Class<?> superclass = _rowClass;
while ((superclass = superclass.getSuperclass()) != null) { while ((superclass = superclass.getSuperclass()) != null) {
Field[] inheritedFields = superclass.getDeclaredFields(); Field[] inheritedFields = superclass.getDeclaredFields();
Field[] allFields = new Field[inheritedFields.length + f.length]; Field[] allFields = new Field[inheritedFields.length + f.length];
@@ -908,10 +908,11 @@ public class Table<T>
static { static {
try { try {
serializableClass = Serializable.class; serializableClass = Serializable.class;
Class<?> c = Class.forName("java.lang.reflect.AccessibleObject"); Class<?> c = Class.forName("java.lang.reflect.AccessibleObject");
Class[] param = { Boolean.TYPE }; setBypass = c.getMethod("setAccessible", new Class<?>[] { Boolean.TYPE });
setBypass = c.getMethod("setAccessible", param); } catch(Exception ex) {
} catch(Exception ex) {} // nothing to do
}
} }
} }
@@ -258,7 +258,7 @@ public class MessageManager
ResourceBundle bundle = null; ResourceBundle bundle = null;
if (req != null) { if (req != null) {
Enumeration locales = req.getLocales(); Enumeration<?> locales = req.getLocales();
while (locales.hasMoreElements()) { while (locales.hasMoreElements()) {
Locale locale = (Locale)locales.nextElement(); Locale locale = (Locale)locales.nextElement();
@@ -81,7 +81,7 @@ public class ExceptionMap
if (_keys != null) { if (_keys != null) {
return; return;
} else { } else {
_keys = new ArrayList<Class>(); _keys = new ArrayList<Class<?>>();
_values = new ArrayList<String>(); _values = new ArrayList<String>();
} }
@@ -113,7 +113,7 @@ public class ExceptionMap
for (int i = 0; i < classes.size(); i++) { for (int i = 0; i < classes.size(); i++) {
String exclass = classes.get(i); String exclass = classes.get(i);
try { try {
Class cl = Class.forName(exclass); Class<?> cl = Class.forName(exclass);
// replace the string with the class object // replace the string with the class object
_keys.add(cl); _keys.add(cl);
@@ -146,7 +146,7 @@ public class ExceptionMap
{ {
String msg = DEFAULT_ERROR_MSG; String msg = DEFAULT_ERROR_MSG;
for (int i = 0; i < _keys.size(); i++) { for (int i = 0; i < _keys.size(); i++) {
Class cl = _keys.get(i); Class<?> cl = _keys.get(i);
if (cl.isInstance(ex)) { if (cl.isInstance(ex)) {
msg = _values.get(i); msg = _values.get(i);
break; break;
@@ -155,7 +155,7 @@ public class ExceptionMap
return StringUtil.replace(msg, MESSAGE_MARKER, ex.getMessage()); return StringUtil.replace(msg, MESSAGE_MARKER, ex.getMessage());
} }
protected static List<Class> _keys; protected static List<Class<?>> _keys;
protected static List<String> _values; protected static List<String> _values;
// initialize ourselves // initialize ourselves
@@ -20,7 +20,6 @@
package com.samskivert.servlet.util; package com.samskivert.servlet.util;
import java.util.Iterator;
import java.util.Map; import java.util.Map;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
@@ -109,13 +108,15 @@ public class RequestUtils
public static String reconstructURL (HttpServletRequest req) public static String reconstructURL (HttpServletRequest req)
{ {
StringBuffer buf = req.getRequestURL(); StringBuffer buf = req.getRequestURL();
Map map = req.getParameterMap(); @SuppressWarnings("unchecked") Map<String, String[]> map = req.getParameterMap();
if (map.size() > 0) { if (map.size() > 0) {
buf.append("?"); buf.append("?");
for (Iterator iter = map.entrySet().iterator(); iter.hasNext(); ) { for (Map.Entry<String, String[]> entry : map.entrySet()) {
Map.Entry entry = (Map.Entry)iter.next(); if (buf.charAt(buf.length()-1) != '?') {
buf.append("&");
}
buf.append(entry.getKey()).append("="); buf.append(entry.getKey()).append("=");
String[] values = (String[])entry.getValue(); String[] values = entry.getValue();
if (values.length == 1) { if (values.length == 1) {
buf.append(values[0]); buf.append(values[0]);
} else { } else {
@@ -128,9 +129,6 @@ public class RequestUtils
} }
buf.append(")"); buf.append(")");
} }
if (iter.hasNext()) {
buf.append("&");
}
} }
} }
return buf.toString(); return buf.toString();
@@ -356,7 +356,7 @@ public abstract class Controller
Method method, Object source, Object argument) Method method, Object source, Object argument)
{ {
// figure out what sort of arguments are required by the method // figure out what sort of arguments are required by the method
Class[] atypes = method.getParameterTypes(); Class<?>[] atypes = method.getParameterTypes();
if (atypes == null || atypes.length == 0) { if (atypes == null || atypes.length == 0) {
return new Object[0]; return new Object[0];
@@ -72,9 +72,9 @@ public class ObjectEditorTable extends JTable
* the field is used, or its object equivalent if it is a primitive * the field is used, or its object equivalent if it is a primitive
* class. * class.
*/ */
public Class getClass (Field field) public Class<?> getClass (Field field)
{ {
Class clazz = field.getType(); Class<?> clazz = field.getType();
return ClassUtil.objectEquivalentOf(clazz); return ClassUtil.objectEquivalentOf(clazz);
} }
@@ -111,7 +111,7 @@ public class ObjectEditorTable extends JTable
* *
* @param protoClass the Class of the data that will be displayed. * @param protoClass the Class of the data that will be displayed.
*/ */
public ObjectEditorTable (Class protoClass) public ObjectEditorTable (Class<?> protoClass)
{ {
this(protoClass, null); this(protoClass, null);
} }
@@ -122,7 +122,7 @@ public class ObjectEditorTable extends JTable
* @param protoClass the Class of the data that will be displayed. * @param protoClass the Class of the data that will be displayed.
* @param editableFields the names of the fields that are editable. * @param editableFields the names of the fields that are editable.
*/ */
public ObjectEditorTable (Class protoClass, String[] editableFields) public ObjectEditorTable (Class<?> protoClass, String[] editableFields)
{ {
this(protoClass, editableFields, null); this(protoClass, editableFields, null);
} }
@@ -134,7 +134,7 @@ public class ObjectEditorTable extends JTable
* @param editableFields the names of the fields that are editable. * @param editableFields the names of the fields that are editable.
* @param interp The {@link FieldInterpreter} to use. * @param interp The {@link FieldInterpreter} to use.
*/ */
public ObjectEditorTable (Class protoClass, String[] editableFields, public ObjectEditorTable (Class<?> protoClass, String[] editableFields,
FieldInterpreter interp) FieldInterpreter interp)
{ {
this(protoClass, editableFields, interp, null); this(protoClass, editableFields, interp, null);
@@ -148,7 +148,7 @@ public class ObjectEditorTable extends JTable
* @param interp The {@link FieldInterpreter} to use. * @param interp The {@link FieldInterpreter} to use.
* @param displayFields the fields to display, or null to display all. * @param displayFields the fields to display, or null to display all.
*/ */
public ObjectEditorTable (Class protoClass, String[] editableFields, public ObjectEditorTable (Class<?> protoClass, String[] editableFields,
FieldInterpreter interp, String[] displayFields) FieldInterpreter interp, String[] displayFields)
{ {
_interp = (interp != null) ? interp : new FieldInterpreter(); _interp = (interp != null) ? interp : new FieldInterpreter();
@@ -193,13 +193,13 @@ public class TGraphics2D extends Graphics2D
return _primary.getRenderingHint(k); return _primary.getRenderingHint(k);
} }
public void setRenderingHints (Map m) public void setRenderingHints (Map<?, ?> m)
{ {
_copy.setRenderingHints(m); _copy.setRenderingHints(m);
_primary.setRenderingHints(m); _primary.setRenderingHints(m);
} }
public void addRenderingHints (Map m) public void addRenderingHints (Map<?, ?> m)
{ {
_copy.addRenderingHints(m); _copy.addRenderingHints(m);
_primary.addRenderingHints(m); _primary.addRenderingHints(m);
@@ -553,7 +553,7 @@ public class TGraphics2D extends Graphics2D
return _primary.toString(); return _primary.toString();
} }
@SuppressWarnings("deprecation") @Deprecated
public Rectangle getClipRect () public Rectangle getClipRect ()
{ {
// getClipRect is deprecated, but getClipBounds is the new way to do the same thing. We // getClipRect is deprecated, but getClipBounds is the new way to do the same thing. We
@@ -108,8 +108,8 @@ public class TableSorter extends AbstractTableModel {
private JTableHeader tableHeader; private JTableHeader tableHeader;
private MouseListener mouseListener; private MouseListener mouseListener;
private TableModelListener tableModelListener; private TableModelListener tableModelListener;
private Map<Class,Comparator<Object>> columnComparators = private Map<Class<?>,Comparator<Object>> columnComparators =
new HashMap<Class,Comparator<Object>>(); new HashMap<Class<?>,Comparator<Object>>();
private List<Directive> sortingColumns = new ArrayList<Directive>(); private List<Directive> sortingColumns = new ArrayList<Directive>();
public TableSorter() { public TableSorter() {
@@ -221,7 +221,7 @@ public class TableSorter extends AbstractTableModel {
sortingStatusChanged(); sortingStatusChanged();
} }
public void setColumnComparator(Class type, Comparator<Object> comparator) { public void setColumnComparator(Class<?> type, Comparator<Object> comparator) {
if (comparator == null) { if (comparator == null) {
columnComparators.remove(type); columnComparators.remove(type);
} else { } else {
@@ -230,7 +230,7 @@ public class TableSorter extends AbstractTableModel {
} }
protected Comparator<Object> getComparator(int column) { protected Comparator<Object> getComparator(int column) {
Class columnType = tableModel.getColumnClass(column); Class<?> columnType = tableModel.getColumnClass(column);
Comparator<Object> comparator = columnComparators.get(columnType); Comparator<Object> comparator = columnComparators.get(columnType);
if (comparator != null) { if (comparator != null) {
return comparator; return comparator;
@@ -253,6 +253,5 @@ public class MenuUtil
} }
/** The method signature for menu callback methods. */ /** The method signature for menu callback methods. */
protected static final Class[] METHOD_ARGS = protected static final Class<?>[] METHOD_ARGS = new Class<?>[] { ActionEvent.class };
new Class[] { ActionEvent.class };
} }
@@ -160,7 +160,7 @@ public class SwingUtil
* be left at it's original location. * be left at it's original location.
*/ */
public static boolean positionRect ( public static boolean positionRect (
Rectangle r, Rectangle bounds, Collection avoidShapes) Rectangle r, Rectangle bounds, Collection<? extends Shape> avoidShapes)
{ {
Point origPos = r.getLocation(); Point origPos = r.getLocation();
Comparator<Point> comp = createPointComparator(origPos); Comparator<Point> comp = createPointComparator(origPos);
@@ -182,8 +182,8 @@ public class SwingUtil
} }
// see if it hits any shapes we're trying to avoid // see if it hits any shapes we're trying to avoid
for (Iterator iter=avoidShapes.iterator(); iter.hasNext(); ) { for (Iterator<? extends Shape> iter = avoidShapes.iterator(); iter.hasNext(); ) {
Shape shape = (Shape) iter.next(); Shape shape = iter.next();
if (shape.intersects(r)) { if (shape.intersects(r)) {
// remove that shape from our avoid list // remove that shape from our avoid list
@@ -295,7 +295,7 @@ public class ArrayIntSet extends AbstractSet<Integer>
} }
// documentation inherited from interface // documentation inherited from interface
public boolean containsAll (Collection c) public boolean containsAll (Collection<?> c)
{ {
if (c instanceof Interable) { if (c instanceof Interable) {
Interator inter = ((Interable) c).interator(); Interator inter = ((Interable) c).interator();
+19 -19
View File
@@ -41,7 +41,7 @@ public class ClassUtil
* @return true if the class is accessible, false otherwise. Presently returns true if the * @return true if the class is accessible, false otherwise. Presently returns true if the
* class is declared public. * class is declared public.
*/ */
public static boolean classIsAccessible (Class clazz) public static boolean classIsAccessible (Class<?> clazz)
{ {
return Modifier.isPublic(clazz.getModifiers()); return Modifier.isPublic(clazz.getModifiers());
} }
@@ -49,7 +49,7 @@ public class ClassUtil
/** /**
* Get the fields contained in the class and its superclasses. * Get the fields contained in the class and its superclasses.
*/ */
public static Field[] getFields (Class clazz) public static Field[] getFields (Class<?> clazz)
{ {
ArrayList<Field> list = new ArrayList<Field>(); ArrayList<Field> list = new ArrayList<Field>();
getFields(clazz, list); getFields(clazz, list);
@@ -60,10 +60,10 @@ public class ClassUtil
* Add all the fields of the specifed class (and its ancestors) to the list. Note, if we are * Add all the fields of the specifed class (and its ancestors) to the list. Note, if we are
* running in a sandbox, this will only enumerate public members. * running in a sandbox, this will only enumerate public members.
*/ */
public static void getFields (Class clazz, List<Field> addTo) public static void getFields (Class<?> clazz, List<Field> addTo)
{ {
// first get the fields of the superclass // first get the fields of the superclass
Class pclazz = clazz.getSuperclass(); Class<?> pclazz = clazz.getSuperclass();
if (pclazz != null && !pclazz.equals(Object.class)) { if (pclazz != null && !pclazz.equals(Object.class)) {
getFields(pclazz, addTo); getFields(pclazz, addTo);
} }
@@ -100,16 +100,16 @@ public class ClassUtil
* Object array. If args is null, a zero-length Class array is returned. If an element in * Object array. If args is null, a zero-length Class array is returned. If an element in
* args is null, then Void.TYPE is the corresponding Class in the return array. * args is null, then Void.TYPE is the corresponding Class in the return array.
*/ */
public static Class[] getParameterTypesFrom (Object[] args) public static Class<?>[] getParameterTypesFrom (Object[] args)
{ {
Class[] argTypes = null; Class<?>[] argTypes = null;
if (args != null) { if (args != null) {
argTypes = new Class[args.length]; argTypes = new Class[args.length];
for (int i = 0; i < args.length; ++i) { for (int i = 0; i < args.length; ++i) {
argTypes[i] = (args[i] == null) ? Void.TYPE : args[i].getClass(); argTypes[i] = (args[i] == null) ? Void.TYPE : args[i].getClass();
} }
} else { } else {
argTypes = new Class[0]; argTypes = new Class<?>[0];
} }
return argTypes; return argTypes;
} }
@@ -165,7 +165,7 @@ public class ClassUtil
* @return the nearest method located, or null if there is no such method. * @return the nearest method located, or null if there is no such method.
*/ */
public static Method getAccessibleMethodFrom ( public static Method getAccessibleMethodFrom (
Class<?> clazz, String methodName, Class[] parameterTypes) Class<?> clazz, String methodName, Class<?>[] parameterTypes)
{ {
// Look for overridden method in the superclass. // Look for overridden method in the superclass.
Class<?> superclass = clazz.getSuperclass(); Class<?> superclass = clazz.getSuperclass();
@@ -229,7 +229,7 @@ public class ClassUtil
* @return the class's primitive equivalent, if clazz is a primitive wrapper. If clazz is * @return the class's primitive equivalent, if clazz is a primitive wrapper. If clazz is
* primitive, returns clazz. Otherwise, returns null. * primitive, returns clazz. Otherwise, returns null.
*/ */
public static Class<?> primitiveEquivalentOf (Class clazz) public static Class<?> primitiveEquivalentOf (Class<?> clazz)
{ {
return clazz.isPrimitive() ? clazz : _objectToPrimitiveMap.get(clazz); return clazz.isPrimitive() ? clazz : _objectToPrimitiveMap.get(clazz);
} }
@@ -237,7 +237,7 @@ public class ClassUtil
/** /**
* @return the class's object equivalent if the class is a primitive type. * @return the class's object equivalent if the class is a primitive type.
*/ */
public static Class<?> objectEquivalentOf (Class clazz) public static Class<?> objectEquivalentOf (Class<?> clazz)
{ {
return clazz.isPrimitive() ? _primitiveToObjectMap.get(clazz) : clazz; return clazz.isPrimitive() ? _primitiveToObjectMap.get(clazz) : clazz;
} }
@@ -252,7 +252,7 @@ public class ClassUtil
* @return true if compatible, false otherwise. If either argument is <code>null</code>, or one * @return true if compatible, false otherwise. If either argument is <code>null</code>, or one
* of the parameters does not represent a primitive (e.g. Byte.TYPE), returns false. * of the parameters does not represent a primitive (e.g. Byte.TYPE), returns false.
*/ */
public static boolean primitiveIsAssignableFrom (Class lhs, Class rhs) public static boolean primitiveIsAssignableFrom (Class<?> lhs, Class<?> rhs)
{ {
if (lhs == null || rhs == null) { if (lhs == null || rhs == null) {
return false; return false;
@@ -263,7 +263,7 @@ public class ClassUtil
if (lhs.equals(rhs)) { if (lhs.equals(rhs)) {
return true; return true;
} }
Set<Class> wideningSet = _primitiveWideningsMap.get(rhs); Set<Class<?>> wideningSet = _primitiveWideningsMap.get(rhs);
if (wideningSet == null) { if (wideningSet == null) {
return false; return false;
} }
@@ -298,11 +298,11 @@ public class ClassUtil
/** Mapping from primitive wrapper Classes to the sets of primitive classes whose instances can /** Mapping from primitive wrapper Classes to the sets of primitive classes whose instances can
* be assigned an instance of the first. */ * be assigned an instance of the first. */
protected static final Map<Class,Set<Class>> _primitiveWideningsMap = protected static final Map<Class<?>,Set<Class<?>>> _primitiveWideningsMap =
new HashMap<Class,Set<Class>>(11); new HashMap<Class<?>,Set<Class<?>>>(11);
static { static {
Set<Class> set = new HashSet<Class>(); Set<Class<?>> set = new HashSet<Class<?>>();
set.add(Short.TYPE); set.add(Short.TYPE);
set.add(Integer.TYPE); set.add(Integer.TYPE);
set.add(Long.TYPE); set.add(Long.TYPE);
@@ -310,7 +310,7 @@ public class ClassUtil
set.add(Double.TYPE); set.add(Double.TYPE);
_primitiveWideningsMap.put(Byte.TYPE, set); _primitiveWideningsMap.put(Byte.TYPE, set);
set = new HashSet<Class>(); set = new HashSet<Class<?>>();
set.add(Integer.TYPE); set.add(Integer.TYPE);
set.add(Long.TYPE); set.add(Long.TYPE);
set.add(Float.TYPE); set.add(Float.TYPE);
@@ -318,18 +318,18 @@ public class ClassUtil
_primitiveWideningsMap.put(Short.TYPE, set); _primitiveWideningsMap.put(Short.TYPE, set);
_primitiveWideningsMap.put(Character.TYPE, set); _primitiveWideningsMap.put(Character.TYPE, set);
set = new HashSet<Class>(); set = new HashSet<Class<?>>();
set.add(Long.TYPE); set.add(Long.TYPE);
set.add(Float.TYPE); set.add(Float.TYPE);
set.add(Double.TYPE); set.add(Double.TYPE);
_primitiveWideningsMap.put(Integer.TYPE, set); _primitiveWideningsMap.put(Integer.TYPE, set);
set = new HashSet<Class>(); set = new HashSet<Class<?>>();
set.add(Float.TYPE); set.add(Float.TYPE);
set.add(Double.TYPE); set.add(Double.TYPE);
_primitiveWideningsMap.put(Long.TYPE, set); _primitiveWideningsMap.put(Long.TYPE, set);
set = new HashSet<Class>(); set = new HashSet<Class<?>>();
set.add(Double.TYPE); set.add(Double.TYPE);
_primitiveWideningsMap.put(Float.TYPE, set); _primitiveWideningsMap.put(Float.TYPE, set);
} }
+3 -4
View File
@@ -390,9 +390,8 @@ public class Config
} }
// build the sub-properties // build the sub-properties
Iterator iter = keys(); for (Iterator<String> iter = keys(); iter.hasNext(); ) {
while (iter.hasNext()) { String key = iter.next();
String key = (String)iter.next();
if (!key.startsWith(prefix)) { if (!key.startsWith(prefix)) {
continue; continue;
} }
@@ -416,7 +415,7 @@ public class Config
protected void enumerateKeys (HashSet<String> keys) protected void enumerateKeys (HashSet<String> keys)
{ {
Enumeration defkeys = _props.propertyNames(); Enumeration<?> defkeys = _props.propertyNames();
while (defkeys.hasMoreElements()) { while (defkeys.hasMoreElements()) {
keys.add((String)defkeys.nextElement()); keys.add((String)defkeys.nextElement());
} }
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -81,7 +81,7 @@ public class FileUtil
public static boolean unpackJar (JarFile jar, File target) public static boolean unpackJar (JarFile jar, File target)
{ {
boolean failure = false; boolean failure = false;
Enumeration entries = jar.entries(); Enumeration<?> entries = jar.entries();
while (!failure && entries.hasMoreElements()) { while (!failure && entries.hasMoreElements()) {
JarEntry entry = (JarEntry)entries.nextElement(); JarEntry entry = (JarEntry)entries.nextElement();
File efile = new File(target, entry.getName()); File efile = new File(target, entry.getName());
+1 -1
View File
@@ -48,7 +48,7 @@ public class GenUtil
if (type instanceof GenericArrayType) { if (type instanceof GenericArrayType) {
return simpleName(((GenericArrayType)type).getGenericComponentType()) + "[]"; return simpleName(((GenericArrayType)type).getGenericComponentType()) + "[]";
} else if (type instanceof Class) { } else if (type instanceof Class) {
Class clazz = (Class)type; Class<?> clazz = (Class<?>)type;
if (clazz.isArray()) { if (clazz.isArray()) {
return simpleName(clazz.getComponentType()) + "[]"; return simpleName(clazz.getComponentType()) + "[]";
} else { } else {
+2 -3
View File
@@ -538,8 +538,7 @@ public class HashIntMap<V> extends AbstractMap<Integer,V>
protected Record<V>[] createBuckets (int size) protected Record<V>[] createBuckets (int size)
{ {
@SuppressWarnings("unchecked") Record<V>[] recs = @SuppressWarnings("unchecked") Record<V>[] recs = new Record[size];
(Record<V>[]) new Record[size];
return recs; return recs;
} }
@@ -582,7 +581,7 @@ public class HashIntMap<V> extends AbstractMap<Integer,V>
if (!(o instanceof IntEntry)) { if (!(o instanceof IntEntry)) {
return false; return false;
} }
IntEntry that = (IntEntry)o; IntEntry<?> that = (IntEntry<?>)o;
return (this.key == that.getIntKey()) && return (this.key == that.getIntKey()) &&
ObjectUtil.equals(this.value, that.getValue()); ObjectUtil.equals(this.value, that.getValue());
} }
@@ -48,7 +48,7 @@ public class JDK14Logger implements Logger.Factory
} }
// from interface Logger.Factory // from interface Logger.Factory
public Logger getLogger (Class clazz) public Logger getLogger (Class<?> clazz)
{ {
return getLogger(clazz.getName()); return getLogger(clazz.getName());
} }
+1 -1
View File
@@ -213,7 +213,7 @@ public final class Log
try { try {
provider = System.getProperty("log_provider"); provider = System.getProperty("log_provider");
if (provider != null) { if (provider != null) {
Class lpclass = Class.forName(provider); Class<?> lpclass = Class.forName(provider);
_provider = (LogProvider)lpclass.newInstance(); _provider = (LogProvider)lpclass.newInstance();
} }
@@ -39,7 +39,7 @@ public class Log4JLogger implements Logger.Factory
} }
// from interface Logger.Factory // from interface Logger.Factory
public Logger getLogger (Class clazz) public Logger getLogger (Class<?> clazz)
{ {
return getLogger(clazz.getName()); return getLogger(clazz.getName());
} }
+2 -2
View File
@@ -47,7 +47,7 @@ public abstract class Logger
{ {
public void init (); public void init ();
public Logger getLogger (String name); public Logger getLogger (String name);
public Logger getLogger (Class clazz); public Logger getLogger (Class<?> clazz);
} }
/** /**
@@ -61,7 +61,7 @@ public abstract class Logger
/** /**
* Obtains a logger with a name equal to the supplied class's name. * Obtains a logger with a name equal to the supplied class's name.
*/ */
public static Logger getLogger (Class clazz) public static Logger getLogger (Class<?> clazz)
{ {
return _factory.getLogger(clazz); return _factory.getLogger(clazz);
} }
+1 -1
View File
@@ -69,7 +69,7 @@ public class MapEntry<K,V> implements Map.Entry<K,V>
if (!(o instanceof Map.Entry)) { if (!(o instanceof Map.Entry)) {
return false; return false;
} }
Map.Entry e = (Map.Entry)o; Map.Entry<?, ?> e = (Map.Entry<?, ?>)o;
return ObjectUtil.equals(_key, e.getKey()) && return ObjectUtil.equals(_key, e.getKey()) &&
ObjectUtil.equals(_value, e.getValue()); ObjectUtil.equals(_value, e.getValue());
} }
+12 -12
View File
@@ -50,7 +50,7 @@ public class MethodFinder
* @exception IllegalArgumentException if clazz is null, or represents a primitive, or * @exception IllegalArgumentException if clazz is null, or represents a primitive, or
* represents an array type. * represents an array type.
*/ */
public MethodFinder (Class clazz) public MethodFinder (Class<?> clazz)
{ {
if (clazz == null) { if (clazz == null) {
throw new IllegalArgumentException("null Class parameter"); throw new IllegalArgumentException("null Class parameter");
@@ -91,7 +91,7 @@ public class MethodFinder
* @exception NoSuchMethodException if no constructors match the criteria, or if the reflective * @exception NoSuchMethodException if no constructors match the criteria, or if the reflective
* call is ambiguous based on the parameter types. * call is ambiguous based on the parameter types.
*/ */
public Constructor findConstructor (Class[] parameterTypes) public Constructor<?> findConstructor (Class<?>[] parameterTypes)
throws NoSuchMethodException throws NoSuchMethodException
{ {
// make sure the constructor list is loaded // make sure the constructor list is loaded
@@ -101,7 +101,7 @@ public class MethodFinder
parameterTypes = new Class[0]; parameterTypes = new Class[0];
} }
return (Constructor)findMemberIn(_ctorList, parameterTypes); return (Constructor<?>)findMemberIn(_ctorList, parameterTypes);
} }
/** /**
@@ -121,7 +121,7 @@ public class MethodFinder
* @exception NoSuchMethodException if no methods match the criteria, or if the reflective call * @exception NoSuchMethodException if no methods match the criteria, or if the reflective call
* is ambiguous based on the parameter types, or if methodName is null. * is ambiguous based on the parameter types, or if methodName is null.
*/ */
public Method findMethod (String methodName, Class[] parameterTypes) public Method findMethod (String methodName, Class<?>[] parameterTypes)
throws NoSuchMethodException throws NoSuchMethodException
{ {
// make sure the constructor list is loaded // make sure the constructor list is loaded
@@ -155,14 +155,14 @@ public class MethodFinder
* Basis of {@link #findConstructor} and {@link #findMethod}. The member list fed to this * Basis of {@link #findConstructor} and {@link #findMethod}. The member list fed to this
* method will be either all {@link Constructor} objects or all {@link Method} objects. * method will be either all {@link Constructor} objects or all {@link Method} objects.
*/ */
protected Member findMemberIn (List<Member> memberList, Class[] parameterTypes) protected Member findMemberIn (List<Member> memberList, Class<?>[] parameterTypes)
throws NoSuchMethodException throws NoSuchMethodException
{ {
List<Member> matchingMembers = new ArrayList<Member>(); List<Member> matchingMembers = new ArrayList<Member>();
for (Iterator<Member> it = memberList.iterator(); it.hasNext();) { for (Iterator<Member> it = memberList.iterator(); it.hasNext();) {
Member member = it.next(); Member member = it.next();
Class[] methodParamTypes = _paramMap.get(member); Class<?>[] methodParamTypes = _paramMap.get(member);
// check for exactly equal method signature // check for exactly equal method signature
if (Arrays.equals(methodParamTypes, parameterTypes)) { if (Arrays.equals(methodParamTypes, parameterTypes)) {
@@ -256,7 +256,7 @@ public class MethodFinder
{ {
if (_ctorList == null) { if (_ctorList == null) {
_ctorList = new ArrayList<Member>(); _ctorList = new ArrayList<Member>();
Constructor[] ctors = _clazz.getConstructors(); Constructor<?>[] ctors = _clazz.getConstructors();
for (int i = 0; i < ctors.length; ++i) { for (int i = 0; i < ctors.length; ++i) {
_ctorList.add(ctors[i]); _ctorList.add(ctors[i]);
_paramMap.put(ctors[i], ctors[i].getParameterTypes()); _paramMap.put(ctors[i], ctors[i].getParameterTypes());
@@ -276,7 +276,7 @@ public class MethodFinder
for (int i = 0; i < methods.length; ++i) { for (int i = 0; i < methods.length; ++i) {
Method m = methods[i]; Method m = methods[i];
String methodName = m.getName(); String methodName = m.getName();
Class[] paramTypes = m.getParameterTypes(); Class<?>[] paramTypes = m.getParameterTypes();
List<Member> list = _methodMap.get(methodName); List<Member> list = _methodMap.get(methodName);
if (list == null) { if (list == null) {
@@ -306,13 +306,13 @@ public class MethodFinder
*/ */
protected boolean memberIsMoreSpecific (Member first, Member second) protected boolean memberIsMoreSpecific (Member first, Member second)
{ {
Class[] firstParamTypes = _paramMap.get(first); Class<?>[] firstParamTypes = _paramMap.get(first);
Class[] secondParamTypes = _paramMap.get(second); Class<?>[] secondParamTypes = _paramMap.get(second);
return ClassUtil.compatibleClasses(secondParamTypes, firstParamTypes); return ClassUtil.compatibleClasses(secondParamTypes, firstParamTypes);
} }
/** The target class to look for methods and constructors in. */ /** The target class to look for methods and constructors in. */
protected Class _clazz; protected Class<?> _clazz;
/** Mapping from method name to the Methods in the target class with that name. */ /** Mapping from method name to the Methods in the target class with that name. */
protected Map<String,List<Member>> _methodMap = null; protected Map<String,List<Member>> _methodMap = null;
@@ -322,5 +322,5 @@ public class MethodFinder
/** Mapping from a Constructor or Method object to the Class objects representing its formal /** Mapping from a Constructor or Method object to the Class objects representing its formal
* parameters. */ * parameters. */
protected Map<Member,Class[]> _paramMap = new HashMap<Member,Class[]>(); protected Map<Member,Class<?>[]> _paramMap = new HashMap<Member,Class<?>[]>();
} }
+2 -2
View File
@@ -53,7 +53,7 @@ public abstract class Predicate<T>
*/ */
public static class InstanceOf<T> extends Predicate<T> public static class InstanceOf<T> extends Predicate<T>
{ {
public InstanceOf (Class clazz) public InstanceOf (Class<?> clazz)
{ {
_class = clazz; _class = clazz;
} }
@@ -65,7 +65,7 @@ public abstract class Predicate<T>
} }
/** The class that must be implemented by applicants. */ /** The class that must be implemented by applicants. */
protected Class _class; protected Class<?> _class;
} }
/** /**
@@ -162,7 +162,7 @@ public class PropertiesUtil
int preflen = prefix.length(); int preflen = prefix.length();
// scan the source properties // scan the source properties
Enumeration names = source.propertyNames(); Enumeration<?> names = source.propertyNames();
while (names.hasMoreElements()) { while (names.hasMoreElements()) {
String name = (String)names.nextElement(); String name = (String)names.nextElement();
// skip unrelated properties // skip unrelated properties
+8 -8
View File
@@ -481,11 +481,11 @@ public class StringUtil
buf.append(closeBox); buf.append(closeBox);
} else if (val instanceof Iterable) { } else if (val instanceof Iterable) {
toString(buf, ((Iterable)val).iterator(), openBox, closeBox); toString(buf, ((Iterable<?>)val).iterator(), openBox, closeBox);
} else if (val instanceof Iterator) { } else if (val instanceof Iterator) {
buf.append(openBox); buf.append(openBox);
Iterator iter = (Iterator)val; Iterator<?> iter = (Iterator<?>)val;
for (int i = 0; iter.hasNext(); i++) { for (int i = 0; iter.hasNext(); i++) {
if (i > 0) { if (i > 0) {
buf.append(sep); buf.append(sep);
@@ -496,7 +496,7 @@ public class StringUtil
} else if (val instanceof Enumeration) { } else if (val instanceof Enumeration) {
buf.append(openBox); buf.append(openBox);
Enumeration enm = (Enumeration)val; Enumeration<?> enm = (Enumeration<?>)val;
for (int i = 0; enm.hasMoreElements(); i++) { for (int i = 0; enm.hasMoreElements(); i++) {
if (i > 0) { if (i > 0) {
buf.append(sep); buf.append(sep);
@@ -551,7 +551,7 @@ public class StringUtil
{ {
// get an iterator if this is a collection // get an iterator if this is a collection
if (val instanceof Iterable) { if (val instanceof Iterable) {
val = ((Iterable)val).iterator(); val = ((Iterable<?>)val).iterator();
} }
String openBox = formatter.getOpenBox(); String openBox = formatter.getOpenBox();
@@ -570,7 +570,7 @@ public class StringUtil
} else if (val instanceof Iterator) { } else if (val instanceof Iterator) {
buf.append(openBox); buf.append(openBox);
Iterator iter = (Iterator)val; Iterator<?> iter = (Iterator<?>)val;
for (int i = 0; iter.hasNext(); i++) { for (int i = 0; iter.hasNext(); i++) {
if (i > 0) { if (i > 0) {
buf.append(", "); buf.append(", ");
@@ -581,7 +581,7 @@ public class StringUtil
} else if (val instanceof Enumeration) { } else if (val instanceof Enumeration) {
buf.append(openBox); buf.append(openBox);
Enumeration enm = (Enumeration)val; Enumeration<?> enm = (Enumeration<?>)val;
for (int i = 0; enm.hasMoreElements(); i++) { for (int i = 0; enm.hasMoreElements(); i++) {
if (i > 0) { if (i > 0) {
buf.append(", "); buf.append(", ");
@@ -759,7 +759,7 @@ public class StringUtil
char[] chars = new char[count*2]; char[] chars = new char[count*2];
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
int val = (int)bytes[i]; int val = bytes[i];
if (val < 0) { if (val < 0) {
val += 256; val += 256;
} }
@@ -1199,7 +1199,7 @@ public class StringUtil
* name. For example, <code>com.samskivert.util.StringUtil</code> would be reported as * name. For example, <code>com.samskivert.util.StringUtil</code> would be reported as
* <code>util.StringUtil</code>. * <code>util.StringUtil</code>.
*/ */
public static String shortClassName (Class clazz) public static String shortClassName (Class<?> clazz)
{ {
return shortClassName(clazz.getName()); return shortClassName(clazz.getName());
} }
+1 -1
View File
@@ -71,7 +71,7 @@ public class Tuple<L,R> implements Serializable
public boolean equals (Object other) public boolean equals (Object other)
{ {
if (other instanceof Tuple) { if (other instanceof Tuple) {
Tuple to = (Tuple)other; Tuple<?, ?> to = (Tuple<?, ?>)other;
return (left.equals(to.left) && right.equals(to.right)); return (left.equals(to.left) && right.equals(to.right));
} else { } else {
return false; return false;
@@ -38,7 +38,7 @@ public class ValueMarshaller
* @exception Exception thrown if no field parser exists for the * @exception Exception thrown if no field parser exists for the
* target type or if an error occurs while parsing the value. * target type or if an error occurs while parsing the value.
*/ */
public static Object unmarshal (Class type, String source) public static Object unmarshal (Class<?> type, String source)
throws Exception throws Exception
{ {
// look up an argument parser for the field type // look up an argument parser for the field type
@@ -56,10 +56,10 @@ public class ValueMarshaller
public Object parse (String source) throws Exception; public Object parse (String source) throws Exception;
} }
protected static HashMap<Class,Parser> _parsers; protected static HashMap<Class<?>,Parser> _parsers;
static { static {
_parsers = new HashMap<Class,Parser>(); _parsers = new HashMap<Class<?>,Parser>();
// we can parse strings // we can parse strings
_parsers.put(String.class, new Parser() { _parsers.put(String.class, new Parser() {
@@ -62,7 +62,7 @@ public class ConfigTest extends TestCase
config.setValue("prop2", "three"); config.setValue("prop2", "three");
System.out.println("prop2: " + config.getValue("prop2", "two")); System.out.println("prop2: " + config.getValue("prop2", "two"));
Iterator iter = config.keys(); Iterator<String> iter = config.keys();
System.out.println("Keys: " + StringUtil.toString(iter)); System.out.println("Keys: " + StringUtil.toString(iter));
config.setValue("sub.sub3", "three"); config.setValue("sub.sub3", "three");
@@ -149,7 +149,7 @@ public class DispatcherServlet extends HttpServlet
if (StringUtil.isBlank(appcl)) { if (StringUtil.isBlank(appcl)) {
_app = new Application(); _app = new Application();
} else { } else {
Class appclass = Class.forName(appcl); Class<?> appclass = Class.forName(appcl);
_app = (Application)appclass.newInstance(); _app = (Application)appclass.newInstance();
} }
@@ -418,6 +418,7 @@ public class DispatcherServlet extends HttpServlet
* Called when a method throws an exception during template * Called when a method throws an exception during template
* evaluation. * evaluation.
*/ */
@SuppressWarnings("unchecked")
public Object methodException (Class clazz, String method, Exception e) public Object methodException (Class clazz, String method, Exception e)
throws Exception throws Exception
{ {
@@ -580,7 +581,7 @@ public class DispatcherServlet extends HttpServlet
if (logic == null) { if (logic == null) {
try { try {
Class pcl = Class.forName(lclass); Class<?> pcl = Class.forName(lclass);
logic = (Logic)pcl.newInstance(); logic = (Logic)pcl.newInstance();
} catch (ClassNotFoundException cnfe) { } catch (ClassNotFoundException cnfe) {
@@ -116,7 +116,7 @@ public class InvocationContext extends VelocityContext
@Deprecated @Deprecated
public void putAllParameters () public void putAllParameters ()
{ {
Enumeration e = _req.getParameterNames(); Enumeration<?> e = _req.getParameterNames();
while (e.hasMoreElements()) { while (e.hasMoreElements()) {
String param = (String)e.nextElement(); String param = (String)e.nextElement();
put(param, _req.getParameter(param)); put(param, _req.getParameter(param));
@@ -130,7 +130,7 @@ public class InvocationContext extends VelocityContext
public String encodeAllParameters () public String encodeAllParameters ()
{ {
StringBuilder buf = new StringBuilder(); StringBuilder buf = new StringBuilder();
Enumeration e = _req.getParameterNames(); Enumeration<?> e = _req.getParameterNames();
while (e.hasMoreElements()) { while (e.hasMoreElements()) {
if (buf.length() > 0) { if (buf.length() > 0) {
buf.append('&'); buf.append('&');
@@ -45,7 +45,7 @@ public class SetNextFieldRule extends Rule
// identify the objects to be used // identify the objects to be used
Object child = digester.peek(0); Object child = digester.peek(0);
Object parent = digester.peek(1); Object parent = digester.peek(1);
Class pclass = parent.getClass(); Class<?> pclass = parent.getClass();
if (digester.getLogger().isDebugEnabled()) { if (digester.getLogger().isDebugEnabled()) {
digester.getLogger().debug("Set " + pclass.getName() + "." + digester.getLogger().debug("Set " + pclass.getName() + "." +
@@ -85,10 +85,10 @@ public class SetPropertyFieldsRule extends Rule
throws Exception throws Exception
{ {
Object top = digester.peek(); Object top = digester.peek();
Class topclass = top.getClass(); Class<?> topclass = top.getClass();
// iterate over the attributes, setting public fields where applicable // iterate over the attributes, setting public fields where applicable
for (int i = 0; i < attrs.getLength(); i++) { for (int i = 0; i < attrs.getLength(); i++) {
String lname = attrs.getLocalName(i); String lname = attrs.getLocalName(i);
if (StringUtil.isBlank(lname)) { if (StringUtil.isBlank(lname)) {
lname = attrs.getQName(i); lname = attrs.getQName(i);
@@ -61,7 +61,7 @@ public class ValidatedSetNextRule extends Rule
* specified parameter type. * specified parameter type.
*/ */
public ValidatedSetNextRule ( public ValidatedSetNextRule (
String methodName, Class paramType, Validator validator) String methodName, Class<?> paramType, Validator validator)
{ {
// keep this for later // keep this for later
_methodName = methodName; _methodName = methodName;
@@ -81,14 +81,14 @@ public class ValidatedSetNextRule extends Rule
return; return;
} }
Class pclass = parent.getClass(); Class<?> pclass = parent.getClass();
if (digester.getLogger().isDebugEnabled()) { if (digester.getLogger().isDebugEnabled()) {
digester.getLogger().debug("Call " + pclass.getName() + "." + digester.getLogger().debug("Call " + pclass.getName() + "." +
_methodName + " (" + child + ")"); _methodName + " (" + child + ")");
} }
// call the specified method // call the specified method
Class[] paramTypes = new Class[1]; Class<?>[] paramTypes = new Class<?>[1];
paramTypes[0] = (_paramType == null) ? child.getClass() : _paramType; paramTypes[0] = (_paramType == null) ? child.getClass() : _paramType;
Method method = parent.getClass().getMethod(_methodName, paramTypes); Method method = parent.getClass().getMethod(_methodName, paramTypes);
method.invoke(parent, new Object[] { child }); method.invoke(parent, new Object[] { child });
@@ -111,6 +111,6 @@ public class ValidatedSetNextRule extends Rule
} }
protected String _methodName; protected String _methodName;
protected Class _paramType; protected Class<?> _paramType;
protected Validator _validator; protected Validator _validator;
} }