本文整理匯總了Java中org.odata4j.format.Entry類的典型用法代碼示例。如果您正苦於以下問題:Java Entry類的具體用法?Java Entry怎麽用?Java Entry使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Entry類屬於org.odata4j.format包,在下文中一共展示了Entry類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: parse
import org.odata4j.format.Entry; //導入依賴的package包/類
/**
* Entryのパース.
* @param reader バース対象文字
* @return Entry
*/
@Override
public Entry parse(Reader reader) {
JsonStreamReader jsr = PersoniumJsonStreamReaderFactory.createJsonStreamReader(reader);
try {
ensureNext(jsr);
// skip the StartObject event
ensureStartObject(jsr.nextEvent());
// parse the entry
return parseEntry(getMetadata().getEdmEntitySet(getEntitySetName()), jsr);
// no interest in the closing events
} finally {
jsr.close();
}
}
示例2: getRequestEntity
import org.odata4j.format.Entry; //導入依賴的package包/類
protected OEntity getRequestEntity(HttpHeaders httpHeaders, UriInfo uriInfo, InputStream payload, EdmDataServices metadata, String entitySetName, OEntityKey entityKey) throws UnsupportedEncodingException {
// TODO validation of MaxDataServiceVersion against DataServiceVersion
// see spec [ms-odata] section 1.7
ODataVersion version = InternalUtil.getDataServiceVersion(httpHeaders.getRequestHeaders().getFirst(ODataConstants.Headers.DATA_SERVICE_VERSION));
FormatParser<Entry> parser = FormatParserFactory.getParser(Entry.class, httpHeaders.getMediaType(),
new Settings(version, metadata, entitySetName, entityKey, null, false));
String charset = httpHeaders.getMediaType().getParameters().get("charset");
if (charset == null) {
charset = ODataConstants.Charsets.Upper.ISO_8859_1; // from HTTP 1.1
}
Entry entry = parser.parse(new BufferedReader(
new InputStreamReader(payload, charset)));
return entry.getEntity();
}
示例3: createRequestEntry
import org.odata4j.format.Entry; //導入依賴的package包/類
public Entry createRequestEntry(EdmEntitySet entitySet, OEntityKey entityKey, List<OProperty<?>> props, List<OLink> links) {
final OEntity entity = entityKey == null
? OEntities.createRequest(entitySet, props, links)
: OEntities.create(entitySet, entityKey, props, links);
return new Entry() {
public String getUri() {
return null;
}
public OEntity getEntity() {
return entity;
}
};
}
示例4: getRequest
import org.odata4j.format.Entry; //導入依賴的package包/類
private ODataClientRequest getRequest() {
EdmEntitySet ees = metadata.getEdmEntitySet(entitySetName);
Entry entry = client.createRequestEntry(ees, null, props, links);
entity = entry.getEntity();
StringBuilder url = new StringBuilder(serviceRootUri);
if (parent != null) {
url.append(InternalUtil.getEntityRelId(parent))
.append("/")
.append(navProperty);
} else {
url.append(entitySetName);
}
ODataClientRequest request;
if (Boolean.TRUE.equals(ees.getType().getHasStream())) {
setMediaStream(entity);
request = new ODataClientRequest("POST", url.toString(), prepareSlugHeaders(ees), null, entity.getMediaLinkStream());
} else {
request = ODataClientRequest.post(url.toString(), entry);
}
return request;
}
示例5: parse
import org.odata4j.format.Entry; //導入依賴的package包/類
@Override
public Entry parse(Reader reader) {
JsonStreamReader jsr = JsonStreamReaderFactory.createJsonStreamReader(reader);
try {
ensureNext(jsr);
// skip the StartObject event
ensureStartObject(jsr.nextEvent());
if (isResponse) {
ensureNext(jsr);
}
// parse the entry
return parseEntry(metadata.getEdmEntitySet(entitySetName), jsr);
// no interest in the closing events
} finally {
jsr.close();
}
}
示例6: parseFunctionFeed
import org.odata4j.format.Entry; //導入依賴的package包/類
/**
* Function parsing will be handled in separate story.
*
* @param reader the reader
* @return the o collection<? extends o object>
*/
protected OCollection<? extends OObject> parseFunctionFeed(Reader reader) {
EdmEntitySet entitySet = this.metadata.getEdmEntitySet((EdmEntityType) returnType.getItemType());
Settings settings = new Settings(
// someone really needs to spend some time on service version negotiation....
ODataVersion.V3,
this.metadata,
entitySet.getName(),
this.entityKey,
null, // feed customization mapping
this.isResponse,
this.returnType.getItemType());
JsonLiteFeedFormatParser parser = new JsonLiteFeedFormatParser(settings);
JsonFeed feed = parser.parse(reader);
OCollection.Builder<OObject> c = newCollectionBuilder();
for (Entry e : feed.getEntries()) {
c.add(e.getEntity());
}
return c.build();
//return null;
}
示例7: parseFeed
import org.odata4j.format.Entry; //導入依賴的package包/類
protected JsonFeed parseFeed(EdmEntitySet ees, JsonStreamReader jsr) {
JsonFeed feed = new JsonFeed();
feed.entries = new ArrayList<Entry>();
while (jsr.hasNext()) {
JsonEvent event = jsr.nextEvent();
if (event.isStartObject()) {
JsonEntry entry = parseEntry(ees, jsr);
feed.entries.add(entry);
} else if (event.isEndArray()) {
break;
}
}
return feed;
}
示例8: parse
import org.odata4j.format.Entry; //導入依賴的package包/類
@Override
public Entry parse(Reader reader) {
JsonStreamReader jsr = JsonStreamReaderFactory.createJsonStreamReader(reader);
try {
ensureNext(jsr);
// skip the StartObject event
ensureStartObject(jsr.nextEvent());
if (isResponse) {
// "d" property
ensureNext(jsr);
ensureStartProperty(jsr.nextEvent(), DATA_PROPERTY);
// skip the StartObject event
ensureStartObject(jsr.nextEvent());
}
// parse the entry
return parseEntry(metadata.getEdmEntitySet(entitySetName), jsr);
// no interest in the closing events
} finally {
jsr.close();
}
}
示例9: parseFunctionFeed
import org.odata4j.format.Entry; //導入依賴的package包/類
protected OCollection<? extends OObject> parseFunctionFeed(Reader reader) {
// entitySetName is a function
// this really reveals a fundamental flaw in the parsers being driven by EdmEntitySets
// instead of EdmEntityTypes.
EdmEntitySet entitySet = this.metadata.getEdmEntitySet((EdmEntityType) returnType.getItemType());
Settings settings = new Settings(
// someone really needs to spend some time on service version negotiation....
ODataVersion.V2,
this.metadata,
entitySet.getName(),
this.entityKey,
null, // feed customization mapping
this.isResponse,
this.returnType.getItemType());
JsonFeedFormatParser parser = new JsonFeedFormatParser(settings);
JsonFeed feed = parser.parse(reader);
OCollection.Builder<OObject> c = newCollectionBuilder();
for (Entry e : feed.getEntries()) {
c.add(e.getEntity());
}
return c.build();
}
示例10: writeRequestEntry
import org.odata4j.format.Entry; //導入依賴的package包/類
public void writeRequestEntry(Writer w, Entry entry) {
DateTime utc = new DateTime().withZone(DateTimeZone.UTC);
String updated = InternalUtil.toString(utc);
XMLWriter2 writer = XMLFactoryProvider2.getInstance().newXMLWriterFactory2().createXMLWriter(w);
writer.startDocument();
writer.startElement(new QName2("entry"), atom);
writer.writeNamespace("d", d);
writer.writeNamespace("m", m);
OEntity entity = entry.getEntity();
writeEntry(writer, null, entity.getProperties(), entity.getLinks(),
null, updated, entity.getEntitySet(), false);
writer.endDocument();
}
示例11: parseFeed
import org.odata4j.format.Entry; //導入依賴的package包/類
AtomFeed parseFeed(XMLEventReader2 reader, EdmEntitySet entitySet) {
AtomFeed feed = new AtomFeed();
List<AtomEntry> rt = new ArrayList<AtomEntry>();
while (reader.hasNext()) {
XMLEvent2 event = reader.nextEvent();
if (isStartElement(event, ATOM_ENTRY)) {
rt.add(parseEntry(reader, event.asStartElement(), entitySet));
} else if (isStartElement(event, ATOM_LINK)) {
if ("next".equals(event.asStartElement().getAttributeByName(new QName2("rel")).getValue())) {
feed.next = event.asStartElement().getAttributeByName(new QName2("href")).getValue();
}
} else if (isEndElement(event, ATOM_FEED)) {
// return from a sub feed, if we went down the hierarchy
break;
}
}
feed.entries = Enumerable.create(rt).cast(Entry.class);
return feed;
}
示例12: buildPayload
import org.odata4j.format.Entry; //導入依賴的package包/類
private String buildPayload(String entitySet, final List<OProperty<?>> props, EdmDataServices edm) {
final EdmEntitySet ees = edm.getEdmEntitySet(entitySet);
Entry entry = new Entry() {
public String getUri() {
return null;
}
public OEntity getEntity() {
return OEntities.createRequest(ees, props, null);
}
};
StringWriter sw = new StringWriter();
FormatWriter<Entry> fw = FormatWriterFactory.getFormatWriter(Entry.class, null, "ATOM", null); //$NON-NLS-1$
fw.write(null, sw, entry);
return sw.toString();
}
示例13: convertFromString
import org.odata4j.format.Entry; //導入依賴的package包/類
protected static OEntity convertFromString(String requestEntity, MediaType type, ODataVersion version, EdmDataServices metadata, String entitySetName, OEntityKey entityKey, Boolean isResponse) throws NotAcceptableException {
//previously we are hard coding it to have false, since we always get the entity to be created as name, value pair.
//setting the isResponse to true only when we are building the OEntity from the response as it contain root element, metadata, data,etc
FormatParser<Entry> parser = FormatParserFactory.getParser(Entry.class, type,
new Settings(version, metadata, entitySetName, entityKey, null, isResponse));
Entry entry = parser.parse(new StringReader(requestEntity));
return entry.getEntity();
}
示例14: getRequest
import org.odata4j.format.Entry; //導入依賴的package包/類
private ODataClientRequest getRequest() {
List<OProperty<?>> requestProps = props;
if (updateRoot != null) {
OEntity updateRootEntity = (OEntity) updateRoot;
requestProps = Enumerable.create(updateRootEntity.getProperties()).toList();
for (final OProperty<?> prop : props) {
OProperty<?> requestProp = Enumerable.create(requestProps).firstOrNull(new Predicate1<OProperty<?>>() {
public boolean apply(OProperty<?> input) {
return input.getName().equals(prop.getName());
}
});
requestProps.remove(requestProp);
requestProps.add(prop);
}
}
OEntityKey entityKey = Enumerable.create(segments).last().key;
Entry entry = client.createRequestEntry(entitySet, entityKey, requestProps, links);
String path = Enumerable.create(segments).join("/");
ODataClientRequest request = updateRoot != null ?
ODataClientRequest.put(serviceRootUri + path, entry) :
ODataClientRequest.merge(serviceRootUri + path, entry);
// if this is update request (w/o stream) then send it as merge
if (Boolean.TRUE.equals(entitySet.getType().getHasStream())) {
request = ODataClientRequest.merge(serviceRootUri + path, entry);
}
if (ifMatch != null)
request.header(Headers.IF_MATCH, ifMatch);
return request;
}
示例15: getResult
import org.odata4j.format.Entry; //導入依賴的package包/類
private Enumerable<T> getResult(final Feed feed) {
Enumerable<Entry> entries = Enumerable.createFromIterator(new Func<Iterator<Entry>>() {
public Iterator<Entry> apply() {
return new EntryIterator(buildRequest(null), feed);
}
});
return entries.select(new Func1<Entry, T>() {
public T apply(Entry input) {
return InternalUtil.toEntity(entityType, input.getEntity());
}
}).cast(entityType);
}