コード例 #1
0
ファイル: CachedTOCJars.java プロジェクト: ceylon/ceylon
    private List<String> getFileNames(String path) {
      if (artifact instanceof ContentAwareArtifactResult) {
        return ((ContentAwareArtifactResult) artifact).getFileNames(path);
      }

      File jar = artifact.artifact();
      if (jar != null) {
        load();
        // add a trailing / to only list members
        boolean emptyPackage = path.isEmpty();
        // only used for non-empty packages
        path += "/";
        List<String> ret = new ArrayList<String>();
        for (String name : contents) {
          String part = null;
          if (!emptyPackage && name.startsWith(path)) {
            // keep only the part after the package name
            part = name.substring(path.length());
          } else if (emptyPackage) {
            // keep it all, we'll filter later those in subfolders
            part = name;
          }
          // only keep those not in subfolders
          if (part != null && part.indexOf('/') == -1) ret.add(name);
        }
        return ret;
      } else {
        throw new RuntimeException("No file associated with artifact : " + artifact.toString());
      }
    }
コード例 #2
0
ファイル: CachedTOCJars.java プロジェクト: ceylon/ceylon
 URI getContentUri(String path) {
   if (artifact instanceof ContentAwareArtifactResult) {
     return ((ContentAwareArtifactResult) artifact).getContentUri(path);
   }
   File jar = artifact.artifact();
   if (jar != null) {
     load();
     try {
       if (contents.contains(path) || folders.contains(path)) {
         String uripath = FileUtil.absoluteFile(jar).toURI().getSchemeSpecificPart();
         return new URI("classpath", uripath + "!" + path, null);
       }
     } catch (URISyntaxException e) {
       throw new RuntimeException(e);
     }
     throw new RuntimeException("Missing entry: " + path + " in jar file: " + jar.getPath());
   }
   throw new RuntimeException("No file associated with artifact : " + artifact.toString());
 }
コード例 #3
0
ファイル: CachedTOCJars.java プロジェクト: ceylon/ceylon
 byte[] getContents(String path) {
   if (artifact instanceof ContentAwareArtifactResult) {
     return ((ContentAwareArtifactResult) artifact).getContents(path);
   }
   File jar = artifact.artifact();
   if (jar != null) {
     try {
       ZipFile zf = new ZipFile(jar);
       try {
         ZipEntry entry = zf.getEntry(path);
         if (entry != null) return loadFile(zf.getInputStream(entry), (int) entry.getSize());
       } finally {
         zf.close();
       }
     } catch (IOException e) {
       throw new RuntimeException(e);
     }
     throw new RuntimeException("Missing entry: " + path + " in jar file: " + jar.getPath());
   }
   throw new RuntimeException("No file associated with artifact : " + artifact.toString());
 }