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


Java CharChunk.getStart方法代码示例

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


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

示例1: lastSlash

import org.apache.tomcat.util.buf.CharChunk; //导入方法依赖的package包/类
/**
 * Find the position of the last slash in the given char chunk.
 */
private static final int lastSlash(CharChunk name) {

	char[] c = name.getBuffer();
	int end = name.getEnd();
	int start = name.getStart();
	int pos = end;

	while (pos > start) {
		if (c[--pos] == '/') {
			break;
		}
	}

	return (pos);

}
 
开发者ID:how2j,项目名称:lazycat,代码行数:20,代码来源:Mapper.java

示例2: appendCharChunk

import org.apache.tomcat.util.buf.CharChunk; //导入方法依赖的package包/类
/**
 * Write a CharChunk out at the current write position.
 * A null CharChunk is encoded as a string with length 0.  
 */
public void appendCharChunk(CharChunk cc) {
    if (cc == null) {
        log.error(sm.getString("ajpmessage.null"), 
                new NullPointerException());
        appendInt(0);
        appendByte(0);
        return;
    }
    int start = cc.getStart();
    int end = cc.getEnd();
    appendInt(end - start);
    char[] cbuf = cc.getBuffer();
    for (int i = start; i < end; i++) {
        char c = cbuf[i];
        // Note:  This is clearly incorrect for many strings,
        // but is the only consistent approach within the current
        // servlet framework.  It must suffice until servlet output
        // streams properly encode their output.
        if (((c <= 31) && (c != 9)) || c == 127 || c > 255) {
            c = ' ';
        }
        appendByte(c);
    }
    appendByte(0);
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:30,代码来源:AjpMessage.java

示例3: write

import org.apache.tomcat.util.buf.CharChunk; //导入方法依赖的package包/类
/**
 * This method will write the contents of the specified char 
 * buffer to the output stream, without filtering. This method is meant to
 * be used to write the response header.
 * 
 * @param cc data to be written
 */
protected void write(CharChunk cc) {

    int start = cc.getStart();
    int end = cc.getEnd();
    checkLengthBeforeWrite(end-start);
    char[] cbuf = cc.getBuffer();
    for (int i = start; i < end; i++) {
        char c = cbuf[i];
        // Note:  This is clearly incorrect for many strings,
        // but is the only consistent approach within the current
        // servlet framework.  It must suffice until servlet output
        // streams properly encode their output.
        if (((c <= 31) && (c != 9)) || c == 127 || c > 255) {
            c = ' ';
        }
        buf[pos++] = (byte) c;
    }

}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:27,代码来源:AbstractOutputBuffer.java

示例4: lastSlash

import org.apache.tomcat.util.buf.CharChunk; //导入方法依赖的package包/类
/**
 * Find the position of the last slash in the given char chunk.
 */
private static final int lastSlash(CharChunk name) {

    char[] c = name.getBuffer();
    int end = name.getEnd();
    int start = name.getStart();
    int pos = end;

    while (pos > start) {
        if (c[--pos] == '/') {
            break;
        }
    }

    return (pos);

}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:20,代码来源:Mapper.java

示例5: nthSlash

import org.apache.tomcat.util.buf.CharChunk; //导入方法依赖的package包/类
/**
 * Find the position of the nth slash, in the given char chunk.
 */
private static final int nthSlash(CharChunk name, int n) {

    char[] c = name.getBuffer();
    int end = name.getEnd();
    int start = name.getStart();
    int pos = start;
    int count = 0;

    while (pos < end) {
        if ((c[pos++] == '/') && ((++count) == n)) {
            pos--;
            break;
        }
    }

    return (pos);

}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:22,代码来源:Mapper.java

示例6: nthSlash

import org.apache.tomcat.util.buf.CharChunk; //导入方法依赖的package包/类
/**
 * Find the position of the nth slash, in the given char chunk.
 */
private static final int nthSlash(CharChunk name, int n) {

	char[] c = name.getBuffer();
	int end = name.getEnd();
	int start = name.getStart();
	int pos = start;
	int count = 0;

	while (pos < end) {
		if ((c[pos++] == '/') && ((++count) == n)) {
			pos--;
			break;
		}
	}

	return (pos);

}
 
开发者ID:how2j,项目名称:lazycat,代码行数:22,代码来源:Mapper.java

示例7: write

import org.apache.tomcat.util.buf.CharChunk; //导入方法依赖的package包/类
/**
 * This method will write the contents of the specyfied char 
 * buffer to the output stream, without filtering. This method is meant to
 * be used to write the response header.
 * 
 * @param cc data to be written
 */
protected void write(CharChunk cc) {

    int start = cc.getStart();
    int end = cc.getEnd();
    char[] cbuf = cc.getBuffer();
    for (int i = start; i < end; i++) {
        char c = cbuf[i];
        // Note:  This is clearly incorrect for many strings,
        // but is the only consistent approach within the current
        // servlet framework.  It must suffice until servlet output
        // streams properly encode their output.
        if ((c <= 31) && (c != 9)) {
            c = ' ';
        } else if (c == 127) {
            c = ' ';
        }
        buf[pos++] = (byte) c;
    }

}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:28,代码来源:InternalOutputBuffer.java

示例8: appendCharChunk

import org.apache.tomcat.util.buf.CharChunk; //导入方法依赖的package包/类
/**
 * Write a CharChunk out at the current write position. A null CharChunk is
 * encoded as a string with length 0.
 */
public void appendCharChunk(CharChunk cc) {
	if (cc == null) {
		log.error(sm.getString("ajpmessage.null"), new NullPointerException());
		appendInt(0);
		appendByte(0);
		return;
	}
	int start = cc.getStart();
	int end = cc.getEnd();
	appendInt(end - start);
	char[] cbuf = cc.getBuffer();
	for (int i = start; i < end; i++) {
		char c = cbuf[i];
		// Note: This is clearly incorrect for many strings,
		// but is the only consistent approach within the current
		// servlet framework. It must suffice until servlet output
		// streams properly encode their output.
		if (((c <= 31) && (c != 9)) || c == 127 || c > 255) {
			c = ' ';
		}
		appendByte(c);
	}
	appendByte(0);
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:29,代码来源:AjpMessage.java

示例9: write

import org.apache.tomcat.util.buf.CharChunk; //导入方法依赖的package包/类
/**
 * This method will write the contents of the specified char buffer to the
 * output stream, without filtering. This method is meant to be used to
 * write the response header.
 * 
 * @param cc
 *            data to be written
 */
protected void write(CharChunk cc) {

	int start = cc.getStart();
	int end = cc.getEnd();
	checkLengthBeforeWrite(end - start);
	char[] cbuf = cc.getBuffer();
	for (int i = start; i < end; i++) {
		char c = cbuf[i];
		// Note: This is clearly incorrect for many strings,
		// but is the only consistent approach within the current
		// servlet framework. It must suffice until servlet output
		// streams properly encode their output.
		if (((c <= 31) && (c != 9)) || c == 127 || c > 255) {
			c = ' ';
		}
		buf[pos++] = (byte) c;
	}

}
 
开发者ID:how2j,项目名称:lazycat,代码行数:28,代码来源:AbstractOutputBuffer.java

示例10: write

import org.apache.tomcat.util.buf.CharChunk; //导入方法依赖的package包/类
/**
 * This method will write the contents of the specified char 
 * buffer to the output stream, without filtering. This method is meant to
 * be used to write the response header.
 * 
 * @param cc data to be written
 */
protected void write(CharChunk cc) {

    int start = cc.getStart();
    int end = cc.getEnd();
    char[] cbuf = cc.getBuffer();
    for (int i = start; i < end; i++) {
        char c = cbuf[i];
        // Note:  This is clearly incorrect for many strings,
        // but is the only consistent approach within the current
        // servlet framework.  It must suffice until servlet output
        // streams properly encode their output.
        if ((c <= 31) && (c != 9)) {
            c = ' ';
        } else if (c == 127) {
            c = ' ';
        }
        buf[pos++] = (byte) c;
    }

}
 
开发者ID:WhiteBearSolutions,项目名称:WBSAirback,代码行数:28,代码来源:AbstractOutputBuffer.java

示例11: appendCharChunk

import org.apache.tomcat.util.buf.CharChunk; //导入方法依赖的package包/类
/**
 * Write a CharChunk out at the current write position.
 * A null CharChunk is encoded as a string with length 0.  
 */
public void appendCharChunk(CharChunk cc) {
    if (cc == null) {
        log.error(sm.getString("ajpmessage.null"), 
                new NullPointerException());
        appendInt(0);
        appendByte(0);
        return;
    }
    int start = cc.getStart();
    int end = cc.getEnd();
    appendInt(end - start);
    char[] cbuf = cc.getBuffer();
    for (int i = start; i < end; i++) {
        char c = cbuf[i];
        // Note:  This is clearly incorrect for many strings,
        // but is the only consistent approach within the current
        // servlet framework.  It must suffice until servlet output
        // streams properly encode their output.
        if ((c <= 31) && (c != 9)) {
            c = ' ';
        } else if (c == 127) {
            c = ' ';
        }
        appendByte(c);
    }
    appendByte(0);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:32,代码来源:AjpMessage.java

示例12: checkNormalize

import org.apache.tomcat.util.buf.CharChunk; //导入方法依赖的package包/类
/**
 * Check that the URI is normalized following character decoding.
 * <p>
 * This method checks for "\", 0, "//", "/./" and "/../". This method will
 * return false if sequences that are supposed to be normalized are still
 * present in the URI.
 *
 * @param uriMB URI to be checked (should be chars)
 */
public static boolean checkNormalize(MessageBytes uriMB) {

    CharChunk uriCC = uriMB.getCharChunk();
    char[] c = uriCC.getChars();
    int start = uriCC.getStart();
    int end = uriCC.getEnd();

    int pos = 0;

    // Check for '\' and 0
    for (pos = start; pos < end; pos++) {
        if (c[pos] == '\\') {
            return false;
        }
        if (c[pos] == 0) {
            return false;
        }
    }

    // Check for "//"
    for (pos = start; pos < (end - 1); pos++) {
        if (c[pos] == '/') {
            if (c[pos + 1] == '/') {
                return false;
            }
        }
    }

    // Check for ending with "/." or "/.."
    if (((end - start) >= 2) && (c[end - 1] == '.')) {
        if ((c[end - 2] == '/')
                || ((c[end - 2] == '.')
                && (c[end - 3] == '/'))) {
            return false;
        }
    }

    // Check for "/./"
    if (uriCC.indexOf("/./", 0, 3, 0) >= 0) {
        return false;
    }

    // Check for "/../"
    if (uriCC.indexOf("/../", 0, 4, 0) >= 0) {
        return false;
    }

    return true;

}
 
开发者ID:sunmingshuai,项目名称:apache-tomcat-7.0.73-with-comment,代码行数:60,代码来源:CoyoteAdapter.java

示例13: normalize

import org.apache.tomcat.util.buf.CharChunk; //导入方法依赖的package包/类
private void normalize(CharChunk cc) {
	// Strip query string and/or fragment first as doing it this way makes
	// the normalization logic a lot simpler
	int truncate = cc.indexOf('?');
	if (truncate == -1) {
		truncate = cc.indexOf('#');
	}
	char[] truncateCC = null;
	if (truncate > -1) {
		truncateCC = Arrays.copyOfRange(cc.getBuffer(), cc.getStart() + truncate, cc.getEnd());
		cc.setEnd(cc.getStart() + truncate);
	}

	if (cc.endsWith("/.") || cc.endsWith("/..")) {
		try {
			cc.append('/');
		} catch (IOException e) {
			throw new IllegalArgumentException(cc.toString(), e);
		}
	}

	char[] c = cc.getChars();
	int start = cc.getStart();
	int end = cc.getEnd();
	int index = 0;
	int startIndex = 0;

	// Advance past the first three / characters (should place index just
	// scheme://host[:port]

	for (int i = 0; i < 3; i++) {
		startIndex = cc.indexOf('/', startIndex + 1);
	}

	// Remove /./
	index = startIndex;
	while (true) {
		index = cc.indexOf("/./", 0, 3, index);
		if (index < 0) {
			break;
		}
		copyChars(c, start + index, start + index + 2, end - start - index - 2);
		end = end - 2;
		cc.setEnd(end);
	}

	// Remove /../
	index = startIndex;
	int pos;
	while (true) {
		index = cc.indexOf("/../", 0, 4, index);
		if (index < 0) {
			break;
		}
		// Can't go above the server root
		if (index == startIndex) {
			throw new IllegalArgumentException();
		}
		int index2 = -1;
		for (pos = start + index - 1; (pos >= 0) && (index2 < 0); pos--) {
			if (c[pos] == (byte) '/') {
				index2 = pos;
			}
		}
		copyChars(c, start + index2, start + index + 3, end - start - index - 3);
		end = end + index2 - index - 3;
		cc.setEnd(end);
		index = index2;
	}

	// Add the query string and/or fragment (if present) back in
	if (truncateCC != null) {
		try {
			cc.append(truncateCC, 0, truncateCC.length);
		} catch (IOException ioe) {
			throw new IllegalArgumentException(ioe);
		}
	}
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:80,代码来源:Response.java

示例14: checkNormalize

import org.apache.tomcat.util.buf.CharChunk; //导入方法依赖的package包/类
/**
 * Check that the URI is normalized following character decoding.
 * <p>
 * This method checks for "\", 0, "//", "/./" and "/../". This method will
 * return false if sequences that are supposed to be normalized are still
 * present in the URI.
 *
 * @param uriMB
 *            URI to be checked (should be chars)
 */
public static boolean checkNormalize(MessageBytes uriMB) {

	CharChunk uriCC = uriMB.getCharChunk();
	char[] c = uriCC.getChars();
	int start = uriCC.getStart();
	int end = uriCC.getEnd();

	int pos = 0;

	// Check for '\' and 0
	for (pos = start; pos < end; pos++) {
		if (c[pos] == '\\') {
			return false;
		}
		if (c[pos] == 0) {
			return false;
		}
	}

	// Check for "//"
	for (pos = start; pos < (end - 1); pos++) {
		if (c[pos] == '/') {
			if (c[pos + 1] == '/') {
				return false;
			}
		}
	}

	// Check for ending with "/." or "/.."
	if (((end - start) >= 2) && (c[end - 1] == '.')) {
		if ((c[end - 2] == '/') || ((c[end - 2] == '.') && (c[end - 3] == '/'))) {
			return false;
		}
	}

	// Check for "/./"
	if (uriCC.indexOf("/./", 0, 3, 0) >= 0) {
		return false;
	}

	// Check for "/../"
	if (uriCC.indexOf("/../", 0, 4, 0) >= 0) {
		return false;
	}

	return true;

}
 
开发者ID:how2j,项目名称:lazycat,代码行数:59,代码来源:CoyoteAdapter.java

示例15: checkNormalize

import org.apache.tomcat.util.buf.CharChunk; //导入方法依赖的package包/类
/**
 * Check that the URI is normalized following character decoding.
 * <p>
 * This method checks for "\", 0, "//", "/./" and "/../". This method will
 * return false if sequences that are supposed to be normalized are still 
 * present in the URI.
 * 
 * @param uriMB URI to be checked (should be chars)
 */
public static boolean checkNormalize(MessageBytes uriMB) {

    CharChunk uriCC = uriMB.getCharChunk();
    char[] c = uriCC.getChars();
    int start = uriCC.getStart();
    int end = uriCC.getEnd();

    int pos = 0;

    // Check for '\' and 0
    for (pos = start; pos < end; pos++) {
        if (c[pos] == '\\') {
            return false;
        }
        if (c[pos] == 0) {
            return false;
        }
    }

    // Check for "//"
    for (pos = start; pos < (end - 1); pos++) {
        if (c[pos] == '/') {
            if (c[pos + 1] == '/') {
                return false;
            }
        }
    }

    // Check for ending with "/." or "/.."
    if (((end - start) >= 2) && (c[end - 1] == '.')) {
        if ((c[end - 2] == '/') 
                || ((c[end - 2] == '.') 
                && (c[end - 3] == '/'))) {
            return false;
        }
    }

    // Check for "/./"
    if (uriCC.indexOf("/./", 0, 3, 0) >= 0) {
        return false;
    }

    // Check for "/../"
    if (uriCC.indexOf("/../", 0, 4, 0) >= 0) {
        return false;
    }

    return true;

}
 
开发者ID:WhiteBearSolutions,项目名称:WBSAirback,代码行数:60,代码来源:CoyoteAdapter.java


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