当前位置: 首页>>代码示例>>Java>>正文


Java StringReader.skip方法代码示例

本文整理汇总了Java中java.io.StringReader.skip方法的典型用法代码示例。如果您正苦于以下问题:Java StringReader.skip方法的具体用法?Java StringReader.skip怎么用?Java StringReader.skip使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.io.StringReader的用法示例。


在下文中一共展示了StringReader.skip方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: skipConstant

import java.io.StringReader; //导入方法依赖的package包/类
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;
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:21,代码来源:HttpParser.java

示例2: readToken

import java.io.StringReader; //导入方法依赖的package包/类
/**
 * @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();
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:24,代码来源:HttpParser.java

示例3: skipConstant

import java.io.StringReader; //导入方法依赖的package包/类
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;
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:20,代码来源:HttpParser.java

示例4: readToken

import java.io.StringReader; //导入方法依赖的package包/类
/**
 * @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();
	}
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:24,代码来源:HttpParser.java

示例5: readQuotedToken

import java.io.StringReader; //导入方法依赖的package包/类
/**
 * 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();
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:50,代码来源:HttpParser.java

示例6: readQuotedToken

import java.io.StringReader; //导入方法依赖的package包/类
/**
 * 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();
	}
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:49,代码来源:HttpParser.java

示例7: readLhex

import java.io.StringReader; //导入方法依赖的package包/类
/**
 * 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();
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:58,代码来源:HttpParser.java

示例8: readLhex

import java.io.StringReader; //导入方法依赖的package包/类
/**
 * 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();
	}
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:57,代码来源:HttpParser.java


注:本文中的java.io.StringReader.skip方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。