ie.omk.smpp
Class Address

java.lang.Object
  extended by ie.omk.smpp.Address
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
ErrorAddress, SmeAddress

public class Address
extends Object
implements Serializable

Object representing a Short Message Entity's address. An address consists of a Type Of Number, a Numbering Plan Indicator and an address.

See Also:
GSMConstants, Serialized Form

Constructor Summary
Address()
          Create a new Address with all nul values.
Address(int ton, int npi, String address)
          Create a new Address.
 
Method Summary
 boolean equals(Object obj)
          Test for equality.
 String getAddress()
          Get the address.
 int getLength()
          Get the number of bytes this object would encode to.
 int getNPI()
          Get the Numbering Plan Indicator.
 int getTON()
          Get the Type Of Number.
 int hashCode()
          Get a unique hash code for this address.
 void readFrom(byte[] addr, int offset)
          Decode this address from a byte array.
 void setAddress(String address)
          Set the address.
 void setNPI(int npi)
          Set the Numbering Plan Indicator.
 void setTON(int ton)
          Set the Type of Number.
 String toString()
           
 void writeTo(OutputStream out)
          Encode this object as bytes to the output stream.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Address

public Address()
Create a new Address with all nul values. TON will be 0, NPI will be 0 and the address field will be blank.


Address

public Address(int ton,
               int npi,
               String address)
Create a new Address.

Parameters:
ton - The Type Of Number.
npi - The Numbering Plan Indicator.
address - The address.
Method Detail

getTON

public int getTON()
Get the Type Of Number.


setTON

public void setTON(int ton)
Set the Type of Number.


getNPI

public int getNPI()
Get the Numbering Plan Indicator.


setNPI

public void setNPI(int npi)
Set the Numbering Plan Indicator.


getAddress

public String getAddress()
Get the address.


setAddress

public void setAddress(String address)
Set the address.


hashCode

public int hashCode()
Get a unique hash code for this address.

Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Test for equality. Two address objects are equal if their TON, NPI and address fields are equal.

Overrides:
equals in class Object

getLength

public int getLength()
Get the number of bytes this object would encode to.


writeTo

public void writeTo(OutputStream out)
             throws IOException
Encode this object as bytes to the output stream. An address encodes as a single byte for the TON, a single byte for the NPI and a nul-terminated ASCII character string.

Parameters:
out - The output stream to encode the address to.
Throws:
IOException - If an I/O error occurs while writing to the output stream.

readFrom

public void readFrom(byte[] addr,
                     int offset)
Decode this address from a byte array.

Parameters:
addr - The byte array to read the address from.
offset - The offset within the byte array to begin decoding from.
Throws:
ArrayIndexOutOfBoundsException - If the byte array does not contain enough bytes to decode an address.

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2011 smppapi at Sourceforge. All Rights Reserved.