All posts by Nick Lothian

Rome Fetcher

The 0.3 release of the Rome Syndication Library marks the first release of the
Rome Fetcher.

This library provides a simple but useful implementation of a HTTP fetcher for RSS/Atom feeds. It supports
HTTP conditional gets (ie: last modified and ETag handling),
and enables users to follow the Atom aggregator behaviour recommendations.

As has been
noted
over the
last couple
of days syndication clients often ignore the finer points of feed retrieval. The Rome
Fetcher is designed to do the right thing in the simplest way possible.

It comes with a decent set of test cases (using an embedded Jetty instance) – although they are currently disabled as they crash Maven (I believe this is a Maven bug).

The other big selling point is that in introduces no new libraries above the requirements used by Rome (ie, JDom beta 10).

Rome HTTP Fetcher

As Pat
mentioned, I've done a http fetching library for Rome. It is now
checked in and available.

It supports HTTP conditional gets
(ie: last modified and ETag handling) and GZip encoded feeds.
It should enable user to write aggregators that follow the
Atom aggregator behaviour recommendations.

Some docs are available (although
this will probably move).

If you are interested, please give it a go and report issues on the Wiki or on the Rome dev mailing list.

Command Line Processing in Java

I've always found processing command line parameters in Java something of
a hassle. It's not hard, but it can be error prone and
having to write the same code over and over is annoying.

Here's a class I wrote that I find useful for this. Usage:

String usage = "java " + YourClass.class.getName() + " -a FirstParam -b
SecondParam";
CmdLineProcessor cmdLine = new CmdLineProcessor(args, usage);
cmdLine.setExpectedArgumentCount(4);
if (cmdLine.process()) {
	String firstParam = cmdLine.getArgument("-a");
	String secondParam = cmdLine.getArgument("-b");
	System.out.println("Parameters were " + firstParam + " and " +
secondParam);
}
// usage message is output if process() did not return true

The class:

public class CmdLineProcessor {
	private String[] args;
	private int expectedArgumentCount = 0;
	private String usageMessage;

	public CmdLineProcessor(String[] args, String usage) {
		this.args = args;
		setUsageMessage(usage);
	}

	public boolean process() {
		if ((args == null)
			|| (args.length != expectedArgumentCount)) {

			System.err.println(getUsageMessage());
			return false;
		}
		return true;
	}

	public String getArgument(String param)
			throws IllegalArgumentException {
		for (int i = 0; i < args.length; i++) {
			if (param.equals(args[i] )) {
				if (args.length > (i + 1)) {
					return args[i+1];
				}
			}
		}
		System.err.println(getUsageMessage());
		throw new IllegalArgumentException();
	}

	public int getExpectedArgumentCount() {
		return expectedArgumentCount;
	}

	public String getUsageMessage() {
		return usageMessage;
	}

	public void setExpectedArgumentCount(int i) {
		expectedArgumentCount = i;
	}

	public void setUsageMessage(String string) {
		usageMessage = string;
	}
}

Feel free to reuse it as you need.

Book reviews in a sentance

I've read a few books over the last 3 months. Here's my ultra-short reviews (in no particular order).

Patrick O'Brian's Master and Commander, Post Captain
and H.M.S. Surprise: Good, but not outstanding. O'Brian has a tendancy to massively understate keys parts of storyline
and I find that some sub-plots just do not come to a satisfying conclusion.

Richard Morgan's Altered Carbon,
Broken Angels and Market Forces: Great reading, but extremely violent. Morgan write reasonably hard SciFi set
in the far future (in the case of Altered Carbon/Broken Angels) or some kind of near alternate future (Market Forces).
Altered Carbon and Broken Angels are a series, so read them in that order. Market Forces is an unrelated work and probably
a good place to start.

A short anecdote about
Market Forces (from an interview with Morgan:
Market Forces was originally written as a film script, bit rejected because

the central character was too morally ambivalent for Van Damme or Stallone to pick up

If you find Market Forces too violent then don't read the other books. None the less – you won't want to put these
books down.

Dan Brown's The Da Vinci Code, Angels & Demons and
Deception Point: The Da Vinci Code is an outstanding read, and highly recommended. The others are average
thrillers, and no where near the same standard.

Mark Haddon's The Curious Incident of the Dog in the Night-Time: a pretty sad story from the point of view
of and Autistic boy (and math genius) growing up. It's an interesting read, but I'd hesitate to recommend it unconditionally.

Stuff I've been Doing

Obviously I haven't done much blogging lately. However, I have moved house and done a few trips to
various far-flung places around the country.

I flew back from Perth last week. The Perth<->Adelaide trip normally takes around 3 hours. We had (according to
the pilot) 300 kph tail winds, so we did it 2:15, which was great!

Another, unrelated note: a hand whisk taped to a piece of plastic attached to a hammer drill does NOT make
a suitible substitute for an electric beater. It will, however do a great job of painting the kitchen with cheesecake…

Tim Bray at Sun

Tim Bray is going to work at Sun. That is
the best bit of news about Sun I've heard for a long, time. Hopefully he will be able to express some of Sun's ideas in
a less confusing way than the mixed messages we currently get.

Someone (I'm hoping a few referers from this link) should point him at JavaBlogs
and tell him to add himself to it – since that's where all the cool kids get their news (in the Java world, anyway).

Pluto Documentation Updated

The Pluto (JSR168 RI) Website
has been updated. If you have any comments on what we can do better, either let me know,
enter them Bugzilla or send them to the mailing lists.

In particular if you notice any mistakes or things that could be more clear on the
Using the Pluto Portal page please let
me know. I'm quite keen for the Pluto documentation to more closely follow the “Ant” model of Apache documentation
(ie: lots of correct and understandable documentation) than the “Maven” model.

Java Search JSR?

I am wondering if there are any updates on the progress of the JSR proposed in
this
message? Small quote:


The Search Specification will be an API for composing and federating search queries to a
set of search providers, and aggregating returned results. The main
goal is to support search as a way of integrating enterprise
systems. Examples of use cases include a Java web application or
portal that offers combined Web, enterprise, and site search, or a front-end
Java customer support application that offers search of a variety of
back-end enterprise applications, as a way of locating all available
information on a particular customer.