@@ -628,39 +628,154 @@ public ObjectWriter withoutAttribute(Object key) {
628
628
/**********************************************************
629
629
*/
630
630
631
- public SequenceWriter createSequenceWriter (File out ) throws IOException {
631
+ /**
632
+ * Method for creating a {@link SequenceWriter} to write a sequence of root
633
+ * values using configuration of this {@link ObjectWriter}.
634
+ * Sequence is not surrounded by JSON array; some backend types may not
635
+ * support writing of such sequences as root level.
636
+ * Resulting writer needs to be {@link SequenceWriter#close()}d after all
637
+ * values have been written to ensure closing of underlying generator and
638
+ * output stream.
639
+ *
640
+ * @param out Target file to write value sequence to.
641
+ *
642
+ * @since 2.5
643
+ */
644
+ public SequenceWriter writeValues (File out ) throws IOException {
632
645
return _newSequenceWriter (false ,
633
646
_generatorFactory .createGenerator (out , JsonEncoding .UTF8 ), true );
634
647
}
635
648
636
- public SequenceWriter createSequenceWriter (JsonGenerator gen ) throws IOException {
649
+ /**
650
+ * Method for creating a {@link SequenceWriter} to write a sequence of root
651
+ * values using configuration of this {@link ObjectWriter}.
652
+ * Sequence is not surrounded by JSON array; some backend types may not
653
+ * support writing of such sequences as root level.
654
+ * Resulting writer needs to be {@link SequenceWriter#close()}d after all
655
+ * values have been written to ensure that all content gets flushed by
656
+ * the generator. However, since a {@link JsonGenerator} is explicitly passed,
657
+ * it will NOT be closed when {@link SequenceWriter#close()} is called.
658
+ *
659
+ * @param gen Low-level generator caller has already constructed that will
660
+ * be used for actual writing of token stream.
661
+ *
662
+ * @since 2.5
663
+ */
664
+ public SequenceWriter writeValues (JsonGenerator gen ) throws IOException {
637
665
return _newSequenceWriter (false , _configureGenerator (gen ), false );
638
666
}
639
667
640
- public SequenceWriter createSequenceWriter (Writer out ) throws IOException {
668
+ /**
669
+ * Method for creating a {@link SequenceWriter} to write a sequence of root
670
+ * values using configuration of this {@link ObjectWriter}.
671
+ * Sequence is not surrounded by JSON array; some backend types may not
672
+ * support writing of such sequences as root level.
673
+ * Resulting writer needs to be {@link SequenceWriter#close()}d after all
674
+ * values have been written to ensure closing of underlying generator and
675
+ * output stream.
676
+ *
677
+ * @param out Target writer to use for writing the token stream
678
+ *
679
+ * @since 2.5
680
+ */
681
+ public SequenceWriter writeValues (Writer out ) throws IOException {
641
682
return _newSequenceWriter (false ,
642
683
_generatorFactory .createGenerator (out ), true );
643
684
}
644
685
645
- public SequenceWriter createSequenceWriter (OutputStream out ) throws IOException {
686
+ /**
687
+ * Method for creating a {@link SequenceWriter} to write a sequence of root
688
+ * values using configuration of this {@link ObjectWriter}.
689
+ * Sequence is not surrounded by JSON array; some backend types may not
690
+ * support writing of such sequences as root level.
691
+ * Resulting writer needs to be {@link SequenceWriter#close()}d after all
692
+ * values have been written to ensure closing of underlying generator and
693
+ * output stream.
694
+ *
695
+ * @param out Physical output stream to use for writing the token stream
696
+ *
697
+ * @since 2.5
698
+ */
699
+ public SequenceWriter writeValues (OutputStream out ) throws IOException {
646
700
return _newSequenceWriter (false ,
647
701
_generatorFactory .createGenerator (out , JsonEncoding .UTF8 ), true );
648
702
}
649
-
650
- public SequenceWriter createArrayWriter (File out ) throws IOException {
703
+
704
+ /**
705
+ * Method for creating a {@link SequenceWriter} to write an array of
706
+ * root-level values, using configuration of this {@link ObjectWriter}.
707
+ * Resulting writer needs to be {@link SequenceWriter#close()}d after all
708
+ * values have been written to ensure closing of underlying generator and
709
+ * output stream.
710
+ *<p>
711
+ * Note that the type to use with {@link ObjectWriter#forType(Class)} needs to
712
+ * be type of individual values (elements) to write and NOT matching array
713
+ * or {@link java.util.Collection} type.
714
+ *
715
+ * @param out File to write token stream to
716
+ *
717
+ * @since 2.5
718
+ */
719
+ public SequenceWriter writeValuesAsArray (File out ) throws IOException {
651
720
return _newSequenceWriter (true ,
652
721
_generatorFactory .createGenerator (out , JsonEncoding .UTF8 ), true );
653
722
}
654
723
655
- public SequenceWriter createArrayWriter (JsonGenerator gen ) throws IOException {
724
+ /**
725
+ * Method for creating a {@link SequenceWriter} to write an array of
726
+ * root-level values, using configuration of this {@link ObjectWriter}.
727
+ * Resulting writer needs to be {@link SequenceWriter#close()}d after all
728
+ * values have been written to ensure that all content gets flushed by
729
+ * the generator. However, since a {@link JsonGenerator} is explicitly passed,
730
+ * it will NOT be closed when {@link SequenceWriter#close()} is called.
731
+ *<p>
732
+ * Note that the type to use with {@link ObjectWriter#forType(Class)} needs to
733
+ * be type of individual values (elements) to write and NOT matching array
734
+ * or {@link java.util.Collection} type.
735
+ *
736
+ * @param gen Underlying generator to use for writing the token stream
737
+ *
738
+ * @since 2.5
739
+ */
740
+ public SequenceWriter writeValuesAsArray (JsonGenerator gen ) throws IOException {
656
741
return _newSequenceWriter (true , gen , false );
657
742
}
658
743
659
- public SequenceWriter createArrayWriter (Writer out ) throws IOException {
744
+ /**
745
+ * Method for creating a {@link SequenceWriter} to write an array of
746
+ * root-level values, using configuration of this {@link ObjectWriter}.
747
+ * Resulting writer needs to be {@link SequenceWriter#close()}d after all
748
+ * values have been written to ensure closing of underlying generator and
749
+ * output stream.
750
+ *<p>
751
+ * Note that the type to use with {@link ObjectWriter#forType(Class)} needs to
752
+ * be type of individual values (elements) to write and NOT matching array
753
+ * or {@link java.util.Collection} type.
754
+ *
755
+ * @param out Writer to use for writing the token stream
756
+ *
757
+ * @since 2.5
758
+ */
759
+ public SequenceWriter writeValuesAsArray (Writer out ) throws IOException {
660
760
return _newSequenceWriter (true , _generatorFactory .createGenerator (out ), true );
661
761
}
662
762
663
- public SequenceWriter createArrayWriter (OutputStream out ) throws IOException {
763
+ /**
764
+ * Method for creating a {@link SequenceWriter} to write an array of
765
+ * root-level values, using configuration of this {@link ObjectWriter}.
766
+ * Resulting writer needs to be {@link SequenceWriter#close()}d after all
767
+ * values have been written to ensure closing of underlying generator and
768
+ * output stream.
769
+ *<p>
770
+ * Note that the type to use with {@link ObjectWriter#forType(Class)} needs to
771
+ * be type of individual values (elements) to write and NOT matching array
772
+ * or {@link java.util.Collection} type.
773
+ *
774
+ * @param out Physical output stream to use for writing the token stream
775
+ *
776
+ * @since 2.5
777
+ */
778
+ public SequenceWriter writeValuesAsArray (OutputStream out ) throws IOException {
664
779
return _newSequenceWriter (true ,
665
780
_generatorFactory .createGenerator (out , JsonEncoding .UTF8 ), true );
666
781
}
0 commit comments