# ObjectStreamField

public class **ObjectStreamField** extends [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html)  
implements [Comparable](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Comparable.html)\<[Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html)\> A description of a Serializable field from a Serializable class. An array
of ObjectStreamFields is used to declare the Serializable fields of a class.

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/java/io/ObjectStreamClass.html`

### Public Constructor Summary

|---|---|
|   | [ObjectStreamField](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/ObjectStreamField.html#ObjectStreamField(java.lang.String,%20java.lang.Class<?>))([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) name, [Class](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Class.html)\<?\> type) Create a Serializable field with the specified type. |
|   | [ObjectStreamField](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/ObjectStreamField.html#ObjectStreamField(java.lang.String,%20java.lang.Class<?>,%20boolean))([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) name, [Class](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Class.html)\<?\> type, boolean unshared) Creates an ObjectStreamField representing a serializable field with the given name and type. |

### Public Method Summary

|---|---|
| int | [compareTo](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/ObjectStreamField.html#compareTo(java.lang.Object))([Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) obj) Compare this field with another `ObjectStreamField`. |
| [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) | [getName](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/ObjectStreamField.html#getName())() Get the name of this field. |
| int | [getOffset](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/ObjectStreamField.html#getOffset())() Offset of field within instance data. |
| [Class](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Class.html)\<?\> | [getType](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/ObjectStreamField.html#getType())() Get the type of the field. |
| char | [getTypeCode](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/ObjectStreamField.html#getTypeCode())() Returns character encoding of field type. |
| [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) | [getTypeString](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/ObjectStreamField.html#getTypeString())() Return the JVM type signature. |
| boolean | [isPrimitive](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/ObjectStreamField.html#isPrimitive())() Return true if this field has a primitive type. |
| boolean | [isUnshared](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/ObjectStreamField.html#isUnshared())() Returns boolean value indicating whether or not the serializable field represented by this ObjectStreamField instance is unshared. |
| [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) | [toString](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/ObjectStreamField.html#toString())() Return a string that describes this field. |

### Protected Method Summary

|---|---|
| void | [setOffset](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/ObjectStreamField.html#setOffset(int))(int offset) Offset within instance data. |

### Inherited Method Summary

From class [java.lang.Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html)

|---|---|
| [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) | [clone](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#clone())() Creates and returns a copy of this `Object`. |
| boolean | [equals](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#equals(java.lang.Object))([Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) obj) Compares this instance with the specified object and indicates if they are equal. |
| void | [finalize](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#finalize())() Invoked when the garbage collector has detected that this instance is no longer reachable. |
| final [Class](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Class.html)\<?\> | [getClass](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#getClass())() Returns the unique instance of `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Class.html` that represents this object's class. |
| int | [hashCode](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#hashCode())() Returns an integer hash code for this object. |
| final void | [notify](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#notify())() Causes a thread which is waiting on this object's monitor (by means of calling one of the `wait()` methods) to be woken up. |
| final void | [notifyAll](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#notifyAll())() Causes all threads which are waiting on this object's monitor (by means of calling one of the `wait()` methods) to be woken up. |
| [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) | [toString](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#toString())() Returns a string containing a concise, human-readable description of this object. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait(long,%20int))(long timeout, int nanos) Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object or until the specified timeout expires. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait(long))(long timeout) Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object or until the specified timeout expires. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait())() Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object. |

From interface [java.lang.Comparable](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Comparable.html)

|---|---|
| abstract int | [compareTo](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Comparable.html#compareTo(T))([Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) o) Compares this object with the specified object for order. |

## Public Constructors

#### public
**ObjectStreamField**
([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) name, [Class](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Class.html)\<?\> type)

Create a Serializable field with the specified type. This field should
be documented with a `serialField` tag.

##### Parameters

| name | the name of the serializable field |
| type | the `Class` object of the serializable field |
|---|---|

#### public
**ObjectStreamField**
([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) name, [Class](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Class.html)\<?\> type, boolean unshared)

Creates an ObjectStreamField representing a serializable field with the
given name and type. If unshared is false, values of the represented
field are serialized and deserialized in the default manner--if the
field is non-primitive, object values are serialized and deserialized as
if they had been written and read by calls to writeObject and
readObject. If unshared is true, values of the represented field are
serialized and deserialized as if they had been written and read by
calls to writeUnshared and readUnshared.

##### Parameters

| name | field name |
| type | field type |
| unshared | if false, write/read field values in the same manner as writeObject/readObject; if true, write/read in the same manner as writeUnshared/readUnshared |
|---|---|

## Public Methods

#### public int
**compareTo**
([Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) obj)

Compare this field with another `ObjectStreamField`. Return
-1 if this is smaller, 0 if equal, 1 if greater. Types that are
primitives are "smaller" than object types. If equal, the field names
are compared.

##### Parameters

| obj |   |
|---|---|

#### public [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html)
**getName**
()

Get the name of this field.

##### Returns

- a `String` representing the name of the serializable field

#### public int
**getOffset**
()

Offset of field within instance data.

##### Returns

- the offset of this field

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/java/io/ObjectStreamField.html#setOffset(int)`

#### public [Class](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Class.html)\<?\>
**getType**
()

Get the type of the field. If the type is non-primitive and this
`ObjectStreamField` was obtained from a deserialized `https://developers.google.com/j2objc/javadoc/jre/reference/java/io/ObjectStreamClass.html` instance, then `Object.class` is returned.
Otherwise, the `Class` object for the type of the field is
returned.

##### Returns

- a `Class` object representing the type of the serializable field

#### public char
**getTypeCode**
()

Returns character encoding of field type. The encoding is as follows:
>
> ```
>  B            byte
>  C            char
>  D            double
>  F            float
>  I            int
>  J            long
>  L            class or interface
>  S            short
>  Z            boolean
>  [            array
>  
> ```

<br />

##### Returns

- the typecode of the serializable field

#### public [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html)
**getTypeString**
()

Return the JVM type signature.

##### Returns

- null if this field has a primitive type.

#### public boolean
**isPrimitive**
()

Return true if this field has a primitive type.

##### Returns

- true if and only if this field corresponds to a primitive type

#### public boolean
**isUnshared**
()

Returns boolean value indicating whether or not the serializable field
represented by this ObjectStreamField instance is unshared.

##### Returns

- `true` if this field is unshared

#### public [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html)
**toString**
()

Return a string that describes this field.

##### Returns

- a printable representation of this object.

## Protected Methods

#### protected void
**setOffset**
(int offset)

Offset within instance data.

##### Parameters

| offset | the offset of the field |
|---|---|

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/java/io/ObjectStreamField.html#getOffset()`