Java Code Examples for com.libra.Utils#isSpace()

The following examples show how to use com.libra.Utils#isSpace() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ExprCompiler.java    From virtualview_tools with MIT License 6 votes vote down vote up
private boolean isSpace(String str) {
    boolean ret = true;

    if (!TextUtils.isEmpty(str)) {
        int len = str.length();
        for (int i = 0; i < len; ++i) {
            char c = str.charAt(i);
            if (!Utils.isSpace(c)) {
                ret = false;
                break;
            }
        }
    }

    return ret;
}
 
Example 2
Source File: LexParser.java    From virtualview_tools with MIT License 4 votes vote down vote up
public boolean parse(String expr) {
    boolean ret = false;

    if (!TextUtils.isEmpty(expr)) {
        if (null != mListener) {
            mListener.onLexParseStart();

            int len = expr.length();
            Parser curLexer = null;
            int result = Parser.RESULT_FAILED;
            ret = true;
            for (int i = 0; i < len; ++i) {
                char ch = expr.charAt(i);

                if (null == curLexer) {
                    if (!Utils.isSpace(ch)) {
                        for (Parser lexer : mLexers) {
                            result = lexer.addChar(ch);
                            if (Parser.RESULT_FAILED != result) {
                                curLexer = lexer;
                                break;
                            }
                        }
                    } else {
                        continue;
                    }
                } else {
                    result = curLexer.addChar(ch);
                }

                if (null != curLexer) {
                    switch (result) {
                        case Parser.RESULT_FAILED:
                            ret = false;
                            Log.e(TAG, "failed str:" + expr + "  char:" + ch);
                            break;

                        case Parser.RESULT_FINISHED_REMAIN:
                            if (!Utils.isSpace(ch)) {
                                --i;
                            }
                        case Parser.RESULT_FINISHED:
                            Token token = curLexer.getToken();
                            if (null != token) {
                                ret = mListener.onLexParseToken(token);
                            } else {
                                ret = false;
                                Log.e(TAG, "token is null");
                            }

                            curLexer.reset();
                            curLexer = null;
                            break;
                    }
                } else {
                    ret = false;
                    Log.e(TAG, "can not reg char:" + ch);
                    break;
                }

                if (!ret) {
                    if (null != curLexer) {
                        curLexer.reset();
                    }
                    break;
                }
            }

            ret = mListener.onLexParseEnd(ret);
        } else {
            Log.e(TAG, "listener is null");
        }
    } else {
        Log.e(TAG, "str is empty");
    }

    return ret;
}