title: JTable, RowFilter and RowFilter.Entry
body: <ol>
  <li><p>please I have an issue with <a href="http://docs.oracle.com/javase/7/docs/api/javax/swing/RowFilter.html" rel="nofollow noreferrer">RowFilter</a> (<a href="http://docs.oracle.com/javase/7/docs/api/javax/swing/RowFilter.ComparisonType.html" rel="nofollow noreferrer">its ComparisonType</a>) to put together </p>
  
  <ul>
  <li>Regex(String), Number, Date</li>
  </ul>
  
  <p>together with </p>
  
  <ul>
  <li>AND, OR, NOR </li>
  </ul></li>
  <li><p>no idea how </p>
  
  <ul>
  <li>to handle with null value for AND, OR, NOR</li>
  <li>if Regex(String), Number, Date has the same logics or there "small differencies"</li>
  <li>especially how to compare Date value </li>
  </ul></li>
  <li><p>some longer and detailed descriptions are welcome</p></li>
  <li><p>in this <a href="http://sscce.org/" rel="nofollow noreferrer">SSCCE</a> to see my basic issues into <code>frame.add(new JButton(new AbstractAction("Toggle filter") {</code></p></li>
  </ol>
  
  <p><img src="https://i.stack.imgur.com/UES6T.jpg" alt="enter image description here"><img src="https://i.stack.imgur.com/7eVt1.jpg" alt="enter image description here"></p>
  
  <pre><code>import java.awt.BorderLayout;
  import java.awt.event.ActionEvent;
  import java.util.Calendar;
  import java.util.Date;
  import javax.swing.*;
  import javax.swing.table.DefaultTableModel;
  import javax.swing.table.TableModel;
  import javax.swing.table.TableRowSorter;
  
  public class JTableFilterDemo {
  
      private static TableRowSorter&lt;TableModel&gt; sorter;
      private Object[][] data = {{"A", 5, true, new Date()},
          {"B", 2, false, new Date()}, {"C", 4, false, new Date()},
          {"D", 8, true, new Date()}, {"E", 13, false, new Date()},
          {"F", 7, true, new Date()}, {"G", 55, false, new Date()},
          {"H", 6, false, new Date()}, {"I", 1, true, new Date()}};
      private String columnNames[] = {"Item", "Value", "Boolean", "Date"};
      private TableModel model = new DefaultTableModel(data, columnNames) {
          private static final long serialVersionUID = 1L;
  
          @Override
          public Class&lt;?&gt; getColumnClass(int column) {
              switch (column) {
                  case 1:
                      return Integer.class;
                  case 2:
                      return Boolean.class;
                  case 3:
                      return Date.class;
                  default:
                      return String.class;
              }
          }
      };
      private JTable table = new JTable(model);
      private Date modifDate = new Date();
  
      public JTableFilterDemo() {
          modifyDateInTable();
          table.setPreferredScrollableViewportSize(table.getPreferredSize());
          RowFilter&lt;Object, Number&gt; filter = new RowFilter&lt;Object, Number&gt;() {
              @Override
              public boolean include(RowFilter.Entry entry) {
                  //String str = (String) entry.getValue(0);//String
                  //return str.matches(("(?i)^a|^g"));//String
                  //Boolean bol = (Boolean) entry.getValue(2);//Boolean
                  //return bol.booleanValue() == false;//Boolean
                  //Date date = (Date) entry.getValue(3);//Date
                  //return date.getTime() &gt; (long) (new Date().getTime());//Date
                  //return ((Number) entry.getValue(1)).intValue() % 2 == 0;//Integer
                  //return ((Number) entry.getValue(1)).intValue() &gt; 0;//Integer
                  return ((Number) entry.getValue(1)).intValue() &gt; 10
                          &amp; ((Number) entry.getValue(1)).intValue() &lt; 50;//AND with Integer
              }
          };
          sorter = new TableRowSorter&lt;TableModel&gt;(model);
          sorter.setRowFilter(filter);
          table.setRowSorter(sorter);
          JScrollPane scrollPane = new JScrollPane(table);
          JFrame frame = new JFrame("Filtering Table");
          frame.add(new JButton(new AbstractAction("Toggle filter") {
              private static final long serialVersionUID = 1L;
              private RowFilter&lt;TableModel, Object&gt; filter = new RowFilter&lt;TableModel, Object&gt;() {
                  @Override
                  public boolean include(javax.swing.RowFilter.Entry&lt;? extends TableModel, ? extends Object&gt; entry) {
                      //String str = (String) entry.getValue(0);//String
                      //return str.matches(("(?i)^a|^g"));//String
                      //Boolean bol = (Boolean) entry.getValue(2);//Boolean
                      //return bol.booleanValue() == false;//Boolean
                      //Date date = (Date) entry.getValue(3);//Date
                      //return date.getTime() &gt; (long) (new Date().getTime());//Date
                      //return ((Number) entry.getValue(1)).intValue() % 2 == 0;//Integer
                      //return ((Number) entry.getValue(1)).intValue() &gt; 0;//Integer
                      return ((Number) entry.getValue(1)).intValue() &gt; 10
                              &amp; ((Number) entry.getValue(1)).intValue() &lt; 50;//AND with Integer
  
                      // ---&gt;  doesn't works
                      //return ((Number) entry.getValue(1)).intValue() &gt; 10 |
                      //((Number) entry.getValue(1)).intValue() &lt; 50;//OR with Integer
  
                      // ---&gt; works, but initialized on 2nd. event
                      //return ((Number) entry.getValue(1)).intValue() &gt; 10 != 
                      //((Number) entry.getValue(1)).intValue() &lt; 50;//NOR with Integer 
                  }
              };
  
              @Override
              public void actionPerformed(ActionEvent e) {
                  if (sorter.getRowFilter() != null) {
                      sorter.setRowFilter(null);
                  } else {
                      sorter.setRowFilter(filter);
                  }
              }
          }), BorderLayout.SOUTH);
          frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          frame.add(scrollPane);
          frame.pack();
          frame.setVisible(true);
      }
  
      private void modifyDateInTable() {
          Calendar c = Calendar.getInstance();
          c.setTime(modifDate);
          c.add(Calendar.DATE, - 1);
          modifDate = c.getTime();
          table.setValueAt(modifDate, 0, 3);
          c.setTime(modifDate);
          c.add(Calendar.DATE, +5);
          modifDate = c.getTime();
          table.setValueAt(modifDate, 1, 3);
          c.setTime(modifDate);
          c.add(Calendar.DATE, +1);
          modifDate = c.getTime();
          table.setValueAt(modifDate, 2, 3);
          c.setTime(modifDate);
          c.add(Calendar.DATE, - 16);
          modifDate = c.getTime();
          table.setValueAt(modifDate, 3, 3);
          c.setTime(modifDate);
          c.add(Calendar.DATE, +30);
          modifDate = c.getTime();
          table.setValueAt(modifDate, 4, 3);
          c.setTime(modifDate);
          c.add(Calendar.DATE, +55);
          modifDate = c.getTime();
          table.setValueAt(modifDate, 5, 3);
          c.setTime(modifDate);
          c.add(Calendar.DATE, +155);
          modifDate = c.getTime();
          table.setValueAt(modifDate, 6, 3);
          c.setTime(modifDate);
          c.add(Calendar.DATE, -23);
          modifDate = c.getTime();
          table.setValueAt(modifDate, 7, 3);
      }
  
      public static void main(String[] args) {
          SwingUtilities.invokeLater(new Runnable() {
              @Override
              public void run() {
                  JTableFilterDemo jtfd = new JTableFilterDemo();
              }
          });
      }
  }
  </code></pre>