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 {
final Deque varStack = new ArrayDeque();
final Set excludes = new HashSet();
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(""));
}
public void addVariable(final String name) {
varStack.peek().getVariables().add(name.toUpperCase());
}
public void addVariables(final List names) {
if(names != null){
for(String name: names){
varStack.peek().getVariables().add(name.toUpperCase());
}
}
}
public void addQueryColumnSet(final String name, final List columns) {
varStack.peek().getQueryColumns().put(name.toUpperCase(),columns);
}
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 Stack pop() {
return 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