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

📄 resourcemanager.java

📁 主要是对串口驱动的的一些控制源码!!! 在下载javacomm20-win32.zip后就可以使用。
💻 JAVA
字号:
/**
 * $Log: ResourceManager.java,v $
 * Revision 1.2  2003/01/18 21:59:39  mwulff
 * added abstract method log()
 *
 * Revision 1.1  2003/01/16 13:08:32  mwulff
 * initial version
 *
 * Revision 1.7  2002/12/14 22:41:43  mwulff
 * no message
 *
 * Revision 1.6  2002/12/01 21:37:28  mwulff
 * accomodated to ServerResourceManager and ClientResourceManager
 * that are now implemented as singleton
 *
 * Revision 1.5  2002/11/30 11:52:20  mwulff
 * no message
 *
 * Revision 1.4  2002/11/21 10:57:11  mwulff
 * changed the default communicationBufferSize to 512
 *
 * Revision 1.3  2002/11/17 17:47:23  mwulff
 * removed field logConfPath and corresponding getter and setter methods
 *
 * Revision 1.2  2002/11/15 18:19:08  mwulff
 * functions initCBSizeParam and initCPLimitParam now takes a NodeList
 * as argument
 *
 * Revision 1.1  2002/11/08 19:14:58  mwulff
 * initial version
 *
 */
package de.fhm.jkf.resource.clsv;

import java.io.File;

import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

/**
 * @author marten wulff
 * 
 * <br><br><center><table border="1" width="80%"><hr>
 * <strong><a href="http://jkf.sourceforge.net">The JKF Project</a></strong>
 * <p>
 * Copyright (C) 2002 by Marten Wulff
 * <p>
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 * <p>
 * This library 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
 * Lesser General Public License for more details.
 * <p>
 * You should have received a copy of the <a href="http://www.gnu.org/copyleft/lesser.html">
 * GNU Lesser General Public License</a> along with this library; if not, write to
 * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 * MA  02111-1307  USA
 * <hr></table></center>
 */
public abstract class ResourceManager {

	// flag that indicated if resources are already loaded
	protected boolean dataLoaded = false;

	// compression limit, a value from -1 means no compression
	protected int compressLimit = -1;

	// inital size of the communication buffers
	protected int communicationBufferSize = 512;

	// path for the configuration file
	protected String confFile = "";

	/**
	 * Constructor for ResourceManager.
	 */
	protected ResourceManager() {
		super();
	}

	protected void initCBSizeParam(NodeList nodes) {
		if (nodes.getLength() > 0) {
			Node node = nodes.item(0);
			communicationBufferSize =
				Integer.parseInt(node.getFirstChild().getNodeValue());


			log(
				"Setting communication buffer size to: "
					+ communicationBufferSize);
		}
	}

	protected void initCPLimitParam(NodeList nodes) {
		if (nodes.getLength() > 0) {
			Node node = nodes.item(0);
			compressLimit =
				Integer.parseInt(node.getFirstChild().getNodeValue());
		}
		
		// if the given value is smaller than 250, set param to -1
		// --> no compression
		if (compressLimit < 250) {
			compressLimit = -1;
		}

		log("Setting compress limit to: " + compressLimit);
	}

	protected boolean configExists() {

		if (confFile != null) {
			File tmp = new File(confFile);
			if (tmp.exists()) {
				return true;
			}
		}

		return false;
	}

	/**
	 * Returns the compressLimit.
	 * @return int
	 */
	public int getCompressLimit() {
		return compressLimit;
	}
	
	/**
	 * Returns the communicationBufferSize.
	 * @return int
	 */
	public int getCommunicationBufferSize() {
		return communicationBufferSize;
	} 
	
	/**
	 * Sets the confFilePath.
	 * @param confFilePath The confFilePath to set
	 */
	public void setConfFile(String confFile) {
		this.confFile = confFile;
	}

	/**
	 * Sets the compressLimit.
	 * @param compressLimit The compressLimit to set
	 */
	public void setCompressLimit(int compressLimit) {
		// if the given value is smaller than 250, set param to -1
		// --> no compression
		if (compressLimit < 250) {
			this.compressLimit = -1;
		} else {
			this.compressLimit = compressLimit;
		}
	}

	/**
	 * Sets the communicationBufferSize.
	 * @param communicationBufferSize The communicationBufferSize to set
	 */
	public void setCommunicationBufferSize(int communicationBufferSize) {
		this.communicationBufferSize = communicationBufferSize;
	}
	
	protected abstract void log(Object message);

}

⌨️ 快捷键说明

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