1 19 20 package org.netbeans.modules.masterfs.filebasedfs.naming; 21 22 import java.io.File ; 23 import java.io.FileFilter ; 24 import java.io.FilenameFilter ; 25 import java.io.IOException ; 26 27 30 public final class UNCName extends FolderName { 31 UNCName(final FileNaming parent, final File f) { 32 super(parent, f); 33 } 34 35 public final File getFile() { 36 File file = super.getFile(); 37 file = (file instanceof UNCFile) ? file : new UNCFile(file); 38 return file; 39 } 40 41 public final FileNaming getParent() { 42 final FileNaming parent = super.getParent(); 43 return parent; 44 } 45 46 public static final class UNCFile extends File { 47 private UNCFile(final File file) { 48 super(file.getAbsolutePath()); 49 } 50 51 public final boolean isDirectory() { 52 return true; 53 } 54 55 public final File getParentFile() { 56 return wrap(super.getParentFile()); 57 } 58 59 public final File getAbsoluteFile() { 60 return wrap(super.getAbsoluteFile()); 61 } 62 63 public final File getCanonicalFile() throws IOException { 64 return wrap(super.getCanonicalFile()); 65 } 66 67 68 public final File [] listFiles() { 69 return wrap(super.listFiles()); 70 } 71 72 73 public final File [] listFiles(final FilenameFilter filter) { 74 return wrap(super.listFiles(filter)); 75 } 76 77 public final File [] listFiles(final FileFilter filter) { 78 return wrap(super.listFiles(filter)); 79 } 80 81 private File [] wrap(final File [] files) { 82 if (files != null) { 83 for (int i = 0; i < files.length; i++) { 84 final File file = files[i]; 85 files[i] = (file != null) ? new UNCFile(file) : null; 86 ; 87 } 88 } 89 return files; 90 } 91 92 private File wrap(final File file) { 93 return (file != null) ? new UNCFile(file) : null; 94 } 95 96 public final boolean exists() { 97 return true; 98 } 99 100 } 101 } | Popular Tags |