Search in sources :

Example 1 with DeedXMLWriter

use of delta.games.lotro.lore.deeds.io.xml.DeedXMLWriter in project lotro-tools by dmorcellet.

the class DeedsContainer method writeSortedDeeds.

/**
 * Write a XML file with a sorted list of deeds.
 * @param deeds Deeds to sort and write.
 * @param out Output file.
 */
public static void writeSortedDeeds(List<DeedDescription> deeds, File out) {
    List<Comparator<DeedDescription>> comparators = new ArrayList<Comparator<DeedDescription>>();
    comparators.add(new DeedNameComparator());
    comparators.add(new DeedDescriptionComparator());
    CompoundComparator<DeedDescription> comparator = new CompoundComparator<DeedDescription>(comparators);
    Collections.sort(deeds, comparator);
    DeedXMLWriter writer = new DeedXMLWriter();
    writer.writeDeeds(out, deeds, EncodingNames.UTF_8);
}
Also used : DeedDescription(delta.games.lotro.lore.deeds.DeedDescription) DeedNameComparator(delta.games.lotro.lore.deeds.comparators.DeedNameComparator) ArrayList(java.util.ArrayList) DeedDescriptionComparator(delta.games.lotro.lore.deeds.comparators.DeedDescriptionComparator) DeedXMLWriter(delta.games.lotro.lore.deeds.io.xml.DeedXMLWriter) CompoundComparator(delta.common.utils.collections.CompoundComparator) DeedDescriptionComparator(delta.games.lotro.lore.deeds.comparators.DeedDescriptionComparator) DeedNameComparator(delta.games.lotro.lore.deeds.comparators.DeedNameComparator) CompoundComparator(delta.common.utils.collections.CompoundComparator) Comparator(java.util.Comparator)

Example 2 with DeedXMLWriter

use of delta.games.lotro.lore.deeds.io.xml.DeedXMLWriter in project lotro-tools by dmorcellet.

the class DeedsFileBuilder method doIt.

private void doIt() {
    File loreDir = LotroCoreConfig.getInstance().getLoreDir();
    File deedsDir = new File(loreDir, "deeds");
    List<DeedDescription> deeds = new ArrayList<DeedDescription>();
    DeedXMLParser parser = new DeedXMLParser();
    for (File deedFile : deedsDir.listFiles()) {
        List<DeedDescription> newDeeds = parser.parseXML(deedFile);
        deeds.addAll(newDeeds);
    }
    File out = new File(loreDir, "deeds.xml");
    DeedXMLWriter writer = new DeedXMLWriter();
    writer.writeDeeds(out, deeds, EncodingNames.UTF_8);
}
Also used : DeedDescription(delta.games.lotro.lore.deeds.DeedDescription) ArrayList(java.util.ArrayList) DeedXMLWriter(delta.games.lotro.lore.deeds.io.xml.DeedXMLWriter) File(java.io.File) DeedXMLParser(delta.games.lotro.lore.deeds.io.xml.DeedXMLParser)

Aggregations

DeedDescription (delta.games.lotro.lore.deeds.DeedDescription)2 DeedXMLWriter (delta.games.lotro.lore.deeds.io.xml.DeedXMLWriter)2 ArrayList (java.util.ArrayList)2 CompoundComparator (delta.common.utils.collections.CompoundComparator)1 DeedDescriptionComparator (delta.games.lotro.lore.deeds.comparators.DeedDescriptionComparator)1 DeedNameComparator (delta.games.lotro.lore.deeds.comparators.DeedNameComparator)1 DeedXMLParser (delta.games.lotro.lore.deeds.io.xml.DeedXMLParser)1 File (java.io.File)1 Comparator (java.util.Comparator)1