click-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sa...@apache.org
Subject svn commit: r941239 - in /click/trunk/click/extras/src/org/apache/click/extras: control/DateField.java tree/Tree.java tree/TreeNode.java
Date Wed, 05 May 2010 10:47:09 GMT
Author: sabob
Date: Wed May  5 10:47:09 2010
New Revision: 941239

URL: http://svn.apache.org/viewvc?rev=941239&view=rev
Log:
genericsgenerics cleanup

Modified:
    click/trunk/click/extras/src/org/apache/click/extras/control/DateField.java
    click/trunk/click/extras/src/org/apache/click/extras/tree/Tree.java
    click/trunk/click/extras/src/org/apache/click/extras/tree/TreeNode.java

Modified: click/trunk/click/extras/src/org/apache/click/extras/control/DateField.java
URL: http://svn.apache.org/viewvc/click/trunk/click/extras/src/org/apache/click/extras/control/DateField.java?rev=941239&r1=941238&r2=941239&view=diff
==============================================================================
--- click/trunk/click/extras/src/org/apache/click/extras/control/DateField.java (original)
+++ click/trunk/click/extras/src/org/apache/click/extras/control/DateField.java Wed May  5
10:47:09 2010
@@ -30,6 +30,7 @@ import java.util.Locale;
 import org.apache.click.Context;
 import org.apache.click.control.TextField;
 import org.apache.click.element.CssImport;
+import org.apache.click.element.Element;
 import org.apache.click.element.JsImport;
 import org.apache.click.element.JsScript;
 import org.apache.click.util.ClickUtils;
@@ -133,7 +134,7 @@ import org.apache.click.util.HtmlStringB
  */
 public class DateField extends TextField {
 
-    // -------------------------------------------------------------- Constants
+    // Constants --------------------------------------------------------------
 
     private static final long serialVersionUID = 1L;
 
@@ -141,7 +142,7 @@ public class DateField extends TextField
     static final String[] SUPPORTTED_LANGUAGES =
         {"da", "de", "fi", "fr", "ja", "nl", "pl", "pt", "ru"};
 
-    // ----------------------------------------------------- Instance Variables
+    // Instance Variables -----------------------------------------------------
 
     /** The DateField's date value. */
     protected Date date;
@@ -180,7 +181,7 @@ public class DateField extends TextField
     /** Indicates whether the help property should be rendered or not. */
     private boolean renderHelp = true;
 
-    // ----------------------------------------------------------- Constructors
+    // Constructors -----------------------------------------------------------
 
     /**
      * Construct the Date Field with the given name.
@@ -308,7 +309,7 @@ public class DateField extends TextField
         setFormatPattern(dateFormatPattern);
     }
 
-    // ------------------------------------------------------ Public Attributes
+    // Public Attributes ------------------------------------------------------
 
     /**
      * Return the field Date value, or null if value was empty or a parsing
@@ -588,7 +589,7 @@ public class DateField extends TextField
      * @return the HTML head import statements for the control
      */
     @Override
-    public List getHeadElements() {
+    public List<Element> getHeadElements() {
         // CLK-309. Skip imports if dateField is disabled, readonly or calendar
         // should not be displayed.
         if (isReadonly() || isDisabled() || !isShowCalendar()) {
@@ -748,7 +749,7 @@ public class DateField extends TextField
         return null;
     }
 
-    // --------------------------------------------------------- Public Methods
+    // Public Methods ---------------------------------------------------------
 
     /**
      * Validate the DateField request submission.
@@ -829,7 +830,7 @@ public class DateField extends TextField
         }
     }
 
-    // ------------------------------------------------------ Protected Methods
+    // Protected Methods ------------------------------------------------------
 
     /**
      * Render the calendar button HTML representation to the buffer.
@@ -885,7 +886,7 @@ public class DateField extends TextField
      *
      * @param headElements the list of head elements to include for this control
      */
-    protected void addCalendarOptions(List headElements) {
+    protected void addCalendarOptions(List<Element> headElements) {
         String fieldId = getId();
         String imgId = fieldId + "-button";
 

Modified: click/trunk/click/extras/src/org/apache/click/extras/tree/Tree.java
URL: http://svn.apache.org/viewvc/click/trunk/click/extras/src/org/apache/click/extras/tree/Tree.java?rev=941239&r1=941238&r2=941239&view=diff
==============================================================================
--- click/trunk/click/extras/src/org/apache/click/extras/tree/Tree.java (original)
+++ click/trunk/click/extras/src/org/apache/click/extras/tree/Tree.java Wed May  5 10:47:09
2010
@@ -40,6 +40,7 @@ import org.apache.click.control.Abstract
 import org.apache.click.control.ActionLink;
 import org.apache.click.control.Decorator;
 import org.apache.click.element.CssImport;
+import org.apache.click.element.Element;
 import org.apache.click.element.JsImport;
 import org.apache.click.extras.control.SubmitLink;
 import org.apache.click.util.ClickUtils;
@@ -222,7 +223,7 @@ public class Tree extends AbstractContro
     private boolean javascriptEnabled = false;
 
     /** List of subscribed listeners to tree events.*/
-    private List listeners = new ArrayList();
+    private List<TreeListener> listeners = new ArrayList<TreeListener>();
 
     /** Current javascript policy in effect. */
     private int javascriptPolicy = 0;
@@ -499,7 +500,7 @@ public class Tree extends AbstractContro
      * @return the HTML HEAD elements for the control
      */
     @Override
-    public List getHeadElements() {
+    public List<Element> getHeadElements() {
 
         if (headElements == null) {
             headElements = super.getHeadElements();
@@ -774,11 +775,12 @@ public class Tree extends AbstractContro
     /**
      * Returns all the nodes that were expanded.
      *
-     * @param includeInvisibleNodes indicator if only invisible nodes should be included.
-     * @return list of currently expanded nodes.
+     * @param includeInvisibleNodes indicator if only invisible nodes should be
+     * included
+     * @return list of currently expanded nodes
      */
-    public List getExpandedNodes(boolean includeInvisibleNodes) {
-        List currentlyExpanded = new ArrayList();
+    public List<TreeNode> getExpandedNodes(boolean includeInvisibleNodes) {
+        List<TreeNode> currentlyExpanded = new ArrayList<TreeNode>();
         for (Iterator it = iterator(); it.hasNext();) {
             TreeNode node = (TreeNode) it.next();
             if (node.isExpanded())  {
@@ -796,8 +798,8 @@ public class Tree extends AbstractContro
      * @param includeInvisibleNodes indicates if invisible nodes should be included.
      * @return list of currently selected nodes.
      */
-    public List getSelectedNodes(boolean includeInvisibleNodes) {
-        List currentlySelected = new ArrayList();
+    public List<TreeNode> getSelectedNodes(boolean includeInvisibleNodes) {
+        List<TreeNode> currentlySelected = new ArrayList<TreeNode>();
         for (Iterator it = iterator(); it.hasNext();) {
             TreeNode node = (TreeNode) it.next();
             if (node.isSelected()) {
@@ -827,7 +829,7 @@ public class Tree extends AbstractContro
      *
      * @return iterator over all elements in the tree
      */
-    public Iterator iterator() {
+    public Iterator<TreeNode> iterator() {
         return iterator(getRootNode());
     }
 
@@ -838,7 +840,7 @@ public class Tree extends AbstractContro
      * @param node starting point of nodes to iterator over
      * @return iterator over all nodes starting form the specified node
      */
-    public Iterator iterator(TreeNode node) {
+    public Iterator<TreeNode> iterator(TreeNode node) {
         if (node == null) {
             node = getRootNode();
         }
@@ -1339,8 +1341,7 @@ public class Tree extends AbstractContro
      * @param previousState contains the previous expanded state
      */
     protected void fireNodeExpanded(TreeNode node, boolean previousState) {
-        for (Iterator it = listeners.iterator(); it.hasNext();) {
-            TreeListener l = (TreeListener) it.next();
+        for (TreeListener l : listeners) {
             l.nodeExpanded(this, node, getContext(), previousState);
         }
     }
@@ -1353,8 +1354,7 @@ public class Tree extends AbstractContro
      * @param previousState contains the previous expanded state
      */
     protected void fireNodeCollapsed(TreeNode node, boolean previousState) {
-        for (Iterator it = listeners.iterator(); it.hasNext();) {
-            TreeListener l = (TreeListener) it.next();
+        for (TreeListener l : listeners) {
             l.nodeCollapsed(this, node, getContext(), previousState);
         }
     }
@@ -1367,8 +1367,7 @@ public class Tree extends AbstractContro
      * @param previousState contains the previous selected state
      */
     protected void fireNodeSelected(TreeNode node, boolean previousState) {
-        for (Iterator it = listeners.iterator(); it.hasNext();) {
-            TreeListener l = (TreeListener) it.next();
+        for (TreeListener l : listeners) {
             l.nodeSelected(this, node, getContext(), previousState);
         }
     }
@@ -1381,8 +1380,7 @@ public class Tree extends AbstractContro
      * @param previousState contains the previous selected state
      */
     protected void fireNodeDeselected(TreeNode node, boolean previousState) {
-        for (Iterator it = listeners.iterator(); it.hasNext();) {
-            TreeListener l = (TreeListener) it.next();
+        for (TreeListener l : listeners) {
             l.nodeDeselected(this, node, getContext(), previousState);
         }
     }
@@ -1685,7 +1683,7 @@ public class Tree extends AbstractContro
     static class BreadthTreeIterator implements Iterator {
 
         /**queue for storing node's. */
-        private List queue = new ArrayList();
+        private List<TreeNode> queue = new ArrayList();
 
         /** indicator to iterate collapsed node's. */
         private boolean iterateCollapsedNodes = true;
@@ -1733,10 +1731,10 @@ public class Tree extends AbstractContro
          * @return the next node in the iteration.
          * @exception NoSuchElementException iteration has no more node.
          */
-        public Object next() {
+        public TreeNode next() {
             try {
                 //remove from the end of queue
-                TreeNode node = (TreeNode) queue.remove(queue.size() - 1);
+                TreeNode node = queue.remove(queue.size() - 1);
                 if (node.hasChildren()) {
                     if (iterateCollapsedNodes || node.isExpanded()) {
                         push(node.getChildren());
@@ -1763,9 +1761,9 @@ public class Tree extends AbstractContro
          *
          * @param children list of node's to push on the beginning of the queue
          */
-        private void push(List children) {
-            for (Iterator it = children.iterator(); it.hasNext();) {
-                queue.add(0, it.next()); //add to the beginning of queue
+        private void push(List<TreeNode> children) {
+            for (TreeNode child : children) {
+                queue.add(0, child); //add to the beginning of queue
             }
         }
     }

Modified: click/trunk/click/extras/src/org/apache/click/extras/tree/TreeNode.java
URL: http://svn.apache.org/viewvc/click/trunk/click/extras/src/org/apache/click/extras/tree/TreeNode.java?rev=941239&r1=941238&r2=941239&view=diff
==============================================================================
--- click/trunk/click/extras/src/org/apache/click/extras/tree/TreeNode.java (original)
+++ click/trunk/click/extras/src/org/apache/click/extras/tree/TreeNode.java Wed May  5 10:47:09
2010
@@ -56,7 +56,7 @@ import java.util.Random;
  */
 public class TreeNode implements Serializable {
 
-    // -------------------------------------------------------------- Constants
+    // Constants --------------------------------------------------------------
 
     /** default serial version id. */
     private static final long serialVersionUID = 1L;
@@ -65,7 +65,7 @@ public class TreeNode implements Seriali
      * not explicitly provided. */
     private final static Random RANDOM = new Random();
 
-    // ----------------------------------------------------- Instance Variables
+    // Instance Variables -----------------------------------------------------
 
     /** Each node must have a unique id in the tree. If a node is not provided
      * an id, one is generated using the java.util.Random class.*/
@@ -91,12 +91,12 @@ public class TreeNode implements Seriali
     private TreeNode parent;
 
     /** List containing this nodes children. */
-    private List children;
+    private List<TreeNode> children;
 
     /** A custom icon the Tree will render for this node. */
     private String icon;
 
-    // ---------------------------------------------------- Public Constructors
+    // Public Constructors ----------------------------------------------------
 
     /**
      * Creates a default node with no value or id.
@@ -161,7 +161,7 @@ public class TreeNode implements Seriali
         parent.add(this);
     }
 
-    // --------------------------------------------- Public Getters and Setters
+    // Public Getters and Setters ---------------------------------------------
 
     /**
      * Returns this node's parent object or null if parent is not specified.
@@ -228,8 +228,8 @@ public class TreeNode implements Seriali
         if (this.childrenSupported != childrenSupported) {
             this.childrenSupported = childrenSupported;
             if (!childrenSupported) {
-                for (int i = 0; i < getChildren().size(); i++) {
-                    remove((TreeNode) children.get(i));
+                for (TreeNode child : getChildren()) {
+                    remove(child);
                 }
             }
         }
@@ -258,7 +258,7 @@ public class TreeNode implements Seriali
      *
      * @return the unmodifiable list of children.
      */
-    public List getChildren() {
+    public List<TreeNode> getChildren() {
         if (children == null) {
             return Collections.EMPTY_LIST;
         }
@@ -324,7 +324,7 @@ public class TreeNode implements Seriali
         this.icon = icon;
     }
 
-    // -------------------------------------------------------- Public Behavior
+    // Public Behavior --------------------------------------------------------
 
     /**
      * Adds the specified node as a child of this node and sets the child's parent
@@ -381,7 +381,7 @@ public class TreeNode implements Seriali
             throw new IllegalArgumentException("null child specified");
         }
         if (getMutableChildren() == null) {
-            children = new ArrayList();
+            children = new ArrayList<TreeNode>();
         }
         if (children.contains(child)) {
             return;
@@ -401,7 +401,7 @@ public class TreeNode implements Seriali
             throw new IllegalArgumentException("null child specified");
         }
         if (getMutableChildren() == null) {
-            children = new ArrayList();
+            children = new ArrayList<TreeNode>();
         }
         getMutableChildren().remove(child);
         child.setParent(null);
@@ -528,6 +528,7 @@ public class TreeNode implements Seriali
      *
      * @see Object#equals(Object)
      */
+    @Override
     public boolean equals(Object thatObject) {
         if (thatObject == this) {
             return true;
@@ -549,6 +550,7 @@ public class TreeNode implements Seriali
      * @return a hash code value for this object.
      * @see Object#hashCode()
      */
+    @Override
     public int hashCode() {
         return getId().hashCode();
     }
@@ -558,6 +560,7 @@ public class TreeNode implements Seriali
      *
      * @return string representation of this node
      */
+    @Override
     public String toString() {
         StringBuffer buffer = new StringBuffer();
         buffer.append("TreeNode -> [");
@@ -570,7 +573,7 @@ public class TreeNode implements Seriali
         return buffer.toString();
     }
 
-    // ----------------------------------------------- Package-private Behavior
+    // Package Private Methods ------------------------------------------------
 
     /**
      * Sets this node to the specified selected state.
@@ -590,14 +593,14 @@ public class TreeNode implements Seriali
         this.expanded = expanded;
     }
 
-    // ------------------------------------------------------- Private Behavior
+    // Private Behavior -------------------------------------------------------
 
     /**
      * Returns the list of mutable children of this node.
      *
      * @return mutable children of this node
      */
-    private List getMutableChildren() {
+    private List<TreeNode> getMutableChildren() {
         return children;
     }
 



Mime
View raw message