1 19 20 package org.netbeans.modules.masterfs.filebasedfs.fileobjects; 21 22 import java.io.File ; 23 import java.io.FileNotFoundException ; 24 import java.io.IOException ; 25 import java.io.InputStream ; 26 import java.io.OutputStream ; 27 import java.util.Date ; 28 import org.netbeans.modules.masterfs.filebasedfs.FileBasedFileSystem; 29 import org.netbeans.modules.masterfs.providers.ProvidedExtensions; 30 import org.openide.filesystems.FileLock; 31 import org.openide.filesystems.FileObject; 32 33 36 public class ReplaceForSerialization extends Object implements java.io.Serializable { 37 40 static final long serialVersionUID = -7451332135435542113L; 41 private final String absolutePath; 42 43 public ReplaceForSerialization(final File file) { 44 absolutePath = file.getAbsolutePath(); 45 } 46 47 public final Object readResolve() { 48 final File file = new File (absolutePath); 49 final FileBasedFileSystem fs = FileBasedFileSystem.getInstance(file); 50 final FileObject retVal = (fs != null) ? fs.findFileObject(file) : null; 51 52 53 return (retVal != null) ? retVal : new Invalid (file); 54 } 55 56 private static class Invalid extends BaseFileObj { 57 protected Invalid(File file) { 58 super(file); 59 } 60 61 public void delete(FileLock lock, ProvidedExtensions.IOHandler io) throws IOException { 62 throw new IOException (getPath()); 63 } 64 65 boolean checkLock(FileLock lock) throws IOException { 66 return false; 67 } 68 69 protected void setValid(boolean valid) {} 70 71 public boolean isFolder() { 72 return false; 73 } 74 75 public Date lastModified() { 76 return new Date (0L); 77 } 78 79 84 public boolean isValid() { 85 return false; 86 } 87 88 public InputStream getInputStream() throws FileNotFoundException { 89 throw new FileNotFoundException (getPath()); 90 } 91 92 public OutputStream getOutputStream(FileLock lock) throws IOException { 93 throw new IOException (getPath()); 94 } 95 96 public FileLock lock() throws IOException { 97 throw new IOException (getPath()); 98 } 99 100 public FileObject[] getChildren() { 101 return new FileObject[] {}; 102 } 103 104 public FileObject getFileObject(String name, String ext) { 105 return null; 106 } 107 108 public FileObject createFolder(String name) throws IOException { 109 throw new IOException (getPath()); 110 } 111 112 public FileObject createData(String name, String ext) throws IOException { 113 throw new IOException (getPath()); 114 } 115 116 public void refresh(final boolean expected, boolean fire) { 117 } 118 } 119 } 120 | Popular Tags |