/** * Sets attributes of <code>Address</code> to the provided values. */ private void setAddressParameter(String descr, Address address, byte ton, byte npi, String addr) { address.setTon(ton); address.setNpi(npi); try { address.setAddress(addr); } catch (WrongLengthOfStringException e) { System.out.println("The length of " + descr + " parameter is wrong."); } } }
public Address(byte ton, byte npi, int maxAddressLength) { setTon(ton); setNpi(npi); try { setAddress(Data.DFLT_ADDR, maxAddressLength); } catch (WrongLengthOfStringException e) { throw new Error("Default address value was longer than default max address length."); } }
/** * Sets attributes of <code>Address</code> to the provided values. */ private void setAddressParameter(String descr, Address address, byte ton, byte npi, String addr) { address.setTon(ton); address.setNpi(npi); try { address.setAddress(addr); } catch (WrongLengthOfStringException e) { System.out.println("The length of " + descr + " parameter is wrong."); } } }
public Address(byte ton, byte npi, String address, int maxAddressLength) throws WrongLengthOfStringException { setTon(ton); setNpi(npi); setAddress(address, maxAddressLength); }
public void setData(ByteBuffer buffer) throws NotEnoughDataInByteBufferException, TerminatingZeroNotFoundException, WrongLengthOfStringException { byte ton = buffer.removeByte(); byte npi = buffer.removeByte(); String address = buffer.removeCString(); setAddress(address); setTon(ton); setNpi(npi); }
/** * Prompts the user to enter an address value with specified max length. */ private Address getAddress(String type, Address address, int maxAddressLength) throws WrongLengthOfStringException { byte ton = getParam(type + " address TON", address.getTon()); byte npi = getParam(type + " address NPI", address.getNpi()); String addr = getParam(type + " address", address.getAddress()); address.setTon(ton); address.setNpi(npi); address.setAddress(addr, maxAddressLength); return address; }