Package org.apache.abdera.parser

Examples of org.apache.abdera.parser.ParserOptions


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

    Parser parser)
      throws ParseException,
             IOException {
    log.debug(Messages.get("PARSING.REQUEST.DOCUMENT"));
    if (document == null) {
      ParserOptions options = parser.getDefaultParserOptions();
      document = getDocument(parser, options);
    }
    return document;
  }
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

    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

 
  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, URI baseUri) {
    if (value == null) return null;
    FOMFactory fomfactory = (FOMFactory) factory;
    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, options);
    return doc.getRoot();
  }
View Full Code Here

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

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

    ParserOptions opts = Parser.INSTANCE.getDefaultParserOptions();

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

    Document<Feed> doc;

    try {
      doc = Parser.INSTANCE.parse(input, "", opts);
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.