private static Result parse(String input,boolean requireToNormalize){
  String root="";
  WindowsPathType type=null;
  int len=input.length();
  int off=0;
  if (len > 1) {
    char c0=input.charAt(0);
    char c1=input.charAt(1);
    char c=0;
    int next=2;
    if (isSlash(c0) && isSlash(c1)) {
      type=WindowsPathType.UNC;
      off=nextNonSlash(input,next,len);
      next=nextSlash(input,off,len);
      if (off == next)       throw new InvalidPathException(input,"UNC path is missing hostname");
      String host=input.substring(off,next);
      off=nextNonSlash(input,next,len);
      next=nextSlash(input,off,len);
      if (off == next)       throw new InvalidPathException(input,"UNC path is missing sharename");
      root="\\\\" + host + "\\"+ input.substring(off,next)+ "\\";
      off=next;
    }
 else {
      if (isLetter(c0) && c1 == ':') {
        char c2;
        if (len > 2 && isSlash(c2=input.charAt(2))) {
          if (c2 == '\\') {
            root=input.substring(0,3);
          }
 else {
            root=input.substring(0,2) + '\\';
          }
          off=3;
          type=WindowsPathType.ABSOLUTE;
        }
 else {
          root=input.substring(0,2);
          off=2;
          type=WindowsPathType.DRIVE_RELATIVE;
        }
      }
    }
  }
  if (off == 0) {
    if (len > 0 && isSlash(input.charAt(0))) {
      type=WindowsPathType.DIRECTORY_RELATIVE;
      root="\\";
    }
 else {
      type=WindowsPathType.RELATIVE;
    }
  }
  if (requireToNormalize) {
    StringBuilder sb=new StringBuilder(input.length());
    sb.append(root);
    return new Result(type,root,normalize(sb,input,off));
  }
 else {
    return new Result(type,root,input);
  }
}

private static Result parse ( String input , boolean requireToNormalize ) { String root = "" ; WindowsPathType type = null ; int len = input . length ( ) ; int off = 0 ; if ( len > 1 ) { char c0 = input . charAt ( 0 ) ; char c1 = input . charAt ( 1 ) ; char c = 0 ; int next = 2 ; if ( isSlash ( c0 ) && isSlash ( c1 ) ) { type = WindowsPathType . UNC ; off = nextNonSlash ( input , next , len ) ; next = nextSlash ( input , off , len ) ; if ( off == next ) throw new InvalidPathException ( input , "UNC path is missing hostname" ) ; String host = input . substring ( off , next ) ; off = nextNonSlash ( input , next , len ) ; next = nextSlash ( input , off , len ) ; if ( off == next ) throw new InvalidPathException ( input , "UNC path is missing sharename" ) ; root = "\\\\" + host + "\\" + input . substring ( off , next ) + "\\" ; off = next ; } else { if ( isLetter ( c0 ) && c1 == ':' ) { char c2 ; if ( len > 2 && isSlash ( c2 = input . charAt ( 2 ) ) ) { if ( c2 == '\\' ) { root = input . substring ( 0 , 3 ) ; } else { root = input . substring ( 0 , 2 ) + '\\' ; } off = 3 ; type = WindowsPathType . ABSOLUTE ; } else { root = input . substring ( 0 , 2 ) ; off = 2 ; type = WindowsPathType . DRIVE_RELATIVE ; } } } } if ( off == 0 ) { if ( len > 0 && isSlash ( input . charAt ( 0 ) ) ) { type = WindowsPathType . DIRECTORY_RELATIVE ; root = "\\" ; } else { type = WindowsPathType . RELATIVE ; } } if ( requireToNormalize ) { StringBuilder sb = new StringBuilder ( input . length ( ) ) ; sb . append ( root ) ; return new Result ( type , root , normalize ( sb , input , off ) ) ; } else { return new Result ( type , root , input ) ; } }
parses the given input as a windows path .
