X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Futil%2FStringUtils.java;fp=src%2Fjalview%2Futil%2FStringUtils.java;h=3025e8a328f4e156d7fa685aa53714268cc38eb4;hb=304e64fb34b32659be1bbfd39fb4e15b2f79586e;hp=bf5b87a4f873a2ba9185109467cb4c5ef634fc9d;hpb=61ff8fb4efa315c35149c9d11850d99e3d00c441;p=jalview.git diff --git a/src/jalview/util/StringUtils.java b/src/jalview/util/StringUtils.java index bf5b87a..3025e8a 100644 --- a/src/jalview/util/StringUtils.java +++ b/src/jalview/util/StringUtils.java @@ -119,29 +119,6 @@ public class StringUtils } /** - * Returns the last part of 'input' after the last occurrence of 'token'. For - * example to extract only the filename from a full path or URL. - * - * @param input - * @param token - * a delimiter which must be in regular expression format - * @return - */ - public static String getLastToken(String input, String token) - { - if (input == null) - { - return null; - } - if (token == null) - { - return input; - } - String[] st = input.split(token); - return st[st.length - 1]; - } - - /** * Parses the input string into components separated by the delimiter. Unlike * String.split(), this method will ignore occurrences of the delimiter which * are nested within single quotes in name-value pair values, e.g. a='b,c'. @@ -570,4 +547,29 @@ public class StringUtils } return enc; } + + /** + * Answers true if the string is not empty and consists only of digits, or + * characters 'a'-'f' or 'A'-'F', else false + * + * @param s + * @return + */ + public static boolean isHexString(String s) + { + int j = s.length(); + if (j == 0) + { + return false; + } + for (int i = 0; i < j; i++) + { + int c = s.charAt(i); + if (!(c >= '0' && c <= '9' || c >= 'a' && c <= 'f' || c >= 'A' && c <= 'F')) + { + return false; + } + } + return true; + } }