private Version processScrXml(Resource resource, String path) throws Exception { if (resource == null) { return null; } SAXParserFactory spf = SAXParserFactory.newInstance(); spf.setNamespaceAware(true); SAXParser parser = spf.newSAXParser(); SCRContentHandler handler = new SCRContentHandler(); parser.parse(resource.openInputStream(), handler); return handler.highest; }
public Set<TypeRef> parseClassFileWithCollector(ClassDataCollector cd) throws Exception { InputStream in = resource.openInputStream(); try { return parseClassFile(in, cd); } finally { in.close(); } }
public Set<TypeRef> parseClassFileWithCollector(ClassDataCollector cd) throws Exception { InputStream in = resource.openInputStream(); try { return parseClassFile(in, cd); } finally { in.close(); } }
private static Document toDoc(InputStream in) throws Exception { try (Jar jar = new Jar("feature", in)) { Resource resource = jar.getResource("feature.xml"); if (resource == null) { throw new IllegalArgumentException("JAR does not contain proper 'feature.xml"); } DocumentBuilder db = XML.dbf.newDocumentBuilder(); Document doc = db.parse(resource.openInputStream()); return doc; } }
private static Document toDoc(InputStream in) throws Exception { try (Jar jar = new Jar("feature", in)) { Resource resource = jar.getResource("feature.xml"); if (resource == null) { throw new IllegalArgumentException("JAR does not contain proper 'feature.xml"); } DocumentBuilder db = XML.dbf.newDocumentBuilder(); Document doc = db.parse(resource.openInputStream()); return doc; } }
public static void build(Jar sub, Resource resource) throws Exception { InputStream in = resource.openInputStream(); try { build(sub, in, resource.lastModified()); } catch (Exception e) { e.printStackTrace(); } finally { in.close(); } }
public Manifest getManifest() throws Exception { check(); if (manifest == null) { Resource manifestResource = getResource("META-INF/MANIFEST.MF"); if (manifestResource != null) { InputStream in = manifestResource.openInputStream(); manifest = new Manifest(in); in.close(); } } return manifest; }
public static void build(Jar sub, Resource resource) throws Exception { InputStream in = resource.openInputStream(); try { build(sub, in, resource.lastModified()); } catch (Exception e) { e.printStackTrace(); } finally { in.close(); } }
/** * Turn a resource into a file so that anything in the conversion is properly caught * @param r * @throws Exception */ public FileResource(Resource r) throws Exception { this.file = File.createTempFile("fileresource", ".resource"); deleteOnClose(true); this.file.deleteOnExit(); IO.copy(r.openInputStream(), this.file); }
public void add(Jar jar) throws Exception { for (Resource r : jar.getResources().values()) { InputStream in = r.openInputStream(); try { parse(in); } finally { in.close(); } } }
public void add(Jar jar) throws Exception { for (Resource r : jar.getResources().values()) { InputStream in = r.openInputStream(); try { parse(in); } finally { in.close(); } } }
public Manifest getManifest() throws Exception { check(); if (manifest == null) { Resource manifestResource = getResource(manifestName); if (manifestResource != null) { InputStream in = manifestResource.openInputStream(); manifest = new Manifest(in); in.close(); } } return manifest; }
public void add(Jar jar) throws Exception { for (Resource r : jar.getResources().values()) { InputStream in = r.openInputStream(); try { parse(in); } finally { in.close(); } } }
public static void build(Jar sub, Resource resource) throws Exception { InputStream in = resource.openInputStream(); try { build(sub, in, resource.lastModified()); } catch (Exception e) { e.printStackTrace(); } finally { in.close(); } }
public void add(Jar jar) throws Exception { for (Resource r : jar.getResources() .values()) { try (InputStream in = r.openInputStream()) { parse(in); } } }
public Manifest getManifest() throws Exception { check(); if (manifest == null) { Resource manifestResource = getResource(manifestName); if (manifestResource != null) { try (InputStream in = manifestResource.openInputStream()) { manifest = new Manifest(in); } } } return manifest; }
private void copyResource(File dir, String path, Resource resource) throws Exception { File to = IO.getBasedFile(dir, path); IO.mkdirs(to.getParentFile()); IO.copy(resource.openInputStream(), to); }
public Set<TypeRef> parseClassFileWithCollector(ClassDataCollector cd) throws Exception { ByteBuffer bb = resource.buffer(); if (bb != null) { return parseClassFileData(ByteBufferDataInput.wrap(bb), cd); } return parseClassFile(resource.openInputStream(), cd); }
public String _sha1(String args[]) throws Exception { Macro.verifyCommand(args, _sha1Help, new Pattern[] { null, null, Pattern.compile("base64|hex") }, 2, 3); Digester<SHA1> digester = SHA1.getDigester(); Resource r = dot.getResource(args[1]); if (r == null) throw new FileNotFoundException("From sha1, not found " + args[1]); IO.copy(r.openInputStream(), digester); return Base64.encodeBase64(digester.digest().digest()); }
public String _sha1(String args[]) throws Exception { Macro.verifyCommand(args, _sha1Help, new Pattern[] { null, null, Pattern.compile("base64|hex") }, 2, 3); Digester<SHA1> digester = SHA1.getDigester(); Resource r = dot.getResource(args[1]); if (r == null) throw new FileNotFoundException("From sha1, not found " + args[1]); IO.copy(r.openInputStream(), digester); return Base64.encodeBase64(digester.digest().digest()); }