Clover Coverage Report - FEST Swing 1.2
Coverage timestamp: Tue Jun 1 2010 15:19:25 PDT
../../../../img/srcFileCovDistChart10.png 0% of files have more coverage
7   52   4   7
4   17   0.57   1
1     4  
1    
7.7% of code in this file is excluded from these metrics.
 
  Colors       Line # 30 7 7.7% 4 0 100% 1.0
 
No Tests
 
1    /*
2    * Created on Apr 15, 2008
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5    * in compliance with the License. You may obtain a copy of the License at
6    *
7    * http://www.apache.org/licenses/LICENSE-2.0
8    *
9    * Unless required by applicable law or agreed to in writing, software distributed under the License
10    * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11    * or implied. See the License for the specific language governing permissions and limitations under
12    * the License.
13    *
14    * Copyright @2008-2010 the original author or authors.
15    */
16    package org.fest.swing.util;
17   
18    import static org.fest.util.Strings.concat;
19    import static org.fest.util.Strings.quote;
20   
21    import java.awt.Color;
22   
23    import org.fest.util.Strings;
24   
25    /**
26    * Understands utility methods related to colors.
27    *
28    * @author Alex Ruiz
29    */
 
30    public final class Colors {
31   
32    /**
33    * Returns a <code>{@link Color}</code> from the given <code>String</code> containing the hexadecimal coding of a
34    * color.
35    * @param hexString contains the hexadecimal coding of a color.
36    * @return a <code>Color</code> from the given <code>String</code> containing the hexadecimal coding of a color.
37    * @throws NullPointerException if the hexadecimal code is <code>null</code>.
38    * @throws IllegalArgumentException if the hexadecimal code is empty.
39    * @throws NumberFormatException if the hexadecimal code is empty.
40    */
 
41  14 toggle public static Color colorFromHexString(String hexString) {
42  1 if (hexString == null) throw new NullPointerException("The hexadecimal code should not be null");
43  1 if (Strings.isEmpty(hexString)) throw new IllegalArgumentException("The hexadecimal code should not be empty");
44  12 try {
45  12 return new Color(Integer.parseInt(hexString, 16));
46    } catch (NumberFormatException e) {
47  1 throw new NumberFormatException(concat("The hexadecimal code ", quote(hexString), " is not a valid color code"));
48    }
49    }
50   
 
51    toggle private Colors() {}
52    }