1 4 package com.openedit.store; 5 6 10 public class Option implements Comparable 11 { 12 protected String fieldName; 13 protected String fieldId; 14 protected String fieldValue; 15 16 protected PriceSupport fieldPriceSupport; 17 protected boolean fieldRequired = false; 18 19 public Option() 20 { 21 } 22 public Option(String inId, String inValue) 23 { 24 setId(inId); 25 setName(inId); 26 setValue(inValue); 27 } 28 public String getId() 29 { 30 return fieldId; 31 } 32 public void setId(String inId) 33 { 34 fieldId = inId; 35 } 36 public String getName() 37 { 38 if (fieldName == null) 39 { 40 fieldName = getId(); 41 } 42 return fieldName; 43 } 44 public void setName(String inName) 45 { 46 fieldName = inName; 47 } 48 public PriceSupport getPriceSupport() 49 { 50 return fieldPriceSupport; 51 } 52 public void setPriceSupport(PriceSupport inPriceSupport) 53 { 54 fieldPriceSupport = inPriceSupport; 55 } 56 57 public void addTierPrice( int inQuantity, Price inPrice ) 58 { 59 if (getPriceSupport() == null) 60 { 61 setPriceSupport(new PriceSupport()); 62 } 63 getPriceSupport().addTierPrice( inQuantity, inPrice ); 64 } 65 66 public boolean isRequired() 67 { 68 return fieldRequired; 69 } 70 public void setRequired(boolean inRequired) 71 { 72 fieldRequired = inRequired; 73 } 74 75 public String getValue() 76 { 77 return fieldValue; 78 } 79 80 public void setValue(String inValue) 81 { 82 fieldValue = inValue; 83 } 84 public String toString() 85 { 86 if( getValue() != null) 87 { 88 return getValue(); 89 } 90 else 91 { 92 return ""; 93 } 94 } 95 public boolean equals( Object inObj) 96 { 97 if( inObj instanceof Option) 98 { 99 Option in = (Option)inObj; 100 boolean ids = in.getId().equals(getId()); 101 if( ids ) 102 { 103 if( in.getValue() == getValue() ) 104 { 105 return true; 106 } 107 if( in.getValue() != null && in.getValue().equalsIgnoreCase( getValue() ) ) 108 { 109 return true; 110 } 111 } 112 } 113 return false; 114 } 115 public int compareTo(Object inO) 116 { 117 Option in = (Option)inO; 118 return in.getName().compareTo(in.getName()); 119 } 120 } 121 | Popular Tags |