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


Java CharChunk类代码示例

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


CharChunk类属于org.apache.tomcat.util.buf包,在下文中一共展示了CharChunk类的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: appendBytes

import org.apache.tomcat.util.buf.CharChunk; //导入依赖的package包/类
/**
 * 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());
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:23,代码来源:AjpMessage.java

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

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

示例5: exactFind

import org.apache.tomcat.util.buf.CharChunk; //导入依赖的package包/类
/**
 * Exact mapping.
 */
private final void internalMapExactWrapper
    (Wrapper[] wrappers, CharChunk path, MappingData mappingData) {
    Wrapper wrapper = exactFind(wrappers, path);
    if (wrapper != null) {
        mappingData.requestPath.setString(wrapper.name);
        mappingData.wrapper = wrapper.object;
        if (path.equals("/")) {
            // Special handling for Context Root mapped servlet
            mappingData.pathInfo.setString("/");
            mappingData.wrapperPath.setString("");
            // This seems wrong but it is what the spec says...
            mappingData.contextPath.setString("");
        } else {
            mappingData.wrapperPath.setString(wrapper.name);
        }
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:21,代码来源:Mapper.java

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

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

示例8: 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:liaokailin,项目名称:tomcat7,代码行数:20,代码来源:Mapper.java

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

示例10: 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:lamsfoundation,项目名称:lams,代码行数:25,代码来源:CoyoteAdapter.java

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

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

示例13: appendBytes

import org.apache.tomcat.util.buf.CharChunk; //导入依赖的package包/类
/**
 * 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());
	}
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:22,代码来源:AjpMessage.java

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

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


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