Niko Schmuck FAQ

We assume that you know that you have a newsfeed available as a file in a supported format (currently RSS 0.91, 1.0 and 2.0 are supported). Reading in a newsfeed is then really as simple as:

import java.io.File; import de.nava.informa.core.ChannelIF; import de.nava.informa.impl.basic.ChannelBuilder; import de.nava.informa.parsers.FeedParser; ... File inpFile = new File("javanews.xml"); ChannelIF channel = FeedParser.parse(new ChannelBuilder(), inpFile);

For accessing the news items please look into the JavaDoc for ChannelIF.

Very similar solution to the previous question, here is the code fragment (replace fooURL with your URL object):

ChannelIF channel = FeedParser.parse(channelBuilder, fooURL);

Yes, normally you don't have to care about the channel format, since the FeedParser takes the format into account. The format of the channel can be retrieved with ChannelIF.getFormat().

It is also possible to determine the channel format without parsing the complete feed, but analysing the root element. Here is an example how the FormatDetector could be used:

import de.nava.informa.core.ChannelFormat; import de.nava.informa.utils.FormatDetector; ... ChannelFormat format = FormatDetector.getFormat(fooURL);

For this purpose please use the ItemComparator (see JavaDoc) which allows you to sort news item in ascending (oldest entries first, this is the default setting) or descending order. You can also set (optionally) if you want the retrieve date or the original date (as specified in the channel definition) to be used, with the later assumed as default behaviour.

The following example should clearify the usage:

import de.nava.informa.utils.ItemComparator; ... // convert from List to Array Object[] items = channel.getItems().toArray(); // sort news items (latest entry first) java.util.Arrays.sort(items, new ItemComparator(true));

I would highly recommend to have a look into the source code of the ChannelRegistry class (JavaDoc) where you might get an idea how to use channel collections in your own code.

Fortunately, Java SDK has everything for this already. All you have to do is specify your default Authenticator which will be queried when username and password are required to access restricted domains. It's very convenient mechanism and it allows lots of fun things to be build on top of it: dialog boxes, password repositories and etc. To get started quickly, try adding the following line to your application and access the secured feed after that (note that it will open dialog box, so better you weren't running it on server side):

Authenticator.setDefault(new PluginAuthenticator());

Of course, this implementation isn't perfect -- it's just default. To do better, create your own implementation.

Due to lack of time the documentation is not complete yet. Please study the source code and especially the test cases (in the directory test/src) in the meantime. If you are willing to help out to improve documenation please contact the informa-developer mailing list.