Methods Summary |
---|
public void | clear()Removes all entries from the Map and removes all attributes from the
portlet context.
entries = null;
Enumeration e = context.getAttributeNames();
while (e.hasMoreElements()) {
context.removeAttribute(e.nextElement().toString());
}
|
public java.util.Set | entrySet()Creates a Set of all portlet context attributes as well as context init
parameters.
if (entries == null) {
entries = new HashSet<Object>();
// Add portlet context attributes
Enumeration enumeration = context.getAttributeNames();
while (enumeration.hasMoreElements()) {
final String key = enumeration.nextElement().toString();
final Object value = context.getAttribute(key);
entries.add(new Map.Entry() {
public boolean equals(Object obj) {
Map.Entry entry = (Map.Entry) obj;
return ((key == null) ? (entry.getKey() == null) : key
.equals(entry.getKey()))
&& ((value == null) ? (entry.getValue() == null)
: value.equals(entry.getValue()));
}
public int hashCode() {
return ((key == null) ? 0 : key.hashCode())
^ ((value == null) ? 0 : value.hashCode());
}
public Object getKey() {
return key;
}
public Object getValue() {
return value;
}
public Object setValue(Object obj) {
context.setAttribute(key.toString(), obj);
return value;
}
});
}
// Add portlet context init params
enumeration = context.getInitParameterNames();
while (enumeration.hasMoreElements()) {
final String key = enumeration.nextElement().toString();
final Object value = context.getInitParameter(key);
entries.add(new Map.Entry() {
public boolean equals(Object obj) {
Map.Entry entry = (Map.Entry) obj;
return ((key == null) ? (entry.getKey() == null) : key
.equals(entry.getKey()))
&& ((value == null) ? (entry.getValue() == null)
: value.equals(entry.getValue()));
}
public int hashCode() {
return ((key == null) ? 0 : key.hashCode())
^ ((value == null) ? 0 : value.hashCode());
}
public Object getKey() {
return key;
}
public Object getValue() {
return value;
}
public Object setValue(Object obj) {
context.setAttribute(key.toString(), obj);
return value;
}
});
}
}
return entries;
|
public java.lang.Object | get(java.lang.Object key)Returns the portlet context attribute or init parameter based on the
given key. If the entry is not found, null is returned.
// Try context attributes first, then init params
// This gives the proper shadowing effects
String keyString = key.toString();
Object value = context.getAttribute(keyString);
return (value == null) ? context.getInitParameter(keyString) : value;
|
public java.lang.Object | put(java.lang.Object key, java.lang.Object value)Sets a portlet context attribute given a attribute name and value.
entries = null;
context.setAttribute(key.toString(), value);
return get(key);
|
public java.lang.Object | remove(java.lang.Object key)Removes the specified portlet context attribute.
entries = null;
Object value = get(key);
context.removeAttribute(key.toString());
return value;
|