From 7fcd2cba58ac55e84cf182c7898bca087aaa7abc Mon Sep 17 00:00:00 2001 From: Heng Sin Low Date: Sun, 23 Dec 2012 15:08:57 +0800 Subject: [PATCH] IDEMPIERE-455 Discover and fix FindBugs problems / Eclipse warning - Fixed generic type warning. Drop classes that's not used anywhere. --- .../src/org/compiere/db/LDAP.java | 5 +- .../src/org/compiere/model/VO.java | 212 ------------------ .../src/org/compiere/util/ASyncWorker.java | 106 --------- .../org/compiere/apps/ASyncProcessBase.java | 98 -------- .../hazelcast/service/TopicImpl.java | 8 +- 5 files changed, 7 insertions(+), 422 deletions(-) delete mode 100644 org.adempiere.base/src/org/compiere/model/VO.java delete mode 100644 org.adempiere.base/src/org/compiere/util/ASyncWorker.java delete mode 100644 org.adempiere.ui.swing/src/org/compiere/apps/ASyncProcessBase.java diff --git a/org.adempiere.base/src/org/compiere/db/LDAP.java b/org.adempiere.base/src/org/compiere/db/LDAP.java index 47dd6816d4..af76389498 100644 --- a/org.adempiere.base/src/org/compiere/db/LDAP.java +++ b/org.adempiere.base/src/org/compiere/db/LDAP.java @@ -66,7 +66,7 @@ public class LDAP // DirContext ctx = new InitialDirContext(env); // Test - Get the attributes - Attributes answer = ctx.getAttributes(""); + ctx.getAttributes(""); // Print the answer //if (false) @@ -156,7 +156,8 @@ public class LDAP * Print Attributes to System.out * @param attrs */ - private static void dump (Attributes attrs) + @SuppressWarnings("unused") + private static void dump (Attributes attrs) { if (attrs == null) { diff --git a/org.adempiere.base/src/org/compiere/model/VO.java b/org.adempiere.base/src/org/compiere/model/VO.java deleted file mode 100644 index 4cbdfb0c73..0000000000 --- a/org.adempiere.base/src/org/compiere/model/VO.java +++ /dev/null @@ -1,212 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.model; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Map; -import java.util.Set; - -/** - * Value Object - * - * @author Jorg Janke - * @version $Id: VO.java,v 1.3 2006/07/30 00:58:04 jjanke Exp $ - */ -public class VO - implements Map, Serializable -{ - /** - * - */ - private static final long serialVersionUID = -8437638669140712217L; - - /** - * Constructor - */ - public VO () - { - super (); - } // VO - -// private static final long serialVersionUID = 8683452581122892189L; - - /** Keys */ - private ArrayList m_keys = new ArrayList(); - /** Values */ - private ArrayList m_values = new ArrayList(); - - /** - * Get Size - * @return size - */ - public int size () - { - return m_keys.size(); - } // size - - /** - * Is Empty - * @return true if empty - */ - public boolean isEmpty () - { - return m_keys.isEmpty(); - } // isEmpty - - /** - * Contains Key - * @param key key - * @return true if contains - */ - public boolean containsKey (Object key) - { - if (key == null) - return false; - return m_keys.contains(key); - } // containsKey - - /** - * Contains Value - * @param value value - * @return true if contains value - */ - public boolean containsValue (Object value) - { - if (value == null) - return false; - return m_values.contains(value); - } // containsValue - - /** - * Get Value with Key - * @param key key - * @return value or null - */ - public synchronized Object get (Object key) - { - if (key == null) - return null; - int index = m_keys.indexOf(key); - if (index != -1) - return m_values.get(index); - return null; - } // get - - /** - * Put key/value - * @param key key - * @param value value - * @return previous value or null - */ - public synchronized Object put (Object key, Object value) - { - if (key == null) - return null; - if (value == null) - return remove(key); - // - String stringKey = key.toString(); - String stringValue = value.toString(); - int index = m_keys.indexOf(key); - if (index != -1) - return m_values.set (index, stringValue); - m_values.add(stringKey); - m_values.add(stringValue); - return null; - } // put - - /** - * Remove - * @param key key - * @return previous value or null - */ - public synchronized Object remove (Object key) - { - if (key == null) - return null; - int index = m_keys.indexOf(key); - Object old = null; - if (index != -1) - { - old = m_values.get(index); - m_keys.remove(index); - m_values.remove(index); - } - return old; - } // remove - - /** - * Put All - * @param t map - */ - public void putAll (Map t) - { - Iterator it = t.keySet().iterator(); - while (it.hasNext()) - { - Object key = it.next(); - Object value = t.get(key); - put(key, value); - } - } // putAll - - /** - * Clear keys/values - */ - public void clear () - { - m_keys.clear(); - m_values.clear(); - } // clear - - /** - * Get Key Set - * @return key set - */ - public Set keySet () - { - HashSet set = new HashSet(m_keys); - return set; - } // keySet - - /** - * Get Values - * @return values as collection - */ - public Collection values () - { - return m_values; - } // values - - /** - * Get Values Set - * @return values set - */ - public Set entrySet () - { - HashSet set = new HashSet(m_values); - return set; - } // entrySet - - - - -} // VO diff --git a/org.adempiere.base/src/org/compiere/util/ASyncWorker.java b/org.adempiere.base/src/org/compiere/util/ASyncWorker.java deleted file mode 100644 index 754ba249af..0000000000 --- a/org.adempiere.base/src/org/compiere/util/ASyncWorker.java +++ /dev/null @@ -1,106 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.util; - -import java.util.logging.Level; - -import javax.swing.SwingUtilities; - -import org.compiere.process.ProcessInfo; - -/** - * ASync Worker for starting methods in classes implementing ASyncProcess - * - * @author Jorg Janke - * @version $Id: ASyncWorker.java,v 1.2 2006/07/30 00:51:05 jjanke Exp $ - */ -public class ASyncWorker extends Thread -{ - /** - * Execute method Synchronously - * @param parent parent - * @param pi process info - * @return result - */ - public static ProcessInfo executeSync (ASyncProcess parent, ProcessInfo pi) - { - ASyncWorker worker = new ASyncWorker (parent, pi); - worker.start(); - try - { - worker.join(); - } - catch (InterruptedException e) - { - log.log(Level.SEVERE, "executeSync", e); - } - return worker.getResult(); - } // executeSync - - /** Logger */ - private static CLogger log = CLogger.getCLogger(ASyncWorker.class); - - /** - * Constructor - * @param parent Parent Process - * @param pi process info - */ - public ASyncWorker (ASyncProcess parent, ProcessInfo pi) - { - m_parent = parent; - m_pi = pi; - } // ASuncWorker - - private ProcessInfo m_pi; - private ASyncProcess m_parent; - - /** - * The Worker Method - */ - public void run() - { - SwingUtilities.invokeLater(new Runnable() - { - public void run() - { - m_parent.lockUI(m_pi); - } - }); - - // - m_parent.executeASync(m_pi); - // - - SwingUtilities.invokeLater(new Runnable() - { - public void run() - { - m_parent.unlockUI (m_pi); - } - }); - } // run - - /** - * Get Result (usually not used as result is returned via unlockUI - * @return result - */ - public ProcessInfo getResult() - { - return m_pi; - } // getResult - -} // ASyncWorker diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/ASyncProcessBase.java b/org.adempiere.ui.swing/src/org/compiere/apps/ASyncProcessBase.java deleted file mode 100644 index 7166436002..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/ASyncProcessBase.java +++ /dev/null @@ -1,98 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.apps; - -import org.compiere.process.ProcessInfo; -import org.compiere.util.ASyncProcess; -import org.compiere.util.ASyncWorker; -import org.compiere.util.Env; -import org.compiere.util.Msg; -import org.compiere.util.Splash; - -/** - * ASync Process Base Class - * - * @author Jorg Janke - * @version $Id: ASyncProcessBase.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $ - */ -public abstract class ASyncProcessBase implements ASyncProcess -{ - /** - * Constructor - * @param pi process info - */ - public ASyncProcessBase(ProcessInfo pi) - { - m_pi = pi; - } // ASyncProcessBase - - private ProcessInfo m_pi; - private boolean m_isLocked = false; - private Splash m_splash; - - /** - * Start ASync Worker - */ - void start() - { - if (isUILocked()) // don't start twice - return; - ASyncWorker worker = new ASyncWorker (this, m_pi); - worker.start(); // calls lockUI, executeASync, unlockUI - } // start - - /** - * Lock User Interface. - * Called from the Worker before processing - * @param pi process info - */ - public void lockUI (ProcessInfo pi) - { - m_isLocked = true; - m_splash = new Splash (Msg.getMsg(Env.getCtx(), "Processing")); - m_splash.toFront(); - } // lockUI - - /** - * Unlock User Interface. - * Called from the Worker when processing is done - * @param pi process info - */ - public void unlockUI (ProcessInfo pi) - { - m_isLocked = false; - m_splash.dispose(); - m_splash = null; - } // unlockUI - - /** - * Is the UI locked (Internal method) - * @return true, if UI is locked - */ - public boolean isUILocked() - { - return m_isLocked; - } // isLoacked - - /** - * Method to be executed async - * Called from the Worker - * @param pi process info - */ - public abstract void executeASync (ProcessInfo pi); - -} // ASyncProcessBase diff --git a/org.idempiere.hazelcast.service/src/org/idempiere/hazelcast/service/TopicImpl.java b/org.idempiere.hazelcast.service/src/org/idempiere/hazelcast/service/TopicImpl.java index fa6347121b..8f77d59794 100644 --- a/org.idempiere.hazelcast.service/src/org/idempiere/hazelcast/service/TopicImpl.java +++ b/org.idempiere.hazelcast.service/src/org/idempiere/hazelcast/service/TopicImpl.java @@ -71,15 +71,15 @@ public class TopicImpl implements ITopic { topic.publish(message); } - class TopicSubscriberAdapter implements MessageListener { - protected ITopicSubscriber subscriber; + class TopicSubscriberAdapter implements MessageListener { + protected ITopicSubscriber subscriber; - protected TopicSubscriberAdapter(ITopicSubscriber subscriber) { + protected TopicSubscriberAdapter(ITopicSubscriber subscriber) { this.subscriber = subscriber; } @Override - public void onMessage(Message message) { + public void onMessage(Message message) { subscriber.onMessage(message.getMessageObject()); } }