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); }
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; }