📄 jibcardterminalfactory.java
字号:
/*--------------------------------------------------------------------------- * Copyright (C) 1999,2000 Dallas Semiconductor Corporation, All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL DALLAS SEMICONDUCTOR BE LIABLE FOR ANY CLAIM, DAMAGES * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. * * Except as contained in this notice, the name of Dallas Semiconductor * shall not be used except as stated in the Dallas Semiconductor * Branding Policy. *--------------------------------------------------------------------------- */package com.dalsemi.onewire.jib.terminal;import java.util.Properties;import opencard.core.terminal.CardTerminalFactory;import opencard.core.terminal.CardTerminal;import opencard.core.terminal.CardTerminalException;import opencard.core.terminal.CardTerminalRegistry;import opencard.core.terminal.TerminalInitException;/** <p>A <code>JiBCardTerminalFactory</code> produces <code>CardTerminal</code> objects * that know how to communicate with Java Powered iButtons attached at an <code>address</code>.</p> * * <p>To use a <code>JiBCardTerminalFactory</code>, the proper <b>opencard.properties</b> * file entry must be found by the OpenCard software. An <b>opencard.properties</b> * file contains entries that resemble the following:</p> * <code><pre> * #Only the last uncommented line will be used to search for iButtons. * #Uncomment the next line to search COM1 using native code * #OpenCard.terminals=com.dalsemi.onewire.jib.terminal.JiBCardTerminalFactory|OneWireAdapter|ONEWIRE_PORT_TYPE_LEGACY_SERIAL|COM1 * * #Uncomment the next line to search COM1 using pure java code * OpenCard.terminals=com.dalsemi.onewire.jib.terminal.JiBCardTerminalFactory|OneWireAdapter|ONEWIRE_PORT_TYPE_SERIAL|COM1 * * #Uncomment the next line to search COM2 using native code * #OpenCard.terminals=com.dalsemi.onewire.jib.terminal.JiBCardTerminalFactory|OneWireAdapter|ONEWIRE_PORT_TYPE_LEGACY_SERIAL|COM2 * * #This line will search the LPT1 for iButtons. * #OpenCard.terminals=com.dalsemi.onewire.jib.terminal.JiBCardTerminalFactory|OneWireAdapter|ONEWIRE_PORT_TYPE_LEGACY_PARALLEL|LPT1 * * #Uncomment the next line to search LPT2 using native code * #OpenCard.terminals=com.dalsemi.onewire.jib.terminal.JiBCardTerminalFactory|OneWireAdapter|ONEWIRE_PORT_TYPE_LEGACY_PARALLEL|LPT2 * </pre></code> * <p>In this case, the port <b>COM1</b> will be searched using code based on the Java COMM API.</p> * * @author K */public class JiBCardTerminalFactory implements CardTerminalFactory{ /** Create a specific <code>CardTerminal</code> object that knows how to handle * a specific card terminal and register it to the CardTerminalRegistry. * @param ctr * the CardTerminalRegistry for registration-process * @param terminalInfo * the parameter array for the terminal. * {TerminalName, TerminalType, factory-specific count of parameters....}. * @throws OpenCardInitializationException * thrown when initialization error occured * @throws CardTerminalException * thrown when CardTerminal error occured * @throws TerminalInitException * thrown when terminalInfo is incorrect or factory not able to * support requested terminal type. */ public void createCardTerminals(CardTerminalRegistry ctr, String[] terminalInfo) throws CardTerminalException { com.dalsemi.onewire.debug.Debug.debug("createCardTerminals called..."); if (terminalInfo==null) { com.dalsemi.onewire.debug.Debug.debug("terminalInfo is null!"); } else { for (int i=0;i<terminalInfo.length;i++) { com.dalsemi.onewire.debug.Debug.debug(i+": "+terminalInfo[i]); } } if (terminalInfo.length < 2) throw new TerminalInitException("createCardTerminals needs at least 2 parameters to identify the terminal"); if (terminalInfo[0].equals("OneWireAdapter") || terminalInfo[0].equals("iButtonAdapter")) { if (terminalInfo.length == 2) ctr.add(new JiBCardTerminal(terminalInfo[0], terminalInfo[1], "")); else ctr.add(new JiBCardTerminal(terminalInfo[0], terminalInfo[1], terminalInfo[2])); //add information on the services //com.dalsemi.onewire.debug.Debug.debug("putting some properties"); //System.getProperties().put("OpenCard.services", "com.dalsemi.onewire.jib.service.JiBCardServiceFactory"); } else { throw new TerminalInitException("Type unknown: " + terminalInfo[1]); } } /** Initialize the <code>CardTerminalFactory</code>. This method does nothing * in the <code>JiBCardTerminalFactory</code> class. */ public void open() {} /** Deinitialize the <code>CardTerminalFactory</code>. This method does nothing * in the <code>JiBCardTerminalFactory</code> class. */ public void close() {}}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -