📄 caseinfolisthandler.java
字号:
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* 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 for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
package eti.bi.alphaminer.core.handler;
import java.util.Vector;
import eti.bi.alphaminer.core.observer.ObserveSubject;
import eti.bi.alphaminer.core.observer.Observer;
import eti.bi.alphaminer.vo.CaseInfoList;
import eti.bi.alphaminer.vo.CaseInformation;
import eti.bi.alphaminer.vo.SearchCriteria;
import eti.bi.alphaminer.vo.SearchedCaseInfoList;
/**
* CaseInfoLisHandler is a class storing case information of all cases available
* in the KBBI server and case information of cases that matched a specific
* query.
*
* The class is responsible for communicating with the communication handler to
* retrieve case information.
*/
public class CaseInfoListHandler implements ObserveSubject {
/**
* An instance of CaseInfoListHandler
*/
private static CaseInfoListHandler m_CaseInfoListHandler;
/**
* A list of case information for cases available
*/
private CaseInfoList m_CaseInfoList;
/**
* A list of case information for the searched cases
*/
private SearchedCaseInfoList m_SearchedCaseInfoList;
/**
* A vector for storing observer instances that are to be notified after
* certain operation in CaseInfoListHandler
*/
private Vector m_Observers;
/**
* Constructs a CaseInfoListHandler
*/
protected CaseInfoListHandler(){}
/**
* Clear contents of case list and searched case list.
*/
public void clearList()
{
m_CaseInfoList = null;
m_SearchedCaseInfoList = null;
}
/**
* Returns a list of case information of all cases available.
* @param a_IsRefreshed true to refresh case information list from the server;
* false to keep using the list stored in the CaseInfoListHandler instance.
* @return a list of case information
*/
public CaseInfoList getCaseInfoList(boolean a_IsRefreshed)
{
if (a_IsRefreshed)
m_CaseInfoList = CommunicationHandlerBridge.getInstance().getCaseInfoList();
return m_CaseInfoList;
}
/**
* Gets a CaseInfoListHandler.
* @return a CaseInfoListHandler instance
*/
public static CaseInfoListHandler getInstance() {
/* Create a new CaseInfoListHandler only if it does not exist */
if (m_CaseInfoListHandler==null)
{
m_CaseInfoListHandler = new CaseInfoListHandler();
m_CaseInfoListHandler.initialization();
}
return m_CaseInfoListHandler;
}
/**
* Gets a list of case information of the searched cases.
* @return a list of case information of the searched cases
*/
public SearchedCaseInfoList getSearchedCaseInfoList()
{
return m_SearchedCaseInfoList;
}
/**
* Registers an observer for CaseInfoListHandler instance.
* @param a_Observer object that is interested on changes occurred in the
* CaseInfoListHandler instance.
*/
@SuppressWarnings("unchecked")
public void registerInterest(Observer a_Observer)
{
m_Observers.addElement(a_Observer);
}
/**
* Search cases that match the specific searching criteria.
* @param a_SearchCriteria a SearchCriteria object stores the searching
* criteria
* @param a_Threshold a threshold used to identify valid searched cases
*/
public void searchCase(SearchCriteria a_SearchCriteria, double a_Threshold)
{
/* Get search result from CommunicationHandler */
m_SearchedCaseInfoList = CommunicationHandlerBridge.getInstance().searchCase(a_SearchCriteria, a_Threshold);
/* Notify every observers about the new list of case information of the searched result */
for (int i=0; i<m_Observers.size(); i++)
((Observer) m_Observers.elementAt(i)).sendNotify("search result");
}
public void updateCaseStatus(String a_CaseID, String a_Status)
{
CaseInformation info = null;
if (m_CaseInfoList!=null)
{
info = m_CaseInfoList.getCaseInfo(a_CaseID);
if (info!=null)
{
info.setStatus(a_Status);
m_CaseInfoList.setCaseInfo(info);
}
}
if (m_SearchedCaseInfoList!=null)
{
info = m_SearchedCaseInfoList.getCaseInfo(a_CaseID);
if (info!=null)
{
info.setStatus(a_Status);
m_SearchedCaseInfoList.setCaseInfo(info);
}
}
}
/**
* Frees the resources hold by the CaseInfoListHandler instance.
*/
/*
protected void finalize()
{
m_CaseInfoListHandler = null;
}
*/
/**
* Initalizes members of the CaseInfoListHandler class.
*/
private void initialization()
{
m_Observers = new Vector();
m_CaseInfoList = new CaseInfoList();
m_SearchedCaseInfoList = new SearchedCaseInfoList();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -