PreviousNext…

Single category view parsing with Java

Background

I wanted a way for a Java Applet to gather data from a single-category Domino view. I first wanted to get a list of available categories in the view and then I wanted to get a list of data from the view entries within a selected category.

The most promising post in the Sandbox (linked here) seemed to provide exactly what I was after. By using IBM's powerful XML4J (XML Parser for Java) parser toolkit to process a ?ReadViewEntries-type Domino URL I could get a viable data source. However, a major drawback for me was the fact that the xml4j.jar file alone is over 700Kb in size.

The article got me thinking, however. The XML data returned by a ?ReadViewEntries call is pretty simple in its structure, after all. So I had a bash at writing my own set of classes to parse the XML data returned by a this Domino URL. The resulting .jar file is just under 5Kb in size and works like a dream.

In The Zip

The .zip file attached contains: the 4 classes ('NotesView*.java') that gets the Domino view data as per both my original requirements; the 'javadoc' output for the 4 classes (access via 'index.html'); and an application that demonstrates it all working ('NVTest.java').

Extract the lot to somewhere where you can compile the .java files; edit 'NVTest.java' and plug in some real values for the first three variables defined therein ('baseURL', 'maxCategories' and 'categoryKey'); compile all the .java files; and run the 'NVTest' application.

Looking at what 'NVTest.java' does should give you a good idea as to how to use the 'NotesView*' classes (they are pretty basic, after all).

Caveats

  • Whilst I am a reasonably experienced Notes/Domino developer, I am a complete beginner when it comes to Java. Any real Java developer will probably take one look at my code and roll their eyes. And that's fine. If, once they've finished rolling their eyes, they could then clean up the code and re-submit it as a response to this post, that would be great.
  • I have endeavored to ensure that all the code supplied is JDK 1.1 compliant (i.e. it should be able to be used by an applet running in any modern browser). If you need it to be JDK 1.0 compliant then you'll need to re-write the 'NotesViewData' class to use the InputStream sub-classes instead of the Reader sub-classes I have used. The other classes should be JDK 1.0 compliant already. If anyone spots anything in my code that is not JDK 1.1 compliant, please let us all know by adding a response to this post.
  • I built my parser without direct reference to a ?ReadViewEntries-type view DTD or schema, so potentially it might not be able to handle all eventualities. Again, if anyone would like to make these classes more robust, then please submit your efforts as a response to this post.

Further reading

Downloads

Comments on this post are now closed.

About

I’m a software architect / developer / general IT wrangler specialising in web, mobile web and middleware using things like node.js, Java, C#, PHP, HTML5 and more.

Best described as a simpleton, but kindly. You can read more here.

";
File Attachment Icon
NotesViewJava.zip