src/main/java/tinyrtpl/Rtpl.java
private static Data evalTokenList(TokenList tl) {
        if (tl.type == 1) return null;
        if (tl.type == 2) return (Data) (tl.data);
        for (int i = 0, len = tl.size(); i < len; i++) {
            if (tl.get(i).type == 0)
                tl.set(i, 2, evalTokenList(tl.get(i)));
        }
        if (tl.size() == 1) {
            tl = tl.get(0);
            return evalTokenList(tl);
        }

        boolean useAviator = true;
        if (useAviator) {//TODO
            String exp = tl.toString();
            Object result = AviatorEvaluator.execute(exp);
            if (result instanceof Long) result = Long.toString((Long) result);
            if (result instanceof Boolean) {
                return new Data(result, 1);
            } else if (result instanceof Integer) {
                return new Data(result, 2);
            } else if (result instanceof Float || result instanceof Double) {
                return new Data(result, 3);
            } else if (result instanceof String) {
                String sr = (String) result;
                if (sr.equals("true")) return new Data(true, 1);
                if (sr.equals("false")) return new Data(false, 1);

                try {
                    int vi = Integer.parseInt(sr);
                    return new Data(vi, 2);
                } catch (NumberFormatException ex) {
                    try {
                        double vd = Double.parseDouble(sr);
                        return new Data(vd, 3);
                    } catch (NumberFormatException ex1) {
                        try {
                            float vf = Float.parseFloat(sr);
                            return new Data(new BigDecimal(String.valueOf(vf)).doubleValue(), 3);
                        } catch (NumberFormatException ex2) {
                            return new Data(sr, 4);
                        }
                    }
                }
            } else {
                return new Data(result.toString(), 4);
            }
        } else {
            return Rtpl.calDataExp(tl);
        }
    }
/**
     * Return a Data instance evaluated from tokens.
     * @param tl: tokens
     * @return a Data instance
     */
Return a Data instance evaluated from tokens.
@param tl: tokens
@return a Data instance
Return a Data instance evaluated from tokens . @param tl : tokens @return a Data instance
private static Data evalTokenList(TokenList tl) {
        if (tl.type == 1) return null;
        if (tl.type == 2) return (Data) (tl.data);
        for (int i = 0, len = tl.size(); i < len; i++) {
            if (tl.get(i).type == 0)
                tl.set(i, 2, evalTokenList(tl.get(i)));
        }
        if (tl.size() == 1) {
            tl = tl.get(0);
            return evalTokenList(tl);
        }
        boolean useAviator = true;
        if (useAviator) {
            String exp = tl.toString();
            Object result = AviatorEvaluator.execute(exp);
            if (result instanceof Long) result = Long.toString((Long) result);
            if (result instanceof Boolean) {
                return new Data(result, 1);
            } else if (result instanceof Integer) {
                return new Data(result, 2);
            } else if (result instanceof Float || result instanceof Double) {
                return new Data(result, 3);
            } else if (result instanceof String) {
                String sr = (String) result;
                if (sr.equals("true")) return new Data(true, 1);
                if (sr.equals("false")) return new Data(false, 1);
                try {
                    int vi = Integer.parseInt(sr);
                    return new Data(vi, 2);
                } catch (NumberFormatException ex) {
                    try {
                        double vd = Double.parseDouble(sr);
                        return new Data(vd, 3);
                    } catch (NumberFormatException ex1) {
                        try {
                            float vf = Float.parseFloat(sr);
                            return new Data(new BigDecimal(String.valueOf(vf)).doubleValue(), 3);
                        } catch (NumberFormatException ex2) {
                            return new Data(sr, 4);
                        }
                    }
                }
            } else {
                return new Data(result.toString(), 4);
            }
        } else {
            return Rtpl.calDataExp(tl);
        }
    }
private static Data evalTokenList ( TokenList tl ) { if ( tl . type == 1 ) return null ; if ( tl . type == 2 ) return ( Data ) ( tl . data ) ; for ( int i = 0 , len = tl . size ( ) ; i < len ; i ++ ) { if ( tl . get ( i ) . type == 0 ) tl . set ( i , 2 , evalTokenList ( tl . get ( i ) ) ) ; } if ( tl . size ( ) == 1 ) { tl = tl . get ( 0 ) ; return evalTokenList ( tl ) ; } boolean useAviator = true ; if ( useAviator ) { String exp = tl . toString ( ) ; Object result = AviatorEvaluator . execute ( exp ) ; if ( result instanceof Long ) result = Long . toString ( ( Long ) result ) ; if ( result instanceof Boolean ) { return new Data ( result , 1 ) ; } else if ( result instanceof Integer ) { return new Data ( result , 2 ) ; } else if ( result instanceof Float || result instanceof Double ) { return new Data ( result , 3 ) ; } else if ( result instanceof String ) { String sr = ( String ) result ; if ( sr . equals ( "true" ) ) return new Data ( true , 1 ) ; if ( sr . equals ( "false" ) ) return new Data ( false , 1 ) ; try { int vi = Integer . parseInt ( sr ) ; return new Data ( vi , 2 ) ; } catch ( NumberFormatException ex ) { try { double vd = Double . parseDouble ( sr ) ; return new Data ( vd , 3 ) ; } catch ( NumberFormatException ex1 ) { try { float vf = Float . parseFloat ( sr ) ; return new Data ( new BigDecimal ( String . valueOf ( vf ) ) . doubleValue ( ) , 3 ) ; } catch ( NumberFormatException ex2 ) { return new Data ( sr , 4 ) ; } } } } else { return new Data ( result . toString ( ) , 4 ) ; } } else { return Rtpl . calDataExp ( tl ) ; } }
Return a Data instance evaluated from tokens.
Return a Data instance evaluated from tokens .
//TODO