@Test public void testFindNodeByName() { FileObject[] childFiles = new FileObject[] { childFile1, childFile2, childFile3 }; try { doReturn( FileType.FOLDER ).when( repositoryRoot ).getType(); doReturn( childFiles ).when( repositoryRoot ).getChildren(); doReturn( childFileName1 ).when( childFile1 ).getName(); doReturn( childFileName2 ).when( childFile2 ).getName(); doReturn( childFileName3 ).when( childFile3 ).getName(); doReturn( "BaseName1" ).when( childFileName1 ).getBaseName(); doReturn( "BaseName2" ).when( childFileName2 ).getBaseName(); doReturn( "BaseName3" ).when( childFileName3 ).getBaseName(); doReturn( childFile2 ).when( repositoryRoot ).getChild( "BaseName2" ); assertEquals( childFile2, RepositoryTreeModel.findNodeByName( repositoryRoot, "BaseName2" ) ); } catch ( FileSystemException e ) { e.printStackTrace(); } }
public static FileObject findNodeByName( final FileObject node, final String name ) throws FileSystemException { if ( node.getType() != FileType.FOLDER ) { return null; } final FileObject child = node.getChild( name ); if ( child == null ) { return null; } return child; }
RepositoryTreeModel implements TreeModel { public static FileObject findNodeByName( final FileObject node, final String name ) throws FileSystemException { if ( node.getType() != FileType.FOLDER ) { return null; } final FileObject child = node.getChild( name ); if ( child == null ) { return null; } return child; } }
RepositoryTreeModel implements TreeModel { public static FileObject findNodeByName( final FileObject node, final String name ) throws FileSystemException { if ( node.getType() != FileType.FOLDER ) { return null; } final FileObject child = node.getChild( name ); if ( child == null ) { return null; } return child; } RepositoryTreeModel();  RepositoryTreeModel( final FileObject repositoryRoot, final String[] filters, final boolean showFoldersOnly ); }
RepositoryTreeModel implements TreeModel { public static FileObject findNodeByName( final FileObject node, final String name ) throws FileSystemException { if ( node.getType() != FileType.FOLDER ) { return null; } final FileObject child = node.getChild( name ); if ( child == null ) { return null; } return child; } RepositoryTreeModel();  RepositoryTreeModel( final FileObject repositoryRoot, final String[] filters, final boolean showFoldersOnly ); void setShowFoldersOnly( final boolean showFoldersOnly ); boolean isShowFoldersOnly(); boolean isShowHiddenFiles(); void setShowHiddenFiles( final boolean showHiddenFiles ); String[] getFilters(); void setFilters( final String[] filters ); FileObject getFileSystemRoot(); void setFileSystemRoot( final FileObject root ); Object getRoot(); Object getChild( Object parent, final int index ); int getChildCount( Object parent ); boolean isLeaf( final Object node ); void valueForPathChanged( final TreePath path, final Object newValue ); int getIndexOfChild( Object parent, final Object childNode ); void addTreeModelListener( final TreeModelListener l ); void removeTreeModelListener( final TreeModelListener l ); void fireTreeDataChanged(); TreePath getTreePathForSelection( FileObject selectedFolder, final String selection ); static FileObject findNodeByName( final FileObject node, final String name ); }
RepositoryTreeModel implements TreeModel { public static FileObject findNodeByName( final FileObject node, final String name ) throws FileSystemException { if ( node.getType() != FileType.FOLDER ) { return null; } final FileObject child = node.getChild( name ); if ( child == null ) { return null; } return child; } RepositoryTreeModel();  RepositoryTreeModel( final FileObject repositoryRoot, final String[] filters, final boolean showFoldersOnly ); void setShowFoldersOnly( final boolean showFoldersOnly ); boolean isShowFoldersOnly(); boolean isShowHiddenFiles(); void setShowHiddenFiles( final boolean showHiddenFiles ); String[] getFilters(); void setFilters( final String[] filters ); FileObject getFileSystemRoot(); void setFileSystemRoot( final FileObject root ); Object getRoot(); Object getChild( Object parent, final int index ); int getChildCount( Object parent ); boolean isLeaf( final Object node ); void valueForPathChanged( final TreePath path, final Object newValue ); int getIndexOfChild( Object parent, final Object childNode ); void addTreeModelListener( final TreeModelListener l ); void removeTreeModelListener( final TreeModelListener l ); void fireTreeDataChanged(); TreePath getTreePathForSelection( FileObject selectedFolder, final String selection ); static FileObject findNodeByName( final FileObject node, final String name );  }