summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPer-Åke Minborg <minborg@speedment.com>2016-10-28 11:40:54 -0700
committerHenri Sara <hesara@vaadin.com>2016-11-05 04:15:03 +0200
commita1af515897aef4dcd95cef4b11db4d651247b5e7 (patch)
treedaa1412395a537f042a8d1368674a51ae0d16b78
parent3e2ddb469152c430bde5d2c61a9b279a10a8806f (diff)
downloadvaadin-framework-a1af515897aef4dcd95cef4b11db4d651247b5e7.tar.gz
vaadin-framework-a1af515897aef4dcd95cef4b11db4d651247b5e7.zip
Replace Stack with Deque
Change-Id: I80b73b653e97904605dc62484a7448f3bfbf722a
-rw-r--r--server/src/main/java/com/vaadin/server/ComponentSizeValidator.java21
-rw-r--r--server/src/main/java/com/vaadin/server/JsonPaintTarget.java21
-rw-r--r--server/src/main/java/com/vaadin/ui/MenuBar.java13
3 files changed, 29 insertions, 26 deletions
diff --git a/server/src/main/java/com/vaadin/server/ComponentSizeValidator.java b/server/src/main/java/com/vaadin/server/ComponentSizeValidator.java
index 129000b3bb..a4981a94b9 100644
--- a/server/src/main/java/com/vaadin/server/ComponentSizeValidator.java
+++ b/server/src/main/java/com/vaadin/server/ComponentSizeValidator.java
@@ -23,7 +23,6 @@ import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
-import java.util.Stack;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -41,6 +40,8 @@ import com.vaadin.ui.TabSheet;
import com.vaadin.ui.UI;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;
+import java.util.ArrayDeque;
+import java.util.Deque;
@SuppressWarnings({ "serial", "deprecation" })
public class ComponentSizeValidator implements Serializable {
@@ -105,7 +106,7 @@ public class ComponentSizeValidator implements Serializable {
* Comparability form component which is defined in the different jar.
*
* TODO : Normally this logic shouldn't be here. But it means that the whole
- * this class has wrong design and impementation and should be refactored.
+ * this class has wrong design and implementation and should be refactored.
*/
private static boolean isForm(Component component) {
if (!(component instanceof HasComponents)) {
@@ -123,7 +124,7 @@ public class ComponentSizeValidator implements Serializable {
}
private static void printServerError(String msg,
- Stack<ComponentInfo> attributes, boolean widthError,
+ Deque<ComponentInfo> attributes, boolean widthError,
PrintStream errorStream) {
StringBuffer err = new StringBuffer();
err.append("Vaadin DEBUG\n");
@@ -134,7 +135,7 @@ public class ComponentSizeValidator implements Serializable {
while (attributes.size() > LAYERS_SHOWN) {
attributes.pop();
}
- while (!attributes.empty()) {
+ while (!attributes.isEmpty()) {
ci = attributes.pop();
showComponent(ci.component, ci.info, err, indent, widthError);
}
@@ -219,7 +220,7 @@ public class ComponentSizeValidator implements Serializable {
clientJSON.append("\"id\":\"").append(paintableId).append("\"");
if (invalidHeight) {
- Stack<ComponentInfo> attributes = null;
+ Deque<ComponentInfo> attributes = null;
String msg = "";
// set proper error messages
if (parent instanceof AbstractOrderedLayout) {
@@ -249,7 +250,7 @@ public class ComponentSizeValidator implements Serializable {
clientJSON.append(",\"heightMsg\":\"").append(msg).append("\"");
}
if (invalidWidth) {
- Stack<ComponentInfo> attributes = null;
+ Deque<ComponentInfo> attributes = null;
String msg = "";
if (parent instanceof AbstractOrderedLayout) {
AbstractOrderedLayout ol = (AbstractOrderedLayout) parent;
@@ -307,9 +308,9 @@ public class ComponentSizeValidator implements Serializable {
}
- private static Stack<ComponentInfo> getHeightAttributes(
+ private static Deque<ComponentInfo> getHeightAttributes(
Component component) {
- Stack<ComponentInfo> attributes = new Stack<>();
+ Deque<ComponentInfo> attributes = new ArrayDeque<>();
attributes
.add(new ComponentInfo(component, getHeightString(component)));
Component parent = component.getParent();
@@ -322,9 +323,9 @@ public class ComponentSizeValidator implements Serializable {
return attributes;
}
- private static Stack<ComponentInfo> getWidthAttributes(
+ private static Deque<ComponentInfo> getWidthAttributes(
Component component) {
- Stack<ComponentInfo> attributes = new Stack<>();
+ final Deque<ComponentInfo> attributes = new ArrayDeque<>();
attributes.add(new ComponentInfo(component, getWidthString(component)));
Component parent = component.getParent();
attributes.add(new ComponentInfo(parent, getWidthString(parent)));
diff --git a/server/src/main/java/com/vaadin/server/JsonPaintTarget.java b/server/src/main/java/com/vaadin/server/JsonPaintTarget.java
index 3d0b7393e6..69a9889c30 100644
--- a/server/src/main/java/com/vaadin/server/JsonPaintTarget.java
+++ b/server/src/main/java/com/vaadin/server/JsonPaintTarget.java
@@ -24,14 +24,15 @@ import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
-import java.util.Stack;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.vaadin.ui.Alignment;
import com.vaadin.ui.Component;
import com.vaadin.ui.CustomLayout;
+import java.util.ArrayDeque;
import java.util.ArrayList;
+import java.util.Deque;
import java.util.List;
/**
@@ -50,13 +51,13 @@ public class JsonPaintTarget implements PaintTarget {
private final static String UIDL_ARG_NAME = "name";
- private final Stack<String> mOpenTags;
+ private final Deque<String> mOpenTags;
- private final Stack<JsonTag> openJsonTags;
+ private final Deque<JsonTag> openJsonTags;
// these match each other element-wise
- private final Stack<ClientConnector> openPaintables;
- private final Stack<String> openPaintableTags;
+ private final Deque<ClientConnector> openPaintables;
+ private final Deque<String> openPaintableTags;
private final PrintWriter uidlBuffer;
@@ -97,11 +98,11 @@ public class JsonPaintTarget implements PaintTarget {
uidlBuffer = new PrintWriter(outWriter);
// Initialize tag-writing
- mOpenTags = new Stack<>();
- openJsonTags = new Stack<>();
+ mOpenTags = new ArrayDeque<>();
+ openJsonTags = new ArrayDeque<>();
- openPaintables = new Stack<>();
- openPaintableTags = new Stack<>();
+ openPaintables = new ArrayDeque<>();
+ openPaintableTags = new ArrayDeque<>();
cacheEnabled = cachingRequired;
}
@@ -157,7 +158,7 @@ public class JsonPaintTarget implements PaintTarget {
* If the parent tag is closed before every child tag is closed an
* PaintException is raised.
*
- * @param tag
+ * @param tagName
* the name of the end tag.
* @throws PaintException
* if the paint operation failed.
diff --git a/server/src/main/java/com/vaadin/ui/MenuBar.java b/server/src/main/java/com/vaadin/ui/MenuBar.java
index 8fca3f1460..5319df7e8b 100644
--- a/server/src/main/java/com/vaadin/ui/MenuBar.java
+++ b/server/src/main/java/com/vaadin/ui/MenuBar.java
@@ -21,7 +21,6 @@ import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import java.util.Stack;
import org.jsoup.nodes.Attributes;
import org.jsoup.nodes.Element;
@@ -36,6 +35,8 @@ import com.vaadin.shared.ui.menubar.MenuBarState;
import com.vaadin.ui.Component.Focusable;
import com.vaadin.ui.declarative.DesignAttributeHandler;
import com.vaadin.ui.declarative.DesignContext;
+import java.util.ArrayDeque;
+import java.util.Deque;
/**
* <p>
@@ -70,7 +71,7 @@ public class MenuBar extends AbstractComponent
return (MenuBarState) super.getState(markAsDirty);
}
- /** Paint (serialise) the component for the client. */
+ /** Paint (serialize) the component for the client. */
@Override
public void paintContent(PaintTarget target) throws PaintException {
target.addAttribute(MenuBarConstants.OPEN_ROOT_MENU_ON_HOWER,
@@ -159,10 +160,10 @@ public class MenuBar extends AbstractComponent
target.endTag("item");
}
- /** Deserialize changes received from client. */
+ /** De-serialize changes received from client. */
@Override
public void changeVariables(Object source, Map<String, Object> variables) {
- Stack<MenuItem> items = new Stack<>();
+ final Deque<MenuItem> items = new ArrayDeque<>();
boolean found = false;
if (variables.containsKey("clickedId")) {
@@ -176,9 +177,9 @@ public class MenuBar extends AbstractComponent
MenuItem tmpItem = null;
// Go through all the items in the menu
- while (!found && !items.empty()) {
+ while (!found && !items.isEmpty()) {
tmpItem = items.pop();
- found = (clickedId.intValue() == tmpItem.getId());
+ found = (clickedId == tmpItem.getId());
if (tmpItem.hasChildren()) {
itr = tmpItem.getChildren().iterator();