/**
 * The MIT License (MIT)
 *
 * Copyright (c) 2015 Marc de Verdelhan
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */
package eu.verdelhan.acr122urw;

/**
 * Hexadecimal utility class.
 */
public final class HexUtils {
	
    /** Array of all hexadecimal chars */
    private static final char[] HEX_CHARS = "0123456789ABCDEF".toCharArray();

    private HexUtils() {
    }

    /**
     * @param s a string
     * @return true if the provided string is hexadecimal, false otherwise
     */
    public static boolean isHexString(String s) {
        try {
            Long.parseLong(s, HEX_CHARS.length);
        } catch (NumberFormatException | NullPointerException e) {
            return false;
        }
        return true;
    }
    
    /**
     * @param s a hex string
     * @return a byte array
     */
    public static byte[] hexStringToBytes(String s) {
        int len = s.length();
        byte[] data = new byte[len / 2];
        for (int i = 0; i < len; i += 2) {
            data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4) + Character.digit(s.charAt(i + 1), 16));
        }
        return data;
    }

    /**
     * @param bytes a byte array
     * @return a hex string
     */
    public static String bytesToHexString(byte[] bytes) {
        char[] hexChars = new char[bytes.length * 2];
        for (int i = 0; i < bytes.length; i++) {
            int v = bytes[i] & 0xFF;
            hexChars[i * 2] = HEX_CHARS[v >>> 4];
            hexChars[i * 2 + 1] = HEX_CHARS[v & 0x0F];
        }
        return new String(hexChars);
    }
}
@@ -1177,16 +1177,49 @@
 22urw;%0A%0A
+import java.util.regex.Pattern;%0A%0A
 /**%0A * H
@@ -1282,9 +1282,156 @@
 s %7B%0A
-%09
+%0A    /** Regex pattern for hexadecimal strings */%0A    private static final Pattern HEX_STRING_PATTERN = Pattern.compile(%22%5E(%5B0-9A-Fa-f%5D%7B2%7D)+$%22);%0A    
 %0A   
@@ -1547,17 +1547,21 @@
 rray();%0A
+    
 %0A
-
     priv
@@ -1762,185 +1762,69 @@
     
-try %7B%0A            Long.parseLong(s, HEX_CHARS.length);%0A        %7D catch (NumberFormatException %7C NullPointerException e) %7B%0A            return false;%0A        %7D%0A        return true
+return (s != null) && HEX_STRING_PATTERN.matcher(s).matches()
 ;%0A  

Fix isHexString() method