Java 类org.jsoup.parser.TokenQueue 实例源码

项目:gestock    文件:HttpConnection.java   
void processResponseHeaders(Map<String, List<String>> resHeaders) {
    for (Map.Entry<String, List<String>> entry : resHeaders.entrySet()) {
        String name = entry.getKey();
        if (name == null)
            continue; // http/1.1 line

        List<String> values = entry.getValue();
        if (name.equalsIgnoreCase("Set-Cookie")) {
            for (String value : values) {
                if (value == null)
                    continue;
                TokenQueue cd = new TokenQueue(value);
                String cookieName = cd.chompTo("=").trim();
                String cookieVal = cd.consumeTo(";").trim();
                // ignores path, date, domain, validateTLSCertificates et al. req'd?
                // name not blank, value not null
                if (cookieName.length() > 0)
                    cookie(cookieName, cookieVal);
            }
        } else { // only take the first instance of each header
            if (!values.isEmpty())
                header(name, values.get(0));
        }
    }
}
项目:sipsoup    文件:CacheCSSFunction.java   
private void byAttribute() {
    TokenQueue cq = new TokenQueue(tq.chompBalanced('[', ']')); // content queue
    String key = cq.consumeToAny(AttributeEvals); // eq, not, start, end, contain, match, (no val)
    Validate.notEmpty(key);
    cq.consumeWhitespace();

    if (cq.isEmpty()) {
        if (key.startsWith("^"))
            evals.add(new Evaluator.AttributeStarting(key.substring(1)));
        else
            evals.add(new Evaluator.Attribute(key));
    } else {
        if (cq.matchChomp("="))
            evals.add(new Evaluator.AttributeWithValue(key, cq.remainder()));

        else if (cq.matchChomp("!="))
            evals.add(new Evaluator.AttributeWithValueNot(key, cq.remainder()));

        else if (cq.matchChomp("^="))
            evals.add(new Evaluator.AttributeWithValueStarting(key, cq.remainder()));

        else if (cq.matchChomp("$="))
            evals.add(new Evaluator.AttributeWithValueEnding(key, cq.remainder()));

        else if (cq.matchChomp("*="))
            evals.add(new Evaluator.AttributeWithValueContaining(key, cq.remainder()));

        else if (cq.matchChomp("~="))
            evals.add(new Evaluator.AttributeWithValueMatching(key, Pattern.compile(cq.remainder())));
        else
            throw new Selector.SelectorParseException(
                    "Could not parse attribute query '%s': unexpected token at '%s'", query, cq.remainder());
    }
}
项目:sipsoup    文件:CacheCSSFunction.java   
private void contains(boolean own) {
    tq.consume(own ? ":containsOwn" : ":contains");
    String searchText = TokenQueue.unescape(tq.chompBalanced('(', ')'));
    Validate.notEmpty(searchText, ":contains(text) query must not be empty");
    if (own)
        evals.add(new Evaluator.ContainsOwnText(searchText));
    else
        evals.add(new Evaluator.ContainsText(searchText));
}
项目:common    文件:HttpConnection.java   
void processResponseHeaders(Map<String, List<String>> resHeaders) {
    for (Map.Entry<String, List<String>> entry : resHeaders.entrySet()) {
        String name = entry.getKey();
        if (name == null)
            continue; // http/1.1 line

        List<String> values = entry.getValue();
        if (name.equalsIgnoreCase("Set-Cookie")) {
            for (String value : values) {
                if (value == null)
                    continue;
                TokenQueue cd = new TokenQueue(value);
                String cookieName = cd.chompTo("=").trim();
                String cookieVal = cd.consumeTo(";").trim();
                // ignores path, date, domain, validateTLSCertificates et al. req'd?
                // name not blank, value not null
                if (cookieName.length() > 0)
                    cookie(cookieName, cookieVal);
            }
        } else { // combine same header names with comma: http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2
            if (values.size() == 1)
                header(name, values.get(0));
            else if (values.size() > 1) {
                StringBuilder accum = new StringBuilder();
                for (int i = 0; i < values.size(); i++) {
                    final String val = values.get(i);
                    if (i != 0)
                        accum.append(", ");
                    accum.append(val);
                }
                header(name, accum.toString());
            }
        }
    }
}
项目:common    文件:QueryParser.java   
private void byAttribute() {
    TokenQueue cq = new TokenQueue(tq.chompBalanced('[', ']')); // content queue
    String key = cq.consumeToAny(AttributeEvals); // eq, not, start, end, contain, match, (no val)
    Validate.notEmpty(key);
    cq.consumeWhitespace();

    if (cq.isEmpty()) {
        if (key.startsWith("^"))
            evals.add(new Evaluator.AttributeStarting(key.substring(1)));
        else
            evals.add(new Evaluator.Attribute(key));
    } else {
        if (cq.matchChomp("="))
            evals.add(new Evaluator.AttributeWithValue(key, cq.remainder()));

        else if (cq.matchChomp("!="))
            evals.add(new Evaluator.AttributeWithValueNot(key, cq.remainder()));

        else if (cq.matchChomp("^="))
            evals.add(new Evaluator.AttributeWithValueStarting(key, cq.remainder()));

        else if (cq.matchChomp("$="))
            evals.add(new Evaluator.AttributeWithValueEnding(key, cq.remainder()));

        else if (cq.matchChomp("*="))
            evals.add(new Evaluator.AttributeWithValueContaining(key, cq.remainder()));

        else if (cq.matchChomp("~="))
            evals.add(new Evaluator.AttributeWithValueMatching(key, Pattern.compile(cq.remainder())));
        else
            throw new Selector.SelectorParseException("Could not parse attribute query '%s': unexpected token at '%s'", query, cq.remainder());
    }
}
项目:common    文件:QueryParser.java   
private void contains(boolean own) {
    tq.consume(own ? ":containsOwn" : ":contains");
    String searchText = TokenQueue.unescape(tq.chompBalanced('(', ')'));
    Validate.notEmpty(searchText, ":contains(text) query must not be empty");
    if (own)
        evals.add(new Evaluator.ContainsOwnText(searchText));
    else
        evals.add(new Evaluator.ContainsText(searchText));
}
项目:gestock    文件:QueryParser.java   
private void byAttribute() {
    TokenQueue cq = new TokenQueue(tq.chompBalanced('[', ']')); // content queue
    String key = cq.consumeToAny(AttributeEvals); // eq, not, start, end, contain, match, (no val)
    Validate.notEmpty(key);
    cq.consumeWhitespace();

    if (cq.isEmpty()) {
        if (key.startsWith("^"))
            evals.add(new Evaluator.AttributeStarting(key.substring(1)));
        else
            evals.add(new Evaluator.Attribute(key));
    } else {
        if (cq.matchChomp("="))
            evals.add(new Evaluator.AttributeWithValue(key, cq.remainder()));

        else if (cq.matchChomp("!="))
            evals.add(new Evaluator.AttributeWithValueNot(key, cq.remainder()));

        else if (cq.matchChomp("^="))
            evals.add(new Evaluator.AttributeWithValueStarting(key, cq.remainder()));

        else if (cq.matchChomp("$="))
            evals.add(new Evaluator.AttributeWithValueEnding(key, cq.remainder()));

        else if (cq.matchChomp("*="))
            evals.add(new Evaluator.AttributeWithValueContaining(key, cq.remainder()));

        else if (cq.matchChomp("~="))
            evals.add(new Evaluator.AttributeWithValueMatching(key, Pattern.compile(cq.remainder())));
        else
            throw new Selector.SelectorParseException("Could not parse attribute query '%s': unexpected token at '%s'", query, cq.remainder());
    }
}
项目:gestock    文件:QueryParser.java   
private void contains(boolean own) {
    tq.consume(own ? ":containsOwn" : ":contains");
    String searchText = TokenQueue.unescape(tq.chompBalanced('(', ')'));
    Validate.notEmpty(searchText, ":contains(text) query must not be empty");
    if (own)
        evals.add(new Evaluator.ContainsOwnText(searchText));
    else
        evals.add(new Evaluator.ContainsText(searchText));
}
项目:CN1ML-NetbeansModule    文件:HttpConnection.java   
void processResponseHeaders(Map<String, List<String>> resHeaders) {
    for (Map.Entry<String, List<String>> entry : resHeaders.entrySet()) {
        String name = entry.getKey();
        if (name == null)
            continue; // http/1.1 line

        List<String> values = entry.getValue();
        if (name.equalsIgnoreCase("Set-Cookie")) {
            for (String value : values) {
                if (value == null)
                    continue;
                TokenQueue cd = new TokenQueue(value);
                String cookieName = cd.chompTo("=").trim();
                String cookieVal = cd.consumeTo(";").trim();
                if (cookieVal == null)
                    cookieVal = "";
                // ignores path, date, domain, secure et al. req'd?
                // name not blank, value not null
                if (cookieName != null && cookieName.length() > 0)
                    cookie(cookieName, cookieVal);
            }
        } else { // only take the first instance of each header
            if (!values.isEmpty())
                header(name, values.get(0));
        }
    }
}
项目:CN1ML-NetbeansModule    文件:QueryParser.java   
private void byAttribute() {
    TokenQueue cq = new TokenQueue(tq.chompBalanced('[', ']')); // content queue
    String key = cq.consumeToAny(AttributeEvals); // eq, not, start, end, contain, match, (no val)
    Validate.notEmpty(key);
    cq.consumeWhitespace();

    if (cq.isEmpty()) {
        if (key.startsWith("^"))
            evals.add(new Evaluator.AttributeStarting(key.substring(1)));
        else
            evals.add(new Evaluator.Attribute(key));
    } else {
        if (cq.matchChomp("="))
            evals.add(new Evaluator.AttributeWithValue(key, cq.remainder()));

        else if (cq.matchChomp("!="))
            evals.add(new Evaluator.AttributeWithValueNot(key, cq.remainder()));

        else if (cq.matchChomp("^="))
            evals.add(new Evaluator.AttributeWithValueStarting(key, cq.remainder()));

        else if (cq.matchChomp("$="))
            evals.add(new Evaluator.AttributeWithValueEnding(key, cq.remainder()));

        else if (cq.matchChomp("*="))
            evals.add(new Evaluator.AttributeWithValueContaining(key, cq.remainder()));

        else if (cq.matchChomp("~="))
            evals.add(new Evaluator.AttributeWithValueMatching(key, Pattern.compile(cq.remainder())));
        else
            throw new Selector.SelectorParseException("Could not parse attribute query '%s': unexpected token at '%s'", query, cq.remainder());
    }
}
项目:CN1ML-NetbeansModule    文件:QueryParser.java   
private void contains(boolean own) {
    tq.consume(own ? ":containsOwn" : ":contains");
    String searchText = TokenQueue.unescape(tq.chompBalanced('(', ')'));
    Validate.notEmpty(searchText, ":contains(text) query must not be empty");
    if (own)
        evals.add(new Evaluator.ContainsOwnText(searchText));
    else
        evals.add(new Evaluator.ContainsText(searchText));
}
项目:astor    文件:HttpConnection.java   
void processResponseHeaders(Map<String, List<String>> resHeaders) {
    for (Map.Entry<String, List<String>> entry : resHeaders.entrySet()) {
        String name = entry.getKey();
        if (name == null)
            continue; // http/1.1 line

        List<String> values = entry.getValue();
        if (name.equalsIgnoreCase("Set-Cookie")) {
            for (String value : values) {
                if (value == null)
                    continue;
                TokenQueue cd = new TokenQueue(value);
                String cookieName = cd.chompTo("=").trim();
                String cookieVal = cd.consumeTo(";").trim();
                // ignores path, date, domain, validateTLSCertificates et al. req'd?
                // name not blank, value not null
                if (cookieName.length() > 0)
                    cookie(cookieName, cookieVal);
            }
        } else { // combine same header names with comma: http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2
            if (values.size() == 1)
                header(name, values.get(0));
            else if (values.size() > 1) {
                StringBuilder accum = new StringBuilder();
                for (int i = 0; i < values.size(); i++) {
                    final String val = values.get(i);
                    if (i != 0)
                        accum.append(", ");
                    accum.append(val);
                }
                header(name, accum.toString());
            }
        }
    }
}
项目:astor    文件:QueryParser.java   
private void byAttribute() {
    TokenQueue cq = new TokenQueue(tq.chompBalanced('[', ']')); // content queue
    String key = cq.consumeToAny(AttributeEvals); // eq, not, start, end, contain, match, (no val)
    Validate.notEmpty(key);
    cq.consumeWhitespace();

    if (cq.isEmpty()) {
        if (key.startsWith("^"))
            evals.add(new Evaluator.AttributeStarting(key.substring(1)));
        else
            evals.add(new Evaluator.Attribute(key));
    } else {
        if (cq.matchChomp("="))
            evals.add(new Evaluator.AttributeWithValue(key, cq.remainder()));

        else if (cq.matchChomp("!="))
            evals.add(new Evaluator.AttributeWithValueNot(key, cq.remainder()));

        else if (cq.matchChomp("^="))
            evals.add(new Evaluator.AttributeWithValueStarting(key, cq.remainder()));

        else if (cq.matchChomp("$="))
            evals.add(new Evaluator.AttributeWithValueEnding(key, cq.remainder()));

        else if (cq.matchChomp("*="))
            evals.add(new Evaluator.AttributeWithValueContaining(key, cq.remainder()));

        else if (cq.matchChomp("~="))
            evals.add(new Evaluator.AttributeWithValueMatching(key, Pattern.compile(cq.remainder())));
        else
            throw new Selector.SelectorParseException("Could not parse attribute query '%s': unexpected token at '%s'", query, cq.remainder());
    }
}
项目:astor    文件:QueryParser.java   
private void contains(boolean own) {
    tq.consume(own ? ":containsOwn" : ":contains");
    String searchText = TokenQueue.unescape(tq.chompBalanced('(', ')'));
    Validate.notEmpty(searchText, ":contains(text) query must not be empty");
    if (own)
        evals.add(new Evaluator.ContainsOwnText(searchText));
    else
        evals.add(new Evaluator.ContainsText(searchText));
}
项目:astor    文件:HttpConnection.java   
void processResponseHeaders(Map<String, List<String>> resHeaders) {
    for (Map.Entry<String, List<String>> entry : resHeaders.entrySet()) {
        String name = entry.getKey();
        if (name == null)
            continue; // http/1.1 line

        List<String> values = entry.getValue();
        if (name.equalsIgnoreCase("Set-Cookie")) {
            for (String value : values) {
                if (value == null)
                    continue;
                TokenQueue cd = new TokenQueue(value);
                String cookieName = cd.chompTo("=").trim();
                String cookieVal = cd.consumeTo(";").trim();
                // ignores path, date, domain, validateTLSCertificates et al. req'd?
                // name not blank, value not null
                if (cookieName.length() > 0)
                    cookie(cookieName, cookieVal);
            }
        } else { // combine same header names with comma: http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2
            if (values.size() == 1)
                header(name, values.get(0));
            else if (values.size() > 1) {
                StringBuilder accum = StringUtil.stringBuilder();
                for (int i = 0; i < values.size(); i++) {
                    final String val = values.get(i);
                    if (i != 0)
                        accum.append(", ");
                    accum.append(val);
                }
                header(name, accum.toString());
            }
        }
    }
}
项目:astor    文件:QueryParser.java   
private void byAttribute() {
    TokenQueue cq = new TokenQueue(tq.chompBalanced('[', ']')); // content queue
    String key = cq.consumeToAny(AttributeEvals); // eq, not, start, end, contain, match, (no val)
    Validate.notEmpty(key);
    cq.consumeWhitespace();

    if (cq.isEmpty()) {
        if (key.startsWith("^"))
            evals.add(new Evaluator.AttributeStarting(key.substring(1)));
        else
            evals.add(new Evaluator.Attribute(key));
    } else {
        if (cq.matchChomp("="))
            evals.add(new Evaluator.AttributeWithValue(key, cq.remainder()));

        else if (cq.matchChomp("!="))
            evals.add(new Evaluator.AttributeWithValueNot(key, cq.remainder()));

        else if (cq.matchChomp("^="))
            evals.add(new Evaluator.AttributeWithValueStarting(key, cq.remainder()));

        else if (cq.matchChomp("$="))
            evals.add(new Evaluator.AttributeWithValueEnding(key, cq.remainder()));

        else if (cq.matchChomp("*="))
            evals.add(new Evaluator.AttributeWithValueContaining(key, cq.remainder()));

        else if (cq.matchChomp("~="))
            evals.add(new Evaluator.AttributeWithValueMatching(key, Pattern.compile(cq.remainder())));
        else
            throw new Selector.SelectorParseException("Could not parse attribute query '%s': unexpected token at '%s'", query, cq.remainder());
    }
}
项目:astor    文件:QueryParser.java   
private void contains(boolean own) {
    tq.consume(own ? ":containsOwn" : ":contains");
    String searchText = TokenQueue.unescape(tq.chompBalanced('(', ')'));
    Validate.notEmpty(searchText, ":contains(text) query must not be empty");
    if (own)
        evals.add(new Evaluator.ContainsOwnText(searchText));
    else
        evals.add(new Evaluator.ContainsText(searchText));
}
项目:astor    文件:HttpConnection.java   
void processResponseHeaders(Map<String, List<String>> resHeaders) {
    for (Map.Entry<String, List<String>> entry : resHeaders.entrySet()) {
        String name = entry.getKey();
        if (name == null)
            continue; // http/1.1 line

        List<String> values = entry.getValue();
        if (name.equalsIgnoreCase("Set-Cookie")) {
            for (String value : values) {
                if (value == null)
                    continue;
                TokenQueue cd = new TokenQueue(value);
                String cookieName = cd.chompTo("=").trim();
                String cookieVal = cd.consumeTo(";").trim();
                // ignores path, date, domain, validateTLSCertificates et al. req'd?
                // name not blank, value not null
                if (cookieName.length() > 0)
                    cookie(cookieName, cookieVal);
            }
        } else { // combine same header names with comma: http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2
            if (values.size() == 1)
                header(name, values.get(0));
            else if (values.size() > 1) {
                StringBuilder accum = StringUtil.stringBuilder();
                for (int i = 0; i < values.size(); i++) {
                    final String val = values.get(i);
                    if (i != 0)
                        accum.append(", ");
                    accum.append(val);
                }
                header(name, accum.toString());
            }
        }
    }
}
项目:astor    文件:QueryParser.java   
private void byAttribute() {
    TokenQueue cq = new TokenQueue(tq.chompBalanced('[', ']')); // content queue
    String key = cq.consumeToAny(AttributeEvals); // eq, not, start, end, contain, match, (no val)
    Validate.notEmpty(key);
    cq.consumeWhitespace();

    if (cq.isEmpty()) {
        if (key.startsWith("^"))
            evals.add(new Evaluator.AttributeStarting(key.substring(1)));
        else
            evals.add(new Evaluator.Attribute(key));
    } else {
        if (cq.matchChomp("="))
            evals.add(new Evaluator.AttributeWithValue(key, cq.remainder()));

        else if (cq.matchChomp("!="))
            evals.add(new Evaluator.AttributeWithValueNot(key, cq.remainder()));

        else if (cq.matchChomp("^="))
            evals.add(new Evaluator.AttributeWithValueStarting(key, cq.remainder()));

        else if (cq.matchChomp("$="))
            evals.add(new Evaluator.AttributeWithValueEnding(key, cq.remainder()));

        else if (cq.matchChomp("*="))
            evals.add(new Evaluator.AttributeWithValueContaining(key, cq.remainder()));

        else if (cq.matchChomp("~="))
            evals.add(new Evaluator.AttributeWithValueMatching(key, Pattern.compile(cq.remainder())));
        else
            throw new Selector.SelectorParseException("Could not parse attribute query '%s': unexpected token at '%s'", query, cq.remainder());
    }
}
项目:astor    文件:QueryParser.java   
private void contains(boolean own) {
    tq.consume(own ? ":containsOwn" : ":contains");
    String searchText = TokenQueue.unescape(tq.chompBalanced('(', ')'));
    Validate.notEmpty(searchText, ":contains(text) query must not be empty");
    if (own)
        evals.add(new Evaluator.ContainsOwnText(searchText));
    else
        evals.add(new Evaluator.ContainsText(searchText));
}
项目:BoL-API-Parser    文件:HttpConnection.java   
void processResponseHeaders(Map<String, List<String>> resHeaders) {
    for (Map.Entry<String, List<String>> entry : resHeaders.entrySet()) {
        String name = entry.getKey();
        if (name == null)
            continue; // http/1.1 line

        List<String> values = entry.getValue();
        if (name.equalsIgnoreCase("Set-Cookie")) {
            for (String value : values) {
                if (value == null)
                    continue;
                TokenQueue cd = new TokenQueue(value);
                String cookieName = cd.chompTo("=").trim();
                String cookieVal = cd.consumeTo(";").trim();
                if (cookieVal == null)
                    cookieVal = "";
                // ignores path, date, domain, secure et al. req'd?
                // name not blank, value not null
                if (cookieName != null && cookieName.length() > 0)
                    cookie(cookieName, cookieVal);
            }
        } else { // only take the first instance of each header
            if (!values.isEmpty())
                header(name, values.get(0));
        }
    }
}
项目:BoL-API-Parser    文件:QueryParser.java   
private void byAttribute() {
    TokenQueue cq = new TokenQueue(tq.chompBalanced('[', ']')); // content queue
    String key = cq.consumeToAny(AttributeEvals); // eq, not, start, end, contain, match, (no val)
    Validate.notEmpty(key);
    cq.consumeWhitespace();

    if (cq.isEmpty()) {
        if (key.startsWith("^"))
            evals.add(new Evaluator.AttributeStarting(key.substring(1)));
        else
            evals.add(new Evaluator.Attribute(key));
    } else {
        if (cq.matchChomp("="))
            evals.add(new Evaluator.AttributeWithValue(key, cq.remainder()));

        else if (cq.matchChomp("!="))
            evals.add(new Evaluator.AttributeWithValueNot(key, cq.remainder()));

        else if (cq.matchChomp("^="))
            evals.add(new Evaluator.AttributeWithValueStarting(key, cq.remainder()));

        else if (cq.matchChomp("$="))
            evals.add(new Evaluator.AttributeWithValueEnding(key, cq.remainder()));

        else if (cq.matchChomp("*="))
            evals.add(new Evaluator.AttributeWithValueContaining(key, cq.remainder()));

        else if (cq.matchChomp("~="))
            evals.add(new Evaluator.AttributeWithValueMatching(key, Pattern.compile(cq.remainder())));
        else
            throw new Selector.SelectorParseException("Could not parse attribute query '%s': unexpected token at '%s'", query, cq.remainder());
    }
}
项目:BoL-API-Parser    文件:QueryParser.java   
private void contains(boolean own) {
    tq.consume(own ? ":containsOwn" : ":contains");
    String searchText = TokenQueue.unescape(tq.chompBalanced('(', ')'));
    Validate.notEmpty(searchText, ":contains(text) query must not be empty");
    if (own)
        evals.add(new Evaluator.ContainsOwnText(searchText));
    else
        evals.add(new Evaluator.ContainsText(searchText));
}
项目:JabRefAutocomplete    文件:HttpConnection.java   
void processResponseHeaders(Map<String, List<String>> resHeaders) {
    for (Map.Entry<String, List<String>> entry : resHeaders.entrySet()) {
        String name = entry.getKey();
        if (name == null)
            continue; // http/1.1 line

        List<String> values = entry.getValue();
        if (name.equalsIgnoreCase("Set-Cookie")) {
            for (String value : values) {
                if (value == null)
                    continue;
                TokenQueue cd = new TokenQueue(value);
                String cookieName = cd.chompTo("=").trim();
                String cookieVal = cd.consumeTo(";").trim();
                if (cookieVal == null)
                    cookieVal = "";
                // ignores path, date, domain, secure et al. req'd?
                // name not blank, value not null
                if (cookieName != null && cookieName.length() > 0)
                    cookie(cookieName, cookieVal);
            }
        } else { // only take the first instance of each header
            if (!values.isEmpty())
                header(name, values.get(0));
        }
    }
}
项目:JabRefAutocomplete    文件:QueryParser.java   
private void byAttribute() {
    TokenQueue cq = new TokenQueue(tq.chompBalanced('[', ']')); // content queue
    String key = cq.consumeToAny("=", "!=", "^=", "$=", "*=", "~="); // eq, not, start, end, contain, match, (no val)
    Validate.notEmpty(key);
    cq.consumeWhitespace();

    if (cq.isEmpty()) {
        if (key.startsWith("^"))
            evals.add(new Evaluator.AttributeStarting(key.substring(1)));
        else
            evals.add(new Evaluator.Attribute(key));
    } else {
        if (cq.matchChomp("="))
            evals.add(new Evaluator.AttributeWithValue(key, cq.remainder()));

        else if (cq.matchChomp("!="))
            evals.add(new Evaluator.AttributeWithValueNot(key, cq.remainder()));

        else if (cq.matchChomp("^="))
            evals.add(new Evaluator.AttributeWithValueStarting(key, cq.remainder()));

        else if (cq.matchChomp("$="))
            evals.add(new Evaluator.AttributeWithValueEnding(key, cq.remainder()));

        else if (cq.matchChomp("*="))
            evals.add(new Evaluator.AttributeWithValueContaining(key, cq.remainder()));

        else if (cq.matchChomp("~="))
            evals.add(new Evaluator.AttributeWithValueMatching(key, Pattern.compile(cq.remainder())));
        else
            throw new Selector.SelectorParseException("Could not parse attribute query '%s': unexpected token at '%s'", query, cq.remainder());
    }
}
项目:JabRefAutocomplete    文件:QueryParser.java   
private void contains(boolean own) {
    tq.consume(own ? ":containsOwn" : ":contains");
    String searchText = TokenQueue.unescape(tq.chompBalanced('(', ')'));
    Validate.notEmpty(searchText, ":contains(text) query must not be empty");
    if (own)
        evals.add(new Evaluator.ContainsOwnText(searchText));
    else
        evals.add(new Evaluator.ContainsText(searchText));
}
项目:AngelList-Mobile    文件:HttpConnection.java   
void processResponseHeaders(Map<String, List<String>> resHeaders) {
    for (Map.Entry<String, List<String>> entry : resHeaders.entrySet()) {
        String name = entry.getKey();
        if (name == null)
            continue; // http/1.1 line

        List<String> values = entry.getValue();
        if (name.equalsIgnoreCase("Set-Cookie")) {
            for (String value : values) {
                if (value == null)
                    continue;
                TokenQueue cd = new TokenQueue(value);
                String cookieName = cd.chompTo("=").trim();
                String cookieVal = cd.consumeTo(";").trim();
                if (cookieVal == null)
                    cookieVal = "";
                // ignores path, date, domain, secure et al. req'd?
                // name not blank, value not null
                if (cookieName != null && cookieName.length() > 0)
                    cookie(cookieName, cookieVal);
            }
        } else { // only take the first instance of each header
            if (!values.isEmpty())
                header(name, values.get(0));
        }
    }
}
项目:AngelList-Mobile    文件:QueryParser.java   
private void byAttribute() {
    TokenQueue cq = new TokenQueue(tq.chompBalanced('[', ']')); // content queue
    String key = cq.consumeToAny("=", "!=", "^=", "$=", "*=", "~="); // eq, not, start, end, contain, match, (no val)
    Validate.notEmpty(key);
    cq.consumeWhitespace();

    if (cq.isEmpty()) {
        if (key.startsWith("^"))
            evals.add(new Evaluator.AttributeStarting(key.substring(1)));
        else
            evals.add(new Evaluator.Attribute(key));
    } else {
        if (cq.matchChomp("="))
            evals.add(new Evaluator.AttributeWithValue(key, cq.remainder()));

        else if (cq.matchChomp("!="))
            evals.add(new Evaluator.AttributeWithValueNot(key, cq.remainder()));

        else if (cq.matchChomp("^="))
            evals.add(new Evaluator.AttributeWithValueStarting(key, cq.remainder()));

        else if (cq.matchChomp("$="))
            evals.add(new Evaluator.AttributeWithValueEnding(key, cq.remainder()));

        else if (cq.matchChomp("*="))
            evals.add(new Evaluator.AttributeWithValueContaining(key, cq.remainder()));

        else if (cq.matchChomp("~="))
            evals.add(new Evaluator.AttributeWithValueMatching(key, Pattern.compile(cq.remainder())));
        else
            throw new Selector.SelectorParseException("Could not parse attribute query '%s': unexpected token at '%s'", query, cq.remainder());
    }
}
项目:AngelList-Mobile    文件:QueryParser.java   
private void contains(boolean own) {
    tq.consume(own ? ":containsOwn" : ":contains");
    String searchText = TokenQueue.unescape(tq.chompBalanced('(', ')'));
    Validate.notEmpty(searchText, ":contains(text) query must not be empty");
    if (own)
        evals.add(new Evaluator.ContainsOwnText(searchText));
    else
        evals.add(new Evaluator.ContainsText(searchText));
}
项目:jsoup-learning    文件:HttpConnection.java   
void processResponseHeaders(Map<String, List<String>> resHeaders) {
    for (Map.Entry<String, List<String>> entry : resHeaders.entrySet()) {
        String name = entry.getKey();
        if (name == null)
            continue; // http/1.1 line

        List<String> values = entry.getValue();
        if (name.equalsIgnoreCase("Set-Cookie")) {
            for (String value : values) {
                if (value == null)
                    continue;
                TokenQueue cd = new TokenQueue(value);
                String cookieName = cd.chompTo("=").trim();
                String cookieVal = cd.consumeTo(";").trim();
                if (cookieVal == null)
                    cookieVal = "";
                // ignores path, date, domain, secure et al. req'd?
                // name not blank, value not null
                if (cookieName != null && cookieName.length() > 0)
                    cookie(cookieName, cookieVal);
            }
        } else { // only take the first instance of each header
            if (!values.isEmpty())
                header(name, values.get(0));
        }
    }
}
项目:jsoup-learning    文件:QueryParser.java   
private void byAttribute() {
    TokenQueue cq = new TokenQueue(tq.chompBalanced('[', ']')); // content queue
    String key = cq.consumeToAny("=", "!=", "^=", "$=", "*=", "~="); // eq, not, start, end, contain, match, (no val)
    Validate.notEmpty(key);
    cq.consumeWhitespace();

    if (cq.isEmpty()) {
        if (key.startsWith("^"))
            evals.add(new Evaluator.AttributeStarting(key.substring(1)));
        else
            evals.add(new Evaluator.Attribute(key));
    } else {
        if (cq.matchChomp("="))
            evals.add(new Evaluator.AttributeWithValue(key, cq.remainder()));

        else if (cq.matchChomp("!="))
            evals.add(new Evaluator.AttributeWithValueNot(key, cq.remainder()));

        else if (cq.matchChomp("^="))
            evals.add(new Evaluator.AttributeWithValueStarting(key, cq.remainder()));

        else if (cq.matchChomp("$="))
            evals.add(new Evaluator.AttributeWithValueEnding(key, cq.remainder()));

        else if (cq.matchChomp("*="))
            evals.add(new Evaluator.AttributeWithValueContaining(key, cq.remainder()));

        else if (cq.matchChomp("~="))
            evals.add(new Evaluator.AttributeWithValueMatching(key, Pattern.compile(cq.remainder())));
        else
            throw new Selector.SelectorParseException("Could not parse attribute query '%s': unexpected token at '%s'", query, cq.remainder());
    }
}
项目:jsoup-learning    文件:QueryParser.java   
private void contains(boolean own) {
    tq.consume(own ? ":containsOwn" : ":contains");
    String searchText = TokenQueue.unescape(tq.chompBalanced('(', ')'));
    Validate.notEmpty(searchText, ":contains(text) query must not be empty");
    if (own)
        evals.add(new Evaluator.ContainsOwnText(searchText));
    else
        evals.add(new Evaluator.ContainsText(searchText));
}
项目:idylfin    文件:HttpConnection.java   
void processResponseHeaders(Map<String, List<String>> resHeaders) {
    for (Map.Entry<String, List<String>> entry : resHeaders.entrySet()) {
        String name = entry.getKey();
        if (name == null)
            continue; // http/1.1 line

        List<String> values = entry.getValue();
        if (name.equalsIgnoreCase("Set-Cookie")) {
            for (String value : values) {
                if (value == null)
                    continue;
                TokenQueue cd = new TokenQueue(value);
                String cookieName = cd.chompTo("=").trim();
                String cookieVal = cd.consumeTo(";").trim();
                if (cookieVal == null)
                    cookieVal = "";
                // ignores path, date, domain, secure et al. req'd?
                // name not blank, value not null
                if (cookieName != null && cookieName.length() > 0)
                    cookie(cookieName, cookieVal);
            }
        } else { // only take the first instance of each header
            if (!values.isEmpty())
                header(name, values.get(0));
        }
    }
}
项目:idylfin    文件:QueryParser.java   
private void byAttribute() {
    TokenQueue cq = new TokenQueue(tq.chompBalanced('[', ']')); // content queue
    String key = cq.consumeToAny("=", "!=", "^=", "$=", "*=", "~="); // eq, not, start, end, contain, match, (no val)
    Validate.notEmpty(key);
    cq.consumeWhitespace();

    if (cq.isEmpty()) {
        if (key.startsWith("^"))
            evals.add(new Evaluator.AttributeStarting(key.substring(1)));
        else
            evals.add(new Evaluator.Attribute(key));
    } else {
        if (cq.matchChomp("="))
            evals.add(new Evaluator.AttributeWithValue(key, cq.remainder()));

        else if (cq.matchChomp("!="))
            evals.add(new Evaluator.AttributeWithValueNot(key, cq.remainder()));

        else if (cq.matchChomp("^="))
            evals.add(new Evaluator.AttributeWithValueStarting(key, cq.remainder()));

        else if (cq.matchChomp("$="))
            evals.add(new Evaluator.AttributeWithValueEnding(key, cq.remainder()));

        else if (cq.matchChomp("*="))
            evals.add(new Evaluator.AttributeWithValueContaining(key, cq.remainder()));

        else if (cq.matchChomp("~="))
            evals.add(new Evaluator.AttributeWithValueMatching(key, Pattern.compile(cq.remainder())));
        else
            throw new Selector.SelectorParseException("Could not parse attribute query '%s': unexpected token at '%s'", query, cq.remainder());
    }
}
项目:idylfin    文件:QueryParser.java   
private void contains(boolean own) {
    tq.consume(own ? ":containsOwn" : ":contains");
    String searchText = TokenQueue.unescape(tq.chompBalanced('(', ')'));
    Validate.notEmpty(searchText, ":contains(text) query must not be empty");
    if (own)
        evals.add(new Evaluator.ContainsOwnText(searchText));
    else
        evals.add(new Evaluator.ContainsText(searchText));
}
项目:sipsoup    文件:ConsumeToTest.java   
public static void main(String[] args) {
    String testStr = "\"sdfbsdfds,s\"dfs,d";
    TokenQueue tokenQueue = new TokenQueue(testStr);
    System.out.println(tokenQueue.consumeTo(","));
}
项目:common    文件:QueryParser.java   
/**
 * Create a new QueryParser.
 * @param query CSS query
 */
private QueryParser(String query) {
    this.query = query;
    this.tq = new TokenQueue(query);
}
项目:gestock    文件:QueryParser.java   
/**
 * Create a new QueryParser.
 * @param query CSS query
 */
private QueryParser(String query) {
    this.query = query;
    this.tq = new TokenQueue(query);
}
项目:CN1ML-NetbeansModule    文件:QueryParser.java   
/**
 * Create a new QueryParser.
 * @param query CSS query
 */
private QueryParser(String query) {
    this.query = query;
    this.tq = new TokenQueue(query);
}
项目:astor    文件:QueryParser.java   
/**
 * Create a new QueryParser.
 * @param query CSS query
 */
private QueryParser(String query) {
    this.query = query;
    this.tq = new TokenQueue(query);
}