本文整理汇总了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;
}
示例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();
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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());
}
示例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;
}
示例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;
}
示例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;
}