1/*- 2 * See the file LICENSE for redistribution information. 3 * 4 * Copyright (c) 2002,2008 Oracle. All rights reserved. 5 * 6 * $Id: Weight.java,v 12.7 2008/01/08 20:58:30 bostic Exp $ 7 */ 8 9package collections.ship.marshal; 10 11import java.io.Serializable; 12 13/** 14 * Weight represents a weight amount and unit of measure. 15 * 16 * <p> In this sample, Weight is embedded in part data values which are stored 17 * as Java serialized objects; therefore Weight must be Serializable. </p> 18 * 19 * @author Mark Hayes 20 */ 21public class Weight implements Serializable { 22 23 public final static String GRAMS = "grams"; 24 public final static String OUNCES = "ounces"; 25 26 private double amount; 27 private String units; 28 29 public Weight(double amount, String units) { 30 31 this.amount = amount; 32 this.units = units; 33 } 34 35 public final double getAmount() { 36 37 return amount; 38 } 39 40 public final String getUnits() { 41 42 return units; 43 } 44 45 public String toString() { 46 47 return "[" + amount + ' ' + units + ']'; 48 } 49} 50