本文整理汇总了Java中org.apache.tomcat.util.buf.CharChunk.getBuffer方法的典型用法代码示例。如果您正苦于以下问题:Java CharChunk.getBuffer方法的具体用法?Java CharChunk.getBuffer怎么用?Java CharChunk.getBuffer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.tomcat.util.buf.CharChunk
的用法示例。
在下文中一共展示了CharChunk.getBuffer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: convertMB
import org.apache.tomcat.util.buf.CharChunk; //导入方法依赖的package包/类
/**
* Character conversion of the a US-ASCII MessageBytes.
*/
protected void convertMB(MessageBytes mb) {
// This is of course only meaningful for bytes
if (mb.getType() != MessageBytes.T_BYTES) {
return;
}
ByteChunk bc = mb.getByteChunk();
CharChunk cc = mb.getCharChunk();
int length = bc.getLength();
cc.allocate(length, -1);
// Default encoding: fast conversion
byte[] bbuf = bc.getBuffer();
char[] cbuf = cc.getBuffer();
int start = bc.getStart();
for (int i = 0; i < length; i++) {
cbuf[i] = (char) (bbuf[i + start] & 0xff);
}
mb.setChars(cbuf, 0, length);
}
示例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);
}
示例3: convertMB
import org.apache.tomcat.util.buf.CharChunk; //导入方法依赖的package包/类
/**
* Character conversion of the a US-ASCII MessageBytes.
*/
protected void convertMB(MessageBytes mb) {
// This is of course only meaningful for bytes
if (mb.getType() != MessageBytes.T_BYTES) {
return;
}
ByteChunk bc = mb.getByteChunk();
CharChunk cc = mb.getCharChunk();
int length = bc.getLength();
cc.allocate(length, -1);
// Default encoding: fast conversion
byte[] bbuf = bc.getBuffer();
char[] cbuf = cc.getBuffer();
int start = bc.getStart();
for (int i = 0; i < length; i++) {
cbuf[i] = (char) (bbuf[i + start] & 0xff);
}
mb.setChars(cbuf, 0, length);
}
示例4: compare
import org.apache.tomcat.util.buf.CharChunk; //导入方法依赖的package包/类
/**
* Compare given char chunk with String.
* Return -1, 0 or +1 if inferior, equal, or superior to the String.
*/
private static final int compare(CharChunk name, int start, int end,
String compareTo) {
int result = 0;
char[] c = name.getBuffer();
int len = compareTo.length();
if ((end - start) < len) {
len = end - start;
}
for (int i = 0; (i < len) && (result == 0); i++) {
if (c[i + start] > compareTo.charAt(i)) {
result = 1;
} else if (c[i + start] < compareTo.charAt(i)) {
result = -1;
}
}
if (result == 0) {
if (compareTo.length() > (end - start)) {
result = -1;
} else if (compareTo.length() < (end - start)) {
result = 1;
}
}
return result;
}
示例5: 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);
}
示例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);
}
示例7: compare
import org.apache.tomcat.util.buf.CharChunk; //导入方法依赖的package包/类
/**
* Compare given char chunk with String. Return -1, 0 or +1 if inferior,
* equal, or superior to the String.
*/
private static final int compare(CharChunk name, int start, int end, String compareTo) {
int result = 0;
char[] c = name.getBuffer();
int len = compareTo.length();
if ((end - start) < len) {
len = end - start;
}
for (int i = 0; (i < len) && (result == 0); i++) {
if (c[i + start] > compareTo.charAt(i)) {
result = 1;
} else if (c[i + start] < compareTo.charAt(i)) {
result = -1;
}
}
if (result == 0) {
if (compareTo.length() > (end - start)) {
result = -1;
} else if (compareTo.length() < (end - start)) {
result = 1;
}
}
return result;
}
示例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();
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;
}
}
示例9: compareIgnoreCase
import org.apache.tomcat.util.buf.CharChunk; //导入方法依赖的package包/类
/**
* Compare given char chunk with String ignoring case. Return -1, 0 or +1 if
* inferior, equal, or superior to the String.
*/
private static final int compareIgnoreCase(CharChunk name, int start, int end, String compareTo) {
int result = 0;
char[] c = name.getBuffer();
int len = compareTo.length();
if ((end - start) < len) {
len = end - start;
}
for (int i = 0; (i < len) && (result == 0); i++) {
if (Ascii.toLower(c[i + start]) > Ascii.toLower(compareTo.charAt(i))) {
result = 1;
} else if (Ascii.toLower(c[i + start]) < Ascii.toLower(compareTo.charAt(i))) {
result = -1;
}
}
if (result == 0) {
if (compareTo.length() > (end - start)) {
result = -1;
} else if (compareTo.length() < (end - start)) {
result = 1;
}
}
return result;
}
示例10: 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;
}
}
示例11: 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;
}
}
示例12: 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);
}
示例13: compareIgnoreCase
import org.apache.tomcat.util.buf.CharChunk; //导入方法依赖的package包/类
/**
* Compare given char chunk with String ignoring case.
* Return -1, 0 or +1 if inferior, equal, or superior to the String.
*/
private static final int compareIgnoreCase(CharChunk name, int start, int end,
String compareTo) {
int result = 0;
char[] c = name.getBuffer();
int len = compareTo.length();
if ((end - start) < len) {
len = end - start;
}
for (int i = 0; (i < len) && (result == 0); i++) {
if (Ascii.toLower(c[i + start]) > Ascii.toLower(compareTo.charAt(i))) {
result = 1;
} else if (Ascii.toLower(c[i + start]) < Ascii.toLower(compareTo.charAt(i))) {
result = -1;
}
}
if (result == 0) {
if (compareTo.length() > (end - start)) {
result = -1;
} else if (compareTo.length() < (end - start)) {
result = 1;
}
}
return result;
}
示例14: convertMB
import org.apache.tomcat.util.buf.CharChunk; //导入方法依赖的package包/类
/**
* Character conversion of the a US-ASCII MessageBytes.
*/
protected void convertMB(MessageBytes mb) {
// This is of course only meaningful for bytes
if (mb.getType() != MessageBytes.T_BYTES)
return;
ByteChunk bc = mb.getByteChunk();
CharChunk cc = mb.getCharChunk();
int length = bc.getLength();
cc.allocate(length, -1);
// Default encoding: fast conversion
byte[] bbuf = bc.getBuffer();
char[] cbuf = cc.getBuffer();
int start = bc.getStart();
for (int i = 0; i < length; i++) {
cbuf[i] = (char) (bbuf[i + start] & 0xff);
}
mb.setChars(cbuf, 0, length);
}
示例15: 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;
}
}