public ListParser(String tag, ElementFinderFactory factory, BodyMarshaller<T> bodyMarshaller) { this.tag = tag; this.listCreator = factory.getListElementFinder(bodyMarshaller, this); }
/** * Will parse the body of an XML tag into {@link Object} then inform the {@link ParseWatcher} * The idea is to have a callback for a number of elements to create a {@link java.util.List} * * @param bodyMarshaller The marshaller to create an object from the XML body * @param watcher The watcher on elements to be informed of object creation * @param <T> The type you wish to create from the XML body * @return {@link ElementFinder} */ public <T> ElementFinder<T> getListElementFinder(BodyMarshaller<T> bodyMarshaller, ParseWatcher<T> watcher) { return getListElementFinder(new BasicParser<T>(bodyMarshaller), watcher); }
public PodcastChannelParser(ElementFinderFactory factory) { this.podcastItemFinder = factory.getListElementFinder(new PodcastItemParser(factory), parseWatcher); this.titleFinder = factory.getStringWrapperTypeFinder(Title.class); this.linkFinder = factory.getStringWrapperTypeFinder(Link.class); this.imageFinder = factory.getTypeFinder(new ChannelImageParser(factory)); }
@Before public void setUp() { initMocks(this); stub(mockFactory.getListElementFinder(Mockito.<BodyMarshaller<Object>>any(), Mockito.<ParseWatcher<Object>>any())).toReturn(mockListCreator); listParser = new ListParser<Object>("individualItemTag", mockFactory, mockMarshaller); }
public FeedParser(ElementFinderFactory factory) { this.idFinder = factory.getStringFinder(); this.titleFinder = factory.getStringFinder(); this.updatedFinder = factory.getStringFinder(); this.authorFinder = factory.getTypeFinder(new AuthorParser(factory)); this.logoFinder = factory.getStringFinder(); this.generatorFinder = factory.getStringFinder(); this.linkFinder = factory.getAttributeFinder(new LinkAttributeMarshaller(), ATTR_HREF, ATTR_REL, ATTR_TITLE, ATTR_TYPE); this.entryFinder = factory.getListElementFinder(new EntryParser(factory), parseWatcher); }