Skip to content

Most visited

Recently visited

navigation
Added in API level 1

ObjectStreamField

public class ObjectStreamField
extends Object implements Comparable<Object>

java.lang.Object
   ↳ java.io.ObjectStreamField


Describes a field for the purpose of serialization. Classes can define the collection of fields that are serialized, which may be different from the set of all declared fields.

See also:

Summary

Public constructors

ObjectStreamField(String name, Class<?> cl)

Constructs an ObjectStreamField with the specified name and type.

ObjectStreamField(String name, Class<?> cl, boolean unshared)

Constructs an ObjectStreamField with the specified name, type and the indication if it is unshared.

Public methods

int compareTo(Object o)

Compares this field descriptor to the specified one.

String getName()

Gets the name of this field.

int getOffset()

Gets the offset of this field in the object.

Class<?> getType()

Gets the type of this field.

char getTypeCode()

Gets a character code for the type of this field.

String getTypeString()

Gets the type signature used by the VM to represent the type of this field.

boolean isPrimitive()

Indicates whether this field's type is a primitive type.

boolean isUnshared()

Indicates whether this field is unshared.

String toString()

Returns a string containing a concise, human-readable description of this field descriptor.

Protected methods

void setOffset(int newValue)

Sets this field's offset in the object.

Inherited methods

From class java.lang.Object
From interface java.lang.Comparable

Public constructors

ObjectStreamField

Added in API level 1
ObjectStreamField (String name, 
                Class<?> cl)

Constructs an ObjectStreamField with the specified name and type.

Parameters
name String: the name of the field.
cl Class: the type of the field.
Throws
NullPointerException if name or cl is null.

ObjectStreamField

Added in API level 1
ObjectStreamField (String name, 
                Class<?> cl, 
                boolean unshared)

Constructs an ObjectStreamField with the specified name, type and the indication if it is unshared.

Parameters
name String: the name of the field.
cl Class: the type of the field.
unshared boolean: true if the field is written and read unshared; false otherwise.
Throws
NullPointerException if name or cl is null.

See also:

Public methods

compareTo

Added in API level 1
int compareTo (Object o)

Compares this field descriptor to the specified one. Checks first if one of the compared fields has a primitive type and the other one not. If so, the field with the primitive type is considered to be "smaller". If both fields are equal, their names are compared.

Parameters
o Object: the object to compare with.
Returns
int -1 if this field is "smaller" than field o, 0 if both fields are equal; 1 if this field is "greater" than field o.

getName

Added in API level 1
String getName ()

Gets the name of this field.

Returns
String the field's name.

getOffset

Added in API level 1
int getOffset ()

Gets the offset of this field in the object.

Returns
int this field's offset.

getType

Added in API level 1
Class<?> getType ()

Gets the type of this field.

Returns
Class<?> a Class object representing the type of the field.

getTypeCode

Added in API level 1
char getTypeCode ()

Gets a character code for the type of this field. The following codes are used:

 B     byte
 C     char
 D     double
 F     float
 I     int
 J     long
 L     class or interface
 S     short
 Z     boolean
 [     array
 

Returns
char the field's type code.

getTypeString

Added in API level 1
String getTypeString ()

Gets the type signature used by the VM to represent the type of this field.

Returns
String the signature of this field's class or null if this field's type is primitive.

isPrimitive

Added in API level 1
boolean isPrimitive ()

Indicates whether this field's type is a primitive type.

Returns
boolean true if this field's type is primitive; false if the type of this field is a regular class.

isUnshared

Added in API level 1
boolean isUnshared ()

Indicates whether this field is unshared.

Returns
boolean true if this field is unshared, false otherwise.

toString

Added in API level 1
String toString ()

Returns a string containing a concise, human-readable description of this field descriptor.

Returns
String a printable representation of this descriptor.

Protected methods

setOffset

Added in API level 1
void setOffset (int newValue)

Sets this field's offset in the object.

Parameters
newValue int: the field's new offset.
This site uses cookies to store your preferences for site-specific language and display options.

Hooray!

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.