question: protected void closeOutUnwantedEmbeddedTags ( AttributeSet attr ) throws IOException { tagsToRemove . removeAllElements ( ) ; attr = convertToHTML ( attr , null ) ; HTML . Tag t ; Object tValue ; int firstIndex = - 1 ; int size = tags . size ( ) ; for ( int i = size - 1 ; i >= 0 ; i -- ) { t = tags . elementAt ( i ) ; tValue = tagValues . elementAt ( i ) ; if ( ( attr == null ) || noMatchForTagInAttributes ( attr , t , tValue ) ) { firstIndex = i ; tagsToRemove . addElement ( t ) ; } } if ( firstIndex != - 1 ) { boolean removeAll = ( ( size - firstIndex ) == tagsToRemove . size ( ) ) ; for ( int i = size - 1 ; i >= firstIndex ; i -- ) { t = tags . elementAt ( i ) ; if ( removeAll || tagsToRemove . contains ( t ) ) { tags . removeElementAt ( i ) ; tagValues . removeElementAt ( i ) ; } write ( '<' ) ; write ( '/' ) ; write ( t . toString ( ) ) ; write ( '>' ) ; } size = tags . size ( ) ; for ( int i = firstIndex ; i < size ; i ++ ) { t = tags . elementAt ( i ) ; write ( '<' ) ; write ( t . toString ( ) ) ; Object o = tagValues . elementAt ( i ) ; if ( o != null && o instanceof AttributeSet ) { writeAttributes ( ( AttributeSet ) o ) ; } write ( '>' ) ; } } }
target:  Searches the attribute set and for each tag that is stored in the tag vector.  If the tag is not found, then the tag is removed from the vector and a corresponding end tag is written out.