当前位置: 首页>>代码示例>>Java>>正文


Java Content.getType方法代码示例

本文整理汇总了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;

    }
 
开发者ID:rometools,项目名称:rome,代码行数:19,代码来源:Atom03Generator.java

示例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;

    }
 
开发者ID:rometools,项目名称:rome,代码行数:19,代码来源:Atom10Generator.java

示例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;
}
 
开发者ID:patexoid,项目名称:ZombieLib2,代码行数:16,代码来源:OpdsView.java

示例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);

            }

        }
    }
 
开发者ID:patexoid,项目名称:ZombieLib2,代码行数:56,代码来源:OPDSGenerator.java

示例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);
            }

        }
    }
 
开发者ID:rometools,项目名称:rome,代码行数:47,代码来源:Atom03Generator.java

示例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);

            }

        }
    }
 
开发者ID:rometools,项目名称:rome,代码行数:57,代码来源:Atom10Generator.java


注:本文中的com.rometools.rome.feed.atom.Content.getType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。