diff --git a/openjpa-kernel/src/main/java/org/apache/openjpa/meta/AbstractCFMetaDataFactory.java b/openjpa-kernel/src/main/java/org/apache/openjpa/meta/AbstractCFMetaDataFactory.java index 731af902f..eaacb7374 100644 --- a/openjpa-kernel/src/main/java/org/apache/openjpa/meta/AbstractCFMetaDataFactory.java +++ b/openjpa-kernel/src/main/java/org/apache/openjpa/meta/AbstractCFMetaDataFactory.java @@ -167,7 +167,7 @@ public abstract class AbstractCFMetaDataFactory } public boolean store(ClassMetaData[] metas, QueryMetaData[] queries, - SequenceMetaData[] seqs, int mode, Map output) { + SequenceMetaData[] seqs, int mode, Map output) { if (mode == MODE_NONE) return true; if (isMappingOnlyFactory() && (mode & MODE_MAPPING) == 0) @@ -338,14 +338,14 @@ public abstract class AbstractCFMetaDataFactory for (int i = 0; i < cls.length; i++) ser.removeMetaData(pr.getMetaData(cls[i], envLoader, false)); - serialize(ser, null, ser.PRETTY); + serialize(ser, null, Serializer.PRETTY); } if (qqs != null && !qqs.isEmpty()) { ser = newSerializer(); ser.setMode(MODE_QUERY); for (int i = 0; i < qqs.size(); i++) ser.addQueryMetaData((QueryMetaData) qqs.get(i)); - serialize(ser, null, ser.PRETTY); + serialize(ser, null, Serializer.PRETTY); } return true; } @@ -473,7 +473,8 @@ public abstract class AbstractCFMetaDataFactory /** * Tell the given serialier to write its metadatas. */ - protected void serialize(MetaDataSerializer ser, Map output, int flags) { + protected void serialize(MetaDataSerializer ser, Map output, + int flags) { try { if (output == null) ser.serialize(flags); diff --git a/openjpa-kernel/src/main/java/org/apache/openjpa/meta/AbstractMetaDataFactory.java b/openjpa-kernel/src/main/java/org/apache/openjpa/meta/AbstractMetaDataFactory.java index d47e8b6d2..8fb60f97b 100644 --- a/openjpa-kernel/src/main/java/org/apache/openjpa/meta/AbstractMetaDataFactory.java +++ b/openjpa-kernel/src/main/java/org/apache/openjpa/meta/AbstractMetaDataFactory.java @@ -84,7 +84,7 @@ public abstract class AbstractMetaDataFactory } public boolean store(ClassMetaData[] metas, QueryMetaData[] queries, - SequenceMetaData[] seqs, int mode, Map output) { + SequenceMetaData[] seqs, int mode, Map output) { return false; } diff --git a/openjpa-kernel/src/main/java/org/apache/openjpa/meta/MetaDataFactory.java b/openjpa-kernel/src/main/java/org/apache/openjpa/meta/MetaDataFactory.java index cc14ca852..a45a67c78 100644 --- a/openjpa-kernel/src/main/java/org/apache/openjpa/meta/MetaDataFactory.java +++ b/openjpa-kernel/src/main/java/org/apache/openjpa/meta/MetaDataFactory.java @@ -87,7 +87,7 @@ public interface MetaDataFactory * @return false if this factory is unable to store metadata */ public boolean store(ClassMetaData[] metas, QueryMetaData[] queries, - SequenceMetaData[] seqs, int mode, Map output); + SequenceMetaData[] seqs, int mode, Map output); /** * Drop the metadata for the given classes in the given mode(s). diff --git a/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DecoratingDataSource.java b/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DecoratingDataSource.java index 81269c904..54c7913d9 100644 --- a/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DecoratingDataSource.java +++ b/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DecoratingDataSource.java @@ -22,7 +22,6 @@ import java.sql.Connection; import java.sql.SQLException; import java.util.Collection; import java.util.Collections; -import java.util.Iterator; import java.util.List; import javax.sql.DataSource; @@ -36,7 +35,8 @@ import java.util.concurrent.CopyOnWriteArrayList; */ public class DecoratingDataSource extends DelegatingDataSource { - private List _decorators = new CopyOnWriteArrayList(); + private List _decorators = + new CopyOnWriteArrayList(); /** * Constructor. Supply wrapped data source. @@ -49,7 +49,7 @@ public class DecoratingDataSource extends DelegatingDataSource { * Return a read-only list of connection decorators in the order they were * added. */ - public Collection getDecorators() { + public Collection getDecorators() { return Collections.unmodifiableCollection(_decorators); } @@ -64,7 +64,7 @@ public class DecoratingDataSource extends DelegatingDataSource { /** * Add multiple connection decorators efficiently. */ - public void addDecorators(Collection decorators) { + public void addDecorators(Collection decorators) { if (decorators != null) _decorators.addAll(decorators); } @@ -95,9 +95,9 @@ public class DecoratingDataSource extends DelegatingDataSource { } private Connection decorate(Connection conn) throws SQLException { - if (!_decorators.isEmpty()) - for (Iterator itr = _decorators.iterator(); itr.hasNext();) - conn = ((ConnectionDecorator) itr.next()).decorate(conn); + for(ConnectionDecorator decorator : _decorators) { + conn = decorator.decorate(conn); + } return conn; } } diff --git a/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingCallableStatement.java b/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingCallableStatement.java index 62ab28d07..821eb82a5 100644 --- a/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingCallableStatement.java +++ b/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingCallableStatement.java @@ -336,6 +336,9 @@ public class DelegatingCallableStatement _stmnt.setAsciiStream(i1, is, i2); } + /** + * @deprecated + */ public void setUnicodeStream(int i1, InputStream is, int i2) throws SQLException { _stmnt.setUnicodeStream(i1, is, i2); @@ -509,6 +512,10 @@ public class DelegatingCallableStatement return _stmnt.getDouble(i); } + /** + * @deprecated use getBigDecimal(int parameterIndex) or + * getBigDecimal(String parameterName) + */ public BigDecimal getBigDecimal(int a, int b) throws SQLException { return _stmnt.getBigDecimal(a, b); } @@ -537,7 +544,7 @@ public class DelegatingCallableStatement return _stmnt.getBigDecimal(i); } - public Object getObject(int i, Map m) throws SQLException { + public Object getObject(int i, Map> m) throws SQLException { return _stmnt.getObject(i, m); } @@ -760,7 +767,7 @@ public class DelegatingCallableStatement throw new UnsupportedOperationException(); } - public Object getObject(String a, Map b) throws SQLException { + public Object getObject(String a, Map>b) throws SQLException { throw new UnsupportedOperationException(); } diff --git a/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingConnection.java b/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingConnection.java index 473a96b44..687133779 100644 --- a/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingConnection.java +++ b/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingConnection.java @@ -63,7 +63,7 @@ public class DelegatingConnection implements Connection, Closeable { private static final Localizer _loc = Localizer.forPackage (DelegatingConnection.class); - private static final Map _jdbc3; + private static final Map _jdbc3; static { boolean jdbc3 = false; @@ -76,7 +76,7 @@ public class DelegatingConnection implements Connection, Closeable { } if (jdbc3) { - _jdbc3 = new HashMap(); + _jdbc3 = new HashMap(); _jdbc3.put(SET_SAVEPOINT, m); } else _jdbc3 = null; @@ -331,11 +331,11 @@ public class DelegatingConnection implements Connection, Closeable { return stmnt; } - public Map getTypeMap() throws SQLException { + public Map> getTypeMap() throws SQLException { return _conn.getTypeMap(); } - public void setTypeMap(Map map) throws SQLException { + public void setTypeMap(Map> map) throws SQLException { _conn.setTypeMap(map); } @@ -578,7 +578,7 @@ public class DelegatingConnection implements Connection, Closeable { } private static Method createJDBC3Method(Object key, String name, - Class[] args) { + Class[] args) { try { Method m = Connection.class.getMethod(name, args); _jdbc3.put(key, m); diff --git a/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingPreparedStatement.java b/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingPreparedStatement.java index 0ff439ff0..b73ae2476 100644 --- a/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingPreparedStatement.java +++ b/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingPreparedStatement.java @@ -330,6 +330,9 @@ public class DelegatingPreparedStatement _stmnt.setAsciiStream(i1, is, i2); } + /** + * @deprecated + */ public void setUnicodeStream(int i1, InputStream is, int i2) throws SQLException { _stmnt.setUnicodeStream(i1, is, i2); diff --git a/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingResultSet.java b/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingResultSet.java index 0f571cac1..ff68c3755 100644 --- a/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingResultSet.java +++ b/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingResultSet.java @@ -146,6 +146,7 @@ public class DelegatingResultSet implements ResultSet, Closeable { return _rs.getDouble(a); } + @Deprecated public BigDecimal getBigDecimal(int a, int b) throws SQLException { return _rs.getBigDecimal(a, b); } @@ -170,6 +171,7 @@ public class DelegatingResultSet implements ResultSet, Closeable { return _rs.getAsciiStream(a); } + @Deprecated public InputStream getUnicodeStream(int a) throws SQLException { return _rs.getUnicodeStream(a); } @@ -210,6 +212,7 @@ public class DelegatingResultSet implements ResultSet, Closeable { return _rs.getDouble(a); } + @Deprecated public BigDecimal getBigDecimal(String a, int b) throws SQLException { return _rs.getBigDecimal(a, b); } @@ -234,6 +237,7 @@ public class DelegatingResultSet implements ResultSet, Closeable { return _rs.getAsciiStream(a); } + @Deprecated public InputStream getUnicodeStream(String a) throws SQLException { return _rs.getUnicodeStream(a); } @@ -568,7 +572,7 @@ public class DelegatingResultSet implements ResultSet, Closeable { return _stmnt; } - public Object getObject(int a, Map b) throws SQLException { + public Object getObject(int a, Map> b) throws SQLException { return _rs.getObject(a, b); } @@ -588,7 +592,7 @@ public class DelegatingResultSet implements ResultSet, Closeable { return _rs.getArray(a); } - public Object getObject(String a, Map b) throws SQLException { + public Object getObject(String a, Map> b) throws SQLException { return _rs.getObject(a, b); } diff --git a/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/JDBCEvent.java b/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/JDBCEvent.java index ce8fbf49e..598037e47 100644 --- a/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/JDBCEvent.java +++ b/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/JDBCEvent.java @@ -29,6 +29,7 @@ import java.util.EventObject; * @author Abe White * @see JDBCListener */ +@SuppressWarnings("serial") public class JDBCEvent extends EventObject { /** diff --git a/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/JDBCEventConnectionDecorator.java b/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/JDBCEventConnectionDecorator.java index 52ed8f220..126ba6bc0 100644 --- a/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/JDBCEventConnectionDecorator.java +++ b/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/JDBCEventConnectionDecorator.java @@ -32,6 +32,7 @@ import org.apache.openjpa.lib.util.concurrent.AbstractConcurrentEventManager; * @author Abe White * @nojavadoc */ +@SuppressWarnings("serial") public class JDBCEventConnectionDecorator extends AbstractConcurrentEventManager implements ConnectionDecorator { diff --git a/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/LoggingConnectionDecorator.java b/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/LoggingConnectionDecorator.java index 349b3de7a..03cfd7cde 100644 --- a/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/LoggingConnectionDecorator.java +++ b/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/LoggingConnectionDecorator.java @@ -893,8 +893,8 @@ public class LoggingConnectionDecorator implements ConnectionDecorator { extends DelegatingPreparedStatement { private final String _sql; - private List _params = null; - private List _paramBatch = null; + private List _params = null; + private List> _paramBatch = null; public LoggingPreparedStatement(PreparedStatement stmnt, String sql) throws SQLException { @@ -1025,7 +1025,7 @@ public class LoggingConnectionDecorator implements ConnectionDecorator { // set the current params to the saved values if (index < _paramBatch.size()) - _params = (List) _paramBatch.get(index); + _params = (List) _paramBatch.get(index); } } err = wrap(se, LoggingPreparedStatement.this); @@ -1138,6 +1138,7 @@ public class LoggingConnectionDecorator implements ConnectionDecorator { super.setAsciiStream(i1, is, i2); } + @Deprecated public void setUnicodeStream(int i1, InputStream is, int i2) throws SQLException { setLogParameter(i1, "InputStream", is); @@ -1181,10 +1182,12 @@ public class LoggingConnectionDecorator implements ConnectionDecorator { if (shouldTrackParameters()) { // make sure our list is initialized if (_paramBatch == null) - _paramBatch = new ArrayList(); + _paramBatch = new ArrayList>(); // copy parameters since they will be re-used - if (_params != null) - _paramBatch.add(new ArrayList(_params)); + if (_params != null) { + List copyParms = new ArrayList(_params); + _paramBatch.add(copyParms); + } else _paramBatch.add(null); } @@ -1258,7 +1261,8 @@ public class LoggingConnectionDecorator implements ConnectionDecorator { StringBuffer paramBuf = null; if (_params != null && !_params.isEmpty()) { paramBuf = new StringBuffer(); - for (Iterator itr = _params.iterator(); itr.hasNext();) { + for (Iterator itr = _params.iterator(); itr + .hasNext();) { paramBuf.append(itr.next()); if (itr.hasNext()) paramBuf.append(", "); @@ -1327,7 +1331,7 @@ public class LoggingConnectionDecorator implements ConnectionDecorator { private void setLogParameter(int index, String val) { if (_params == null) - _params = new ArrayList(); + _params = new ArrayList(); while (_params.size() < index) _params.add(null); if (val.length() > 80) @@ -1462,8 +1466,8 @@ public class LoggingConnectionDecorator implements ConnectionDecorator { private class LoggingCallableStatement extends DelegatingCallableStatement { private final String _sql; - private List _params = null; - private List _paramBatch = null; + private List _params = null; + private List> _paramBatch = null; public LoggingCallableStatement(CallableStatement stmt, String sql) throws SQLException { @@ -1594,7 +1598,7 @@ public class LoggingConnectionDecorator implements ConnectionDecorator { // set the current params to the saved values if (index < _paramBatch.size()) - _params = (List) _paramBatch.get(index); + _params = (List) _paramBatch.get(index); } } err = wrap(se, LoggingCallableStatement.this); @@ -1707,6 +1711,7 @@ public class LoggingConnectionDecorator implements ConnectionDecorator { super.setAsciiStream(i1, is, i2); } + @Deprecated public void setUnicodeStream(int i1, InputStream is, int i2) throws SQLException { setLogParameter(i1, "InputStream", is); @@ -1750,10 +1755,13 @@ public class LoggingConnectionDecorator implements ConnectionDecorator { if (shouldTrackParameters()) { // make sure our list is initialized if (_paramBatch == null) - _paramBatch = new ArrayList(); + _paramBatch = new ArrayList>(); // copy parameters since they will be re-used - if (_params != null) - _paramBatch.add(new ArrayList(_params)); + if (_params != null) { + List copyParams = + new ArrayList(_params); + _paramBatch.add(copyParams); + } else _paramBatch.add(null); } @@ -1827,7 +1835,8 @@ public class LoggingConnectionDecorator implements ConnectionDecorator { StringBuffer paramBuf = null; if (_params != null && !_params.isEmpty()) { paramBuf = new StringBuffer(); - for (Iterator itr = _params.iterator(); itr.hasNext();) { + for (Iterator itr = _params.iterator(); itr + .hasNext();) { paramBuf.append(itr.next()); if (itr.hasNext()) paramBuf.append(", "); @@ -1896,7 +1905,7 @@ public class LoggingConnectionDecorator implements ConnectionDecorator { private void setLogParameter(int index, String val) { if (_params == null) - _params = new ArrayList(); + _params = new ArrayList(); while (_params.size() < index) _params.add(null); if (val.length() > 80) diff --git a/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/ReportingSQLException.java b/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/ReportingSQLException.java index 560108a69..d65f22136 100644 --- a/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/ReportingSQLException.java +++ b/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/ReportingSQLException.java @@ -28,6 +28,7 @@ import java.sql.Statement; * @author Marc Prud'hommeaux * @nojavadoc */ +@SuppressWarnings("serial") public class ReportingSQLException extends SQLException { private final transient Statement _stmnt; diff --git a/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/SQLFormatter.java b/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/SQLFormatter.java index 8eb5fa98c..b5fec3e84 100644 --- a/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/SQLFormatter.java +++ b/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/SQLFormatter.java @@ -184,7 +184,7 @@ public class SQLFormatter { int start = 0; int end = -1; StringBuffer clause; - List clauses = new ArrayList(); + List clauses = new ArrayList(); clauses.add(new StringBuffer()); for (int i = 0; i < separators.length; i++) { end = lowerCaseSql.indexOf(" " + separators[i].toLowerCase(), @@ -192,7 +192,7 @@ public class SQLFormatter { if (end == -1) break; - clause = (StringBuffer) clauses.get(clauses.size() - 1); + clause = clauses.get(clauses.size() - 1); clause.append(sql.substring(start, end)); clause = new StringBuffer(); @@ -203,12 +203,12 @@ public class SQLFormatter { start = end + 1 + separators[i].length(); } - clause = (StringBuffer) clauses.get(clauses.size() - 1); + clause = clauses.get(clauses.size() - 1); clause.append(sql.substring(start)); StringBuffer pp = new StringBuffer(sql.length()); - for (Iterator iter = clauses.iterator(); iter.hasNext();) { - pp.append(wrapLine(((StringBuffer) iter.next()).toString())); + for (Iterator iter = clauses.iterator(); iter.hasNext();){ + pp.append(wrapLine(iter.next().toString())); if (iter.hasNext()) pp.append(newline); } diff --git a/openjpa-lib/src/main/java/org/apache/openjpa/lib/log/LogFactoryAdapter.java b/openjpa-lib/src/main/java/org/apache/openjpa/lib/log/LogFactoryAdapter.java index 0bc0d85cb..aa7f79219 100644 --- a/openjpa-lib/src/main/java/org/apache/openjpa/lib/log/LogFactoryAdapter.java +++ b/openjpa-lib/src/main/java/org/apache/openjpa/lib/log/LogFactoryAdapter.java @@ -31,11 +31,11 @@ import java.util.concurrent.ConcurrentHashMap; public abstract class LogFactoryAdapter implements LogFactory { // cache category to log adapters - private Map _logs = new ConcurrentHashMap(); + private Map _logs = new ConcurrentHashMap(); public Log getLog(String channel) { // no locking; OK if same adapter created multiple times - Log log = (Log) _logs.get(channel); + Log log = _logs.get(channel); if (log == null) { log = newLogAdapter(channel); _logs.put(channel, log); diff --git a/openjpa-lib/src/main/java/org/apache/openjpa/lib/log/LogFactoryImpl.java b/openjpa-lib/src/main/java/org/apache/openjpa/lib/log/LogFactoryImpl.java index 47652915d..7c3f9b5df 100644 --- a/openjpa-lib/src/main/java/org/apache/openjpa/lib/log/LogFactoryImpl.java +++ b/openjpa-lib/src/main/java/org/apache/openjpa/lib/log/LogFactoryImpl.java @@ -73,7 +73,8 @@ public class LogFactoryImpl /** * The {@link Log}s that this factory manages, keyed by log channel name. */ - private Map _logs = new ConcurrentHashMap(); // + private Map _logs = + new ConcurrentHashMap(); /** * The default logging level. @@ -83,7 +84,8 @@ public class LogFactoryImpl /** * Storage for logging level configuration specified at configuration time. */ - private Map _configuredLevels = new HashMap(); // + private Map _configuredLevels = + new HashMap(); /** * The stream to write to. Defaults to System.err. @@ -106,11 +108,11 @@ public class LogFactoryImpl public Log getLog(String channel) { // no locking; ok if same log created multiple times - LogImpl l = (LogImpl) _logs.get(channel); + LogImpl l = _logs.get(channel); if (l == null) { l = newLogImpl(); - l.setChannel(channel); - Short lvl = (Short) _configuredLevels.get(shorten(channel)); + l.setChannel(channel); // TODO add to interface? + Short lvl = _configuredLevels.get(shorten(channel)); l.setLevel(lvl == null ? _defaultLogLevel : lvl.shortValue()); _logs.put(channel, l); } @@ -271,11 +273,12 @@ public class LogFactoryImpl public void setInto(Options opts) { if (!opts.isEmpty()) { - Map.Entry e; - for (Iterator iter = opts.entrySet().iterator(); iter.hasNext();) { - e = (Map.Entry) iter.next(); - _configuredLevels.put(shorten((String) e.getKey()), - new Short(getLevel((String) e.getValue()))); + Map.Entry e; + for (Iterator> iter = + opts.entrySet().iterator(); iter.hasNext();) { + e = iter.next(); + _configuredLevels.put(shorten((String) e.getKey()), new Short( + getLevel((String) e.getValue()))); } opts.clear(); } diff --git a/openjpa-lib/src/main/java/org/apache/openjpa/lib/log/MultiLogFactory.java b/openjpa-lib/src/main/java/org/apache/openjpa/lib/log/MultiLogFactory.java index 13fb9fced..204090337 100644 --- a/openjpa-lib/src/main/java/org/apache/openjpa/lib/log/MultiLogFactory.java +++ b/openjpa-lib/src/main/java/org/apache/openjpa/lib/log/MultiLogFactory.java @@ -20,7 +20,6 @@ package org.apache.openjpa.lib.log; import java.util.ArrayList; import java.util.Arrays; -import java.util.Iterator; import java.util.List; import java.util.concurrent.CopyOnWriteArrayList; @@ -33,7 +32,7 @@ import java.util.concurrent.CopyOnWriteArrayList; */ public class MultiLogFactory implements LogFactory { - private List _delegates; + private List _delegates; /** * Create an instance with the given delegates. @@ -53,7 +52,8 @@ public class MultiLogFactory implements LogFactory { * Create an instance with the given delegates. */ public MultiLogFactory(LogFactory[] delegates) { - _delegates = new CopyOnWriteArrayList(Arrays.asList(delegates)); + _delegates = + new CopyOnWriteArrayList(Arrays.asList(delegates)); } public void addLogFactory(LogFactory factory) { @@ -75,16 +75,15 @@ public class MultiLogFactory implements LogFactory { * Returns a Log impl that combines all logs. */ public synchronized Log getLog(String channel) { - List logs = new ArrayList(_delegates.size()); - for (Iterator i = _delegates.iterator(); i.hasNext();) { - LogFactory f = (LogFactory) i.next(); + List logs = new ArrayList(_delegates.size()); + for(LogFactory f : _delegates) { if (f != null) { Log l = f.getLog(channel); if (l != null) logs.add(l); } } - return new MultiLog((Log[]) logs.toArray(new Log[logs.size()])); + return new MultiLog(logs.toArray(new Log[logs.size()])); } /** diff --git a/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/CFMetaDataParser.java b/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/CFMetaDataParser.java index 5d858dc7f..a0c2d056d 100644 --- a/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/CFMetaDataParser.java +++ b/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/CFMetaDataParser.java @@ -278,11 +278,12 @@ public class CFMetaDataParser extends XMLMetaDataParser { * taking into account the package currently being parsed for relative * class names. */ - protected Class classForName(String name, boolean resolve) + protected Class classForName(String name, boolean resolve) throws SAXException { if (name == null) return null; - Class cls = classForName(name, _package, resolve, currentClassLoader()); + Class cls = + classForName(name, _package, resolve, currentClassLoader()); if (cls == null) throw getException(_loc.get("invalid-class", name).getMessage()); return cls; @@ -292,7 +293,7 @@ public class CFMetaDataParser extends XMLMetaDataParser { * Load the given class name against the given package and the set * of accepted standard packages. Return null if the class cannot be loaded. */ - public static Class classForName(String name, String pkg, + public static Class classForName(String name, String pkg, boolean resolve, ClassLoader loader) { if (StringUtils.isEmpty(name)) return null; diff --git a/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/CFMetaDataSerializer.java b/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/CFMetaDataSerializer.java index 1e66e0f2c..34cf78c9f 100644 --- a/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/CFMetaDataSerializer.java +++ b/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/CFMetaDataSerializer.java @@ -53,21 +53,23 @@ public abstract class CFMetaDataSerializer extends XMLMetaDataSerializer { /** * Helper method to group objects by package. - * - * @return mapping of package name to a collection of objects in - * that package + * + * @return mapping of package name to a collection of objects in that + * package */ - protected Map groupByPackage(Collection objs) throws SAXException { - Map packages = new LinkedHashMap(); + protected Map> groupByPackage( + Collection objs) throws SAXException { + Map> packages = + new LinkedHashMap>(); String packageName; - Collection packageObjs; + Collection packageObjs; Object obj; - for (Iterator itr = objs.iterator(); itr.hasNext();) { + for (Iterator itr = objs.iterator(); itr.hasNext();) { obj = itr.next(); packageName = getPackage(obj); - packageObjs = (Collection) packages.get(packageName); + packageObjs = packages.get(packageName); if (packageObjs == null) { - packageObjs = new LinkedList(); + packageObjs = new LinkedList(); packages.put(packageName, packageObjs); } packageObjs.add(obj); diff --git a/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/ClassAnnotationMetaDataFilter.java b/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/ClassAnnotationMetaDataFilter.java index a6ee36b40..ca407a1c2 100644 --- a/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/ClassAnnotationMetaDataFilter.java +++ b/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/ClassAnnotationMetaDataFilter.java @@ -44,14 +44,14 @@ public class ClassAnnotationMetaDataFilter implements MetaDataFilter { /** * Constructor; supply annotation to match against. */ - public ClassAnnotationMetaDataFilter(Class anno) { + public ClassAnnotationMetaDataFilter(Class anno) { this(new Class[]{ anno }); } /** * Constructor; supply annotations to match against. */ - public ClassAnnotationMetaDataFilter(Class[] annos) { + public ClassAnnotationMetaDataFilter(Class[] annos) { _annos = new String[annos.length]; for (int i = 0; i < annos.length; i++) _annos[i] = "L" + annos[i].getName().replace('.', '/') + ";"; diff --git a/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/ClassArgParser.java b/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/ClassArgParser.java index 574923446..40764a27e 100644 --- a/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/ClassArgParser.java +++ b/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/ClassArgParser.java @@ -157,9 +157,9 @@ public class ClassArgParser { * @param arg a class name, .java file, .class file, or metadata * file naming the type(s) to act on */ - public Class[] parseTypes(String arg) { + public Class[] parseTypes(String arg) { String[] names = parseTypeNames(arg); - Class[] objs = new Class[names.length]; + Class[] objs = new Class[names.length]; for (int i = 0; i < names.length; i++) objs[i] = Strings.toClass(names[i], _loader); return objs; @@ -169,9 +169,9 @@ public class ClassArgParser { * Return the {@link Class} representation of the class(es) named in the * given metadatas. */ - public Class[] parseTypes(MetaDataIterator itr) { + public Class[] parseTypes(MetaDataIterator itr) { String[] names = parseTypeNames(itr); - Class[] objs = new Class[names.length]; + Class[] objs = new Class[names.length]; for (int i = 0; i < names.length; i++) objs[i] = Strings.toClass(names[i], _loader); return objs; @@ -181,20 +181,23 @@ public class ClassArgParser { * Return a mapping of each metadata resource to an array of its * contained classes. */ - public Map mapTypes(MetaDataIterator itr) { - Map map = mapTypeNames(itr); - Map.Entry entry; + public Map[]> mapTypes(MetaDataIterator itr) { + Map map = mapTypeNames(itr); + Map[]> rval = new HashMap[]>(); + Map.Entry entry; String[] names; - Class[] objs; - for (Iterator i = map.entrySet().iterator(); i.hasNext();) { - entry = (Map.Entry) i.next(); - names = (String[]) entry.getValue(); + Class[] objs; + for (Iterator> i = + map.entrySet().iterator(); i.hasNext();) { + entry = i.next(); + names = entry.getValue(); objs = new Class[names.length]; - for (int j = 0; j < names.length; j++) + for (int j = 0; j < names.length; j++) { objs[j] = Strings.toClass(names[j], _loader); - entry.setValue(objs); + } + rval.put(entry.getKey(), objs); } - return map; + return rval; } /** @@ -216,8 +219,8 @@ public class ClassArgParser { return new String[]{ getFromJavaFile(file) }; if ((AccessController.doPrivileged( J2DoPrivHelper.existsAction(file))).booleanValue()) { - Collection col = getFromMetaDataFile(file); - return (String[]) col.toArray(new String[col.size()]); + Collection col = getFromMetaDataFile(file); + return col.toArray(new String[col.size()]); } } catch (Exception e) { throw new NestableRuntimeException( @@ -235,7 +238,7 @@ public class ClassArgParser { if (itr == null) return new String[0]; - List names = new ArrayList(); + List names = new ArrayList(); Object source = null; try { while (itr.hasNext()) { @@ -246,15 +249,15 @@ public class ClassArgParser { throw new NestableRuntimeException( _loc.get("class-arg", source).getMessage(), e); } - return (String[]) names.toArray(new String[names.size()]); + return names.toArray(new String[names.size()]); } /** * Parse the names in the given metadata iterator stream, closing the * stream on completion. */ - private void appendTypeNames(Object source, InputStream in, List names) - throws IOException { + private void appendTypeNames(Object source, InputStream in, + List names) throws IOException { try { if (source.toString().endsWith(".class")) names.add(getFromClass(in)); @@ -271,20 +274,20 @@ public class ClassArgParser { * Return a mapping of each metadata resource to an array of its contained * class names. */ - public Map mapTypeNames(MetaDataIterator itr) { + public Map mapTypeNames(MetaDataIterator itr) { if (itr == null) - return Collections.EMPTY_MAP; + return Collections.emptyMap(); - Map map = new HashMap(); + Map map = new HashMap(); Object source = null; - List names = new ArrayList(); + List names = new ArrayList(); try { while (itr.hasNext()) { source = itr.next(); appendTypeNames(source, itr.getInputStream(), names); - if (!names.isEmpty()) - map.put(source, (String[]) names.toArray - (new String[names.size()])); + if (!names.isEmpty()) { + map.put(source, names.toArray(new String[names.size()])); + } names.clear(); } } catch (Exception e) { @@ -372,7 +375,8 @@ public class ClassArgParser { /** * Returns the classes named in the given common format metadata file. */ - private Collection getFromMetaDataFile(File file) throws IOException { + private Collection getFromMetaDataFile(File file) + throws IOException { FileReader in = null; try { in = new FileReader(file); @@ -389,8 +393,8 @@ public class ClassArgParser { /** * Returns the classes named in the given common format metadata stream. */ - private Collection getFromMetaData(Reader xml) throws IOException { - Collection names = new ArrayList(); + private Collection getFromMetaData(Reader xml) throws IOException { + Collection names = new ArrayList(); BufferedReader in = new BufferedReader(xml); boolean comment = false; diff --git a/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/ClassMetaDataIterator.java b/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/ClassMetaDataIterator.java index 6dc81839e..772a95b7c 100644 --- a/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/ClassMetaDataIterator.java +++ b/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/ClassMetaDataIterator.java @@ -46,16 +46,16 @@ import serp.util.Strings; public class ClassMetaDataIterator implements MetaDataIterator { private final ClassLoader _loader; - private final List _locs; + private final List _locs; private int _loc = -1; - private final List _urls = new ArrayList(3); + private final List _urls = new ArrayList(3); private int _url = -1; /** * Constructor; supply the class whose metadata to find, the suffix * of metadata files, and whether to parse top-down or bottom-up. */ - public ClassMetaDataIterator(Class cls, String suffix, boolean topDown) { + public ClassMetaDataIterator(Class cls, String suffix, boolean topDown) { this(cls, suffix, null, topDown); } @@ -63,22 +63,22 @@ public class ClassMetaDataIterator implements MetaDataIterator { * Constructor; supply the class whose metadata to find, the suffix * of metadata files, and whether to parse top-down or bottom-up. */ - public ClassMetaDataIterator(Class cls, String suffix, ClassLoader loader, + public ClassMetaDataIterator(Class cls, String suffix, ClassLoader loader, boolean topDown) { // skip classes that can't have metadata if (cls != null && (cls.isPrimitive() || cls.getName().startsWith("java.") || cls.getName().startsWith("javax."))) { _loader = null; - _locs = Collections.EMPTY_LIST; + _locs = Collections.emptyList(); return; } if (loader == null) { MultiClassLoader multi = AccessController .doPrivileged(J2DoPrivHelper.newMultiClassLoaderAction()); - multi.addClassLoader(multi.SYSTEM_LOADER); - multi.addClassLoader(multi.THREAD_LOADER); + multi.addClassLoader(MultiClassLoader.SYSTEM_LOADER); + multi.addClassLoader(MultiClassLoader.THREAD_LOADER); multi.addClassLoader(getClass().getClassLoader()); if (cls != null) { @@ -94,7 +94,7 @@ public class ClassMetaDataIterator implements MetaDataIterator { // collect the set of all possible metadata locations; start with // system locations - _locs = new ArrayList(); + _locs = new ArrayList(); _locs.add("META-INF/package" + suffix); _locs.add("WEB-INF/package" + suffix); _locs.add("package" + suffix); @@ -148,7 +148,7 @@ public class ClassMetaDataIterator implements MetaDataIterator { } public boolean hasNext() throws IOException { - Enumeration e; + Enumeration e; while (_url + 1 >= _urls.size()) { if (++_loc >= _locs.size()) return false; @@ -158,7 +158,7 @@ public class ClassMetaDataIterator implements MetaDataIterator { try { e = AccessController.doPrivileged( J2DoPrivHelper.getResourcesAction( - _loader, (String) _locs.get(_loc))); + _loader, _locs.get(_loc))); } catch (PrivilegedActionException pae) { throw (IOException) pae.getException(); } @@ -168,7 +168,7 @@ public class ClassMetaDataIterator implements MetaDataIterator { return true; } - public Object next() throws IOException { + public URL next() throws IOException { if (!hasNext()) throw new NoSuchElementException(); return _urls.get(++_url); @@ -179,7 +179,7 @@ public class ClassMetaDataIterator implements MetaDataIterator { throw new IllegalStateException(); try { return AccessController.doPrivileged( - J2DoPrivHelper.openStreamAction((URL) _urls.get(_url))); + J2DoPrivHelper.openStreamAction(_urls.get(_url))); } catch (PrivilegedActionException pae) { throw (IOException) pae.getException(); } @@ -188,8 +188,7 @@ public class ClassMetaDataIterator implements MetaDataIterator { public File getFile() throws IOException { if (_url == -1 || _url >= _urls.size()) throw new IllegalStateException(); - File file = new File(URLDecoder.decode(((URL) _urls.get(_url)). - getFile())); + File file = new File(URLDecoder.decode((_urls.get(_url)).getFile())); return ((AccessController.doPrivileged( J2DoPrivHelper.existsAction(file))).booleanValue()) ? file:null; } diff --git a/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/ClasspathMetaDataIterator.java b/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/ClasspathMetaDataIterator.java index f457c67c6..e4f95c564 100644 --- a/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/ClasspathMetaDataIterator.java +++ b/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/ClasspathMetaDataIterator.java @@ -65,8 +65,8 @@ public class ClasspathMetaDataIterator extends MetaDataIteratorChain { if (!(AccessController.doPrivileged( J2DoPrivHelper.existsAction(file))).booleanValue()) continue; - if ((AccessController.doPrivileged(J2DoPrivHelper - .isDirectoryAction(file))).booleanValue()) + if (AccessController.doPrivileged(J2DoPrivHelper + .isDirectoryAction(file)).booleanValue()) addIterator(new FileMetaDataIterator(file, filter)); else if (tokens[i].endsWith(".jar")) { try { diff --git a/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/FileMetaDataIterator.java b/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/FileMetaDataIterator.java index c283766f3..ac8511917 100644 --- a/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/FileMetaDataIterator.java +++ b/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/FileMetaDataIterator.java @@ -25,6 +25,7 @@ import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.net.MalformedURLException; +import java.net.URL; import java.security.AccessController; import java.security.PrivilegedActionException; import java.util.ArrayList; @@ -49,7 +50,7 @@ public class FileMetaDataIterator implements MetaDataIterator { private static final Localizer _loc = Localizer.forPackage (FileMetaDataIterator.class); - private final Iterator _itr; + private final Iterator _itr; private File _file = null; /** @@ -68,7 +69,7 @@ public class FileMetaDataIterator implements MetaDataIterator { if (dir == null) _itr = null; else { - Collection metas = new ArrayList(); + Collection metas = new ArrayList(); FileResource rsrc = (filter == null) ? null : new FileResource(); scan(dir, filter, rsrc, metas, 0); _itr = metas.iterator(); @@ -80,7 +81,7 @@ public class FileMetaDataIterator implements MetaDataIterator { * to the given collection. */ private int scan(File file, MetaDataFilter filter, FileResource rsrc, - Collection metas, int scanned) throws IOException { + Collection metas, int scanned) throws IOException { if (scanned > SCAN_LIMIT) throw new IllegalStateException(_loc.get("too-many-files", String.valueOf(SCAN_LIMIT)).getMessage()); @@ -107,11 +108,11 @@ public class FileMetaDataIterator implements MetaDataIterator { return _itr != null && _itr.hasNext(); } - public Object next() throws IOException { + public URL next() throws IOException { if (_itr == null) throw new NoSuchElementException(); - _file = (File) _itr.next(); + _file = _itr.next(); try { File f = AccessController.doPrivileged(J2DoPrivHelper .getAbsoluteFileAction(_file)); diff --git a/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/MetaDataIteratorChain.java b/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/MetaDataIteratorChain.java index 9df6929bc..a3d35c8b6 100644 --- a/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/MetaDataIteratorChain.java +++ b/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/MetaDataIteratorChain.java @@ -22,7 +22,6 @@ import java.io.File; import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; import java.util.NoSuchElementException; @@ -34,7 +33,7 @@ import java.util.NoSuchElementException; */ public class MetaDataIteratorChain implements MetaDataIterator { - private List _itrs = null; + private List _itrs = null; private int _cur = -1; private MetaDataIterator _itr = null; @@ -48,7 +47,7 @@ public class MetaDataIteratorChain implements MetaDataIterator { * Combine two iterators. */ public MetaDataIteratorChain(MetaDataIterator itr1, MetaDataIterator itr2) { - _itrs = new ArrayList(2); + _itrs = new ArrayList(2); _itrs.add(itr1); _itrs.add(itr2); } @@ -60,7 +59,7 @@ public class MetaDataIteratorChain implements MetaDataIterator { if (_cur != -1) throw new IllegalStateException(); if (_itrs == null) - _itrs = new ArrayList(4); + _itrs = new ArrayList(4); _itrs.add(itr); } @@ -101,8 +100,10 @@ public class MetaDataIteratorChain implements MetaDataIterator { } public void close() { - if (_itrs != null) - for (Iterator itr = _itrs.iterator(); itr.hasNext();) - ((MetaDataIterator) itr.next()).close(); + if (_itrs != null) { + for(MetaDataIterator mdi: _itrs) { + mdi.close(); + } + } } } diff --git a/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/MetaDataParser.java b/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/MetaDataParser.java index 1d024a036..8c53b2530 100644 --- a/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/MetaDataParser.java +++ b/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/MetaDataParser.java @@ -64,7 +64,7 @@ public interface MetaDataParser { * top-down or bottom-up. If the class is null, only top-level locations * will be parsed. */ - public void parse(Class cls, boolean topDown) throws IOException; + public void parse(Class cls, boolean topDown) throws IOException; /** * Parse the metadata in the given reader. diff --git a/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/MetaDataSerializer.java b/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/MetaDataSerializer.java index 3ec300a10..9dddc9e74 100644 --- a/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/MetaDataSerializer.java +++ b/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/MetaDataSerializer.java @@ -50,9 +50,9 @@ public interface MetaDataSerializer { * parsed. The objects must implement the {@link SourceTracker} interface. * * @param output if null, then serialize directly to the file system; - * othwerwise, populate the specified {@link Map} with + * otherwise, populate the specified {@link Map} with * keys that are the {@link File} instances, and - * values that are the {@link String} contents of the metadata + * values that are the {@link String} contents of the MetaData * @param flags bit flags specifying the output flags; e.g. {@link #PRETTY} */ public void serialize(Map output, int flags) throws IOException; diff --git a/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/ResourceMetaDataIterator.java b/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/ResourceMetaDataIterator.java index 0508aa1c0..d2f3321bc 100644 --- a/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/ResourceMetaDataIterator.java +++ b/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/ResourceMetaDataIterator.java @@ -41,7 +41,7 @@ import org.apache.openjpa.lib.util.MultiClassLoader; */ public class ResourceMetaDataIterator implements MetaDataIterator { - private List _urls = null; + private List _urls = null; private int _url = -1; /** @@ -59,18 +59,18 @@ public class ResourceMetaDataIterator implements MetaDataIterator { if (loader == null) { MultiClassLoader multi = AccessController .doPrivileged(J2DoPrivHelper.newMultiClassLoaderAction()); - multi.addClassLoader(multi.SYSTEM_LOADER); - multi.addClassLoader(multi.THREAD_LOADER); + multi.addClassLoader(MultiClassLoader.SYSTEM_LOADER); + multi.addClassLoader(MultiClassLoader.THREAD_LOADER); multi.addClassLoader(getClass().getClassLoader()); loader = multi; } try { - Enumeration e = AccessController.doPrivileged( + Enumeration e = AccessController.doPrivileged( J2DoPrivHelper.getResourcesAction(loader, rsrc)); while (e.hasMoreElements()) { if (_urls == null) - _urls = new ArrayList(3); + _urls = new ArrayList(3); _urls.add(e.nextElement()); } } catch (PrivilegedActionException pae) { @@ -82,7 +82,7 @@ public class ResourceMetaDataIterator implements MetaDataIterator { return _urls != null && _url + 1 < _urls.size(); } - public Object next() { + public URL next() { if (!hasNext()) throw new NoSuchElementException(); return _urls.get(++_url); @@ -93,7 +93,7 @@ public class ResourceMetaDataIterator implements MetaDataIterator { throw new IllegalStateException(); try { return AccessController.doPrivileged( - J2DoPrivHelper.openStreamAction((URL) _urls.get(_url))); + J2DoPrivHelper.openStreamAction(_urls.get(_url))); } catch (PrivilegedActionException pae) { throw (IOException) pae.getException(); } @@ -102,8 +102,7 @@ public class ResourceMetaDataIterator implements MetaDataIterator { public File getFile() throws IOException { if (_url == -1 || _url >= _urls.size()) throw new IllegalStateException(); - File file = new File(URLDecoder.decode(((URL) _urls.get(_url)). - getFile())); + File file = new File(URLDecoder.decode((_urls.get(_url)).getFile())); return ((AccessController.doPrivileged( J2DoPrivHelper.existsAction(file))).booleanValue()) ? file :null; } diff --git a/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/URLMetaDataIterator.java b/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/URLMetaDataIterator.java index 6c5d9c96d..d37402b12 100644 --- a/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/URLMetaDataIterator.java +++ b/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/URLMetaDataIterator.java @@ -50,7 +50,7 @@ public class URLMetaDataIterator implements MetaDataIterator { return _url != null && !_iterated; } - public Object next() throws IOException { + public URL next() throws IOException { if (!hasNext()) throw new IllegalStateException(); diff --git a/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/XMLMetaDataParser.java b/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/XMLMetaDataParser.java index 1e2a6418c..d7f5b1940 100644 --- a/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/XMLMetaDataParser.java +++ b/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/XMLMetaDataParser.java @@ -82,7 +82,7 @@ public abstract class XMLMetaDataParser extends DefaultHandler // map of classloaders to sets of parsed locations, so that we don't parse // the same resource multiple times for the same class - private Map _parsed = null; + private Map> _parsed = null; private Log _log = null; private boolean _validating = true; @@ -100,7 +100,7 @@ public abstract class XMLMetaDataParser extends DefaultHandler private String _sourceName = null; private File _sourceFile = null; private StringBuffer _text = null; - private List _comments = null; + private List _comments = null; private Location _location = new Location(); private LexicalHandler _lh = null; private int _depth = -1; @@ -254,7 +254,7 @@ public abstract class XMLMetaDataParser extends DefaultHandler public List getResults() { if (_results == null) - return Collections.EMPTY_LIST; + return Collections.emptyList(); return _results; } @@ -392,12 +392,12 @@ public abstract class XMLMetaDataParser extends DefaultHandler if (!_caching) return false; if (_parsed == null) - _parsed = new HashMap(); + _parsed = new HashMap>(); ClassLoader loader = currentClassLoader(); - Set set = (Set) _parsed.get(loader); + Set set = _parsed.get(loader); if (set == null) { - set = new HashSet(); + set = new HashSet(); _parsed.put(loader, set); } boolean added = set.add(src); @@ -456,7 +456,7 @@ public abstract class XMLMetaDataParser extends DefaultHandler public void comment(char[] ch, int start, int length) throws SAXException { if (_parseComments && _depth <= _ignore) { if (_comments == null) - _comments = new ArrayList(3); + _comments = new ArrayList(3); _comments.add(String.valueOf(ch, start, length)); } if (_lh != null) @@ -597,7 +597,7 @@ public abstract class XMLMetaDataParser extends DefaultHandler protected String[] currentComments() { if (_comments == null || _comments.isEmpty()) return Commentable.EMPTY_COMMENTS; - return (String[]) _comments.toArray(new String[_comments.size()]); + return _comments.toArray(new String[_comments.size()]); } /** diff --git a/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/XMLMetaDataSerializer.java b/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/XMLMetaDataSerializer.java index 1618b5138..226f0a12e 100644 --- a/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/XMLMetaDataSerializer.java +++ b/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/XMLMetaDataSerializer.java @@ -29,7 +29,9 @@ import java.util.Collection; import java.util.HashMap; import java.util.Iterator; import java.util.LinkedList; +import java.util.List; import java.util.Map; + import javax.xml.transform.Result; import javax.xml.transform.TransformerConfigurationException; import javax.xml.transform.TransformerFactory; @@ -37,17 +39,17 @@ import javax.xml.transform.sax.SAXTransformerFactory; import javax.xml.transform.sax.TransformerHandler; import javax.xml.transform.stream.StreamResult; -import org.xml.sax.Attributes; -import org.xml.sax.ContentHandler; -import org.xml.sax.SAXException; -import org.xml.sax.ext.LexicalHandler; -import org.xml.sax.helpers.AttributesImpl; import org.apache.openjpa.lib.log.Log; import org.apache.openjpa.lib.util.Files; import org.apache.openjpa.lib.util.J2DoPrivHelper; import org.apache.openjpa.lib.util.Localizer; import org.apache.openjpa.lib.xml.Commentable; import org.apache.openjpa.lib.xml.XMLWriter; +import org.xml.sax.Attributes; +import org.xml.sax.ContentHandler; +import org.xml.sax.SAXException; +import org.xml.sax.ext.LexicalHandler; +import org.xml.sax.helpers.AttributesImpl; /** * Abstract base type for serlializers that transfer groups of objects @@ -90,18 +92,16 @@ public abstract class XMLMetaDataSerializer implements MetaDataSerializer { serialize((Map) null, flags); } - public void serialize(Map output, int flags) throws IOException { - Map files = getFileMap(); + public void serialize(Map output, int flags) + throws IOException { + Map> files = getFileMap(); if (files == null) return; // for each file, serialize objects - Map.Entry entry; - for (Iterator itr = files.entrySet().iterator(); itr.hasNext();) { - entry = (Map.Entry) itr.next(); - File file = (File) entry.getKey(); - Collection fileObjs = (Collection) entry.getValue(); - + Collection fileObjs; + for(File file : files.keySet()) { + fileObjs = files.get(file); if (_log != null && _log.isInfoEnabled()) _log.info(_loc.get("ser-file", file)); @@ -151,18 +151,17 @@ public abstract class XMLMetaDataSerializer implements MetaDataSerializer { * written to, and values of a {@link Collection} of * {@link SourceTracker} instances. */ - protected Map getFileMap() { - Collection objs = getObjects(); + protected Map> getFileMap() { + Collection objs = getObjects(); if (objs == null || objs.isEmpty()) return null; // create a map of files to lists of objects - Map files = new HashMap(); + Map> files = + new HashMap>(); File file; - Collection fileObjs; - Object obj; - for (Iterator itr = objs.iterator(); itr.hasNext();) { - obj = itr.next(); + Collection fileObjs; + for(Object obj : objs) { file = getSourceFile(obj); if (file == null) { if (_log != null && _log.isTraceEnabled()) @@ -170,9 +169,9 @@ public abstract class XMLMetaDataSerializer implements MetaDataSerializer { continue; } - fileObjs = (Collection) files.get(file); + fileObjs = (Collection) files.get(file); if (fileObjs == null) { - fileObjs = new LinkedList(); + fileObjs = new LinkedList(); files.put(file, fileObjs); } fileObjs.add(obj); @@ -244,8 +243,8 @@ public abstract class XMLMetaDataSerializer implements MetaDataSerializer { /** * Serialize the given collection of objects to the given handler. */ - private void serialize(Collection objs, ContentHandler handler, int flags) - throws SAXException { + private void serialize(Collection objs, ContentHandler handler, + int flags) throws SAXException { if (_log != null && _log.isTraceEnabled()) _log.trace(_loc.get("ser-objs", objs)); @@ -352,10 +351,10 @@ public abstract class XMLMetaDataSerializer implements MetaDataSerializer { /** * Serialize the given set of objects. */ - protected abstract void serialize(Collection objs) throws SAXException; + protected abstract void serialize(Collection objs) throws SAXException; /** * Return the current set of objects for serialization. */ - protected abstract Collection getObjects(); + protected abstract Collection getObjects(); } diff --git a/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/ZipFileMetaDataIterator.java b/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/ZipFileMetaDataIterator.java index 57ae0cfe5..175a57f4f 100644 --- a/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/ZipFileMetaDataIterator.java +++ b/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/ZipFileMetaDataIterator.java @@ -44,7 +44,7 @@ public class ZipFileMetaDataIterator private final ZipFile _file; private final MetaDataFilter _filter; - private final Enumeration _entries; + private final Enumeration _entries; private ZipEntry _entry = null; private ZipEntry _last = null; @@ -84,14 +84,14 @@ public class ZipFileMetaDataIterator // search for next metadata file while (_entry == null && _entries.hasMoreElements()) { - _entry = (ZipEntry) _entries.nextElement(); + _entry = _entries.nextElement(); if (_filter != null && !_filter.matches(this)) _entry = null; } return _entry != null; } - public Object next() throws IOException { + public String next() throws IOException { if (!hasNext()) throw new NoSuchElementException(); String ret = _entry.getName(); diff --git a/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/ZipStreamMetaDataIterator.java b/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/ZipStreamMetaDataIterator.java index 39150ee01..0c001ba80 100644 --- a/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/ZipStreamMetaDataIterator.java +++ b/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/ZipStreamMetaDataIterator.java @@ -75,7 +75,7 @@ public class ZipStreamMetaDataIterator return _entry != null; } - public Object next() throws IOException { + public String next() throws IOException { if (!hasNext()) throw new NoSuchElementException(); String ret = _entry.getName(); diff --git a/openjpa-lib/src/main/java/org/apache/openjpa/lib/rop/AbstractListIterator.java b/openjpa-lib/src/main/java/org/apache/openjpa/lib/rop/AbstractListIterator.java index 78ea47872..3c3e52689 100644 --- a/openjpa-lib/src/main/java/org/apache/openjpa/lib/rop/AbstractListIterator.java +++ b/openjpa-lib/src/main/java/org/apache/openjpa/lib/rop/AbstractListIterator.java @@ -28,17 +28,17 @@ import org.apache.openjpa.lib.util.Localizer; * @author Abe White * @nojavadoc */ -abstract class AbstractListIterator implements ListIterator { +abstract class AbstractListIterator implements ListIterator { private static final Localizer _loc = Localizer.forPackage (AbstractListIterator.class); - public void add(Object o) { + public void add(E o) { throw new UnsupportedOperationException(_loc.get("read-only") .getMessage()); } - public void set(Object o) { + public void set(E o) { throw new UnsupportedOperationException(_loc.get("read-only") .getMessage()); } diff --git a/openjpa-lib/src/main/java/org/apache/openjpa/lib/rop/AbstractResultList.java b/openjpa-lib/src/main/java/org/apache/openjpa/lib/rop/AbstractResultList.java index e6b80be82..0e4c684d0 100644 --- a/openjpa-lib/src/main/java/org/apache/openjpa/lib/rop/AbstractResultList.java +++ b/openjpa-lib/src/main/java/org/apache/openjpa/lib/rop/AbstractResultList.java @@ -30,7 +30,8 @@ import org.apache.openjpa.lib.util.Localizer; * @author Abe White * @nojavadoc */ -public abstract class AbstractResultList implements ResultList { +@SuppressWarnings("serial") +public abstract class AbstractResultList implements ResultList { private static final Localizer _loc = Localizer.forPackage (AbstractResultList.class); @@ -48,15 +49,15 @@ public abstract class AbstractResultList implements ResultList { throw readOnly(); } - public boolean addAll(Collection c) { + public boolean addAll(Collection c) { throw readOnly(); } - public boolean addAll(int index, Collection c) { + public boolean addAll(int index, Collection c) { throw readOnly(); } - public Object remove(int index) { + public E remove(int index) { throw readOnly(); } @@ -64,15 +65,15 @@ public abstract class AbstractResultList implements ResultList { throw readOnly(); } - public boolean removeAll(Collection c) { + public boolean removeAll(Collection c) { throw readOnly(); } - public boolean retainAll(Collection c) { + public boolean retainAll(Collection c) { throw readOnly(); } - public Object set(int index, Object element) { + public E set(int index, Object element) { throw readOnly(); } @@ -80,7 +81,7 @@ public abstract class AbstractResultList implements ResultList { throw readOnly(); } - public List subList(int from, int to) { + public List subList(int from, int to) { throw new UnsupportedOperationException(); } diff --git a/openjpa-lib/src/main/java/org/apache/openjpa/lib/rop/ResultList.java b/openjpa-lib/src/main/java/org/apache/openjpa/lib/rop/ResultList.java index 5492f89c8..faece771d 100644 --- a/openjpa-lib/src/main/java/org/apache/openjpa/lib/rop/ResultList.java +++ b/openjpa-lib/src/main/java/org/apache/openjpa/lib/rop/ResultList.java @@ -37,7 +37,7 @@ import org.apache.openjpa.lib.util.Closeable; * * @author Marc Prud'hommeaux */ -public interface ResultList extends List, Serializable, Closeable { +public interface ResultList extends List, Serializable, Closeable { /** * Returns true if the provider backing this list is open. diff --git a/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/Options.java b/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/Options.java index c25a11cdd..ea8b5f0fd 100644 --- a/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/Options.java +++ b/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/Options.java @@ -51,6 +51,7 @@ import serp.util.Strings; * @author Abe White * @nojavadoc */ +@SuppressWarnings("serial") public class Options extends TypedProperties { /**