PageRenderTime 26ms CodeModel.GetById 14ms app.highlight 8ms RepoModel.GetById 1ms app.codeStats 0ms

/protocols/smpp/src/main/java/org/mobicents/protocols/smpp/message/QueryBroadcastSM.java

http://mobicents.googlecode.com/
Java | 100 lines | 59 code | 15 blank | 26 comment | 3 complexity | fa327bfc99b56cadf4ac35c46826c9ea 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.Address;
 28import org.mobicents.protocols.smpp.util.PacketDecoder;
 29import org.mobicents.protocols.smpp.util.PacketEncoder;
 30
 31/**
 32 * Query the status of a previously submitted broadcast message.
 33 * @version $Id: QueryBroadcastSM.java 457 2009-01-15 17:37:42Z orank $
 34 * @since 0.4.0
 35 */
 36public class QueryBroadcastSM extends SMPPPacket {
 37    private static final long serialVersionUID = 2L;
 38
 39    private String messageId;
 40    private Address source;
 41    
 42    public QueryBroadcastSM() {
 43        super (CommandId.QUERY_BROADCAST_SM);
 44    }
 45
 46    public String getMessageId() {
 47        return messageId;
 48    }
 49
 50    public void setMessageId(String messageId) {
 51        this.messageId = messageId;
 52    }
 53
 54    public Address getSource() {
 55        return source;
 56    }
 57
 58    public void setSource(Address source) {
 59        this.source = source;
 60    }
 61
 62    @Override
 63    public boolean equals(Object obj) {
 64        boolean equals = super.equals(obj);
 65        if (equals) {
 66            QueryBroadcastSM other = (QueryBroadcastSM) obj;
 67            equals |= safeCompare(messageId, other.messageId);
 68            equals |= safeCompare(source, other.source);
 69        }
 70        return equals;
 71    }
 72    
 73    @Override
 74    public int hashCode() {
 75        int hc = super.hashCode();
 76        hc += (messageId != null) ? messageId.hashCode() : 0;
 77        hc += (source != null) ? source.hashCode() : 0;
 78        return hc;
 79    }
 80
 81    @Override
 82    protected void readMandatory(PacketDecoder decoder) {
 83        messageId = decoder.readCString();
 84        source = decoder.readAddress();
 85    }
 86    
 87    @Override
 88    protected void writeMandatory(PacketEncoder encoder) throws IOException {
 89        encoder.writeCString(messageId);
 90        encoder.writeAddress(source);
 91    }
 92    
 93    @Override
 94    protected int getMandatorySize() {
 95        int length = 1;
 96        length += sizeOf(messageId);
 97        length += sizeOf(source);
 98        return length;
 99    }
100}