Beispiel #1
0
  /**
   * Overrides parsing the URL to validate constraints on well formed archive syntax.
   *
   * @see URLStreamHandler#parseURL(java.net.URL, java.lang.String, int, int)
   */
  @Override
  protected void parseURL(URL url, String specification, int start, int limit) {
    super.parseURL(url, specification, start, limit);

    // There needs to be another URL protocol right after the archive
    // protocol, and not a "/".
    //
    if (start > limit || specification.charAt(start) == '/') {
      throw new IllegalArgumentException(
          "archive protocol must be immediately followed by another URL protocol " + specification);
    }

    // There must be at least one archive path.
    //
    int archiveSeparator = specification.indexOf("!/", start);
    if (archiveSeparator < 0) {
      throw new IllegalArgumentException(
          "missing archive separators " + specification.substring(start, limit));
    }

    // Parse to count the archive paths that must will be delegated to the
    // nested URL based on the number of schemes at the start.
    //
    for (int i = start, end = specification.indexOf('/', start) - 1;
        (i = specification.indexOf(':', i)) < end;
        ++i) {
      // There should be at least one archive separator per scheme.
      //
      archiveSeparator = specification.indexOf("!/", archiveSeparator + 2);
      if (archiveSeparator < 0) {
        throw new IllegalArgumentException("too few archive separators " + specification);
      }
    }
  }
Beispiel #2
0
 /**
  * Parse the <code>string</code>str into <code>URL</code> u which already have the context
  * properties. The string generally have the following format: <code>
  * <center>/c:/windows/win.ini</center></code>.
  *
  * @param u The URL object that's parsed into
  * @param str The string equivalent of the specification URL
  * @param start The index in the spec string from which to begin parsing
  * @param end The index to stop parsing
  * @see java.net.URLStreamHandler#toExternalForm(URL)
  * @see java.net.URL
  */
 @Override
 protected void parseURL(URL u, String str, int start, int end) {
   if (end < start) {
     return;
   }
   String parseString = ""; // $NON-NLS-1$
   if (start < end) {
     parseString = str.substring(start, end).replace('\\', '/');
   }
   super.parseURL(u, parseString, 0, parseString.length());
 }
Beispiel #3
0
 // Overrides URLStreamHandler
 protected void parseURL(URL u, String spec, int start, int limit) {
   super.parseURL(u, spec.replace(File.separatorChar, '/'), start, limit);
 }
 @Override
 protected void parseURL(URL u, String spec, int start, int end) {
   uri = spec.substring(start, end);
   super.parseURL(u, spec, start, end);
 }