You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by rw...@apache.org on 2016/09/02 23:08:50 UTC

svn commit: r1759043 - in /pivot/trunk/wtk/src/org/apache/pivot/wtk: TabPane.java TableView.java TaskAdapter.java TextArea.java Theme.java TreeView.java VFSBrowser.java VFSBrowserSheet.java

Author: rwhitcomb
Date: Fri Sep  2 23:08:50 2016
New Revision: 1759043

URL: http://svn.apache.org/viewvc?rev=1759043&view=rev
Log:
Code cleanup:  Use the Utils.checkNull() method in a bunch of places
where we check for null arguments and throw IllegalArgumentException.

This gives us cleaner code, cleaner and more consistent error messages
and gives an opportunity for internationalization of these messages
since they will be in one place.

Modified:
    pivot/trunk/wtk/src/org/apache/pivot/wtk/TabPane.java
    pivot/trunk/wtk/src/org/apache/pivot/wtk/TableView.java
    pivot/trunk/wtk/src/org/apache/pivot/wtk/TaskAdapter.java
    pivot/trunk/wtk/src/org/apache/pivot/wtk/TextArea.java
    pivot/trunk/wtk/src/org/apache/pivot/wtk/Theme.java
    pivot/trunk/wtk/src/org/apache/pivot/wtk/TreeView.java
    pivot/trunk/wtk/src/org/apache/pivot/wtk/VFSBrowser.java
    pivot/trunk/wtk/src/org/apache/pivot/wtk/VFSBrowserSheet.java

Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/TabPane.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/TabPane.java?rev=1759043&r1=1759042&r2=1759043&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/TabPane.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/TabPane.java Fri Sep  2 23:08:50 2016
@@ -23,6 +23,7 @@ import org.apache.pivot.collections.Arra
 import org.apache.pivot.collections.Sequence;
 import org.apache.pivot.util.ImmutableIterator;
 import org.apache.pivot.util.ListenerList;
+import org.apache.pivot.util.Utils;
 import org.apache.pivot.util.Vote;
 import org.apache.pivot.wtk.content.ButtonDataRenderer;
 import org.apache.pivot.wtk.skin.TabPaneSkin;
@@ -50,9 +51,7 @@ public class TabPane extends Container {
 
         @Override
         public void insert(Component tab, int index) {
-            if (tab == null) {
-                throw new IllegalArgumentException("tab is null.");
-            }
+            Utils.checkNull(tab, "Tab component");
 
             // Add the tab to the component sequence
             TabPane.this.add(tab);
@@ -355,7 +354,7 @@ public class TabPane extends Container {
         } else {
             int index = tabs.indexOf(comp);
             if (index < 0) {
-                throw new IllegalArgumentException("component is not a child of the TabPane");
+                throw new IllegalArgumentException("Component is not a child of the TabPane");
             }
             setSelectedIndex(index);
         }
@@ -366,9 +365,7 @@ public class TabPane extends Container {
     }
 
     public void setTabDataRenderer(Button.DataRenderer tabDataRenderer) {
-        if (tabDataRenderer == null) {
-            throw new IllegalArgumentException();
-        }
+        Utils.checkNull(tabDataRenderer, "Tab data renderer");
 
         Button.DataRenderer previousTabDataRenderer = this.tabDataRenderer;
         if (previousTabDataRenderer != tabDataRenderer) {

Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/TableView.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/TableView.java?rev=1759043&r1=1759042&r2=1759043&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/TableView.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/TableView.java Fri Sep  2 23:08:50 2016
@@ -36,6 +36,7 @@ import org.apache.pivot.json.JSONSeriali
 import org.apache.pivot.serialization.SerializationException;
 import org.apache.pivot.util.Filter;
 import org.apache.pivot.util.ImmutableIterator;
+import org.apache.pivot.util.Utils;
 import org.apache.pivot.util.ListenerList;
 import org.apache.pivot.wtk.content.TableViewCellRenderer;
 import org.apache.pivot.wtk.content.TableViewHeaderDataRenderer;
@@ -224,9 +225,7 @@ public class TableView extends Component
          * @param headerDataRenderer The new renderer for the header data.
          */
         public void setHeaderDataRenderer(HeaderDataRenderer headerDataRenderer) {
-            if (headerDataRenderer == null) {
-                throw new IllegalArgumentException("headerDataRenderer is null.");
-            }
+            Utils.checkNull(headerDataRenderer, "Header data renderer");
 
             HeaderDataRenderer previousHeaderDataRenderer = this.headerDataRenderer;
             if (previousHeaderDataRenderer != headerDataRenderer) {
@@ -438,9 +437,7 @@ public class TableView extends Component
          * contents of this column.
          */
         public void setCellRenderer(CellRenderer cellRenderer) {
-            if (cellRenderer == null) {
-                throw new IllegalArgumentException("cellRenderer is null.");
-            }
+            Utils.checkNull(cellRenderer, "Cell renderer");
 
             CellRenderer previousCellRenderer = this.cellRenderer;
 
@@ -643,13 +640,11 @@ public class TableView extends Component
 
         @Override
         public void insert(Column column, int index) {
-            if (column == null) {
-                throw new IllegalArgumentException("column is null.");
-            }
+            Utils.checkNull(column, "Column");
 
             if (column.tableView != null) {
                 throw new IllegalArgumentException(
-                    "column is already in use by another table view.");
+                    "Column is already in use by another table view.");
             }
 
             columns.insert(column, index);
@@ -1242,9 +1237,7 @@ public class TableView extends Component
      */
     @SuppressWarnings("unchecked")
     public void setTableData(List<?> tableData) {
-        if (tableData == null) {
-            throw new IllegalArgumentException("tableData is null.");
-        }
+        Utils.checkNull(tableData, "Table data");
 
         List<?> previousTableData = this.tableData;
 
@@ -1283,9 +1276,7 @@ public class TableView extends Component
      * <tt>]</tt>) denoting the data to be presented by the table view.
      */
     public final void setTableData(String tableData) {
-        if (tableData == null) {
-            throw new IllegalArgumentException("tableData is null.");
-        }
+        Utils.checkNull(tableData, "Table data");
 
         try {
             setTableData(JSONSerializer.parseList(tableData));
@@ -1301,9 +1292,7 @@ public class TableView extends Component
      * presented by the table view.
      */
     public void setTableData(URL tableData) {
-        if (tableData == null) {
-            throw new IllegalArgumentException("tableData is null.");
-        }
+        Utils.checkNull(tableData, "URL for table data");
 
         JSONSerializer jsonSerializer = new JSONSerializer();
 
@@ -1411,9 +1400,7 @@ public class TableView extends Component
      * @return The ranges that were actually set.
      */
     public Sequence<Span> setSelectedRanges(Sequence<Span> selectedRanges) {
-        if (selectedRanges == null) {
-            throw new IllegalArgumentException("selectedRanges is null.");
-        }
+        Utils.checkNull(selectedRanges, "Selected ranges");
 
         // When we're in mode NONE, the only thing we can do is to clear the
         // selection
@@ -1429,9 +1416,7 @@ public class TableView extends Component
         for (int i = 0, n = selectedRanges.getLength(); i < n; i++) {
             Span range = selectedRanges.get(i);
 
-            if (range == null) {
-                throw new IllegalArgumentException("range is null.");
-            }
+            Utils.checkNull(range, "Selected range");
 
             if (range.start < 0) {
                 throw new IndexOutOfBoundsException("range.start < 0, " + range.start);
@@ -1465,9 +1450,7 @@ public class TableView extends Component
      * @see #setSelectedRanges(Sequence)
      */
     public final Sequence<Span> setSelectedRanges(String selectedRanges) {
-        if (selectedRanges == null) {
-            throw new IllegalArgumentException("selectedRanges is null.");
-        }
+        Utils.checkNull(selectedRanges, "Selected ranges");
 
         try {
             setSelectedRanges(parseSelectedRanges(selectedRanges));
@@ -1564,9 +1547,7 @@ public class TableView extends Component
      * @return The ranges that were added to the selection.
      */
     public Sequence<Span> addSelectedRange(Span range) {
-        if (range == null) {
-            throw new IllegalArgumentException("range is null.");
-        }
+        Utils.checkNull(range, "Range");
 
         return addSelectedRange(range.start, range.end);
     }
@@ -1626,9 +1607,7 @@ public class TableView extends Component
      * @return The ranges that were removed from the selection.
      */
     public Sequence<Span> removeSelectedRange(Span range) {
-        if (range == null) {
-            throw new IllegalArgumentException("range is null.");
-        }
+        Utils.checkNull(range, "Range");
 
         return removeSelectedRange(range.start, range.end);
     }
@@ -1694,17 +1673,13 @@ public class TableView extends Component
 
     @SuppressWarnings("unchecked")
     public void setSelectedRows(Sequence<Object> rows) {
-        if (rows == null) {
-            throw new IllegalArgumentException("rows is null");
-        }
+        Utils.checkNull(rows, "Selected rows");
 
         ArrayList<Span> selectedRanges = new ArrayList<>();
 
         for (int i = 0, n = rows.getLength(); i < n; i++) {
             Object row = rows.get(i);
-            if (row == null) {
-                throw new IllegalArgumentException("item is null");
-            }
+            Utils.checkNull(row, "Selected row");
 
             int index = ((List<Object>) tableData).indexOf(row);
             if (index == -1) {
@@ -1730,9 +1705,7 @@ public class TableView extends Component
      * @param selectMode The new selection mode.
      */
     public void setSelectMode(SelectMode selectMode) {
-        if (selectMode == null) {
-            throw new IllegalArgumentException("selectMode is null.");
-        }
+        Utils.checkNull(selectMode, "Select mode");
 
         SelectMode previousSelectMode = this.selectMode;
 
@@ -1782,9 +1755,7 @@ public class TableView extends Component
      */
     public Dictionary<String, SortDirection> setSort(
         Sequence<Dictionary.Pair<String, SortDirection>> sort) {
-        if (sort == null) {
-            throw new IllegalArgumentException("sort is null");
-        }
+        Utils.checkNull(sort, "Sort");
 
         sortMap.clear();
         sortList.clear();
@@ -1813,9 +1784,7 @@ public class TableView extends Component
      * or can't be parsed from the JSON input.
      */
     public final Dictionary<String, SortDirection> setSort(String sort) {
-        if (sort == null) {
-            throw new IllegalArgumentException("sort is null");
-        }
+        Utils.checkNull(sort, "Sort");
 
         try {
             setSort(parseSort(sort));
@@ -1916,9 +1885,7 @@ public class TableView extends Component
     }
 
     public void setTableDataBindType(BindType tableDataBindType) {
-        if (tableDataBindType == null) {
-            throw new IllegalArgumentException("tableDataBindType is null");
-        }
+        Utils.checkNull(tableDataBindType, "Table data bind type");
 
         BindType previousTableDataBindType = this.tableDataBindType;
 
@@ -1960,9 +1927,7 @@ public class TableView extends Component
     }
 
     public void setSelectedRowBindType(BindType selectedRowBindType) {
-        if (selectedRowBindType == null) {
-            throw new IllegalArgumentException("selectedRowBindType is null");
-        }
+        Utils.checkNull(selectedRowBindType, "Selected row bind type");
 
         BindType previousSelectedRowBindType = this.selectedRowBindType;
         if (previousSelectedRowBindType != selectedRowBindType) {
@@ -2003,9 +1968,7 @@ public class TableView extends Component
     }
 
     public void setSelectedRowsBindType(BindType selectedRowsBindType) {
-        if (selectedRowsBindType == null) {
-            throw new IllegalArgumentException("selectedRowsBindType is null");
-        }
+        Utils.checkNull(selectedRowsBindType, "Selected rows bind type");
 
         BindType previousSelectedRowsBindType = this.selectedRowsBindType;
         if (previousSelectedRowsBindType != selectedRowsBindType) {

Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/TaskAdapter.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/TaskAdapter.java?rev=1759043&r1=1759042&r2=1759043&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/TaskAdapter.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/TaskAdapter.java Fri Sep  2 23:08:50 2016
@@ -16,6 +16,7 @@
  */
 package org.apache.pivot.wtk;
 
+import org.apache.pivot.util.Utils;
 import org.apache.pivot.util.concurrent.Task;
 import org.apache.pivot.util.concurrent.TaskListener;
 
@@ -68,9 +69,7 @@ public class TaskAdapter<T> implements T
      * thread
      */
     public TaskAdapter(TaskListener<T> taskListener) {
-        if (taskListener == null) {
-            throw new IllegalArgumentException("taskListener cannot be null");
-        }
+        Utils.checkNull(taskListener, "Task listener");
 
         this.taskListener = taskListener;
     }

Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/TextArea.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/TextArea.java?rev=1759043&r1=1759042&r2=1759043&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/TextArea.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/TextArea.java Fri Sep  2 23:08:50 2016
@@ -31,6 +31,7 @@ import org.apache.pivot.collections.Sequ
 import org.apache.pivot.json.JSON;
 import org.apache.pivot.util.ImmutableIterator;
 import org.apache.pivot.util.ListenerList;
+import org.apache.pivot.util.Utils;
 
 /**
  * A component that allows a user to enter multiple lines of unformatted text.
@@ -88,9 +89,7 @@ public class TextArea extends Component
         }
 
         public void insertText(CharSequence text, int index) {
-            if (text == null) {
-                throw new IllegalArgumentException();
-            }
+            Utils.checkNull(text, "Text to insert");
 
             indexBoundsCheck("index", index, 0, characters.length());
 
@@ -316,13 +315,11 @@ public class TextArea extends Component
 
         @Override
         public void insert(Paragraph paragraph, int index) {
-            if (paragraph == null) {
-                throw new IllegalArgumentException("paragraph is null.");
-            }
+            Utils.checkNull(paragraph, "Paragraph");
 
             if (paragraph.textArea != null) {
                 throw new IllegalArgumentException(
-                    "paragraph is already in use by another text area.");
+                    "Paragraph is already in use by another text area.");
             }
 
             // Determine insertion count, including terminator character
@@ -672,9 +669,7 @@ public class TextArea extends Component
      * @param text The new text for the control (cannot be {@code null}).
      */
     public void setText(String text) {
-        if (text == null) {
-            throw new IllegalArgumentException();
-        }
+        Utils.checkNull(text, "Text");
 
         if (text.length() > maximumLength) {
             throw new IllegalArgumentException("Text length is greater than maximum length.");
@@ -690,9 +685,7 @@ public class TextArea extends Component
     }
 
     public void setText(URL textURL) throws IOException {
-        if (textURL == null) {
-            throw new IllegalArgumentException("URL for text is null.");
-        }
+        Utils.checkNull(textURL, "URL for text");
 
         try (InputStream inputStream = textURL.openStream()) {
             setText(new InputStreamReader(inputStream));
@@ -700,9 +693,7 @@ public class TextArea extends Component
     }
 
     public void setText(Reader textReader) throws IOException {
-        if (textReader == null) {
-            throw new IllegalArgumentException();
-        }
+        Utils.checkNull(textReader, "Text reader");
 
         // Construct the paragraph list
         ArrayList<Paragraph> paragraphsLocal = new ArrayList<>();
@@ -758,9 +749,7 @@ public class TextArea extends Component
     }
 
     private void insertText(CharSequence text, int index, boolean addToEditHistory) {
-        if (text == null) {
-            throw new IllegalArgumentException();
-        }
+        Utils.checkNull(text, "Text to insert");
 
         indexBoundsCheck("index", index, 0, characterCount);
 
@@ -1043,9 +1032,7 @@ public class TextArea extends Component
      * @see #setSelection(int, int)
      */
     public final void setSelection(Span selection) {
-        if (selection == null) {
-            throw new IllegalArgumentException("selection is null.");
-        }
+        Utils.checkNull(selection, "Selection span");
 
         setSelection(Math.min(selection.start, selection.end), (int) selection.getLength());
     }
@@ -1159,9 +1146,7 @@ public class TextArea extends Component
     }
 
     public void setTextBindType(BindType textBindType) {
-        if (textBindType == null) {
-            throw new IllegalArgumentException();
-        }
+        Utils.checkNull(textBindType, "Text bind type");
 
         BindType previousTextBindType = this.textBindType;
 

Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/Theme.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/Theme.java?rev=1759043&r1=1759042&r2=1759043&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/Theme.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/Theme.java Fri Sep  2 23:08:50 2016
@@ -22,6 +22,7 @@ import java.awt.Font;
 import org.apache.pivot.collections.Dictionary;
 import org.apache.pivot.collections.HashMap;
 import org.apache.pivot.util.Service;
+import org.apache.pivot.util.Utils;
 import org.apache.pivot.wtk.skin.BorderSkin;
 import org.apache.pivot.wtk.skin.BoxPaneSkin;
 import org.apache.pivot.wtk.skin.CardPaneSkin;
@@ -197,9 +198,7 @@ public abstract class Theme {
      * the component class.
      */
     public Class<? extends Skin> get(Class<? extends Component> componentClass) {
-        if (componentClass == null) {
-            throw new IllegalArgumentException("Component class is null.");
-        }
+        Utils.checkNull(componentClass, "Component class");
 
         return componentSkinMap.get(componentClass);
     }
@@ -212,13 +211,8 @@ public abstract class Theme {
      * @param skinClass The skin class.
      */
     public void set(Class<? extends Component> componentClass, Class<? extends Skin> skinClass) {
-        if (componentClass == null) {
-            throw new IllegalArgumentException("Component class is null.");
-        }
-
-        if (skinClass == null) {
-            throw new IllegalArgumentException("Skin class is null.");
-        }
+        Utils.checkNull(componentClass, "Component class");
+        Utils.checkNull(skinClass, "Skin class");
 
         componentSkinMap.put(componentClass, skinClass);
     }

Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/TreeView.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/TreeView.java?rev=1759043&r1=1759042&r2=1759043&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/TreeView.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/TreeView.java Fri Sep  2 23:08:50 2016
@@ -30,6 +30,7 @@ import org.apache.pivot.collections.immu
 import org.apache.pivot.util.Filter;
 import org.apache.pivot.util.ListenerList;
 import org.apache.pivot.util.Vote;
+import org.apache.pivot.util.Utils;
 import org.apache.pivot.wtk.content.TreeViewNodeRenderer;
 
 /**
@@ -931,6 +932,14 @@ public class TreeView extends Component
         return treeData;
     }
 
+    private void checkNullOrEmpty(Path path) {
+        Utils.checkNull(path, "Path");
+
+        if (path.getLength() == 0) {
+            throw new IllegalArgumentException("Path is empty.");
+        }
+    }
+
     /**
      * Sets the tree data. Note that it is the responsibility of the caller to
      * ensure that the current tree node renderer is capable of displaying the
@@ -945,9 +954,7 @@ public class TreeView extends Component
      * @param treeData The data to be presented by the tree.
      */
     public void setTreeData(List<?> treeData) {
-        if (treeData == null) {
-            throw new IllegalArgumentException("treeData is null.");
-        }
+        Utils.checkNull(treeData, "Tree data");
 
         List<?> previousTreeData = this.treeData;
 
@@ -1005,9 +1012,7 @@ public class TreeView extends Component
      * @param nodeRenderer The new node renderer.
      */
     public void setNodeRenderer(NodeRenderer nodeRenderer) {
-        if (nodeRenderer == null) {
-            throw new IllegalArgumentException("nodeRenderer is null.");
-        }
+        Utils.checkNull(nodeRenderer, "Node renderer");
 
         NodeRenderer previousNodeRenderer = this.nodeRenderer;
 
@@ -1061,9 +1066,7 @@ public class TreeView extends Component
      * @see TreeViewSelectionListener
      */
     public void setSelectMode(SelectMode selectMode) {
-        if (selectMode == null) {
-            throw new IllegalArgumentException("selectMode is null");
-        }
+        Utils.checkNull(selectMode, "Select mode");
 
         SelectMode previousSelectMode = this.selectMode;
 
@@ -1100,9 +1103,7 @@ public class TreeView extends Component
      * <tt>NONE</tt>).
      */
     public Sequence<Path> setSelectedPaths(Sequence<Path> selectedPaths) {
-        if (selectedPaths == null) {
-            throw new IllegalArgumentException("selectedPaths is null.");
-        }
+        Utils.checkNull(selectedPaths, "Selected paths");
 
         if (selectMode == SelectMode.NONE) {
             throw new IllegalStateException("Selection is not enabled.");
@@ -1177,13 +1178,7 @@ public class TreeView extends Component
      * @param path The new path to select.
      */
     public void setSelectedPath(Path path) {
-        if (path == null) {
-            throw new IllegalArgumentException("path is null.");
-        }
-
-        if (path.getLength() == 0) {
-            throw new IllegalArgumentException("path is empty.");
-        }
+        checkNullOrEmpty(path);
 
         setSelectedPaths(new ArrayList<Path>(path));
     }
@@ -1214,13 +1209,7 @@ public class TreeView extends Component
      * @throws IllegalStateException If multi-select is not enabled.
      */
     public boolean addSelectedPath(Path path) {
-        if (path == null) {
-            throw new IllegalArgumentException("path is null.");
-        }
-
-        if (path.getLength() == 0) {
-            throw new IllegalArgumentException("path is empty.");
-        }
+        checkNullOrEmpty(path);
 
         if (selectMode != SelectMode.MULTI) {
             throw new IllegalStateException("Tree view is not in multi-select mode.");
@@ -1251,13 +1240,7 @@ public class TreeView extends Component
      * @throws IllegalStateException If multi-select is not enabled.
      */
     public boolean removeSelectedPath(Path path) {
-        if (path == null) {
-            throw new IllegalArgumentException("path is null.");
-        }
-
-        if (path.getLength() == 0) {
-            throw new IllegalArgumentException("path is empty.");
-        }
+        checkNullOrEmpty(path);
 
         if (selectMode != SelectMode.MULTI) {
             throw new IllegalStateException("Tree view is not in multi-select mode.");
@@ -1320,9 +1303,7 @@ public class TreeView extends Component
      * @param path Path to the node to check.
      */
     public boolean isNodeSelected(Path path) {
-        if (path == null) {
-            throw new IllegalArgumentException("path is null.");
-        }
+        Utils.checkNull(path, "Path");
 
         return (selectedPaths.indexOf(path) >= 0);
     }
@@ -1335,9 +1316,7 @@ public class TreeView extends Component
      */
     @SuppressWarnings("unchecked")
     public boolean isNodeDisabled(Path path) {
-        if (path == null) {
-            throw new IllegalArgumentException("path is null.");
-        }
+        Utils.checkNull(path, "Path");
 
         boolean disabled = false;
 
@@ -1464,9 +1443,7 @@ public class TreeView extends Component
      * @see #getCheckmarksEnabled()
      */
     public boolean isNodeChecked(Path path) {
-        if (path == null) {
-            throw new IllegalArgumentException("path is null.");
-        }
+        Utils.checkNull(path, "Path");
 
         return (checkedPaths.indexOf(path) >= 0);
     }
@@ -1485,9 +1462,7 @@ public class TreeView extends Component
      * @see #setShowMixedCheckmarkState(boolean)
      */
     public NodeCheckState getNodeCheckState(Path path) {
-        if (path == null) {
-            throw new IllegalArgumentException("path is null.");
-        }
+        Utils.checkNull(path, "Path");
 
         NodeCheckState checkState = NodeCheckState.UNCHECKED;
 
@@ -1528,13 +1503,7 @@ public class TreeView extends Component
      * @see NodeCheckState#MIXED
      */
     public void setNodeChecked(Path path, boolean checked) {
-        if (path == null) {
-            throw new IllegalArgumentException("path is null.");
-        }
-
-        if (path.getLength() == 0) {
-            throw new IllegalArgumentException("path is empty.");
-        }
+        checkNullOrEmpty(path);
 
         if (!checkmarksEnabled) {
             throw new IllegalStateException("Checkmarks are not enabled.");
@@ -1657,13 +1626,7 @@ public class TreeView extends Component
      * collapse it.
      */
     public void setBranchExpanded(Path path, boolean expanded) {
-        if (path == null) {
-            throw new IllegalArgumentException("path is null.");
-        }
-
-        if (path.getLength() == 0) {
-            throw new IllegalArgumentException("path is empty.");
-        }
+        checkNullOrEmpty(path);
 
         // Give listeners a chance to veto the operation
         Vote vote = treeViewBranchListeners.previewBranchExpandedChange(this, path);
@@ -1698,9 +1661,7 @@ public class TreeView extends Component
      * @return <tt>true</tt> if the branch is expanded; <tt>false</tt> otherwise.
      */
     public boolean isBranchExpanded(Path path) {
-        if (path == null) {
-            throw new IllegalArgumentException("path is null.");
-        }
+        checkNullOrEmpty(path);
 
         return (expandedPaths.indexOf(path) >= 0);
     }
@@ -1822,13 +1783,7 @@ public class TreeView extends Component
      * @return The bounds, or <tt>null</tt> if the node is not currently visible.
      */
     public Bounds getNodeBounds(Path path) {
-        if (path == null) {
-            throw new IllegalArgumentException("path is null.");
-        }
-
-        if (path.getLength() == 0) {
-            throw new IllegalArgumentException("path is empty.");
-        }
+        checkNullOrEmpty(path);
 
         TreeView.Skin treeViewSkin = (TreeView.Skin) getSkin();
         return treeViewSkin.getNodeBounds(path);

Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/VFSBrowser.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/VFSBrowser.java?rev=1759043&r1=1759042&r2=1759043&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/VFSBrowser.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/VFSBrowser.java Fri Sep  2 23:08:50 2016
@@ -31,6 +31,7 @@ import org.apache.pivot.collections.immu
 import org.apache.pivot.io.FileObjectList;
 import org.apache.pivot.util.Filter;
 import org.apache.pivot.util.ListenerList;
+import org.apache.pivot.util.Utils;
 
 /**
  * A file browser that uses the Apache Commons VFS (Virtual File System) to be
@@ -155,9 +156,7 @@ public class VFSBrowser extends Containe
      * @throws FileSystemException if there are problems.
      */
     public VFSBrowser(FileSystemManager manager, String rootFolder, String homeFolder) throws FileSystemException {
-        if (rootFolder == null) {
-            throw new IllegalArgumentException("Root folder is null.");
-        }
+        Utils.checkNull(rootFolder, "Root folder");
 
         // Note: these methods all could trigger events, but since we're
         // in the constructor and the skin isn't set yet, there will not
@@ -219,9 +218,7 @@ public class VFSBrowser extends Containe
      * @throws FileSystemException if there are any problems.
      */
     public void setRootDirectory(FileObject rootDirectory) throws FileSystemException {
-        if (rootDirectory == null) {
-            throw new IllegalArgumentException("Root directory is null.");
-        }
+        Utils.checkNull(rootDirectory, "Root directory");
 
         // Give some grace to set the root folder to an actual file and
         // have it work (by using the parent folder instead)
@@ -269,9 +266,7 @@ public class VFSBrowser extends Containe
      * @throws FileSystemException if there are any problems.
      */
     public void setHomeDirectory(FileObject homeDirectory) throws FileSystemException {
-        if (homeDirectory == null) {
-            throw new IllegalArgumentException("Home directory is null.");
-        }
+        Utils.checkNull(homeDirectory, "Home directory");
 
         // Give some grace to set the home folder to an actual file and
         // have it work (by using the parent folder instead)
@@ -303,15 +298,13 @@ public class VFSBrowser extends Containe
      * @throws FileSystemException if there are any problems.
      */
     public boolean addSelectedFile(FileObject file) throws FileSystemException {
-        if (file == null) {
-            throw new IllegalArgumentException();
-        }
+        Utils.checkNull(file, "Selected file");
 
         // TODO: is this a good way to do this?
         // if (file.isAbsolute()) {
         if (baseFileName != null && baseFileName.isAncestor(file.getName())) {
             if (!file.getParent().equals(rootDirectory)) {
-                throw new IllegalArgumentException();
+                throw new IllegalArgumentException("Selected file is not in the root directory");
             }
         } else {
             file = manager.resolveFile(rootDirectory, file.getName().getBaseName());
@@ -333,9 +326,7 @@ public class VFSBrowser extends Containe
      * not already selected.
      */
     public boolean removeSelectedFile(FileObject file) {
-        if (file == null) {
-            throw new IllegalArgumentException();
-        }
+        Utils.checkNull(file, "Selected file");
 
         int index = selectedFiles.remove(file);
         if (index != -1) {
@@ -399,9 +390,7 @@ public class VFSBrowser extends Containe
      */
     public Sequence<FileObject> setSelectedFiles(Sequence<FileObject> selectedFiles)
         throws FileSystemException {
-        if (selectedFiles == null) {
-            throw new IllegalArgumentException("selectedFiles is null.");
-        }
+        Utils.checkNull(selectedFiles, "Selected files");
 
         if (!multiSelect && selectedFiles.getLength() > 1) {
             throw new IllegalArgumentException("Multi-select is not enabled.");
@@ -414,9 +403,7 @@ public class VFSBrowser extends Containe
         for (int i = 0, n = selectedFiles.getLength(); i < n; i++) {
             FileObject file = selectedFiles.get(i);
 
-            if (file == null) {
-                throw new IllegalArgumentException("file is null.");
-            }
+            Utils.checkNull(file, "Selected file");
 
             // TODO: is this correct?
             // if (!file.isAbsolute()) {

Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/VFSBrowserSheet.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/VFSBrowserSheet.java?rev=1759043&r1=1759042&r2=1759043&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/VFSBrowserSheet.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/VFSBrowserSheet.java Fri Sep  2 23:08:50 2016
@@ -28,6 +28,7 @@ import org.apache.pivot.collections.immu
 import org.apache.pivot.io.FileObjectList;
 import org.apache.pivot.util.Filter;
 import org.apache.pivot.util.ListenerList;
+import org.apache.pivot.util.Utils;
 
 /**
  * A file browser sheet that uses the Apache Commons VFS (Virtual File System)
@@ -174,13 +175,8 @@ public class VFSBrowserSheet extends She
     public VFSBrowserSheet(FileSystemManager manager, Mode mode, String rootFolder, String homeFolder)
             throws FileSystemException
     {
-        if (mode == null) {
-            throw new IllegalArgumentException("Mode is null.");
-        }
-
-        if (rootFolder == null) {
-            throw new IllegalArgumentException("Root folder is null.");
-        }
+        Utils.checkNull(mode, "Mode");
+        Utils.checkNull(rootFolder, "Root folder");
 
         this.mode = mode;
 
@@ -210,13 +206,8 @@ public class VFSBrowserSheet extends She
     public VFSBrowserSheet(FileSystemManager manager, Mode mode, FileObject rootFolder, FileObject homeFolder)
             throws FileSystemException
     {
-        if (mode == null) {
-            throw new IllegalArgumentException("Mode is null.");
-        }
-
-        if (rootFolder == null) {
-            throw new IllegalArgumentException("Root folder is null.");
-        }
+        Utils.checkNull(mode, "Mode");
+        Utils.checkNull(rootFolder, "Root folder");
 
         this.mode = mode;
 
@@ -261,9 +252,7 @@ public class VFSBrowserSheet extends She
     }
 
     public void setMode(Mode mode) {
-        if (mode == null) {
-            throw new IllegalArgumentException("Mode is null.");
-        }
+        Utils.checkNull(mode, "Mode");
 
         Mode previousMode = this.mode;
 
@@ -282,9 +271,7 @@ public class VFSBrowserSheet extends She
     }
 
     public void setRootDirectory(FileObject rootDirectory) throws FileSystemException {
-        if (rootDirectory == null) {
-            throw new IllegalArgumentException("Root directory is null.");
-        }
+        Utils.checkNull(rootDirectory, "Root directory");
 
         // Give some grace to set the root folder to an actual file and
         // have it work (by using the parent folder instead)
@@ -321,16 +308,14 @@ public class VFSBrowserSheet extends She
     public void setHomeDirectory(FileObject homeDirectory)
             throws FileSystemException
     {
-        if (homeDirectory == null) {
-            throw new IllegalArgumentException("Home file is null.");
-        }
+        Utils.checkNull(homeDirectory, "Home directory");
 
         // Give some grace to set the home folder to an actual file and
         // have it work (by using the parent folder instead)
         if (homeDirectory.getType() != FileType.FOLDER) {
             homeDirectory = homeDirectory.getParent();
             if (homeDirectory == null || homeDirectory.getType() != FileType.FOLDER) {
-                throw new IllegalArgumentException("Root file is not a directory.");
+                throw new IllegalArgumentException("Home file is not a directory.");
             }
         }
 
@@ -400,9 +385,7 @@ public class VFSBrowserSheet extends She
      */
     public Sequence<FileObject> setSelectedFiles(Sequence<FileObject> selectedFiles)
         throws FileSystemException {
-        if (selectedFiles == null) {
-            throw new IllegalArgumentException("selectedFiles is null.");
-        }
+        Utils.checkNull(selectedFiles, "Selected files");
 
         if (mode != Mode.OPEN_MULTIPLE && selectedFiles.getLength() > 1) {
             throw new IllegalArgumentException("Multi-select is not enabled.");
@@ -415,9 +398,7 @@ public class VFSBrowserSheet extends She
         for (int i = 0, n = selectedFiles.getLength(); i < n; i++) {
             FileObject file = selectedFiles.get(i);
 
-            if (file == null) {
-                throw new IllegalArgumentException("Selected file is null.");
-            }
+            Utils.checkNull(file, "Selected file");
 
             // TODO: is this correct?
             // if (!file.isAbsolute()) {