當前位置: 首頁>>代碼示例>>Java>>正文


Java Attribute類代碼示例

本文整理匯總了Java中org.jdom.Attribute的典型用法代碼示例。如果您正苦於以下問題:Java Attribute類的具體用法?Java Attribute怎麽用?Java Attribute使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Attribute類屬於org.jdom包,在下文中一共展示了Attribute類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: generateGeneratorElement

import org.jdom.Attribute; //導入依賴的package包/類
protected Element generateGeneratorElement(Generator generator) {
    Element generatorElement = new Element("generator", getFeedNamespace());

    if (generator.getUrl() != null) {
        Attribute urlAttribute = new Attribute("url", generator.getUrl());
        generatorElement.setAttribute(urlAttribute);
    }

    if (generator.getVersion() != null) {
        Attribute versionAttribute = new Attribute("version", generator.getVersion());
        generatorElement.setAttribute(versionAttribute);
    }

    if (generator.getValue() != null) {
        generatorElement.addContent(generator.getValue());
    }

    return generatorElement;

}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:21,代碼來源:Atom03Generator.java

示例2: getChildWithName

import org.jdom.Attribute; //導入依賴的package包/類
public static Element getChildWithName(Element parent, String name, boolean optional) throws StudyUnrecognizedFormatException {
  for (Element child : parent.getChildren()) {
    Attribute attribute = child.getAttribute(NAME);
    if (attribute == null) {
      continue;
    }
    if (name.equals(attribute.getValue())) {
      return child;
    }
  }
  if (optional) {
    return null;
  }
  throw new StudyUnrecognizedFormatException();
}
 
開發者ID:medvector,項目名稱:educational-plugin,代碼行數:16,代碼來源:StudySerializationUtils.java

示例3: createRootElement

import org.jdom.Attribute; //導入依賴的package包/類
protected Element createRootElement(Feed feed) {
    Element root = new Element("feed",getFeedNamespace());
    root.addNamespaceDeclaration(getFeedNamespace());
    Attribute version = new Attribute("version", getVersion());
    root.setAttribute(version);
    generateModuleNamespaceDefs(root);
    return root;
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:9,代碼來源:Atom03Generator.java

示例4: generateLinkElement

import org.jdom.Attribute; //導入依賴的package包/類
protected Element generateLinkElement(Link link) {
    Element linkElement = new Element("link", getFeedNamespace());

    if (link.getRel() != null) {
        Attribute relAttribute = new Attribute("rel", link.getRel().toString());
        linkElement.setAttribute(relAttribute);
    }

    if (link.getType() != null) {
        Attribute typeAttribute = new Attribute("type", link.getType());
        linkElement.setAttribute(typeAttribute);
    }

    if (link.getHref() != null) {
        Attribute hrefAttribute = new Attribute("href", link.getHref());
        linkElement.setAttribute(hrefAttribute);
    }
    return linkElement;
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:20,代碼來源:Atom03Generator.java

示例5: resolveURI

import org.jdom.Attribute; //導入依賴的package包/類
/** Use xml:base attributes at feed and entry level to resolve relative links */
private String resolveURI(URL baseURI, Parent parent, String url) {
    url = (url.equals(".") || url.equals("./")) ? "" : url;
    if (isRelativeURI(url) && parent != null && parent instanceof Element) {
        Attribute baseAtt = ((Element)parent).getAttribute("base", Namespace.XML_NAMESPACE);
        String xmlBase = (baseAtt == null) ? "" : baseAtt.getValue();
        if (!isRelativeURI(xmlBase) && !xmlBase.endsWith("/")) {
            xmlBase = xmlBase.substring(0, xmlBase.lastIndexOf("/")+1);
        }
        return resolveURI(baseURI, parent.getParent(), xmlBase + url);
    } else if (isRelativeURI(url) && parent == null) {
        return baseURI + url;
    } else if (baseURI != null && url.startsWith("/")) {
        String hostURI = baseURI.getProtocol() + "://" + baseURI.getHost();
        if (baseURI.getPort() != baseURI.getDefaultPort()) {
            hostURI = hostURI + ":" + baseURI.getPort();
        }
        return hostURI + url;
    }
    return url;
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:22,代碼來源:Atom10Parser.java

示例6: generateSubjectElement

import org.jdom.Attribute; //導入依賴的package包/類
/**
 * Utility method to generate an element for a subject.
 * <p>
 * @param subject the subject to generate an element for.
 * @return the element for the subject.
 */
protected final Element generateSubjectElement(DCSubject subject) {
    Element subjectElement = new Element("subject", getDCNamespace());

    if (subject.getTaxonomyUri() != null) {
        Element descriptionElement = new Element("Description", getRDFNamespace());
        Element topicElement = new Element("topic", getTaxonomyNamespace());
        Attribute resourceAttribute = new Attribute("resource", subject.getTaxonomyUri(), getRDFNamespace());
        topicElement.setAttribute(resourceAttribute);
        descriptionElement.addContent(topicElement);

        if (subject.getValue() != null) {
            Element valueElement = new Element("value", getRDFNamespace());
            valueElement.addContent(subject.getValue());
            descriptionElement.addContent(valueElement);
        }
        subjectElement.addContent(descriptionElement);
    } else {
        subjectElement.addContent(subject.getValue());
    }
    return subjectElement;
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:28,代碼來源:DCModuleGenerator.java

示例7: isMyType

import org.jdom.Attribute; //導入依賴的package包/類
public boolean isMyType(Document document) {
    boolean ok = false;
    Element rssRoot = document.getRootElement();
    ok = rssRoot.getName().equals("rss");
    if (ok) {
        ok = false;
        Attribute version = rssRoot.getAttribute("version");
        if (version!=null) {
            ok = version.getValue().equals(getRSSVersion());
        }
    }
    return ok;
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:14,代碼來源:RSS091UserlandParser.java

示例8: generateCategoryElement

import org.jdom.Attribute; //導入依賴的package包/類
protected Element generateCategoryElement(Category cat) {
    Element catElement = new Element("category", getFeedNamespace());

    if (cat.getTerm() != null) {
        Attribute termAttribute = new Attribute("term", cat.getTerm());
        catElement.setAttribute(termAttribute);
    }

    if (cat.getLabel() != null) {
        Attribute labelAttribute = new Attribute("label", cat.getLabel());
        catElement.setAttribute(labelAttribute);
    }

    if (cat.getScheme() != null) {
        Attribute schemeAttribute = new Attribute("scheme", cat.getScheme());
        catElement.setAttribute(schemeAttribute);
    }
    return catElement;
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:20,代碼來源:Atom10Generator.java

示例9: generateLinkElement

import org.jdom.Attribute; //導入依賴的package包/類
protected Element generateLinkElement(Link link) {
    Element linkElement = new Element("link", getFeedNamespace());

    if (link.getRel() != null) {
        Attribute relAttribute = new Attribute("rel", link.getRel().toString());
        linkElement.setAttribute(relAttribute);
    }

    if (link.getType() != null) {
        Attribute typeAttribute = new Attribute("type", link.getType());
        linkElement.setAttribute(typeAttribute);
    }

    if (link.getHref() != null) {
        Attribute hrefAttribute = new Attribute("href", link.getHref());
        linkElement.setAttribute(hrefAttribute);
    }
    
    if (link.getHreflang() != null) {
        Attribute hreflangAttribute = new Attribute("hreflang", link.getHreflang());
        linkElement.setAttribute(hreflangAttribute);
    }
    return linkElement;
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:25,代碼來源:Atom10Generator.java

示例10: generateTagLineElement

import org.jdom.Attribute; //導入依賴的package包/類
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;
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:14,代碼來源:Atom10Generator.java

示例11: generateGeneratorElement

import org.jdom.Attribute; //導入依賴的package包/類
protected Element generateGeneratorElement(Generator generator) {
    Element generatorElement = new Element("generator", getFeedNamespace());

    if (generator.getUrl() != null) {
        Attribute urlAttribute = new Attribute("uri", generator.getUrl());
        generatorElement.setAttribute(urlAttribute);
    }

    if (generator.getVersion() != null) {
        Attribute versionAttribute = new Attribute("version", generator.getVersion());
        generatorElement.setAttribute(versionAttribute);
    }

    if (generator.getValue() != null) {
        generatorElement.addContent(generator.getValue());
    }

    return generatorElement;

}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:21,代碼來源:Atom10Generator.java

示例12: populateItem

import org.jdom.Attribute; //導入依賴的package包/類
protected void populateItem(Item item, Element eItem, int index) {
    super.populateItem(item,eItem, index);

    Description description = item.getDescription();
    if (description!=null && description.getType()!=null) {
        Element eDescription = eItem.getChild("description",getFeedNamespace());
        eDescription.setAttribute(new Attribute("type",description.getType()));
    }
    eItem.removeChild("expirationDate",getFeedNamespace());
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:11,代碼來源:RSS094Generator.java

示例13: generateCloud

import org.jdom.Attribute; //導入依賴的package包/類
protected Element generateCloud(Cloud cloud) {
    Element eCloud = new Element("cloud",getFeedNamespace());

    if (cloud.getDomain() != null) {
        eCloud.setAttribute(new Attribute("domain", cloud.getDomain()));
    }

    if (cloud.getPort() != 0) {
        eCloud.setAttribute(new Attribute("port", String.valueOf(cloud.getPort())));
    }

    if (cloud.getPath() != null) {
        eCloud.setAttribute(new Attribute("path", cloud.getPath()));
    }

    if (cloud.getRegisterProcedure() != null) {
        eCloud.setAttribute(new Attribute("registerProcedure", cloud.getRegisterProcedure()));
    }

    if (cloud.getProtocol() != null) {
        eCloud.setAttribute(new Attribute("protocol", cloud.getProtocol()));
    }
    return eCloud;
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:25,代碼來源:RSS092Generator.java

示例14: generateSourceElement

import org.jdom.Attribute; //導入依賴的package包/類
protected Element generateSourceElement(Source source) {
    Element sourceElement = new Element("source",getFeedNamespace());
    if (source.getUrl() != null) {
        sourceElement.setAttribute(new Attribute("url", source.getUrl()));
    }
    sourceElement.addContent(source.getValue());
    return sourceElement;
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:9,代碼來源:RSS092Generator.java

示例15: getTaxonomy

import org.jdom.Attribute; //導入依賴的package包/類
/**
 * Utility method to parse a taxonomy from an element.
 * <p>
 * @param desc the taxonomy description element.
 * @return the string contained in the resource of the element.
 */
protected final String getTaxonomy(Element desc) {
    String d = null;
    Element taxo = desc.getChild("topic", getTaxonomyNamespace());
    if (taxo!=null) {
        Attribute a = taxo.getAttribute("resource", getRDFNamespace());
        if (a!=null) {
            d = a.getValue();
        }
    }
    return d;
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:18,代碼來源:DCModuleParser.java


注:本文中的org.jdom.Attribute類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。