public static String validateAndCreateIMs(ArrayList arrIMLines) throws Exception { String err = ""; String line; String[] result_str; int colIndex; // set array with headers if (arrIMLines.size() > 0) { line = (String) arrIMLines.get(0); // get headers line += ",dummy"; // for supporting method split. result_str = line.split(","); IM.colsNum = result_str.length; for (int i = 0; i < result_str.length; i++) { IM.arrIMLineHeaders.add(result_str[i]); } } for (int i = 1; i < arrIMLines.size(); i++) { // start from 1 to skip header line = (String) arrIMLines.get(i); if ((Util.str(line)).length() == 0) { continue; } line += ",dummy"; // for supporting method split. result_str = line.split(","); Value[] result = Util.attStrToArrValue(result_str); // checlk for length if (result.length != IM.colsNum) { err += "IM, line#" + (i + 1) + ": The number of tokens should be " + IM.colsNum + "\n"; continue; } IM im = new IM(); colIndex = IM.arrIMLineHeaders.indexOf("mcc"); if (colIndex == -1) { throw new Exception("The colomn 'mcc' is missing in the IM file"); } im.mcc = result[colIndex]; im.mcc.pos = i + 1; colIndex = IM.arrIMLineHeaders.indexOf("mnc"); if (colIndex == -1) { throw new Exception("The colomn 'mnc' is missing in the IM file"); } im.mnc = result[colIndex]; colIndex = IM.arrIMLineHeaders.indexOf("operator_name"); if (colIndex == -1) { throw new Exception("The colomn 'operator_name' is missing in the IM file"); } im.operator_name = result[colIndex]; colIndex = IM.arrIMLineHeaders.indexOf("account_type"); if (colIndex == -1) { throw new Exception("The colomn 'account_type' is missing in the IM file"); } im.account_type = result[colIndex]; colIndex = IM.arrIMLineHeaders.indexOf("country_name"); if (colIndex == -1) { throw new Exception("The colomn 'country_name' is missing in the IM file"); } im.country_name = result[colIndex]; colIndex = IM.arrIMLineHeaders.indexOf("Brand_instance_name"); if (colIndex == -1) { throw new Exception("The colomn 'Brand_instance_name' is missing in the IM file"); } im.Brand_instance_name = result[colIndex]; colIndex = IM.arrIMLineHeaders.indexOf("IspProfileName"); if (colIndex == -1) { throw new Exception("The colomn 'IspProfileName' is missing in the IM file"); } im.IspProfileName = result[colIndex]; colIndex = IM.arrIMLineHeaders.indexOf("gprs_access_point_name"); if (colIndex == -1) { throw new Exception("The colomn 'gprs_access_point_name' is missing in the IM file"); } im.gprs_access_point_name = result[colIndex]; colIndex = IM.arrIMLineHeaders.indexOf("ap_requires_auth"); if (colIndex == -1) { throw new Exception("The colomn 'ap_requires_auth' is missing in the IM file"); } im.ap_requires_auth = result[colIndex]; colIndex = IM.arrIMLineHeaders.indexOf("ppp_auth_type"); if (colIndex == -1) { throw new Exception("The colomn 'ppp_auth_type' is missing in the IM file"); } im.ppp_auth_type = result[colIndex]; colIndex = IM.arrIMLineHeaders.indexOf("ppp_auth_name"); if (colIndex == -1) { throw new Exception("The colomn 'ppp_auth_name' is missing in the IM file"); } im.ppp_auth_name = result[colIndex]; colIndex = IM.arrIMLineHeaders.indexOf("ppp_auth_secret"); if (colIndex == -1) { throw new Exception("The colomn 'ppp_auth_secret' is missing in the IM file"); } im.ppp_auth_secret = result[colIndex]; colIndex = IM.arrIMLineHeaders.indexOf("nap_addr_type"); if (colIndex == -1) { throw new Exception("The colomn 'nap_addr_type' is missing in the IM file"); } im.nap_addr_type = result[colIndex]; colIndex = IM.arrIMLineHeaders.indexOf("bearer"); if (colIndex == -1) { throw new Exception("The colomn 'bearer' is missing in the IM file"); } im.bearer = result[colIndex]; colIndex = IM.arrIMLineHeaders.indexOf("ServerAddr"); if (colIndex == -1) { throw new Exception("The colomn 'ServerAddr' is missing in the IM file"); } im.ServerAddr = result[colIndex]; colIndex = IM.arrIMLineHeaders.indexOf("ServerPort"); if (colIndex == -1) { throw new Exception("The colomn 'ServerPort' is missing in the IM file"); } im.ServerPort = result[colIndex]; colIndex = IM.arrIMLineHeaders.indexOf("ClientID"); if (colIndex == -1) { throw new Exception("The colomn 'ClientID' is missing in the IM file"); } im.ClientID = result[colIndex]; colIndex = IM.arrIMLineHeaders.indexOf("PrivateKey1"); if (colIndex == -1) { throw new Exception("The colomn 'PrivateKey1' is missing in the IM file"); } im.PrivateKey1 = result[colIndex]; colIndex = IM.arrIMLineHeaders.indexOf("PrivateKey2"); if (colIndex == -1) { throw new Exception("The colomn 'PrivateKey2' is missing in the IM file"); } im.PrivateKey2 = result[colIndex]; colIndex = IM.arrIMLineHeaders.indexOf("ServerPostURL"); if (colIndex == -1) { throw new Exception("The colomn 'ServerPostURL' is missing in the IM file"); } im.ServerPostURL = result[colIndex]; colIndex = IM.arrIMLineHeaders.indexOf("LoginAutoResetConversation"); if (colIndex == -1) { throw new Exception("The colomn 'LoginAutoResetConversation' is missing in the IM file"); } im.LoginAutoResetConversation = result[colIndex]; colIndex = IM.arrIMLineHeaders.indexOf("ServerCirSupported"); if (colIndex == -1) { throw new Exception("The colomn 'ServerCirSupported' is missing in the IM file"); } im.ServerCirSupported = result[colIndex]; colIndex = IM.arrIMLineHeaders.indexOf("ServerLoginMethod"); if (colIndex == -1) { throw new Exception("The colomn 'ServerLoginMethod' is missing in the IM file"); } im.ServerLoginMethod = result[colIndex]; colIndex = IM.arrIMLineHeaders.indexOf("ServerProxyAddress"); if (colIndex == -1) { throw new Exception("The colomn 'ServerProxyAddress' is missing in the IM file"); } im.ServerProxyAddress = result[colIndex]; colIndex = IM.arrIMLineHeaders.indexOf("ServerProxyPassword"); if (colIndex == -1) { throw new Exception("The colomn 'ServerProxyPassword' is missing in the IM file"); } im.ServerProxyPassword = result[colIndex]; colIndex = IM.arrIMLineHeaders.indexOf("ServerProxyUserName"); if (colIndex == -1) { throw new Exception("The colomn 'ServerProxyUserName' is missing in the IM file"); } im.ServerProxyUserName = result[colIndex]; colIndex = IM.arrIMLineHeaders.indexOf("ServerTransportType"); if (colIndex == -1) { throw new Exception("The colomn 'ServerTransportType' is missing in the IM file"); } im.ServerTransportType = result[colIndex]; colIndex = IM.arrIMLineHeaders.indexOf("ServerSMSDestinationAddress"); if (colIndex == -1) { throw new Exception("The colomn 'ServerSMSDestinationAddress' is missing in the IM file"); } im.ServerSMSDestinationAddress = result[colIndex]; colIndex = IM.arrIMLineHeaders.indexOf("ServSMSCirSup"); if (colIndex == -1) { throw new Exception("The colomn 'ServSMSCirSup' is missing in the IM file"); } im.ServSMSCirSup = result[colIndex]; colIndex = IM.arrIMLineHeaders.indexOf("SvTCPCIRKeepTim"); if (colIndex == -1) { throw new Exception("The colomn 'SvTCPCIRKeepTim' is missing in the IM file"); } im.SvTCPCIRKeepTim = result[colIndex]; colIndex = IM.arrIMLineHeaders.indexOf("SvTCPCIRSup"); if (colIndex == -1) { throw new Exception("The colomn 'SvTCPCIRSup' is missing in the IM file"); } im.SvTCPCIRSup = result[colIndex]; colIndex = IM.arrIMLineHeaders.indexOf("ServerCloseSocketAfterResponse"); if (colIndex == -1) { throw new Exception( "The colomn 'ServerCloseSocketAfterResponse' is missing in the IM file"); } im.ServerCloseSocketAfterResponse = result[colIndex]; colIndex = IM.arrIMLineHeaders.indexOf("AutoRefreshContactList"); if (colIndex == -1) { throw new Exception("The colomn 'AutoRefreshContactList' is missing in the IM file"); } im.AutoRefreshContactList = result[colIndex]; colIndex = IM.arrIMLineHeaders.indexOf("FrbdUnauthoMsgs"); if (colIndex == -1) { throw new Exception("The colomn 'FrbdUnauthoMsgs' is missing in the IM file"); } im.FrbdUnauthoMsgs = result[colIndex]; // validate all data String lineErr = im.validateData(); if (lineErr.length() > 0) { err += "IM, data not valid, line #" + (i + 1) + ": \n" + lineErr + "\n"; } IM.arrIMFromLines.add(im); } return err; }