org.jdom.Element.setAttribute()方法的使用及代码示例

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

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

Element.setAttribute介绍

[英]This sets an attribute value for this element. Any existing attribute with the same name and namespace URI is removed.
[中]这将为此元素设置属性值。将删除具有相同名称和命名空间URI的任何现有属性。

代码示例

代码示例来源:origin: JetBrains/ideavim

public void saveData(@NotNull Element element) {
 if (isKeyRepeat != null) {
  final Element editor = new Element("editor");
  element.addContent(editor);
  final Element keyRepeat = new Element("key-repeat");
  keyRepeat.setAttribute("enabled", Boolean.toString(isKeyRepeat));
  editor.addContent(keyRepeat);
 }
}

代码示例来源:origin: net.sf.aislib.tools.mapping/library

/**
 * FIXME
 */
public Element toXML() {
 Element result = new Element ("primary-key");
 result.setAttribute ("column-name", pkColumnName);
 if (pkName != null) {
  result.setAttribute ("name", pkName);
 }
 return result;
}

代码示例来源:origin: net.sf.taverna.t2/workflowmodel-impl

private void populateBeanElementFromXStream(Object obj, Element bean)
    throws JDOMException, IOException {
  bean.setAttribute(BEAN_ENCODING, XSTREAM_ENCODING);
  XStream xstream = new XStream(new DomDriver());
  SAXBuilder builder = new SAXBuilder();
  Element configElement = builder.build(
      new StringReader(xstream.toXML(obj))).getRootElement();
  configElement.getParent().removeContent(configElement);
  bean.addContent(configElement);
}

代码示例来源:origin: JetBrains/ideavim

public void saveData(@NotNull Element element) {
 final Element conflictsElement = new Element(SHORTCUT_CONFLICTS_ELEMENT);
 for (Map.Entry<KeyStroke, ShortcutOwner> entry : shortcutConflicts.entrySet()) {
  final ShortcutOwner owner = entry.getValue();
  if (owner != ShortcutOwner.UNDEFINED) {
   final Element conflictElement = new Element(SHORTCUT_CONFLICT_ELEMENT);
   conflictElement.setAttribute(OWNER_ATTRIBUTE, owner.getName());
   final Element textElement = new Element(TEXT_ELEMENT);
   StringHelper.setSafeXmlText(textElement, entry.getKey().toString());
   conflictElement.addContent(textElement);
   conflictsElement.addContent(conflictElement);
  }
 }
 element.addContent(conflictsElement);
}

代码示例来源:origin: org.geotools/gt-coverage

private Element createShortElement(final int value) {
  Element GeoKeyRecord = new Element(GeoTiffConstants.GEOTIFF_SHORT_TAG);
  GeoKeyRecord.setAttribute(GeoTiffConstants.VALUE_ATTRIBUTE, String
      .valueOf(value));
  return GeoKeyRecord;
}

代码示例来源:origin: net.bpelunit/framework

public static Element createIfActivity(String conditionContent) {
  Element ifElement = createBPELElement(IF_ELEMENT);
  Element condition = createBPELElement(CONDITION_ELEMENT);
  condition.setAttribute("expressionLanguage",
      XpathLanguage.LANGUAGE_SPEZIFIKATION);
  condition.setText(conditionContent);
  ifElement.addContent(condition);
  return ifElement;
}

代码示例来源:origin: JetBrains/ideavim

public void saveData(@NotNull final Element element) {
 logger.debug("saveData");
 final Element registersElement = new Element("registers");
 for (Character key : registers.keySet()) {
  final Register register = registers.get(key);
  final Element registerElement = new Element("register");
  registerElement.setAttribute("name", String.valueOf(key));
  registerElement.setAttribute("type", Integer.toString(register.getType().getValue()));
  final String text = register.getText();
  if (text != null) {
   final Element textElement = new Element("text");
   StringHelper.setSafeXmlText(textElement, text);
   registerElement.addContent(textElement);
  }
  else {
   final Element keys = new Element("keys");
   final List<KeyStroke> list = register.getKeys();
   for (KeyStroke stroke : list) {
    final Element k = new Element("key");
    k.setAttribute("char", Integer.toString(stroke.getKeyChar()));
    k.setAttribute("code", Integer.toString(stroke.getKeyCode()));
    k.setAttribute("mods", Integer.toString(stroke.getModifiers()));
    keys.addContent(k);
   }
   registerElement.addContent(keys);
  }
  registersElement.addContent(registerElement);
 }
 element.addContent(registersElement);
}

代码示例来源:origin: org.geotools/gt-coverage

private Element createAsciiElement(final String value) {
  Element param = new Element(GeoTiffConstants.GEOTIFF_ASCII_TAG);
  param.setAttribute(GeoTiffConstants.VALUE_ATTRIBUTE, String.valueOf(value));
  return param;
}

代码示例来源:origin: GoogleCloudPlatform/google-cloud-intellij

@Before
public void setUpElements() {
 configurationElement.setAttribute(TYPE, GCP_APP_ENGINE_DEPLOY);
 settingsElement.setAttribute(ENVIRONMENT_ATTRIBUTE, APP_ENGINE_FLEX.name());
 configurationElement.addContent(deploymentElement);
 deploymentElement.addContent(settingsElement);
}

代码示例来源:origin: JetBrains/ideavim

@Override
public Element getState() {
 LOG.debug("Saving state");
 final Element element = new Element("ideavim");
 // Save whether the plugin is enabled or not
 final Element state = new Element("state");
 state.setAttribute("version", Integer.toString(STATE_VERSION));
 state.setAttribute("enabled", Boolean.toString(enabled));
 element.addContent(state);
 mark.saveData(element);
 register.saveData(element);
 search.saveData(element);
 history.saveData(element);
 key.saveData(element);
 editor.saveData(element);
 return element;
}

代码示例来源:origin: org.openwfe/openwfe-applic

/**
 * A dumb implementation, will return the name of this service as
 * an element.
 */
public org.jdom.Element getStatus ()
{
  final org.jdom.Element result = new org.jdom.Element(this.serviceName);
  result.setAttribute("class", this.getClass().getName());
  return result;
}

代码示例来源:origin: org.entando.entando/entando-core-engine

private void setConfig(Element configElement) {
  if (null != this.getStaticItems()) {
    CDATA cdata = new CDATA(this.getStaticItems());
    configElement.addContent(cdata);
  }
  if (null != this.getExtractorBeanName()) {
    configElement.setAttribute("extractorBean", this.getExtractorBeanName());
  }
  if (null != this.getCustomSeparator()) {
    configElement.setAttribute("separator", this.getCustomSeparator());
  }
}

代码示例来源:origin: hsz/idea-gitignore

@Override
public Element getState() {
  final Element element = new Element(KEY.ROOT.toString());
  element.setAttribute(KEY.MISSING_GITIGNORE.toString(), Boolean.toString(missingGitignore));
  element.setAttribute(KEY.IGNORED_FILE_STATUS.toString(), Boolean.toString(ignoredFileStatus));
  element.setAttribute(KEY.OUTER_IGNORE_RULES.toString(), Boolean.toString(outerIgnoreRules));
  element.setAttribute(KEY.OUTER_IGNORE_WRAPPER_HEIGHT.toString(), Integer.toString(outerIgnoreWrapperHeight));
  element.setAttribute(KEY.VERSION.toString(), version);
  element.setAttribute(KEY.STARRED_TEMPLATES.toString(), StringUtil.join(starredTemplates, Constants.DOLLAR));
  element.setAttribute(KEY.UNIGNORE_ACTIONS.toString(), Boolean.toString(unignoreActions));
  element.setAttribute(KEY.HIDE_IGNORED_FILES.toString(), Boolean.toString(hideIgnoredFiles));
  element.setAttribute(KEY.INFORM_TRACKED_IGNORED.toString(), Boolean.toString(informTrackedIgnored));
  element.setAttribute(KEY.NOTIFY_IGNORED_EDITING.toString(), Boolean.toString(notifyIgnoredEditing));
      continue;
    Element languageElement = new Element(KEY.LANGUAGES_LANGUAGE.toString());
    languageElement.setAttribute(KEY.LANGUAGES_ID.toString(), entry.getKey().getID());
    for (Map.Entry<IgnoreLanguagesSettings.KEY, Object> data : entry.getValue().entrySet()) {
      languageElement.setAttribute(data.getKey().name(), data.getValue().toString());
    languagesElement.addContent(languageElement);
  element.addContent(languagesElement);
  element.addContent(createTemplatesElement(userTemplates));

代码示例来源:origin: org.openwfe/openwfe-applic

/**
 * classy, isn't it ?
 */
protected void beginWithClass (final String eltName, final Object bean)
{
  final org.jdom.Element elt = new org.jdom.Element(eltName);
  elt.setAttribute(A_CLASS, bean.getClass().getName());
  beginElement(elt);
}

代码示例来源:origin: JetBrains/ideavim

public void saveData(@NotNull Element element) {
 Element marksElem = new Element("globalmarks");
 for (Mark mark : globalMarks.values()) {
  if (!mark.isClear()) {
   Element markElem = new Element("mark");
   markElem.setAttribute("key", Character.toString(mark.getKey()));
   markElem.setAttribute("line", Integer.toString(mark.getLogicalLine()));
   markElem.setAttribute("column", Integer.toString(mark.getCol()));
   markElem.setAttribute("filename", StringUtil.notNullize(mark.getFilename()));
   markElem.setAttribute("protocol", StringUtil.notNullize(mark.getProtocol(), "file"));
   marksElem.addContent(markElem);
   if (logger.isDebugEnabled()) {
    logger.debug("saved mark = " + mark);
 element.addContent(marksElem);
   fileMarkElem.setAttribute("name", file);
   fileMarkElem.setAttribute("timestamp", Long.toString(marks.timestamp.getTime()));
   for (Mark mark : marks.values()) {
    if (!mark.isClear() && !Character.isUpperCase(mark.getKey()) &&
     markElem.setAttribute("key", Character.toString(mark.getKey()));
     markElem.setAttribute("line", Integer.toString(mark.getLogicalLine()));
     markElem.setAttribute("column", Integer.toString(mark.getCol()));
     fileMarkElem.addContent(markElem);
   jumpElem.setAttribute("line", Integer.toString(jump.getLogicalLine()));
   jumpElem.setAttribute("column", Integer.toString(jump.getCol()));
   jumpElem.setAttribute("filename", StringUtil.notNullize(jump.getFilename()));

代码示例来源:origin: org.geotools/gt-coverage

private Element createFieldElement(final TIFFTag tag) {
  Element field = new Element(GeoTiffConstants.GEOTIFF_FIELD_TAG);
  field.setAttribute(GeoTiffConstants.NUMBER_ATTRIBUTE, String.valueOf(tag
      .getNumber()));
  field.setAttribute(GeoTiffConstants.NAME_ATTRIBUTE, tag.getName());
  return field;
}

代码示例来源:origin: hsz/idea-gitignore

/**
 * Creates {@link Element} with a list of the {@link UserTemplate} items.
 *
 * @param userTemplates templates
 * @return {@link Element} instance with user templates
 */
public static Element createTemplatesElement(@NotNull List<UserTemplate> userTemplates) {
  Element templates = new Element(KEY.USER_TEMPLATES.toString());
  for (UserTemplate userTemplate : userTemplates) {
    Element templateElement = new Element(KEY.USER_TEMPLATES_TEMPLATE.toString());
    templateElement.setAttribute(KEY.USER_TEMPLATES_NAME.toString(), userTemplate.getName());
    templateElement.addContent(userTemplate.getContent());
    templates.addContent(templateElement);
  }
  return templates;
}

代码示例来源:origin: org.entando.entando/entando-core-engine

protected Element createRootTypeElement(IApsEntity currentEntityType) {
  Element typeElement = new Element(this.getEntityTypeRootElementName());
  typeElement.setAttribute("typecode", currentEntityType.getTypeCode());
  typeElement.setAttribute("typedescr", currentEntityType.getTypeDescr());
  return typeElement;
}

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

public static void addSerializer(Element parent, SerializerDefinition def) {
  parent.addContent(new Element(STORE_SERIALIZATION_TYPE_ELMT).setText(def.getName()));
  if(def.hasSchemaInfo()) {
    for(Map.Entry<Integer, String> entry: def.getAllSchemaInfoVersions().entrySet()) {
      Element schemaElmt = new Element(STORE_SERIALIZATION_META_ELMT);
      if(def.hasVersion())
        schemaElmt.setAttribute(STORE_VERSION_ATTR, Integer.toString(entry.getKey()));
      else
        schemaElmt.setAttribute(STORE_VERSION_ATTR, "none");
      schemaElmt.setText(entry.getValue());
      parent.addContent(schemaElmt);
    }
  }
  if(def.hasCompression()) {
    Compression compression = def.getCompression();
    Element compressionElmt = new Element(STORE_COMPRESSION_ELMT);
    Element type = new Element(STORE_COMPRESSION_TYPE_ELMT);
    type.setText(compression.getType());
    compressionElmt.addContent(type);
    String optionsText = compression.getOptions();
    if(optionsText != null) {
      Element options = new Element(STORE_COMPRESSION_OPTIONS_ELMT);
      options.setText(optionsText);
      compressionElmt.addContent(options);
    }
    parent.addContent(compressionElmt);
  }
}

代码示例来源:origin: org.apache.wookie/wookie-parser

public Element toXml() {
  Element contentElem = new Element(IW3CXMLConfiguration.CONTENT_ELEMENT,IW3CXMLConfiguration.MANIFEST_NAMESPACE);
  contentElem.setAttribute(IW3CXMLConfiguration.SOURCE_ATTRIBUTE,getSrc());
  if (getType() != null) contentElem.setAttribute(IW3CXMLConfiguration.TYPE_ATTRIBUTE,getType());
  if (getCharSet() != null) contentElem.setAttribute(IW3CXMLConfiguration.CHARSET_ATTRIBUTE,getCharSet());
  
  contentElem = setLocalisationAttributes(contentElem);
  return contentElem;
}

相关文章