in src/main/java/org/apache/commons/ognl/MapPropertyAccessor.java [95:144]
public String getSourceAccessor( OgnlContext context, Object target, Object index )
{
Objects.requireNonNull(context, "context");
Objects.requireNonNull(context.getCurrentNode(), "getCurrentNode()");
Node currentNode = Objects.requireNonNull(context.getCurrentNode().jjtGetParent(), "node is null for '" + index + "'" );
boolean indexedAccess = false;
if ( !( currentNode instanceof ASTProperty ) )
{
currentNode = currentNode.jjtGetParent();
}
if ( currentNode instanceof ASTProperty )
{
indexedAccess = ( (ASTProperty) currentNode ).isIndexedAccess();
}
String indexStr = index.toString();
context.setCurrentAccessor( Map.class );
context.setCurrentType( Object.class );
if ( index instanceof String && !indexedAccess )
{
String key = indexStr.replace( "\"", "" );
if ( "size".equals( key ) )
{
context.setCurrentType( int.class );
return ".size()";
}
if ( "keys".equals( key ) || "keySet".equals( key ) )
{
context.setCurrentType( Set.class );
return ".keySet()";
}
if ( "values".equals( key ) )
{
context.setCurrentType( Collection.class );
return ".values()";
}
if ( "isEmpty".equals( key ) )
{
context.setCurrentType( boolean.class );
return ".isEmpty()";
}
}
return ".get(" + indexStr + ")";
}