Package org.apache.abdera.model

Examples of org.apache.abdera.model.Content

Per RFC4287:

 The "atom:content" element either contains or links to the content of the entry.  The content of atom:content is Language-Sensitive. atomInlineTextContent = element atom:content { atomCommonAttributes, attribute type { "text" | "html" }?, (text) } atomInlineXHTMLContent = element atom:content { atomCommonAttributes, attribute type { "xhtml" }, xhtmlDiv } atomInlineOtherContent = element atom:content { atomCommonAttributes, attribute type { atomMediaType }?, (text|anyElement) } atomOutOfLineContent = element atom:content { atomCommonAttributes, attribute type { atomMediaType }?, attribute src { atomUri }, empty } atomContent = atomInlineTextContent | atomInlineXHTMLContent | atomInlineOtherContent | atomOutOfLineContent 

   * Sets the content for this entry
   * @throws MimeTypeParseException
   */
  public Content setContent(String value, String mediatype) throws MimeTypeParseException {
    FOMFactory factory = (FOMFactory) this.factory;
    Content content = factory.newContent(new MimeType(mediatype));
    content.setValue(value);
    setContentElement(content);
    return content;
  }
View Full Code Here


   * @throws MimeTypeParseException
* @throws IRISyntaxException
   */
  public Content setContent(IRI uri, String mediatype) throws MimeTypeParseException, IRISyntaxException {
    FOMFactory factory = (FOMFactory) this.factory;
    Content content = factory.newContent(new MimeType(mediatype));
    content.setSrc(uri.toString());
    setContentElement(content);
    return content;
  }
View Full Code Here

    Link link = getSelfLink();
    return (link != null) ? link.getResolvedHref() : null;
  }
 
  public String getContent() {
    Content content = getContentElement();
    return (content != null) ? content.getValue() : null;
  }
View Full Code Here

    Content content = getContentElement();
    return (content != null) ? content.getValue() : null;
  }
 
  public IRI getContentSrc() throws IRISyntaxException {
    Content content = getContentElement();
    return (content != null) ? content.getResolvedSrc() : null;
  }
View Full Code Here

    Content content = getContentElement();
    return (content != null) ? content.getResolvedSrc() : null;
  }
 
  public Type getContentType() {
    Content content = getContentElement();
    return (content != null) ? content.getContentType() : null;
  }
View Full Code Here

    Text text = getTitleElement();
    return (text != null) ? text.getTextType() : null;
  }

  public MimeType getContentMimeType() {
    Content content = getContentElement();
    return (content != null) ? content.getMimeType() : null;
  }
View Full Code Here

 
  public Content newContent(
    Type type,
    Element parent) {
      if (type == null) type = Content.Type.TEXT;
      Content content =
        new FOMContent(type, (OMContainer)parent,this);
      try {
        if (type.equals(Content.Type.XML))
          content.setMimeType(XML_MEDIA_TYPE);
      } catch (MimeTypeParseException e) { /* Can't happen */ }
      return content;
  }
View Full Code Here

    MimeType mediaType,
    Element parent) {
    Content.Type type =
      (MimeTypeHelper.isXml(mediaType.toString())) ?
         Content.Type.XML : Content.Type.MEDIA;
    Content content = newContent(type, parent);
    try {
      content.setMimeType(mediaType.toString());
    } catch (MimeTypeParseException e) { /* Can't happen */ }
    return content;
  }
View Full Code Here

        setEntryContent(factory, e, content);
       
    }
   
    protected void setEntryContent(Factory factory, Entry e, String content) {
        Content ct = factory.newContent(Content.Type.XML);
        ct.setValue(content);
        e.setContentElement(ct);
    }
View Full Code Here

    IRI uri = new IRI("http://www.snellspace.com/public/contentsummary.xml");
    Document<Feed> doc = parse(uri);
    Feed feed = doc.getRoot();
    int n = 1;
    for (Entry entry : feed.getEntries()) {
      Content content = entry.getContentElement();
      Text summary = entry.getSummaryElement();
      switch (n) {
        case 1:
          // XML Content Type
          assertEquals(Content.Type.XML, content.getContentType());
          assertTrue(content.getMimeType().match("application/xml"));
          assertEquals(Text.Type.TEXT, summary.getTextType());
          break;
        case 2:
          // XML Content Type by src reference
          assertEquals(Content.Type.XML, content.getContentType());
          assertNotNull(content.getResolvedSrc());
          assertEquals(Text.Type.TEXT, summary.getTextType());
          break;
        case 3:
          // Text Content Type. This is really an order test,
          // to determine how a reader selects which text to show
          assertEquals(Content.Type.TEXT, content.getContentType());
          assertEquals(Text.Type.TEXT, summary.getTextType());
          break;
        case 4:
          // Text Content Type. This is really an order test,
          // to determine how a reader selects which text to show
          assertEquals(Content.Type.TEXT, content.getContentType());
          assertEquals(Text.Type.TEXT, summary.getTextType());
          break;
        case 5:
          // Embedded iCalendar
          assertEquals(Content.Type.MEDIA, content.getContentType());
          assertTrue(content.getMimeType().match("text/calendar"));
          assertEquals(Text.Type.TEXT, summary.getTextType());
          break;
        case 6:
          // Embedded Base64 encoded GIF
          assertEquals(Content.Type.MEDIA, content.getContentType());
          assertTrue(content.getMimeType().match("image/gif"));
          assertEquals(Text.Type.TEXT, summary.getTextType());
          break;
      }
      n++;
    }
View Full Code Here

TOP

Related Classes of org.apache.abdera.model.Content

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.