/** Checks if the header field is null and if not, creates it. */ private void checkHeader() { if (header == null) { header = new PDUHeader(); } }
public int getCommandId() { return header == null ? 0 : header.getCommandId(); }
public int getCommandLength() { return header == null ? 0 : header.getCommandLength(); }
public ByteBuffer getData() { ByteBuffer buffer = new ByteBuffer(); buffer.appendInt(getCommandLength()); buffer.appendInt(getCommandId()); buffer.appendInt(getCommandStatus()); buffer.appendInt(getSequenceNumber()); return buffer; }
PDUHeader header = new PDUHeader(); try { header.setData(headerBuf); } catch (NotEnoughDataInByteBufferException e) { if (buffer.length() < header.getCommandLength()) { PDU pdu = createPDU(header.getCommandId()); if (pdu != null) { thisMessageBuffer = buffer.removeBuffer(header.getCommandLength()); } catch (NotEnoughDataInByteBufferException e) {} // can't fail pdu.setData(thisMessageBuffer);
public int getCommandStatus() { return header == null ? 0 : header.getCommandStatus(); }
public int getSequenceNumber() { return header == null ? 0 : header.getSequenceNumber(); } }
/** * Sets the command status, i.e. error status of the PDU. */ public void setCommandStatus(int cmdStatus) { checkHeader(); header.setCommandStatus(cmdStatus); }
/** * Parses the header from the buffer. * Also sets the flag that the sequence number was changed as it was read * from the binary buffer. * @param buffer the buffer which contains the PDU * @see PDUHeader#setData(ByteBuffer) */ private void setHeader(ByteBuffer buffer) throws NotEnoughDataInByteBufferException { checkHeader(); header.setData(buffer); sequenceNumberChanged = true; }
/** Creates the binary PDU header from the header fields of the PDU. */ private ByteBuffer getHeader() { checkHeader(); return header.getData(); }
/** * Sets the length of the PDU. Don't do it manually, it won't have * any wffect. */ public void setCommandLength(int cmdLen) { checkHeader(); header.setCommandLength(cmdLen); }
/** Sets the command id. */ public void setCommandId(int cmdId) { checkHeader(); header.setCommandId(cmdId); }
/** Returns the command status of the PDU. */ public int getCommandStatus() { checkHeader(); return header.getCommandStatus(); }
/** * Returns the sequence number of the PDU. * If the PDU is created by yourself and not parsed from binary data * received from SMSC, then the sequence number will be very likely * incorrect until you didn't set it previously by calling function * <code>assignSequenceNumber</code> or <code>setSequenceNumber</code>. * @see #assignSequenceNumber() * @see #setSequenceNumber(int) */ public int getSequenceNumber() { checkHeader(); return header.getSequenceNumber(); }
/** * Returns the command id of the PDU object. * The command id can be either read from the binary data received from SMSC * or can be set by derived class as the command id of the PDU which is * represented by the class. */ public int getCommandId() { checkHeader(); return header.getCommandId(); }
/** * Returns the length of this PDU. * The length is only valid if you probe the PDU which was parsed from * binary data received from SMSC. If you created the PDU and filled in the * filds of the PDU, the length returned by this function will be very * likely incorrect. */ public int getCommandLength() { checkHeader(); return header.getCommandLength(); }