| Handler |

    1   package gate.util.protocols.gate;
    2
    3   import java.net.*;
    4   import java.io.*;
    5
    6   import gate.util.*;
    7
    8   /**
    9    * The handler for the "gate://" URLs.
    10   * All this class does is to transparently transform a "gate://" URL into
    11   * an URL of the according type and forward all requests through it.
    12   */
    13  public class Handler extends URLStreamHandler {
    14
    15    protected URLConnection openConnection(URL u) throws java.io.IOException {
    16      URL actualURL = Handler.class.getResource(
    17                        Files.getResourcePath() + u.getPath()
    18                      );
    19      if(actualURL == null) throw new FileNotFoundException(u.toExternalForm());
    20      return actualURL.openConnection();
    21    }
    22  }
    23

| Handler |