1 10 11 package org.mmbase.bridge.jsp.taglib.util; 12 13 import java.util.*; 14 15 import javax.servlet.jsp.JspTagException ; 16 17 import org.mmbase.bridge.jsp.taglib.ContextReferrerTag; 18 import org.mmbase.util.logging.*; 19 20 27 public abstract class Referids { 28 private static final Logger log = Logging.getLoggerInstance(Referids.class); 29 30 public static Map getReferids(Attribute referids, ContextReferrerTag tag) throws JspTagException { 31 Map result = new LinkedHashMap(); Iterator i = referids.getList(tag).iterator(); 34 while (i.hasNext()) { 35 String key = (String ) i.next(); 36 if (key.equals("")) continue; 37 int at = key.indexOf('@'); 38 String urlKey; 39 if (at > -1) { 40 urlKey = key.substring(at + 1, key.length()); 41 key = key.substring(0, at); 42 } else { 43 urlKey = key; 44 } 45 46 boolean mayBeMissing; 47 if (key.endsWith("?")) { 48 mayBeMissing = true; 49 boolean keyIsUrlKey = key.equals(urlKey); 50 key = key.substring(0, key.length() - 1); 51 if (keyIsUrlKey) urlKey = key; 52 } else { 53 mayBeMissing = false; 54 } 55 if (key.equals("_")) { 56 if (urlKey.equals("_")) throw new JspTagException ("Should use '@' when using '_' in referids"); 57 Object value = tag.findWriter().getWriterValue(); 58 result.put(urlKey, value); 59 } else if ((! mayBeMissing) || tag.getContextProvider().getContextContainer().isPresent(key)) { 60 Object value = tag.getObject(key); 61 if (value != null) { 62 if (log.isDebugEnabled()) { 63 log.debug("adding parameter (with referids) " + key + "/" + value); 64 } 65 result.put(urlKey, value); 66 } 67 } else { 68 log.debug("No key '" + key + "' in context, not adding to referids"); 69 } 70 } 71 return result; 72 } 73 74 } 75 | Popular Tags |