ByteArrayComparator.compare
Code IndexAdd Codota to your IDE (free)

Best code snippets using org.opennms.core.utils.ByteArrayComparator.compare(Showing top 15 results out of 315)

origin: OpenNMS/opennms

public static boolean isInetAddressInRange(final byte[] addr, final byte[] begin, final byte[] end) {
  if (s_BYTE_ARRAY_COMPARATOR.compare(addr, begin) > 0) {
    return (s_BYTE_ARRAY_COMPARATOR.compare(addr, end) <= 0);
  } else {
    return s_BYTE_ARRAY_COMPARATOR.compare(addr, begin) == 0;
  }
}
origin: OpenNMS/opennms

public static boolean isInetAddressInRange(final String addrString, final String beginString, final String endString) {
  final byte[] addr = InetAddressUtils.toIpAddrBytes(addrString);
  final byte[] begin = InetAddressUtils.toIpAddrBytes(beginString);
  if (s_BYTE_ARRAY_COMPARATOR.compare(addr, begin) > 0) {
    final byte[] end = InetAddressUtils.toIpAddrBytes(endString);
    return (s_BYTE_ARRAY_COMPARATOR.compare(addr, end) <= 0);
  } else if (s_BYTE_ARRAY_COMPARATOR.compare(addr, begin) == 0) {
    return true;
  } else { 
    return false;
  }
}
origin: OpenNMS/opennms

  /**
   * <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());
  }
}
origin: OpenNMS/opennms

/**
 * <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));
}
origin: OpenNMS/opennms

@Override
public void visitRanges(List<Range> ranges) {
  // if we've already matched a specific, don't bother with the ranges
  if (!shouldTryToMatch()) return;
  for (final Range range : ranges) {
    final byte[] addr = m_address.getAddress();
    final byte[] begin = InetAddressUtils.toIpAddrBytes(range.getBegin());
    final byte[] end = InetAddressUtils.toIpAddrBytes(range.getEnd());

    final boolean inRange;
    if (BYTE_ARRAY_COMPARATOR.compare(begin, end) <= 0) {
      inRange = InetAddressUtils.isInetAddressInRange(addr, begin, end);
    } else {
      LOG.warn("{} has an 'end' that is earlier than its 'beginning'!", range);
      inRange = InetAddressUtils.isInetAddressInRange(addr, end, begin);
    }
    if (inRange) {
      handleMatch();
      return;
    }
  }
}
origin: OpenNMS/opennms

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 {
origin: OpenNMS/opennms

if (new ByteArrayComparator().compare(speca, addr) == 0) {
  has_specific = true;
  break;
origin: OpenNMS/opennms

if (new ByteArrayComparator().compare(speca, addr) == 0) {
  has_specific = true;
  break;
origin: OpenNMS/opennms

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);
origin: OpenNMS/opennms

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;
origin: OpenNMS/opennms

if (new ByteArrayComparator().compare(current, primary) < 0) {
  primaryAddr = currentAddr;
if (new ByteArrayComparator().compare(current, primary) > 0) {
  primaryAddr = currentAddr;
origin: OpenNMS/opennms

/**
 * Given a list of IP addresses, return the lowest as determined by the
 * numeric representation and not the alphanumeric string.
 *
 * @param addresses a {@link java.util.List} object.
 * @return a {@link java.net.InetAddress} object.
 */
public static InetAddress getLowestInetAddress(final List<InetAddress> addresses) {
  if (addresses == null) {
    throw new IllegalArgumentException("Cannot take null parameters.");
  }
  InetAddress lowest = null;
  // Start with the highest conceivable IP address value
  final byte[] originalBytes = toIpAddrBytes("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff");
  byte[] lowestBytes = originalBytes;
  for (final InetAddress temp : addresses) {
    byte[] tempBytes = temp.getAddress();
    if (s_BYTE_ARRAY_COMPARATOR.compare(tempBytes, lowestBytes) < 0) {
      lowestBytes = tempBytes;
      lowest = temp;
    }
  }
  return s_BYTE_ARRAY_COMPARATOR.compare(originalBytes, lowestBytes) == 0 ? null : lowest;
}
origin: OpenNMS/opennms

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;
origin: OpenNMS/opennms

  /**
   * 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());
  }
}
origin: OpenNMS/opennms

if (new ByteArrayComparator().compare(current, primary) < 0) {
  primaryAddr = currentAddr;
if (new ByteArrayComparator().compare(current, primary) > 0) {
  primaryAddr = currentAddr;
org.opennms.core.utilsByteArrayComparatorcompare

Popular methods of ByteArrayComparator

  • <init>
  • unsignedByteToInt

Popular classes and methods

  • getExternalFilesDir (Context)
  • findViewById (Activity)
  • setRequestProperty (URLConnection)
    Sets the value of the specified request header field. The value will only be used by the current URL
  • Pointer (com.sun.jna)
    An abstraction for a native pointer data type. A Pointer instance represents, on the Java side, a na
  • MalformedURLException (java.net)
    Thrown to indicate that a malformed URL has occurred. Either no legal protocol could be found in a s
  • URL (java.net)
    Class URL represents a Uniform Resource Locator, a pointer to a "resource" on the World Wide Web.
  • SQLException (java.sql)
    An exception that indicates a failed JDBC operation. It provides the following information about pro
  • Scanner (java.util)
    A parser that parses a text string of primitive types and strings with the help of regular expressio
  • Semaphore (java.util.concurrent)
    A counting semaphore. Conceptually, a semaphore maintains a set of permits. Each #acquire blocks if
  • Scheduler (org.quartz)
    This is the main interface of a Quartz Scheduler. A Scheduler maintains a registry of org.quartz.Job

For IntelliJ IDEA and
Android Studio

  • Codota IntelliJ IDEA pluginCodota Android Studio pluginCode IndexSign in
  • EnterpriseFAQAboutContact Us
  • Terms of usePrivacy policyCodeboxFind Usages
Add Codota to your IDE (free)