Package org.apache.abdera.parser

Examples of org.apache.abdera.parser.Parser


        connection.setRequestProperty("Accept", MediaType.APPLICATION_ATOM_XML);
        connection.connect();
        assertEquals (200, connection.getResponseCode());

        Abdera abdera = new Abdera();
        Parser parser = abdera.getParser();
        Document<Entry> document = parser.parse(connection.getInputStream());
        connection.disconnect();

        Entry e = document.getRoot();
        e.addAuthor("Tester X McTestness");
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

    el = factory.newName();
    assertNotNull(el);
    el = factory.newName();
    el.setText("a");
    assertEquals(el.getText(), "a");
    Parser parser = factory.newParser();
    assertNotNull(parser);
    Person person = factory.newPerson(Constants.AUTHOR, null);
    assertNotNull(person);
    assertEquals(person.getQName(), Constants.AUTHOR);
    person = factory.newPerson(Constants.AUTHOR, null);
View Full Code Here

  @Test
  public void testContentClone() throws Exception {
    String s = "<entry xmlns='http://www.w3.org/2005/Atom'><content type='html'>test</content></entry>";
    ByteArrayInputStream in = new ByteArrayInputStream(s.getBytes());
    Abdera abdera = new Abdera();
    Parser parser = abdera.getParser();
    Document<Entry> doc = parser.parse(in);
    Entry entry = (Entry)(doc.getRoot().clone());
    assertEquals(entry.getContentType(), Content.Type.HTML);
  }
View Full Code Here

      OutputStream cout = CompressionUtil.getEncodedOutputStream(out, CompressionCodec.GZIP);
      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

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

      out.close();
     
      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

public class Parse {

  public static void main(String[] args) throws Exception {
   
    Parser parser = Abdera.getNewParser();
   
    InputStream in = Parse.class.getResourceAsStream("/temp.xml");
    Document<Feed> doc = parser.parse(in);
    Feed feed = doc.getRoot();
   
    System.out.println(feed.getTitle());
    System.out.println(feed.getTitleType());
    System.out.println(feed.getAlternateLink().getResolvedHref());
View Full Code Here

    @Override
    public Object doTransform(Object src, String outputEncoding) throws TransformerException
    {
        try
        {
            Parser parser = Abdera.getInstance().getParser();
            Document<Element> doc;
            if (src instanceof InputStream)
            {
                doc = parser.parse((InputStream) src, outputEncoding);
            }
            else if (src instanceof byte[])
            {
                doc = parser.parse(new ByteArrayInputStream((byte[]) src), outputEncoding);
            }
            else
            {
                doc = parser.parse(new StringReader((String) src));
            }
           
            //we only need to check for the registered source types
            return doc.getRoot();
        }
View Full Code Here

TOP

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

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.