/** * 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. * * @param that * @return a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object. */ public int compareTo(DNSEntry 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; }
/** * 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. * * @param that * @return a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object. */ public int compareTo(DNSEntry 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; }
/** * 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. * * @param that * @return a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object. */ public int compareTo(DNSEntry 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; }
/** * 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. * * @param that * @return a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object. */ public int compareTo(DNSEntry 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; }
/** * Creates a byte array representation of this record. This is needed for tie-break tests according to draft-cheshire-dnsext-multicastdns-04.txt chapter 9.2. * * @return byte array representation */ protected byte[] toByteArray() { try { ByteArrayOutputStream bout = new ByteArrayOutputStream(); DataOutputStream dout = new DataOutputStream(bout); this.toByteArray(dout); dout.close(); return bout.toByteArray(); } catch (IOException e) { throw new InternalError(); } }
/** * Creates a byte array representation of this record. This is needed for tie-break tests according to draft-cheshire-dnsext-multicastdns-04.txt chapter 9.2. * * @return byte array representation */ protected byte[] toByteArray() { try { ByteArrayOutputStream bout = new ByteArrayOutputStream(); DataOutputStream dout = new DataOutputStream(bout); this.toByteArray(dout); dout.close(); return bout.toByteArray(); } catch (IOException e) { throw new InternalError(); } }
/** * Creates a byte array representation of this record. This is needed for tie-break tests according to draft-cheshire-dnsext-multicastdns-04.txt chapter 9.2. * * @return byte array representation */ protected byte[] toByteArray() { try { ByteArrayOutputStream bout = new ByteArrayOutputStream(); DataOutputStream dout = new DataOutputStream(bout); this.toByteArray(dout); dout.close(); return bout.toByteArray(); } catch (IOException e) { throw new InternalError(); } }
/** * Creates a byte array representation of this record. This is needed for tie-break tests according to draft-cheshire-dnsext-multicastdns-04.txt chapter 9.2. * * @return byte array representation */ protected byte[] toByteArray() { try { ByteArrayOutputStream bout = new ByteArrayOutputStream(); DataOutputStream dout = new DataOutputStream(bout); this.toByteArray(dout); dout.close(); return bout.toByteArray(); } catch (IOException e) { throw new InternalError(); } }