⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 nullserialport.java

📁 java communications api 3.0
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* * @(#)NullSerialPort.java	1.12 98/06/25 SMI *  * Copyright 2003 Sun Microsystems, Inc. All rights reserved. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. *  * Sun grants you ("Licensee") a non-exclusive, royalty free, license * to use, modify and redistribute this software in source and binary * code form, provided that i) this copyright notice and license appear * on all copies of the software; and ii) Licensee does not utilize the * software in a manner which is disparaging to Sun. *  * This software is provided "AS IS," without a warranty of any kind. * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND * ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY * LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THE * SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS * BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, * INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, * HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING * OUT OF THE USE OF OR INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN * ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. *  * This software is not designed or intended for use in on-line control * of aircraft, air traffic, aircraft navigation or aircraft * communications; or in the design, construction, operation or * maintenance of any nuclear facility. Licensee represents and * warrants that it will not use or redistribute the Software for such * purposes. */import java.io.*;import java.util.TooManyListenersException;import javax.comm.*;/** * Class declaration * * * @author * @version 1.9, 05/04/00 */class NullSerialPort extends SerialPort {    /**     * Constructor declaration     *     *     * @param name     *     * @see     */    NullSerialPort(String name) throws IOException {	this.name = name;    }    private InputStream ins;    /**     * Method declaration     *     *     * @return     *     * @throws IOException     *     * @see     */    public InputStream getInputStream() throws IOException {	if (closed) {	    throw new IllegalStateException("Port Closed");	} 	return ins;    }     private OutputStream outs;    /**     * Method declaration     *     *     * @return     *     * @throws IOException     *     * @see     */    public OutputStream getOutputStream() throws IOException {	if (closed) {	    throw new IllegalStateException("Port Closed");	} 	return outs;    }     /**     * The following methods deal with receive thresholds     */    private int rcvThreshold = -1;    /**     * Method declaration     *     *     * @param thresh     *     * @throws UnsupportedCommOperationException     *     * @see     */    public void enableReceiveThreshold(int thresh) 	    throws UnsupportedCommOperationException {	if (closed) {	    throw new IllegalStateException("Port Closed");	} 	rcvThreshold = thresh;    }     /**     * Method declaration     *     *     * @see     */    public void disableReceiveThreshold() {	if (closed) {	    throw new IllegalStateException("Port Closed");	} 	rcvThreshold = -1;    }     /**     * Method declaration     *     *     * @return     *     * @see     */    public boolean isReceiveThresholdEnabled() {	if (closed) {	    throw new IllegalStateException("Port Closed");	} 	return rcvThreshold != -1;    }     /**     * Method declaration     *     *     * @return     *     * @see     */    public int getReceiveThreshold() {	if (closed) {	    throw new IllegalStateException("Port Closed");	} 	return rcvThreshold;    }     /**     * The following methods deal with receive timeouts     */    int rcvTimeout = -1;    /**     * Method declaration     *     *     * @param rcvTimeout     *     * @throws UnsupportedCommOperationException     *     * @see     */    public void enableReceiveTimeout(int rcvTimeout) 	    throws UnsupportedCommOperationException {	if (closed) {	    throw new IllegalStateException("Port Closed");	} 	this.rcvTimeout = rcvTimeout;    }     /**     * Method declaration     *     *     * @see     */    public void disableReceiveTimeout() {	if (closed) {	    throw new IllegalStateException("Port Closed");	} 	this.rcvTimeout = -1;    }     /**     * Method declaration     *     *     * @return     *     * @see     */    public int getReceiveTimeout() {	if (closed) {	    throw new IllegalStateException("Port Closed");	} 	return rcvTimeout;    }     /**     * Method declaration     *     *     * @return     *     * @see     */    public boolean isReceiveTimeoutEnabled() {	if (closed) {	    throw new IllegalStateException("Port Closed");	} 	return rcvTimeout == -1 ? false : true;    }     /**     * The following methods deal with receive framing     */    private boolean framing = false;    private int     framingByte;    boolean	    framingByteReceived;    /**     * Method declaration     *     *     * @see     */    public void disableReceiveFraming() {	if (closed) {	    throw new IllegalStateException("Port Closed");	} 	framing = false;    }     /**     * Method declaration     *     *     * @param framingByte     *     * @throws UnsupportedCommOperationException     *     * @see     */    public void enableReceiveFraming(int framingByte) 	    throws UnsupportedCommOperationException {	if (closed) {	    throw new IllegalStateException("Port Closed");	} 	framing = true;	this.framingByte = framingByte & 0xff;    }     /**     * Method declaration     *     *     * @return     *     * @see     */    public int getReceiveFramingByte() {	if (closed) {	    throw new IllegalStateException("Port Closed");	} 	return framingByte;    }     /**     * Method declaration     *     *     * @return     *     * @see     */    public boolean isReceiveFramingEnabled() {	if (closed) {	    throw new IllegalStateException("Port Closed");	} 	return framing;    }     /**     * Method declaration     *     *     * @param size     *     * @see     */    public void setInputBufferSize(int size) {	if (closed) {	    throw new IllegalStateException("Port Closed");	}     }     /**     * Method declaration     *     *     * @return     *     * @see     */    public int getInputBufferSize() {	if (closed) {	    throw new IllegalStateException("Port Closed");	} 	return 0;    }     /**     * Method declaration     *     *     * @param size     *     * @see     */    public void setOutputBufferSize(int size) {	if (closed) {	    throw new IllegalStateException("Port Closed");	}     }     /**     * Method declaration     *     *     * @return     *     * @see     */    public int getOutputBufferSize() {	if (closed) {	    throw new IllegalStateException("Port Closed");	} 	return 0;    }     /* Serial Port methods */    private int baudrate;    private int parity;    private int dataBits;    private int stopBits;    private int flowcontrol;    /**     * Method declaration     *     *     * @return     *     * @see     */    public int getBaudRate() {	if (closed) {	    throw new IllegalStateException("Port Closed");	} 	return baudrate;    }     /**     * Method declaration     *     *     * @return     *     * @see     */    public int getDataBits() {	if (closed) {	    throw new IllegalStateException("Port Closed");	} 	return dataBits;    }     /**     * Method declaration     *     *     * @return     *     * @see     */    public int getStopBits() {	if (closed) {	    throw new IllegalStateException("Port Closed");	} 	return stopBits;    }     /**     * Method declaration     *     *     * @return     *     * @see     */    public int getParity() {	if (closed) {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -