01: /* Copyright 2001 The JA-SIG Collaborative. All rights reserved.
02: * See license distributed with this file and
03: * available online at http://www.uportal.org/license.html
04: */
05:
06: package org.jasig.portal;
07:
08: import java.io.Serializable;
09: import java.util.Enumeration;
10: import java.util.Hashtable;
11:
12: /**
13: * Description of user preferences that are common to all of the core stylesheets
14: * @author Peter Kharchenko
15: * @version $Revision: 35884 $
16: */
17:
18: public class StylesheetUserPreferences implements Serializable {
19: private int id;
20: private Hashtable parameters;
21:
22: public StylesheetUserPreferences() {
23: parameters = new Hashtable();
24: }
25:
26: public StylesheetUserPreferences(StylesheetUserPreferences sup) {
27: this .id = sup.id;
28: this .parameters = new Hashtable(sup.getParameterValues());
29: }
30:
31: /**
32: * Provides a copy of this object with all fields instantiated to reflect
33: * the values of this object. This allows subclasses to override to add
34: * correct copying behavior for their added fields.
35: *
36: * @return a copy of this object
37: */
38: public Object newInstance() {
39: return new StylesheetUserPreferences(this );
40: }
41:
42: public int getStylesheetId() {
43: return id;
44: }
45:
46: public void setStylesheetId(int n) {
47: id = n;
48: }
49:
50: public String getParameterValue(String parameterName) {
51: return (parameterName != null) ? (String) parameters
52: .get(parameterName) : null;
53: }
54:
55: public void putParameterValue(String parameterName,
56: String parameterValue) {
57: if (parameterName != null && parameterValue != null)
58: parameters.put(parameterName, parameterValue);
59: }
60:
61: public void deleteParameter(String parameterName) {
62: if (parameterName != null)
63: parameters.remove(parameterName);
64: }
65:
66: public Hashtable getParameterValues() {
67: return parameters;
68: }
69:
70: public void setParameterValues(Hashtable parameters) {
71: if (parameters != null)
72: this .parameters = parameters;
73: else
74: this .parameters.clear();
75: }
76:
77: public String getCacheKey() {
78: StringBuffer sbKey = new StringBuffer();
79: for (Enumeration e = parameters.keys(); e.hasMoreElements();) {
80: String pName = (String) e.nextElement();
81: sbKey.append(pName).append("=").append(
82: (String) parameters.get(pName));
83: }
84: return sbKey.toString();
85: }
86:
87: }
|