diff options
author | rbuj <robert.buj@gmail.com> | 2014-07-26 12:16:50 +0200 |
---|---|---|
committer | David Tardon <dtardon@redhat.com> | 2014-07-27 08:36:25 +0000 |
commit | dfb1d56b71b3e5891635d887043a415b8b0295d6 (patch) | |
tree | 0c95e1e63b5dcf15984f89650b0f34a7f0850540 /jurt | |
parent | c2e2ac63b6db50b87efbd7ea6b2b5b99133b1cb7 (diff) |
jurt: Enhanced For-Loops
Change-Id: I74a9b8afd1e4a1364c61c7b85277909f38611f6d
Reviewed-on: https://gerrit.libreoffice.org/10553
Reviewed-by: David Tardon <dtardon@redhat.com>
Tested-by: David Tardon <dtardon@redhat.com>
Diffstat (limited to 'jurt')
3 files changed, 23 insertions, 38 deletions
diff --git a/jurt/com/sun/star/comp/servicemanager/ServiceManager.java b/jurt/com/sun/star/comp/servicemanager/ServiceManager.java index 8def4ac72eb3..4a4a4e6f05e6 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 62c4e231018e..c57d236943dd 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 e849d8b387e9..f7ad9119a4c1 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); } } |