@Override public boolean hasNext() { return reader.hasNext(byteBuf); }
@Override public String getValue() { return getString(byteBuf); }
@Override BsonString readString(@Loose @ModifiesIndexes ByteBuf byteBuf) { return new NettyBsonString(getStringReader().readStringAsSlice(byteBuf)); }
@Override BsonValue<?> readDeprecated(@Loose @ModifiesIndexes ByteBuf byteBuf) { return new StringBsonDeprecated(getStringReader().readString(byteBuf, false)); }
@Override BsonRegex readRegex(@Loose @ModifiesIndexes ByteBuf byteBuf) throws NettyBsonReaderException { String pattern = getStringReader().readCString(byteBuf, false); String options = getStringReader().readCString(byteBuf, true); EnumSet<BsonRegex.Options> optionsSet = ParsingTools.parseRegexOptions(options); return new DefaultBsonRegex(optionsSet, pattern); }
@Override BsonBinary readBinary(@Loose @ModifiesIndexes ByteBuf byteBuf) { int length = byteBuf.readInt(); byte subtype = byteBuf.readByte(); ByteBuf content = byteBuf.readSlice(length); return new NettyBsonBsonBinary(subtype, ParsingTools.getBinarySubtype(subtype), content); } }
@Override public BsonDocument.Entry<?> next() { if (!hasNext()) { throw new NoSuchElementException(); } try { return reader.readDocumentEntry(byteBuf); } catch (NettyBsonReaderException ex) { throw new RuntimeException(ex); } }
@Override public BsonValue<?> next() { if (!hasNext()) { throw new NoSuchElementException(); } try { return reader.readArrayEntry(byteBuf); } catch (NettyBsonReaderException ex) { throw new RuntimeException(ex); } }
@Override public BsonDocument next() { try { if (!hasNext()) { throw new NoSuchElementException(); } return reader.readDocument(allocationType, buff); } catch (NettyBsonReaderException ex) { throw new NettyBsonReaderRuntimeException(ex); } }
@Override public Void visit(BsonString value, ByteBuf arg) { writeString(arg, value.getValue()); return null; }
@Override public UnmodifiableIterator<BsonValue<?>> iterator() { return new MyIterator(byteBuf.slice(), offHeapReader); }
private Object writeReplace() throws ObjectStreamException { return new StringBsonString(getValue()); } }
@Override public UnmodifiableIterator<Entry<?>> iterator() { return new MyIterator(byteBuf.slice(), offHeapReader); }
@Override public Void visit(BsonRegex value, ByteBuf arg) { writeCString(arg, value.getPattern()); writeCString(arg, value.getOptionsAsText()); return null; }
@Override BsonString readString(@Loose @ModifiesIndexes ByteBuf byteBuf) { return new StringBsonString(getStringReader().readString(byteBuf, false)); }
@Override public Void visit(BsonDeprecated value, ByteBuf arg) { writeString(arg, value.getValue()); return null; }
@Override public boolean hasNext() { return reader.hasNext(byteBuf); }
@Override BsonJavaScript readJavaScript(@Loose @ModifiesIndexes ByteBuf byteBuf) { return new DefaultBsonJavaScript(getStringReader().readString(byteBuf, false)); }
@Override public Void visit(BsonJavaScript value, ByteBuf arg) { writeString(arg, value.getValue()); return null; }
@Override BsonJavaScriptWithScope readJavaScriptWithScope(@Loose @ModifiesIndexes ByteBuf byteBuf) throws NettyBsonReaderException { byteBuf.readInt(); String js = getStringReader().readString(byteBuf, false); BsonDocument scope = readJavaScriptScope(byteBuf); return new DefaultBsonJavaScriptWithCode(js, scope); }