@Test public void testGetValueAt() { final String localizedName1 = "fileName1"; final String localizedName2 = "fileName2"; final String localizedName3 = "fileName3"; final String description1 = "description1"; final String description2 = "description2"; final String description3 = "description3"; final long modifiedTime = System.currentTimeMillis(); RepositoryTableModel repoTableModel = new RepositoryTableModel(); assertNotNull( repoTableModel ); repoTableModel.setSelectedPath( fileObject ); try { doReturn( FileType.FOLDER ).when( fileObject ).getType(); FileObject[] childFiles = new FileObject[] { childFile1, childFile2, childFile3 }; doReturn( childFileName1 ).when( childFile1 ).getName(); doReturn( childFileName2 ).when( childFile2 ).getName(); doReturn( childFileName3 ).when( childFile3 ).getName(); doReturn( "file1.txt" ).when( childFileName1 ).getBaseName(); doReturn( "file2.txt" ).when( childFileName2 ).getBaseName(); doReturn( "file3.txt" ).when( childFileName3 ).getBaseName(); doReturn( childFileContent1 ).when( childFile1 ).getContent(); doReturn( childFileContent2 ).when( childFile2 ).getContent(); doReturn( childFileContent3 ).when( childFile3 ).getContent(); doReturn( localizedName1 ).when( childFileContent1 ).getAttribute( "localized-name" ); doReturn( localizedName2 ).when( childFileContent2 ).getAttribute( "localized-name" ); doReturn( localizedName3 ).when( childFileContent3 ).getAttribute( "localized-name" ); doReturn( description1 ).when( childFileContent1 ).getAttribute( "description" ); doReturn( description2 ).when( childFileContent2 ).getAttribute( "description" ); doReturn( description3 ).when( childFileContent3 ).getAttribute( "description" ); doReturn( modifiedTime ).when( childFileContent1 ).getLastModifiedTime(); doReturn( modifiedTime ).when( childFileContent2 ).getLastModifiedTime(); doReturn( modifiedTime ).when( childFileContent3 ).getLastModifiedTime(); doReturn( childFiles ).when( fileObject ).getChildren(); assertEquals( localizedName1, repoTableModel.getValueAt( 0, 0 ) ); assertEquals( "file1.txt", repoTableModel.getValueAt( 0, 1 ) ); assertEquals( new Date( modifiedTime ), repoTableModel.getValueAt( 0, 2 ) ); assertEquals( description1, repoTableModel.getValueAt( 0, 3 ) ); } catch ( FileSystemException e ) { e.printStackTrace(); } }
public Object getValueAt( final int row, final int column ) { final FileObject node1 = getElementForRow( row ); try { switch ( column ) { case 0: return node1.getContent().getAttribute( "localized-name" ); case 1: return URLDecoder.decode( node1.getName().getBaseName().replaceAll( "\\+", "%2B" ), "UTF-8" ); case 2: final long lastModifiedTime = node1.getContent().getLastModifiedTime(); if ( lastModifiedTime == -1 ) { return null; } return new Date( lastModifiedTime ); case 3: return node1.getContent().getAttribute( "description" ); default: throw new IndexOutOfBoundsException(); } } catch ( FileSystemException fse ) { UncaughtExceptionsModel.getInstance().addException( fse ); return null; } catch ( UnsupportedEncodingException e ) { UncaughtExceptionsModel.getInstance().addException( e ); return null; } }
RepositoryTableModel extends AbstractTableModel { public Object getValueAt( final int row, final int column ) { final FileObject node1 = getElementForRow( row ); try { switch ( column ) { case 0: return node1.getContent().getAttribute( "localized-name" ); case 1: return URLDecoder.decode( node1.getName().getBaseName().replaceAll( "\\+", "%2B" ), "UTF-8" ); case 2: final long lastModifiedTime = node1.getContent().getLastModifiedTime(); if ( lastModifiedTime == -1 ) { return null; } return new Date( lastModifiedTime ); case 3: return node1.getContent().getAttribute( "description" ); default: throw new IndexOutOfBoundsException(); } } catch ( FileSystemException fse ) { UncaughtExceptionsModel.getInstance().addException( fse ); return null; } catch ( UnsupportedEncodingException e ) { UncaughtExceptionsModel.getInstance().addException( e ); return null; } } }
RepositoryTableModel extends AbstractTableModel { public Object getValueAt( final int row, final int column ) { final FileObject node1 = getElementForRow( row ); try { switch ( column ) { case 0: return node1.getContent().getAttribute( "localized-name" ); case 1: return URLDecoder.decode( node1.getName().getBaseName().replaceAll( "\\+", "%2B" ), "UTF-8" ); case 2: final long lastModifiedTime = node1.getContent().getLastModifiedTime(); if ( lastModifiedTime == -1 ) { return null; } return new Date( lastModifiedTime ); case 3: return node1.getContent().getAttribute( "description" ); default: throw new IndexOutOfBoundsException(); } } catch ( FileSystemException fse ) { UncaughtExceptionsModel.getInstance().addException( fse ); return null; } catch ( UnsupportedEncodingException e ) { UncaughtExceptionsModel.getInstance().addException( e ); return null; } } RepositoryTableModel(); }
RepositoryTableModel extends AbstractTableModel { public Object getValueAt( final int row, final int column ) { final FileObject node1 = getElementForRow( row ); try { switch ( column ) { case 0: return node1.getContent().getAttribute( "localized-name" ); case 1: return URLDecoder.decode( node1.getName().getBaseName().replaceAll( "\\+", "%2B" ), "UTF-8" ); case 2: final long lastModifiedTime = node1.getContent().getLastModifiedTime(); if ( lastModifiedTime == -1 ) { return null; } return new Date( lastModifiedTime ); case 3: return node1.getContent().getAttribute( "description" ); default: throw new IndexOutOfBoundsException(); } } catch ( FileSystemException fse ) { UncaughtExceptionsModel.getInstance().addException( fse ); return null; } catch ( UnsupportedEncodingException e ) { UncaughtExceptionsModel.getInstance().addException( e ); return null; } } RepositoryTableModel(); boolean isShowHiddenFiles(); void setShowHiddenFiles( final boolean showHiddenFiles ); String[] getFilters(); void setFilters( final String[] filters ); FileObject getSelectedPath(); void setSelectedPath( final FileObject selectedPath ); int getColumnCount(); int getRowCount(); String getColumnName( final int col ); FileObject getElementForRow( final int row ); Object getValueAt( final int row, final int column ); Class getColumnClass( final int column ); }
RepositoryTableModel extends AbstractTableModel { public Object getValueAt( final int row, final int column ) { final FileObject node1 = getElementForRow( row ); try { switch ( column ) { case 0: return node1.getContent().getAttribute( "localized-name" ); case 1: return URLDecoder.decode( node1.getName().getBaseName().replaceAll( "\\+", "%2B" ), "UTF-8" ); case 2: final long lastModifiedTime = node1.getContent().getLastModifiedTime(); if ( lastModifiedTime == -1 ) { return null; } return new Date( lastModifiedTime ); case 3: return node1.getContent().getAttribute( "description" ); default: throw new IndexOutOfBoundsException(); } } catch ( FileSystemException fse ) { UncaughtExceptionsModel.getInstance().addException( fse ); return null; } catch ( UnsupportedEncodingException e ) { UncaughtExceptionsModel.getInstance().addException( e ); return null; } } RepositoryTableModel(); boolean isShowHiddenFiles(); void setShowHiddenFiles( final boolean showHiddenFiles ); String[] getFilters(); void setFilters( final String[] filters ); FileObject getSelectedPath(); void setSelectedPath( final FileObject selectedPath ); int getColumnCount(); int getRowCount(); String getColumnName( final int col ); FileObject getElementForRow( final int row ); Object getValueAt( final int row, final int column ); Class getColumnClass( final int column );  }