KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ofbiz > pos > jpos > service > MsrTestService


1 /*
2  * $Id: MsrTestService.java 5462 2005-08-05 18:35:48Z jonesde $
3  *
4  * Copyright (c) 2004 The Open For Business Project - www.ofbiz.org
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a
7  * copy of this software and associated documentation files (the "Software"),
8  * to deal in the Software without restriction, including without limitation
9  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  * and/or sell copies of the Software, and to permit persons to whom the
11  * Software is furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included
14  * in all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
21  * OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
22  * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23  *
24  */

25 package org.ofbiz.pos.jpos.service;
26
27 import jpos.MSRConst;
28 import jpos.JposException;
29 import jpos.events.DataEvent;
30
31 import org.ofbiz.base.util.GeneralException;
32
33 /**
34  *
35  * @author <a HREF="mailto:jaz@ofbiz.org">Andy Zeneski</a>
36  * @version $Rev: 5462 $
37  * @since 3.2
38  */

39 public class MsrTestService extends BaseService implements jpos.services.MSRService17 {
40
41     public static final String JavaDoc module = MsrTestService.class.getName();
42     public static final int JPOS_MSR_ACCT_ERR = 100;
43     public static final int JPOS_MSR_EXPD_ERR = 101;
44     protected static MsrTestService instance = null;
45
46     protected String JavaDoc title = "";
47     protected String JavaDoc firstname = "John";
48     protected String JavaDoc middle = "";
49     protected String JavaDoc surname = "Doe";
50     protected String JavaDoc suffix = "";
51
52     protected String JavaDoc[] accountNumber = {"4111111111111111", "4111111111111111" };
53     protected String JavaDoc[] expireDate = { "0909", "0909" };
54     protected String JavaDoc serviceCode = "";
55
56     protected byte[] track1DiscretionaryData = new byte[0];
57     protected byte[] track2DiscretionaryData = new byte[0];
58     protected byte[] track1Data = new byte[0];
59     protected byte[] track2Data = new byte[0];
60     protected byte[] track3Data = new byte[0];
61     protected int[] sentinels = new int[0];
62     protected int[] lrc = new int[0];
63
64     protected boolean parseDecodeData = true;
65     protected boolean decodeData = true;
66     protected boolean autoDisable = false;
67     protected boolean sendSentinels = true;
68
69     protected int tracksToRead = MSRConst.MSR_TR_1_2_3;
70     protected int errorType = MSRConst.MSR_ERT_CARD;
71
72     public MsrTestService() {
73         instance = this;
74     }
75
76     // MSRService12
77
public boolean getCapISO() throws JposException {
78         // the type of cards this reader supports (ISO only)
79
return true;
80     }
81
82     public boolean getCapJISOne() throws JposException {
83         // the type of cards this reader supports (ISO only)
84
return false;
85     }
86
87     public boolean getCapJISTwo() throws JposException {
88         // the type of cards this reader supports (ISO only)
89
return false;
90     }
91
92     public String JavaDoc getAccountNumber() throws JposException {
93         return this.accountNumber[1];
94     }
95
96     public boolean getAutoDisable() throws JposException {
97         return this.autoDisable;
98     }
99
100     public void setAutoDisable(boolean b) throws JposException {
101         this.autoDisable = b;
102     }
103
104     public boolean getDecodeData() throws JposException {
105         return this.decodeData;
106     }
107
108     public void setDecodeData(boolean b) throws JposException {
109         this.decodeData = b;
110         if (!b) {
111             this.parseDecodeData = false;
112         }
113     }
114
115     public int getErrorReportingType() throws JposException {
116         return this.errorType;
117     }
118
119     public void setErrorReportingType(int i) throws JposException {
120         this.errorType = i;
121     }
122
123     public String JavaDoc getExpirationDate() throws JposException {
124         return this.expireDate[1];
125     }
126
127     public String JavaDoc getFirstName() throws JposException {
128         return this.firstname;
129     }
130
131     public String JavaDoc getMiddleInitial() throws JposException {
132         return this.middle;
133     }
134
135     public boolean getParseDecodeData() throws JposException {
136         return this.parseDecodeData;
137     }
138
139     public void setParseDecodeData(boolean b) throws JposException {
140         this.parseDecodeData = b;
141     }
142
143     public String JavaDoc getServiceCode() throws JposException {
144         return this.serviceCode;
145     }
146
147     public String JavaDoc getSuffix() throws JposException {
148         return this.suffix;
149     }
150
151     public String JavaDoc getSurname() throws JposException {
152         return this.surname;
153     }
154
155     public String JavaDoc getTitle() throws JposException {
156         return this.title;
157     }
158
159     public byte[] getTrack1Data() throws JposException {
160         return this.track1Data;
161     }
162
163     public byte[] getTrack1DiscretionaryData() throws JposException {
164         return this.track1DiscretionaryData;
165     }
166
167     public byte[] getTrack2Data() throws JposException {
168         return this.track2Data;
169     }
170
171     public byte[] getTrack2DiscretionaryData() throws JposException {
172         return this.track2DiscretionaryData;
173     }
174
175     public byte[] getTrack3Data() throws JposException {
176         return this.track3Data;
177     }
178
179     public int getTracksToRead() throws JposException {
180         return this.tracksToRead;
181     }
182
183     public void setTracksToRead(int i) throws JposException {
184         this.tracksToRead = i;
185     }
186
187     public void clearInput() throws JposException {
188     }
189
190     // MSRService13
191
public int getCapPowerReporting() throws JposException {
192         return 0; // not used
193
}
194
195     public int getPowerNotify() throws JposException {
196         return 0; // not used
197
}
198
199     public void setPowerNotify(int i) throws JposException {
200         // not used
201
}
202
203     public int getPowerState() throws JposException {
204         return 0; // not used
205
}
206
207     // MSRService15
208
public boolean getCapTransmitSentinels() throws JposException {
209         return true;
210     }
211
212     public byte[] getTrack4Data() throws JposException {
213         return new byte[0]; // not implemented
214
}
215
216     public boolean getTransmitSentinels() throws JposException {
217         return this.sendSentinels;
218     }
219
220     public void setTransmitSentinels(boolean b) throws JposException {
221         this.sendSentinels = b;
222     }
223
224     public static void sendTest() throws GeneralException {
225         if (instance == null) {
226             throw new GeneralException("MsrTestService instance is null; make sure 'TestMsr' is configured in pos-containers.xml");
227         }
228         DataEvent event = new DataEvent(instance, 0);
229         instance.fireEvent(event);
230     }
231 }
232
Popular Tags