import com.vaadin.server.ErrorEvent;
import com.vaadin.server.ErrorHandler;
-import java.util.stream.Stream;
/**
* <code>EventRouter</code> class implementing the inheritable event listening
// Find the correct method
final Method[] methods = target.getClass().getMethods();
-
- final Method method = Stream.of(methods)
- .filter(m -> methodName.equals(m.getName()))
- .findAny().orElseThrow(IllegalArgumentException::new);
+ Method method = null;
+ for (int i = 0; i < methods.length; i++) {
+ if (methods[i].getName().equals(methodName)) {
+ method = methods[i];
+ }
+ }
+ if (method == null) {
+ throw new IllegalArgumentException();
+ }
// Remove the listeners
if (listenerList != null) {
// Send the event to all listeners. The listeners themselves
// will filter out unwanted events.
final Object[] listeners = listenerList.toArray();
- for (Object listener : listeners) {
- ListenerMethod listenerMethod = (ListenerMethod) listener;
+ for (int i = 0; i < listeners.length; i++) {
+ ListenerMethod listenerMethod = (ListenerMethod) listeners[i];
if (null != errorHandler) {
try {
listenerMethod.receiveEvent(event);
import java.util.EventObject;
import java.util.logging.Level;
import java.util.logging.Logger;
-import java.util.stream.Stream;
/**
* <p>
private static Method findHighestMethod(Class<?> cls, String method,
Class<?>[] paramTypes) {
Class<?>[] ifaces = cls.getInterfaces();
- for (Class<?> iface : ifaces) {
- Method ifaceMethod = findHighestMethod(iface, method, paramTypes);
+ for (int i = 0; i < ifaces.length; i++) {
+ Method ifaceMethod = findHighestMethod(ifaces[i], method,
+ paramTypes);
if (ifaceMethod != null) {
return ifaceMethod;
}
return parentMethod;
}
}
-
- // we ignore parameter types for now - you need to add this
- return Stream.of(cls.getMethods())
- .filter(m -> method.equals(m.getName()))
- .findAny().orElse(null);
-
+ Method[] methods = cls.getMethods();
+ for (int i = 0; i < methods.length; i++) {
+ // we ignore parameter types for now - you need to add this
+ if (methods[i].getName().equals(method)) {
+ return methods[i];
+ }
+ }
+ return null;
}
/**
// Finds the correct method
final Method[] methods = target.getClass().getMethods();
Method method = null;
- for (Method method1 : methods) {
- if (method1.getName().equals(methodName)) {
- method = method1;
+ for (int i = 0; i < methods.length; i++) {
+ if (methods[i].getName().equals(methodName)) {
+ method = methods[i];
}
}
if (method == null) {
// Find the correct method
final Method[] methods = target.getClass().getMethods();
Method method = null;
- for (Method method1 : methods) {
- if (method1.getName().equals(methodName)) {
- method = method1;
+ for (int i = 0; i < methods.length; i++) {
+ if (methods[i].getName().equals(methodName)) {
+ method = methods[i];
}
}
if (method == null) {
// Finds the correct method
final Method[] methods = target.getClass().getMethods();
Method method = null;
- for (Method method1 : methods) {
- if (method1.getName().equals(methodName)) {
- method = method1;
+ for (int i = 0; i < methods.length; i++) {
+ if (methods[i].getName().equals(methodName)) {
+ method = methods[i];
}
}
if (method == null) {
}
} else if (isForm(component)) {
HasComponents form = (HasComponents) component;
- for (Component child : form) {
+ for (Iterator<Component> iterator = form.iterator(); iterator
+ .hasNext();) {
+ Component child = iterator.next();
errors = validateComponentRelativeSizes(child, errors, parent);
}
}
connectorTracker);
}
- if (null != transportType) // Collections
- switch (transportType) {
- case JsonConstants.VTYPE_LIST:
- return decodeList(targetType, restrictToInternalTypes,
+ // Collections
+ if (JsonConstants.VTYPE_LIST.equals(transportType)) {
+ return decodeList(targetType, restrictToInternalTypes,
(JsonArray) encodedJsonValue, connectorTracker);
- case JsonConstants.VTYPE_SET:
- return decodeSet(targetType, restrictToInternalTypes,
+ } else if (JsonConstants.VTYPE_SET.equals(transportType)) {
+ return decodeSet(targetType, restrictToInternalTypes,
(JsonArray) encodedJsonValue, connectorTracker);
- case JsonConstants.VTYPE_MAP:
- return decodeMap(targetType, restrictToInternalTypes,
+ } else if (JsonConstants.VTYPE_MAP.equals(transportType)) {
+ return decodeMap(targetType, restrictToInternalTypes,
encodedJsonValue, connectorTracker);
- default:
- break;
}
// Arrays
return connectorTracker.getConnector(encodedJsonValue.asString());
}
-
- if (null != transportType) // Legacy types
- switch (transportType) {
- case JsonConstants.VTYPE_STRING:
- return encodedJsonValue.asString();
- case JsonConstants.VTYPE_INTEGER:
- return (int) encodedJsonValue.asNumber();
- case JsonConstants.VTYPE_LONG:
- return (long) encodedJsonValue.asNumber();
- case JsonConstants.VTYPE_FLOAT:
- return (float) encodedJsonValue.asNumber();
- case JsonConstants.VTYPE_DOUBLE:
- return encodedJsonValue.asNumber();
- case JsonConstants.VTYPE_BOOLEAN:
- return encodedJsonValue.asBoolean();
- default:
- break;
+ // Legacy types
+
+ if (JsonConstants.VTYPE_STRING.equals(transportType)) {
+ return encodedJsonValue.asString();
+ } else if (JsonConstants.VTYPE_INTEGER.equals(transportType)) {
+ return (int) encodedJsonValue.asNumber();
+ } else if (JsonConstants.VTYPE_LONG.equals(transportType)) {
+ return (long) encodedJsonValue.asNumber();
+ } else if (JsonConstants.VTYPE_FLOAT.equals(transportType)) {
+ return (float) encodedJsonValue.asNumber();
+ } else if (JsonConstants.VTYPE_DOUBLE.equals(transportType)) {
+ return encodedJsonValue.asNumber();
+ } else if (JsonConstants.VTYPE_BOOLEAN.equals(transportType)) {
+ return encodedJsonValue.asBoolean();
}
throw new JsonException("Unknown type " + transportType);
if (directory.exists() && !directory.isHidden()) {
// Get the list of the files contained in the directory
String[] files = directory.list();
- for (String file : files) {
+ for (int i = 0; i < files.length; i++) {
// we are only interested in .gwt.xml files
- if (!file.endsWith(".gwt.xml")) {
+ if (!files[i].endsWith(".gwt.xml")) {
continue;
}
+
// remove the .gwt.xml extension
- String classname = file.substring(0, file.length() - 8);
+ String classname = files[i].substring(0, files[i].length() - 8);
String packageName = locationString
.substring(locationString.lastIndexOf('/') + 1);
classname = packageName + "." + classname;
+
if (!WidgetSetBuilder.isWidgetset(classname)) {
// Only return widgetsets and not GWT modules to avoid
// comparing modules and widgetsets
continue;
}
+
if (!widgetsets.containsKey(classname)) {
String packagePath = packageName.replaceAll("\\.", "/");
String basePath = location.getFile();
if (basePath.endsWith("/" + packagePath)) {
basePath = basePath.replaceAll("/" + packagePath + "$",
- "");
+ "");
} else if (basePath.endsWith("/" + packagePath + "/")) {
basePath = basePath.replaceAll("/" + packagePath + "/$",
- "");
+ "");
} else {
throw new IllegalStateException(
- "Error trying to find base path, location ("
- + location.getFile()
- + ") does not end in expected '/"
- + packagePath + "'");
+ "Error trying to find base path, location ("
+ + location.getFile()
+ + ") does not end in expected '/"
+ + packagePath + "'");
}
try {
URL url = new URL(location.getProtocol(),
- location.getHost(), location.getPort(),
- basePath);
+ location.getHost(), location.getPort(),
+ basePath);
widgetsets.put(classname, url);
} catch (MalformedURLException e) {
// should never happen as based on an existing URL,
.getValue("Vaadin-Widgetsets");
if (value != null) {
String[] widgetsetNames = value.split(",");
- for (String widgetsetName : widgetsetNames) {
- String widgetsetname = widgetsetName.trim();
+ for (int i = 0; i < widgetsetNames.length; i++) {
+ String widgetsetname = widgetsetNames[i].trim();
if (!widgetsetname.equals("")) {
widgetsets.put(widgetsetname, location);
}
.getValue("Vaadin-Stylesheets");
if (value != null) {
String[] stylesheets = value.split(",");
- for (String untrimmedStylesheet : stylesheets) {
- String stylesheet = untrimmedStylesheet.trim();
+ for (int i = 0; i < stylesheets.length; i++) {
+ String stylesheet = stylesheets[i].trim();
if (!stylesheet.equals("")) {
addonStyles.put(stylesheet, location);
}
debug("Classpath: " + classpath);
String[] split = classpath.split(pathSep);
- for (String classpathEntry : split) {
+ for (int i = 0; i < split.length; i++) {
+ String classpathEntry = split[i];
if (acceptClassPathEntry(classpathEntry)) {
locations.add(classpathEntry);
}
// add all directories recursively
File[] dirs = file.listFiles(DIRECTORIES_ONLY);
- for (File dir : dirs) {
+ for (int i = 0; i < dirs.length; i++) {
try {
// add the present directory
- if (!dir.isHidden() && !dir.getPath().contains(File.separator + ".")) {
- String key = dir.getCanonicalPath() + "/" + name + dir.getName();
- URL url = dir.getCanonicalFile().toURI().toURL();
+ if (!dirs[i].isHidden()
+ && !dirs[i].getPath().contains(File.separator + ".")) {
+ String key = dirs[i].getCanonicalPath() + "/" + name
+ + dirs[i].getName();
+ URL url = dirs[i].getCanonicalFile().toURI().toURL();
locations.put(key, url);
}
- }catch (Exception ioe) {
+ } catch (Exception ioe) {
return;
}
- include(name + dir.getName(), dir, locations);
+ include(name + dirs[i].getName(), dirs[i], locations);
}
}
}
String[] cssProperties = css.split(";");
- for (String cssProperty : cssProperties) {
- String[] keyValuePair = cssProperty.split(":");
+ for (int i = 0; i < cssProperties.length; i++) {
+ String[] keyValuePair = cssProperties[i].split(":");
String key = keyValuePair[0].trim();
if (key.equals("")) {
continue;
String symbol = value.replaceAll("[0-9\\.\\-]+", "");
if (!symbol.equals("")) {
value = value.substring(0, value.indexOf(symbol))
- .trim();
+ .trim();
}
float v = Float.parseFloat(value);
Unit unit = Unit.getUnitFromSymbol(symbol);
- switch (key) {
- case "top":
- topValue = v;
- topUnits = unit;
- break;
- case "right":
- rightValue = v;
- rightUnits = unit;
- break;
- case "bottom":
- bottomValue = v;
- bottomUnits = unit;
- break;
- case "left":
- leftValue = v;
- leftUnits = unit;
- break;
+ if (key.equals("top")) {
+ topValue = v;
+ topUnits = unit;
+ } else if (key.equals("right")) {
+ rightValue = v;
+ rightUnits = unit;
+ } else if (key.equals("bottom")) {
+ bottomValue = v;
+ bottomUnits = unit;
+ } else if (key.equals("left")) {
+ leftValue = v;
+ leftUnits = unit;
}
}
}
// this is implemented differently than other listeners to maintain
// backwards compatibility
if (progressListeners != null) {
- for (ProgressListener l : progressListeners) {
+ for (Iterator<ProgressListener> it = progressListeners
+ .iterator(); it.hasNext();) {
+ ProgressListener l = it.next();
l.updateProgress(totalBytes, contentLength);
}
}
propertyName = removeSubsequentUppercase(propertyName);
String[] words = propertyName.split("(?<!^)(?=[A-Z])");
StringBuilder builder = new StringBuilder();
- for (String word : words) {
+ for (int i = 0; i < words.length; i++) {
if (builder.length() > 0) {
builder.append("-");
}
- builder.append(word.toLowerCase());
+ builder.append(words[i].toLowerCase());
}
return builder.toString();
}
throw new IllegalArgumentException(
"Value must be OK or NOTOK");
}, model -> {
- switch (model) {
- case "1":
- return "OK";
- case "2":
- return "NOTOK";
- default:
- throw new IllegalArgumentException(
- "Value in model must be 1 or 2");
- }
+ if (model.equals("1")) {
+ return "OK";
+ } else if (model.equals("2")) {
+ return "NOTOK";
+ } else {
+ throw new IllegalArgumentException(
+ "Value in model must be 1 or 2");
+ }
});
binding.bind(StatusBean::getStatus, StatusBean::setStatus);
binder.setBean(bean);
Boolean[] explicitImmediate = { null, Boolean.FALSE, Boolean.TRUE,
Boolean.TRUE };
boolean[] immediate = { true, false, true, true };
- for (String designElements : design) {
- component = (AbstractComponent) Design.read(new ByteArrayInputStream(designElements.getBytes(Charset.forName("UTF-8"))));
+ for (int i = 0; i < design.length; i++) {
+ component = (AbstractComponent) Design
+ .read(new ByteArrayInputStream(
+ design[i].getBytes(Charset.forName("UTF-8"))));
}
}