Author: doogie
Date: Sun May 3 02:16:13 2009 New Revision: 771016 URL: http://svn.apache.org/viewvc?rev=771016&view=rev Log: Generics markup. Modified: ofbiz/trunk/framework/common/src/org/ofbiz/common/FindServices.java ofbiz/trunk/framework/common/src/org/ofbiz/common/authentication/AuthenticationComparator.java ofbiz/trunk/framework/common/src/org/ofbiz/common/email/EmailServices.java ofbiz/trunk/framework/common/src/org/ofbiz/common/email/NotificationServices.java Modified: ofbiz/trunk/framework/common/src/org/ofbiz/common/FindServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/src/org/ofbiz/common/FindServices.java?rev=771016&r1=771015&r2=771016&view=diff ============================================================================== --- ofbiz/trunk/framework/common/src/org/ofbiz/common/FindServices.java (original) +++ ofbiz/trunk/framework/common/src/org/ofbiz/common/FindServices.java Sun May 3 02:16:13 2009 @@ -19,15 +19,14 @@ package org.ofbiz.common; import java.sql.Timestamp; -import java.util.ArrayList; import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; +import javolution.util.FastList; import javolution.util.FastMap; +import javolution.util.FastSet; import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.ObjectType; @@ -67,10 +66,10 @@ public static final String module = FindServices.class.getName(); - public static HashMap<String, EntityOperator> entityOperators; + public static Map<String, EntityOperator> entityOperators; static { - entityOperators = new HashMap<String, EntityOperator>(); + entityOperators = FastMap.newInstance(); entityOperators.put("and", EntityOperator.AND); entityOperators.put("between", EntityOperator.BETWEEN); entityOperators.put("equals", EntityOperator.EQUALS); @@ -95,7 +94,7 @@ * @param inputFields Input parameters run thru UtilHttp.getParameterMap * @return a map with field name and operator */ - public static HashMap<String, HashMap<String, HashMap<String, Object>>> prepareField(Map<String, ?> inputFields, Map<String, Object> queryStringMap, Map<String, List<Object[]>> origValueMap) { + public static Map<String, Map<String, Map<String, Object>>> prepareField(Map<String, ?> inputFields, Map<String, Object> queryStringMap, Map<String, List<Object[]>> origValueMap) { // Strip the "_suffix" off of the parameter name and // build a three-level map of values keyed by fieldRoot name, // fld0 or fld1, and, then, "op" or "value" @@ -110,7 +109,7 @@ // Note that "normalizedFields" will contain values other than those // Contained in the associated entity. // Those extra fields will be ignored in the second half of this method. - HashMap<String, HashMap<String, HashMap<String, Object>>> normalizedFields = new HashMap<String, HashMap<String, HashMap<String, Object>>>(); + Map<String, Map<String, Map<String, Object>>> normalizedFields = FastMap.newInstance(); //StringBuffer queryStringBuf = new StringBuffer(); for (String fieldNameRaw: inputFields.keySet()) { // The name as it appeas in the HTML form String fieldNameRoot = null; // The entity field name. Everything to the left of the first "_" if @@ -120,8 +119,8 @@ // If it is an "op" field, it will be "equals", "greaterThan", etc. int iPos = -1; int iPos2 = -1; - HashMap<String, HashMap<String, Object>> subMap = null; - HashMap<String, Object> subMap2 = null; + Map<String, Map<String, Object>> subMap = null; + Map<String, Object> subMap2 = null; String fieldMode = null; fieldValue = inputFields.get(fieldNameRaw); @@ -182,19 +181,19 @@ } subMap = normalizedFields.get(fieldNameRoot); if (subMap == null) { - subMap = new HashMap<String, HashMap<String, Object>>(); + subMap = FastMap.newInstance(); normalizedFields.put(fieldNameRoot, subMap); } subMap2 = subMap.get(fieldPair); if (subMap2 == null) { - subMap2 = new HashMap<String, Object>(); + subMap2 = FastMap.newInstance(); subMap.put(fieldPair, subMap2); } subMap2.put(fieldMode, fieldValue); List<Object[]> origList = origValueMap.get(fieldNameRoot); if (origList == null) { - origList = new ArrayList<Object[]>(); + origList = FastList.newInstance(); origValueMap.put(fieldNameRoot, origList); } Object [] origValues = {fieldNameRaw, fieldValue}; @@ -212,14 +211,14 @@ * @param normalizedFields list of field the user have populated * @return a arrayList usable to create an entityCondition */ - public static ArrayList<EntityCondition> createCondition(ModelEntity modelEntity, HashMap<String, HashMap<String, HashMap<String, Object>>> normalizedFields, Map<String, Object> queryStringMap, Map<String, List<Object[]>> origValueMap, GenericDelegator delegator, Map<String, ?> context) { - HashMap<String, HashMap<String, Object>> subMap = null; - HashMap<String, Object> subMap2 = null; + public static List<EntityCondition> createCondition(ModelEntity modelEntity, Map<String, Map<String, Map<String, Object>>> normalizedFields, Map<String, Object> queryStringMap, Map<String, List<Object[]>> origValueMap, GenericDelegator delegator, Map<String, ?> context) { + Map<String, Map<String, Object>> subMap = null; + Map<String, Object> subMap2 = null; EntityOperator fieldOp = null; Object fieldValue = null; // If it is a "value" field, it will be the value to be used in the query. // If it is an "op" field, it will be "equals", "greaterThan", etc. EntityExpr cond = null; - ArrayList<EntityCondition> tmpList = new ArrayList<EntityCondition>(); + List<EntityCondition> tmpList = FastList.newInstance(); String opString = null; String ignoreCase = null; int count = 0; @@ -275,7 +274,7 @@ // Set up so next part finds ending conditions for same day subMap2 = subMap.get("fld1"); if (subMap2 == null) { - subMap2 = new HashMap<String, Object>(); + subMap2 = FastMap.newInstance(); subMap.put("fld1", subMap2); } String endOfDay = dayStart(timeStampString, 1); @@ -482,7 +481,7 @@ // parameters run thru UtilHttp.getParameterMap Map<String, Object> queryStringMap = FastMap.newInstance(); Map<String, List<Object[]>> origValueMap = FastMap.newInstance(); - HashMap<String, HashMap<String, HashMap<String, Object>>> normalizedFields = prepareField(inputFields, queryStringMap, origValueMap); + Map<String, Map<String, Map<String, Object>>> normalizedFields = prepareField(inputFields, queryStringMap, origValueMap); // Now use only the values that correspond to entity fields to build // an EntityConditionList @@ -491,7 +490,7 @@ GenericValue entityValue = delegator.makeValue(entityName, FastMap.newInstance()); ModelEntity modelEntity = entityValue.getModelEntity(); - ArrayList<EntityCondition> tmpList = createCondition(modelEntity, normalizedFields, queryStringMap, origValueMap, delegator, context); + List<EntityCondition> tmpList = createCondition(modelEntity, normalizedFields, queryStringMap, origValueMap, delegator, context); /* the filter by date condition should only be added when there are other conditions or when * the user has specified a noConditionFind. Otherwise, specifying filterByDate will become @@ -585,7 +584,7 @@ return retValue; } - public static HashMap<String, Object> buildReducedQueryString(Map<String, ?> inputFields, String entityName, GenericDelegator delegator) { + public static Map<String, Object> buildReducedQueryString(Map<String, ?> inputFields, String entityName, GenericDelegator delegator) { // Strip the "_suffix" off of the parameter name and // build a three-level map of values keyed by fieldRoot name, // fld0 or fld1, and, then, "op" or "value" @@ -601,7 +600,7 @@ // Contained in the associated entity. // Those extra fields will be ignored in the second half of this method. ModelEntity modelEntity = delegator.getModelEntity(entityName); - HashMap<String, Object> normalizedFields = new HashMap<String, Object>(); + Map<String, Object> normalizedFields = FastMap.newInstance(); //StringBuffer queryStringBuf = new StringBuffer(); for (String fieldNameRaw: inputFields.keySet()) { // The name as it appeas in the HTML form String fieldNameRoot = null; // The entity field name. Everything to the left of the first "_" if Modified: ofbiz/trunk/framework/common/src/org/ofbiz/common/authentication/AuthenticationComparator.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/src/org/ofbiz/common/authentication/AuthenticationComparator.java?rev=771016&r1=771015&r2=771016&view=diff ============================================================================== --- ofbiz/trunk/framework/common/src/org/ofbiz/common/authentication/AuthenticationComparator.java (original) +++ ofbiz/trunk/framework/common/src/org/ofbiz/common/authentication/AuthenticationComparator.java Sun May 3 02:16:13 2009 @@ -28,7 +28,7 @@ * * Used to sort Authenticators by weight */ -public class AuthenticationComparator implements Comparator { +public class AuthenticationComparator implements Comparator<Authenticator> { /** * Compares its two arguments for order. Returns a negative integer, @@ -62,9 +62,7 @@ * @throws ClassCastException if the arguments' types prevent them from * being compared by this Comparator. */ - public int compare(Object o1, Object o2) { - Authenticator a1 = (Authenticator) o1; - Authenticator a2 = (Authenticator) o2; + public int compare(Authenticator a1, Authenticator a2) { if (a1.getWeight() < a2.getWeight()) { return -1; } else if (a1.getWeight() > a2.getWeight()) { Modified: ofbiz/trunk/framework/common/src/org/ofbiz/common/email/EmailServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/src/org/ofbiz/common/email/EmailServices.java?rev=771016&r1=771015&r2=771016&view=diff ============================================================================== --- ofbiz/trunk/framework/common/src/org/ofbiz/common/email/EmailServices.java (original) +++ ofbiz/trunk/framework/common/src/org/ofbiz/common/email/EmailServices.java Sun May 3 02:16:13 2009 @@ -97,7 +97,7 @@ String subject = (String) context.get("subject"); String partyId = (String) context.get("partyId"); String body = (String) context.get("body"); - List bodyParts = (List) context.get("bodyParts"); + List<Map<String, Object>> bodyParts = UtilGenerics.checkList(context.get("bodyParts")); GenericValue userLogin = (GenericValue) context.get("userLogin"); results.put("partyId", partyId); @@ -234,9 +234,7 @@ // BodyParts contain a list of Maps items containing content(String) and type(String) of the attachement MimeMultipart mp = new MimeMultipart(); Debug.logInfo(bodyParts.size() + " multiparts found",module); - Iterator bodyPartIter = bodyParts.iterator(); - while (bodyPartIter.hasNext()) { - Map bodyPart = (Map) bodyPartIter.next(); + for (Map<String, Object> bodyPart: bodyParts) { Object bodyPartContent = bodyPart.get("content"); MimeBodyPart mbp = new MimeBodyPart(); @@ -451,11 +449,11 @@ List<Map<String, ? extends Object>> bodyParts = FastList.newInstance(); if (bodyText != null) { bodyText = FlexibleStringExpander.expandString(bodyText, screenContext, locale); - bodyParts.add(UtilMisc.toMap("content", bodyText, "type", "text/html")); + bodyParts.add(UtilMisc.<String, Object>toMap("content", bodyText, "type", "text/html")); } else { - bodyParts.add(UtilMisc.toMap("content", bodyWriter.toString(), "type", "text/html")); + bodyParts.add(UtilMisc.<String, Object>toMap("content", bodyWriter.toString(), "type", "text/html")); } - bodyParts.add(UtilMisc.toMap("content", baos.toByteArray(), "type", "application/pdf", "filename", attachmentName)); + bodyParts.add(UtilMisc.<String, Object>toMap("content", baos.toByteArray(), "type", "application/pdf", "filename", attachmentName)); serviceContext.put("bodyParts", bodyParts); } catch (GeneralException ge) { String errMsg = "Error rendering PDF attachment for email: " + ge.toString(); Modified: ofbiz/trunk/framework/common/src/org/ofbiz/common/email/NotificationServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/src/org/ofbiz/common/email/NotificationServices.java?rev=771016&r1=771015&r2=771016&view=diff ============================================================================== --- ofbiz/trunk/framework/common/src/org/ofbiz/common/email/NotificationServices.java (original) +++ ofbiz/trunk/framework/common/src/org/ofbiz/common/email/NotificationServices.java Sun May 3 02:16:13 2009 @@ -128,7 +128,7 @@ if (body == null) { // prepare the body of the notification email - Map bodyResult = prepareNotification(ctx, context); + Map<String, Object> bodyResult = prepareNotification(ctx, context); // ensure the body was generated successfully if (bodyResult.get(ModelService.RESPONSE_MESSAGE).equals(ModelService.RESPOND_SUCCESS)) { |
Free forum by Nabble | Edit this page |