1 9 package org.jboss.portal.common.net.file; 10 11 import org.jboss.portal.common.net.URLNavigationProvider; 12 import org.jboss.portal.common.net.URLVisitor; 13 import org.apache.log4j.Logger; 14 15 import java.util.Iterator ; 16 import java.net.URL ; 17 import java.io.IOException ; 18 import java.io.File ; 19 20 24 public class FileURLNavigationProvider implements URLNavigationProvider 25 { 26 27 28 private Logger log = Logger.getLogger(FileURLNavigationProvider.class); 29 30 public boolean isDir(URL url) throws IllegalArgumentException 31 { 32 throw new UnsupportedOperationException ("todo"); 33 } 34 35 public Iterator getChildren(URL url) 36 { 37 throw new UnsupportedOperationException ("todo"); 38 } 39 40 public void visit(URL url, URLVisitor visitor) throws IllegalArgumentException , IOException 41 { 42 File file = new File (url.getFile()); 43 String name = file.getName(); 44 if (file.isDirectory()) 45 { 46 visitor.startDir(name); 47 File [] childrenFiles = file.listFiles(); 48 for (int i = 0; i < childrenFiles.length; i++) 49 { 50 File childFile = childrenFiles[i]; 51 URL childURL = childFile.toURL(); 52 visit(childURL, visitor); 53 } 54 visitor.endDir(name); 55 } 56 else 57 { 58 visitor.file(name, url); 59 } 60 } 61 } 62 | Popular Tags |