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

📄 irlapstate.java

📁 JRed is a 100% Java implementation of the IrDA infrared communications protocols. JRed lets you beam
💻 JAVA
字号:
/*
**************************************************************************
** $Header: /cvsroot/jred/jred/src/com/synchrona/jred/irlap/IrLAPState.java,v 1.2 2000/07/30 05:57:57 mpatters Exp $
**
** Copyright (C) 2000 Synchrona, Inc. All rights reserved.
**
** This file is part of JRed, a 100% Java implementation of the IrDA
** infrared communications protocols.
**
** This file may be distributed under the terms of the Synchrona Public
** License as defined by Synchrona, Inc. and appearing in the file
** LICENSE included in the packaging of this file. The Synchrona Public
** License is based on the Q Public License as defined by Troll Tech AS
** of Norway; it differs only in its use of the courts of Florida, USA
** rather than those of Oslo, Norway.
**************************************************************************
*/
package com.synchrona.jred.irlap;

import com.synchrona.util.Log;
import java.io.PrintWriter;

/**
 * IrLAPState is a base class for all of the IrLAP states. You shouldn't
 * use this in production, but it provides stub implementations of the
 * event handlers so you can see what's going on (or at least get some
 * indication when something that you aren't expecting happens).
 * <p>
 * IrLAPState is part of the implementation of the ObjectsAsStates pattern,
 * which can be found in the Gang of Four book. IrLAPContext provides access
 * to variables that are shared by all states, as well as methods to change
 * state and respond to events.
 * <p>
 * IrLAPState also implements the Singleton pattern. There is at most one
 * instance of each subclass of IrLAPState.
 */
class IrLAPState {
	protected Log m_log;         // log stream

	//--------------------------------------------------------------------
	// Static stuff
	//--------------------------------------------------------------------

	// You'll want to do this in each subclass of IrLAPState to 
	// create a single instance of that subclass.
	private static IrLAPState s_instance = new IrLAPState();

	// Will late binding make sure we get the correct instance? Need
	// to test this (see IrLAPStateNDM). It may be compiler-dependent.
	public static IrLAPState getInstance() {
		return s_instance;
	}

	//--------------------------------------------------------------------
	// Start event handlers. These are the things you'll want to modify as
	// you implement new IrLAP states or change the behavior of existing
	// ones. The names suck but they're based on the IrLAP specification;
	// it's kind of hard to check compliance if you have to keep translating
	// from their terse names to more meaningful ones.
	//--------------------------------------------------------------------

	public void connectResponse(IrLAPContext context, int nDestination, byte yConnection, byte [] ayParameters) throws Exception {
		logIfEnabled("connectionRequest (empty)");
	}

	public void discoveryRequest(IrLAPContext context) throws Exception {
		logIfEnabled("discoveryRequest (empty)");
	}

	/**
	 * Somebody has sent us data.
	 */
	public void handleData(IrLAPContext context, byte yConnection, int nNr, boolean bCommand, boolean bPoll, byte [] ayData) throws Exception {
		logIfEnabled("data (empty)");
	}

	/**
	 * An IrLAP service user wants to send data to an IrLAP client.
	 */
	public void handleDataRequest(IrLAPContext context, byte ayData, int nOffset, int nLength) throws Exception {
		logIfEnabled("data-request (empty)");
	}

	public void handleDisconnect(IrLAPContext context, int nSource, byte yConnection) throws Exception {
		logIfEnabled("DISC (empty)");
	}

	public void handleFTimerExpired(IrLAPContext context) throws Exception {
		logIfEnabled("F-timer-expired (empty)");
	}

	public void handlePTimerExpired(IrLAPContext context) throws Exception {
		logIfEnabled("P-timer-expired (empty)");
	}

	public void handleQueryTimerExpired(IrLAPContext context) throws Exception {
		logIfEnabled("query-timer-expired (empty)");
	}

	public void handleSlotTimerExpired(IrLAPContext context) throws Exception {
		logIfEnabled("slot-timer-expired (empty)");
	}

	public void handleRR(IrLAPContext context, byte yConnection, int nNr, boolean bCommand, boolean bPoll) throws Exception {
		logIfEnabled("RR (empty)");
	}

	public void handleSNRM(IrLAPContext context, int nSource, int nDestination, byte yConnection, byte [] ayParameters) throws Exception {
		logIfEnabled("SNRM (empty) source=" + nSource + " destination=" + nDestination + " connection=" + yConnection);
	}

	public void handleUA(IrLAPContext context, byte [] ayParams, int nOffset, int nLength) throws Exception {
		logIfEnabled("UA (empty)");
	}

	public void handleWatchdogTimerExpired(IrLAPContext context) throws Exception {
		logIfEnabled("WD-timer-expired (empty)");
	}

	public void handleXID(IrLAPContext context, int nSource, int nDestination, byte ySlot, boolean bCommand, byte [] ayHints) throws Exception {
		logIfEnabled("XID (empty) [source=" + nSource + " destination=" + nDestination + " slot=" + ySlot + " command?=" + bCommand + "]");
	}

	//--------------------------------------------------------------------
	// End of event handlers, start of support stuff
	//--------------------------------------------------------------------

	public void debug(String strCategory, String strMessage) {
		m_log.debug(strCategory, strMessage);
	}

	public void setLog(Log log) {
		m_log = log;
	}

	public void setLog(PrintWriter log) {
	}

	public void setLogging(boolean bDoLogging) {
	}

	//--------------------------------------------------------------------
	// End of public methods, start protected methdods
	//--------------------------------------------------------------------

	protected void logIfEnabled(String strMessage) throws Exception {
	}

	//--------------------------------------------------------------------
	// End of protected methods, start private methods
	//--------------------------------------------------------------------

	protected IrLAPState() {
		m_log        = null;
	}

}

⌨️ 快捷键说明

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