本文整理汇总了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!" );
}
}
}
示例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;
}