Archive for October, 2003

The regex package found in Java 1.4 is a very nice thing to have available as a standard library. It also seems like a great convenience that there are methods right on java.lang.String for using regexes. The crazy thing is that with String.matches the regex is essentially turned into “^regex$”, meaning that the entire string has to match the pattern you give it.

Why on Earth would they make the only regex searching function built into java.lang.String work like that? Clearly, if the behavior you want is to match the entire string, you can easily type those two characters… And, rather than documenting this right there at String.matches, you have to trudge through the javadoc until you get to the top of the Matcher javadoc to discover this magic behavior.

Unlike some other nameless blog that just rants about stuff without providing any solutions, I’ve got a solution to recommend to Sun: add either the find() or lookingAt() method to java.lang.String. I’m not sure what made them think that entire string matching was the most useful behavior, but at least they can easily do something about this without breaking existing programs. In the meantime, without changing any code, they can at least add a line to the java.lang.String.matches javadoc that says

“Warning: this method requires the entire string to match the regular expression, as if you had typed ^regex$ even though you hadn’t. By using the pattern .*regex.* this will probably do what you expect. Or you can increase your chances of RSI and use Pattern.compile(regex).matcher(string).find() to do what you really want.

Comments 20 Comments »

The Eclipse Project Draft 3.0 Plan has been updated and now shows milestones up through M9 with final 3.0 release in June 2004. Unfortunately, it doesn’t look like anything else has been updated to show what is in the Nov 21 M5 release. I really want the J2SE 1.5 features, but those are still under “proposed items”. There is some code that may make it into M5 that provides some of the backend stuff (AST) support for generics. But, as the bug linked says, there’s a bunch of other work yet to be done.

I don’t think giving up generics is worth switching from Eclipse to javac.

Comments 1 Comment »

Peter-Paul Koch has created a site that will likely help him keep busy as a freelance web designer. QuirksMode - for all your browser quirks covers all sorts of useful information about JavaScript, the DOM and CSS all with an eye toward cross-browser compatibility. That’s a good thing for folks who are still plagued with supporting Netscape 4.x. (I’m not!)

The Quirks Mode news page also looks valuable. From there, I discovered the handy phrogz.net UL to menu converter, which does just what it sounds… turn your nested lists into menus! It’s that easy!

Comments No Comments »

SHARETHIS.addEntry({ title: "Mozilla Tabbrowser Extensions", url: "http://www.blueskyonmars.com/2003/10/30/mozilla-tabbrowser-extensions/" });

Comments No Comments »

Whenever I link to a book or DVD or whatever on Amazon.com, I include the token referral link, not really expecting to get anything out of it. But, someone out there actually bought some stuff after following one of my links! Hey, thanks! My first $2 in Amazon earnings. Only a couple thousand more for that plasma TV :)

Comments No Comments »

From time to time, the discussions on slashdot lead to some useful information… like this: rdiff-backup is a program that utilizes rsync’s rdiff code to do incremental backups. Using rdiff, it can save just the parts of files that have changed, making it possible to store incremental changes in a much smaller amount of space. It can run on Linux, Windows (via cygwin) and Mac OS X, so I’ll be able to back up all of the data we’ve got.

Comments No Comments »

Pashua makes it very easy to create dialogs for Python, PHP, Shell, Perl and AppleScript programs. (Nope, no Java.) The example screenshot shows that it is very simple to use.

Comments 4 Comments »

In the Velocity User Guide, it says that “Velocity’s behaviour is to gobble up excess whitespace.” and gives some examples that it says will produce the same output. That’s not the way it works for me:

public void testVelocityWhitespace()
{
  VelocityEngine ve = new VelocityEngine();
  try
  {
    ve.init();
    VelocityContext context = new VelocityContext();
    String test1 = "Send me #set($foo = ["$10 and ","a cake"])#foreach($a in $foo)$a #end please.";
    String test2 = "Send me\n" +
      "#set( $foo = ["$10 and ","a cake"] )\n" +
      "#foreach( $a in $foo )\n" +
      "$a\n" +
      "#end\n" +
      "please.";
    String test3 = "Send me\n" +
      "			#set($foo       = ["$10 and ","a cake"])\n"
      "							 #foreach           ($a in $foo )$a\n" +
      "					 #end please.";
    StringWriter sw = new StringWriter();
    ve.evaluate(context, sw, "test", test1);
    String output1 = sw.toString();
    sw = new StringWriter();
    ve.evaluate(context, sw, "test", test2);
    String output2 = sw.toString();
    sw = new StringWriter();
    ve.evaluate(context, sw, "test", test3);
    String output3 = sw.toString();
    System.out.println(output1);
    System.out.println(output2);
    System.out.println(output3);
    assertEquals(output1, output2);
    assertEquals(output1, output3);
  }
  catch (Exception e)
  {
    e.printStackTrace();
    fail("Template didn't work correctly.");
  }
}

Perhaps there’s a property that controls it. Either way, the documentation should probably change to reflect what Velocity really does. (By the way, this is not at all a knock on Velocity. I think it’s a very nice templating system.)

Comments 1 Comment »

Why War? has links and information leaked from Diebold Election Systems’ internal mailing lists. Check this out:

“I have become increasingly concerned about the apparent lack of concern over the practice of writing contracts to provide products and services which do not exist and then attempting to build these items on an unreasonable timetable with no written plan, little to no time for testing, and minimal resources. It also seems to be an accepted practice to exaggerate our progress and functionality to our customers and ourselves then make excuses at delivery time when these products and services do not meet expectations.”

Some or all of that probably sounds familiar to anyone who’s been doing development for a while. I definitely would hold critical systems like voting systems to a much higher standard than that. The groups responsible for certifying voting machines should really torture test them and prod at them for vulnerabilities. I get the feeling that not enough of that kind of testing has gone on.

Comments No Comments »

Seeing as I work with a bunch of librarians, I found this collection of Librarian tee shirts to be most amusing.

Comments No Comments »