GemFire 6.6.3

com.gemstone.gemfire.pdx
Interface PdxSerializable


public interface PdxSerializable

When a domain class implements PdxSerializable it marks itself as a PDX. The implementation of toData provides the serialization code and fromData provides the deserialization code. These methods also define each field name and field type of the PDX. Domain classes should serialize and deserialize all its member fields in the same order in toData and fromData method. Also fromData and toData must read and write the same fields each time they are called. A domain class that implements this interface must also have a public zero-arg constructor which is used during deserialization.

Simple example:

public class User implements PdxSerializable {
  private String name;
  private int userId;

  public User() {
  }

  public void toData(PdxWriter out) {
    out.writeString("name", this.name);
    out.writeInt("userId", this.userId);
  }

  public void fromData(PdxReader in) {
    this.name = in.readString("name");
    this.userId = in.readInt("userId");
  }
}
 

Since:
6.6

Method Summary
 void fromData(PdxReader reader)
          Deserializes the PDX fields using the given reader.
 void toData(PdxWriter writer)
          Serializes the PDX fields using the given writer.
 

Method Detail

toData

void toData(PdxWriter writer)
Serializes the PDX fields using the given writer.

Parameters:
writer - the PdxWriter to use to write the PDX fields.

fromData

void fromData(PdxReader reader)
Deserializes the PDX fields using the given reader.

Parameters:
reader - the PdxReader to use to read the PDX fields.

GemFire 6.6.3

Copyright © 1997-2012 VMware, Inc. All rights reserved.