01: /*
02: * Copyright 2001-2004 The Apache Software Foundation.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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: package samples.stock;
18:
19: /**
20: *
21: * @author Doug Davis (dug@us.ibm.com)
22: */
23: public class ComInfoService {
24: public String getInfo(String symbol, String dataType)
25: throws Exception {
26: int i, j;
27: String[] types = { "symbol", "name", "address" };
28: String[][] data = {
29: { "IBM", "International Business Machines",
30: "Armonk, NY" },
31:
32: { "MACR", "Macromedia", "Newton, MA" },
33:
34: { "CSCO", "Cisco Systems", "San Jose, CA" } };
35:
36: for (i = 0; i < types.length; i++)
37: if (types[i].equals(dataType))
38: break;
39:
40: if (i == types.length)
41: return ("Unknown dataType: " + dataType);
42:
43: for (j = 0; j < data.length; j++)
44: if (data[j][0].equals(symbol))
45: break;
46:
47: if (j == data.length)
48: return ("Unknown symbol: " + symbol);
49:
50: return (data[j][i]);
51: }
52: }
|