The algorithm for determining the address type is below. The following
excerpt is taken from PDUUtils.java
The type-of-address is determined by OR'ing 0x80 with the addressType
and number plan.

The algorithm here is actually was built around the circumstances of
the telco networks here in the Philippines.  There are actually other
values for the number plan I think (not sure if there are other
address types as well) but they are not included here.  If there are
differences in the foreign network values let me know and we'll see if
something can be done.

        // ==================================================
        // ADDRESS-TYPE CONSTANTS
        // ==================================================
        // some typical ones used for sending, though receiving may get other
types
        // usually 1 001 0001 (0x91) international format
        //         1 000 0001 (0x81) (unknown) short number (e.g. access
codes)
        //         1 101 0000 (0xD0) alphanumeric (e.g. access code names
like PasaLoad)
        public static final int ADDRESS_NUMBER_PLAN_ID_MASK = 0x0F;

        public static final int ADDRESS_NUMBER_PLAN_ID_UNKNOWN = 0x00;
        public static final int ADDRESS_NUMBER_PLAN_ID_TELEPHONE = 0x01;
        public static final int ADDRESS_TYPE_MASK = 0x70;
        public static final int ADDRESS_TYPE_UNKNOWN = 0x00;
        public static final int ADDRESS_TYPE_INTERNATIONAL = 0x10;
        public static final int ADDRESS_TYPE_ALPHANUMERIC = 0x50;

        public static int getAddressTypeFor(String address)
        {
            boolean international = false;

                // strip any + to simplify checks
            // but presence of + automatically assumes an
            // international style address
                if (address.startsWith("+"))
                {
                    international = true;
                        address = address.substring(1);
                }

                for (int i = 0; i < address.length(); i++)
                {
                        if (!Character.isDigit(address.charAt(i)))
                        {
                                // check if alphanumeric
                                return 
createAddressType(ADDRESS_TYPE_ALPHANUMERIC);
                        }
                }
                // check if 12 digits or plus is used
                // 12 digits is the max length and anything number
                // with this length is already international format
                // if the length is less, the presence of the plus
                // will determine international format or not
                if ((address.length() == 12) || (international))
                {
                    return createAddressType(ADDRESS_TYPE_INTERNATIONAL |
ADDRESS_NUMBER_PLAN_ID_TELEPHONE);
                }
                else
                {
                    return createAddressType(ADDRESS_TYPE_UNKNOWN |
ADDRESS_NUMBER_PLAN_ID_TELEPHONE);
                }
        }

        public static int extractAddressType(int addressType)
        {
                return addressType & ADDRESS_TYPE_MASK;
        }

        public static int extractNumberPlan(int addressType)
        {
                return addressType & ADDRESS_NUMBER_PLAN_ID_MASK;
        }

        public static int createAddressType(int addressType)
        {
                // last bit is always set
                return 0x80 | addressType;
        }





--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"SMSLib Users Group" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/SMSLib?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to