private void addDiscriminatorNode ( DiscriminatorNode dn ) { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEntryEnabled ( ) ) { Tr . entry ( tc , "addDiscriminatorNode, weight=" + dn . weight ) ; } if ( discriminators == null ) { // add it as the first node discriminators = dn ; if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEntryEnabled ( ) ) { Tr . exit ( tc , "addDiscriminatorNode" ) ; } return ; } DiscriminatorNode thisDN = discriminators ; if ( thisDN . weight > dn . weight ) { // add it as the first node if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) { Tr . debug ( tc , "Adding disc first in list" ) ; } thisDN . prev = dn ; dn . next = thisDN ; discriminators = dn ; if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEntryEnabled ( ) ) { Tr . exit ( tc , "addDiscriminatorNode" ) ; } return ; } DiscriminatorNode lastDN = discriminators ; while ( thisDN . next != null ) { // somewhere in the middle lastDN = thisDN ; thisDN = thisDN . next ; if ( thisDN . weight > dn . weight ) { // put it in the middle if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) { Tr . debug ( tc , "Adding disc before " + thisDN . disc . getChannel ( ) . getName ( ) ) ; } thisDN . prev = dn ; dn . next = thisDN ; lastDN . next = dn ; dn . prev = lastDN ; if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEntryEnabled ( ) ) { Tr . exit ( tc , "addDiscriminatorNode" ) ; } return ; } } // guess its at the end thisDN . next = dn ; dn . prev = thisDN ; if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEntryEnabled ( ) ) { Tr . exit ( tc , "addDiscriminatorNode" ) ; } }
add a discriminatorNode to the linked list .