Pages

Wednesday, September 17, 2008

BFR - An Update

It started with a simple need. I wanted, if I'm moving my downloaded file using BFR, it will store the latest chapter that I've download And show it at the mapping table. Simple right, i thought so to, well at least when i started doing it.

Basically i need to add a method that can recognize a pattern like volXX chapterYY. But since there's no fixed format for this. I need to add series of pattern that *possible* for such thing. Simple enough.

Then i need to store the latest chapter so it can be compared with future chapter that i move. To do this, i need to update my xml data. This is what i like about serializing with XML, since you know the format you can modify it using external program. Trying to do this with Java Serialization API would be nearly impossible :(

Here is the thing where it get tricky. I can do it manually, but if do that, than it would beat the purpose of creating this application. So i want to do it Automatically.

What i do is, when the application start it will try to serialize the xml data using the format known to the program. If the data is outdated, the serialization will fail. And it will throw a value required exception. When this happened i just switch to the old serializer, copy the data to the new serializer, backup the old file and then save the new XML data file. Simple but a bit tricky, wasted the whole weekend for it :(

And the last part is to create a simple rule that can determine which one is the latest chapter between 2 filename. I wanted the rule to be able to handle more complex comparison, like when there's only the volume info available and no chapter information. Or comparing which one is latest volXX chapterYY or ChapterYYY only format.

For now, the rule only consider the volXX chapterYY compared to volXX chapterYY format. Creating and plugging a new Rule should be simple enough in the future though.

You can download it from Here

No comments: