From eb0f0bfb16e5bcecc5c046fca8ccc899e11cc2f0 Mon Sep 17 00:00:00 2001 From: Adam Heath Date: Mon, 11 Jan 2010 22:21:12 +0000 Subject: [PATCH] Fix several generics warnings. git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@898090 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/ofbiz/base/util/cache/CacheLineTable.java | 5 +++-- framework/birt/src/org/ofbiz/birt/BirtWorker.java | 7 ++++--- .../src/org/ofbiz/birt/container/BirtContainer.java | 3 ++- .../src/org/ofbiz/birt/email/BirtEmailServices.java | 13 +++++++------ .../service/OFBizBirtViewerReportService.java | 3 ++- .../org/ofbiz/birt/webapp/view/BirtViewHandler.java | 5 +++-- .../common/src/org/ofbiz/common/FindServices.java | 12 +++++------- .../org/ofbiz/service/engine/SOAPClientEngine.java | 3 ++- .../org/ofbiz/service/test/ServiceSOAPTests.java | 3 ++- framework/sql/src/org/ofbiz/sql/test/SQLTest.java | 2 +- .../ofbiz/testtools/seleniumxml/SeleniumXml.java | 8 ++++---- .../org/ofbiz/webapp/event/SOAPEventHandler.java | 3 ++- 12 files changed, 37 insertions(+), 30 deletions(-) diff --git a/framework/base/src/org/ofbiz/base/util/cache/CacheLineTable.java b/framework/base/src/org/ofbiz/base/util/cache/CacheLineTable.java index 8e4da9b9a5..a97cb5aeef 100644 --- a/framework/base/src/org/ofbiz/base/util/cache/CacheLineTable.java +++ b/framework/base/src/org/ofbiz/base/util/cache/CacheLineTable.java @@ -33,6 +33,7 @@ import javolution.util.FastMap; import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.ObjectType; +import org.ofbiz.base.util.UtilGenerics; import org.ofbiz.base.util.UtilValidate; import org.ofbiz.base.util.collections.LRUMap; import org.ofbiz.base.util.collections.ReadOnlyMapEntry; @@ -224,11 +225,11 @@ public class CacheLineTable implements Serializable { jdbm.helper.FastIterator iter = fileTable.keys(); Object key = iter.next(); while (key != null) { - CacheLine value = (CacheLine) fileTable.get(key); + CacheLine value = UtilGenerics.cast(fileTable.get(key)); if (key instanceof ObjectType.NullObject) { key = null; } - list.add(new ReadOnlyMapEntry>((K) key, value)); + list.add(new ReadOnlyMapEntry>(UtilGenerics.cast(key), value)); key = iter.next(); } } catch (IOException e) { diff --git a/framework/birt/src/org/ofbiz/birt/BirtWorker.java b/framework/birt/src/org/ofbiz/birt/BirtWorker.java index 77670c2bd5..756796ec29 100644 --- a/framework/birt/src/org/ofbiz/birt/BirtWorker.java +++ b/framework/birt/src/org/ofbiz/birt/BirtWorker.java @@ -36,6 +36,7 @@ import org.eclipse.birt.report.engine.api.PDFRenderOption; import org.eclipse.birt.report.engine.api.RenderOption; import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.GeneralException; +import org.ofbiz.base.util.UtilGenerics; import org.ofbiz.birt.container.BirtContainer; import org.ofbiz.entity.Delegator; import org.ofbiz.entity.jdbc.ConnectionFactory; @@ -62,7 +63,7 @@ public class BirtWorker { * @throws GeneralException * @throws SQLException */ - public static void exportReport(IReportRunnable design, Map context, String contentType, OutputStream output) + public static void exportReport(IReportRunnable design, Map context, String contentType, OutputStream output) throws EngineException, GeneralException, SQLException { Locale birtLocale = (Locale)context.get(BIRT_LOCALE); @@ -95,7 +96,7 @@ public class BirtWorker { } // set parameters if exists - Map parameters = (Map)context.get(BirtWorker.BIRT_PARAMETERS); + Map parameters = UtilGenerics.cast(context.get(BirtWorker.BIRT_PARAMETERS)); if (parameters != null) { Debug.logInfo("Set birt parameters:" + parameters, module); task.setParameterValues(parameters); @@ -126,7 +127,7 @@ public class BirtWorker { } else if (options.getOutputFormat().equalsIgnoreCase(RenderOption.OUTPUT_FORMAT_PDF)) { // set pdf render options PDFRenderOption pdfOptions = new PDFRenderOption(options); - pdfOptions.setOption(IPDFRenderOption.PAGE_OVERFLOW, new Boolean(true) ); + pdfOptions.setOption(IPDFRenderOption.PAGE_OVERFLOW, Boolean.TRUE ); } else if (options.getOutputFormat().equalsIgnoreCase("xls")) { // set excel render options EXCELRenderOption excelOptions = new EXCELRenderOption(options); diff --git a/framework/birt/src/org/ofbiz/birt/container/BirtContainer.java b/framework/birt/src/org/ofbiz/birt/container/BirtContainer.java index 87ac355521..e33273b0a6 100644 --- a/framework/birt/src/org/ofbiz/birt/container/BirtContainer.java +++ b/framework/birt/src/org/ofbiz/birt/container/BirtContainer.java @@ -38,6 +38,7 @@ import org.ofbiz.base.container.ContainerConfig; import org.ofbiz.base.container.ContainerException; import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.FileUtil; +import org.ofbiz.base.util.UtilGenerics; import org.ofbiz.base.util.UtilObject; import org.ofbiz.base.util.UtilProperties; import org.ofbiz.entity.Delegator; @@ -93,7 +94,7 @@ public class BirtContainer implements Container { osgiConfig.put("osgi.configuration.area", new File(System.getProperty("ofbiz.home"), "runtime" + File.separator + "tempfiles").getPath()); config.setOSGiConfig(osgiConfig); - HashMap context = config.getAppContext(); + HashMap context = UtilGenerics.cast(config.getAppContext()); // set delegator, dispatcher and security objects to report diff --git a/framework/birt/src/org/ofbiz/birt/email/BirtEmailServices.java b/framework/birt/src/org/ofbiz/birt/email/BirtEmailServices.java index f857b6e16f..2dac5eb9f0 100644 --- a/framework/birt/src/org/ofbiz/birt/email/BirtEmailServices.java +++ b/framework/birt/src/org/ofbiz/birt/email/BirtEmailServices.java @@ -38,6 +38,7 @@ import org.eclipse.birt.report.engine.api.IReportEngine; import org.eclipse.birt.report.engine.api.IReportRunnable; import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.GeneralException; +import org.ofbiz.base.util.UtilGenerics; import org.ofbiz.base.util.UtilMisc; import org.ofbiz.base.util.UtilValidate; import org.ofbiz.base.util.collections.MapStack; @@ -75,9 +76,9 @@ public class BirtEmailServices { String birtReportLocation = (String) serviceContext.remove("birtReportLocation"); String attachmentName = (String) serviceContext.remove("attachmentName"); Locale locale = (Locale) serviceContext.get("locale"); - Map bodyParameters = (Map) serviceContext.remove("bodyParameters"); + Map bodyParameters = UtilGenerics.cast(serviceContext.remove("bodyParameters")); Locale birtLocale = (Locale) serviceContext.remove(BirtWorker.BIRT_LOCALE); - Map birtParameters = (Map) serviceContext.remove(BirtWorker.BIRT_PARAMETERS); + Map birtParameters = UtilGenerics.cast(serviceContext.remove(BirtWorker.BIRT_PARAMETERS)); String birtImageDirectory = (String) serviceContext.remove(BirtWorker.BIRT_IMAGE_DIRECTORY); String birtContentType = (String) serviceContext.remove(BirtWorker.BIRT_CONTENT_TYPE); if (bodyParameters == null) { @@ -99,7 +100,7 @@ public class BirtEmailServices { } StringWriter bodyWriter = new StringWriter(); - MapStack screenContext = MapStack.create(); + MapStack screenContext = MapStack.create(); screenContext.put("locale", locale); ScreenRenderer screens = new ScreenRenderer(bodyWriter, screenContext, htmlScreenRenderer); screens.populateContextForService(ctx, bodyParameters); @@ -137,7 +138,7 @@ public class BirtEmailServices { // create the output stream for the generation ByteArrayOutputStream baos = new ByteArrayOutputStream(); - Map birtContext = FastMap.newInstance(); + Map birtContext = FastMap.newInstance(); if (birtLocale == null) { birtLocale = locale; } @@ -161,7 +162,7 @@ public class BirtEmailServices { baos.close(); // store in the list of maps for sendmail.... - List bodyParts = FastList.newInstance(); + List> bodyParts = FastList.newInstance(); if (bodyText != null) { bodyText = FlexibleStringExpander.expandString(bodyText, screenContext, locale); bodyParts.add(UtilMisc.toMap("content", bodyText, "type", "text/html")); @@ -226,7 +227,7 @@ public class BirtEmailServices { if (Debug.verboseOn()) Debug.logVerbose("sendMailFromScreen sendMail context: " + serviceContext, module); - Map result = ServiceUtil.returnSuccess(); + Map result = ServiceUtil.returnSuccess(); try { if (isMultiPart) { dispatcher.runSync("sendMailMultiPart", serviceContext); diff --git a/framework/birt/src/org/ofbiz/birt/report/service/OFBizBirtViewerReportService.java b/framework/birt/src/org/ofbiz/birt/report/service/OFBizBirtViewerReportService.java index d86a863f02..07388aaa28 100644 --- a/framework/birt/src/org/ofbiz/birt/report/service/OFBizBirtViewerReportService.java +++ b/framework/birt/src/org/ofbiz/birt/report/service/OFBizBirtViewerReportService.java @@ -49,6 +49,7 @@ import org.eclipse.birt.report.utility.BirtUtility; import org.eclipse.birt.report.utility.DataUtil; import org.eclipse.birt.report.utility.ParameterAccessor; import org.ofbiz.base.util.Debug; +import org.ofbiz.base.util.UtilGenerics; import org.ofbiz.birt.container.BirtContainer; import org.ofbiz.entity.Delegator; import org.ofbiz.entity.GenericEntityException; @@ -228,7 +229,7 @@ public class OFBizBirtViewerReportService extends BirtViewerReportService { runTask.close( ); // check for non-fatal errors - List errors = (List) runTask.getErrors( ); + List errors = UtilGenerics.cast(runTask.getErrors( )); if ( !errors.isEmpty( ) ) { return errors; diff --git a/framework/birt/src/org/ofbiz/birt/webapp/view/BirtViewHandler.java b/framework/birt/src/org/ofbiz/birt/webapp/view/BirtViewHandler.java index 754fcdd3a0..3e72d4864c 100644 --- a/framework/birt/src/org/ofbiz/birt/webapp/view/BirtViewHandler.java +++ b/framework/birt/src/org/ofbiz/birt/webapp/view/BirtViewHandler.java @@ -36,6 +36,7 @@ import org.eclipse.birt.report.engine.api.IReportEngine; import org.eclipse.birt.report.engine.api.IReportRunnable; import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.GeneralException; +import org.ofbiz.base.util.UtilGenerics; import org.ofbiz.base.util.UtilHttp; import org.ofbiz.base.util.UtilProperties; import org.ofbiz.birt.BirtWorker; @@ -84,9 +85,9 @@ public class BirtViewHandler implements ViewHandler { design = engine.openReportDesign(servletContext.getRealPath(page)); } - Map context = FastMap.newInstance(); + Map context = FastMap.newInstance(); // set parameters from request - Map parameters = (Map)request.getAttribute(BirtWorker.BIRT_PARAMETERS); + Map parameters = UtilGenerics.cast(request.getAttribute(BirtWorker.BIRT_PARAMETERS)); if (parameters != null) { context.put(BirtWorker.BIRT_PARAMETERS, parameters); } diff --git a/framework/common/src/org/ofbiz/common/FindServices.java b/framework/common/src/org/ofbiz/common/FindServices.java index 91d976fe8f..856f355a96 100644 --- a/framework/common/src/org/ofbiz/common/FindServices.java +++ b/framework/common/src/org/ofbiz/common/FindServices.java @@ -66,11 +66,10 @@ public class FindServices { public static final String module = FindServices.class.getName(); - public static Map entityOperators; + public static Map> entityOperators; static { entityOperators = FastMap.newInstance(); - entityOperators.put("and", EntityOperator.AND); entityOperators.put("between", EntityOperator.BETWEEN); entityOperators.put("equals", EntityOperator.EQUALS); entityOperators.put("greaterThan", EntityOperator.GREATER_THAN); @@ -81,7 +80,6 @@ public class FindServices { entityOperators.put("like", EntityOperator.LIKE); entityOperators.put("not", EntityOperator.NOT); entityOperators.put("notEqual", EntityOperator.NOT_EQUAL); - entityOperators.put("or", EntityOperator.OR); } public FindServices() {} @@ -214,7 +212,7 @@ public class FindServices { public static List createCondition(ModelEntity modelEntity, Map>> normalizedFields, Map queryStringMap, Map> origValueMap, Delegator delegator, Map context) { Map> subMap = null; Map subMap2 = null; - EntityOperator fieldOp = null; + EntityComparisonOperator 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; @@ -298,12 +296,12 @@ public class FindServices { } if (ignoreCase != null && ignoreCase.equals("Y") && "java.lang.String".equals(fieldObject.getClass().getName())) { - cond = EntityCondition.makeCondition(EntityFunction.UPPER_FIELD(fieldName), (EntityComparisonOperator) fieldOp, EntityFunction.UPPER(((String)fieldValue).toUpperCase())); + cond = EntityCondition.makeCondition(EntityFunction.UPPER_FIELD(fieldName), fieldOp, EntityFunction.UPPER(((String)fieldValue).toUpperCase())); } else { if (fieldObject.equals(GenericEntity.NULL_FIELD.toString())) { fieldObject = null; } - cond = EntityCondition.makeCondition(fieldName, (EntityComparisonOperator) fieldOp, fieldObject); + cond = EntityCondition.makeCondition(fieldName, fieldOp, fieldObject); } if (EntityOperator.NOT_EQUAL.equals(fieldOp) && fieldObject != null) { @@ -357,7 +355,7 @@ public class FindServices { } // String rhs = fieldValue.toString(); fieldObject = modelEntity.convertFieldValue(modelField, fieldValue, delegator, context); - cond = EntityCondition.makeCondition(fieldName, (EntityComparisonOperator) fieldOp, fieldObject); + cond = EntityCondition.makeCondition(fieldName, fieldOp, fieldObject); tmpList.add(cond); // add to queryStringMap diff --git a/framework/service/src/org/ofbiz/service/engine/SOAPClientEngine.java b/framework/service/src/org/ofbiz/service/engine/SOAPClientEngine.java index e8c9890511..22e4b0c376 100644 --- a/framework/service/src/org/ofbiz/service/engine/SOAPClientEngine.java +++ b/framework/service/src/org/ofbiz/service/engine/SOAPClientEngine.java @@ -37,6 +37,7 @@ import org.apache.axis2.addressing.EndpointReference; import org.apache.axis2.client.Options; import org.apache.axis2.client.ServiceClient; import org.ofbiz.base.util.Debug; +import org.ofbiz.base.util.UtilGenerics; import org.ofbiz.base.util.UtilValidate; import org.ofbiz.entity.Delegator; import org.ofbiz.entity.serialize.XmlSerializer; @@ -135,7 +136,7 @@ public final class SOAPClientEngine extends GenericAsyncEngine { OMElement payload = factory.createOMElement(serviceName); payload.addChild(parameterSer.getFirstElement()); OMElement respOMElement = client.sendReceive(payload); - results = (Map) XmlSerializer.deserialize(respOMElement.toString(), delegator); + results = UtilGenerics.cast(XmlSerializer.deserialize(respOMElement.toString(), delegator)); } catch (Exception e) { Debug.logError(e, module); } diff --git a/framework/service/src/org/ofbiz/service/test/ServiceSOAPTests.java b/framework/service/src/org/ofbiz/service/test/ServiceSOAPTests.java index 8b3655fbee..7f20adb42f 100644 --- a/framework/service/src/org/ofbiz/service/test/ServiceSOAPTests.java +++ b/framework/service/src/org/ofbiz/service/test/ServiceSOAPTests.java @@ -6,6 +6,7 @@ import java.util.Map; import javolution.util.FastMap; import org.ofbiz.base.util.UtilDateTime; +import org.ofbiz.base.util.UtilGenerics; import org.ofbiz.entity.GenericValue; import org.ofbiz.service.testtools.OFBizTestCase; @@ -35,7 +36,7 @@ public class ServiceSOAPTests extends OFBizTestCase { testing.put("createdStamp", UtilDateTime.nowTimestamp()); serviceContext.put("testing", testing); Map results = dispatcher.runSync("testSoap", serviceContext); - List testingNodes = (List) results.get("testingNodes"); + List testingNodes = UtilGenerics.cast(results.get("testingNodes")); assertNotNull(testingNodes); } } diff --git a/framework/sql/src/org/ofbiz/sql/test/SQLTest.java b/framework/sql/src/org/ofbiz/sql/test/SQLTest.java index 71d42af3f8..c8be3b38ea 100644 --- a/framework/sql/src/org/ofbiz/sql/test/SQLTest.java +++ b/framework/sql/src/org/ofbiz/sql/test/SQLTest.java @@ -65,7 +65,7 @@ public class SQLTest extends GenericTestCaseBase { assertTrue("has first field all", fieldAllIt.hasNext()); FieldAll fieldAll = fieldAllIt.next(); assertEquals("first fieldAll.alias", "a", fieldAll.getAlias()); - assertEquals("no excludes", set(), set(fieldAll)); + assertEquals("no excludes", GenericTestCaseBase.set(), set(fieldAll)); assertTrue("has second field all", fieldAllIt.hasNext()); fieldAll = fieldAllIt.next(); diff --git a/framework/testtools/src/org/ofbiz/testtools/seleniumxml/SeleniumXml.java b/framework/testtools/src/org/ofbiz/testtools/seleniumxml/SeleniumXml.java index 720df81ce8..d97fd5bf9c 100644 --- a/framework/testtools/src/org/ofbiz/testtools/seleniumxml/SeleniumXml.java +++ b/framework/testtools/src/org/ofbiz/testtools/seleniumxml/SeleniumXml.java @@ -226,7 +226,7 @@ public class SeleniumXml { public void runCommands() throws TestCaseException { Element root = this.doc.getRootElement(); - List nodes = root.getChildren(); + List nodes = UtilGenerics.cast(root.getChildren()); runCommands(nodes); } @@ -502,11 +502,11 @@ public class SeleniumXml { public void ifCmd(Element elem) throws TestCaseException { String isRun = replaceParam(elem.getAttributeValue("condition")); if (isRun != null && !isRun.equals("") && Boolean.valueOf(isRun)) { - List children = elem.getChildren(); + List children = UtilGenerics.cast(elem.getChildren()); this.runCommands(children); }else{ Element child = elem.getChild("else"); - List children = child.getChildren(); + List children = UtilGenerics.cast(child.getChildren()); this.runCommands(children); } } @@ -514,7 +514,7 @@ public class SeleniumXml { public void partialRunDependency(Element elem) throws TestCaseException { String isRun = replaceParam(elem.getAttributeValue("isRun")); if (isRun != null && Boolean.valueOf(isRun)) { - List children = elem.getChildren(); + List children = UtilGenerics.cast(elem.getChildren()); this.runCommands(children); } } diff --git a/framework/webapp/src/org/ofbiz/webapp/event/SOAPEventHandler.java b/framework/webapp/src/org/ofbiz/webapp/event/SOAPEventHandler.java index a276b11bdd..1a228f2016 100644 --- a/framework/webapp/src/org/ofbiz/webapp/event/SOAPEventHandler.java +++ b/framework/webapp/src/org/ofbiz/webapp/event/SOAPEventHandler.java @@ -45,6 +45,7 @@ import org.apache.axiom.soap.SOAPEnvelope; import org.apache.axiom.soap.SOAPFactory; import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder; import org.ofbiz.base.util.Debug; +import org.ofbiz.base.util.UtilGenerics; import org.ofbiz.base.util.UtilXml; import org.ofbiz.entity.GenericDelegator; import org.ofbiz.entity.serialize.XmlSerializer; @@ -175,7 +176,7 @@ public class SOAPEventHandler implements EventHandler { if (serviceObj instanceof OMElement) { OMElement serviceElement = (OMElement) serviceObj; String serviceName = serviceElement.getLocalName(); - Map parameters = (Map) XmlSerializer.deserialize(serviceElement.toString(), delegator); + Map parameters = UtilGenerics.cast(XmlSerializer.deserialize(serviceElement.toString(), delegator)); try { // verify the service is exported for remote execution and invoke it ModelService model = dispatcher.getDispatchContext().getModelService(serviceName);