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

Method writeIterator

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

Source from the content-addressed store, hash-verified

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