public ArrayNode filter ( ComparisonExpression expression ) { ArrayNode result = new ObjectMapper ( ) . createArrayNode ( ) ; if ( node . isArray ( ) ) { Iterator < JsonNode > iterator = node . iterator ( ) ; int validObjectsCount = 0 ; int topCount = 0 ; while ( iterator . hasNext ( ) ) { JsonNode curNode = iterator . next ( ) ; if ( expression == null || ( expression != null && new Query ( curNode ) . is ( expression ) ) ) { validObjectsCount ++ ; if ( this . skip != null && this . skip . intValue ( ) > 0 && this . skip . intValue ( ) >= validObjectsCount ) { continue ; } if ( this . top != null && topCount >= this . top . intValue ( ) ) { break ; } result . add ( curNode ) ; topCount ++ ; } } } else { throw new UnsupportedExprException ( "Filters are only supported on ArrayNode objects" ) ; } return result ; }
Allows filtering values in a ArrayNode as per passed ComparisonExpression