package bid;

import com.ibm.tspaces.*;
import java.io.Serializable;

/**
 * Title:        TSpaces bid.com
 * Description:  A prototypical bid system implemented using IBM TSpaces
 * Copyright:    Copyright (c) 2001
 * Company:      UCF SEECS
 * @author Charles E. Hughes
 * @version 1.0
 */

public class RegisterTuple extends SubclassableTuple implements Serializable {

  /**
  ** Default constructor will build a template that would match
  ** all registration tuples in the space.
  ** Form is Name
  */
  public RegisterTuple() throws TupleSpaceException {
    super(new Field(String.class), new Field(String.class));
  }

  /**
  ** Constructor with only key specified  will build a template
  ** for retrieving the data
  */
  public RegisterTuple(String key)  throws TupleSpaceException {
    super(key,new Field(String.class));
  }

  /**
  ** Constructor with both key and data specified will create
  ** a Tuple that can be written to BidSpaces
  */
  public RegisterTuple(String key, String data) throws TupleSpaceException {
    super(key,data);
  }

  /**
  ** Access fields without the ugly Tuple and Field code.
  */
  public String getData()  throws TupleSpaceException {
    // extract the contents of the 2nd field.
    return (String)this.getField(1).getValue();
  }

  public String getName()  throws TupleSpaceException {
    // extract the contents of the 2nd field.
    return (String)this.getField(0).getValue();
  }

  /**
   * Tuple matching will now be traced
   */
  public boolean matches( SuperTuple t ) {
    // This message will show up in the output from the TSServer.
    Debug.out("SubclassMyTuple.matches() called by server!!!!");
    return super.matches(t);
  }  // end matches()

}