use of me.vertretungsplan.objects.AdditionalInfo in project substitution-schedule-parser by vertretungsplanme.
the class AmgRottweilMessagesParser method parse.
@NotNull
AdditionalInfo parse(String html) {
Document doc = Jsoup.parse(html);
Elements messages = doc.select("tr td:eq(1)");
StringBuilder text = new StringBuilder();
boolean first = true;
for (Element message : messages) {
if (first) {
first = false;
} else {
text.append("<br><br>");
}
text.append(message.text());
}
AdditionalInfo info = new AdditionalInfo();
info.setHasInformation(false);
info.setTitle(getTitle());
info.setText(text.toString());
return info;
}
use of me.vertretungsplan.objects.AdditionalInfo in project substitution-schedule-parser by vertretungsplanme.
the class BaseRSSFeedParser method parse.
@NotNull
private AdditionalInfo parse(String xml) {
AdditionalInfo info = new AdditionalInfo();
info.setTitle(getTitle());
Document doc = Jsoup.parse(xml, "", Parser.xmlParser());
StringBuilder content = new StringBuilder();
int count = 0;
for (Element item : doc.select("item")) {
if (count >= MAX_ITEMS_COUNT) {
break;
} else if (count != 0) {
content.append("<br><br>");
}
content.append("<b><a href=\"");
content.append(item.select("link").text());
content.append("\">");
content.append(item.select("title").text());
content.append("</a></b><br>");
final String text = Jsoup.parse(item.select("description").text()).text();
final String truncatedText = text.substring(0, Math.min(text.length(), MAX_LENGTH));
content.append(truncatedText);
if (truncatedText.length() < text.length())
content.append("…");
count++;
}
info.setText(content.toString());
return info;
}
Aggregations