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 2018/06/18 14:51:41 UTC
svn commit: r1833730 [1/2] - in /pivot/trunk:
core/src/org/apache/pivot/collections/
core/src/org/apache/pivot/serialization/
core/test/org/apache/pivot/collections/test/
wtk-terra/src/org/apache/pivot/wtk/skin/terra/
wtk/src/org/apache/pivot/wtk/ wtk/...
Author: rwhitcomb
Date: Mon Jun 18 14:51:41 2018
New Revision: 1833730
URL: http://svn.apache.org/viewvc?rev=1833730&view=rev
Log:
PIVOT-1032: Working on the style errors.
Modified:
pivot/trunk/core/src/org/apache/pivot/collections/ArrayList.java
pivot/trunk/core/src/org/apache/pivot/collections/EnumSet.java
pivot/trunk/core/src/org/apache/pivot/collections/Sequence.java
pivot/trunk/core/src/org/apache/pivot/serialization/CSVSerializer.java
pivot/trunk/core/src/org/apache/pivot/serialization/CSVSerializerListener.java
pivot/trunk/core/test/org/apache/pivot/collections/test/ArrayListTest.java
pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTableViewSkin.java
pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTextInputSkin.java
pivot/trunk/wtk/src/org/apache/pivot/wtk/CSSColor.java
pivot/trunk/wtk/src/org/apache/pivot/wtk/Cursor.java
pivot/trunk/wtk/src/org/apache/pivot/wtk/Origin.java
pivot/trunk/wtk/src/org/apache/pivot/wtk/Platform.java
pivot/trunk/wtk/src/org/apache/pivot/wtk/media/BufferedImageSerializer.java
Modified: pivot/trunk/core/src/org/apache/pivot/collections/ArrayList.java
URL: http://svn.apache.org/viewvc/pivot/trunk/core/src/org/apache/pivot/collections/ArrayList.java?rev=1833730&r1=1833729&r2=1833730&view=diff
==============================================================================
--- pivot/trunk/core/src/org/apache/pivot/collections/ArrayList.java (original)
+++ pivot/trunk/core/src/org/apache/pivot/collections/ArrayList.java Mon Jun 18 14:51:41 2018
@@ -30,16 +30,24 @@ import org.apache.pivot.util.Utils;
* Implementation of the {@link List} interface that is backed by an array. <p>
* NOTE This class is not thread-safe. For concurrent access, use a
* {@link org.apache.pivot.collections.concurrent.SynchronizedList}.
+ *
+ * @param <T> Type of the list elements.
*/
public class ArrayList<T> implements List<T>, Serializable {
private static final long serialVersionUID = 2123086211369612675L;
+ /**
+ * Iterator through the items of the ArrayList.
+ */
private class ArrayListItemIterator implements ItemIterator<T> {
private int index = 0;
private int modificationCountLocal;
private boolean forward = true;
- public ArrayListItemIterator() {
+ /**
+ * Initialize the iterator.
+ */
+ ArrayListItemIterator() {
modificationCountLocal = ArrayList.this.modificationCount;
}
@@ -92,7 +100,7 @@ public class ArrayList<T> implements Lis
}
@Override
- public void insert(T item) {
+ public void insert(final T item) {
indexBoundsCheck();
ArrayList.this.insert(item, index);
@@ -100,7 +108,7 @@ public class ArrayList<T> implements Lis
}
@Override
- public void update(T item) {
+ public void update(final T item) {
indexBoundsCheck();
ArrayList.this.update(forward ? index - 1 : index, item);
@@ -119,6 +127,10 @@ public class ArrayList<T> implements Lis
modificationCountLocal++;
}
+ /**
+ * Check the current index against the ArrayList length.
+ * @throws IndexOutOfBoundsException if the index is out of range.
+ */
private void indexBoundsCheck() {
Utils.checkIndexBounds(index, 0, ArrayList.this.length);
}
@@ -134,27 +146,55 @@ public class ArrayList<T> implements Lis
public static final int DEFAULT_CAPACITY = 10;
+ /**
+ * Construct a new unsorted ArrayList with the default capacity.
+ */
public ArrayList() {
items = new Object[DEFAULT_CAPACITY];
}
- public ArrayList(Comparator<T> comparator) {
+ /**
+ * Construct a new ArrayList sorted by the given comparator, with the
+ * default capacity.
+ *
+ * @param comparator A comparator to sort the entries in the list.
+ */
+ public ArrayList(final Comparator<T> comparator) {
this();
this.comparator = comparator;
}
- public ArrayList(int capacity) {
+ /**
+ * Construct a new unsorted ArrayList with the given initial capacity.
+ *
+ * @param capacity The initial capacity for this list.
+ * @throws IllegalArgumentException if the given capacity is negative.
+ */
+ public ArrayList(final int capacity) {
Utils.checkNonNegative(capacity, "capacity");
items = new Object[capacity];
}
- @SuppressWarnings({ "unchecked" })
- public ArrayList(T... items) {
+ /**
+ * Construct a new ArrayList with the given list of items.
+ *
+ * @param items The initial list of values for the list.
+ */
+ @SuppressWarnings("unchecked")
+ public ArrayList(final T... items) {
this(items, 0, items.length);
}
- public ArrayList(T[] items, int index, int count) {
+ /**
+ * Construct a new ArrayList with a subset of the given list of items.
+ *
+ * @param items The full array of items to choose from.
+ * @param index The starting location of the items to choose.
+ * @param count The count of items to pick from the full array, starting at the index.
+ * @throws IndexOutOfBoundsException if the given index is negative or greater than the count.
+ */
+ public ArrayList(final T[] items, final int index, final int count) {
Utils.checkNull(items, "items");
Utils.checkIndexBounds(index, count, 0, items.length);
@@ -164,11 +204,24 @@ public class ArrayList<T> implements Lis
length = count;
}
- public ArrayList(Sequence<T> items) {
+ /**
+ * Construct a new ArrayList with the given sequence of items.
+ *
+ * @param items The initial list of values for the list.
+ */
+ public ArrayList(final Sequence<T> items) {
this(items, 0, items.getLength());
}
- public ArrayList(Sequence<T> items, int index, int count) {
+ /**
+ * Construct a new ArrayList with a subset of the given sequence of items.
+ *
+ * @param items The full sequence of items to choose from.
+ * @param index The starting location of the items to choose.
+ * @param count The count of items to pick from the full sequence, starting at the index.
+ * @throws IndexOutOfBoundsException if the given index is negative or greater than the count.
+ */
+ public ArrayList(final Sequence<T> items, final int index, final int count) {
Utils.checkNull(items, "items");
Utils.checkIndexBounds(index, count, 0, items.getLength());
@@ -181,11 +234,24 @@ public class ArrayList<T> implements Lis
length = count;
}
- public ArrayList(ArrayList<T> arrayList) {
+ /**
+ * Copy the given ArrayList into a new one.
+ *
+ * @param arrayList The existing list to copy into this one.
+ */
+ public ArrayList(final ArrayList<T> arrayList) {
this(arrayList, 0, arrayList.length);
}
- public ArrayList(ArrayList<T> arrayList, int index, int count) {
+ /**
+ * Construct a new ArrayList with a subset of the given ArrayList.
+ *
+ * @param arrayList The full list of items to choose from.
+ * @param index The starting location of the items to choose.
+ * @param count The count of items to pick from the full list, starting at the index.
+ * @throws IndexOutOfBoundsException if the given index is negative or greater than the count.
+ */
+ public ArrayList(final ArrayList<T> arrayList, final int index, final int count) {
Utils.checkNull(arrayList, "arrayList");
Utils.checkIndexBounds(index, count, 0, arrayList.length);
@@ -197,7 +263,12 @@ public class ArrayList<T> implements Lis
comparator = arrayList.comparator;
}
- public ArrayList(java.util.Collection<T> c) {
+ /**
+ * Copy the given collection into a new ArrayList.
+ *
+ * @param c The existing collection to copy into this list.
+ */
+ public ArrayList(final java.util.Collection<T> c) {
Utils.checkNull(c, "c");
items = c.toArray();
@@ -205,7 +276,7 @@ public class ArrayList<T> implements Lis
}
@Override
- public int add(T item) {
+ public int add(final T item) {
int index = -1;
if (comparator == null) {
@@ -225,11 +296,23 @@ public class ArrayList<T> implements Lis
}
@Override
- public void insert(T item, int index) {
+ public void insert(final T item, final int index) {
insert(item, index, true);
}
- private void insert(T item, int index, boolean validate) {
+ /**
+ * Private method to insert an item into the list, with an option to validate
+ * its position with any comparator.
+ *
+ * @param item The item to insert.
+ * @param index The position at which to insert the item.
+ * @param validate Whether or not to ensure the item is being inserted into
+ * the correct sorted position if the list has a comparator.
+ * @throws IllegalArgumentException if the "validate" parameter is true, and
+ * there is a comparator set, and the given insertion point is incorrect for
+ * the value of the item.
+ */
+ private void insert(final T item, final int index, final boolean validate) {
Utils.checkIndexBounds(index, 0, length);
if (comparator != null && validate) {
@@ -259,7 +342,7 @@ public class ArrayList<T> implements Lis
@SuppressWarnings("unchecked")
@Override
- public T update(int index, T item) {
+ public T update(final int index, final T item) {
Utils.checkIndexBounds(index, 0, length - 1);
T previousItem = (T) items[index];
@@ -273,7 +356,8 @@ public class ArrayList<T> implements Lis
if ((predecessorItem != null && comparator.compare(item, predecessorItem) < 0)
|| (successorItem != null && comparator.compare(item, successorItem) > 0)) {
- throw new IllegalArgumentException("Updated item at index " + index + " is not in correct sorted order.");
+ throw new IllegalArgumentException(
+ "Updated item at index " + index + " is not in correct sorted order.");
}
}
@@ -290,7 +374,7 @@ public class ArrayList<T> implements Lis
}
@Override
- public int remove(T item) {
+ public int remove(final T item) {
int index = indexOf(item);
if (index >= 0) {
@@ -302,7 +386,7 @@ public class ArrayList<T> implements Lis
@SuppressWarnings("unchecked")
@Override
- public Sequence<T> remove(int index, int count) {
+ public Sequence<T> remove(final int index, final int count) {
Utils.checkIndexBounds(index, count, 0, length);
ArrayList<T> removed = new ArrayList<>((T[]) items, index, count);
@@ -343,14 +427,14 @@ public class ArrayList<T> implements Lis
@SuppressWarnings("unchecked")
@Override
- public T get(int index) {
+ public T get(final int index) {
Utils.checkIndexBounds(index, 0, length - 1);
return (T) items[index];
}
@Override
- public int indexOf(T item) {
+ public int indexOf(final T item) {
int i;
if (comparator == null) {
@@ -380,12 +464,21 @@ public class ArrayList<T> implements Lis
return length;
}
- public void addAll(Collection<T> collection) {
+ /**
+ * Add all the elements of the given collection to this list.
+ *
+ * @param collection The collection whose elements should be added.
+ */
+ public void addAll(final Collection<T> collection) {
for (T item : collection) {
add(item);
}
}
+ /**
+ * Trim the internal storage for this list to exactly fit the current
+ * number of items in it.
+ */
public void trimToSize() {
Object[] itemsLocal = new Object[length];
System.arraycopy(this.items, 0, itemsLocal, 0, length);
@@ -394,7 +487,19 @@ public class ArrayList<T> implements Lis
length = itemsLocal.length;
}
- public void ensureCapacity(int capacity) {
+ /**
+ * Ensure there is sufficient capacity in the internal storage for the given
+ * number of items. This can be used before a large number of inserts to
+ * avoid many incremental storage updates during the inserts.
+ * <p> If there is already sufficient storage for the given capacity nothing
+ * happens, regardless of how many items are currently in the list. This means
+ * that to ensure capacity for the current length plus "n" new items, this
+ * method should be called with the {@link getLength} plus the number of items
+ * to insert.
+ *
+ * @param capacity The new capacity to allow for.
+ */
+ public void ensureCapacity(final int capacity) {
if (capacity > items.length) {
int capacityMax = Math.max(this.items.length * 3 / 2, capacity);
Object[] itemsLocal = new Object[capacityMax];
@@ -404,15 +509,27 @@ public class ArrayList<T> implements Lis
}
}
+ /**
+ * @return The current capacity of the list, that is, how many items can be
+ * stored before allocating more memory.
+ */
public int getCapacity() {
return items.length;
}
+ /**
+ * @return The current contents of the list as an array of objects.
+ */
public Object[] toArray() {
return Arrays.copyOf(items, length);
}
- public T[] toArray(Class<? extends T[]> type) {
+ /**
+ * @return The current contents of the list as an array of the given type.
+ * @param type The type of the array elements to be returned (which should
+ * match the declared type of this ArrayList).
+ */
+ public T[] toArray(final Class<? extends T[]> type) {
return Arrays.copyOf(items, length, type);
}
@@ -422,7 +539,7 @@ public class ArrayList<T> implements Lis
}
@Override
- public void setComparator(Comparator<T> comparator) {
+ public void setComparator(final Comparator<T> comparator) {
Comparator<T> previousComparator = this.comparator;
if (comparator != null) {
@@ -452,7 +569,7 @@ public class ArrayList<T> implements Lis
@Override
@SuppressWarnings("unchecked")
- public boolean equals(Object o) {
+ public boolean equals(final Object o) {
boolean equals = false;
if (this == o) {
@@ -490,7 +607,7 @@ public class ArrayList<T> implements Lis
public String toString() {
StringBuilder sb = new StringBuilder();
- sb.append(getClass().getName());
+ sb.append(getClass().getSimpleName());
sb.append(" [");
int i = 0;
@@ -508,12 +625,30 @@ public class ArrayList<T> implements Lis
return sb.toString();
}
- public static <T> void sort(ArrayList<T> arrayList, Comparator<T> comparator) {
+ /**
+ * Sort the current contents of the given list using the given comparator.
+ *
+ * @param <T> Type of the list elements.
+ * @param arrayList The list to sort.
+ * @param comparator The comparator to use to establish the sort order.
+ */
+ public static <T> void sort(final ArrayList<T> arrayList, final Comparator<T> comparator) {
sort(arrayList, 0, arrayList.getLength(), comparator);
}
+ /**
+ * Sort a portion of the given list.
+ *
+ * @param <T> Type of the list elements.
+ * @param arrayList The list to sort.
+ * @param from The beginning index in the list of the items to sort (inclusive).
+ * @param to The ending index of the items to sort (exclusive), that is, the elements
+ * from "from" to "to - 1" are sorted on return.
+ * @param comparator The comparator to use to establish the sorted order.
+ */
@SuppressWarnings("unchecked")
- public static <T> void sort(ArrayList<T> arrayList, int from, int to, Comparator<T> comparator) {
+ public static <T> void sort(final ArrayList<T> arrayList, final int from, final int to,
+ final Comparator<T> comparator) {
Utils.checkNull(arrayList, "arrayList");
Utils.checkNull(comparator, "comparator");
@@ -522,34 +657,49 @@ public class ArrayList<T> implements Lis
arrayList.modificationCount++;
}
- public static <T extends Comparable<? super T>> void sort(ArrayList<T> arrayList) {
- sort(arrayList, new Comparator<T>() {
- @Override
- public int compare(T t1, T t2) {
- return t1.compareTo(t2);
- }
- });
- }
-
+ /**
+ * Sort the given array list according to the "natural" sort order of the comparable elements.
+ * <p> The elements must implement the {@link Comparable} interface, as the default sort calls
+ * the {@link Comparable#compareTo} method to order the elements.
+ *
+ * @param <T> The comparable type of the elements in the list.
+ * @param arrayList The list to sort.
+ */
+ public static <T extends Comparable<? super T>> void sort(final ArrayList<T> arrayList) {
+ sort(arrayList, (o1, o2) -> o1.compareTo(o2));
+ }
+
+ /**
+ * Search for a given element in the list using the "binary search" algorithm, which requires a comparator
+ * to establish the sort order of the elements.
+ *
+ * @param <T> Type of the list elements.
+ * @param arrayList The list to search.
+ * @param item The item to search for in the list.
+ * @param comparator Comparator to use for testing.
+ * @return The index of the item in the list if found, or -1 if the item cannot be found in the list.
+ */
@SuppressWarnings("unchecked")
- public static <T> int binarySearch(ArrayList<T> arrayList, T item, Comparator<T> comparator) {
+ public static <T> int binarySearch(final ArrayList<T> arrayList, final T item, final Comparator<T> comparator) {
Utils.checkNull(arrayList, "arrayList");
Utils.checkNull(comparator, "comparator");
Utils.checkNull(item, "item");
- int index = Arrays.binarySearch((T[]) arrayList.items, 0, arrayList.length, item,
- comparator);
+ int index = Arrays.binarySearch((T[]) arrayList.items, 0, arrayList.length, item, comparator);
return index;
}
- public static <T extends Comparable<? super T>> int binarySearch(ArrayList<T> arrayList, T item) {
- return binarySearch(arrayList, item, new Comparator<T>() {
- @Override
- public int compare(T t1, T t2) {
- return t1.compareTo(t2);
- }
- });
+ /**
+ * Search for an item in the given list using the elements' "natural" ordering.
+ *
+ * @param <T> The comparable type of the elements in the list.
+ * @param arrayList The list to search.
+ * @param item The item to search for.
+ * @return The index of the item in the list if found, or -1 if the item is not found.
+ */
+ public static <T extends Comparable<? super T>> int binarySearch(final ArrayList<T> arrayList, final T item) {
+ return binarySearch(arrayList, item, (o1, o2) -> o1.compareTo(o2));
}
}
Modified: pivot/trunk/core/src/org/apache/pivot/collections/EnumSet.java
URL: http://svn.apache.org/viewvc/pivot/trunk/core/src/org/apache/pivot/collections/EnumSet.java?rev=1833730&r1=1833729&r2=1833730&view=diff
==============================================================================
--- pivot/trunk/core/src/org/apache/pivot/collections/EnumSet.java (original)
+++ pivot/trunk/core/src/org/apache/pivot/collections/EnumSet.java Mon Jun 18 14:51:41 2018
@@ -26,6 +26,8 @@ import org.apache.pivot.util.ListenerLis
/**
* Implementation of the {@link Set} interface that is backed by an array of
* enum values.
+ *
+ * @param <E> The enum type contained in this set.
*/
public class EnumSet<E extends Enum<E>> implements Set<E>, Serializable {
private static final long serialVersionUID = 3544488357505145448L;
@@ -77,7 +79,7 @@ public class EnumSet<E extends Enum<E>>
private transient SetListener.Listeners<E> setListeners = new SetListener.Listeners<>();
- public EnumSet(Class<E> enumClass) {
+ public EnumSet(final Class<E> enumClass) {
this.enumClass = enumClass;
elements = enumClass.getEnumConstants();
@@ -89,7 +91,7 @@ public class EnumSet<E extends Enum<E>>
}
@Override
- public boolean add(E element) {
+ public boolean add(final E element) {
boolean added = false;
int ordinal = element.ordinal();
@@ -105,7 +107,7 @@ public class EnumSet<E extends Enum<E>>
}
@Override
- public boolean remove(E element) {
+ public boolean remove(final E element) {
boolean removed = false;
int ordinal = element.ordinal();
@@ -130,7 +132,7 @@ public class EnumSet<E extends Enum<E>>
}
@Override
- public boolean contains(E element) {
+ public boolean contains(final E element) {
return members[element.ordinal()];
}
@@ -150,7 +152,7 @@ public class EnumSet<E extends Enum<E>>
}
@Override
- public void setComparator(Comparator<E> comparator) {
+ public void setComparator(final Comparator<E> comparator) {
throw new UnsupportedOperationException();
}
@@ -172,7 +174,7 @@ public class EnumSet<E extends Enum<E>>
* in this set.
* @return The new empty set.
*/
- public static <E extends Enum<E>> EnumSet<E> noneOf(Class<E> elementClass) {
+ public static <E extends Enum<E>> EnumSet<E> noneOf(final Class<E> elementClass) {
return new EnumSet<E>(elementClass);
}
@@ -184,7 +186,7 @@ public class EnumSet<E extends Enum<E>>
* in this set.
* @return The new complete set.
*/
- public static <E extends Enum<E>> EnumSet<E> allOf(Class<E> elementClass) {
+ public static <E extends Enum<E>> EnumSet<E> allOf(final Class<E> elementClass) {
EnumSet<E> set = new EnumSet<E>(elementClass);
for (E e : elementClass.getEnumConstants()) {
set.add(e);
@@ -199,7 +201,7 @@ public class EnumSet<E extends Enum<E>>
* @param e The only element to assign to the new set.
* @return The new set containing the single element.
*/
- public static <E extends Enum<E>> EnumSet<E> of(E e) {
+ public static <E extends Enum<E>> EnumSet<E> of(final E e) {
EnumSet<E> set = new EnumSet<>(e.getDeclaringClass());
set.add(e);
return set;
@@ -213,7 +215,7 @@ public class EnumSet<E extends Enum<E>>
* @param e2 The second element to add.
* @return The new set containing only these two elements.
*/
- public static <E extends Enum<E>> EnumSet<E> of (E e1, E e2) {
+ public static <E extends Enum<E>> EnumSet<E> of(final E e1, final E e2) {
EnumSet<E> set = new EnumSet<>(e1.getDeclaringClass());
set.add(e1);
set.add(e2);
@@ -229,7 +231,7 @@ public class EnumSet<E extends Enum<E>>
* @param e3 The third element to add.
* @return The new set containing only these three elements.
*/
- public static <E extends Enum<E>> EnumSet<E> of (E e1, E e2, E e3) {
+ public static <E extends Enum<E>> EnumSet<E> of(final E e1, final E e2, final E e3) {
EnumSet<E> set = new EnumSet<>(e1.getDeclaringClass());
set.add(e1);
set.add(e2);
@@ -247,7 +249,7 @@ public class EnumSet<E extends Enum<E>>
* @param e4 The fourth element to add.
* @return The new set containing only these four elements.
*/
- public static <E extends Enum<E>> EnumSet<E> of(E e1, E e2, E e3, E e4) {
+ public static <E extends Enum<E>> EnumSet<E> of(final E e1, final E e2, final E e3, final E e4) {
EnumSet<E> set = new EnumSet<>(e1.getDeclaringClass());
set.add(e1);
set.add(e2);
@@ -263,7 +265,7 @@ public class EnumSet<E extends Enum<E>>
* @param c The other collection to add to this set.
* @return Whether or not the enum set changed as a result.
*/
- public boolean addAll(Collection<E> c) {
+ public boolean addAll(final Collection<E> c) {
boolean changed = false;
for (E elem : c) {
if (add(elem)) {
Modified: pivot/trunk/core/src/org/apache/pivot/collections/Sequence.java
URL: http://svn.apache.org/viewvc/pivot/trunk/core/src/org/apache/pivot/collections/Sequence.java?rev=1833730&r1=1833729&r2=1833730&view=diff
==============================================================================
--- pivot/trunk/core/src/org/apache/pivot/collections/Sequence.java (original)
+++ pivot/trunk/core/src/org/apache/pivot/collections/Sequence.java Mon Jun 18 14:51:41 2018
@@ -19,18 +19,21 @@ package org.apache.pivot.collections;
import java.util.Iterator;
import java.util.NoSuchElementException;
+import org.apache.pivot.annotations.UnsupportedOperation;
import org.apache.pivot.util.ImmutableIterator;
import org.apache.pivot.util.Utils;
/**
* Interface representing an ordered sequence of items.
+ *
+ * @param <T> The type of elements stored in this sequence.
*/
public interface Sequence<T> {
/**
* Collection of static utility methods providing path access to nested
* sequence data.
*
- * @param <T> note that in Tree the type parameter currently it's not used
+ * @param <T> note that in Tree the type parameter currently is not used
*/
public static class Tree<T> {
/**
@@ -44,54 +47,55 @@ public interface Sequence<T> {
elements = new ArrayList<>();
}
- public Path(Integer... elements) {
+ public Path(final Integer... elements) {
this.elements = new ArrayList<>(elements);
}
- public Path(Path path) {
+ public Path(final Path path) {
elements = new ArrayList<>(path.elements);
}
- public Path(Path path, int depth) {
+ public Path(final Path path, final int depth) {
elements = new ArrayList<>(path.elements, 0, depth);
}
- private Path(ArrayList<Integer> elements) {
+ private Path(final ArrayList<Integer> elements) {
this.elements = elements;
}
@Override
- public int add(Integer element) {
+ public int add(final Integer element) {
return elements.add(element);
}
@Override
- public void insert(Integer element, int index) {
+ public void insert(final Integer element, final int index) {
elements.insert(element, index);
}
@Override
- public Integer update(int index, Integer element) {
+ public Integer update(final int index, final Integer element) {
return elements.update(index, element);
}
@Override
- public int remove(Integer element) {
+ @UnsupportedOperation
+ public int remove(final Integer element) {
throw new UnsupportedOperationException();
}
@Override
- public Sequence<Integer> remove(int index, int count) {
+ public Sequence<Integer> remove(final int index, final int count) {
return elements.remove(index, count);
}
@Override
- public Integer get(int index) {
+ public Integer get(final int index) {
return elements.get(index);
}
@Override
- public int indexOf(Integer element) {
+ public int indexOf(final Integer element) {
return elements.indexOf(element);
}
@@ -130,7 +134,7 @@ public interface Sequence<T> {
return elements.toArray(Integer[].class);
}
- public static Path forDepth(int depth) {
+ public static Path forDepth(final int depth) {
return new Path(new ArrayList<Integer>(depth));
}
}
@@ -139,37 +143,43 @@ public interface Sequence<T> {
* Class representing an immutable path.
*/
public static class ImmutablePath extends Path {
- public ImmutablePath(Integer... elements) {
+ public ImmutablePath(final Integer... elements) {
super(elements);
}
- public ImmutablePath(Path path) {
+ public ImmutablePath(final Path path) {
super(path);
}
@Override
- public int add(Integer element) {
+ @UnsupportedOperation
+ public int add(final Integer element) {
throw new UnsupportedOperationException();
}
@Override
- public void insert(Integer element, int index) {
+ @UnsupportedOperation
+ public void insert(final Integer element, final int index) {
throw new UnsupportedOperationException();
}
@Override
- public Integer update(int index, Integer element) {
+ @UnsupportedOperation
+ public Integer update(final int index, final Integer element) {
throw new UnsupportedOperationException();
}
@Override
- public Sequence<Integer> remove(int index, int count) {
+ @UnsupportedOperation
+ public Sequence<Integer> remove(final int index, final int count) {
throw new UnsupportedOperationException();
}
}
/**
* Nested sequence item iterator interface.
+ *
+ * @param <T> Type of object contained in the sequence and the iterator.
*/
public interface ItemIterator<T> extends Iterator<T> {
/**
@@ -188,7 +198,7 @@ public interface Sequence<T> {
private Path previousPath = null;
private Path nextPath = new Path();
- public DepthFirstItemIterator(Sequence<T> sequence) {
+ public DepthFirstItemIterator(final Sequence<T> sequence) {
stack.push(sequence);
nextPath.add(0);
normalize();
@@ -252,6 +262,7 @@ public interface Sequence<T> {
}
@Override
+ @UnsupportedOperation
public void remove() {
throw new UnsupportedOperationException();
}
@@ -278,7 +289,7 @@ public interface Sequence<T> {
* parent sequence.
*/
@SuppressWarnings("unchecked")
- public static <T> int add(Sequence<T> sequence, T item, Path path) {
+ public static <T> int add(final Sequence<T> sequence, final T item, final Path path) {
return ((Sequence<T>) get(sequence, path)).add(item);
}
@@ -294,7 +305,7 @@ public interface Sequence<T> {
* parent sequence.
*/
@SuppressWarnings("unchecked")
- public static <T> void insert(Sequence<T> sequence, T item, Path path, int index) {
+ public static <T> void insert(final Sequence<T> sequence, final T item, final Path path, final int index) {
((Sequence<T>) get(sequence, path)).insert(item, index);
}
@@ -330,7 +341,7 @@ public interface Sequence<T> {
* @param item The item to remove.
* @return The path of the item that was removed.
*/
- public static <T> Path remove(Sequence<T> sequence, T item) {
+ public static <T> Path remove(final Sequence<T> sequence, final T item) {
Path path = pathOf(sequence, item);
if (path == null) {
throw new IllegalArgumentException("item is not a descendant of sequence.");
@@ -351,7 +362,7 @@ public interface Sequence<T> {
* @return The sequence of items that were removed.
*/
@SuppressWarnings("unchecked")
- public static <T> Sequence<T> remove(final Sequence<T> sequence, final Path path, int count) {
+ public static <T> Sequence<T> remove(final Sequence<T> sequence, final Path path, final int count) {
Utils.checkNull(sequence, "sequence");
Utils.checkNull(path, "path");
@@ -437,7 +448,7 @@ public interface Sequence<T> {
* @param sequence The sequence for which we are requesting an iterator.
* @return The new iterator over the sequence (depth-first order).
*/
- public static <T> ItemIterator<T> depthFirstIterator(Sequence<T> sequence) {
+ public static <T> ItemIterator<T> depthFirstIterator(final Sequence<T> sequence) {
return new DepthFirstItemIterator<>(sequence);
}
@@ -450,7 +461,7 @@ public interface Sequence<T> {
* @return <tt>true</tt> if the second argument is a descendant of the first
* path argument, <tt>false</tt> otherwise.
*/
- public static boolean isDescendant(Path ancestorPath, Path descendantPath) {
+ public static boolean isDescendant(final Path ancestorPath, final Path descendantPath) {
int ancestorLength = ancestorPath.getLength();
int descendantLength = descendantPath.getLength();
@@ -550,7 +561,7 @@ public interface Sequence<T> {
* @param c The other collection to add to this sequence.
*/
default void addAll(Collection<T> c) {
- c.forEach (item -> add(item));
+ c.forEach(item -> add(item));
}
/**
Modified: pivot/trunk/core/src/org/apache/pivot/serialization/CSVSerializer.java
URL: http://svn.apache.org/viewvc/pivot/trunk/core/src/org/apache/pivot/serialization/CSVSerializer.java?rev=1833730&r1=1833729&r2=1833730&view=diff
==============================================================================
--- pivot/trunk/core/src/org/apache/pivot/serialization/CSVSerializer.java (original)
+++ pivot/trunk/core/src/org/apache/pivot/serialization/CSVSerializer.java Mon Jun 18 14:51:41 2018
@@ -50,12 +50,13 @@ public class CSVSerializer implements Se
private Charset charset;
private Type itemType;
- private ArrayList<String> keys = new ArrayList<>();
+ private List<String> keys = new ArrayList<>();
private boolean writeKeys = false;
private boolean verbose = false;
private int c = -1;
+ private static final int BOM = 0xFEFF;
private CSVSerializerListener.Listeners csvSerializerListeners = null;
@@ -70,15 +71,15 @@ public class CSVSerializer implements Se
this(Charset.forName(DEFAULT_CHARSET_NAME), DEFAULT_ITEM_TYPE);
}
- public CSVSerializer(Charset charset) {
+ public CSVSerializer(final Charset charset) {
this(charset, DEFAULT_ITEM_TYPE);
}
- public CSVSerializer(Type itemType) {
+ public CSVSerializer(final Type itemType) {
this(Charset.forName(DEFAULT_CHARSET_NAME), itemType);
}
- public CSVSerializer(Charset charset, Type itemType) {
+ public CSVSerializer(final Charset charset, final Type itemType) {
Utils.checkNull(charset, "charset");
Utils.checkNull(itemType, "itemType");
@@ -117,7 +118,7 @@ public class CSVSerializer implements Se
* @param keys The keys to be read/written.
* @throws IllegalArgumentException for {@code null} input.
*/
- public void setKeys(Sequence<String> keys) {
+ public void setKeys(final Sequence<String> keys) {
Utils.checkNull(keys, "keys");
this.keys = new ArrayList<>(keys);
@@ -129,7 +130,7 @@ public class CSVSerializer implements Se
* @param keys The list of keys to be read/written.
* @throws IllegalArgumentException for {@code null} input.
*/
- public void setKeys(String... keys) {
+ public void setKeys(final String... keys) {
Utils.checkNull(keys, "keys");
setKeys(new ArrayAdapter<>(keys));
@@ -151,7 +152,7 @@ public class CSVSerializer implements Se
* contain the keys. Otherwise, the first line will contain the first line
* of data.
*/
- public void setWriteKeys(boolean writeKeys) {
+ public void setWriteKeys(final boolean writeKeys) {
this.writeKeys = writeKeys;
}
@@ -170,7 +171,7 @@ public class CSVSerializer implements Se
*
* @param verbose Whether or not to echo the input.
*/
- public void setVerbose(boolean verbose) {
+ public void setVerbose(final boolean verbose) {
this.verbose = verbose;
}
@@ -186,7 +187,7 @@ public class CSVSerializer implements Se
*/
@SuppressWarnings("resource")
@Override
- public List<?> readObject(InputStream inputStream) throws IOException, SerializationException {
+ public List<?> readObject(final InputStream inputStream) throws IOException, SerializationException {
Utils.checkNull(inputStream, "inputStream");
Reader reader = new BufferedReader(new InputStreamReader(inputStream, charset), BUFFER_SIZE);
@@ -210,10 +211,11 @@ public class CSVSerializer implements Se
* @throws SerializationException for any formatting errors with the data.
* @throws IllegalArgumentException for {@code null} input reader.
*/
- public List<?> readObject(Reader reader) throws IOException, SerializationException {
+ public List<?> readObject(final Reader reader) throws IOException, SerializationException {
Utils.checkNull(reader, "reader");
LineNumberReader lineNumberReader = new LineNumberReader(reader);
+ lineNumberReader.setLineNumber(1);
if (keys.getLength() == 0) {
// Read keys from first line
@@ -222,17 +224,16 @@ public class CSVSerializer implements Se
throw new SerializationException("Could not read keys from input.");
}
- String[] keysLocal = line.split(",");
- this.keys = new ArrayList<>(keysLocal.length);
+ String[] keysOnLine = line.split(",");
+ this.keys = new ArrayList<>(keysOnLine.length);
- for (int i = 0; i < keysLocal.length; i++) {
- String key = keysLocal[i];
+ for (String key : keysOnLine) {
this.keys.add(key.trim());
}
}
// Create the list and notify the listeners
- ArrayList<Object> items = new ArrayList<>();
+ List<Object> items = new ArrayList<>();
if (csvSerializerListeners != null) {
csvSerializerListeners.beginList(this, items);
@@ -241,8 +242,8 @@ public class CSVSerializer implements Se
// Move to the first character
c = lineNumberReader.read();
- // Ignore BOM (if present)
- if (c == 0xFEFF) {
+ // Ignore Byte Order Mark (if present)
+ if (c == BOM) {
c = lineNumberReader.read();
}
@@ -263,7 +264,7 @@ public class CSVSerializer implements Se
}
} catch (SerializationException exception) {
System.err.println("An error occurred while processing input at line number "
- + (lineNumberReader.getLineNumber() + 1));
+ + lineNumberReader.getLineNumber());
throw exception;
}
@@ -277,7 +278,7 @@ public class CSVSerializer implements Se
}
@SuppressWarnings("unchecked")
- private Object readItem(Reader reader) throws IOException, SerializationException {
+ private Object readItem(final Reader reader) throws IOException, SerializationException {
Object item = null;
if (c != -1) {
@@ -339,7 +340,7 @@ public class CSVSerializer implements Se
return item;
}
- private String readValue(Reader reader) throws IOException, SerializationException {
+ private String readValue(final Reader reader) throws IOException, SerializationException {
String value = null;
// Read the next value from this line, returning null if there are
@@ -409,7 +410,7 @@ public class CSVSerializer implements Se
*/
@SuppressWarnings("resource")
@Override
- public void writeObject(List<?> items, OutputStream outputStream) throws IOException,
+ public void writeObject(final List<?> items, final OutputStream outputStream) throws IOException,
SerializationException {
Utils.checkNull(items, "items");
Utils.checkNull(outputStream, "outputStream");
@@ -434,7 +435,7 @@ public class CSVSerializer implements Se
* @throws IllegalArgumentException for {@code null} input arguments.
*/
@SuppressWarnings("unchecked")
- public void writeObject(List<?> items, Writer writer) throws IOException {
+ public void writeObject(final List<?> items, final Writer writer) throws IOException {
Utils.checkNull(items, "items");
Utils.checkNull(writer, "writer");
@@ -449,6 +450,8 @@ public class CSVSerializer implements Se
writer.append(key);
}
+
+ writer.append("\r\n");
}
for (Object item : items) {
@@ -495,7 +498,7 @@ public class CSVSerializer implements Se
}
@Override
- public String getMIMEType(List<?> objects) {
+ public String getMIMEType(final List<?> objects) {
return MIME_TYPE + "; charset=" + charset.name();
}
Modified: pivot/trunk/core/src/org/apache/pivot/serialization/CSVSerializerListener.java
URL: http://svn.apache.org/viewvc/pivot/trunk/core/src/org/apache/pivot/serialization/CSVSerializerListener.java?rev=1833730&r1=1833729&r2=1833730&view=diff
==============================================================================
--- pivot/trunk/core/src/org/apache/pivot/serialization/CSVSerializerListener.java (original)
+++ pivot/trunk/core/src/org/apache/pivot/serialization/CSVSerializerListener.java Mon Jun 18 14:51:41 2018
@@ -26,20 +26,20 @@ public interface CSVSerializerListener {
/**
* CSV Serializer listeners.
*/
- public static class Listeners extends ListenerList<CSVSerializerListener>
+ public static final class Listeners extends ListenerList<CSVSerializerListener>
implements CSVSerializerListener {
@Override
- public void beginList(CSVSerializer csvSerializer, List<?> list) {
+ public void beginList(final CSVSerializer csvSerializer, final List<?> list) {
forEach(listener -> listener.beginList(csvSerializer, list));
}
@Override
- public void endList(CSVSerializer csvSerializer) {
+ public void endList(final CSVSerializer csvSerializer) {
forEach(listener -> listener.endList(csvSerializer));
}
@Override
- public void readItem(CSVSerializer csvSerializer, Object item) {
+ public void readItem(final CSVSerializer csvSerializer, final Object item) {
forEach(listener -> listener.readItem(csvSerializer, item));
}
}
@@ -51,17 +51,17 @@ public interface CSVSerializerListener {
@Deprecated
public static class Adapter implements CSVSerializerListener {
@Override
- public void beginList(CSVSerializer csvSerializer, List<?> list) {
+ public void beginList(final CSVSerializer csvSerializer, final List<?> list) {
// empty block
}
@Override
- public void endList(CSVSerializer csvSerializer) {
+ public void endList(final CSVSerializer csvSerializer) {
// empty block
}
@Override
- public void readItem(CSVSerializer csvSerializer, Object item) {
+ public void readItem(final CSVSerializer csvSerializer, final Object item) {
// empty block
}
}
Modified: pivot/trunk/core/test/org/apache/pivot/collections/test/ArrayListTest.java
URL: http://svn.apache.org/viewvc/pivot/trunk/core/test/org/apache/pivot/collections/test/ArrayListTest.java?rev=1833730&r1=1833729&r2=1833730&view=diff
==============================================================================
--- pivot/trunk/core/test/org/apache/pivot/collections/test/ArrayListTest.java (original)
+++ pivot/trunk/core/test/org/apache/pivot/collections/test/ArrayListTest.java Mon Jun 18 14:51:41 2018
@@ -117,4 +117,17 @@ public class ArrayListTest {
assertEquals(list.get(1), "b");
assertEquals(list.get(2), "c");
}
+
+ @Test
+ public void comparatorTest() {
+ // Note: this is a reverse-order comparator
+ ArrayList<Integer> list = new ArrayList<>((i1, i2) -> i2.compareTo(i1));
+
+ list.add(12);
+ list.add(5);
+ list.add(-3);
+ list.add(45);
+
+ assertEquals(list.toString(), "ArrayList [45, 12, 5, -3]");
+ }
}
Modified: pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTableViewSkin.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTableViewSkin.java?rev=1833730&r1=1833729&r2=1833730&view=diff
==============================================================================
--- pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTableViewSkin.java (original)
+++ pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTableViewSkin.java Mon Jun 18 14:51:41 2018
@@ -117,7 +117,7 @@ public class TerraTableViewSkin extends
}
@Override
- public void install(Component component) {
+ public void install(final Component component) {
super.install(component);
TableView tableView = (TableView) component;
@@ -128,11 +128,11 @@ public class TerraTableViewSkin extends
}
@Override
- public int getPreferredWidth(int height) {
+ public int getPreferredWidth(final int height) {
return getPreferredWidth((TableView) getComponent(), includeTrailingVerticalGridLine);
}
- public static int getPreferredWidth(TableView tableView, boolean includeTrailingVerticalGridLine) {
+ public static int getPreferredWidth(final TableView tableView, final boolean includeTrailingVerticalGridLine) {
int preferredWidth = 0;
TableView.ColumnSequence columns = tableView.getColumns();
@@ -178,7 +178,7 @@ public class TerraTableViewSkin extends
}
@Override
- public int getPreferredHeight(int width) {
+ public int getPreferredHeight(final int width) {
int preferredHeight = 0;
TableView tableView = (TableView) getComponent();
@@ -212,7 +212,7 @@ public class TerraTableViewSkin extends
}
@Override
- public int getBaseline(int width, int height) {
+ public int getBaseline(final int width, final int height) {
TableView tableView = (TableView) getComponent();
@SuppressWarnings("unchecked")
List<Object> tableData = (List<Object>) tableView.getTableData();
@@ -313,8 +313,10 @@ public class TerraTableViewSkin extends
/**
* Calculates the table row height, which is determined as the maximum
* preferred height of all cell renderers.
+ * @param tableView The table to calculate for.
+ * @return The calculated row height.
*/
- private static int calculateFixedRowHeight(TableView tableView) {
+ private static int calculateFixedRowHeight(final TableView tableView) {
int fixedRowHeight = 0;
TableView.ColumnSequence columns = tableView.getColumns();
@@ -330,7 +332,7 @@ public class TerraTableViewSkin extends
}
@Override
- public void paint(Graphics2D graphics) {
+ public void paint(final Graphics2D graphics) {
TableView tableView = (TableView) getComponent();
@SuppressWarnings("unchecked")
List<Object> tableData = (List<Object>) tableView.getTableData();
@@ -519,7 +521,7 @@ public class TerraTableViewSkin extends
}
}
- private int getRowY(int rowIndex) {
+ private int getRowY(final int rowIndex) {
int rowY;
if (variableRowHeight) {
if (rowIndex == 0) {
@@ -533,7 +535,7 @@ public class TerraTableViewSkin extends
return rowY;
}
- private int getRowHeight(int rowIndex) {
+ private int getRowHeight(final int rowIndex) {
int rowHeight;
if (variableRowHeight) {
rowHeight = rowBoundaries.get(rowIndex).intValue();
@@ -548,7 +550,7 @@ public class TerraTableViewSkin extends
return rowHeight;
}
- protected int getVariableRowHeight(int rowIndex, ArrayList<Integer> columnWidthsArgument) {
+ protected int getVariableRowHeight(final int rowIndex, final ArrayList<Integer> columnWidthsArgument) {
TableView tableView = (TableView) getComponent();
@SuppressWarnings("unchecked")
List<Object> tableData = (List<Object>) tableView.getTableData();
@@ -572,7 +574,7 @@ public class TerraTableViewSkin extends
// Table view skin methods
@Override
- public int getRowAt(int y) {
+ public int getRowAt(final int y) {
Utils.checkNonNegative(y, "y");
TableView tableView = (TableView) getComponent();
@@ -601,7 +603,7 @@ public class TerraTableViewSkin extends
}
@Override
- public int getColumnAt(int x) {
+ public int getColumnAt(final int x) {
Utils.checkNonNegative(x, "x");
TableView tableView = (TableView) getComponent();
@@ -624,12 +626,12 @@ public class TerraTableViewSkin extends
}
@Override
- public Bounds getRowBounds(int rowIndex) {
+ public Bounds getRowBounds(final int rowIndex) {
return new Bounds(0, getRowY(rowIndex), getWidth(), getRowHeight(rowIndex));
}
@Override
- public Bounds getColumnBounds(int columnIndex) {
+ public Bounds getColumnBounds(final int columnIndex) {
int columnX = 0;
for (int i = 0; i < columnIndex; i++) {
columnX += (columnWidths.get(i).intValue() + 1);
@@ -639,7 +641,7 @@ public class TerraTableViewSkin extends
}
@Override
- public Bounds getCellBounds(int rowIndex, int columnIndex) {
+ public Bounds getCellBounds(final int rowIndex, final int columnIndex) {
TableView tableView = (TableView) getComponent();
@SuppressWarnings("unchecked")
List<Object> tableData = (List<Object>) tableView.getTableData();
@@ -657,7 +659,7 @@ public class TerraTableViewSkin extends
rowHeight);
}
- public static ArrayList<Integer> getColumnWidths(TableView tableView, int width) {
+ public static ArrayList<Integer> getColumnWidths(final TableView tableView, final int width) {
int fixedWidth = 0;
int relativeWidth = 0;
@@ -716,240 +718,240 @@ public class TerraTableViewSkin extends
}
@Override
- public boolean isFocusable() {
+ public final boolean isFocusable() {
TableView tableView = (TableView) getComponent();
return (tableView.getSelectMode() != SelectMode.NONE);
}
@Override
- public boolean isOpaque() {
+ public final boolean isOpaque() {
return (backgroundColor != null && backgroundColor.getTransparency() == Transparency.OPAQUE);
}
- public Font getFont() {
+ public final Font getFont() {
return font;
}
- public void setFont(Font font) {
+ public final void setFont(final Font font) {
Utils.checkNull(font, "font");
this.font = font;
invalidateComponent();
}
- public final void setFont(String font) {
+ public final void setFont(final String font) {
setFont(decodeFont(font));
}
- public final void setFont(Dictionary<String, ?> font) {
+ public final void setFont(final Dictionary<String, ?> font) {
setFont(Theme.deriveFont(font));
}
- public Color getColor() {
+ public final Color getColor() {
return color;
}
- public void setColor(Color color) {
+ public final void setColor(final Color color) {
Utils.checkNull(color, "color");
this.color = color;
repaintComponent();
}
- public final void setColor(String color) {
+ public final void setColor(final String color) {
setColor(GraphicsUtilities.decodeColor(color, "color"));
}
- public final void setColor(int color) {
+ public final void setColor(final int color) {
Theme theme = Theme.getTheme();
setColor(theme.getColor(color));
}
- public Color getDisabledColor() {
+ public final Color getDisabledColor() {
return disabledColor;
}
- public void setDisabledColor(Color disabledColor) {
+ public final void setDisabledColor(final Color disabledColor) {
Utils.checkNull(disabledColor, "disabledColor");
this.disabledColor = disabledColor;
repaintComponent();
}
- public final void setDisabledColor(String disabledColor) {
+ public final void setDisabledColor(final String disabledColor) {
setDisabledColor(GraphicsUtilities.decodeColor(disabledColor, "disabledColor"));
}
- public final void setDisabledColor(int disabledColor) {
+ public final void setDisabledColor(final int disabledColor) {
Theme theme = Theme.getTheme();
setDisabledColor(theme.getColor(disabledColor));
}
- public Color getBackgroundColor() {
+ public final Color getBackgroundColor() {
return backgroundColor;
}
- public void setBackgroundColor(Color backgroundColor) {
+ public final void setBackgroundColor(final Color backgroundColor) {
// We allow a null background color here
this.backgroundColor = backgroundColor;
repaintComponent();
}
- public final void setBackgroundColor(String backgroundColor) {
+ public final void setBackgroundColor(final String backgroundColor) {
setBackgroundColor(GraphicsUtilities.decodeColor(backgroundColor, "backgroundColor"));
}
- public final void setBackgroundColor(int backgroundColor) {
+ public final void setBackgroundColor(final int backgroundColor) {
Theme theme = Theme.getTheme();
setBackgroundColor(theme.getColor(backgroundColor));
}
- public Color getSelectionColor() {
+ public final Color getSelectionColor() {
return selectionColor;
}
- public void setSelectionColor(Color selectionColor) {
+ public final void setSelectionColor(final Color selectionColor) {
Utils.checkNull(selectionColor, "selectionColor");
this.selectionColor = selectionColor;
repaintComponent();
}
- public final void setSelectionColor(String selectionColor) {
+ public final void setSelectionColor(final String selectionColor) {
setSelectionColor(GraphicsUtilities.decodeColor(selectionColor, "selectionColor"));
}
- public final void setSelectionColor(int selectionColor) {
+ public final void setSelectionColor(final int selectionColor) {
Theme theme = Theme.getTheme();
setSelectionColor(theme.getColor(selectionColor));
}
- public Color getSelectionBackgroundColor() {
+ public final Color getSelectionBackgroundColor() {
return selectionBackgroundColor;
}
- public void setSelectionBackgroundColor(Color selectionBackgroundColor) {
+ public final void setSelectionBackgroundColor(final Color selectionBackgroundColor) {
Utils.checkNull(selectionBackgroundColor, "selectionBackgroundColor");
this.selectionBackgroundColor = selectionBackgroundColor;
repaintComponent();
}
- public final void setSelectionBackgroundColor(String selectionBackgroundColor) {
+ public final void setSelectionBackgroundColor(final String selectionBackgroundColor) {
setSelectionBackgroundColor(
GraphicsUtilities.decodeColor(selectionBackgroundColor, "selectionBackgroundColor"));
}
- public final void setSelectionBackgroundColor(int selectionBackgroundColor) {
+ public final void setSelectionBackgroundColor(final int selectionBackgroundColor) {
Theme theme = Theme.getTheme();
setSelectionBackgroundColor(theme.getColor(selectionBackgroundColor));
}
- public Color getInactiveSelectionColor() {
+ public final Color getInactiveSelectionColor() {
return inactiveSelectionColor;
}
- public void setInactiveSelectionColor(Color inactiveSelectionColor) {
+ public final void setInactiveSelectionColor(final Color inactiveSelectionColor) {
Utils.checkNull(inactiveSelectionColor, "inactiveSelectionColor");
this.inactiveSelectionColor = inactiveSelectionColor;
repaintComponent();
}
- public final void setInactiveSelectionColor(String inactiveSelectionColor) {
+ public final void setInactiveSelectionColor(final String inactiveSelectionColor) {
setInactiveSelectionColor(
GraphicsUtilities.decodeColor(inactiveSelectionColor, "inactiveSelectionColor"));
}
- public final void setInactiveSelectionColor(int inactiveSelectionColor) {
+ public final void setInactiveSelectionColor(final int inactiveSelectionColor) {
Theme theme = Theme.getTheme();
setInactiveSelectionColor(theme.getColor(inactiveSelectionColor));
}
- public Color getInactiveSelectionBackgroundColor() {
+ public final Color getInactiveSelectionBackgroundColor() {
return inactiveSelectionBackgroundColor;
}
- public void setInactiveSelectionBackgroundColor(Color inactiveSelectionBackgroundColor) {
+ public final void setInactiveSelectionBackgroundColor(final Color inactiveSelectionBackgroundColor) {
Utils.checkNull(inactiveSelectionBackgroundColor, "inactiveSelectionBackgroundColor");
this.inactiveSelectionBackgroundColor = inactiveSelectionBackgroundColor;
repaintComponent();
}
- public final void setInactiveSelectionBackgroundColor(String inactiveSelectionBackgroundColor) {
+ public final void setInactiveSelectionBackgroundColor(final String inactiveSelectionBackgroundColor) {
setInactiveSelectionBackgroundColor(
GraphicsUtilities.decodeColor(inactiveSelectionBackgroundColor, "inactiveSelectionBackgroundColor"));
}
- public final void setInactiveSelectionBackgroundColor(int inactiveSelectionBackgroundColor) {
+ public final void setInactiveSelectionBackgroundColor(final int inactiveSelectionBackgroundColor) {
Theme theme = Theme.getTheme();
setInactiveSelectionBackgroundColor(theme.getColor(inactiveSelectionBackgroundColor));
}
- public Color getHighlightBackgroundColor() {
+ public final Color getHighlightBackgroundColor() {
return highlightBackgroundColor;
}
- public void setHighlightBackgroundColor(Color highlightBackgroundColor) {
+ public final void setHighlightBackgroundColor(final Color highlightBackgroundColor) {
Utils.checkNull(highlightBackgroundColor, "highlightBackgroundColor");
this.highlightBackgroundColor = highlightBackgroundColor;
repaintComponent();
}
- public final void setHighlightBackgroundColor(String highlightBackgroundColor) {
+ public final void setHighlightBackgroundColor(final String highlightBackgroundColor) {
setHighlightBackgroundColor(
GraphicsUtilities.decodeColor(highlightBackgroundColor, "highlightBackgroundColor"));
}
- public final void setHighlightBackgroundColor(int highlightBackgroundColor) {
+ public final void setHighlightBackgroundColor(final int highlightBackgroundColor) {
Theme theme = Theme.getTheme();
setHighlightBackgroundColor(theme.getColor(highlightBackgroundColor));
}
- public Color getAlternateRowBackgroundColor() {
+ public final Color getAlternateRowBackgroundColor() {
return alternateRowBackgroundColor;
}
- public void setAlternateRowBackgroundColor(Color alternateRowBackgroundColor) {
+ public final void setAlternateRowBackgroundColor(final Color alternateRowBackgroundColor) {
this.alternateRowBackgroundColor = alternateRowBackgroundColor;
repaintComponent();
}
- public final void setAlternateRowBackgroundColor(String alternateRowBackgroundColor) {
+ public final void setAlternateRowBackgroundColor(final String alternateRowBackgroundColor) {
setAlternateRowBackgroundColor(
GraphicsUtilities.decodeColor(alternateRowBackgroundColor, "alternateRowBackgroundColor"));
}
- public final void setAlternateRowBackgroundColor(int alternateRowBackgroundColor) {
+ public final void setAlternateRowBackgroundColor(final int alternateRowBackgroundColor) {
Theme theme = Theme.getTheme();
setAlternateRowBackgroundColor(theme.getColor(alternateRowBackgroundColor));
}
- public Color getColumnSelectionColor() {
+ public final Color getColumnSelectionColor() {
return columnSelectionColor;
}
- public void setColumnSelectionColor(Color columnSelectionColor) {
+ public final void setColumnSelectionColor(final Color columnSelectionColor) {
this.columnSelectionColor = columnSelectionColor;
repaintComponent();
}
- public final void setColumnSelectionColor(String columnSelectionColor) {
+ public final void setColumnSelectionColor(final String columnSelectionColor) {
setColumnSelectionColor(GraphicsUtilities.decodeColor(columnSelectionColor, "columnSelectionColor"));
}
- public final void setColumnSelectionColor(int columnSelectionColor) {
+ public final void setColumnSelectionColor(final int columnSelectionColor) {
Theme theme = Theme.getTheme();
setColumnSelectionColor(theme.getColor(columnSelectionColor));
}
- public Color getColumnSelectionHorizontalGridColor() {
+ public final Color getColumnSelectionHorizontalGridColor() {
return columnSelectionHorizontalGridColor;
}
- public void setColumnSelectionHorizontalGridColor(Color columnSelectionHorizontalGridColor) {
+ public final void setColumnSelectionHorizontalGridColor(final Color columnSelectionHorizontalGridColor) {
Utils.checkNull(columnSelectionHorizontalGridColor, "columnSelectionHorizontalGridColor");
this.columnSelectionHorizontalGridColor = columnSelectionHorizontalGridColor;
@@ -962,101 +964,101 @@ public class TerraTableViewSkin extends
GraphicsUtilities.decodeColor(columnSelectionHorizontalGridColor, "columnSelectionHorizontalGridColor"));
}
- public final void setColumnSelectionHorizontalGridColor(int columnSelectionHorizontalGridColor) {
+ public final void setColumnSelectionHorizontalGridColor(final int columnSelectionHorizontalGridColor) {
Theme theme = Theme.getTheme();
setColumnSelectionHorizontalGridColor(theme.getColor(columnSelectionHorizontalGridColor));
}
- public Color getHorizontalGridColor() {
+ public final Color getHorizontalGridColor() {
return horizontalGridColor;
}
- public void setHorizontalGridColor(Color horizontalGridColor) {
+ public final void setHorizontalGridColor(final Color horizontalGridColor) {
Utils.checkNull(horizontalGridColor, "horizontalGridColor");
this.horizontalGridColor = horizontalGridColor;
repaintComponent();
}
- public final void setHorizontalGridColor(String horizontalGridColor) {
+ public final void setHorizontalGridColor(final String horizontalGridColor) {
setHorizontalGridColor(GraphicsUtilities.decodeColor(horizontalGridColor, "horizontalGridColor"));
}
- public final void setHorizontalGridColor(int horizontalGridColor) {
+ public final void setHorizontalGridColor(final int horizontalGridColor) {
Theme theme = Theme.getTheme();
setHorizontalGridColor(theme.getColor(horizontalGridColor));
}
- public Color getVerticalGridColor() {
+ public final Color getVerticalGridColor() {
return verticalGridColor;
}
- public void setVerticalGridColor(Color verticalGridColor) {
+ public final void setVerticalGridColor(final Color verticalGridColor) {
Utils.checkNull(verticalGridColor, "verticalGridColor");
this.verticalGridColor = verticalGridColor;
repaintComponent();
}
- public final void setVerticalGridColor(String verticalGridColor) {
+ public final void setVerticalGridColor(final String verticalGridColor) {
setVerticalGridColor(GraphicsUtilities.decodeColor(verticalGridColor, "verticalGridColor"));
}
- public final void setVerticalGridColor(int verticalGridColor) {
+ public final void setVerticalGridColor(final int verticalGridColor) {
Theme theme = Theme.getTheme();
setVerticalGridColor(theme.getColor(verticalGridColor));
}
- public boolean getShowHighlight() {
+ public final boolean getShowHighlight() {
return showHighlight;
}
- public void setShowHighlight(boolean showHighlight) {
+ public final void setShowHighlight(final boolean showHighlight) {
this.showHighlight = showHighlight;
repaintComponent();
}
- public boolean getShowHorizontalGridLines() {
+ public final boolean getShowHorizontalGridLines() {
return showHorizontalGridLines;
}
- public void setShowHorizontalGridLines(boolean showHorizontalGridLines) {
+ public final void setShowHorizontalGridLines(final boolean showHorizontalGridLines) {
this.showHorizontalGridLines = showHorizontalGridLines;
repaintComponent();
}
- public boolean getShowVerticalGridLines() {
+ public final boolean getShowVerticalGridLines() {
return showVerticalGridLines;
}
- public void setShowVerticalGridLines(boolean showVerticalGridLines) {
+ public final void setShowVerticalGridLines(final boolean showVerticalGridLines) {
this.showVerticalGridLines = showVerticalGridLines;
repaintComponent();
}
- public boolean getIncludeTrailingVerticalGridLine() {
+ public final boolean getIncludeTrailingVerticalGridLine() {
return includeTrailingVerticalGridLine;
}
- public void setIncludeTrailingVerticalGridLine(boolean includeTrailingVerticalGridLine) {
+ public final void setIncludeTrailingVerticalGridLine(final boolean includeTrailingVerticalGridLine) {
this.includeTrailingVerticalGridLine = includeTrailingVerticalGridLine;
invalidateComponent();
}
- public boolean getIncludeTrailingHorizontalGridLine() {
+ public final boolean getIncludeTrailingHorizontalGridLine() {
return includeTrailingHorizontalGridLine;
}
- public void setIncludeTrailingHorizontalGridLine(boolean includeTrailingHorizontalGridLine) {
+ public final void setIncludeTrailingHorizontalGridLine(final boolean includeTrailingHorizontalGridLine) {
this.includeTrailingHorizontalGridLine = includeTrailingHorizontalGridLine;
invalidateComponent();
}
- public boolean isVariableRowHeight() {
+ public final boolean isVariableRowHeight() {
return variableRowHeight;
}
- public void setVariableRowHeight(boolean variableRowHeight) {
+ public final void setVariableRowHeight(final boolean variableRowHeight) {
this.variableRowHeight = variableRowHeight;
this.rowBoundaries = null;
this.fixedRowHeight = -1;
@@ -1067,7 +1069,7 @@ public class TerraTableViewSkin extends
* @return Is this {@link TableView} going into edit mode on a mouse down or
* on a mouse double click?
*/
- public boolean isEditOnMouseDown() {
+ public final boolean isEditOnMouseDown() {
return editOnMouseDown;
}
@@ -1078,12 +1080,12 @@ public class TerraTableViewSkin extends
* necessary to rapidly edit a table view.
* @param editOnMouseDown The new setting.
*/
- public void setEditOnMouseDown(boolean editOnMouseDown) {
+ public final void setEditOnMouseDown(final boolean editOnMouseDown) {
this.editOnMouseDown = editOnMouseDown;
}
@Override
- public boolean mouseMove(Component component, int x, int y) {
+ public boolean mouseMove(final Component component, final int x, final int y) {
boolean consumed = super.mouseMove(component, x, y);
TableView tableView = (TableView) getComponent();
@@ -1106,7 +1108,7 @@ public class TerraTableViewSkin extends
}
@Override
- public void mouseOut(Component component) {
+ public void mouseOut(final Component component) {
super.mouseOut(component);
TableView tableView = (TableView) getComponent();
@@ -1121,7 +1123,7 @@ public class TerraTableViewSkin extends
}
@Override
- public boolean mouseDown(Component component, Mouse.Button button, int x, int y) {
+ public boolean mouseDown(final Component component, final Mouse.Button button, final int x, final int y) {
boolean consumed = super.mouseDown(component, button, x, y);
TableView tableView = (TableView) getComponent();
@@ -1203,7 +1205,7 @@ public class TerraTableViewSkin extends
}
@Override
- public boolean mouseUp(Component component, Mouse.Button button, int x, int y) {
+ public boolean mouseUp(final Component component, final Mouse.Button button, final int x, final int y) {
boolean consumed = super.mouseUp(component, button, x, y);
TableView tableView = (TableView) getComponent();
@@ -1217,7 +1219,8 @@ public class TerraTableViewSkin extends
}
@Override
- public boolean mouseClick(Component component, Mouse.Button button, int x, int y, int count) {
+ public boolean mouseClick(final Component component, final Mouse.Button button, final int x, final int y,
+ final int count) {
boolean consumed = super.mouseClick(component, button, x, y, count);
if (!editOnMouseDown) {
@@ -1241,8 +1244,8 @@ public class TerraTableViewSkin extends
}
@Override
- public boolean mouseWheel(Component component, Mouse.ScrollType scrollType, int scrollAmount,
- int wheelRotation, int x, int y) {
+ public boolean mouseWheel(final Component component, final Mouse.ScrollType scrollType, final int scrollAmount,
+ final int wheelRotation, final int x, final int y) {
TableView tableView = (TableView) getComponent();
if (highlightIndex != -1) {
@@ -1277,14 +1280,15 @@ public class TerraTableViewSkin extends
* </ul>
*/
@Override
- public boolean keyPressed(Component component, int keyCode, KeyLocation keyLocation) {
+ public boolean keyPressed(final Component component, final int keyCode, final KeyLocation keyLocation) {
boolean consumed = super.keyPressed(component, keyCode, keyLocation);
TableView tableView = (TableView) getComponent();
SelectMode selectMode = tableView.getSelectMode();
+ Modifier cmdModifier = Platform.getCommandModifier();
switch (keyCode) {
- case KeyCode.UP: {
+ case KeyCode.UP:
if (selectMode != SelectMode.NONE) {
int index = tableView.getFirstSelectedIndex();
@@ -1306,9 +1310,8 @@ public class TerraTableViewSkin extends
}
break;
- }
- case KeyCode.DOWN: {
+ case KeyCode.DOWN:
if (selectMode != SelectMode.NONE) {
int index = tableView.getLastSelectedIndex();
int count = tableView.getTableData().getLength();
@@ -1331,9 +1334,8 @@ public class TerraTableViewSkin extends
}
break;
- }
- case KeyCode.SPACE: {
+ case KeyCode.SPACE:
if (lastKeyboardSelectIndex != -1 && selectMode != SelectMode.NONE) {
if (!tableView.isRowDisabled(lastKeyboardSelectIndex)) {
switch (selectMode) {
@@ -1351,15 +1353,15 @@ public class TerraTableViewSkin extends
tableView.addSelectedIndex(lastKeyboardSelectIndex);
}
break;
+ default:
+ break;
}
consumed = true;
}
}
break;
- }
- case KeyCode.A: {
- Modifier cmdModifier = Platform.getCommandModifier();
+ case KeyCode.A:
if (Keyboard.isPressed(cmdModifier)) {
if (selectMode == SelectMode.MULTI) {
tableView.selectAll();
@@ -1368,13 +1370,12 @@ public class TerraTableViewSkin extends
}
}
break;
- }
- case KeyCode.U: {
- Modifier cmdModifier = Platform.getCommandModifier();
+ case KeyCode.U:
if (Keyboard.isPressed(cmdModifier)) {
switch (selectMode) {
case NONE:
+ default:
break;
case SINGLE:
case MULTI:
@@ -1385,11 +1386,9 @@ public class TerraTableViewSkin extends
}
}
break;
- }
- default: {
+ default:
break;
- }
}
// Clear the highlight
@@ -1405,14 +1404,14 @@ public class TerraTableViewSkin extends
// Component state events
@Override
- public void enabledChanged(Component component) {
+ public void enabledChanged(final Component component) {
super.enabledChanged(component);
repaintComponent();
}
@Override
- public void focusedChanged(Component component, Component obverseComponent) {
+ public void focusedChanged(final Component component, final Component obverseComponent) {
super.focusedChanged(component, obverseComponent);
repaintComponent();
@@ -1420,12 +1419,12 @@ public class TerraTableViewSkin extends
// Table view events
@Override
- public void tableDataChanged(TableView tableView, List<?> previousTableData) {
+ public void tableDataChanged(final TableView tableView, final List<?> previousTableData) {
invalidateComponent();
}
@Override
- public void columnSourceChanged(TableView tableView, TableView previousColumnSource) {
+ public void columnSourceChanged(final TableView tableView, final TableView previousColumnSource) {
if (previousColumnSource != null) {
previousColumnSource.getTableViewColumnListeners().remove(this);
}
@@ -1440,23 +1439,23 @@ public class TerraTableViewSkin extends
}
@Override
- public void rowEditorChanged(TableView tableView, TableView.RowEditor previousRowEditor) {
+ public void rowEditorChanged(final TableView tableView, final TableView.RowEditor previousRowEditor) {
// No-op
}
@Override
- public void selectModeChanged(TableView tableView, SelectMode previousSelectMode) {
+ public void selectModeChanged(final TableView tableView, final SelectMode previousSelectMode) {
repaintComponent();
}
@Override
- public void disabledRowFilterChanged(TableView tableView, Filter<?> previousDisabledRowFilter) {
+ public void disabledRowFilterChanged(final TableView tableView, final Filter<?> previousDisabledRowFilter) {
repaintComponent();
}
// Table view column events
@Override
- public void columnInserted(TableView tableView, int index) {
+ public void columnInserted(final TableView tableView, final int index) {
TableView.Column column = tableView.getColumns().get(index);
if (column.getWidth() == -1) {
@@ -1467,7 +1466,7 @@ public class TerraTableViewSkin extends
}
@Override
- public void columnsRemoved(TableView tableView, int index, Sequence<TableView.Column> columns) {
+ public void columnsRemoved(final TableView tableView, final int index, final Sequence<TableView.Column> columns) {
for (int i = 0, n = columns.getLength(); i < n; i++) {
TableView.Column column = columns.get(i);
@@ -1480,24 +1479,24 @@ public class TerraTableViewSkin extends
}
@Override
- public void columnNameChanged(TableView.Column column, String previousName) {
+ public void columnNameChanged(final TableView.Column column, final String previousName) {
invalidateComponent();
}
@Override
- public void columnHeaderDataChanged(TableView.Column column, Object previousHeaderData) {
+ public void columnHeaderDataChanged(final TableView.Column column, final Object previousHeaderData) {
// No-op
}
@Override
- public void columnHeaderDataRendererChanged(TableView.Column column,
- TableView.HeaderDataRenderer previousHeaderDataRenderer) {
+ public void columnHeaderDataRendererChanged(final TableView.Column column,
+ final TableView.HeaderDataRenderer previousHeaderDataRenderer) {
// No-op
}
@Override
- public void columnWidthChanged(TableView.Column column, int previousWidth,
- boolean previousRelative) {
+ public void columnWidthChanged(final TableView.Column column, final int previousWidth,
+ final boolean previousRelative) {
if (column.getWidth() == -1) {
defaultWidthColumnCount++;
} else {
@@ -1508,35 +1507,35 @@ public class TerraTableViewSkin extends
}
@Override
- public void columnWidthLimitsChanged(TableView.Column column, int previousMinimumWidth,
- int previousMaximumWidth) {
+ public void columnWidthLimitsChanged(final TableView.Column column, final int previousMinimumWidth,
+ final int previousMaximumWidth) {
invalidateComponent();
}
@Override
- public void columnFilterChanged(TableView.Column column, Object previousFilter) {
+ public void columnFilterChanged(final TableView.Column column, final Object previousFilter) {
// No-op
}
@Override
- public void columnCellRendererChanged(TableView.Column column,
- TableView.CellRenderer previousCellRenderer) {
+ public void columnCellRendererChanged(final TableView.Column column,
+ final TableView.CellRenderer previousCellRenderer) {
invalidateComponent();
}
// Table view row events
@Override
- public void rowInserted(TableView tableView, int index) {
+ public void rowInserted(final TableView tableView, final int index) {
invalidateComponent();
}
@Override
- public void rowsRemoved(TableView tableView, int index, int count) {
+ public void rowsRemoved(final TableView tableView, final int index, final int count) {
invalidateComponent();
}
@Override
- public void rowUpdated(TableView tableView, int index) {
+ public void rowUpdated(final TableView tableView, final int index) {
if (variableRowHeight || defaultWidthColumnCount > 0) {
invalidateComponent();
} else {
@@ -1545,12 +1544,12 @@ public class TerraTableViewSkin extends
}
@Override
- public void rowsCleared(TableView listView) {
+ public void rowsCleared(final TableView listView) {
invalidateComponent();
}
@Override
- public void rowsSorted(TableView tableView) {
+ public void rowsSorted(final TableView tableView) {
if (variableRowHeight) {
invalidateComponent();
} else {
@@ -1560,7 +1559,7 @@ public class TerraTableViewSkin extends
// Table view selection detail events
@Override
- public void selectedRangeAdded(TableView tableView, int rangeStart, int rangeEnd) {
+ public void selectedRangeAdded(final TableView tableView, final int rangeStart, final int rangeEnd) {
if (tableView.isValid()) {
Bounds selectionBounds = getRowBounds(rangeStart);
selectionBounds = selectionBounds.union(getRowBounds(rangeEnd));
@@ -1577,7 +1576,7 @@ public class TerraTableViewSkin extends
}
@Override
- public void selectedRangeRemoved(TableView tableView, int rangeStart, int rangeEnd) {
+ public void selectedRangeRemoved(final TableView tableView, final int rangeStart, final int rangeEnd) {
// Repaint the area containing the removed selection
if (tableView.isValid()) {
Bounds selectionBounds = getRowBounds(rangeStart);
@@ -1587,7 +1586,7 @@ public class TerraTableViewSkin extends
}
@Override
- public void selectedRangesChanged(TableView tableView, Sequence<Span> previousSelectedRanges) {
+ public void selectedRangesChanged(final TableView tableView, final Sequence<Span> previousSelectedRanges) {
if (previousSelectedRanges != null
&& previousSelectedRanges != tableView.getSelectedRanges()) {
if (tableView.isValid()) {
@@ -1631,7 +1630,7 @@ public class TerraTableViewSkin extends
}
@Override
- public void selectedRowChanged(TableView tableView, Object previousSelectedRow) {
+ public void selectedRowChanged(final TableView tableView, final Object previousSelectedRow) {
// No-op
}
}