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

java.lang.Object
  extended byjava.util.AbstractMap
      extended byorg.mmbase.bridge.jsp.taglib.util.ContextContainer
All Implemented Interfaces:
Map
Direct Known Subclasses:
PageContextContainer, StandaloneContextContainer

public abstract class ContextContainer
extends AbstractMap
implements Map

This is a HashMap, but the keys can contain 'dots', in which case there is searched for HashMaps in the HashMap.

Version:
$Id: ContextContainer.java,v 1.51 2006/06/26 18:32:46 johannes Exp $
Author:
Michiel Meeuwissen

Nested Class Summary
 
Nested classes inherited from class java.util.Map
Map.Entry
 
Field Summary
static int LOCATION_APPLICATION
           
static int LOCATION_ATTRIBUTES
           
static int LOCATION_COOKIE
           
static int LOCATION_MULTIPART
           
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
           
protected  ContextContainer parent
           
 
Constructor Summary
ContextContainer(String i, ContextContainer p)
          Since a ContextContainer can contain other ContextContainer, it has to know which ContextContainer contains this.
 
Method Summary
 boolean containsKey(Object key)
           
 boolean containsKey(String key)
           
 boolean containsKey(String key, boolean checkParent)
          Like the containsKey of HashMap.
 Set entrySet()
           
 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)
           
 Object get(String key, boolean checkParent)
          Like get, but you can explicity indicate if to search 'parent' Contextes as well.
protected abstract  Backing getBacking()
          Returns the Map which will is used for actually storing stuff.
 String getId()
           
 Object getObject(String key)
           
protected  org.mmbase.bridge.jsp.taglib.util.Pair getPair(String key, boolean checkParent)
          This function takes a key, which can contain dots.
 ContextContainer getParent()
           
 boolean isPresent(String key)
           
 boolean isRegistered(String key)
           
 Set keySet()
           
static String locationToString(int i)
           
 Object put(Object key, Object value)
          Keys must be Strings, so put(Object, ..) is forbidden in this HashMap!
 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)
           
 void registerNode(String newId, Node n)
           
 void release(PageContext pc, ContextContainer p)
           
 void reregister(String id, Object n)
           
 void setJspVar(PageContext pageContext, String jspvar, int type, Object value)
           
 void setParent(PageContext pc, ContextContainer p)
           
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)
           
 
Methods inherited from class java.util.AbstractMap
clear, clone, containsValue, equals, hashCode, isEmpty, putAll, remove, size, values
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
clear, containsValue, equals, hashCode, isEmpty, putAll, remove, 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_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

parent

protected ContextContainer parent
Constructor Detail

ContextContainer

public ContextContainer(String i,
                        ContextContainer p)
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)

getBacking

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

Since:
MMBase-1.8

release

public void release(PageContext pc,
                    ContextContainer p)

entrySet

public Set entrySet()
Specified by:
entrySet in interface Map

getId

public String getId()

setParent

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

getParent

public ContextContainer getParent()
Since:
MMBase-1.7

put

public Object put(Object key,
                  Object value)
Keys must be Strings, so put(Object, ..) is forbidden in this HashMap!

Specified by:
put in interface Map

put

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

Throws:
JspTagException

containsKey

public boolean containsKey(Object key)
Specified by:
containsKey in interface Map

getPair

protected org.mmbase.bridge.jsp.taglib.util.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

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(String key)
                    throws JspTagException
Throws:
JspTagException

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(String key)
           throws JspTagException
Throws:
JspTagException

get

public Object get(Object key)
Specified by:
get in interface Map

keySet

public Set keySet()
Specified by:
keySet in interface Map

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)

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)

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

toString

public String toString()


MMBase build 1.8.1.20060716