List of usage examples for org.jdom2 Element Element
public Element(final String name, final String prefix, final String uri)
From source file:by.epam.lw05.xml.ListToXml.java
private static Document listToDocument(List<Gun> guns) { Element root = new Element("arsenal", "tns", "http://www.example.com/Tarifes"); root.addNamespaceDeclaration(Namespace.getNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance")); Attribute attr = new Attribute("schemaLocation", "http://www.example.com/Tarifes myschema.xsd", Namespace.getNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance")); root.setAttribute(attr);// w w w.ja v a2 s. c o m for (Gun gun : guns) { Element combatUnit = new Element("combatunit"); combatUnit.setAttribute("serial", String.valueOf(gun.getSerial())); Element model = new Element("model"); model.setText(gun.getModel()); combatUnit.addContent(model); Element handy = new Element("handy"); handy.setText(gun.getHandy()); combatUnit.addContent(handy); Element origin = new Element("origin"); origin.setText(String.valueOf(gun.getOrigin())); combatUnit.addContent(origin); Element ttx = new Element("ttx"); Element distance = new Element("distance"); distance.setText(String.valueOf(gun.getDistance())); ttx.addContent(distance); Element optics = new Element("optics"); optics.setText(String.valueOf(gun.isOptics())); ttx.addContent(optics); combatUnit.addContent(ttx); root.addContent(combatUnit); } return new Document(root); }
From source file:com.izforge.izpack.util.xmlmerge.action.FullMergeAction.java
License:Open Source License
@Override public void perform(Element originalElement, Element patchElement, Element outputParentElement) throws AbstractXmlMergeException { logger.fine("Merging: " + originalElement + " (original) and " + patchElement + " (patch)"); Mapper mapper = (Mapper) m_mapperFactory.getOperation(originalElement, patchElement); if (originalElement == null) { outputParentElement.addContent(mapper.map(patchElement)); } else if (patchElement == null) { outputParentElement.addContent((Content) originalElement.clone()); } else {/*from w w w.j av a 2s. c o m*/ Element workingElement = new Element(originalElement.getName(), originalElement.getNamespacePrefix(), originalElement.getNamespaceURI()); addAttributes(workingElement, originalElement); logger.fine("Adding " + workingElement); outputParentElement.addContent(workingElement); doIt(workingElement, originalElement, patchElement); } }
From source file:com.izforge.izpack.util.xmlmerge.action.OrderedMergeAction.java
License:Open Source License
@Override public void perform(Element originalElement, Element patchElement, Element outputParentElement) throws AbstractXmlMergeException { logger.fine("Merging: " + originalElement + " (original) and " + patchElement + "(patch)"); Mapper mapper = (Mapper) m_mapperFactory.getOperation(originalElement, patchElement); if (originalElement == null) { outputParentElement.addContent(mapper.map(patchElement)); } else if (patchElement == null) { outputParentElement.addContent((Content) originalElement.clone()); } else {// w w w .j ava 2 s . c o m Element workingElement = new Element(originalElement.getName(), originalElement.getNamespacePrefix(), originalElement.getNamespaceURI()); addAttributes(workingElement, originalElement); logger.fine("Adding " + workingElement); outputParentElement.addContent(workingElement); doIt(workingElement, originalElement, patchElement); } }
From source file:com.kixeye.kixmpp.server.module.auth.SaslKixmppServerModule.java
License:Apache License
/** * @see com.kixeye.kixmpp.server.module.KixmppServerModule#getFeatures(io.netty.channel.Channel) *///w w w.j a v a2s. co m public List<Element> getFeatures(Channel channel) { List<Element> features = new LinkedList<>(); Boolean isAuthed = channel.attr(IS_AUTHENTICATED).get(); if (isAuthed == null || isAuthed == false) { Element mechanisms = new Element("mechanisms", null, "urn:ietf:params:xml:ns:xmpp-sasl"); Element plainMechanism = new Element("mechanism", "urn:ietf:params:xml:ns:xmpp-sasl"); plainMechanism.setText("PLAIN"); mechanisms.addContent(plainMechanism); features.add(mechanisms); } return features; }
From source file:com.kixeye.kixmpp.server.module.bind.BindKixmppServerModule.java
License:Apache License
/** * @see com.kixeye.kixmpp.server.module.KixmppServerModule#getFeatures(io.netty.channel.Channel) *///from w ww .jav a2s. c o m public List<Element> getFeatures(Channel channel) { List<Element> features = new LinkedList<>(); Boolean isBound = channel.attr(IS_BOUND).get(); if (isBound == null || isBound == false) { Element bind = new Element("bind", null, "urn:ietf:params:xml:ns:xmpp-bind"); features.add(bind); } return features; }
From source file:com.kixeye.kixmpp.server.module.session.SessionKixmppServerModule.java
License:Apache License
/** * @see com.kixeye.kixmpp.server.module.KixmppModule#getFeatures(io.netty.channel.Channel) *///from w ww.j a va 2s. c o m public List<Element> getFeatures(Channel channel) { List<Element> features = new LinkedList<>(); Boolean isSessionEnabled = channel.attr(IS_SESSION_ESTABLISHED).get(); if (isSessionEnabled == null || isSessionEnabled == false) { Element bind = new Element("session", null, "urn:ietf:params:xml:ns:xmpp-session"); features.add(bind); } return features; }