org.mmbase.bridge.jsp.taglib.util
Class ContextContainer

java.lang.Object
  extended by java.util.AbstractMap<String,Object>
      extended by org.mmbase.bridge.jsp.taglib.util.ContextContainer
All Implemented Interfaces:
Map<String,Object>
Direct Known Subclasses:
PageContextContainer, StandaloneContextContainer

public abstract class ContextContainer
extends AbstractMap<String,Object>
implements Map<String,Object>

This is basicly a Map, and it also implements Map. This map is however not completely normal, because its get(Object) method can return non-null for keys it does not actually contain (as e.g. returend by entrySet(). Firstly, the keys can contain 'dots', in which case this key is 'split' by the dot, and the second part is interpreted as a key in the Map stored undert the first part in this Map. Secondly, this Map can have a 'parent'. If a key cannot be found in this map itself, it will also try it in the parent (if there is one). Both 'dotted' keys, and parent keys, do not appear in size, keySet and entrySet methods. You can use keySet(boolean) and entrySet(boolean).

Version:
$Id: ContextContainer.java 40226 2009-12-14 10:50:33Z michiel $
Author:
Michiel Meeuwissen

Nested Class Summary
 
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Field Summary
static int LOCATION_APPLICATION
           
static int LOCATION_ATTRIBUTES
           
static int LOCATION_COOKIE
           
static int LOCATION_MULTIPART
           
static int LOCATION_MULTIPART_OPT
           
static int LOCATION_NOTSET
           
static int LOCATION_PAGE
           
static int LOCATION_PARAMETERS
           
static int LOCATION_PARENT
           
static int LOCATION_REQUEST
           
static int LOCATION_SESSION
           
static int LOCATION_THIS
           
 
Constructor Summary
ContextContainer(String i)
          Since a ContextContainer can contain other ContextContainer, it has to know which ContextContainer contains this.
 
Method Summary
 void clear()
           
 boolean containsKey(Object key)
           
 boolean containsKey(String key, boolean checkParent)
          Like the containsKey of HashMap.
 Set<Map.Entry<String,Object>> entrySet()
           
 Set<Map.Entry<String,Object>> entrySet(boolean checkParent)
           
 Object find(PageContext pageContext, int from, String referId)
           
 Object find(PageContext pageContext, String externid)
           
 Object findAndRegister(PageContext pageContext, int from, String referId, String newId)
          Searches a key in request, postparameters, session, parent context and registers it in this one.
 Object findAndRegister(PageContext pageContext, int from, String referId, String newId, boolean check)
           
 Object findAndRegister(PageContext pageContext, String id)
           
 Object findAndRegister(PageContext pageContext, String externid, String newId)
           
 Object findAndRegister(PageContext pageContext, String externid, String newId, boolean check)
           
 String findAndRegisterString(PageContext pageContext, String id)
           
 String findAndRegisterString(PageContext pageContext, String id, boolean check)
           
static Object fixEncoding(Object value, PageContext pageContext)
           
protected static Object fixEncoding(Object value, String encoding)
          Java Servlet Specification Version 2.3 SRV.4.9 says that a servlet engine should read a request as ISO-8859-1 if request.getCharacterEncoding() returns null.
 Object get(Object key)
           
 Object get(String key, boolean checkParent)
          Like get, but you can explicity indicate if to search 'parent' Contextes as well.
abstract  Backing getBacking()
          Returns the Map which will be used for actually storing stuff.
(package private) static String getDefaultCharacterEncoding(PageContext pageContext)
           
 String getId()
           
 Object getObject(String key)
           
 PageContext getPageContext()
           
(package private)  Pair getPair(String key, boolean checkParent)
          This function takes a key, which can contain dots.
abstract  ContextContainer getParent()
           
(package private) static boolean isContextIdentifierChar(char c)
           
 boolean isPresent(String key)
           
 boolean isRegistered(String key)
           
protected  Set<String> keySet(boolean checkParent)
           
static String locationToString(int i)
           
 Object put(String key, Object value)
          Not all Strings can be allowed as keys.
 void register(String newId, Object n)
           
 void register(String newId, Object n, boolean check)
           
protected  void register(String newId, Object n, boolean check, boolean checkParent)
           
 void register(String newId, WriterHelper helper, boolean check)
           
(package private)  void registerAll(Map<String,Object> map)
           
 void registerNode(String newId, Node n)
           
 void release(PageContext pc, ContextContainer p)
           
 Object remove(Object key)
           
 void reregister(String id, Object n)
           
 void setJspVar(PageContext pageContext, String jspvar, int type, Object value)
           
 void setParent(PageContext pc, ContextContainer p)
           
protected  boolean simpleContainsKey(String key, boolean checkParent)
          Like containsKey but doesn't check for dots.
protected  Object simpleGet(String key, boolean checkParent)
          Like get, but does not try to search dots, because you know already that there aren't.
static int stringToLocation(String s)
           
 String toString()
           
 void unRegister(String key)
           
protected  void unRegister(String key, boolean checkParent)
           
(package private)  void unRegisterAll(Set<String> set)
           
 
Methods inherited from class java.util.AbstractMap
clone, containsValue, equals, hashCode, isEmpty, keySet, putAll, size, values
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
containsValue, equals, hashCode, isEmpty, keySet, putAll, size, values
 

Field Detail

LOCATION_NOTSET

public static final int LOCATION_NOTSET
See Also:
Constant Field Values

LOCATION_PAGE

public static final int LOCATION_PAGE
See Also:
Constant Field Values

LOCATION_PARENT

public static final int LOCATION_PARENT
See Also:
Constant Field Values

LOCATION_PARAMETERS

public static final int LOCATION_PARAMETERS
See Also:
Constant Field Values

LOCATION_MULTIPART

public static final int LOCATION_MULTIPART
See Also:
Constant Field Values

LOCATION_MULTIPART_OPT

public static final int LOCATION_MULTIPART_OPT
See Also:
Constant Field Values

LOCATION_SESSION

public static final int LOCATION_SESSION
See Also:
Constant Field Values

LOCATION_COOKIE

public static final int LOCATION_COOKIE
See Also:
Constant Field Values

LOCATION_ATTRIBUTES

public static final int LOCATION_ATTRIBUTES
See Also:
Constant Field Values

LOCATION_REQUEST

public static final int LOCATION_REQUEST
See Also:
Constant Field Values

LOCATION_APPLICATION

public static final int LOCATION_APPLICATION
See Also:
Constant Field Values

LOCATION_THIS

public static final int LOCATION_THIS
See Also:
Constant Field Values
Constructor Detail

ContextContainer

public ContextContainer(String i)
Since a ContextContainer can contain other ContextContainer, it has to know which ContextContainer contains this. And it also has an id.

Method Detail

stringToLocation

public static int stringToLocation(String s)
                            throws JspTagException
Throws:
JspTagException

locationToString

public static String locationToString(int i)

isContextIdentifierChar

static boolean isContextIdentifierChar(char c)

getBacking

public abstract Backing getBacking()
Returns the Map which will be used for actually storing stuff.

Since:
MMBase-1.8

release

public void release(PageContext pc,
                    ContextContainer p)

entrySet

public Set<Map.Entry<String,Object>> entrySet()
Specified by:
entrySet in interface Map<String,Object>
Specified by:
entrySet in class AbstractMap<String,Object>
Since:
MMBase-1.9.2

entrySet

public Set<Map.Entry<String,Object>> entrySet(boolean checkParent)

getId

public String getId()

setParent

public void setParent(PageContext pc,
                      ContextContainer p)
Since:
MMBase-1.8

getParent

public abstract ContextContainer getParent()
Since:
MMBase-1.7

getPageContext

public PageContext getPageContext()
Since:
MMBase-1.8.3

put

public Object put(String key,
                  Object value)
Not all Strings can be allowed as keys. Keys are like variable names.

Specified by:
put in interface Map<String,Object>
Overrides:
put in class AbstractMap<String,Object>

getPair

Pair getPair(String key,
             boolean checkParent)
       throws JspTagException
This function takes a key, which can contain dots. It returns a structure with a new ContextContainer and the rest of the key. It also returns if it had to 'go down' to find this, because if it has done this, the next time you may not go up again (check the parent).

Throws:
JspTagException

simpleContainsKey

protected boolean simpleContainsKey(String key,
                                    boolean checkParent)
Like containsKey but doesn't check for dots.


containsKey

public boolean containsKey(String key,
                           boolean checkParent)
                    throws JspTagException
Like the containsKey of HashMap.

Parameters:
key - The key to search
checkParent - If this is false, it will only look in the current Container (and below).
Throws:
JspTagException

containsKey

public boolean containsKey(Object key)
Specified by:
containsKey in interface Map<String,Object>
Overrides:
containsKey in class AbstractMap<String,Object>

simpleGet

protected Object simpleGet(String key,
                           boolean checkParent)
Like get, but does not try to search dots, because you know already that there aren't.


get

public Object get(String key,
                  boolean checkParent)
           throws JspTagException
Like get, but you can explicity indicate if to search 'parent' Contextes as well.

Throws:
JspTagException

get

public Object get(Object key)
Specified by:
get in interface Map<String,Object>
Overrides:
get in class AbstractMap<String,Object>

keySet

protected Set<String> keySet(boolean checkParent)
Since:
MMBase-1.7

getObject

public Object getObject(String key)
                 throws JspTagException
Throws:
JspTagException
Since:
MMBase-1.7 (here)

register

public void register(String newId,
                     Object n,
                     boolean check)
              throws JspTagException
Throws:
JspTagException
Since:
MMBase-1.7 (here)

register

public void register(String newId,
                     WriterHelper helper,
                     boolean check)
              throws JspTagException
Throws:
JspTagException
Since:
MMBase-1.8

register

protected void register(String newId,
                        Object n,
                        boolean check,
                        boolean checkParent)
                 throws JspTagException
Throws:
JspTagException
Since:
MMBase-1.7

register

public void register(String newId,
                     Object n)
              throws JspTagException
Throws:
JspTagException
Since:
MMBase-1.7 (here)

registerAll

void registerAll(Map<String,Object> map)
           throws JspTagException
Throws:
JspTagException
Since:
MMBase-1.7

unRegisterAll

void unRegisterAll(Set<String> set)
             throws JspTagException
Throws:
JspTagException
Since:
MMBase-1.7

registerNode

public void registerNode(String newId,
                         Node n)
                  throws JspTagException
Throws:
JspTagException
Since:
MMBase-1.7 (here)

isRegistered

public boolean isRegistered(String key)
                     throws JspTagException
Throws:
JspTagException
Since:
MMBase-1.7 (here)

remove

public Object remove(Object key)
Specified by:
remove in interface Map<String,Object>
Overrides:
remove in class AbstractMap<String,Object>

clear

public void clear()
Specified by:
clear in interface Map<String,Object>
Overrides:
clear in class AbstractMap<String,Object>

unRegister

public void unRegister(String key)
                throws JspTagException
Throws:
JspTagException
Since:
MMBase-1.7 (here)

unRegister

protected void unRegister(String key,
                          boolean checkParent)
                   throws JspTagException
Throws:
JspTagException
Since:
MMBase-1.7

reregister

public void reregister(String id,
                       Object n)
                throws JspTagException
Throws:
JspTagException
Since:
MMBase-1.7 (here)

fixEncoding

protected static Object fixEncoding(Object value,
                                    String encoding)
                             throws TaglibException
Java Servlet Specification Version 2.3 SRV.4.9 says that a servlet engine should read a request as ISO-8859-1 if request.getCharacterEncoding() returns null. We override this behaviour because the browser propably sends the request in the same encoding as the html was send to te browser And it is likely that the html was send to the browser in the same encoding as the MMBase encoding property.

Throws:
TaglibException
Since:
MMBase-1.8

fixEncoding

public static Object fixEncoding(Object value,
                                 PageContext pageContext)
                          throws TaglibException
Throws:
TaglibException
Since:
MMBase-1.8

find

public Object find(PageContext pageContext,
                   int from,
                   String referId)
            throws JspTagException
Throws:
JspTagException
Since:
MMBase-1.7

find

public Object find(PageContext pageContext,
                   String externid)
            throws JspTagException
Throws:
JspTagException
Since:
MMBase-1.7

findAndRegister

public Object findAndRegister(PageContext pageContext,
                              int from,
                              String referId,
                              String newId)
                       throws JspTagException
Searches a key in request, postparameters, session, parent context and registers it in this one. Returns null if it could not be found.

Throws:
JspTagException

findAndRegister

public Object findAndRegister(PageContext pageContext,
                              int from,
                              String referId,
                              String newId,
                              boolean check)
                       throws JspTagException
Throws:
JspTagException

findAndRegister

public Object findAndRegister(PageContext pageContext,
                              String externid,
                              String newId)
                       throws JspTagException
Throws:
JspTagException

findAndRegister

public Object findAndRegister(PageContext pageContext,
                              String externid,
                              String newId,
                              boolean check)
                       throws JspTagException
Throws:
JspTagException

findAndRegister

public Object findAndRegister(PageContext pageContext,
                              String id)
                       throws JspTagException
Throws:
JspTagException

findAndRegisterString

public String findAndRegisterString(PageContext pageContext,
                                    String id)
                             throws JspTagException
Throws:
JspTagException

findAndRegisterString

public String findAndRegisterString(PageContext pageContext,
                                    String id,
                                    boolean check)
                             throws JspTagException
Throws:
JspTagException

isPresent

public boolean isPresent(String key)
                  throws JspTagException
Throws:
JspTagException

setJspVar

public void setJspVar(PageContext pageContext,
                      String jspvar,
                      int type,
                      Object value)
Since:
MMBase-1.8

getDefaultCharacterEncoding

static String getDefaultCharacterEncoding(PageContext pageContext)

toString

public String toString()
Overrides:
toString in class AbstractMap<String,Object>


MMBase 2.0-SNAPSHOT - null