userpreferencesettingsimpl.java

来自「esri的ArcGIS Server超级学习模板程序(for java)」· Java 代码 · 共 70 行

JAVA
70
字号
package com.esri.solutions.jitk.personalization.data;

import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;

import com.esri.solutions.jitk.personalization.PersonalizationException;
import com.esri.solutions.jitk.personalization.data.beans.v1.PreferenceSettingsType;

public class UserPreferenceSettingsImpl implements IPreferenceSettings {

	private static final String ERROR_NULL_USER_OBJECT = "Object not injected with User object.";
	
	/**
	 * Logger to use to log messages from this class.
	 */
	private static final Logger LOG = LogManager.getLogger(UserPreferenceSettingsImpl.class);

	/**
	 * Reference to associated User for these settings.
	 */
	private IUser m_user;
	
	/*
	 * (non-Javadoc)
	 * @see com.esri.solutions.jitk.personalization.data.IPreferenceSettings#getPreferenceSettings()
	 */
	public PreferenceSettingsType getPreferenceSettings()
			throws PersonalizationException {

		if (m_user == null) {
			LOG.error(ERROR_NULL_USER_OBJECT);
			throw new IllegalStateException (ERROR_NULL_USER_OBJECT);
		}
		
		return m_user.getPreferenceSettings();
	}

	/*
	 * (non-Javadoc)
	 * @see com.esri.solutions.jitk.personalization.data.IPreferenceSettings#save()
	 */
	public void save() throws PersonalizationException {
		if (m_user == null) {
			LOG.error(ERROR_NULL_USER_OBJECT);
			throw new IllegalStateException (ERROR_NULL_USER_OBJECT);
		}
		
		m_user.save();

	}
	
	/**
	 * Sets the reference to the User that these Preference Settings
	 * are associated with.
	 * 
	 * @param user Reference to the {@link IUser} object, cannot
	 * 				be <code>null</code>.
	 * 
	 * @throws NullPointerException		Thrown if the <code>user</code>
	 * 									argument is <code>null</code>.
	 */
	public void setUser (IUser user) {
		if (user == null) {
			throw new NullPointerException ();
		}
		
		m_user = user;
	}
}

⌨️ 快捷键说明

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