use of plugin.overland.gui.XMLFilter in project pcgen by PCGen.
the class RoomBoardFactory method load.
public static RoomBoard load(File dataDir) {
//Create a new list for the room and board
PairList<RBCost> inns = new PairList<>();
PairList<RBCost> foods = new PairList<>();
PairList<RBCost> animals = new PairList<>();
File path = new File(dataDir, DIR_RNBPRICE);
if (path.isDirectory()) {
File[] dataFiles = path.listFiles(new XMLFilter());
SAXBuilder builder = new SAXBuilder();
for (int i = 0; i < dataFiles.length; i++) {
try {
Document methodSet = builder.build(dataFiles[i]);
DocType dt = methodSet.getDocType();
if (//$NON-NLS-1$
dt.getElementName().equals("RNBPRICE")) {
//Do work here
loadRBData(methodSet, inns, foods, animals);
}
methodSet = null;
dt = null;
} catch (Exception e) {
Logging.errorPrintLocalised("XML Error with file {0}", dataFiles[i].getName());
Logging.errorPrint(e.getMessage(), e);
}
}
} else {
//$NON-NLS-1$
Logging.errorPrintLocalised("in_plugin_overland_noDatafile", path.getPath());
}
return new RoomBoardImplementation(inns, foods, animals);
}
use of plugin.overland.gui.XMLFilter in project pcgen by PCGen.
the class TravelMethodFactory method load.
// ### Factory methods ###
public static Vector<TravelMethod> load(File datadir) {
//Create a new list for the travel methods
Vector<TravelMethod> tms = new Vector<>();
File path = new File(datadir, DIR_TRAVELMETHODS);
if (path.isDirectory()) {
File[] dataFiles = path.listFiles(new XMLFilter());
SAXBuilder builder = new SAXBuilder();
for (int i = 0; i < dataFiles.length; i++) {
try {
Document methodSet = builder.build(dataFiles[i]);
DocType dt = methodSet.getDocType();
if (dt.getElementName().equals(XML_ELEMENT_TRAVEL)) {
//Do work here
TravelMethod tm = TravelMethodFactory.create(methodSet);
tms.add(tm);
}
} catch (Exception e) {
Logging.errorPrint(e.getMessage(), e);
}
}
} else {
//$NON-NLS-1$
Logging.errorPrintLocalised("in_plugin_overland_noDatafile", path.getPath());
}
return tms;
}
Aggregations