本文整理汇总了Java中com.rometools.rome.feed.atom.Content.getType方法的典型用法代码示例。如果您正苦于以下问题:Java Content.getType方法的具体用法?Java Content.getType怎么用?Java Content.getType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.rometools.rome.feed.atom.Content
的用法示例。
在下文中一共展示了Content.getType方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generateTagLineElement
import com.rometools.rome.feed.atom.Content; //导入方法依赖的package包/类
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;
}
示例2: generateTagLineElement
import com.rometools.rome.feed.atom.Content; //导入方法依赖的package包/类
protected Element generateTagLineElement(final Content tagline) {
final Element taglineElement = new Element("subtitle", 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;
}
示例3: reduceContent
import com.rometools.rome.feed.atom.Content; //导入方法依赖的package包/类
private Content reduceContent(Content first, Content second) {
Content newContent = new Content();
String type = first.getType();
String newValue;
if (type.toLowerCase().contains("html")) {
newValue = first.getValue() + "<br/>" + second.getValue();
} else {
newValue = first.getValue() + "\n " + second.getValue();
}
newContent.setValue(newValue);
newContent.setType(type);
newContent.setSrc(first.getSrc());
return newContent;
}
示例4: fillContentElement
import com.rometools.rome.feed.atom.Content; //导入方法依赖的package包/类
private void fillContentElement(final Element contentElement, final Content content) throws FeedException {
final String type = content.getType();
String atomType = type;
if (type != null) {
// Fix for issue #39 "Atom 1.0 Text Types Not Set Correctly"
// we're not sure who set this value, so ensure Atom types are used
if ("text/plain".equals(type)) {
atomType = Content.TEXT;
} else if ("text/html".equals(type)) {
atomType = Content.HTML;
} else if ("application/xhtml+xml".equals(type)) {
atomType = Content.XHTML;
}
final Attribute typeAttribute = new Attribute("type", type);
contentElement.setAttribute(typeAttribute);
}
final String href = content.getSrc();
if (href != null) {
final Attribute srcAttribute = new Attribute("src", href);
contentElement.setAttribute(srcAttribute);
}
final String value = content.getValue();
if (value != null) {
if (atomType != null && (atomType.equals(Content.XHTML) || atomType.contains("/xml") || atomType.contains("+xml"))) {
String tmpDocString = "<tmpdoc>" + value +
"</tmpdoc>";
final StringReader tmpDocReader = new StringReader(tmpDocString);
Document tmpDoc;
try {
final SAXBuilder saxBuilder = new SAXBuilder();
tmpDoc = saxBuilder.build(tmpDocReader);
} catch (final Exception ex) {
throw new FeedException("Invalid XML", ex);
}
final List<org.jdom2.Content> children = tmpDoc.getRootElement().removeContent();
contentElement.addContent(children);
} else {
// must be type html, text or some other non-XML format
// JDOM will escape property for XML
contentElement.addContent(value);
}
}
}
示例5: fillContentElement
import com.rometools.rome.feed.atom.Content; //导入方法依赖的package包/类
protected void fillContentElement(final Element contentElement, final Content content) throws FeedException {
final String type = content.getType();
if (type != null) {
final Attribute typeAttribute = new Attribute("type", type);
contentElement.setAttribute(typeAttribute);
}
final String mode = content.getMode();
if (mode != null) {
final Attribute modeAttribute = new Attribute("mode", mode);
contentElement.setAttribute(modeAttribute);
}
final String value = content.getValue();
if (value != null) {
if (mode == null || mode.equals(Content.ESCAPED)) {
contentElement.addContent(value);
} else if (mode.equals(Content.BASE64)) {
contentElement.addContent(Base64.encode(value));
} else if (mode.equals(Content.XML)) {
final StringBuffer tmpDocString = new StringBuffer("<tmpdoc>");
tmpDocString.append(value);
tmpDocString.append("</tmpdoc>");
final StringReader tmpDocReader = new StringReader(tmpDocString.toString());
Document tmpDoc;
try {
final SAXBuilder saxBuilder = new SAXBuilder();
tmpDoc = saxBuilder.build(tmpDocReader);
} catch (final Exception ex) {
throw new FeedException("Invalid XML", ex);
}
final List<org.jdom2.Content> children = tmpDoc.getRootElement().removeContent();
contentElement.addContent(children);
}
}
}
示例6: fillContentElement
import com.rometools.rome.feed.atom.Content; //导入方法依赖的package包/类
protected void fillContentElement(final Element contentElement, final Content content) throws FeedException {
final String type = content.getType();
String atomType = type;
if (type != null) {
// Fix for issue #39 "Atom 1.0 Text Types Not Set Correctly"
// we're not sure who set this value, so ensure Atom types are used
if ("text/plain".equals(type)) {
atomType = Content.TEXT;
} else if ("text/html".equals(type)) {
atomType = Content.HTML;
} else if ("application/xhtml+xml".equals(type)) {
atomType = Content.XHTML;
}
final Attribute typeAttribute = new Attribute("type", atomType);
contentElement.setAttribute(typeAttribute);
}
final String href = content.getSrc();
if (href != null) {
final Attribute srcAttribute = new Attribute("src", href);
contentElement.setAttribute(srcAttribute);
}
final String value = content.getValue();
if (value != null) {
if (atomType != null && (atomType.equals(Content.XHTML) || atomType.indexOf("/xml") != -1 || atomType.indexOf("+xml") != -1)) {
final StringBuffer tmpDocString = new StringBuffer("<tmpdoc>");
tmpDocString.append(value);
tmpDocString.append("</tmpdoc>");
final StringReader tmpDocReader = new StringReader(tmpDocString.toString());
Document tmpDoc;
try {
final SAXBuilder saxBuilder = new SAXBuilder();
tmpDoc = saxBuilder.build(tmpDocReader);
} catch (final Exception ex) {
throw new FeedException("Invalid XML", ex);
}
final List<org.jdom2.Content> children = tmpDoc.getRootElement().removeContent();
contentElement.addContent(children);
} else {
// must be type html, text or some other non-XML format
// JDOM will escape property for XML
contentElement.addContent(value);
}
}
}