Factored URL Link constants out into UrlConstants file.
[jalview.git] / src / jalview / util / UrlLink.java
index 4297090..e196c8c 100644 (file)
@@ -20,6 +20,8 @@
  */
 package jalview.util;
 
+import static jalview.util.UrlConstants.SEQUENCE_ID;
+
 import java.util.Vector;
 
 public class UrlLink
@@ -48,7 +50,7 @@ public class UrlLink
    */
   public UrlLink(String link)
   {
-    int sep = link.indexOf("|"), psqid = link.indexOf("$SEQUENCE_ID");
+    int sep = link.indexOf("|"), psqid = link.indexOf("$" + SEQUENCE_ID);
     if (psqid > -1)
     {
       dynamic = true;
@@ -77,7 +79,7 @@ public class UrlLink
       }
       // Parse URL : Whole URL string first
       url_prefix = link.substring(sep + 1, psqid);
-      if (link.indexOf("$SEQUENCE_ID=/") == psqid
+      if (link.indexOf("$" + SEQUENCE_ID + "=/") == psqid
               && (p = link.indexOf("/=$", psqid + 14)) > psqid + 14)
       {
         // Extract Regex and suffix
@@ -102,7 +104,7 @@ public class UrlLink
       {
         regexReplace = null;
         // verify format is really correct.
-        if (link.indexOf("$SEQUENCE_ID$") == psqid)
+        if (link.indexOf("$" + SEQUENCE_ID + "$") == psqid)
         {
           url_suffix = link.substring(psqid + 13);
           regexReplace = null;
@@ -295,12 +297,13 @@ public class UrlLink
     }
   }
 
+  @Override
   public String toString()
   {
     return label
             + "|"
             + url_prefix
-            + (dynamic ? ("$SEQUENCE_ID" + ((regexReplace != null) ? "="
+            + (dynamic ? ("$" + SEQUENCE_ID + ((regexReplace != null) ? "="
                     + regexReplace + "=$" : "$")) : "")
             + ((url_suffix == null) ? "" : url_suffix);
 
@@ -341,7 +344,8 @@ public class UrlLink
      * "PF3|http://us.expasy.org/cgi-bin/niceprot.pl?$SEQUENCE_ID=/PFAM:(.+)/=$"
      * , "NOTFER|http://notfer.org/$SEQUENCE_ID=/(?<!\\s)(.+)/=$",
      */
-    "NESTED|http://nested/$SEQUENCE_ID=/^(?:Label:)?(?:(?:gi\\|(\\d+))|([^:]+))/=$/nested" };
+    "NESTED|http://nested/$" + SEQUENCE_ID
+            + "=/^(?:Label:)?(?:(?:gi\\|(\\d+))|([^:]+))/=$/nested" };
     String[] idstrings = new String[] {
     /*
      * //"LGUL_human", //"QWIQW_123123", "uniprot|why_do+_12313_foo",