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

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

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

Element.setText介绍

暂无

代码示例

代码示例来源:origin: hibernate/hibernate-orm

/**
 * Adds <code>formula</code> element.
 *
 * @param element Parent element.
 * @param formula Formula descriptor.
 */
public static void addFormula(Element element, Formula formula) {
  element.addElement( "formula" ).setText( formula.getText() );
}

代码示例来源:origin: hibernate/hibernate-orm

public static Element addNativelyGeneratedId(
      Element parent, String name, String type,
      boolean useRevisionEntityWithNativeId) {
    final Element idMapping = parent.addElement( "id" );
    idMapping.addAttribute( "name", name ).addAttribute( "type", type );

    final Element generatorMapping = idMapping.addElement( "generator" );
    if ( useRevisionEntityWithNativeId ) {
      generatorMapping.addAttribute( "class", "native" );
    }
    else {
      generatorMapping.addAttribute( "class", "org.hibernate.envers.enhanced.OrderedSequenceGenerator" );
      generatorMapping.addElement( "param" ).addAttribute( "name", "sequence_name" ).setText(
          "REVISION_GENERATOR"
      );
      generatorMapping.addElement( "param" )
          .addAttribute( "name", "table_name" )
          .setText( "REVISION_GENERATOR" );
      generatorMapping.addElement( "param" ).addAttribute( "name", "initial_value" ).setText( "1" );
      generatorMapping.addElement( "param" ).addAttribute( "name", "increment_size" ).setText( "1" );
    }
//        generatorMapping.addAttribute("class", "sequence");
//        generatorMapping.addElement("param").addAttribute("name", "sequence").setText("custom");

    return idMapping;
  }

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

Element existingAppName = (Element)generatedModel.selectSingleNode(
    "//adminconsole/global/appname");
existingAppName.setText(appName.getText());
if (appName.attributeValue("plugin") != null) {
  existingAppName.addAttribute("plugin", appName.attributeValue("plugin"));
Element existingLogoImage = (Element)generatedModel.selectSingleNode(
    "//adminconsole/global/logo-image");
existingLogoImage.setText(appLogoImage.getText());
if (appLogoImage.attributeValue("plugin") != null) {
  existingLogoImage.addAttribute("plugin", appLogoImage.attributeValue("plugin"));
Element existingLoginImage = (Element)generatedModel.selectSingleNode(
    "//adminconsole/global/login-image");
existingLoginImage.setText(appLoginImage.getText());
if (appLoginImage.attributeValue("plugin") != null) {
  existingLoginImage.addAttribute("plugin", appLoginImage.attributeValue("plugin"));
    "//adminconsole/global/version");
if (existingVersion != null) {
  existingVersion.setText(appVersion.getText());
  if (appVersion.attributeValue("plugin") != null) {
    existingVersion.addAttribute("plugin", appVersion.attributeValue("plugin"));

代码示例来源:origin: hibernate/hibernate-orm

private void mapEnumerationType(Element parent, Type type, Properties parameters) {
  if ( parameters.getProperty( EnumType.ENUM ) != null ) {
    parent.addElement( "param" )
        .addAttribute( "name", EnumType.ENUM )
        .setText( parameters.getProperty( EnumType.ENUM ) );
  }
  else {
    parent.addElement( "param" )
        .addAttribute( "name", EnumType.ENUM )
        .setText( type.getReturnedClass().getName() );
  }
  if ( parameters.getProperty( EnumType.NAMED ) != null ) {
    parent.addElement( "param" )
        .addAttribute( "name", EnumType.NAMED )
        .setText( parameters.getProperty( EnumType.NAMED ) );
  }
  else {
    parent.addElement( "param" )
        .addAttribute( "name", EnumType.NAMED )
        .setText( "" + !( (EnumType) ( (CustomType) type ).getUserType() ).isOrdinal() );
  }
}

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

private Document endDocument(Project project) {
  // Save the error information
  Element errorsElement = root.addElement(ERRORS_ELEMENT_NAME);
  for (AnalysisError analysisError : bugCollection.getErrors()) {
    errorsElement.addElement(ANALYSIS_ERROR_ELEMENT_NAME).setText(analysisError.getMessage());
  }
  for (Iterator<String> i = bugCollection.missingClassIterator(); i.hasNext();) {
    errorsElement.addElement(MISSING_CLASS_ELEMENT_NAME).setText(i.next());
  }
  return document;
}

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

appName.addAttribute( "plugin", canonicalName );
if ( imageEl != null )
  imageEl.setText( "plugins/" + canonicalName + "/" + imageEl.getText() );
  imageEl.addAttribute( "plugin", canonicalName ); // Set the plugin name so that the proper i18n String can be loaded.
  imageEl.setText( "plugins/" + canonicalName + "/" + imageEl.getText() );
  imageEl.addAttribute( "plugin", canonicalName ); // Set the plugin name so that the proper i18n String can be loaded.

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

/**
 * Add BugCode elements.
 *
 * @param bugCodeSet
 *            all bug codes (abbrevs) referenced in the BugCollection
 */
private void addBugCodes(Set<String> bugCodeSet) {
  Element root = document.getRootElement();
  for (String bugCode : bugCodeSet) {
    Element element = root.addElement("BugCode");
    element.addAttribute("abbrev", bugCode);
    Element description = element.addElement("Description");
    description.setText(I18N.instance().getBugTypeDescription(bugCode));
  }
}

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

public IQVersionHandler() {
  super("XMPP Server Version Handler");
  info = new IQHandlerInfo("query", "jabber:iq:version");
  if (bodyElement == null) {
    bodyElement = DocumentHelper.createElement(QName.get("query", "jabber:iq:version"));
    bodyElement.addElement("name").setText(AdminConsole.getAppName());
    bodyElement.addElement("version").setText(AdminConsole.getVersionString());
  }
}

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

added.setText(child.getText());
        added.addAttribute(attr.getQName(), attr.getValue());
delayInformation.addAttribute("stamp", XMPPDateTimeFormat.format(sentDate));
if (room.canAnyoneDiscoverJID()) {
  delayInformation.addAttribute("from", senderJID);

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

element.addElement(propName[i]);
  element.addElement(eleName);
element.element(eleName).addAttribute(attName, value);
  element.addElement(lastName);
element.element(lastName).setText(value);

代码示例来源:origin: ronmamo/reflections

private Document createDocument(final Reflections reflections) {
    Store map = reflections.getStore();

    Document document = DocumentFactory.getInstance().createDocument();
    Element root = document.addElement("Reflections");
    for (String indexName : map.keySet()) {
      Element indexElement = root.addElement(indexName);
      for (String key : map.get(indexName).keySet()) {
        Element entryElement = indexElement.addElement("entry");
        entryElement.addElement("key").setText(key);
        Element valuesElement = entryElement.addElement("values");
        for (String value : map.get(indexName).get(key)) {
          valuesElement.addElement("value").setText(value);
        }
      }
    }
    return document;
  }
}

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

lastActivity.addAttribute("seconds", String.valueOf(lastActivityTime));
return reply;
      lastActivity.addAttribute("seconds", String.valueOf(lastActivityTime));
      String lastStatus = presenceManager.getLastPresenceStatus(user);
      if (lastStatus != null && lastStatus.length() > 0) {
        lastActivity.setText(lastStatus);
      lastActivity.addAttribute("seconds", "0");

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

@Override
public void execute(SessionData sessionData, Element command) {
  Element note = command.addElement("note");
  Map<String, List<String>> data = sessionData.getData();
  // Gets the username
  String username;
  try {
    username = get(data, "username", 0);
  }
  catch (NullPointerException npe) {
    note.addAttribute("type", "error");
    note.setText("Username required parameter.");
    return;
  }
  // Loads the vCard
  Element vCard = VCardManager.getInstance().getVCard(username);
  if (vCard == null) {
    note.addAttribute("type", "error");
    note.setText("VCard not found.");
    return;
  }
  // Fire event.
  VCardEventDispatcher.dispatchVCardDeleted(username, vCard);
  // Answer that the operation was successful
  note.addAttribute("type", "info");
  note.setText("Operation finished successfully");
}

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

@Override
public IQ handleIQ(IQ packet) {
  IQ response = IQ.createResultIQ(packet);
  Element timeElement = DocumentHelper.createElement(QName.get(info.getName(), info.getNamespace()));
  timeElement.addElement("tzo").setText(formatsTimeZone(TimeZone.getDefault()));
  timeElement.addElement("utc").setText(getUtcDate(new Date()));
  response.setChildElement(timeElement);
  return response;
}

代码示例来源:origin: org.nuiton.jrst/jrst

@Override
public Node parse(Element e) {
  Element result = DocumentHelper.createElement("topic").addAttribute(
      "value", e.attributeValue("value"));
  result.addAttribute("type", "contents");
  result.setText(e.getText());
  return result;
}

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

@Override
public void execute(SessionData sessionData, Element command) {
  Element note = command.addElement("note");
  Map<String, List<String>> data = sessionData.getData();
  // Get the username
  String username;
  try {
    username = get(data, "username", 0);
  }
  catch (NullPointerException npe) {
    note.addAttribute("type", "error");
    note.setText("Username required parameter.");
    return;
  }
  // Sends the event
  User user;
  try {
    // Loads the new user            
    user = UserManager.getUserProvider().loadUser(username);
    // Fire event.
    Map<String, Object> params = Collections.emptyMap();
    UserEventDispatcher.dispatchEvent(user, UserEventDispatcher.EventType.user_created, params);
  } catch (UserNotFoundException e) {
    note.addAttribute("type", "error");
    note.setText("User not found.");
  }
  // Answer that the operation was successful
  note.addAttribute("type", "info");
  note.setText("Operation finished successfully");
}

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

private Document createDocument(final Reflections reflections) {
    Store map = reflections.getStore();

    Document document = DocumentFactory.getInstance().createDocument();
    Element root = document.addElement("Reflections");
    for (String indexName : map.keySet()) {
      Element indexElement = root.addElement(indexName);
      for (String key : map.get(indexName).keySet()) {
        Element entryElement = indexElement.addElement("entry");
        entryElement.addElement("key").setText(key);
        Element valuesElement = entryElement.addElement("values");
        for (String value : map.get(indexName).get(key)) {
          valuesElement.addElement("value").setText(value);
        }
      }
    }
    return document;
  }
}

代码示例来源:origin: com.centit.support/centit-utils

public static Element createXMLElement(String elementName , String valueType, Object value){
  Element element = DocumentHelper.createElement(elementName);
  element.addAttribute("type",valueType);
  element.setText(StringBaseOpt.objectToString(value));
  return element;
}

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

@Override
public void execute(SessionData sessionData, Element command) {
  Element note = command.addElement("note");
  Map<String, List<String>> data = sessionData.getData();
  // Get the group name
  String groupname;
  try {
    groupname = get(data, "groupName", 0);
  }
  catch (NullPointerException npe) {
    note.addAttribute("type", "error");
    note.setText("Group name required parameter.");
    return;
  }
  // Sends the event
  Group group;
  try {
    group = GroupManager.getInstance().getGroup(groupname, true);
    // Fire event.
    Map<String, Object> params = Collections.emptyMap();
    GroupEventDispatcher.dispatchEvent(group, GroupEventDispatcher.EventType.group_deleting, params);
  } catch (GroupNotFoundException e) {
    note.addAttribute("type", "error");
    note.setText("Group not found.");
  }
  // Answer that the operation was successful
  note.addAttribute("type", "info");
  note.setText("Operation finished successfully");
}

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

@Override
public Presence addParticipant(JID jid, String reason, MUCRole senderRole)
    throws NotAllowedException, ForbiddenException {
  if (MUCRole.Role.moderator != senderRole.getRole()) {
    throw new ForbiddenException();
  }
  // Update the presence with the new role and inform all occupants
  Presence updatedPresence = changeOccupantRole(jid, MUCRole.Role.participant);
  if (updatedPresence != null) {
    Element frag = updatedPresence.getChildElement(
        "x", "http://jabber.org/protocol/muc#user");
    // Add the reason why the user was granted voice
    if (reason != null && reason.trim().length() > 0) {
      frag.element("item").addElement("reason").setText(reason);
    }
  }
  return updatedPresence;
}

相关文章

Element类方法