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

📄 systemconfig.java

📁 这是外国一个开源推理机
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/*  Sesame - Storage and Querying architecture for RDF and RDF Schema *  Copyright (C) 2001-2005 Aduna * *  Contact: *  	Aduna *  	Prinses Julianaplein 14 b *  	3817 CS Amersfoort *  	The Netherlands *  	tel. +33 (0)33 465 99 87 *  	fax. +33 (0)33 465 99 87 * *  	http://aduna.biz/ *  	http://www.openrdf.org/ * *  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. * *  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. * *  You should have received a copy of the GNU Lesser General Public *  License along with this library; if not, write to the Free Software *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */package org.openrdf.sesame.config;import java.util.ArrayList;import java.util.Arrays;import java.util.Collections;import java.util.HashMap;import java.util.Iterator;import java.util.List;import java.util.Map;import java.util.Properties;import java.util.Set;public class SystemConfig {/*------------------------------------------+| Variables                                 |+------------------------------------------*/	protected String _adminPassword = "";	protected String _logDir;	protected int _logLevel = 0;	protected String _tmpDir;	protected boolean _rmiEnabled;	protected String _rmiFactoryClass;	protected int _rmiPort;	protected Properties _systemProps = new Properties();	protected HashMap _userMap = new HashMap();	protected List _userList = new ArrayList();	protected HashMap _repositoryMap = new HashMap();	protected ArrayList _repositoryList = new ArrayList();	protected List _listeners = new ArrayList();/*------------------------------------------+| Constructors                              |+------------------------------------------*/	public SystemConfig() {	}/*------------------------------------------+| Server-related methods                    |+------------------------------------------*/	public void setAdminPassword(String password) {		_adminPassword = password;		_notifyListeners();	}	public String getAdminPassword() {		return _adminPassword;	}	public void setLogDir(String logDir) {		_logDir = logDir;		_notifyListeners();	}	public String getLogDir() {		return _logDir;	}	public void setLogLevel(int logLevel) {		_logLevel = logLevel;		_notifyListeners();	}	public int getLogLevel() {		return _logLevel;	}	public void setTmpDir(String tmpDir) {		_tmpDir = tmpDir;		_notifyListeners();	}	public String getTmpDir() {		return _tmpDir;	}	public void setSystemProp(String key, String value) {		_systemProps.setProperty(key, value);		_notifyListeners();	}	public String getSystemProp(String key) {		return _systemProps.getProperty(key);	}	public Properties getSystemProps() {		return _systemProps;	}	public void setRMIEnabled(boolean rmiEnabled) {		if (_rmiEnabled != rmiEnabled) {			_rmiEnabled = rmiEnabled;			_notifyListeners();		}	}	public boolean isRMIEnabled() {		return _rmiEnabled;	}	public void setRMIFactory(String rmiFactoryClass, int port) {		_rmiFactoryClass = rmiFactoryClass;		_rmiPort = port;		_notifyListeners();	}	public String getRMIFactoryClass() {		return _rmiFactoryClass;	}	public int getRMIPort() {		return _rmiPort;	}/*------------------------------------------+| User-related methods                      |+------------------------------------------*/	public void addUserInfo(UserInfo ui) {		_userMap.put(ui.getLogin(), ui);		_userList.add(ui);		_notifyListeners();	}	/**	 * Removes the user with the supplied login	 *	 * @param login User login	 */	public void removeUser(String login) {		UserInfo user = (UserInfo)_userMap.remove(login);		_userList.remove(user);		_notifyListeners();	}	public UserInfo getUserInfo(String login) {		return (UserInfo)_userMap.get(login);	}	public UserInfo getUserInfo(int userID) {		for (int i = 0; i < _userList.size(); i++) {			UserInfo ui = (UserInfo)_userList.get(i);			if (ui.getID() == userID) {				return ui;			}		}		return null;	}	public Set getUsernames() {		return Collections.unmodifiableSet(_userMap.keySet());	}	/**	 * Gets a List of users	 *	 * @return a List of UserInfo objects.	 */	public List getUserInfoList() {		return Collections.unmodifiableList(_userList);	}	/**	 * Gets all users that have read and/or write access to the	 * specified repository.	 **/	public List getUsersForRepository(RepositoryConfig repConfig) {		List result = new ArrayList();		String repositoryId = repConfig.getRepositoryId();		for (int i = 0; i < _userList.size(); i++) {			UserInfo userInfo = (UserInfo)_userList.get(i);			if (userInfo.hasReadOrWriteAccess(repositoryId)) {				result.add(userInfo);			}		}		return result;	}	/**	 * Gets an unused user id.	 *	 * @return An unused user id.	 */	public int getUnusedUserId() {		// Collect used ids		int[] usedIDs = new int[_userList.size()];		for (int i = 0; i < _userList.size(); i++) {			UserInfo userInfo = (UserInfo)_userList.get(i);			usedIDs[i] = userInfo.getID();		}		Arrays.sort(usedIDs);		// User id 's 1 and 2 are reserved for the ADMIN and ANONYMOUS accounts		// respectively. Begin at id 3.		int nextUserId = 3;		while (Arrays.binarySearch(usedIDs, nextUserId) < 0) {			nextUserId++;		}		return nextUserId;	}	/**	 * Sets the id of the user with the supplied login to the given id	 *	 * @param login User login	 * @param id User id	 */	public void setUserId(String login, int id) {		getUserInfo(login).setID(id);		_notifyListeners();	}	/**	 * Sets the login of the user with the supplied old login to the given new	 * login	 *	 * @param oldLogin Old user login	 * @param newLogin New user login	 */	public void setUserLogin(String oldLogin, String newLogin) {		UserInfo userInfo = getUserInfo(oldLogin);		userInfo.setLogin(newLogin);		_userMap.remove(oldLogin);		_userMap.put(newLogin, userInfo);		_notifyListeners();	}	/**	 * Sets the full name of the user with the supplied login to the given full	 * name	 *	 * @param login User login	 * @param fullName User full name	 */	public void setUserFullName(String login, String fullName) {		getUserInfo(login).setFullName(fullName);		_notifyListeners();	}	/**	 * Sets the password of the user with the supplied login to the given	 * password	 *	 * @param login User login	 * @param password User password	 */	public void setUserPassword(String login, String password) {		getUserInfo(login).setPassword(password);		_notifyListeners();	}/*------------------------------------------+| Repository-related methods                |+------------------------------------------*/	public void addRepositoryConfig(RepositoryConfig ri) {		RepositoryConfig oldInfo = (RepositoryConfig)_repositoryMap.put(ri.getRepositoryId(), ri);		if (oldInfo != null) {			_repositoryList.remove(oldInfo);		}		_repositoryList.add(ri);		_notifyListeners();	}	public RepositoryConfig getRepositoryConfig(String id) {		return (RepositoryConfig)_repositoryMap.get(id);	}	public List getRepositoryConfigList() {		return Collections.unmodifiableList(_repositoryList);	}	/**	 * Gets a List of sails from the repository with the supplied id	 *	 * @param id Repository id	 * @return an unmodifiable List of SailConfig objects.	 * @see SailConfig	 */	public List getSails(String id) {		return getRepositoryConfig(id).getSailList();	}	/**	 * Gets a Map of parameters from the sail with the supplied class of the	 * repository with the given id	 *	 * @param id Repository id	 * @param sailClass Sail class	 * return Map of parameters	 */	public Map getParameters(String id, String sailClass) {		return getRepositoryConfig(id).getSail(sailClass).getConfigParameters();	}	/**	 * Sets the id of the repository with the supplied old id to the given new id	 *	 * @param oldId Old repository id	 * @param newId New repository id	 */	public void setRepositoryId(String oldId, String newId) {		RepositoryConfig repository = getRepositoryConfig(oldId);		repository.setRepositoryId(newId);		_repositoryMap.remove(oldId);		_repositoryMap.put(newId, repository);		_notifyListeners();	}	/**	 * Sets the title of the repository with the supplied id to the given	 * title	 *	 * @param id Repository id	 * @param title Repository title	 */	public void setRepositoryTitle(String id, String title) {		getRepositoryConfig(id).setTitle(title);		_notifyListeners();	}	/**	 * Checks if the repository with the supplied id is world readable	 *	 * @param id Repository id	 * @return Boolean indicating if the repository is world readable	 */	public boolean isWorldReadable(String id) {		return getRepositoryConfig(id).isWorldReadable();	}	/**	 * Sets if the repository with the supplied id is world readable	 *	 * @param id Repository id	 * @param worldReadable Boolean indicating if the repository is world	 * readable	 */	public void setWorldReadable(String id, boolean worldReadable) {		getRepositoryConfig(id).setWorldReadable(worldReadable);		_notifyListeners();	}	/**	 * Checks if the repository with the supplied id is world writeable	 *	 * @param id The repository id	 * @return Boolean indicating if the repository is world writeable	 */	public boolean isWorldWriteable(String id) {		return getRepositoryConfig(id).isWorldWriteable();	}	/**	 * Sets if the repository with the supplied id is world writeable	 *	 * @param id The repository id	 * @param worldWriteable Boolean indicating if the repository is world	 * writeable	 */	public void setWorldWriteable(String id, boolean worldWriteable) {		getRepositoryConfig(id).setWorldWriteable(worldWriteable);		_notifyListeners();

⌨️ 快捷键说明

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