Java Code Examples for java.nio.ByteBuffer#compareTo()
The following examples show how to use
java.nio.ByteBuffer#compareTo() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WholeConfigDifferentiator.java From nifi-minifi with Apache License 2.0 | 6 votes |
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; } }
Example 2
Source File: BgpFsDestinationPrefix.java From onos with Apache License 2.0 | 6 votes |
@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; }
Example 3
Source File: BgpFsSourcePrefix.java From onos with Apache License 2.0 | 6 votes |
@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; }
Example 4
Source File: Main.java From graphicsfuzz with Apache License 2.0 | 5 votes |
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; }
Example 5
Source File: TimeUUIDType.java From stratio-cassandra with Apache License 2.0 | 5 votes |
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); }
Example 6
Source File: IPReachabilityInformationTlv.java From onos with Apache License 2.0 | 5 votes |
@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); }
Example 7
Source File: IsIsNonPseudonode.java From onos with Apache License 2.0 | 5 votes |
@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); }
Example 8
Source File: IsIsPseudonode.java From onos with Apache License 2.0 | 5 votes |
@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)); }
Example 9
Source File: TestPipelinedSorter.java From tez with Apache License 2.0 | 5 votes |
@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); }
Example 10
Source File: TestTezMerger.java From tez with Apache License 2.0 | 5 votes |
@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); }
Example 11
Source File: WholeConfigDifferentiator.java From nifi-minifi with Apache License 2.0 | 4 votes |
public boolean isNew(ByteBuffer inputBuffer) { AtomicReference<ByteBuffer> currentConfigFileReference = configurationFileHolder.getConfigFileReference(); ByteBuffer currentConfigFile = currentConfigFileReference.get(); return inputBuffer.compareTo(currentConfigFile) != 0; }