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
4   53   2   4
0   16   0.5   1
1     2  
1    
16.7% of code in this file is excluded from these metrics.
 
  JTableColumnByIdentifierQuery       Line # 30 4 16.7% 2 0 100% 1.0
 
No Tests
 
1    /*
2    * Created on Oct 13, 2008
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
5    * 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 is distributed on
10    * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
11    * specific language governing permissions and limitations under the License.
12    *
13    * Copyright @2008-2010 the original author or authors.
14    */
15    package org.fest.swing.query;
16   
17    import javax.swing.JTable;
18    import javax.swing.table.TableColumn;
19   
20    import org.fest.swing.annotation.RunsInCurrentThread;
21   
22    /**
23    * Understands an action that returns the index of a column in a <code>{@link JTable}</code> whose identifier matches
24    * the given one.
25    * @see JTable#getColumn(Object)
26    * @see TableColumn#getModelIndex()
27    *
28    * @author Alex Ruiz
29    */
 
30    public final class JTableColumnByIdentifierQuery {
31   
32    /**
33    * Returns the index of a column in a <code>{@link JTable}</code> whose identifier matches the given one.
34    * <p>
35    * <b>Note:</b> This method is <b>not</b> guaranteed to be executed in the event dispatch thread (EDT.) Clients are
36    * responsible for calling this method from the EDT.
37    * </p>
38    * @param table the given <code>JTable</code>.
39    * @param identifier the column identifier.
40    * @return the index of a column with a matching identifier. Otherwise it returns -1.
41    */
 
42  16 toggle @RunsInCurrentThread
43    public static int columnIndexByIdentifier(final JTable table, final Object identifier) {
44  16 try {
45  16 TableColumn column = table.getColumn(identifier);
46  13 return table.convertColumnIndexToView(column.getModelIndex());
47    } catch (IllegalArgumentException e) {
48  3 return -1;
49    }
50    }
51   
 
52    toggle private JTableColumnByIdentifierQuery() {}
53    }