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

        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

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

    Document<Feed> doc = Parser.INSTANCE.parse(in, url.toURI(), options);
View Full Code Here

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

    Document<Feed> doc = Parser.INSTANCE.parse(in, url.toURI(), options);
View Full Code Here

        }
        return text;
      }
    };
   
    ParserOptions options = Parser.INSTANCE.getDefaultParserOptions();
    options.setTextFilter(filter);
   
    URL url = FOMTest.class.getResource("/simple.xml");
    InputStream in = url.openStream();
    Document<Feed> doc = Parser.INSTANCE.parse(in, url.toURI(), options);
    Feed feed = doc.getRoot();
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

      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

     */
    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 doc = parser.parse(new StringReader(s), null, options);
      doc.getRoot().toString();
    }
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.