MCPcopy Index your code
hub / github.com/antlr/codebuff / writeObject

Method writeObject

output/java8/1.4.15/Interpreter.java:686–719  ·  view source on GitHub ↗

Generic method to emit text for an object. It differentiates between templates, iterable objects, and plain old Java objects (POJOs)

(STWriter out, InstanceScope scope, Object o, String[] options)

Source from the content-addressed store, hash-verified

684 */
685
686 protected int writeObject(STWriter out, InstanceScope scope, Object o, String[] options) {
687 int n = 0;
688 if ( o==null ) {
689 if ( options!=null && options[Option.NULL.ordinal()] !=null ) {
690 o = options[Option.NULL.ordinal()];
691 }
692 else return 0;
693 }
694 if ( o instanceof ST ) {
695 scope = new InstanceScope(scope, (ST)o);
696 if ( options!=null && options[Option.WRAP.ordinal()] !=null ) {
697 // if we have a wrap string, then inform writer it
698 // might need to wrap
699 try {
700 out.writeWrap(options[Option.WRAP.ordinal()]);
701 }
702 catch (IOException ioe) {
703 errMgr.IOError(scope.st, ErrorType.WRITE_IO_ERROR, ioe);
704 }
705 }
706 n = exec(out, scope);
707 }
708 else {
709 o = convertAnythingIteratableToIterator(scope, o); // normalize
710 try {
711 if ( o instanceof Iterator ) n = writeIterator(out, scope, o, options);
712 else n = writePOJO(out, scope, o, options);
713 }
714 catch (IOException ioe) {
715 errMgr.IOError(scope.st, ErrorType.WRITE_IO_ERROR, ioe, o);
716 }
717 }
718 return n;
719 }
720
721 protected int writeIterator(STWriter out, InstanceScope scope, Object o, String[] options) throws IOException {
722 if ( o==null ) return 0;

Callers 3

writeObjectNoOptionsMethod · 0.95
writeIteratorMethod · 0.95

Calls 7

execMethod · 0.95
writeIteratorMethod · 0.95
writePOJOMethod · 0.95
ordinalMethod · 0.65
writeWrapMethod · 0.65
IOErrorMethod · 0.65

Tested by

no test coverage detected