1114 return result; |
1114 return result; |
1115 } |
1115 } |
1116 throw new IllegalArgumentException("Invalid relative path: " + file); |
1116 throw new IllegalArgumentException("Invalid relative path: " + file); |
1117 } |
1117 } |
1118 |
1118 |
1119 @SuppressWarnings("deprecation") // bug 6410637 |
|
1120 public static String getJavacFileName(FileObject file) { |
|
1121 if (file instanceof BaseFileObject) |
|
1122 return ((BaseFileObject)file).getPath(); |
|
1123 URI uri = file.toUri(); |
|
1124 String scheme = uri.getScheme(); |
|
1125 if (scheme == null || scheme.equals("file") || scheme.equals("jar")) |
|
1126 return uri.getPath(); |
|
1127 else |
|
1128 return uri.toString(); |
|
1129 } |
|
1130 |
|
1131 @SuppressWarnings("deprecation") // bug 6410637 |
|
1132 public static String getJavacBaseFileName(FileObject file) { |
|
1133 if (file instanceof BaseFileObject) |
|
1134 return ((BaseFileObject)file).getName(); |
|
1135 URI uri = file.toUri(); |
|
1136 String scheme = uri.getScheme(); |
|
1137 if (scheme == null || scheme.equals("file") || scheme.equals("jar")) { |
|
1138 String path = uri.getPath(); |
|
1139 if (path == null) |
|
1140 return null; |
|
1141 if (scheme != null && scheme.equals("jar")) |
|
1142 path = path.substring(path.lastIndexOf('!') + 1); |
|
1143 return path.substring(path.lastIndexOf('/') + 1); |
|
1144 } else { |
|
1145 return uri.toString(); |
|
1146 } |
|
1147 } |
|
1148 |
|
1149 private static <T> T nullCheck(T o) { |
1119 private static <T> T nullCheck(T o) { |
1150 o.getClass(); // null check |
1120 o.getClass(); // null check |
1151 return o; |
1121 return o; |
1152 } |
1122 } |
1153 |
1123 |