コード例 #1
0
ファイル: JavaLN.java プロジェクト: drsjb80/SOCKSProxy
  public static void main(String args[]) {
    ConsoleHandler ch = new ConsoleHandler();
    ch.setLevel(Level.FINEST);

    JavaLN l = new JavaLN();
    l.setLevel(Level.FINEST);
    l.addHandler(ch);
    l.setUseParentHandlers(false);

    l.info(l.toString());
    l.severe("this is a test");
    l.entering("not", "needed"); // check for call to base class
    l.entering();
    l.entering(new Integer(10));
    l.entering(args);
    l.entering(new Object[] {new Integer(1), "one"});
    l.exiting();
    l.exiting("exiting");
    l.throwing(new Throwable("Throwable message"));

    JavaLN m = new JavaLN("one");
    m.severe(m.toString());
    m.severe("this is another test");

    JavaLN n = new JavaLN("two", null);
    n.severe(n.toString());
    n.severe("this is a third test");
    n.warning(new Throwable("this is a test"));
  }
コード例 #2
0
ファイル: REplican.java プロジェクト: drsjb80/REplican
  /*
   ** Use the array pairs as pattern and replacement pairs.  E.g.:
   ** pairs[0] == "\\.wmv.*" and pairs[1] == ".wmv"
   */
  static String replaceAll(String s, String pairs[]) {
    logger.entering(s);
    logger.entering(pairs);

    if (pairs == null) return (s);

    if ((pairs.length % 2) != 0) {
      logger.severe("pairs not even");
    }

    for (int i = 0; i < pairs.length; i += 2) {
      s = s.replaceAll(pairs[i], pairs[i + 1]);
    }

    logger.exiting(s);
    return (s);
  }
コード例 #3
0
ファイル: REplican.java プロジェクト: drsjb80/REplican
  private void fetchOne(boolean examine, boolean save, YouAreEll yrl, InputStream is) {
    logger.entering(examine);
    logger.entering(save);
    logger.entering(yrl);

    if (examine) is = new DelimitedBufferedInputStream(is, '<', '>');

    BufferedOutputStream bos = null;
    WebFile wf = null;
    if (save) {
      wf = new WebFile(yrl, args);
      bos = wf.getBOS();

      if (bos == null) save = false;
    }

    if (save || examine) {
      if (!examineORsave(yrl, is, bos, examine, save, yrl.getURL())) {
        logger.severe("examineORsave failed");
      }
    }

    if (bos != null) {
      try {
        bos.close();
        if (args.SetLastModified) wf.getFile().setLastModified(yrl.getLastModified());
      } catch (IOException e) {
        logger.throwing(e);
      }
    }

    if (examine) {
      try {
        is.close();
      } catch (IOException e) {
        logger.throwing(e);
      }
    }
  }
コード例 #4
0
ファイル: REplican.java プロジェクト: drsjb80/REplican
  private void setDefaults() {
    if (args.Interesting == null) {
      String urlref = "\\s*=\\s*[\"']?([^\"'>]*)";
      String href = "[hH][rR][eE][fF]";
      String src = "[sS][rR][cC]";

      String init[] = {
        href + urlref, src + urlref,
      };

      args.Interesting = init;
    }

    if (args.URLFixUp == null) {
      // so, i don't remember why i collasped multiple spaces and
      // removed \'s. must have been important and i should have
      // documented. 's confuse URLs...
      // args.URLFixUp = new String[]{"\\s+", " ", "\\\\", ""};
      args.URLFixUp = new String[] {"\\s+", " ", "\\\\", "", "\'", "%27"};
    }

    // if they don't specify anything, look at only text.
    if (args.MIMEExamine == null
        && args.MIMEIgnore == null
        && args.PathExamine == null
        && args.PathIgnore == null) {
      args.MIMEExamine = new String[] {"text/.*"};
      if (args.PrintExamine)
        logger.warning("--MIMEExamine=" + java.util.Arrays.toString(args.MIMEExamine));
    }

    // if they don't specify anything, save only what is specified on
    // the command line.
    if (args.MIMESave == null
        && args.MIMERefuse == null
        && args.PathSave == null
        && args.PathRefuse == null) {
      if (args.additional.length == 0) {
        logger.severe("No URLs specified");
        System.exit(1);
      }

      args.PathSave = new String[args.additional.length];

      for (int i = 0; i < args.additional.length; i++)
        args.PathSave[i] = escapeURL(args.additional[i]);

      if (args.PrintSave) logger.warning("--PathSave=" + java.util.Arrays.toString(args.PathSave));
    }

    if (args.PrintAll)
      args.PrintAccept =
          args.PrintReject =
              args.PrintSave = args.PrintRefuse = args.PrintExamine = args.PrintIgnore = true;

    /*
     ** make sure we accept everything we examine, save, and the initial
     ** URLs
     */
    args.PathAccept = Utils.combineArrays(args.PathAccept, args.PathExamine);
    args.PathAccept = Utils.combineArrays(args.PathAccept, args.PathSave);
    args.PathAccept = Utils.combineArrays(args.PathAccept, args.additional);
  }