package market.Qms.function;

/**
 * 
 * @desc   String���͵����ֻ�����ĸת��Ϊ�ʱ�������Ӧ���л���
 * @author meiguiping
 * @date   2010 11:35:45 AM
 */
public class StringFormat 
{	
	public static int	getNumber(String str)	throws Exception
	{
		int	r	=	0;
		str	=	str.toUpperCase();
		
		//string�����Ƿ�����Ҫ��
		if(!str.matches("[A-Z]+") && !str.matches("[0-9]+") )
		{
			throw new Exception("�������ʹ������飡");
		}
		
		if(str.matches("[0-9]+"))
		{
			r	=	Integer.parseInt(str)-1;
			return r;
		}
		
		
		int	len	=	str.length();
		switch(len)
		{
			
			case 0:
				r	=	0;
				break;
			case 1:
				r	=	(int)str.charAt(0)-65;//A��ASCII��ֵΪ65
				break;
			case 2:
				r	=	(int)str.charAt(1)-64+((int)str.charAt(0)-65+25);//����Ϊ2ʱ
//			default:
//				r	=	111;
//				break;
		}	
		return r;
	}
}
