@Override public void writeText(String text) { Element top = (Element) stack.getLast(); top.addText(text); }
private String getAvailablePluginsUpdateRequest() { Element xmlRequest = docFactory.createDocument().addElement("available"); // Add locale so we can get current name and description of plugins Element locale = xmlRequest.addElement("locale"); locale.addText(JiveGlobals.getLocale().toString()); return xmlRequest.asXML(); }
bugCodeSet.add(bugPattern.getAbbrev()); element.addElement("ShortMessage").addText(bugPattern.getShortDescription()); element.addElement("LongMessage").addText(bugInstance.getMessage()); Element annElement = (Element) annElementIter.next(); BugAnnotation ann = annIter.next(); annElement.addElement("Message").addText(ann.toString());
@Override void populateXmlForModifications(Modifications modifications, XmlWriterContext writerContext, Element modificationsTag) { Modification firstModification = modifications.first(); Element changeset = modificationsTag.addElement("changeset"); String revision = firstModification.getRevision(); changeset.addAttribute("changesetUri", StageXmlViewModel.httpUrlFor(writerContext.getBaseUrl(), writerContext.stageIdForLocator(revision))); changeset.addElement("checkinTime").addText(DateUtils.formatISO8601(firstModification.getModifiedTime())); changeset.addElement("revision").addText(revision); } }
for (Object o : list) { if (o instanceof String) { root.addText(o.toString()); } else { root.add(((org.dom4j.Node)o).detach());
public Element asXMLElement() { Element option = DocumentHelper.createElement(QName.get("option", "jabber:x:data")); if (getLabel() != null) { option.addAttribute("label", getLabel()); } if (getValue() != null) { option.addElement("value").addText(getValue()); } return option; } }
private DOMElement getXmlForJobPlan(XmlWriterContext writerContext, WaitingJobPlan waitingJobPlan) { JobPlan jobPlan = waitingJobPlan.jobPlan(); DOMElement root = new DOMElement("job"); root.addAttribute("name", jobPlan.getName()).addAttribute("id", String.valueOf(jobPlan.getJobId())); root.addElement("link").addAttribute("rel", "self").addAttribute("href", httpUrlFor(writerContext.getBaseUrl(), jobPlan.getIdentifier())); root.addElement("buildLocator").addText(jobPlan.getIdentifier().buildLocator()); if (!StringUtils.isBlank(waitingJobPlan.envName())) { root.addElement("environment").addText(waitingJobPlan.envName()); } if (!jobPlan.getResources().isEmpty()) { DOMElement resources = new DOMElement("resources"); for (Resource resource : jobPlan.getResources()) { resources.addElement("resource").addCDATA(resource.getName()); } root.add(resources); } if (!jobPlan.getVariables().isEmpty()) { DOMElement envVars = new DOMElement("environmentVariables"); for (EnvironmentVariable environmentVariable : jobPlan.getVariables()) { envVars.addElement("variable").addAttribute("name", environmentVariable.getName()).addText(environmentVariable.getDisplayValue()); } root.add(envVars); } return root; }
private void addBugPatterns(Set<String> bugTypeSet) { Element root = document.getRootElement(); for (String bugType : bugTypeSet) { BugPattern bugPattern = DetectorFactoryCollection.instance().lookupBugPattern(bugType); if (bugPattern == null) { continue; } Element details = root.addElement("BugPattern"); details.addAttribute("type", bugType).addAttribute("abbrev", bugPattern.getAbbrev()) .addAttribute("category", bugPattern.getCategory()); details.addElement("ShortDescription").addText(bugPattern.getShortDescription()); details.addElement("Details").addCDATA(bugPattern.getDetailText()); } }
public Document toXml(XmlWriterContext writerContext) { DOMElement root = new DOMElement("stage"); root.addAttribute("name", stage.getName()).addAttribute("counter", String.valueOf(stage.getCounter())); Document document = new DOMDocument(root); root.addElement("link").addAttribute("rel", "self").addAttribute("href", httpUrl(writerContext.getBaseUrl())); StageIdentifier stageId = stage.getIdentifier(); root.addElement("id").addCDATA(stageId.asURN()); String pipelineName = stageId.getPipelineName(); root.addElement("pipeline").addAttribute("name", pipelineName) .addAttribute("counter", String.valueOf(stageId.getPipelineCounter())) .addAttribute("label", stageId.getPipelineLabel()) .addAttribute("href", writerContext.getBaseUrl() + "/api/pipelines/" + pipelineName + "/" + stage.getPipelineId() + ".xml"); root.addElement("updated").addText(DateUtils.formatISO8601(stage.latestTransitionDate())); root.addElement("result").addText(stage.getResult().toString()); root.addElement("state").addText(stage.status()); root.addElement("approvedBy").addCDATA(stage.getApprovedBy()); Element jobs = root.addElement("jobs"); for (JobInstance jobInstance : stage.getJobInstances()) { jobs.addElement("job").addAttribute("href", writerContext.getBaseUrl() + "/api/jobs/" + jobInstance.getId() + ".xml"); } return document; }
@Override void populateXmlForModifications(Modifications modifications, XmlWriterContext writerContext, Element modificationsTag) { for (Modification modification : modifications) { Element changeset = modificationsTag.addElement("changeset"); changeset.addAttribute("changesetUri", ScmMaterial.changesetUrl(modification, writerContext.getBaseUrl(), material.getId())); changeset.addElement("user").addCDATA(modification.getUserDisplayName()); changeset.addElement("checkinTime").addText(DateUtils.formatISO8601(modification.getModifiedTime())); changeset.addElement("revision").addCDATA(modification.getRevision()); changeset.addElement("message").addCDATA(modification.getComment()); } } }
/** * If the current text buffer contains any text then create a new text node * with it and add it to the current element */ protected void completeCurrentTextNode() { if (stripWhitespaceText) { boolean whitespace = true; for (int i = 0, size = textBuffer.length(); i < size; i++) { if (!Character.isWhitespace(textBuffer.charAt(i))) { whitespace = false; break; } } if (!whitespace) { currentElement.addText(textBuffer.toString()); } } else { currentElement.addText(textBuffer.toString()); } textBuffer.setLength(0); textInTextBuffer = false; }
@Override void populateXmlForModifications(Modifications modifications, XmlWriterContext writerContext, Element modificationsTag) { for (Modification modification : modifications) { Element changeset = modificationsTag.addElement("changeset"); changeset.addAttribute("changesetUri", ScmMaterial.changesetUrl(modification, writerContext.getBaseUrl(), material.getId())); changeset.addElement("user").addCDATA(modification.getUserDisplayName()); changeset.addElement("checkinTime").addText(DateUtils.formatISO8601(modification.getModifiedTime())); changeset.addElement("revision").addCDATA(modification.getRevision()); changeset.addElement("message").addCDATA(modification.getComment()); List<ModifiedFile> modifiedFiles = modification.getModifiedFiles(); for (ModifiedFile modifiedFile : modifiedFiles) { changeset.addElement("file").addAttribute("name", modifiedFile.getFileName()).addAttribute("action", modifiedFile.getAction().toString()); } } } }
currentRegistration.addElement("username").addText(nickname);
public Document toXml(XmlWriterContext writerContext) { DOMElement root = new DOMElement("pipeline"); root.addAttribute("name", pipeline.getName()).addAttribute("counter", String.valueOf(pipeline.getCounter())).addAttribute("label", pipeline.getLabel()); Document document = new DOMDocument(root); String baseUrl = writerContext.getBaseUrl(); root.addElement("link").addAttribute("rel", "self").addAttribute("href", httpUrl(baseUrl)); root.addElement("id").addCDATA(pipeline.getPipelineIdentifier().asURN()); PipelineTimelineEntry pipelineAfter = pipeline.getPipelineAfter(); if (pipelineAfter != null) { addTimelineLink(root, baseUrl, "insertedBefore", pipelineAfter); } PipelineTimelineEntry pipelineBefore = pipeline.getPipelineBefore(); if (pipelineBefore != null) { addTimelineLink(root, baseUrl, "insertedAfter", pipelineBefore); } root.addElement("scheduleTime").addText(DateUtils.formatISO8601(pipeline.getScheduledDate())); Element materials = root.addElement("materials"); for (MaterialRevision materialRevision : pipeline.getCurrentRevisions()) { populateXml(materials, materialRevision, writerContext); } Element stages = root.addElement("stages"); for (StageInstanceModel stage : pipeline.getStageHistory()) { if (! (stage instanceof NullStageHistoryItem)) { stages.addElement("stage").addAttribute("href", StageXmlViewModel.httpUrlFor(writerContext.getBaseUrl(), stage.getId())); } } root.addElement("approvedBy").addCDATA(pipeline.getApprovedBy()); return document; }