/**
* Resets or removes the value associated with the specified key.
* <p/>
* If this implementation supports stored defaults, and there is such
* a default for the specified preference, the given key will be
* reset to the stored default.
* <p/>
* If there is no default available the key will be removed.
*
* @param key to reset
* @throws java.lang.IllegalArgumentException
* if key is <code>null</code>.
* @throws javax.portlet.ReadOnlyException
* if this preference cannot be modified for this request
*/
public void reset(String key) throws ReadOnlyException {
if (key == null) throw new IllegalArgumentException("key is NULL");
PersistencePreferenceAttribute ppa = (PersistencePreferenceAttribute) attributes.get(key);
if (ppa != null) {
if (ppa.isReadOnly()) throw new ReadOnlyException("PortletPreference is read-only!");
Preference defaultPref = (Preference) defaultPrefsMap.get(key);
if (defaultPref != null) {
Value[] defvals = defaultPref.getValue();
String[] vals = new String[defvals.length];
for (int i = 0; i < defvals.length; i++) {
vals[i] = defvals[i].getContent();
}
ppa.setAValues(vals);
} else {
attributes.remove(key);
}
}
}
PortletPreferencesImpl.java 文件源码
java
阅读 20
收藏 0
点赞 0
评论 0
项目:GridSphere
作者:
评论列表
文章目录