/** * @return The HostAddrType for this instance */ public HostAddrType getAddrType() { Integer value = getFieldAsInteger(HostAddressField.ADDR_TYPE); return HostAddrType.fromValue(value); }
/** * {@inheritDoc} */ @Override public String getName() { return name(); }
/** * @see Object#hashCode() */ @Override public int hashCode() { int hash = 17 + getAddrType().getValue() * 31; if (getAddress() != null) { hash = 31 * hash + Arrays.hashCode(getAddress()); } return hash; } }
/** * Get the HostAddrType associated with a value. * * @param value The integer value of the HostAddrType we are looking for * @return The associated HostAddrType, or NULL if not found or if value is null */ public static HostAddrType fromValue(Integer value) { if (value != null) { for (EnumType e : values()) { if (e.getValue() == value.intValue()) { return (HostAddrType) e; } } } return HostAddrType.NONE; } }
/** * @see Object#hashCode() */ @Override public int hashCode() { int hash = 17 + getAddrType().getValue() * 31; if (getAddress() != null) { hash = 31 * hash + Arrays.hashCode(getAddress()); } return hash; } }
/** * Get the HostAddrType associated with a value. * * @param value The integer value of the HostAddrType we are looking for * @return The associated HostAddrType, or NULL if not found or if value is null */ public static HostAddrType fromValue(Integer value) { if (value != null) { for (EnumType e : values()) { if (e.getValue() == value.intValue()) { return (HostAddrType) e; } } } return HostAddrType.NONE; } }
/** * @return The HostAddrType for this instance */ public HostAddrType getAddrType() { Integer value = getFieldAsInteger(HostAddressField.ADDR_TYPE); return HostAddrType.fromValue(value); }
public void writeAddress(HostAddress address) throws IOException { write(address.getAddrType().getValue()); write(address.getAddress().length); write(address.getAddress(), 0, address.getAddress().length); }
/** * {@inheritDoc} */ @Override public String getName() { return name(); }
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 writeAddress(HostAddress address) throws IOException { write(address.getAddrType().getValue()); write(address.getAddress().length); write(address.getAddress(), 0, address.getAddress().length); }
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; }