MCPcopy Create free account
hub / github.com/antlr/codebuff / writeIterator

Method writeIterator

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

Source from the content-addressed store, hash-verified

721 }
722
723 protected int writeIterator(STWriter out, InstanceScope scope, Object o, String[] options) throws IOException {
724 if ( o==null ) return 0;
725 int n = 0;
726 Iterator<?> it = (Iterator<?>)o;
727 String separator = null;
728 if ( options!=null ) separator = options[Option.SEPARATOR.ordinal()];
729 boolean seenAValue = false;
730 while ( it.hasNext() ) {
731 Object iterValue = it.next();
732 // Emit separator if we're beyond first value
733 boolean needSeparator = seenAValue && separator!=null && // we have a separator and
734 (iterValue!=null || // either we have a value
735 options[Option.NULL.ordinal()] !=null); // or no value but null option
736 if ( needSeparator ) n += out.writeSeparator(separator);
737 int nw = writeObject(out, scope, iterValue, options);
738 if ( nw>0) seenAValue = true;
739 n += nw;
740 }
741 return n;
742 }
743
744 protected int writePOJO(STWriter out, InstanceScope scope, Object o, String[] options) throws IOException {
745 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