(STWriter out, InstanceScope scope, Object o, String[] options)
| 715 | } |
| 716 | |
| 717 | protected int writeIterator(STWriter out, InstanceScope scope, Object o, String[] options) throws IOException { |
| 718 | if ( o==null ) return 0; |
| 719 | int n = 0; |
| 720 | Iterator<?> it = (Iterator<?>)o; |
| 721 | String separator = null; |
| 722 | if ( options!=null ) separator = options[Option.SEPARATOR.ordinal()]; |
| 723 | boolean seenAValue = false; |
| 724 | while ( it.hasNext() ) { |
| 725 | Object iterValue = it.next(); |
| 726 | // Emit separator if we're beyond first value |
| 727 | boolean needSeparator = seenAValue && separator!=null && // we have a separator and (iterValue!=null || // either we have a value options[Option.NULL.ordinal()] !=null); // or no value but null option |
| 728 | if ( needSeparator ) n += out.writeSeparator(separator); |
| 729 | int nw = writeObject(out, scope, iterValue, options); |
| 730 | if ( nw>0) seenAValue = true; |
| 731 | n += nw; |
| 732 | } |
| 733 | return n; |
| 734 | } |
| 735 | |
| 736 | protected int writePOJO(STWriter out, InstanceScope scope, Object o, String[] options) throws IOException { |
| 737 | String formatString = null; |
no test coverage detected