List of usage examples for org.dom4j Element addText
Element addText(String text);
Text
node with the given text to this element. From source file:de.matzefratze123.heavyspleef.core.extension.ExtensionLobbyWall.java
License:Open Source License
@Override public void marshal(Element element) { Element startElement = element.addElement("start"); Element xStartElement = startElement.addElement("x"); Element yStartElement = startElement.addElement("y"); Element zStartElement = startElement.addElement("z"); Element worldStartElement = startElement.addElement("world"); Element endElement = element.addElement("end"); Element xEndElement = endElement.addElement("x"); Element yEndElement = endElement.addElement("y"); Element zEndElement = endElement.addElement("z"); Element worldEndElement = endElement.addElement("world"); worldStartElement.addText(start.getWorld().getName()); xStartElement.addText(String.valueOf(start.getBlockX())); yStartElement.addText(String.valueOf(start.getBlockY())); zStartElement.addText(String.valueOf(start.getBlockZ())); worldEndElement.addText(end.getWorld().getName()); xEndElement.addText(String.valueOf(end.getBlockX())); yEndElement.addText(String.valueOf(end.getBlockY())); zEndElement.addText(String.valueOf(end.getBlockZ())); }
From source file:de.matzefratze123.heavyspleef.flag.presets.BooleanFlag.java
License:Open Source License
@Override public void marshal(Element element) { element.addText(String.valueOf(getValue())); }
From source file:de.matzefratze123.heavyspleef.flag.presets.EnumListFlag.java
License:Open Source License
@Override public void marshalListItem(Element element, T item) { element.addText(item.name()); }
From source file:de.matzefratze123.heavyspleef.flag.presets.LocationFlag.java
License:Open Source License
@Override public void marshal(Element element) { Element worldElement = element.addElement("world"); Element xElement = element.addElement("x"); Element yElement = element.addElement("y"); Element zElement = element.addElement("z"); Location value = getValue();/*from w ww .j a va 2s. c om*/ Validate.notNull(value, "getValue() cannot be null when marshalling flag value"); worldElement.addText(value.getWorld().getName()); xElement.addText(String.valueOf(value.getX())); yElement.addText(String.valueOf(value.getY())); zElement.addText(String.valueOf(value.getZ())); }
From source file:de.matzefratze123.heavyspleef.flag.presets.LocationListFlag.java
License:Open Source License
@Override public void marshalListItem(Element element, Location item) { Element worldElement = element.addElement("world"); Element xElement = element.addElement("x"); Element yElement = element.addElement("y"); Element zElement = element.addElement("z"); worldElement.addText(item.getWorld().getName()); xElement.addText(String.valueOf(item.getX())); yElement.addText(String.valueOf(item.getY())); zElement.addText(String.valueOf(item.getZ())); }
From source file:de.matzefratze123.heavyspleef.flag.presets.StringFlag.java
License:Open Source License
@Override public void marshal(Element element) { element.addText(getValue()); }
From source file:de.matzefratze123.heavyspleef.persistence.xml.CuboidRegionXMLCodec.java
License:Open Source License
@Override public void apply(Element applyTo, CuboidRegion region) { Vector pos1 = region.getPos1(); Vector pos2 = region.getPos2(); Element pos1Element = applyTo.addElement("pos1"); Element x1Element = pos1Element.addElement("x"); Element y1Element = pos1Element.addElement("y"); Element zElement = pos1Element.addElement("z"); Element pos2Element = applyTo.addElement("pos2"); Element x2Element = pos2Element.addElement("x"); Element y2Element = pos2Element.addElement("y"); Element z2Element = pos2Element.addElement("z"); x1Element.addText(String.valueOf(pos1.getBlockX())); y1Element.addText(String.valueOf(pos1.getBlockY())); zElement.addText(String.valueOf(pos1.getBlockZ())); x2Element.addText(String.valueOf(pos2.getBlockX())); y2Element.addText(String.valueOf(pos2.getBlockY())); z2Element.addText(String.valueOf(pos2.getBlockZ())); }
From source file:de.matzefratze123.heavyspleef.persistence.xml.GameAccessor.java
License:Open Source License
@SuppressWarnings("unchecked") @Override/*from w w w . java2 s. c om*/ public void write(Game game, Element element) { wl.lock(); try { element.addAttribute("name", game.getName()); element.addAttribute("world", game.getWorld().getName()); FlagManager flagManager = game.getFlagManager(); Map<String, AbstractFlag<?>> flags = flagManager.getPresentFlags(); Element flagsElement = element.addElement("flags"); for (Entry<String, AbstractFlag<?>> entry : flags.entrySet()) { Element flagElement = flagsElement.addElement("flag"); flagElement.addAttribute("name", entry.getKey()); entry.getValue().marshal(flagElement); } GamePropertyBundle defaultBundle = flagManager.getDefaultPropertyBundle(); Element propertiesElement = element.addElement("properties"); for (Entry<GameProperty, Object> propertyEntry : defaultBundle.entrySet()) { Element propertyElement = propertiesElement.addElement("property"); propertyElement.addAttribute("key", propertyEntry.getKey().name().toLowerCase()); propertyElement.addAttribute("class", propertyEntry.getValue().getClass().getName()); propertyElement.addText(propertyEntry.getValue().toString()); } Collection<Floor> floors = game.getFloors(); Element floorsElement = element.addElement("floors"); for (Floor floor : floors) { Element floorElement = floorsElement.addElement("floor"); floorElement.addAttribute("name", floor.getName()); } ExtensionRegistry extRegistry = heavySpleef.getExtensionRegistry(); Collection<GameExtension> extensions = game.getExtensions(); Element extensionsElement = element.addElement("extensions"); for (GameExtension extension : extensions) { Element extensionElement = extensionsElement.addElement("extension"); extensionElement.addAttribute("name", extRegistry.getExtensionName(extension.getClass())); extension.marshal(extensionElement); } Map<String, Region> deathzones = game.getDeathzones(); Element deathzonesElement = element.addElement("deathzones"); for (Entry<String, Region> entry : deathzones.entrySet()) { String name = entry.getKey(); Region deathzone = entry.getValue(); RegionType type = RegionType.byRegionType(deathzone.getClass()); Element deathzoneElement = deathzonesElement.addElement("deathzone"); deathzoneElement.addAttribute("name", name); deathzoneElement.addAttribute("regiontype", type.getPersistenceName()); XMLRegionMetadataCodec<Region> metadataCodec = (XMLRegionMetadataCodec<Region>) METADATA_CODECS .get(deathzone.getClass()); metadataCodec.apply(deathzoneElement, deathzone); } } finally { wl.unlock(); } }
From source file:de.thischwa.pmcms.tool.ChecksumTool.java
License:LGPL
/** * Converting a Map with the file checksums to a dom. *///from www.ja v a 2 s .co m public static Document getDomChecksums(final Map<String, String> checksums) { Document dom = DocumentHelper.createDocument(); dom.setXMLEncoding(Constants.STANDARD_ENCODING); Element root = dom.addElement("checksums"); for (String name : checksums.keySet()) { Element fileElement = root.addElement("file"); Element nameElement = fileElement.addElement("name"); nameElement.addCDATA(name); Element hashElement = fileElement.addElement("checksum"); hashElement.addText(checksums.get(name)); } return dom; }
From source file:de.tu_berlin.cit.intercloud.xmpp.core.resultsetmanagement.ResultSet.java
License:Open Source License
/** * Generates a Result Set Management 'set' element that describes the parto * of the result set that was generated. You typically would use the List * that was returned by {@link #applyRSMDirectives(Element)} as an argument * to this method./*from w w w . jav a 2 s.c o m*/ * * @param returnedResults * The subset of Results that is returned by the current query. * @return An Element named 'set' that can be included in the result IQ * stanza, which returns the subset of results. */ public Element generateSetElementFromResults(List<E> returnedResults) { if (returnedResults == null) { throw new IllegalArgumentException("Argument 'returnedResults' cannot be null."); } final Element setElement = DocumentHelper .createElement(QName.get("set", ResultSet.NAMESPACE_RESULT_SET_MANAGEMENT)); // the size element contains the size of this entire result set. setElement.addElement("count").setText(String.valueOf(size())); // if the query wasn't a 'count only' query, add two more elements if (returnedResults.size() > 0) { final Element firstElement = setElement.addElement("first"); firstElement.addText(returnedResults.get(0).getUID()); firstElement.addAttribute("index", String.valueOf(indexOf(returnedResults.get(0)))); setElement.addElement("last").addText(returnedResults.get(returnedResults.size() - 1).getUID()); } return setElement; }