congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
XmlUtils.parseDocument
Code IndexAdd Tabnine to your IDE (free)

How to use
parseDocument
method
in
com.android.utils.XmlUtils

Best Java code snippets using com.android.utils.XmlUtils.parseDocument (Showing top 15 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

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.amazon.device.tools.build/gradle-core

private void recordXmlResourcesUsages(@NonNull File file, boolean isDefaultFolder,
    @Nullable Resource from)
    throws IOException, ParserConfigurationException, SAXException {
  String xml = Files.toString(file, UTF_8);
  Document document = XmlUtils.parseDocument(xml, true);
  recordResourceReferences(file, isDefaultFolder, document.getDocumentElement(), from);
}
origin: com.android.tools.build/gradle-core

/** {@link #loadFromXmlFile(File)} but using a String */
public void loadFromXml(@NonNull String persistedState)
    throws IOException, SAXException, ParserConfigurationException {
  loadFromDocument(XmlUtils.parseDocument(persistedState, false));
}
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 tmpBuildInfo a past build build-info.xml as a String
 * @throws IOException cannot be thrown.
 * @throws SAXException when the xml is not correct.
 * @throws ParserConfigurationException when the xml parser cannot be initialized.
 */
public void mergeFrom(@NonNull String tmpBuildInfo)
    throws IOException, SAXException, ParserConfigurationException {
  mergeFrom(XmlUtils.parseDocument(tmpBuildInfo, false));
}
origin: com.android.tools.build/gradle-core

private void mergeAnnotationsXml(@NonNull String path, @NonNull String xml) {
  try {
    Document document = XmlUtils.parseDocument(xml, false);
    mergeDocument(document);
  } catch (Exception e) {
    String message = "Failed to merge " + path + ": " + e.toString();
    if (e instanceof SAXParseException) {
      SAXParseException spe = (SAXParseException)e;
      message = "Line " + spe.getLineNumber() + ":" + spe.getColumnNumber() + ": " + message;
    }
    error(message);
    if (!(e instanceof IOException)) {
      e.printStackTrace();
    }
  }
}
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. Any parsing errors are silently ignored.
 *
 * @param xml            the XML content to be parsed (must be well formed)
 * @param namespaceAware whether the parser is namespace aware
 * @return the DOM document, or null
 */
@Nullable
public static Document parseDocumentSilently(@NonNull String xml, boolean namespaceAware) {
  try {
    return parseDocument(xml, namespaceAware);
  } catch (Exception e) {
    // pass
    // This method is deliberately silent; will return null
  }
  return null;
}
origin: com.amazon.device.tools.build/gradle-core

private void mergeAnnotationsXml(@NonNull String path, @NonNull String xml) {
  try {
    Document document = XmlUtils.parseDocument(xml, false);
    mergeDocument(document);
  } catch (Exception e) {
    warning("Failed to merge " + path + ": " + e.toString());
    if (!(e instanceof IOException)) {
      e.printStackTrace();
    }
  }
}
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.build/gradle-core

private void recordResources(@NonNull ResourceFolderType folderType, File folder)
    throws ParserConfigurationException, SAXException, IOException {
  File[] files = folder.listFiles();
  if (files != null) {
    for (File file : files) {
      String path = file.getPath();
      mModel.file = file;
      try {
        boolean isXml = endsWithIgnoreCase(path, DOT_XML);
        if (isXml) {
          String xml = Files.toString(file, UTF_8);
          Document document = XmlUtils.parseDocument(xml, true);
          mModel.visitXmlDocument(file, folderType, document);
        } else {
          mModel.visitBinaryResource(folderType, file);
        }
      } finally {
        mModel.file = null;
      }
    }
  }
}
origin: com.android.tools.lint/lint-api

@Nullable
public static Document parseDocumentSilently(@NonNull CharSequence xml, boolean namespaceAware) {
  try {
    Reader reader = getReader(xml, true);
    return XmlUtils.parseDocument(reader, namespaceAware);
  } catch (Exception e) {
    // pass
    // This method is deliberately silent; will return null
  }
  return null;
}
origin: com.android.tools.lint/lint

  throws IOException {
try {
  Document document = XmlUtils.parseDocument(xml, false);
origin: com.android.tools.lint/lint-checks

private void recordInactiveXmlResources(@NonNull ResourceFolderType folderType,
 @NonNull File folder) {
  File[] files = folder.listFiles();
  if (files != null) {
    for (File file : files) {
      String path = file.getPath();
      boolean isXml = endsWithIgnoreCase(path, DOT_XML);
      try {
        if (isXml) {
          String xml = Files.toString(file, UTF_8);
          Document document = XmlUtils.parseDocument(xml, true);
          mModel.visitXmlDocument(file, folderType, document);
        } else {
          mModel.visitBinaryResource(folderType, file);
        }
      } catch (Throwable ignore) {
        // Tolerate parsing errors etc in these files; they're user
        // sources, and this is even for inactive source sets.
      }
    }
  }
}
origin: com.amazon.device.tools.build/gradle-core

@Nullable
private static Document checkDocument(@NonNull String pkg, @NonNull String xml,
    boolean namespaceAware) {
  try {
    return XmlUtils.parseDocument(xml, namespaceAware);
  } catch (SAXException sax) {
    warning("Failed to parse document for package " + pkg + ": " + sax.toString());
  } catch (Exception e) {
    // pass
    // This method is deliberately silent; will return null
  }
  return null;
}
origin: com.android.tools.build/gradle-core

@Nullable
private static Document checkDocument(@NonNull String pkg, @NonNull String xml,
    boolean namespaceAware) {
  try {
    return XmlUtils.parseDocument(xml, namespaceAware);
  } catch (SAXException sax) {
    warning("Failed to parse document for package " + pkg + ": " + sax.toString());
  } catch (Exception e) {
    // pass
    // This method is deliberately silent; will return null
  }
  return null;
}
com.android.utilsXmlUtilsparseDocument

Javadoc

Parses the given Reader as a DOM document, using the JDK parser. The parser does not validate, and is optionally namespace aware.

Popular methods of XmlUtils

  • 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.
  • appendXmlTextValue
    Appends text to the given StringBuilder and escapes it as required for a DOM text node.
  • appendXmlAttributeValue,
  • appendXmlTextValue,
  • getSourceFilePosition,
  • stripBom

Popular in Java

  • Running tasks concurrently on multiple threads
  • getExternalFilesDir (Context)
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • getContentResolver (Context)
  • GridLayout (java.awt)
    The GridLayout class is a layout manager that lays out a container's components in a rectangular gri
  • URLEncoder (java.net)
    This class is used to encode a string using the format required by application/x-www-form-urlencoded
  • Timestamp (java.sql)
    A Java representation of the SQL TIMESTAMP type. It provides the capability of representing the SQL
  • TimeUnit (java.util.concurrent)
    A TimeUnit represents time durations at a given unit of granularity and provides utility methods to
  • Handler (java.util.logging)
    A Handler object accepts a logging request and exports the desired messages to a target, for example
  • StringUtils (org.apache.commons.lang)
    Operations on java.lang.String that arenull safe. * IsEmpty/IsBlank - checks if a String contains
  • Top 17 Free Sublime Text Plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

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