mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
Code cleanup - move old iterator/while loops to for loops
This commit is contained in:
@@ -1,11 +1,10 @@
|
||||
package com.avaje.ebean.config;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* A map like structure of properties.
|
||||
@@ -68,9 +67,8 @@ final class PropertyMap implements Serializable {
|
||||
}
|
||||
|
||||
synchronized void putAll(Map<String, String> keyValueMap) {
|
||||
Iterator<Entry<String, String>> it = keyValueMap.entrySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
Map.Entry<String, String> entry = it.next();
|
||||
|
||||
for (Map.Entry<String, String> entry : keyValueMap.entrySet()) {
|
||||
put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,20 +1,18 @@
|
||||
package com.avaje.ebean.config;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Helper used to load the PropertyMap.
|
||||
*/
|
||||
@@ -81,9 +79,7 @@ final class PropertyMapLoader {
|
||||
}
|
||||
|
||||
// put values in initially without any evaluation
|
||||
Iterator<Entry<Object, Object>> it = props.entrySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
Map.Entry<Object, Object> entry = it.next();
|
||||
for (Map.Entry<Object, Object> entry : props.entrySet()) {
|
||||
String key = ((String) entry.getKey()).toLowerCase();
|
||||
String val = ((String) entry.getValue());
|
||||
if (val != null) {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.avaje.ebeaninternal.server.cache;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import com.avaje.ebean.annotation.CacheTuning;
|
||||
@@ -89,9 +88,7 @@ public class DefaultCacheHolder {
|
||||
}
|
||||
|
||||
public void clearAll() {
|
||||
Iterator<ServerCache> it = concMap.values().iterator();
|
||||
while (it.hasNext()) {
|
||||
ServerCache serverCache = it.next();
|
||||
for (ServerCache serverCache : concMap.values()) {
|
||||
serverCache.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,9 +111,7 @@ public class DefaultServerCache implements ServerCache {
|
||||
|
||||
int hc = reset ? removedHitCount.getAndSet(0) : removedHitCount.get();
|
||||
|
||||
Iterator<CacheEntry> it = map.values().iterator();
|
||||
while (it.hasNext()) {
|
||||
CacheEntry cacheEntry = it.next();
|
||||
for (CacheEntry cacheEntry : map.values()) {
|
||||
hc += cacheEntry.getHitCount(reset);
|
||||
}
|
||||
|
||||
@@ -268,10 +266,6 @@ public class DefaultServerCache implements ServerCache {
|
||||
return map.size();
|
||||
}
|
||||
|
||||
private Iterator<CacheEntry> cacheEntries() {
|
||||
return map.values().iterator();
|
||||
}
|
||||
|
||||
/**
|
||||
* The task used to periodically trim the cache.
|
||||
*/
|
||||
@@ -296,7 +290,7 @@ public class DefaultServerCache implements ServerCache {
|
||||
long idleExpire = System.currentTimeMillis() - (maxIdleSecs*1000);
|
||||
long ttlExpire = System.currentTimeMillis() - (maxSecsToLive*1000);
|
||||
|
||||
Iterator<CacheEntry> it = cacheEntries();
|
||||
Iterator<CacheEntry> it = map.values().iterator();
|
||||
while (it.hasNext()) {
|
||||
CacheEntry cacheEntry = it.next();
|
||||
if (maxIdleSecs > 0 && idleExpire > cacheEntry.getLastAccessTime()) {
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.avaje.ebeaninternal.server.core;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import javax.persistence.Embeddable;
|
||||
@@ -11,6 +10,7 @@ import javax.persistence.Table;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.avaje.ebean.config.CompoundType;
|
||||
import com.avaje.ebean.config.ScalarTypeConverter;
|
||||
import com.avaje.ebean.config.ServerConfig;
|
||||
@@ -65,7 +65,9 @@ public class BootupClasses implements ClassPathSearchMatcher {
|
||||
|
||||
public BootupClasses(List<Class<?>> list) {
|
||||
if (list != null) {
|
||||
process(list.iterator());
|
||||
for (Class<?> cls : list) {
|
||||
isMatch(cls);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,13 +85,6 @@ public class BootupClasses implements ClassPathSearchMatcher {
|
||||
this.serverConfigStartupList.addAll(parent.serverConfigStartupList);
|
||||
}
|
||||
|
||||
private void process(Iterator<Class<?>> it) {
|
||||
while (it.hasNext()) {
|
||||
Class<?> cls = it.next();
|
||||
isMatch(cls);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a copy of this object so that classes can be added to it.
|
||||
*/
|
||||
@@ -297,13 +292,6 @@ public class BootupClasses implements ClassPathSearchMatcher {
|
||||
return beanListenerList;
|
||||
}
|
||||
|
||||
public void add(Iterator<Class<?>> it) {
|
||||
while (it.hasNext()) {
|
||||
Class<?> clazz = it.next();
|
||||
isMatch(clazz);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isMatch(Class<?> cls) {
|
||||
|
||||
if (isEmbeddable(cls)) {
|
||||
|
||||
@@ -3,9 +3,9 @@ package com.avaje.ebeaninternal.server.deploy;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
@@ -603,9 +603,7 @@ public class BeanDescriptor<T> implements MetaBeanInfo {
|
||||
|
||||
if (isEmbedded()) {
|
||||
// initialise all the properties
|
||||
Iterator<BeanProperty> it = propertiesAll();
|
||||
while (it.hasNext()) {
|
||||
BeanProperty prop = it.next();
|
||||
for (BeanProperty prop : propertiesAll()) {
|
||||
prop.initialise();
|
||||
}
|
||||
} else {
|
||||
@@ -623,9 +621,7 @@ public class BeanDescriptor<T> implements MetaBeanInfo {
|
||||
|
||||
if (!isEmbedded()) {
|
||||
// initialise all the non-id properties
|
||||
Iterator<BeanProperty> it = propertiesAll();
|
||||
while (it.hasNext()) {
|
||||
BeanProperty prop = it.next();
|
||||
for (BeanProperty prop : propertiesAll()) {
|
||||
if (!prop.isId()) {
|
||||
prop.initialise();
|
||||
}
|
||||
@@ -1028,9 +1024,7 @@ public class BeanDescriptor<T> implements MetaBeanInfo {
|
||||
* Reset the statistics on all the query plans.
|
||||
*/
|
||||
public void clearQueryStatistics() {
|
||||
Iterator<CQueryPlan> it = queryPlanCache.values().iterator();
|
||||
while (it.hasNext()) {
|
||||
CQueryPlan queryPlan = (CQueryPlan) it.next();
|
||||
for (CQueryPlan queryPlan : queryPlanCache.values()) {
|
||||
queryPlan.resetStatistics();
|
||||
}
|
||||
}
|
||||
@@ -1046,13 +1040,6 @@ public class BeanDescriptor<T> implements MetaBeanInfo {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the query plans for this BeanDescriptor.
|
||||
*/
|
||||
public Iterator<CQueryPlan> queryPlans() {
|
||||
return queryPlanCache.values().iterator();
|
||||
}
|
||||
|
||||
public CQueryPlan getQueryPlan(HashQueryPlan key) {
|
||||
return queryPlanCache.get(key);
|
||||
}
|
||||
@@ -1854,10 +1841,10 @@ public class BeanDescriptor<T> implements MetaBeanInfo {
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an Iterator of all BeanProperty. This includes transient properties.
|
||||
* Return a collection of all BeanProperty. This includes transient properties.
|
||||
*/
|
||||
public Iterator<BeanProperty> propertiesAll() {
|
||||
return propMap.values().iterator();
|
||||
public Collection<BeanProperty> propertiesAll() {
|
||||
return propMap.values();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -8,7 +8,6 @@ import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@@ -512,9 +511,7 @@ public class BeanDescriptorManager implements BeanDescriptorMap {
|
||||
*/
|
||||
private void readEntityBeanTable() {
|
||||
|
||||
Iterator<DeployBeanInfo<?>> it = deplyInfoMap.values().iterator();
|
||||
while (it.hasNext()) {
|
||||
DeployBeanInfo<?> info = it.next();
|
||||
for (DeployBeanInfo<?> info : deplyInfoMap.values()) {
|
||||
BeanTable beanTable = createBeanTable(info);
|
||||
beanTableMap.put(beanTable.getBeanType(), beanTable);
|
||||
}
|
||||
@@ -528,18 +525,14 @@ public class BeanDescriptorManager implements BeanDescriptorMap {
|
||||
*/
|
||||
private void readEntityDeploymentAssociations() {
|
||||
|
||||
Iterator<DeployBeanInfo<?>> it = deplyInfoMap.values().iterator();
|
||||
while (it.hasNext()) {
|
||||
DeployBeanInfo<?> info = it.next();
|
||||
for (DeployBeanInfo<?> info : deplyInfoMap.values()) {
|
||||
readDeployAssociations(info);
|
||||
}
|
||||
}
|
||||
|
||||
private void readInheritedIdGenerators() {
|
||||
|
||||
Iterator<DeployBeanInfo<?>> it = deplyInfoMap.values().iterator();
|
||||
while (it.hasNext()) {
|
||||
DeployBeanInfo<?> info = it.next();
|
||||
for (DeployBeanInfo<?> info : deplyInfoMap.values()) {
|
||||
DeployBeanDescriptor<?> descriptor = info.getDescriptor();
|
||||
InheritInfo inheritInfo = descriptor.getInheritInfo();
|
||||
if (inheritInfo != null && !inheritInfo.isRoot()) {
|
||||
@@ -615,10 +608,10 @@ public class BeanDescriptorManager implements BeanDescriptorMap {
|
||||
* @param info the new inheritance info
|
||||
*/
|
||||
private void setInheritanceInfo(DeployBeanInfo<?> info) {
|
||||
|
||||
for (DeployBeanPropertyAssocOne<?> oneProp : info.getDescriptor().propertiesAssocOne()) {
|
||||
if (!oneProp.isTransient()) {
|
||||
DeployBeanInfo<?> assoc = deplyInfoMap.get(oneProp.getTargetType());
|
||||
|
||||
if (assoc != null){
|
||||
oneProp.getTableJoin().setInheritInfo(assoc.getDescriptor().getInheritInfo());
|
||||
}
|
||||
@@ -628,7 +621,6 @@ public class BeanDescriptorManager implements BeanDescriptorMap {
|
||||
for (DeployBeanPropertyAssocMany<?> manyProp : info.getDescriptor().propertiesAssocMany()) {
|
||||
if (!manyProp.isTransient()) {
|
||||
DeployBeanInfo<?> assoc = deplyInfoMap.get(manyProp.getTargetType());
|
||||
|
||||
if (assoc != null){
|
||||
manyProp.getTableJoin().setInheritInfo(assoc.getDescriptor().getInheritInfo());
|
||||
}
|
||||
@@ -757,9 +749,7 @@ public class BeanDescriptorManager implements BeanDescriptorMap {
|
||||
String searchName = name.substring(0, p).toLowerCase();
|
||||
|
||||
// search for this in the possible matches
|
||||
Iterator<String> it = matchSet.iterator();
|
||||
while (it.hasNext()) {
|
||||
String possibleMappedBy = it.next();
|
||||
for (String possibleMappedBy : matchSet) {
|
||||
String possibleLower = possibleMappedBy.toLowerCase();
|
||||
if (possibleLower.indexOf(searchName) > -1) {
|
||||
// we have a match..
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.avaje.ebeaninternal.server.deploy;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import javax.persistence.PersistenceException;
|
||||
@@ -806,12 +805,8 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> {
|
||||
private BeanProperty initMapKeyProperty() {
|
||||
|
||||
// search for the property
|
||||
|
||||
BeanDescriptor<?> targetDesc = getTargetDescriptor();
|
||||
|
||||
Iterator<BeanProperty> it = targetDesc.propertiesAll();
|
||||
while (it.hasNext()){
|
||||
BeanProperty prop = it.next();
|
||||
for (BeanProperty prop : targetDesc.propertiesAll()) {
|
||||
if (mapKey.equalsIgnoreCase(prop.getName())) {
|
||||
return prop;
|
||||
}
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
package com.avaje.ebeaninternal.server.deploy;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import com.avaje.ebean.EbeanServer;
|
||||
import com.avaje.ebean.SqlUpdate;
|
||||
@@ -15,129 +13,113 @@ import com.avaje.ebeaninternal.util.DefaultExpressionRequest;
|
||||
|
||||
public class IntersectionRow {
|
||||
|
||||
private final String tableName;
|
||||
private final String tableName;
|
||||
|
||||
private final LinkedHashMap<String,Object> values = new LinkedHashMap<String,Object>();
|
||||
private final LinkedHashMap<String, Object> values = new LinkedHashMap<String, Object>();
|
||||
|
||||
private ArrayList<Object> excludeIds;
|
||||
private BeanDescriptor<?> excludeDescriptor;
|
||||
private ArrayList<Object> excludeIds;
|
||||
private BeanDescriptor<?> excludeDescriptor;
|
||||
|
||||
public IntersectionRow(String tableName){
|
||||
this.tableName = tableName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Id's to exclude. This is for deleting non-attached detail Id's.
|
||||
*/
|
||||
public void setExcludeIds(ArrayList<Object> excludeIds, BeanDescriptor<?> excludeDescriptor){
|
||||
this.excludeIds = excludeIds;
|
||||
this.excludeDescriptor = excludeDescriptor;
|
||||
}
|
||||
public IntersectionRow(String tableName) {
|
||||
this.tableName = tableName;
|
||||
}
|
||||
|
||||
public void put(String key, Object value){
|
||||
values.put(key, value);
|
||||
}
|
||||
/**
|
||||
* Set Id's to exclude. This is for deleting non-attached detail Id's.
|
||||
*/
|
||||
public void setExcludeIds(ArrayList<Object> excludeIds, BeanDescriptor<?> excludeDescriptor) {
|
||||
this.excludeIds = excludeIds;
|
||||
this.excludeDescriptor = excludeDescriptor;
|
||||
}
|
||||
|
||||
public void put(String key, Object value) {
|
||||
values.put(key, value);
|
||||
}
|
||||
|
||||
|
||||
public SqlUpdate createInsert(EbeanServer server){
|
||||
public SqlUpdate createInsert(EbeanServer server) {
|
||||
|
||||
BindParams bindParams = new BindParams();
|
||||
|
||||
BindParams bindParams = new BindParams();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("insert into ").append(tableName).append(" (");
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("insert into ").append(tableName).append(" (");
|
||||
|
||||
int count = 0;
|
||||
Iterator<Entry<String, Object>> it = values.entrySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
if (count++ > 0){
|
||||
sb.append(", ");
|
||||
}
|
||||
|
||||
Map.Entry<String, Object> entry = it.next();
|
||||
sb.append(entry.getKey());
|
||||
|
||||
bindParams.setParameter(count, entry.getValue());
|
||||
}
|
||||
|
||||
sb.append(") values (");
|
||||
for (int i = 0; i < count; i++) {
|
||||
if (i > 0){
|
||||
sb.append(", ");
|
||||
}
|
||||
sb.append("?");
|
||||
}
|
||||
sb.append(")");
|
||||
|
||||
return new DefaultSqlUpdate(server, sb.toString(), bindParams);
|
||||
}
|
||||
|
||||
public SqlUpdate createDelete(EbeanServer server){
|
||||
|
||||
|
||||
BindParams bindParams = new BindParams();
|
||||
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("delete from ").append(tableName).append(" where ");
|
||||
|
||||
int count = 0;
|
||||
Iterator<Entry<String, Object>> it = values.entrySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
if (count++ > 0){
|
||||
sb.append(" and ");
|
||||
}
|
||||
|
||||
Map.Entry<String, Object> entry = it.next();
|
||||
|
||||
sb.append(entry.getKey());
|
||||
sb.append(" = ?");
|
||||
|
||||
bindParams.setParameter(count, entry.getValue());
|
||||
}
|
||||
if (excludeIds != null){
|
||||
IdInExpression idIn = new IdInExpression(excludeIds);
|
||||
|
||||
DefaultExpressionRequest er = new DefaultExpressionRequest(excludeDescriptor);
|
||||
idIn.addSqlNoAlias(er);
|
||||
idIn.addBindValues(er);
|
||||
|
||||
sb.append(" and not ( ");
|
||||
sb.append(er.getSql());
|
||||
sb.append(" ) ");
|
||||
|
||||
ArrayList<Object> bindValues = er.getBindValues();
|
||||
for (int i = 0; i < bindValues.size(); i++) {
|
||||
bindParams.setParameter(++count, bindValues.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
return new DefaultSqlUpdate(server, sb.toString(), bindParams);
|
||||
}
|
||||
|
||||
public SqlUpdate createDeleteChildren(EbeanServer server) {
|
||||
|
||||
BindParams bindParams = new BindParams();
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("delete from ").append(tableName).append(" where ");
|
||||
|
||||
int count = 0;
|
||||
Iterator<Entry<String, Object>> it = values.entrySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
if (count++ > 0) {
|
||||
sb.append(" and ");
|
||||
}
|
||||
|
||||
Map.Entry<String, Object> entry = it.next();
|
||||
|
||||
sb.append(entry.getKey());
|
||||
sb.append(" = ?");
|
||||
|
||||
bindParams.setParameter(count, entry.getValue());
|
||||
}
|
||||
|
||||
return new DefaultSqlUpdate(server, sb.toString(), bindParams);
|
||||
int count = 0;
|
||||
for (Map.Entry<String, Object> entry : values.entrySet()) {
|
||||
if (count++ > 0) {
|
||||
sb.append(", ");
|
||||
}
|
||||
sb.append(entry.getKey());
|
||||
bindParams.setParameter(count, entry.getValue());
|
||||
}
|
||||
|
||||
sb.append(") values (");
|
||||
for (int i = 0; i < count; i++) {
|
||||
if (i > 0) {
|
||||
sb.append(", ");
|
||||
}
|
||||
sb.append("?");
|
||||
}
|
||||
sb.append(")");
|
||||
|
||||
return new DefaultSqlUpdate(server, sb.toString(), bindParams);
|
||||
}
|
||||
|
||||
public SqlUpdate createDelete(EbeanServer server) {
|
||||
|
||||
BindParams bindParams = new BindParams();
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("delete from ").append(tableName).append(" where ");
|
||||
|
||||
int count = 0;
|
||||
for (Map.Entry<String, Object> entry : values.entrySet()) {
|
||||
if (count++ > 0) {
|
||||
sb.append(" and ");
|
||||
}
|
||||
sb.append(entry.getKey());
|
||||
sb.append(" = ?");
|
||||
bindParams.setParameter(count, entry.getValue());
|
||||
}
|
||||
|
||||
if (excludeIds != null) {
|
||||
IdInExpression idIn = new IdInExpression(excludeIds);
|
||||
|
||||
DefaultExpressionRequest er = new DefaultExpressionRequest(excludeDescriptor);
|
||||
idIn.addSqlNoAlias(er);
|
||||
idIn.addBindValues(er);
|
||||
|
||||
sb.append(" and not ( ");
|
||||
sb.append(er.getSql());
|
||||
sb.append(" ) ");
|
||||
|
||||
ArrayList<Object> bindValues = er.getBindValues();
|
||||
for (int i = 0; i < bindValues.size(); i++) {
|
||||
bindParams.setParameter(++count, bindValues.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
return new DefaultSqlUpdate(server, sb.toString(), bindParams);
|
||||
}
|
||||
|
||||
public SqlUpdate createDeleteChildren(EbeanServer server) {
|
||||
|
||||
BindParams bindParams = new BindParams();
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("delete from ").append(tableName).append(" where ");
|
||||
|
||||
int count = 0;
|
||||
for (Map.Entry<String, Object> entry : values.entrySet()) {
|
||||
if (count++ > 0) {
|
||||
sb.append(" and ");
|
||||
}
|
||||
|
||||
sb.append(entry.getKey());
|
||||
sb.append(" = ?");
|
||||
|
||||
bindParams.setParameter(count, entry.getValue());
|
||||
}
|
||||
|
||||
return new DefaultSqlUpdate(server, sb.toString(), bindParams);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
@@ -229,9 +228,7 @@ public class DeployBeanDescriptor<T> {
|
||||
|
||||
boolean missingMethods = false;
|
||||
|
||||
Iterator<DeployBeanProperty> it = propMap.values().iterator();
|
||||
while (it.hasNext()) {
|
||||
DeployBeanProperty prop = it.next();
|
||||
for (DeployBeanProperty prop : propMap.values()) {
|
||||
if (!prop.isTransient()) {
|
||||
String m = "";
|
||||
if (prop.getReadMethod() == null) {
|
||||
@@ -722,9 +719,7 @@ public class DeployBeanDescriptor<T> {
|
||||
|
||||
boolean hasLazyFetch = false;
|
||||
|
||||
Iterator<DeployBeanProperty> it = propMap.values().iterator();
|
||||
while (it.hasNext()) {
|
||||
DeployBeanProperty prop = it.next();
|
||||
for (DeployBeanProperty prop : propMap.values()) {
|
||||
if (prop.isTransient()) {
|
||||
// ignore transient props etc
|
||||
} else if (prop instanceof DeployBeanPropertyAssocMany<?>) {
|
||||
@@ -797,9 +792,7 @@ public class DeployBeanDescriptor<T> {
|
||||
|
||||
ArrayList<DeployBeanProperty> list = new ArrayList<DeployBeanProperty>(2);
|
||||
|
||||
Iterator<DeployBeanProperty> it = propMap.values().iterator();
|
||||
while (it.hasNext()) {
|
||||
DeployBeanProperty prop = it.next();
|
||||
for (DeployBeanProperty prop : propMap.values()) {
|
||||
if (prop.isId()) {
|
||||
list.add(prop);
|
||||
}
|
||||
@@ -828,9 +821,7 @@ public class DeployBeanDescriptor<T> {
|
||||
|
||||
ArrayList<DeployBeanPropertyAssocOne<?>> list = new ArrayList<DeployBeanPropertyAssocOne<?>>();
|
||||
|
||||
Iterator<DeployBeanProperty> it = propMap.values().iterator();
|
||||
while (it.hasNext()) {
|
||||
DeployBeanProperty prop = it.next();
|
||||
for (DeployBeanProperty prop : propMap.values()) {
|
||||
if (prop instanceof DeployBeanPropertyAssocOne<?>) {
|
||||
if (!prop.isEmbedded()) {
|
||||
list.add((DeployBeanPropertyAssocOne<?>) prop);
|
||||
@@ -849,9 +840,7 @@ public class DeployBeanDescriptor<T> {
|
||||
|
||||
ArrayList<DeployBeanPropertyAssocMany<?>> list = new ArrayList<DeployBeanPropertyAssocMany<?>>();
|
||||
|
||||
Iterator<DeployBeanProperty> it = propMap.values().iterator();
|
||||
while (it.hasNext()) {
|
||||
DeployBeanProperty prop = it.next();
|
||||
for (DeployBeanProperty prop : propMap.values()) {
|
||||
if (prop instanceof DeployBeanPropertyAssocMany<?>) {
|
||||
list.add((DeployBeanPropertyAssocMany<?>) prop);
|
||||
}
|
||||
@@ -869,13 +858,8 @@ public class DeployBeanDescriptor<T> {
|
||||
|
||||
ArrayList<DeployBeanProperty> list = new ArrayList<DeployBeanProperty>();
|
||||
|
||||
Iterator<DeployBeanProperty> it = propMap.values().iterator();
|
||||
while (it.hasNext()) {
|
||||
DeployBeanProperty prop = it.next();
|
||||
|
||||
if (prop instanceof DeployBeanPropertyAssoc<?>) {
|
||||
|
||||
} else {
|
||||
for (DeployBeanProperty prop : propMap.values()) {
|
||||
if (prop instanceof DeployBeanPropertyAssoc<?> == false) {
|
||||
if (!prop.isId() && prop.isVersionColumn()) {
|
||||
list.add(prop);
|
||||
}
|
||||
@@ -892,13 +876,8 @@ public class DeployBeanDescriptor<T> {
|
||||
|
||||
ArrayList<DeployBeanProperty> list = new ArrayList<DeployBeanProperty>();
|
||||
|
||||
Iterator<DeployBeanProperty> it = propMap.values().iterator();
|
||||
while (it.hasNext()) {
|
||||
DeployBeanProperty prop = it.next();
|
||||
|
||||
if (prop instanceof DeployBeanPropertyAssoc<?>) {
|
||||
|
||||
} else {
|
||||
for (DeployBeanProperty prop : propMap.values()) {
|
||||
if (prop instanceof DeployBeanPropertyAssoc<?> == false) {
|
||||
if (!prop.isId()) {
|
||||
list.add(prop);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.avaje.ebeaninternal.server.deploy.parse;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.sql.Types;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -51,9 +50,7 @@ public class DeployInherit {
|
||||
private void findInheritClasses(List<Class<?>> entityList) {
|
||||
|
||||
// go through each class and initialise the info object...
|
||||
Iterator<Class<?>> it = entityList.iterator();
|
||||
while (it.hasNext()) {
|
||||
Class<?> cls = (Class<?>) it.next();
|
||||
for (Class<?> cls : entityList) {
|
||||
if (isInheritanceClass(cls)) {
|
||||
DeployInheritInfo info = createInfo(cls);
|
||||
deployMap.put(cls, info);
|
||||
@@ -62,9 +59,8 @@ public class DeployInherit {
|
||||
}
|
||||
|
||||
private void buildDeployTree() {
|
||||
Iterator<DeployInheritInfo> it = deployMap.values().iterator();
|
||||
while (it.hasNext()) {
|
||||
DeployInheritInfo info = it.next();
|
||||
|
||||
for (DeployInheritInfo info : deployMap.values()) {
|
||||
if (!info.isRoot()) {
|
||||
DeployInheritInfo parent = getInfo(info.getParent());
|
||||
parent.addChild(info);
|
||||
@@ -74,19 +70,15 @@ public class DeployInherit {
|
||||
|
||||
private void buildFinalTree() {
|
||||
|
||||
Iterator<DeployInheritInfo> it = deployMap.values().iterator();
|
||||
while (it.hasNext()) {
|
||||
DeployInheritInfo deploy = it.next();
|
||||
for (DeployInheritInfo deploy : deployMap.values()) {
|
||||
if (deploy.isRoot()) {
|
||||
// build tree top down...
|
||||
createFinalInfo(null, null, deploy);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private InheritInfo createFinalInfo(InheritInfo root, InheritInfo parent,
|
||||
DeployInheritInfo deploy) {
|
||||
private InheritInfo createFinalInfo(InheritInfo root, InheritInfo parent, DeployInheritInfo deploy) {
|
||||
|
||||
InheritInfo node = new InheritInfo(root, parent, deploy);
|
||||
if (parent != null) {
|
||||
@@ -99,12 +91,7 @@ public class DeployInherit {
|
||||
}
|
||||
|
||||
// buildFinalChildren(root, child, deploy);
|
||||
|
||||
Iterator<DeployInheritInfo> it = deploy.children();
|
||||
|
||||
while (it.hasNext()) {
|
||||
DeployInheritInfo childDeploy = it.next();
|
||||
|
||||
for (DeployInheritInfo childDeploy : deploy.children()) {
|
||||
createFinalInfo(root, node, childDeploy);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.avaje.ebeaninternal.server.deploy.parse;
|
||||
|
||||
import java.sql.Types;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import com.avaje.ebeaninternal.server.deploy.InheritInfo;
|
||||
@@ -80,8 +79,8 @@ public class DeployInheritInfo {
|
||||
/**
|
||||
* Return the child nodes.
|
||||
*/
|
||||
public Iterator<DeployInheritInfo> children() {
|
||||
return children.iterator();
|
||||
public List<DeployInheritInfo> children() {
|
||||
return children;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
package com.avaje.ebeaninternal.server.expression;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import com.avaje.ebean.event.BeanQueryRequest;
|
||||
import com.avaje.ebeaninternal.api.HashQueryPlanBuilder;
|
||||
@@ -29,9 +27,7 @@ class AllEqualsExpression implements SpiExpression {
|
||||
|
||||
public void containsMany(BeanDescriptor<?> desc, ManyWhereJoins manyWhereJoin) {
|
||||
if (propMap != null) {
|
||||
Iterator<String> it = propMap.keySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
String propertyName = it.next();
|
||||
for (String propertyName : propMap.keySet()) {
|
||||
ElPropertyDeploy elProp = desc.getElPropertyDeploy(name(propertyName));
|
||||
if (elProp != null && elProp.containsMany()) {
|
||||
manyWhereJoin.add(elProp);
|
||||
@@ -45,9 +41,7 @@ class AllEqualsExpression implements SpiExpression {
|
||||
if (propMap.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
Iterator<Object> it = propMap.values().iterator();
|
||||
while (it.hasNext()) {
|
||||
Object value = it.next();
|
||||
for (Object value : propMap.values()) {
|
||||
if (value != null) {
|
||||
request.addBindValue(value);
|
||||
} else {
|
||||
@@ -64,12 +58,9 @@ class AllEqualsExpression implements SpiExpression {
|
||||
|
||||
request.append("(");
|
||||
|
||||
Set<Entry<String, Object>> entries = propMap.entrySet();
|
||||
Iterator<Entry<String, Object>> it = entries.iterator();
|
||||
|
||||
int count = 0;
|
||||
while (it.hasNext()) {
|
||||
Map.Entry<java.lang.String, java.lang.Object> entry = it.next();
|
||||
for (Map.Entry<String,Object> entry : propMap.entrySet()) {
|
||||
|
||||
Object value = entry.getValue();
|
||||
String propName = entry.getKey();
|
||||
|
||||
|
||||
+2
-5
@@ -1,7 +1,6 @@
|
||||
package com.avaje.ebeaninternal.server.expression;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
|
||||
import com.avaje.ebean.ExampleExpression;
|
||||
import com.avaje.ebean.LikeType;
|
||||
@@ -207,10 +206,8 @@ public class DefaultExampleExpression implements SpiExpression, ExampleExpressio
|
||||
OrmQueryRequest<?> r = (OrmQueryRequest<?>) request;
|
||||
BeanDescriptor<?> beanDescriptor = r.getBeanDescriptor();
|
||||
|
||||
Iterator<BeanProperty> propIter = beanDescriptor.propertiesAll();
|
||||
|
||||
while (propIter.hasNext()) {
|
||||
BeanProperty beanProperty = propIter.next();
|
||||
for (BeanProperty beanProperty : beanDescriptor.propertiesAll()) {
|
||||
|
||||
String propName = beanProperty.getName();
|
||||
Object value = beanProperty.getValue(entity);
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.avaje.ebeaninternal.server.lib.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
|
||||
@@ -60,9 +60,7 @@ public class Dnode {
|
||||
sb = new StringBuilder();
|
||||
}
|
||||
sb.append("<").append(nodeName);
|
||||
Iterator<String> it = attributeNames();
|
||||
while (it.hasNext()) {
|
||||
String attr = it.next();
|
||||
for (String attr : attrList.keySet()) {
|
||||
Object attrValue = getAttribute(attr);
|
||||
sb.append(" ").append(attr).append("=\"");
|
||||
if (attrValue != null) {
|
||||
@@ -145,9 +143,7 @@ public class Dnode {
|
||||
if (children.remove(node)) {
|
||||
return true;
|
||||
}
|
||||
Iterator<Dnode> it = children.iterator();
|
||||
while (it.hasNext()) {
|
||||
Dnode child = it.next();
|
||||
for (Dnode child : children) {
|
||||
if (child.remove(node)) {
|
||||
return true;
|
||||
}
|
||||
@@ -286,8 +282,8 @@ public class Dnode {
|
||||
/**
|
||||
* The attribute names as strings.
|
||||
*/
|
||||
public Iterator<String> attributeNames() {
|
||||
return attrList.keySet().iterator();
|
||||
public Collection<String> attributeNames() {
|
||||
return attrList.keySet();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,8 +2,9 @@ package com.avaje.ebeaninternal.server.lib.util;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* A simple test message that can be sent via smtp.
|
||||
@@ -84,8 +85,8 @@ public class MailMessage {
|
||||
/**
|
||||
* Return the recipient list.
|
||||
*/
|
||||
public Iterator<MailAddress> getRecipientList() {
|
||||
return recipientList.iterator();
|
||||
public List<MailAddress> getRecipientList() {
|
||||
return recipientList;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -119,15 +120,15 @@ public class MailMessage {
|
||||
/**
|
||||
* Return the body text.
|
||||
*/
|
||||
public Iterator<String> getBodyLines() {
|
||||
return bodylines.iterator();
|
||||
public List<String> getBodyLines() {
|
||||
return bodylines;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the headers.
|
||||
*/
|
||||
public Iterator<String> getHeaderFields() {
|
||||
return header.keySet().iterator();
|
||||
public Collection<String> getHeaderFields() {
|
||||
return header.keySet();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -140,16 +141,13 @@ public class MailMessage {
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder(100);
|
||||
sb.append("Sender: " + senderAddress + "\tRecipient: " + recipientList + "\n");
|
||||
Iterator<String> hi = header.keySet().iterator();
|
||||
while (hi.hasNext()) {
|
||||
String key = hi.next();
|
||||
for (String key : header.keySet()) {
|
||||
String hline = key + ": " + header.get(key) + "\n";
|
||||
sb.append(hline);
|
||||
}
|
||||
sb.append("\n");
|
||||
Iterator<String> e = bodylines.iterator();
|
||||
while (e.hasNext()) {
|
||||
sb.append(e.next()).append("\n");
|
||||
for (String line : bodylines) {
|
||||
sb.append(line).append("\n");
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
package com.avaje.ebeaninternal.server.lib.util;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
@@ -10,206 +7,200 @@ import java.io.OutputStreamWriter;
|
||||
import java.net.InetAddress;
|
||||
import java.net.Socket;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Sends simple MailMessages via smtp.
|
||||
* Sends simple MailMessages via smtp.
|
||||
*/
|
||||
public class MailSender implements Runnable {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(MailSender.class);
|
||||
|
||||
int traceLevel = 0;
|
||||
|
||||
Socket sserver;
|
||||
String server;
|
||||
|
||||
BufferedReader in;
|
||||
private static final Logger logger = LoggerFactory.getLogger(MailSender.class);
|
||||
|
||||
OutputStreamWriter out;
|
||||
|
||||
MailMessage message;
|
||||
int traceLevel = 0;
|
||||
|
||||
MailListener listener = null;
|
||||
Socket sserver;
|
||||
String server;
|
||||
|
||||
private static final int SMTP_PORT = 25;
|
||||
BufferedReader in;
|
||||
|
||||
/**
|
||||
* Create for a given mail server.
|
||||
*/
|
||||
public MailSender(String server) {
|
||||
this.server = server;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the listener to handle MessageEvents.
|
||||
*/
|
||||
public void setMailListener(MailListener listener){
|
||||
this.listener = listener;
|
||||
}
|
||||
OutputStreamWriter out;
|
||||
|
||||
/**
|
||||
* Send the message.
|
||||
*/
|
||||
public void run() {
|
||||
send(message);
|
||||
}
|
||||
MailMessage message;
|
||||
|
||||
/**
|
||||
* Send the message in a background thread.
|
||||
*/
|
||||
public void sendInBackground(MailMessage message){
|
||||
this.message = message;
|
||||
Thread thread = new Thread(this);
|
||||
thread.start();
|
||||
}
|
||||
MailListener listener = null;
|
||||
|
||||
|
||||
/**
|
||||
* Send the message in the current thread.
|
||||
*/
|
||||
public void send(MailMessage message){
|
||||
try {
|
||||
Iterator<MailAddress> i = message.getRecipientList();
|
||||
while (i.hasNext()) {
|
||||
MailAddress recipientAddress = (MailAddress) i.next();
|
||||
sserver = new Socket(server, SMTP_PORT);
|
||||
send(message, sserver, recipientAddress);
|
||||
sserver.close();
|
||||
|
||||
if (listener != null){
|
||||
MailEvent event = new MailEvent(message, null);
|
||||
listener.handleEvent(event);
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
if (listener != null){
|
||||
MailEvent event = new MailEvent(message, ex);
|
||||
listener.handleEvent(event);
|
||||
} else {
|
||||
logger.error(null, ex);
|
||||
}
|
||||
private static final int SMTP_PORT = 25;
|
||||
|
||||
/**
|
||||
* Create for a given mail server.
|
||||
*/
|
||||
public MailSender(String server) {
|
||||
this.server = server;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the listener to handle MessageEvents.
|
||||
*/
|
||||
public void setMailListener(MailListener listener) {
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the message.
|
||||
*/
|
||||
public void run() {
|
||||
send(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the message in a background thread.
|
||||
*/
|
||||
public void sendInBackground(MailMessage message) {
|
||||
this.message = message;
|
||||
Thread thread = new Thread(this);
|
||||
thread.start();
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the message in the current thread.
|
||||
*/
|
||||
public void send(MailMessage message) {
|
||||
try {
|
||||
for (MailAddress recipientAddress : message.getRecipientList()) {
|
||||
sserver = new Socket(server, SMTP_PORT);
|
||||
send(message, sserver, recipientAddress);
|
||||
sserver.close();
|
||||
|
||||
if (listener != null) {
|
||||
MailEvent event = new MailEvent(message, null);
|
||||
listener.handleEvent(event);
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
if (listener != null) {
|
||||
MailEvent event = new MailEvent(message, ex);
|
||||
listener.handleEvent(event);
|
||||
} else {
|
||||
logger.error(null, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void send(MailMessage message, Socket sserver, MailAddress recipientAddress) throws IOException {
|
||||
|
||||
// A bit convoluted, but doesn't depend on DNS in any way...
|
||||
InetAddress localhost = sserver.getLocalAddress();
|
||||
String localaddress = localhost.getHostAddress();
|
||||
MailAddress sender = message.getSender();
|
||||
message.setCurrentRecipient(recipientAddress);
|
||||
|
||||
// Mandatory header fields, Date and From
|
||||
if (message.getHeader("Date") == null) {
|
||||
message.addHeader("Date", new java.util.Date().toString());
|
||||
}
|
||||
if (message.getHeader("From") == null) {
|
||||
message.addHeader("From", sender.getAlias() + " <" + sender.getEmailAddress() + ">");
|
||||
}
|
||||
|
||||
private void send(MailMessage message, Socket sserver, MailAddress recipientAddress) throws IOException {
|
||||
|
||||
// A bit convoluted, but doesn't depend on DNS in any way...
|
||||
InetAddress localhost = sserver.getLocalAddress();
|
||||
String localaddress = localhost.getHostAddress();
|
||||
MailAddress sender = message.getSender();
|
||||
message.setCurrentRecipient(recipientAddress);
|
||||
|
||||
// Mandatory header fields, Date and From
|
||||
if (message.getHeader("Date") == null){
|
||||
message.addHeader("Date", new java.util.Date().toString());
|
||||
}
|
||||
if (message.getHeader("From") == null){
|
||||
message.addHeader("From", sender.getAlias() + " <" + sender.getEmailAddress() + ">");
|
||||
}
|
||||
|
||||
//if (message.getHeader("From") == null){
|
||||
message.addHeader("To", recipientAddress.getAlias() + " <" + recipientAddress.getEmailAddress() + ">");
|
||||
//}
|
||||
|
||||
out = new OutputStreamWriter(sserver.getOutputStream());
|
||||
in = new BufferedReader(new InputStreamReader(sserver.getInputStream()));
|
||||
String sintro = readln();
|
||||
if (!sintro.startsWith("220")) { // 220
|
||||
logger.debug("SmtpSender: intro==" + sintro);
|
||||
return;
|
||||
}
|
||||
|
||||
writeln("EHLO " + localaddress);
|
||||
if (!expect250()) {
|
||||
return;
|
||||
}
|
||||
|
||||
writeln("MAIL FROM:<" + sender.getEmailAddress() + ">");
|
||||
if (!expect250()) {
|
||||
return;
|
||||
}
|
||||
writeln("RCPT TO:<" + recipientAddress.getEmailAddress() + ">");
|
||||
if (!expect250()){
|
||||
return;
|
||||
}
|
||||
writeln("DATA");
|
||||
while (true) { // may be multiple 250 replies pending from server
|
||||
String line = readln();
|
||||
if (line.startsWith("3"))
|
||||
break; // ready to send
|
||||
if (!line.startsWith("2")) {
|
||||
logger.debug("SmtpSender.send reponse to DATA: " + line);
|
||||
return;
|
||||
}
|
||||
}
|
||||
Iterator<String> hi = message.getHeaderFields();
|
||||
while (hi.hasNext()) {
|
||||
String key = (String) hi.next();
|
||||
writeln(key + ": " + message.getHeader(key));
|
||||
}
|
||||
writeln(""); // end of header;
|
||||
Iterator<String> e = message.getBodyLines();
|
||||
while (e.hasNext()) {
|
||||
String bline = (String) e.next();
|
||||
if (bline.startsWith(".")) {
|
||||
bline = "." + bline;
|
||||
}
|
||||
writeln(bline);
|
||||
}
|
||||
writeln(".");
|
||||
expect250();
|
||||
writeln("QUIT");
|
||||
// if (message.getHeader("From") == null){
|
||||
message.addHeader("To", recipientAddress.getAlias() + " <" + recipientAddress.getEmailAddress() + ">");
|
||||
// }
|
||||
|
||||
out = new OutputStreamWriter(sserver.getOutputStream());
|
||||
in = new BufferedReader(new InputStreamReader(sserver.getInputStream()));
|
||||
String sintro = readln();
|
||||
if (!sintro.startsWith("220")) { // 220
|
||||
logger.debug("SmtpSender: intro==" + sintro);
|
||||
return;
|
||||
}
|
||||
|
||||
private boolean expect250() throws IOException {
|
||||
String line = readln();
|
||||
if (!line.startsWith("2")) {
|
||||
logger.info("SmtpSender.expect250: " + line);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
writeln("EHLO " + localaddress);
|
||||
if (!expect250()) {
|
||||
return;
|
||||
}
|
||||
|
||||
private void writeln(String s) throws IOException {
|
||||
if (traceLevel > 2){
|
||||
logger.debug("From client: " + s);
|
||||
}
|
||||
out.write(s + "\r\n");
|
||||
out.flush();
|
||||
writeln("MAIL FROM:<" + sender.getEmailAddress() + ">");
|
||||
if (!expect250()) {
|
||||
return;
|
||||
}
|
||||
|
||||
private String readln() throws IOException {
|
||||
String line = in.readLine();
|
||||
if (traceLevel > 1){
|
||||
logger.debug("From server: " + line);
|
||||
}
|
||||
return line;
|
||||
writeln("RCPT TO:<" + recipientAddress.getEmailAddress() + ">");
|
||||
if (!expect250()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the trace level.
|
||||
*/
|
||||
public void setTraceLevel(int traceLevel){
|
||||
this.traceLevel = traceLevel;
|
||||
writeln("DATA");
|
||||
while (true) { // may be multiple 250 replies pending from server
|
||||
String line = readln();
|
||||
if (line.startsWith("3"))
|
||||
break; // ready to send
|
||||
if (!line.startsWith("2")) {
|
||||
logger.debug("SmtpSender.send reponse to DATA: " + line);
|
||||
return;
|
||||
}
|
||||
}
|
||||
for (String key : message.getHeaderFields()) {
|
||||
writeln(key + ": " + message.getHeader(key));
|
||||
}
|
||||
writeln(""); // end of header;
|
||||
for (String bline : message.getBodyLines()) {
|
||||
if (bline.startsWith(".")) {
|
||||
bline = "." + bline;
|
||||
}
|
||||
writeln(bline);
|
||||
}
|
||||
writeln(".");
|
||||
expect250();
|
||||
writeln("QUIT");
|
||||
|
||||
/**
|
||||
* Return the hostname of the local machine.
|
||||
*/
|
||||
public String getLocalHostName() {
|
||||
try {
|
||||
InetAddress ipaddress = InetAddress.getLocalHost();
|
||||
String localHost = ipaddress.getHostName();
|
||||
if (localHost == null) {
|
||||
return "localhost";
|
||||
} else {
|
||||
return localHost;
|
||||
}
|
||||
} catch (UnknownHostException e) {
|
||||
return "localhost";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean expect250() throws IOException {
|
||||
String line = readln();
|
||||
if (!line.startsWith("2")) {
|
||||
logger.info("SmtpSender.expect250: " + line);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void writeln(String s) throws IOException {
|
||||
if (traceLevel > 2) {
|
||||
logger.debug("From client: " + s);
|
||||
}
|
||||
out.write(s + "\r\n");
|
||||
out.flush();
|
||||
}
|
||||
|
||||
private String readln() throws IOException {
|
||||
String line = in.readLine();
|
||||
if (traceLevel > 1) {
|
||||
logger.debug("From server: " + line);
|
||||
}
|
||||
return line;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the trace level.
|
||||
*/
|
||||
public void setTraceLevel(int traceLevel) {
|
||||
this.traceLevel = traceLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the hostname of the local machine.
|
||||
*/
|
||||
public String getLocalHostName() {
|
||||
try {
|
||||
InetAddress ipaddress = InetAddress.getLocalHost();
|
||||
String localHost = ipaddress.getHostName();
|
||||
if (localHost == null) {
|
||||
return "localhost";
|
||||
} else {
|
||||
return localHost;
|
||||
}
|
||||
} catch (UnknownHostException e) {
|
||||
return "localhost";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
package com.avaje.ebeaninternal.server.persist;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
import javax.persistence.PersistenceException;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Used to hold BatchedPstmt objects for batch based execution.
|
||||
* <p>
|
||||
@@ -92,9 +91,7 @@ public class BatchedPstmtHolder {
|
||||
// but still need to close PreparedStatements.
|
||||
boolean isError = false;
|
||||
|
||||
Iterator<BatchedPstmt> it = stmtMap.values().iterator();
|
||||
while (it.hasNext()) {
|
||||
BatchedPstmt bs = it.next();
|
||||
for (BatchedPstmt bs : stmtMap.values()) {
|
||||
try {
|
||||
if (!isError) {
|
||||
bs.executeBatch(getGeneratedKeys);
|
||||
@@ -119,7 +116,7 @@ public class BatchedPstmtHolder {
|
||||
bs.close();
|
||||
} catch (SQLException ex) {
|
||||
// error closing PreparedStatement
|
||||
logger.error(null, ex);
|
||||
logger.error(null, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,9 +2,7 @@ package com.avaje.ebeaninternal.server.query;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
@@ -87,14 +85,12 @@ public class SqlTreeAlias {
|
||||
*/
|
||||
public void buildAlias() {
|
||||
|
||||
Iterator<String> i = joinProps.iterator();
|
||||
while (i.hasNext()) {
|
||||
calcAlias(i.next());
|
||||
for (String joinProp : joinProps) {
|
||||
calcAlias(joinProp);
|
||||
}
|
||||
|
||||
i = manyWhereJoinProps.iterator();
|
||||
while (i.hasNext()) {
|
||||
calcAliasManyWhere(i.next());
|
||||
for (String joinProp : manyWhereJoinProps) {
|
||||
calcAliasManyWhere(joinProp);
|
||||
}
|
||||
|
||||
mapEmbeddedPropertyAlias();
|
||||
@@ -192,9 +188,7 @@ public class SqlTreeAlias {
|
||||
*/
|
||||
private String parseAliasMap(String clause, HashMap<String, String> parseAliasMap) {
|
||||
|
||||
Iterator<Entry<String, String>> i = parseAliasMap.entrySet().iterator();
|
||||
while (i.hasNext()) {
|
||||
Map.Entry<String, String> e = i.next();
|
||||
for (Map.Entry<String, String> e : parseAliasMap.entrySet()) {
|
||||
String k = "${" + e.getKey() + "}";
|
||||
clause = clause.replace(k, e.getValue() + ".");
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@@ -304,11 +303,8 @@ public class SqlTreeBuilder {
|
||||
} else {
|
||||
// add extra joins required to support predicates
|
||||
// and/or order by clause
|
||||
Iterator<SqlTreeNodeExtraJoin> it = extraJoins.iterator();
|
||||
while (it.hasNext()) {
|
||||
SqlTreeNodeExtraJoin extraJoin = it.next();
|
||||
for (SqlTreeNodeExtraJoin extraJoin: extraJoins) {
|
||||
myList.add(extraJoin);
|
||||
|
||||
if (extraJoin.isManyJoin()) {
|
||||
// as we are now going to join to the many then we need
|
||||
// to add the distinct to the sql query to stop duplicate
|
||||
@@ -420,9 +416,7 @@ public class SqlTreeBuilder {
|
||||
// Also note that this can include transient properties.
|
||||
// This makes sense for transient properties used to
|
||||
// hold sum() count() type values (with SqlSelect)
|
||||
Iterator<String> it = queryProps.getSelectProperties();
|
||||
while (it.hasNext()) {
|
||||
String propName = it.next();
|
||||
for (String propName : queryProps.getSelectProperties()) {
|
||||
if (propName.length() > 0) {
|
||||
addProperty(selectProps, desc, queryProps, propName);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
@@ -390,16 +389,16 @@ public class OrmQueryProperties implements Serializable {
|
||||
* This is because bean joins will have there own node in the SqlTree.
|
||||
* </p>
|
||||
*/
|
||||
public Iterator<String> getSelectProperties() {
|
||||
public Set<String> getSelectProperties() {
|
||||
|
||||
if (secondaryQueryJoins == null) {
|
||||
return included.iterator();
|
||||
return included;
|
||||
}
|
||||
|
||||
LinkedHashSet<String> temp = new LinkedHashSet<String>(secondaryQueryJoins.size() + included.size());
|
||||
temp.addAll(included);
|
||||
temp.addAll(secondaryQueryJoins);
|
||||
return temp.iterator();
|
||||
return temp;
|
||||
}
|
||||
|
||||
public void addSecondaryQueryJoin(String property) {
|
||||
|
||||
@@ -14,7 +14,6 @@ import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
import java.util.Currency;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
@@ -27,6 +26,8 @@ import org.joda.time.DateTime;
|
||||
import org.joda.time.LocalDate;
|
||||
import org.joda.time.LocalDateTime;
|
||||
import org.joda.time.LocalTime;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.avaje.ebean.annotation.EnumMapping;
|
||||
import com.avaje.ebean.annotation.EnumValue;
|
||||
@@ -46,9 +47,6 @@ import com.avaje.ebeaninternal.server.type.reflect.ReflectionBasedCompoundType;
|
||||
import com.avaje.ebeaninternal.server.type.reflect.ReflectionBasedCompoundTypeProperty;
|
||||
import com.avaje.ebeaninternal.server.type.reflect.ReflectionBasedTypeBuilder;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Default implementation of TypeManager.
|
||||
* <p>
|
||||
@@ -441,11 +439,9 @@ public final class DefaultTypeManager implements TypeManager, KnownImmutable {
|
||||
|
||||
int maxValueLen = 0;
|
||||
|
||||
Iterator it = nameValueMap.entrySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
Map.Entry entry = (Map.Entry) it.next();
|
||||
String name = (String) entry.getKey();
|
||||
String value = (String) entry.getValue();
|
||||
for (Map.Entry<String,String> entry : nameValueMap.entrySet()) {
|
||||
String name = entry.getKey();
|
||||
String value = entry.getValue();
|
||||
|
||||
maxValueLen = Math.max(maxValueLen, value.length());
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.avaje.ebeaninternal.server.util;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
|
||||
import javax.persistence.PersistenceException;
|
||||
|
||||
@@ -180,10 +179,8 @@ public class BindParamsParser {
|
||||
// Chop up Collection parameter into a number
|
||||
// of individual parameters and add each one individually
|
||||
Collection<?> collection = (Collection<?>)inValue;
|
||||
Iterator<?> it = collection.iterator();
|
||||
int c = 0;
|
||||
while (it.hasNext()) {
|
||||
Object elVal = (Object) it.next();
|
||||
for (Object elVal : collection) {
|
||||
if (++c > 1){
|
||||
orderedList.appendSql(",");
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@ import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.jar.Attributes;
|
||||
@@ -262,9 +261,7 @@ public class ClassPathSearch {
|
||||
if (includePkgs.size() > 0) {
|
||||
// just search the relevant directories based on the
|
||||
// list of included packages
|
||||
Iterator<String> it = includePkgs.iterator();
|
||||
while (it.hasNext()) {
|
||||
String pkg = it.next();
|
||||
for (String pkg : includePkgs) {
|
||||
String relativePath = pkg.replace('.', '/');
|
||||
File dir = new File(classPath, relativePath);
|
||||
if (dir.exists()) {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.avaje.ebeaninternal.server.util;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
@@ -177,9 +176,7 @@ public class ClassPathSearchFilter {
|
||||
if (set.contains(match)) {
|
||||
return true;
|
||||
}
|
||||
Iterator<String> incIt = set.iterator();
|
||||
while (incIt.hasNext()) {
|
||||
String val = incIt.next();
|
||||
for (String val : set) {
|
||||
if (match.contains(val)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user