public Optional<XmlElement> getByTypeAndKey( ManifestModel.NodeTypes type, @Nullable String keyValue) { return getRootNode().getNodeByTypeAndKey(type, keyValue); }
/** * Reorder application element * * @param xmlElement the root element of the manifest document. */ private static void reOrderApplication(@NonNull XmlElement xmlElement) { // look up application element. Optional<XmlElement> element = xmlElement .getNodeByTypeAndKey(ManifestModel.NodeTypes.APPLICATION, null); if (!element.isPresent()) { return; } XmlElement applicationElement = element.get(); List<Node> comments = XmlElement.getLeadingComments(applicationElement.getXml()); // move the application's comments if any. for (Node comment : comments) { xmlElement.getXml().removeChild(comment); xmlElement.getXml().appendChild(comment); } // remove the application element and add it back, it will be automatically placed last. xmlElement.getXml().removeChild(applicationElement.getXml()); xmlElement.getXml().appendChild(applicationElement.getXml()); }
/** * Reorder uses-sdk element * * @param xmlElement the root element of the manifest document. */ private static void reOrderUsesSdk(@NonNull XmlElement xmlElement) { // look up application element. Optional<XmlElement> element = xmlElement .getNodeByTypeAndKey(ManifestModel.NodeTypes.USES_SDK, null); if (!element.isPresent()) { return; } XmlElement usesSdk = element.get(); Node firstChild = xmlElement.getXml().getFirstChild(); // already the first element ? if (firstChild == usesSdk.getXml()) { return; } List<Node> comments = XmlElement.getLeadingComments(usesSdk.getXml()); // move the application's comments if any. for (Node comment : comments) { xmlElement.getXml().removeChild(comment); xmlElement.getXml().insertBefore(comment, firstChild); } // remove the application element and add it back, it will be automatically placed last. xmlElement.getXml().removeChild(usesSdk.getXml()); xmlElement.getXml().insertBefore(usesSdk.getXml(), firstChild); }
getNodeByTypeAndKey(lowerPriorityChild.getType(), null /* keyValue */); if (!thisChildElementOptional.isPresent()) { return false;
getNodeByTypeAndKey(lowerPriorityChild.getType(),lowerPriorityChild.getKey());