01: /*
02: * Copyright 2001 Sun Microsystems, Inc. All rights reserved.
03: * PROPRIETARY/CONFIDENTIAL. Use of this product is subject to license terms.
04: */
05:
06: package com.sun.portal.providers.userinfo.tag;
07:
08: import java.util.*;
09:
10: import javax.servlet.http.HttpServletRequest;
11:
12: import com.sun.portal.providers.context.ProviderContext;
13: import com.sun.portal.desktop.context.ContextException;
14:
15: /**
16: * this class provides generic access to STRING service attributes
17: */
18:
19: public class AttributeTag implements ReadTag, WriteTag {
20:
21: private ProviderContext context = null;
22:
23: public void init(String channel, ProviderContext context,
24: HttpServletRequest req) throws TagException {
25:
26: if (context == null) {
27: throw new TagException(
28: "AttributeTag.init(): provider context was null");
29: }
30:
31: // set desktop context
32: this .context = context;
33:
34: }
35:
36: public void set(String key, String newValue) throws TagException {
37: if (newValue.equals(get(key))) {
38: return;
39: }
40:
41: context.setStringAttribute(key, newValue);
42: return;
43: }
44:
45: public String get(String key) throws TagException {
46: String val = context.getStringAttribute(key);
47: if (val != null) {
48: return val;
49: } else {
50: return "";
51: }
52: }
53: }
|