public static String updatePerfLevelSpecString(String oldSpecString, PerfLevelDescriptor[] newPlds, boolean recursive) {
        PerfLevelDescriptor[] currentPlds = getPerfLevelSpecsFromString(oldSpecString, false);

        if (currentPlds == null)
            currentPlds = PmiRegistry.getDefaultPerfLevelSpecs();

        if (newPlds == null)
            return oldSpecString;

        ArrayList tmpPds = new ArrayList(newPlds.length);
        for (int i = 0; i < newPlds.length; i++) {
            // skip plds like pmi=level if not recursive
            if (newPlds[i] == null)
                continue;

            String[] newPath = newPlds[i].getPath();
            if (!recursive && newPath.length == 1 && newPath[0].equalsIgnoreCase("pmi"))
                continue;

            boolean found = false;
            for (int j = 0; j < currentPlds.length; j++) {
                if (recursive) {
                    // update the subtree in currentPlds
                    if (newPlds[i].isSubPath(currentPlds[j])) {
                        currentPlds[j].setLevel(newPlds[i].getLevel()); // update it
                    }
                } else { // not recursive

                }

                // update itself in currentPlds
                if (newPlds[i].comparePath(currentPlds[j]) == 0) {
                    found = true;
                    currentPlds[j].setLevel(newPlds[i].getLevel()); // update it
                    if (!recursive)
                        break;
                }

            }
            if (!found) { // not included in subtree
                tmpPds.add(newPlds[i]);
            }
        }

        String ret = getStringFromPerfLevelSpecs(currentPlds, false);

        if (tmpPds.size() > 0) {
            PerfLevelDescriptor[] extraPlds = new PerfLevelDescriptor[tmpPds.size()];
            for (int i = 0; i < extraPlds.length; i++)
                extraPlds[i] = (PerfLevelDescriptor) tmpPds.get(i);

            String newString = getStringFromPerfLevelSpecs(extraPlds, false);
            if (newString != null)
                ret += ":" + newString;
        }

        return getCompressedPerfString(ret);
    }
public static String updatePerfLevelSpecString ( String oldSpecString , PerfLevelDescriptor [ ] newPlds , boolean recursive ) { PerfLevelDescriptor [ ] currentPlds = getPerfLevelSpecsFromString ( oldSpecString , false ) ; if ( currentPlds == null ) currentPlds = PmiRegistry . getDefaultPerfLevelSpecs ( ) ; if ( newPlds == null ) return oldSpecString ; ArrayList tmpPds = new ArrayList ( newPlds . length ) ; for ( int i = 0 ; i < newPlds . length ; i ++ ) { if ( newPlds [ i ] == null ) continue ; String [ ] newPath = newPlds [ i ] . getPath ( ) ; if ( ! recursive && newPath . length == 1 && newPath [ 0 ] . equalsIgnoreCase ( "pmi" ) ) continue ; boolean found = false ; for ( int j = 0 ; j < currentPlds . length ; j ++ ) { if ( recursive ) { if ( newPlds [ i ] . isSubPath ( currentPlds [ j ] ) ) { currentPlds [ j ] . setLevel ( newPlds [ i ] . getLevel ( ) ) ; } } else { } if ( newPlds [ i ] . comparePath ( currentPlds [ j ] ) == 0 ) { found = true ; currentPlds [ j ] . setLevel ( newPlds [ i ] . getLevel ( ) ) ; if ( ! recursive ) break ; } } if ( ! found ) { tmpPds . add ( newPlds [ i ] ) ; } } String ret = getStringFromPerfLevelSpecs ( currentPlds , false ) ; if ( tmpPds . size ( ) > 0 ) { PerfLevelDescriptor [ ] extraPlds = new PerfLevelDescriptor [ tmpPds . size ( ) ] ; for ( int i = 0 ; i < extraPlds . length ; i ++ ) extraPlds [ i ] = ( PerfLevelDescriptor ) tmpPds . get ( i ) ; String newString = getStringFromPerfLevelSpecs ( extraPlds , false ) ; if ( newString != null ) ret += ":" + newString ; } return getCompressedPerfString ( ret ) ; }
/*
public static String updatePerfLevelSpecString(PmiJmxMapper mapper,
String oldSpecString,
MBeanLevelSpec[] newSpecs,
boolean recursive)
{
if(newSpecs == null || newSpecs.length == 0)
return oldSpecString;

PerfLevelDescriptor[] newPlds = new PerfLevelDescriptor[newSpecs.length];
for(int i=0; i<newPlds.length; i++){}
//newPlds[i] = mapper.getPerfLevelDescriptor(newSpecs[i]);
return updatePerfLevelSpecString(oldSpecString, newPlds, recursive);
}