## org.apache.hadoop.io
Class BinaryComparable

    java.lang.Object
      org.apache.hadoop.io.BinaryComparable

All Implemented Interfaces:
  Comparable<BinaryComparable>

Direct Known Subclasses:
  BytesWritable, Text

    public abstract class BinaryComparable

extends Object
implements Comparable<BinaryComparable>

Interface supported by `WritableComparable` types supporting ordering/permutation by a representative set of bytes.

Constructor Summary
`BinaryComparable()`

Method Summary
`int` `compareTo(BinaryComparable other)` Compare bytes from {#getBytes()}.
`int` `compareTo(byte[] other, int off, int len)` Compare bytes from {#getBytes()} to those provided.
`boolean` `equals(Object other)` Return true if bytes from {#getBytes()} match.
`abstract byte[]` `getBytes()` Return representative byte array for this instance.
`abstract int` `getLength()` Return n st bytes 0..n-1 from {#getBytes()} are valid.
`int` `hashCode()` Return a hash of the bytes returned from {#getBytes()}.

Methods inherited from class java.lang.Object
`clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### BinaryComparable

    public BinaryComparable()

Method Detail

### getLength

    public abstract int getLength()

  Return n st bytes 0..n-1 from {#getBytes()} are valid.

### getBytes

    public abstract byte[] getBytes()

  Return representative byte array for this instance.

### compareTo

    public int compareTo(BinaryComparable other)

  Compare bytes from {#getBytes()}.

  Specified by:
    `compareTo` in interface `Comparable<BinaryComparable>`
  See Also:
    `WritableComparator.compareBytes(byte[],int,int,byte[],int,int)`

### compareTo

    public int compareTo(byte[] other,
                         int off,
                         int len)

  Compare bytes from {#getBytes()} to those provided.

### equals

    public boolean equals(Object other)

  Return true if bytes from {#getBytes()} match.

  Overrides:
    `equals` in class `Object`

### hashCode

    public int hashCode()

  Return a hash of the bytes returned from {#getBytes()}.

  Overrides:
    `hashCode` in class `Object`
  See Also:
    `WritableComparator.hashBytes(byte[],int)`

Copyright © 2009 The Apache Software Foundation