List of usage examples for org.jdom2 Element setAttribute
public Element setAttribute(final String name, final String value)
This sets an attribute value for this element.
From source file:de.mud.flash.FlashTerminal.java
License:Open Source License
/** * The simple terminal only draws new lines and ignores changes on lines * aready written./*from w w w. java 2 s . com*/ * * @param terminal * @return */ private Element redrawSimpleTerminal(Element terminal) { terminal.setAttribute("simple", "true"); int checkPoint = buffer.scrollMarker < 0 ? 0 : buffer.scrollMarker; // first check whether our check point is in the back buffer while (checkPoint < buffer.screenBase) { terminal.addContent(redrawLine(0, checkPoint++)); } // then dive into the screen area ... while (checkPoint < buffer.bufSize) { int line = checkPoint - (buffer.screenBase - 1); if (line > buffer.getCursorRow()) { break; } terminal.addContent(redrawLine(0, checkPoint++)); } // update scroll marker buffer.scrollMarker = checkPoint; buffer.update[0] = false; return terminal; }
From source file:de.nava.informa.exporters.RSS_0_91_Exporter.java
License:Open Source License
public void write(ChannelIF channel) throws IOException { if (writer == null) { throw new RuntimeException("No writer has been initialized."); }/*from w w w . j a va 2s .co m*/ // create XML outputter with indent: 2 spaces, print new lines. Format format = Format.getPrettyFormat(); format.setEncoding(encoding); XMLOutputter outputter = new XMLOutputter(format); // ---- Element rootElem = new Element("rss"); rootElem.setAttribute("version", RSS_VERSION); Element channelElem = new Element("channel"); channelElem.addContent(new Element("title").setText(channel.getTitle())); channelElem.addContent(new Element("description").setText(channel.getDescription())); if (channel.getSite() != null) { channelElem.addContent(new Element("link").setText(channel.getSite().toString())); } if (channel.getLanguage() != null) { channelElem.addContent(new Element("language").setText(channel.getLanguage())); } Collection items = channel.getItems(); Iterator it = items.iterator(); while (it.hasNext()) { channelElem.addContent(getItemElement((ItemIF) it.next())); } // export channel image if (channel.getImage() != null) { Element imgElem = new Element("image"); imgElem.addContent(new Element("title").setText(channel.getImage().getTitle())); imgElem.addContent(new Element("url").setText(channel.getImage().getLocation().toString())); imgElem.addContent(new Element("link").setText(channel.getImage().getLink().toString())); imgElem.addContent(new Element("height").setText("" + channel.getImage().getHeight())); imgElem.addContent(new Element("width").setText("" + channel.getImage().getWidth())); imgElem.addContent(new Element("description").setText(channel.getImage().getDescription())); channelElem.addContent(imgElem); } // TODO: add exporting textinput field // if (channel.getTextInput() != null) { // channelElem.addContent(channel.getTextInput().getElement()); // } if (channel.getCopyright() != null) { channelElem.addContent(new Element("copyright").setText(channel.getCopyright())); } // we have all together for the channel definition rootElem.addContent(channelElem); // --- DocType docType = new DocType("rss", PUBLIC_ID, SYSTEM_ID); Document doc = new Document(rootElem, docType); outputter.output(doc, writer); }
From source file:de.nava.informa.exporters.RSS_2_0_Exporter.java
License:Open Source License
/** * Get the item Element to output for an ItemIF implementer * * @param item - The ItemIF object to convert to DOM-form * @return - The DOM element to output//from w w w . ja v a 2s. c o m */ protected Element getItemElement(ItemIF item) { Element itemElem = new Element("item"); itemElem.addContent(new Element("title").setText(item.getTitle())); if (item.getLink() != null) { itemElem.addContent(new Element("link").setText(item.getLink().toString())); } if (item.getDescription() != null) { itemElem.addContent(new Element("description").setText(item.getDescription())); } if (item.getCategories() != null) { Collection categories = item.getCategories(); for (Object category : categories) { CategoryIF cat = (CategoryIF) category; itemElem = getCategoryElements(itemElem, cat, null); } } if (item.getDate() != null) { itemElem.addContent(new Element("pubDate").setText(ParserUtils.formatDate(item.getDate()))); } if (item.getGuid() != null) { Element guid = new Element("guid").setText(item.getGuid().getLocation()); guid.setAttribute("isPermaLink", Boolean.toString(item.getGuid().isPermaLink())); itemElem.addContent(guid); } if (item.getComments() != null) { itemElem.addContent(new Element("comments").setText(item.getComments().toString())); } return itemElem; }
From source file:de.nava.informa.exporters.RSS_2_0_Exporter.java
License:Open Source License
public void write(ChannelIF channel) throws IOException { if (writer == null) { throw new RuntimeException("No writer has been initialized."); }/*w ww .ja v a 2 s. co m*/ // create XML outputter with indent: 2 spaces, print new lines. Format format = Format.getPrettyFormat(); format.setEncoding(encoding); XMLOutputter outputter = new XMLOutputter(format); Namespace dcNs = Namespace.getNamespace("dc", NS_DC); Namespace syNs = Namespace.getNamespace("sy", NS_SY); Namespace adminNs = Namespace.getNamespace("admin", NS_ADMIN); //Namespace rdfNs = Namespace.getNamespace("rdf", NS_RDF); Element rootElem = new Element("rss"); rootElem.addNamespaceDeclaration(dcNs); rootElem.addNamespaceDeclaration(syNs); rootElem.addNamespaceDeclaration(adminNs); rootElem.setAttribute("version", RSS_VERSION); Element channelElem = new Element("channel"); // rootElem.setAttribute("version"); channelElem.addContent(new Element("title").setText(channel.getTitle())); if (channel.getSite() != null) { channelElem.addContent(new Element("link").setText(channel.getSite().toString())); } channelElem.addContent(new Element("description").setText(channel.getDescription())); if (channel.getLanguage() != null) { channelElem.addContent(new Element("language", dcNs).setText(channel.getLanguage())); } if (channel.getCopyright() != null) { channelElem.addContent(new Element("copyright", dcNs).setText(channel.getCopyright())); } if (channel.getPubDate() != null) { channelElem.addContent(new Element("pubDate").setText(ParserUtils.formatDate(channel.getPubDate()))); } if (channel.getCategories() != null) { Collection categories = channel.getCategories(); for (Object category : categories) { CategoryIF cat = (CategoryIF) category; channelElem = getCategoryElements(channelElem, cat, null); } } if (channel.getUpdateBase() != null) { channelElem.addContent(new Element("updateBase", syNs).setText(df.format(channel.getUpdateBase()))); } if (channel.getUpdatePeriod() != null) { // don't put out frequency without specifying period channelElem.addContent(new Element("updateFrequency", syNs) .setText((new Integer(channel.getUpdateFrequency())).toString())); channelElem.addContent(new Element("updatePeriod", syNs).setText(channel.getUpdatePeriod().toString())); } // export channel image if (channel.getImage() != null) { Element imgElem = new Element("image"); imgElem.addContent(new Element("title").setText(channel.getImage().getTitle())); imgElem.addContent(new Element("url").setText(channel.getImage().getLocation().toString())); imgElem.addContent(new Element("link").setText(channel.getImage().getLink().toString())); imgElem.addContent(new Element("height").setText("" + channel.getImage().getHeight())); imgElem.addContent(new Element("width").setText("" + channel.getImage().getWidth())); imgElem.addContent(new Element("description").setText(channel.getImage().getDescription())); channelElem.addContent(imgElem); } // TODO: add exporting textinput field // if (channel.getTextInput() != null) { // channelElem.addContent(channel.getTextInput().getElement()); // } Collection items = channel.getItems(); for (Object item : items) { channelElem.addContent(getItemElement((ItemIF) item)); } rootElem.addContent(channelElem); // --- Document doc = new Document(rootElem); outputter.output(doc, writer); // --- writer.close(); }
From source file:de.openVJJ.basic.Module.java
License:Open Source License
/** * @see de.openVJJ.basic.Plugable#getConfig(org.jdom2.Element) *//* ww w .j a va 2s . c om*/ @Override public void getConfig(Element element) { super.getConfig(element); Element plugablesElement = new Element(ELEMENT_NAME_PLUGABLES); element.addContent(plugablesElement); int pugableNr = 0; Map<Plugable, Integer> plugabelNrMap = new HashMap<Plugable, Integer>(); for (Plugable plugable : getPlugables()) { plugabelNrMap.put(plugable, pugableNr); Element plugableElement = new Element(ELEMENT_NAME_PLUGABLE); plugablesElement.addContent(plugableElement); plugableElement.setAttribute(ELEMENT_ATTRIBUTE_PLUGABLE_CLASS, plugable.getClass().getName()); plugableElement.setAttribute(ELEMENT_ATTRIBUTE_PLUGABLE_NR, String.valueOf(pugableNr)); Element plugableConfigElement = new Element(ELEMENT_NAME_PLUGABLE_CONFIG); plugableElement.addContent(plugableConfigElement); plugable.getConfig(plugableConfigElement); pugableNr++; } Element connectionsElement = new Element(ELEMENT_NAME_CONNECTIONS); element.addContent(connectionsElement); for (ConnectionInfo connectionInfo : getConnectionInfo()) { Element connectionElement = new Element(ELEMENT_NAME_CONNECTION); connectionsElement.addContent(connectionElement); connectionElement.setAttribute(ELEMENT_ATTRIBUTE_IN_PLUGABLE_NR, String.valueOf(plugabelNrMap.get(connectionInfo.getIn()))); connectionElement.setAttribute(ELEMENT_ATTRIBUTE_OUT_PLUGABLE_NR, String.valueOf(plugabelNrMap.get(connectionInfo.getOut()))); connectionElement.setAttribute(ELEMENT_ATTRIBUTE_IN_NAME, connectionInfo.getInName()); connectionElement.setAttribute(ELEMENT_ATTRIBUTE_OUT_NAME, connectionInfo.getOutName()); } }
From source file:de.openVJJ.basic.Plugable.java
License:Open Source License
/** * for saving configuration // w ww . j av a2s. com * @param element to save configuration to. */ public void getConfig(Element element) { Element guiPositionElement = new Element(ELEMENT_NAME_GUI_POSITION); element.addContent(guiPositionElement); Rectangle guiPosition = getGuiPosition(); guiPositionElement.setAttribute("x", String.valueOf(guiPosition.x)); guiPositionElement.setAttribute("y", String.valueOf(guiPosition.y)); guiPositionElement.setAttribute("height", String.valueOf(guiPosition.height)); guiPositionElement.setAttribute("width", String.valueOf(guiPosition.width)); }
From source file:de.openVJJ.ImageListener.MJPEGServer.java
License:Open Source License
@Override public void getConfig(Element element) { element.setAttribute("server.port", String.valueOf(server.port)); }
From source file:de.openVJJ.imagePublisher.IPCam_250E_IGuard.java
License:Open Source License
@Override public void getConfig(Element element) { element.setAttribute("networkAddress", networkAddress); element.setAttribute("port", String.valueOf(port)); }
From source file:de.openVJJ.imagePublisher.XuggleVideoFileInput.java
License:Open Source License
@Override public void getConfig(Element element) { if (inputFileName != null) { element.setAttribute("inputFileName", inputFileName); }//from w ww .j a v a 2s . c om }
From source file:de.openVJJ.InputComponents.java
License:Open Source License
public static void save(String fileName) { Element rootElement = new Element(ROOT_ELEMET_NAME); Element gpuElement = new Element(GPU_ELEMENT_NAME); gpuElement.setAttribute("activ", String.valueOf(useGPU)); rootElement.addContent(gpuElement);/* w w w. j av a 2s .c o m*/ Element compnetsElement = new Element(COMPONENTS_ELEMENT_NAME); for (ImagePublisher imagePublisher : imagePublishers) { compnetsElement.addContent(componetToXML(imagePublisher)); } rootElement.addContent(compnetsElement); try { FileWriter fileWriter = new FileWriter(fileName); new XMLOutputter().output(new Document(rootElement), fileWriter); } catch (IOException e) { e.printStackTrace(); } }