@Override public E next() { if (hasNext()) { @SuppressWarnings("unchecked") final E res = (E) odataClient.getBinder().getODataEntity(cached); cached = null; return res; } throw new NoSuchElementException("No entity found"); }
@SuppressWarnings("unchecked") @Override public boolean hasNext() { if (available && cached == null) { if (contentType.isCompatible(ContentType.APPLICATION_ATOM_SVC) || contentType.isCompatible(ContentType.APPLICATION_ATOM_XML)) { cached = nextAtomEntityFromEntitySet(stream, osEntitySet, namespaces); } else { cached = nextJSONEntityFromEntitySet(stream, osEntitySet); } if (cached == null) { available = false; try { entitySet = (T) odataClient.getReader(). readEntitySet(new ByteArrayInputStream(osEntitySet.toByteArray()), contentType); } catch (final ODataDeserializerException e) { available = false; } close(); } } return available; }
namespaces = getAllElementAttributes(stream, "feed", osEntitySet); } else { namespaces = null; try { if (consume(stream, "\"value\":", osEntitySet, true) >= 0) { int c = 0; while (c != '[' && (c = stream.read()) >= 0) {
private String getAllElementAttributes(final InputStream input, final String name, final OutputStream os) { final ByteArrayOutputStream attrs = new ByteArrayOutputStream(); String res; try { byte[] attrsDeclaration = null; final String key = "<" + name + " "; if (consume(input, key, os, true) >= 0 && consume(input, ">", attrs, false) >= 0) { attrsDeclaration = attrs.toByteArray(); os.write(attrsDeclaration); os.write('>'); } res = attrsDeclaration == null ? "" : new String(attrsDeclaration, Constants.UTF8).trim(); } catch (Exception e) { LOG.error("Error retrieving entities from EntitySet", e); res = ""; } return res.endsWith("/") ? res.substring(0, res.length() - 1) : res; }
(URI) null, null, reference.cast(new ClientEntitySetIterator<ClientEntitySet, ClientEntity>( client, src, ContentType.parse(format)))); } else if (ClientEntitySet.class.isAssignableFrom(reference)) {
private String getAllElementAttributes(final InputStream input, final String name, final OutputStream os) { final ByteArrayOutputStream attrs = new ByteArrayOutputStream(); String res; try { byte[] attrsDeclaration = null; final String key = "<" + name + " "; if (consume(input, key, os, true) >= 0 && consume(input, ">", attrs, false) >= 0) { attrsDeclaration = attrs.toByteArray(); os.write(attrsDeclaration); os.write('>'); } res = attrsDeclaration == null ? "" : new String(attrsDeclaration, Constants.UTF8).trim(); } catch (Exception e) { LOG.error("Error retrieving entities from EntitySet", e); res = ""; } return res.endsWith("/") ? res.substring(0, res.length() - 1) : res; }
(URI) null, null, reference.cast(new ClientEntitySetIterator<ClientEntitySet, ClientEntity>( client, src, ContentType.parse(format)))); } else if (ClientEntitySet.class.isAssignableFrom(reference)) {
@Override public E next() { if (hasNext()) { @SuppressWarnings("unchecked") final E res = (E) odataClient.getBinder().getODataEntity(cached); cached = null; return res; } throw new NoSuchElementException("No entity found"); }
@SuppressWarnings("unchecked") @Override public boolean hasNext() { if (available && cached == null) { if (contentType.isCompatible(ContentType.APPLICATION_ATOM_SVC) || contentType.isCompatible(ContentType.APPLICATION_ATOM_XML)) { cached = nextAtomEntityFromEntitySet(stream, osEntitySet, namespaces); } else { cached = nextJSONEntityFromEntitySet(stream, osEntitySet); } if (cached == null) { available = false; try { entitySet = (T) odataClient.getReader(). readEntitySet(new ByteArrayInputStream(osEntitySet.toByteArray()), contentType); } catch (final ODataDeserializerException e) { available = false; } close(); } } return available; }
namespaces = getAllElementAttributes(stream, "feed", osEntitySet); } else { namespaces = null; try { if (consume(stream, "\"value\":", osEntitySet, true) >= 0) { int c = 0; while (c != '[' && (c = stream.read()) >= 0) {
private ResWrap<Entity> nextAtomEntityFromEntitySet( final InputStream input, final OutputStream osEntitySet, final String namespaces) { final ByteArrayOutputStream entity = new ByteArrayOutputStream(); ResWrap<Entity> atomEntity = null; try { if (consume(input, "<entry>", osEntitySet, false) >= 0) { entity.write("<entry ".getBytes(Constants.UTF8)); entity.write(namespaces.getBytes(Constants.UTF8)); entity.write(">".getBytes(Constants.UTF8)); if (consume(input, "</entry>", entity, true) >= 0) { atomEntity = odataClient.getDeserializer(ContentType.APPLICATION_ATOM_XML). toEntity(new ByteArrayInputStream(entity.toByteArray())); } } } catch (Exception e) { LOG.error("Error retrieving entities from EntitySet", e); } return atomEntity; }
private ResWrap<Entity> nextAtomEntityFromEntitySet( final InputStream input, final OutputStream osEntitySet, final String namespaces) { final ByteArrayOutputStream entity = new ByteArrayOutputStream(); ResWrap<Entity> atomEntity = null; try { if (consume(input, "<entry>", osEntitySet, false) >= 0) { entity.write("<entry ".getBytes(Constants.UTF8)); entity.write(namespaces.getBytes(Constants.UTF8)); entity.write(">".getBytes(Constants.UTF8)); if (consume(input, "</entry>", entity, true) >= 0) { atomEntity = odataClient.getDeserializer(ContentType.APPLICATION_ATOM_XML). toEntity(new ByteArrayInputStream(entity.toByteArray())); } } } catch (Exception e) { LOG.error("Error retrieving entities from EntitySet", e); } return atomEntity; }