private String getChildSuffix ( StructuralNode node , boolean performRecursiveCheck ) { String resultSuffix = "" ; String suffix = null ; StructuralNode child = null ; try { for ( int i = 0 ; i < staticSuffixList . length ; i ++ ) { suffix = staticSuffixList [ i ] ; Iterator < StructuralNode > iter = node . getChildIterator ( ) ; while ( iter . hasNext ( ) ) { child = iter . next ( ) ; try { if ( child . getURI ( ) . getPath ( ) . endsWith ( suffix ) ) { return suffix ; } } catch ( Exception e ) { } } } if ( performRecursiveCheck ) { Iterator < StructuralNode > iter = node . getChildIterator ( ) ; while ( iter . hasNext ( ) ) { child = iter . next ( ) ; resultSuffix = getChildSuffix ( child , performRecursiveCheck ) ; if ( ! resultSuffix . equals ( "" ) ) { return resultSuffix ; } } } } catch ( Exception e ) { } return resultSuffix ; }
Get a suffix from the children which exists in staticSuffixList . An option is provided to check recursively . Note that the immediate children are always checked first before further recursive check is done .