package com.eactive.eai.adapter.socket2.common;

import com.eactive.eai.adapter.socket2.protocol.ByteMessage;


public class HexUtil {
	private HexUtil() {
		
	}
	public static byte[] string2Hex(String line)  {
		
		ByteMessage m = new ByteMessage();
		
		while(line.indexOf("0x") != -1) {
			m.append(line.substring(0, line.indexOf("0x")));
			String hex = line.substring(line.indexOf("0x"), line.indexOf("0x")+4);	
			m.append((byte) Integer.parseInt(hex.substring(2), 16));
			line = line.substring(line.indexOf("0x")+4);				
		}
		m.append(line);
		return m.getBytes();
	}
}
