This should be an IndexOutOfBoundsException, not IllegalArgumentException. In 
either case, it's not strictly necessary because the same exception will be 
thrown by the "colors" ArrayList.

On Sep 6, 2010, at 6:26 PM, [email protected] wrote:

> Author: smartini
> Date: Mon Sep  6 22:26:24 2010
> New Revision: 993167
> 
> URL: http://svn.apache.org/viewvc?rev=993167&view=rev
> Log:
> added check range on index in color get/set, so in case of wrong (out of 
> range) index the following Exception will be generated (some parts omitted): 
> Caused by: java.lang.IllegalArgumentException: Index not in range [0, 23]
> 
> Modified:
>    pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTheme.java
> 
> Modified: 
> pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTheme.java
> URL: 
> http://svn.apache.org/viewvc/pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTheme.java?rev=993167&r1=993166&r2=993167&view=diff
> ==============================================================================
> --- pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTheme.java 
> (original)
> +++ pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTheme.java 
> Mon Sep  6 22:26:24 2010
> @@ -304,6 +304,10 @@ public final class TerraTheme extends Th
>      * @param index
>      */
>     public Color getColor(int index) {
> +        if (index < 0 || index >= colors.getLength()) {
> +            throw new IllegalArgumentException("Index not in range [0, " + 
> (colors.getLength() -1) + "]");
> +        }
> +
>         return colors.get(index);
>     }
> 
> @@ -314,6 +318,9 @@ public final class TerraTheme extends Th
>      * @param color
>      */
>     public void setColor(int index, Color color) {
> +        if (index < 0 || index >= colors.getLength()) {
> +            throw new IllegalArgumentException("Index not in range [0, " + 
> (colors.getLength() -1) + "]");
> +        }
>         if (color == null) {
>             throw new IllegalArgumentException();
>         }
> 
> 

Reply via email to