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

Method writeIterator

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

Source from the content-addressed store, hash-verified

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