public void insertHrefBefore ( String newHref , String refHref ) { String refHrefEncoded = encodeHref ( refHref ) ; String newHrefEncoded = encodeHref ( newHref ) ; if ( isDuplicate ( newHrefEncoded ) ) return ; Element child = getFirstChild ( root , "href" ) ; //$NON-NLS-1$ while ( child != null ) { if ( refHrefEncoded . equals ( getFirstText ( child ) ) ) { insertBefore ( child , "href" , newHrefEncoded ) ; //$NON-NLS-1$ return ; } child = getNextSibling ( child , "href" ) ; //$NON-NLS-1$ } Assert . isTrue ( false , Policy . bind ( "assert.noHrefRef" ) ) ; //$NON-NLS-1$ }
Inserts the given newHref before the given refHref in the set of hrefs . If newHref already exists it is not inserted .