01: /*
02: * Copyright 2002 Sun Microsystems, Inc. All
03: * rights reserved. Use of this product is subject
04: * to license terms. Federal Acquisitions:
05: * Commercial Software -- Government Users
06: * Subject to Standard License Terms and
07: * Conditions.
08: *
09: * Sun, Sun Microsystems, the Sun logo, and Sun ONE
10: * are trademarks or registered trademarks of Sun Microsystems,
11: * Inc. in the United States and other countries.
12: */
13: package com.sun.portal.portletcontainercommon.descriptor;
14:
15: import java.util.List;
16: import java.util.ArrayList;
17: import java.util.Iterator;
18:
19: import org.jdom.Element;
20: import org.jdom.Namespace;
21:
22: /**
23: * The suppors descriptor is the descriptor for the portlet modes that
24: * are supported for a portlet.
25: * <P>
26: */
27: public class SupportsDescriptor {
28:
29: // Supports Element Names
30: public static final String MIME_TYPE = "mime-type";
31: public static final String PORTLET_MODE = "portlet-mode";
32:
33: // Global variables
34: private String _mimeType;
35: private List _portletModes = new ArrayList();
36:
37: /**
38: * Loads the init param descriptor into memory.
39: * <P>
40: * @param The supports Element
41: */
42: public void load(Element element, Namespace namespace) {
43: _mimeType = element.getChildTextTrim(MIME_TYPE, namespace);
44: List modeElements = element
45: .getChildren(PORTLET_MODE, namespace);
46: if (modeElements != null) {
47: for (Iterator i = modeElements.iterator(); i.hasNext();) {
48: Element modeElement = (Element) i.next();
49: _portletModes.add(modeElement.getTextTrim());
50: }
51: }
52:
53: }
54:
55: /**
56: * Returns the mime type.
57: * <P>
58: * @return <code>String</code> of the mime type.
59: */
60: public String getMimeType() {
61: return _mimeType;
62: }
63:
64: /**
65: * Returns the supported portlet modes.
66: * <P>
67: * @return <code>List</code> of the portlet modes for this mime type.
68: */
69: public List getPortletModes() {
70: return _portletModes;
71: }
72:
73: /**
74: * The toString method.
75: * <P>
76: * @return the <code>String</code> representation of the supports
77: * descriptor.
78: */
79: public String toString() {
80: StringBuffer sb = new StringBuffer("SupportsDescriptor [");
81:
82: sb.append("mime type [").append(_mimeType).append("] ");
83: sb.append("portlet mode [");
84: for (int i = 0; i < _portletModes.size(); i++) {
85: sb.append((String) _portletModes.get(i));
86: sb.append(", ");
87: }
88: sb.append("] ]");
89:
90: return sb.toString();
91: }
92: }
|