Package org.apache.abdera.model

Examples of org.apache.abdera.model.Document


            return null;
        FOMFactory fomfactory = (FOMFactory)factory;
        Parser parser = fomfactory.newParser();
        ParserOptions options = parser.getDefaultParserOptions();
        options.setFactory(fomfactory);
        Document doc = parser.parse(new StringReader(value), (baseUri != null) ? baseUri.toString() : null, options);
        return doc.getRoot();
    }
View Full Code Here


        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

   */
  @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

     * @param base An Abdera FOM Document or Element object providing the payload of the request
     * @param options The request options
     */
    public ClientResponse post(String uri, Base base, RequestOptions options) {
        if (base instanceof Document) {
            Document d = (Document)base;
            if (options.getSlug() == null && d.getSlug() != null)
                options.setSlug(d.getSlug());
        }
        return execute("POST", uri, new BaseRequestEntity(base, options.isUseChunked()), options);
    }
View Full Code Here

     */
    public ClientResponse put(String uri, Base base, RequestOptions options) {
        if (options == null)
            options = getDefaultRequestOptions();
        if (base instanceof Document) {
            Document d = (Document)base;
            if (options.getSlug() == null && d.getSlug() != null)
                options.setSlug(d.getSlug());

            if (options.isConditionalPut()) {
                if (d.getEntityTag() != null)
                    options.setIfMatch(d.getEntityTag());
                else if (d.getLastModified() != null)
                    options.setIfUnmodifiedSince(d.getLastModified());
            }
        }
        return execute("PUT", uri, new BaseRequestEntity(base, options.isUseChunked()), options);
    }
View Full Code Here

     
      // Apply an XSLT transform to the entire Feed
      TransformerFactory factory = TransformerFactory.newInstance();
     
      // Abdera is capable of parsing any well-formed XML document, even XSLT
      Document xslt = parser.parse(XsltExample.class.getResourceAsStream("/test.xslt"));
      AbderaSource xsltSource = new AbderaSource(xslt);
      Transformer transformer = factory.newTransformer(xsltSource);
     
      // Now let's get the feed we're going to transform
      Document<Feed> feed = parser.parse(XsltExample.class.getResourceAsStream("/simple.xml"));
View Full Code Here

      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

    Parser parser = fomfactory.newParser();
    ByteArrayInputStream bais = new ByteArrayInputStream(value.getBytes(getXMLStreamReader().getCharacterEncodingScheme()));
    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

    String charset = options.getCharset();
    if (charset == null) {
      if (base instanceof Document)
        charset = ((Document)base).getCharset();
      else if (base instanceof Element) {
        Document doc = ((Element)base).getDocument();
        if (doc != null) charset = doc.getCharset();
      }
      if (charset == null) charset = "UTF-8";
    } else {
      Document doc = null;
      if (base instanceof Document)
        doc = (Document)base;
      else if (base instanceof Element)
        doc = ((Element)base).getDocument();
      if (doc != null) doc.setCharset(charset);
    }
    base.writeTo(new OutputStreamWriter(out,charset))
    finishCompressedOutputStream(out, options);
    if (options.getAutoClose()) out.close();
  }
View Full Code Here

  public ClientResponse post(
    String uri,
    Base base,
    RequestOptions options) {
      if (base instanceof Document) {
        Document d = (Document) base;
        if (options.getSlug() == null &&
            d.getSlug() != null)
          options.setSlug(d.getSlug());
      }
      return execute("POST", uri, new BaseRequestEntity(base, options.isUseChunked()), options);
  }
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.