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

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

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

Element.add介绍

[英]Adds the given Attribute to this element. If the given node already has a parent defined then an IllegalAddException will be thrown. Attributes with null values are silently ignored. If the value of the attribute is null then this method call will remove any attributes with the QName of this attribute.
[中]将给定的Attribute添加到此元素。如果给定节点已定义父节点,则将抛出IllegalAddException。具有空值的属性将被静默忽略。如果该属性的值为null,则此方法调用将删除任何具有该属性的QName的属性。

代码示例

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

void addRevisionInfoRelation(Element anyMapping) {
  anyMapping.add( cloneAndSetupRevisionInfoRelationMapping() );
}

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

private void sendPacketError(Element stanza, PacketError.Condition condition) {
  Element reply = stanza.createCopy();
  reply.addAttribute("type", "error");
  reply.addAttribute("to", stanza.attributeValue("from"));
  reply.addAttribute("from", stanza.attributeValue("to"));
  reply.add(new PacketError(condition).getElement());
  deliver(reply.asXML());
}

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

private String createSessionRestartResponse()
{
  final Element response = DocumentHelper.createElement( QName.get( "body", "http://jabber.org/protocol/httpbind" ) );
  response.addNamespace("stream", "http://etherx.jabber.org/streams");
  final Element features = response.addElement("stream:features");
  for (Element feature : getAvailableStreamFeaturesElements()) {
    features.add(feature);
  }
  return response.asXML();
}

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

public Sent(Forwarded forwarded) {
    super("sent", "urn:xmpp:carbons:2");
    element.add(forwarded.getElement());
  }
}

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

/**
 * Returns an Element with the privacy list XML representation.
 *
 * @return an Element with the privacy list XML representation.
 */
public Element asElement() {
  //Element listElement = DocumentFactory.getInstance().createDocument().addElement("list");
  Element listElement = DocumentFactory.getInstance().createDocument()
      .addElement("list", "jabber:iq:privacy");
  listElement.addAttribute("name", getName());
  // Add the list items to the result
  for (PrivacyItem item : items) {
    listElement.add(item.asElement());
  }
  return listElement;
}

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

public Received(Forwarded forwarded) {
    super("received", "urn:xmpp:carbons:2");
    element.add(forwarded.getElement());
  }
}

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

/**
 * Sets the wrapped stanza by this Route packet. ClientRoute packets may have a single child
 * element. This is a convenience method to avoid manipulating this underlying packet's
 * Element instance directly.
 *
 * @param childElement the child element.
 */
public void setChildElement(Element childElement) {
  for (Iterator i=element.elementIterator(); i.hasNext(); ) {
    element.remove((Element)i.next());
  }
  element.add(childElement);
}

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

/**
 * Adds mapping of the id of a related entity to the given xml mapping, prefixing the id with the given prefix.
 *
 * @param xmlMapping Mapping, to which to add the xml.
 * @param prefix Prefix for the names of properties which will be prepended to properties that form the id.
 * @param columnNameIterator Iterator over the column names that will be used for properties that form the id.
 * @param relatedIdMapping Id mapping data of the related entity.
 */
@SuppressWarnings({"unchecked"})
private void addRelatedToXmlMapping(
    Element xmlMapping,
    String prefix,
    MetadataTools.ColumnNameIterator columnNameIterator,
    IdMappingData relatedIdMapping) {
  final Element properties = (Element) relatedIdMapping.getXmlRelationMapping().clone();
  MetadataTools.prefixNamesInPropertyElement( properties, prefix, columnNameIterator, true, true );
  for ( Element idProperty : (java.util.List<Element>) properties.elements() ) {
    xmlMapping.add( (Element) idProperty.clone() );
  }
}

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

private void updatePresence() {
  if (extendedInformation != null && presence != null) {
    // Remove any previous extendedInformation, then re-add it.
    Element mucUser = presence.getElement().element(QName.get("x", "http://jabber.org/protocol/muc#user"));
    if (mucUser != null) {
      // Remove any previous extendedInformation, then re-add it.
      presence.getElement().remove(mucUser);
    }
    Element exi = extendedInformation.createCopy();
    presence.getElement().add(exi);
  }
}

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

@Override
public void execute(SessionData data, Element command) {
  DataForm form = new DataForm(DataForm.Type.result);
  FormField field = form.addField();
  field.setType(FormField.Type.hidden);
  field.setVariable("FORM_TYPE");
  field.addValue("http://jabber.org/protocol/admin");
  List<String> accounts = data.getData().get("accountjids");
  if (accounts != null && accounts.size() > 0) {
    populateResponseFields(form, accounts);
  }
  command.add(form.getElement());
}

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

/**
 * Generate a conflict packet to indicate that the nickname being requested/used is already in
 * use by another user.
 *
 * @param packet the packet to be bounced.
 */
void sendErrorPacket(IQ packet, PacketError.Condition error, Element pubsubError) {
  IQ reply = IQ.createResultIQ(packet);
  reply.setChildElement(packet.getChildElement().createCopy());
  reply.setError(error);
  if (pubsubError != null) {
    // Add specific pubsub error if available
    reply.getError().getElement().add(pubsubError);
  }
  router.route(reply);
}

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

@Override
public void execute(SessionData data, Element command) {
  DataForm form = new DataForm(DataForm.Type.result);
  FormField field = form.addField();
  field.setType(FormField.Type.hidden);
  field.setVariable("FORM_TYPE");
  field.addValue("http://jabber.org/protocol/admin");
  field = form.addField();
  field.setLabel(getLabel());
  field.setVariable("onlineuserssessionsnum");
  SessionManager sessionManager = SessionManager.getInstance();
  field.addValue(sessionManager.getUserSessionsCount(false));
  command.add(form.getElement());
}

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

@Override
protected void addStageInformation(SessionData data, Element command) {
  DataForm form = new DataForm(DataForm.Type.form);
  form.setTitle("Deleting a user");
  form.addInstruction("Fill out this form to delete a user.");
  FormField field = form.addField();
  field.setType(FormField.Type.hidden);
  field.setVariable("FORM_TYPE");
  field.addValue("http://jabber.org/protocol/admin");
  field = form.addField();
  field.setType(FormField.Type.jid_single);
  field.setLabel("The Jabber ID for the account to be deleted");
  field.setVariable("accountjid");
  field.setRequired(true);
  // Add the form to the command
  command.add(form.getElement());
}

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

@Override
protected void addStageInformation(SessionData data, Element command) {
  DataForm form = new DataForm(DataForm.Type.form);
  form.setTitle("Dispatching a vCard deleting event.");
  form.addInstruction("Fill out this form to dispatch a vCard deleting event.");
  FormField field = form.addField();
  field.setType(FormField.Type.hidden);
  field.setVariable("FORM_TYPE");
  field.addValue("http://jabber.org/protocol/admin");
  field = form.addField();
  field.setType(FormField.Type.text_single);
  field.setLabel("The username of the user who's vCard is being deleted");
  field.setVariable("username");
  field.setRequired(true);
  // Add the form to the command
  command.add(form.getElement());
}

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

@Override
protected void addStageInformation(SessionData data, Element command) {
  DataForm form = new DataForm(DataForm.Type.form);
  form.setTitle("Delete group");
  form.addInstruction("Fill out this form to delete a group.");
  FormField field = form.addField();
  field.setType(FormField.Type.hidden);
  field.setVariable("FORM_TYPE");
  field.addValue("http://jabber.org/protocol/admin");
  field = form.addField();
  field.setType(FormField.Type.text_single);
  field.setLabel("Group Name");
  field.setVariable("group");
  field.setRequired(true);
  // Add the form to the command
  command.add(form.getElement());
}

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

@Override
protected void addStageInformation(SessionData data, Element command) {
  DataForm form = new DataForm(DataForm.Type.form);
  form.setTitle("Dispatching a user deleting event.");
  form.addInstruction("Fill out this form to dispatch a user deleting event.");
  FormField field = form.addField();
  field.setType(FormField.Type.hidden);
  field.setVariable("FORM_TYPE");
  field.addValue("http://jabber.org/protocol/admin");
  field = form.addField();
  field.setType(FormField.Type.text_single);
  field.setLabel("The username of the user that is being deleted");
  field.setVariable("username");
  field.setRequired(true);
  // Add the form to the command
  command.add(form.getElement());
}

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

@Override
protected void addStageInformation(SessionData data, Element command) {
  DataForm form = new DataForm(DataForm.Type.form);
  form.setTitle("Dispatching a vCard created event.");
  form.addInstruction("Fill out this form to dispatch a vCard created event.");
  FormField field = form.addField();
  field.setType(FormField.Type.hidden);
  field.setVariable("FORM_TYPE");
  field.addValue("http://jabber.org/protocol/admin");
  field = form.addField();
  field.setType(FormField.Type.text_single);
  field.setLabel("The username of the user who's vCard was created");
  field.setVariable("username");
  field.setRequired(true);
  // Add the form to the command
  command.add(form.getElement());
}

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

@Override
protected void addStageInformation(SessionData data, Element command) {
  DataForm form = new DataForm(DataForm.Type.form);
  form.setTitle("Requesting List of Group Members");
  form.addInstruction("Fill out this form to request list of group members and admins.");
  FormField field = form.addField();
  field.setType(FormField.Type.hidden);
  field.setVariable("FORM_TYPE");
  field.addValue("http://jabber.org/protocol/admin");
  field = form.addField();
  field.setType(FormField.Type.text_single);
  field.setLabel("Group Name");
  field.setVariable("group");
  field.setRequired(true);
  // Add the form to the command
  command.add(form.getElement());
}

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

@Override
protected void addStageInformation(SessionData data, Element command) {
  DataForm form = new DataForm(DataForm.Type.form);
  form.setTitle("Dispatching a group created event.");
  form.addInstruction("Fill out this form to dispatch a group created event.");
  FormField field = form.addField();
  field.setType(FormField.Type.hidden);
  field.setVariable("FORM_TYPE");
  field.addValue("http://jabber.org/protocol/admin");
  field = form.addField();
  field.setType(FormField.Type.text_single);
  field.setLabel("The group name of the group that was created");
  field.setVariable("groupName");
  field.setRequired(true);
  // Add the form to the command
  command.add(form.getElement());
}

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

@Override
protected void addStageInformation(SessionData data, Element command) {
  DataForm form = new DataForm(DataForm.Type.form);
  form.setTitle("Dispatching a vCard updated event.");
  form.addInstruction("Fill out this form to dispatch a vCard updated event.");
  FormField field = form.addField();
  field.setType(FormField.Type.hidden);
  field.setVariable("FORM_TYPE");
  field.addValue("http://jabber.org/protocol/admin");
  field = form.addField();
  field.setType(FormField.Type.text_single);
  field.setLabel("The username of the user who's vCard was updated");
  field.setVariable("username");
  field.setRequired(true);
  // Add the form to the command
  command.add(form.getElement());
}

相关文章

微信公众号

最新文章

更多

Element类方法