public AsyncWork < Boolean , Exception > nextInnerElement ( ElementContext parent ) { if ( event . context . isEmpty ( ) ) return new AsyncWork <> ( Boolean . FALSE , null ) ; if ( Type . START_ELEMENT . equals ( event . type ) && event . context . getFirst ( ) == parent && event . isClosed ) return new AsyncWork <> ( Boolean . FALSE , null ) ; if ( Type . END_ELEMENT . equals ( event . type ) && event . context . getFirst ( ) == parent ) return new AsyncWork <> ( Boolean . FALSE , null ) ; boolean parentPresent = false ; for ( ElementContext ctx : event . context ) if ( ctx == parent ) { parentPresent = true ; break ; } if ( ! parentPresent ) return new AsyncWork <> ( null , new Exception ( "Invalid context: parent element " + parent . localName + " is not in the current context" ) ) ; ISynchronizationPoint < Exception > next = next ( ) ; do { if ( next . isUnblocked ( ) ) { if ( next . hasError ( ) ) return new AsyncWork <> ( null , next . getError ( ) ) ; if ( Type . END_ELEMENT . equals ( event . type ) ) { if ( event . context . getFirst ( ) == parent ) return new AsyncWork <> ( Boolean . FALSE , null ) ; } else if ( Type . START_ELEMENT . equals ( event . type ) ) { if ( event . context . size ( ) > 1 && event . context . get ( 1 ) == parent ) return new AsyncWork <> ( Boolean . TRUE , null ) ; } next = next ( ) ; continue ; } break ; } while ( true ) ; AsyncWork < Boolean , Exception > result = new AsyncWork <> ( ) ; ISynchronizationPoint < Exception > n = next ; next . listenInline ( ( ) -> { if ( n . hasError ( ) ) result . error ( n . getError ( ) ) ; else if ( Type . END_ELEMENT . equals ( event . type ) && event . context . getFirst ( ) == parent ) result . unblockSuccess ( Boolean . FALSE ) ; else if ( Type . START_ELEMENT . equals ( event . type ) && event . context . size ( ) > 1 && event . context . get ( 1 ) == parent ) result . unblockSuccess ( Boolean . TRUE ) ; else new ParsingTask ( ( ) -> { nextInnerElement ( parent ) . listenInline ( result ) ; } ) . start ( ) ; } , result ) ; return result ; }
Go to the next inner element . The result is false if the parent element has been closed .