Is there a way to to use the whole Smack parsing framework and use an external parser?

Hi all,

I have parsong code for custom XMPP stanzas, it turns a raw XMPP String into a Java object. I currently have code (providers & co) that turns the parsed IQs and turns them back into a string so I can then use my parsers as-is, this is not optimal. I have lots of code for parsing my custom IQ stanzas and I really do not want to have to write it again for Smack nor have to maintain two sets. Is there a way to just get the raw string from smack without all the processing?

Thanks,

Gabriel

How does your parsing code turn the “raw” String into a Java object? It appears you should just abstract a little lower, e.g. just like Smack does, so instead of transforming a String to a POJO, transform a $Parser instance to a POJO. You can basically wrap the parser that Smack hands over to providers into any other parser (e.g. JABX). You could also transform it to a String in the provider and then into a POJO, but that sounds like bad design.

I actually use Tigase’s libs, it takes a String and outputs an “Element” which is a kind of map; I just take this and pass it to my transformers lib to create POJO. This is why I don’t really need to use the parser Smack uses but instead just get the raw String and pass it on to Tigase’s parsing lib and then to my transformers.

I don’t know Tigase’s parsing lib, but I wouldnt’ be surprised if you can feed it something else then a String. Any code pointers for me?

Sorry, I said String but it is a char[].

It uses this:XMPPDomBuilderHandler (Tigase XMPP Server 7.0.0 API) and hands it over to it’s parser with the char[], an offset and the length, here is an example usage:

Examples of tigase.xml.SimpleParser | massapi.com

(using a different impl. of the SimpleBuilder interface).

Ahh, then you are out of luck. It appears you have to first get the full element as String and then parse it again, if you want to use SimpleParser.

Ok, thanks