org.jdom2.Attribute.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(7.0k)|赞(0)|评价(0)|浏览(112)

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

Attribute.<init>介绍

[英]Default, no-args constructor for implementations to use if needed.
[中]默认情况下,如果需要,没有用于实现的args构造函数。

代码示例

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

public void populate(Element parent) {
  if (value == null && !isDefault()) {
    if (!isDefault()) {
      throw bomb(
          format("Try to write null value into configuration! [{0}.{1}]",
              field.getDeclaringClass().getName(), field.getName()));
    }
    throw bomb(format("A non default field {0}(on {1}) had null value",
        field.getName(), field.getDeclaringClass().getName()));
  }
  String attributeName = field.getAnnotation(ConfigAttribute.class).value();
  parent.setAttribute(new Attribute(attributeName, valueString()));
}

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

@Override
public Attribute attribute(String name, String value, Namespace namespace) {
  Attribute a = new Attribute();
  a.name = name;
  a.value = value;
  if (namespace == null) {
    namespace = Namespace.NO_NAMESPACE;
  }
  a.namespace = namespace;
  return a;
}

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

@Override
public Attribute attribute(String name, String value, AttributeType type, Namespace namespace) {
  Attribute a = new Attribute();
  a.name = name;
  a.type = type;
  a.value = value;
  if (namespace == null) {
    namespace = Namespace.NO_NAMESPACE;
  }
  a.namespace = namespace;
  return a;
}

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

@Override
public Attribute attribute(String name, String value, Namespace namespace) {
  return new Attribute(name, value, namespace);
}

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

@Override
public Attribute attribute(String name, String value) {
  Attribute a = new Attribute();
  a.name = name;
  a.value = value;
  a.namespace = Namespace.NO_NAMESPACE;
  return a;
}

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

@Override
public Attribute attribute(String name, String value, AttributeType type) {
  Attribute a = new Attribute();
  a.name = name;
  a.type = type;
  a.value = value;
  a.namespace = Namespace.NO_NAMESPACE;
  return a;
}

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

@Override
public Attribute attribute(String name, String value, AttributeType type,
    Namespace namespace) {
  return new Attribute(name, value, type, namespace);
}

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

@Override
public Attribute attribute(String name, String value, AttributeType type) {
  return new Attribute(name, value, type);
}

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

@Override
public Attribute attribute(String name, String value) {
  return new Attribute(name, value);
}

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

@Override
@Deprecated
public Attribute attribute(String name, String value, int type) {
  return new Attribute(name, value, type);
}

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

@Override
@Deprecated
public Attribute attribute(String name, String value, int type,
    Namespace namespace) {
  return new Attribute(name, value, AttributeType.byIndex(type),
      namespace);
}

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

/**
 * <p>
 * This sets an attribute value for this element.  Any existing attribute
 * with the same name and namespace URI is removed.
 * </p>
 *
 * @param name name of the attribute to set
 * @param value value of the attribute to set
 * @return this element modified
 * @throws IllegalNameException if the given name is illegal as an
 *         attribute name.
 * @throws IllegalDataException if the given attribute value is
 *         illegal character data (as determined by
 *         {@link org.jdom2.Verifier#checkCharacterData}).
 */
public Element setAttribute(final String name, final String value) {
  final Attribute attribute = getAttribute(name);
  if (attribute == null) {
    final Attribute newAttribute = new Attribute(name, value);
    setAttribute(newAttribute);
  } else {
    attribute.setValue(value);
  }
  return this;
}

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

/**
 * <p>
 * This sets an attribute value for this element.  Any existing attribute
 * with the same name and namespace URI is removed.
 * </p>
 *
 * @param name name of the attribute to set
 * @param value value of the attribute to set
 * @param ns namespace of the attribute to set. A null implies Namespace.NO_NAMESPACE.
 * @return this element modified
 * @throws IllegalNameException if the given name is illegal as an
 *         attribute name, or if the namespace is an unprefixed default
 *         namespace
 * @throws IllegalDataException if the given attribute value is
 *         illegal character data (as determined by
 *         {@link org.jdom2.Verifier#checkCharacterData}).
 * @throws IllegalAddException if the attribute namespace prefix
 *         collides with another namespace prefix on the element.
 */
public Element setAttribute(final String name, final String value, final Namespace ns) {
  final Attribute attribute = getAttribute(name, ns);
  if (attribute == null) {
    final Attribute newAttribute = new Attribute(name, value, ns);
    setAttribute(newAttribute);
  } else {
    attribute.setValue(value);
  }
  return this;
}

代码示例来源:origin: com.rometools/rome

protected Element generateSourceElement(final Source source) {
  final Element sourceElement = new Element("source", getFeedNamespace());
  final String url = source.getUrl();
  if (url != null) {
    sourceElement.setAttribute(new Attribute("url", url));
  }
  sourceElement.addContent(source.getValue());
  return sourceElement;
}

代码示例来源:origin: rometools/rome

protected Element generateTagLineElement(final Content tagline) {
  final Element taglineElement = new Element("tagline", getFeedNamespace());
  final String type = tagline.getType();
  if (type != null) {
    final Attribute typeAttribute = new Attribute("type", type);
    taglineElement.setAttribute(typeAttribute);
  }
  final String value = tagline.getValue();
  if (value != null) {
    taglineElement.addContent(value);
  }
  return taglineElement;
}

代码示例来源:origin: rometools/rome

protected Element generateSourceElement(final Source source) {
  final Element sourceElement = new Element("source", getFeedNamespace());
  final String url = source.getUrl();
  if (url != null) {
    sourceElement.setAttribute(new Attribute("url", url));
  }
  sourceElement.addContent(source.getValue());
  return sourceElement;
}

代码示例来源:origin: rometools/rome

@Override
protected Element createRootElement(final Channel channel) {
  final Element root = new Element("rss", getFeedNamespace());
  final Attribute version = new Attribute("version", getVersion());
  root.setAttribute(version);
  root.addNamespaceDeclaration(getContentNamespace());
  generateModuleNamespaceDefs(root);
  return root;
}

代码示例来源:origin: rometools/rome

protected Element createRootElement(final Feed feed) {
  final Element root = new Element("feed", getFeedNamespace());
  root.addNamespaceDeclaration(getFeedNamespace());
  final Attribute version = new Attribute("version", getVersion());
  root.setAttribute(version);
  generateModuleNamespaceDefs(root);
  return root;
}

代码示例来源:origin: apache/marmotta

protected Element generateTagLineElement(Content tagline) {
  Element taglineElement = new Element("subtitle", getFeedNamespace());
  if (tagline.getType() != null) {
    Attribute typeAttribute = new Attribute("type", tagline.getType());
    taglineElement.setAttribute(typeAttribute);
  }
  if (tagline.getValue() != null) {
    taglineElement.addContent(tagline.getValue());
  }
  return taglineElement;
}

代码示例来源:origin: rometools/rome

@Override
protected void populateItem(final Item item, final Element eItem, final int index) {
  super.populateItem(item, eItem, index);
  final Description description = item.getDescription();
  if (description != null && description.getType() != null) {
    final Element eDescription = eItem.getChild("description", getFeedNamespace());
    eDescription.setAttribute(new Attribute("type", description.getType()));
  }
  eItem.removeChild("expirationDate", getFeedNamespace());
}

相关文章