com.cflint.StackHandler Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of CFLint Show documentation
Show all versions of CFLint Show documentation
A static code analysis tool for ColdFusion (in the spirit of FindBugs and Lint). With CFLint, you are able to analyze your ColdFusion code base for code violations.
package com.cflint;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Deque;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
public class StackHandler {
Deque varStack = new ArrayDeque();
public StackHandler() {
super();
excludes.add("VARIABLES");
excludes.add("ARGUMENTS");
excludes.add("SUPER");
excludes.add("SESSION");
excludes.add("APPLICATION");
excludes.add("THIS");
excludes.add("LOCAL");
varStack.push(new Stack(""));
}
// Set variables = new HashSet();
Set excludes = new HashSet();
public void addVariable(final String name) {
varStack.peek().getVariables().add(name.toUpperCase());
}
public void addArgument(final String name) {
varStack.peek().getArguments().add(name.toUpperCase());
}
public boolean hasArgument(final String name) {
return varStack.peek().getArguments().contains(name.toUpperCase());
}
public void push(final String pathName) {
varStack.push(new Stack(pathName));
}
public void pop() {
varStack.pop();
}
public Object getPluginVar(final Class> clazz, final String var) {
final String key = clazz.getName() + "_" + var;
final Iterator iter = varStack.iterator();
while (iter.hasNext()) {
final Stack vars = iter.next();
if (vars.getPluginvariables().containsKey(key)) {
return vars.getPluginvariables().get(key);
}
}
return null;
}
@SuppressWarnings("unchecked")
public Collection