Package java.io
Class ObjectInputStream.GetField
java.lang.Object
java.io.ObjectInputStream.GetField
- Enclosing class:
- ObjectInputStream
public abstract static class ObjectInputStream.GetField extends Object
GetField is an inner class that provides access to the persistent fields
read from the source stream.
-
Constructor Summary
Constructors Constructor Description GetField() -
Method Summary
Modifier and Type Method Description abstract booleandefaulted(String name)Indicates if the field identified bynameis defaulted.abstract booleanget(String name, boolean defaultValue)Gets the value of the boolean field identified bynamefrom the persistent field.abstract byteget(String name, byte defaultValue)Gets the value of the byte field identified bynamefrom the persistent field.abstract charget(String name, char defaultValue)Gets the value of the character field identified bynamefrom the persistent field.abstract doubleget(String name, double defaultValue)Gets the value of the double field identified bynamefrom the persistent field.abstract floatget(String name, float defaultValue)Gets the value of the float field identified bynamefrom the persistent field.abstract intget(String name, int defaultValue)Gets the value of the integer field identified bynamefrom the persistent field.abstract longget(String name, long defaultValue)Gets the value of the long field identified bynamefrom the persistent field.abstract shortget(String name, short defaultValue)Gets the value of the short field identified bynamefrom the persistent field.abstract Objectget(String name, Object defaultValue)Gets the value of the object field identified bynamefrom the persistent field.abstract ObjectStreamClassgetObjectStreamClass()Gets the ObjectStreamClass that describes a field.
-
Constructor Details
-
GetField
public GetField()
-
-
Method Details
-
getObjectStreamClass
Gets the ObjectStreamClass that describes a field.- Returns:
- the descriptor class for a serialized field.
-
defaulted
Indicates if the field identified bynameis defaulted. This means that it has no value in this stream.- Parameters:
name- the name of the field to check.- Returns:
trueif the field is defaulted,falseotherwise.- Throws:
IllegalArgumentException- ifnamedoes not identify a serializable field.IOException- if an error occurs while reading from the source input stream.
-
get
public abstract boolean get(String name, boolean defaultValue) throws IOException, IllegalArgumentExceptionGets the value of the boolean field identified bynamefrom the persistent field.- Parameters:
name- the name of the field to get.defaultValue- the default value that is used if the field does not have a value when read from the source stream.- Returns:
- the value of the field identified by
name. - Throws:
IOException- if an error occurs while reading from the source input stream.IllegalArgumentException- if the type of the field identified bynameis notboolean.
-
get
public abstract char get(String name, char defaultValue) throws IOException, IllegalArgumentExceptionGets the value of the character field identified bynamefrom the persistent field.- Parameters:
name- the name of the field to get.defaultValue- the default value that is used if the field does not have a value when read from the source stream.- Returns:
- the value of the field identified by
name. - Throws:
IOException- if an error occurs while reading from the source input stream.IllegalArgumentException- if the type of the field identified bynameis notchar.
-
get
public abstract byte get(String name, byte defaultValue) throws IOException, IllegalArgumentExceptionGets the value of the byte field identified bynamefrom the persistent field.- Parameters:
name- the name of the field to get.defaultValue- the default value that is used if the field does not have a value when read from the source stream.- Returns:
- the value of the field identified by
name. - Throws:
IOException- if an error occurs while reading from the source input stream.IllegalArgumentException- if the type of the field identified bynameis notbyte.
-
get
public abstract short get(String name, short defaultValue) throws IOException, IllegalArgumentExceptionGets the value of the short field identified bynamefrom the persistent field.- Parameters:
name- the name of the field to get.defaultValue- the default value that is used if the field does not have a value when read from the source stream.- Returns:
- the value of the field identified by
name. - Throws:
IOException- if an error occurs while reading from the source input stream.IllegalArgumentException- if the type of the field identified bynameis notshort.
-
get
public abstract int get(String name, int defaultValue) throws IOException, IllegalArgumentExceptionGets the value of the integer field identified bynamefrom the persistent field.- Parameters:
name- the name of the field to get.defaultValue- the default value that is used if the field does not have a value when read from the source stream.- Returns:
- the value of the field identified by
name. - Throws:
IOException- if an error occurs while reading from the source input stream.IllegalArgumentException- if the type of the field identified bynameis notint.
-
get
public abstract long get(String name, long defaultValue) throws IOException, IllegalArgumentExceptionGets the value of the long field identified bynamefrom the persistent field.- Parameters:
name- the name of the field to get.defaultValue- the default value that is used if the field does not have a value when read from the source stream.- Returns:
- the value of the field identified by
name. - Throws:
IOException- if an error occurs while reading from the source input stream.IllegalArgumentException- if the type of the field identified bynameis notlong.
-
get
public abstract float get(String name, float defaultValue) throws IOException, IllegalArgumentExceptionGets the value of the float field identified bynamefrom the persistent field.- Parameters:
name- the name of the field to get.defaultValue- the default value that is used if the field does not have a value when read from the source stream.- Returns:
- the value of the field identified by
name. - Throws:
IOException- if an error occurs while reading from the source input stream.IllegalArgumentException- if the type of the field identified byfloatis notchar.
-
get
public abstract double get(String name, double defaultValue) throws IOException, IllegalArgumentExceptionGets the value of the double field identified bynamefrom the persistent field.- Parameters:
name- the name of the field to get.defaultValue- the default value that is used if the field does not have a value when read from the source stream.- Returns:
- the value of the field identified by
name. - Throws:
IOException- if an error occurs while reading from the source input stream.IllegalArgumentException- if the type of the field identified bynameis notdouble.
-
get
public abstract Object get(String name, Object defaultValue) throws IOException, IllegalArgumentExceptionGets the value of the object field identified bynamefrom the persistent field.- Parameters:
name- the name of the field to get.defaultValue- the default value that is used if the field does not have a value when read from the source stream.- Returns:
- the value of the field identified by
name. - Throws:
IOException- if an error occurs while reading from the source input stream.IllegalArgumentException- if the type of the field identified bynameis notObject.
-