?? irlapstatequery.java
字號:
/*
**************************************************************************
** $Header: /cvsroot/jred/jred/src/com/synchrona/jred/irlap/IrLAPStateQuery.java,v 1.2 2000/07/30 20:18:12 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.Assert;
import com.synchrona.util.Log;
import java.io.PrintWriter;
class IrLAPStateQuery extends IrLAPState {
private Log _log;
//--------------------------------------------------------------------
// 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 IrLAPStateQuery();
// 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;
}
public void handleSlotTimerExpired(IrLAPContext context) throws Exception {
logIfEnabled("slot-timer-expired");
if ( context.getSlotCount() < 6 ) {
context.setSlotCount((byte) (context.getSlotCount() + 1));
} else {
context.setSlotCount((byte) 0xFF);
context.setMediaBusy(false);
context.nextState(IrLAPStateNDM.getInstance());
}
context.sendDiscoveryRequest();
context.startSlotTimer();
}
public void handleXID(IrLAPContext context, int nSource, int nDestination, byte ySlot, boolean bCommand, byte [] ayHints) throws Exception {
Assert.fail(null != context, "IrLAPContext is null.");
Assert.fail(null != ayHints, "Service hints are null.");
logIfEnabled("XID (empty) [source=" + nSource
+ " destination=" + nDestination
+ " slot=" + ySlot
+ " command?=" + bCommand + "]");
System.err.println("(IrLAPStateQuery.handleXID) creating service hints");
ServiceHints hints = new ServiceHints(ayHints, 0, ayHints.length);
System.err.println("(IrLAPStateQuery.handleXID) creating discovery info");
DiscoveryInformation discoveryInfo = new DiscoveryInformation(nSource, hints);
System.err.println("(IrLAPStateQuery.handleXID) sending discoveryIndication");
context.discoveryIndication(discoveryInfo);
System.err.println("(IrLAPStateQuery.handleXID) finished sending discoveryIndication");
}
//--------------------------------------------------------------------
// End of event handlers, start of support stuff
//--------------------------------------------------------------------
public void debug(String strCategory, String strMessage) {
_log.debug(strCategory, strMessage);
}
public void setLog(Log log) {
_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 IrLAPStateQuery() {
_log = null;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -