/** * Compare a given {@link InetAddress} with the current HostAddress * @param address The {@link InetAddress} we want to compare with the HostAddress * @return <tt>true</tt> if they are equal */ public boolean equalsWith(InetAddress address) { if (address == null) { return false; } HostAddress that = new HostAddress(address); return equals(that); }
/** * @see Object#equals(Object) */ @Override public boolean equals(Object other) { if (other == this) { return true; } if (!(other instanceof HostAddress)) { return false; } HostAddress that = (HostAddress) other; return getAddrType() == that.getAddrType() && Arrays.equals(getAddress(), that.getAddress()); }
/** * Creates a new instance of a HostAddress using an {@link InetAddress} * @param inetAddress The {@link InetAddress} to use */ public HostAddress(InetAddress inetAddress) { super(fieldInfos); setAddrType(HostAddrType.ADDRTYPE_INET); setAddress(inetAddress.getAddress()); }
public HostAddress readAddress() throws IOException { int typeValue = readShort(); HostAddrType addrType = HostAddrType.fromValue(typeValue); if (addrType == HostAddrType.NONE) { throw new IOException("Invalid host address type"); } byte[] addrData = readCountedOctets(); if (addrData == null) { throw new IOException("Invalid host address data"); } HostAddress addr = new HostAddress(); addr.setAddrType(addrType); addr.setAddress(addrData); return addr; }
public void addHost(String hostNameOrIpAddress) throws UnknownHostException { InetAddress address = InetAddress.getByName(hostNameOrIpAddress); hostAddresses.add(new HostAddress(address)); }
for (HostAddress hostAddr : hostAddresses) { try { InetAddress iAddr = InetAddress.getByAddress(hostAddr.getAddress()); clientAddresses[i++] = iAddr; } catch (UnknownHostException e) {
/** * Tells if the list of HostAddresses contain a given HostAddress * @param address The {@link InetAddress} we are looking for * @return <tt>true</tt> if it's present */ public boolean contains(InetAddress address) { for (HostAddress hostAddress : getElements()) { if (hostAddress.equalsWith(address)) { return true; } } return false; } }
public HostAddress readAddress() throws IOException { int typeValue = readShort(); HostAddrType addrType = HostAddrType.fromValue(typeValue); if (addrType == HostAddrType.NONE) { throw new IOException("Invalid host address type"); } byte[] addrData = readCountedOctets(); if (addrData == null) { throw new IOException("Invalid host address data"); } HostAddress addr = new HostAddress(); addr.setAddrType(addrType); addr.setAddress(addrData); return addr; }
public void addHost(String hostNameOrIpAddress) throws UnknownHostException { InetAddress address = InetAddress.getByName(hostNameOrIpAddress); hostAddresses.add(new HostAddress(address)); }
/** * Tells if the list of HostAddresses contain a given HostAddress * @param address The {@link InetAddress} we are looking for * @return <tt>true</tt> if it's present */ public boolean contains(InetAddress address) { for (HostAddress hostAddress : getElements()) { if (hostAddress.equalsWith(address)) { return true; } } return false; } }
/** * @see Object#equals(Object) */ @Override public boolean equals(Object other) { if (other == this) { return true; } if (!(other instanceof HostAddress)) { return false; } HostAddress that = (HostAddress) other; return getAddrType() == that.getAddrType() && Arrays.equals(getAddress(), that.getAddress()); }
/** * Compare a given {@link InetAddress} with the current HostAddress * @param address The {@link InetAddress} we want to compare with the HostAddress * @return <tt>true</tt> if they are equal */ public boolean equalsWith(InetAddress address) { if (address == null) { return false; } HostAddress that = new HostAddress(address); return equals(that); }
hostAddresses = new HostAddresses(); for (InetAddress iAddr : clientAddresses) { hostAddresses.add(new HostAddress(iAddr));
/** * Creates a new instance of a HostAddress using an {@link InetAddress} * @param inetAddress The {@link InetAddress} to use */ public HostAddress(InetAddress inetAddress) { super(fieldInfos); setAddrType(HostAddrType.ADDRTYPE_INET); setAddress(inetAddress.getAddress()); }
if ( sessionInfoPriv.getEncPart().getSAddress() == null || !sessionInfoPriv.getEncPart().getSAddress().equalsWith( sAddress ) ) if ( sessionInfoPriv.getEncPart().getRAddress() != null && !sessionInfoPriv.getEncPart().getRAddress().equalsWith( rAddress ) )
/** * @see Object#hashCode() */ @Override public int hashCode() { int hash = 17 + getAddrType().getValue() * 31; if (getAddress() != null) { hash = 31 * hash + Arrays.hashCode(getAddress()); } return hash; } }
/** * @see Object#hashCode() */ @Override public int hashCode() { int hash = 17 + getAddrType().getValue() * 31; if (getAddress() != null) { hash = 31 * hash + Arrays.hashCode(getAddress()); } return hash; } }
public void writeAddress(HostAddress address) throws IOException { write(address.getAddrType().getValue()); write(address.getAddress().length); write(address.getAddress(), 0, address.getAddress().length); }
public void writeAddress(HostAddress address) throws IOException { write(address.getAddrType().getValue()); write(address.getAddress().length); write(address.getAddress(), 0, address.getAddress().length); }