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


Java CharChunk.getEnd方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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:sunmingshuai,项目名称:apache-tomcat-7.0.73-with-comment,代码行数:22,代码来源:Mapper.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:sunmingshuai,项目名称:apache-tomcat-7.0.73-with-comment,代码行数:20,代码来源:Mapper.java

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例9: for

import org.apache.tomcat.util.buf.CharChunk; //导入方法依赖的package包/类
/**
 * Extension mappings.
 */
private final void internalMapExtensionWrapper
    (Wrapper[] wrappers, CharChunk path, MappingData mappingData) {
    char[] buf = path.getBuffer();
    int pathEnd = path.getEnd();
    int servletPath = path.getOffset();
    int slash = -1;
    for (int i = pathEnd - 1; i >= servletPath; i--) {
        if (buf[i] == '/') {
            slash = i;
            break;
        }
    }
    if (slash >= 0) {
        int period = -1;
        for (int i = pathEnd - 1; i > slash; i--) {
            if (buf[i] == '.') {
                period = i;
                break;
            }
        }
        if (period >= 0) {
            path.setOffset(period + 1);
            path.setEnd(pathEnd);
            int pos = find(wrappers, path);
            if ((pos != -1)
                && (path.equals(wrappers[pos].name))) {
                mappingData.wrapperPath.setChars
                    (buf, servletPath, pathEnd - servletPath);
                mappingData.requestPath.setChars
                    (buf, servletPath, pathEnd - servletPath);
                mappingData.wrapper = wrappers[pos].object;
            }
            path.setOffset(servletPath);
            path.setEnd(pathEnd);
        }
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:41,代码来源:Mapper.java

示例10: internalMapExtensionWrapper

import org.apache.tomcat.util.buf.CharChunk; //导入方法依赖的package包/类
/**
 * Extension mappings.
 *
 * @param wrappers
 *            Set of wrappers to check for matches
 * @param path
 *            Path to map
 * @param mappingData
 *            Mapping data for result
 * @param resourceExpected
 *            Is this mapping expecting to find a resource
 */
private final void internalMapExtensionWrapper(Wrapper[] wrappers, CharChunk path, MappingData mappingData,
		boolean resourceExpected) {
	char[] buf = path.getBuffer();
	int pathEnd = path.getEnd();
	int servletPath = path.getOffset();
	int slash = -1;
	for (int i = pathEnd - 1; i >= servletPath; i--) {
		if (buf[i] == '/') {
			slash = i;
			break;
		}
	}
	if (slash >= 0) {
		int period = -1;
		for (int i = pathEnd - 1; i > slash; i--) {
			if (buf[i] == '.') {
				period = i;
				break;
			}
		}
		if (period >= 0) {
			path.setOffset(period + 1);
			path.setEnd(pathEnd);
			Wrapper wrapper = exactFind(wrappers, path);
			if (wrapper != null && (resourceExpected || !wrapper.resourceOnly)) {
				mappingData.wrapperPath.setChars(buf, servletPath, pathEnd - servletPath);
				mappingData.requestPath.setChars(buf, servletPath, pathEnd - servletPath);
				mappingData.wrapper = wrapper.object;
			}
			path.setOffset(servletPath);
			path.setEnd(pathEnd);
		}
	}
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:47,代码来源:Mapper.java

示例11: internalMapExtensionWrapper

import org.apache.tomcat.util.buf.CharChunk; //导入方法依赖的package包/类
/**
 * Extension mappings.
 *
 * @param wrappers          Set of wrappers to check for matches
 * @param path              Path to map
 * @param mappingData       Mapping data for result
 * @param resourceExpected  Is this mapping expecting to find a resource
 */
private final void internalMapExtensionWrapper(Wrapper[] wrappers,
        CharChunk path, MappingData mappingData, boolean resourceExpected) {
    char[] buf = path.getBuffer();
    int pathEnd = path.getEnd();
    int servletPath = path.getOffset();
    int slash = -1;
    for (int i = pathEnd - 1; i >= servletPath; i--) {
        if (buf[i] == '/') {
            slash = i;
            break;
        }
    }
    if (slash >= 0) {
        int period = -1;
        for (int i = pathEnd - 1; i > slash; i--) {
            if (buf[i] == '.') {
                period = i;
                break;
            }
        }
        if (period >= 0) {
            path.setOffset(period + 1);
            path.setEnd(pathEnd);
            Wrapper wrapper = exactFind(wrappers, path);
            if (wrapper != null
                    && (resourceExpected || !wrapper.resourceOnly)) {
                mappingData.wrapperPath.setChars(buf, servletPath, pathEnd
                        - servletPath);
                mappingData.requestPath.setChars(buf, servletPath, pathEnd
                        - servletPath);
                mappingData.wrapper = wrapper.object;
            }
            path.setOffset(servletPath);
            path.setEnd(pathEnd);
        }
    }
}
 
开发者ID:sunmingshuai,项目名称:apache-tomcat-7.0.73-with-comment,代码行数:46,代码来源:Mapper.java

示例12: getCredentials

import org.apache.tomcat.util.buf.CharChunk; //导入方法依赖的package包/类
private Credentials getCredentials(Request request) {
    Credentials credentials = null;
    MessageBytes authorization = request.getCoyoteRequest().getMimeHeaders().getValue("authorization");
    if (authorization != null) {
        authorization.toBytes();
        ByteChunk authBC = authorization.getByteChunk();
        if (authBC.startsWithIgnoreCase("basic ", 0)) {
            authBC.setOffset(authBC.getOffset() + 6);

            CharChunk authCC = authorization.getCharChunk();
            Base64.decode(authBC, authCC);

            String username;
            String password = null;

            int colon = authCC.indexOf(':');
            if (colon < 0) {
                username = authCC.toString();
            } else {
                char[] buf = authCC.getBuffer();
                username = new String(buf, 0, colon);
                password = new String(buf, colon + 1, authCC.getEnd() - colon - 1);
            }
            authBC.setOffset(authBC.getOffset() - 6);
            credentials = new Credentials(username, password);
        }
    }
    return credentials;
}
 
开发者ID:wso2-incubator,项目名称:iot-server-appliances,代码行数:30,代码来源:BasicAuthAuthenticator.java

示例13: 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:WhiteBearSolutions,项目名称:WBSAirback,代码行数:32,代码来源:AjpMessage.java

示例14: internalMapExtensionWrapper

import org.apache.tomcat.util.buf.CharChunk; //导入方法依赖的package包/类
/**
 * Extension mappings.
 * 
 * @param wrappers          Set of wrappers to check for matches
 * @param path              Path to map
 * @param mappingData       Mapping data for result
 * @param resourceExpected  Is this mapping expecting to find a resource
 */
private final void internalMapExtensionWrapper(Wrapper[] wrappers,
        CharChunk path, MappingData mappingData, boolean resourceExpected) {
    char[] buf = path.getBuffer();
    int pathEnd = path.getEnd();
    int servletPath = path.getOffset();
    int slash = -1;
    for (int i = pathEnd - 1; i >= servletPath; i--) {
        if (buf[i] == '/') {
            slash = i;
            break;
        }
    }
    if (slash >= 0) {
        int period = -1;
        for (int i = pathEnd - 1; i > slash; i--) {
            if (buf[i] == '.') {
                period = i;
                break;
            }
        }
        if (period >= 0) {
            path.setOffset(period + 1);
            path.setEnd(pathEnd);
            int pos = find(wrappers, path);
            if ((pos != -1) && (path.equals(wrappers[pos].name)) &&
                    (resourceExpected || !wrappers[pos].resourceOnly)) {
                mappingData.wrapperPath.setChars
                    (buf, servletPath, pathEnd - servletPath);
                mappingData.requestPath.setChars
                    (buf, servletPath, pathEnd - servletPath);
                mappingData.wrapper = wrappers[pos].object;
            }
            path.setOffset(servletPath);
            path.setEnd(pathEnd);
        }
    }
}
 
开发者ID:WhiteBearSolutions,项目名称:WBSAirback,代码行数:46,代码来源:Mapper.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:liaokailin,项目名称:tomcat7,代码行数:60,代码来源:CoyoteAdapter.java


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