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

changeset 400
35e29f51a7c3
parent 333
7c2d6da61646
child 404
14735c7932d7
child 415
49359d0e6a9c
equal deleted inserted replaced
399:90c28923e449 400:35e29f51a7c3
27 27
28 import java.io.File; 28 import java.io.File;
29 import java.io.IOException; 29 import java.io.IOException;
30 import java.io.InputStreamReader; 30 import java.io.InputStreamReader;
31 import java.io.Reader; 31 import java.io.Reader;
32 import java.net.URI;
33 import java.net.URISyntaxException;
32 import java.nio.charset.CharsetDecoder; 34 import java.nio.charset.CharsetDecoder;
33 import javax.lang.model.element.Modifier; 35 import javax.lang.model.element.Modifier;
34 import javax.lang.model.element.NestingKind; 36 import javax.lang.model.element.NestingKind;
35 import javax.tools.JavaFileObject; 37 import javax.tools.JavaFileObject;
36 38
91 protected static String removeExtension(String fileName) { 93 protected static String removeExtension(String fileName) {
92 int lastDot = fileName.lastIndexOf("."); 94 int lastDot = fileName.lastIndexOf(".");
93 return (lastDot == -1 ? fileName : fileName.substring(0, lastDot)); 95 return (lastDot == -1 ? fileName : fileName.substring(0, lastDot));
94 } 96 }
95 97
98 protected static URI createJarUri(File jarFile, String entryName) {
99 URI jarURI = jarFile.toURI().normalize();
100 String separator = entryName.startsWith("/") ? "!" : "!/";
101 try {
102 // The jar URI convention appears to be not to re-encode the jarURI
103 return new URI("jar:" + jarURI + separator + entryName);
104 } catch (URISyntaxException e) {
105 throw new CannotCreateUriError(jarURI + separator + entryName, e);
106 }
107 }
108
109 /** Used when URLSyntaxException is thrown unexpectedly during
110 * implementations of (Base)FileObject.toURI(). */
111 protected static class CannotCreateUriError extends Error {
112 private static final long serialVersionUID = 9101708840997613546L;
113 public CannotCreateUriError(String value, Throwable cause) {
114 super(value, cause);
115 }
116 }
117
96 /** The file manager that created this JavaFileObject. */ 118 /** The file manager that created this JavaFileObject. */
97 protected final JavacFileManager fileManager; 119 protected final JavacFileManager fileManager;
98
99 } 120 }

mercurial