📄 protectedproperties.java
字号:
/**
*
* AgentAcademy - an open source Data Mining framework for
* training intelligent agents
*
* Copyright (C) 2001-2003 AA Consortium.
*
* This library is open source 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.0 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 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.agentacademy.modules.dataminer.core;
/**
* <p>Title: The Data Miner prototype</p>
* <p>Description: A prototype for the DataMiner (DM), the Agent Academy (AA) module responsible for performing data mining on the contents of the Agent Use Repository (AUR). The extracted knowledge is to be sent back to the AUR in the form of a PMML document.</p>
* <p>Copyright: Copyright (c) 2002</p>
* <p>Company: CERTH</p>
* @author asymeon
* @version 0.3
*/
import java.util.Properties;
import java.util.Map;
import java.util.Enumeration;
import java.io.InputStream;
/**
* Simple class that extends the Properties class so that the properties are
* unable to be modified.
*
*/
public class ProtectedProperties extends Properties {
// the properties need to be open during construction of the object
private boolean closed = false;
/**
* Creates a set of protected properties from a set of normal ones.
*
* @param props the properties to be stored and protected.
*/
public ProtectedProperties(Properties props)
{
Enumeration propEnum = props.propertyNames();
while (propEnum.hasMoreElements()) {
String propName = (String) propEnum.nextElement();
String propValue = props.getProperty(propName);
super.setProperty(propName, propValue);
}
closed = true; // no modifications allowed from now on
}
/**
* Overrides a method to prevent the properties from being modified.
*
* @return never returns without throwing an exception.
* @exception UnsupportedOperationException always.
*/
public Object setProperty(String key, String value)
throws UnsupportedOperationException
{
if (closed)
throw new
UnsupportedOperationException("ProtectedProperties cannot be modified!");
else return super.setProperty(key, value);
}
/**
* Overrides a method to prevent the properties from being modified.
*
* @return never returns without throwing an exception.
* @exception UnsupportedOperationException always.
*/
public void load(InputStream inStream) throws UnsupportedOperationException {
throw new
UnsupportedOperationException("ProtectedProperties cannot be modified!");
}
/**
* Overrides a method to prevent the properties from being modified.
*
* @return never returns without throwing an exception.
* @exception UnsupportedOperationException always.
*/
public void clear() throws UnsupportedOperationException {
throw new
UnsupportedOperationException("ProtectedProperties cannot be modified!");
}
/**
* Overrides a method to prevent the properties from being modified.
*
* @return never returns without throwing an exception.
* @exception UnsupportedOperationException always.
*/
public Object put(Object key,
Object value) throws UnsupportedOperationException {
if (closed)
throw new
UnsupportedOperationException("ProtectedProperties cannot be modified!");
else return super.put(key, value);
}
/**
* Overrides a method to prevent the properties from being modified.
*
* @return never returns without throwing an exception.
* @exception UnsupportedOperationException always.
*/
public void putAll(Map t) throws UnsupportedOperationException {
throw new
UnsupportedOperationException("ProtectedProperties cannot be modified!");
}
/**
* Overrides a method to prevent the properties from being modified.
*
* @return never returns without throwing an exception.
* @exception UnsupportedOperationException always.
*/
public Object remove(Object key) throws UnsupportedOperationException {
throw new
UnsupportedOperationException("ProtectedProperties cannot be modified!");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -