本文整理了Java中org.apache.abdera.parser.Parser
类的一些代码示例,展示了Parser
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Parser
类的具体详情如下:
包路径:org.apache.abdera.parser.Parser
类名称:Parser
暂无
代码示例来源:origin: org.apache.abdera/abdera-core
@SuppressWarnings("unchecked")
public <T extends Element> Document<T> getDocument() {
if (doc == null) {
if (pipein == null)
return null;
doc = abdera.getParser().parse(pipein);
}
return (Document<T>)doc;
}
代码示例来源:origin: org.apache.abdera/abdera-server
private <T extends Element> Document<T> getEntry(InputStream stream, RequestContext request) throws ParseException,
IOException {
Parser parser = request.getAbdera().getParser();
if (parser == null)
throw new IllegalArgumentException("No Parser implementation was provided");
Document<?> document =
parser.parse(stream, request.getResolvedUri().toString(), parser.getDefaultParserOptions());
return (Document<T>)document;
}
代码示例来源:origin: org.apache.abdera/abdera-client
/**
* Get the response payload as a parsed Abdera FOM Document using the specified parser
*
* @param parser The parser
*/
public <T extends Element> Document<T> getDocument(Parser parser) throws ParseException {
return getDocument(parser, parser.getDefaultParserOptions());
}
代码示例来源:origin: org.apache.abdera/abdera-server
@SuppressWarnings("unchecked")
public synchronized <T extends Element> Document<T> getDocument(Parser parser) throws ParseException, IOException {
log.debug(Localizer.get("PARSING.REQUEST.DOCUMENT"));
if (parser == null)
parser = getAbdera().getParser();
if (parser == null)
throw new IllegalArgumentException("No Parser implementation was provided");
if (document == null)
document = getDocument(parser, parser.getDefaultParserOptions());
return (Document<T>)document;
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.abdera
@SuppressWarnings("unchecked")
public <T extends Element>Document<T> getDocument() {
if (doc == null) {
if (pipein == null) return null;
doc = abdera.getParser().parse(pipein);
}
return doc;
}
代码示例来源:origin: org.apache.abdera/abdera-parser
protected Element _parse(String value, IRI baseUri) throws ParseException, UnsupportedEncodingException {
if (value == null)
return null;
FOMFactory fomfactory = (FOMFactory)factory;
Parser parser = fomfactory.newParser();
ParserOptions options = parser.getDefaultParserOptions();
options.setFactory(fomfactory);
Document doc = parser.parse(new StringReader(value), (baseUri != null) ? baseUri.toString() : null, options);
return doc.getRoot();
}
代码示例来源:origin: org.apache.abdera/abdera-filesystem
private Entry getEntry(File entryFile) {
if (!entryFile.exists() || !entryFile.isFile())
throw new RuntimeException();
try {
FileInputStream fis = new FileInputStream(entryFile);
Document<Entry> doc = abdera.getParser().parse(fis);
Entry entry = doc.getRoot();
return entry;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
代码示例来源:origin: org.apache.cxf/cxf-bundle-jaxrs
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();
}
代码示例来源:origin: net.sf.taverna.t2.activities/interaction-activity
private Entry getEntry(final File entryFile) {
if (!entryFile.exists() || !entryFile.isFile()) {
throw new RuntimeException();
}
try {
final FileInputStream fis = new FileInputStream(entryFile);
final Document<Entry> doc = this.abdera.getParser().parse(fis);
final Entry entry = doc.getRoot();
return entry;
} catch (final Exception e) {
throw new RuntimeException(e);
}
}
代码示例来源:origin: org.apache.cxf/cxf-rt-rs-extension-providers
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);
}
}
XMLStreamReader reader = StaxUtils.createXMLStreamReader(is);
Document<T> doc = parser.parse(reader);
return doc.getRoot();
}
代码示例来源:origin: org.apache.abdera/abdera-security
protected Document domToFom(org.w3c.dom.Document dom, SecurityOptions options) {
Document doc = null;
if (dom != null) {
try {
ByteArrayOutputStream out = new ByteArrayOutputStream();
TransformerFactory tf = TransformerFactory.newInstance();
Transformer t = tf.newTransformer();
t.transform(new DOMSource(dom), new StreamResult(out));
ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
doc = options.getParser().parse(in);
} catch (Exception e) {
}
}
return doc;
}
代码示例来源:origin: apache/cxf
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);
}
}
XMLStreamReader reader = StaxUtils.createXMLStreamReader(is);
Document<T> doc = parser.parse(reader);
return doc.getRoot();
}
代码示例来源:origin: org.apache.abdera/abdera-security
protected Element domToFom(org.w3c.dom.Element element, SecurityOptions options) {
Element el = null;
if (element != null) {
try {
ByteArrayOutputStream out = new ByteArrayOutputStream();
TransformerFactory tf = TransformerFactory.newInstance();
Transformer t = tf.newTransformer();
t.transform(new DOMSource(element), new StreamResult(out));
ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
el = options.getParser().parse(in).getRoot();
} catch (Exception e) {
}
}
return el;
}
}
代码示例来源:origin: org.apache.abdera/abdera-client
try {
if (options == null)
options = parser.getDefaultParserOptions();
String charset = getCharacterEncoding();
if (charset != null)
Document<T> doc = parser.parse(getReader(), base, options);
EntityTag etag = getEntityTag();
if (etag != null)
代码示例来源:origin: org.dataconservancy.dcs/dcs-ingest-client
private void parseEntry() {
if (entry == null) {
Document<Entry> doc =
abdera.getParser().parse(new ByteArrayInputStream(content));
entry = doc.getRoot();
}
}
}
代码示例来源:origin: org.apache.abdera/abdera-extensions-json
private void toJson(OutputStream aout, Writer writer) throws Exception {
Document<Element> doc = null;
try {
ByteArrayOutputStream out = new ByteArrayOutputStream();
if (writer == null)
super.writeTo(out);
else
super.writeTo(out, writer);
ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
doc = abdera.getParser().parse(in);
} catch (Exception e) {
}
if (doc != null) {
doc.writeTo("json", aout);
} else {
throw new RuntimeException("There was an error serializing the entry to JSON");
}
}
}
代码示例来源:origin: com.sun.jersey.contribs/jersey-atom-abdera
Document document = parser.parse(new ByteArrayInputStream(baos.toByteArray()));
entry.setContent(document.getRoot(), mediaType.toString());
代码示例来源:origin: org.apache.ws.commons.axiom/fom-testsuite
@Override
protected void runTest() throws Throwable {
Document<Entry> document = abdera.getParser().parse(
TestGetCategoriesByScheme.class.getResourceAsStream("entry-with-categories.xml"));
Entry entry = document.getRoot();
List<Category> categories = entry.getCategories("http://www.example.org/");
assertThat(categories).hasSize(2);
assertThat(categories.get(0).getTerm()).isEqualTo("term1");
assertThat(categories.get(1).getTerm()).isEqualTo("term2");
categories = entry.getCategories(null);
assertThat(categories).hasSize(1);
assertThat(categories.get(0).getTerm()).isEqualTo("other");
}
}
代码示例来源:origin: org.apache.abdera/abdera-security
private void sign(OutputStream aout, Writer writer) throws Exception {
Document<Element> doc = null;
try {
ByteArrayOutputStream out = new ByteArrayOutputStream();
if (writer == null)
super.writeTo(out);
else
super.writeTo(out, writer);
ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
doc = abdera.getParser().parse(in);
} catch (Exception e) {
}
if (doc != null) {
doc = signDocument(abdera, doc);
doc.writeTo(aout);
} else {
super.writeTo(aout);
}
}
}
代码示例来源:origin: org.apache.abdera/abdera-server
@SuppressWarnings("unchecked")
public synchronized <T extends Element> Document<T> getDocument(Parser parser, ParserOptions options)
throws ParseException, IOException {
log.debug(Localizer.get("PARSING.REQUEST.DOCUMENT"));
if (parser == null)
parser = getAbdera().getParser();
if (parser == null)
throw new IllegalArgumentException("No Parser implementation was provided");
if (document == null) {
document = parser.parse(getInputStream(), getResolvedUri().toString(), options);
}
return (Document<T>)document;
}
内容来源于网络,如有侵权,请联系作者删除!