public class ObjectStreamField extends Object implements Comparable<Object>
Constructor and Description |
---|
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.
|
Modifier and Type | Method and Description |
---|---|
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.
|
protected void |
setOffset(int newValue)
Sets this field's offset in the object.
|
String |
toString()
Returns a string containing a concise, human-readable description of this
field descriptor.
|
public ObjectStreamField(String name, Class<?> cl)
name
- the name of the field.cl
- the type of the field.NullPointerException
- if name
or cl
is null
.public ObjectStreamField(String name, Class<?> cl, boolean unshared)
name
- the name of the field.cl
- the type of the field.unshared
- true
if the field is written and read unshared;
false
otherwise.NullPointerException
- if name
or cl
is null
.ObjectOutputStream.writeUnshared(Object)
public int compareTo(Object o)
compareTo
in interface Comparable<Object>
o
- the object to compare with.o
, 0 if both
fields are equal; 1 if this field is "greater" than field o
.public String getName()
public int getOffset()
public Class<?> getType()
Class
object representing the type of the field.public char getTypeCode()
B byte C char D double F float I int J long L class or interface S short Z boolean [ array
public String getTypeString()
null
if this
field's type is primitive.public boolean isPrimitive()
true
if this field's type is primitive; false
if
the type of this field is a regular class.protected void setOffset(int newValue)
newValue
- the field's new offset.public String toString()
public boolean isUnshared()
true
if this field is unshared, false
otherwise.