private void initializePath(String p_uriSpec,int p_nStartIndex) throws MalformedURIException {
  if (p_uriSpec == null) {
    throw new MalformedURIException("Cannot initialize path from null string!");
  }
  int index=p_nStartIndex;
  int start=p_nStartIndex;
  int end=p_uriSpec.length();
  char testChar='\0';
  if (start < end) {
    if (getScheme() == null || p_uriSpec.charAt(start) == '/') {
      while (index < end) {
        testChar=p_uriSpec.charAt(index);
        if (testChar == '%') {
          if (index + 2 >= end || !isHex(p_uriSpec.charAt(index + 1)) || !isHex(p_uriSpec.charAt(index + 2))) {
            throw new MalformedURIException("Path contains invalid escape sequence!");
          }
          index+=2;
        }
 else         if (!isPathCharacter(testChar)) {
          if (testChar == '?' || testChar == '#') {
            break;
          }
          throw new MalformedURIException("Path contains invalid character: " + testChar);
        }
        ++index;
      }
    }
 else {
      while (index < end) {
        testChar=p_uriSpec.charAt(index);
        if (testChar == '?' || testChar == '#') {
          break;
        }
        if (testChar == '%') {
          if (index + 2 >= end || !isHex(p_uriSpec.charAt(index + 1)) || !isHex(p_uriSpec.charAt(index + 2))) {
            throw new MalformedURIException("Opaque part contains invalid escape sequence!");
          }
          index+=2;
        }
 else         if (!isURICharacter(testChar)) {
          throw new MalformedURIException("Opaque part contains invalid character: " + testChar);
        }
        ++index;
      }
    }
  }
  m_path=p_uriSpec.substring(start,index);
  if (testChar == '?') {
    index++;
    start=index;
    while (index < end) {
      testChar=p_uriSpec.charAt(index);
      if (testChar == '#') {
        break;
      }
      if (testChar == '%') {
        if (index + 2 >= end || !isHex(p_uriSpec.charAt(index + 1)) || !isHex(p_uriSpec.charAt(index + 2))) {
          throw new MalformedURIException("Query string contains invalid escape sequence!");
        }
        index+=2;
      }
 else       if (!isURICharacter(testChar)) {
        throw new MalformedURIException("Query string contains invalid character: " + testChar);
      }
      index++;
    }
    m_queryString=p_uriSpec.substring(start,index);
  }
  if (testChar == '#') {
    index++;
    start=index;
    while (index < end) {
      testChar=p_uriSpec.charAt(index);
      if (testChar == '%') {
        if (index + 2 >= end || !isHex(p_uriSpec.charAt(index + 1)) || !isHex(p_uriSpec.charAt(index + 2))) {
          throw new MalformedURIException("Fragment contains invalid escape sequence!");
        }
        index+=2;
      }
 else       if (!isURICharacter(testChar)) {
        throw new MalformedURIException("Fragment contains invalid character: " + testChar);
      }
      index++;
    }
    m_fragment=p_uriSpec.substring(start,index);
  }
}

private void initializePath ( String p_uriSpec , int p_nStartIndex ) throws MalformedURIException { if ( p_uriSpec == null ) { throw new MalformedURIException ( "Cannot initialize path from null string!" ) ; } int index = p_nStartIndex ; int start = p_nStartIndex ; int end = p_uriSpec . length ( ) ; char testChar = '\0' ; if ( start < end ) { if ( getScheme ( ) == null || p_uriSpec . charAt ( start ) == '/' ) { while ( index < end ) { testChar = p_uriSpec . charAt ( index ) ; if ( testChar == '%' ) { if ( index + 2 >= end || ! isHex ( p_uriSpec . charAt ( index + 1 ) ) || ! isHex ( p_uriSpec . charAt ( index + 2 ) ) ) { throw new MalformedURIException ( "Path contains invalid escape sequence!" ) ; } index += 2 ; } else if ( ! isPathCharacter ( testChar ) ) { if ( testChar == '?' || testChar == '#' ) { break ; } throw new MalformedURIException ( "Path contains invalid character: " + testChar ) ; } ++ index ; } } else { while ( index < end ) { testChar = p_uriSpec . charAt ( index ) ; if ( testChar == '?' || testChar == '#' ) { break ; } if ( testChar == '%' ) { if ( index + 2 >= end || ! isHex ( p_uriSpec . charAt ( index + 1 ) ) || ! isHex ( p_uriSpec . charAt ( index + 2 ) ) ) { throw new MalformedURIException ( "Opaque part contains invalid escape sequence!" ) ; } index += 2 ; } else if ( ! isURICharacter ( testChar ) ) { throw new MalformedURIException ( "Opaque part contains invalid character: " + testChar ) ; } ++ index ; } } } m_path = p_uriSpec . substring ( start , index ) ; if ( testChar == '?' ) { index ++ ; start = index ; while ( index < end ) { testChar = p_uriSpec . charAt ( index ) ; if ( testChar == '#' ) { break ; } if ( testChar == '%' ) { if ( index + 2 >= end || ! isHex ( p_uriSpec . charAt ( index + 1 ) ) || ! isHex ( p_uriSpec . charAt ( index + 2 ) ) ) { throw new MalformedURIException ( "Query string contains invalid escape sequence!" ) ; } index += 2 ; } else if ( ! isURICharacter ( testChar ) ) { throw new MalformedURIException ( "Query string contains invalid character: " + testChar ) ; } index ++ ; } m_queryString = p_uriSpec . substring ( start , index ) ; } if ( testChar == '#' ) { index ++ ; start = index ; while ( index < end ) { testChar = p_uriSpec . charAt ( index ) ; if ( testChar == '%' ) { if ( index + 2 >= end || ! isHex ( p_uriSpec . charAt ( index + 1 ) ) || ! isHex ( p_uriSpec . charAt ( index + 2 ) ) ) { throw new MalformedURIException ( "Fragment contains invalid escape sequence!" ) ; } index += 2 ; } else if ( ! isURICharacter ( testChar ) ) { throw new MalformedURIException ( "Fragment contains invalid character: " + testChar ) ; } index ++ ; } m_fragment = p_uriSpec . substring ( start , index ) ; } }
initialize the path for this uri from a uri string spec .
