use of delta.games.lotro.lore.region.Area in project lotro-tools by dmorcellet.
the class AreaPageParser method parseAreaPage.
/**
* Parse the region page at the given URL.
* @param identifier Identifier of the area.
* @return An area or <code>null</code> if an error occurred.
*/
public Area parseAreaPage(String identifier) {
Area ret = null;
String url = "http://lorebook.lotro.com/wiki/Area:" + identifier;
try {
DownloadService downloader = DownloadService.getInstance();
String page = downloader.getPage(url);
Source source = new Source(page);
// <div class="lorebooktitle">Area: Bindbole Wood</div>
Element titleTag = JerichoHtmlUtils.findElementByTagNameAndAttributeValue(source, HTMLElementName.DIV, "class", "lorebooktitle");
String name = "";
if (titleTag != null) {
name = CharacterReference.decodeCollapseWhiteSpace(titleTag.getContent());
if (name.startsWith(TITLE_SEED)) {
name = name.substring(TITLE_SEED.length()).trim();
}
}
_area = new Area(identifier, name);
// <div id="regionQuests"
Element questsTable = JerichoHtmlUtils.findElementByTagNameAndAttributeValue(source, HTMLElementName.TABLE, "id", "region_quests_table");
if (questsTable != null) {
parseQuests(questsTable);
}
ret = _area;
_area = null;
} catch (Exception e) {
_logger.error("Cannot parse region page [" + url + "]", e);
}
return ret;
}
use of delta.games.lotro.lore.region.Area in project lotro-tools by dmorcellet.
the class RegionPageParser method parseArea.
private void parseArea(Element area) {
/*
<div>
<img id="1879064022" class="territoryMarker" src="http://content.turbine.com/sites/google_map/search_result_icon.gif" title="Highlight on Map">
<a href="/wiki/Area:Bindbole_Wood">Bindbole Wood</a>
</div>
*/
String areaName = JerichoHtmlUtils.getTagContents(area, HTMLElementName.A);
Element firstA = area.getFirstElement(HTMLElementName.A);
if (firstA != null) {
String url = firstA.getAttributeValue("href");
if ((url != null) && (url.startsWith(AREA_URL_SEED))) {
String areaIdentifier = url.substring(AREA_URL_SEED.length()).trim();
Area a = new Area(areaIdentifier, areaName);
_region.addArea(a);
}
// System.out.println("Area: ["+areaName+"], URL=["+url+"]");
}
}
use of delta.games.lotro.lore.region.Area in project lotro-tools by dmorcellet.
the class MainTestRegionParsing method main.
/**
* Basic main method for test.
* @param args Not used.
*/
public static void main(String[] args) {
RegionPageParser regionParser = new RegionPageParser();
Region shire = regionParser.parseRegionPage("The_Shire");
if (shire != null) {
AreaPageParser areaParser = new AreaPageParser();
System.out.println(shire.dump());
Area[] areas = shire.getAreas();
for (Area area : areas) {
String identifier = area.getIdentifier();
Area a = areaParser.parseAreaPage(identifier);
System.out.println(a.dump());
String[] questIdentifiers = a.getQuestIdentifiers();
System.out.println(Arrays.deepToString(questIdentifiers));
}
}
}
use of delta.games.lotro.lore.region.Area in project lotro-tools by dmorcellet.
the class MainTestAreaParsing method main.
/**
* Basic main method for test.
* @param args Not used.
*/
public static void main(String[] args) {
AreaPageParser parser = new AreaPageParser();
Area area = parser.parseAreaPage("Bindbole_Wood");
if (area != null) {
System.out.println(area.dump());
}
}
Aggregations