Build 1.0_r1(from source)

java.io
Class EmulatedFields

java.lang.Object
  extended by java.io.EmulatedFields

 class EmulatedFields
extends Object

An EmulatedFields is an object that represents a set of emulated fields for an object being dumped or loaded. It allows objects to be dumped with a shape different than the fields they were declared to have.

See Also:
ObjectInputStream.GetField, ObjectOutputStream.PutField, EmulatedFieldsForLoading, EmulatedFieldsForDumping

Nested Class Summary
(package private) static class EmulatedFields.ObjectSlot
           
 
Constructor Summary
EmulatedFields(ObjectStreamField[] fields, ObjectStreamField[] declared)
          Constructs a new instance of EmulatedFields.
 
Method Summary
 boolean defaulted(String name)
          Return a boolean indicating if the field named name has been assigned a value explicitly (false) or if it still holds a default value for the type (true) because it hasn't been assigned to yet.
 boolean get(String name, boolean defaultValue)
          Find and return the boolean value of a given field named name in the receiver.
 byte get(String name, byte defaultValue)
          Find and return the byte value of a given field named name in the receiver.
 char get(String name, char defaultValue)
          Find and return the char value of a given field named name in the receiver.
 double get(String name, double defaultValue)
          Find and return the double value of a given field named name in the receiver.
 float get(String name, float defaultValue)
          Find and return the float value of a given field named name in the receiver.
 int get(String name, int defaultValue)
          Find and return the int value of a given field named name in the receiver.
 long get(String name, long defaultValue)
          Find and return the long value of a given field named name in the receiver.
 Object get(String name, Object defaultValue)
          Find and return the Object value of a given field named name in the receiver.
 short get(String name, short defaultValue)
          Find and return the short value of a given field named name in the receiver.
 void put(String name, boolean value)
          Find and set the boolean value of a given field named name in the receiver.
 void put(String name, byte value)
          Find and set the byte value of a given field named name in the receiver.
 void put(String name, char value)
          Find and set the char value of a given field named name in the receiver.
 void put(String name, double value)
          Find and set the double value of a given field named name in the receiver.
 void put(String name, float value)
          Find and set the float value of a given field named name in the receiver.
 void put(String name, int value)
          Find and set the int value of a given field named name in the receiver.
 void put(String name, long value)
          Find and set the long value of a given field named name in the receiver.
 void put(String name, Object value)
          Find and set the Object value of a given field named name in the receiver.
 void put(String name, short value)
          Find and set the short value of a given field named name in the receiver.
 EmulatedFields.ObjectSlot[] slots()
          Return the array of ObjectSlot the receiver represents.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EmulatedFields

public EmulatedFields(ObjectStreamField[] fields,
                      ObjectStreamField[] declared)
Constructs a new instance of EmulatedFields.

Parameters:
fields - an array of ObjectStreamFields, which describe the fields to be emulated (names, types, etc).
declared - an array of ObjectStreamFields, which describe the declared fields.
Method Detail

defaulted

public boolean defaulted(String name)
                  throws IllegalArgumentException
Return a boolean indicating if the field named name has been assigned a value explicitly (false) or if it still holds a default value for the type (true) because it hasn't been assigned to yet.

Parameters:
name - a String, the name of the field to test
Returns:
true if name still holds its default value, false otherwise
Throws:
IllegalArgumentException - If name is null

get

public byte get(String name,
                byte defaultValue)
         throws IllegalArgumentException
Find and return the byte value of a given field named name in the receiver. If the field has not been assigned any value yet, the default value defaultValue is returned instead.

Parameters:
name - A String, the name of the field to find
defaultValue - Return value in case the field has not been assigned to yet.
Returns:
the value of the given field if it has been assigned, the default value otherwise
Throws:
IllegalArgumentException - If the corresponding field can not be found.

get

public char get(String name,
                char defaultValue)
         throws IllegalArgumentException
Find and return the char value of a given field named name in the receiver. If the field has not been assigned any value yet, the default value defaultValue is returned instead.

Parameters:
name - A String, the name of the field to find
defaultValue - Return value in case the field has not been assigned to yet.
Returns:
the value of the given field if it has been assigned, the default value otherwise
Throws:
IllegalArgumentException - If the corresponding field can not be found.

get

public double get(String name,
                  double defaultValue)
           throws IllegalArgumentException
Find and return the double value of a given field named name in the receiver. If the field has not been assigned any value yet, the default value defaultValue is returned instead.

Parameters:
name - A String, the name of the field to find
defaultValue - Return value in case the field has not been assigned to yet.
Returns:
the value of the given field if it has been assigned, the default value otherwise
Throws:
IllegalArgumentException - If the corresponding field can not be found.

get

public float get(String name,
                 float defaultValue)
          throws IllegalArgumentException
Find and return the float value of a given field named name in the receiver. If the field has not been assigned any value yet, the default value defaultValue is returned instead.

Parameters:
name - A String, the name of the field to find
defaultValue - Return value in case the field has not been assigned to yet.
Returns:
the value of the given field if it has been assigned, the default value otherwise
Throws:
IllegalArgumentException - If the corresponding field can not be found.

get

public int get(String name,
               int defaultValue)
        throws IllegalArgumentException
Find and return the int value of a given field named name in the receiver. If the field has not been assigned any value yet, the default value defaultValue is returned instead.

Parameters:
name - A String, the name of the field to find
defaultValue - Return value in case the field has not been assigned to yet.
Returns:
the value of the given field if it has been assigned, the default value otherwise
Throws:
IllegalArgumentException - If the corresponding field can not be found.

get

public long get(String name,
                long defaultValue)
         throws IllegalArgumentException
Find and return the long value of a given field named name in the receiver. If the field has not been assigned any value yet, the default value defaultValue is returned instead.

Parameters:
name - A String, the name of the field to find
defaultValue - Return value in case the field has not been assigned to yet.
Returns:
the value of the given field if it has been assigned, the default value otherwise
Throws:
IllegalArgumentException - If the corresponding field can not be found.

get

public Object get(String name,
                  Object defaultValue)
           throws IllegalArgumentException
Find and return the Object value of a given field named name in the receiver. If the field has not been assigned any value yet, the default value defaultValue is returned instead.

Parameters:
name - A String, the name of the field to find
defaultValue - Return value in case the field has not been assigned to yet.
Returns:
the value of the given field if it has been assigned, the default value otherwise
Throws:
IllegalArgumentException - If the corresponding field can not be found.

get

public short get(String name,
                 short defaultValue)
          throws IllegalArgumentException
Find and return the short value of a given field named name in the receiver. If the field has not been assigned any value yet, the default value defaultValue is returned instead.

Parameters:
name - A String, the name of the field to find
defaultValue - Return value in case the field has not been assigned to yet.
Returns:
the value of the given field if it has been assigned, the default value otherwise
Throws:
IllegalArgumentException - If the corresponding field can not be found.

get

public boolean get(String name,
                   boolean defaultValue)
            throws IllegalArgumentException
Find and return the boolean value of a given field named name in the receiver. If the field has not been assigned any value yet, the default value defaultValue is returned instead.

Parameters:
name - A String, the name of the field to find
defaultValue - Return value in case the field has not been assigned to yet.
Returns:
the value of the given field if it has been assigned, the default value otherwise
Throws:
IllegalArgumentException - If the corresponding field can not be found.

put

public void put(String name,
                byte value)
         throws IllegalArgumentException
Find and set the byte value of a given field named name in the receiver.

Parameters:
name - A String, the name of the field to set
value - New value for the field.
Throws:
IllegalArgumentException - If the corresponding field can not be found.

put

public void put(String name,
                char value)
         throws IllegalArgumentException
Find and set the char value of a given field named name in the receiver.

Parameters:
name - A String, the name of the field to set
value - New value for the field.
Throws:
IllegalArgumentException - If the corresponding field can not be found.

put

public void put(String name,
                double value)
         throws IllegalArgumentException
Find and set the double value of a given field named name in the receiver.

Parameters:
name - A String, the name of the field to set
value - New value for the field.
Throws:
IllegalArgumentException - If the corresponding field can not be found.

put

public void put(String name,
                float value)
         throws IllegalArgumentException
Find and set the float value of a given field named name in the receiver.

Parameters:
name - A String, the name of the field to set
value - New value for the field.
Throws:
IllegalArgumentException - If the corresponding field can not be found.

put

public void put(String name,
                int value)
         throws IllegalArgumentException
Find and set the int value of a given field named name in the receiver.

Parameters:
name - A String, the name of the field to set
value - New value for the field.
Throws:
IllegalArgumentException - If the corresponding field can not be found.

put

public void put(String name,
                long value)
         throws IllegalArgumentException
Find and set the long value of a given field named name in the receiver.

Parameters:
name - A String, the name of the field to set
value - New value for the field.
Throws:
IllegalArgumentException - If the corresponding field can not be found.

put

public void put(String name,
                Object value)
         throws IllegalArgumentException
Find and set the Object value of a given field named name in the receiver.

Parameters:
name - A String, the name of the field to set
value - New value for the field.
Throws:
IllegalArgumentException - If the corresponding field can not be found.

put

public void put(String name,
                short value)
         throws IllegalArgumentException
Find and set the short value of a given field named name in the receiver.

Parameters:
name - A String, the name of the field to set
value - New value for the field.
Throws:
IllegalArgumentException - If the corresponding field can not be found.

put

public void put(String name,
                boolean value)
         throws IllegalArgumentException
Find and set the boolean value of a given field named name in the receiver.

Parameters:
name - A String, the name of the field to set
value - New value for the field.
Throws:
IllegalArgumentException - If the corresponding field can not be found.

slots

public EmulatedFields.ObjectSlot[] slots()
Return the array of ObjectSlot the receiver represents.

Returns:
array of ObjectSlot the receiver represents.

Build 1.0_r1(from source)

Please submit a feedback, bug or feature