1 23 24 package examples.invoice.persistclass; 25 26 import org.objectweb.jorm.api.PAccessor; 27 import org.objectweb.jorm.api.PBinding; 28 import org.objectweb.jorm.api.PException; 29 30 import java.io.Serializable ; 31 32 35 public class Product implements PAccessor, ProductAccessor { 36 private String name; 37 private char size; 38 private String color; 39 private float weight; 40 private float price; 41 private String picture; private PBinding pBinding; 43 44 public PBinding getPBinding() { 45 return pBinding; 46 } 47 48 51 public Product(Object conn, PBinding pb, String n, char s, String c, float w, float p) throws PException { 52 pBinding = pb; 53 name = n; 54 size = s; 55 color = (c == null) ? "black" : c; 56 weight = w; 57 price = p; 58 picture = "My Picture"; 59 pBinding.export(conn); 60 pBinding.write(conn, this); 61 } 62 63 66 public Product(Object conn, PBinding pb) throws PException { 67 pBinding = pb; 68 pb.read(conn, this); 69 } 70 71 74 public void delete(Object conn) throws PException { 75 pBinding.unexport(conn); 76 pBinding.write(conn, this); 77 pBinding = null; 78 } 79 80 83 public String toPrintable() throws PException { 84 return "ID: [" + pBinding.getPName().encodeString() + "] - VALUE: [name: " + name + ", size: " + size + ", color: " + color + ", weight: " + weight + "kg, price: " + price + "euros, picture: (" + picture + ")]"; 85 } 86 87 89 public Object getMemoryInstance() { 90 return this; 91 } 92 93 95 public void paSetName(String val) throws PException { 97 name = val; 98 } 99 100 public String paGetName() throws PException { 101 return name; 102 } 103 104 public void paSetSize(char val) throws PException { 106 size = val; 107 } 108 109 public char paGetSize() throws PException { 110 return size; 111 } 112 113 public void paSetColor(String val) throws PException { 115 color = val; 116 } 117 118 public String paGetColor() throws PException { 119 return color; 120 } 121 122 public void paSetWeight(float val) throws PException { 124 weight = val; 125 } 126 127 public float paGetWeight() throws PException { 128 return weight; 129 } 130 131 public void paSetPrice(float val) throws PException { 133 price = val; 134 } 135 136 public float paGetPrice() throws PException { 137 return price; 138 } 139 public void paSetPicture(Serializable val) throws PException { 141 picture = (String ) val; 142 } 143 144 public Serializable paGetPicture() throws PException { 145 return picture; 146 } 147 } 148 | Popular Tags |