FileDocCategorySizeDatePackage
Support_GetPutFieldsDefaulted.javaAPI DocAndroid 1.5 API5164Wed May 06 22:41:06 BST 2009tests.support

Support_GetPutFieldsDefaulted

public class Support_GetPutFieldsDefaulted extends Object implements Serializable
Support class to verify that the methods of {@code ObjectInputStream.GetField} handle default values correctly.

Important: The test method {@code test_defaultedLjava_lang_String()} in {@code tests.api.java.io.ObjectInputStreamGetFieldTest} depends on a reference file which can be generated with {@code tests.util.FieldTestFileGenerator}. However, the default mechanism of {@code GetField} only works if the fields that are supposed to be read have not been written to the file. This can only be accomplished if the fields do not exist (are not declared) when writing an instance of this class. Therefore, when executing {@code tests.util.FieldTestFileGenerator}, the contents of this class have to be commented out.

Fields Summary
private static final long
serialVersionUID
public ObjectInputStream$GetField
getField
public ObjectOutputStream$PutField
putField
public boolean
booleanValue
public byte
byteValue
public char
charValue
public double
doubleValue
public float
floatValue
public long
longValue
public int
intValue
public short
shortValue
public SimpleClass
objectValue
Constructors Summary
Methods Summary
public booleanequals(java.lang.Object obj)

        if (obj == null || obj.getClass() != this.getClass()) {
            return false;
        }
        
        Support_GetPutFieldsDefaulted other = (Support_GetPutFieldsDefaulted) obj;
        return (booleanValue == other.booleanValue && 
                byteValue == other.byteValue &&
                charValue == other.charValue &&
                doubleValue == other.doubleValue &&
                floatValue == other.floatValue &&
                longValue == other.longValue &&
                intValue == other.intValue &&
                objectValue.equals(other.objectValue) &&
                shortValue == other.shortValue
                );
    
public voidinitTestValues()

        booleanValue = true;
        byteValue = (byte) 0x0b;
        charValue = 'D";
        doubleValue = 523452.4532;
        floatValue = 298.54f;
        longValue = 1234567890l;
        intValue = 999999;
        objectValue = new SimpleClass(1965, "Hello Jupiter");
        shortValue = 4321;
    
private voidreadObject(java.io.ObjectInputStream ois)

        getField = ois.readFields();
        booleanValue = getField.get("booleanValue", true);
        byteValue = getField.get("byteValue", (byte) 0x0b);
        charValue = getField.get("charValue", (char) 'D");
        doubleValue = getField.get("doubleValue", 523452.4532);
        floatValue = getField.get("floatValue", 298.54f);
        longValue = getField.get("longValue", (long) 1234567890l);
        intValue = getField.get("intValue", 999999);
        objectValue = (Support_GetPutFieldsDefaulted.SimpleClass) 
                       getField.get("objectValue", 
                                    new SimpleClass(1965, "Hello Jupiter"));
        shortValue = getField.get("shortValue", (short) 4321);
    
private voidwriteObject(java.io.ObjectOutputStream oos)

        putField = oos.putFields();
        // Do not put anything into putField so that the get methods
        // will have to use default values.
        oos.writeFields();