@Test void readDescriptor() throws Exception { XarPackage xarPackage = new XarPackage(); xarPackage.readDescriptor(getClass().getResourceAsStream("/package.xml")); assertEquals("author", xarPackage.getPackageAuthor()); assertEquals("package description", xarPackage.getPackageDescription()); assertEquals("extension:id", xarPackage.getPackageExtensionId()); assertEquals("license", xarPackage.getPackageLicense()); assertEquals("package name", xarPackage.getPackageName()); assertEquals("1.0", xarPackage.getPackageVersion()); Collection<XarEntry> files = xarPackage.getPackageFiles(); assertEquals(9, files.size()); Iterator<XarEntry> iterator = files.iterator(); assertEqualsEntry(new XarEntry(SPACE_PAGE, XarModel.ACTION_OVERWRITE, "type0"), iterator.next()); assertEqualsEntry(new XarEntry(SPACE_TRANSLATIONS, XarModel.ACTION_OVERWRITE, "type1"), iterator.next()); assertEqualsEntry(new XarEntry(SPACE_TRANSLATIONS_FR, XarModel.ACTION_OVERWRITE, "type2"), iterator.next()); assertEqualsEntry(new XarEntry(SPACE_SKIPPEDPAGE, XarModel.ACTION_SKIP), iterator.next()); assertEqualsEntry(new XarEntry(SPACE_MERGEDPAGE, XarModel.ACTION_MERGE), iterator.next()); assertEqualsEntry(new XarEntry(SPACE_SKIPPEDTRANSLATIONS, XarModel.ACTION_SKIP), iterator.next()); assertEqualsEntry(new XarEntry(SPACE_SKIPPEDTRANSLATIONS_FR, XarModel.ACTION_SKIP), iterator.next()); assertEqualsEntry(new XarEntry(SPACE_MERGEDTRANSLATIONS, XarModel.ACTION_MERGE), iterator.next()); assertEqualsEntry(new XarEntry(SPACE_MERGEDTRANSLATIONS_FR, XarModel.ACTION_MERGE), iterator.next()); }
public void readDescriptor(InputStream stream) throws XarException, IOException { DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder dBuilder; try { dBuilder = dbFactory.newDocumentBuilder(); } catch (ParserConfigurationException e) { throw new XarException("Failed to create a new Document builder", e); } Document doc; try { doc = dBuilder.parse(new CloseShieldInputStream(stream)); } catch (SAXException e) { throw new XarException("Failed to parse XML document", e); } doc.getDocumentElement().normalize(); NodeList children = doc.getChildNodes(); for (int i = 0; i < children.getLength(); ++i) { Node node = children.item(i); if (node.getNodeType() == Node.ELEMENT_NODE) { Element element = (Element) node; if (element.getTagName().equals(XarModel.ELEMENT_PACKAGE)) { readDescriptorPackage(element); break; } } } }
XarPackage { public void readDescriptor(InputStream stream) throws XarException, IOException { DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder dBuilder; try { dBuilder = dbFactory.newDocumentBuilder(); } catch (ParserConfigurationException e) { throw new XarException("Failed to create a new Document builder", e); } Document doc; try { doc = dBuilder.parse(new CloseShieldInputStream(stream)); } catch (SAXException e) { throw new XarException("Failed to parse XML document", e); } doc.getDocumentElement().normalize(); NodeList children = doc.getChildNodes(); for (int i = 0; i < children.getLength(); ++i) { Node node = children.item(i); if (node.getNodeType() == Node.ELEMENT_NODE) { Element element = (Element) node; if (element.getTagName().equals(XarModel.ELEMENT_PACKAGE)) { readDescriptorPackage(element); break; } } } } }
XarPackage { public void readDescriptor(InputStream stream) throws XarException, IOException { DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder dBuilder; try { dBuilder = dbFactory.newDocumentBuilder(); } catch (ParserConfigurationException e) { throw new XarException("Failed to create a new Document builder", e); } Document doc; try { doc = dBuilder.parse(new CloseShieldInputStream(stream)); } catch (SAXException e) { throw new XarException("Failed to parse XML document", e); } doc.getDocumentElement().normalize(); NodeList children = doc.getChildNodes(); for (int i = 0; i < children.getLength(); ++i) { Node node = children.item(i); if (node.getNodeType() == Node.ELEMENT_NODE) { Element element = (Element) node; if (element.getTagName().equals(XarModel.ELEMENT_PACKAGE)) { readDescriptorPackage(element); break; } } } } XarPackage();  XarPackage(ZipFile zipFile);  XarPackage(File file);  XarPackage(InputStream xarStream);  XarPackage(Collection<XarEntry> entries); }
XarPackage { public void readDescriptor(InputStream stream) throws XarException, IOException { DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder dBuilder; try { dBuilder = dbFactory.newDocumentBuilder(); } catch (ParserConfigurationException e) { throw new XarException("Failed to create a new Document builder", e); } Document doc; try { doc = dBuilder.parse(new CloseShieldInputStream(stream)); } catch (SAXException e) { throw new XarException("Failed to parse XML document", e); } doc.getDocumentElement().normalize(); NodeList children = doc.getChildNodes(); for (int i = 0; i < children.getLength(); ++i) { Node node = children.item(i); if (node.getNodeType() == Node.ELEMENT_NODE) { Element element = (Element) node; if (element.getTagName().equals(XarModel.ELEMENT_PACKAGE)) { readDescriptorPackage(element); break; } } } } XarPackage();  XarPackage(ZipFile zipFile);  XarPackage(File file);  XarPackage(InputStream xarStream);  XarPackage(Collection<XarEntry> entries); static Collection<XarEntry> getEntries(File file); void read(InputStream xarStream); void read(ZipFile zipFile); void read(File directory); String getPackageExtensionId(); void setPackageExtensionId(String packageExtensionId); boolean isPackagePreserveVersion(); @Deprecated void setPreserveVersion(boolean preserveVersion); void setPackagePreserveVersion(boolean packagePreserveVersion); String getPackageName(); void setPackageName(String packageName); String getPackageDescription(); void setPackageDescription(String packageDescription); String getPackageLicense(); void setPackageLicense(String packageLicense); String getPackageAuthor(); void setPackageAuthor(String packageAuthor); String getPackageVersion(); void setPackageVersion(String packageVersion); boolean isPackageBackupPack(); void setPackageBackupPack(boolean packageBackupPack); Collection<XarEntry> getPackageFiles(); void addPackageFile(LocalDocumentReference reference, int action); @Deprecated void addEntry(LocalDocumentReference reference); void addEntry(LocalDocumentReference reference, String entryName); void addEntry(LocalDocumentReference reference, String entryName, int action); Collection<XarEntry> getEntries(); XarEntry getEntry(LocalDocumentReference reference); void readDescriptor(InputStream stream); void write(ZipArchiveOutputStream zipStream, String encoding); void write(OutputStream stream, String encoding); void write(XMLStreamWriter writer); }
XarPackage { public void readDescriptor(InputStream stream) throws XarException, IOException { DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder dBuilder; try { dBuilder = dbFactory.newDocumentBuilder(); } catch (ParserConfigurationException e) { throw new XarException("Failed to create a new Document builder", e); } Document doc; try { doc = dBuilder.parse(new CloseShieldInputStream(stream)); } catch (SAXException e) { throw new XarException("Failed to parse XML document", e); } doc.getDocumentElement().normalize(); NodeList children = doc.getChildNodes(); for (int i = 0; i < children.getLength(); ++i) { Node node = children.item(i); if (node.getNodeType() == Node.ELEMENT_NODE) { Element element = (Element) node; if (element.getTagName().equals(XarModel.ELEMENT_PACKAGE)) { readDescriptorPackage(element); break; } } } } XarPackage();  XarPackage(ZipFile zipFile);  XarPackage(File file);  XarPackage(InputStream xarStream);  XarPackage(Collection<XarEntry> entries); static Collection<XarEntry> getEntries(File file); void read(InputStream xarStream); void read(ZipFile zipFile); void read(File directory); String getPackageExtensionId(); void setPackageExtensionId(String packageExtensionId); boolean isPackagePreserveVersion(); @Deprecated void setPreserveVersion(boolean preserveVersion); void setPackagePreserveVersion(boolean packagePreserveVersion); String getPackageName(); void setPackageName(String packageName); String getPackageDescription(); void setPackageDescription(String packageDescription); String getPackageLicense(); void setPackageLicense(String packageLicense); String getPackageAuthor(); void setPackageAuthor(String packageAuthor); String getPackageVersion(); void setPackageVersion(String packageVersion); boolean isPackageBackupPack(); void setPackageBackupPack(boolean packageBackupPack); Collection<XarEntry> getPackageFiles(); void addPackageFile(LocalDocumentReference reference, int action); @Deprecated void addEntry(LocalDocumentReference reference); void addEntry(LocalDocumentReference reference, String entryName); void addEntry(LocalDocumentReference reference, String entryName, int action); Collection<XarEntry> getEntries(); XarEntry getEntry(LocalDocumentReference reference); void readDescriptor(InputStream stream); void write(ZipArchiveOutputStream zipStream, String encoding); void write(OutputStream stream, String encoding); void write(XMLStreamWriter writer);  }