/protocols/smpp/src/main/java/org/mobicents/protocols/smpp/message/QuerySM.java
http://mobicents.googlecode.com/ · Java · 113 lines · 67 code · 17 blank · 29 comment · 3 complexity · c905df47ecde20eb016f7744bd7678f7 MD5 · raw file
- /*
- * JBoss, Home of Professional Open Source
- * Copyright 2011, Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
- package org.mobicents.protocols.smpp.message;
- import java.io.IOException;
- import org.mobicents.protocols.smpp.Address;
- import org.mobicents.protocols.smpp.util.PacketDecoder;
- import org.mobicents.protocols.smpp.util.PacketEncoder;
- import org.mobicents.protocols.smpp.version.SMPPVersion;
- /**
- * Query the state of a message.
- *
- * @version $Id: QuerySM.java 457 2009-01-15 17:37:42Z orank $
- */
- public class QuerySM extends SMPPPacket {
- private static final long serialVersionUID = 2L;
-
- private String messageId;
- private Address source;
-
- /**
- * Construct a new QuerySM.
- */
- public QuerySM() {
- super(CommandId.QUERY_SM);
- }
-
- public String getMessageId() {
- return messageId;
- }
- public void setMessageId(String messageId) {
- this.messageId = messageId;
- }
- public Address getSource() {
- return source;
- }
- public void setSource(Address source) {
- this.source = source;
- }
- @Override
- public boolean equals(Object obj) {
- boolean equals = super.equals(obj);
- if (equals) {
- QuerySM other = (QuerySM) obj;
- equals |= safeCompare(messageId, other.messageId);
- equals |= safeCompare(source, other.source);
- }
- return equals;
- }
-
- @Override
- public int hashCode() {
- int hc = super.hashCode();
- hc += (messageId != null) ? messageId.hashCode() : 0;
- hc += (source != null) ? source.hashCode() : 0;
- return hc;
- }
- @Override
- protected void toString(StringBuilder buffer) {
- buffer.append("messageId=").append(messageId)
- .append(",source=").append(source);
- }
- @Override
- protected void validateMandatory(SMPPVersion smppVersion) {
- smppVersion.validateMessageId(messageId);
- smppVersion.validateAddress(source);
- }
-
- @Override
- protected void readMandatory(PacketDecoder decoder) {
- messageId = decoder.readCString();
- source = decoder.readAddress();
- }
- @Override
- protected void writeMandatory(PacketEncoder encoder) throws IOException {
- encoder.writeCString(messageId);
- encoder.writeAddress(source);
- }
-
- @Override
- protected int getMandatorySize() {
- return 1 + sizeOf(messageId) + sizeOf(source);
- }
- }