/** * Does a lexicographic comparison of the byte array representation * of this record and that record. * This is needed for tie-break tests according to * draft-cheshire-dnsext-multicastdns-04.txt chapter 9.2. */ private int lexCompare(DNSRecord.Address that) { byte[] thisBytes = this.toByteArray(); byte[] thatBytes = that.toByteArray(); for (int i = 0, n = Math.min(thisBytes.length, thatBytes.length); i < n; i++) { if (thisBytes[i] > thatBytes[i]) { return 1; } else { if (thisBytes[i] < thatBytes[i]) { return -1; } } } return thisBytes.length - thatBytes.length; }