[sword-devel] I want to port the API to Java

Troy A. Griffitts sword-devel@crosswire.org
Thu, 06 Dec 2001 20:53:09 -0700


Mike,

> >       jsword currently requires the jgl container api.  The current, standard
> > java container library is not extensive enough to contain a multimap
> > equivelant of the c++ stl.  The primary difference between a map and
> > multimap is that a multimap has the ability to iterate thru duplicate
> > key values, whereas a map does not allow duplicate key values.
> 
> I am still reading up on the project so there may be some holes in my
> logic here.
> 
> Did you do the multimap exclusively for the SWConfig object? If so it
> seems to be that a better way to do this is by using a combination of
> HashMap and Properties objects. Each .conf file would have it's own
> Properties object, which are then stored in a configuration HashMap. So
> getting the value of a property would look like:
> 
> String val = ((Properties)configHash.get("KJV")).getProperty("ModDrv");

the issue is more with something like:

[KJV]
DataPath=./modules/texts/rawtext/kjv/
ModDrv=RawText
SourceType=GBF
Lang=en
GlobalOptionFilter=GBFFootnotes
GlobalOptionFilter=GBFStrongs
GlobalOptionFilter=GBFMorph


in c++, I can:

SWMgr *manager = new SWMgr();
string modDrv = (*manager->config)["KJV"]["ModDrv"];

and, (this is the multimap stuff):

for (ConfigEntMap::iterator it =
(*manager->config)["KJV"].lower_bound("GlobalOptionFilter");
    it != (*manager->config)["KJV"].upper_bound("GlobalOptionFilter");
    it++) {
  // do whatever with *it;
}


I don't believe a Properties object, nor a HashMap object allow
duplicate key values.  You can correct me if I'm wrong.  I don't mind
using the jgl library.  I'm sure we'll end up using other 3rd party libs
before things are thru.

	Sounds like you've dug into things!  Great!

			-Troy.




> 
> Which you could then hide in a convenience method if desired:
> 
> SWConfig config = SWConfig.getInstance();
> String val = config.getModuleProperty("KJV", "ModDrv");
> 
> Of course you still need a way to iterate through the modules and
> properties, but that's already done for with the HashMap.keySet() and
> Properties.keySet() methods. Which you could again hide:
> 
> Iterator moduleIterator = config.iterator();
> // ... later that afternoon ...
> Iterator propertyIterator = config.getModuleIterator( modName );
> 
> The names may be changed to protect the innocent, but I hope the idea is
> clear.
> 
> Am I understanding all of this correctly, or do I need to go back and
> rethink this?
> 
> /mike
> 
> --
> ******************************************
>  Mike Dougherty -- Java Software Engineer
> ******************************************
>  Going to church does not make a person religious, nor does going to
> school
>  make a person educated, any more than going to a garage makes a person
> a car.