All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jgroups.util.Range Maven / Gradle / Ivy

Go to download

This artifact provides a single jar that contains all classes required to use remote EJB and JMS, including all dependencies. It is intended for use by those not using maven, maven users should just import the EJB and JMS BOM's instead (shaded JAR's cause lots of problems with maven, as it is very easy to inadvertently end up with different versions on classes on the class path).

There is a newer version: 33.0.2.Final
Show newest version

package org.jgroups.util;


import java.io.DataInput;
import java.io.DataOutput;


public class Range implements Streamable, Comparable {
    public long low=-1;  // first msg to be retransmitted
    public long high=-1; // last msg to be retransmitted



    /** For externalization */
    public Range() {
    }

    public Range(long low, long high) {
        this.low=low; this.high=high;
    }


    public String toString() {
        return "[" + low + " : " + high + ']';
    }


    public int compareTo(Range other) {
        if(low == other.low && high == other.high)
            return 0;
        return low < other.low? -1 : 1;
    }

    public int hashCode() {
        return (int)low;
    }

    public boolean equals(Object obj) {
        Range other=(Range)obj;
        return compareTo(other) == 0;
    }



    public void writeTo(DataOutput out) throws Exception {
        Bits.writeLongSequence(low, high, out);
    }

    public void readFrom(DataInput in) throws Exception {
        long[] seqnos=Bits.readLongSequence(in);
        low=seqnos[0];
        high=seqnos[1];
    }

    public int serializedSize() {
        return Bits.size(low, high);
    }


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy