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


Java MessageBytes.getCharChunk方法代码示例

本文整理汇总了Java中org.apache.tomcat.util.buf.MessageBytes.getCharChunk方法的典型用法代码示例。如果您正苦于以下问题:Java MessageBytes.getCharChunk方法的具体用法?Java MessageBytes.getCharChunk怎么用?Java MessageBytes.getCharChunk使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.tomcat.util.buf.MessageBytes的用法示例。


在下文中一共展示了MessageBytes.getCharChunk方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: convertMB

import org.apache.tomcat.util.buf.MessageBytes; //导入方法依赖的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.MessageBytes; //导入方法依赖的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: convertMB

import org.apache.tomcat.util.buf.MessageBytes; //导入方法依赖的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

示例4: convertMB

import org.apache.tomcat.util.buf.MessageBytes; //导入方法依赖的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

示例5: appendBytes

import org.apache.tomcat.util.buf.MessageBytes; //导入方法依赖的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

示例6: write

import org.apache.tomcat.util.buf.MessageBytes; //导入方法依赖的package包/类
/**
 * 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());
    }

}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:21,代码来源:AbstractOutputBuffer.java

示例7: map

import org.apache.tomcat.util.buf.MessageBytes; //导入方法依赖的package包/类
/**
 * Map the specified URI relative to the context,
 * mutating the given mapping data.
 *
 * @param uri URI
 * @param mappingData This structure will contain the result of the mapping
 *                    operation
 */
public void map(MessageBytes uri, MappingData mappingData)
    throws Exception {

    uri.toChars();
    CharChunk uricc = uri.getCharChunk();
    uricc.setLimit(-1);
    internalMapWrapper(context, uricc, mappingData);

}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:18,代码来源:Mapper.java

示例8: write

import org.apache.tomcat.util.buf.MessageBytes; //导入方法依赖的package包/类
/**
 * 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());
    }

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

示例9: write

import org.apache.tomcat.util.buf.MessageBytes; //导入方法依赖的package包/类
/**
 * 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());
	}

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

示例10: checkNormalize

import org.apache.tomcat.util.buf.MessageBytes; //导入方法依赖的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;

}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:60,代码来源:CoyoteAdapter.java

示例11: checkNormalize

import org.apache.tomcat.util.buf.MessageBytes; //导入方法依赖的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;

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

示例12: checkNormalize

import org.apache.tomcat.util.buf.MessageBytes; //导入方法依赖的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;

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


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