openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From curti...@apache.org
Subject svn commit: r1030083 - in /openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence: AnnotationPersistenceMetaDataSerializer.java EntityManagerFactoryImpl.java QueryImpl.java meta/SourceAnnotationHandler.java
Date Tue, 02 Nov 2010 15:18:13 GMT
Author: curtisr7
Date: Tue Nov  2 15:18:10 2010
New Revision: 1030083

URL: http://svn.apache.org/viewvc?rev=1030083&view=rev
Log:
OPENJPA-1865: Findbugs. Use entrySet iterator rather than keySet. Patch contributed by Guy
Korland.

Modified:
    openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/AnnotationPersistenceMetaDataSerializer.java
    openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerFactoryImpl.java
    openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/QueryImpl.java
    openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/meta/SourceAnnotationHandler.java

Modified: openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/AnnotationPersistenceMetaDataSerializer.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/AnnotationPersistenceMetaDataSerializer.java?rev=1030083&r1=1030082&r2=1030083&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/AnnotationPersistenceMetaDataSerializer.java
(original)
+++ openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/AnnotationPersistenceMetaDataSerializer.java
Tue Nov  2 15:18:10 2010
@@ -18,55 +18,76 @@
  */
 package org.apache.openjpa.persistence;
 
-import org.apache.openjpa.lib.meta.SourceTracker;
-import org.apache.openjpa.lib.util.J2DoPrivHelper;
-import org.apache.openjpa.lib.util.Localizer;
-import org.apache.openjpa.lib.util.JavaVersions;
-import org.apache.openjpa.lib.log.Log;
-import org.apache.openjpa.lib.conf.Configurations;
-import org.apache.openjpa.conf.OpenJPAConfiguration;
-import org.apache.openjpa.meta.*;
-import org.apache.openjpa.kernel.QueryLanguages;
-import org.apache.openjpa.util.InternalException;
-import org.apache.commons.lang.StringUtils;
-
-import java.security.AccessController;
-import java.security.PrivilegedActionException;
-import java.util.*;
 import java.io.File;
+import java.io.FileWriter;
 import java.io.IOException;
 import java.io.Writer;
-import java.io.FileWriter;
-import java.lang.reflect.Member;
+import java.lang.annotation.Annotation;
 import java.lang.reflect.Field;
+import java.lang.reflect.Member;
 import java.lang.reflect.Method;
-import java.lang.annotation.Annotation;
-
-import serp.util.Strings;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.EnumSet;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+import java.util.Map.Entry;
 
-import javax.persistence.Entity;
+import javax.persistence.AttributeOverride;
+import javax.persistence.Basic;
+import javax.persistence.CascadeType;
 import javax.persistence.Embeddable;
+import javax.persistence.Embedded;
+import javax.persistence.EmbeddedId;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.Id;
+import javax.persistence.IdClass;
+import javax.persistence.ManyToMany;
+import javax.persistence.ManyToOne;
+import javax.persistence.MapKey;
 import javax.persistence.MappedSuperclass;
 import javax.persistence.NamedNativeQuery;
 import javax.persistence.NamedQuery;
+import javax.persistence.OneToMany;
+import javax.persistence.OneToOne;
+import javax.persistence.OrderBy;
 import javax.persistence.QueryHint;
 import javax.persistence.SequenceGenerator;
-import javax.persistence.Id;
-import javax.persistence.IdClass;
-import javax.persistence.EmbeddedId;
-import javax.persistence.Version;
 import javax.persistence.Transient;
-import javax.persistence.Basic;
-import javax.persistence.Embedded;
-import javax.persistence.ManyToOne;
-import javax.persistence.OneToOne;
-import javax.persistence.OneToMany;
-import javax.persistence.ManyToMany;
-import javax.persistence.OrderBy;
-import javax.persistence.MapKey;
-import javax.persistence.AttributeOverride;
-import javax.persistence.CascadeType;
-import javax.persistence.FetchType;
+import javax.persistence.Version;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.openjpa.conf.OpenJPAConfiguration;
+import org.apache.openjpa.kernel.QueryLanguages;
+import org.apache.openjpa.lib.conf.Configurations;
+import org.apache.openjpa.lib.log.Log;
+import org.apache.openjpa.lib.meta.SourceTracker;
+import org.apache.openjpa.lib.util.J2DoPrivHelper;
+import org.apache.openjpa.lib.util.JavaVersions;
+import org.apache.openjpa.lib.util.Localizer;
+import org.apache.openjpa.meta.ClassMetaData;
+import org.apache.openjpa.meta.FieldMetaData;
+import org.apache.openjpa.meta.JavaTypes;
+import org.apache.openjpa.meta.MetaDataInheritanceComparator;
+import org.apache.openjpa.meta.MetaDataModes;
+import org.apache.openjpa.meta.MetaDataRepository;
+import org.apache.openjpa.meta.Order;
+import org.apache.openjpa.meta.QueryMetaData;
+import org.apache.openjpa.meta.SequenceMetaData;
+import org.apache.openjpa.meta.ValueMetaData;
+import org.apache.openjpa.util.InternalException;
+
+import serp.util.Strings;
 
 //@todo: javadocs
 
@@ -1217,14 +1238,18 @@ public class AnnotationPersistenceMetaDa
         }
     }
 
+    @SuppressWarnings("unchecked")
     public void serialize(Writer out, int flags) throws IOException {
         Map output = new HashMap();
         serialize(output, flags);
 
-        for(Object meta: output.keySet()) {
+        Set<Entry> entrySet = output.entrySet();
+        for(Entry entry : entrySet) {
+            Object meta = entry.getKey();
+            List<String> annos = (List<String>) entry.getValue();
+
             out.write("--"+meta.toString());
             out.write("\n");
-            List<String> annos = (List<String>) output.get(meta);
             for(String ann: annos) {
                 out.write("\t");
                 out.write(ann);

Modified: openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerFactoryImpl.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerFactoryImpl.java?rev=1030083&r1=1030082&r2=1030083&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerFactoryImpl.java
(original)
+++ openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerFactoryImpl.java
Tue Nov  2 15:18:10 2010
@@ -236,8 +236,9 @@ public class EntityManagerFactoryImpl
         OpenJPAEntityManagerSPI em = newEntityManagerImpl(broker);
 
         // allow setting of other bean properties of EM
-        for (Object key : props.keySet()) {
-            em.setProperty(key.toString(), props.get(key));
+        Set<Map.Entry> entrySet = props.entrySet();
+        for (Map.Entry entry : entrySet) {
+            em.setProperty(entry.getKey().toString(), entry.getValue());
         }
         if (log != null && log.isTraceEnabled()) {
             log.trace(this + " created EntityManager " + em + ".");

Modified: openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/QueryImpl.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/QueryImpl.java?rev=1030083&r1=1030082&r2=1030083&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/QueryImpl.java
(original)
+++ openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/QueryImpl.java
Tue Nov  2 15:18:10 2010
@@ -32,6 +32,7 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import java.util.Map.Entry;
 import java.util.concurrent.locks.ReentrantLock;
 
 import javax.persistence.FlushModeType;
@@ -48,6 +49,7 @@ import org.apache.openjpa.conf.OpenJPACo
 import org.apache.openjpa.kernel.Broker;
 import org.apache.openjpa.kernel.DelegatingQuery;
 import org.apache.openjpa.kernel.DelegatingResultList;
+import org.apache.openjpa.kernel.DistinctResultList;
 import org.apache.openjpa.kernel.FetchConfiguration;
 import org.apache.openjpa.kernel.Filters;
 import org.apache.openjpa.kernel.PreparedQuery;
@@ -55,7 +57,6 @@ import org.apache.openjpa.kernel.Prepare
 import org.apache.openjpa.kernel.QueryLanguages;
 import org.apache.openjpa.kernel.QueryOperations;
 import org.apache.openjpa.kernel.QueryStatistics;
-import org.apache.openjpa.kernel.DistinctResultList;
 import org.apache.openjpa.kernel.exps.AggregateListener;
 import org.apache.openjpa.kernel.exps.FilterListener;
 import org.apache.openjpa.kernel.jpql.JPQLParser;
@@ -987,9 +988,11 @@ public class QueryImpl<X> implements Ope
         if (_declaredParams == null) {
             _declaredParams = new HashMap<Object, Parameter<?>>();
             OrderedMap<Object,Class<?>> paramTypes = _query.getOrderedParameterTypes();
-            for (Object key : paramTypes.keySet()) {
-                Parameter<?> param = null;
-                Class<?> expectedValueType = paramTypes.get(key);
+            for(Entry<Object,Class<?>> entry : paramTypes.entrySet()){
+                Object key = entry.getKey();    
+                Class<?> expectedValueType = entry.getValue();
+                Parameter<?> param;
+
                 if (key instanceof Integer) {
                     param = new ParameterImpl((Integer)key, expectedValueType);
                 } else if (key instanceof String) {

Modified: openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/meta/SourceAnnotationHandler.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/meta/SourceAnnotationHandler.java?rev=1030083&r1=1030082&r2=1030083&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/meta/SourceAnnotationHandler.java
(original)
+++ openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/meta/SourceAnnotationHandler.java
Tue Nov  2 15:18:10 2010
@@ -18,6 +18,9 @@
  */
 package org.apache.openjpa.persistence.meta;
 
+import static javax.persistence.AccessType.FIELD;
+import static javax.persistence.AccessType.PROPERTY;
+
 import java.lang.annotation.Annotation;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -25,6 +28,7 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import java.util.Map.Entry;
 
 import javax.annotation.processing.ProcessingEnvironment;
 import javax.lang.model.element.AnnotationMirror;
@@ -43,8 +47,6 @@ import javax.lang.model.type.TypeMirror;
 import javax.lang.model.util.Types;
 import javax.persistence.Access;
 import javax.persistence.AccessType;
-import static javax.persistence.AccessType.*;
-
 import javax.persistence.Embeddable;
 import javax.persistence.Entity;
 import javax.persistence.ManyToMany;
@@ -53,6 +55,7 @@ import javax.persistence.MappedSuperclas
 import javax.persistence.OneToMany;
 import javax.persistence.OneToOne;
 import javax.persistence.Transient;
+
 import org.apache.openjpa.lib.util.Localizer;
 import org.apache.openjpa.meta.AccessCode;
 import org.apache.openjpa.util.UserException;
@@ -428,11 +431,11 @@ public class SourceAnnotationHandler 
         List<? extends AnnotationMirror> annos = e.getAnnotationMirrors();
         for (AnnotationMirror mirror : annos) {
             if (mirror.getAnnotationType().toString().equals(anno.getName())) {
-                Map<? extends ExecutableElement, ? extends AnnotationValue> 
-                values = mirror.getElementValues();
-                for (ExecutableElement ex : values.keySet()) {
-                    if (ex.getSimpleName().toString().equals(attr))
-                        return values.get(ex).getValue();
+                Map<? extends ExecutableElement, ? extends AnnotationValue> values
= mirror.getElementValues();
+                for (Entry<? extends ExecutableElement, ? extends AnnotationValue>
entry : values.entrySet()) {
+                    if (entry.getKey().getSimpleName().toString().equals(attr)) {
+                        return entry.getValue().getValue();
+                    }
                 }
             }
         }



Mime
View raw message