this.isStatic = isStatic;
if (DesignByContractAspect.verbose) System.out.println("[dbc] Initialising condition: " + condExpr);
originalExpr = condExpr;
condExpr += " ";
StringBuffer newcond = new StringBuffer();
StringBuffer param = null;
for (int i = 0 ; i < condExpr.length() ; i++)
{
char c = condExpr.charAt(i);
if (c == '$")
{
param = new StringBuffer();
continue;
}
else if (param != null && (c == '." || c == ' " || c == '=" || c == '>" || c == '<"
|| c == ')" || c == '}" || c == ';" || c == '[" || c == ']"))
{
//Get param name as it was (without the leading '$')
String prm = param.toString();
if (prm.equals(TARGET) && isStatic)
{
//For a static method or static condition, use the class name instead of a parameter
newcond.append(clazz.getName());
}
else
{
//Get param name for beanshell
String bsparam = "p" + i;
newcond.append(bsparam);
parameterLookup.put(bsparam, prm);
}
param = null;
}
if (param == null)
{
newcond.append(c);
}
else
{
param.append(c);
}
}
Expression expr = ExpressionParser.parseExpression(newcond.toString());
BeanshellGenerator gen = new BeanshellGenerator(expr);
this.condExpr = gen.createBeanshellCode();
if (DesignByContractAspect.verbose) System.out.println("[dbc] Expanded to Java code:\n" + this.condExpr);
this.clazz = clazz;