private String[] computeSegments(String path){
  int segmentCount=computeSegmentCount(path);
  if (segmentCount == 0)   return NO_SEGMENTS;
  String[] newSegments=new String[segmentCount];
  int len=path.length();
  int firstPosition=(path.charAt(0) == SEPARATOR) ? 1 : 0;
  if (firstPosition == 1 && len > 1 && (path.charAt(1) == SEPARATOR))   firstPosition=2;
  int lastPosition=(path.charAt(len - 1) != SEPARATOR) ? len - 1 : len - 2;
  int next=firstPosition;
  for (int i=0; i < segmentCount; i++) {
    int start=next;
    int end=path.indexOf(SEPARATOR,next);
    if (end == -1) {
      newSegments[i]=path.substring(start,lastPosition + 1);
    }
 else {
      newSegments[i]=path.substring(start,end);
    }
    next=end + 1;
  }
  return newSegments;
}

private String [ ] computeSegments ( String path ) { int segmentCount = computeSegmentCount ( path ) ; if ( segmentCount == 0 ) return NO_SEGMENTS ; String [ ] newSegments = new String [ segmentCount ] ; int len = path . length ( ) ; int firstPosition = ( path . charAt ( 0 ) == SEPARATOR ) ? 1 : 0 ; if ( firstPosition == 1 && len > 1 && ( path . charAt ( 1 ) == SEPARATOR ) ) firstPosition = 2 ; int lastPosition = ( path . charAt ( len - 1 ) != SEPARATOR ) ? len - 1 : len - 2 ; int next = firstPosition ; for ( int i = 0 ; i < segmentCount ; i ++ ) { int start = next ; int end = path . indexOf ( SEPARATOR , next ) ; if ( end == - 1 ) { newSegments [ i ] = path . substring ( start , lastPosition + 1 ) ; } else { newSegments [ i ] = path . substring ( start , end ) ; } next = end + 1 ; } return newSegments ; }
computes the segment array for the given canonicalized path .
