Change the formula token logic to java codes