org.jdom2.Element.hasAttributes()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(7.7k)|赞(0)|评价(0)|浏览(117)

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

Element.hasAttributes介绍

[英]Indicate whether this Element has any attributes. Where possible you should call this method before calling getAttributes() because calling getAttributes() will create the necessary Attribute List memory structures, even if there are no Attributes attached to the Element. Calling hasAttributes() first can save memory.
[中]指示此元素是否具有任何属性。在可能的情况下,您应该在调用getAttributes()之前调用此方法,因为调用getAttributes()将创建必要的属性列表内存结构,即使元素没有附加属性。首先调用hasAttributes()可以节省内存。

代码示例

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

@Override
public final Iterator<?> getAttributeAxisIterator(Object contextNode) throws UnsupportedAxisException {
  if (isElement(contextNode) && ((Element)contextNode).hasAttributes()) {
    return ((Element)contextNode).getAttributes().iterator();
  }
  return JaxenConstants.EMPTY_ITERATOR;
}

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

out.writeInt(0);
if (hasAttributes()) {
  final int ans = attributes.size();
  out.writeInt(ans);

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

if (hasAttributes()) {
  for (Attribute a : getAttributes()) {
    final String reason =

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

if (element.hasAttributes()) {
  reason = checkNamespaceCollision(namespace, element.getAttributes());
  if (reason != null) {

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

if (element.hasAttributes()) {
  for (Attribute att : element.getAttributes()) {
    final org.w3c.dom.Attr a = printAttribute(fstack, basedoc, att);

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

if (element.hasAttributes()) {
  for (final Attribute a : element.getAttributes()) {
    final Namespace ns = a.getNamespace();

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

if (element.hasAttributes()) {
  for (final Attribute attribute : element.getAttributes()) {
    printAttribute(out, fstack, attribute);

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

if (element.hasAttributes()) {
  for (Attribute a : element.getAttributes()) {
    if (!a.isSpecified() && fstack.isSpecifiedAttributesOnly()) {

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

Iterator<Attribute> ait = element.hasAttributes() ?
    element.getAttributes().iterator() :
      null;

代码示例来源:origin: Vhati/Slipstream-Mod-Manager

public LikeFilter( String type, Element selectorNode ) {
  this.type = type;
  if ( selectorNode.hasAttributes() ) {
    this.attrMap = new HashMap<String,String>();
    for ( Attribute attr : selectorNode.getAttributes() ) {
      attrMap.put( attr.getName(), attr.getValue() );
    }
  }
  this.value = selectorNode.getTextTrim();
  if ( this.value.length() == 0 ) this.value = null;
}

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

if (element.hasAttributes()) {
  for (final Attribute attribute : element.getAttributes()) {
    printAttribute(out, fstack, attribute);

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

/**
 * Generation of peerLink tags.
 * 
 * @param m source
 * @param e element to attach new element to
 */
private void generatePeerLinks(final Metadata m, final Element e) {
  for (final PeerLink peerLink : m.getPeerLinks()) {
    final Element peerLinkElement = new Element("peerLink", NS);
    addNotNullAttribute(peerLinkElement, "type", peerLink.getType());
    addNotNullAttribute(peerLinkElement, "href", peerLink.getHref());
    if (peerLinkElement.hasAttributes()) {
      e.addContent(peerLinkElement);
    }
  }
}

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

/**
 * Generation of peerLink tags.
 * 
 * @param m source
 * @param e element to attach new element to
 */
private void generatePeerLinks(final Metadata m, final Element e) {
  for (final PeerLink peerLink : m.getPeerLinks()) {
    final Element peerLinkElement = new Element("peerLink", NS);
    addNotNullAttribute(peerLinkElement, "type", peerLink.getType());
    addNotNullAttribute(peerLinkElement, "href", peerLink.getHref());
    if (peerLinkElement.hasAttributes()) {
      e.addContent(peerLinkElement);
    }
  }
}

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

/**
 * Generation of license tags.
 * 
 * @param m source
 * @param e element to attach new element to
 */
private void generateLicenses(final Metadata m, final Element e) {
  for (final License license : m.getLicenses()) {
    final Element licenseElement = new Element("license", NS);
    addNotNullAttribute(licenseElement, "type", license.getType());
    addNotNullAttribute(licenseElement, "href", license.getHref());
    if (license.getValue() != null) {
      licenseElement.addContent(license.getValue());
    }
    if (licenseElement.hasAttributes() || !licenseElement.getTextTrim().isEmpty()) {
      e.addContent(licenseElement);
    }
  }
}

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

/**
 * Generation of license tags.
 * 
 * @param m source
 * @param e element to attach new element to
 */
private void generateLicenses(final Metadata m, final Element e) {
  for (final License license : m.getLicenses()) {
    final Element licenseElement = new Element("license", NS);
    addNotNullAttribute(licenseElement, "type", license.getType());
    addNotNullAttribute(licenseElement, "href", license.getHref());
    if (license.getValue() != null) {
      licenseElement.addContent(license.getValue());
    }
    if (licenseElement.hasAttributes() || !licenseElement.getTextTrim().isEmpty()) {
      e.addContent(licenseElement);
    }
  }
}

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

/**
 * Generation of subTitle tags.
 * 
 * @param m source
 * @param e element to attach new element to
 */
private void generateSubTitles(final Metadata m, final Element e) {
  for (final SubTitle subTitle : m.getSubTitles()) {
    final Element subTitleElement = new Element("subTitle", NS);
    addNotNullAttribute(subTitleElement, "type", subTitle.getType());
    addNotNullAttribute(subTitleElement, "lang", subTitle.getLang());
    addNotNullAttribute(subTitleElement, "href", subTitle.getHref());
    if (subTitleElement.hasAttributes()) {
      e.addContent(subTitleElement);
    }
  }
}

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

/**
 * Generation of subTitle tags.
 * 
 * @param m source
 * @param e element to attach new element to
 */
private void generateSubTitles(final Metadata m, final Element e) {
  for (final SubTitle subTitle : m.getSubTitles()) {
    final Element subTitleElement = new Element("subTitle", NS);
    addNotNullAttribute(subTitleElement, "type", subTitle.getType());
    addNotNullAttribute(subTitleElement, "lang", subTitle.getLang());
    addNotNullAttribute(subTitleElement, "href", subTitle.getHref());
    if (subTitleElement.hasAttributes()) {
      e.addContent(subTitleElement);
    }
  }
}

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

/**
 * Generation of location tags.
 * 
 * @param m source
 * @param e element to attach new element to
 */
private void generateLocations(final Metadata m, final Element e) {
  final GMLGenerator geoRssGenerator = new GMLGenerator();
  for (final Location location : m.getLocations()) {
    final Element locationElement = new Element("location", NS);
    addNotNullAttribute(locationElement, "description", location.getDescription());
    addNotNullAttribute(locationElement, "start", location.getStart());
    addNotNullAttribute(locationElement, "end", location.getEnd());
    if (location.getGeoRss() != null) {
      geoRssGenerator.generate(location.getGeoRss(), locationElement);
    }
    if (locationElement.hasAttributes() || !locationElement.getChildren().isEmpty()) {
      e.addContent(locationElement);
    }
  }
}

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

/**
 * Generation of status tag.
 * 
 * @param m source
 * @param e element to attach new element to
 */
private void generateStatus(final Metadata m, final Element e) {
  if (m.getStatus() == null) {
    return;
  }
  final Element statusElement = new Element("status", NS);
  if (m.getStatus().getState() != null) {
    statusElement.setAttribute("state", m.getStatus().getState().name());
  }
  addNotNullAttribute(statusElement, "reason", m.getStatus().getReason());
  if (statusElement.hasAttributes()) {
    e.addContent(statusElement);
  }
}

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

/**
 * Generation of status tag.
 * 
 * @param m source
 * @param e element to attach new element to
 */
private void generateStatus(final Metadata m, final Element e) {
  if (m.getStatus() == null) {
    return;
  }
  final Element statusElement = new Element("status", NS);
  if (m.getStatus().getState() != null) {
    statusElement.setAttribute("state", m.getStatus().getState().name());
  }
  addNotNullAttribute(statusElement, "reason", m.getStatus().getReason());
  if (statusElement.hasAttributes()) {
    e.addContent(statusElement);
  }
}

相关文章

微信公众号

最新文章

更多