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


Java CharChunk.getBuffer方法代码示例

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

}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:26,代码来源:CoyoteAdapter.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: 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);

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

示例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;
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:29,代码来源:Mapper.java

示例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);

}
 
开发者ID:sunmingshuai,项目名称:apache-tomcat-7.0.73-with-comment,代码行数:20,代码来源: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:liaokailin,项目名称:tomcat7,代码行数:22,代码来源:Mapper.java

示例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;
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:28,代码来源:Mapper.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();
	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

示例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;
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:28,代码来源:Mapper.java

示例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;
    }

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

示例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;
    }

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

示例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);

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

示例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;
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:29,代码来源:Mapper.java

示例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);

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

示例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;
    }

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


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