Hi, I am working on parsing a tab delimited file and converting it to an xml stringbuffer, which I am going to then put on a queue. I have a requirement from my architect that I am supposed to keep track of how big the buffer is getting and if hits a certain size I am supposed to create new buffer and put the old one on the queue and so on. My first question is - how do I even keep track of the size - this may not be a too difficult but I have never done anything like this so I have no idea how? Secondly, wouldn't a better approach be to just somehow break my incoming tab delimited file up first and then just parse those chunks - as my parsing routine is already quite complex plus I think the performance is going to be bad - if I constantly have to check how big the buffer is getting, while I am parsing. If anybody has any ideas on this I would greatly appreciate it. Many Thanks!
My first question is - how do I even keep track of the size - this may not be a too difficult but I have never done anything like this so I have no idea how? StringBuffer class has a method length(), -- returns the length (character count) of the string buffer. Is that what you are looking for?
Sounds like you may be getting into a tricky place ... splitting XML messages into multiple queue entries. Do they have to split on tag boundaries, row boundaries, or can you just split at exactly max buffer length regardless of where it falls in the XML? Will the receiving end know how to distinguish fragments from complete messages, and put fragments back together? Hope you have clear specs there! To split on complete tags, your code might look something like:
where nextTag is a whole tag: <thing>value</thing>
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Thanks very much for the responses: To clarify - regarding the size: Well what I am really after is the bytes - preferably I would like some api which would return bytes - but if that does not exist I guess I could convert the chars to bytes and thus compute my size in btyes - does anyone know what that algorithm is - to convert chars to bytes - is it something like a char = 2 bytes, or a char = 4 bytes?
And to clariy where to break the xml: I have a specified tag that I have to break on. If I go over the max size a bit till I come to the specified tag that is okay. Many Thanks!!
Those cherries would go best on cherry cheesecake. Don't put those cherries on this tiny ad:
a bit of art, as a gift, the permaculture playing cards