Example usage for org.apache.solr.common.util StrUtils HEX_DIGITS

List of usage examples for org.apache.solr.common.util StrUtils HEX_DIGITS

Introduction

In this page you can find the example usage for org.apache.solr.common.util StrUtils HEX_DIGITS.

Prototype

null HEX_DIGITS

To view the source code for org.apache.solr.common.util StrUtils HEX_DIGITS.

Click Source Link

Usage

From source file:org.phenotips.variantstore.db.solr.SolrVariantUtils.java

License:Open Source License

/**
 * Turns bytes[] into a hex String. Copied from {@link
 * org.apache.solr.update.processor.SignatureUpdateProcessorFactory}.
 *
 * @param bytes a byte array/*from   w ww . j  a  v a 2s.  c  om*/
 *
 * @return a String
 */
private static String byteArrayToString(byte[] bytes) {
    char[] arr = new char[bytes.length << 1];

    for (int i = 0; i < bytes.length; i++) {
        int b = bytes[i];
        int idx = i << 1;
        arr[idx] = StrUtils.HEX_DIGITS[(b >> 4) & 0xf];
        arr[idx + 1] = StrUtils.HEX_DIGITS[b & 0xf];
    }
    return Arrays.toString(arr);

}