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

Method writeIterator

output/java/1.4.15/Interpreter.java:748–766  ·  view source on GitHub ↗
(STWriter out, InstanceScope scope, Object o, String[] options)

Source from the content-addressed store, hash-verified

746 }
747
748 protected int writeIterator(STWriter out, InstanceScope scope, Object o, String[] options) throws IOException {
749 if ( o==null ) return 0;
750 int n = 0;
751 Iterator<?> it = (Iterator<?>)o;
752 String separator = null;
753 if ( options !=null ) separator = options[Option.SEPARATOR.ordinal()];
754 boolean seenAValue = false;
755 while ( it.hasNext() ) {
756 Object iterValue = it.next();
757 // Emit separator if we're beyond first value
758 boolean needSeparator = seenAValue&& separator !=null && // we have a separator and
759 (iterValue !=null || // either we have a value options[Option.NULL.ordinal()]!=null); // or no value but null option
760 if ( needSeparator ) n += out.writeSeparator(separator);
761 int nw = writeObject(out, scope, iterValue, options);
762 if ( nw>0) seenAValue = true;
763 n += nw;
764 }
765 return n;
766 }
767
768 protected int writePOJO(STWriter out, InstanceScope scope, Object o, String[] options) throws IOException {
769 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