public IPAddressRange(String cidrNotation) { SubnetV4Utils su = new SubnetV4Utils(cidrNotation); low = new Long(su.getInfo().getAddressAsInteger()); size = su.getInfo().getMaskSize(); }
/** * {@inheritDoc} * @since 2.2 */ @Override public String toString() { final StringBuilder buf = new StringBuilder(); buf.append("CIDR Signature:\t[").append(getCidrSignature()).append("]") .append(" Netmask: [").append(getNetmask()).append("]\n") .append("Network:\t[").append(getNetworkAddress()).append("]\n") .append("Broadcast:\t[").append(getBroadcastAddress()).append("]\n") .append("First Address:\t[").append(getLowAddress()).append("]\n") .append("Last Address:\t[").append(getHighAddress()).append("]\n") .append("# Addresses:\t[").append(getAddressCount()).append("]\n"); return buf.toString(); } }
/** * Get the count of available addresses. * Will be zero for CIDR/31 and CIDR/32 if the inclusive flag is false. * @return the count of addresses, may be zero. * @throws RuntimeException if the correct count is greater than {@code Integer.MAX_VALUE} * @deprecated use {@link #getAddressCountLong()} instead */ @Deprecated public int getAddressCount() { long countLong = getAddressCountLong(); if (countLong > Integer.MAX_VALUE) { throw new RuntimeException("Count is larger than an integer: " + countLong); } // N.B. cannot be negative return (int)countLong; }
/** * {@inheritDoc} * @since 2.2 */ @Override public String toString() { final StringBuilder buf = new StringBuilder(); buf.append("CIDR Signature:\t[").append(getCidrSignature()).append("]") .append(" Netmask: [").append(getNetmask()).append("]\n") .append("Network:\t[").append(getNetworkAddress()).append("]\n") .append("Broadcast:\t[").append(getBroadcastAddress()).append("]\n") .append("First Address:\t[").append(getLowAddress()).append("]\n") .append("Last Address:\t[").append(getHighAddress()).append("]\n") .append("# Addresses:\t[").append(getAddressCount()).append("]\n"); return buf.toString(); } }
/** * Get the count of available addresses. * Will be zero for CIDR/31 and CIDR/32 if the inclusive flag is false. * @return the count of addresses, may be zero. * @throws RuntimeException if the correct count is greater than {@code Integer.MAX_VALUE} * @deprecated use {@link #getAddressCountLong()} instead */ @Deprecated public int getAddressCount() { long countLong = getAddressCountLong(); if (countLong > Integer.MAX_VALUE) { throw new RuntimeException("Count is larger than an integer: " + countLong); } // N.B. cannot be negative return (int)countLong; }
/** * Get the count of available addresses. * Will be zero for CIDR/31 and CIDR/32 if the inclusive flag is false. * @return the count of addresses, may be zero. * @throws RuntimeException if the correct count is greater than {@code Integer.MAX_VALUE} * @deprecated use {@link #getAddressCountLong()} instead */ @Deprecated public int getAddressCount() { long countLong = getAddressCountLong(); if (countLong > Integer.MAX_VALUE) { throw new RuntimeException("Count is larger than an integer: " + countLong); } // N.B. cannot be negative return (int)countLong; }
/** * {@inheritDoc} * @since 2.2 */ @Override public String toString() { final StringBuilder buf = new StringBuilder(); buf.append("CIDR Signature:\t[").append(getCidrSignature()).append("]") .append(" Netmask: [").append(getNetmask()).append("]\n") .append("Network:\t[").append(getNetworkAddress()).append("]\n") .append("Broadcast:\t[").append(getBroadcastAddress()).append("]\n") .append("First Address:\t[").append(getLowAddress()).append("]\n") .append("Last Address:\t[").append(getHighAddress()).append("]\n") .append("# Addresses:\t[").append(getAddressCount()).append("]\n"); return buf.toString(); } }
/** * Get the count of available addresses. * Will be zero for CIDR/31 and CIDR/32 if the inclusive flag is false. * @return the count of addresses, may be zero. * @throws RuntimeException if the correct count is greater than {@code Integer.MAX_VALUE} * @deprecated use {@link #getAddressCountLong()} instead */ @Deprecated public int getAddressCount() { long countLong = getAddressCountLong(); if (countLong > Integer.MAX_VALUE) { throw new RuntimeException("Count is larger than an integer: " + countLong); } // N.B. cannot be negative return (int)countLong; }
/** * {@inheritDoc} * @since 2.2 */ @Override public String toString() { final StringBuilder buf = new StringBuilder(); buf.append("CIDR Signature:\t[").append(getCidrSignature()).append("]") .append(" Netmask: [").append(getNetmask()).append("]\n") .append("Network:\t[").append(getNetworkAddress()).append("]\n") .append("Broadcast:\t[").append(getBroadcastAddress()).append("]\n") .append("First Address:\t[").append(getLowAddress()).append("]\n") .append("Last Address:\t[").append(getHighAddress()).append("]\n") .append("# Addresses:\t[").append(getAddressCount()).append("]\n"); return buf.toString(); } }
public int getAddressAsInteger() { return address(); }
public String getBroadcastAddress() { return format(toArray(broadcast())); }
public String getBroadcastAddress() { return format(toArray(broadcast())); }
public int getAddressAsInteger() { return address(); }
public int getAddressAsInteger() { return address(); }
public String getBroadcastAddress() { return format(toArray(broadcast())); }
protected String encodeIPv4() { SubnetV4Utils su = new SubnetV4Utils(low, size); return su.getInfo().getAddress(); }
public String getBroadcastAddress() { return format(toArray(broadcast())); }
private int low() { return (isInclusiveHostCount() ? network() : broadcastLong() - networkLong() > 1 ? network() + 1 : 0); }
protected String encodeIPv4() { SubnetV4Utils su = new SubnetV4Utils(low, size); return su.getInfo().getAddress(); }
public int getAddressAsInteger() { return address(); }