resolve method came along reasonably well today. It needed quite a bit of pre-initialised information that I hadn't provided, so I spent some time getting all of that together. This included things like preallocated local nodes for the URIs of rdf:type, rdfs:Literal, and the URI objects and local nodes for the Kowari Node Type model URI, and the URI representing a URI Reference.
With this info in place I could get going on the resolve implementation, which is based mainly on the String Pool. Unfortunately, there turned out to be no easy option to get the String Pool, so this resulted in a half hour discussion about how it should be done.
The String Pools are stored internally in the
ResolverSession object which is given to every
Resolver instance. Ideally, we don't want anyone implementing a resolver to have unfettered access to this data, as it really is internal. It is only internal resolvers, such as the node type resolver, which need to see this information.
It is on occasions like this that I see the point of the "friend" modifier in C++ (a modifier I try to avoid... unless it is really called for). The closest analogy to this in Java is "package scope" which applies to anything with protected or default visibility. Unfortunately, this only applies to anything in the same package (not even a sub package) so it is of limited use.
Rant on Inheritance
Java does annoy me a little on inheritance. Both default and "protected" modifiers permit classes in the same package to see the data. However, there is no way to only allow inheritance, while hiding the same information from the rest of the package.
It would also be nice to permit subpackages to have the same access rights as package peers. That way, "internal" packages could see data that external packages can't, without having to pollute the parent package that everyone needs to see.
Back to String Pool Access
I suggested a class in the
Resolver package which could see the internal data from the
ResolverSession as this would let me get to the String Pool data that I need, without changing the
ResolverSession interface. SR was against this, as he didn't see it providing much benefit in data hiding.
I finally ended up adding some of the String Pool methods to the
ResolverSession interface. At least these methods were all about finding data in the string pools, so they were read-only operations. So even though external packages can now see the methods, they can't cause any damage.
In the course of the discussion, it turned out that ML also needs some access to the string pool as well. So instead of adding just a single method to the
ResolverSession interface, I had to add two. The result was a modification of 6 classes which all implement this interface. Fortunately, only 4 of them were test classes which did not need to support all of the methods, so I just threw an
ResolverSession has two string pools, the methods I implemented actually performed the operation twice (on both the persistent and the temporary string pools), and then used tuples operations to concatenate the results. The NodeType resolver then calls the new
findStringPoolType method twice (once for typed literals and again for untyped literals) and concatenates those results. So there's a bit of concatenation going on.
Finally, the results needed to be sent back as a
Resolutions are just a
Tuples interface along with 2 methods, called
isComplete. The last time I implemented this class I was able to extend a
TuplesImpl, but this time I don't necessarily know what type of tuples the data will be based on, so I had to wrap a
Tuples object instead.
Wrapping an object with 23 public methods is a pain.
By the end of the day I had it all coded and compiling, but I hadn't run anything yet.
Thursday, October 28, 2004