/protocols/smpp/src/main/java/org/mobicents/protocols/smpp/ErrorAddress.java
Java | 113 lines | 38 code | 13 blank | 62 comment | 0 complexity | 50486f0591bb6f07ed3b10ad42fa526b MD5 | raw file
1/* 2 * JBoss, Home of Professional Open Source 3 * Copyright 2011, Red Hat, Inc. and individual contributors 4 * by the @authors tag. See the copyright.txt in the distribution for a 5 * full listing of individual contributors. 6 * 7 * This is free software; you can redistribute it and/or modify it 8 * under the terms of the GNU Lesser General Public License as 9 * published by the Free Software Foundation; either version 2.1 of 10 * the License, or (at your option) any later version. 11 * 12 * This software is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * Lesser General Public License for more details. 16 * 17 * You should have received a copy of the GNU Lesser General Public 18 * License along with this software; if not, write to the Free 19 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 20 * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 21 */ 22 23package org.mobicents.protocols.smpp; 24 25import org.mobicents.protocols.smpp.util.PacketDecoder; 26import org.mobicents.protocols.smpp.util.PacketEncoder; 27 28/** 29 * An address that message submission was unsuccessfully submitted to. This 30 * class is used in the SubmitMultiResp packet type to return a list of SME 31 * addresses that message submission failed for along with an error code for 32 * each address indicating the reason for the failure. 33 * 34 */ 35public class ErrorAddress extends Address { 36 static final long serialVersionUID = 2L; 37 38 /** 39 * The error code showing why this address failed. 40 */ 41 private long error; 42 43 /** 44 * Create a new ErrorAddress object. 45 */ 46 public ErrorAddress() { 47 } 48 49 /** 50 * Create a new ErrorAddress object. 51 * 52 * @param ton 53 * The Type Of Number. 54 * @param npi 55 * The Numbering Plan Indicator. 56 * @param addr 57 * The address. 58 */ 59 public ErrorAddress(int ton, int npi, String addr) { 60 super(ton, npi, addr); 61 } 62 63 /** 64 * Create a new ErrorAddress object. 65 * 66 * @param ton 67 * The Type Of Number. 68 * @param npi 69 * The Numbering Plan Indicator. 70 * @param addr 71 * The address. 72 * @param error 73 * The error code indicating why message submission failed. 74 */ 75 public ErrorAddress(int ton, int npi, String addr, long error) { 76 super(ton, npi, addr); 77 this.error = error; 78 } 79 80 /** 81 * Get the error code associated with this ErrorAddress. 82 */ 83 public long getError() { 84 return error; 85 } 86 87 /** 88 * Set the error code associated with this ErrorAddress. 89 */ 90 public void setError(long error) { 91 this.error = error; 92 } 93 94 public int getLength() { 95 return super.getLength() + 4; 96 } 97 98 public void writeTo(PacketEncoder encoder) throws java.io.IOException { 99 super.writeTo(encoder); 100 encoder.writeUInt4(error); 101 } 102 103 public void readFrom(PacketDecoder decoder) { 104 super.readFrom(decoder); 105 error = decoder.readUInt4(); 106 } 107 108 @Override 109 public String toString() { 110 return new StringBuffer(super.toString()) 111 .append("/Error=").append(error).toString(); 112 } 113}