public boolean containsVariable(final String name) { if (SESSION_VARIABLE_NAME.equals(name)) { return this.sessionAttributesVariablesMap != null; } if (PARAM_VARIABLE_NAME.equals(name)) { return true; } return APPLICATION_VARIABLE_NAME.equals(name) || this.requestAttributesVariablesMap.containsVariable(name); }
public void setVariable(final String name, final Object value) { ensureLevelInitialized(true); if (this.level > 0) { // We will only take care of new/old values if we are not on level 0 int levelIndex = searchNameInIndex(name,this.index); if (levelIndex >= 0) { // There already is a registered movement for this key - we should modify it instead of creating a new one this.newValues[this.index][levelIndex] = value; } else { if (this.names[this.index].length == this.levelSizes[this.index]) { // We need to grow the arrays for this level this.names[this.index] = Arrays.copyOf(this.names[this.index], this.names[this.index].length + DEFAULT_LEVELARRAYS_SIZE); this.newValues[this.index] = Arrays.copyOf(this.newValues[this.index], this.newValues[this.index].length + DEFAULT_LEVELARRAYS_SIZE); this.oldValues[this.index] = Arrays.copyOf(this.oldValues[this.index], this.oldValues[this.index].length + DEFAULT_LEVELARRAYS_SIZE); } levelIndex = this.levelSizes[this.index]; // We will add at the end this.names[this.index][levelIndex] = name; /* * Per construction, according to the Servlet API, an attribute set to null and a non-existing * attribute are exactly the same. So we don't really have a reason to worry about the attribute * already existing or not when it was set to null. */ this.oldValues[this.index][levelIndex] = this.request.getAttribute(name); this.newValues[this.index][levelIndex] = value; this.levelSizes[this.index]++; } } // No matter if value is null or not. Value null will be equivalent to .removeAttribute() this.request.setAttribute(name, value); }
@Override public String toString() { final Map<String,Object> equivalentMap = new LinkedHashMap<String, Object>(); final Enumeration<String> attributeNamesEnum = this.request.getAttributeNames(); while (attributeNamesEnum.hasMoreElements()) { final String name = attributeNamesEnum.nextElement(); equivalentMap.put(name, this.request.getAttribute(name)); } final String textInliningStr = (getInliner() != null? "[" + getInliner().getName() + "]" : "" ); final String templateDataStr = "(" + getTemplateData().getTemplate() + ")"; return equivalentMap.toString() + (hasSelectionTarget()? "<" + getSelectionTarget() + ">" : "") + textInliningStr + templateDataStr; }
new RequestAttributesVariablesMap(configuration, templateData, templateResolutionAttributes, this.request, locale, variables); this.requestParametersVariablesMap = new RequestParametersMap(this.request); this.applicationAttributesVariablesMap = new ServletContextAttributesMap(this.servletContext);
public List<IProcessableElementTag> getElementStackAbove(final int contextLevel) { return this.requestAttributesVariablesMap.getElementStackAbove(contextLevel); }
public Object getSelectionTarget() { return this.requestAttributesVariablesMap.getSelectionTarget(); }
public List<IProcessableElementTag> getElementStack() { return this.requestAttributesVariablesMap.getElementStack(); }
public IInliner getInliner() { return this.requestAttributesVariablesMap.getInliner(); }
public void decreaseLevel() { this.requestAttributesVariablesMap.decreaseLevel(); }
public TemplateData getTemplateData() { return this.requestAttributesVariablesMap.getTemplateData(); }
public String getStringRepresentationByLevel() { // Request parameters, session and servlet context can be safely ignored here return this.requestAttributesVariablesMap.getStringRepresentationByLevel(); }
public void setTemplateData(final TemplateData templateData) { Validate.notNull(templateData, "Template Data cannot be null"); ensureLevelInitialized(false); this.lastTemplateData = templateData; this.templateDatas[this.index] = this.lastTemplateData; this.templateStack.clear(); }
public void setInliner(final IInliner inliner) { ensureLevelInitialized(false); // We use NoOpInliner.INSTACE in order to signal when inlining has actually been disabled this.lastInliner = (inliner == null? NoOpInliner.INSTANCE : inliner); this.inliners[this.index] = this.lastInliner; }
public void setSelectionTarget(final Object selectionTarget) { ensureLevelInitialized(false); this.lastSelectionTarget = new SelectionTarget(selectionTarget); this.selectionTargets[this.index] = this.lastSelectionTarget; }