samplestocksource.java
来自「cqME :java framework for TCK test.」· Java 代码 · 共 91 行
JAVA
91 行
/* * $Id$ * * Copyright 1996-2007 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License version * 2 only, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License version 2 for more details (a copy is * included at /legal/license.txt). * * You should have received a copy of the GNU General Public License * version 2 along with this work; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA * * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa * Clara, CA 95054 or visit www.sun.com if you need additional * information or have any questions. * */package com.sun.tdk.sampletck.api.com.sun.tdk.sampleapi.StockInfoManager;import java.io.IOException;import java.util.Hashtable;import java.io.PrintWriter;import com.sun.tck.midp.lib.DistributedTest;/** * An utility class used to simulate real source of stock information. * <P> * It can be run in the JavaTest's agent or as a standalone application. */public class SampleStockSource extends DistributedTest { /** * All values should be in fixed order. Some may be empty. * Predefined stocks in format: * name|time|price|change|high|low|open|prev */ private final String[][] predefinedStocks = { {"ANS", "ANS|17:02|27.5|-3.75|32.14|14.5|24.75|26.3"} , {"AYC", "AYC|03:21|7.1|3.4|12.1|3.2|7.4|7"} , {"FDA", "FDA|11:59|40.8|3.2|69.13|27|40.3|40.02"} , {"KAI", "KAI|00:00|121.3|-32.5|231|120|132|143"} }; public SampleStockSource() { setName("Server"); } /** * Standalone interface */ public static void main(String args[]) { SampleStockSource sss = new SampleStockSource(); sss.run(args, new PrintWriter(System.err), new PrintWriter(System.out)); } public void handle_getStockQuote(String from, String args[]) { synchronized (this) { Hashtable definedStocks; String params = ""; definedStocks = new Hashtable(); for (int i = 0; i < predefinedStocks.length; i++) { definedStocks.put(predefinedStocks[i][0], predefinedStocks[i][1]); } params = args[1]; try { send(from, new String[] { "getStockQuote", (String) definedStocks.get(params)}); } catch (IOException e) { ref.println("Unexpected IOException while sending getStockQuote"); } } }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?