List<byte[]> byteArrayList = .... ; byte[] valueToFind = .... ; int index = Collections.binarySearch(byteArrayList, valueToFind, new ByteArrayComparator());
/** * <P> * Creates a generator object that iterates over the range from start to * end, inclusive. * </P> * * @param start * The start address. * @param end * The ending address. * * @exception java.lang.IllegalArgumentException * Thrown if the start address is greater than the ending * address. * */ IPAddressRangeGenerator(byte[] start, byte[] end) { if (new ByteArrayComparator().compare(start, end) > 0) throw new IllegalArgumentException("start must be less than or equal to end"); m_next = new BigInteger(1, Arrays.copyOf(start, start.length)); m_end = new BigInteger(1, Arrays.copyOf(end, end.length)); }
if (new ByteArrayComparator().compare(current, primary) < 0) { primaryAddr = currentAddr; if (new ByteArrayComparator().compare(current, primary) > 0) { primaryAddr = currentAddr;
if (new ByteArrayComparator().compare(current, primary) < 0) { primaryAddr = currentAddr; if (new ByteArrayComparator().compare(current, primary) > 0) { primaryAddr = currentAddr;
/** * returns the difference of spec1 - spec2 * * @param spec1 a {@link java.lang.String} object. * @param spec2 a {@link java.lang.String} object. * @return -1 for spec1 < spec2, 0 for spec1 == spec2, 1 for spec1 > spec2 */ @Override public int compare(final String spec1, final String spec2) { final InetAddress addr1 = InetAddressUtils.addr(spec1); final InetAddress addr2 = InetAddressUtils.addr(spec2); return new ByteArrayComparator().compare(addr1 == null? null : addr1.getAddress(), addr2 == null? null : addr2.getAddress()); } }
if (addr2 instanceof Inet4Address) { return new ByteArrayComparator().compare(addr1.getAddress(), addr2.getAddress()); } else { return -1; if (scopeComparison == 0) { return new ByteArrayComparator().compare(addr1.getAddress(), addr2.getAddress()); } else { return scopeComparison;
byte[] to = end.getAddress(); if (new ByteArrayComparator().compare(from, to) > 0) { LOG.warn("The beginning of the address range is greater than the end of the address range ({} - {}), swapping values to create a valid IP address range", InetAddressUtils.str(start), InetAddressUtils.str(end)); m_end = from;
/** * <p>compare</p> * * @param rng1 a {@link org.opennms.netmgt.config.common.Range} object. * @param rng2 a {@link org.opennms.netmgt.config.common.Range} object. * @return a int. */ @Override public int compare(final Range rng1, final Range rng2) { final InetAddress addr1 = InetAddressUtils.addr(rng1.getBegin()); final InetAddress addr2 = InetAddressUtils.addr(rng2.getBegin()); return new ByteArrayComparator().compare(addr1 == null? null : addr1.getAddress(), addr2 == null? null : addr2.getAddress()); } }
int comparison = new ByteArrayComparator().compare(addr, toIpAddrBytes(rng.getBegin())); if (comparison > 0) { int endComparison = new ByteArrayComparator().compare(addr, toIpAddrBytes(rng.getEnd())); if (endComparison <= 0) { has_range_include = true; if (new ByteArrayComparator().compare(addr, toIpAddrBytes(spec)) == 0) { has_specific = true; LOG.debug("interfaceInPackage: Interface {} defined as 'specific'", iface); int comparison = new ByteArrayComparator().compare(addr, toIpAddrBytes(rng.getBegin())); if (comparison > 0) { int endComparison = new ByteArrayComparator().compare(addr, toIpAddrBytes(rng.getEnd())); if (endComparison <= 0) { LOG.debug("interfaceInPackage: Interface {} matches an exclude range", iface);
if (new ByteArrayComparator().compare(speca, addr) == 0) { has_specific = true; break;
if (new ByteArrayComparator().compare(speca, addr) == 0) { has_specific = true; break;
if (new ByteArrayComparator().compare(speca, addr) == 0) { has_specific = true; break;
if (new ByteArrayComparator().compare(speca, addr) == 0) { has_specific = true; break;
if (new ByteArrayComparator().compare(speca, addr) == 0) { has_specific = true; break;
final String o2ip = InetAddressUtils.str(o2.getIpAddress()); if (!"0.0.0.0".equals(o1ip) && !"0.0.0.0".equals(o2ip)) { return new ByteArrayComparator().compare(InetAddressUtils.toIpAddrBytes(o1ip), InetAddressUtils.toIpAddrBytes(o2ip)); } else {
final String o2ip = InetAddressUtils.str(o2.getIpAddress()); if (!"0.0.0.0".equals(o1ip) && !"0.0.0.0".equals(o2ip)) { return new ByteArrayComparator().compare(InetAddressUtils.toIpAddrBytes(o1ip), InetAddressUtils.toIpAddrBytes(o2ip)); } else {