Go through the problems and solutions found by code of a telecom BSS System

Source: Internet
Author: User

===
* Error code: * correct code:

If (string) RS [4]). Equals ("C "))...{
//
}

 

If ("C". Equals (string) RS [4])... {
//
}

* Cause: Rs [4] may be null, leading to Null Object Reference and throwing an exception.

===
Code optimization

* Original code: * replace:
Cpvo. setprodtype (staticparameters. getproducttype (RS [4]);

If (string) RS [4]). Equals ("C "))...{
Cpvo. setprodtype ("general products ");
}
Else if (string) RS [4]). Equals ("S "))...{
Cpvo. setprodtype ("solution ");
}
Else
Cpvo. setprodtype (string) RS [4]);

 

The definition class staticparameters. See the staticparameters. Java file.
Other static parameters have similar problems, such as binding a flag.

* Code:

Import java. util. hashmap;
Import java. util. Map;

Public class staticparameters
...{
Private Static map producttypes = NULL;
 
Static ...{
// Initialize a set of Static Parameters
Initproducttypes ();
}
 
Private Static void initproducttypes ()
...{
If (producttypes = NULL)
...{
Producttypes = new hashmap ();
Producttypes. Put ("C", "General Products ");
Producttypes. Put ("S", "solution ");
}
}

Public static string getproducttype (string code)
...{
String value = (string) producttypes. Get (CODE );
Return Value = NULL? Code: value;
}
}

 
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.