コード例 #1
0
ファイル: JopSpider.java プロジェクト: jordibrus/proview
  static void openURL(
      JopSession session, String name, boolean newFrame, String frameName, String bookmark) {
    System.out.println("openURL " + name);
    Object root = session.getRoot();

    // Replace any URL symbol
    name = replaceUrlSymbol(session, name);
    try {
      String url_str = null;
      if (name.substring(0, 5).equals("http:")) {
        url_str = name;
        if (url_str.lastIndexOf(".html") == -1
            && url_str.lastIndexOf(".shtml") == -1
            && url_str.lastIndexOf(".htm") == -1
            && url_str.lastIndexOf(".pdf") == -1) url_str = url_str + ".html";
      } else if (name.startsWith("$pwr_doc/")) {
        URL current = ((JApplet) root).getDocumentBase();
        String current_str = current.toString();
        int idx1 = current_str.indexOf('/');
        if (idx1 != -1 && current_str.length() > idx1 + 1) {
          idx1 = current_str.indexOf('/', idx1 + 1);
          if (idx1 != -1 && current_str.length() > idx1 + 1) {
            idx1 = current_str.indexOf('/', idx1 + 1);
            if (idx1 != -1 && current_str.length() > idx1 + 1) {
              url_str = current_str.substring(0, idx1 + 1) + "pwr_doc/" + name.substring(9);
              if (url_str.lastIndexOf(".html") == -1
                  && url_str.lastIndexOf(".shtml") == -1
                  && url_str.lastIndexOf(".htm") == -1
                  && url_str.lastIndexOf(".pdf") == -1) url_str = url_str + ".html";
            }
          }
        }
      } else {
        URL current = ((JApplet) root).getCodeBase();
        String current_str = current.toString();
        int idx1 = current_str.lastIndexOf('/');
        int idx2 = current_str.lastIndexOf(':');
        int idx = idx1;
        if (idx2 > idx) idx = idx2;
        String path = current_str.substring(0, idx + 1);
        if (name.lastIndexOf(".html") == -1
            && name.lastIndexOf(".shtml") == -1
            && name.lastIndexOf(".htm") == -1
            && name.lastIndexOf(".pdf") == -1) url_str = new String(path + name + ".html");
        else url_str = new String(path + name);
        if (bookmark != null) url_str += "#" + bookmark;
      }
      System.out.println("Opening URL: " + url_str);

      URL url = new URL(url_str);
      AppletContext appCtx = ((JApplet) root).getAppletContext();
      if (newFrame) appCtx.showDocument(url, "_blank");
      else if (frameName != null) appCtx.showDocument(url, frameName);
      else appCtx.showDocument(url, "_self");
    } catch (MalformedURLException e) {
      System.out.println("MalformedURL : " + name);
    }
  }
コード例 #2
0
ファイル: AudioApplet.java プロジェクト: suman1234567890/CFB
 public void init() {
   context = this.getAppletContext();
   String audioURL = this.getParameter("audio");
   if (audioURL == null) {
     audioURL = "http://localhost:8080/TGMC-version1/abc.wav?Text=who";
   }
   try {
     URL url = new URL(this.getDocumentBase(), audioURL);
     clip = context.getAudioClip(url);
   } catch (MalformedURLException e) {
     e.printStackTrace();
     context.showStatus("Could not load audio file!");
   }
 }