java.io.StringReader#skip ( )源码实例Demo

下面列出了java.io.StringReader#skip ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: spring-boot-protocol   文件: MediaType.java
static SkipResult skipConstant(StringReader input, String constant) throws IOException {
    int len = constant.length();

    int c = skipLws(input, false);

    for (int i = 0; i < len; i++) {
        if (i == 0 && c == -1) {
            return SkipResult.EOF;
        }
        if (c != constant.charAt(i)) {
            input.skip(-(i + 1));
            return SkipResult.NOT_FOUND;
        }
        if (i != (len - 1)) {
            c = input.read();
        }
    }
    return SkipResult.FOUND;
}
 
源代码2 项目: spring-boot-protocol   文件: MediaType.java
/**
 * @return  the token if one was found, the empty string if no data was
 *          available to read or <code>null</code> if data other than a
 *          token was found
 */
static String readToken(StringReader input) throws IOException {
    StringBuilder result = new StringBuilder();

    int c = skipLws(input, false);

    while (c != -1 && isToken(c)) {
        result.append((char) c);
        c = input.read();
    }
    // Skip back so non-token character is available for next read
    input.skip(-1);

    if (c != -1 && result.length() == 0) {
        return null;
    } else {
        return result.toString();
    }
}
 
源代码3 项目: Tomcat7.0.67   文件: HttpParser.java
private static SkipConstantResult skipConstant(StringReader input,
        String constant) throws IOException {
    int len = constant.length();

    int c = skipLws(input, false);

    for (int i = 0; i < len; i++) {
        if (i == 0 && c == -1) {
            return SkipConstantResult.EOF;
        }
        if (c != constant.charAt(i)) {
            input.skip(-(i + 1));
            return SkipConstantResult.NOT_FOUND;
        }
        if (i != (len - 1)) {
            c = input.read();
        }
    }
    return SkipConstantResult.FOUND;
}
 
源代码4 项目: Tomcat7.0.67   文件: HttpParser.java
/**
 * @return  the token if one was found, the empty string if no data was
 *          available to read or <code>null</code> if data other than a
 *          token was found
 */
private static String readToken(StringReader input) throws IOException {
    StringBuilder result = new StringBuilder();

    int c = skipLws(input, false);

    while (c != -1 && isToken(c)) {
        result.append((char) c);
        c = input.read();
    }
    // Skip back so non-token character is available for next read
    input.skip(-1);

    if (c != -1 && result.length() == 0) {
        return null;
    } else {
        return result.toString();
    }
}
 
源代码5 项目: tomcatsrc   文件: HttpParser.java
private static SkipConstantResult skipConstant(StringReader input,
        String constant) throws IOException {
    int len = constant.length();

    int c = skipLws(input, false);

    for (int i = 0; i < len; i++) {
        if (i == 0 && c == -1) {
            return SkipConstantResult.EOF;
        }
        if (c != constant.charAt(i)) {
            input.skip(-(i + 1));
            return SkipConstantResult.NOT_FOUND;
        }
        if (i != (len - 1)) {
            c = input.read();
        }
    }
    return SkipConstantResult.FOUND;
}
 
源代码6 项目: tomcatsrc   文件: HttpParser.java
/**
 * @return  the token if one was found, the empty string if no data was
 *          available to read or <code>null</code> if data other than a
 *          token was found
 */
private static String readToken(StringReader input) throws IOException {
    StringBuilder result = new StringBuilder();

    int c = skipLws(input, false);

    while (c != -1 && isToken(c)) {
        result.append((char) c);
        c = input.read();
    }
    // Skip back so non-token character is available for next read
    input.skip(-1);

    if (c != -1 && result.length() == 0) {
        return null;
    } else {
        return result.toString();
    }
}
 
源代码7 项目: spring-boot-protocol   文件: MediaType.java
/**
 * Token can be read unambiguously with or without surrounding quotes so
 * this parsing method for token permits optional surrounding double quotes.
 * This is not defined in any RFC. It is a special case to handle data from
 * buggy clients (known buggy clients for DIGEST auth include Microsoft IE 8
 * &amp; 9, Apple Safari for OSX and iOS) that add quotes to values that
 * should be tokens.
 *
 * @return the token if one was found, null if data other than a token or
 *         quoted token was found or null if the end of data was reached
 *         before a quoted token was terminated
 */
static String readQuotedToken(StringReader input) throws IOException {

    StringBuilder result = new StringBuilder();
    boolean quoted = false;

    int c = skipLws(input, false);

    if (c == '"') {
        quoted = true;
    } else if (c == -1 || !isToken(c)) {
        return null;
    } else {
        result.append((char) c);
    }
    c = input.read();

    while (c != -1 && isToken(c)) {
        result.append((char) c);
        c = input.read();
    }

    if (quoted) {
        if (c != '"') {
            return null;
        }
    } else {
        // Skip back so non-token character is available for next read
        input.skip(-1);
    }

    if (c != -1 && result.length() == 0) {
        return null;
    } else {
        return result.toString();
    }
}
 
源代码8 项目: Tomcat7.0.67   文件: HttpParser.java
/**
 * Token can be read unambiguously with or without surrounding quotes so
 * this parsing method for token permits optional surrounding double quotes.
 * This is not defined in any RFC. It is a special case to handle data from
 * buggy clients (known buggy clients for DIGEST auth include Microsoft IE 8
 * &amp; 9, Apple Safari for OSX and iOS) that add quotes to values that
 * should be tokens.
 *
 * @return the token if one was found, null if data other than a token or
 *         quoted token was found or null if the end of data was reached
 *         before a quoted token was terminated
 */
private static String readQuotedToken(StringReader input)
        throws IOException {

    StringBuilder result = new StringBuilder();
    boolean quoted = false;

    int c = skipLws(input, false);

    if (c == '"') {
        quoted = true;
    } else if (c == -1 || !isToken(c)) {
        return null;
    } else {
        result.append((char) c);
    }
    c = input.read();

    while (c != -1 && isToken(c)) {
        result.append((char) c);
        c = input.read();
    }

    if (quoted) {
        if (c != '"') {
            return null;
        }
    } else {
        // Skip back so non-token character is available for next read
        input.skip(-1);
    }

    if (c != -1 && result.length() == 0) {
        return null;
    } else {
        return result.toString();
    }
}
 
源代码9 项目: tomcatsrc   文件: HttpParser.java
/**
 * Token can be read unambiguously with or without surrounding quotes so
 * this parsing method for token permits optional surrounding double quotes.
 * This is not defined in any RFC. It is a special case to handle data from
 * buggy clients (known buggy clients for DIGEST auth include Microsoft IE 8
 * &amp; 9, Apple Safari for OSX and iOS) that add quotes to values that
 * should be tokens.
 *
 * @return the token if one was found, null if data other than a token or
 *         quoted token was found or null if the end of data was reached
 *         before a quoted token was terminated
 */
private static String readQuotedToken(StringReader input)
        throws IOException {

    StringBuilder result = new StringBuilder();
    boolean quoted = false;

    int c = skipLws(input, false);

    if (c == '"') {
        quoted = true;
    } else if (c == -1 || !isToken(c)) {
        return null;
    } else {
        result.append((char) c);
    }
    c = input.read();

    while (c != -1 && isToken(c)) {
        result.append((char) c);
        c = input.read();
    }

    if (quoted) {
        if (c != '"') {
            return null;
        }
    } else {
        // Skip back so non-token character is available for next read
        input.skip(-1);
    }

    if (c != -1 && result.length() == 0) {
        return null;
    } else {
        return result.toString();
    }
}
 
源代码10 项目: Carbonado   文件: StringClob.java
public Reader openReader(long pos) throws FetchException {
    StringReader r = new StringReader(mStr);
    try {
        r.skip(pos);
    } catch (IOException e) {
        throw new FetchException(e);
    }
    return r;
}
 
源代码11 项目: spring-boot-protocol   文件: MediaType.java
/**
 * LHEX can be read unambiguously with or without surrounding quotes so this
 * parsing method for LHEX permits optional surrounding double quotes. Some
 * buggy clients (libwww-perl for DIGEST auth) are known to send quoted LHEX
 * when the specification requires just LHEX.
 *
 * <p>
 * LHEX are, literally, lower-case hexadecimal digits. This implementation
 * allows for upper-case digits as well, converting the returned value to
 * lower-case.
 *
 * @return  the sequence of LHEX (minus any surrounding quotes) if any was
 *          found, or <code>null</code> if data other LHEX was found
 */
static String readLhex(StringReader input) throws IOException {

    StringBuilder result = new StringBuilder();
    boolean quoted = false;

    int c = skipLws(input, false);

    if (c == '"') {
        quoted = true;
    } else if (c == -1 || !isHex(c)) {
        return null;
    } else {
        if ('A' <= c && c <= 'F') {
            c -= ('A' - 'a');
        }
        result.append((char) c);
    }
    c = input.read();

    while (c != -1 && isHex(c)) {
        if ('A' <= c && c <= 'F') {
            c -= ('A' - 'a');
        }
        result.append((char) c);
        c = input.read();
    }

    if (quoted) {
        if (c != '"') {
            return null;
        }
    } else {
        // Skip back so non-hex character is available for next read
        input.skip(-1);
    }

    if (c != -1 && result.length() == 0) {
        return null;
    } else {
        return result.toString();
    }
}
 
源代码12 项目: Tomcat7.0.67   文件: HttpParser.java
/**
 * LHEX can be read unambiguously with or without surrounding quotes so this
 * parsing method for LHEX permits optional surrounding double quotes. Some
 * buggy clients (libwww-perl for DIGEST auth) are known to send quoted LHEX
 * when the specification requires just LHEX.
 *
 * <p>
 * LHEX are, literally, lower-case hexadecimal digits. This implementation
 * allows for upper-case digits as well, converting the returned value to
 * lower-case.
 *
 * @return  the sequence of LHEX (minus any surrounding quotes) if any was
 *          found, or <code>null</code> if data other LHEX was found
 */
private static String readLhex(StringReader input)
        throws IOException {

    StringBuilder result = new StringBuilder();
    boolean quoted = false;

    int c = skipLws(input, false);

    if (c == '"') {
        quoted = true;
    } else if (c == -1 || !isHex(c)) {
        return null;
    } else {
        if ('A' <= c && c <= 'F') {
            c -= ('A' - 'a');
        }
        result.append((char) c);
    }
    c = input.read();

    while (c != -1 && isHex(c)) {
        if ('A' <= c && c <= 'F') {
            c -= ('A' - 'a');
        }
        result.append((char) c);
        c = input.read();
    }

    if (quoted) {
        if (c != '"') {
            return null;
        }
    } else {
        // Skip back so non-hex character is available for next read
        input.skip(-1);
    }

    if (c != -1 && result.length() == 0) {
        return null;
    } else {
        return result.toString();
    }
}
 
源代码13 项目: tomcatsrc   文件: HttpParser.java
/**
 * LHEX can be read unambiguously with or without surrounding quotes so this
 * parsing method for LHEX permits optional surrounding double quotes. Some
 * buggy clients (libwww-perl for DIGEST auth) are known to send quoted LHEX
 * when the specification requires just LHEX.
 *
 * <p>
 * LHEX are, literally, lower-case hexadecimal digits. This implementation
 * allows for upper-case digits as well, converting the returned value to
 * lower-case.
 *
 * @return  the sequence of LHEX (minus any surrounding quotes) if any was
 *          found, or <code>null</code> if data other LHEX was found
 */
private static String readLhex(StringReader input)
        throws IOException {

    StringBuilder result = new StringBuilder();
    boolean quoted = false;

    int c = skipLws(input, false);

    if (c == '"') {
        quoted = true;
    } else if (c == -1 || !isHex(c)) {
        return null;
    } else {
        if ('A' <= c && c <= 'F') {
            c -= ('A' - 'a');
        }
        result.append((char) c);
    }
    c = input.read();

    while (c != -1 && isHex(c)) {
        if ('A' <= c && c <= 'F') {
            c -= ('A' - 'a');
        }
        result.append((char) c);
        c = input.read();
    }

    if (quoted) {
        if (c != '"') {
            return null;
        }
    } else {
        // Skip back so non-hex character is available for next read
        input.skip(-1);
    }

    if (c != -1 && result.length() == 0) {
        return null;
    } else {
        return result.toString();
    }
}