1 8 9 package collections.ship.factory; 10 11 import java.io.Serializable ; 12 13 import com.sleepycat.bind.tuple.MarshalledTupleKeyEntity; 14 import com.sleepycat.bind.tuple.TupleInput; 15 import com.sleepycat.bind.tuple.TupleOutput; 16 17 33 public class Supplier implements Serializable , MarshalledTupleKeyEntity { 34 35 static final String CITY_KEY = "city"; 36 37 private transient String number; 38 private String name; 39 private int status; 40 private String city; 41 42 public Supplier(String number, String name, int status, String city) { 43 44 this.number = number; 45 this.name = name; 46 this.status = status; 47 this.city = city; 48 } 49 50 public final String getNumber() { 51 52 return number; 53 } 54 55 public final String getName() { 56 57 return name; 58 } 59 60 public final int getStatus() { 61 62 return status; 63 } 64 65 public final String getCity() { 66 67 return city; 68 } 69 70 public String toString() { 71 72 return "[Supplier: number=" + number + 73 " name=" + name + 74 " status=" + status + 75 " city=" + city + ']'; 76 } 77 78 80 public void marshalPrimaryKey(TupleOutput keyOutput) { 81 82 keyOutput.writeString(this.number); 83 } 84 85 public void unmarshalPrimaryKey(TupleInput keyInput) { 86 87 this.number = keyInput.readString(); 88 } 89 90 public boolean marshalSecondaryKey(String keyName, TupleOutput keyOutput) { 91 92 if (keyName.equals(CITY_KEY)) { 93 if (this.city != null) { 94 keyOutput.writeString(this.city); 95 return true; 96 } else { 97 return false; 98 } 99 } else { 100 throw new UnsupportedOperationException (keyName); 101 } 102 } 103 104 public boolean nullifyForeignKey(String keyName) { 105 106 throw new UnsupportedOperationException (keyName); 107 } 108 } 109 | Popular Tags |