Package org.jdom2

Examples of org.jdom2.Attribute


      return;
    }
    TreeMap<String,Attribute> sorted = new TreeMap<String, Attribute>();
    List<?> atts = emt.getAttributes();
    for (Object o : atts.toArray()) {
      Attribute a = (Attribute)o;
      sorted.put(a.getQualifiedName(), a);
      a.detach();
    }
    for (Attribute a : sorted.values()) {
      emt.setAttribute(a);
    }
    for (Object o : emt.getChildren()) {
View Full Code Here


    assertTrue(a != b);
    assertTrue(a.size() == b.size());
    Iterator<Attribute> ait = a.iterator();
    Iterator<Attribute> bit = b.iterator();
    while (ait.hasNext() && bit.hasNext()) {
      Attribute aa = ait.next();
      Attribute bb = bit.next();
      compare(aa, bb);
    }
    assertFalse(ait.hasNext());
    assertFalse(bit.hasNext());
   
View Full Code Here

  @Test
  public void testOutputElementAttributeNotSpecifiedA() {
    String txt = "<root att=\"val\" />";
    final Element root = new Element("root");
    final Attribute att = new Attribute("att", "val");
    root.setAttribute(att);
    att.setSpecified(false);
    checkOutput(root, txt, txt, txt, "<root />", txt);
  }
View Full Code Here

  @Test
  public void testOutputElementAttributeNotSpecifiedB() {
    String txt = "<root atta=\"val\" attb=\"attb\" />";
    final Element root = new Element("root");
    final Attribute atta = new Attribute("atta", "val");
    final Attribute attb = new Attribute("attb", "attb");
    root.setAttribute(atta);
    root.setAttribute(attb);
    atta.setSpecified(false);
    checkOutput(root, txt, txt, txt, "<root attb=\"attb\" />", txt);
  }
View Full Code Here

  @Test
  public void testOutputElementNamespaces() {
    String txt = "<ns:root xmlns:ns=\"myns\" xmlns:ans=\"attributens\" xmlns:two=\"two\" ans:att=\"val\"/>";
    Element emt = new Element("root", Namespace.getNamespace("ns", "myns"));
    Namespace ans = Namespace.getNamespace("ans", "attributens");
    emt.setAttribute(new Attribute("att", "val", ans));
    emt.addNamespaceDeclaration(Namespace.getNamespace("two", "two"));
    checkOutput(emt,
        txt, txt,txt, txt, txt);
  }
View Full Code Here

    for(Player player: game.getPlayerManager().getPlayers()) {
      // new player
      Element playerElement = new Element("player");
      playersElement.addContent(playerElement);
      // attributes
      Attribute name = new Attribute("name", player.getName());
      Attribute money = new Attribute("money", String.valueOf(player.getBank().getMoney()));
      Attribute type = new Attribute("type", (player instanceof IAPlayer) ? "IAPlayer" : "RealPlayer");
      Attribute color = new Attribute("color", player.getColorString());
      playerElement.setAttribute(name);
      playerElement.setAttribute(money);
      playerElement.setAttribute(type);
      playerElement.setAttribute(color);
    }
View Full Code Here

    for(Base base: game.getBaseManager().getBases()) {
      // new player
      Element baseElement = new Element("base");
      basesElement.addContent(baseElement);
      // attributes
      Attribute id = new Attribute("id", String.valueOf(base.getId()));
      Attribute x = new Attribute("x", String.valueOf(base.getPosition().x));
      Attribute y = new Attribute("y", String.valueOf(base.getPosition().y));
      if(base.getPlayer() != null) {
        Attribute player = new Attribute("player", base.getPlayer().getName());
        baseElement.setAttribute(player);
      }
      Attribute nbAgents = new Attribute("nbAgents", String.valueOf(base.getNbAgents()));
      Attribute might = new Attribute("might", String.valueOf(base.getMight()));
      baseElement.setAttribute(id);
      baseElement.setAttribute(x);
      baseElement.setAttribute(y);
      baseElement.setAttribute(nbAgents);
      baseElement.setAttribute(might);
View Full Code Here

        return new Document(root);
    }

    protected Element createRootElement(Channel channel) {
        Element root = new Element("rss",getFeedNamespace());
        Attribute version = new Attribute("version", getVersion());
        root.setAttribute(version);
        root.addNamespaceDeclaration(getContentNamespace());
        generateModuleNamespaceDefs(root);
        return root;
    }
View Full Code Here

    String ret = null;
    List linksList = parent.getChildren("link", ATOM_10_NS);
    if (linksList != null) {
      for (Iterator links = linksList.iterator(); links.hasNext();) {
        Element link = (Element) links.next();
        Attribute relAtt = getAttribute(link, "rel");
        Attribute hrefAtt = getAttribute(link, "href");
        if ((relAtt == null && "alternate".equals(rel)) || (relAtt != null && relAtt.getValue().equals(rel))) {
          ret = hrefAtt.getValue();
          break;
        }
      }
    }
    return ret;
View Full Code Here

            params.put("cmlimit", limit);
            params.put("cmprop", "title|type");
        }

        if (queryContinue != null && queryContinue.getName().equals(prop) && queryContinue.getAttributes().size() == 1) {
            final Attribute a = queryContinue.getAttributes().get(0);
            params.put(a.getName(), a.getValue());
        }

        return params;
    }
View Full Code Here

TOP

Related Classes of org.jdom2.Attribute

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.