/** * 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; }
public void setSourceAddr(String address) throws WrongLengthOfStringException { setSourceAddr(new Address(address)); } public void setSourceAddr(byte ton, byte npi, String address) throws WrongLengthOfStringException {
public void setAddress(String address, int maxAddressLength) throws WrongLengthOfStringException { checkCString(address, maxAddressLength); this.maxAddressLength = maxAddressLength; this.address = address; }
public Address(byte ton, byte npi, String address, int maxAddressLength) throws WrongLengthOfStringException { setTon(ton); setNpi(npi); setAddress(address, maxAddressLength); }
public String debugString() { String dbgs = "(addr: "; dbgs += super.debugString(); dbgs += Integer.toString(getTon()); dbgs += " "; dbgs += Integer.toString(getNpi()); dbgs += " "; dbgs += getAddress(); dbgs += ") "; return dbgs; }
/** * Constructor for building the object from <code>SubmitSM</code> * PDU. * * @param systemId system id of the client * @param submit the PDU send from the client */ ShortMessageValue(String systemId, SubmitSM submit) throws UnsupportedEncodingException { this.systemId = systemId; serviceType = submit.getServiceType(); sourceAddr = submit.getSourceAddr().getAddress(); destinationAddr = submit.getDestAddr().getAddress(); String encoding = DataCodingCharsetHandler.getCharsetName(submit.getDataCoding()); shortMessage = submit.getShortMessage(encoding); } }
public void setData(ByteBuffer buffer) throws NotEnoughDataInByteBufferException, TerminatingZeroNotFoundException, WrongLengthOfStringException, WrongDestFlagException { destFlag = buffer.removeByte(); switch (destFlag) { case Data.SM_DEST_SME_ADDRESS : { Address address = new Address(); address.setData(buffer); setAddress(address); break; } case Data.SM_DEST_DL_NAME : { DistributionList dl = new DistributionList(); dl.setData(buffer); setDistributionList(dl); break; } default : { throw new WrongDestFlagException("" + destFlag); } } }
public String debugString() { String dbgs = "(unsucsme: "; dbgs += super.debugString(); dbgs += Integer.toString(getErrorStatusCode()); dbgs += ") "; return dbgs; } }
public void setAddress(String address) throws WrongLengthOfStringException { setAddress(address, maxAddressLength); } public void setAddress(String address, int maxAddressLength) throws WrongLengthOfStringException {
public ByteBuffer getData() { ByteBuffer addressBuf = new ByteBuffer(); addressBuf.appendByte(getTon()); addressBuf.appendByte(getNpi()); try { addressBuf.appendCString(getAddress(), Data.ENC_ASCII); } catch(UnsupportedEncodingException e) { // can't happen, ascii is always supported } return addressBuf; }
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."); } }
public String debugString() { String dbgs = "(data: "; dbgs += super.debugString(); dbgs += getSourceAddr().debugString(); dbgs += " "; dbgs += getDestAddr().debugString(); dbgs += " "; dbgs += debugStringOptional(); dbgs += ") "; return dbgs; } }
ton = getByteProperty("source-ton", sourceAddress.getTon()); npi = getByteProperty("source-npi", sourceAddress.getNpi()); addr = properties.getProperty("source-address", sourceAddress.getAddress()); setAddressParameter("source-address", sourceAddress, ton, npi, addr); ton = getByteProperty("destination-ton", destAddress.getTon()); npi = getByteProperty("destination-npi", destAddress.getNpi()); addr = properties.getProperty("destination-address", destAddress.getAddress()); setAddressParameter("destination-address", destAddress, ton, npi, addr);
/** * 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 void setSourceAddr(String address) throws WrongLengthOfStringException { setSourceAddr(new Address(address)); } public void setSourceAddr(byte ton, byte npi, String address) throws WrongLengthOfStringException {
public String debugString() { String dbgs = "(submit: "; dbgs += super.debugString(); dbgs += getSourceAddr().debugString(); dbgs += " "; dbgs += getDestAddr().debugString(); dbgs += " "; dbgs += shortMessage.debugString(); dbgs += " "; dbgs += debugStringOptional(); dbgs += ") "; return dbgs; } }
ton = getByteProperty("source-ton", sourceAddress.getTon()); npi = getByteProperty("source-npi", sourceAddress.getNpi()); addr = properties.getProperty("source-address", sourceAddress.getAddress()); setAddressParameter("source-address", sourceAddress, ton, npi, addr); ton = getByteProperty("destination-ton", destAddress.getTon()); npi = getByteProperty("destination-npi", destAddress.getNpi()); addr = properties.getProperty("destination-address", destAddress.getAddress()); setAddressParameter("destination-address", destAddress, ton, npi, addr);
/** * 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 void setSourceAddr(byte ton, byte npi, String address) throws WrongLengthOfStringException { setSourceAddr(new Address(ton, npi, address)); }
public String debugString() { String dbgs = "(cancel: "; dbgs += super.debugString(); dbgs += getServiceType(); dbgs += " "; dbgs += getMessageId(); dbgs += " "; dbgs += getSourceAddr().debugString(); dbgs += " "; dbgs += getDestAddr().debugString(); dbgs += ") "; return dbgs; } }