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); }
/** * @return an {@link ElementFinderFactory} this Factory is how you select which XML elements to parse as what java types * see it's javadoc for more */ public static ElementFinderFactory getElementFinderFactory() { return new ElementFinderFactory(); }
public ChannelImageParser(ElementFinderFactory factory) { this.titleFinder = factory.getStringFinder(); this.linkFinder = factory.getStringFinder(); this.urlFinder = factory.getStringFinder(); this.widthFinder = factory.getIntegerFinder(); this.heightFinder = factory.getIntegerFinder(); }
public EntryParser(ElementFinderFactory factory) { idFinder = factory.getStringFinder(); titleFinder = factory.getStringFinder(); summaryFinder = factory.getStringFinder(); updatedFinder = factory.getStringFinder(); linkFinder = factory.getListAttributeFinder(new LinkAttributeMarshaller(), linkParseWatcher, ATTR_HREF, ATTR_REL, ATTR_TITLE, ATTR_TYPE); }
public PodcastItemParser(ElementFinderFactory factory) { this.titleFinder = factory.getStringWrapperTypeFinder(Title.class); this.authorFinder = factory.getStringWrapperTypeFinder(Author.class); this.linkFinder = factory.getStringWrapperTypeFinder(Link.class); itunesDurationFinder = factory.getStringWrapperTypeFinder(ItunesDuration.class); itunesImageFinder = factory.getAttributeFinder(new ImageAttributeMarshaller(), TAG_ITUNES_IMAGE_ATTR); }
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)); }
/** * Will parse the body of an XML tag into an {@link Boolean} * * @return {@link ElementFinder} */ public ElementFinder<Boolean> getBooleanFinder() { return getTypeFinder(new BooleanBodyMarshaller()); }
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 a simple {@link Integer} wrapper class. This is a class that * has a constructor that takes a single primitive int parameter. * * @param clazz The class of your Integer Wrapper Class * @param <T> The type you wish to create from the XML body * @return {@link ElementFinder} */ public <T> ElementFinder<T> getIntegerWrapperTypeFinder(Class<T> clazz) { return getTypeFinder(new BasicParser<T>(getIntegerWrapperMarshaller(clazz))); }
/** * Will parse the body of an XML tag into a simple {@link String} wrapper class. This is a class that * has a constructor that takes a single {@link String} parameter. * * @param clazz The class of your String Wrapper Class * @param <T> The type you wish to create from the XML body * @return {@link ElementFinder} */ public <T> ElementFinder<T> getStringWrapperTypeFinder(Class<T> clazz) { return getTypeFinder(new BasicParser<T>(getStringWrapperMarshaller(clazz))); }
public AuthorParser(ElementFinderFactory factory) { nameFinder = factory.getStringFinder(); }
/** * Will parse the attributes off an XML tag, these are then passed to your {@link AttributeMarshaller} * to create an object of type {@link Object}. * * @param attributeMarshaller The marshaller to parse the attributes into your required type * @param attrTags The tags of the attributes you wish to parse * @param <T> The type you wish to create from the attributes * @return {@link ElementFinder} */ public <T> ElementFinder<T> getAttributeFinder(AttributeMarshaller<T> attributeMarshaller, String... attrTags) { return getTypeFinder(new BasicAttributeParser<T>(attributeMarshaller, attrTags)); }
/** * 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); }
/** * Will parse the body of all XML tags with the {@code tag} argument * into a {@link java.util.List} of {@link Object}. This is a simple Integer wrapper class that * has a constructor that takes a single {@link Integer} parameter.<br/> * See {@link #getIntegerWrapperTypeFinder(Class)} for more info. * * @param tag The tag to parse the body for each list element * @param clazz The class of the wrapper type you wish your List to be made of * @param <T> The type you wish to create from the XML body * @return {@link ElementFinder} */ public <T> ElementFinder<List<T>> getIntegerWrapperTypeListFinder(String tag, Class<T> clazz) { return getTypeFinder(new ListParser<T>(tag, this, getIntegerWrapperMarshaller(clazz))); }
/** * Will parse the body of all XML tags with the {@code tag} argument * into a {@link java.util.List} of {@link Object}. This is a simple String wrapper class that * has a constructor that takes a single {@link String} parameter.<br/> * See {@link #getStringWrapperTypeFinder(Class)} for more info. * * @param tag The tag to parse the body for each list element * @param clazz The class of the wrapper type you wish your List to be made of * @param <T> The type you wish to create from the XML body * @return {@link ElementFinder} */ public <T> ElementFinder<List<T>> getStringWrapperTypeListFinder(String tag, Class<T> clazz) { return getTypeFinder(new ListParser<T>(tag, this, getStringWrapperMarshaller(clazz))); }
@Override public void execute() { ElementFinderFactory factory = SimpleEasyXmlParser.getElementFinderFactory(); elementFinder = factory.getStringFinder(); Instigator instigator = new OneElementInstigator(elementFinder, "novoda", finishWatcher); SimpleEasyXmlParser.parse(XML, instigator); }
/** * Will parse the body of an XML tag into an {@link Integer} * * @return {@link ElementFinder} */ public ElementFinder<Integer> getIntegerFinder() { return getTypeFinder(new IntegerBodyMarshaller()); }
@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); }
@Override public void execute() { ElementFinderFactory factory = SimpleEasyXmlParser.getElementFinderFactory(); elementFinder = factory.getStringFinder(); Instigator instigator = new SimpleInstigator(elementFinder, finishWatcher); SimpleEasyXmlParser.parse(XML, instigator); }
/** * Will parse the body of an XML tag into {@link Object} using the supplied {@link BodyMarshaller} * * @param bodyMarshaller The marshaller to parse the body into your required type * @param <T> The type you wish to create from the XML body * @return {@link ElementFinder} */ public <T> ElementFinder<T> getTypeFinder(BodyMarshaller<T> bodyMarshaller) { return getTypeFinder(new BasicParser<T>(bodyMarshaller)); }