Search in sources :

Example 1 with PairList

use of plugin.overland.util.PairList 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);
}
Also used : RBCost(plugin.overland.util.RBCost) SAXBuilder(org.jdom2.input.SAXBuilder) XMLFilter(plugin.overland.gui.XMLFilter) PairList(plugin.overland.util.PairList) Document(org.jdom2.Document) File(java.io.File) DocType(org.jdom2.DocType) ParseException(java.text.ParseException)

Aggregations

File (java.io.File)1 ParseException (java.text.ParseException)1 DocType (org.jdom2.DocType)1 Document (org.jdom2.Document)1 SAXBuilder (org.jdom2.input.SAXBuilder)1 XMLFilter (plugin.overland.gui.XMLFilter)1 PairList (plugin.overland.util.PairList)1 RBCost (plugin.overland.util.RBCost)1