It would be great if a mark set on a org.bson.BsonReader could be unset. Right now only resetiing to the mark(ed) position is possible.
My use case(s):
I wrote a reflection based org.bson.codecs.Codec that uses the new MongoDB java driver. Within the mongo database any inserted entity holds a field with the type (or name or...) of the correct Java-Pojo this entity maps to. When reading entities from the mongo I first need to read that type-property, then I create the java-Pojo instance and then I reset the mark to re-read all remaining fields into the newly created Java-instance. I am aware of the fact that I could have used the DocumentCodec provided by the mongo driver for that purpose but this would imply double conversion hence double work hence less performance.
Now, in most cases the first field read IS actually the type and I do not reset the mark. In this case I would like to unset the mark.
While decoding any decoder may internally mark the reader itself in order to apply logic as described above. Unfortunately the BsonReader is not capable of setting more than one mark at a time.
My desired behaviour would be: Any mark set can be reset and unset. All marks could be put on a stack?!
The main issue here is, that I cannot be sure that I don’t know if the nested decoder uses mark itself.
- duplicates
-
JAVA-2416 BSONReader mark - add support to unset a mark (in contrast to resetting), and add support for multiple marks
- Closed