1 19 20 package org.netbeans.modules.java.source.parsing; 21 22 23 import java.io.File ; 24 import java.io.FileInputStream ; 25 import java.io.FileOutputStream ; 26 import java.io.FileReader ; 27 import java.io.FileWriter ; 28 import java.net.URI ; 29 30 34 public class OutputFileObject extends FileObjects.FileBase { 35 36 private final File baseFolder; 37 38 39 public static OutputFileObject create (final File baseFolder, final File diskDelegate) { 40 assert baseFolder != null && diskDelegate != null; 41 String [] pkgNamePair = FileObjects.getFolderAndBaseName(FileObjects.getRelativePath(baseFolder,diskDelegate),File.separatorChar); 42 return new OutputFileObject (baseFolder, diskDelegate, FileObjects.convertFolder2Package(pkgNamePair[0],File.separatorChar), pkgNamePair[1]); 43 } 44 45 46 private OutputFileObject (final File baseFolder, final File diskDelegate, final String packageName, final String baseName) { 47 super (diskDelegate, packageName, baseName); 48 this.baseFolder = baseFolder; 49 } 50 51 public java.nio.CharBuffer getCharContent(boolean ignoreEncodingErrors) throws java.io.IOException { 52 throw new UnsupportedOperationException ("Binary file"); 53 } 54 55 public boolean delete() { 56 return this.f.delete(); 57 } 58 59 public String getPath() { 60 return this.f.getPath(); 61 } 62 63 public URI toUri () { 64 return this.f.toURI(); 65 } 66 67 public long getLastModified() { 68 return this.f.lastModified(); 69 } 70 71 public java.io.InputStream openInputStream() throws java.io.IOException { 72 return new FileInputStream (this.f); 73 } 74 75 public java.io.OutputStream openOutputStream() throws java.io.IOException { 76 return new FileOutputStream (f); 77 } 78 79 public java.io.Reader openReader(boolean b) throws java.io.IOException { 80 return new FileReader (this.f); 81 } 82 83 public java.io.Writer openWriter() throws java.io.IOException { 84 return new FileWriter (this.f); 85 } 86 87 public @Override String toString () { 88 return this.f.getAbsolutePath(); 89 } 90 91 public @Override boolean equals (Object other) { 92 if (other instanceof OutputFileObject) { 93 OutputFileObject ofo = (OutputFileObject) other; 94 return this.baseFolder.equals(ofo.baseFolder) && 95 this.f.equals(ofo.f); 96 } 97 return false; 98 } 99 100 public @Override int hashCode () { 101 return this.f.hashCode(); 102 } 103 } 104 | Popular Tags |