當前位置: 首頁>>代碼示例>>Java>>正文


Java ObjectStreamConstants.SC_SERIALIZABLE屬性代碼示例

本文整理匯總了Java中java.io.ObjectStreamConstants.SC_SERIALIZABLE屬性的典型用法代碼示例。如果您正苦於以下問題:Java ObjectStreamConstants.SC_SERIALIZABLE屬性的具體用法?Java ObjectStreamConstants.SC_SERIALIZABLE怎麽用?Java ObjectStreamConstants.SC_SERIALIZABLE使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在java.io.ObjectStreamConstants的用法示例。


在下文中一共展示了ObjectStreamConstants.SC_SERIALIZABLE屬性的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: validate

public void validate() throws ValidityException
{
	// If neither SC_SERIALIZABLE nor SC_EXTERNALIZABLE is set, then the number of
	// fields is always zero. (spec section 4.3)
	if ( ( descflags & ( ObjectStreamConstants.SC_SERIALIZABLE | ObjectStreamConstants.SC_EXTERNALIZABLE ) ) == 0 && fields != null
		&& fields.length > 0 ) {
		throw new ValidityException( "non-serializable, non-externalizable class has fields!" );
	}
	if ( ( descflags
		& ( ObjectStreamConstants.SC_SERIALIZABLE | ObjectStreamConstants.SC_EXTERNALIZABLE ) ) == ( ObjectStreamConstants.SC_SERIALIZABLE
			| ObjectStreamConstants.SC_EXTERNALIZABLE ) ) {
		throw new ValidityException( "both Serializable and Externalizable are set!" );
	}
	if ( ( descflags & ObjectStreamConstants.SC_ENUM ) != 0 ) {
		// we're an enum; shouldn't have any fields/superinterfaces
		if ( ( fields != null && fields.length > 0 ) || interfaces != null ) {
			throw new ValidityException( "enums shouldn't implement interfaces or have non-constant fields!" );
		}
	}
	else {
		// non-enums shouldn't have enum constant fields.
		if ( enumconstants != null && enumconstants.size() > 0 ) {
			throw new ValidityException( "non-enum classes shouldn't have enum constants!" );
		}
	}
}
 
開發者ID:kartoFlane,項目名稱:superluminal2,代碼行數:26,代碼來源:ClassDesc.java

示例2: read_Classdata

public void read_Classdata( DataInputStream dis, Instance inst ) throws IOException
{
	ArrayList<ClassDesc> classes = new ArrayList<ClassDesc>();
	inst.classdesc.getHierarchy( classes );
	Map<ClassDesc, Map<Field, Object>> alldata = new HashMap<ClassDesc, Map<Field, Object>>();
	Map<ClassDesc, List<Content>> ann = new HashMap<ClassDesc, List<Content>>();
	for ( ClassDesc cd : classes ) {
		Map<Field, Object> values = new HashMap<Field, Object>();
		if ( ( cd.descflags & ObjectStreamConstants.SC_SERIALIZABLE ) != 0 ) {
			if ( ( cd.descflags & ObjectStreamConstants.SC_EXTERNALIZABLE ) != 0 ) {
				throw new IOException( "SC_EXTERNALIZABLE & SC_SERIALIZABLE encountered" );
			}
			for ( Field f : cd.fields ) {
				Object o = read_FieldValue( f.type, dis );
				values.put( f, o );
			}
			alldata.put( cd, values );
			if ( ( cd.descflags & ObjectStreamConstants.SC_WRITE_METHOD ) != 0 ) {
				if ( ( cd.descflags & ObjectStreamConstants.SC_ENUM ) != 0 ) {
					throw new IOException( "SC_ENUM & SC_WRITE_METHOD encountered!" );
				}
				ann.put( cd, read_classAnnotation( dis ) );
			}
		}
		else if ( ( cd.descflags & ObjectStreamConstants.SC_EXTERNALIZABLE ) != 0 ) {
			if ( ( cd.descflags & ObjectStreamConstants.SC_SERIALIZABLE ) != 0 ) {
				throw new IOException( "SC_SERIALIZABLE & SC_EXTERNALIZABLE encountered" );
			}
			if ( ( cd.descflags & ObjectStreamConstants.SC_BLOCK_DATA ) != 0 ) {
				throw new EOFException( "hit externalizable with nonzero SC_BLOCK_DATA; can't interpret data" );
			}
			else {
				ann.put( cd, read_classAnnotation( dis ) );
			}
		}
	}
	inst.annotations = ann;
	inst.fielddata = alldata;
}
 
開發者ID:kartoFlane,項目名稱:superluminal2,代碼行數:39,代碼來源:JDeserialize.java


注:本文中的java.io.ObjectStreamConstants.SC_SERIALIZABLE屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。