java.nio.ByteBuffer#compareTo ( )源码实例Demo

下面列出了java.nio.ByteBuffer#compareTo ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: nifi-minifi   文件: WholeConfigDifferentiator.java
boolean compareInputStreamToConfigFile(InputStream inputStream) throws IOException {
    logger.debug("Checking if change is different");
    AtomicReference<ByteBuffer> currentConfigFileReference = configurationFileHolder.getConfigFileReference();
    ByteBuffer currentConfigFile = currentConfigFileReference.get();
    ByteBuffer byteBuffer = ByteBuffer.allocate(currentConfigFile.limit());
    DataInputStream dataInputStream = new DataInputStream(inputStream);
    try {
        dataInputStream.readFully(byteBuffer.array());
    } catch (EOFException e) {
        logger.debug("New config is shorter than the current. Must be different.");
        return true;
    }
    logger.debug("Read the input");

    if (dataInputStream.available() != 0) {
        return true;
    } else {
        return byteBuffer.compareTo(currentConfigFile) != 0;
    }
}
 
源代码2 项目: onos   文件: BgpFsDestinationPrefix.java
@Override
public int compareTo(Object o) {
    if (this.equals(o)) {
        return 0;
    }

    if (o instanceof BgpFsDestinationPrefix) {
        BgpFsDestinationPrefix that = (BgpFsDestinationPrefix) o;

        if (this.ipPrefix().prefixLength() == that.ipPrefix().prefixLength()) {
            ByteBuffer value1 = ByteBuffer.wrap(this.ipPrefix.address().toOctets());
            ByteBuffer value2 = ByteBuffer.wrap(that.ipPrefix.address().toOctets());
            return value1.compareTo(value2);
        }

        if (this.ipPrefix().prefixLength() > that.ipPrefix().prefixLength()) {
            return 1;
        } else if (this.ipPrefix().prefixLength() < that.ipPrefix().prefixLength()) {
            return -1;
        }
    }
    return 1;
}
 
源代码3 项目: onos   文件: BgpFsSourcePrefix.java
@Override
public int compareTo(Object o) {
    if (this.equals(o)) {
        return 0;
    }

    if (o instanceof BgpFsSourcePrefix) {
        BgpFsSourcePrefix that = (BgpFsSourcePrefix) o;

        if (this.ipPrefix().prefixLength() == that.ipPrefix().prefixLength()) {
            ByteBuffer value1 = ByteBuffer.wrap(this.ipPrefix.address().toOctets());
            ByteBuffer value2 = ByteBuffer.wrap(that.ipPrefix.address().toOctets());
            return value1.compareTo(value2);
        }

        if (this.ipPrefix().prefixLength() > that.ipPrefix().prefixLength()) {
            return 1;
        } else if (this.ipPrefix().prefixLength() < that.ipPrefix().prefixLength()) {
            return -1;
        }
    }
    return 1;
}
 
源代码4 项目: graphicsfuzz   文件: Main.java
private boolean byteBuffersEqual(ByteBuffer bb1, ByteBuffer bb2) {
  bb1.position(0);
  bb2.position(0);
  boolean res = (bb1.compareTo(bb2) == 0);
  bb1.position(0);
  bb2.position(0);
  return res;
}
 
源代码5 项目: stratio-cassandra   文件: TimeUUIDType.java
public int compare(ByteBuffer o1, ByteBuffer o2)
{
    if (!o1.hasRemaining() || !o2.hasRemaining())
        return o1.hasRemaining() ? 1 : o2.hasRemaining() ? -1 : 0;

    int res = compareTimestampBytes(o1, o2);
    if (res != 0)
        return res;
    return o1.compareTo(o2);
}
 
源代码6 项目: onos   文件: IPReachabilityInformationTlv.java
@Override
public int compareTo(Object o) {
    if (this.equals(o)) {
        return 0;
    }
    ByteBuffer value1 = ByteBuffer.wrap(this.ipPrefix);
    ByteBuffer value2 = ByteBuffer.wrap(((IPReachabilityInformationTlv) o).ipPrefix);
    return value1.compareTo(value2);
}
 
源代码7 项目: onos   文件: IsIsNonPseudonode.java
@Override
public int compareTo(Object o) {
    if (this.equals(o)) {
        return 0;
    }
    ByteBuffer value1 = ByteBuffer.wrap(this.isoNodeID);
    ByteBuffer value2 = ByteBuffer.wrap(((IsIsNonPseudonode) o).isoNodeID);
    return value1.compareTo(value2);
}
 
源代码8 项目: onos   文件: IsIsPseudonode.java
@Override
public int compareTo(Object o) {
    if (this.equals(o)) {
        return 0;
    }
    ByteBuffer value1 = ByteBuffer.wrap(this.isoNodeID);
    ByteBuffer value2 = ByteBuffer.wrap(((IsIsPseudonode) o).isoNodeID);
    if (value1.compareTo(value2) != 0) {
        return value1.compareTo(value2);
    }
    return ((Byte) (this.psnIdentifier)).compareTo((Byte) (((IsIsPseudonode) o).psnIdentifier));
}
 
源代码9 项目: tez   文件: TestPipelinedSorter.java
@Override
public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2) {
  //wrapping is done so that it would throw exceptions on wrong lengths
  ByteBuffer bb1 = ByteBuffer.wrap(b1, s1, l1);
  ByteBuffer bb2 = ByteBuffer.wrap(b2, s2, l2);

  return bb1.compareTo(bb2);
}
 
源代码10 项目: tez   文件: TestTezMerger.java
@Override
//Not a valid comparison, but just to check byte boundaries
public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2) {
  Preconditions.checkArgument(l2 > 0 && l1 > 0, "l2=" + l2 + ",l1=" + l1);
  ByteBuffer bb1 = ByteBuffer.wrap(b1, s1, l1);
  ByteBuffer bb2 = ByteBuffer.wrap(b2, s2, l2);
  return bb1.compareTo(bb2);
}
 
源代码11 项目: nifi-minifi   文件: WholeConfigDifferentiator.java
public boolean isNew(ByteBuffer inputBuffer) {
    AtomicReference<ByteBuffer> currentConfigFileReference = configurationFileHolder.getConfigFileReference();
    ByteBuffer currentConfigFile = currentConfigFileReference.get();
    return inputBuffer.compareTo(currentConfigFile) != 0;
}