@Override public ClassDescriptor getClassDescriptor() throws ResourceNotFoundException, InvalidClassFileFormatException { return codeBase.getClassDescriptor(); }
@Override public int getNumBytes() { return codeBase.getNumBytes(); }
@Override public String toString() { return codeBase.getPathName(); } }
@Override public String getResourceName() { if (overriddenResourceName != null) { return overriddenResourceName; } return codeBase.getResourceName(); }
@Override public InputStream openResource() throws IOException { return codeBase.openFile(); }
static IScannableCodeBase createFilesystemCodeBase(FilesystemCodeBaseLocator codeBaseLocator) throws IOException { String fileName = codeBaseLocator.getPathName(); File file = new File(fileName); if (!file.exists() || !file.canRead()) { return createEmptyCodeBase(codeBaseLocator, file); } else if (file.isDirectory()) { return new DirectoryCodeBase(codeBaseLocator, file); } else if (!file.isFile()) { return createEmptyCodeBase(codeBaseLocator, file); } else if (fileName.endsWith(".class")) { return new SingleFileCodeBase(codeBaseLocator, fileName); } else if (fileName.endsWith(File.separator + "jrt-fs.jar")) { return new JrtfsCodeBase(codeBaseLocator, fileName); } else { try { return ZipCodeBaseFactory.makeZipCodeBase(codeBaseLocator, file); } catch (IOException e) { return createEmptyCodeBase(codeBaseLocator, file); } } }
@Override public ICodeBaseEntry lookupResource(String resourceName) { if (!resourceName.equals(getResourceName())) { return null; } return new SingleFileCodeBaseEntry(this); }
@Override public InputStream openResource() throws IOException { return codeBase.openFile(); }
static IScannableCodeBase createFilesystemCodeBase(FilesystemCodeBaseLocator codeBaseLocator) throws IOException { String fileName = codeBaseLocator.getPathName(); File file = new File(fileName); if (!file.exists()) { throw new FileNotFoundException("File " + file.getAbsolutePath() + " doesn't exist"); } else if (!file.canRead()) { throw new IOException("File " + file.getAbsolutePath() + " not readable"); } else if (file.isDirectory()) { return new DirectoryCodeBase(codeBaseLocator, file); } else if (!file.isFile()) { throw new IOException("File " + file.getAbsolutePath() + " is not a normal file"); } else if (fileName.endsWith(".class")) { return new SingleFileCodeBase(codeBaseLocator, fileName); } else { return ZipCodeBaseFactory.makeZipCodeBase(codeBaseLocator, file); } }
@Override public String getResourceName() { if (overriddenResourceName != null) { return overriddenResourceName; } return codeBase.getResourceName(); }
/** * Get the resource name of the single file. We have to open the file and * parse the constant pool in order to find this out. * * @return the resource name (e.g., "java/lang/String.class" if the class is * java.lang.String) */ String getResourceName() { if (!resourceNameKnown) { // The resource name of a classfile can only be determined by // reading // the file and parsing the constant pool. // If we can't do this for some reason, then we just // make the resource name equal to the filename. try { resourceName = getClassDescriptor().toResourceName(); } catch (Exception e) { resourceName = fileName; } resourceNameKnown = true; } return resourceName; }
@Override public String toString() { return codeBase.getPathName(); } }
@Override public int getNumBytes() { return codeBase.getNumBytes(); }
@Override public ICodeBaseEntry lookupResource(String resourceName) { if (!resourceName.equals(getResourceName())) { return null; } return new SingleFileCodeBaseEntry(this); }
@Override public ClassDescriptor getClassDescriptor() throws ResourceNotFoundException, InvalidClassFileFormatException { return codeBase.getClassDescriptor(); }
/** * Get the resource name of the single file. We have to open the file and * parse the constant pool in order to find this out. * * @return the resource name (e.g., "java/lang/String.class" if the class is * java.lang.String) */ String getResourceName() { if (!resourceNameKnown) { // The resource name of a classfile can only be determined by // reading // the file and parsing the constant pool. // If we can't do this for some reason, then we just // make the resource name equal to the filename. try { resourceName = getClassDescriptor().toResourceName(); } catch (Exception e) { resourceName = fileName; } resourceNameKnown = true; } return resourceName; }