Tabnine Logo
XmlUtils
Code IndexAdd Tabnine to your IDE (free)

How to use
XmlUtils
in
com.android.utils

Best Java code snippets using com.android.utils.XmlUtils (Showing top 20 results out of 315)

origin: com.amazon.device.tools.build/gradle-core

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());
}
origin: com.android.tools.build/gradle-core

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);
    }
  }
}
origin: com.android.tools.build/gradle-core

/**
 * 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));
}
origin: com.android.tools/common

/**
 * 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);
}
origin: com.android.tools/common

public static String toXml(
    @NonNull Node node,
    @Nullable Map<SourcePosition, SourceFilePosition> blame) {
  PositionAwareStringBuilder sb = new PositionAwareStringBuilder(1000);
  append(sb, node, blame);
  return sb.toString();
}
origin: com.android.tools/common

  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(
origin: com.android.tools.lint/lint

  throws IOException {
try {
  Document document = XmlUtils.parseDocument(xml, false);
    signature = XmlUtils.fromXmlAttributeValue(signature);
    Matcher matcher = XML_SIGNATURE.matcher(signature);
    if (matcher.matches()) {
origin: com.android.tools.lint/lint

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('"');
}
origin: com.amazon.device.tools.build/builder

  content = XmlPrettyPrinter.prettyPrint(document, true);
} catch (Throwable t) {
  content = XmlUtils.toXml(document, false);
origin: com.android.tools.lint/lint-api

case HTML:
case HTML_WITH_UNICODE:
  return XmlUtils.toXmlTextValue(message);
origin: com.android.tools.build/builder

/**
 * 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));
}
origin: com.amazon.device.tools.build/builder

  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;
  }
}
origin: com.android.tools.lint/lint-api

if (end > i) {
  String entity = html.substring(i, end + 1);
  String s = XmlUtils.fromXmlAttributeValue(entity);
  if (s.startsWith("&")) {
origin: com.android.tools.lint/lint-api

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('"');
}
origin: com.android.tools.build/builder

  content = XmlPrettyPrinter.prettyPrint(document, true);
} catch (Throwable t) {
  content = XmlUtils.toXml(document);
origin: com.android.tools.lint/lint

  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
origin: com.android.tools.lint/lint-checks

  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;
  }
}
origin: com.android.tools/common

/**
 * 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();
  }
}
origin: com.android.tools.build/gradle-core

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);
}
origin: com.android.tools.build/builder

Document document = XmlUtils.parseUtfXmlFile(itemStorage, true);
com.android.utilsXmlUtils

Javadoc

XML Utilities

Most used methods

  • parseDocument
    Parses the given XML string as a DOM document, using the JDK parser. The parser does not validate, a
  • parseDocumentSilently
    Parses the given XML string as a DOM document, using the JDK parser. The parser does not validate, a
  • parseUtfXmlFile
    Parses the given UTF file as a DOM document, using the JDK parser. The parser does not validate, and
  • toXmlAttributeValue
    Converts the given attribute value to an XML-attribute-safe value, meaning that single and double qu
  • toXml
  • toXmlTextValue
    Converts the given attribute value to an XML-text-safe value, meaning that less than and ampersand c
  • fromXmlAttributeValue
    Converts the given XML-attribute-safe value to a java string
  • getRootTagName
    Returns the name of the root element tag stored in the given file, or null if it can't be determined
  • getUtfReader
    Returns a character reader for the given file, which must be a UTF encoded file. The reader does no
  • lookupNamespacePrefix
    Returns the namespace prefix matching the requested namespace URI. If no such declaration is found,
  • append
    Dump node to string without indentation adjustments
  • appendXmlAttributeValue
    Appends text to the given StringBuilder and escapes it as required for a DOM attribute node.
  • append,
  • appendXmlAttributeValue,
  • appendXmlTextValue,
  • getSourceFilePosition,
  • stripBom

Popular in Java

  • Start an intent from android
  • notifyDataSetChanged (ArrayAdapter)
  • compareTo (BigDecimal)
  • putExtra (Intent)
  • Menu (java.awt)
  • FileReader (java.io)
    A specialized Reader that reads from a file in the file system. All read requests made by calling me
  • PriorityQueue (java.util)
    A PriorityQueue holds elements on a priority heap, which orders the elements according to their natu
  • SortedMap (java.util)
    A map that has its keys ordered. The sorting is according to either the natural ordering of its keys
  • AtomicInteger (java.util.concurrent.atomic)
    An int value that may be updated atomically. See the java.util.concurrent.atomic package specificati
  • Pattern (java.util.regex)
    Patterns are compiled regular expressions. In many cases, convenience methods such as String#matches
  • Github Copilot alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now