Preserve query in geo URI
[zxing.git] / core / src / com / google / zxing / client / result / ExpandedProductParsedResult.java
1 /*
2  * Copyright (C) 2010 ZXing authors
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 /*
18  * These authors would like to acknowledge the Spanish Ministry of Industry,
19  * Tourism and Trade, for the support in the project TSI020301-2008-2
20  * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled
21  * Mobile Dynamic Environments", led by Treelogic
22  * ( http://www.treelogic.com/ ):
23  *
24  *   http://www.piramidepse.com/
25  */
26
27 package com.google.zxing.client.result;
28
29 import java.util.Hashtable;
30
31 /**
32  * @author Antonio Manuel Benjumea Conde, Servinform, S.A.
33  * @author Agustín Delgado, Servinform, S.A.
34  */
35 public class ExpandedProductParsedResult extends ParsedResult {
36
37   public static final String KILOGRAM = "KG";
38   public static final String POUND = "LB";
39
40   private final String productID;
41   private final String sscc;
42   private final String lotNumber;
43   private final String productionDate;
44   private final String packagingDate;
45   private final String bestBeforeDate;
46   private final String expirationDate;
47   private final String weight;
48   private final String weightType;
49   private final String weightIncrement;
50   private final String price;
51   private final String priceIncrement;
52   private final String priceCurrency;
53   // For AIS that not exist in this object
54   private final Hashtable uncommonAIs;
55
56   ExpandedProductParsedResult() {
57     super(ParsedResultType.PRODUCT);
58     this.productID = "";
59     this.sscc = "";
60     this.lotNumber = "";
61     this.productionDate = "";
62     this.packagingDate = "";
63     this.bestBeforeDate = "";
64     this.expirationDate = "";
65     this.weight = "";
66     this.weightType = "";
67     this.weightIncrement = "";
68     this.price = "";
69     this.priceIncrement = "";
70     this.priceCurrency = "";
71     this.uncommonAIs = new Hashtable();
72   }
73
74   public ExpandedProductParsedResult(String productID, String sscc,
75       String lotNumber, String productionDate, String packagingDate,
76       String bestBeforeDate, String expirationDate, String weight,
77       String weightType, String weightIncrement, String price,
78       String priceIncrement, String priceCurrency, Hashtable uncommonAIs) {
79     super(ParsedResultType.PRODUCT);
80     this.productID = productID;
81     this.sscc = sscc;
82     this.lotNumber = lotNumber;
83     this.productionDate = productionDate;
84     this.packagingDate = packagingDate;
85     this.bestBeforeDate = bestBeforeDate;
86     this.expirationDate = expirationDate;
87     this.weight = weight;
88     this.weightType = weightType;
89     this.weightIncrement = weightIncrement;
90     this.price = price;
91     this.priceIncrement = priceIncrement;
92     this.priceCurrency = priceCurrency;
93     this.uncommonAIs = uncommonAIs;
94   }
95
96   public boolean equals(Object o){
97     if (!(o instanceof ExpandedProductParsedResult)) {
98       return false;
99     }
100
101     ExpandedProductParsedResult other = (ExpandedProductParsedResult)o;
102
103     return this.productID.equals(       other.productID)
104       && this.sscc.equals(            other.sscc)
105       && this.lotNumber.equals(       other.lotNumber)
106       && this.productionDate.equals(  other.productionDate)
107       && this.bestBeforeDate.equals(  other.bestBeforeDate)
108       && this.expirationDate.equals(  other.expirationDate)
109       && this.weight.equals(          other.weight)
110       && this.weightType.equals(      other.weightType)
111       && this.weightIncrement.equals( other.weightIncrement)
112       && this.price.equals(           other.price)
113       && this.priceIncrement.equals(  other.priceIncrement)
114       && this.priceCurrency.equals(   other.priceCurrency)
115       && this.uncommonAIs.equals(     other.uncommonAIs);
116   }
117
118   public int hashCode(){
119     int hash1 = this.productID.hashCode();
120     hash1 = 31 * hash1 + this.sscc.hashCode();
121     hash1 = 31 * hash1 + this.lotNumber.hashCode();
122     hash1 = 31 * hash1 + this.productionDate.hashCode();
123     hash1 = 31 * hash1 + this.bestBeforeDate.hashCode();
124     hash1 = 31 * hash1 + this.expirationDate.hashCode();
125     hash1 = 31 * hash1 + this.weight.hashCode();
126
127     int hash2 = this.weightType.hashCode();
128     hash2 = 31 * hash2 + this.weightIncrement.hashCode();
129     hash2 = 31 * hash2 + this.price.hashCode();
130     hash2 = 31 * hash2 + this.priceIncrement.hashCode();
131     hash2 = 31 * hash2 + this.priceCurrency.hashCode();
132     hash2 = 31 * hash2 + this.uncommonAIs.hashCode();
133     return hash1 ^ hash2;
134   }
135
136   public String getProductID() {
137     return productID;
138   }
139
140   public String getSscc() {
141     return sscc;
142   }
143
144   public String getLotNumber() {
145     return lotNumber;
146   }
147
148   public String getProductionDate() {
149     return productionDate;
150   }
151
152   public String getPackagingDate() {
153     return packagingDate;
154   }
155
156   public String getBestBeforeDate() {
157     return bestBeforeDate;
158   }
159
160   public String getExpirationDate() {
161     return expirationDate;
162   }
163
164   public String getWeight() {
165     return weight;
166   }
167
168   public String getWeightType() {
169     return weightType;
170   }
171
172   public String getWeightIncrement() {
173     return weightIncrement;
174   }
175
176   public String getPrice() {
177     return price;
178   }
179
180   public String getPriceIncrement() {
181     return priceIncrement;
182   }
183
184   public String getPriceCurrency() {
185     return priceCurrency;
186   }
187
188   public Hashtable getUncommonAIs() {
189     return uncommonAIs;
190   }
191
192   public String getDisplayResult() {
193     return productID;
194   }
195 }