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

Method writeObject

output/java/1.4.17/Interpreter.java:714–747  ·  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

712 */
713
714 protected int writeObject(STWriter out, InstanceScope scope, Object o, String[] options) {
715 int n = 0;
716 if ( o==null ) {
717 if ( options !=null && options[Option.NULL.ordinal()]!=null ) {
718 o = options[Option.NULL.ordinal()];
719 }
720 else return 0;
721 }
722 if ( o instanceof ST) {
723 scope = new InstanceScope(scope, (ST)o);
724 if ( options !=null && options[Option.WRAP.ordinal()]!=null ) {
725 // if we have a wrap string, then inform writer it
726 // might need to wrap
727 try {
728 out.writeWrap(options[Option.WRAP.ordinal()]);
729 }
730 catch (IOException ioe) {
731 errMgr.IOError(scope.st, ErrorType.WRITE_IO_ERROR, ioe);
732 }
733 }
734 n = exec(out, scope);
735 }
736 else {
737 o = convertAnythingIteratableToIterator(scope, o); // normalize
738 try {
739 if ( o instanceof Iterator) n = writeIterator(out, scope, o, options);
740 else n = writePOJO(out, scope, o, options);
741 }
742 catch (IOException ioe) {
743 errMgr.IOError(scope.st, ErrorType.WRITE_IO_ERROR, ioe, o);
744 }
745 }
746 return n;
747 }
748
749 protected int writeIterator(STWriter out, InstanceScope scope, Object o, String[] options) throws IOException {
750 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