/**
  * Search through a map of id-IndexElement mapping using the a element find the id when the index
  * element fall into the same range.
  *
  * @param element a index element
  * @param mappings id-indexelement mappings.
  * @return String id
  */
 private String searchForId(IndexElement element, Map<String, IndexElement> mappings) {
   String id = null;
   for (Map.Entry<String, IndexElement> entry : mappings.entrySet()) {
     IndexElement identElement = entry.getValue();
     if (identElement.getStart() <= element.getStart()
         && identElement.getStop() >= element.getStop()) {
       id = entry.getKey();
       break;
     }
   }
   return id;
 }
  /**
   * Find the id from xml string based indexElement's range.
   *
   * @param indexElement index element.
   * @param pattern This pattern should only match once.
   * @return String id or accession.
   */
  private String getIDByPattern(IndexElement indexElement, Pattern pattern, boolean quickMatch) {
    String id = null;

    // first get the XML string (only the first bit) from which to extract the ID
    long start = indexElement.getStart();
    long stop = quickMatch ? start + XML_CHAR_INCREMENT : indexElement.getStop();
    String xml = indexer.getXmlSnippet(start, stop);
    // then apply the regex pattern to find the ID
    Matcher m = pattern.matcher(xml);
    if (m.find()) {
      id = m.group(1);
    }

    return id;
  }