package gov.nih.nci.ncia.util;

import java.text.DecimalFormat;
import java.text.NumberFormat;

/**
 * Util class for Ultrasound process
 * 
 * @author zhoujim
 *
 */
public class UltrasoundUtil {

public static final int[] MASKS = {0x0001, 0x0002, 0x0004, 0x0008, 0x0010, 0x0020,0x0040, 0x0100, 0x0200};
	
	public static String getMultiModalityByCode(String code)
	{
		NumberFormat nf = new DecimalFormat("#0000");
	    int intCode = Integer.valueOf(code, 16);
	    StringBuffer buff = new StringBuffer();
	    for(int i=0; i< MASKS.length;i++) {
	         if((MASKS[i] & intCode) > 0) {
	        	 String s = Integer.toString(MASKS[i],16);
	        	 long l = Long.parseLong(s);
	        	 buff.append(nf.format(l)+",");
	         }
	   }
	   String result = buff.toString(); 
	  return result.substring(0,result.length()-1);
	}
	
	public static void main(String[] args) {
		String result = getMultiModalityByCode("0011");
		System.out.println("result: " + result );
	}
}

@@ -139,17 +139,16 @@
 cess%0D%0A *
- 
 %0D%0A * @au
@@ -311,17 +311,16 @@
 0200%7D;%0D%0A
-%09
 %0D%0A%09publi
@@ -731,17 +731,43 @@
 ormat(l)
-+
+);%0D%0A%09        %09 buff.append(
 %22,%22);%0D%0A%09
@@ -825,14 +825,14 @@
 g();
- 
 %0D%0A%09  
+ 
 retu
@@ -878,17 +878,16 @@
 );%0D%0A%09%7D%0D%0A
-%09
 %0D%0A%09publi

fix pmd complaint about string buff use