/protocols/smpp/src/main/java/org/mobicents/protocols/smpp/message/Outbind.java
Java | 111 lines | 69 code | 18 blank | 24 comment | 3 complexity | 5fc86ddb2801cadf6c353b8489643e68 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.message; 24 25import java.io.IOException; 26 27import org.mobicents.protocols.smpp.util.PacketDecoder; 28import org.mobicents.protocols.smpp.util.PacketEncoder; 29import org.mobicents.protocols.smpp.version.SMPPVersion; 30 31 32/** 33 * $Id: Outbind.java 457 2009-01-15 17:37:42Z orank $ 34 */ 35public class Outbind extends SMPPPacket { 36 private static final long serialVersionUID = 2L; 37 38 private String systemId; 39 private String password; 40 41 public Outbind() { 42 super(CommandId.OUTBIND); 43 } 44 45 public String getSystemId() { 46 return systemId; 47 } 48 49 public void setSystemId(String systemId) { 50 this.systemId = systemId; 51 } 52 53 public String getPassword() { 54 return password; 55 } 56 57 public void setPassword(String password) { 58 this.password = password; 59 } 60 61 @Override 62 public boolean equals(Object obj) { 63 boolean equals = super.equals(obj); 64 if (equals) { 65 Outbind other = (Outbind) obj; 66 equals |= safeCompare(systemId, other.systemId); 67 equals |= safeCompare(password, other.password); 68 } 69 return equals; 70 } 71 72 @Override 73 public int hashCode() { 74 int hc = super.hashCode(); 75 hc += (systemId != null) ? systemId.hashCode() : 0; 76 hc += (password != null) ? password.hashCode() : 0; 77 return hc; 78 } 79 80 @Override 81 protected void toString(StringBuilder buffer) { 82 buffer.append("systemId=").append(systemId) 83 .append(",password=").append(password); 84 } 85 86 @Override 87 protected void validateMandatory(SMPPVersion smppVersion) { 88 smppVersion.validateSystemId(systemId); 89 smppVersion.validatePassword(password); 90 } 91 92 @Override 93 protected void readMandatory(PacketDecoder decoder) { 94 systemId = decoder.readCString(); 95 password = decoder.readCString(); 96 } 97 98 @Override 99 protected void writeMandatory(PacketEncoder encoder) throws IOException { 100 encoder.writeCString(systemId); 101 encoder.writeCString(password); 102 } 103 104 @Override 105 protected int getMandatorySize() { 106 int length = 2; 107 length += sizeOf(systemId); 108 length += sizeOf(password); 109 return length; 110 } 111}