Java Code Examples for java.util.zip.ZipFile#getEntry()

The following examples show how to use java.util.zip.ZipFile#getEntry() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WorkerLoad.java    From arx with Apache License 2.0 6 votes vote down vote up
/**
 * Reads the input from the file.
 *
 * @param config
 * @param zip
 * @throws IOException
 */
private void readInput(final ModelConfiguration config, final ZipFile zip) throws IOException {

    final ZipEntry entry = zip.getEntry("data/input.csv"); //$NON-NLS-1$
    if (entry == null) { return; }
    
    // Read input
    // Use project delimiter for backwards compatibility
    config.setInput(Data.create(new BufferedInputStream(zip.getInputStream(entry)),
                                getCharset(),
                                model.getCSVSyntax().getDelimiter(), getLength(zip, entry)));

    // And encode
    config.getInput().getHandle();
    
    // Disable visualization
    if (model.getMaximalSizeForComplexOperations() > 0 &&
        config.getInput().getHandle().getNumRows() > model.getMaximalSizeForComplexOperations()) {
        model.setVisualizationEnabled(false);
    }
}
 
Example 2
Source File: PatchManagerService.java    From titan-hotfix with Apache License 2.0 6 votes vote down vote up
/**
 * 获取patch包中的dex个数
 *
 * @param patchFile patch包
 * @return patch包中的Dex个数
 */
private int getDexCount(ZipFile patchFile) {
    int count = 0;
    String dexName = "classes.dex";
    ZipEntry entry = patchFile.getEntry(dexName);
    if (entry != null) {
        count = 1;
    } else {
        return count;
    }

    int idx = 2;
    while (true) {
        dexName = "classes" + idx + ".dex";
        if (patchFile.getEntry(dexName) == null) {
            break;
        }
        count++;
        idx++;
    }
    return count;
}
 
Example 3
Source File: ClassFileSourceImpl.java    From cfr with MIT License 6 votes vote down vote up
private Map<String, String> getManifestContent(ZipFile zipFile) {
    try {
        ZipEntry manifestEntry = zipFile.getEntry(MiscConstants.MANIFEST_PATH);
        Map<String, String> manifest;
        if (manifestEntry == null) {
            // Odd, but feh.
            manifest = MapFactory.newMap();
        } else {
            InputStream is = zipFile.getInputStream(manifestEntry);
            BufferedReader bis = new BufferedReader(new InputStreamReader(is));
            manifest = MapFactory.newMap();
            String line;
            while (null != (line = bis.readLine())) {
                int idx = line.indexOf(':');
                if (idx <= 0) continue;
                manifest.put(line.substring(0, idx), line.substring(idx + 1).trim());
            }
            bis.close();
        }
        return manifest;
    } catch (Exception e) {
        return MapFactory.newMap();
    }
}
 
Example 4
Source File: TestSupportBundleManager.java    From datacollector with Apache License 2.0 6 votes vote down vote up
@Test
public void testSimpleStatsBundleCreation() throws Exception {
  ZipFile bundle = zipFile(ImmutableList.of(SimpleGenerator.class.getSimpleName()), BundleType.STATS);
  ZipEntry entry;

  // Make sure that some files are actually missing
  entry = bundle.getEntry("metadata.properties");
  assertNull(entry);

  // Check we have expected files
  entry = bundle.getEntry("generators.properties");
  assertNotNull(entry);

  entry = bundle.getEntry("failed_generators.properties");
  assertNotNull(entry);

  entry = bundle.getEntry("com.streamsets.datacollector.bundles.content.SimpleGenerator/file.txt");
  assertNotNull(entry);
}
 
Example 5
Source File: FileUtils.java    From openemm with GNU Affero General Public License v3.0 6 votes vote down vote up
public static void extractZipEntryToStream(  ZipFile zipFile, String entryName, OutputStream outputStream) throws ZipEntryNotFoundException, IOException {
	
	if( logger.isDebugEnabled()) {
		logger.debug( "Transferring ZIP entry " + entryName + " from ZIP file " + zipFile.getName() + " to stream");
	}
	
	ZipEntry zipEntry = zipFile.getEntry( entryName);
	
	if( zipEntry == null) {
		logger.info( "ZIP entry not found: " + entryName);
		
		throw new ZipEntryNotFoundException( entryName);
	}
	
	try (InputStream inputStream = zipFile.getInputStream(zipEntry)) {
		streamToStream( inputStream, zipEntry.getSize(), outputStream);
	}
}
 
Example 6
Source File: GrailsPluginSupport.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public GrailsPlugin getPluginFromZipFile(String path) {
    GrailsPlugin plugin = null;
    try {
        File pluginFile = new File(path);
        if (pluginFile.exists() && pluginFile.isFile()) {
            final ZipFile file = new ZipFile(pluginFile);
            try {
                final ZipEntry entry = file.getEntry("plugin.xml"); // NOI18N
                if (entry != null) {
                    InputStream stream = file.getInputStream(entry);
                    plugin = getPluginFromInputStream(stream, pluginFile);
                }
            } finally {
                file.close();
            }
        }
    } catch (Exception ex) {
        Exceptions.printStackTrace(ex);
    }
    return plugin;
}
 
Example 7
Source File: TestUCFPackage.java    From incubator-taverna-language with Apache License 2.0 5 votes vote down vote up
@Test
	public void fileEntryFromString() throws Exception {
		UCFPackage container = new UCFPackage();
		container.setPackageMediaType(UCFPackage.MIME_WORKFLOW_BUNDLE);

		container
				.addResource("Hello there þĸł", "helloworld.txt", "text/plain");

		container.save(tmpFile);
		ZipFile zipFile = new ZipFile(tmpFile);
		ZipEntry manifestEntry = zipFile.getEntry("META-INF/manifest.xml");
		InputStream manifestStream = zipFile.getInputStream(manifestEntry);
		//System.out.println(IOUtils.toString(manifestStream, "UTF-8"));
		/*
<?xml version="1.0" encoding="UTF-8"?>
<manifest:manifest xmlns:manifest="urn:oasis:names:tc:opendocument:xmlns:manifest:1.0">
 <manifest:file-entry manifest:media-type="text/plain" manifest:full-path="helloworld.txt" manifest:size="18"/>
</manifest:manifest>
		 */
		Document doc = parseXml(manifestStream);
		assertEquals(MANIFEST_NS, doc.getRootElement().getNamespace());
		assertEquals("manifest", doc.getRootElement().getNamespacePrefix());
		assertEquals("manifest:manifest", doc.getRootElement().getQualifiedName());
		assertXpathEquals("text/plain", doc.getRootElement(), "/manifest:manifest/manifest:file-entry/@manifest:media-type");
		assertXpathEquals("helloworld.txt", doc.getRootElement(), "/manifest:manifest/manifest:file-entry/@manifest:full-path");
/*
 * Different platforms encode UTF8 in different ways
 * 		assertXpathEquals("18", doc.getRootElement(), "/manifest:manifest/manifest:file-entry/@manifest:size");
 */
		
		InputStream io = zipFile.getInputStream(zipFile
				.getEntry("helloworld.txt"));
		assertEquals("Hello there þĸł", IOUtils.toString(io, "UTF-8"));
	}
 
Example 8
Source File: dexclassloader.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
/**
 * Finds a resource. This method is called by {@code getResource()} after
 * the parent ClassLoader has failed to find a loaded resource of the same
 * name.
 *
 * @param name The name of the resource to find
 * @return the location of the resource as a URL, or {@code null} if the
 * resource is not found.
 */
@Override
protected URL findResource(String name) {
    ensureInit();

    int length = mFiles.length;

    for (int i = 0; i < length; i++) {
        File pathFile = mFiles[i];
        ZipFile zip = mZips[i];

        if (zip.getEntry(name) != null) {
            if (VERBOSE_DEBUG)
                System.out.println("  found " + name + " in " + pathFile);
            try {
                // File.toURL() is compliant with RFC 1738 in always
                // creating absolute path names. If we construct the
                // URL by concatenating strings, we might end up with
                // illegal URLs for relative names.
                return new URL("jar:" + pathFile.toURL() + "!/" + name);
            } catch (MalformedURLException e) {
                throw new RuntimeException(e);
            }
        }
    }

    if (VERBOSE_DEBUG)
        System.out.println("  resource " + name + " not found");

    return null;
}
 
Example 9
Source File: KarafJavaScriptForESBWithMavenManager.java    From tesb-studio-se with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("deprecation")
private void addFeatureFileToExport(List<ExportFileResource> list, ExportFileResource[] processes) {
    if (destinationKar != null) {
        File karFile = new File(destinationKar);
        if (karFile.exists()) {
            ProcessItem processItem = (ProcessItem) processes[0].getItem();
            String projectName = getCorrespondingProjectName(processItem);
            String jobName = processItem.getProperty().getLabel();
            String jobVersion = processItem.getProperty().getVersion();
            StringBuilder sb = new StringBuilder();
            sb.append("repository/").append(projectName).append(PATH_SEPARATOR).append(jobName).append(PATH_SEPARATOR); //$NON-NLS-1$
            String featurePath = sb.append(jobName).append("-feature/").append(jobVersion).append(PATH_SEPARATOR) //$NON-NLS-1$
                    .append(jobName).append("-feature-").append(jobVersion).append(".xml").toString(); //$NON-NLS-1$ //$NON-NLS-2$
            ExportFileResource featureFileResource = new ExportFileResource(null, ""); //$NON-NLS-1$
            try {
                ZipFile zipFile = new ZipFile(karFile);
                ZipEntry zipEntry = zipFile.getEntry(featurePath);
                if (zipEntry != null) {
                    InputStream in = null;
                    try {
                        in = zipFile.getInputStream(zipEntry);
                        File featureFile = new File(getTmpFolder() + "feature/feature.xml"); //$NON-NLS-1$
                        FilesUtils.copyFile(in, featureFile);
                        featureFileResource
                                .addResource(IMavenProperties.MAIN_RESOURCES_PATH + "feature", featureFile.toURL()); //$NON-NLS-1$
                    } finally {
                        zipFile.close();
                    }
                }
            } catch (Exception e) {
                ExceptionHandler.process(e);
            }
            list.add(featureFileResource);
        }
    }
}
 
Example 10
Source File: ClassPath.java    From visualvm with GNU General Public License v2.0 5 votes vote down vote up
String getLocationForClassFile(String fileName) {
    if (entries != null) {
        if (entries.contains(fileName)) {
            return zipFilePath;
        } else {
            return null;
        }
    } else {
        if (++hits >= threshHits) {
            entries = new HashSet();
            MiscUtils.getAllClassesInJar(zipFilePath, false, entries);
            return getLocationForClassFile(fileName);
        } else {
            ZipFile zip;
            try {
                zip = getZipFileForName(zipFilePath);
            } catch (IOException ex) {
                System.err.println("Warning: CLASSPATH component " + zipFilePath + ": " + ex); // NOI18N
                return null;
            }
            ZipEntry entry = zip.getEntry(fileName);

            if (entry != null) {
                return zipFilePath;
            } else {
                return null;
            }
        }
    }
}
 
Example 11
Source File: GZipUtils.java    From zheshiyigeniubidexiangmu with MIT License 5 votes vote down vote up
/**
 * @param @param  unZipfile
 * @param @param  destFile 指定读取文件,需要从压缩文件中读取文件内容的文件名
 * @param @return 设定文件
 * @return String 返回类型
 * @throws
 * @Title: unZip
 * @Description: TODO(这里用一句话描述这个方法的作用)
 */
public static String unZip(String unZipfile, String destFile) {// unZipfileName需要解压的zip文件名
    InputStream inputStream;
    String inData = null;
    try {
        // 生成一个zip的文件
        File f = new File(unZipfile);
        ZipFile zipFile = new ZipFile(f);

        // 遍历zipFile中所有的实体,并把他们解压出来
        ZipEntry entry = zipFile.getEntry(destFile);
        if (!entry.isDirectory()) {
            // 获取出该压缩实体的输入流
            inputStream = zipFile.getInputStream(entry);

            ByteArrayOutputStream out = new ByteArrayOutputStream();
            byte[] bys = new byte[4096];
            for (int p = -1; (p = inputStream.read(bys)) != -1; ) {
                out.write(bys, 0, p);
            }
            inData = out.toString();
            out.close();
            inputStream.close();
        }
        zipFile.close();
    } catch (IOException ioe) {
        ioe.printStackTrace();
    }
    return inData;
}
 
Example 12
Source File: JarWithFile.java    From baratine with GNU General Public License v2.0 5 votes vote down vote up
private ZipEntry getZipEntryImpl(String path)
  throws IOException
{
  if (path.startsWith("/")) {
    path = path.substring(1);
  }

  boolean isValid = false;

  ZipFile zipFile = getZipFile();
  
  try {
    if (zipFile != null) {
      ZipEntry entry = zipFile.getEntry(path);
      
      isValid = true;
      
      return entry;
    }
    else
      return null;
  } finally {
    if (isValid)
      closeZipFile(zipFile);
    else if (zipFile != null)
      zipFile.close();
  }
}
 
Example 13
Source File: WorkerLoad.java    From arx with Apache License 2.0 5 votes vote down vote up
/**
 * Reads the project from the file.
 *
 * @param zip
 * @throws IOException
 * @throws ClassNotFoundException
 */
private void readModel(final ZipFile zip) throws IOException,
                                         ClassNotFoundException {
	
    final ZipEntry entry = zip.getEntry("project.dat"); //$NON-NLS-1$
    if (entry == null) { throw new IOException(Resources.getMessage("WorkerLoad.11")); } //$NON-NLS-1$

    // Read model
    final ObjectInputStream oos = new BackwardsCompatibleObjectInputStream(new BufferedInputStream(zip.getInputStream(entry)));
    model = (Model) oos.readObject();
    oos.close();
}
 
Example 14
Source File: MultiDexExtractor.java    From appinventor-extensions with Apache License 2.0 4 votes vote down vote up
private static List<File> performExtractions(File sourceApk, File dexDir)
        throws IOException {

    final String extractedFilePrefix = sourceApk.getName() + EXTRACTED_NAME_EXT;

    // Ensure that whatever deletions happen in prepareDexDir only happen if the zip that
    // contains a secondary dex file in there is not consistent with the latest apk.  Otherwise,
    // multi-process race conditions can cause a crash loop where one process deletes the zip
    // while another had created it.
    prepareDexDir(dexDir, extractedFilePrefix);

    List<File> files = new ArrayList<File>();

    final ZipFile apk = new ZipFile(sourceApk);
    try {

        int secondaryNumber = 2;

        ZipEntry dexFile = apk.getEntry(DEX_PREFIX + secondaryNumber + DEX_SUFFIX);
        while (dexFile != null) {
            String fileName = extractedFilePrefix + secondaryNumber + EXTRACTED_SUFFIX;
            File extractedFile = new File(dexDir, fileName);
            files.add(extractedFile);

            Log.i(TAG, "Extraction is needed for file " + extractedFile);
            int numAttempts = 0;
            boolean isExtractionSuccessful = false;
            while (numAttempts < MAX_EXTRACT_ATTEMPTS && !isExtractionSuccessful) {
                numAttempts++;

                // Create a zip file (extractedFile) containing only the secondary dex file
                // (dexFile) from the apk.
                extract(apk, dexFile, extractedFile, extractedFilePrefix);

                // Verify that the extracted file is indeed a zip file.
                isExtractionSuccessful = verifyZipFile(extractedFile);

                // Log the sha1 of the extracted zip file
                Log.i(TAG, "Extraction " + (isExtractionSuccessful ? "success" : "failed") +
                        " - length " + extractedFile.getAbsolutePath() + ": " +
                        extractedFile.length());
                if (!isExtractionSuccessful) {
                    // Delete the extracted file
                    extractedFile.delete();
                    if (extractedFile.exists()) {
                        Log.w(TAG, "Failed to delete corrupted secondary dex '" +
                                extractedFile.getPath() + "'");
                    }
                }
            }
            if (!isExtractionSuccessful) {
                throw new IOException("Could not create zip file " +
                        extractedFile.getAbsolutePath() + " for secondary dex (" +
                        secondaryNumber + ")");
            }
            secondaryNumber++;
            dexFile = apk.getEntry(DEX_PREFIX + secondaryNumber + DEX_SUFFIX);
        }
    } finally {
        try {
            apk.close();
        } catch (IOException e) {
            Log.w(TAG, "Failed to close resource", e);
        }
    }

    return files;
}
 
Example 15
Source File: MultiDexExtractor.java    From Neptune with Apache License 2.0 4 votes vote down vote up
/**
 * 解压apk中的dex文件到指定目录下
 */
private List<ExtractedDex> performExtractions() throws IOException {
    final String extractedDexPrefix = sourceApk.getName() + EXTRACTED_NAME_EXT;
    // clear already exist dex files
    clearDexDir(dexDir);

    List<ExtractedDex> files = new ArrayList<>();
    final ZipFile apkFile = new ZipFile(sourceApk);
    try {
        int secondaryNumber = 2;
        String entryName = "classes" + secondaryNumber + ".dex";
        ZipEntry dexEntry = apkFile.getEntry(entryName);
        while (dexEntry != null) {
            // extractd dexFile:  xxx.apk.classes.N.zip
            String fileName = extractedDexPrefix + secondaryNumber + EXTRACTED_SUFFIX;
            ExtractedDex dexFile = new ExtractedDex(dexDir, fileName);
            files.add(dexFile);

            int numAttempts = 0;
            boolean extractSuccess = false;
            while (numAttempts < MAX_EXTRACT_ATTEMPTS && !extractSuccess) {
                numAttempts++;
                // Read zip crc of extracted dex
                try {
                    // Create a zip file (extractedFile) containing only the secondary dex file
                    // (dexFile) from the apk.
                    extractDex2Zip(apkFile, dexEntry, dexFile);

                    dexFile.crc = getZipCrc(dexFile);
                    extractSuccess = true;
                } catch (IOException e) {
                    extractSuccess = false;
                }

                if (!extractSuccess) {
                    dexFile.delete();
                }
            }

            if (!extractSuccess) {
                throw new IOException("Could not create zip file " +
                        dexFile.getAbsolutePath() + " for secondary dex (" +
                        secondaryNumber + ")");
            }

            secondaryNumber++;
            entryName = "classes" + secondaryNumber + ".dex";
            dexEntry = apkFile.getEntry(entryName);
        }
    } finally {
        FileUtils.closeQuietly(apkFile);
    }

    return files;
}
 
Example 16
Source File: MultiDexExtractor.java    From letv with Apache License 2.0 4 votes vote down vote up
private static List<File> performExtractions(File sourceApk, File dexDir) throws IOException {
    String extractedFilePrefix = sourceApk.getName() + EXTRACTED_NAME_EXT;
    prepareDexDir(dexDir, extractedFilePrefix);
    List<File> files = new ArrayList();
    ZipFile apk = new ZipFile(sourceApk);
    int secondaryNumber = 2;
    try {
        ZipEntry dexFile = apk.getEntry(DEX_PREFIX + 2 + DEX_SUFFIX);
        while (dexFile != null) {
            File extractedFile = new File(dexDir, extractedFilePrefix + secondaryNumber + EXTRACTED_SUFFIX);
            files.add(extractedFile);
            Log.i(TAG, "Extraction is needed for file " + extractedFile);
            int numAttempts = 0;
            boolean isExtractionSuccessful = false;
            while (numAttempts < 3 && !isExtractionSuccessful) {
                numAttempts++;
                extract(apk, dexFile, extractedFile, extractedFilePrefix);
                isExtractionSuccessful = verifyZipFile(extractedFile);
                Log.i(TAG, "Extraction " + (isExtractionSuccessful ? Constants.CALLBACK_SUCCESS : Constants.CALLBACK_FAILD) + " - length " + extractedFile.getAbsolutePath() + ": " + extractedFile.length());
                if (!isExtractionSuccessful) {
                    extractedFile.delete();
                    if (extractedFile.exists()) {
                        Log.w(TAG, "Failed to delete corrupted secondary dex '" + extractedFile.getPath() + "'");
                    }
                }
            }
            if (isExtractionSuccessful) {
                secondaryNumber++;
                dexFile = apk.getEntry(DEX_PREFIX + secondaryNumber + DEX_SUFFIX);
            } else {
                throw new IOException("Could not create zip file " + extractedFile.getAbsolutePath() + " for secondary dex (" + secondaryNumber + ")");
            }
        }
        return files;
    } finally {
        try {
            apk.close();
        } catch (IOException e) {
            Log.w(TAG, "Failed to close resource", e);
        }
    }
}
 
Example 17
Source File: AbstractXlsxSAXHandler.java    From rapidminer-studio with GNU Affero General Public License v3.0 4 votes vote down vote up
/**
 * Parses entry of zip file using the specified handler. Will NOT close the Zip file afterwards.
 *
 * @param zipFile
 *            The file containing the entry
 * @throws XlsxException
 *             If the zip entry could not be found.
 * @throws IOException
 *             On error accessing the zip data.
 * @throws ParserConfigurationException
 *             If a parser cannot be created which satisfies the used configuration.
 * @throws SAXException
 *             If any SAX errors occur during processing.
 * @throws UserError
 *             in case the XLSX file is malformed
 */
public T parseZipEntry(ZipFile zipFile) throws IOException, ParserConfigurationException, SAXException, UserError {

	// Lookup zip entry
	ZipEntry zipEntry = zipFile.getEntry(getZipEntryPath());
	if (zipEntry == null) {
		throw new UserError(null, "xlsx_file_missing_entry", getZipEntryPath());
	}

	// Get stream for entry
	try (InputStream zipInputStream = zipFile.getInputStream(zipEntry)) {
		SAXParserFactory.newInstance().newSAXParser().parse(zipInputStream, this);
	}

	return getResult();
}
 
Example 18
Source File: TestUCFPackage.java    From incubator-taverna-language with Apache License 2.0 4 votes vote down vote up
@Test
	public void addResourceContainerXml() throws Exception {
		UCFPackage container = new UCFPackage();
		container.setPackageMediaType(UCFPackage.MIME_WORKFLOW_BUNDLE);
		container.addResource("Hello there", "helloworld.txt", "text/plain");
		container.addResource("Soup for everyone", "soup.txt", "text/plain");
		container.setRootFile("helloworld.txt");
		assertEquals("helloworld.txt", container.getRootFiles().get(0)
				.getPath());

		String containerXml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n"
				+ "<container xmlns=\"urn:oasis:names:tc:opendocument:xmlns:container\" xmlns:ns2=\"http://www.w3.org/2000/09/xmldsig#\" xmlns:ns3=\"http://www.w3.org/2001/04/xmlenc#\">\n"
				+ "    <ex:example xmlns:ex=\"http://example.com/\">first example</ex:example>\n"
				+ "    <rootFiles>\n"
				+ "        <rootFile xmlns:ex=\"http://example.com/\" media-type=\"text/plain\" full-path=\"soup.txt\" ex:extraAnnotation=\"hello\"/>\n"
				+ "    </rootFiles>\n"
				+ "    <ex:example xmlns:ex=\"http://example.com/\">second example</ex:example>\n"
				+ "    <ex:example xmlns:ex=\"http://example.com/\">third example</ex:example>\n"
				+ "</container>\n";
		// Should overwrite setRootFile()
		container.addResource(containerXml, "META-INF/container.xml",
				"text/xml");

		assertEquals("soup.txt", container.getRootFiles().get(0).getPath());

		container.save(tmpFile);

		ZipFile zipFile = new ZipFile(tmpFile);
		ZipEntry manifestEntry = zipFile.getEntry("META-INF/container.xml");
		InputStream manifestStream = zipFile.getInputStream(manifestEntry);
		
		//System.out.println(IOUtils.toString(manifestStream, "UTF-8"));
		/*
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<container xmlns="urn:oasis:names:tc:opendocument:xmlns:container" xmlns:ns2="http://www.w3.org/2000/09/xmldsig#" xmlns:ns3="http://www.w3.org/2001/04/xmlenc#">
    <ex:example xmlns:ex="http://example.com/">first example</ex:example>
    <rootFiles>
        <rootFile xmlns:ex="http://example.com/" full-path="soup.txt" media-type="text/plain" ex:extraAnnotation="hello"/>
    </rootFiles>
    <ex:example xmlns:ex="http://example.com/">second example</ex:example>
    <ex:example xmlns:ex="http://example.com/">third example</ex:example>
</container>
		 */
		Document doc = parseXml(manifestStream);
		assertEquals(CONTAINER_NS, doc.getRootElement().getNamespace());
		
		// Should work, but we'll ignore testing these (TAVERNA-920)
		//assertEquals("", doc.getRootElement().getNamespacePrefix());
		//assertEquals("container", doc.getRootElement().getQualifiedName());
		assertEquals("container", doc.getRootElement().getName());
		
		assertXpathEquals("soup.txt", doc.getRootElement(), "/c:container/c:rootFiles/c:rootFile[1]/@full-path");
		assertXpathEquals("text/plain", doc.getRootElement(), "/c:container/c:rootFiles/c:rootFile[1]/@media-type");
		assertXpathEquals("hello", doc.getRootElement(), "/c:container/c:rootFiles/c:rootFile[1]/@ex:extraAnnotation");

		assertXpathEquals("first example", doc.getRootElement(), "/c:container/ex:example[1]");
		assertXpathEquals("second example", doc.getRootElement(), "/c:container/ex:example[2]");
		assertXpathEquals("third example", doc.getRootElement(), "/c:container/ex:example[3]");
		
		// Check order
		Element first = (Element) xpathSelectElement(doc.getRootElement(), "/c:container/*[1]");
		assertEquals("ex:example", first.getQualifiedName());
		Element second = (Element) xpathSelectElement(doc.getRootElement(), "/c:container/*[2]");

		// Should work, but we'll ignore testing these (TAVERNA-920)
		//assertEquals("rootFiles", second.getQualifiedName());
		assertEquals("rootFiles", second.getName());
		
		Element third = (Element) xpathSelectElement(doc.getRootElement(), "/c:container/*[3]");
		assertEquals("ex:example", third.getQualifiedName());
		Element fourth = (Element) xpathSelectElement(doc.getRootElement(), "/c:container/*[4]");
		assertEquals("ex:example", fourth.getQualifiedName());
		
		
		
	}
 
Example 19
Source File: RelativePath.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
ZipEntry getZipEntry(ZipFile zip) {
    return zip.getEntry(path);
}
 
Example 20
Source File: RelativePath.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
ZipEntry getZipEntry(ZipFile zip) {
    return zip.getEntry(path);
}