Java 类org.jdom2.located.LocatedJDOMFactory 实例源码

项目:Cardinal    文件:RepositoryModule.java   
private LoadedMap loadMap(@NonNull File map, @NonNull File repo) {
  Cardinal.getPluginLogger().info("Loading map from " + map.getAbsolutePath());
  SAXBuilder builder = new SAXBuilder();
  builder.setJDOMFactory(new LocatedJDOMFactory());
  try {
    Document doc = builder.build(new FileInputStream(map.getAbsolutePath() + "/map.xml"));
    Element root = doc.getRootElement();
    Map<Element, Element> includeReplacements = Maps.newHashMap();
    for (Content descendant : root.getDescendants()) {
      if (descendant.getCType().equals(Content.CType.Element)
          && ((Element) descendant).getName().equals("include")) {
        Element includeElement = (Element) descendant;
        String source = includeElement.getAttributeValue("src");
        File include = new File(map.getParentFile(), source);
        if (!include.exists()) {
          include = new File(repo, source);
        }
        Document includeDoc = builder.build(include);
        includeReplacements.put(includeElement, includeDoc.getRootElement());
      }
    }
    includeReplacements.forEach((original, replacement) -> {
      List<Content> toAdd = new ArrayList<Content>(replacement.getContent().size());
      replacement.getContent().forEach(content -> toAdd.add(content.clone().detach()));
      original.getParentElement().addContent(toAdd);
      original.getParentElement().removeContent(original);
    });
    Proto proto = Proto.parseProto(root.getAttributeValue("proto"));
    String name = root.getChildText("name");
    String gamemode = root.getChildText("gamemode");
    LoadedMap.Edition edition = LoadedMap.Edition.forName(root.getChildText("edition"));
    String objective = root.getChildText("objective");
    Map<Contributor, String> authors = Maps.newHashMap();
    for (Element authorsElement : root.getChildren("authors")) {
      for (Element author : authorsElement.getChildren()) {
        // putContributor(author, authors);
      }
    }
    Map<Contributor, String> contributors = Maps.newHashMap();
    for (Element contributorsElement : root.getChildren("contributors")) {
      for (Element contributor : contributorsElement.getChildren()) {
        // putContributor(contributor, contributors);
      }
    }

    return new LoadedMap(map, doc, proto, name, gamemode, edition, objective, authors, contributors, 0);
  } catch (NullPointerException | JDOMException | IOException ex) {
    if (Cardinal.getInstance().getConfig().getBoolean("displayMapLoadErrors")) {
      ex.printStackTrace();
    }
    return null;
  }
}
项目:BPMNspector    文件:ProcessImporter.java   
public ProcessImporter() {
    builder = new SAXBuilder();
    builder.setJDOMFactory(new LocatedJDOMFactory());
    bpmnXsdValidator = new BpmnXsdValidator();
    wsdlValidator = new WsdlValidator();
}
项目:BPMN-Reference-Validator    文件:FileImporter.java   
/**
 * Constructs a new {@code FileImporter}
 * 
 * @param language
 *            - in order to enable language specific error messages language
 *            dependent properties are needed
 */
public FileImporter(Properties language) {
    this.language = language;
    builder = new SAXBuilder();
    builder.setJDOMFactory(new LocatedJDOMFactory());
    bpmnXsdValidator = new BpmnXsdValidator();
}