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));
	        	 buff.append(',');
	         }
	   }
	   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 );
	}
}

@@ -370,16 +370,33 @@
 ng code)
+ throws Exception
 %0D%0A%09%7B%0D%0A%09%09
@@ -986,12 +986,13 @@
 de(%22
-0011
+Utltr
 %22);%0D

Use exception if the image is not Ultrasound image.