00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 package collections.ship.marshal;
00011
00012 import java.io.Serializable;
00013
00014 import com.sleepycat.bind.tuple.TupleInput;
00015 import com.sleepycat.bind.tuple.TupleOutput;
00016
00034 public class Supplier implements Serializable, MarshalledEnt {
00035
00036 static final String CITY_KEY = "city";
00037
00038 private transient String number;
00039 private String name;
00040 private int status;
00041 private String city;
00042
00043 public Supplier(String number, String name, int status, String city) {
00044
00045 this.number = number;
00046 this.name = name;
00047 this.status = status;
00048 this.city = city;
00049 }
00050
00055 void setKey(String number) {
00056
00057 this.number = number;
00058 }
00059
00060 public final String getNumber() {
00061
00062 return number;
00063 }
00064
00065 public final String getName() {
00066
00067 return name;
00068 }
00069
00070 public final int getStatus() {
00071
00072 return status;
00073 }
00074
00075 public final String getCity() {
00076
00077 return city;
00078 }
00079
00080 public String toString() {
00081
00082 return "[Supplier: number=" + number +
00083 " name=" + name +
00084 " status=" + status +
00085 " city=" + city + ']';
00086 }
00087
00088
00089
00090 Supplier() {
00091
00092
00093
00094 }
00095
00096 public void unmarshalPrimaryKey(TupleInput keyInput) {
00097
00098 this.number = keyInput.readString();
00099 }
00100
00101 public void marshalPrimaryKey(TupleOutput keyOutput) {
00102
00103 keyOutput.writeString(this.number);
00104 }
00105
00106 public boolean marshalSecondaryKey(String keyName, TupleOutput keyOutput) {
00107
00108 if (keyName.equals(CITY_KEY)) {
00109 if (this.city != null) {
00110 keyOutput.writeString(this.city);
00111 return true;
00112 } else {
00113 return false;
00114 }
00115 } else {
00116 throw new UnsupportedOperationException(keyName);
00117 }
00118 }
00119 }