MCPcopy Index your code
hub / github.com/antlr/codebuff / writeIterator

Method writeIterator

output/java8/1.4.14/Interpreter.java:717–734  ·  view source on GitHub ↗
(STWriter out, InstanceScope scope, Object o, String[] options)

Source from the content-addressed store, hash-verified

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;

Callers 1

writeObjectMethod · 0.95

Calls 5

writeObjectMethod · 0.95
ordinalMethod · 0.65
nextMethod · 0.65
writeSeparatorMethod · 0.65
hasNextMethod · 0.45

Tested by

no test coverage detected