public static String normalizeRegionName(final String regionName){
  if (regionName == null || regionName.length() == 0) {
    return EMPTY_VALUE;
  }
  char[] resultName=new char[regionName.length() + 1];
  boolean changed=false;
  boolean isPrevCharSlash=false;
  int startIndex;
  if (regionName.charAt(0) != '/') {
    changed=true;
    startIndex=0;
  }
 else {
    isPrevCharSlash=true;
    startIndex=1;
  }
  resultName[0]='/';
  int resultLength=1;
  for (int index=startIndex; index < regionName.length(); ++index) {
    char currChar=regionName.charAt(index);
    if (currChar == '/') {
      if (isPrevCharSlash) {
        changed=true;
        continue;
      }
      isPrevCharSlash=true;
    }
 else {
      isPrevCharSlash=false;
    }
    resultName[resultLength++]=currChar;
  }
  if (resultName[resultLength - 1] == '/') {
    --resultLength;
    changed=true;
  }
  if (changed) {
    return new String(resultName,0,resultLength);
  }
 else {
    return regionName;
  }
}

public static String normalizeRegionName ( final String regionName ) { if ( regionName == null || regionName . length ( ) == 0 ) { return EMPTY_VALUE ; } char [ ] resultName = new char [ regionName . length ( ) + 1 ] ; boolean changed = false ; boolean isPrevCharSlash = false ; int startIndex ; if ( regionName . charAt ( 0 ) != '/' ) { changed = true ; startIndex = 0 ; } else { isPrevCharSlash = true ; startIndex = 1 ; } resultName [ 0 ] = '/' ; int resultLength = 1 ; for ( int index = startIndex ; index < regionName . length ( ) ; ++ index ) { char currChar = regionName . charAt ( index ) ; if ( currChar == '/' ) { if ( isPrevCharSlash ) { changed = true ; continue ; } isPrevCharSlash = true ; } else { isPrevCharSlash = false ; } resultName [ resultLength ++ ] = currChar ; } if ( resultName [ resultLength - 1 ] == '/' ) { -- resultLength ; changed = true ; } if ( changed ) { return new String ( resultName , 0 , resultLength ) ; } else { return regionName ; } }
change the region name to a standard format having single ' / ' as separator and starting with a ' / ' as in standard posix paths
