jurt/com/sun/star/comp/servicemanager/ServiceManager.java | 34 +++++----- jurt/com/sun/star/lib/connections/pipe/PipeConnection.java | 14 ---- jurt/com/sun/star/lib/connections/socket/SocketConnection.java | 13 --- 3 files changed, 23 insertions(+), 38 deletions(-)
New commits: commit dfb1d56b71b3e5891635d887043a415b8b0295d6 Author: rbuj <robert....@gmail.com> Date: Sat Jul 26 12:16:50 2014 +0200 jurt: Enhanced For-Loops Change-Id: I74a9b8afd1e4a1364c61c7b85277909f38611f6d Reviewed-on: https://gerrit.libreoffice.org/10553 Reviewed-by: David Tardon <dtar...@redhat.com> Tested-by: David Tardon <dtar...@redhat.com> diff --git a/jurt/com/sun/star/comp/servicemanager/ServiceManager.java b/jurt/com/sun/star/comp/servicemanager/ServiceManager.java index 8def4ac..4a4a4e6 100644 --- a/jurt/com/sun/star/comp/servicemanager/ServiceManager.java +++ b/jurt/com/sun/star/comp/servicemanager/ServiceManager.java @@ -296,10 +296,7 @@ public class ServiceManager implements XMultiServiceFactory, throws com.sun.star.uno.RuntimeException { if (eventListener != null) { - java.util.Iterator<XEventListener> enumer = eventListener.iterator(); - - while (enumer.hasNext()) { - XEventListener listener = enumer.next(); + for (XEventListener listener : eventListener) { listener.disposing(new com.sun.star.lang.EventObject(this)); } eventListener.clear(); @@ -468,16 +465,17 @@ public class ServiceManager implements XMultiServiceFactory, String[] serviceNames = xServiceInfo.getSupportedServiceNames(); - for ( int i=0; i<serviceNames.length; i++ ) { - if ( factoriesByServiceNames.containsKey( serviceNames[i] ) ) { - ArrayList<Object> vec = factoriesByServiceNames.get(serviceNames[i]); - - if ( !vec.remove(object) ) + for (String serviceName : serviceNames) { + if (factoriesByServiceNames.containsKey(serviceName)) { + ArrayList<Object> vec = factoriesByServiceNames.get(serviceName); + if (!vec.remove(object)) { System.err.println("The implementation " + xServiceInfo.getImplementationName() + - " is not registered for the service " + serviceNames[i] + " - ignoring!"); - - if ( vec.isEmpty() ) // remove the vector if no implementations aviable for the service - factoriesByServiceNames.remove( serviceNames[i] ); + " is not registered for the service " + serviceName + " - ignoring!"); + } + // remove the vector if no implementations aviable for the service + if (vec.isEmpty()) { + factoriesByServiceNames.remove(serviceName); + } } } } @@ -565,12 +563,14 @@ public class ServiceManager implements XMultiServiceFactory, public boolean supportsService( String serviceName ) throws com.sun.star.uno.RuntimeException { - for (int i=0; i<supportedServiceNames.length; i++) - if (supportedServiceNames[i].equals( serviceName )) return true; + for (String supportedServiceName : supportedServiceNames) { + if (supportedServiceName.equals(serviceName)) { + return true; + } + } return getImplementationName().equals(serviceName); - - } + } /** * Supplies list of all supported services. diff --git a/jurt/com/sun/star/lib/connections/pipe/PipeConnection.java b/jurt/com/sun/star/lib/connections/pipe/PipeConnection.java index 62c4e23..c57d236 100644 --- a/jurt/com/sun/star/lib/connections/pipe/PipeConnection.java +++ b/jurt/com/sun/star/lib/connections/pipe/PipeConnection.java @@ -19,7 +19,6 @@ package com.sun.star.lib.connections.pipe; import java.io.IOException; import java.util.ArrayList; -import java.util.Iterator; import java.util.StringTokenizer; import com.sun.star.connection.XConnection; @@ -103,25 +102,19 @@ public class PipeConnection implements XConnection, XConnectionBroadcaster { } private void notifyListeners_open() { - Iterator<XStreamListener> elements = _aListeners.iterator(); - while(elements.hasNext()) { - XStreamListener xStreamListener = elements.next(); + for (XStreamListener xStreamListener : _aListeners) { xStreamListener.started(); } } private void notifyListeners_close() { - Iterator<XStreamListener> elements = _aListeners.iterator(); - while(elements.hasNext()) { - XStreamListener xStreamListener = elements.next(); + for (XStreamListener xStreamListener : _aListeners) { xStreamListener.closed(); } } private void notifyListeners_error(com.sun.star.uno.Exception exception) { - Iterator<XStreamListener> elements = _aListeners.iterator(); - while(elements.hasNext()) { - XStreamListener xStreamListener = elements.next(); + for (XStreamListener xStreamListener : _aListeners) { xStreamListener.error(exception); } } @@ -215,4 +208,3 @@ public class PipeConnection implements XConnection, XConnectionBroadcaster { } } - diff --git a/jurt/com/sun/star/lib/connections/socket/SocketConnection.java b/jurt/com/sun/star/lib/connections/socket/SocketConnection.java index e849d8b..f7ad911 100644 --- a/jurt/com/sun/star/lib/connections/socket/SocketConnection.java +++ b/jurt/com/sun/star/lib/connections/socket/SocketConnection.java @@ -25,7 +25,6 @@ import java.io.InputStream; import java.io.OutputStream; import java.net.Socket; import java.util.ArrayList; -import java.util.Iterator; import com.sun.star.connection.XConnection; import com.sun.star.connection.XConnectionBroadcaster; @@ -89,25 +88,19 @@ public class SocketConnection implements XConnection, XConnectionBroadcaster { } private void notifyListeners_open() { - Iterator<XStreamListener> elements = _listeners.iterator(); - while(elements.hasNext()) { - XStreamListener xStreamListener = elements.next(); + for (XStreamListener xStreamListener : _listeners) { xStreamListener.started(); } } private void notifyListeners_close() { - Iterator<XStreamListener> elements = _listeners.iterator(); - while(elements.hasNext()) { - XStreamListener xStreamListener = elements.next(); + for (XStreamListener xStreamListener : _listeners) { xStreamListener.closed(); } } private void notifyListeners_error(com.sun.star.uno.Exception exception) { - Iterator<XStreamListener> elements = _listeners.iterator(); - while(elements.hasNext()) { - XStreamListener xStreamListener = elements.next(); + for (XStreamListener xStreamListener : _listeners) { xStreamListener.error(exception); } } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits