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


Java ObjectStreamConstants.TC_STRING属性代码示例

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


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

示例1: handleStringElement

/*******************
 * Handle a string element.
 * 
 * @param obj The RMIObject to populate with class names.
 ******************/
private void handleStringElement(LinkedList<Byte> dataStack) throws BaRMIeInvalidReplyDataPacketException {
	//Handle a string based on the type
	switch(dataStack.pop()) {
		//Standard string
		case ObjectStreamConstants.TC_STRING:
			this.extractUtf8(dataStack);
			break;
			
		//Long string
		case ObjectStreamConstants.TC_LONGSTRING:
			this.extractLongUtf8(dataStack);
			break;
			
		//References
		case ObjectStreamConstants.TC_REFERENCE:
			this.extractInt(dataStack);
			break;
			
		//Invalid string type
		default:
			throw new BaRMIeInvalidReplyDataPacketException("Invalid string element type.");
	}
}
 
开发者ID:NickstaDB,项目名称:BaRMIe,代码行数:28,代码来源:RMIReplyDataParser.java

示例2: handleClassAnnotation

/*******************
 * Handle a classAnnotation element and return any string annotation
 * elements in the classAnnotation.
 * 
 * @param obj The RMIObject to populate with class names.
 * @param dataStack The remaining data in the ReplyData packet.
 * @return An ArrayList of strings representing any string annotations extracted from the stream.
 ******************/
private ArrayList<String> handleClassAnnotation(RMIObject obj, LinkedList<Byte> dataStack) throws BaRMIeInvalidReplyDataPacketException {
	ArrayList<String> stringAnnotations;
	byte b;
	
	//Create the arraylist
	stringAnnotations = new ArrayList<String>();
	
	//Read elements from the stream until a TC_ENDBLOCKDATA element is read
	while((b = dataStack.pop()) != ObjectStreamConstants.TC_ENDBLOCKDATA) {
		//Handle the annotation
		switch(b) {
			//Read string annotations into an array list to return
			case ObjectStreamConstants.TC_STRING:
				stringAnnotations.add(this.extractUtf8(dataStack));
				break;
				
			//Skip over reference annotations
			case ObjectStreamConstants.TC_REFERENCE:
				//Read past the reference handle
				this.extractInt(dataStack);
				break;
				
			//Ignore null annotations...
			case ObjectStreamConstants.TC_NULL:
				break;
				
			//Unknown annotation type
			default:
				throw new BaRMIeInvalidReplyDataPacketException("Unknown classAnnotation element type (0x" + String.format("%02x", b) + ").");
		}
	}
	
	//Return the string annotations
	return stringAnnotations;
}
 
开发者ID:NickstaDB,项目名称:BaRMIe,代码行数:43,代码来源:RMIReplyDataParser.java

示例3: readObject

@Override
protected Object readObject(ObjectInput in, List<Object> cache, byte version) throws IOException,
		ClassNotFoundException {
	if (in.readByte() == ObjectStreamConstants.TC_STRING) {
		return in.readUTF();
	}
	return super.readObject(in, cache, version);
}
 
开发者ID:kenweezy,项目名称:teiid,代码行数:8,代码来源:BatchSerializer.java

示例4: read_Content

/**
 * <p>
 * Read the next object corresponding to the spec grammar rule "content", and return
 * an object of type content.
 * </p>
 *
 * <p>
 * Usually, there is a 1:1 mapping of content items and returned instances. The
 * one case where this isn't true is when an exception is embedded inside another
 * object. When this is encountered, only the serialized exception object is
 * returned; it's up to the caller to backtrack in order to gather any data from the
 * object that was being serialized when the exception was thrown.
 * </p>
 *
 * @param tc
 *            the last byte read from the stream; it must be one of the TC_* values
 *            within ObjectStreamConstants.*
 * @param dis
 *            the DataInputStream to read from
 * @param blockdata
 *            whether or not to read TC_BLOCKDATA (this is the difference
 *            between spec rules "object" and "content").
 * @return an object representing the last read item from the stream
 * @throws IOException
 *             when a validity or I/O error occurs while reading
 */
public Content read_Content( byte tc, DataInputStream dis, boolean blockdata ) throws IOException
{
	try {
		switch ( tc ) {
			case ObjectStreamConstants.TC_OBJECT:
				return read_newObject( dis );
			case ObjectStreamConstants.TC_CLASS:
				return read_newClass( dis );
			case ObjectStreamConstants.TC_ARRAY:
				return read_newArray( dis );
			case ObjectStreamConstants.TC_STRING:
			case ObjectStreamConstants.TC_LONGSTRING:
				return read_newString( tc, dis );
			case ObjectStreamConstants.TC_ENUM:
				return read_newEnum( dis );
			case ObjectStreamConstants.TC_CLASSDESC:
			case ObjectStreamConstants.TC_PROXYCLASSDESC:
				return handle_newClassDesc( tc, dis );
			case ObjectStreamConstants.TC_REFERENCE:
				return read_prevObject( dis );
			case ObjectStreamConstants.TC_NULL:
				return null;
			case ObjectStreamConstants.TC_EXCEPTION:
				return read_Exception( dis );
			case ObjectStreamConstants.TC_BLOCKDATA:
			case ObjectStreamConstants.TC_BLOCKDATALONG:
				if ( blockdata == false ) {
					throw new IOException( "got a blockdata TC_*, but not allowed here: " + hex( tc ) );
				}
				return read_blockdata( tc, dis );
			default:
				throw new IOException( "unknown content tc byte in stream: " + hex( tc ) );
		}
	}
	catch ( ReadException ere ) {
		return ere.getExceptionObject();
	}
}
 
开发者ID:kartoFlane,项目名称:superluminal2,代码行数:64,代码来源:JDeserialize.java


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