@@ -448,19 +448,20 @@ public ToXmlGenerator createGenerator(OutputStream out) throws IOException {
448
448
public ToXmlGenerator createGenerator (OutputStream out , JsonEncoding enc ) throws IOException
449
449
{
450
450
// false -> we won't manage the stream unless explicitly directed to
451
- IOContext ctxt = _createContext (out , false );
451
+ final IOContext ctxt = _createContext (out , false );
452
452
ctxt .setEncoding (enc );
453
453
return new ToXmlGenerator (ctxt ,
454
454
_generatorFeatures , _xmlGeneratorFeatures ,
455
- _objectCodec , _createXmlWriter (out ));
455
+ _objectCodec , _createXmlWriter (ctxt , out ));
456
456
}
457
457
458
458
@ Override
459
459
public ToXmlGenerator createGenerator (Writer out ) throws IOException
460
460
{
461
- return new ToXmlGenerator (_createContext (out , false ),
461
+ final IOContext ctxt = _createContext (out , false );
462
+ return new ToXmlGenerator (ctxt ,
462
463
_generatorFeatures , _xmlGeneratorFeatures ,
463
- _objectCodec , _createXmlWriter (out ));
464
+ _objectCodec , _createXmlWriter (ctxt , out ));
464
465
}
465
466
466
467
@ SuppressWarnings ("resource" )
@@ -469,10 +470,10 @@ public ToXmlGenerator createGenerator(File f, JsonEncoding enc) throws IOExcepti
469
470
{
470
471
OutputStream out = new FileOutputStream (f );
471
472
// true -> yes, we have to manage the stream since we created it
472
- IOContext ctxt = _createContext (out , true );
473
+ final IOContext ctxt = _createContext (out , true );
473
474
ctxt .setEncoding (enc );
474
475
return new ToXmlGenerator (ctxt , _generatorFeatures , _xmlGeneratorFeatures ,
475
- _objectCodec , _createXmlWriter (out ));
476
+ _objectCodec , _createXmlWriter (ctxt , out ));
476
477
}
477
478
478
479
/*
@@ -580,7 +581,7 @@ protected FromXmlParser _createParser(char[] data, int offset, int len, IOContex
580
581
}
581
582
return xp ;
582
583
}
583
-
584
+
584
585
@ Override
585
586
protected FromXmlParser _createParser (byte [] data , int offset , int len , IOContext ctxt ) throws IOException
586
587
{
@@ -612,22 +613,22 @@ protected JsonGenerator _createGenerator(Writer out, IOContext ctxt) throws IOEx
612
613
/**********************************************************************
613
614
*/
614
615
615
- protected XMLStreamWriter _createXmlWriter (OutputStream out ) throws IOException
616
+ protected XMLStreamWriter _createXmlWriter (IOContext ctxt , OutputStream out ) throws IOException
616
617
{
617
618
XMLStreamWriter sw ;
618
619
try {
619
- sw = _xmlOutputFactory .createXMLStreamWriter (out , "UTF-8" );
620
+ sw = _xmlOutputFactory .createXMLStreamWriter (_decorate ( ctxt , out ) , "UTF-8" );
620
621
} catch (XMLStreamException e ) {
621
622
return StaxUtil .throwAsGenerationException (e , null );
622
623
}
623
624
return _initializeXmlWriter (sw );
624
625
}
625
626
626
- protected XMLStreamWriter _createXmlWriter (Writer w ) throws IOException
627
+ protected XMLStreamWriter _createXmlWriter (IOContext ctxt , Writer w ) throws IOException
627
628
{
628
629
XMLStreamWriter sw ;
629
630
try {
630
- sw = _xmlOutputFactory .createXMLStreamWriter (w );
631
+ sw = _xmlOutputFactory .createXMLStreamWriter (_decorate ( ctxt , w ) );
631
632
} catch (XMLStreamException e ) {
632
633
return StaxUtil .throwAsGenerationException (e , null );
633
634
}
@@ -820,4 +821,31 @@ private final static int skipSpace(InputAccessor acc, byte b) throws IOException
820
821
}
821
822
}
822
823
824
+ /*
825
+ /**********************************************************
826
+ /* Decorators, output
827
+ /**********************************************************
828
+ */
829
+
830
+ protected OutputStream _decorate (IOContext ioCtxt , OutputStream out ) throws IOException
831
+ {
832
+ if (_outputDecorator != null ) {
833
+ OutputStream out2 = _outputDecorator .decorate (ioCtxt , out );
834
+ if (out2 != null ) {
835
+ return out2 ;
836
+ }
837
+ }
838
+ return out ;
839
+ }
840
+
841
+ protected Writer _decorate (IOContext ioCtxt , Writer out ) throws IOException
842
+ {
843
+ if (_outputDecorator != null ) {
844
+ Writer out2 = _outputDecorator .decorate (ioCtxt , out );
845
+ if (out2 != null ) {
846
+ return out2 ;
847
+ }
848
+ }
849
+ return out ;
850
+ }
823
851
}
0 commit comments