org.apache.abdera.parser.Parser类的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(8.5k)|赞(0)|评价(0)|浏览(146)

本文整理了Java中org.apache.abdera.parser.Parser类的一些代码示例,展示了Parser类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Parser类的具体详情如下:
包路径:org.apache.abdera.parser.Parser
类名称:Parser

Parser介绍

暂无

代码示例

代码示例来源:origin: org.apache.abdera/abdera-core

  1. @SuppressWarnings("unchecked")
  2. public <T extends Element> Document<T> getDocument() {
  3. if (doc == null) {
  4. if (pipein == null)
  5. return null;
  6. doc = abdera.getParser().parse(pipein);
  7. }
  8. return (Document<T>)doc;
  9. }

代码示例来源:origin: org.apache.abdera/abdera-server

  1. private <T extends Element> Document<T> getEntry(InputStream stream, RequestContext request) throws ParseException,
  2. IOException {
  3. Parser parser = request.getAbdera().getParser();
  4. if (parser == null)
  5. throw new IllegalArgumentException("No Parser implementation was provided");
  6. Document<?> document =
  7. parser.parse(stream, request.getResolvedUri().toString(), parser.getDefaultParserOptions());
  8. return (Document<T>)document;
  9. }

代码示例来源:origin: org.apache.abdera/abdera-client

  1. /**
  2. * Get the response payload as a parsed Abdera FOM Document using the specified parser
  3. *
  4. * @param parser The parser
  5. */
  6. public <T extends Element> Document<T> getDocument(Parser parser) throws ParseException {
  7. return getDocument(parser, parser.getDefaultParserOptions());
  8. }

代码示例来源:origin: org.apache.abdera/abdera-server

  1. @SuppressWarnings("unchecked")
  2. public synchronized <T extends Element> Document<T> getDocument(Parser parser) throws ParseException, IOException {
  3. log.debug(Localizer.get("PARSING.REQUEST.DOCUMENT"));
  4. if (parser == null)
  5. parser = getAbdera().getParser();
  6. if (parser == null)
  7. throw new IllegalArgumentException("No Parser implementation was provided");
  8. if (document == null)
  9. document = getDocument(parser, parser.getDefaultParserOptions());
  10. return (Document<T>)document;
  11. }

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.abdera

  1. @SuppressWarnings("unchecked")
  2. public <T extends Element>Document<T> getDocument() {
  3. if (doc == null) {
  4. if (pipein == null) return null;
  5. doc = abdera.getParser().parse(pipein);
  6. }
  7. return doc;
  8. }

代码示例来源:origin: org.apache.abdera/abdera-parser

  1. protected Element _parse(String value, IRI baseUri) throws ParseException, UnsupportedEncodingException {
  2. if (value == null)
  3. return null;
  4. FOMFactory fomfactory = (FOMFactory)factory;
  5. Parser parser = fomfactory.newParser();
  6. ParserOptions options = parser.getDefaultParserOptions();
  7. options.setFactory(fomfactory);
  8. Document doc = parser.parse(new StringReader(value), (baseUri != null) ? baseUri.toString() : null, options);
  9. return doc.getRoot();
  10. }

代码示例来源:origin: org.apache.abdera/abdera-filesystem

  1. private Entry getEntry(File entryFile) {
  2. if (!entryFile.exists() || !entryFile.isFile())
  3. throw new RuntimeException();
  4. try {
  5. FileInputStream fis = new FileInputStream(entryFile);
  6. Document<Entry> doc = abdera.getParser().parse(fis);
  7. Entry entry = doc.getRoot();
  8. return entry;
  9. } catch (Exception e) {
  10. throw new RuntimeException(e);
  11. }
  12. }

代码示例来源:origin: org.apache.cxf/cxf-bundle-jaxrs

  1. public T readFrom(Class<T> clazz, Type t, Annotation[] a, MediaType mt,
  2. MultivaluedMap<String, String> headers, InputStream is)
  3. throws IOException {
  4. Parser parser = ATOM_ENGINE.getParser();
  5. synchronized (parser) {
  6. ParserOptions options = parser.getDefaultParserOptions();
  7. if (options != null) {
  8. options.setAutodetectCharset(autodetectCharset);
  9. }
  10. }
  11. Document<T> doc = parser.parse(is);
  12. return doc.getRoot();
  13. }

代码示例来源:origin: net.sf.taverna.t2.activities/interaction-activity

  1. private Entry getEntry(final File entryFile) {
  2. if (!entryFile.exists() || !entryFile.isFile()) {
  3. throw new RuntimeException();
  4. }
  5. try {
  6. final FileInputStream fis = new FileInputStream(entryFile);
  7. final Document<Entry> doc = this.abdera.getParser().parse(fis);
  8. final Entry entry = doc.getRoot();
  9. return entry;
  10. } catch (final Exception e) {
  11. throw new RuntimeException(e);
  12. }
  13. }

代码示例来源:origin: org.apache.cxf/cxf-rt-rs-extension-providers

  1. public T readFrom(Class<T> clazz, Type t, Annotation[] a, MediaType mt,
  2. MultivaluedMap<String, String> headers, InputStream is)
  3. throws IOException {
  4. Parser parser = ATOM_ENGINE.getParser();
  5. synchronized (parser) {
  6. ParserOptions options = parser.getDefaultParserOptions();
  7. if (options != null) {
  8. options.setAutodetectCharset(autodetectCharset);
  9. }
  10. }
  11. XMLStreamReader reader = StaxUtils.createXMLStreamReader(is);
  12. Document<T> doc = parser.parse(reader);
  13. return doc.getRoot();
  14. }

代码示例来源:origin: org.apache.abdera/abdera-security

  1. protected Document domToFom(org.w3c.dom.Document dom, SecurityOptions options) {
  2. Document doc = null;
  3. if (dom != null) {
  4. try {
  5. ByteArrayOutputStream out = new ByteArrayOutputStream();
  6. TransformerFactory tf = TransformerFactory.newInstance();
  7. Transformer t = tf.newTransformer();
  8. t.transform(new DOMSource(dom), new StreamResult(out));
  9. ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
  10. doc = options.getParser().parse(in);
  11. } catch (Exception e) {
  12. }
  13. }
  14. return doc;
  15. }

代码示例来源:origin: apache/cxf

  1. public T readFrom(Class<T> clazz, Type t, Annotation[] a, MediaType mt,
  2. MultivaluedMap<String, String> headers, InputStream is)
  3. throws IOException {
  4. Parser parser = ATOM_ENGINE.getParser();
  5. synchronized (parser) {
  6. ParserOptions options = parser.getDefaultParserOptions();
  7. if (options != null) {
  8. options.setAutodetectCharset(autodetectCharset);
  9. }
  10. }
  11. XMLStreamReader reader = StaxUtils.createXMLStreamReader(is);
  12. Document<T> doc = parser.parse(reader);
  13. return doc.getRoot();
  14. }

代码示例来源:origin: org.apache.abdera/abdera-security

  1. protected Element domToFom(org.w3c.dom.Element element, SecurityOptions options) {
  2. Element el = null;
  3. if (element != null) {
  4. try {
  5. ByteArrayOutputStream out = new ByteArrayOutputStream();
  6. TransformerFactory tf = TransformerFactory.newInstance();
  7. Transformer t = tf.newTransformer();
  8. t.transform(new DOMSource(element), new StreamResult(out));
  9. ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
  10. el = options.getParser().parse(in).getRoot();
  11. } catch (Exception e) {
  12. }
  13. }
  14. return el;
  15. }
  16. }

代码示例来源:origin: org.apache.abdera/abdera-client

  1. try {
  2. if (options == null)
  3. options = parser.getDefaultParserOptions();
  4. String charset = getCharacterEncoding();
  5. if (charset != null)
  6. Document<T> doc = parser.parse(getReader(), base, options);
  7. EntityTag etag = getEntityTag();
  8. if (etag != null)

代码示例来源:origin: org.dataconservancy.dcs/dcs-ingest-client

  1. private void parseEntry() {
  2. if (entry == null) {
  3. Document<Entry> doc =
  4. abdera.getParser().parse(new ByteArrayInputStream(content));
  5. entry = doc.getRoot();
  6. }
  7. }
  8. }

代码示例来源:origin: org.apache.abdera/abdera-extensions-json

  1. private void toJson(OutputStream aout, Writer writer) throws Exception {
  2. Document<Element> doc = null;
  3. try {
  4. ByteArrayOutputStream out = new ByteArrayOutputStream();
  5. if (writer == null)
  6. super.writeTo(out);
  7. else
  8. super.writeTo(out, writer);
  9. ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
  10. doc = abdera.getParser().parse(in);
  11. } catch (Exception e) {
  12. }
  13. if (doc != null) {
  14. doc.writeTo("json", aout);
  15. } else {
  16. throw new RuntimeException("There was an error serializing the entry to JSON");
  17. }
  18. }
  19. }

代码示例来源:origin: com.sun.jersey.contribs/jersey-atom-abdera

  1. Document document = parser.parse(new ByteArrayInputStream(baos.toByteArray()));
  2. entry.setContent(document.getRoot(), mediaType.toString());

代码示例来源:origin: org.apache.ws.commons.axiom/fom-testsuite

  1. @Override
  2. protected void runTest() throws Throwable {
  3. Document<Entry> document = abdera.getParser().parse(
  4. TestGetCategoriesByScheme.class.getResourceAsStream("entry-with-categories.xml"));
  5. Entry entry = document.getRoot();
  6. List<Category> categories = entry.getCategories("http://www.example.org/");
  7. assertThat(categories).hasSize(2);
  8. assertThat(categories.get(0).getTerm()).isEqualTo("term1");
  9. assertThat(categories.get(1).getTerm()).isEqualTo("term2");
  10. categories = entry.getCategories(null);
  11. assertThat(categories).hasSize(1);
  12. assertThat(categories.get(0).getTerm()).isEqualTo("other");
  13. }
  14. }

代码示例来源:origin: org.apache.abdera/abdera-security

  1. private void sign(OutputStream aout, Writer writer) throws Exception {
  2. Document<Element> doc = null;
  3. try {
  4. ByteArrayOutputStream out = new ByteArrayOutputStream();
  5. if (writer == null)
  6. super.writeTo(out);
  7. else
  8. super.writeTo(out, writer);
  9. ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
  10. doc = abdera.getParser().parse(in);
  11. } catch (Exception e) {
  12. }
  13. if (doc != null) {
  14. doc = signDocument(abdera, doc);
  15. doc.writeTo(aout);
  16. } else {
  17. super.writeTo(aout);
  18. }
  19. }
  20. }

代码示例来源:origin: org.apache.abdera/abdera-server

  1. @SuppressWarnings("unchecked")
  2. public synchronized <T extends Element> Document<T> getDocument(Parser parser, ParserOptions options)
  3. throws ParseException, IOException {
  4. log.debug(Localizer.get("PARSING.REQUEST.DOCUMENT"));
  5. if (parser == null)
  6. parser = getAbdera().getParser();
  7. if (parser == null)
  8. throw new IllegalArgumentException("No Parser implementation was provided");
  9. if (document == null) {
  10. document = parser.parse(getInputStream(), getResolvedUri().toString(), options);
  11. }
  12. return (Document<T>)document;
  13. }

相关文章