List of usage examples for org.jdom2 Element getContentSize
@Override public int getContentSize()
From source file:jodtemplate.pptx.postprocessor.StylePostprocessor.java
License:Apache License
@Override public Document process(final Map<String, Object> context, final Document document, final Slide slide, final Resources resources, final Configuration configuration) throws JODTemplateException { final IteratorIterable<Element> atElements = document .getDescendants(Filters.element(PPTXDocument.T_ELEMENT, getNamespace())); final List<Element> atElementsList = new ArrayList<>(); while (atElements.hasNext()) { atElementsList.add(atElements.next()); }//from w w w . j av a 2 s. c om for (Element at : atElementsList) { if (at.getContentSize() != 0) { final Content content = at.getContent(0); if (content instanceof Comment) { final Comment comment = (Comment) content; processComment(comment, at, slide, configuration); } } } return document; }
From source file:jodtemplate.pptx.postprocessor.StylePostprocessor.java
License:Apache License
private List<Element> getRemainingElements(final int fromIndex, final Element ap) { final List<Element> remains = new ArrayList<>(); for (int i = fromIndex; i < ap.getContentSize(); ++i) { final Content apChild = ap.getContent(i); if (apChild instanceof Element) { final Element apChildElement = (Element) apChild; if (PPTXDocument.R_ELEMENT.equals(apChildElement.getName()) || PPTXDocument.BR_ELEMENT.equals(apChildElement.getName())) { remains.add(apChildElement); }/*from ww w .ja va2s .c o m*/ } } return remains; }
From source file:jodtemplate.pptx.style.HtmlStylizer.java
License:Apache License
private Element createTextElement(final List<org.jsoup.nodes.Element> tags, final Element arPr, final TextNode textNode, final Slide slide) { final Element ar = new Element(PPTXDocument.R_ELEMENT, getDrawingmlNamespace()); final Element formattedArPr = applyFormatting(tags, arPr, slide); if (formattedArPr.hasAttributes() || formattedArPr.getContentSize() != 0) { ar.addContent(formattedArPr);/*from ww w . jav a2 s. c om*/ } final Element at = new Element(PPTXDocument.T_ELEMENT, getDrawingmlNamespace()); at.setText(textNode.getWholeText()); ar.addContent(at); return ar; }
From source file:net.instantcom.mm7.DeliverReq.java
License:Open Source License
@Override public Element save(Element parent) { Element e = super.save(parent); if (sender != null) { Element r = new Element("Sender", e.getNamespace()); r.addContent(sender.save(e));//from w w w .j av a2 s .com e.addContent(r); } if (!recipients.isEmpty()) { Element r = new Element("Recipients", e.getNamespace()); addRecipients(r, Address.RecipientType.TO); addRecipients(r, Address.RecipientType.CC); addRecipients(r, Address.RecipientType.BCC); if (r.getContentSize() > 0) { e.addContent(r); } } if (linkedId != null) { e.addContent(new Element("LinkedID", e.getNamespace()).setText(linkedId)); } if (senderSPI != null) { e.addContent(new Element("SenderSPI", e.getNamespace()).setText(senderSPI)); } if (recipientSPI != null) { e.addContent(new Element("RecipientSPI", e.getNamespace()).setText(recipientSPI)); } if (timeStamp != null) { e.addContent(new Element("TimeStamp", e.getNamespace()).setText(timeStamp.toString())); } if (replyChargingId != null) { e.addContent(new Element("ReplyChargingID", e.getNamespace()).setText(replyChargingId)); } if (priority != null) { e.addContent(new Element("Priority", e.getNamespace()).setText(priority.toString())); } if (Subject != null) { e.addContent(new Element("Subject", e.getNamespace()).setText(Subject)); } if (applicId != null) { e.addContent(new Element("ApplicID", e.getNamespace()).setText(applicId)); } if (replyApplicId != null) { e.addContent(new Element("ReplyApplicID", e.getNamespace()).setText(replyApplicId)); } if (auxApplicInfo != null) { e.addContent(new Element("AuxApplicInfo", e.getNamespace()).setText(auxApplicInfo)); } if (content != null) { Element c = new Element("Content", e.getNamespace()); String href = c.getAttributeValue("href"); if (href != null) { c.setAttribute("href", href); } e.addContent(c); } return e; }
From source file:net.instantcom.mm7.DeliverReq.java
License:Open Source License
private void addRecipients(Element e, Address.RecipientType recipientType) { Element r = new Element(recipientType.toString(), e.getNamespace()); for (Address a : recipients) { if (a.getRecipientType().equals(recipientType)) { r.addContent(a.save(e));/* w ww. j ava2 s .com*/ } } if (r.getContentSize() > 0) { e.addContent(r); } }
From source file:net.instantcom.mm7.SubmitReq.java
License:Open Source License
public Element save(Element parent) { Element e = super.save(parent); e.setName("SubmitReq"); if (!recipients.isEmpty()) { Element r = new Element("Recipients", e.getNamespace()); addRecipients(r, RecipientType.TO); addRecipients(r, RecipientType.CC); addRecipients(r, RecipientType.BCC); if (r.getContentSize() > 0) { e.addContent(r);/* ww w. j av a 2 s . co m*/ } } if (serviceCode != null) { e.addContent(new Element("ServiceCode", e.getNamespace()).setText(serviceCode)); } if (linkedId != null) { e.addContent(new Element("LinkedID", e.getNamespace()).setText(linkedId)); } if (messageClass != null) { e.addContent(new Element("MessageClass", e.getNamespace()).setText(messageClass.toString())); } if (timeStamp != null) { e.addContent( new Element("TimeStamp", e.getNamespace()).setText(new RelativeDate(timeStamp).toString())); } if (replyChargingSize != null) { e.addContent(new Element("ReplyChargingSize", e.getNamespace()).setText(replyChargingSize.toString())); } if (replyDeadline != null) { e.addContent(new Element("ReplyDeadline", e.getNamespace()).setText(replyDeadline.toString())); } if (earlistDeliveryTime != null) { e.addContent( new Element("EarlistDeliveryTime", e.getNamespace()).setText(earlistDeliveryTime.toString())); } if (expiryDate != null) { e.addContent(new Element("ExpiryDate", e.getNamespace()).setText(expiryDate.toString())); } if (deliveryReport != null) { e.addContent( new Element("DeliveryReport", e.getNamespace()).setText(deliveryReport ? "True" : "False")); } if (readReply != null) { e.addContent(new Element("ReadReply", e.getNamespace()).setText(readReply ? "True" : "False")); } if (priority != null) { e.addContent(new Element("Priority", e.getNamespace()).setText(priority.toString())); } if (subject != null) { e.addContent(new Element("Subject", e.getNamespace()).setText(subject.toString())); } if (chargedParty != null) { e.addContent(new Element("ChargedParty", e.getNamespace()).setText(chargedParty.toString())); } if (chargedPartyId != null) { e.addContent(new Element("ChargedPartyID", e.getNamespace()).setText(chargedPartyId.toString())); } if (distributionIndicator != null) { e.addContent(new Element("DistributionIndicator", e.getNamespace()) .setText(distributionIndicator ? "True" : "False")); } // deliveryCondition if (applicID != null) { e.addContent(new Element("ApplicID", e.getNamespace()).setText(applicID)); } if (replyApplicID != null) { e.addContent(new Element("ReplyApplicID", e.getNamespace()).setText(replyApplicID)); } if (auxApplicId != null) { e.addContent(new Element("AuxApplicId", e.getNamespace()).setText(auxApplicId)); } if (contentClass != null) { e.addContent(new Element("ContentClass", e.getNamespace()).setText(contentClass.toString())); } if (drmContent != null) { e.addContent(new Element("DRMContent", e.getNamespace()).setText(drmContent ? "True" : "False")); } if (content != null) { Element c = new Element("Content", e.getNamespace()); if (allowAdaptations != null) { c.setAttribute("allowAdaptations", allowAdaptations ? "True" : "False"); } c.setAttribute("href", "cid:mm7-content"); e.addContent(c); } return e; }
From source file:org.apache.maven.io.util.WriterUtils.java
License:Apache License
/** * Method insertAtPreferredLocation.// w w w .j av a 2s. c o m * * @param parent * @param counter * @param child */ public static void insertAtPreferredLocation(final Element parent, final Element child, final IndentationCounter counter) { int contentIndex = 0; int elementCounter = 0; final Iterator it = parent.getContent().iterator(); Text lastText = null; int offset = 0; while (it.hasNext() && elementCounter <= counter.getCurrentIndex()) { final Object next = it.next(); offset = offset + 1; if (next instanceof Element) { elementCounter = elementCounter + 1; contentIndex = contentIndex + offset; offset = 0; } if (next instanceof Text && it.hasNext()) { lastText = (Text) next; } } if (lastText != null && lastText.getTextTrim().length() == 0) { lastText = lastText.clone(); } else { String starter = lineSeparator; for (int i = 0; i < counter.getDepth(); i++) { starter = starter + INDENT; // TODO make settable? } lastText = factory.text(starter); } if (parent.getContentSize() == 0) { final Text finalText = lastText.clone(); finalText.setText(finalText.getText().substring(0, finalText.getText().length() - INDENT.length())); parent.addContent(contentIndex, finalText); } parent.addContent(contentIndex, child); parent.addContent(contentIndex, lastText); }
From source file:org.apache.maven.toolchain.model.io.jdom.MavenToolchainsJDOMWriter.java
License:Apache License
/** * Method insertAtPreferredLocation.//from w w w . j a va 2 s. c o m * * @param parent * @param counter * @param child */ protected void insertAtPreferredLocation(final Element parent, final Element child, final IndentationCounter counter) { int contentIndex = 0; int elementCounter = 0; final Iterator it = parent.getContent().iterator(); Text lastText = null; int offset = 0; while (it.hasNext() && elementCounter <= counter.getCurrentIndex()) { final Object next = it.next(); offset = offset + 1; if (next instanceof Element) { elementCounter = elementCounter + 1; contentIndex = contentIndex + offset; offset = 0; } if (next instanceof Text && it.hasNext()) { lastText = (Text) next; } } if (lastText != null && lastText.getTextTrim().length() == 0) { lastText = lastText.clone(); } else { String starter = lineSeparator; for (int i = 0; i < counter.getDepth(); i++) { starter = starter + INDENT; // TODO make settable? } lastText = factory.text(starter); } if (parent.getContentSize() == 0) { final Text finalText = lastText.clone(); finalText.setText(finalText.getText().substring(0, finalText.getText().length() - INDENT.length())); parent.addContent(contentIndex, finalText); } parent.addContent(contentIndex, child); parent.addContent(contentIndex, lastText); }
From source file:org.artifactory.version.converter.v162.FolderDownloadConfigConverter.java
License:Open Source License
private void addDefaultConfig(Element rootElement, Namespace namespace) { //Use defaults from descriptor FolderDownloadConfigDescriptor descriptor = new FolderDownloadConfigDescriptor(); Element folderDownload = new Element("folderDownloadConfig", namespace); Namespace folderConfigNs = folderDownload.getNamespace(); ArrayList<Element> elements = Lists.newArrayList(); elements.add(new Element("enabled", folderConfigNs).setText(String.valueOf(descriptor.isEnabled()))); elements.add(new Element("maxDownloadSizeMb", folderConfigNs) .setText(String.valueOf(descriptor.getMaxDownloadSizeMb()))); elements.add(new Element("maxFiles", folderConfigNs).setText(String.valueOf(descriptor.getMaxFiles()))); elements.add(new Element("maxConcurrentRequests", folderConfigNs) .setText(String.valueOf(descriptor.getMaxConcurrentRequests()))); folderDownload.addContent(elements); rootElement.addContent(rootElement.getContentSize(), folderDownload); }
From source file:org.artifactory.version.converter.v166.SourceDeletedDetectionConverter.java
License:Open Source License
private void addOriginAbsenceDetectionElement(Element contentSynchronisation) { Element source = new Element("source", contentSynchronisation.getNamespace()); Element originAbsenceDetection = new Element("originAbsenceDetection", source.getNamespace()); originAbsenceDetection.addContent("false"); source.addContent(source.getContentSize(), originAbsenceDetection); contentSynchronisation.addContent(contentSynchronisation.getContentSize(), source); }