view src/main/java/nl/cwi/monetdb/embedded/mapping/MonetDBEmbeddedBlob.java @ 42:dfea8468cd1a embedded

Finished Java code for CRUD operations on tables and the documentation.
author Pedro Ferreira <pedro.ferreira@monetdbsolutions.com>
date Tue, 08 Nov 2016 14:57:26 +0100 (2016-11-08)
parents 3a19ebf83af6
children 2ab2b21cf930
line wrap: on
line source
package nl.cwi.monetdb.embedded.mapping;

import java.util.Arrays;

/**
 * A Java representation for the BLOB data type. Added for more efficient data mapping when fetching from the database.
 *
 * @author <a href="mailto:pedro.ferreira@monetdbsolutions.com">Pedro Ferreira</a>
 */
public class MonetDBEmbeddedBlob {

    /**
     * The BLOB's content as a Java byte array.
     */
    private final byte[] blob;

    public MonetDBEmbeddedBlob(byte[] blob) { this.blob = blob; }

    /**
     * Get the BLOB content itself,
     *
     * @return A Java byte array containing the BLOB itself
     */
    public byte[] getBlob() { return blob; }

    /**
     * Overriding the equals method for the byte array.
     */
    @Override
    public boolean equals(Object obj) {
        return obj instanceof MonetDBEmbeddedBlob && Arrays.equals(this.blob, ((MonetDBEmbeddedBlob) obj).getBlob());
    }

    /**
     * Overriding the hashCode method for the byte array.
     */
    @Override
    public int hashCode() { return Arrays.hashCode(this.blob); }

    /**
     * Overriding the toString method for the byte array.
     */
    @Override
    public String toString() { return Arrays.toString(blob); }
}