Package org.apache.abdera.model

Examples of org.apache.abdera.model.Document


                MimeType type = new MimeType(request.getContentType());
                String charset = type.getParameter("charset");
                String uri = AppTest.INSTANCE.getBase() + "/collections/entries/" + target;
                ParserOptions options = getParser().getDefaultParserOptions();
                options.setCharset(charset);
                Document doc = getParser().parse(request.getInputStream(), uri, options);
                if (doc.getRoot() instanceof Entry) {
                  Entry newentry = (Entry) doc.getRoot().clone();
                  if (newentry.getId().equals(entry.getId())) {
                    newentry.setUpdated(new Date());
                    entry.discard();
                    feed.getRoot().insertEntry(newentry);
                    response.setStatus(HttpServletResponse.SC_NO_CONTENT);
View Full Code Here


   * Returns the appropriate media type for the given Abdera base
   */
  public static <T extends Base>String getMimeType(T base) {
    String type = null;
    if (base instanceof Document) {
      Document doc = (Document)base;
      MimeType mt = doc.getContentType();
      type = (mt != null) ? mt.toString() : getMimeType(doc.getRoot());
    } else if (base instanceof Element) {
      Element el = (Element)base;
      if (el.getDocument() != null) {
        MimeType mt = el.getDocument().getContentType();
        type = (mt != null) ? mt.toString() : null;
View Full Code Here

    assertEquals(generator.getText(), Version.APP_NAME);
    assertEquals(generator.getVersion(), Version.VERSION);
    assertEquals(generator.getUri().toString(), Version.URI);
    Div div = factory.newDiv();
    assertNotNull(div);
    Document doc = factory.newDocument();
    assertNotNull(doc);
    Element el = factory.newEmail();
    assertNotNull(el);
    el = factory.newEmail();
    el.setText("a");
View Full Code Here

 
  public void testSourceResult() throws Exception {
    try {
      // Apply an XSLT transform to the entire Feed
      TransformerFactory factory = TransformerFactory.newInstance();
      Document xslt = getParser().parse(FOMTest.class.getResourceAsStream("/test.xslt"));
      AbderaSource xsltSource = new AbderaSource(xslt);
      Transformer transformer = factory.newTransformer(xsltSource);
      Document<Feed> feed = getParser().parse(FOMTest.class.getResourceAsStream("/simple.xml"));
      AbderaSource feedSource = new AbderaSource(feed);
      ByteArrayOutputStream out = new ByteArrayOutputStream();
View Full Code Here

  public void testContentClone() throws Exception {
    String s = "<entry xmlns='http://www.w3.org/2005/Atom'><content type='html'>test</content></entry>";
    ByteArrayInputStream in = new ByteArrayInputStream(s.getBytes());
    Abdera abdera = new Abdera();
    Parser parser = abdera.getParser();
    Document doc = parser.parse(in);
    Entry entry = (Entry)(doc.getRoot().clone());
    assertEquals(entry.getContentType(), Content.Type.HTML);
  }
View Full Code Here

    Parser parser = fomfactory.newParser();
    ByteArrayInputStream bais = new ByteArrayInputStream(value.getBytes());
    ParserOptions options = parser.getDefaultParserOptions();
    options.setCharset(getXMLStreamReader().getCharacterEncodingScheme());
    options.setFactory(fomfactory);
    Document doc = parser.parse(bais, (baseUri != null) ? baseUri.toString() : null, options);
    return doc.getRoot();
  }
View Full Code Here

      log.debug(Localizer.get("RETURNING.DOCUMENT"));
      BaseResponseContext response = new BaseResponseContext(base);
      response.setStatus(status);
      if (lastModified != null) response.setLastModified(lastModified);
      response.setContentType(MimeTypeHelper.getMimeType(base));
      Document doc = base instanceof Document ? (Document)base : ((Element)base).getDocument();
      if (doc.getEntityTag() != null) {
        response.setEntityTag(doc.getEntityTag());
      } else if (doc.getLastModified() != null) {
        response.setLastModified(doc.getLastModified());
      }
      return response;
  }
View Full Code Here

    WritableByteChannel out,
    WriterOptions options)
      throws IOException {
    String charset = options.getCharset();
    if (charset == null) {
      Document doc = null;
      if (base instanceof Document)
        doc = (Document) base;
      else if (base instanceof Element) {
        doc = ((Element)base).getDocument();
      }
      charset = doc != null ? doc.getCharset() : null;
    }
    writeTo(
      base,
      Channels.newWriter(
        out, charset != null ?
View Full Code Here

   */
  @SuppressWarnings("unchecked")
  public static <T extends Base>String getMimeType(T base) {
    String type = null;
    if (base instanceof Document) {
      Document doc = (Document)base;     
      MimeType mt = doc.getContentType();
      type = (mt != null) ? mt.toString() : getMimeType(doc.getRoot());
    } else if (base instanceof Element) {
      Element el = (Element)base;
      if (el.getDocument() != null) {
        MimeType mt = el.getDocument().getContentType();
        type = (mt != null) ? mt.toString() : null;
View Full Code Here

    public void writeTo(Writer writer, java.io.Writer out, WriterOptions options) throws IOException {
        writer.writeTo(this, out, options);
    }

    public void writeTo(OutputStream out) throws IOException {
        Document doc = getDocument();
        String charset = doc != null ? doc.getCharset() : "UTF-8";
        Writer writer = this.getFactory().getAbdera().getWriter();
        writeTo(writer, new OutputStreamWriter(out, charset));
    }
View Full Code Here

TOP

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

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.