Package org.apache.abdera.parser

Examples of org.apache.abdera.parser.ParserOptions


    @Test
    public void testXMLRestrictedChar() throws Exception {
        String s = "<?xml version='1.1'?><t t='\u007f' />";
        Abdera abdera = new Abdera();
        Parser parser = abdera.getParser();
        ParserOptions options = parser.getDefaultParserOptions();
        options.setFilterRestrictedCharacters(true);
        Document<Element> doc = parser.parse(new StringReader(s), null, options);
        doc.getRoot().toString();
    }
View Full Code Here


    @Test
    public void testXMLRestrictedChar2() throws Exception {
        String s = "<?xml version='1.0'?><t t='\u0002' />";
        Abdera abdera = new Abdera();
        Parser parser = abdera.getParser();
        ParserOptions options = parser.getDefaultParserOptions();
        options.setFilterRestrictedCharacters(true);
        options.setCharset("UTF-8");
        Document<Element> doc = parser.parse(new ByteArrayInputStream(s.getBytes("UTF-8")), null, options);
        doc.getRoot().toString();
    }
View Full Code Here

        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

  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

    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

    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

            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/" + feed.getRoot().getEntries().size();
              entry.setId(newID);
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

      entry.writeTo(cout);
      cout.close();
      byte[] bytes = out.toByteArray();
      ByteArrayInputStream in = new ByteArrayInputStream(bytes);
      Parser parser = abdera.getParser();
      ParserOptions options = parser.getDefaultParserOptions();
      options.setCompressionCodecs(CompressionCodec.GZIP);
      Document<Entry> doc = abdera.getParser().parse(in,null,options);
      entry = doc.getRoot();
    }
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.