本文整理汇总了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);
}
示例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;
}
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
}
示例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;
}
}
示例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;
}
}
示例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);
}
}
}
示例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);
}
}
}
示例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);
}
}
}
示例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;
}
示例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);
}
示例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);
}
}
}
示例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;
}