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

changeset 415
49359d0e6a9c
parent 400
35e29f51a7c3
child 418
4776a869fdfa
     1.1 --- a/src/share/classes/com/sun/tools/javac/file/ZipFileIndexArchive.java	Wed Sep 23 18:29:41 2009 -0700
     1.2 +++ b/src/share/classes/com/sun/tools/javac/file/ZipFileIndexArchive.java	Wed Sep 23 18:48:13 2009 -0700
     1.3 @@ -123,88 +123,41 @@
     1.4              this.zipName = zipFileName;
     1.5          }
     1.6  
     1.7 +        @Override
     1.8 +        public URI toUri() {
     1.9 +            return createJarUri(zipName, getPrefixedEntryName());
    1.10 +        }
    1.11 +
    1.12 +        @Override
    1.13 +        public String getName() {
    1.14 +            return zipName + "(" + getPrefixedEntryName() + ")";
    1.15 +        }
    1.16 +
    1.17 +        @Override
    1.18 +        public String getShortName() {
    1.19 +            return zipName.getName() + "(" + entry.getName() + ")";
    1.20 +        }
    1.21 +
    1.22 +        @Override
    1.23 +        public JavaFileObject.Kind getKind() {
    1.24 +            return getKind(entry.getName());
    1.25 +        }
    1.26 +
    1.27 +        @Override
    1.28          public InputStream openInputStream() throws IOException {
    1.29 -
    1.30              if (inputStream == null) {
    1.31 -                inputStream = new ByteArrayInputStream(read());
    1.32 +                assert entry != null; // see constructor
    1.33 +                inputStream = new ByteArrayInputStream(zfIndex.read(entry));
    1.34              }
    1.35              return inputStream;
    1.36          }
    1.37  
    1.38          @Override
    1.39 -        protected CharsetDecoder getDecoder(boolean ignoreEncodingErrors) {
    1.40 -            return fileManager.getDecoder(fileManager.getEncodingName(), ignoreEncodingErrors);
    1.41 -        }
    1.42 -
    1.43          public OutputStream openOutputStream() throws IOException {
    1.44              throw new UnsupportedOperationException();
    1.45          }
    1.46  
    1.47 -        public Writer openWriter() throws IOException {
    1.48 -            throw new UnsupportedOperationException();
    1.49 -        }
    1.50 -
    1.51 -        /** @deprecated see bug 6410637 */
    1.52 -        @Deprecated
    1.53 -        public String getName() {
    1.54 -            return name;
    1.55 -        }
    1.56 -
    1.57 -        public boolean isNameCompatible(String cn, JavaFileObject.Kind k) {
    1.58 -            cn.getClass(); // null check
    1.59 -            if (k == Kind.OTHER && getKind() != k)
    1.60 -                return false;
    1.61 -            return name.equals(cn + k.extension);
    1.62 -        }
    1.63 -
    1.64 -        /** @deprecated see bug 6410637 */
    1.65 -        @Deprecated
    1.66          @Override
    1.67 -        public String getPath() {
    1.68 -            return zipName + "(" + entry.getName() + ")";
    1.69 -        }
    1.70 -
    1.71 -        public long getLastModified() {
    1.72 -            return entry.getLastModified();
    1.73 -        }
    1.74 -
    1.75 -        public boolean delete() {
    1.76 -            throw new UnsupportedOperationException();
    1.77 -        }
    1.78 -
    1.79 -        @Override
    1.80 -        public boolean equals(Object other) {
    1.81 -            if (!(other instanceof ZipFileIndexFileObject))
    1.82 -                return false;
    1.83 -            ZipFileIndexFileObject o = (ZipFileIndexFileObject) other;
    1.84 -            return entry.equals(o.entry);
    1.85 -        }
    1.86 -
    1.87 -        @Override
    1.88 -        public int hashCode() {
    1.89 -            return zipName.hashCode() + (name.hashCode() << 10);
    1.90 -        }
    1.91 -
    1.92 -        public String getZipName() {
    1.93 -            return zipName.getPath();
    1.94 -        }
    1.95 -
    1.96 -        public String getZipEntryName() {
    1.97 -            return entry.getName();
    1.98 -        }
    1.99 -
   1.100 -        public URI toUri() {
   1.101 -            if (zfIndex.symbolFilePrefix != null)
   1.102 -                return createJarUri(zipName, zfIndex.symbolFilePrefix.path + entry.getName());
   1.103 -            else
   1.104 -                return createJarUri(zipName, entry.getName());
   1.105 -        }
   1.106 -
   1.107 -        private byte[] read() throws IOException {
   1.108 -            assert entry != null; // see constructor
   1.109 -            return zfIndex.read(entry);
   1.110 -        }
   1.111 -
   1.112          public CharBuffer getCharContent(boolean ignoreEncodingErrors) throws IOException {
   1.113              CharBuffer cb = fileManager.getCachedContent(this);
   1.114              if (cb == null) {
   1.115 @@ -228,8 +181,28 @@
   1.116          }
   1.117  
   1.118          @Override
   1.119 +        public Writer openWriter() throws IOException {
   1.120 +            throw new UnsupportedOperationException();
   1.121 +        }
   1.122 +
   1.123 +        @Override
   1.124 +        public long getLastModified() {
   1.125 +            return entry.getLastModified();
   1.126 +        }
   1.127 +
   1.128 +        @Override
   1.129 +        public boolean delete() {
   1.130 +            throw new UnsupportedOperationException();
   1.131 +        }
   1.132 +
   1.133 +        @Override
   1.134 +        protected CharsetDecoder getDecoder(boolean ignoreEncodingErrors) {
   1.135 +            return fileManager.getDecoder(fileManager.getEncodingName(), ignoreEncodingErrors);
   1.136 +        }
   1.137 +
   1.138 +        @Override
   1.139          protected String inferBinaryName(Iterable<? extends File> path) {
   1.140 -            String entryName = getZipEntryName();
   1.141 +            String entryName = entry.getName();
   1.142              if (zfIndex.symbolFilePrefix != null) {
   1.143                  String prefix = zfIndex.symbolFilePrefix.path;
   1.144                  if (entryName.startsWith(prefix))
   1.145 @@ -237,6 +210,34 @@
   1.146              }
   1.147              return removeExtension(entryName).replace('/', '.');
   1.148          }
   1.149 +
   1.150 +        @Override
   1.151 +        public boolean isNameCompatible(String cn, JavaFileObject.Kind k) {
   1.152 +            cn.getClass(); // null check
   1.153 +            if (k == Kind.OTHER && getKind() != k)
   1.154 +                return false;
   1.155 +            return name.equals(cn + k.extension);
   1.156 +        }
   1.157 +
   1.158 +        @Override
   1.159 +        public boolean equals(Object other) {
   1.160 +            if (!(other instanceof ZipFileIndexFileObject))
   1.161 +                return false;
   1.162 +            ZipFileIndexFileObject o = (ZipFileIndexFileObject) other;
   1.163 +            return entry.equals(o.entry);
   1.164 +        }
   1.165 +
   1.166 +        @Override
   1.167 +        public int hashCode() {
   1.168 +            return zipName.hashCode() + (name.hashCode() << 10);
   1.169 +        }
   1.170 +
   1.171 +        private String getPrefixedEntryName() {
   1.172 +            if (zfIndex.symbolFilePrefix != null)
   1.173 +                return zfIndex.symbolFilePrefix.path + entry.getName();
   1.174 +            else
   1.175 +                return entry.getName();
   1.176 +        }
   1.177      }
   1.178  
   1.179  }

mercurial