public boolean setClassifications ( Flow [ ] newFlows ) throws InvalidFlowsException { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEntryEnabled ( ) ) SibTr . entry ( tc , "setClassifications" , newFlows ) ; boolean noClassChange = true ; // Do we have the same set of flows but with different weightings only? if ( flows == null || ( flows . length != newFlows . length ) ) { // We know that this is more than a weight change noClassChange = false ; } // Set up the new data structures to hold classification information ArrayList < String > newClassificationNames = new ArrayList < String > ( ) ; HashMap < String , ClassWeight > newMessageClasses = new HashMap < String , ClassWeight > ( ) ; HashMap < Integer , Integer > newWeightMap = new HashMap < Integer , Integer > ( ) ; // Set the new default classification newClassificationNames . add ( 0 , "$SIdefault" ) ; // Iterate over the new flows for ( int i = 0 ; i < newFlows . length ; i ++ ) { // Get the next classification name String nextClassificationName = newFlows [ i ] . getClassification ( ) ; if ( noClassChange && ! classificationNames . contains ( nextClassificationName ) ) { // This classification was not in the old list noClassChange = false ; } // The zeroth position is reserved for default, non-classified messages ClassWeight classWeight = new ClassWeight ( i + 1 , newFlows [ i ] . getWeighting ( ) ) ; // Put the new weight in the messageClasses map ClassWeight cw = newMessageClasses . put ( nextClassificationName , classWeight ) ; // Check for duplicate classification names if ( cw != null ) { InvalidFlowsException ife = new InvalidFlowsException ( ) ; if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEntryEnabled ( ) ) SibTr . exit ( tc , "setClassifications" , ife ) ; throw ife ; } newClassificationNames . add ( i + 1 , nextClassificationName ) ; // Put the new value in the weightMap newWeightMap . put ( Integer . valueOf ( i + 1 ) , Integer . valueOf ( newFlows [ i ] . getWeighting ( ) ) ) ; } // Have set up the new data structures, reset the old ones. classificationNames = newClassificationNames ; messageClasses = newMessageClasses ; weightMap = newWeightMap ; // And clone the flows this . flows = newFlows . clone ( ) ; // The number of classifications numberOfClasses = flows . length ; if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEntryEnabled ( ) ) SibTr . exit ( tc , "setClassifications" , Boolean . valueOf ( noClassChange ) ) ; return noClassChange ; }
Supports the setting of a new set of classifications based on a set of Flows provided by the caller .