本文整理了Java中org.apache.abdera.parser.Parser.parse()
方法的一些代码示例,展示了Parser.parse()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Parser.parse()
方法的具体详情如下:
包路径:org.apache.abdera.parser.Parser
类名称:Parser
方法名:parse
[英]Parse the input stream using the default character set encoding (UTF-8)
[中]使用默认字符集编码(UTF-8)解析输入流
代码示例来源: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.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-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: 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.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-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-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-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;
}
代码示例来源:origin: org.xcmis/xcmis-restatom
/**
* {@inheritDoc}
*/
public Element readFrom(Class<Element> clazz, Type type, Annotation[] anno, MediaType mediaType,
MultivaluedMap<String, String> headers, InputStream is) throws IOException, WebApplicationException
{
Parser parser = AbderaFactory.getInstance().getFactory().newParser();
Document<Element> doc = parser.parse(is);
return doc.getRoot();
}
代码示例来源:origin: apache/cxf
private Entry getEntry(String endpointAddress, String acceptType) throws Exception {
CloseableHttpClient client = HttpClientBuilder.create().build();
HttpGet get = new HttpGet(endpointAddress);
get.setHeader("Content-Type", "*/*");
if (acceptType != null) {
get.setHeader("Accept", acceptType);
}
try {
CloseableHttpResponse response = client.execute(get);
Document<Entry> doc = abdera.getParser().parse(copyIn(response.getEntity().getContent()));
return doc.getRoot();
} finally {
get.releaseConnection();
}
}
代码示例来源:origin: rackerlabs/atom-hopper
private Entry hydrateEntry(PersistedEntry persistedEntry, Abdera abderaReference) {
final Document<Entry> hydratedEntryDocument = abderaReference.getParser().parse(
new StringReader( persistedEntry.getEntryBody() ) );
Entry entry = null;
if (hydratedEntryDocument != null) {
entry = hydratedEntryDocument.getRoot();
entry.setUpdated(persistedEntry.getDateLastUpdated());
entry.setPublished(persistedEntry.getCreationDate());
}
return entry;
}
代码示例来源:origin: rackerlabs/atom-hopper
private Entry hydrateEntry(PersistedEntry persistedEntry, Abdera abderaReference) {
final Document<Entry> hydratedEntryDocument = abderaReference.getParser().parse(new StringReader(persistedEntry.getEntryBody()));
Entry entry = null;
if (hydratedEntryDocument != null) {
entry = hydratedEntryDocument.getRoot();
entry.setUpdated(persistedEntry.getDateLastUpdated());
entry.setPublished(persistedEntry.getCreationDate());
}
return entry;
}
代码示例来源:origin: rackerlabs/atom-hopper
private Entry hydrateEntry(PersistedEntry persistedEntry, Abdera abderaReference) {
final Document<Entry> hydratedEntryDocument = abderaReference.getParser().parse(
new StringReader(persistedEntry.getEntryBody()));
Entry entry = null;
if (hydratedEntryDocument != null) {
entry = hydratedEntryDocument.getRoot();
entry.setUpdated(persistedEntry.getDateLastUpdated());
entry.setPublished(persistedEntry.getCreationDate());
}
return entry;
}
代码示例来源: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: rackerlabs/atom-hopper
private Entry hydrateEntry(PersistedEntry persistedEntry, Abdera abderaReference) {
final Document<Entry> hydratedEntryDocument = abderaReference.getParser().parse(new StringReader(persistedEntry.getEntryBody()));
Entry entry = null;
if (hydratedEntryDocument != null) {
entry = hydratedEntryDocument.getRoot();
entry.setUpdated(persistedEntry.getDateLastUpdated());
entry.setPublished(persistedEntry.getCreationDate());
}
return entry;
}
代码示例来源: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: com.sun.jersey.contribs/jersey-atom-abdera
public Service readFrom(Class<Service> type, Type genericType,
Annotation[] annotations, MediaType mediaType,
MultivaluedMap<String, String> headers,
InputStream stream) throws IOException, WebApplicationException {
Parser parser = null;
if (mediaType.equals(MediaType.APPLICATION_JSON_TYPE) || mediaType.getSubtype().endsWith("+json")) {
parser = Abdera.getInstance().getParserFactory().getParser("json");
} else {
parser = Abdera.getInstance().getParser();
}
Document<Service> document = parser.parse(stream);
return document.getRoot();
}
代码示例来源:origin: com.sun.jersey.contribs/jersey-atom-abdera
public Entry readFrom(Class<Entry> type, Type genericType,
Annotation[] annotations, MediaType mediaType,
MultivaluedMap<String, String> headers,
InputStream stream) throws IOException, WebApplicationException {
Parser parser = null;
if (mediaType.equals(MediaType.APPLICATION_JSON_TYPE) || mediaType.getSubtype().endsWith("+json")) {
parser = Abdera.getInstance().getParserFactory().getParser("json");
} else {
parser = Abdera.getInstance().getParser();
}
Document<Entry> document = parser.parse(stream);
return document.getRoot();
}
代码示例来源:origin: com.sun.jersey.contribs/jersey-atom-abdera
public Feed readFrom(Class<Feed> type, Type genericType,
Annotation[] annotations, MediaType mediaType,
MultivaluedMap<String, String> headers,
InputStream stream) throws IOException, WebApplicationException {
Parser parser = null;
if (mediaType.equals(MediaType.APPLICATION_JSON_TYPE) || mediaType.getSubtype().endsWith("+json")) {
parser = Abdera.getInstance().getParserFactory().getParser("json");
} else {
parser = Abdera.getInstance().getParser();
}
Document<Feed> document = parser.parse(stream);
return document.getRoot();
}
代码示例来源:origin: org.fcrepo/fcrepo-server
public AtomAPIMMessage(String messageText) {
//Parser parser = abdera.getParser();
Document<Entry> entryDoc = abderaParser.parse(new StringReader(messageText));
entry = entryDoc.getRoot();
methodName = entry.getTitle();
date = entry.getUpdated();
author = entry.getAuthor().getName();
fedoraBaseUrl = entry.getAuthor().getUri().toString();
pid = entry.getSummary();
returnVal = entry.getContent();
serverVersion = getCategoryTerm(versionPredicate);
format = getCategoryTerm(formatPredicate);
}
内容来源于网络,如有侵权,请联系作者删除!