in core/src/main/java/org/apache/myfaces/extensions/validator/core/el/FaceletsTaglibExpressionHelper.java [240:335]
private static int resolveELTerms(Object o, Map<Object, Object> visited,
List<String> foundELTerms, int count) throws Exception
{
if (o == null || visited.containsKey(o) || count > 50)
{
return 0;
}
visited.put(o, null);
int elCount = 0;
Class c = o.getClass();
//inspect maps
if (o instanceof Map)
{
for (Object entry : ((Map) o).values())
{
//found entry for "virtual" facelets var
if(entry.toString().contains("ValueExpression["))
{
foundELTerms.add(entry.toString());
}
elCount += resolveELTerms(entry, visited, foundELTerms, count + 1);
}
return elCount;
}
if (ExtValUtils.getELHelper().isELTermWellFormed(o))
{
if (foundELTerms != null)
{
foundELTerms.add(o.toString());
}
return ++elCount;
}
//analyze arrays
if (c.isArray())
{
int length = Array.getLength(o);
//check array [L -> no array of primitive types
if (o.toString().startsWith("[L"))
{
for (int i = 0; i < length; i++)
{
if (o.toString().startsWith("[Ljava.lang.String"))
{
if (ExtValUtils.getELHelper().isELTermWellFormed(Array.get(o, i)))
{
if (foundELTerms != null)
{
foundELTerms.add(o.toString());
}
elCount++;
}
}
else
{
elCount += resolveELTerms(Array.get(o, i), visited, foundELTerms, count + 1);
}
}
}
return elCount;
}
List<Field> attributes = findAllAttributes(c, new ArrayList<Field>());
Field[] fields = attributes.toArray(new Field[attributes.size()]);
AccessibleObject.setAccessible(fields, true);
for (Field currentField : fields)
{
if (currentField.get(o) == null)
{
continue;
}
if (currentField.getType().equals(String.class))
{
if (currentField.get(o) != null && ExtValUtils.getELHelper().isELTermWellFormed(currentField.get(o)))
{
if (foundELTerms != null)
{
foundELTerms.add(o.toString());
}
elCount++;
}
}
else if (!currentField.getType().isPrimitive())
{
elCount += resolveELTerms(currentField.get(o), visited, foundELTerms, count + 1);
}
}
return elCount;
}