public static String decodeFirstOctet(Pdu pdu) { // Use reflection to check for method signatures hasTpXXX() and getTpXXX() // that are specific to a particular type in actual object StringBuffer sb = new StringBuffer(); sb.append("First Octet: " + PduUtils.byteToPdu(pdu.getFirstOctet())); sb.append(" ["); // TP-MTI switch (pdu.getTpMti()) { case PduUtils.TP_MTI_SMS_DELIVER: sb.append("TP-MTI: (SMS-DELIVER)"); break; case PduUtils.TP_MTI_SMS_STATUS_REPORT: sb.append("TP-MTI: (SMS-STATUS REPORT)"); break; case PduUtils.TP_MTI_SMS_SUBMIT: sb.append("TP-MTI: (SMS-SUBMIT)"); break; default: throw new RuntimeException("Invalid message type"); } // TP-MMS if (hasTpField(pdu, "TpMms") != null) { if (hasTpField(pdu, "TpMms")) { sb.append(", TP-MMS: (Has more messages)"); } else { sb.append(", TP-MMS: (has no messages)"); } } // TP-RD if (hasTpField(pdu, "TpRd") != null) { if (hasTpField(pdu, "TpRd")) { sb.append(", TP-RD: (Reject duplicates)"); } else { sb.append(", TP-RD: (allow duplicates)"); } } // TP-VPF if ((hasTpField(pdu, "TpVpf") != null) && (hasTpField(pdu, "TpVpf") != false)) { switch (getTpField(pdu, "TpVpf")) { case PduUtils.TP_VPF_INTEGER: sb.append(", TP-VPF: (validity format, integer"); break; case PduUtils.TP_VPF_TIMESTAMP: sb.append(", TP-VPF: (validity format, timestamp"); break; case PduUtils.TP_VPF_NONE: sb.append(", TP-VPF: (validity format, none)"); break; } } // TP-SRI if (hasTpField(pdu, "TpSri") != null) { if (hasTpField(pdu, "TpSri")) { sb.append(", TP-SRI: (Requests Status Report)"); } else { sb.append(", TP-SRI: (No Status Report)"); } } // TP-SRR if (hasTpField(pdu, "TpSrr") != null) { if (hasTpField(pdu, "TpSrr")) { sb.append(", TP-SRR: (Requests Status Report)"); } else { sb.append(", TP-SRR: (No Status Report)"); } } // TP-UDHI if (pdu.hasTpUdhi()) { sb.append(", TP-UDHI: (has UDH)"); } else { sb.append(", TP-UDHI: (no UDH)"); } sb.append("]"); sb.append("\n"); return sb.toString(); }