public String generateUniqueName(String name,boolean addName){
  while (mUsedNames.containsKey(name.toLowerCase())) {
    Matcher matcher=mRegEx.matcher(name);
    if (matcher.matches()) {
      name=matcher.group(1) + (Integer.parseInt(matcher.group(2)) + 1);
    }
 else {
      name=name + "2";
    }
  }
  if (addName) {
    mUsedNames.put(name.toLowerCase(),"UNUSED");
    notifyChanged();
  }
  return name.toLowerCase();
}

public String generateUniqueName ( String name , boolean addName ) { while ( mUsedNames . containsKey ( name . toLowerCase ( ) ) ) { Matcher matcher = mRegEx . matcher ( name ) ; if ( matcher . matches ( ) ) { name = matcher . group ( 1 ) + ( Integer . parseInt ( matcher . group ( 2 ) ) + 1 ) ; } else { name = name + "2" ; } } if ( addName ) { mUsedNames . put ( name . toLowerCase ( ) , "UNUSED" ) ; notifyChanged ( ) ; } return name . toLowerCase ( ) ; }
generates a name that is unique within the scope of the current namemanager , based on the input name . if the base name was unique , returns it directly .
