private void recordManifestUsages(File manifest) throws IOException, ParserConfigurationException, SAXException { String xml = Files.toString(manifest, UTF_8); Document document = XmlUtils.parseDocument(xml, true); recordManifestUsages(document.getDocumentElement()); }
protected void readManifest(File manifest) { if (manifest.exists()) { try { String xml = Files.toString(manifest, Charsets.UTF_8); Document document = XmlUtils.parseDocumentSilently(xml, true); if (document != null) { readManifest(document); } } catch (IOException e) { client.log(e, "Could not read manifest %1$s", manifest); } } }
/** * Merges the artifacts of a temporary build info into this build's artifacts. If this build * finishes the build-info.xml will contain the artifacts produced by this iteration as well as * the artifacts produced in a previous iteration and saved into the temporary build info. * * @param tmpBuildInfoFile a past build build-info.xml * @throws IOException cannot be thrown. * @throws SAXException when the xml is not correct. * @throws ParserConfigurationException when the xml parser cannot be initialized. */ public void mergeFromFile(@NonNull File tmpBuildInfoFile) throws IOException, SAXException, ParserConfigurationException { mergeFrom(XmlUtils.parseUtfXmlFile(tmpBuildInfoFile, false)); }
/** * Parses the given XML string as a DOM document, using the JDK parser. The parser does not * validate, and is optionally namespace aware. * * @param xml the XML content to be parsed (must be well formed) * @param namespaceAware whether the parser is namespace aware * @return the DOM document */ @NonNull public static Document parseDocument(@NonNull String xml, boolean namespaceAware) throws ParserConfigurationException, IOException, SAXException { xml = stripBom(xml); return parseDocument(new StringReader(xml), namespaceAware); }
public static String toXml( @NonNull Node node, @Nullable Map<SourcePosition, SourceFilePosition> blame) { PositionAwareStringBuilder sb = new PositionAwareStringBuilder(1000); append(sb, node, blame); return sb.toString(); }
NodeList children = node.getChildNodes(); for (int i = 0, n = children.getLength(); i < n; i++) { append(sb, children.item(i), blame); break; case Node.TEXT_NODE: { sb.append(toXmlTextValue(node.getNodeValue())); break; sb.append(attribute.getNodeName()); sb.append('=').append('"'); sb.append(toXmlAttributeValue(attribute.getNodeValue())); sb.append('"'); for (int i = 0; i < childCount; i++) { Node child = children.item(i); append(sb, child, blame); SourceFilePosition position = getSourceFilePosition(node); if (!position.equals(SourceFilePosition.UNKNOWN)) { blame.put(
throws IOException { try { Document document = XmlUtils.parseDocument(xml, false); signature = XmlUtils.fromXmlAttributeValue(signature); Matcher matcher = XML_SIGNATURE.matcher(signature); if (matcher.matches()) {
private static void writeAttribute(Writer writer, int indent, String name, String value) throws IOException { writer.write('\n'); indent(writer, indent); writer.write(name); writer.write('='); writer.write('"'); writer.write(XmlUtils.toXmlAttributeValue(value)); writer.write('"'); }
content = XmlPrettyPrinter.prettyPrint(document, true); } catch (Throwable t) { content = XmlUtils.toXml(document, false);
case HTML: case HTML_WITH_UNICODE: return XmlUtils.toXmlTextValue(message);
/** * Parse the root element of the file, return true if it is a vector. */ private static boolean isRootVector(File resourceFile) { return TAG_VECTOR.equals(XmlUtils.getRootTagName(resourceFile)); }
private static String getStringValue(@NonNull File file, @NonNull String xPath) { XPath xpath = AndroidXPathFactory.newXPath(); try { InputSource source = new InputSource(XmlUtils.getUtfReader(file)); return xpath.evaluate(xPath, source); } catch (XPathExpressionException e) { // won't happen. } catch (IOException e) { throw new RuntimeException(e); } return null; } }
if (end > i) { String entity = html.substring(i, end + 1); String s = XmlUtils.fromXmlAttributeValue(entity); if (s.startsWith("&")) {
private static void writeAttribute(Writer writer, int indent, String name, String value) throws IOException { writer.write('\n'); indent(writer, indent); writer.write(name); writer.write('='); writer.write('"'); writer.write(XmlUtils.toXmlAttributeValue(value)); writer.write('"'); }
content = XmlPrettyPrinter.prettyPrint(document, true); } catch (Throwable t) { content = XmlUtils.toXml(document);
append("</div>\n"); //class=chips }, XmlUtils.toXmlTextValue(firstIssue.getBriefDescription(TextFormat.TEXT)), true, new Action("Explain", getExplanationId(firstIssue), "reveal")); // HTML style isn't handled right by card widget
private static boolean checkResourceRepository( @NonNull AbstractResourceRepository resources, @NonNull String name) { List<ResourceItem> items = resources.getResourceItem(ResourceType.DRAWABLE, name); if (items == null) { return false; } // Check if at least one drawable with this name is a vector. for (ResourceItem item : items) { ResourceFile source = item.getSource(); if (source == null) { return false; } File file = source.getFile(); if (!file.getPath().endsWith(SdkConstants.DOT_XML)) { continue; } return SdkConstants.TAG_VECTOR.equals(XmlUtils.getRootTagName(file)); } return false; } }
/** * Parses the given UTF file as a DOM document, using the JDK parser. The parser does not * validate, and is optionally namespace aware. * * @param file the UTF encoded file to parse * @param namespaceAware whether the parser is namespace aware * @return the DOM document */ @NonNull public static Document parseUtfXmlFile(@NonNull File file, boolean namespaceAware) throws ParserConfigurationException, IOException, SAXException { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); Reader reader = getUtfReader(file); try { InputSource is = new InputSource(reader); factory.setNamespaceAware(namespaceAware); factory.setValidating(false); DocumentBuilder builder = factory.newDocumentBuilder(); return builder.parse(is); } finally { reader.close(); } }
private void recordManifestUsages(File manifest) throws IOException, ParserConfigurationException, SAXException { String xml = Files.toString(manifest, UTF_8); Document document = XmlUtils.parseDocument(xml, true); mModel.visitXmlDocument(manifest, null, document); }
Document document = XmlUtils.parseUtfXmlFile(itemStorage, true);