package testopencv;


/*
 */
public class StringHelper {
	   public static float n2f(Object d) {
	        float i = 0;
	        if (d != null) {
	            String dual = d.toString().trim();
	            try {
	                i = new Float(dual).floatValue();
	            } catch (Exception e) {
	                System.out.println("Unable to find integer value");
	            }
	        }
	        return i;
	    }

	 
	public static String n2s(String d) {
		String dual = "";
		if (d == null) {
			dual = "";
		} else
			dual = d.toString().trim();

		return dual;
	}


	
	public static String n2s(Object d) {
		String dual = "";
		if (d == null) {
			dual = "";
		} else
			dual = d.toString().trim();

		return dual;
	}

	public static float nullObjectToFloatEmpty(Object d) {
		float i = 0;
		if (d != null) {
			String dual = d.toString().trim();
			try {
				i = new Float(dual).floatValue();
			} catch (Exception e) {
				System.out.println("Unable to find integer value");
			}
		}
		return i;
	}
	public static double n2d(Object d) {
		double i = 0;
		if (d != null) {
			String dual = d.toString().trim();
			try {
				i = new Double(dual).intValue();
			} catch (Exception e) {
				System.out.println("Unable to find integer value");
			}
		}
		return i;
	}

    public static int count=0;
	public static int n2i(Object d) {
		int i = 0;
		if (d != null) {
			String dual = d.toString().trim();
			try {
				i = new Integer(dual).intValue();
			} catch (Exception e) {
count++;
				System.out.println("Unable to find integer value For "+d+" "+count);
			}
		}
		return i;
	}
	
}
