Package org.apache.abdera.parser

Examples of org.apache.abdera.parser.Parser


 
 
  protected Element _parse(String value, IRI baseUri) throws ParseException, IRISyntaxException {
    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.toString(), 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

    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

  }

  private void setContent() throws Exception {
    // For Abdera 0.1.0 this would be:
    // Parser parser = Factory.INSTANCE.newParser();
    Parser parser = Abdera.getNewParser();
    InputStream is = ParserTest.class.getResourceAsStream("/entry.xml");
    Document<Entry> doc = parser.parse(is);
    Entry entry = doc.getRoot();
    Content content = entry.getFactory().newContent(Content.Type.XML);
    content.setValue("<some><xml>document</xml></some>");
    content.setMimeType("application/xml");
    entry.setContentElement(content);
View Full Code Here

   
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    entry.writeTo(out);
   
    ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
    Parser parser = abdera.getParser();
    Document<Entry> doc = parser.parse(in);
    entry = doc.getRoot();
   
    group = entry.getExtension(GROUP);
    List<MediaContent> list = entry.getExtensions(CONTENT);
    for (MediaContent item : list) {
View Full Code Here

  }
 
  private Document<Element> getDocument(BufferingResponseWrapper wrapper) {
    Reader rdr = wrapper.getReader();
    InputStream in = wrapper.getInputStream();
    Parser parser = abdera.getParser();
    try {
      if (rdr != null) {
        return parser.parse(rdr);
      }
      if (in != null) {
        return parser.parse(in);
      }
    } catch (Exception e) {}
    return null;
  }
View Full Code Here

import java.io.InputStream;

public class OpenSearchTest extends TestCase {
  public void testBasics() throws Exception
  {
    Parser parser = Abdera.getNewParser();
   
    InputStream stream = OpenSearchTest.class.getResourceAsStream("/opensearch.xml");
    Document<Element> doc = parser.parse(stream);

    IntegerElement tr = doc.getRoot().getFirstChild(OpenSearchConstants.TOTAL_RESULTS_V10);
    assertNotNull(tr);
    assertEquals(tr.getValue(), 47);
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

  public synchronized <T extends Element>Document<T> getDocument()
    throws ParseException,
           IOException {
    if (document == null) {
      Abdera abdera = context.getAbdera();
      Parser parser = abdera.getParser();
      ParserOptions options = parser.getDefaultParserOptions();
      document = getDocument(parser, options);
    }
    return document;
  }
View Full Code Here

    ParserOptions options)
     throws ParseException,
            IOException  {
    if (document == null) {
      Abdera abdera = context.getAbdera();
      Parser parser = abdera.getParser();
      document = getDocument(parser, options);
    }
    return document;
  }
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.