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


Java ObjectStreamConstants.TC_RESET属性代码示例

本文整理汇总了Java中java.io.ObjectStreamConstants.TC_RESET属性的典型用法代码示例。如果您正苦于以下问题:Java ObjectStreamConstants.TC_RESET属性的具体用法?Java ObjectStreamConstants.TC_RESET怎么用?Java ObjectStreamConstants.TC_RESET使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在java.io.ObjectStreamConstants的用法示例。


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

示例1: read_classAnnotation

public List<Content> read_classAnnotation( DataInputStream dis ) throws IOException
{
	List<Content> list = new ArrayList<Content>();
	while ( true ) {
		byte tc = dis.readByte();
		if ( tc == ObjectStreamConstants.TC_ENDBLOCKDATA ) {
			return list;
		}
		if ( tc == ObjectStreamConstants.TC_RESET ) {
			reset();
			continue;
		}
		Content c = read_Content( tc, dis, true );
		if ( c != null && c.isExceptionObject() ) {
			throw new ReadException( c );
		}
		list.add( c );
	}
}
 
开发者ID:kartoFlane,项目名称:superluminal2,代码行数:19,代码来源:JDeserialize.java

示例2: read_Exception

/**
 * Read the content of a thrown exception object. According to the spec, this must be
 * an object of type Throwable. Although the Sun JDK always appears to provide enough
 * information about the hierarchy to reach all the way back to java.lang.Throwable,
 * it's unclear whether this is actually a requirement. From my reading, it's
 * possible that some other ObjectOutputStream implementations may leave some gaps in
 * the hierarchy, forcing this app to hit the classloader. To avoid this, we merely
 * ensure that the written object is indeed an instance; ensuring that the object is
 * indeed a Throwable is an exercise left to the user.
 */
public Content read_Exception( DataInputStream dis ) throws IOException
{
	reset();
	byte tc = dis.readByte();
	if ( tc == ObjectStreamConstants.TC_RESET ) {
		throw new ValidityException( "TC_RESET for object while reading exception: what should we do?" );
	}
	Content c = read_Content( tc, dis, false );
	if ( c == null ) {
		throw new ValidityException( "stream signaled for an exception, but exception object was null!" );
	}
	if ( !( c instanceof Instance ) ) {
		throw new ValidityException( "stream signaled for an exception, but content is not an object!" );
	}
	if ( c.isExceptionObject() ) {
		throw new ReadException( c );
	}
	c.setIsExceptionObject( true );
	reset();
	return c;
}
 
开发者ID:kartoFlane,项目名称:superluminal2,代码行数:31,代码来源:JDeserialize.java

示例3: decodeLast

@Override
protected void decodeLast(ChannelHandlerContext ctx, ByteBuf buffer, List<Object> out) throws Exception {
    switch (buffer.readableBytes()) {
    case 0:
        return;
    case 1:
        // Ignore the last TC_RESET
        if (buffer.getByte(buffer.readerIndex()) == ObjectStreamConstants.TC_RESET) {
            buffer.skipBytes(1);
            return;
        }
    }

    decode(ctx, buffer, out);
}
 
开发者ID:wuyinxian124,项目名称:netty4.0.27Learn,代码行数:15,代码来源:CompatibleMarshallingDecoder.java

示例4: read

/**
* Reads up to <code>len</code> bytes of data into an array of bytes from this input stream. If the maximum number of bytes that can be 
* read from the byte array have already been read, -1 is returned. Otherwise this stream attempts to read the smaller of <code>len</code> 
* and the number of bytes left to read in the byte array.<br>
* <br>
* This read method cannot block.
* 
* @return the total number of bytes read into the byte array, or -1 if there is no more data because the end of the stream has been reached.
* 
* @throws IOException if no byte array is currently specified.
*/
	public int read(byte b[], int off, int len) throws IOException
	{
this.check();
		
int readLength = len; /*readLength is used to indicate how many bytes that are to be read from the byte array.
														This variable differs from len only when the object stream reset code is returned.*/
		
if(b == null) throw new NullPointerException("Byte array b is null!");
		else if(len <= 0) return 0;
else if ((off < 0) || (off > b.length) || (len < 0) || ((off + len) > b.length) || ((off + len) < 0)) throw new IndexOutOfBoundsException();
		else if(this.currentByteArrayPos >= this.byteDataMaxPos) return -1;
		
if((this.currentByteArrayPos + readLength) > this.byteDataMaxPos) readLength = this.byteDataMaxPos - this.currentByteArrayPos;
				
if(returnObjectStreamResetCode && !objectStreamResetCodeReturned)
		{
			objectStreamResetCodeReturned = true;
	b[off++] = ObjectStreamConstants.TC_RESET;
	readLength--;
		}
		
System.arraycopy(this.byteArray, this.currentByteArrayPos, b, off, readLength);
this.currentByteArrayPos += readLength;
		
return len;
	}
 
开发者ID:tolo,项目名称:JServer,代码行数:37,代码来源:MutableByteArrayInputStream.java


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