本文整理汇总了Java中java.io.ObjectStreamConstants.TC_CLASSDESC属性的典型用法代码示例。如果您正苦于以下问题:Java ObjectStreamConstants.TC_CLASSDESC属性的具体用法?Java ObjectStreamConstants.TC_CLASSDESC怎么用?Java ObjectStreamConstants.TC_CLASSDESC使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类java.io.ObjectStreamConstants
的用法示例。
在下文中一共展示了ObjectStreamConstants.TC_CLASSDESC属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleClassDesc
/*******************
* Handle a classDesc element.
*
* @param obj The RMIObject to populate with class names.
* @param dataStack The remaining data in the ReplyData packet.
******************/
private void handleClassDesc(RMIObject obj, LinkedList<Byte> dataStack) throws BaRMIeInvalidReplyDataPacketException {
String className;
//Delegate depending on the type of classDesc
switch(dataStack.pop()) {
//ClassDesc
case ObjectStreamConstants.TC_CLASSDESC:
//Read the class name
className = this.extractUtf8(dataStack);
//Skip over the serialVersionUID
this.extractLong(dataStack);
//Handle the classDescInfo element, pass the class name in as there may be annotations for the class in there
this.handleClassDescInfo(obj, dataStack, className);
break;
//ProxyClassDesc
case ObjectStreamConstants.TC_PROXYCLASSDESC:
//Handle the proxyClassDescInfo element
this.handleProxyClassDescInfo(obj, dataStack);
break;
//Null - e.g. when the super class is null
case ObjectStreamConstants.TC_NULL:
break;
//Unknown classDesc type
default:
throw new BaRMIeInvalidReplyDataPacketException("Unknown classDesc element type.");
}
}
示例2: main
public static void main(String[] args) {
byte[] ref = new byte[4];
ref[0] = ObjectStreamConstants.TC_BASE;
ref[1] = ObjectStreamConstants.TC_NULL;
ref[2] = ObjectStreamConstants.TC_REFERENCE;
ref[3] = ObjectStreamConstants.TC_CLASSDESC;
int version = ObjectStreamConstants.PROTOCOL_VERSION_1;
}
示例3: 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();
}
}