use of org.jsoup.nodes.Element in project nixmash-blog by mintster.
the class JsoupHtmlParser method parseSelector.
private String parseSelector(Field f) {
String selector = f.getAnnotation(Selector.class).value();
Elements elems = doc.select(selector);
if (elems.size() > 0) {
final Element elem = elems.get(0);
// Check which value annotation is present and retrieve data depending on the type of annotation
if (f.isAnnotationPresent(TextValue.class)) {
return elem.text();
} else if (f.isAnnotationPresent(HtmlValue.class)) {
return elem.html();
} else if (f.isAnnotationPresent(AttributeValue.class)) {
return elem.attr(f.getAnnotation(AttributeValue.class).name());
} else
return elem.text();
}
return null;
}
use of org.jsoup.nodes.Element in project nixmash-blog by mintster.
the class JsoupHtmlParser method parseLink.
private JsoupLink parseLink(Field f) {
String css = f.getAnnotation(LinkSelector.class).value();
String selector = String.format("a[href]%s", css);
Element element = doc.select(selector).first();
if (element != null) {
return createJsoupLink(element);
}
return null;
}
use of org.jsoup.nodes.Element in project nixmash-blog by mintster.
the class JsoupHtmlParser method parseImage.
private JsoupImage parseImage(Field f) {
String css = f.getAnnotation(ImageSelector.class).value();
String selector = String.format("img%s", css);
Element media = doc.select(selector).first();
if (media != null) {
return createImageElement(media);
}
return null;
}
use of org.jsoup.nodes.Element in project nixmash-blog by mintster.
the class JsoupHtmlParser method parseMetaProperty.
private String parseMetaProperty(Field f) {
String tagproperty = f.getAnnotation(MetaProperty.class).value();
String selector = String.format("meta[property=%s]", tagproperty);
Element element = doc.select(selector).first();
if (element != null)
return element.attr("content");
return null;
}
use of org.jsoup.nodes.Element in project nixmash-blog by mintster.
the class JsoupHtmlParser method parseMetaName.
private String parseMetaName(Field f) {
String tagname = f.getAnnotation(MetaName.class).value();
String selector = String.format("meta[name=%s]", tagname);
Element element = doc.select(selector).first();
if (element != null)
return element.attr("content");
return null;
}
Aggregations