Jtest logo




Contents  Previous  Next  Index

INTER.CLO


A single character should not be prefixed or followed by a logic operator in an internationalized environment

Description

This rule flags code where a single character is prefixed or followed by a logic operator.

If code contains a single character prefixed or followed by a logic operator, it will not run in an internationalized environment.

Example

 package INTER;
 public class CLO{
   public boolean cmpchar(char ch){
         if (( ch >='a' && ch <='z') || (ch >='A' && ch<='Z'))  // 
violation
                return true;
          return false;
        }
    }

Repair

Use the Character comparison methods, which use the Unicode standard to identify character properties. Thus replace the "if" statement above with: ...

 	 if (Character.isLetter(ch)) 
                                 ...

For more information on the Character comparison methods, see the section 'Checking Character Properties' at http://java.sun.com/docs/books/tutorial/i18n/text/charintro.html

Reference

http://java.sun.com/docs/books/tutorial/i18n/intro/checklist.html


Contents  Previous  Next  Index

ParaSoft logo
(888) 305-0041 info@parasoft.com Copyright © 1996-2001 ParaSoft