Hi Christ,

Jira created.  #CAMEL-6655.


I think I have messed up the code in my last post and revised the method as
below.  Kindly check and advise if this can work.

/*
    <p>Since it is vendor specified, so users must have the code and type,
         therefore users should concatenate these information as a string
         using a separator(":") and pass this in as the Entry's value
    </p>
    <p>Usage: Entry<String, String>
                   String key must equal
 "VENDOR_SPECIFIC_OPTIONAL_PARAMETER"
                   String value should be "code:type:param_value"
*/
   protected OptionalParameter generateVendorSpecificOptParam(Entry<String,
String> entry)
           throws SecurityException, IllegalArgumentException,
IllegalAccessException{

           OptionalParameter optParam = null ;

       String valueStr = (String)entry.getValue() ;
       String[] inputStr = valueStr.split(":", 3) ;     
       short code = Short.parseShort(inputStr[0]) ;
  //code must fall inside the ranges specified in SMPP 3.4 specification
  //0x1400 - 0x3FFF
             if ( !(code >= 0x1400 or code <= 0x3FFF)
                  throw new IllegalArgumentException() ;

  //type must be one of the defined Class and must be in uppercase

        String type = inputStr[1] ;
        if ( type.equals("OCTETSTRING") ){
                 optParam = new OptionalParameter.OctetString(code,
inputStr[2]) ;           
        }else if (type.equals("COCTETSTRING") ) {
                 optParam = new OptionalParameter.COctetString(code,
inputStr[2]) ; 
        }else if(type.equals("BYTE") ){
                 optParam = new OptionalParameter.Byte(code,
Byte.valueOf(inputStr[2])) ; 
        }else if (type.equals("INT") ){
                optParam = new OptionalParameter.Int(code,
Integer.valueOf(inputStr[2]));
        }else if (type.equals("SHORT") ) {
                optParam = new OptionalParameter.Short(code,
Short.valueOf(inputStr[2]));
        }else if (type.equals("NULL") )
                optParam = new OptionalParameter.Null(code);
        }else
                throw new IllegualArgumentException() ;
        }
             return optParam ;
   } 





--
View this message in context: 
http://camel.465427.n5.nabble.com/How-to-add-Vendor-Specific-Optional-Parameter-in-CamelSmppOptionalParameters-tp5737268p5737639.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to