private int _prependOrWrite ( char [ ] buffer , int ptr , char esc ) throws IOException , JsonGenerationException { if ( ptr > 0 ) { // fits, just prepend buffer [ -- ptr ] = esc ; } else { // won't fit, write _writer . write ( esc ) ; } return ptr ; }
Method called to try to either prepend character escape at front of given buffer ; or if not possible to write it out directly .