So, here’s my problem. I have objects like this
public class FooClass{
private int fooInt;
private String fooString, fooString_2;
}
and I have to search through them, differentiating them by either one of their parameters. Also, I am required to store them as binary files (ObjectOutputStream etc). So far I thought of using multiple ArrayList,or multiple HashMap but the problem with the latter would be that I need to perform partial String match, (beginsWith), so HashMap would be pretty useless I think.. Anyway having multiple lists of the same objects seems horrible in terms of implementations, and at this point I’m really stuck and out of ideas. Any help would be greatly appreciated!
I found this article: Use search engine technology for object persistence (I haven’t read it entirely) but I think it’s the solution you are looking for. The solution is base on Lucene.
If you will decide to use Lucene, then you should look at those tutorials. Part of this tutorials also talks about Basic Concepts which will help you to decide whether this solution works for you.
If you want your data to be represented as Java objects (I think it’s a solution you are really looking for), it would be better to use Compass (built on top of Lucene). It supports automatic marshalling, which means that Compass extract the required property from the Object model at run-time and inserts the required meta-data into the Search Engine index.. Take a look at the OSEM – Object/Search Engine Mapping in the Compass reference.