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")); }
void doit() { String username = args.Username; String password = args.Password; if (username != null || password != null) Authenticator.setDefault(new MyAuthenticator(username, password)); System.setProperty("java.protocol.handler.pkgs", "edu.mscd.cs"); String[] add = args.additional; if (add == null) { logger.warning("No URLs specified, exiting"); System.exit(1); } /* ** add the specified URLs to the list to be fetched. */ String[] t = new String[add.length]; for (int i = 0; i < add.length; i++) { t[i] = "<a href=\"" + add[i] + "\">"; } /* ** add to the URLs, with no base */ addToURLs(null, t); fetchAll(); /* ** shall we save the cookies to a file? */ String savecookies = args.SaveCookies; if (savecookies != null) cookies.saveCookies(savecookies); }
private void fetch(String url) { logger.entering(url); boolean Path = args.PathExamine != null || args.PathIgnore != null || args.PathSave != null || args.PathRefuse != null; boolean MIME = args.MIMEExamine != null || args.MIMEIgnore != null || args.MIMESave != null || args.MIMERefuse != null; logger.fine("Path = " + Path); logger.fine("MIME = " + MIME); boolean tb[] = EISR(url, "path", args.PathExamine, args.PathIgnore, args.PathSave, args.PathRefuse); boolean Pexamine = tb[0]; boolean Psave = tb[1]; /* * if there is no MIME, and the Path doesn't say to examine or save, * we're done. */ if (!MIME && !Pexamine && !Psave) return; /* * otherwise, we need to Path examine or save, or we need the MIME * header. in either case, we need an InputStream. */ InputStream is = null; YouAreEll yrl = null; for (int t = 0; t < args.Tries; t++) { yrl = new YouAreEll(url, urls, cookies, args); is = yrl.getInputStream(); if (is != null) break; if (args.Tries > 1) logger.warning("Trying again"); } if (is == null) return; boolean Mexamine = false; boolean Msave = false; if (MIME && yrl.getContentType() != null) { tb = EISR( yrl.getContentType(), "MIME", args.MIMEExamine, args.MIMEIgnore, args.MIMESave, args.MIMERefuse); Mexamine = tb[0]; Msave = tb[1]; } // we've looked at both Path and now MIME and there's nothing to do if (!Pexamine && !Psave && !Mexamine && !Msave) return; fetchOne(Pexamine || Mexamine, Psave || Msave, yrl, is); try { is.close(); } catch (IOException IOE) { logger.throwing(IOE); } }
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); }