src/share/classes/com/sun/tools/javac/file/ZipFileIndexArchive.java

changeset 400
35e29f51a7c3
parent 333
7c2d6da61646
child 404
14735c7932d7
child 415
49359d0e6a9c
equal deleted inserted replaced
399:90c28923e449 400:35e29f51a7c3
70 } 70 }
71 71
72 public JavaFileObject getFileObject(RelativeDirectory subdirectory, String file) { 72 public JavaFileObject getFileObject(RelativeDirectory subdirectory, String file) {
73 RelativeFile fullZipFileName = new RelativeFile(subdirectory, file); 73 RelativeFile fullZipFileName = new RelativeFile(subdirectory, file);
74 ZipFileIndex.Entry entry = zfIndex.getZipIndexEntry(fullZipFileName); 74 ZipFileIndex.Entry entry = zfIndex.getZipIndexEntry(fullZipFileName);
75 JavaFileObject ret = new ZipFileIndexFileObject(fileManager, zfIndex, entry, zfIndex.getZipFile().getPath()); 75 JavaFileObject ret = new ZipFileIndexFileObject(fileManager, zfIndex, entry, zfIndex.getZipFile());
76 return ret; 76 return ret;
77 } 77 }
78 78
79 public Set<RelativeDirectory> getSubdirectories() { 79 public Set<RelativeDirectory> getSubdirectories() {
80 return zfIndex.getAllDirectories(); 80 return zfIndex.getAllDirectories();
82 82
83 public void close() throws IOException { 83 public void close() throws IOException {
84 zfIndex.close(); 84 zfIndex.close();
85 } 85 }
86 86
87 @Override
87 public String toString() { 88 public String toString() {
88 return "ZipFileIndexArchive[" + zfIndex + "]"; 89 return "ZipFileIndexArchive[" + zfIndex + "]";
89 } 90 }
90 91
91 /** 92 /**
109 */ 110 */
110 InputStream inputStream = null; 111 InputStream inputStream = null;
111 112
112 /** The name of the zip file where this entry resides. 113 /** The name of the zip file where this entry resides.
113 */ 114 */
114 String zipName; 115 File zipName;
115 116
116 117
117 ZipFileIndexFileObject(JavacFileManager fileManager, ZipFileIndex zfIndex, ZipFileIndex.Entry entry, String zipFileName) { 118 ZipFileIndexFileObject(JavacFileManager fileManager, ZipFileIndex zfIndex, ZipFileIndex.Entry entry, File zipFileName) {
118 super(fileManager); 119 super(fileManager);
119 this.name = entry.getFileName(); 120 this.name = entry.getFileName();
120 this.zfIndex = zfIndex; 121 this.zfIndex = zfIndex;
121 this.entry = entry; 122 this.entry = entry;
122 this.zipName = zipFileName; 123 this.zipName = zipFileName;
128 inputStream = new ByteArrayInputStream(read()); 129 inputStream = new ByteArrayInputStream(read());
129 } 130 }
130 return inputStream; 131 return inputStream;
131 } 132 }
132 133
134 @Override
133 protected CharsetDecoder getDecoder(boolean ignoreEncodingErrors) { 135 protected CharsetDecoder getDecoder(boolean ignoreEncodingErrors) {
134 return fileManager.getDecoder(fileManager.getEncodingName(), ignoreEncodingErrors); 136 return fileManager.getDecoder(fileManager.getEncodingName(), ignoreEncodingErrors);
135 } 137 }
136 138
137 public OutputStream openOutputStream() throws IOException { 139 public OutputStream openOutputStream() throws IOException {
155 return name.equals(cn + k.extension); 157 return name.equals(cn + k.extension);
156 } 158 }
157 159
158 /** @deprecated see bug 6410637 */ 160 /** @deprecated see bug 6410637 */
159 @Deprecated 161 @Deprecated
162 @Override
160 public String getPath() { 163 public String getPath() {
161 return zipName + "(" + entry.getName() + ")"; 164 return zipName + "(" + entry.getName() + ")";
162 } 165 }
163 166
164 public long getLastModified() { 167 public long getLastModified() {
181 public int hashCode() { 184 public int hashCode() {
182 return zipName.hashCode() + (name.hashCode() << 10); 185 return zipName.hashCode() + (name.hashCode() << 10);
183 } 186 }
184 187
185 public String getZipName() { 188 public String getZipName() {
186 return zipName; 189 return zipName.getPath();
187 } 190 }
188 191
189 public String getZipEntryName() { 192 public String getZipEntryName() {
190 return entry.getName(); 193 return entry.getName();
191 } 194 }
192 195
193 public URI toUri() { 196 public URI toUri() {
194 String zipName = new File(getZipName()).toURI().normalize().getPath(); 197 if (zfIndex.symbolFilePrefix != null)
195 String entryName = getZipEntryName(); 198 return createJarUri(zipName, zfIndex.symbolFilePrefix.path + entry.getName());
196 return URI.create("jar:" + zipName + "!" + entryName); 199 else
200 return createJarUri(zipName, entry.getName());
197 } 201 }
198 202
199 private byte[] read() throws IOException { 203 private byte[] read() throws IOException {
200 assert entry != null; // see constructor 204 assert entry != null; // see constructor
201 return zfIndex.read(entry); 205 return zfIndex.read(entry);

mercurial