本文整理汇总了Java中org.apache.tomcat.util.buf.MessageBytes.T_BYTES属性的典型用法代码示例。如果您正苦于以下问题:Java MessageBytes.T_BYTES属性的具体用法?Java MessageBytes.T_BYTES怎么用?Java MessageBytes.T_BYTES使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.apache.tomcat.util.buf.MessageBytes
的用法示例。
在下文中一共展示了MessageBytes.T_BYTES属性的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: convertMB
/**
* 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: appendBytes
/**
* Write a MessageBytes out at the current write position.
* A null MessageBytes is encoded as a string with length 0.
*/
public void appendBytes(MessageBytes mb) {
if (mb == null) {
log.error(sm.getString("ajpmessage.null"),
new NullPointerException());
appendInt(0);
appendByte(0);
return;
}
if (mb.getType() == MessageBytes.T_BYTES) {
ByteChunk bc = mb.getByteChunk();
appendByteChunk(bc);
} else if (mb.getType() == MessageBytes.T_CHARS) {
CharChunk cc = mb.getCharChunk();
appendCharChunk(cc);
} else {
appendString(mb.toString());
}
}
示例3: convertMB
/**
* 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: convertMB
/**
* 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);
}
示例5: appendBytes
/**
* Write a MessageBytes out at the current write position. A null
* MessageBytes is encoded as a string with length 0.
*/
public void appendBytes(MessageBytes mb) {
if (mb == null) {
log.error(sm.getString("ajpmessage.null"), new NullPointerException());
appendInt(0);
appendByte(0);
return;
}
if (mb.getType() == MessageBytes.T_BYTES) {
ByteChunk bc = mb.getByteChunk();
appendByteChunk(bc);
} else if (mb.getType() == MessageBytes.T_CHARS) {
CharChunk cc = mb.getCharChunk();
appendCharChunk(cc);
} else {
appendString(mb.toString());
}
}
示例6: write
/**
* This method will write the contents of the specified message bytes
* buffer to the output stream, without filtering. This method is meant to
* be used to write the response header.
*
* @param mb data to be written
*/
protected void write(MessageBytes mb) {
if (mb.getType() == MessageBytes.T_BYTES) {
ByteChunk bc = mb.getByteChunk();
write(bc);
} else if (mb.getType() == MessageBytes.T_CHARS) {
CharChunk cc = mb.getCharChunk();
write(cc);
} else {
write(mb.toString());
}
}
示例7: processParameters
public void processParameters( MessageBytes data, String encoding ) {
if( data==null || data.isNull() || data.getLength() <= 0 ) {
return;
}
if( data.getType() != MessageBytes.T_BYTES ) {
data.toBytes();
}
ByteChunk bc=data.getByteChunk();
processParameters( bc.getBytes(), bc.getOffset(),
bc.getLength(), getCharset(encoding));
}
示例8: write
/**
* This method will write the contents of the specyfied message bytes
* buffer to the output stream, without filtering. This method is meant to
* be used to write the response header.
*
* @param mb data to be written
*/
protected void write(MessageBytes mb) {
if (mb.getType() == MessageBytes.T_BYTES) {
ByteChunk bc = mb.getByteChunk();
write(bc);
} else if (mb.getType() == MessageBytes.T_CHARS) {
CharChunk cc = mb.getCharChunk();
write(cc);
} else {
write(mb.toString());
}
}
示例9: processParameters
public void processParameters(MessageBytes data, String encoding) {
if (data == null || data.isNull() || data.getLength() <= 0)
return;
if (data.getType() != MessageBytes.T_BYTES) {
data.toBytes();
}
ByteChunk bc = data.getByteChunk();
processParameters(bc.getBytes(), bc.getOffset(), bc.getLength(),
encoding);
}
示例10: processCookies
/** Add all Cookie found in the headers of a request.
*/
public void processCookies( MimeHeaders headers ) {
if( headers==null )
return;// nothing to process
// process each "cookie" header
int pos=0;
while( pos>=0 ) {
// Cookie2: version ? not needed
pos=headers.findHeader( "Cookie", pos );
// no more cookie headers headers
if( pos<0 ) break;
MessageBytes cookieValue=headers.getValue( pos );
if( cookieValue==null || cookieValue.isNull() ) {
pos++;
continue;
}
// Uncomment to test the new parsing code
if( cookieValue.getType() == MessageBytes.T_BYTES ) {
if( dbg>0 ) log( "Parsing b[]: " + cookieValue.toString());
ByteChunk bc=cookieValue.getByteChunk();
processCookieHeader( bc.getBytes(),
bc.getOffset(),
bc.getLength());
} else {
if( dbg>0 ) log( "Parsing S: " + cookieValue.toString());
processCookieHeader( cookieValue.toString() );
}
pos++;// search from the next position
}
}
示例11: write
/**
* This method will write the contents of the specified message bytes buffer
* to the output stream, without filtering. This method is meant to be used
* to write the response header.
*
* @param mb
* data to be written
*/
protected void write(MessageBytes mb) {
if (mb.getType() == MessageBytes.T_BYTES) {
ByteChunk bc = mb.getByteChunk();
write(bc);
} else if (mb.getType() == MessageBytes.T_CHARS) {
CharChunk cc = mb.getCharChunk();
write(cc);
} else {
write(mb.toString());
}
}
示例12: processParameters
public void processParameters(MessageBytes data, String encoding) {
if (data == null || data.isNull() || data.getLength() <= 0) {
return;
}
if (data.getType() != MessageBytes.T_BYTES) {
data.toBytes();
}
ByteChunk bc = data.getByteChunk();
processParameters(bc.getBytes(), bc.getOffset(), bc.getLength(), getCharset(encoding));
}
示例13: processCookies
/** Add all Cookie found in the headers of a request.
*/
public void processCookies( MimeHeaders headers ) {
if( headers==null ) {
return;// nothing to process
}
// process each "cookie" header
int pos=0;
while( pos>=0 ) {
// Cookie2: version ? not needed
pos=headers.findHeader( "Cookie", pos );
// no more cookie headers headers
if( pos<0 ) {
break;
}
MessageBytes cookieValue=headers.getValue( pos );
if( cookieValue==null || cookieValue.isNull() ) {
pos++;
continue;
}
if( cookieValue.getType() != MessageBytes.T_BYTES ) {
Exception e = new Exception();
log.warn("Cookies: Parsing cookie as String. Expected bytes.",
e);
cookieValue.toBytes();
}
if(log.isDebugEnabled()) {
log.debug("Cookies: Parsing b[]: " + cookieValue.toString());
}
ByteChunk bc=cookieValue.getByteChunk();
if (CookieSupport.PRESERVE_COOKIE_HEADER) {
int len = bc.getLength();
if (len > 0) {
byte[] buf = new byte[len];
System.arraycopy(bc.getBytes(), bc.getOffset(), buf, 0, len);
processCookieHeader(buf, 0, len);
}
} else {
processCookieHeader( bc.getBytes(),
bc.getOffset(),
bc.getLength());
}
pos++;// search from the next position
}
}
示例14: processCookies
/**
* Add all Cookie found in the headers of a request.
*/
public void processCookies(MimeHeaders headers) {
if (headers == null) {
return;// nothing to process
}
// process each "cookie" header
int pos = 0;
while (pos >= 0) {
// Cookie2: version ? not needed
pos = headers.findHeader("Cookie", pos);
// no more cookie headers headers
if (pos < 0) {
break;
}
MessageBytes cookieValue = headers.getValue(pos);
if (cookieValue == null || cookieValue.isNull()) {
pos++;
continue;
}
if (cookieValue.getType() != MessageBytes.T_BYTES) {
Exception e = new Exception();
log.warn("Cookies: Parsing cookie as String. Expected bytes.", e);
cookieValue.toBytes();
}
if (log.isDebugEnabled()) {
log.debug("Cookies: Parsing b[]: " + cookieValue.toString());
}
ByteChunk bc = cookieValue.getByteChunk();
if (CookieSupport.PRESERVE_COOKIE_HEADER) {
int len = bc.getLength();
if (len > 0) {
byte[] buf = new byte[len];
System.arraycopy(bc.getBytes(), bc.getOffset(), buf, 0, len);
processCookieHeader(buf, 0, len);
}
} else {
processCookieHeader(bc.getBytes(), bc.getOffset(), bc.getLength());
}
pos++;// search from the next position
}
}