/** * Get the string representation of the supplied binary hash. * * @param hash the binary hash * @return the hex-encoded representation of the binary hash, or null if the hash is null */ public static String asHexString( byte[] hash ) { return hash != null ? StringUtil.getHexString(hash) : null; }
/** * Get the string representation of the supplied binary hash. * * @param hash the binary hash * @return the hex-encoded representation of the binary hash, or null if the hash is null */ public static String asHexString( byte[] hash ) { return hash != null ? StringUtil.getHexString(hash) : null; }
/** * Get the string representation of the supplied binary hash. * * @param hash the binary hash * @return the hex-encoded representation of the binary hash, or null if the hash is null */ public static String asHexString( byte[] hash ) { return hash != null ? StringUtil.getHexString(hash) : null; }
public BinaryKey( byte[] hash ) { this(StringUtil.getHexString(hash)); }
public BinaryKey( byte[] hash ) { this(StringUtil.getHexString(hash)); }
@Override public String getHexHash() { return StringUtil.getHexString(hash); }
/** * {@inheritDoc} * * @see org.modeshape.connector.store.jpa.util.Serializer.LargeValues#read(org.modeshape.graph.property.ValueFactories, * byte[], long) */ @Override public Object read( ValueFactories valueFactories, byte[] hash, long length ) { String key = StringUtil.getHexString(hash); return skippedKeys.add(key); }
public LargeValue get( byte[] hash ) { String hexHash = StringUtil.getHexString(hash); return largeValuesByHexHash.get(hexHash); }
/** * {@inheritDoc} * * @see org.modeshape.connector.store.jpa.util.Serializer.LargeValues#write(byte[], long, * org.modeshape.graph.property.PropertyType, java.lang.Object) */ @Override public void write( byte[] hash, long length, PropertyType type, Object value ) { String hexHash = StringUtil.getHexString(hash); largeValuesByHexHash.put(hexHash, new LargeValue(hash, length, type, value)); }
if (value instanceof Binary) { byte[] bytes = IoUtil.readBytes(((Binary)value).getStream()); str = StringUtil.getHexString(bytes); } else { str = stringFactory.create(value);
if (value instanceof Binary) { byte[] bytes = IoUtil.readBytes(((Binary)value).getStream()); str = StringUtil.getHexString(bytes); } else { str = stringFactory.create(value);
/** * Computes the SHA1 for the given file. By default, this method will look at the * {@link FileSystemConnector#contentBasedSha1()} flag and either take the URL of the file (using @see * java.util.File#toURI().toURL() and return the SHA1 of the URL string or return the SHA1 of the entire file content. * * @param file a {@link File} instance; never null * @return the SHA1 of the file. */ protected String sha1( File file ) { try { if (contentBasedSha1()) { byte[] hash = SecureHash.getHash(SecureHash.Algorithm.SHA_1, file); return StringUtil.getHexString(hash); } return SecureHash.sha1(createUrlForFile(file).toString()); } catch (Exception e) { throw new ConnectorException(e); } }
/** * Computes the SHA1 for the given file. By default, this method will look at the * {@link FileSystemConnector#contentBasedSha1()} flag and either take the URL of the file (using @see * java.util.File#toURI().toURL() and return the SHA1 of the URL string or return the SHA1 of the entire file content. * * @param file a {@link File} instance; never null * @return the SHA1 of the file. */ protected String sha1( File file ) { try { if (contentBasedSha1()) { byte[] hash = SecureHash.getHash(SecureHash.Algorithm.SHA_1, file); return StringUtil.getHexString(hash); } return SecureHash.sha1(createUrlForFile(file).toString()); } catch (Exception e) { throw new ConnectorException(e); } }
public boolean isSkipped( Binary binary ) { String key = StringUtil.getHexString(binary.getHash()); return isSkipped(key); }
@Test public void shouldComputeSha1HashOfNonEmptyContent() throws Exception { binary = new InMemoryBinary(validByteArrayContent); assertThat(binary.getSize(), is((long)validByteArrayContent.length)); byte[] hash = binary.getHash(); assertThat(hash.length, is(20)); assertThat(StringUtil.getHexString(hash), is("14abe696257e85ba18b7c784d6c7855f46ce50ea")); }
@Test public void shouldComputeSha1HashOfNonEmptyContent() throws Exception { binary = new InMemoryBinaryValue(store, validByteArrayContent); assertThat(binary.getSize(), is((long)validByteArrayContent.length)); byte[] hash = binary.getHash(); assertThat(hash.length, is(20)); assertThat(StringUtil.getHexString(hash), is("14abe696257e85ba18b7c784d6c7855f46ce50ea")); }
@Test public void shouldComputeSha1HashOfEmptyContent() throws Exception { validByteArrayContent = new byte[0]; binary = new InMemoryBinary(validByteArrayContent); assertThat(binary.getSize(), is(0l)); assertThat(binary, hasNoContent()); byte[] hash = binary.getHash(); assertThat(hash.length, is(20)); assertThat(StringUtil.getHexString(hash), is("da39a3ee5e6b4b0d3255bfef95601890afd80709")); }
@Test public void shouldComputeSha1HashOfEmptyContent() throws Exception { validByteArrayContent = new byte[0]; binary = new InMemoryBinaryValue(store, validByteArrayContent); assertThat(binary.getSize(), is(0l)); assertThat(binary, hasNoContent()); byte[] hash = binary.getHash(); assertThat(hash.length, is(20)); assertThat(StringUtil.getHexString(hash), is("da39a3ee5e6b4b0d3255bfef95601890afd80709")); }