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

Method writeIterator

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

Source from the content-addressed store, hash-verified

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