Example #1
0
 /**
  * Add the {@code indexExtension} to the path in locator, preserving query string elements if
  * present
  *
  * @param locator
  * @param indexExtension
  * @return
  */
 public static String appendToPath(ResourceLocator locator, String indexExtension) {
   String indexFile = locator.getURLPath() + indexExtension;
   String qs = locator.getURLQueryString();
   if (qs != null && qs.length() > 0) {
     indexFile += "?" + qs;
   }
   return indexFile;
 }
Example #2
0
 /**
  * @param locator
  * @return locator.getIndexPath() if not null, otherwise {@link #appendToPath(ResourceLocator,
  *     String)} where the second argument is .idx or tbi, depending on the resource
  */
 public static String indexFile(ResourceLocator locator) {
   if (locator.getIndexPath() != null) {
     return locator.getIndexPath();
   }
   String indexExtension =
       (locator.getURLPath().toLowerCase().endsWith(".gz")
               || locator.getPath().toLowerCase().endsWith(".bgz"))
           ? ".tbi"
           : Tribble.STANDARD_INDEX_EXTENSION;
   return appendToPath(locator, indexExtension);
 }