diff options
author | Ahmed Ashour <asashour@yahoo.com> | 2017-10-20 10:10:02 +0200 |
---|---|---|
committer | Péter Török <31210544+torok-peter@users.noreply.github.com> | 2017-10-20 11:10:02 +0300 |
commit | a9c83ba07e4dec90eb7d6e332b91adde9613ebb4 (patch) | |
tree | 7907a6c389ae740572197d949e27c6fd3c25491c /client | |
parent | 0a26d0e44169f9643e7d30ba370b8ecbbe128a56 (diff) | |
download | vaadin-framework-a9c83ba07e4dec90eb7d6e332b91adde9613ebb4.tar.gz vaadin-framework-a9c83ba07e4dec90eb7d6e332b91adde9613ebb4.zip |
Use .toLowerCase and .toUpperCase(Locale.ROOT) (#10182)
* Use .toLowerCase and .toUpperCase(Locale.ROOT)
* Spaces
* add spaces after if(
Diffstat (limited to 'client')
17 files changed, 65 insertions, 42 deletions
diff --git a/client/src/main/java/com/vaadin/client/CSSRule.java b/client/src/main/java/com/vaadin/client/CSSRule.java index b351d9c36b..c425fbd2ce 100644 --- a/client/src/main/java/com/vaadin/client/CSSRule.java +++ b/client/src/main/java/com/vaadin/client/CSSRule.java @@ -64,7 +64,7 @@ public class CSSRule { if (!$doc.styleSheets) return null; - selector = selector.toLowerCase(); + selector = selector.toLowerCase('en'); var allMatches = []; @@ -87,7 +87,7 @@ public class CSSRule { for (var i=0; i<j; i++) { var r = theRules[i]; if (r.type == 1 || sheet.imports) { - var selectors = r.selectorText.toLowerCase().split(","); + var selectors = r.selectorText.toLowerCase('en').split(","); var n = selectors.length; for (var m=0; m<n; m++) { if (selectors[m].replace(/^\s+|\s+$/g, "") == selector) { diff --git a/client/src/main/java/com/vaadin/client/ComputedStyle.java b/client/src/main/java/com/vaadin/client/ComputedStyle.java index 7d2b3fb732..b54ee64ed4 100644 --- a/client/src/main/java/com/vaadin/client/ComputedStyle.java +++ b/client/src/main/java/com/vaadin/client/ComputedStyle.java @@ -83,7 +83,7 @@ public class ComputedStyle { if (cs.getPropertyValue) { // Convert name to dashed format - name = name.replace(/([A-Z])/g, "-$1").toLowerCase(); + name = name.replace(/([A-Z])/g, "-$1").toLowerCase('en'); var ret = cs.getPropertyValue(name); } else { diff --git a/client/src/main/java/com/vaadin/client/WidgetUtil.java b/client/src/main/java/com/vaadin/client/WidgetUtil.java index 7d54ac7650..94439dc945 100644 --- a/client/src/main/java/com/vaadin/client/WidgetUtil.java +++ b/client/src/main/java/com/vaadin/client/WidgetUtil.java @@ -18,6 +18,7 @@ package com.vaadin.client; import java.io.Serializable; import java.util.HashMap; +import java.util.Locale; import java.util.Map; import java.util.logging.Logger; @@ -1888,7 +1889,7 @@ public class WidgetUtil { ErrorLevel errorLevel) { for (ErrorLevel errorLevelValue : ErrorLevel.values()) { String className = prefix + "-" - + errorLevelValue.toString().toLowerCase(); + + errorLevelValue.toString().toLowerCase(Locale.ROOT); if (errorLevel == errorLevelValue) { element.addClassName(className); } else { diff --git a/client/src/main/java/com/vaadin/client/debug/internal/SelectorPath.java b/client/src/main/java/com/vaadin/client/debug/internal/SelectorPath.java index 07da3fbd4a..19a1682f49 100644 --- a/client/src/main/java/com/vaadin/client/debug/internal/SelectorPath.java +++ b/client/src/main/java/com/vaadin/client/debug/internal/SelectorPath.java @@ -18,6 +18,7 @@ package com.vaadin.client.debug.internal; import java.util.HashMap; import java.util.List; +import java.util.Locale; import java.util.Map; import com.google.gwt.dom.client.Element; @@ -199,7 +200,7 @@ public class SelectorPath { name = getNameWithCount(name); // Use direct path and elementX naming style. - return "WebElement " + name.substring(0, 1).toLowerCase() + return "WebElement " + name.substring(0, 1).toLowerCase(Locale.ROOT) + name.substring(1) + " = getDriver().findElement(By.vaadin(\"" + path + "\"));"; } @@ -242,7 +243,8 @@ public class SelectorPath { name = name.replaceAll("\\W", ""); // Lowercase the first character of name - return elementType + "Element " + name.substring(0, 1).toLowerCase() + return elementType + "Element " + + name.substring(0, 1).toLowerCase(Locale.ROOT) + name.substring(1) + " = "; } diff --git a/client/src/main/java/com/vaadin/client/event/PointerEventSupportImpl.java b/client/src/main/java/com/vaadin/client/event/PointerEventSupportImpl.java index 9ceeb86994..3fa3ecd6eb 100644 --- a/client/src/main/java/com/vaadin/client/event/PointerEventSupportImpl.java +++ b/client/src/main/java/com/vaadin/client/event/PointerEventSupportImpl.java @@ -15,6 +15,8 @@ */ package com.vaadin.client.event; +import java.util.Locale; + import com.vaadin.client.event.PointerEvent.EventType; /** @@ -38,7 +40,7 @@ public class PointerEventSupportImpl { * @return the native event name of the given event */ public String getNativeEventName(EventType eventName) { - return eventName.toString().toLowerCase(); + return eventName.toString().toLowerCase(Locale.ROOT); } /** diff --git a/client/src/main/java/com/vaadin/client/extensions/DragSourceExtensionConnector.java b/client/src/main/java/com/vaadin/client/extensions/DragSourceExtensionConnector.java index cb2870cf7a..52b9d1f0ea 100644 --- a/client/src/main/java/com/vaadin/client/extensions/DragSourceExtensionConnector.java +++ b/client/src/main/java/com/vaadin/client/extensions/DragSourceExtensionConnector.java @@ -16,6 +16,7 @@ package com.vaadin.client.extensions; import java.util.LinkedHashMap; +import java.util.Locale; import java.util.Map; import java.util.logging.Logger; @@ -490,7 +491,7 @@ public class DragSourceExtensionConnector extends AbstractExtensionConnector { assert dropEffect != null : "Drop effect should never be null"; sendDragEndEventToServer(nativeEvent, - DropEffect.valueOf(dropEffect.toUpperCase())); + DropEffect.valueOf(dropEffect.toUpperCase(Locale.ROOT))); } } diff --git a/client/src/main/java/com/vaadin/client/extensions/DropTargetExtensionConnector.java b/client/src/main/java/com/vaadin/client/extensions/DropTargetExtensionConnector.java index 3791db53b4..b9ce983dab 100644 --- a/client/src/main/java/com/vaadin/client/extensions/DropTargetExtensionConnector.java +++ b/client/src/main/java/com/vaadin/client/extensions/DropTargetExtensionConnector.java @@ -19,6 +19,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.Set; @@ -219,7 +220,8 @@ public class DropTargetExtensionConnector extends AbstractExtensionConnector { DataTransfer.DropEffect dropEffect = DataTransfer.DropEffect // the valueOf() needs to have equal string and name() // doesn't return in all upper case - .valueOf(getState().dropEffect.name().toUpperCase()); + .valueOf(getState().dropEffect.name() + .toUpperCase(Locale.ROOT)); event.getDataTransfer().setDropEffect(dropEffect); } } @@ -283,13 +285,13 @@ public class DropTargetExtensionConnector extends AbstractExtensionConnector { JsArrayString typesJsArray = getTypes( nativeEvent.getDataTransfer()); - /* Handle event if transfer doesn't contain files. + /* + * Handle event if transfer doesn't contain files. * * Spec: "Dragging files can currently only happen from outside a * browsing context, for example from a file system manager - * application." - * Thus there cannot be at the same time both files and other data - * dragged + * application." Thus there cannot be at the same time both files + * and other data dragged */ if (!containsFiles(typesJsArray)) { nativeEvent.preventDefault(); @@ -304,7 +306,8 @@ public class DropTargetExtensionConnector extends AbstractExtensionConnector { } sendDropEventToServer(types, data, DragSourceExtensionConnector - .getDropEffect(nativeEvent.getDataTransfer()), nativeEvent); + .getDropEffect(nativeEvent.getDataTransfer()), + nativeEvent); } } @@ -332,8 +335,8 @@ public class DropTargetExtensionConnector extends AbstractExtensionConnector { } // Execute criterion defined via API - if (allowed && getState().criteria != null && !getState().criteria - .isEmpty()) { + if (allowed && getState().criteria != null + && !getState().criteria.isEmpty()) { // Collect payload data types Set<Payload> payloadSet = new HashSet<>(); @@ -370,7 +373,7 @@ public class DropTargetExtensionConnector extends AbstractExtensionConnector { * https://html.spec.whatwg.org/multipage/interaction.html#the-datatransfer-interface:dom-datatransfer-types-2 * * @param types - * Array of data types. + * Array of data types. * @return {@code} true if given array contains {@code "Files"}, {@code * false} otherwise. */ @@ -403,8 +406,8 @@ public class DropTargetExtensionConnector extends AbstractExtensionConnector { .buildMouseEventDetails(dropEvent, getDropTargetElement()); // Send data to server with RPC - getRpcProxy(DropTargetRpc.class) - .drop(types, data, dropEffect, mouseEventDetails); + getRpcProxy(DropTargetRpc.class).drop(types, data, dropEffect, + mouseEventDetails); } /** diff --git a/client/src/main/java/com/vaadin/client/ui/VComboBox.java b/client/src/main/java/com/vaadin/client/ui/VComboBox.java index 683f04a942..df134c4505 100644 --- a/client/src/main/java/com/vaadin/client/ui/VComboBox.java +++ b/client/src/main/java/com/vaadin/client/ui/VComboBox.java @@ -21,6 +21,7 @@ import java.util.Collection; import java.util.Date; import java.util.HashSet; import java.util.List; +import java.util.Locale; import java.util.Set; import com.google.gwt.animation.client.AnimationScheduler; @@ -1164,8 +1165,9 @@ public class VComboBox extends Composite implements Field, KeyDownHandler, // TODO try to select the new value if it matches what was // sent for V7 compatibility } - } else if (item != null && !"".equals(lastFilter) && item.getText() - .toLowerCase().contains(lastFilter.toLowerCase())) { + } else if (item != null && !"".equals(lastFilter) + && item.getText().toLowerCase(Locale.ROOT) + .contains(lastFilter.toLowerCase(Locale.ROOT))) { doItemAction(item, true); } else { // currentSuggestion has key="" for nullselection diff --git a/client/src/main/java/com/vaadin/client/ui/VContextMenu.java b/client/src/main/java/com/vaadin/client/ui/VContextMenu.java index 7d2f718566..e6aabd1af1 100644 --- a/client/src/main/java/com/vaadin/client/ui/VContextMenu.java +++ b/client/src/main/java/com/vaadin/client/ui/VContextMenu.java @@ -16,6 +16,8 @@ package com.vaadin.client.ui; +import java.util.Locale; + import com.google.gwt.core.client.Scheduler; import com.google.gwt.dom.client.Element; import com.google.gwt.dom.client.NodeList; @@ -287,7 +289,8 @@ public class VContextMenu extends VOverlay implements SubPartAware { com.google.gwt.user.client.Element subElement) { if (getElement().isOrHasChild(subElement)) { com.google.gwt.dom.client.Element e = subElement; - while (e != null && !e.getTagName().toLowerCase().equals("tr")) { + while (e != null + && !e.getTagName().toLowerCase(Locale.ROOT).equals("tr")) { e = e.getParentElement(); // ApplicationConnection.getConsole().log("Found row"); } diff --git a/client/src/main/java/com/vaadin/client/ui/VCustomLayout.java b/client/src/main/java/com/vaadin/client/ui/VCustomLayout.java index a3e7217685..d66db480ae 100644 --- a/client/src/main/java/com/vaadin/client/ui/VCustomLayout.java +++ b/client/src/main/java/com/vaadin/client/ui/VCustomLayout.java @@ -17,6 +17,7 @@ package com.vaadin.client.ui; import java.util.HashMap; +import java.util.Locale; import java.util.Map; import com.google.gwt.dom.client.Element; @@ -271,7 +272,7 @@ public class VCustomLayout extends ComplexPanel { scripts = ""; int endOfPrevScript = 0; int nextPosToCheck = 0; - String lc = html.toLowerCase(); + String lc = html.toLowerCase(Locale.ROOT); String res = ""; int scriptStart = lc.indexOf("<script", nextPosToCheck); while (scriptStart > 0) { @@ -286,7 +287,7 @@ public class VCustomLayout extends ComplexPanel { // Extract body html = res; - lc = html.toLowerCase(); + lc = html.toLowerCase(Locale.ROOT); int startOfBody = lc.indexOf("<body"); if (startOfBody < 0) { res = html; diff --git a/client/src/main/java/com/vaadin/client/ui/VDateField.java b/client/src/main/java/com/vaadin/client/ui/VDateField.java index 558ddaa494..971248cee9 100644 --- a/client/src/main/java/com/vaadin/client/ui/VDateField.java +++ b/client/src/main/java/com/vaadin/client/ui/VDateField.java @@ -265,7 +265,7 @@ public abstract class VDateField<R extends Enum<R>> extends FlowPanel * @return the resolution variable name */ public String getResolutionVariable(R resolution) { - return resolution.name().toLowerCase(Locale.ENGLISH); + return resolution.name().toLowerCase(Locale.ROOT); } /** diff --git a/client/src/main/java/com/vaadin/client/ui/VDragAndDropWrapper.java b/client/src/main/java/com/vaadin/client/ui/VDragAndDropWrapper.java index 0202cdf430..0ef910ac96 100644 --- a/client/src/main/java/com/vaadin/client/ui/VDragAndDropWrapper.java +++ b/client/src/main/java/com/vaadin/client/ui/VDragAndDropWrapper.java @@ -17,6 +17,7 @@ package com.vaadin.client.ui; import java.util.ArrayList; import java.util.List; +import java.util.Locale; import java.util.Map; import com.google.gwt.core.client.GWT; @@ -672,11 +673,11 @@ public class VDragAndDropWrapper extends VCustomComponent protected void deEmphasis(boolean doLayout) { if (emphasizedVDrop != null) { VDragAndDropWrapper.setStyleName(getElement(), OVER_STYLE, false); - VDragAndDropWrapper.setStyleName(getElement(), - OVER_STYLE + "-" + emphasizedVDrop.toString().toLowerCase(), + VDragAndDropWrapper.setStyleName(getElement(), OVER_STYLE + "-" + + emphasizedVDrop.toString().toLowerCase(Locale.ROOT), false); - VDragAndDropWrapper.setStyleName(getElement(), - OVER_STYLE + "-" + emphasizedHDrop.toString().toLowerCase(), + VDragAndDropWrapper.setStyleName(getElement(), OVER_STYLE + "-" + + emphasizedHDrop.toString().toLowerCase(Locale.ROOT), false); } if (doLayout) { @@ -692,10 +693,10 @@ public class VDragAndDropWrapper extends VCustomComponent deEmphasis(false); VDragAndDropWrapper.setStyleName(getElement(), OVER_STYLE, true); VDragAndDropWrapper.setStyleName(getElement(), OVER_STYLE + "-" - + verticalDropLocation.toString().toLowerCase(), true); - VDragAndDropWrapper.setStyleName(getElement(), - OVER_STYLE + "-" - + horizontalDropLocation.toString().toLowerCase(), + + verticalDropLocation.toString().toLowerCase(Locale.ROOT), + true); + VDragAndDropWrapper.setStyleName(getElement(), OVER_STYLE + "-" + + horizontalDropLocation.toString().toLowerCase(Locale.ROOT), true); emphasizedVDrop = verticalDropLocation; emphasizedHDrop = horizontalDropLocation; diff --git a/client/src/main/java/com/vaadin/client/ui/dd/DragAndDropHandler.java b/client/src/main/java/com/vaadin/client/ui/dd/DragAndDropHandler.java index 602e692a6e..55e17c325f 100644 --- a/client/src/main/java/com/vaadin/client/ui/dd/DragAndDropHandler.java +++ b/client/src/main/java/com/vaadin/client/ui/dd/DragAndDropHandler.java @@ -15,6 +15,8 @@ */ package com.vaadin.client.ui.dd; +import java.util.Locale; + import com.google.gwt.dom.client.NativeEvent; import com.google.gwt.event.dom.client.KeyCodes; import com.google.gwt.event.shared.HandlerRegistration; @@ -174,7 +176,7 @@ public class DragAndDropHandler { public void onPreviewNativeEvent(NativePreviewEvent event) { final int typeInt = event.getTypeInt(); if (typeInt == -1 && event.getNativeEvent().getType() - .toLowerCase().contains("pointer")) { + .toLowerCase(Locale.ROOT).contains("pointer")) { /* * Ignore PointerEvents since IE10 and IE11 send * also MouseEvents for backwards compatibility. diff --git a/client/src/main/java/com/vaadin/client/ui/dd/VDragAndDropManager.java b/client/src/main/java/com/vaadin/client/ui/dd/VDragAndDropManager.java index f1b2e3736a..4030778d34 100644 --- a/client/src/main/java/com/vaadin/client/ui/dd/VDragAndDropManager.java +++ b/client/src/main/java/com/vaadin/client/ui/dd/VDragAndDropManager.java @@ -15,6 +15,8 @@ */ package com.vaadin.client.ui.dd; +import java.util.Locale; + import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.Scheduler; import com.google.gwt.dom.client.Element; @@ -319,7 +321,7 @@ public class VDragAndDropManager { NativePreviewEvent event) { int typeInt = event.getTypeInt(); if (typeInt == -1 && event.getNativeEvent() - .getType().toLowerCase() + .getType().toLowerCase(Locale.ROOT) .contains("pointer")) { /* * Ignore PointerEvents since IE10 and IE11 send diff --git a/client/src/main/java/com/vaadin/client/ui/dd/VDragEvent.java b/client/src/main/java/com/vaadin/client/ui/dd/VDragEvent.java index 1c038de772..f603fbc464 100644 --- a/client/src/main/java/com/vaadin/client/ui/dd/VDragEvent.java +++ b/client/src/main/java/com/vaadin/client/ui/dd/VDragEvent.java @@ -16,6 +16,7 @@ package com.vaadin.client.ui.dd; import java.util.HashMap; +import java.util.Locale; import java.util.Map; import com.google.gwt.dom.client.Document; @@ -257,7 +258,7 @@ public class VDragEvent { syncContent(element, cloneNode); if (BrowserInfo.get().isIE()) { - if (cloneNode.getTagName().toLowerCase().equals("tr")) { + if (cloneNode.getTagName().toLowerCase(Locale.ROOT).equals("tr")) { TableElement table = Document.get().createTableElement(); TableSectionElement tbody = Document.get().createTBodyElement(); table.appendChild(tbody); diff --git a/client/src/main/java/com/vaadin/client/ui/orderedlayout/Slot.java b/client/src/main/java/com/vaadin/client/ui/orderedlayout/Slot.java index 2faffeede0..63daaf2bc3 100644 --- a/client/src/main/java/com/vaadin/client/ui/orderedlayout/Slot.java +++ b/client/src/main/java/com/vaadin/client/ui/orderedlayout/Slot.java @@ -17,6 +17,7 @@ package com.vaadin.client.ui.orderedlayout; import java.util.List; +import java.util.Locale; import com.google.gwt.aria.client.Roles; import com.google.gwt.core.client.GWT; @@ -387,8 +388,8 @@ public class Slot extends SimplePanel implements HasErrorIndicatorElement { if (caption == null) { return; } - captionWrap.removeClassName( - "v-caption-on-" + this.captionPosition.name().toLowerCase()); + captionWrap.removeClassName("v-caption-on-" + + this.captionPosition.name().toLowerCase(Locale.ROOT)); this.captionPosition = captionPosition; if (captionPosition == CaptionPosition.BOTTOM @@ -398,8 +399,8 @@ public class Slot extends SimplePanel implements HasErrorIndicatorElement { captionWrap.insertFirst(caption); } - captionWrap.addClassName( - "v-caption-on-" + captionPosition.name().toLowerCase()); + captionWrap.addClassName("v-caption-on-" + + captionPosition.name().toLowerCase(Locale.ROOT)); } /** diff --git a/client/src/main/java/com/vaadin/client/ui/orderedlayout/VAbstractOrderedLayout.java b/client/src/main/java/com/vaadin/client/ui/orderedlayout/VAbstractOrderedLayout.java index 6dcc78feeb..80fbe7a079 100644 --- a/client/src/main/java/com/vaadin/client/ui/orderedlayout/VAbstractOrderedLayout.java +++ b/client/src/main/java/com/vaadin/client/ui/orderedlayout/VAbstractOrderedLayout.java @@ -16,6 +16,7 @@ package com.vaadin.client.ui.orderedlayout; import java.util.HashMap; +import java.util.Locale; import java.util.Map; import com.google.gwt.core.client.GWT; @@ -345,8 +346,8 @@ public class VAbstractOrderedLayout extends FlowPanel { return CaptionPosition.TOP; } String captionClass = matcher.getGroup(1); - CaptionPosition captionPosition = CaptionPosition - .valueOf(CaptionPosition.class, captionClass.toUpperCase()); + CaptionPosition captionPosition = CaptionPosition.valueOf( + CaptionPosition.class, captionClass.toUpperCase(Locale.ROOT)); return captionPosition; } |