org.dom4j.Element.addText()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(11.1k)|赞(0)|评价(0)|浏览(287)

本文整理了Java中org.dom4j.Element.addText()方法的一些代码示例,展示了Element.addText()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Element.addText()方法的具体详情如下:
包路径:org.dom4j.Element
类名称:Element
方法名:addText

Element.addText介绍

[英]Adds a new Text node with the given text to this element.
[中]将具有给定文本的新Text节点添加到此元素。

代码示例

代码示例来源:origin: spotbugs/spotbugs

@Override
public void writeText(String text) {
  Element top = (Element) stack.getLast();
  top.addText(text);
}

代码示例来源:origin: igniterealtime/Openfire

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();
}

代码示例来源:origin: spotbugs/spotbugs

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());

代码示例来源:origin: igniterealtime/Openfire

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());

代码示例来源:origin: gocd/gocd

@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);
  }
}

代码示例来源:origin: igniterealtime/Openfire

x.addElement("title").addText(getTitle());
  x.addElement("instructions").addText((String)instrItr.next());

代码示例来源:origin: jenkinsci/jenkins

for (Object o : list) {
  if (o instanceof String) {
    root.addText(o.toString());
  } else {
    root.add(((org.dom4j.Node)o).detach());

代码示例来源:origin: igniterealtime/Openfire

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;
  }
}

代码示例来源:origin: igniterealtime/Openfire

field.addElement("desc").addText(getDescription());
Iterator<String> valuesItr = getValues();
while (valuesItr.hasNext()) {
  field.addElement("value").addText(valuesItr.next());

代码示例来源:origin: gocd/gocd

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;
}

代码示例来源:origin: spotbugs/spotbugs

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());
  }
}

代码示例来源:origin: gocd/gocd

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;
}

代码示例来源:origin: igniterealtime/Openfire

String text = pp.getText();
if (parent != null) {
  parent.addText(text);
String text = pp.getText();
if (parent != null) {
  parent.addText(text);

代码示例来源:origin: gocd/gocd

@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());
    }
  }
}

代码示例来源:origin: igniterealtime/Openfire

field = (Element) fields.next();
if ("username".equals(field.attributeValue("var"))) {
  field.addElement("value").addText(user.getUsername());
  field.addElement("value").addText(user.getName());
      .addText(user.getEmail() == null ? "" : user.getEmail());

代码示例来源:origin: org.dom4j/dom4j

/**
 * 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;
}

代码示例来源:origin: gocd/gocd

@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());
      }
    }
  }
}

代码示例来源:origin: igniterealtime/Openfire

currentRegistration.addElement("username").addText(nickname);

代码示例来源:origin: gocd/gocd

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;
}

代码示例来源:origin: gocd/gocd

jobInstance.getStageId()));
root.addElement("result").addText(jobInstance.getResult().toString());
root.addElement("state").addText(jobInstance.getState().toString());

相关文章

Element类方法