Package org.jdom2

Examples of org.jdom2.Document


    /* Load the map. This is called in the main class upon game start */
    public void load(File loadFile) {
        try {
            SAXBuilder builder = new SAXBuilder();
            Document document = builder.build(loadFile);
            Element root = document.getRootElement();

            for (Element tile : root.getChildren()) {
                int x = (int) Double.parseDouble(tile.getAttributeValue("x"));
                int y = (int) Double.parseDouble(tile.getAttributeValue("y"));
                tiles[x][y] = new Tile(TileType.valueOf(tile.getAttributeValue("type")), x, y, 32, 32);
View Full Code Here


        System.out.println("Loaded map: " + loadFile.getName());
    }

    public void save(File saveFile) {
        Document document = new Document();
        Element root = new Element("tiles");
        document.setRootElement(root);

        for (int x = 0; x < AMOUNT_TILES_WIDTH; x++) {
            for (int y = 0; y < AMOUNT_TILES_HEIGHT; y++) {
                Element tile = new Element("tile");
                System.out.println("X: " + tiles[x][y].getX() + " Y: " + tiles[x][y].getY() + " Type: " + String.valueOf(tiles[x][y].getType()));
View Full Code Here

  private static final String PLAYER = "player";
 
  public static Tree<String> buildDemoPokerTree() throws JDOMException, IOException {
    NodeMetaInfo<String> root = null;
    SAXBuilder parser = new SAXBuilder();
    Document doc = parser.build("/home/m1/programming/java/jPokerTreeView/data/large_tree.xml");
    Element data = doc.getRootElement().getChildren().get(0);
    root = convert(data);
    root.setChildren(convert(data.getChildren()));
   
    Tree<String> tree = new Tree<String>(root);
    return tree;
View Full Code Here

  }
 
  public static Tree<String> buildPokerTree(String filePath) throws JDOMException, IOException{
    NodeMetaInfo<String> root = null;
    SAXBuilder parser = new SAXBuilder();
    Document doc = parser.build(filePath);
    Element data = doc.getRootElement().getChildren().get(0);
    root = convert(data);
    root.setChildren(convert(data.getChildren()));
   
    Tree<String> tree = new Tree<String>(root);
    return tree;
View Full Code Here

  }
 
  public static Tree<String> buildDemoPokerSmallTree() throws JDOMException, IOException {
    NodeMetaInfo<String> root = null;
    SAXBuilder parser = new SAXBuilder();
    Document doc = parser.build("/home/m1/programming/java/jPokerTreeView/data/simple_tree.xml");
    Element data = doc.getRootElement().getChildren().get(0);
    root = convert(data);
    root.setChildren(convert(data.getChildren()));
    Tree<String> tree = new Tree<String>(root);
    return tree;
  }
View Full Code Here

                String cleanScmUrl = "not defined";
                try
                {
                    String content = ReleaseUtil.readXmlFile(pomFile, ls);
                    SAXBuilder builder = new SAXBuilder();
                    Document document = builder.build(new StringReader( content ));
                    Element root = document.getRootElement();

                    Element scmElement = root.getChild("scm", getNamespaceOrNull(root));

                    if(null != scmElement)
                    {
View Full Code Here

    if (messageFormatIS == null) {
      logger.debug("file messageformat.xml not found in classpath");
    } else {
      try {
        SAXBuilder builder = new SAXBuilder();
        Document document = builder.build(messageFormatIS);

        messageFormatIS.close();

        Element rootElement = document.getRootElement();
        List<Element> markers = rootElement.getChildren("marker");
        for (Element marker : markers) {
          AbstractFoundationLoggingMarker.markersXmlMap.put(marker.getAttributeValue("id"), marker);
        }
View Full Code Here

        this.representationFactory = representationFactory;
    }

    public ReadableRepresentation read(Reader reader) {
        try {
            Document d = new SAXBuilder().build(reader);
            Element root = d.getRootElement();
            return readRepresentation(root).toImmutableResource();
        } catch (JDOMException e) {
            throw new RepresentationException(e);
        } catch (IOException e) {
            throw new RepresentationException(e);
View Full Code Here

  public static void createGame(Game game, String fileName) throws JDOMException, IOException {
   
    SAXBuilder sxb = new SAXBuilder();
   
    // Extraction of the root (normally named "game")
    Document document = sxb.build(new File("files/"+fileName));
    Element root = document.getRootElement();
   
    // Creation of the players from the Element "players"
    Element playersElement = root.getChild("players");
    createPlayers(game, playersElement);
   
View Full Code Here

   * @see  Game
   * @see  XmlReader
   */
  public static void createXmlFile(Game game, String name) {
    Element gameElement = new Element(name);
    Document document = new Document(gameElement);
    if(game != null){
      gameElement.addContent(getPlayersElement(game));
      gameElement.addContent(getBasesElement(game));
      gameElement.addContent(getTowersElement(game));
      gameElement.addContent(getAgentsElement(game));
View Full Code Here

TOP

Related Classes of org.jdom2.Document

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.