@Test public void testIsSafeToCache() { TypedTableModel model = new TypedTableModel( ); model.addColumn( "id", java.lang.String.class ); model.addColumn( "id", java.lang.Integer.class ); model.addColumn( "bb", java.lang.Boolean.class ); model.addColumn( "bb", java.util.Date.class ); model.addColumn( "id", java.lang.Integer.TYPE ); model.addRow( "R0", "C0", "1" ); model.addRow( "R0", "C1", 1 ); model.addRow( "R2", "C2", true ); model.addRow( "R2", "C3", new Date() ); model.addRow( "R0", "C1", 1 ); TableModel tableModel = new CachableTableModel( model ); assertTrue( CachableTableModel.isSafeToCache( tableModel ) ); }
public static boolean isSafeToCache( final TableModel model ) { final int columnCount = model.getColumnCount(); for ( int i = 0; i < columnCount; i += 1 ) { Class columnClass = model.getColumnClass( i ); while ( columnClass.isArray() ) { columnClass = columnClass.getComponentType(); } if ( String.class.equals( columnClass ) ) { continue; } if ( Number.class.isAssignableFrom( columnClass ) ) { continue; } if ( Date.class.isAssignableFrom( columnClass ) ) { continue; } if ( Boolean.class.equals( columnClass ) ) { continue; } if ( columnClass.isPrimitive() ) { continue; } if ( Paint.class.isAssignableFrom( columnClass ) ) { continue; } if ( Shape.class.isAssignableFrom( columnClass ) ) { continue; } if ( Stroke.class.isAssignableFrom( columnClass ) ) { continue; } if ( columnClass.isEnum() ) { continue; } return false; } return true; }
CachableTableModel extends AbstractTableModel implements MetaTableModel { public static boolean isSafeToCache( final TableModel model ) { final int columnCount = model.getColumnCount(); for ( int i = 0; i < columnCount; i += 1 ) { Class columnClass = model.getColumnClass( i ); while ( columnClass.isArray() ) { columnClass = columnClass.getComponentType(); } if ( String.class.equals( columnClass ) ) { continue; } if ( Number.class.isAssignableFrom( columnClass ) ) { continue; } if ( Date.class.isAssignableFrom( columnClass ) ) { continue; } if ( Boolean.class.equals( columnClass ) ) { continue; } if ( columnClass.isPrimitive() ) { continue; } if ( Paint.class.isAssignableFrom( columnClass ) ) { continue; } if ( Shape.class.isAssignableFrom( columnClass ) ) { continue; } if ( Stroke.class.isAssignableFrom( columnClass ) ) { continue; } if ( columnClass.isEnum() ) { continue; } return false; } return true; } }
CachableTableModel extends AbstractTableModel implements MetaTableModel { public static boolean isSafeToCache( final TableModel model ) { final int columnCount = model.getColumnCount(); for ( int i = 0; i < columnCount; i += 1 ) { Class columnClass = model.getColumnClass( i ); while ( columnClass.isArray() ) { columnClass = columnClass.getComponentType(); } if ( String.class.equals( columnClass ) ) { continue; } if ( Number.class.isAssignableFrom( columnClass ) ) { continue; } if ( Date.class.isAssignableFrom( columnClass ) ) { continue; } if ( Boolean.class.equals( columnClass ) ) { continue; } if ( columnClass.isPrimitive() ) { continue; } if ( Paint.class.isAssignableFrom( columnClass ) ) { continue; } if ( Shape.class.isAssignableFrom( columnClass ) ) { continue; } if ( Stroke.class.isAssignableFrom( columnClass ) ) { continue; } if ( columnClass.isEnum() ) { continue; } return false; } return true; } CachableTableModel( final TableModel model ); }
CachableTableModel extends AbstractTableModel implements MetaTableModel { public static boolean isSafeToCache( final TableModel model ) { final int columnCount = model.getColumnCount(); for ( int i = 0; i < columnCount; i += 1 ) { Class columnClass = model.getColumnClass( i ); while ( columnClass.isArray() ) { columnClass = columnClass.getComponentType(); } if ( String.class.equals( columnClass ) ) { continue; } if ( Number.class.isAssignableFrom( columnClass ) ) { continue; } if ( Date.class.isAssignableFrom( columnClass ) ) { continue; } if ( Boolean.class.equals( columnClass ) ) { continue; } if ( columnClass.isPrimitive() ) { continue; } if ( Paint.class.isAssignableFrom( columnClass ) ) { continue; } if ( Shape.class.isAssignableFrom( columnClass ) ) { continue; } if ( Stroke.class.isAssignableFrom( columnClass ) ) { continue; } if ( columnClass.isEnum() ) { continue; } return false; } return true; } CachableTableModel( final TableModel model ); String getColumnName( final int column ); Class getColumnClass( final int columnIndex ); DataAttributes getCellDataAttributes( final int row, final int column ); boolean isCellDataAttributesSupported(); DataAttributes getColumnAttributes( final int column ); DataAttributes getTableAttributes(); int getRowCount(); int getColumnCount(); Object getValueAt( final int rowIndex, final int columnIndex ); static boolean isSafeToCache( final TableModel model ); }
CachableTableModel extends AbstractTableModel implements MetaTableModel { public static boolean isSafeToCache( final TableModel model ) { final int columnCount = model.getColumnCount(); for ( int i = 0; i < columnCount; i += 1 ) { Class columnClass = model.getColumnClass( i ); while ( columnClass.isArray() ) { columnClass = columnClass.getComponentType(); } if ( String.class.equals( columnClass ) ) { continue; } if ( Number.class.isAssignableFrom( columnClass ) ) { continue; } if ( Date.class.isAssignableFrom( columnClass ) ) { continue; } if ( Boolean.class.equals( columnClass ) ) { continue; } if ( columnClass.isPrimitive() ) { continue; } if ( Paint.class.isAssignableFrom( columnClass ) ) { continue; } if ( Shape.class.isAssignableFrom( columnClass ) ) { continue; } if ( Stroke.class.isAssignableFrom( columnClass ) ) { continue; } if ( columnClass.isEnum() ) { continue; } return false; } return true; } CachableTableModel( final TableModel model ); String getColumnName( final int column ); Class getColumnClass( final int columnIndex ); DataAttributes getCellDataAttributes( final int row, final int column ); boolean isCellDataAttributesSupported(); DataAttributes getColumnAttributes( final int column ); DataAttributes getTableAttributes(); int getRowCount(); int getColumnCount(); Object getValueAt( final int rowIndex, final int columnIndex ); static boolean isSafeToCache( final TableModel model );  }