Package org.apache.abdera.parser

Examples of org.apache.abdera.parser.ParserOptions


     
      byte[] bytes = out.toByteArray();
     
      ByteArrayInputStream in = new ByteArrayInputStream(bytes);
      Parser parser = abdera.getParser();
      ParserOptions options = parser.getDefaultParserOptions();
      options.setCompressionCodecs(CompressionCodec.DEFLATE);
      Document<Entry> doc = abdera.getParser().parse(in,null,options);
     
      doc.getRoot().toString();
    }
View Full Code Here


    ListParseFilter filter = new WhiteListParseFilter();
    filter.add(Constants.FEED);
    filter.add(Constants.ENTRY);
    filter.add(Constants.TITLE);
    filter.add(Constants.ID);
    ParserOptions options = getParser().getDefaultParserOptions();
    options.setParseFilter(filter);
   
    URL url = FOMTest.class.getResource("/simple.xml");
    InputStream in = url.openStream();

    Document<Feed> doc = getParser().parse(in, url.toString().replaceAll(" ", "%20"), options);
View Full Code Here

  @Test
  public void testBlackListParseFilter() throws Exception {
   
    ListParseFilter filter = new BlackListParseFilter();
    filter.add(Constants.UPDATED);
    ParserOptions options = getParser().getDefaultParserOptions();
    options.setParseFilter(filter);
   
    URL url = FOMTest.class.getResource("/simple.xml");
    InputStream in = url.openStream();

    Document<Feed> doc = getParser().parse(in, url.toString().replaceAll(" ", "%20"), options);
View Full Code Here

  protected Element _parse(String value, IRI baseUri) throws ParseException, UnsupportedEncodingException {
    if (value == null) return null;
    FOMFactory fomfactory = (FOMFactory) factory;
    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

        } catch (Exception e) {
            e.printStackTrace();
            return;
        }

        ParserOptions opts = parser.getDefaultParserOptions();

        ListParseFilter filter = new WhiteListParseFilter();
        filter.add(Constants.FEED);
        filter.add(Constants.ENTRY);
        filter.add(Constants.TITLE);
        opts.setParseFilter(filter);

        Document<Feed> doc;

        try {
            doc = parser.parse(input, "", opts);
View Full Code Here

    public T readFrom(Class<T> clazz, Type t, Annotation[] a, MediaType mt,
                         MultivaluedMap<String, String> headers, InputStream is)
        throws IOException {
        Parser parser = ATOM_ENGINE.getParser();
        synchronized (parser) {
            ParserOptions options = parser.getDefaultParserOptions();
            if (options != null) {
                options.setAutodetectCharset(autodetectCharset);
            }
        }
        Document<T> doc = parser.parse(is);
        return doc.getRoot();
    }
View Full Code Here

        return true;
      }
    };
    exceptionFilter.add(new QName("http://example.org", "a"));
   
    ParserOptions options = parser.getDefaultParserOptions();
    options.setParseFilter(exceptionFilter);
    Document<Feed> doc = parser.parse(
      UnacceptableElementsExample.class.getResourceAsStream("/xmlcontent.xml"),
      null, options);
   
    // this will throw a FOMException
View Full Code Here

    } catch (Exception e) {
      e.printStackTrace();
      return;
    }

    ParserOptions opts = parser.getDefaultParserOptions();

    ListParseFilter filter = new WhiteListParseFilter();
    filter.add(Constants.FEED);
    filter.add(Constants.ENTRY);
    filter.add(Constants.TITLE);
    opts.setParseFilter(filter);

    Document<Feed> doc;

    try {
      doc = parser.parse(input, "", opts);
View Full Code Here

                    try {
                        if (MimeTypeHelper.isMatch(request.getContentType(), "application/atom+xml;type=entry")) {
                            MimeType type = new MimeType(request.getContentType());
                            String charset = type.getParameter("charset");
                            String uri = AppTest.INSTANCE.getBase() + "/collections/entries";
                            ParserOptions options = getParser().getDefaultParserOptions();
                            options.setCharset(charset);
                            Document<?> doc = getParser().parse(request.getInputStream(), uri, options);
                            if (doc.getRoot() instanceof Entry) {
                                Entry entry = (Entry)doc.getRoot().clone();
                                String newID =
                                    AppTest.INSTANCE.getBase() + "/collections/entries/"
View Full Code Here

                        if (MimeTypeHelper.isMatch(request.getContentType(), "application/atom+xml;type=entry")) {
                            Entry entry = feed.getRoot().getEntries().get(target);
                            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());
View Full Code Here

TOP

Related Classes of org.apache.abdera.parser.ParserOptions

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.