Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Adding PIN message sending feature #81

Open
wants to merge 2 commits into from

3 participants

@ali-irawan

adding PIN message sending feature

@jeffheifetz

Hi Ali,

First off you will need to sign your CLAs. An IICL for you and a CCLA for your company if you work for one. You can find more details here - http://blackberry.github.com/howToContribute.html

@jeffheifetz jeffheifetz commented on the diff
...java/blackberry/messaging/message/MessageUtility.java
((5 lines not shown))
+ /**
+ * Check whether the address given is PIN address.
+ * PIN Address is in hexadecimal format [ 0-9, A-F ]
+ *
+ * @param address address to be check
+ * @return true when the address is a PIN address
+ */
+ public static boolean isPIN ( String address ) {
+ char[] check = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
+
+ // PIN should in 8 length string
+ if(address.length()!=8) return false;
+ for(int i=0;i<address.length();i++){
+ boolean pass = false;
+ for(int j=0;j<check.length;j++){
+ if(address.charAt(i)==check[j]){

Just wondering if you had considered an algorithm comparing ASCII codes ( for fewer comparisons) or regular expressions?

Yup. I have considered that. Since I don't need to compare all characters I not prefer to use regex at all.
Well thanks for the information about the IICL. I'll review the document. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 12, 2011
  1. @ali-irawan

    Adding more comments

    ali-irawan authored
This page is out of date. Refresh to see the latest.
View
35 api/messaging/src/main/java/blackberry/messaging/message/MessageUtility.java
@@ -19,8 +19,9 @@
import net.rim.blackberry.api.mail.Address;
import net.rim.blackberry.api.mail.AddressException;
-import net.rim.blackberry.api.mail.Message;
import net.rim.blackberry.api.mail.Folder;
+import net.rim.blackberry.api.mail.Message;
+import net.rim.blackberry.api.mail.PINAddress;
import net.rim.blackberry.api.mail.Store;
/**
@@ -312,7 +313,12 @@ private static int min( int end, int b ) {
for( int i = 0; i < emails.length; i++ ) {
try {
- addresses[ i ] = new Address( emails[ i ], emails[ i ] );
+ // Check if PIN address, use PINAddress instead of Address
+ if(MessageUtility.isPIN (emails[i])){
+ addresses[ i ] = new PINAddress( emails[ i ], emails[ i ]);
+ } else {
+ addresses[ i ] = new Address( emails[ i ], emails[ i ] );
+ }
} catch( AddressException e ) {
addresses[ i ] = null;
}
@@ -320,4 +326,29 @@ private static int min( int end, int b ) {
return addresses;
}
+
+ /**
+ * Check whether the address given is PIN address.
+ * PIN Address is in hexadecimal format [ 0-9, A-F ]
+ *
+ * @param address address to be check
+ * @return true when the address is a PIN address
+ */
+ public static boolean isPIN ( String address ) {
+ char[] check = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
+
+ // PIN should in 8 length string
+ if(address.length()!=8) return false;
+ for(int i=0;i<address.length();i++){
+ boolean pass = false;
+ for(int j=0;j<check.length;j++){
+ if(address.charAt(i)==check[j]){

Just wondering if you had considered an algorithm comparing ASCII codes ( for fewer comparisons) or regular expressions?

Yup. I have considered that. Since I don't need to compare all characters I not prefer to use regex at all.
Well thanks for the information about the IICL. I'll review the document. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ pass = true;
+ break;
+ }
+ }
+ if(!pass) return false;
+ }
+ return true;
+ }
}
Something went wrong with that request. Please try again.