コード例 #1
0
ファイル: Handler.java プロジェクト: komma/komma
  /**
   * 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);
      }
    }
  }
コード例 #2
0
ファイル: Handler.java プロジェクト: dennis-xlc/ORDER
 /**
  * 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());
 }
コード例 #3
0
ファイル: Handler.java プロジェクト: nickman/shorthand
 /**
  * {@inheritDoc}
  *
  * @see java.net.URLStreamHandler#setURL(java.net.URL, java.lang.String, java.lang.String, int,
  *     java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
  */
 @Override
 protected void setURL(
     URL u,
     String protocol,
     String host,
     int port,
     String authority,
     String userInfo,
     String path,
     String query,
     String ref) {
   if (path == null || path.trim().isEmpty()) {
     path = "" + counter.incrementAndGet();
   }
   if (host == null || host.trim().isEmpty()) {
     host = "localhost";
   }
   super.setURL(u, protocol, host, port, authority, userInfo, path, query, ref);
   u.hashCode();
   BufferManager.getInstance().registerMemBuffer(u);
 }
コード例 #4
0
ファイル: Handler.java プロジェクト: hbuexinxin/photopulse
 // Overrides URLStreamHandler
 protected void parseURL(URL u, String spec, int start, int limit) {
   super.parseURL(u, spec.replace(File.separatorChar, '/'), start, limit);
 }
コード例 #5
0
 @Override
 protected void parseURL(URL u, String spec, int start, int end) {
   uri = spec.substring(start, end);
   super.parseURL(u, spec, start, end);
 }