diff --git a/src/java/com/samskivert/jdbc/SimpleRepository.java b/src/java/com/samskivert/jdbc/SimpleRepository.java index 154d194d..549da1d3 100644 --- a/src/java/com/samskivert/jdbc/SimpleRepository.java +++ b/src/java/com/samskivert/jdbc/SimpleRepository.java @@ -37,7 +37,7 @@ public class SimpleRepository extends Repository public static interface PreCondition { /** 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. */ protected V execute (Operation op) - throws PersistenceException + throws PersistenceException { return execute(op, true, true); } @@ -114,7 +114,7 @@ public class SimpleRepository extends Repository * @return whatever value is returned by the invoked operation. */ protected V executeUpdate (Operation op) - throws PersistenceException + throws PersistenceException { return execute(op, true, false); } @@ -132,7 +132,7 @@ public class SimpleRepository extends Repository * @return whatever value is returned by the invoked operation. */ protected V execute (Operation op, boolean retryOnTransientFailure, boolean readOnly) - throws PersistenceException + throws PersistenceException { Connection conn = null; DatabaseLiaison liaison = null; diff --git a/src/java/com/samskivert/jdbc/StaticConnectionProvider.java b/src/java/com/samskivert/jdbc/StaticConnectionProvider.java index 28860f7a..f25262cb 100644 --- a/src/java/com/samskivert/jdbc/StaticConnectionProvider.java +++ b/src/java/com/samskivert/jdbc/StaticConnectionProvider.java @@ -194,14 +194,12 @@ public class StaticConnectionProvider implements ConnectionProvider public void shutdown () { // close all of the connections - Iterator iter = _keys.keySet().iterator(); - while (iter.hasNext()) { - String key = (String)iter.next(); - Mapping conmap = _keys.get(key); + for (Map.Entry entry : _keys.entrySet()) { + Mapping conmap = entry.getValue(); try { conmap.connection.close(); } catch (SQLException sqe) { - log.warning("Error shutting down connection [key=" + key + ", err=" + sqe + "]."); + log.warning("Error shutting down connection", "key", entry.getKey(), "err", sqe); } } diff --git a/src/java/com/samskivert/jdbc/TransitionRepository.java b/src/java/com/samskivert/jdbc/TransitionRepository.java index c8015cd5..fe1f650e 100644 --- a/src/java/com/samskivert/jdbc/TransitionRepository.java +++ b/src/java/com/samskivert/jdbc/TransitionRepository.java @@ -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. */ - public void transition (Class clazz, String name, Transition trans) + public void transition (Class clazz, String name, Transition trans) throws PersistenceException { if (!isTransitionApplied(clazz, name)) { @@ -94,7 +94,7 @@ public class TransitionRepository extends SimpleRepository /** * 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 { 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 * process noted it first. */ - public boolean noteTransition (Class clazz, final String name) + public boolean noteTransition (Class clazz, final String name) throws PersistenceException { final String cname = clazz.getName(); @@ -168,7 +168,7 @@ public class TransitionRepository extends SimpleRepository /** * Clear the transition. */ - public void clearTransition (Class clazz, final String name) + public void clearTransition (Class clazz, final String name) throws PersistenceException { final String cname = clazz.getName(); diff --git a/src/java/com/samskivert/jdbc/depot/BindVisitor.java b/src/java/com/samskivert/jdbc/depot/BindVisitor.java index eab550a8..3d2b2907 100644 --- a/src/java/com/samskivert/jdbc/depot/BindVisitor.java +++ b/src/java/com/samskivert/jdbc/depot/BindVisitor.java @@ -73,14 +73,14 @@ public class BindVisitor implements ExpressionVisitor public void visit (WhereCondition whereCondition) throws Exception { - for (Comparable value : whereCondition.getValues()) { + for (Comparable value : whereCondition.getValues()) { if (value != null) { _stmt.setObject(_argIdx ++, value); } } } - public void visit (Key key) + public void visit (Key key) throws Exception { key.condition.accept(this); @@ -89,12 +89,13 @@ public class BindVisitor implements ExpressionVisitor public void visit (MultiKey key) throws Exception { - for (Map.Entry entry : key.getSingleFieldsMap().entrySet()) { + + for (Map.Entry> entry : key.getSingleFieldsMap().entrySet()) { if (entry.getValue() != null) { _stmt.setObject(_argIdx ++, entry.getValue()); } } - Comparable[] values = key.getMultiValues(); + Comparable[] values = key.getMultiValues(); for (int ii = 0; ii < values.length; ii++) { _stmt.setObject(_argIdx ++, values[ii]); } @@ -130,7 +131,7 @@ public class BindVisitor implements ExpressionVisitor public void visit (In in) throws Exception { - Comparable[] values = in.getValues(); + Comparable[] values = in.getValues(); for (int ii = 0; ii < values.length; ii++) { _stmt.setObject(_argIdx ++, values[ii]); } @@ -229,7 +230,7 @@ public class BindVisitor implements ExpressionVisitor public void visit (UpdateClause updateClause) throws Exception { - DepotMarshaller marsh = _types.getMarshaller(updateClause.getPersistentClass()); + DepotMarshaller marsh = _types.getMarshaller(updateClause.getPersistentClass()); // bind the update arguments String[] fields = updateClause.getFields(); @@ -251,7 +252,7 @@ public class BindVisitor implements ExpressionVisitor public void visit (InsertClause insertClause) throws Exception { - DepotMarshaller marsh = _types.getMarshaller(insertClause.getPersistentClass()); + DepotMarshaller marsh = _types.getMarshaller(insertClause.getPersistentClass()); Object pojo = insertClause.getPojo(); Set idFields = insertClause.getIdentityFields(); diff --git a/src/java/com/samskivert/jdbc/depot/BuildVisitor.java b/src/java/com/samskivert/jdbc/depot/BuildVisitor.java index 83444999..7816c9bf 100644 --- a/src/java/com/samskivert/jdbc/depot/BuildVisitor.java +++ b/src/java/com/samskivert/jdbc/depot/BuildVisitor.java @@ -98,7 +98,7 @@ public abstract class BuildVisitor implements ExpressionVisitor { Class pClass = whereCondition.getPersistentClass(); String[] keyFields = Key.getKeyFields(pClass); - List values = whereCondition.getValues(); + List> values = whereCondition.getValues(); for (int ii = 0; ii < keyFields.length; ii ++) { if (ii > 0) { _builder.append(" and "); @@ -113,7 +113,7 @@ public abstract class BuildVisitor implements ExpressionVisitor } } - public void visit (Key key) + public void visit (Key key) throws Exception { _builder.append(" where "); @@ -125,7 +125,7 @@ public abstract class BuildVisitor implements ExpressionVisitor { _builder.append(" where "); boolean first = true; - for (Map.Entry entry : key.getSingleFieldsMap().entrySet()) { + for (Map.Entry> entry : key.getSingleFieldsMap().entrySet()) { if (first) { first = false; } else { @@ -145,7 +145,7 @@ public abstract class BuildVisitor implements ExpressionVisitor appendRhsColumn(key.getPersistentClass(), key.getMultiField()); _builder.append(" in ("); - Comparable[] values = key.getMultiValues(); + Comparable[] values = key.getMultiValues(); for (int ii = 0; ii < values.length; ii ++) { if (ii > 0) { _builder.append(", "); @@ -206,7 +206,7 @@ public abstract class BuildVisitor implements ExpressionVisitor { in.getColumn().accept(this); _builder.append(" in ("); - Comparable[] values = in.getValues(); + Comparable[] values = in.getValues(); for (int ii = 0; ii < values.length; ii ++) { if (ii > 0) { _builder.append(", "); @@ -465,7 +465,7 @@ public abstract class BuildVisitor implements ExpressionVisitor throws Exception { Class pClass = insertClause.getPersistentClass(); - DepotMarshaller marsh = _types.getMarshaller(pClass); + DepotMarshaller marsh = _types.getMarshaller(pClass); _innerClause = true; String[] fields = marsh.getColumnFieldNames(); @@ -514,8 +514,8 @@ public abstract class BuildVisitor implements ExpressionVisitor protected void appendLhsColumn (Class type, String field) throws Exception { - DepotMarshaller dm = _types.getMarshaller(type); - FieldMarshaller fm = dm.getFieldMarshaller(field); + DepotMarshaller dm = _types.getMarshaller(type); + FieldMarshaller fm = dm.getFieldMarshaller(field); if (dm == null) { throw new IllegalArgumentException( "Unknown field on persistent record [record=" + type + ", field=" + field + "]"); @@ -529,8 +529,8 @@ public abstract class BuildVisitor implements ExpressionVisitor protected void appendRhsColumn (Class type, String field) throws Exception { - DepotMarshaller dm = _types.getMarshaller(type); - FieldMarshaller fm = dm.getFieldMarshaller(field); + DepotMarshaller dm = _types.getMarshaller(type); + FieldMarshaller fm = dm.getFieldMarshaller(field); if (dm == null) { throw new IllegalArgumentException( "Unknown field on persistent record [record=" + type + ", field=" + field + "]"); diff --git a/src/java/com/samskivert/jdbc/depot/DepotMarshaller.java b/src/java/com/samskivert/jdbc/depot/DepotMarshaller.java index 2915bf02..79911032 100644 --- a/src/java/com/samskivert/jdbc/depot/DepotMarshaller.java +++ b/src/java/com/samskivert/jdbc/depot/DepotMarshaller.java @@ -120,14 +120,14 @@ public class DepotMarshaller continue; } - FieldMarshaller fm = FieldMarshaller.createMarshaller(field); + FieldMarshaller fm = FieldMarshaller.createMarshaller(field); _fields.put(field.getName(), fm); fields.add(field.getName()); // check to see if this is our primary key if (field.getAnnotation(Id.class) != null) { if (_pkColumns == null) { - _pkColumns = new ArrayList(); + _pkColumns = new ArrayList>(); } _pkColumns.add(fm); } @@ -194,7 +194,7 @@ public class DepotMarshaller String[] conFields = constraint.fieldNames(); Set colSet = new HashSet(); for (int ii = 0; ii < conFields.length; ii ++) { - FieldMarshaller fm = _fields.get(conFields[ii]); + FieldMarshaller fm = _fields.get(conFields[ii]); if (fm == null) { throw new IllegalArgumentException( "Unknown unique constraint field: " + conFields[ii]); @@ -287,7 +287,7 @@ public class DepotMarshaller /** * 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); } @@ -349,11 +349,11 @@ public class DepotMarshaller } try { - Comparable[] values = new Comparable[_pkColumns.size()]; + Comparable[] values = new Comparable[_pkColumns.size()]; int nulls = 0; for (int ii = 0; ii < _pkColumns.size(); ii++) { - FieldMarshaller field = _pkColumns.get(ii); - if ((values[ii] = (Comparable)field.getField().get(object)) == null) { + FieldMarshaller field = _pkColumns.get(ii); + if ((values[ii] = (Comparable)field.getField().get(object)) == null) { nulls++; } } @@ -383,7 +383,7 @@ public class DepotMarshaller * Creates a primary key record for the type of object handled by this marshaller, using the * supplied primary key value. */ - public Key makePrimaryKey (Comparable... values) + public Key makePrimaryKey (Comparable... values) { if (!hasPrimaryKey()) { throw new UnsupportedOperationException( @@ -407,14 +407,14 @@ public class DepotMarshaller throw new UnsupportedOperationException( 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++) { Object keyValue = _pkColumns.get(ii).getFromSet(rs); - if (!(keyValue instanceof Comparable)) { - throw new IllegalArgumentException("Key field must be Comparable [field=" + + if (!(keyValue instanceof Comparable)) { + throw new IllegalArgumentException("Key field must be Comparable [field=" + _pkColumns.get(ii).getColumnName() + "]"); } - values[ii] = (Comparable) keyValue; + values[ii] = (Comparable) keyValue; } return makePrimaryKey(values); } @@ -445,7 +445,7 @@ public class DepotMarshaller // then create and populate the persistent object T po = _pClass.newInstance(); - for (FieldMarshaller fm : _fields.values()) { + for (FieldMarshaller fm : _fields.values()) { if (!fields.contains(fm.getColumnName())) { // this field was not in the result set, make sure that's OK if (fm.getComputed() != null && !fm.getComputed().required()) { @@ -530,7 +530,7 @@ public class DepotMarshaller final SQLBuilder builder = ctx.getSQLBuilder(new DepotTypes(ctx, _pClass)); // perform the context-sensitive initialization of the field marshallers - for (FieldMarshaller fm : _fields.values()) { + for (FieldMarshaller fm : _fields.values()) { fm.init(builder); } @@ -545,7 +545,7 @@ public class DepotMarshaller ColumnDefinition[] declarations = new ColumnDefinition[_allFields.length]; int jj = 0; 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 ColumnDefinition colDef = fm.getColumnDefinition(); if (colDef != null) { @@ -684,7 +684,7 @@ public class DepotMarshaller // add any missing columns for (String fname : _columnFields) { - final FieldMarshaller fmarsh = _fields.get(fname); + final FieldMarshaller fmarsh = _fields.get(fname); if (metaData.tableColumns.remove(fmarsh.getColumnName())) { continue; } @@ -873,7 +873,7 @@ public class DepotMarshaller throws PersistenceException { for (String fname : _columnFields) { - FieldMarshaller fmarsh = _fields.get(fname); + FieldMarshaller fmarsh = _fields.get(fname); meta.tableColumns.remove(fmarsh.getColumnName()); } for (String column : meta.tableColumns) { @@ -977,11 +977,11 @@ public class DepotMarshaller protected Map _valueGenerators = new HashMap(); /** A field marshaller for each persistent field in our object. */ - protected Map _fields = new HashMap(); + protected Map> _fields = new HashMap>(); /** The field marshallers for our persistent object's primary key columns or null if it did not * define a primary key. */ - protected ArrayList _pkColumns; + protected ArrayList> _pkColumns; /** The persisent fields of our object, in definition order. */ protected String[] _allFields; diff --git a/src/java/com/samskivert/jdbc/depot/DepotRepository.java b/src/java/com/samskivert/jdbc/depot/DepotRepository.java index 43605428..ece90f4f 100644 --- a/src/java/com/samskivert/jdbc/depot/DepotRepository.java +++ b/src/java/com/samskivert/jdbc/depot/DepotRepository.java @@ -78,7 +78,7 @@ public abstract class DepotRepository /** * Loads the persistent object that matches the specified primary key. */ - protected T load (Class type, Comparable primaryKey, + protected T load (Class type, Comparable primaryKey, QueryClause... clauses) throws PersistenceException { @@ -89,7 +89,7 @@ public abstract class DepotRepository /** * Loads the persistent object that matches the specified primary key. */ - protected T load (Class type, String ix, Comparable val, + protected T load (Class type, String ix, Comparable val, QueryClause... clauses) throws PersistenceException { @@ -100,8 +100,8 @@ public abstract class DepotRepository /** * Loads the persistent object that matches the specified two-column primary key. */ - protected T load (Class type, String ix1, Comparable val1, - String ix2, Comparable val2, + protected T load (Class type, String ix1, Comparable val1, + String ix2, Comparable val2, QueryClause... clauses) throws PersistenceException { @@ -112,9 +112,9 @@ public abstract class DepotRepository /** * Loads the persistent object that matches the specified three-column primary key. */ - protected T load (Class type, String ix1, Comparable val1, - String ix2, Comparable val2, String ix3, - Comparable val3, QueryClause... clauses) + protected T load (Class type, String ix1, Comparable val1, + String ix2, Comparable val2, String ix3, + Comparable val3, QueryClause... clauses) throws PersistenceException { clauses = ArrayUtil.append(clauses, new Key(type, ix1, val1, ix2, val2, ix3, val3)); @@ -231,7 +231,7 @@ public abstract class DepotRepository requireNotComputed(pClass, "update"); DepotMarshaller marsh = _ctx.getMarshaller(pClass); - Key key = marsh.getPrimaryKey(record); + Key key = marsh.getPrimaryKey(record); if (key == null) { throw new IllegalArgumentException("Can't update record with null primary key."); } @@ -269,7 +269,8 @@ public abstract class DepotRepository requireNotComputed(pClass, "updatePartial"); DepotMarshaller marsh = _ctx.getMarshaller(pClass); - Key key = marsh.getPrimaryKey(record); + + Key key = marsh.getPrimaryKey(record); if (key == null) { 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. */ protected int updatePartial ( - Class type, Comparable primaryKey, Map updates) + Class type, Comparable primaryKey, Map updates) throws PersistenceException { Object[] fieldsValues = new Object[updates.size()*2]; @@ -328,7 +329,7 @@ public abstract class DepotRepository * @return the number of rows modified by this action. */ protected int updatePartial ( - Class type, Comparable primaryKey, Object... fieldsValues) + Class type, Comparable primaryKey, Object... fieldsValues) throws PersistenceException { 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. */ protected int updatePartial ( - Class type, String ix1, Comparable val1, String ix2, Comparable val2, + Class type, String ix1, Comparable val1, String ix2, Comparable val2, Object... fieldsValues) throws PersistenceException { @@ -365,8 +366,8 @@ public abstract class DepotRepository * @return the number of rows modified by this action. */ protected int updatePartial ( - Class type, String ix1, Comparable val1, String ix2, Comparable val2, - String ix3, Comparable val3, Object... fieldsValues) + Class type, String ix1, Comparable val1, String ix2, Comparable val2, + String ix3, Comparable val3, Object... fieldsValues) throws PersistenceException { return updatePartial(new Key(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. */ protected int updateLiteral ( - Class type, Comparable primaryKey, Map fieldsToValues) + Class type, Comparable primaryKey, Map fieldsToValues) throws PersistenceException { Key key = _ctx.getMarshaller(type).makePrimaryKey(primaryKey); @@ -477,7 +478,7 @@ public abstract class DepotRepository * @return the number of rows modified by this action. */ protected int updateLiteral ( - Class type, String ix1, Comparable val1, String ix2, Comparable val2, + Class type, String ix1, Comparable val1, String ix2, Comparable val2, Map fieldsToValues) throws PersistenceException { @@ -503,8 +504,8 @@ public abstract class DepotRepository * @return the number of rows modified by this action. */ protected int updateLiteral ( - Class type, String ix1, Comparable val1, String ix2, Comparable val2, - String ix3, Comparable val3, Map fieldsToValues) + Class type, String ix1, Comparable val1, String ix2, Comparable val2, + String ix3, Comparable val3, Map fieldsToValues) throws PersistenceException { Key key = new Key(type, ix1, val1, ix2, val2, ix3, val3); @@ -662,7 +663,8 @@ public abstract class DepotRepository * * @return the number of rows deleted by this action. */ - protected int delete (Class type, Comparable primaryKeyValue) + protected int delete ( + Class type, Comparable primaryKeyValue) throws PersistenceException { return delete(type, _ctx.getMarshaller(type).makePrimaryKey(primaryKeyValue)); @@ -714,7 +716,7 @@ public abstract class DepotRepository protected void requireNotComputed (Class type, String action) throws PersistenceException { - DepotMarshaller marsh = _ctx.getMarshaller(type); + DepotMarshaller marsh = _ctx.getMarshaller(type); if (marsh == null) { throw new PersistenceException("Unknown persistent type [class=" + type + "]"); } diff --git a/src/java/com/samskivert/jdbc/depot/DepotTypes.java b/src/java/com/samskivert/jdbc/depot/DepotTypes.java index 681e1334..d99f69c3 100644 --- a/src/java/com/samskivert/jdbc/depot/DepotTypes.java +++ b/src/java/com/samskivert/jdbc/depot/DepotTypes.java @@ -152,9 +152,9 @@ public class DepotTypes * * @exception IllegalArgumentException thrown if the specified class is not known. */ - public DepotMarshaller getMarshaller (Class cl) + public DepotMarshaller getMarshaller (Class cl) { - DepotMarshaller marsh = _classMap.get(cl); + DepotMarshaller marsh = _classMap.get(cl); if (marsh == null) { throw new IllegalArgumentException("Persistent class not known: " + cl); } @@ -202,10 +202,11 @@ public class DepotTypes } /** Classes mapped to integers, used for table abbreviation indexing. */ - protected Map _classIx = new HashMap(); + protected Map, Integer> _classIx = new HashMap, Integer>(); /** Classes mapped to marshallers, used for table names and field lists. */ - protected Map _classMap = new HashMap(); + protected Map, DepotMarshaller> _classMap = + new HashMap, DepotMarshaller>(); /** When false, override the normal table abbreviations and return full table names instead. */ protected boolean _useTableAbbreviations = true; diff --git a/src/java/com/samskivert/jdbc/depot/EntityMigration.java b/src/java/com/samskivert/jdbc/depot/EntityMigration.java index f48da575..18593fd8 100644 --- a/src/java/com/samskivert/jdbc/depot/EntityMigration.java +++ b/src/java/com/samskivert/jdbc/depot/EntityMigration.java @@ -101,7 +101,7 @@ public abstract class EntityMigration extends Modifier return true; } - protected void init (String tableName, Map marshallers) { + protected void init (String tableName, Map> marshallers) { super.init(tableName, marshallers); _newColumnDef = marshallers.get(_newColumnName).getColumnDefinition(); } @@ -133,7 +133,7 @@ public abstract class EntityMigration extends Modifier return false; } - protected void init (String tableName, Map marshallers) { + protected void init (String tableName, Map> marshallers) { super.init(tableName, marshallers); _columnName = marshallers.get(_fieldName).getColumnName(); _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 * called in {@link #shouldRunMigration}. */ - protected void init (String tableName, Map marshallers) + protected void init (String tableName, Map> marshallers) { _tableName = tableName; } diff --git a/src/java/com/samskivert/jdbc/depot/FieldMarshaller.java b/src/java/com/samskivert/jdbc/depot/FieldMarshaller.java index 2358f587..6b9d3e0f 100644 --- a/src/java/com/samskivert/jdbc/depot/FieldMarshaller.java +++ b/src/java/com/samskivert/jdbc/depot/FieldMarshaller.java @@ -52,10 +52,10 @@ public abstract class FieldMarshaller * Creates and returns a field marshaller for the specified field. Throws an exception if the * field in question cannot be marshalled. */ - public static FieldMarshaller createMarshaller (Field field) + public static FieldMarshaller createMarshaller (Field field) { Class ftype = field.getType(); - FieldMarshaller marshaller; + FieldMarshaller marshaller; // primitive types if (ftype.equals(Boolean.TYPE)) { diff --git a/src/java/com/samskivert/jdbc/depot/FindAllQuery.java b/src/java/com/samskivert/jdbc/depot/FindAllQuery.java index fad76858..4784d971 100644 --- a/src/java/com/samskivert/jdbc/depot/FindAllQuery.java +++ b/src/java/com/samskivert/jdbc/depot/FindAllQuery.java @@ -117,7 +117,7 @@ public abstract class FindAllQuery if (_marsh.getPrimaryKeyFields().length == 1) { // 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; for (Key key : fetchKeys) { keyFieldValues[ii ++] = key.condition.getValues().get(0); diff --git a/src/java/com/samskivert/jdbc/depot/IdentityValueGenerator.java b/src/java/com/samskivert/jdbc/depot/IdentityValueGenerator.java index 7b85b2c4..98706615 100644 --- a/src/java/com/samskivert/jdbc/depot/IdentityValueGenerator.java +++ b/src/java/com/samskivert/jdbc/depot/IdentityValueGenerator.java @@ -31,7 +31,7 @@ import com.samskivert.jdbc.depot.annotation.GeneratedValue; */ 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); } diff --git a/src/java/com/samskivert/jdbc/depot/Key.java b/src/java/com/samskivert/jdbc/depot/Key.java index 1b81ca7a..4466438f 100644 --- a/src/java/com/samskivert/jdbc/depot/Key.java +++ b/src/java/com/samskivert/jdbc/depot/Key.java @@ -24,6 +24,7 @@ import java.io.Serializable; import java.lang.reflect.Field; import java.util.ArrayList; import java.util.Collection; +import java.util.List; import java.util.HashMap; import java.util.Map; @@ -46,7 +47,7 @@ public class Key extends WhereClause public static class WhereCondition implements SQLExpression, Serializable { - public WhereCondition (Class pClass, ArrayList values) + public WhereCondition (Class pClass, ArrayList> values) { _pClass = pClass; _values = values; @@ -69,7 +70,7 @@ public class Key extends WhereClause return _pClass; } - public ArrayList getValues () + public ArrayList> getValues () { return _values; } @@ -83,7 +84,7 @@ public class Key extends WhereClause if (obj == null || getClass() != obj.getClass()) { return false; } - WhereCondition other = (WhereCondition) obj; + WhereCondition other = (WhereCondition) obj; return _pClass == other._pClass && _values.equals(other.getValues()); } @@ -94,7 +95,7 @@ public class Key extends WhereClause } protected Class _pClass; - protected ArrayList _values; + protected ArrayList> _values; // List is not Serializable } /** The expression that identifies our row. */ @@ -103,7 +104,7 @@ public class Key extends WhereClause /** * Constructs a new single-column {@code Key} with the given value. */ - public Key (Class pClass, String ix, Comparable val) + public Key (Class pClass, String ix, Comparable val) { this(pClass, new String[] { ix }, new Comparable[] { val }); } @@ -111,8 +112,8 @@ public class Key extends WhereClause /** * Constructs a new two-column {@code Key} with the given values. */ - public Key (Class pClass, String ix1, Comparable val1, - String ix2, Comparable val2) + public Key (Class pClass, String ix1, Comparable val1, + String ix2, Comparable val2) { this(pClass, new String[] { ix1, ix2 }, new Comparable[] { val1, val2 }); } @@ -120,8 +121,8 @@ public class Key extends WhereClause /** * Constructs a new three-column {@code Key} with the given values. */ - public Key (Class pClass, String ix1, Comparable val1, - String ix2, Comparable val2, String ix3, Comparable val3) + public Key (Class pClass, String ix1, Comparable val1, + String ix2, Comparable val2, String ix3, Comparable val3) { this(pClass, new String[] { ix1, ix2, ix3 }, new Comparable[] { val1, val2, val3 }); } @@ -129,14 +130,14 @@ public class Key extends WhereClause /** * Constructs a new multi-column {@code Key} with the given values. */ - public Key (Class pClass, String[] fields, Comparable[] values) + public Key (Class pClass, String[] fields, Comparable[] values) { if (fields.length != values.length) { throw new IllegalArgumentException("Field and Value arrays must be of equal length."); } // build a local map of field name -> field value - Map map = new HashMap(); + Map> map = new HashMap>(); for (int i = 0; i < fields.length; i ++) { map.put(fields[i], values[i]); } @@ -145,9 +146,9 @@ public class Key extends WhereClause String[] keyFields = getKeyFields(pClass); // now extract the values in field order and ensure none are extra or missing - ArrayList newValues = new ArrayList(); + ArrayList> newValues = new ArrayList>(); for (int ii = 0; ii < keyFields.length; ii++) { - Comparable nugget = map.remove(keyFields[ii]); + Comparable nugget = map.remove(keyFields[ii]); if (nugget == null) { // make sure we were provided with a value for this primary key field throw new IllegalArgumentException("Missing value for key field: " + keyFields[ii]); @@ -227,7 +228,7 @@ public class Key extends WhereClause if (obj == null || getClass() != obj.getClass()) { return false; } - return condition.equals(((Key) obj).condition); + return condition.equals(((Key) obj).condition); } @Override @@ -260,7 +261,7 @@ public class Key extends WhereClause { String[] fields = _keyFields.get(pClass); if (fields == null) { - ArrayList kflist = new ArrayList(); + List kflist = new ArrayList(); for (Field field : pClass.getFields()) { // look for @Id fields if (field.getAnnotation(Id.class) != null) { diff --git a/src/java/com/samskivert/jdbc/depot/MultiKey.java b/src/java/com/samskivert/jdbc/depot/MultiKey.java index 75205f35..c9f0a0dc 100644 --- a/src/java/com/samskivert/jdbc/depot/MultiKey.java +++ b/src/java/com/samskivert/jdbc/depot/MultiKey.java @@ -38,7 +38,7 @@ public class MultiKey extends WhereClause /** * Constructs a new single-column {@code MultiKey} with the given value range. */ - public MultiKey (Class pClass, String ix, Comparable... val) + public MultiKey (Class pClass, String ix, Comparable... val) { this(pClass, new String[0], new Comparable[0], ix, val); } @@ -46,7 +46,8 @@ public class MultiKey extends WhereClause /** * Constructs a new two-column {@code MultiKey} with the given value range. */ - public MultiKey (Class pClass, String ix1, Comparable val1, String ix2, Comparable... val2) + public MultiKey (Class pClass, String ix1, Comparable val1, String ix2, + Comparable... val2) { this(pClass, new String[] { ix1 }, new Comparable[] { val1 }, ix2, val2); } @@ -54,8 +55,8 @@ public class MultiKey extends WhereClause /** * Constructs a new three-column {@code MultiKey} with the given value range. */ - public MultiKey (Class pClass, String ix1, Comparable val1, String ix2, Comparable val2, - String ix3, Comparable... val3) + public MultiKey (Class pClass, String ix1, Comparable val1, + String ix2, Comparable val2, String ix3, Comparable... val3) { this(pClass, new String[] { ix1, ix2 }, new Comparable[] { val1, val2 }, ix3, val3); } @@ -64,8 +65,8 @@ public class MultiKey extends WhereClause * Constructs a new multi-column {@code MultiKey} with the given value range. * @TODO: See {@link Key#Key(Class, String[], Comparable[]) for somewhat relevant comments. */ - public MultiKey (Class pClass, String[] sFields, Comparable[] sValues, - String mField, Comparable[] mValues) + public MultiKey (Class pClass, String[] sFields, Comparable[] sValues, + String mField, Comparable[] mValues) { if (sFields.length != sValues.length) { throw new IllegalArgumentException( @@ -74,7 +75,7 @@ public class MultiKey extends WhereClause _pClass = pClass; _mField = mField; _mValues = mValues; - _map = new HashMap(); + _map = new HashMap>(); for (int i = 0; i < sFields.length; i ++) { _map.put(sFields[i], sValues[i]); } @@ -85,7 +86,7 @@ public class MultiKey extends WhereClause return _pClass; } - public Map getSingleFieldsMap () + public Map> getSingleFieldsMap () { return _map; } @@ -95,7 +96,7 @@ public class MultiKey extends WhereClause return _mField; } - public Comparable[] getMultiValues () + public Comparable[] getMultiValues () { return _mValues; } @@ -126,7 +127,7 @@ public class MultiKey extends WhereClause // from CacheInvalidator public void invalidate (PersistenceContext ctx) { - HashMap newMap = new HashMap(_map); + HashMap> newMap = new HashMap>(_map); for (int i = 0; i < _mValues.length; i ++) { newMap.put(_mField, _mValues[i]); ctx.cacheInvalidate(new SimpleCacheKey(_pClass, newMap)); @@ -141,7 +142,7 @@ public class MultiKey extends WhereClause } protected String _mField; - protected Comparable[] _mValues; + protected Comparable[] _mValues; protected Class _pClass; - protected HashMap _map; + protected HashMap> _map; } diff --git a/src/java/com/samskivert/jdbc/depot/MySQLBuilder.java b/src/java/com/samskivert/jdbc/depot/MySQLBuilder.java index e778095a..6f6e1642 100644 --- a/src/java/com/samskivert/jdbc/depot/MySQLBuilder.java +++ b/src/java/com/samskivert/jdbc/depot/MySQLBuilder.java @@ -205,7 +205,7 @@ public class MySQLBuilder } @Override - protected String getColumnType (FieldMarshaller fm, int length) + protected String getColumnType (FieldMarshaller fm, int length) { if (fm instanceof ByteMarshaller) { return "TINYINT"; diff --git a/src/java/com/samskivert/jdbc/depot/PersistenceContext.java b/src/java/com/samskivert/jdbc/depot/PersistenceContext.java index 518ccfd0..0e376a00 100644 --- a/src/java/com/samskivert/jdbc/depot/PersistenceContext.java +++ b/src/java/com/samskivert/jdbc/depot/PersistenceContext.java @@ -316,9 +316,8 @@ public class PersistenceContext log.debug("storing [key=" + key + ", value=" + entry + "]"); CacheAdapter.CacheBin bin = _cache.getCache(key.getCacheId()); - CacheAdapter.CachedValue element = bin.lookup(key.getCacheKey()); - @SuppressWarnings("unchecked") T oldEntry = - (element != null ? (T) element.getValue() : null); + CacheAdapter.CachedValue element = bin.lookup(key.getCacheKey()); + T oldEntry = (element != null ? element.getValue() : null); // update the cache 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 * eviction may trigger further cache invalidations. */ - public void cacheInvalidate (Class pClass, Serializable cacheKey) + public void cacheInvalidate (Class pClass, Serializable 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, * invoking the callback for each cache entry. */ - public void cacheTraverse (Class pClass, CacheTraverser filter) + public void cacheTraverse ( + Class pClass, CacheTraverser filter) { cacheTraverse(pClass.getName(), filter); } diff --git a/src/java/com/samskivert/jdbc/depot/PostgreSQLBuilder.java b/src/java/com/samskivert/jdbc/depot/PostgreSQLBuilder.java index 210c0b0b..bdd4a1dd 100644 --- a/src/java/com/samskivert/jdbc/depot/PostgreSQLBuilder.java +++ b/src/java/com/samskivert/jdbc/depot/PostgreSQLBuilder.java @@ -212,7 +212,7 @@ public class PostgreSQLBuilder } @Override - protected String getColumnType (FieldMarshaller fm, int length) + protected String getColumnType (FieldMarshaller fm, int length) { if (fm instanceof ByteMarshaller) { return "SMALLINT"; diff --git a/src/java/com/samskivert/jdbc/depot/SQLBuilder.java b/src/java/com/samskivert/jdbc/depot/SQLBuilder.java index 09111795..9e20fe87 100644 --- a/src/java/com/samskivert/jdbc/depot/SQLBuilder.java +++ b/src/java/com/samskivert/jdbc/depot/SQLBuilder.java @@ -109,7 +109,7 @@ public abstract class SQLBuilder * TODO: This method should be split into several parts that are more easily overridden on a * 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 (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. * @param length */ - protected abstract String getColumnType (FieldMarshaller fm, int length); + protected abstract String getColumnType (FieldMarshaller fm, int length); /** The class that maps persistent classes to marshallers. */ protected DepotTypes _types; diff --git a/src/java/com/samskivert/jdbc/depot/SimpleCacheKey.java b/src/java/com/samskivert/jdbc/depot/SimpleCacheKey.java index 636912a2..823b86f8 100644 --- a/src/java/com/samskivert/jdbc/depot/SimpleCacheKey.java +++ b/src/java/com/samskivert/jdbc/depot/SimpleCacheKey.java @@ -42,7 +42,7 @@ public class SimpleCacheKey * Construct a {@link SimpleCacheKey} associated with the given persistent class with * the given cache key. */ - public SimpleCacheKey (Class cacheClass, Serializable cacheKey) + public SimpleCacheKey (Class cacheClass, Serializable cacheKey) { this(cacheClass.getName(), cacheKey); } diff --git a/src/java/com/samskivert/jdbc/depot/TableValueGenerator.java b/src/java/com/samskivert/jdbc/depot/TableValueGenerator.java index b488f819..c0606300 100644 --- a/src/java/com/samskivert/jdbc/depot/TableValueGenerator.java +++ b/src/java/com/samskivert/jdbc/depot/TableValueGenerator.java @@ -37,7 +37,8 @@ import com.samskivert.jdbc.JDBCUtil; */ 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); _valueTable = defStr(tg.table(), "IdSequences"); diff --git a/src/java/com/samskivert/jdbc/depot/ValueGenerator.java b/src/java/com/samskivert/jdbc/depot/ValueGenerator.java index ce184968..c8bca36d 100644 --- a/src/java/com/samskivert/jdbc/depot/ValueGenerator.java +++ b/src/java/com/samskivert/jdbc/depot/ValueGenerator.java @@ -36,7 +36,7 @@ import static com.samskivert.jdbc.depot.Log.log; */ public abstract class ValueGenerator { - public ValueGenerator (GeneratedValue gv, DepotMarshaller dm, FieldMarshaller fm) + public ValueGenerator (GeneratedValue gv, DepotMarshaller dm, FieldMarshaller fm) { _allocationSize = gv.allocationSize(); _initialValue = gv.initialValue(); @@ -101,12 +101,12 @@ public abstract class ValueGenerator } } - public DepotMarshaller getDepotMarshaller () + public DepotMarshaller getDepotMarshaller () { return _dm; } - public FieldMarshaller getFieldMarshaller () + public FieldMarshaller getFieldMarshaller () { return _fm; } @@ -115,6 +115,6 @@ public abstract class ValueGenerator protected int _allocationSize; protected boolean _migrateIfExists; - protected DepotMarshaller _dm; - protected FieldMarshaller _fm; + protected DepotMarshaller _dm; + protected FieldMarshaller _fm; } diff --git a/src/java/com/samskivert/jdbc/depot/clause/Where.java b/src/java/com/samskivert/jdbc/depot/clause/Where.java index a6a7fa3e..71ff4b30 100644 --- a/src/java/com/samskivert/jdbc/depot/clause/Where.java +++ b/src/java/com/samskivert/jdbc/depot/clause/Where.java @@ -38,26 +38,26 @@ import com.samskivert.jdbc.depot.operator.Logic.And; */ 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, - ColumnExp index2, Comparable value2) + public Where (ColumnExp index1, Comparable value1, + 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, - ColumnExp index2, Comparable value2, - ColumnExp index3, Comparable value3) + public Where (ColumnExp index1, Comparable value1, + ColumnExp index2, Comparable value2, + ColumnExp index3, Comparable value3) { 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)); } @@ -84,7 +84,7 @@ public class Where extends WhereClause _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]; for (int ii = 0; ii < columns.length; ii ++) { diff --git a/src/java/com/samskivert/jdbc/depot/expression/ExpressionVisitor.java b/src/java/com/samskivert/jdbc/depot/expression/ExpressionVisitor.java index 9fa59fb4..6b7740e7 100644 --- a/src/java/com/samskivert/jdbc/depot/expression/ExpressionVisitor.java +++ b/src/java/com/samskivert/jdbc/depot/expression/ExpressionVisitor.java @@ -55,7 +55,7 @@ public interface ExpressionVisitor throws Exception; public void visit (WhereCondition whereCondition) throws Exception; - public void visit (Key key) + public void visit (Key key) throws Exception; public void visit (MultiKey key) throws Exception; diff --git a/src/java/com/samskivert/jdbc/depot/operator/Arithmetic.java b/src/java/com/samskivert/jdbc/depot/operator/Arithmetic.java index b658cec6..d5a807e2 100644 --- a/src/java/com/samskivert/jdbc/depot/operator/Arithmetic.java +++ b/src/java/com/samskivert/jdbc/depot/operator/Arithmetic.java @@ -32,7 +32,7 @@ public abstract class Arithmetic /** The SQL '+' operator. */ public static class Add extends BinaryOperator { - public Add (SQLExpression column, Comparable value) + public Add (SQLExpression column, Comparable value) { super(column, value); } @@ -52,7 +52,7 @@ public abstract class Arithmetic /** The SQL '-' operator. */ public static class Sub extends BinaryOperator { - public Sub (SQLExpression column, Comparable value) + public Sub (SQLExpression column, Comparable value) { super(column, value); } @@ -72,7 +72,7 @@ public abstract class Arithmetic /** The SQL '*' operator. */ public static class Mul extends BinaryOperator { - public Mul (SQLExpression column, Comparable value) + public Mul (SQLExpression column, Comparable value) { super(column, value); } @@ -92,7 +92,7 @@ public abstract class Arithmetic /** The SQL '/' operator. */ public static class Div extends BinaryOperator { - public Div (SQLExpression column, Comparable value) + public Div (SQLExpression column, Comparable value) { super(column, value); } @@ -112,7 +112,7 @@ public abstract class Arithmetic /** The SQL '&' operator. */ public static class BitAnd extends BinaryOperator { - public BitAnd (SQLExpression column, Comparable value) + public BitAnd (SQLExpression column, Comparable value) { super(column, value); } @@ -132,7 +132,7 @@ public abstract class Arithmetic /** The SQL '|' operator. */ public static class BitOr extends BinaryOperator { - public BitOr (SQLExpression column, Comparable value) + public BitOr (SQLExpression column, Comparable value) { super(column, value); } diff --git a/src/java/com/samskivert/jdbc/depot/operator/Conditionals.java b/src/java/com/samskivert/jdbc/depot/operator/Conditionals.java index 12796583..1d593b36 100644 --- a/src/java/com/samskivert/jdbc/depot/operator/Conditionals.java +++ b/src/java/com/samskivert/jdbc/depot/operator/Conditionals.java @@ -75,7 +75,7 @@ public abstract class Conditionals /** The SQL '=' operator. */ public static class Equals extends SQLOperator.BinaryOperator { - public Equals (SQLExpression column, Comparable value) + public Equals (SQLExpression column, Comparable value) { super(column, value); } @@ -95,7 +95,7 @@ public abstract class Conditionals /** The SQL '!=' operator. */ public static class NotEquals extends SQLOperator.BinaryOperator { - public NotEquals (SQLExpression column, Comparable value) + public NotEquals (SQLExpression column, Comparable value) { super(column, value); } @@ -115,7 +115,7 @@ public abstract class Conditionals /** The SQL '<' operator. */ public static class LessThan extends SQLOperator.BinaryOperator { - public LessThan (SQLExpression column, Comparable value) + public LessThan (SQLExpression column, Comparable value) { super(column, value); } @@ -135,7 +135,7 @@ public abstract class Conditionals /** The SQL '<=' operator. */ public static class LessThanEquals extends SQLOperator.BinaryOperator { - public LessThanEquals (SQLExpression column, Comparable value) + public LessThanEquals (SQLExpression column, Comparable value) { super(column, value); } @@ -155,7 +155,7 @@ public abstract class Conditionals /** The SQL '>' operator. */ public static class GreaterThan extends SQLOperator.BinaryOperator { - public GreaterThan (SQLExpression column, Comparable value) + public GreaterThan (SQLExpression column, Comparable value) { super(column, value); } @@ -175,7 +175,7 @@ public abstract class Conditionals /** The SQL '>=' operator. */ public static class GreaterThanEquals extends SQLOperator.BinaryOperator { - public GreaterThanEquals (SQLExpression column, Comparable value) + public GreaterThanEquals (SQLExpression column, Comparable value) { super(column, value); } @@ -196,18 +196,18 @@ public abstract class Conditionals public static class In implements SQLOperator { - public In (Class pClass, String pColumn, Comparable... values) + public In (Class pClass, String pColumn, Comparable... values) { this(new ColumnExp(pClass, pColumn), values); } public In (Class pClass, String pColumn, - Collection values) + Collection> 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) { throw new IllegalArgumentException("In() condition needs at least one value."); @@ -216,9 +216,9 @@ public abstract class Conditionals _values = values; } - public In (ColumnExp pColumn, Collection values) + public In (ColumnExp pColumn, Collection> values) { - this(pColumn, values.toArray(new Comparable[values.size()])); + this(pColumn, values.toArray(new Comparable[values.size()])); } public ColumnExp getColumn () @@ -226,7 +226,7 @@ public abstract class Conditionals return _column; } - public Comparable[] getValues () + public Comparable[] getValues () { return _values; } @@ -244,13 +244,13 @@ public abstract class Conditionals } protected ColumnExp _column; - protected Comparable[] _values; + protected Comparable[] _values; } /** The SQL ' like ' operator. */ public static class Like extends SQLOperator.BinaryOperator { - public Like (SQLExpression column, Comparable value) + public Like (SQLExpression column, Comparable value) { super(column, value); } diff --git a/src/java/com/samskivert/jdbc/depot/operator/SQLOperator.java b/src/java/com/samskivert/jdbc/depot/operator/SQLOperator.java index d1af066c..7f4e4cef 100644 --- a/src/java/com/samskivert/jdbc/depot/operator/SQLOperator.java +++ b/src/java/com/samskivert/jdbc/depot/operator/SQLOperator.java @@ -83,7 +83,7 @@ public interface SQLOperator extends SQLExpression _rhs = rhs; } - public BinaryOperator (SQLExpression lhs, Comparable rhs) + public BinaryOperator (SQLExpression lhs, Comparable rhs) { this(lhs, new ValueExp(rhs)); } diff --git a/src/java/com/samskivert/jdbc/depot/tools/GenRecordTask.java b/src/java/com/samskivert/jdbc/depot/tools/GenRecordTask.java index 744c2bf3..d0761161 100644 --- a/src/java/com/samskivert/jdbc/depot/tools/GenRecordTask.java +++ b/src/java/com/samskivert/jdbc/depot/tools/GenRecordTask.java @@ -140,7 +140,7 @@ public class GenRecordTask extends Task } /** 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 if (!_prclass.isAssignableFrom(rclass)) { diff --git a/src/java/com/samskivert/jdbc/jora/FieldDescriptor.java b/src/java/com/samskivert/jdbc/jora/FieldDescriptor.java index 04033d63..0d2e0224 100644 --- a/src/java/com/samskivert/jdbc/jora/FieldDescriptor.java +++ b/src/java/com/samskivert/jdbc/jora/FieldDescriptor.java @@ -391,7 +391,7 @@ class FieldDescriptor protected String name; // full (compound) name of component 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_short = 1; diff --git a/src/java/com/samskivert/jdbc/jora/FieldMask.java b/src/java/com/samskivert/jdbc/jora/FieldMask.java index 68828550..1137017d 100644 --- a/src/java/com/samskivert/jdbc/jora/FieldMask.java +++ b/src/java/com/samskivert/jdbc/jora/FieldMask.java @@ -100,7 +100,7 @@ public class FieldMask * Returns true only if the set of modified fields is a subset of the * fields specified. */ - public final boolean onlySubsetModified (Set fieldSet) + public final boolean onlySubsetModified (Set fieldSet) { for (String field : _descripMap.keySet()) { if (isModified(field) && (!fieldSet.contains(field))) { diff --git a/src/java/com/samskivert/jdbc/jora/Table.java b/src/java/com/samskivert/jdbc/jora/Table.java index 92ee50b9..4ffab29d 100644 --- a/src/java/com/samskivert/jdbc/jora/Table.java +++ b/src/java/com/samskivert/jdbc/jora/Table.java @@ -486,11 +486,11 @@ public class Table } protected final int buildFieldsList (ArrayList buf, - Class _rowClass, String prefix) + Class _rowClass, String prefix) { Field[] f = _rowClass.getDeclaredFields(); - Class superclass = _rowClass; + Class superclass = _rowClass; while ((superclass = superclass.getSuperclass()) != null) { Field[] inheritedFields = superclass.getDeclaredFields(); Field[] allFields = new Field[inheritedFields.length + f.length]; @@ -908,10 +908,11 @@ public class Table static { try { - serializableClass = Serializable.class; - Class c = Class.forName("java.lang.reflect.AccessibleObject"); - Class[] param = { Boolean.TYPE }; - setBypass = c.getMethod("setAccessible", param); - } catch(Exception ex) {} + serializableClass = Serializable.class; + Class c = Class.forName("java.lang.reflect.AccessibleObject"); + setBypass = c.getMethod("setAccessible", new Class[] { Boolean.TYPE }); + } catch(Exception ex) { + // nothing to do + } } } diff --git a/src/java/com/samskivert/servlet/MessageManager.java b/src/java/com/samskivert/servlet/MessageManager.java index 20534b49..7345f06f 100644 --- a/src/java/com/samskivert/servlet/MessageManager.java +++ b/src/java/com/samskivert/servlet/MessageManager.java @@ -258,7 +258,7 @@ public class MessageManager ResourceBundle bundle = null; if (req != null) { - Enumeration locales = req.getLocales(); + Enumeration locales = req.getLocales(); while (locales.hasMoreElements()) { Locale locale = (Locale)locales.nextElement(); diff --git a/src/java/com/samskivert/servlet/util/ExceptionMap.java b/src/java/com/samskivert/servlet/util/ExceptionMap.java index c790dd45..e0f5a6ad 100644 --- a/src/java/com/samskivert/servlet/util/ExceptionMap.java +++ b/src/java/com/samskivert/servlet/util/ExceptionMap.java @@ -81,7 +81,7 @@ public class ExceptionMap if (_keys != null) { return; } else { - _keys = new ArrayList(); + _keys = new ArrayList>(); _values = new ArrayList(); } @@ -113,7 +113,7 @@ public class ExceptionMap for (int i = 0; i < classes.size(); i++) { String exclass = classes.get(i); try { - Class cl = Class.forName(exclass); + Class cl = Class.forName(exclass); // replace the string with the class object _keys.add(cl); @@ -146,7 +146,7 @@ public class ExceptionMap { String msg = DEFAULT_ERROR_MSG; for (int i = 0; i < _keys.size(); i++) { - Class cl = _keys.get(i); + Class cl = _keys.get(i); if (cl.isInstance(ex)) { msg = _values.get(i); break; @@ -155,7 +155,7 @@ public class ExceptionMap return StringUtil.replace(msg, MESSAGE_MARKER, ex.getMessage()); } - protected static List _keys; + protected static List> _keys; protected static List _values; // initialize ourselves diff --git a/src/java/com/samskivert/servlet/util/RequestUtils.java b/src/java/com/samskivert/servlet/util/RequestUtils.java index 9205b79d..9b2a473c 100644 --- a/src/java/com/samskivert/servlet/util/RequestUtils.java +++ b/src/java/com/samskivert/servlet/util/RequestUtils.java @@ -20,7 +20,6 @@ package com.samskivert.servlet.util; -import java.util.Iterator; import java.util.Map; import javax.servlet.http.HttpServletRequest; @@ -109,13 +108,15 @@ public class RequestUtils public static String reconstructURL (HttpServletRequest req) { StringBuffer buf = req.getRequestURL(); - Map map = req.getParameterMap(); + @SuppressWarnings("unchecked") Map map = req.getParameterMap(); if (map.size() > 0) { buf.append("?"); - for (Iterator iter = map.entrySet().iterator(); iter.hasNext(); ) { - Map.Entry entry = (Map.Entry)iter.next(); + for (Map.Entry entry : map.entrySet()) { + if (buf.charAt(buf.length()-1) != '?') { + buf.append("&"); + } buf.append(entry.getKey()).append("="); - String[] values = (String[])entry.getValue(); + String[] values = entry.getValue(); if (values.length == 1) { buf.append(values[0]); } else { @@ -128,9 +129,6 @@ public class RequestUtils } buf.append(")"); } - if (iter.hasNext()) { - buf.append("&"); - } } } return buf.toString(); diff --git a/src/java/com/samskivert/swing/Controller.java b/src/java/com/samskivert/swing/Controller.java index ffc3fa2f..35e7f8f8 100644 --- a/src/java/com/samskivert/swing/Controller.java +++ b/src/java/com/samskivert/swing/Controller.java @@ -356,7 +356,7 @@ public abstract class Controller Method method, Object source, Object argument) { // 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) { return new Object[0]; diff --git a/src/java/com/samskivert/swing/ObjectEditorTable.java b/src/java/com/samskivert/swing/ObjectEditorTable.java index e7e6f8e7..f076a194 100644 --- a/src/java/com/samskivert/swing/ObjectEditorTable.java +++ b/src/java/com/samskivert/swing/ObjectEditorTable.java @@ -72,9 +72,9 @@ public class ObjectEditorTable extends JTable * the field is used, or its object equivalent if it is a primitive * class. */ - public Class getClass (Field field) + public Class getClass (Field field) { - Class clazz = field.getType(); + Class clazz = field.getType(); return ClassUtil.objectEquivalentOf(clazz); } @@ -111,7 +111,7 @@ public class ObjectEditorTable extends JTable * * @param protoClass the Class of the data that will be displayed. */ - public ObjectEditorTable (Class protoClass) + public ObjectEditorTable (Class protoClass) { this(protoClass, null); } @@ -122,7 +122,7 @@ public class ObjectEditorTable extends JTable * @param protoClass the Class of the data that will be displayed. * @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); } @@ -134,7 +134,7 @@ public class ObjectEditorTable extends JTable * @param editableFields the names of the fields that are editable. * @param interp The {@link FieldInterpreter} to use. */ - public ObjectEditorTable (Class protoClass, String[] editableFields, + public ObjectEditorTable (Class protoClass, String[] editableFields, FieldInterpreter interp) { this(protoClass, editableFields, interp, null); @@ -148,7 +148,7 @@ public class ObjectEditorTable extends JTable * @param interp The {@link FieldInterpreter} to use. * @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) { _interp = (interp != null) ? interp : new FieldInterpreter(); diff --git a/src/java/com/samskivert/swing/TGraphics2D.java b/src/java/com/samskivert/swing/TGraphics2D.java index 5974fddb..b0b5c7a5 100644 --- a/src/java/com/samskivert/swing/TGraphics2D.java +++ b/src/java/com/samskivert/swing/TGraphics2D.java @@ -193,13 +193,13 @@ public class TGraphics2D extends Graphics2D return _primary.getRenderingHint(k); } - public void setRenderingHints (Map m) + public void setRenderingHints (Map m) { _copy.setRenderingHints(m); _primary.setRenderingHints(m); } - public void addRenderingHints (Map m) + public void addRenderingHints (Map m) { _copy.addRenderingHints(m); _primary.addRenderingHints(m); @@ -553,7 +553,7 @@ public class TGraphics2D extends Graphics2D return _primary.toString(); } - @SuppressWarnings("deprecation") + @Deprecated public Rectangle getClipRect () { // getClipRect is deprecated, but getClipBounds is the new way to do the same thing. We diff --git a/src/java/com/samskivert/swing/TableSorter.java b/src/java/com/samskivert/swing/TableSorter.java index ff0b0dd5..a333fe3b 100644 --- a/src/java/com/samskivert/swing/TableSorter.java +++ b/src/java/com/samskivert/swing/TableSorter.java @@ -108,8 +108,8 @@ public class TableSorter extends AbstractTableModel { private JTableHeader tableHeader; private MouseListener mouseListener; private TableModelListener tableModelListener; - private Map> columnComparators = - new HashMap>(); + private Map,Comparator> columnComparators = + new HashMap,Comparator>(); private List sortingColumns = new ArrayList(); public TableSorter() { @@ -221,7 +221,7 @@ public class TableSorter extends AbstractTableModel { sortingStatusChanged(); } - public void setColumnComparator(Class type, Comparator comparator) { + public void setColumnComparator(Class type, Comparator comparator) { if (comparator == null) { columnComparators.remove(type); } else { @@ -230,7 +230,7 @@ public class TableSorter extends AbstractTableModel { } protected Comparator getComparator(int column) { - Class columnType = tableModel.getColumnClass(column); + Class columnType = tableModel.getColumnClass(column); Comparator comparator = columnComparators.get(columnType); if (comparator != null) { return comparator; diff --git a/src/java/com/samskivert/swing/util/MenuUtil.java b/src/java/com/samskivert/swing/util/MenuUtil.java index 33997ca0..07a994c0 100644 --- a/src/java/com/samskivert/swing/util/MenuUtil.java +++ b/src/java/com/samskivert/swing/util/MenuUtil.java @@ -253,6 +253,5 @@ public class MenuUtil } /** The method signature for menu callback methods. */ - protected static final Class[] METHOD_ARGS = - new Class[] { ActionEvent.class }; + protected static final Class[] METHOD_ARGS = new Class[] { ActionEvent.class }; } diff --git a/src/java/com/samskivert/swing/util/SwingUtil.java b/src/java/com/samskivert/swing/util/SwingUtil.java index c6d59b0a..6b10a3f5 100644 --- a/src/java/com/samskivert/swing/util/SwingUtil.java +++ b/src/java/com/samskivert/swing/util/SwingUtil.java @@ -160,7 +160,7 @@ public class SwingUtil * be left at it's original location. */ public static boolean positionRect ( - Rectangle r, Rectangle bounds, Collection avoidShapes) + Rectangle r, Rectangle bounds, Collection avoidShapes) { Point origPos = r.getLocation(); Comparator comp = createPointComparator(origPos); @@ -182,8 +182,8 @@ public class SwingUtil } // see if it hits any shapes we're trying to avoid - for (Iterator iter=avoidShapes.iterator(); iter.hasNext(); ) { - Shape shape = (Shape) iter.next(); + for (Iterator iter = avoidShapes.iterator(); iter.hasNext(); ) { + Shape shape = iter.next(); if (shape.intersects(r)) { // remove that shape from our avoid list diff --git a/src/java/com/samskivert/util/ArrayIntSet.java b/src/java/com/samskivert/util/ArrayIntSet.java index 100b05f6..867ae941 100644 --- a/src/java/com/samskivert/util/ArrayIntSet.java +++ b/src/java/com/samskivert/util/ArrayIntSet.java @@ -295,7 +295,7 @@ public class ArrayIntSet extends AbstractSet } // documentation inherited from interface - public boolean containsAll (Collection c) + public boolean containsAll (Collection c) { if (c instanceof Interable) { Interator inter = ((Interable) c).interator(); diff --git a/src/java/com/samskivert/util/ClassUtil.java b/src/java/com/samskivert/util/ClassUtil.java index 5cffed85..57605df5 100644 --- a/src/java/com/samskivert/util/ClassUtil.java +++ b/src/java/com/samskivert/util/ClassUtil.java @@ -41,7 +41,7 @@ public class ClassUtil * @return true if the class is accessible, false otherwise. Presently returns true if the * class is declared public. */ - public static boolean classIsAccessible (Class clazz) + public static boolean classIsAccessible (Class clazz) { return Modifier.isPublic(clazz.getModifiers()); } @@ -49,7 +49,7 @@ public class ClassUtil /** * Get the fields contained in the class and its superclasses. */ - public static Field[] getFields (Class clazz) + public static Field[] getFields (Class clazz) { ArrayList list = new ArrayList(); 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 * running in a sandbox, this will only enumerate public members. */ - public static void getFields (Class clazz, List addTo) + public static void getFields (Class clazz, List addTo) { // first get the fields of the superclass - Class pclazz = clazz.getSuperclass(); + Class pclazz = clazz.getSuperclass(); if (pclazz != null && !pclazz.equals(Object.class)) { 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 * 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) { argTypes = new Class[args.length]; for (int i = 0; i < args.length; ++i) { argTypes[i] = (args[i] == null) ? Void.TYPE : args[i].getClass(); } } else { - argTypes = new Class[0]; + argTypes = new Class[0]; } return argTypes; } @@ -165,7 +165,7 @@ public class ClassUtil * @return the nearest method located, or null if there is no such method. */ public static Method getAccessibleMethodFrom ( - Class clazz, String methodName, Class[] parameterTypes) + Class clazz, String methodName, Class[] parameterTypes) { // Look for overridden method in the superclass. 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 * 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); } @@ -237,7 +237,7 @@ public class ClassUtil /** * @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; } @@ -252,7 +252,7 @@ public class ClassUtil * @return true if compatible, false otherwise. If either argument is null, or one * 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) { return false; @@ -263,7 +263,7 @@ public class ClassUtil if (lhs.equals(rhs)) { return true; } - Set wideningSet = _primitiveWideningsMap.get(rhs); + Set> wideningSet = _primitiveWideningsMap.get(rhs); if (wideningSet == null) { return false; } @@ -298,11 +298,11 @@ public class ClassUtil /** Mapping from primitive wrapper Classes to the sets of primitive classes whose instances can * be assigned an instance of the first. */ - protected static final Map> _primitiveWideningsMap = - new HashMap>(11); + protected static final Map,Set>> _primitiveWideningsMap = + new HashMap,Set>>(11); static { - Set set = new HashSet(); + Set> set = new HashSet>(); set.add(Short.TYPE); set.add(Integer.TYPE); set.add(Long.TYPE); @@ -310,7 +310,7 @@ public class ClassUtil set.add(Double.TYPE); _primitiveWideningsMap.put(Byte.TYPE, set); - set = new HashSet(); + set = new HashSet>(); set.add(Integer.TYPE); set.add(Long.TYPE); set.add(Float.TYPE); @@ -318,18 +318,18 @@ public class ClassUtil _primitiveWideningsMap.put(Short.TYPE, set); _primitiveWideningsMap.put(Character.TYPE, set); - set = new HashSet(); + set = new HashSet>(); set.add(Long.TYPE); set.add(Float.TYPE); set.add(Double.TYPE); _primitiveWideningsMap.put(Integer.TYPE, set); - set = new HashSet(); + set = new HashSet>(); set.add(Float.TYPE); set.add(Double.TYPE); _primitiveWideningsMap.put(Long.TYPE, set); - set = new HashSet(); + set = new HashSet>(); set.add(Double.TYPE); _primitiveWideningsMap.put(Float.TYPE, set); } diff --git a/src/java/com/samskivert/util/Config.java b/src/java/com/samskivert/util/Config.java index 8c31cffc..253b3703 100644 --- a/src/java/com/samskivert/util/Config.java +++ b/src/java/com/samskivert/util/Config.java @@ -390,9 +390,8 @@ public class Config } // build the sub-properties - Iterator iter = keys(); - while (iter.hasNext()) { - String key = (String)iter.next(); + for (Iterator iter = keys(); iter.hasNext(); ) { + String key = iter.next(); if (!key.startsWith(prefix)) { continue; } @@ -416,7 +415,7 @@ public class Config protected void enumerateKeys (HashSet keys) { - Enumeration defkeys = _props.propertyNames(); + Enumeration defkeys = _props.propertyNames(); while (defkeys.hasMoreElements()) { keys.add((String)defkeys.nextElement()); } diff --git a/src/java/com/samskivert/util/Crypt.java b/src/java/com/samskivert/util/Crypt.java index 25bdd89e..5684e503 100644 --- a/src/java/com/samskivert/util/Crypt.java +++ b/src/java/com/samskivert/util/Crypt.java @@ -31,540 +31,540 @@ public class Crypt private static final int[] con_salt = { - 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, - 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF, 0xE0, 0xE1, - 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, - 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, 0xF0, 0xF1, - 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, - 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF, 0x00, 0x01, - 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, - 0x0A, 0x0B, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, - 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, - 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, - 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, - 0x23, 0x24, 0x25, 0x20, 0x21, 0x22, 0x23, 0x24, - 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, - 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34, - 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, - 0x3D, 0x3E, 0x3F, 0x40, 0x41, 0x42, 0x43, 0x44, + 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, + 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF, 0xE0, 0xE1, + 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, + 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, 0xF0, 0xF1, + 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, + 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF, 0x00, 0x01, + 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, + 0x0A, 0x0B, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, + 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, + 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, + 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, + 0x23, 0x24, 0x25, 0x20, 0x21, 0x22, 0x23, 0x24, + 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, + 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34, + 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, + 0x3D, 0x3E, 0x3F, 0x40, 0x41, 0x42, 0x43, 0x44, }; private static final boolean[] shifts2 = { - false, false, true, true, true, true, true, true, - false, true, true, true, true, true, true, false + false, false, true, true, true, true, true, true, + false, true, true, true, true, true, true, false }; private static final int[][] skb = { - { - /* for C bits (numbered as per FIPS 46) 1 2 3 4 5 6 */ - 0x00000000, 0x00000010, 0x20000000, 0x20000010, - 0x00010000, 0x00010010, 0x20010000, 0x20010010, - 0x00000800, 0x00000810, 0x20000800, 0x20000810, - 0x00010800, 0x00010810, 0x20010800, 0x20010810, - 0x00000020, 0x00000030, 0x20000020, 0x20000030, - 0x00010020, 0x00010030, 0x20010020, 0x20010030, - 0x00000820, 0x00000830, 0x20000820, 0x20000830, - 0x00010820, 0x00010830, 0x20010820, 0x20010830, - 0x00080000, 0x00080010, 0x20080000, 0x20080010, - 0x00090000, 0x00090010, 0x20090000, 0x20090010, - 0x00080800, 0x00080810, 0x20080800, 0x20080810, - 0x00090800, 0x00090810, 0x20090800, 0x20090810, - 0x00080020, 0x00080030, 0x20080020, 0x20080030, - 0x00090020, 0x00090030, 0x20090020, 0x20090030, - 0x00080820, 0x00080830, 0x20080820, 0x20080830, - 0x00090820, 0x00090830, 0x20090820, 0x20090830, - }, - { - /* for C bits (numbered as per FIPS 46) 7 8 10 11 12 13 */ - 0x00000000, 0x02000000, 0x00002000, 0x02002000, - 0x00200000, 0x02200000, 0x00202000, 0x02202000, - 0x00000004, 0x02000004, 0x00002004, 0x02002004, - 0x00200004, 0x02200004, 0x00202004, 0x02202004, - 0x00000400, 0x02000400, 0x00002400, 0x02002400, - 0x00200400, 0x02200400, 0x00202400, 0x02202400, - 0x00000404, 0x02000404, 0x00002404, 0x02002404, - 0x00200404, 0x02200404, 0x00202404, 0x02202404, - 0x10000000, 0x12000000, 0x10002000, 0x12002000, - 0x10200000, 0x12200000, 0x10202000, 0x12202000, - 0x10000004, 0x12000004, 0x10002004, 0x12002004, - 0x10200004, 0x12200004, 0x10202004, 0x12202004, - 0x10000400, 0x12000400, 0x10002400, 0x12002400, - 0x10200400, 0x12200400, 0x10202400, 0x12202400, - 0x10000404, 0x12000404, 0x10002404, 0x12002404, - 0x10200404, 0x12200404, 0x10202404, 0x12202404, - }, - { - /* for C bits (numbered as per FIPS 46) 14 15 16 17 19 20 */ - 0x00000000, 0x00000001, 0x00040000, 0x00040001, - 0x01000000, 0x01000001, 0x01040000, 0x01040001, - 0x00000002, 0x00000003, 0x00040002, 0x00040003, - 0x01000002, 0x01000003, 0x01040002, 0x01040003, - 0x00000200, 0x00000201, 0x00040200, 0x00040201, - 0x01000200, 0x01000201, 0x01040200, 0x01040201, - 0x00000202, 0x00000203, 0x00040202, 0x00040203, - 0x01000202, 0x01000203, 0x01040202, 0x01040203, - 0x08000000, 0x08000001, 0x08040000, 0x08040001, - 0x09000000, 0x09000001, 0x09040000, 0x09040001, - 0x08000002, 0x08000003, 0x08040002, 0x08040003, - 0x09000002, 0x09000003, 0x09040002, 0x09040003, - 0x08000200, 0x08000201, 0x08040200, 0x08040201, - 0x09000200, 0x09000201, 0x09040200, 0x09040201, - 0x08000202, 0x08000203, 0x08040202, 0x08040203, - 0x09000202, 0x09000203, 0x09040202, 0x09040203, - }, - { - /* for C bits (numbered as per FIPS 46) 21 23 24 26 27 28 */ - 0x00000000, 0x00100000, 0x00000100, 0x00100100, - 0x00000008, 0x00100008, 0x00000108, 0x00100108, - 0x00001000, 0x00101000, 0x00001100, 0x00101100, - 0x00001008, 0x00101008, 0x00001108, 0x00101108, - 0x04000000, 0x04100000, 0x04000100, 0x04100100, - 0x04000008, 0x04100008, 0x04000108, 0x04100108, - 0x04001000, 0x04101000, 0x04001100, 0x04101100, - 0x04001008, 0x04101008, 0x04001108, 0x04101108, - 0x00020000, 0x00120000, 0x00020100, 0x00120100, - 0x00020008, 0x00120008, 0x00020108, 0x00120108, - 0x00021000, 0x00121000, 0x00021100, 0x00121100, - 0x00021008, 0x00121008, 0x00021108, 0x00121108, - 0x04020000, 0x04120000, 0x04020100, 0x04120100, - 0x04020008, 0x04120008, 0x04020108, 0x04120108, - 0x04021000, 0x04121000, 0x04021100, 0x04121100, - 0x04021008, 0x04121008, 0x04021108, 0x04121108, - }, - { - /* for D bits (numbered as per FIPS 46) 1 2 3 4 5 6 */ - 0x00000000, 0x10000000, 0x00010000, 0x10010000, - 0x00000004, 0x10000004, 0x00010004, 0x10010004, - 0x20000000, 0x30000000, 0x20010000, 0x30010000, - 0x20000004, 0x30000004, 0x20010004, 0x30010004, - 0x00100000, 0x10100000, 0x00110000, 0x10110000, - 0x00100004, 0x10100004, 0x00110004, 0x10110004, - 0x20100000, 0x30100000, 0x20110000, 0x30110000, - 0x20100004, 0x30100004, 0x20110004, 0x30110004, - 0x00001000, 0x10001000, 0x00011000, 0x10011000, - 0x00001004, 0x10001004, 0x00011004, 0x10011004, - 0x20001000, 0x30001000, 0x20011000, 0x30011000, - 0x20001004, 0x30001004, 0x20011004, 0x30011004, - 0x00101000, 0x10101000, 0x00111000, 0x10111000, - 0x00101004, 0x10101004, 0x00111004, 0x10111004, - 0x20101000, 0x30101000, 0x20111000, 0x30111000, - 0x20101004, 0x30101004, 0x20111004, 0x30111004, - }, - { - /* for D bits (numbered as per FIPS 46) 8 9 11 12 13 14 */ - 0x00000000, 0x08000000, 0x00000008, 0x08000008, - 0x00000400, 0x08000400, 0x00000408, 0x08000408, - 0x00020000, 0x08020000, 0x00020008, 0x08020008, - 0x00020400, 0x08020400, 0x00020408, 0x08020408, - 0x00000001, 0x08000001, 0x00000009, 0x08000009, - 0x00000401, 0x08000401, 0x00000409, 0x08000409, - 0x00020001, 0x08020001, 0x00020009, 0x08020009, - 0x00020401, 0x08020401, 0x00020409, 0x08020409, - 0x02000000, 0x0A000000, 0x02000008, 0x0A000008, - 0x02000400, 0x0A000400, 0x02000408, 0x0A000408, - 0x02020000, 0x0A020000, 0x02020008, 0x0A020008, - 0x02020400, 0x0A020400, 0x02020408, 0x0A020408, - 0x02000001, 0x0A000001, 0x02000009, 0x0A000009, - 0x02000401, 0x0A000401, 0x02000409, 0x0A000409, - 0x02020001, 0x0A020001, 0x02020009, 0x0A020009, - 0x02020401, 0x0A020401, 0x02020409, 0x0A020409, - }, - { - /* for D bits (numbered as per FIPS 46) 16 17 18 19 20 21 */ - 0x00000000, 0x00000100, 0x00080000, 0x00080100, - 0x01000000, 0x01000100, 0x01080000, 0x01080100, - 0x00000010, 0x00000110, 0x00080010, 0x00080110, - 0x01000010, 0x01000110, 0x01080010, 0x01080110, - 0x00200000, 0x00200100, 0x00280000, 0x00280100, - 0x01200000, 0x01200100, 0x01280000, 0x01280100, - 0x00200010, 0x00200110, 0x00280010, 0x00280110, - 0x01200010, 0x01200110, 0x01280010, 0x01280110, - 0x00000200, 0x00000300, 0x00080200, 0x00080300, - 0x01000200, 0x01000300, 0x01080200, 0x01080300, - 0x00000210, 0x00000310, 0x00080210, 0x00080310, - 0x01000210, 0x01000310, 0x01080210, 0x01080310, - 0x00200200, 0x00200300, 0x00280200, 0x00280300, - 0x01200200, 0x01200300, 0x01280200, 0x01280300, - 0x00200210, 0x00200310, 0x00280210, 0x00280310, - 0x01200210, 0x01200310, 0x01280210, 0x01280310, - }, - { - /* for D bits (numbered as per FIPS 46) 22 23 24 25 27 28 */ - 0x00000000, 0x04000000, 0x00040000, 0x04040000, - 0x00000002, 0x04000002, 0x00040002, 0x04040002, - 0x00002000, 0x04002000, 0x00042000, 0x04042000, - 0x00002002, 0x04002002, 0x00042002, 0x04042002, - 0x00000020, 0x04000020, 0x00040020, 0x04040020, - 0x00000022, 0x04000022, 0x00040022, 0x04040022, - 0x00002020, 0x04002020, 0x00042020, 0x04042020, - 0x00002022, 0x04002022, 0x00042022, 0x04042022, - 0x00000800, 0x04000800, 0x00040800, 0x04040800, - 0x00000802, 0x04000802, 0x00040802, 0x04040802, - 0x00002800, 0x04002800, 0x00042800, 0x04042800, - 0x00002802, 0x04002802, 0x00042802, 0x04042802, - 0x00000820, 0x04000820, 0x00040820, 0x04040820, - 0x00000822, 0x04000822, 0x00040822, 0x04040822, - 0x00002820, 0x04002820, 0x00042820, 0x04042820, - 0x00002822, 0x04002822, 0x00042822, 0x04042822, - }, + { + /* for C bits (numbered as per FIPS 46) 1 2 3 4 5 6 */ + 0x00000000, 0x00000010, 0x20000000, 0x20000010, + 0x00010000, 0x00010010, 0x20010000, 0x20010010, + 0x00000800, 0x00000810, 0x20000800, 0x20000810, + 0x00010800, 0x00010810, 0x20010800, 0x20010810, + 0x00000020, 0x00000030, 0x20000020, 0x20000030, + 0x00010020, 0x00010030, 0x20010020, 0x20010030, + 0x00000820, 0x00000830, 0x20000820, 0x20000830, + 0x00010820, 0x00010830, 0x20010820, 0x20010830, + 0x00080000, 0x00080010, 0x20080000, 0x20080010, + 0x00090000, 0x00090010, 0x20090000, 0x20090010, + 0x00080800, 0x00080810, 0x20080800, 0x20080810, + 0x00090800, 0x00090810, 0x20090800, 0x20090810, + 0x00080020, 0x00080030, 0x20080020, 0x20080030, + 0x00090020, 0x00090030, 0x20090020, 0x20090030, + 0x00080820, 0x00080830, 0x20080820, 0x20080830, + 0x00090820, 0x00090830, 0x20090820, 0x20090830, + }, + { + /* for C bits (numbered as per FIPS 46) 7 8 10 11 12 13 */ + 0x00000000, 0x02000000, 0x00002000, 0x02002000, + 0x00200000, 0x02200000, 0x00202000, 0x02202000, + 0x00000004, 0x02000004, 0x00002004, 0x02002004, + 0x00200004, 0x02200004, 0x00202004, 0x02202004, + 0x00000400, 0x02000400, 0x00002400, 0x02002400, + 0x00200400, 0x02200400, 0x00202400, 0x02202400, + 0x00000404, 0x02000404, 0x00002404, 0x02002404, + 0x00200404, 0x02200404, 0x00202404, 0x02202404, + 0x10000000, 0x12000000, 0x10002000, 0x12002000, + 0x10200000, 0x12200000, 0x10202000, 0x12202000, + 0x10000004, 0x12000004, 0x10002004, 0x12002004, + 0x10200004, 0x12200004, 0x10202004, 0x12202004, + 0x10000400, 0x12000400, 0x10002400, 0x12002400, + 0x10200400, 0x12200400, 0x10202400, 0x12202400, + 0x10000404, 0x12000404, 0x10002404, 0x12002404, + 0x10200404, 0x12200404, 0x10202404, 0x12202404, + }, + { + /* for C bits (numbered as per FIPS 46) 14 15 16 17 19 20 */ + 0x00000000, 0x00000001, 0x00040000, 0x00040001, + 0x01000000, 0x01000001, 0x01040000, 0x01040001, + 0x00000002, 0x00000003, 0x00040002, 0x00040003, + 0x01000002, 0x01000003, 0x01040002, 0x01040003, + 0x00000200, 0x00000201, 0x00040200, 0x00040201, + 0x01000200, 0x01000201, 0x01040200, 0x01040201, + 0x00000202, 0x00000203, 0x00040202, 0x00040203, + 0x01000202, 0x01000203, 0x01040202, 0x01040203, + 0x08000000, 0x08000001, 0x08040000, 0x08040001, + 0x09000000, 0x09000001, 0x09040000, 0x09040001, + 0x08000002, 0x08000003, 0x08040002, 0x08040003, + 0x09000002, 0x09000003, 0x09040002, 0x09040003, + 0x08000200, 0x08000201, 0x08040200, 0x08040201, + 0x09000200, 0x09000201, 0x09040200, 0x09040201, + 0x08000202, 0x08000203, 0x08040202, 0x08040203, + 0x09000202, 0x09000203, 0x09040202, 0x09040203, + }, + { + /* for C bits (numbered as per FIPS 46) 21 23 24 26 27 28 */ + 0x00000000, 0x00100000, 0x00000100, 0x00100100, + 0x00000008, 0x00100008, 0x00000108, 0x00100108, + 0x00001000, 0x00101000, 0x00001100, 0x00101100, + 0x00001008, 0x00101008, 0x00001108, 0x00101108, + 0x04000000, 0x04100000, 0x04000100, 0x04100100, + 0x04000008, 0x04100008, 0x04000108, 0x04100108, + 0x04001000, 0x04101000, 0x04001100, 0x04101100, + 0x04001008, 0x04101008, 0x04001108, 0x04101108, + 0x00020000, 0x00120000, 0x00020100, 0x00120100, + 0x00020008, 0x00120008, 0x00020108, 0x00120108, + 0x00021000, 0x00121000, 0x00021100, 0x00121100, + 0x00021008, 0x00121008, 0x00021108, 0x00121108, + 0x04020000, 0x04120000, 0x04020100, 0x04120100, + 0x04020008, 0x04120008, 0x04020108, 0x04120108, + 0x04021000, 0x04121000, 0x04021100, 0x04121100, + 0x04021008, 0x04121008, 0x04021108, 0x04121108, + }, + { + /* for D bits (numbered as per FIPS 46) 1 2 3 4 5 6 */ + 0x00000000, 0x10000000, 0x00010000, 0x10010000, + 0x00000004, 0x10000004, 0x00010004, 0x10010004, + 0x20000000, 0x30000000, 0x20010000, 0x30010000, + 0x20000004, 0x30000004, 0x20010004, 0x30010004, + 0x00100000, 0x10100000, 0x00110000, 0x10110000, + 0x00100004, 0x10100004, 0x00110004, 0x10110004, + 0x20100000, 0x30100000, 0x20110000, 0x30110000, + 0x20100004, 0x30100004, 0x20110004, 0x30110004, + 0x00001000, 0x10001000, 0x00011000, 0x10011000, + 0x00001004, 0x10001004, 0x00011004, 0x10011004, + 0x20001000, 0x30001000, 0x20011000, 0x30011000, + 0x20001004, 0x30001004, 0x20011004, 0x30011004, + 0x00101000, 0x10101000, 0x00111000, 0x10111000, + 0x00101004, 0x10101004, 0x00111004, 0x10111004, + 0x20101000, 0x30101000, 0x20111000, 0x30111000, + 0x20101004, 0x30101004, 0x20111004, 0x30111004, + }, + { + /* for D bits (numbered as per FIPS 46) 8 9 11 12 13 14 */ + 0x00000000, 0x08000000, 0x00000008, 0x08000008, + 0x00000400, 0x08000400, 0x00000408, 0x08000408, + 0x00020000, 0x08020000, 0x00020008, 0x08020008, + 0x00020400, 0x08020400, 0x00020408, 0x08020408, + 0x00000001, 0x08000001, 0x00000009, 0x08000009, + 0x00000401, 0x08000401, 0x00000409, 0x08000409, + 0x00020001, 0x08020001, 0x00020009, 0x08020009, + 0x00020401, 0x08020401, 0x00020409, 0x08020409, + 0x02000000, 0x0A000000, 0x02000008, 0x0A000008, + 0x02000400, 0x0A000400, 0x02000408, 0x0A000408, + 0x02020000, 0x0A020000, 0x02020008, 0x0A020008, + 0x02020400, 0x0A020400, 0x02020408, 0x0A020408, + 0x02000001, 0x0A000001, 0x02000009, 0x0A000009, + 0x02000401, 0x0A000401, 0x02000409, 0x0A000409, + 0x02020001, 0x0A020001, 0x02020009, 0x0A020009, + 0x02020401, 0x0A020401, 0x02020409, 0x0A020409, + }, + { + /* for D bits (numbered as per FIPS 46) 16 17 18 19 20 21 */ + 0x00000000, 0x00000100, 0x00080000, 0x00080100, + 0x01000000, 0x01000100, 0x01080000, 0x01080100, + 0x00000010, 0x00000110, 0x00080010, 0x00080110, + 0x01000010, 0x01000110, 0x01080010, 0x01080110, + 0x00200000, 0x00200100, 0x00280000, 0x00280100, + 0x01200000, 0x01200100, 0x01280000, 0x01280100, + 0x00200010, 0x00200110, 0x00280010, 0x00280110, + 0x01200010, 0x01200110, 0x01280010, 0x01280110, + 0x00000200, 0x00000300, 0x00080200, 0x00080300, + 0x01000200, 0x01000300, 0x01080200, 0x01080300, + 0x00000210, 0x00000310, 0x00080210, 0x00080310, + 0x01000210, 0x01000310, 0x01080210, 0x01080310, + 0x00200200, 0x00200300, 0x00280200, 0x00280300, + 0x01200200, 0x01200300, 0x01280200, 0x01280300, + 0x00200210, 0x00200310, 0x00280210, 0x00280310, + 0x01200210, 0x01200310, 0x01280210, 0x01280310, + }, + { + /* for D bits (numbered as per FIPS 46) 22 23 24 25 27 28 */ + 0x00000000, 0x04000000, 0x00040000, 0x04040000, + 0x00000002, 0x04000002, 0x00040002, 0x04040002, + 0x00002000, 0x04002000, 0x00042000, 0x04042000, + 0x00002002, 0x04002002, 0x00042002, 0x04042002, + 0x00000020, 0x04000020, 0x00040020, 0x04040020, + 0x00000022, 0x04000022, 0x00040022, 0x04040022, + 0x00002020, 0x04002020, 0x00042020, 0x04042020, + 0x00002022, 0x04002022, 0x00042022, 0x04042022, + 0x00000800, 0x04000800, 0x00040800, 0x04040800, + 0x00000802, 0x04000802, 0x00040802, 0x04040802, + 0x00002800, 0x04002800, 0x00042800, 0x04042800, + 0x00002802, 0x04002802, 0x00042802, 0x04042802, + 0x00000820, 0x04000820, 0x00040820, 0x04040820, + 0x00000822, 0x04000822, 0x00040822, 0x04040822, + 0x00002820, 0x04002820, 0x00042820, 0x04042820, + 0x00002822, 0x04002822, 0x00042822, 0x04042822, + }, }; private static final int[][] SPtrans = { - { - /* nibble 0 */ - 0x00820200, 0x00020000, 0x80800000, 0x80820200, - 0x00800000, 0x80020200, 0x80020000, 0x80800000, - 0x80020200, 0x00820200, 0x00820000, 0x80000200, - 0x80800200, 0x00800000, 0x00000000, 0x80020000, - 0x00020000, 0x80000000, 0x00800200, 0x00020200, - 0x80820200, 0x00820000, 0x80000200, 0x00800200, - 0x80000000, 0x00000200, 0x00020200, 0x80820000, - 0x00000200, 0x80800200, 0x80820000, 0x00000000, - 0x00000000, 0x80820200, 0x00800200, 0x80020000, - 0x00820200, 0x00020000, 0x80000200, 0x00800200, - 0x80820000, 0x00000200, 0x00020200, 0x80800000, - 0x80020200, 0x80000000, 0x80800000, 0x00820000, - 0x80820200, 0x00020200, 0x00820000, 0x80800200, - 0x00800000, 0x80000200, 0x80020000, 0x00000000, - 0x00020000, 0x00800000, 0x80800200, 0x00820200, - 0x80000000, 0x80820000, 0x00000200, 0x80020200, - }, - { - /* nibble 1 */ - 0x10042004, 0x00000000, 0x00042000, 0x10040000, - 0x10000004, 0x00002004, 0x10002000, 0x00042000, - 0x00002000, 0x10040004, 0x00000004, 0x10002000, - 0x00040004, 0x10042000, 0x10040000, 0x00000004, - 0x00040000, 0x10002004, 0x10040004, 0x00002000, - 0x00042004, 0x10000000, 0x00000000, 0x00040004, - 0x10002004, 0x00042004, 0x10042000, 0x10000004, - 0x10000000, 0x00040000, 0x00002004, 0x10042004, - 0x00040004, 0x10042000, 0x10002000, 0x00042004, - 0x10042004, 0x00040004, 0x10000004, 0x00000000, - 0x10000000, 0x00002004, 0x00040000, 0x10040004, - 0x00002000, 0x10000000, 0x00042004, 0x10002004, - 0x10042000, 0x00002000, 0x00000000, 0x10000004, - 0x00000004, 0x10042004, 0x00042000, 0x10040000, - 0x10040004, 0x00040000, 0x00002004, 0x10002000, - 0x10002004, 0x00000004, 0x10040000, 0x00042000, - }, - { - /* nibble 2 */ - 0x41000000, 0x01010040, 0x00000040, 0x41000040, - 0x40010000, 0x01000000, 0x41000040, 0x00010040, - 0x01000040, 0x00010000, 0x01010000, 0x40000000, - 0x41010040, 0x40000040, 0x40000000, 0x41010000, - 0x00000000, 0x40010000, 0x01010040, 0x00000040, - 0x40000040, 0x41010040, 0x00010000, 0x41000000, - 0x41010000, 0x01000040, 0x40010040, 0x01010000, - 0x00010040, 0x00000000, 0x01000000, 0x40010040, - 0x01010040, 0x00000040, 0x40000000, 0x00010000, - 0x40000040, 0x40010000, 0x01010000, 0x41000040, - 0x00000000, 0x01010040, 0x00010040, 0x41010000, - 0x40010000, 0x01000000, 0x41010040, 0x40000000, - 0x40010040, 0x41000000, 0x01000000, 0x41010040, - 0x00010000, 0x01000040, 0x41000040, 0x00010040, - 0x01000040, 0x00000000, 0x41010000, 0x40000040, - 0x41000000, 0x40010040, 0x00000040, 0x01010000, - }, - { - /* nibble 3 */ - 0x00100402, 0x04000400, 0x00000002, 0x04100402, - 0x00000000, 0x04100000, 0x04000402, 0x00100002, - 0x04100400, 0x04000002, 0x04000000, 0x00000402, - 0x04000002, 0x00100402, 0x00100000, 0x04000000, - 0x04100002, 0x00100400, 0x00000400, 0x00000002, - 0x00100400, 0x04000402, 0x04100000, 0x00000400, - 0x00000402, 0x00000000, 0x00100002, 0x04100400, - 0x04000400, 0x04100002, 0x04100402, 0x00100000, - 0x04100002, 0x00000402, 0x00100000, 0x04000002, - 0x00100400, 0x04000400, 0x00000002, 0x04100000, - 0x04000402, 0x00000000, 0x00000400, 0x00100002, - 0x00000000, 0x04100002, 0x04100400, 0x00000400, - 0x04000000, 0x04100402, 0x00100402, 0x00100000, - 0x04100402, 0x00000002, 0x04000400, 0x00100402, - 0x00100002, 0x00100400, 0x04100000, 0x04000402, - 0x00000402, 0x04000000, 0x04000002, 0x04100400, - }, - { - /* nibble 4 */ - 0x02000000, 0x00004000, 0x00000100, 0x02004108, - 0x02004008, 0x02000100, 0x00004108, 0x02004000, - 0x00004000, 0x00000008, 0x02000008, 0x00004100, - 0x02000108, 0x02004008, 0x02004100, 0x00000000, - 0x00004100, 0x02000000, 0x00004008, 0x00000108, - 0x02000100, 0x00004108, 0x00000000, 0x02000008, - 0x00000008, 0x02000108, 0x02004108, 0x00004008, - 0x02004000, 0x00000100, 0x00000108, 0x02004100, - 0x02004100, 0x02000108, 0x00004008, 0x02004000, - 0x00004000, 0x00000008, 0x02000008, 0x02000100, - 0x02000000, 0x00004100, 0x02004108, 0x00000000, - 0x00004108, 0x02000000, 0x00000100, 0x00004008, - 0x02000108, 0x00000100, 0x00000000, 0x02004108, - 0x02004008, 0x02004100, 0x00000108, 0x00004000, - 0x00004100, 0x02004008, 0x02000100, 0x00000108, - 0x00000008, 0x00004108, 0x02004000, 0x02000008, - }, - { - /* nibble 5 */ - 0x20000010, 0x00080010, 0x00000000, 0x20080800, - 0x00080010, 0x00000800, 0x20000810, 0x00080000, - 0x00000810, 0x20080810, 0x00080800, 0x20000000, - 0x20000800, 0x20000010, 0x20080000, 0x00080810, - 0x00080000, 0x20000810, 0x20080010, 0x00000000, - 0x00000800, 0x00000010, 0x20080800, 0x20080010, - 0x20080810, 0x20080000, 0x20000000, 0x00000810, - 0x00000010, 0x00080800, 0x00080810, 0x20000800, - 0x00000810, 0x20000000, 0x20000800, 0x00080810, - 0x20080800, 0x00080010, 0x00000000, 0x20000800, - 0x20000000, 0x00000800, 0x20080010, 0x00080000, - 0x00080010, 0x20080810, 0x00080800, 0x00000010, - 0x20080810, 0x00080800, 0x00080000, 0x20000810, - 0x20000010, 0x20080000, 0x00080810, 0x00000000, - 0x00000800, 0x20000010, 0x20000810, 0x20080800, - 0x20080000, 0x00000810, 0x00000010, 0x20080010, - }, - { - /* nibble 6 */ - 0x00001000, 0x00000080, 0x00400080, 0x00400001, - 0x00401081, 0x00001001, 0x00001080, 0x00000000, - 0x00400000, 0x00400081, 0x00000081, 0x00401000, - 0x00000001, 0x00401080, 0x00401000, 0x00000081, - 0x00400081, 0x00001000, 0x00001001, 0x00401081, - 0x00000000, 0x00400080, 0x00400001, 0x00001080, - 0x00401001, 0x00001081, 0x00401080, 0x00000001, - 0x00001081, 0x00401001, 0x00000080, 0x00400000, - 0x00001081, 0x00401000, 0x00401001, 0x00000081, - 0x00001000, 0x00000080, 0x00400000, 0x00401001, - 0x00400081, 0x00001081, 0x00001080, 0x00000000, - 0x00000080, 0x00400001, 0x00000001, 0x00400080, - 0x00000000, 0x00400081, 0x00400080, 0x00001080, - 0x00000081, 0x00001000, 0x00401081, 0x00400000, - 0x00401080, 0x00000001, 0x00001001, 0x00401081, - 0x00400001, 0x00401080, 0x00401000, 0x00001001, - }, - { - /* nibble 7 */ - 0x08200020, 0x08208000, 0x00008020, 0x00000000, - 0x08008000, 0x00200020, 0x08200000, 0x08208020, - 0x00000020, 0x08000000, 0x00208000, 0x00008020, - 0x00208020, 0x08008020, 0x08000020, 0x08200000, - 0x00008000, 0x00208020, 0x00200020, 0x08008000, - 0x08208020, 0x08000020, 0x00000000, 0x00208000, - 0x08000000, 0x00200000, 0x08008020, 0x08200020, - 0x00200000, 0x00008000, 0x08208000, 0x00000020, - 0x00200000, 0x00008000, 0x08000020, 0x08208020, - 0x00008020, 0x08000000, 0x00000000, 0x00208000, - 0x08200020, 0x08008020, 0x08008000, 0x00200020, - 0x08208000, 0x00000020, 0x00200020, 0x08008000, - 0x08208020, 0x00200000, 0x08200000, 0x08000020, - 0x00208000, 0x00008020, 0x08008020, 0x08200000, - 0x00000020, 0x08208000, 0x00208020, 0x00000000, - 0x08000000, 0x08200020, 0x00008000, 0x00208020 - } + { + /* nibble 0 */ + 0x00820200, 0x00020000, 0x80800000, 0x80820200, + 0x00800000, 0x80020200, 0x80020000, 0x80800000, + 0x80020200, 0x00820200, 0x00820000, 0x80000200, + 0x80800200, 0x00800000, 0x00000000, 0x80020000, + 0x00020000, 0x80000000, 0x00800200, 0x00020200, + 0x80820200, 0x00820000, 0x80000200, 0x00800200, + 0x80000000, 0x00000200, 0x00020200, 0x80820000, + 0x00000200, 0x80800200, 0x80820000, 0x00000000, + 0x00000000, 0x80820200, 0x00800200, 0x80020000, + 0x00820200, 0x00020000, 0x80000200, 0x00800200, + 0x80820000, 0x00000200, 0x00020200, 0x80800000, + 0x80020200, 0x80000000, 0x80800000, 0x00820000, + 0x80820200, 0x00020200, 0x00820000, 0x80800200, + 0x00800000, 0x80000200, 0x80020000, 0x00000000, + 0x00020000, 0x00800000, 0x80800200, 0x00820200, + 0x80000000, 0x80820000, 0x00000200, 0x80020200, + }, + { + /* nibble 1 */ + 0x10042004, 0x00000000, 0x00042000, 0x10040000, + 0x10000004, 0x00002004, 0x10002000, 0x00042000, + 0x00002000, 0x10040004, 0x00000004, 0x10002000, + 0x00040004, 0x10042000, 0x10040000, 0x00000004, + 0x00040000, 0x10002004, 0x10040004, 0x00002000, + 0x00042004, 0x10000000, 0x00000000, 0x00040004, + 0x10002004, 0x00042004, 0x10042000, 0x10000004, + 0x10000000, 0x00040000, 0x00002004, 0x10042004, + 0x00040004, 0x10042000, 0x10002000, 0x00042004, + 0x10042004, 0x00040004, 0x10000004, 0x00000000, + 0x10000000, 0x00002004, 0x00040000, 0x10040004, + 0x00002000, 0x10000000, 0x00042004, 0x10002004, + 0x10042000, 0x00002000, 0x00000000, 0x10000004, + 0x00000004, 0x10042004, 0x00042000, 0x10040000, + 0x10040004, 0x00040000, 0x00002004, 0x10002000, + 0x10002004, 0x00000004, 0x10040000, 0x00042000, + }, + { + /* nibble 2 */ + 0x41000000, 0x01010040, 0x00000040, 0x41000040, + 0x40010000, 0x01000000, 0x41000040, 0x00010040, + 0x01000040, 0x00010000, 0x01010000, 0x40000000, + 0x41010040, 0x40000040, 0x40000000, 0x41010000, + 0x00000000, 0x40010000, 0x01010040, 0x00000040, + 0x40000040, 0x41010040, 0x00010000, 0x41000000, + 0x41010000, 0x01000040, 0x40010040, 0x01010000, + 0x00010040, 0x00000000, 0x01000000, 0x40010040, + 0x01010040, 0x00000040, 0x40000000, 0x00010000, + 0x40000040, 0x40010000, 0x01010000, 0x41000040, + 0x00000000, 0x01010040, 0x00010040, 0x41010000, + 0x40010000, 0x01000000, 0x41010040, 0x40000000, + 0x40010040, 0x41000000, 0x01000000, 0x41010040, + 0x00010000, 0x01000040, 0x41000040, 0x00010040, + 0x01000040, 0x00000000, 0x41010000, 0x40000040, + 0x41000000, 0x40010040, 0x00000040, 0x01010000, + }, + { + /* nibble 3 */ + 0x00100402, 0x04000400, 0x00000002, 0x04100402, + 0x00000000, 0x04100000, 0x04000402, 0x00100002, + 0x04100400, 0x04000002, 0x04000000, 0x00000402, + 0x04000002, 0x00100402, 0x00100000, 0x04000000, + 0x04100002, 0x00100400, 0x00000400, 0x00000002, + 0x00100400, 0x04000402, 0x04100000, 0x00000400, + 0x00000402, 0x00000000, 0x00100002, 0x04100400, + 0x04000400, 0x04100002, 0x04100402, 0x00100000, + 0x04100002, 0x00000402, 0x00100000, 0x04000002, + 0x00100400, 0x04000400, 0x00000002, 0x04100000, + 0x04000402, 0x00000000, 0x00000400, 0x00100002, + 0x00000000, 0x04100002, 0x04100400, 0x00000400, + 0x04000000, 0x04100402, 0x00100402, 0x00100000, + 0x04100402, 0x00000002, 0x04000400, 0x00100402, + 0x00100002, 0x00100400, 0x04100000, 0x04000402, + 0x00000402, 0x04000000, 0x04000002, 0x04100400, + }, + { + /* nibble 4 */ + 0x02000000, 0x00004000, 0x00000100, 0x02004108, + 0x02004008, 0x02000100, 0x00004108, 0x02004000, + 0x00004000, 0x00000008, 0x02000008, 0x00004100, + 0x02000108, 0x02004008, 0x02004100, 0x00000000, + 0x00004100, 0x02000000, 0x00004008, 0x00000108, + 0x02000100, 0x00004108, 0x00000000, 0x02000008, + 0x00000008, 0x02000108, 0x02004108, 0x00004008, + 0x02004000, 0x00000100, 0x00000108, 0x02004100, + 0x02004100, 0x02000108, 0x00004008, 0x02004000, + 0x00004000, 0x00000008, 0x02000008, 0x02000100, + 0x02000000, 0x00004100, 0x02004108, 0x00000000, + 0x00004108, 0x02000000, 0x00000100, 0x00004008, + 0x02000108, 0x00000100, 0x00000000, 0x02004108, + 0x02004008, 0x02004100, 0x00000108, 0x00004000, + 0x00004100, 0x02004008, 0x02000100, 0x00000108, + 0x00000008, 0x00004108, 0x02004000, 0x02000008, + }, + { + /* nibble 5 */ + 0x20000010, 0x00080010, 0x00000000, 0x20080800, + 0x00080010, 0x00000800, 0x20000810, 0x00080000, + 0x00000810, 0x20080810, 0x00080800, 0x20000000, + 0x20000800, 0x20000010, 0x20080000, 0x00080810, + 0x00080000, 0x20000810, 0x20080010, 0x00000000, + 0x00000800, 0x00000010, 0x20080800, 0x20080010, + 0x20080810, 0x20080000, 0x20000000, 0x00000810, + 0x00000010, 0x00080800, 0x00080810, 0x20000800, + 0x00000810, 0x20000000, 0x20000800, 0x00080810, + 0x20080800, 0x00080010, 0x00000000, 0x20000800, + 0x20000000, 0x00000800, 0x20080010, 0x00080000, + 0x00080010, 0x20080810, 0x00080800, 0x00000010, + 0x20080810, 0x00080800, 0x00080000, 0x20000810, + 0x20000010, 0x20080000, 0x00080810, 0x00000000, + 0x00000800, 0x20000010, 0x20000810, 0x20080800, + 0x20080000, 0x00000810, 0x00000010, 0x20080010, + }, + { + /* nibble 6 */ + 0x00001000, 0x00000080, 0x00400080, 0x00400001, + 0x00401081, 0x00001001, 0x00001080, 0x00000000, + 0x00400000, 0x00400081, 0x00000081, 0x00401000, + 0x00000001, 0x00401080, 0x00401000, 0x00000081, + 0x00400081, 0x00001000, 0x00001001, 0x00401081, + 0x00000000, 0x00400080, 0x00400001, 0x00001080, + 0x00401001, 0x00001081, 0x00401080, 0x00000001, + 0x00001081, 0x00401001, 0x00000080, 0x00400000, + 0x00001081, 0x00401000, 0x00401001, 0x00000081, + 0x00001000, 0x00000080, 0x00400000, 0x00401001, + 0x00400081, 0x00001081, 0x00001080, 0x00000000, + 0x00000080, 0x00400001, 0x00000001, 0x00400080, + 0x00000000, 0x00400081, 0x00400080, 0x00001080, + 0x00000081, 0x00001000, 0x00401081, 0x00400000, + 0x00401080, 0x00000001, 0x00001001, 0x00401081, + 0x00400001, 0x00401080, 0x00401000, 0x00001001, + }, + { + /* nibble 7 */ + 0x08200020, 0x08208000, 0x00008020, 0x00000000, + 0x08008000, 0x00200020, 0x08200000, 0x08208020, + 0x00000020, 0x08000000, 0x00208000, 0x00008020, + 0x00208020, 0x08008020, 0x08000020, 0x08200000, + 0x00008000, 0x00208020, 0x00200020, 0x08008000, + 0x08208020, 0x08000020, 0x00000000, 0x00208000, + 0x08000000, 0x00200000, 0x08008020, 0x08200020, + 0x00200000, 0x00008000, 0x08208000, 0x00000020, + 0x00200000, 0x00008000, 0x08000020, 0x08208020, + 0x00008020, 0x08000000, 0x00000000, 0x00208000, + 0x08200020, 0x08008020, 0x08008000, 0x00200020, + 0x08208000, 0x00000020, 0x00200020, 0x08008000, + 0x08208020, 0x00200000, 0x08200000, 0x08000020, + 0x00208000, 0x00008020, 0x08008020, 0x08200000, + 0x00000020, 0x08208000, 0x00208020, 0x00000000, + 0x08000000, 0x08200020, 0x00008000, 0x00208020 + } }; private static final int[] cov_2char = { - 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, - 0x36, 0x37, 0x38, 0x39, 0x41, 0x42, 0x43, 0x44, - 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, - 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, - 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x61, 0x62, - 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, - 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, - 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A + 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, + 0x36, 0x37, 0x38, 0x39, 0x41, 0x42, 0x43, 0x44, + 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, + 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, + 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x61, 0x62, + 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, + 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, + 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A }; private static final int byteToUnsigned (byte b) { - int value = (int)b; + int value = b; - return(value >= 0 ? value : value + 256); + return(value >= 0 ? value : value + 256); } private static int fourBytesToInt (byte[] b, int offset) { - int value; + int value; - value = byteToUnsigned(b[offset++]); - value |= (byteToUnsigned(b[offset++]) << 8); - value |= (byteToUnsigned(b[offset++]) << 16); - value |= (byteToUnsigned(b[offset++]) << 24); + value = byteToUnsigned(b[offset++]); + value |= (byteToUnsigned(b[offset++]) << 8); + value |= (byteToUnsigned(b[offset++]) << 16); + value |= (byteToUnsigned(b[offset++]) << 24); - return(value); + return(value); } private static final void intToFourBytes (int iValue, byte[] b, int offset) { - b[offset++] = (byte)((iValue) & 0xff); - b[offset++] = (byte)((iValue >>> 8 ) & 0xff); - b[offset++] = (byte)((iValue >>> 16) & 0xff); - b[offset++] = (byte)((iValue >>> 24) & 0xff); + b[offset++] = (byte)((iValue) & 0xff); + b[offset++] = (byte)((iValue >>> 8 ) & 0xff); + b[offset++] = (byte)((iValue >>> 16) & 0xff); + b[offset++] = (byte)((iValue >>> 24) & 0xff); } private static final void PERM_OP (int a, int b, int n, int m, - int[] results) + int[] results) { - int t; + int t; - t = ((a >>> n) ^ b) & m; - a ^= t << n; - b ^= t; + t = ((a >>> n) ^ b) & m; + a ^= t << n; + b ^= t; - results[0] = a; - results[1] = b; + results[0] = a; + results[1] = b; } private static final int HPERM_OP (int a, int n, int m) { - int t; + int t; - t = ((a << (16 - n)) ^ a) & m; - a = a ^ t ^ (t >>> (16 - n)); + t = ((a << (16 - n)) ^ a) & m; + a = a ^ t ^ (t >>> (16 - n)); - return(a); + return(a); } private static int[] des_set_key (byte[] key) { - int[] schedule = new int[ITERATIONS * 2]; + int[] schedule = new int[ITERATIONS * 2]; - int c = fourBytesToInt(key, 0); - int d = fourBytesToInt(key, 4); + int c = fourBytesToInt(key, 0); + int d = fourBytesToInt(key, 4); - int[] results = new int[2]; + int[] results = new int[2]; - PERM_OP(d, c, 4, 0x0f0f0f0f, results); - d = results[0]; c = results[1]; + PERM_OP(d, c, 4, 0x0f0f0f0f, results); + d = results[0]; c = results[1]; - c = HPERM_OP(c, -2, 0xcccc0000); - d = HPERM_OP(d, -2, 0xcccc0000); + c = HPERM_OP(c, -2, 0xcccc0000); + d = HPERM_OP(d, -2, 0xcccc0000); - PERM_OP(d, c, 1, 0x55555555, results); - d = results[0]; c = results[1]; + PERM_OP(d, c, 1, 0x55555555, results); + d = results[0]; c = results[1]; - PERM_OP(c, d, 8, 0x00ff00ff, results); - c = results[0]; d = results[1]; + PERM_OP(c, d, 8, 0x00ff00ff, results); + c = results[0]; d = results[1]; - PERM_OP(d, c, 1, 0x55555555, results); - d = results[0]; c = results[1]; + PERM_OP(d, c, 1, 0x55555555, results); + d = results[0]; c = results[1]; - d = (((d & 0x000000ff) << 16) | (d & 0x0000ff00) | - ((d & 0x00ff0000) >>> 16) | ((c & 0xf0000000) >>> 4)); - c &= 0x0fffffff; + d = (((d & 0x000000ff) << 16) | (d & 0x0000ff00) | + ((d & 0x00ff0000) >>> 16) | ((c & 0xf0000000) >>> 4)); + c &= 0x0fffffff; - int s, t; - int j = 0; + int s, t; + int j = 0; - for (int i = 0; i < ITERATIONS; i ++) { - if (shifts2[i]) { - c = (c >>> 2) | (c << 26); - d = (d >>> 2) | (d << 26); + for (int i = 0; i < ITERATIONS; i ++) { + if (shifts2[i]) { + c = (c >>> 2) | (c << 26); + d = (d >>> 2) | (d << 26); - } else { - c = (c >>> 1) | (c << 27); - d = (d >>> 1) | (d << 27); - } + } else { + c = (c >>> 1) | (c << 27); + d = (d >>> 1) | (d << 27); + } - c &= 0x0fffffff; - d &= 0x0fffffff; + c &= 0x0fffffff; + d &= 0x0fffffff; - s = skb[0][ (c ) & 0x3f ]| - skb[1][((c >>> 6) & 0x03) | ((c >>> 7) & 0x3c)]| - skb[2][((c >>> 13) & 0x0f) | ((c >>> 14) & 0x30)]| - skb[3][((c >>> 20) & 0x01) | ((c >>> 21) & 0x06) | - ((c >>> 22) & 0x38)]; + s = skb[0][ (c ) & 0x3f ]| + skb[1][((c >>> 6) & 0x03) | ((c >>> 7) & 0x3c)]| + skb[2][((c >>> 13) & 0x0f) | ((c >>> 14) & 0x30)]| + skb[3][((c >>> 20) & 0x01) | ((c >>> 21) & 0x06) | + ((c >>> 22) & 0x38)]; - t = skb[4][ (d ) & 0x3f ]| - skb[5][((d >>> 7) & 0x03) | ((d >>> 8) & 0x3c)]| - skb[6][ (d >>>15) & 0x3f ]| - skb[7][((d >>>21) & 0x0f) | ((d >>> 22) & 0x30)]; + t = skb[4][ (d ) & 0x3f ]| + skb[5][((d >>> 7) & 0x03) | ((d >>> 8) & 0x3c)]| + skb[6][ (d >>>15) & 0x3f ]| + skb[7][((d >>>21) & 0x0f) | ((d >>> 22) & 0x30)]; - schedule[j++] = ((t << 16) | (s & 0x0000ffff)) & 0xffffffff; - s = ((s >>> 16) | (t & 0xffff0000)); + schedule[j++] = ((t << 16) | (s & 0x0000ffff)) & 0xffffffff; + s = ((s >>> 16) | (t & 0xffff0000)); - s = (s << 4) | (s >>> 28); - schedule[j++] = s & 0xffffffff; - } - return(schedule); + s = (s << 4) | (s >>> 28); + schedule[j++] = s & 0xffffffff; + } + return(schedule); } private static final int D_ENCRYPT (int L, int R, int S, - int E0, int E1, int[] s) + int E0, int E1, int[] s) { - int t, u, v; + int t, u, v; - v = R ^ (R >>> 16); - u = v & E0; - v = v & E1; - u = (u ^ (u << 16)) ^ R ^ s[S]; - t = (v ^ (v << 16)) ^ R ^ s[S + 1]; - t = (t >>> 4) | (t << 28); + v = R ^ (R >>> 16); + u = v & E0; + v = v & E1; + u = (u ^ (u << 16)) ^ R ^ s[S]; + t = (v ^ (v << 16)) ^ R ^ s[S + 1]; + t = (t >>> 4) | (t << 28); - L ^= SPtrans[1][(t ) & 0x3f] | - SPtrans[3][(t >>> 8) & 0x3f] | - SPtrans[5][(t >>> 16) & 0x3f] | - SPtrans[7][(t >>> 24) & 0x3f] | - SPtrans[0][(u ) & 0x3f] | - SPtrans[2][(u >>> 8) & 0x3f] | - SPtrans[4][(u >>> 16) & 0x3f] | - SPtrans[6][(u >>> 24) & 0x3f]; + L ^= SPtrans[1][(t ) & 0x3f] | + SPtrans[3][(t >>> 8) & 0x3f] | + SPtrans[5][(t >>> 16) & 0x3f] | + SPtrans[7][(t >>> 24) & 0x3f] | + SPtrans[0][(u ) & 0x3f] | + SPtrans[2][(u >>> 8) & 0x3f] | + SPtrans[4][(u >>> 16) & 0x3f] | + SPtrans[6][(u >>> 24) & 0x3f]; - return(L); + return(L); } private static final int[] body (int[] schedule, int Eswap0, int Eswap1) { - int left = 0; - int right = 0; - int t = 0; + int left = 0; + int right = 0; + int t = 0; - for (int j = 0; j < 25; j ++) { - for (int i = 0; i < ITERATIONS * 2; i += 4) { - left = D_ENCRYPT(left, right, i, - Eswap0, Eswap1, schedule); - right = D_ENCRYPT(right, left, i + 2, - Eswap0, Eswap1, schedule); - } - t = left; - left = right; - right = t; - } + for (int j = 0; j < 25; j ++) { + for (int i = 0; i < ITERATIONS * 2; i += 4) { + left = D_ENCRYPT(left, right, i, + Eswap0, Eswap1, schedule); + right = D_ENCRYPT(right, left, i + 2, + Eswap0, Eswap1, schedule); + } + t = left; + left = right; + right = t; + } - t = right; + t = right; - right = (left >>> 1) | (left << 31); - left = (t >>> 1) | (t << 31); + right = (left >>> 1) | (left << 31); + left = (t >>> 1) | (t << 31); - left &= 0xffffffff; - right &= 0xffffffff; + left &= 0xffffffff; + right &= 0xffffffff; - int[] results = new int[2]; + int[] results = new int[2]; - PERM_OP(right, left, 1, 0x55555555, results); - right = results[0]; left = results[1]; + PERM_OP(right, left, 1, 0x55555555, results); + right = results[0]; left = results[1]; - PERM_OP(left, right, 8, 0x00ff00ff, results); - left = results[0]; right = results[1]; + PERM_OP(left, right, 8, 0x00ff00ff, results); + left = results[0]; right = results[1]; - PERM_OP(right, left, 2, 0x33333333, results); - right = results[0]; left = results[1]; + PERM_OP(right, left, 2, 0x33333333, results); + right = results[0]; left = results[1]; - PERM_OP(left, right, 16, 0x0000ffff, results); - left = results[0]; right = results[1]; + PERM_OP(left, right, 16, 0x0000ffff, results); + left = results[0]; right = results[1]; - PERM_OP(right, left, 4, 0x0f0f0f0f, results); - right = results[0]; left = results[1]; + PERM_OP(right, left, 4, 0x0f0f0f0f, results); + right = results[0]; left = results[1]; - int[] out = new int[2]; + int[] out = new int[2]; - out[0] = left; out[1] = right; + out[0] = left; out[1] = right; - return(out); + return(out); } /** @@ -578,88 +578,88 @@ public class Crypt */ public static final String crypt (String salt, String original) { - while (salt.length() < 2) { - salt += "A"; - } + while (salt.length() < 2) { + salt += "A"; + } - StringBuilder buffer = new StringBuilder(" "); + StringBuilder buffer = new StringBuilder(" "); - char charZero = salt.charAt(0); - char charOne = salt.charAt(1); + char charZero = salt.charAt(0); + char charOne = salt.charAt(1); - buffer.setCharAt(0, charZero); - buffer.setCharAt(1, charOne); + buffer.setCharAt(0, charZero); + buffer.setCharAt(1, charOne); - int Eswap0 = con_salt[(int)charZero]; - int Eswap1 = con_salt[(int)charOne] << 4; + int Eswap0 = con_salt[charZero]; + int Eswap1 = con_salt[charOne] << 4; - byte key[] = new byte[8]; + byte key[] = new byte[8]; - for (int i = 0; i < key.length; i ++) { - key[i] = (byte)0; - } + for (int i = 0; i < key.length; i ++) { + key[i] = (byte)0; + } - for (int i = 0; i < key.length && i < original.length(); i ++) { - int iChar = (int)original.charAt(i); - key[i] = (byte)(iChar << 1); - } + for (int i = 0; i < key.length && i < original.length(); i ++) { + int iChar = original.charAt(i); + key[i] = (byte)(iChar << 1); + } - int schedule[] = des_set_key(key); - int out[] = body(schedule, Eswap0, Eswap1); + int schedule[] = des_set_key(key); + int out[] = body(schedule, Eswap0, Eswap1); - byte b[] = new byte[9]; + byte b[] = new byte[9]; - intToFourBytes(out[0], b, 0); - intToFourBytes(out[1], b, 4); - b[8] = 0; + intToFourBytes(out[0], b, 0); + intToFourBytes(out[1], b, 4); + b[8] = 0; - for (int i = 2, y = 0, u = 0x80; i < 13; i ++) { - for (int j = 0, c = 0; j < 6; j ++) { - c <<= 1; + for (int i = 2, y = 0, u = 0x80; i < 13; i ++) { + for (int j = 0, c = 0; j < 6; j ++) { + c <<= 1; - if (((int)b[y] & u) != 0) - c |= 1; + if ((b[y] & u) != 0) + c |= 1; - u >>>= 1; + u >>>= 1; - if (u == 0) - { - y++; - u = 0x80; - } - buffer.setCharAt(i, (char)cov_2char[c]); - } - } + if (u == 0) + { + y++; + u = 0x80; + } + buffer.setCharAt(i, (char)cov_2char[c]); + } + } - return(buffer.toString()); + return(buffer.toString()); } public static void main (String[] args) { - if (args.length >= 2) { - System.out.println("[" + args[0] + "] [" + args[1] + "] => [" + - Crypt.crypt(args[0], args[1]) + "]"); + if (args.length >= 2) { + System.out.println("[" + args[0] + "] [" + args[1] + "] => [" + + Crypt.crypt(args[0], args[1]) + "]"); - } else { - int ccount = 10000; + } else { + int ccount = 10000; - long start = System.currentTimeMillis(); - String key = "samskivert"; - String salt = key.substring(0, 2); + long start = System.currentTimeMillis(); + String key = "samskivert"; + String salt = key.substring(0, 2); - System.out.println("Performing " + ccount + " crypt() calls..."); + System.out.println("Performing " + ccount + " crypt() calls..."); - // do 10,000 encryptions to see how long it takes - for (int i = 0; i < ccount; i++) { - Crypt.crypt(key, salt); - } + // do 10,000 encryptions to see how long it takes + for (int i = 0; i < ccount; i++) { + Crypt.crypt(key, salt); + } - long duration = System.currentTimeMillis() - start; + long duration = System.currentTimeMillis() - start; - System.out.println("Did " + ccount + " crypt()s in " + - duration + "ms."); - System.out.println("crypt()s per second: " + - (ccount*1000)/duration); - } + System.out.println("Did " + ccount + " crypt()s in " + + duration + "ms."); + System.out.println("crypt()s per second: " + + (ccount*1000)/duration); + } } } diff --git a/src/java/com/samskivert/util/FileUtil.java b/src/java/com/samskivert/util/FileUtil.java index 0092b0e2..98f6dfe5 100644 --- a/src/java/com/samskivert/util/FileUtil.java +++ b/src/java/com/samskivert/util/FileUtil.java @@ -81,7 +81,7 @@ public class FileUtil public static boolean unpackJar (JarFile jar, File target) { boolean failure = false; - Enumeration entries = jar.entries(); + Enumeration entries = jar.entries(); while (!failure && entries.hasMoreElements()) { JarEntry entry = (JarEntry)entries.nextElement(); File efile = new File(target, entry.getName()); diff --git a/src/java/com/samskivert/util/GenUtil.java b/src/java/com/samskivert/util/GenUtil.java index db2a3bbc..c8eacbcb 100644 --- a/src/java/com/samskivert/util/GenUtil.java +++ b/src/java/com/samskivert/util/GenUtil.java @@ -48,7 +48,7 @@ public class GenUtil if (type instanceof GenericArrayType) { return simpleName(((GenericArrayType)type).getGenericComponentType()) + "[]"; } else if (type instanceof Class) { - Class clazz = (Class)type; + Class clazz = (Class)type; if (clazz.isArray()) { return simpleName(clazz.getComponentType()) + "[]"; } else { diff --git a/src/java/com/samskivert/util/HashIntMap.java b/src/java/com/samskivert/util/HashIntMap.java index 2ca44849..3e7998d8 100644 --- a/src/java/com/samskivert/util/HashIntMap.java +++ b/src/java/com/samskivert/util/HashIntMap.java @@ -538,8 +538,7 @@ public class HashIntMap extends AbstractMap protected Record[] createBuckets (int size) { - @SuppressWarnings("unchecked") Record[] recs = - (Record[]) new Record[size]; + @SuppressWarnings("unchecked") Record[] recs = new Record[size]; return recs; } @@ -582,7 +581,7 @@ public class HashIntMap extends AbstractMap if (!(o instanceof IntEntry)) { return false; } - IntEntry that = (IntEntry)o; + IntEntry that = (IntEntry)o; return (this.key == that.getIntKey()) && ObjectUtil.equals(this.value, that.getValue()); } diff --git a/src/java/com/samskivert/util/JDK14Logger.java b/src/java/com/samskivert/util/JDK14Logger.java index 17115b94..3676df66 100644 --- a/src/java/com/samskivert/util/JDK14Logger.java +++ b/src/java/com/samskivert/util/JDK14Logger.java @@ -48,7 +48,7 @@ public class JDK14Logger implements Logger.Factory } // from interface Logger.Factory - public Logger getLogger (Class clazz) + public Logger getLogger (Class clazz) { return getLogger(clazz.getName()); } diff --git a/src/java/com/samskivert/util/Log.java b/src/java/com/samskivert/util/Log.java index f2d25bab..f35469b5 100644 --- a/src/java/com/samskivert/util/Log.java +++ b/src/java/com/samskivert/util/Log.java @@ -213,7 +213,7 @@ public final class Log try { provider = System.getProperty("log_provider"); if (provider != null) { - Class lpclass = Class.forName(provider); + Class lpclass = Class.forName(provider); _provider = (LogProvider)lpclass.newInstance(); } diff --git a/src/java/com/samskivert/util/Log4JLogger.java b/src/java/com/samskivert/util/Log4JLogger.java index a70d276d..f76e3197 100644 --- a/src/java/com/samskivert/util/Log4JLogger.java +++ b/src/java/com/samskivert/util/Log4JLogger.java @@ -39,7 +39,7 @@ public class Log4JLogger implements Logger.Factory } // from interface Logger.Factory - public Logger getLogger (Class clazz) + public Logger getLogger (Class clazz) { return getLogger(clazz.getName()); } diff --git a/src/java/com/samskivert/util/Logger.java b/src/java/com/samskivert/util/Logger.java index 651c2a17..6410616c 100644 --- a/src/java/com/samskivert/util/Logger.java +++ b/src/java/com/samskivert/util/Logger.java @@ -47,7 +47,7 @@ public abstract class Logger { public void init (); 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. */ - public static Logger getLogger (Class clazz) + public static Logger getLogger (Class clazz) { return _factory.getLogger(clazz); } diff --git a/src/java/com/samskivert/util/MapEntry.java b/src/java/com/samskivert/util/MapEntry.java index 2b1458a4..a73c1c72 100644 --- a/src/java/com/samskivert/util/MapEntry.java +++ b/src/java/com/samskivert/util/MapEntry.java @@ -69,7 +69,7 @@ public class MapEntry implements Map.Entry if (!(o instanceof Map.Entry)) { return false; } - Map.Entry e = (Map.Entry)o; + Map.Entry e = (Map.Entry)o; return ObjectUtil.equals(_key, e.getKey()) && ObjectUtil.equals(_value, e.getValue()); } diff --git a/src/java/com/samskivert/util/MethodFinder.java b/src/java/com/samskivert/util/MethodFinder.java index b43bfb14..c79d4420 100644 --- a/src/java/com/samskivert/util/MethodFinder.java +++ b/src/java/com/samskivert/util/MethodFinder.java @@ -50,7 +50,7 @@ public class MethodFinder * @exception IllegalArgumentException if clazz is null, or represents a primitive, or * represents an array type. */ - public MethodFinder (Class clazz) + public MethodFinder (Class clazz) { if (clazz == null) { 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 * call is ambiguous based on the parameter types. */ - public Constructor findConstructor (Class[] parameterTypes) + public Constructor findConstructor (Class[] parameterTypes) throws NoSuchMethodException { // make sure the constructor list is loaded @@ -101,7 +101,7 @@ public class MethodFinder 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 * 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 { // 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 * method will be either all {@link Constructor} objects or all {@link Method} objects. */ - protected Member findMemberIn (List memberList, Class[] parameterTypes) + protected Member findMemberIn (List memberList, Class[] parameterTypes) throws NoSuchMethodException { List matchingMembers = new ArrayList(); for (Iterator it = memberList.iterator(); it.hasNext();) { Member member = it.next(); - Class[] methodParamTypes = _paramMap.get(member); + Class[] methodParamTypes = _paramMap.get(member); // check for exactly equal method signature if (Arrays.equals(methodParamTypes, parameterTypes)) { @@ -256,7 +256,7 @@ public class MethodFinder { if (_ctorList == null) { _ctorList = new ArrayList(); - Constructor[] ctors = _clazz.getConstructors(); + Constructor[] ctors = _clazz.getConstructors(); for (int i = 0; i < ctors.length; ++i) { _ctorList.add(ctors[i]); _paramMap.put(ctors[i], ctors[i].getParameterTypes()); @@ -276,7 +276,7 @@ public class MethodFinder for (int i = 0; i < methods.length; ++i) { Method m = methods[i]; String methodName = m.getName(); - Class[] paramTypes = m.getParameterTypes(); + Class[] paramTypes = m.getParameterTypes(); List list = _methodMap.get(methodName); if (list == null) { @@ -306,13 +306,13 @@ public class MethodFinder */ protected boolean memberIsMoreSpecific (Member first, Member second) { - Class[] firstParamTypes = _paramMap.get(first); - Class[] secondParamTypes = _paramMap.get(second); + Class[] firstParamTypes = _paramMap.get(first); + Class[] secondParamTypes = _paramMap.get(second); return ClassUtil.compatibleClasses(secondParamTypes, firstParamTypes); } /** 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. */ protected Map> _methodMap = null; @@ -322,5 +322,5 @@ public class MethodFinder /** Mapping from a Constructor or Method object to the Class objects representing its formal * parameters. */ - protected Map _paramMap = new HashMap(); + protected Map[]> _paramMap = new HashMap[]>(); } diff --git a/src/java/com/samskivert/util/Predicate.java b/src/java/com/samskivert/util/Predicate.java index 6d662a68..e15ac95b 100644 --- a/src/java/com/samskivert/util/Predicate.java +++ b/src/java/com/samskivert/util/Predicate.java @@ -53,7 +53,7 @@ public abstract class Predicate */ public static class InstanceOf extends Predicate { - public InstanceOf (Class clazz) + public InstanceOf (Class clazz) { _class = clazz; } @@ -65,7 +65,7 @@ public abstract class Predicate } /** The class that must be implemented by applicants. */ - protected Class _class; + protected Class _class; } /** diff --git a/src/java/com/samskivert/util/PropertiesUtil.java b/src/java/com/samskivert/util/PropertiesUtil.java index 14b4615f..5103ff22 100644 --- a/src/java/com/samskivert/util/PropertiesUtil.java +++ b/src/java/com/samskivert/util/PropertiesUtil.java @@ -162,7 +162,7 @@ public class PropertiesUtil int preflen = prefix.length(); // scan the source properties - Enumeration names = source.propertyNames(); + Enumeration names = source.propertyNames(); while (names.hasMoreElements()) { String name = (String)names.nextElement(); // skip unrelated properties diff --git a/src/java/com/samskivert/util/StringUtil.java b/src/java/com/samskivert/util/StringUtil.java index e274fdd4..4f8da378 100644 --- a/src/java/com/samskivert/util/StringUtil.java +++ b/src/java/com/samskivert/util/StringUtil.java @@ -481,11 +481,11 @@ public class StringUtil buf.append(closeBox); } else if (val instanceof Iterable) { - toString(buf, ((Iterable)val).iterator(), openBox, closeBox); + toString(buf, ((Iterable)val).iterator(), openBox, closeBox); } else if (val instanceof Iterator) { buf.append(openBox); - Iterator iter = (Iterator)val; + Iterator iter = (Iterator)val; for (int i = 0; iter.hasNext(); i++) { if (i > 0) { buf.append(sep); @@ -496,7 +496,7 @@ public class StringUtil } else if (val instanceof Enumeration) { buf.append(openBox); - Enumeration enm = (Enumeration)val; + Enumeration enm = (Enumeration)val; for (int i = 0; enm.hasMoreElements(); i++) { if (i > 0) { buf.append(sep); @@ -551,7 +551,7 @@ public class StringUtil { // get an iterator if this is a collection if (val instanceof Iterable) { - val = ((Iterable)val).iterator(); + val = ((Iterable)val).iterator(); } String openBox = formatter.getOpenBox(); @@ -570,7 +570,7 @@ public class StringUtil } else if (val instanceof Iterator) { buf.append(openBox); - Iterator iter = (Iterator)val; + Iterator iter = (Iterator)val; for (int i = 0; iter.hasNext(); i++) { if (i > 0) { buf.append(", "); @@ -581,7 +581,7 @@ public class StringUtil } else if (val instanceof Enumeration) { buf.append(openBox); - Enumeration enm = (Enumeration)val; + Enumeration enm = (Enumeration)val; for (int i = 0; enm.hasMoreElements(); i++) { if (i > 0) { buf.append(", "); @@ -759,7 +759,7 @@ public class StringUtil char[] chars = new char[count*2]; for (int i = 0; i < count; i++) { - int val = (int)bytes[i]; + int val = bytes[i]; if (val < 0) { val += 256; } @@ -1199,7 +1199,7 @@ public class StringUtil * name. For example, com.samskivert.util.StringUtil would be reported as * util.StringUtil. */ - public static String shortClassName (Class clazz) + public static String shortClassName (Class clazz) { return shortClassName(clazz.getName()); } diff --git a/src/java/com/samskivert/util/Tuple.java b/src/java/com/samskivert/util/Tuple.java index 04372356..1a56a30e 100644 --- a/src/java/com/samskivert/util/Tuple.java +++ b/src/java/com/samskivert/util/Tuple.java @@ -71,7 +71,7 @@ public class Tuple implements Serializable public boolean equals (Object other) { if (other instanceof Tuple) { - Tuple to = (Tuple)other; + Tuple to = (Tuple)other; return (left.equals(to.left) && right.equals(to.right)); } else { return false; diff --git a/src/java/com/samskivert/util/ValueMarshaller.java b/src/java/com/samskivert/util/ValueMarshaller.java index ebf5e67e..eb59fddc 100644 --- a/src/java/com/samskivert/util/ValueMarshaller.java +++ b/src/java/com/samskivert/util/ValueMarshaller.java @@ -38,7 +38,7 @@ public class ValueMarshaller * @exception Exception thrown if no field parser exists for the * 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 { // look up an argument parser for the field type @@ -56,10 +56,10 @@ public class ValueMarshaller public Object parse (String source) throws Exception; } - protected static HashMap _parsers; + protected static HashMap,Parser> _parsers; static { - _parsers = new HashMap(); + _parsers = new HashMap,Parser>(); // we can parse strings _parsers.put(String.class, new Parser() { diff --git a/src/java/com/samskivert/util/tests/ConfigTest.java b/src/java/com/samskivert/util/tests/ConfigTest.java index ee4cffa0..639832b6 100644 --- a/src/java/com/samskivert/util/tests/ConfigTest.java +++ b/src/java/com/samskivert/util/tests/ConfigTest.java @@ -62,7 +62,7 @@ public class ConfigTest extends TestCase config.setValue("prop2", "three"); System.out.println("prop2: " + config.getValue("prop2", "two")); - Iterator iter = config.keys(); + Iterator iter = config.keys(); System.out.println("Keys: " + StringUtil.toString(iter)); config.setValue("sub.sub3", "three"); diff --git a/src/java/com/samskivert/velocity/DispatcherServlet.java b/src/java/com/samskivert/velocity/DispatcherServlet.java index fb87e130..d7974c21 100644 --- a/src/java/com/samskivert/velocity/DispatcherServlet.java +++ b/src/java/com/samskivert/velocity/DispatcherServlet.java @@ -149,7 +149,7 @@ public class DispatcherServlet extends HttpServlet if (StringUtil.isBlank(appcl)) { _app = new Application(); } else { - Class appclass = Class.forName(appcl); + Class appclass = Class.forName(appcl); _app = (Application)appclass.newInstance(); } @@ -418,6 +418,7 @@ public class DispatcherServlet extends HttpServlet * Called when a method throws an exception during template * evaluation. */ + @SuppressWarnings("unchecked") public Object methodException (Class clazz, String method, Exception e) throws Exception { @@ -580,7 +581,7 @@ public class DispatcherServlet extends HttpServlet if (logic == null) { try { - Class pcl = Class.forName(lclass); + Class pcl = Class.forName(lclass); logic = (Logic)pcl.newInstance(); } catch (ClassNotFoundException cnfe) { diff --git a/src/java/com/samskivert/velocity/InvocationContext.java b/src/java/com/samskivert/velocity/InvocationContext.java index ad13e043..9ad5a426 100644 --- a/src/java/com/samskivert/velocity/InvocationContext.java +++ b/src/java/com/samskivert/velocity/InvocationContext.java @@ -116,7 +116,7 @@ public class InvocationContext extends VelocityContext @Deprecated public void putAllParameters () { - Enumeration e = _req.getParameterNames(); + Enumeration e = _req.getParameterNames(); while (e.hasMoreElements()) { String param = (String)e.nextElement(); put(param, _req.getParameter(param)); @@ -130,7 +130,7 @@ public class InvocationContext extends VelocityContext public String encodeAllParameters () { StringBuilder buf = new StringBuilder(); - Enumeration e = _req.getParameterNames(); + Enumeration e = _req.getParameterNames(); while (e.hasMoreElements()) { if (buf.length() > 0) { buf.append('&'); diff --git a/src/java/com/samskivert/xml/SetNextFieldRule.java b/src/java/com/samskivert/xml/SetNextFieldRule.java index 0c5a4877..3b360af7 100644 --- a/src/java/com/samskivert/xml/SetNextFieldRule.java +++ b/src/java/com/samskivert/xml/SetNextFieldRule.java @@ -45,7 +45,7 @@ public class SetNextFieldRule extends Rule // identify the objects to be used Object child = digester.peek(0); Object parent = digester.peek(1); - Class pclass = parent.getClass(); + Class pclass = parent.getClass(); if (digester.getLogger().isDebugEnabled()) { digester.getLogger().debug("Set " + pclass.getName() + "." + diff --git a/src/java/com/samskivert/xml/SetPropertyFieldsRule.java b/src/java/com/samskivert/xml/SetPropertyFieldsRule.java index 7d2048cd..39fcf17c 100644 --- a/src/java/com/samskivert/xml/SetPropertyFieldsRule.java +++ b/src/java/com/samskivert/xml/SetPropertyFieldsRule.java @@ -85,10 +85,10 @@ public class SetPropertyFieldsRule extends Rule throws Exception { Object top = digester.peek(); - Class topclass = top.getClass(); + Class topclass = top.getClass(); // 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); if (StringUtil.isBlank(lname)) { lname = attrs.getQName(i); diff --git a/src/java/com/samskivert/xml/ValidatedSetNextRule.java b/src/java/com/samskivert/xml/ValidatedSetNextRule.java index 4de8ebb9..67b966a9 100644 --- a/src/java/com/samskivert/xml/ValidatedSetNextRule.java +++ b/src/java/com/samskivert/xml/ValidatedSetNextRule.java @@ -61,7 +61,7 @@ public class ValidatedSetNextRule extends Rule * specified parameter type. */ public ValidatedSetNextRule ( - String methodName, Class paramType, Validator validator) + String methodName, Class paramType, Validator validator) { // keep this for later _methodName = methodName; @@ -81,14 +81,14 @@ public class ValidatedSetNextRule extends Rule return; } - Class pclass = parent.getClass(); + Class pclass = parent.getClass(); if (digester.getLogger().isDebugEnabled()) { digester.getLogger().debug("Call " + pclass.getName() + "." + _methodName + " (" + child + ")"); } // call the specified method - Class[] paramTypes = new Class[1]; + Class[] paramTypes = new Class[1]; paramTypes[0] = (_paramType == null) ? child.getClass() : _paramType; Method method = parent.getClass().getMethod(_methodName, paramTypes); method.invoke(parent, new Object[] { child }); @@ -111,6 +111,6 @@ public class ValidatedSetNextRule extends Rule } protected String _methodName; - protected Class _paramType; + protected Class _paramType; protected Validator _validator; }