@Override public boolean containsKey(Object key) { return ctxtMgr.getValue((String)key) != null; } }
protected Collection getValue(ContextManagerIF ctxtMgr, String var) throws NavigatorRuntimeException { if (var == null) return null; return ctxtMgr.getValue(var); }
@Override public boolean containsKey(Object key) { return contextManager.getValue((String)key, null) != null; }
@Override public Object get(Object key) { return contextManager.getValue((String) key, null); }
private Collection getvalue(ContextTag contextTag, String token) { if (token != null) { if (token.equalsIgnoreCase("none")) return Collections.EMPTY_LIST; else return contextTag.getContextManager().getValue(token); } else return null; } }
/** * INTERNAL: return collection to work with, throw * <code>NavigatorRuntimeException</code> if collection is null. */ protected Collection getInputCollection(ContextManagerIF ctxtMgr) throws NavigatorRuntimeException { if (variableName == null) return ctxtMgr.getDefaultValue(); else return ctxtMgr.getValue(variableName); }
@Override public Object get(Object key) { Collection coll = ctxtMgr.getValue((String) key); if (coll.isEmpty()) throw new VariableNotSetException((String) key); return CollectionUtils.getFirstElement(coll); }
Collection collection2 = contextTag.getContextManager().getValue(equalsVariableName);
private Object getVariableValue(String var) { // first try to access an OKS variable try { Collection coll; ContextTag contextTag = FrameworkUtils.getContextTag(pageContext); if (contextTag != null) { coll = contextTag.getContextManager().getValue(var); // FIXME: what if it's empty? return coll.iterator().next(); } } catch (VariableNotSetException e) { // this is OK; we just move on to trying the page context } return InteractionELSupport.getValue(var, pageContext); }
private Object getVariableValue(String var) { // first try to access an OKS variable try { Collection coll; ContextTag contextTag = FrameworkUtils.getContextTag(pageContext); if (contextTag != null) { coll = contextTag.getContextManager().getValue(var); // FIXME: what if it's empty? return coll.iterator().next(); } } catch (VariableNotSetException e) { // this is OK; we just move on to trying the page context } return InteractionELSupport.getValue(var, pageContext); }
/** * PUBLIC: Returns the first value in the collection bound to a * specific variable in the current scope. The value returned will * be null if the variable is unknown or if the collection is empty. * @since 2.2.1 */ public static Object getSingleValue(String name, ServletRequest request) { NavigatorPageIF ctxt = (NavigatorPageIF) request.getAttribute(NavigatorApplicationIF.CONTEXT_KEY); if (ctxt == null) throw new OntopiaRuntimeException("Could not find navigator context."); Collection coll = ctxt.getContextManager().getValue(name); return CollectionUtils.getFirst(coll); }
/** * PUBLIC: Returns the value bound to a specific variable in the * current scope. The value returned will be null if the variable is * unknown. */ public static Collection getValue(String name, PageContext pageContext) { NavigatorPageIF ctxt = (NavigatorPageIF) pageContext.getAttribute(NavigatorApplicationIF.CONTEXT_KEY, PageContext.REQUEST_SCOPE); if (ctxt == null) throw new OntopiaRuntimeException("Could not find navigator context."); return ctxt.getContextManager().getValue(name); }
Collection scope = contextTag.getContextManager().getValue(basenameScopeVarName);
/** * PUBLIC: Returns the value bound to a specific variable in the * current scope. The value returned will be defaultValue if the variable is * unknown. */ public static Collection getValue(String name, PageContext pageContext, Collection defaultValue) { NavigatorPageIF ctxt = (NavigatorPageIF) pageContext.getAttribute(NavigatorApplicationIF.CONTEXT_KEY, PageContext.REQUEST_SCOPE); if (ctxt == null) throw new OntopiaRuntimeException("Could not find navigator context."); return ctxt.getContextManager().getValue(name, defaultValue); }
/** * Set a variable in the ontopia environment to a given value. */ private void setOntopia(String var, Object val, ContextManagerIF ctxmgr) { if (val instanceof Object[]) { Object[] jstlArray = (Object[])val; // Let the context manager create a collection to hold the array values. // Need one value to do this, so use first value in jstlArray (or null). ctxmgr.setValue(var, (jstlArray.length == 0) ? null : jstlArray[0]); Collection ontopiaValue = ctxmgr.getValue(var); // Add the rest of the values in jstlArray to ontopiaValue. for (int i = 1; i < jstlArray.length; i++) ontopiaValue.add(jstlArray[i]); } else if (val instanceof Collection) { ctxmgr.setValue(var, (Collection)val); } else { ctxmgr.setValue(var, val); } }
coll = ctxtMgr.getValue(variableName); } else { coll = ctxtMgr.getDefaultValue();
} else { context = contextTag.getContextManager().getValue(inScopeOf);
coll = ctxtMgr.getValue(name); else coll = ctxtMgr.getDefaultValue();
@Override public final void generateOutput(JspWriter out, Iterator iter) throws JspTagException, IOException { StringifierIF strify = this; if (strifyCN != null) strify = (StringifierIF) contextTag.getNavigatorApplication().getInstanceOf(strifyCN); Object elem = null; if (iter.hasNext()) elem = iter.next(); if (elem == null) { // try to get the variable from context and stringify it ContextManagerIF ctxtMgr = contextTag.getContextManager(); Collection coll = ctxtMgr.getValue(variableName); if (coll != null) elem = CollectionUtils.getFirstElement(coll); } // finally put out content out.print(strify.toString(elem)); }
/** * INTERNAL: Process the start tag for this instance. */ @Override public int doStartTag() throws JspTagException { // retrieve collection from ContextManager by Name this.contextTag = FrameworkUtils.getContextTag(pageContext); ContextManagerIF ctxtMgr = contextTag.getContextManager(); Collection coll; if (variableName != null) coll = ctxtMgr.getValue(variableName); else coll = ctxtMgr.getDefaultValue(); try { JspWriter out = pageContext.getOut(); out.print(StringUtils.escapeHTMLEntities(coll.toString())); } catch (IOException e) { throw new NavigatorRuntimeException(e); // JSP sucks } // reset members contextTag = null; return SKIP_BODY; }