List of usage examples for com.google.common.hash HashCodes fromBytes
public static HashCode fromBytes(byte[] bytes)
From source file:org.jclouds.sqs.xml.MessageHandler.java
@Override public void endElement(String uri, String name, String qName) { if (qName.equals("MessageId")) { builder.id(currentOrNull(currentText)); } else if (qName.equals("ReceiptHandle")) { builder.receiptHandle(currentOrNull(currentText)); } else if (qName.equals("MD5OfBody")) { builder.md5(HashCodes.fromBytes(base16().lowerCase().decode(currentOrNull(currentText)))); } else if (qName.equals("Body")) { builder.body(currentOrNull(currentText)); } else if (qName.equals("Name")) { this.name = currentOrNull(currentText); } else if (qName.equals("Value")) { builder.addAttribute(this.name, currentOrNull(currentText)); this.name = null; }//from w w w. j a v a 2 s.c o m currentText = new StringBuilder(); }
From source file:org.jclouds.sqs.xml.RegexMessageIdAndMD5Handler.java
@Override public MessageIdAndMD5 apply(HttpResponse response) { String content = returnStringIf200.apply(response); if (content != null) { Matcher matcher = pattern.matcher(content); if (matcher.find()) { return MessageIdAndMD5.builder().id(matcher.group(1)) .md5(HashCodes.fromBytes(base16().lowerCase().decode(matcher.group(2)))).build(); }//from www . j ava 2 s . c om } return null; }
From source file:org.jclouds.sqs.xml.SendMessageBatchResultEntryHandler.java
@Override public void endElement(String uri, String name, String qName) { if (qName.equals("Id")) { this.id = currentOrNull(currentText); } else if (qName.equals("MessageId")) { builder.id(currentOrNull(currentText)); } else if (qName.equals("MD5OfMessageBody")) { builder.md5(HashCodes.fromBytes(base16().lowerCase().decode(currentOrNull(currentText)))); }// w ww. jav a 2 s . c om currentText = new StringBuilder(); }
From source file:ome.util.checksum.NonGuavaHasherImpl.java
/** * This method uses the {@link HashCodes#fromBytes(byte[])} to produce * the required {@link HashCode} return type. The Adler32 output is * converted from <code>long</code> to <code>int</code> and then to a byte * array. This guarantees endianness consistency, as other methods from * {@link HashCodes}, which could be also used, invert the byte order. * * @see com.google.common.hash.Hasher#hash() *//* w w w . j av a 2 s.c o m*/ public HashCode hash() { ByteBuffer buf = ByteBuffer.wrap(new byte[4]); // If Adler32.getValue starts returning 64 bits, the world will end buf.putInt((int) this.checksum.getValue()); return HashCodes.fromBytes(buf.array()); }
From source file:org.geogit.api.ObjectId.java
/** * @return a human friendly representation of this SHA1 * @see java.lang.Object#toString()/* w ww . jav a2 s.c o m*/ */ @Override public String toString() { return HashCodes.fromBytes(hashCode).toString(); }
From source file:org.iff.infra.util.jaxrs.gson.ByteString.java
/** * Converts the byte string to a {@link HashCode}. * @throws IllegalStateException if the string is empty. *///from w ww . ja va2s .c o m public HashCode toHashCode() { checkState(bytes.length > 0, "The byte string must not be empty"); return HashCodes.fromBytes(bytes); }