Package com.cybozu.vmbkp.config

Examples of com.cybozu.vmbkp.config.Parser


    {
        if (str.isEmpty()) {
            return Type.NULLSTRING;
        }
       
        Parser p = new Parser(str);

        /* basic string */
        p.reset();
        if (p.parseBSTRING() != null && p.isEnd()) {
            return Type.BSTRING;
        }

        /* normal string */
        p.reset();
        if (p.parseNSTRING() != null && p.isEnd()) {
            return Type.NSTRING;
        }

        /* quated string */
        return Type.QSTRING;
View Full Code Here


    {
        if (str.isEmpty()) {
            return toQuatedString(str);
        }
       
        Parser p = new Parser(str);

        /* basic string */
        p.reset();
        if (p.parseBSTRING() != null && p.isEnd()) {
            return str;
        }

        /* normal string */
        p.reset();
        if (p.parseNSTRING() != null && p.isEnd()) {
            return str;
        }

        /* quated string */
        return toQuatedString(str);
View Full Code Here

     */
    public static String toUnquatedString(String str)
    {
        if (str.isEmpty()) { return str; }
       
        Parser p = new Parser(str);
        p.reset();
        if (p.parseQSTRING() != null && p.isEnd()) {
            String ret = str.substring(1, str.length() - 1);
            ret = ret.replaceAll("\\\\\"", "\"");
            return ret;
        } else {
            return str;
View Full Code Here

    /**
     * Check a given string is an integer value or not.
     */
    public static boolean isInteger(String val)
    {
        Parser p = new Parser(val);
        String ret = p.parseInteger();
        if (ret != null && p.isEnd()) {
            return true;
        } else {
            return false;
        }
    }
View Full Code Here

    {
        if (! isInteger(val)) {
            return (-1L);
        }

        Parser p = new Parser(val);

        String iStr = p.parseNINT();
        if (iStr.charAt(0) == '+') {
            iStr = iStr.substring(1);
        }
        long i = Long.parseLong(iStr);
       
        if (p.isEnd()) {
            /* NINT */
            return i;
        } else {
            /* EXINT */
            Character uChar = p.parseINTUNIT();
            char u = Character.toUpperCase(uChar.charValue());

            long unit = 1L;
            switch (u) {
            case 'K':
                unit = 1024L; break;
            case 'M':
                unit = 1024L * 1024L; break;
            case 'G':
                unit = 1024L * 1024L * 1024L; break;
            case 'T':
                unit = 1024L * 1024L * 1024L * 1024L; break;
            case 'P':
                unit = 1024L * 1024L * 1024L * 1024L * 1024L; break;
            default:
                return (-1L);
            }

            if (! p.isEnd()) { return (-1L); }

            long ret = i * unit;
            /* check overflow */
            if (ret / i == unit && ret / unit == i) {
                return ret;
View Full Code Here

     *
     * @return '+' or '-' or null.
     */
    public static Character getSign(String val)
    {
        Parser p = new Parser(val);
        return p.parseSIGN();
    }
View Full Code Here

    /**
     * Check a given string is a boolean value or not.
     */
    public static boolean isBool(String val)
    {
        Parser p = new Parser(val);

        if (p.parseBOOL() != null && p.isEnd()) {
            return true;
        } else {
            return false;
        }
    }
View Full Code Here

     *
     * @return boolean value in success, false in failure.
     */
    public static boolean toBool(String val)
    {
        Parser p = new Parser(val);
       
        String t = p.parseTRUE();
        if (t != null && p.isEnd()) {
            return true;
        }
       
        p.reset();
        String f = p.parseFALSE();
        if (f != null && p.isEnd()) {
            return false;
        }

        /* Parse failed. */
        return false;
View Full Code Here

                                 (new InputStreamReader(System.in)));

            String line;
            while ((line = in.readLine()) != null) {
                System.out.println(line); //debug
                Parser p = new Parser(line);
                Context c = p.getContext();

                if (c == null) {
                    System.out.println("NULL");
                } else {
View Full Code Here

TOP

Related Classes of com.cybozu.vmbkp.config.Parser

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.