I'm in the process of figuring out a good way to combine data from several sources into a single activity stream, which means that they should be categorized by date and then sorted by time. While that's a piece of cake with a single view, it gets hairy when you have several views, or perhaps several different types of sources entirely. Fortunately, abstract data types are here to help.
You're already using Lists and Maps, right? For this, I decided to use Maps and one of my personal favorites, the Set. If you're not familiar with them, Sets are like Lists, but only contain one of each element and don't (normally) guarantee any specific order - DocumentCollections are a type of Set (albeit not actually implementing the interface).
I created the categories by using a Map with the Date as the key and Sets of entries as the value. That would work well enough using HashMaps and HashSets, but they would require manual sorting in the XPage to display them in the right order. Fortunately, Java includes some more-specific types for this purpose: SortedMap and SortedSet. These are used the same way as normal Maps and Sets, but automatically maintain an order (based on either your own Comparator or the "natural" ordering based on the objects' compareTo(...) methods). Better still, the specific TreeMap and TreeSet implementation classes have methods to get at the keys and values, respectively, in descending order.
Once I had my collection objects picked out, all I had to do was start filling them in. I used stock Date objects for the Map's keys and wrote a compareTo(...) method for the entries I'm keeping in the Set. Then, on the containing activity stream class, I just had to write a "serializer" method to write out the current state of the objects into a List for access.
While I may change around the way I do this (I may end up putting the category headers inline so I just use one SortedSet for performance), it provides a pretty good example of when you can use some of Java's built-in classes to do some of the grunt work for you.
Public Service Announcement - NotesIn9 is down.
Tue, May 7th 2013 11:16a Jesse Gallagher David Leedy has run into some trouble with NotesIn9.com being down and he asked
if I could help him get the word out about it, which I'm more than happy to do:
Hi - Just wanted to drop a note out there about my NotesIn9.com website.
Currently it's redirecting to someplace else for some unknown reason. I
assume it's been php hacked but I don't know.
My Wordpress site is generously hosted by Chris Miller and I've sent him a
note. Though since he's in the middle of the [read] Keywords: xpages bug
Java Traps and Misconceptions
Tue, Apr 23rd 2013 6:16a Jesse Gallagher I wrote a post over at the Social Biz UG site covering a number of traps and
conceptual hurdles I frequently see people running into when it comes to Java:
ang=en_us [read] Keywords: java
Fun With Old XML Features
Tue, Apr 2nd 2013 11:18p Jesse Gallagher One of the side effects of working on the OpenNTF Domino API is that I saw
every method in the interfaces, including ones that were either new to me or
that I had forgotten about a long time ago. One of these is the "parseXML"
method found on Items, RichTextItems, and EmbeddedObjects. This was added back
in 5.0.3, I assume for some reason related to the mail template, like
everything else added back then. Basically, it takes either the contents of a
text item, the text of a rich text ite [read] Keywords: domino
Release M1 of org.openntf.domino
Tue, Apr 2nd 2013 9:17p Jesse Gallagher Yesterday, we released milestone 1 of our improved Domino API. This is our
first tagged release meant for proper testing - all of the classes are
implemented, many of the banner features are in there, and we've been using it
in various real-world situations. I switched a couple of my side projects over
- my portfolio site, the code for this blog (though I haven't deployed the
template yet), and a couple personal game-related apps. That kind of testing is
going to be crucial in getting us [read] Keywords: domino
A Mini-Vacation With Ruby and the Domino Data Service
Sat, Mar 2nd 2013 4:11p Jesse Gallagher Since I've been neck-deep in LotusScript and Java for the past couple weeks, I
decided to take a bit of a sanity break today and play around with Ruby.
Specifically, I wrote a skeletal wrapper for the Domino Data Service in the
ExtLib and the first steps of a Rails app using it a bit. I don't expect this
to actually be useful down the line, or even necessarily to get any more work
put into it, but it was a fun diversion.
The API takes the same general shape as the normal Domino API, exce [read] Keywords: domino
I Know Some Guys
Tue, Feb 26th 2013 12:09p Jesse Gallagher I've been a bit quiet lately, but that's mostly because I've been pretty busy
lately. After my old company began closing down, I started going whole-hog in
my consulting company, I Know Some Guys. Naturally, I can't go TOO much into
it, but the general gist is "so far, so good." We have a couple clients so far
and they've been keeping me busy indeed. A lot of that has involved classic
Notes client and web development, but I guess that serves me right for
snickering at people work [read] Keywords: domino
The Bean-Backed Table Design Pattern
Tue, Jan 22nd 2013 4:13p Jesse Gallagher First off, I don't like the name of this that I came up with, but it'll have to
One of the design problems that comes up all the time in Notes/Domino
development is the "arbitrary table" idea. In classic Notes, you could solve
this with an embedded view, generated HTML (if you didn't want it to be good),
or a fixed-size table with a bunch of hide-whens. With XPages, everything is
much more flexible, but there's still the question of the actual implementation.
The route I've bee [read] Keywords: domino